Use common BaseService, update AuthService

This commit is contained in:
mar-v-in 2015-06-22 23:26:35 +02:00
parent 6cb0ce2ac1
commit 2f78c63eb6
17 changed files with 237 additions and 192 deletions

2
extern/GmsApi vendored

@ -1 +1 @@
Subproject commit 6743f1d4b1a3cf0202b9d62f2ebc5dfb385b5576
Subproject commit 37e3b4dc398cb349e9637471d6df09db9c8910c8

View File

@ -15,8 +15,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.gms"
android:versionCode="7099448"
android:versionName="1.0">
android:versionCode="7574001"
android:versionName="7.5.74 (µg v0.01)">
<uses-sdk
android:minSdkVersion="10"
@ -344,6 +344,23 @@
</intent-filter>
</activity>
<service
android:name="org.microg.gms.ads.GService"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.ads.gservice.START" />
</intent-filter>
</service>
<service
android:name="org.microg.gms.feedback.FeedbackService"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.feedback.internal.IFeedbackService" />
</intent-filter>
</service>
<service
android:name="org.microg.gms.DummyService"
android:exported="true">
@ -359,7 +376,6 @@
<action android:name="com.google.android.gms.cast.service.BIND_CAST_DEVICE_CONTROLLER_SERVICE" />
<action android:name="com.google.android.gms.drive.ApiService.START" />
<action android:name="com.google.android.gms.identity.service.BIND" />
<action android:name="com.google.android.gms.car.service.START" />
<action android:name="com.google.android.gms.wearable.BIND" />
<action android:name="com.google.android.gms.auth.service.START" />
<action android:name="com.google.android.gms.fitness.GoogleFitnessService.START" />
@ -368,7 +384,6 @@
<action android:name="com.google.android.gms.droidguard.service.START" />
<action android:name="com.google.android.gms.lockbox.service.START" />
<action android:name="com.google.android.gms.cast_mirroring.service.START" />
<action android:name="com.google.android.gms.feedback.internal.IFeedbackService" />
<action android:name="com.google.android.gms.photos.autobackup.service.START" />
<action android:name="com.google.android.gms.udc.service.START" />
<action android:name="com.google.android.gms.mdm.services.DeviceManagerApiService.START" />
@ -380,13 +395,11 @@
<action android:name="com.google.android.gms.common.download.START" />
<action android:name="com.google.android.gms.signin.service.START" />
<action android:name="com.google.android.gms.safetynet.service.START" />
<action android:name="com.google.android.gms.ads.gservice.START" />
<action android:name="com.google.android.contextmanager.service.ContextManagerService.START" />
<action android:name="com.google.android.gms.audiomodem.service.AudioModemService.START" />
<action android:name="com.google.android.gms.nearby.sharing.service.NearbySharingService.START" />
<action android:name="com.google.android.gms.herrevad.services.LightweightNetworkQualityAndroidService.START" />
<action android:name="com.google.android.gms.phenotype.service.START" />
<action android:name="com.google.android.gms.auth.api.credentials.service.START" />
</intent-filter>
</service>

View File

