From 7c312bfe30a0b927619a8068d1cc9aecf2ab807c Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Mon, 12 Jan 2015 00:08:18 +0100 Subject: [PATCH] Add some common Api classes --- .../gms/common/AbstractGmsServiceBroker.java | 170 ------------------ src/com/google/android/gms/common/Scopes.java | 18 ++ .../google/android/gms/common/api/Scope.java | 73 ++++++++ src/org/microg/gms/{maps => }/Constants.java | 7 +- 4 files changed, 94 insertions(+), 174 deletions(-) delete mode 100644 src/com/google/android/gms/common/AbstractGmsServiceBroker.java create mode 100644 src/com/google/android/gms/common/Scopes.java create mode 100644 src/com/google/android/gms/common/api/Scope.java rename src/org/microg/gms/{maps => }/Constants.java (96%) diff --git a/src/com/google/android/gms/common/AbstractGmsServiceBroker.java b/src/com/google/android/gms/common/AbstractGmsServiceBroker.java deleted file mode 100644 index 758d6fa..0000000 --- a/src/com/google/android/gms/common/AbstractGmsServiceBroker.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2014 μ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 com.google.android.gms.common; - -import android.os.Bundle; -import android.os.IBinder; -import android.os.RemoteException; -import com.google.android.gms.common.internal.IGmsCallbacks; -import com.google.android.gms.common.internal.IGmsServiceBroker; - -public abstract class AbstractGmsServiceBroker extends IGmsServiceBroker.Stub { - @Override - public void getPlusService(IGmsCallbacks callback, int versionCode, String packageName, - String str2, String[] paramArrayOfString, String str3, Bundle params) - throws RemoteException { - throw new IllegalArgumentException("Plus service not supported"); - } - - @Override - public void getPanoramaService(IGmsCallbacks callback, int versionCode, String packageName, - Bundle params) throws RemoteException { - throw new IllegalArgumentException("Panorama service not supported"); - } - - @Override - public void getAppDataSearchService(IGmsCallbacks callback, int versionCode, String packageName) - throws RemoteException { - throw new IllegalArgumentException("App Data Search service not supported"); - } - - @Override - public void getWalletService(IGmsCallbacks callback, int versionCode) throws RemoteException { - throw new IllegalArgumentException("Wallet service not supported"); - } - - @Override - public void getPeopleService(IGmsCallbacks callback, int versionCode, String packageName, - Bundle params) throws RemoteException { - throw new IllegalArgumentException("People service not supported"); - } - - @Override - public void getReportingService(IGmsCallbacks callback, int versionCode, String packageName, - Bundle params) throws RemoteException { - throw new IllegalArgumentException("Reporting service not supported"); - } - - @Override - public void getLocationService(IGmsCallbacks callback, int versionCode, String packageName, - Bundle params) throws RemoteException { - throw new IllegalArgumentException("Location service not supported"); - } - - @Override - public void getGoogleLocationManagerService(IGmsCallbacks callback, int versionCode, - String packageName, Bundle params) throws RemoteException { - throw new IllegalArgumentException("Google Location Manager service not supported"); - } - - @Override - public void getGamesService(IGmsCallbacks callback, int versionCode, String packageName, - String str2, String[] args, String str3, IBinder binder, String str4, Bundle params) - throws RemoteException { - throw new IllegalArgumentException("Games service not supported"); - } - - @Override - public void getAppStateService(IGmsCallbacks callback, int versionCode, String packageName, - String str2, String[] args) throws RemoteException { - throw new IllegalArgumentException("App State service not supported"); - } - - @Override - public void getPlayLogService(IGmsCallbacks callback, int versionCode, String packageName, - Bundle params) throws RemoteException { - throw new IllegalArgumentException("Play Log service not supported"); - } - - @Override - public void getAdMobService(IGmsCallbacks callback, int versionCode, String packageName, - Bundle params) throws RemoteException { - throw new IllegalArgumentException("AdMob service not supported"); - } - - @Override - public void getDroidGuardService(IGmsCallbacks callback, int versionCode, String packageName, - Bundle params) throws RemoteException { - throw new IllegalArgumentException("DroidGuard service not supported"); - } - - @Override - public void getLockboxService(IGmsCallbacks callback, int versionCode, String packageName, - Bundle params) throws RemoteException { - throw new IllegalArgumentException("Lockbox service not supported"); - } - - @Override - public void getCastMirroringService(IGmsCallbacks callback, int versionCode, String packageName, - Bundle params) throws RemoteException { - throw new IllegalArgumentException("Cast Mirroring service not supported"); - } - - @Override - public void getNetworkQualityService(IGmsCallbacks callback, int versionCode, - String packageName, Bundle params) throws RemoteException { - throw new IllegalArgumentException("Network Quality service not supported"); - } - - @Override - public void getGoogleIdentityService(IGmsCallbacks callback, int versionCode, - String packageName, Bundle params) throws RemoteException { - throw new IllegalArgumentException("Google Identity service not supported"); - } - - @Override - public void getGoogleFeedbackService(IGmsCallbacks callback, int versionCode, - String packageName, Bundle params) throws RemoteException { - throw new IllegalArgumentException("Google Feedback service not supported"); - } - - @Override - public void getCastService(IGmsCallbacks callback, int versionCode, String packageName, - IBinder binder, Bundle params) throws RemoteException { - throw new IllegalArgumentException("Cast service not supported"); - } - - @Override - public void getDriveService(IGmsCallbacks callback, int versionCode, String packageName, - String[] args, String str2, Bundle params) throws RemoteException { - throw new IllegalArgumentException("Drive service not supported"); - } - - @Override - public void getLightweightAppDataSearchService(IGmsCallbacks callback, int versionCode, - String packageName) throws RemoteException { - throw new IllegalArgumentException("Lightweight App Data Search service not supported"); - } - - @Override - public void getSearchAdministrationService(IGmsCallbacks callback, int versionCode, - String packageName) throws RemoteException { - throw new IllegalArgumentException("Search Administration service not supported"); - } - - @Override - public void getAutoBackupService(IGmsCallbacks callback, int versionCode, String packageName, - Bundle params) throws RemoteException { - throw new IllegalArgumentException("Auto Backup service not supported"); - } - - @Override - public void getAddressService(IGmsCallbacks callback, int versionCode, String packageName) - throws RemoteException { - throw new IllegalArgumentException("Address service not supported"); - } -} diff --git a/src/com/google/android/gms/common/Scopes.java b/src/com/google/android/gms/common/Scopes.java new file mode 100644 index 0000000..bbc0f55 --- /dev/null +++ b/src/com/google/android/gms/common/Scopes.java @@ -0,0 +1,18 @@ +package com.google.android.gms.common; + +public class Scopes { + public static final String PROFILE = "profile"; + public static final String PLUS_LOGIN = "https://www.googleapis.com/auth/plus.login"; + public static final String PLUS_ME = "https://www.googleapis.com/auth/plus.me"; + public static final String GAMES = "https://www.googleapis.com/auth/games"; + public static final String CLOUD_SAVE = "https://www.googleapis.com/auth/datastoremobile"; + public static final String APP_STATE = "https://www.googleapis.com/auth/appstate"; + public static final String DRIVE_FILE = "https://www.googleapis.com/auth/drive.file"; + public static final String DRIVE_APPFOLDER = "https://www.googleapis.com/auth/drive.appdata"; + public static final String FITNESS_ACTIVITY_READ = "https://www.googleapis.com/auth/fitness.activity.read"; + public static final String FITNESS_ACTIVITY_READ_WRITE = "https://www.googleapis.com/auth/fitness.activity.write"; + public static final String FITNESS_LOCATION_READ = "https://www.googleapis.com/auth/fitness.location.read"; + public static final String FITNESS_LOCATION_READ_WRITE = "https://www.googleapis.com/auth/fitness.location.write"; + public static final String FITNESS_BODY_READ = "https://www.googleapis.com/auth/fitness.body.read"; + public static final String FITNESS_BODY_READ_WRITE = "https://www.googleapis.com/auth/fitness.body.write"; +} diff --git a/src/com/google/android/gms/common/api/Scope.java b/src/com/google/android/gms/common/api/Scope.java new file mode 100644 index 0000000..21ad332 --- /dev/null +++ b/src/com/google/android/gms/common/api/Scope.java @@ -0,0 +1,73 @@ +package com.google.android.gms.common.api; + +import android.os.Parcel; +import org.microg.safeparcel.SafeParcelUtil; +import org.microg.safeparcel.SafeParcelable; + +/** + * Describes an OAuth 2.0 scope to request. This has security implications for the user, and + * requesting additional scopes will result in authorization dialogs. + */ +public class Scope implements SafeParcelable { + private final int versionCode; + private final String scopeUri; + + private Scope() { + versionCode = -1; + scopeUri = null; + } + + private Scope(Parcel in) { + this(); + SafeParcelUtil.readObject(this, in); + } + + /** + * Creates a new scope with the given URI. + */ + public Scope(String scopeUri) { + versionCode = 1; + this.scopeUri = scopeUri; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public boolean equals(Object o) { + return this == o || o instanceof Scope && scopeUri.equals(((Scope) o).scopeUri); + } + + public String getScopeUri() { + return scopeUri; + } + + @Override + public int hashCode() { + return scopeUri.hashCode(); + } + + @Override + public String toString() { + return scopeUri; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + SafeParcelUtil.writeObject(this, out, flags); + } + + public static final Creator CREATOR = new Creator() { + @Override + public Scope createFromParcel(Parcel parcel) { + return new Scope(parcel); + } + + @Override + public Scope[] newArray(int i) { + return new Scope[i]; + } + }; +} diff --git a/src/org/microg/gms/maps/Constants.java b/src/org/microg/gms/Constants.java similarity index 96% rename from src/org/microg/gms/maps/Constants.java rename to src/org/microg/gms/Constants.java index 7209e50..9ff2f90 100644 --- a/src/org/microg/gms/maps/Constants.java +++ b/src/org/microg/gms/Constants.java @@ -1,4 +1,4 @@ -package org.microg.gms.maps; +package org.microg.gms; public class Constants { /** @@ -6,6 +6,8 @@ public class Constants { * Does not necessarily mean anything. */ public static final int MAX_REFERENCE_VERSION = 6599436; + public static final String ACTION_GMS_LOCATION_MANAGER_SERVICE_START = "com.google.android.location.internal.GoogleLocationManagerService.START"; + public static final String KEY_MOCK_LOCATION = "mockLocation"; /** * No base map tiles. @@ -31,7 +33,4 @@ public class Constants { * Satellite maps with a transparent layer of major streets. */ public static final int MAP_TYPE_HYBRID = 4; - - public static final String ACTION_GMS_LOCATION_MANAGER_SERVICE_START = "com.google.android.location.internal.GoogleLocationManagerService.START"; - public static final String KEY_MOCK_LOCATION = "mockLocation"; }