Add some search API stub implementations

This commit is contained in:
mar-v-in 2015-06-23 19:22:19 +02:00
parent 7e5bf58bc3
commit 7099a3230e
8 changed files with 164 additions and 19 deletions

2
extern/GmsApi vendored

@ -1 +1 @@
Subproject commit d3c11f1e82949e364c3c36cdb9e2e5071cf42ab4
Subproject commit ef5e6dc0668a8ca152aa38a78f0e91d65120d3b6

View File

@ -16,17 +16,19 @@
package org.microg.gms;
import android.os.RemoteException;
import com.google.android.gms.common.api.CommonStatusCodes;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
public class DummyService extends BaseService {
public DummyService() {
super("GmsDummySvc", AbstractGmsServiceBroker.ID_ACCEPT_ALL);
}
@Override
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) {
// Dummy
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
callback.onPostInitComplete(CommonStatusCodes.ERROR, null, null);
}
}

View File

@ -30,6 +30,8 @@ import com.google.android.gms.auth.AccountChangeEventsResponse;
import org.microg.gms.common.PackageUtils;
import java.io.IOException;
import static android.accounts.AccountManager.KEY_ACCOUNT_NAME;
import static android.accounts.AccountManager.KEY_ACCOUNT_TYPE;
import static android.accounts.AccountManager.KEY_AUTHTOKEN;
@ -95,9 +97,11 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
result.putParcelable(KEY_USER_RECOVERY_INTENT, i);
return result;
}
} catch (Exception e) {
} catch (IOException e) {
Log.w(TAG, e);
throw new RuntimeException(e);
Bundle result = new Bundle();
result.putString(KEY_ERROR, "NetworkError");
return result;
}
}

View File