@ -16,5 +16,5 @@
package com.google.android.gms.ads;
public class AdManagerCreatorImpl {
public class AdManagerCreatorImpl extends AdManagerCreator.Stub {
}

View File

@ -36,6 +36,8 @@ import java.util.HashSet;
import java.util.Set;
public abstract class AbstractGmsServiceBroker extends IGmsServiceBroker.Stub {
public static final int ID_ACCEPT_ALL = -1;
private static final String TAG = "GmsServiceBroker";
private final Set<Integer> supportedServiceIds;
@ -265,7 +267,7 @@ public abstract class AbstractGmsServiceBroker extends IGmsServiceBroker.Stub {
@Override
public void getService(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
if (supportedServiceIds.contains(request.serviceId)) {
if (supportedServiceIds.contains(request.serviceId) || supportedServiceIds.contains(ID_ACCEPT_ALL)) {
handleServiceRequest(callback, request);
} else {
Log.d(TAG, "Service not supported: " + request);

View File

@ -0,0 +1,51 @@
/*
* 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;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import com.google.android.gms.common.internal.IGmsServiceBroker;
public abstract class BaseService extends Service {
private final IGmsServiceBroker broker;
protected final String TAG;
public BaseService(String tag, Integer supportedServiceId, Integer... supportedServiceIds) {
this.TAG = tag;
broker = new AbstractGmsServiceBroker(supportedServiceId, supportedServiceIds) {
@Override
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
Log.d(TAG, "bound by: " + request);
BaseService.this.handleServiceRequest(callback, request);
}
};
}
@Override
public IBinder onBind(Intent intent) {
Log.d(TAG, "onBind: " + intent);
return broker.asBinder();
}
public abstract void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException;
}

View File

@ -16,29 +16,17 @@
package org.microg.gms;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import com.google.android.gms.common.internal.IGmsServiceBroker;
public class DummyService extends Service {
public class DummyService extends BaseService {
private static final String TAG = "GmsDummySvc";
private IGmsServiceBroker broker = new AbstractGmsServiceBroker(-1) {
@Override
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
}
};
public DummyService() {
super("GmsDummySvc", AbstractGmsServiceBroker.ID_ACCEPT_ALL);
}
@Override
public IBinder onBind(Intent intent) {
Log.d(TAG, "onBind: " + intent);
return broker.asBinder();
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) {
// Dummy
}
}

View File

@ -0,0 +1,35 @@
/*
* 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.ads;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import org.microg.gms.BaseService;
import org.microg.gms.common.Services;
public class GService extends BaseService {
public GService() {
super("GmsAdsGSvc", Services.GSERVICES.SERVICE_ID);
}
@Override
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) {
// TODO
}
}

View File

@ -16,6 +16,7 @@
package org.microg.gms.auth;
import android.accounts.Account;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@ -105,6 +106,11 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
return new AccountChangeEventsResponse();
}
@Override
public Bundle getTokenWithAccount(Account account, String scope, Bundle extras) throws RemoteException {
return getToken(account.name, scope, extras);
}
@Override
public Bundle clearToken(String token, Bundle extras) throws RemoteException {
String packageName = extras.getString(KEY_ANDROID_PACKAGE_NAME);

View File

@ -16,29 +16,19 @@
package org.microg.gms.car;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import org.microg.gms.AbstractGmsServiceBroker;
import org.microg.gms.BaseService;
import org.microg.gms.common.Services;
public class CarService extends Service {
private static final String TAG = "GmsCarSvc";
private AbstractGmsServiceBroker broker = new AbstractGmsServiceBroker(Services.CAR.SERVICE_ID) {
@Override
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) {
Log.d(TAG, "getCarService for " + request);
}
};
public class CarService extends BaseService {
public CarService() {
super("GmsCarSvc", Services.CAR.SERVICE_ID);
}
@Override
public IBinder onBind(Intent intent) {
return broker.asBinder();
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) {
// TODO
}
}

View File

@ -16,31 +16,20 @@
package org.microg.gms.droidguard;
import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import org.microg.gms.AbstractGmsServiceBroker;
import org.microg.gms.BaseService;
import org.microg.gms.common.Services;
public class DroidGuardService extends Service {
private static final String TAG = "GmsDroidGuardSvc";
public class DroidGuardService extends BaseService {
private AbstractGmsServiceBroker broker = new AbstractGmsServiceBroker(Services.DROIDGUARD.SERVICE_ID) {
@Override
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) {
Log.d(TAG, "getDroidGuardService for " + request);
}
};
public DroidGuardService() {
super("GmsDroidGuardSvc", Services.DROIDGUARD.SERVICE_ID);
}
@Override
public IBinder onBind(Intent intent) {
return broker.asBinder();
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) {
// TODO
}
}

View File

@ -0,0 +1,34 @@
/*
* 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.feedback;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import org.microg.gms.BaseService;
import org.microg.gms.common.Services;
public class FeedbackService extends BaseService {
public FeedbackService() {
super("GmsFeedbackSvc", Services.FEEDBACK.SERVICE_ID);
}
@Override
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) {
// TODO
}
}

View File

@ -16,52 +16,42 @@
package org.microg.gms.icing;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import com.google.android.gms.common.internal.IGmsServiceBroker;
import org.microg.gms.AbstractGmsServiceBroker;
import org.microg.gms.BaseService;
import org.microg.gms.common.Services;
public class IndexService extends Service {
private static final String TAG = "GmsIcingIndexSvc";
public class IndexService extends BaseService {
private AppDataSearchImpl appDataSearch = new AppDataSearchImpl();
private CorporaSearchImpl corporaSearch = new CorporaSearchImpl();
private IGmsServiceBroker broker = new AbstractGmsServiceBroker(
Services.INDEX.SERVICE_ID, Services.SEARCH_ADMINISTRATION.SERVICE_ID,
Services.SEARCH_CORPORA.SERVICE_ID, Services.SEARCH_GLOBAL.SERVICE_ID,
Services.SEARCH_IME.SERVICE_ID, Services.SEARCH_QUERIES.SERVICE_ID) {
@Override
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
Log.d(TAG, "bound by: " + request);
switch (request.serviceId) {
case Services.INDEX.SERVICE_ID:
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:
break;
case Services.SEARCH_QUERIES.SERVICE_ID:
break;
}
}
};
public IndexService() {
super("GmsIcingIndexSvc",
Services.INDEX.SERVICE_ID, Services.SEARCH_ADMINISTRATION.SERVICE_ID,
Services.SEARCH_CORPORA.SERVICE_ID, Services.SEARCH_GLOBAL.SERVICE_ID,
Services.SEARCH_IME.SERVICE_ID, Services.SEARCH_QUERIES.SERVICE_ID);
}
@Override
public IBinder onBind(Intent intent) {
return broker.asBinder();
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
switch (request.serviceId) {
case Services.INDEX.SERVICE_ID:
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:
break;
case Services.SEARCH_QUERIES.SERVICE_ID:
break;
}
}
}

View File

@ -16,32 +16,23 @@
package org.microg.gms.icing;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import org.microg.gms.AbstractGmsServiceBroker;
import org.microg.gms.BaseService;
import org.microg.gms.common.Services;
public class LightweightIndexService extends Service {
private static final String TAG = "GmsIcingLightIndexSvc";
public class LightweightIndexService extends BaseService {
private LightweightAppDataSearchImpl appDataSearch = new LightweightAppDataSearchImpl();
private AbstractGmsServiceBroker broker = new AbstractGmsServiceBroker(Services.LIGHTWEIGHT_INDEX.SERVICE_ID) {
@Override
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
Log.d(TAG, "bound by: " + request);
callback.onPostInitComplete(0, appDataSearch.asBinder(), null);
}
};
public LightweightIndexService() {
super("GmsIcingLightIndexSvc", Services.LIGHTWEIGHT_INDEX.SERVICE_ID);
}
@Override
public IBinder onBind(Intent intent) {
return broker.asBinder();
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
callback.onPostInitComplete(0, appDataSearch.asBinder(), null);
}
}

View File

@ -16,37 +16,26 @@
package org.microg.gms.location;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import org.microg.gms.AbstractGmsServiceBroker;
import org.microg.gms.BaseService;
import org.microg.gms.common.Services;
public class GoogleLocationManagerService extends Service {
public class GoogleLocationManagerService extends BaseService {
private static final String TAG = "GmsLocManagerSvc";
private GoogleLocationManagerServiceImpl impl = new GoogleLocationManagerServiceImpl(this);
private AbstractGmsServiceBroker broker = new AbstractGmsServiceBroker(Services.LOCATION_MANAGER.SERVICE_ID,
Services.GEODATA.SERVICE_ID, Services.PLACE_DETECTION.SERVICE_ID) {
@Override
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
Log.d(TAG, "bound by: " + request);
callback.onPostInitComplete(0, impl.asBinder(), null);
}
};
public GoogleLocationManagerService() {
super("GmsLocManagerSvc", Services.LOCATION_MANAGER.SERVICE_ID,
Services.GEODATA.SERVICE_ID, Services.PLACE_DETECTION.SERVICE_ID);
}
@Override
public IBinder onBind(Intent intent) {
if (Services.LOCATION_MANAGER.ACTION.equals(intent.getAction())) {
return broker.asBinder();
} else {
return null;
}
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
callback.onPostInitComplete(0, impl.asBinder(), null);
}
}

View File

@ -16,33 +16,23 @@
package org.microg.gms.location;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import org.microg.gms.AbstractGmsServiceBroker;
import org.microg.gms.BaseService;
import org.microg.gms.common.Services;
public class ReportingAndroidService extends Service {
private static final String TAG = "GmsLocReportingSvc";
public class ReportingAndroidService extends BaseService {
private ReportingServiceImpl reportingService = new ReportingServiceImpl();
private AbstractGmsServiceBroker broker = new AbstractGmsServiceBroker(Services.LOCATION_REPORTING.SERVICE_ID) {
@Override
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
Log.d(TAG, "bound by: " + request);
callback.onPostInitComplete(0, reportingService.asBinder(), null);
}
};
public ReportingAndroidService() {
super("GmsLocReportingSvc", Services.LOCATION_REPORTING.SERVICE_ID);
}
@Override
public IBinder onBind(Intent intent) {
Log.d(TAG, "onBind: " + intent);
return broker.asBinder();
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
callback.onPostInitComplete(0, reportingService.asBinder(), null);
}
}

View File

@ -16,37 +16,23 @@
package org.microg.gms.people;
import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import org.microg.gms.AbstractGmsServiceBroker;
import org.microg.gms.BaseService;
import org.microg.gms.common.Services;
public class PeopleService extends Service {
private static final String TAG = "GmsPeopleSvc";
public class PeopleService extends BaseService {
private PeopleServiceImpl impl = new PeopleServiceImpl(this);
private AbstractGmsServiceBroker broker = new AbstractGmsServiceBroker(Services.PEOPLE.SERVICE_ID) {
@Override
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
Log.d(TAG, "bound by: " + request);
callback.onPostInitComplete(0, impl.asBinder(), null);
}
};
public PeopleService() {
super("GmsPeopleSvc", Services.PEOPLE.SERVICE_ID);
}
@Override
public IBinder onBind(Intent intent) {
if (Services.PEOPLE.ACTION.equals(intent.getAction())) {
return broker.asBinder();
} else {
return null;
}
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
callback.onPostInitComplete(0, impl.asBinder(), null);
}
}

View File

@ -16,33 +16,24 @@
package org.microg.gms.playlog;
import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import org.microg.gms.AbstractGmsServiceBroker;
import org.microg.gms.BaseService;
import org.microg.gms.common.Services;
public class PlayLogService extends Service {
private static final String TAG = "GmsPlayLogSvc";
public class PlayLogService extends BaseService {
private PlayLogServiceImpl playLogService = new PlayLogServiceImpl();
private AbstractGmsServiceBroker broker = new AbstractGmsServiceBroker(Services.PLAY_LOG.SERVICE_ID) {
@Override
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
Log.d(TAG, "bound by: " + request);
callback.onPostInitComplete(0, playLogService.asBinder(), null);
}
};
public PlayLogService() {
super("GmsPlayLogSvc", Services.PLAY_LOG.SERVICE_ID);
}
@Override
public IBinder onBind(Intent intent) {
return broker.asBinder();
public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
callback.onPostInitComplete(0, playLogService.asBinder(), null);
}
}