@ -20,10 +20,10 @@ import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.search.corpora.internal.ISearchCorporaService;
import com.google.android.gms.search.global.internal.IGlobalSearchAdminService;
public class CorporaSearchImpl extends ISearchCorporaService.Stub {
private static final String TAG = "GmsIcingCorporaImpl";
public class GlobalSearchAdminImpl extends IGlobalSearchAdminService.Stub {
private static final String TAG = "GmsIcingGlobalImpl";
@Override
public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {

View File

@ -18,6 +18,7 @@ package org.microg.gms.icing;
import android.os.RemoteException;
import com.google.android.gms.common.api.CommonStatusCodes;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
@ -26,7 +27,9 @@ import org.microg.gms.common.Services;
public class IndexService extends BaseService {
private AppDataSearchImpl appDataSearch = new AppDataSearchImpl();
private CorporaSearchImpl corporaSearch = new CorporaSearchImpl();
private GlobalSearchAdminImpl globalSearchAdmin = new GlobalSearchAdminImpl();
private SearchCorporaImpl searchCorpora = new SearchCorporaImpl();
private SearchQueriesImpl searchQueries = new SearchQueriesImpl();
public IndexService() {
super("GmsIcingIndexSvc",
@ -42,15 +45,19 @@ public class IndexService extends BaseService {
callback.onPostInitComplete(0, appDataSearch.asBinder(), null);
break;
case Services.SEARCH_ADMINISTRATION.SERVICE_ID:
break;
case Services.SEARCH_CORPORA.SERVICE_ID:
callback.onPostInitComplete(0, corporaSearch.asBinder(), null);
break;
case Services.SEARCH_GLOBAL.SERVICE_ID:
break;
case Services.SEARCH_IME.SERVICE_ID:
callback.onPostInitComplete(CommonStatusCodes.ERROR, null, null);
break;
case Services.SEARCH_QUERIES.SERVICE_ID:
callback.onPostInitComplete(0, searchQueries.asBinder(), null);
break;
case Services.SEARCH_GLOBAL.SERVICE_ID:
callback.onPostInitComplete(0, globalSearchAdmin.asBinder(), null);
break;
case Services.SEARCH_CORPORA.SERVICE_ID:
callback.onPostInitComplete(0, searchCorpora.asBinder(), null);
break;
case Services.SEARCH_IME.SERVICE_ID:
callback.onPostInitComplete(CommonStatusCodes.ERROR, null, null);
break;
}
}

View File

@ -0,0 +1,79 @@
/*
* Copyright 2013-2015 µg Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.microg.gms.icing;
import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.appdatasearch.CorpusStatus;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.search.corpora.ClearCorpusRequest;
import com.google.android.gms.search.corpora.GetCorpusInfoRequest;
import com.google.android.gms.search.corpora.GetCorpusStatusRequest;
import com.google.android.gms.search.corpora.GetCorpusStatusResponse;
import com.google.android.gms.search.corpora.RequestIndexingRequest;
import com.google.android.gms.search.corpora.RequestIndexingResponse;
import com.google.android.gms.search.corpora.internal.ISearchCorporaCallbacks;
import com.google.android.gms.search.corpora.internal.ISearchCorporaService;
import java.util.HashMap;
import java.util.Map;
public class SearchCorporaImpl extends ISearchCorporaService.Stub {
private static final String TAG = "GmsIcingCorporaImpl";
// We count the sequence number here to make clients happy.
private Map<String, Long> corpusSequenceNumbers = new HashMap<String, Long>();
@Override
public void requestIndexing(RequestIndexingRequest request, ISearchCorporaCallbacks callbacks) throws RemoteException {
Log.d(TAG, "requestIndexing: " + request);
corpusSequenceNumbers.put(request.packageName + "/" + request.corpus, request.sequenceNumber);
callbacks.onRequestIndexing(new RequestIndexingResponse(Status.SUCCESS, true));
}
@Override
public void clearCorpus(ClearCorpusRequest request, ISearchCorporaCallbacks callbacks) throws RemoteException {
Log.d(TAG, "clearCorpus");
}
@Override
public void getCorpusStatus(GetCorpusStatusRequest request, ISearchCorporaCallbacks callbacks) throws RemoteException {
Log.d(TAG, "getCorpusStatus: " + request);
CorpusStatus status = new CorpusStatus();
String numIndex = request.packageName + "/" + request.corpus;
if (corpusSequenceNumbers.containsKey(numIndex)) {
status.found = true;
status.lastIndexedSeqno = corpusSequenceNumbers.get(numIndex);
status.lastCommittedSeqno = status.lastIndexedSeqno;
}
callbacks.onGetCorpusStatus(new GetCorpusStatusResponse(Status.SUCCESS, status));
}
@Override
public void getCorpusInfo(GetCorpusInfoRequest request, ISearchCorporaCallbacks callbacks) throws RemoteException {
Log.d(TAG, "getCorpusInfo");
}
@Override
public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
if (super.onTransact(code, data, reply, flags)) return true;
Log.d(TAG, "onTransact [unknown]: " + code + ", " + data + ", " + flags);
return false;
}
}

View File

@ -0,0 +1,44 @@
/*
* Copyright 2013-2015 µg Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.microg.gms.icing;
import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.search.queries.QueryRequest;
import com.google.android.gms.search.queries.QueryResponse;
import com.google.android.gms.search.queries.internal.ISearchQueriesCallbacks;
import com.google.android.gms.search.queries.internal.ISearchQueriesService;
public class SearchQueriesImpl extends ISearchQueriesService.Stub {
private static final String TAG = "GmsIcingQueriesImpl";
@Override
public void query(QueryRequest request, ISearchQueriesCallbacks callbacks) throws RemoteException {
Log.d(TAG, "query: " + request);
callbacks.onQuery(new QueryResponse(Status.CANCELED, null));
}
@Override
public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
if (super.onTransact(code, data, reply, flags)) return true;
Log.d(TAG, "onTransact [unknown]: " + code + ", " + data + ", " + flags);
return false;
}
}

View File

@ -24,12 +24,21 @@ import com.google.android.gms.playlog.internal.IPlayLogService;
import com.google.android.gms.playlog.internal.LogEvent;
import com.google.android.gms.playlog.internal.PlayLoggerContext;
import java.util.List;
public class PlayLogServiceImpl extends IPlayLogService.Stub {
private static final String TAG = "GmsPlayLogSvcImpl";
@Override
public void event(String packageName, PlayLoggerContext context, LogEvent event) throws RemoteException {
Log.d(TAG, packageName + " event:" + event + " context:" + context);
public void onEvent(String packageName, PlayLoggerContext context, LogEvent event) throws RemoteException {
Log.d(TAG, "onEvent: context[packageName]:" + context.packageName + " event[tag]:" + event.tag);
}
@Override
public void onMultiEvent(String packageName, PlayLoggerContext context, List<LogEvent> events) throws RemoteException {
for (LogEvent event : events) {
onEvent(packageName, context, event);
}
}
@Override