From a2a6c8d56151c2e8267c74226eae0224b2e3de22 Mon Sep 17 00:00:00 2001 From: Venny Date: Fri, 17 Jul 2020 15:55:59 +0200 Subject: [PATCH 1/8] Write readme, remove useless services --- README.md | 33 +++---- .../src/main/AndroidManifest.xml | 98 ------------------- 2 files changed, 14 insertions(+), 117 deletions(-) diff --git a/README.md b/README.md index b378765f..25f09532 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,19 @@ -microG Services Core (GmsCore) -======= -[![Build Status](https://travis-ci.org/microg/android_packages_apps_GmsCore.svg?branch=master)](https://travis-ci.org/microg/android_packages_apps_GmsCore) +# Vanced MicroG + +[![Build Status](https://travis-ci.org/YTVanced/VancedMicroG.svg?branch=master)](https://travis-ci.com/github/YTVanced/VancedMicroG) microG GmsCore is a FLOSS (Free/Libre Open Source Software) framework to allow applications designed for Google Play Services to run on systems, where Play Services is not available. -### Please refer to the [wiki](https://github.com/microg/android_packages_apps_GmsCore/wiki) for downloads and instructions +This fork tweaks MicroG to be usable by applications that require Google authentication such as Youtube Vanced. +## Notable changes -License -------- - Copyright 2013-2019 microG 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. +- No longer a system app +- Package name changed from `com.google.android.gms` to `com.mgoogle.android.gms` to support installation alongside the official MicroG +- Removed unnecessary features: + - Maps & Location + - Wear-Api + - Safetynet + - Games + - Car +- Removed all permissions, as none are required for Google authentication diff --git a/play-services-core/src/main/AndroidManifest.xml b/play-services-core/src/main/AndroidManifest.xml index 91201149..d80ac296 100644 --- a/play-services-core/src/main/AndroidManifest.xml +++ b/play-services-core/src/main/AndroidManifest.xml @@ -197,38 +197,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -295,24 +263,6 @@ android:authorities="com.mgoogle.android.gms.auth.accounts" android:exported="true" /> - - - - - - - - - - - - - - - - @@ -321,12 +271,6 @@ - - - @@ -477,60 +421,18 @@ android:name="com.google.android.gms.gcm.http.GoogleHttpService" android:exported="true" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 391e09e729ba36c6177b6acfcf930d277c1a6df2 Mon Sep 17 00:00:00 2001 From: Venny Date: Fri, 17 Jul 2020 16:32:04 +0200 Subject: [PATCH 2/8] Remove unnecessary options in MicroG settings --- .../org/microg/gms/ui/SettingsActivity.java | 1 - .../src/main/res/xml/preferences_snet.xml | 31 ------------- .../res/xml/preferences_snet_advanced.xml | 43 ------------------- .../src/main/res/xml/preferences_start.xml | 35 --------------- 4 files changed, 110 deletions(-) delete mode 100644 play-services-core/src/main/res/xml/preferences_snet.xml delete mode 100644 play-services-core/src/main/res/xml/preferences_snet_advanced.xml diff --git a/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java b/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java index 88b8f2b0..efc6313b 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java @@ -81,7 +81,6 @@ public class SettingsActivity extends AbstractDashboardActivity { findPreference(PREF_GCM).setSummary(R.string.abc_capital_off); } - findPreference(PREF_SNET).setSummary(R.string.service_status_disabled); // Preferences unifiedNlPrefs = new Preferences(getContext()); // int backendCount = TextUtils.isEmpty(unifiedNlPrefs.getLocationBackends()) ? 0 : diff --git a/play-services-core/src/main/res/xml/preferences_snet.xml b/play-services-core/src/main/res/xml/preferences_snet.xml deleted file mode 100644 index 8a60cf3e..00000000 --- a/play-services-core/src/main/res/xml/preferences_snet.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/play-services-core/src/main/res/xml/preferences_snet_advanced.xml b/play-services-core/src/main/res/xml/preferences_snet_advanced.xml deleted file mode 100644 index e87859af..00000000 --- a/play-services-core/src/main/res/xml/preferences_snet_advanced.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/play-services-core/src/main/res/xml/preferences_start.xml b/play-services-core/src/main/res/xml/preferences_start.xml index 85b5e3d0..b774d823 100644 --- a/play-services-core/src/main/res/xml/preferences_start.xml +++ b/play-services-core/src/main/res/xml/preferences_start.xml @@ -15,16 +15,6 @@ --> - - - - - - - - - - - - - - - - Date: Fri, 17 Jul 2020 16:42:11 +0200 Subject: [PATCH 3/8] Remove missing permissions snackbar --- .../org/microg/gms/people/PeopleServiceImpl.java | 4 +--- .../main/java/org/microg/gms/ui/Conditions.java | 14 +++----------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/play-services-core/src/main/java/org/microg/gms/people/PeopleServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/people/PeopleServiceImpl.java index a2f10015..d68e23d2 100644 --- a/play-services-core/src/main/java/org/microg/gms/people/PeopleServiceImpl.java +++ b/play-services-core/src/main/java/org/microg/gms/people/PeopleServiceImpl.java @@ -52,9 +52,7 @@ public class PeopleServiceImpl extends IPeopleService.Stub { @Override public void loadOwners(final IPeopleCallbacks callbacks, boolean var2, boolean var3, final String accountName, String var5, int sortOrder) { Log.d(TAG, "loadOwners: " + var2 + ", " + var3 + ", " + accountName + ", " + var5 + ", " + sortOrder); - if (context.checkCallingPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { - PackageUtils.assertExtendedAccess(context); - } + AccountManager accountManager = AccountManager.get(context); Bundle accountMetadata = new Bundle(); String accountType = AuthConstants.DEFAULT_ACCOUNT_TYPE; diff --git a/play-services-core/src/main/java/org/microg/gms/ui/Conditions.java b/play-services-core/src/main/java/org/microg/gms/ui/Conditions.java index c1c35ae9..ea892311 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/Conditions.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/Conditions.java @@ -65,27 +65,19 @@ public class Conditions { } }).build(); - private static final String[] REQUIRED_PERMISSIONS = new String[]{ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION, READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE, GET_ACCOUNTS, READ_PHONE_STATE}; + private static final String[] REQUIRED_PERMISSIONS = new String[]{}; public static final Condition PERMISSIONS = new Condition.Builder() .title(R.string.cond_perm_title) .summaryPlurals(R.plurals.cond_perm_summary) .evaluation(new Condition.Evaluation() { - int count = 0; @Override public boolean isActive(Context context) { - count = 0; - if (SDK_INT >= Build.VERSION_CODES.M) { - for (String permission : REQUIRED_PERMISSIONS) { - if (ContextCompat.checkSelfPermission(context, permission) != PERMISSION_GRANTED) - count++; - } - } - return count > 0; + return false; } @Override public int getPluralsCount() { - return count; + return 0; } }) .firstActionPlurals(R.plurals.cond_perm_action, new View.OnClickListener() { From d9bb26828c08e0b58f1dc1e140845296c989ef07 Mon Sep 17 00:00:00 2001 From: Venny Date: Fri, 17 Jul 2020 16:46:41 +0200 Subject: [PATCH 4/8] Remove permissionscheck snackbar builder --- .../java/org/microg/gms/ui/Conditions.java | 24 ------------------- .../org/microg/gms/ui/SettingsActivity.java | 1 - 2 files changed, 25 deletions(-) diff --git a/play-services-core/src/main/java/org/microg/gms/ui/Conditions.java b/play-services-core/src/main/java/org/microg/gms/ui/Conditions.java index ea892311..0b0edead 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/Conditions.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/Conditions.java @@ -64,28 +64,4 @@ public class Conditions { v.getContext().startActivity(intent); } }).build(); - - private static final String[] REQUIRED_PERMISSIONS = new String[]{}; - public static final Condition PERMISSIONS = new Condition.Builder() - .title(R.string.cond_perm_title) - .summaryPlurals(R.plurals.cond_perm_summary) - .evaluation(new Condition.Evaluation() { - @Override - public boolean isActive(Context context) { - return false; - } - - @Override - public int getPluralsCount() { - return 0; - } - }) - .firstActionPlurals(R.plurals.cond_perm_action, new View.OnClickListener() { - @Override - public void onClick(View v) { - if (v.getContext() instanceof Activity) { - ActivityCompat.requestPermissions((Activity) v.getContext(), REQUIRED_PERMISSIONS, 0); - } - } - }).build(); } diff --git a/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java b/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java index efc6313b..4fecfec9 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java @@ -38,7 +38,6 @@ public class SettingsActivity extends AbstractDashboardActivity { public SettingsActivity() { preferencesResource = R.xml.preferences_start; addCondition(Conditions.GCM_BATTERY_OPTIMIZATIONS); - addCondition(Conditions.PERMISSIONS); } @Override From eb67f23f5f2a4d58dd66d5492ebc5bb27fbe379f Mon Sep 17 00:00:00 2001 From: Venny Date: Fri, 17 Jul 2020 17:16:08 +0200 Subject: [PATCH 5/8] Remove unused folders --- .../google/android/gms/ads/AdActivity.java | 22 -- .../android/gms/ads/AdManagerCreatorImpl.java | 20 -- .../chimera/container/DynamiteLoaderImpl.java | 72 ---- .../plusone/PlusOneButtonCreatorImpl.java | 40 --- .../dynamite/WalletDynamiteCreatorImpl.java | 20 -- .../microg/gms/ads/AdvertisingIdService.java | 28 -- .../gms/ads/AdvertisingIdServiceImpl.java | 45 --- .../java/org/microg/gms/ads/GService.java | 35 -- .../java/org/microg/gms/car/CarService.java | 34 -- .../microg/gms/drive/api/DriveApiService.java | 38 --- .../gms/drive/api/DriveServiceImpl.java | 318 ------------------ .../microg/gms/feedback/FeedbackService.java | 34 -- .../microg/gms/games/GamesStubService.java | 58 ---- .../org/microg/gms/games/UpgradeActivity.java | 73 ---- .../measurement/MeasurementBrokerService.java | 39 --- .../measurement/MeasurementServiceImpl.java | 34 -- .../org/microg/gms/places/GeoDataService.java | 36 -- .../gms/places/PlaceDetectionService.java | 37 -- .../gms/places/PlaceDetectionServiceImpl.java | 34 -- .../microg/gms/places/PlacesServiceImpl.java | 34 -- .../microg/gms/plus/PlusOneButtonImpl.java | 27 -- .../gms/reminders/RemindersService.java | 37 -- .../gms/reminders/RemindersServiceImpl.java | 169 ---------- .../microg/gms/tapandpay/TapAndPayImpl.java | 33 -- .../gms/tapandpay/TapAndPayService.java | 38 --- .../org/microg/gms/ui/SelfCheckFragment.java | 4 - .../org/microg/gms/wallet/OwServiceImpl.java | 38 --- .../org/microg/gms/wallet/PaymentService.java | 37 -- .../selfcheck/InstalledPackagesChecks.java | 68 ---- .../selfcheck/RomSpoofSignatureChecks.java | 84 ----- .../org/microg/gms/snet/AttestRequest.java | 83 ----- .../org/microg/gms/snet/AttestResponse.java | 62 ---- .../org/microg/gms/snet/FileState.java | 83 ----- .../org/microg/gms/snet/SELinuxState.java | 81 ----- .../org/microg/gms/snet/SafetyNetData.java | 186 ---------- 35 files changed, 2081 deletions(-) delete mode 100644 play-services-core/src/main/java/com/google/android/gms/ads/AdActivity.java delete mode 100644 play-services-core/src/main/java/com/google/android/gms/ads/AdManagerCreatorImpl.java delete mode 100644 play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteLoaderImpl.java delete mode 100644 play-services-core/src/main/java/com/google/android/gms/plus/plusone/PlusOneButtonCreatorImpl.java delete mode 100644 play-services-core/src/main/java/com/google/android/gms/wallet/dynamite/WalletDynamiteCreatorImpl.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/ads/AdvertisingIdService.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/ads/AdvertisingIdServiceImpl.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/ads/GService.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/car/CarService.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/drive/api/DriveApiService.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/drive/api/DriveServiceImpl.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/feedback/FeedbackService.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/games/GamesStubService.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/games/UpgradeActivity.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/measurement/MeasurementBrokerService.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/measurement/MeasurementServiceImpl.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/places/GeoDataService.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/places/PlaceDetectionService.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/places/PlaceDetectionServiceImpl.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/places/PlacesServiceImpl.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/plus/PlusOneButtonImpl.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/reminders/RemindersService.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/reminders/RemindersServiceImpl.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/tapandpay/TapAndPayImpl.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/tapandpay/TapAndPayService.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/wallet/OwServiceImpl.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/wallet/PaymentService.java delete mode 100644 play-services-core/src/main/java/org/microg/tools/selfcheck/InstalledPackagesChecks.java delete mode 100644 play-services-core/src/main/java/org/microg/tools/selfcheck/RomSpoofSignatureChecks.java delete mode 100644 play-services-core/src/main/protos-java/org/microg/gms/snet/AttestRequest.java delete mode 100644 play-services-core/src/main/protos-java/org/microg/gms/snet/AttestResponse.java delete mode 100644 play-services-core/src/main/protos-java/org/microg/gms/snet/FileState.java delete mode 100644 play-services-core/src/main/protos-java/org/microg/gms/snet/SELinuxState.java delete mode 100644 play-services-core/src/main/protos-java/org/microg/gms/snet/SafetyNetData.java diff --git a/play-services-core/src/main/java/com/google/android/gms/ads/AdActivity.java b/play-services-core/src/main/java/com/google/android/gms/ads/AdActivity.java deleted file mode 100644 index 3829065d..00000000 --- a/play-services-core/src/main/java/com/google/android/gms/ads/AdActivity.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.ads; - -import android.app.Activity; - -public class AdActivity extends Activity { -} diff --git a/play-services-core/src/main/java/com/google/android/gms/ads/AdManagerCreatorImpl.java b/play-services-core/src/main/java/com/google/android/gms/ads/AdManagerCreatorImpl.java deleted file mode 100644 index f0f6a9a5..00000000 --- a/play-services-core/src/main/java/com/google/android/gms/ads/AdManagerCreatorImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.ads; - -public class AdManagerCreatorImpl extends AdManagerCreator.Stub { -} diff --git a/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteLoaderImpl.java b/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteLoaderImpl.java deleted file mode 100644 index 43bd5caf..00000000 --- a/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteLoaderImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.chimera.container; - -import android.content.Context; -import android.content.ContextWrapper; -import android.content.pm.PackageManager; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.dynamic.ObjectWrapper; -import com.google.android.gms.dynamite.IDynamiteLoader; - -import org.microg.gms.common.Constants; - -public class DynamiteLoaderImpl extends IDynamiteLoader.Stub { - private static final String TAG = "GmsDynamiteLoaderImpl"; - - @Override - public IObjectWrapper createModuleContext(IObjectWrapper wrappedContext, String moduleId, int minVersion) throws RemoteException { - Log.d(TAG, "unimplemented Method: createModuleContext for " + moduleId + " at version " + minVersion + ", returning gms context"); - final Context context = (Context) ObjectWrapper.unwrap(wrappedContext); - try { - return ObjectWrapper.wrap(new ContextWrapper(context.createPackageContext(Constants.GMS_PACKAGE_NAME, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY)) { - @Override - public Context getApplicationContext() { - return context; - } - }); - } catch (PackageManager.NameNotFoundException e) { - Log.w(TAG, "returning null instead", e); - return null; - } - } - - @Override - public int getModuleVersion(IObjectWrapper context, String moduleId) throws RemoteException { - return getModuleVersion2(context, moduleId, true); - } - - @Override - public int getModuleVersion2(IObjectWrapper context, String moduleId, boolean updateConfigIfRequired) throws RemoteException { - if (moduleId.equals("com.google.android.gms.firebase_database")) { - Log.d(TAG, "returning temp fix module version for " + moduleId + ". Firebase Database will not be functional!"); - return com.google.android.gms.dynamite.descriptors.com.google.android.gms.firebase_database.ModuleDescriptor.MODULE_VERSION; - } - if (moduleId.equals("com.google.android.gms.googlecertificates")) { - return com.google.android.gms.dynamite.descriptors.com.google.android.gms.googlecertificates.ModuleDescriptor.MODULE_VERSION; - } - if (moduleId.equals("com.google.android.gms.cast.framework.dynamite")) { - Log.d(TAG, "returning temp fix module version for " + moduleId + ". Cast API wil not be functional!"); - return 1; - } - Log.d(TAG, "unimplemented Method: getModuleVersion for " + moduleId); - return 0; - } -} diff --git a/play-services-core/src/main/java/com/google/android/gms/plus/plusone/PlusOneButtonCreatorImpl.java b/play-services-core/src/main/java/com/google/android/gms/plus/plusone/PlusOneButtonCreatorImpl.java deleted file mode 100644 index ddd04bea..00000000 --- a/play-services-core/src/main/java/com/google/android/gms/plus/plusone/PlusOneButtonCreatorImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.plus.plusone; - -import android.content.Context; -import android.os.RemoteException; -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.dynamic.ObjectWrapper; -import com.google.android.gms.plus.internal.IPlusOneButtonCreator; - -import org.microg.gms.auth.AuthConstants; -import org.microg.gms.plus.PlusOneButtonImpl; - -public class PlusOneButtonCreatorImpl extends IPlusOneButtonCreator.Stub { - @Override - public IObjectWrapper create(IObjectWrapper context, int size, int annotation, String url, int activityRequestCode) throws RemoteException { - Context ctx = (Context) ObjectWrapper.unwrap(context); - return ObjectWrapper.wrap(new PlusOneButtonImpl(ctx, size, annotation, url, AuthConstants.DEFAULT_ACCOUNT)); - } - - @Override - public IObjectWrapper createForAccount(IObjectWrapper context, int size, int annotation, String url, String account) throws RemoteException { - Context ctx = (Context) ObjectWrapper.unwrap(context); - return ObjectWrapper.wrap(new PlusOneButtonImpl(ctx, size, annotation, url, account)); - } -} diff --git a/play-services-core/src/main/java/com/google/android/gms/wallet/dynamite/WalletDynamiteCreatorImpl.java b/play-services-core/src/main/java/com/google/android/gms/wallet/dynamite/WalletDynamiteCreatorImpl.java deleted file mode 100644 index 26343597..00000000 --- a/play-services-core/src/main/java/com/google/android/gms/wallet/dynamite/WalletDynamiteCreatorImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.wallet.dynamite; - -public class WalletDynamiteCreatorImpl { -} diff --git a/play-services-core/src/main/java/org/microg/gms/ads/AdvertisingIdService.java b/play-services-core/src/main/java/org/microg/gms/ads/AdvertisingIdService.java deleted file mode 100644 index c3bc63d1..00000000 --- a/play-services-core/src/main/java/org/microg/gms/ads/AdvertisingIdService.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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 android.app.Service; -import android.content.Intent; -import android.os.IBinder; - -public class AdvertisingIdService extends Service { - @Override - public IBinder onBind(Intent intent) { - return new AdvertisingIdServiceImpl().asBinder(); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/ads/AdvertisingIdServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/ads/AdvertisingIdServiceImpl.java deleted file mode 100644 index 30760da9..00000000 --- a/play-services-core/src/main/java/org/microg/gms/ads/AdvertisingIdServiceImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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 android.os.RemoteException; - -import com.google.android.gms.ads.identifier.internal.IAdvertisingIdService; - -import java.util.UUID; - -public class AdvertisingIdServiceImpl extends IAdvertisingIdService.Stub { - @Override - public String getAdvertisingId() throws RemoteException { - return generateAdvertisingId(null); - } - - @Override - public boolean isAdTrackingLimited(boolean defaultHint) throws RemoteException { - return true; - } - - @Override - public String generateAdvertisingId(String packageName) throws RemoteException { - return UUID.randomUUID().toString(); - } - - @Override - public void setAdTrackingLimited(String packageName, boolean limited) throws RemoteException { - // Ignored, sorry :) - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/ads/GService.java b/play-services-core/src/main/java/org/microg/gms/ads/GService.java deleted file mode 100644 index c8239da3..00000000 --- a/play-services-core/src/main/java/org/microg/gms/ads/GService.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.GmsService; - -public class GService extends BaseService { - - public GService() { - super("GmsAdsGSvc", GmsService.GSERVICES, GmsService.ADREQUEST); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) { - // TODO - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/car/CarService.java b/play-services-core/src/main/java/org/microg/gms/car/CarService.java deleted file mode 100644 index bd412b6c..00000000 --- a/play-services-core/src/main/java/org/microg/gms/car/CarService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.car; - -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.GmsService; - -public class CarService extends BaseService { - public CarService() { - super("GmsCarSvc", GmsService.CAR); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) { - // TODO - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/drive/api/DriveApiService.java b/play-services-core/src/main/java/org/microg/gms/drive/api/DriveApiService.java deleted file mode 100644 index 2fc066e1..00000000 --- a/play-services-core/src/main/java/org/microg/gms/drive/api/DriveApiService.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.drive.api; - -import android.os.RemoteException; - -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.GmsService; - -public class DriveApiService extends BaseService { - private DriveServiceImpl impl = new DriveServiceImpl(); - - public DriveApiService() { - super("GmsDriveApiSvc", GmsService.DRIVE); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { - callback.onPostInitComplete(0, impl.asBinder(), null); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/drive/api/DriveServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/drive/api/DriveServiceImpl.java deleted file mode 100644 index 4a899fa9..00000000 --- a/play-services-core/src/main/java/org/microg/gms/drive/api/DriveServiceImpl.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.drive.api; - -import android.content.IntentSender; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.drive.internal.AddEventListenerRequest; -import com.google.android.gms.drive.internal.AddPermissionRequest; -import com.google.android.gms.drive.internal.AuthorizeAccessRequest; -import com.google.android.gms.drive.internal.CancelPendingActionsRequest; -import com.google.android.gms.drive.internal.ChangeResourceParentsRequest; -import com.google.android.gms.drive.internal.CheckResourceIdsExistRequest; -import com.google.android.gms.drive.internal.CloseContentsAndUpdateMetadataRequest; -import com.google.android.gms.drive.internal.CloseContentsRequest; -import com.google.android.gms.drive.internal.ControlProgressRequest; -import com.google.android.gms.drive.internal.CreateContentsRequest; -import com.google.android.gms.drive.internal.CreateFileIntentSenderRequest; -import com.google.android.gms.drive.internal.CreateFileRequest; -import com.google.android.gms.drive.internal.CreateFolderRequest; -import com.google.android.gms.drive.internal.DeleteResourceRequest; -import com.google.android.gms.drive.internal.DisconnectRequest; -import com.google.android.gms.drive.internal.DriveServiceResponse; -import com.google.android.gms.drive.internal.FetchThumbnailRequest; -import com.google.android.gms.drive.internal.GetChangesRequest; -import com.google.android.gms.drive.internal.GetDriveIdFromUniqueIdRequest; -import com.google.android.gms.drive.internal.GetMetadataRequest; -import com.google.android.gms.drive.internal.GetPermissionsRequest; -import com.google.android.gms.drive.internal.IDriveService; -import com.google.android.gms.drive.internal.IDriveServiceCallbacks; -import com.google.android.gms.drive.internal.IEventCallback; -import com.google.android.gms.drive.internal.ListParentsRequest; -import com.google.android.gms.drive.internal.LoadRealtimeRequest; -import com.google.android.gms.drive.internal.OpenContentsRequest; -import com.google.android.gms.drive.internal.OpenFileIntentSenderRequest; -import com.google.android.gms.drive.internal.RealtimeDocumentSyncRequest; -import com.google.android.gms.drive.internal.RemoveEventListenerRequest; -import com.google.android.gms.drive.internal.RemovePermissionRequest; -import com.google.android.gms.drive.internal.SetDrivePreferencesRequest; -import com.google.android.gms.drive.internal.SetFileUploadPreferencesRequest; -import com.google.android.gms.drive.internal.SetResourceParentsRequest; -import com.google.android.gms.drive.internal.StreamContentsRequest; -import com.google.android.gms.drive.internal.TrashResourceRequest; -import com.google.android.gms.drive.internal.UnsubscribeResourceRequest; -import com.google.android.gms.drive.internal.UntrashResourceRequest; -import com.google.android.gms.drive.internal.UpdateMetadataRequest; -import com.google.android.gms.drive.internal.UpdatePermissionRequest; - -public class DriveServiceImpl extends IDriveService.Stub { - private static final String TAG = "GmsDriveSvcImpl"; - - @Override - public void getMetadata(GetMetadataRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: getMetadata"); - - } - - @Override - public void updateMetadata(UpdateMetadataRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: updateMetadata"); - - } - - @Override - public void createContents(CreateContentsRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: createContents"); - - } - - @Override - public void createFile(CreateFileRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: createFile"); - - } - - @Override - public void createFolder(CreateFolderRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: createFolder"); - - } - - @Override - public DriveServiceResponse openContents(OpenContentsRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: openContents"); - return null; - } - - @Override - public void closeContents(CloseContentsRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: closeContents"); - - } - - @Override - public void requestSync(IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: requestSync"); - - } - - @Override - public IntentSender openFileIntentSender(OpenFileIntentSenderRequest request) throws RemoteException { - Log.d(TAG, "unimplemented Method: openFileIntentSender"); - return null; - } - - @Override - public IntentSender createFileIntentSender(CreateFileIntentSenderRequest request) throws RemoteException { - Log.d(TAG, "unimplemented Method: createFileIntentSender"); - return null; - } - - @Override - public void authorizeAccess(AuthorizeAccessRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: authorizeAccess"); - - } - - @Override - public void listParents(ListParentsRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: listParents"); - - } - - @Override - public void addEventListener(AddEventListenerRequest request, IEventCallback callback, String unused, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: addEventListener"); - - } - - @Override - public void removeEventListener(RemoveEventListenerRequest request, IEventCallback callback, String unused, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: removeEventListener"); - - } - - @Override - public void disconnect(DisconnectRequest request) throws RemoteException { - Log.d(TAG, "unimplemented Method: disconnect"); - - } - - @Override - public void trashResource(TrashResourceRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: trashResource"); - - } - - @Override - public void closeContentsAndUpdateMetadata(CloseContentsAndUpdateMetadataRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: closeContentsAndUpdateMetadata"); - - } - - @Override - public void deleteResource(DeleteResourceRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: deleteResource"); - - } - - @Override - public void loadRealtime(LoadRealtimeRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: loadRealtime"); - - } - - @Override - public void setResourceParents(SetResourceParentsRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: setResourceParents"); - - } - - @Override - public void getDriveIdFromUniqueId(GetDriveIdFromUniqueIdRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: getDriveIdFromUniqueId"); - - } - - @Override - public void checkResourceIdsExist(CheckResourceIdsExistRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: checkResourceIdsExist"); - - } - - @Override - public void completePendingAction(IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: completePendingAction"); - - } - - @Override - public void getDrivePreferences(IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: getDrivePreferences"); - - } - - @Override - public void setDrivePreferences(SetDrivePreferencesRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: setDrivePreferences"); - - } - - @Override - public void realtimeDocumentSync(RealtimeDocumentSyncRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: realtimeDocumentSync"); - - } - - @Override - public void getDeviceUsagePreferences(IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: getDeviceUsagePreferences"); - - } - - @Override - public void setFileUploadPreferences(SetFileUploadPreferencesRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: setFileUploadPreferences"); - - } - - @Override - public void cancelPendingActions(CancelPendingActionsRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: cancelPendingActions"); - - } - - @Override - public void untrashResource(UntrashResourceRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: untrashResource"); - - } - - @Override - public void isAutoBackupEnabled(IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: isAutoBackupEnabled"); - - } - - @Override - public void fetchThumbnail(FetchThumbnailRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: fetchThumbnail"); - - } - - @Override - public void getChanges(GetChangesRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: getChanges"); - - } - - @Override - public void unsubscribeResource(UnsubscribeResourceRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: unsubscribeResource"); - - } - - @Override - public void getPermissions(GetPermissionsRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: getPermissions"); - - } - - @Override - public void addPermission(AddPermissionRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: addPermission"); - - } - - @Override - public void updatePermission(UpdatePermissionRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: updatePermission"); - - } - - @Override - public void removePermission(RemovePermissionRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: removePermission"); - - } - - @Override - public void removeQueryResultListener(IEventCallback callback, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: removeQueryResultListener"); - - } - - @Override - public void controlProgress(ControlProgressRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: controlProgress"); - - } - - @Override - public void changeResourceParents(ChangeResourceParentsRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: changeResourceParents"); - - } - - @Override - public DriveServiceResponse streamContents(StreamContentsRequest request, IDriveServiceCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: streamContents"); - return null; - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/feedback/FeedbackService.java b/play-services-core/src/main/java/org/microg/gms/feedback/FeedbackService.java deleted file mode 100644 index 403240ae..00000000 --- a/play-services-core/src/main/java/org/microg/gms/feedback/FeedbackService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.GmsService; - -public class FeedbackService extends BaseService { - public FeedbackService() { - super("GmsFeedbackSvc", GmsService.FEEDBACK); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) { - // TODO - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/games/GamesStubService.java b/play-services-core/src/main/java/org/microg/gms/games/GamesStubService.java deleted file mode 100644 index 8a881387..00000000 --- a/play-services-core/src/main/java/org/microg/gms/games/GamesStubService.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.games; - -import android.app.PendingIntent; -import android.content.Intent; -import android.os.Bundle; -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; - -import org.microg.gms.BaseService; -import org.microg.gms.common.GmsService; - -import static android.app.PendingIntent.FLAG_UPDATE_CURRENT; -import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME; -import static org.microg.gms.games.UpgradeActivity.ACTION_PLAY_GAMES_UPGRADE; -import static org.microg.gms.games.UpgradeActivity.EXTRA_GAME_PACACKE_NAME; - -public class GamesStubService extends BaseService { - - public static final String PARAM_GAME_PACKAGE_NAME = "com.google.android.gms.games.key.gamePackageName"; - - public GamesStubService() { - super("GmsGamesSvc", GmsService.GAMES); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { - String packageName = null; - if (request.extras != null) { - packageName = request.extras.getString(PARAM_GAME_PACKAGE_NAME); - } - if (packageName == null) packageName = GMS_PACKAGE_NAME; - Intent intent = new Intent(ACTION_PLAY_GAMES_UPGRADE); - intent.setPackage(GMS_PACKAGE_NAME); - intent.putExtra(EXTRA_GAME_PACACKE_NAME, packageName); - Bundle bundle = new Bundle(); - bundle.putParcelable("pendingIntent", PendingIntent.getActivity(this, packageName.hashCode(), intent, FLAG_UPDATE_CURRENT)); - callback.onPostInitComplete(CommonStatusCodes.RESOLUTION_REQUIRED, null, bundle); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/games/UpgradeActivity.java b/play-services-core/src/main/java/org/microg/gms/games/UpgradeActivity.java deleted file mode 100644 index ee4f3bd8..00000000 --- a/play-services-core/src/main/java/org/microg/gms/games/UpgradeActivity.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.games; - -import android.app.Activity; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.graphics.drawable.Drawable; -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.view.WindowManager; -import android.widget.ImageView; -import android.widget.TextView; - -import com.mgoogle.android.gms.R; - -public class UpgradeActivity extends Activity { - public static final String ACTION_PLAY_GAMES_UPGRADE = "com.google.android.gms.games.PLAY_GAMES_UPGRADE"; - public static final String EXTRA_GAME_PACACKE_NAME = "com.google.android.gms.games.GAME_PACKAGE_NAME"; - - private static final String TAG = "GmsUpgActivity"; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.games_info); - - WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); - lp.copyFrom(getWindow().getAttributes()); - lp.width = WindowManager.LayoutParams.MATCH_PARENT; - lp.height = WindowManager.LayoutParams.WRAP_CONTENT; - getWindow().setAttributes(lp); - - String packageName = getIntent().getStringExtra(EXTRA_GAME_PACACKE_NAME); - - // receive package info - PackageManager packageManager = getPackageManager(); - ApplicationInfo applicationInfo; - try { - applicationInfo = packageManager.getApplicationInfo(packageName, 0); - } catch (PackageManager.NameNotFoundException e) { - Log.w(TAG, e); - finish(); - return; - } - CharSequence appLabel = packageManager.getApplicationLabel(applicationInfo); - Drawable appIcon = packageManager.getApplicationIcon(applicationInfo); - - ((ImageView) findViewById(R.id.app_icon)).setImageDrawable(appIcon); - ((TextView) findViewById(R.id.title)).setText(getString(R.string.games_info_title, appLabel)); - findViewById(android.R.id.button1).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/measurement/MeasurementBrokerService.java b/play-services-core/src/main/java/org/microg/gms/measurement/MeasurementBrokerService.java deleted file mode 100644 index 4cd9a0f8..00000000 --- a/play-services-core/src/main/java/org/microg/gms/measurement/MeasurementBrokerService.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2018 microG 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.measurement; - -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.common.api.CommonStatusCodes; -import com.google.android.gms.common.api.Status; -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.GmsService; - -public class MeasurementBrokerService extends BaseService { - public MeasurementBrokerService() { - super("GmsMeasureBrokerSvc", GmsService.MEASUREMENT); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { - callback.onPostInitComplete(CommonStatusCodes.SUCCESS, new MeasurementServiceImpl().asBinder(), null); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/measurement/MeasurementServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/measurement/MeasurementServiceImpl.java deleted file mode 100644 index c78851b0..00000000 --- a/play-services-core/src/main/java/org/microg/gms/measurement/MeasurementServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2018 microG 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.measurement; - -import android.os.Parcel; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.measurement.internal.IMeasurementService; - -public class MeasurementServiceImpl extends IMeasurementService.Stub { - private static final String TAG = "GmsMeasureSvcImpl"; - - @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; - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/places/GeoDataService.java b/play-services-core/src/main/java/org/microg/gms/places/GeoDataService.java deleted file mode 100644 index 43a6a84d..00000000 --- a/play-services-core/src/main/java/org/microg/gms/places/GeoDataService.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.places; - -import android.os.RemoteException; - -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.GmsService; - -public class GeoDataService extends BaseService { - public GeoDataService() { - super("GmsPlcGeoSvc", GmsService.GEODATA); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { - callback.onPostInitComplete(0, new PlacesServiceImpl().asBinder(), null); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/places/PlaceDetectionService.java b/play-services-core/src/main/java/org/microg/gms/places/PlaceDetectionService.java deleted file mode 100644 index 761d5a9f..00000000 --- a/play-services-core/src/main/java/org/microg/gms/places/PlaceDetectionService.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.places; - -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.BaseService; -import org.microg.gms.common.GmsService; - -public class PlaceDetectionService extends BaseService { - public PlaceDetectionService() { - super("GmsPlcDtctSvc", GmsService.PLACE_DETECTION); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { - callback.onPostInitComplete(0, new PlaceDetectionServiceImpl().asBinder(), null); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/places/PlaceDetectionServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/places/PlaceDetectionServiceImpl.java deleted file mode 100644 index e1c22a27..00000000 --- a/play-services-core/src/main/java/org/microg/gms/places/PlaceDetectionServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.places; - -import android.os.Parcel; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.location.places.internal.IGooglePlaceDetectionService; - -public class PlaceDetectionServiceImpl extends IGooglePlaceDetectionService.Stub{ - private static final String TAG = "GmsPlcDtctSvcImpl"; - - @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; - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/places/PlacesServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/places/PlacesServiceImpl.java deleted file mode 100644 index c417ac42..00000000 --- a/play-services-core/src/main/java/org/microg/gms/places/PlacesServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.places; - -import android.os.Parcel; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.location.places.internal.IGooglePlacesService; - -public class PlacesServiceImpl extends IGooglePlacesService.Stub { - private static final String TAG = "GmsPlcSvcImpl"; - - @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; - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/plus/PlusOneButtonImpl.java b/play-services-core/src/main/java/org/microg/gms/plus/PlusOneButtonImpl.java deleted file mode 100644 index 9b2df0d7..00000000 --- a/play-services-core/src/main/java/org/microg/gms/plus/PlusOneButtonImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.plus; - -import android.content.Context; -import android.view.View; - -public class PlusOneButtonImpl extends View { - public PlusOneButtonImpl(Context context, int size, int annotation, String url, - String account) { - super(context); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/reminders/RemindersService.java b/play-services-core/src/main/java/org/microg/gms/reminders/RemindersService.java deleted file mode 100644 index 165ceb35..00000000 --- a/play-services-core/src/main/java/org/microg/gms/reminders/RemindersService.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.reminders; - -import android.os.RemoteException; - -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.GmsService; - -public class RemindersService extends BaseService { - - public RemindersService() { - super("GmsRemindSvc", GmsService.REMINDERS); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { - callback.onPostInitComplete(0, new RemindersServiceImpl(), null); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/reminders/RemindersServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/reminders/RemindersServiceImpl.java deleted file mode 100644 index aacd5e54..00000000 --- a/play-services-core/src/main/java/org/microg/gms/reminders/RemindersServiceImpl.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.reminders; - -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.reminders.AccountState; -import com.google.android.gms.reminders.CreateReminderOptionsInternal; -import com.google.android.gms.reminders.LoadRemindersOptions; -import com.google.android.gms.reminders.ReindexDueDatesOptions; -import com.google.android.gms.reminders.UpdateRecurrenceOptions; -import com.google.android.gms.reminders.internal.IRemindersCallbacks; -import com.google.android.gms.reminders.internal.IRemindersService; -import com.google.android.gms.reminders.model.CustomizedSnoozePresetEntity; -import com.google.android.gms.reminders.model.TaskEntity; -import com.google.android.gms.reminders.model.TaskIdEntity; - -import java.util.List; - -public class RemindersServiceImpl extends IRemindersService.Stub { - private static final String TAG = RemindersServiceImpl.class.getSimpleName(); - - @Override - public void loadReminders(IRemindersCallbacks callbacks, LoadRemindersOptions options) throws RemoteException { - Log.d(TAG, "unimplemented Method: loadReminders"); - - } - - @Override - public void addListener(IRemindersCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: addListener"); - - } - - @Override - public void createReminder(IRemindersCallbacks callbacks, TaskEntity task) throws RemoteException { - Log.d(TAG, "unimplemented Method: createReminder"); - - } - - @Override - public void updateReminder(IRemindersCallbacks callbacks, TaskEntity task) throws RemoteException { - Log.d(TAG, "unimplemented Method: updateReminder"); - - } - - @Override - public void deleteReminder(IRemindersCallbacks callbacks, TaskIdEntity taskId) throws RemoteException { - Log.d(TAG, "unimplemented Method: deleteReminder"); - - } - - @Override - public void bumpReminder(IRemindersCallbacks callbacks, TaskIdEntity taskId) throws RemoteException { - Log.d(TAG, "unimplemented Method: bumpReminder"); - - } - - @Override - public void hasUpcomingReminders(IRemindersCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: hasUpcomingReminders"); - - } - - @Override - public void createRecurrence(IRemindersCallbacks callbacks, TaskEntity task) throws RemoteException { - Log.d(TAG, "unimplemented Method: createRecurrence"); - - } - - @Override - public void updateRecurrence(IRemindersCallbacks callbacks, String s1, TaskEntity task, UpdateRecurrenceOptions options) throws RemoteException { - Log.d(TAG, "unimplemented Method: updateRecurrence"); - - } - - @Override - public void deleteRecurrence(IRemindersCallbacks callbacks, String s1, UpdateRecurrenceOptions options) throws RemoteException { - Log.d(TAG, "unimplemented Method: deleteRecurrence"); - - } - - @Override - public void changeRecurrence(IRemindersCallbacks callbacks, String s1, TaskEntity task, UpdateRecurrenceOptions options) throws RemoteException { - Log.d(TAG, "unimplemented Method: changeRecurrence"); - - } - - @Override - public void makeTaskRecurring(IRemindersCallbacks callbacks, TaskEntity task) throws RemoteException { - Log.d(TAG, "unimplemented Method: makeTaskRecurring"); - - } - - @Override - public void makeRecurrenceSingleInstance(IRemindersCallbacks callbacks, String s1, TaskEntity task, UpdateRecurrenceOptions options) throws RemoteException { - Log.d(TAG, "unimplemented Method: makeRecurrenceSingleInstance"); - - } - - @Override - public void clearListeners() throws RemoteException { - Log.d(TAG, "unimplemented Method: clearListeners"); - - } - - @Override - public void batchUpdateReminders(IRemindersCallbacks callbacks, List tasks) throws RemoteException { - Log.d(TAG, "unimplemented Method: batchUpdateReminders"); - - } - - @Override - public void createReminderWithOptions(IRemindersCallbacks callbacks, TaskEntity task, CreateReminderOptionsInternal options) throws RemoteException { - Log.d(TAG, "unimplemented Method: createReminderWithOptions"); - - } - - @Override - public void getCustomizedSnoozePreset(IRemindersCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: getCustomizedSnoozePreset"); - - } - - @Override - public void setCustomizedSnoozePreset(IRemindersCallbacks callbacks, CustomizedSnoozePresetEntity preset) throws RemoteException { - Log.d(TAG, "unimplemented Method: setCustomizedSnoozePreset"); - - } - - @Override - public void setAccountState(IRemindersCallbacks callbacks, AccountState accountState) throws RemoteException { - Log.d(TAG, "unimplemented Method: setAccountState"); - - } - - @Override - public void getAccountState(IRemindersCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: getAccountState"); - - } - - @Override - public void checkReindexDueDatesNeeded(IRemindersCallbacks callbacks, ReindexDueDatesOptions options) throws RemoteException { - Log.d(TAG, "unimplemented Method: checkReindexDueDatesNeeded"); - - } - - @Override - public void reindexDueDates(IRemindersCallbacks callbacks, ReindexDueDatesOptions options) throws RemoteException { - Log.d(TAG, "unimplemented Method: reindexDueDates"); - - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/tapandpay/TapAndPayImpl.java b/play-services-core/src/main/java/org/microg/gms/tapandpay/TapAndPayImpl.java deleted file mode 100644 index 40632650..00000000 --- a/play-services-core/src/main/java/org/microg/gms/tapandpay/TapAndPayImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2019 microG 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.tapandpay; - -import com.google.android.gms.tapandpay.internal.ITapAndPayService; -import android.os.Parcel; -import android.os.RemoteException; -import android.util.Log; - -public class TapAndPayImpl extends ITapAndPayService.Stub { - private static final String TAG = "GmsTapAndPayImpl"; - - @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; - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/tapandpay/TapAndPayService.java b/play-services-core/src/main/java/org/microg/gms/tapandpay/TapAndPayService.java deleted file mode 100644 index 082234e6..00000000 --- a/play-services-core/src/main/java/org/microg/gms/tapandpay/TapAndPayService.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2019 microG 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.tapandpay; - -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; - -import org.microg.gms.BaseService; -import org.microg.gms.common.GmsService; - -public class TapAndPayService extends BaseService { - public TapAndPayService() { - super("GmsTapAndPaySvc", GmsService.TAP_AND_PAY); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { - callback.onPostInitComplete(CommonStatusCodes.SUCCESS, new TapAndPayImpl(), null); - - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/ui/SelfCheckFragment.java b/play-services-core/src/main/java/org/microg/gms/ui/SelfCheckFragment.java index 4a8e3a84..1f4f7f02 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/SelfCheckFragment.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/SelfCheckFragment.java @@ -23,11 +23,9 @@ import android.view.LayoutInflater; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import org.microg.tools.selfcheck.InstalledPackagesChecks; //import org.microg.tools.selfcheck.NlpOsCompatChecks; //import org.microg.tools.selfcheck.NlpStatusChecks; import org.microg.tools.selfcheck.PermissionCheckGroup; -import org.microg.tools.selfcheck.RomSpoofSignatureChecks; import org.microg.tools.selfcheck.SelfCheckGroup; import org.microg.tools.selfcheck.SystemChecks; import org.microg.tools.ui.AbstractSelfCheckFragment; @@ -46,8 +44,6 @@ public class SelfCheckFragment extends AbstractSelfCheckFragment { @Override protected void prepareSelfCheckList(List checks) { - checks.add(new RomSpoofSignatureChecks()); - checks.add(new InstalledPackagesChecks()); if (SDK_INT > LOLLIPOP_MR1) { checks.add(new PermissionCheckGroup(ACCESS_COARSE_LOCATION, "android.permission.ACCESS_BACKGROUND_LOCATION", WRITE_EXTERNAL_STORAGE, GET_ACCOUNTS, READ_PHONE_STATE)); } diff --git a/play-services-core/src/main/java/org/microg/gms/wallet/OwServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/wallet/OwServiceImpl.java deleted file mode 100644 index ad38eb08..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wallet/OwServiceImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.wallet; - -import android.content.Context; -import android.os.Parcel; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.wallet.internal.IOwService; - -public class OwServiceImpl extends IOwService.Stub { - private static final String TAG = "GmsWalletOwSvc"; - - public OwServiceImpl(Context context) { - } - - @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; - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/wallet/PaymentService.java b/play-services-core/src/main/java/org/microg/gms/wallet/PaymentService.java deleted file mode 100644 index e2401def..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wallet/PaymentService.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.wallet; - -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.BaseService; -import org.microg.gms.common.GmsService; - -public class PaymentService extends BaseService { - public PaymentService() { - super("GmsWalletPaySvc", GmsService.WALLET); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { - callback.onPostInitComplete(0, new OwServiceImpl(this), null); - } -} diff --git a/play-services-core/src/main/java/org/microg/tools/selfcheck/InstalledPackagesChecks.java b/play-services-core/src/main/java/org/microg/tools/selfcheck/InstalledPackagesChecks.java deleted file mode 100644 index e7927a2f..00000000 --- a/play-services-core/src/main/java/org/microg/tools/selfcheck/InstalledPackagesChecks.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.tools.selfcheck; - -import android.content.Context; -import android.content.pm.PackageManager; - -import com.mgoogle.android.gms.R; - -import org.microg.gms.common.Constants; -import org.microg.gms.common.PackageUtils; - -import static org.microg.tools.selfcheck.SelfCheckGroup.Result.Negative; -import static org.microg.tools.selfcheck.SelfCheckGroup.Result.Positive; - -public class InstalledPackagesChecks implements SelfCheckGroup { - - @Override - public String getGroupName(Context context) { - return context.getString(R.string.self_check_cat_gms_packages); - } - - @Override - public void doChecks(Context context, ResultCollector collector) { - addPackageInstalledAndSignedResult(context, collector, context.getString(R.string.self_check_pkg_gms), Constants.GMS_PACKAGE_NAME, Constants.GMS_PACKAGE_SIGNATURE_SHA1); - addPackageInstalledAndSignedResult(context, collector, context.getString(R.string.self_check_pkg_vending), "com.android.vending", Constants.GMS_PACKAGE_SIGNATURE_SHA1); - addPackageInstalledResult(context, collector, context.getString(R.string.self_check_pkg_gsf), Constants.GSF_PACKAGE_NAME); - } - - private void addPackageInstalledAndSignedResult(Context context, ResultCollector collector, String nicePackageName, String androidPackageName, String signatureHash) { - if (addPackageInstalledResult(context, collector, nicePackageName, androidPackageName)) { - addPackageSignedResult(context, collector, nicePackageName, androidPackageName, signatureHash); - } - } - - private boolean addPackageSignedResult(Context context, ResultCollector collector, String nicePackageName, String androidPackageName, String signatureHash) { - boolean hashMatches = signatureHash.equals(PackageUtils.firstSignatureDigest(context, androidPackageName)); - collector.addResult(context.getString(R.string.self_check_name_correct_sig, nicePackageName), hashMatches ? Positive : Negative, - context.getString(R.string.self_check_resolution_correct_sig, nicePackageName)); - return hashMatches; - } - - private boolean addPackageInstalledResult(Context context, ResultCollector collector, String nicePackageName, String androidPackageName) { - boolean packageExists = true; - try { - context.getPackageManager().getPackageInfo(androidPackageName, 0); - } catch (PackageManager.NameNotFoundException e) { - packageExists = false; - } - collector.addResult(context.getString(R.string.self_check_name_app_installed, nicePackageName), packageExists ? Positive : Negative, - context.getString(R.string.self_check_resolution_app_installed, nicePackageName)); - return packageExists; - } -} diff --git a/play-services-core/src/main/java/org/microg/tools/selfcheck/RomSpoofSignatureChecks.java b/play-services-core/src/main/java/org/microg/tools/selfcheck/RomSpoofSignatureChecks.java deleted file mode 100644 index b81a0c4d..00000000 --- a/play-services-core/src/main/java/org/microg/tools/selfcheck/RomSpoofSignatureChecks.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.tools.selfcheck; - -import android.content.Context; -import android.content.pm.PackageManager; - -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; - -import com.mgoogle.android.gms.R; - -import org.microg.gms.common.Constants; -import org.microg.gms.common.PackageUtils; - -import static android.content.pm.PackageManager.PERMISSION_GRANTED; -import static org.microg.gms.common.Constants.GMS_PACKAGE_SIGNATURE_SHA1; -import static org.microg.tools.selfcheck.SelfCheckGroup.Result.Negative; -import static org.microg.tools.selfcheck.SelfCheckGroup.Result.Positive; -import static org.microg.tools.selfcheck.SelfCheckGroup.Result.Unknown; - -public class RomSpoofSignatureChecks implements SelfCheckGroup { - - public static final String FAKE_SIGNATURE_PERMISSION = "android.permission.FAKE_PACKAGE_SIGNATURE"; - - @Override - public String getGroupName(Context context) { - return context.getString(R.string.self_check_cat_fake_sig); - } - - @Override - public void doChecks(Context context, ResultCollector collector) { - boolean hasPermission = addRomKnowsFakeSignaturePermission(context, collector); - if (hasPermission) { - addSystemGrantsFakeSignaturePermission(context, collector); - } - addSystemSpoofsSignature(context, collector); - } - - private boolean addRomKnowsFakeSignaturePermission(Context context, ResultCollector collector) { - boolean knowsPermission = true; - try { - context.getPackageManager().getPermissionInfo(FAKE_SIGNATURE_PERMISSION, 0); - } catch (PackageManager.NameNotFoundException e) { - knowsPermission = false; - } - collector.addResult(context.getString(R.string.self_check_name_fake_sig_perm), knowsPermission ? Positive : Unknown, - context.getString(R.string.self_check_resolution_fake_sig_perm)); - return knowsPermission; - } - - private boolean addSystemGrantsFakeSignaturePermission(Context context, ResultCollector collector) { - boolean grantsPermission = ContextCompat.checkSelfPermission(context, FAKE_SIGNATURE_PERMISSION) == PERMISSION_GRANTED; - collector.addResult(context.getString(R.string.self_check_name_perm_granted), grantsPermission ? Positive : Negative, - context.getString(R.string.self_check_resolution_perm_granted), new CheckResolver() { - @Override - public void tryResolve(Fragment fragment) { - fragment.requestPermissions(new String[]{FAKE_SIGNATURE_PERMISSION}, 0); - } - }); - return grantsPermission; - } - - private boolean addSystemSpoofsSignature(Context context, ResultCollector collector) { - boolean spoofsSignature = GMS_PACKAGE_SIGNATURE_SHA1.equals(PackageUtils.firstSignatureDigest(context, Constants.GMS_PACKAGE_NAME)); - collector.addResult(context.getString(R.string.self_check_name_system_spoofs), spoofsSignature ? Positive : Negative, - context.getString(R.string.self_check_resolution_system_spoofs)); - return spoofsSignature; - } -} diff --git a/play-services-core/src/main/protos-java/org/microg/gms/snet/AttestRequest.java b/play-services-core/src/main/protos-java/org/microg/gms/snet/AttestRequest.java deleted file mode 100644 index ed0265e2..00000000 --- a/play-services-core/src/main/protos-java/org/microg/gms/snet/AttestRequest.java +++ /dev/null @@ -1,83 +0,0 @@ -// Code generated by Wire protocol buffer compiler, do not edit. -// Source file: protos-repo/snet.proto -package org.microg.gms.snet; - -import com.squareup.wire.Message; -import com.squareup.wire.ProtoField; -import okio.ByteString; - -import static com.squareup.wire.Message.Datatype.BYTES; -import static com.squareup.wire.Message.Datatype.STRING; - -public final class AttestRequest extends Message { - - public static final ByteString DEFAULT_SAFETYNETDATA = ByteString.EMPTY; - public static final String DEFAULT_DROIDGUARDRESULT = ""; - - @ProtoField(tag = 1, type = BYTES) - public final ByteString safetyNetData; - - @ProtoField(tag = 2, type = STRING) - public final String droidGuardResult; - - public AttestRequest(ByteString safetyNetData, String droidGuardResult) { - this.safetyNetData = safetyNetData; - this.droidGuardResult = droidGuardResult; - } - - private AttestRequest(Builder builder) { - this(builder.safetyNetData, builder.droidGuardResult); - setBuilder(builder); - } - - @Override - public boolean equals(Object other) { - if (other == this) return true; - if (!(other instanceof AttestRequest)) return false; - AttestRequest o = (AttestRequest) other; - return equals(safetyNetData, o.safetyNetData) - && equals(droidGuardResult, o.droidGuardResult); - } - - @Override - public int hashCode() { - int result = hashCode; - if (result == 0) { - result = safetyNetData != null ? safetyNetData.hashCode() : 0; - result = result * 37 + (droidGuardResult != null ? droidGuardResult.hashCode() : 0); - hashCode = result; - } - return result; - } - - public static final class Builder extends Message.Builder { - - public ByteString safetyNetData; - public String droidGuardResult; - - public Builder() { - } - - public Builder(AttestRequest message) { - super(message); - if (message == null) return; - this.safetyNetData = message.safetyNetData; - this.droidGuardResult = message.droidGuardResult; - } - - public Builder safetyNetData(ByteString safetyNetData) { - this.safetyNetData = safetyNetData; - return this; - } - - public Builder droidGuardResult(String droidGuardResult) { - this.droidGuardResult = droidGuardResult; - return this; - } - - @Override - public AttestRequest build() { - return new AttestRequest(this); - } - } -} diff --git a/play-services-core/src/main/protos-java/org/microg/gms/snet/AttestResponse.java b/play-services-core/src/main/protos-java/org/microg/gms/snet/AttestResponse.java deleted file mode 100644 index 291d0bc7..00000000 --- a/play-services-core/src/main/protos-java/org/microg/gms/snet/AttestResponse.java +++ /dev/null @@ -1,62 +0,0 @@ -// Code generated by Wire protocol buffer compiler, do not edit. -// Source file: protos-repo/snet.proto -package org.microg.gms.snet; - -import com.squareup.wire.Message; -import com.squareup.wire.ProtoField; - -import static com.squareup.wire.Message.Datatype.STRING; - -public final class AttestResponse extends Message { - - public static final String DEFAULT_RESULT = ""; - - @ProtoField(tag = 2, type = STRING) - public final String result; - - public AttestResponse(String result) { - this.result = result; - } - - private AttestResponse(Builder builder) { - this(builder.result); - setBuilder(builder); - } - - @Override - public boolean equals(Object other) { - if (other == this) return true; - if (!(other instanceof AttestResponse)) return false; - return equals(result, ((AttestResponse) other).result); - } - - @Override - public int hashCode() { - int result = hashCode; - return result != 0 ? result : (hashCode = this.result != null ? this.result.hashCode() : 0); - } - - public static final class Builder extends Message.Builder { - - public String result; - - public Builder() { - } - - public Builder(AttestResponse message) { - super(message); - if (message == null) return; - this.result = message.result; - } - - public Builder result(String result) { - this.result = result; - return this; - } - - @Override - public AttestResponse build() { - return new AttestResponse(this); - } - } -} diff --git a/play-services-core/src/main/protos-java/org/microg/gms/snet/FileState.java b/play-services-core/src/main/protos-java/org/microg/gms/snet/FileState.java deleted file mode 100644 index 8b47309d..00000000 --- a/play-services-core/src/main/protos-java/org/microg/gms/snet/FileState.java +++ /dev/null @@ -1,83 +0,0 @@ -// Code generated by Wire protocol buffer compiler, do not edit. -// Source file: protos-repo/snet.proto -package org.microg.gms.snet; - -import com.squareup.wire.Message; -import com.squareup.wire.ProtoField; -import okio.ByteString; - -import static com.squareup.wire.Message.Datatype.BYTES; -import static com.squareup.wire.Message.Datatype.STRING; - -public final class FileState extends Message { - - public static final String DEFAULT_FILENAME = ""; - public static final ByteString DEFAULT_DIGEST = ByteString.EMPTY; - - @ProtoField(tag = 1, type = STRING) - public final String fileName; - - @ProtoField(tag = 2, type = BYTES) - public final ByteString digest; - - public FileState(String fileName, ByteString digest) { - this.fileName = fileName; - this.digest = digest; - } - - private FileState(Builder builder) { - this(builder.fileName, builder.digest); - setBuilder(builder); - } - - @Override - public boolean equals(Object other) { - if (other == this) return true; - if (!(other instanceof FileState)) return false; - FileState o = (FileState) other; - return equals(fileName, o.fileName) - && equals(digest, o.digest); - } - - @Override - public int hashCode() { - int result = hashCode; - if (result == 0) { - result = fileName != null ? fileName.hashCode() : 0; - result = result * 37 + (digest != null ? digest.hashCode() : 0); - hashCode = result; - } - return result; - } - - public static final class Builder extends Message.Builder { - - public String fileName; - public ByteString digest; - - public Builder() { - } - - public Builder(FileState message) { - super(message); - if (message == null) return; - this.fileName = message.fileName; - this.digest = message.digest; - } - - public Builder fileName(String fileName) { - this.fileName = fileName; - return this; - } - - public Builder digest(ByteString digest) { - this.digest = digest; - return this; - } - - @Override - public FileState build() { - return new FileState(this); - } - } -} diff --git a/play-services-core/src/main/protos-java/org/microg/gms/snet/SELinuxState.java b/play-services-core/src/main/protos-java/org/microg/gms/snet/SELinuxState.java deleted file mode 100644 index 7e499e2a..00000000 --- a/play-services-core/src/main/protos-java/org/microg/gms/snet/SELinuxState.java +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by Wire protocol buffer compiler, do not edit. -// Source file: protos-repo/snet.proto -package org.microg.gms.snet; - -import com.squareup.wire.Message; -import com.squareup.wire.ProtoField; - -import static com.squareup.wire.Message.Datatype.BOOL; - -public final class SELinuxState extends Message { - - public static final Boolean DEFAULT_SUPPORTED = false; - public static final Boolean DEFAULT_ENABLED = false; - - @ProtoField(tag = 1, type = BOOL) - public final Boolean supported; - - @ProtoField(tag = 2, type = BOOL) - public final Boolean enabled; - - public SELinuxState(Boolean supported, Boolean enabled) { - this.supported = supported; - this.enabled = enabled; - } - - private SELinuxState(Builder builder) { - this(builder.supported, builder.enabled); - setBuilder(builder); - } - - @Override - public boolean equals(Object other) { - if (other == this) return true; - if (!(other instanceof SELinuxState)) return false; - SELinuxState o = (SELinuxState) other; - return equals(supported, o.supported) - && equals(enabled, o.enabled); - } - - @Override - public int hashCode() { - int result = hashCode; - if (result == 0) { - result = supported != null ? supported.hashCode() : 0; - result = result * 37 + (enabled != null ? enabled.hashCode() : 0); - hashCode = result; - } - return result; - } - - public static final class Builder extends Message.Builder { - - public Boolean supported; - public Boolean enabled; - - public Builder() { - } - - public Builder(SELinuxState message) { - super(message); - if (message == null) return; - this.supported = message.supported; - this.enabled = message.enabled; - } - - public Builder supported(Boolean supported) { - this.supported = supported; - return this; - } - - public Builder enabled(Boolean enabled) { - this.enabled = enabled; - return this; - } - - @Override - public SELinuxState build() { - return new SELinuxState(this); - } - } -} diff --git a/play-services-core/src/main/protos-java/org/microg/gms/snet/SafetyNetData.java b/play-services-core/src/main/protos-java/org/microg/gms/snet/SafetyNetData.java deleted file mode 100644 index 16792b16..00000000 --- a/play-services-core/src/main/protos-java/org/microg/gms/snet/SafetyNetData.java +++ /dev/null @@ -1,186 +0,0 @@ -// Code generated by Wire protocol buffer compiler, do not edit. -// Source file: protos-repo/snet.proto -package org.microg.gms.snet; - -import com.squareup.wire.Message; -import com.squareup.wire.ProtoField; -import java.util.Collections; -import java.util.List; -import okio.ByteString; - -import static com.squareup.wire.Message.Datatype.BOOL; -import static com.squareup.wire.Message.Datatype.BYTES; -import static com.squareup.wire.Message.Datatype.INT32; -import static com.squareup.wire.Message.Datatype.INT64; -import static com.squareup.wire.Message.Datatype.STRING; -import static com.squareup.wire.Message.Label.REPEATED; - -public final class SafetyNetData extends Message { - - public static final ByteString DEFAULT_NONCE = ByteString.EMPTY; - public static final String DEFAULT_PACKAGENAME = ""; - public static final List DEFAULT_SIGNATUREDIGEST = Collections.emptyList(); - public static final ByteString DEFAULT_FILEDIGEST = ByteString.EMPTY; - public static final Integer DEFAULT_GMSVERSIONCODE = 0; - public static final List DEFAULT_SUCANDIDATES = Collections.emptyList(); - public static final Long DEFAULT_CURRENTTIMEMS = 0L; - public static final Boolean DEFAULT_GOOGLECN = false; - - @ProtoField(tag = 1, type = BYTES) - public final ByteString nonce; - - @ProtoField(tag = 2, type = STRING) - public final String packageName; - - @ProtoField(tag = 3, type = BYTES, label = REPEATED) - public final List signatureDigest; - - @ProtoField(tag = 4, type = BYTES) - public final ByteString fileDigest; - - @ProtoField(tag = 5, type = INT32) - public final Integer gmsVersionCode; - - @ProtoField(tag = 6, label = REPEATED, messageType = FileState.class) - public final List suCandidates; - - @ProtoField(tag = 7) - public final SELinuxState seLinuxState; - - @ProtoField(tag = 8, type = INT64) - public final Long currentTimeMs; - - @ProtoField(tag = 9, type = BOOL) - public final Boolean googleCn; - - public SafetyNetData(ByteString nonce, String packageName, List signatureDigest, ByteString fileDigest, Integer gmsVersionCode, List suCandidates, SELinuxState seLinuxState, Long currentTimeMs, Boolean googleCn) { - this.nonce = nonce; - this.packageName = packageName; - this.signatureDigest = immutableCopyOf(signatureDigest); - this.fileDigest = fileDigest; - this.gmsVersionCode = gmsVersionCode; - this.suCandidates = immutableCopyOf(suCandidates); - this.seLinuxState = seLinuxState; - this.currentTimeMs = currentTimeMs; - this.googleCn = googleCn; - } - - private SafetyNetData(Builder builder) { - this(builder.nonce, builder.packageName, builder.signatureDigest, builder.fileDigest, builder.gmsVersionCode, builder.suCandidates, builder.seLinuxState, builder.currentTimeMs, builder.googleCn); - setBuilder(builder); - } - - @Override - public boolean equals(Object other) { - if (other == this) return true; - if (!(other instanceof SafetyNetData)) return false; - SafetyNetData o = (SafetyNetData) other; - return equals(nonce, o.nonce) - && equals(packageName, o.packageName) - && equals(signatureDigest, o.signatureDigest) - && equals(fileDigest, o.fileDigest) - && equals(gmsVersionCode, o.gmsVersionCode) - && equals(suCandidates, o.suCandidates) - && equals(seLinuxState, o.seLinuxState) - && equals(currentTimeMs, o.currentTimeMs) - && equals(googleCn, o.googleCn); - } - - @Override - public int hashCode() { - int result = hashCode; - if (result == 0) { - result = nonce != null ? nonce.hashCode() : 0; - result = result * 37 + (packageName != null ? packageName.hashCode() : 0); - result = result * 37 + (signatureDigest != null ? signatureDigest.hashCode() : 1); - result = result * 37 + (fileDigest != null ? fileDigest.hashCode() : 0); - result = result * 37 + (gmsVersionCode != null ? gmsVersionCode.hashCode() : 0); - result = result * 37 + (suCandidates != null ? suCandidates.hashCode() : 1); - result = result * 37 + (seLinuxState != null ? seLinuxState.hashCode() : 0); - result = result * 37 + (currentTimeMs != null ? currentTimeMs.hashCode() : 0); - result = result * 37 + (googleCn != null ? googleCn.hashCode() : 0); - hashCode = result; - } - return result; - } - - public static final class Builder extends Message.Builder { - - public ByteString nonce; - public String packageName; - public List signatureDigest; - public ByteString fileDigest; - public Integer gmsVersionCode; - public List suCandidates; - public SELinuxState seLinuxState; - public Long currentTimeMs; - public Boolean googleCn; - - public Builder() { - } - - public Builder(SafetyNetData message) { - super(message); - if (message == null) return; - this.nonce = message.nonce; - this.packageName = message.packageName; - this.signatureDigest = copyOf(message.signatureDigest); - this.fileDigest = message.fileDigest; - this.gmsVersionCode = message.gmsVersionCode; - this.suCandidates = copyOf(message.suCandidates); - this.seLinuxState = message.seLinuxState; - this.currentTimeMs = message.currentTimeMs; - this.googleCn = message.googleCn; - } - - public Builder nonce(ByteString nonce) { - this.nonce = nonce; - return this; - } - - public Builder packageName(String packageName) { - this.packageName = packageName; - return this; - } - - public Builder signatureDigest(List signatureDigest) { - this.signatureDigest = checkForNulls(signatureDigest); - return this; - } - - public Builder fileDigest(ByteString fileDigest) { - this.fileDigest = fileDigest; - return this; - } - - public Builder gmsVersionCode(Integer gmsVersionCode) { - this.gmsVersionCode = gmsVersionCode; - return this; - } - - public Builder suCandidates(List suCandidates) { - this.suCandidates = checkForNulls(suCandidates); - return this; - } - - public Builder seLinuxState(SELinuxState seLinuxState) { - this.seLinuxState = seLinuxState; - return this; - } - - public Builder currentTimeMs(Long currentTimeMs) { - this.currentTimeMs = currentTimeMs; - return this; - } - - public Builder googleCn(Boolean googleCn) { - this.googleCn = googleCn; - return this; - } - - @Override - public SafetyNetData build() { - return new SafetyNetData(this); - } - } -} From dcefc8dd7b22e6f3858652f600b95277b6c205a8 Mon Sep 17 00:00:00 2001 From: Venny Date: Fri, 17 Jul 2020 17:18:39 +0200 Subject: [PATCH 6/8] Remove iid service --- play-services-api/build.gradle | 1 - play-services-iid-api/build.gradle | 37 -- play-services-iid-api/gradle.properties | 34 -- .../src/main/AndroidManifest.xml | 18 - .../android/gms/iid/IMessengerCompat.aidl | 7 - .../android/gms/iid/MessengerCompat.java | 106 ----- play-services-iid/build.gradle | 47 -- play-services-iid/gradle.properties | 34 -- .../src/main/AndroidManifest.xml | 24 - .../google/android/gms/iid/InstanceID.java | 275 ------------ .../gms/iid/InstanceIDListenerService.java | 138 ------ .../org/microg/gms/iid/InstanceIdRpc.java | 423 ------------------ .../org/microg/gms/iid/InstanceIdStore.java | 111 ----- settings.gradle | 1 - 14 files changed, 1256 deletions(-) delete mode 100644 play-services-iid-api/build.gradle delete mode 100644 play-services-iid-api/gradle.properties delete mode 100644 play-services-iid-api/src/main/AndroidManifest.xml delete mode 100644 play-services-iid-api/src/main/aidl/com/google/android/gms/iid/IMessengerCompat.aidl delete mode 100644 play-services-iid-api/src/main/java/com/google/android/gms/iid/MessengerCompat.java delete mode 100644 play-services-iid/build.gradle delete mode 100644 play-services-iid/gradle.properties delete mode 100644 play-services-iid/src/main/AndroidManifest.xml delete mode 100644 play-services-iid/src/main/java/com/google/android/gms/iid/InstanceID.java delete mode 100644 play-services-iid/src/main/java/com/google/android/gms/iid/InstanceIDListenerService.java delete mode 100644 play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java delete mode 100644 play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdStore.java diff --git a/play-services-api/build.gradle b/play-services-api/build.gradle index 5e627850..7f07c63c 100644 --- a/play-services-api/build.gradle +++ b/play-services-api/build.gradle @@ -36,5 +36,4 @@ dependencies { api project(':play-services-basement') api project(':play-services-cast-api') api project(':play-services-cast-framework-api') - api project(':play-services-iid-api') } diff --git a/play-services-iid-api/build.gradle b/play-services-iid-api/build.gradle deleted file mode 100644 index 7d1eb81f..00000000 --- a/play-services-iid-api/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2013-2015 microG 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. - */ - -apply plugin: 'com.android.library' - -android { - compileSdkVersion androidCompileSdk - buildToolsVersion "$androidBuildVersionTools" - - defaultConfig { - versionName version - minSdkVersion androidMinSdk - targetSdkVersion androidTargetSdk - } - - compileOptions { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - } -} - -dependencies { - api project(':play-services-basement') -} diff --git a/play-services-iid-api/gradle.properties b/play-services-iid-api/gradle.properties deleted file mode 100644 index d54aab99..00000000 --- a/play-services-iid-api/gradle.properties +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright 2013-2016 microG 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. -# - -POM_NAME=Play Services Internal IID API -POM_DESCRIPTION=Interfaces and objects for IPC between Play Services Library and Play Services Core - -POM_PACKAGING=aar - -POM_URL=https://github.com/microg/android_external_GmsApi - -POM_SCM_URL=https://github.com/microg/android_external_GmsApi -POM_SCM_CONNECTION=scm:git@github.com:microg/android_external_GmsApi.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:microg/android_external_GmsApi.git - -POM_LICENCE_NAME=The Apache Software License, Version 2.0 -POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt -POM_LICENCE_DIST=repo - -POM_DEVELOPER_ID=mar-v-in -POM_DEVELOPER_NAME=Marvin W - diff --git a/play-services-iid-api/src/main/AndroidManifest.xml b/play-services-iid-api/src/main/AndroidManifest.xml deleted file mode 100644 index e979258e..00000000 --- a/play-services-iid-api/src/main/AndroidManifest.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - \ No newline at end of file diff --git a/play-services-iid-api/src/main/aidl/com/google/android/gms/iid/IMessengerCompat.aidl b/play-services-iid-api/src/main/aidl/com/google/android/gms/iid/IMessengerCompat.aidl deleted file mode 100644 index 3ebf38c1..00000000 --- a/play-services-iid-api/src/main/aidl/com/google/android/gms/iid/IMessengerCompat.aidl +++ /dev/null @@ -1,7 +0,0 @@ -package com.google.android.gms.iid; - -import android.os.Message; - -interface IMessengerCompat { - void send(in Message message); -} diff --git a/play-services-iid-api/src/main/java/com/google/android/gms/iid/MessengerCompat.java b/play-services-iid-api/src/main/java/com/google/android/gms/iid/MessengerCompat.java deleted file mode 100644 index 05bf4c8c..00000000 --- a/play-services-iid-api/src/main/java/com/google/android/gms/iid/MessengerCompat.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.iid; - -import android.os.Binder; -import android.os.Handler; -import android.os.IBinder; -import android.os.Message; -import android.os.Messenger; -import android.os.Parcel; -import android.os.Parcelable; -import android.os.RemoteException; - -import static android.os.Build.VERSION.SDK_INT; -import static android.os.Build.VERSION_CODES.LOLLIPOP; - -public class MessengerCompat implements Parcelable { - private Messenger messenger; - private IMessengerCompat messengerCompat; - - public MessengerCompat(IBinder binder) { - if (SDK_INT >= LOLLIPOP) { - messenger = new Messenger(binder); - } else { - messengerCompat = IMessengerCompat.Stub.asInterface(binder); - } - } - - public MessengerCompat(Handler handler) { - if (SDK_INT >= LOLLIPOP) { - messenger = new Messenger(handler); - } else { - messengerCompat = new IMessengerCompatImpl(handler); - } - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public boolean equals(Object o) { - return o instanceof MessengerCompat && ((MessengerCompat) o).getBinder().equals(getBinder()); - } - - public IBinder getBinder() { - return messenger != null ? messenger.getBinder() : messengerCompat.asBinder(); - } - - @Override - public int hashCode() { - return getBinder().hashCode(); - } - - public void send(Message message) throws RemoteException { - if (messenger != null) messenger.send(message); - else messengerCompat.send(message); - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeStrongBinder(getBinder()); - } - - public static final Creator CREATOR = new Creator() { - @Override - public MessengerCompat createFromParcel(Parcel source) { - IBinder binder = source.readStrongBinder(); - return binder != null ? new MessengerCompat(binder) : null; - } - - @Override - public MessengerCompat[] newArray(int size) { - return new MessengerCompat[size]; - } - }; - - private static class IMessengerCompatImpl extends IMessengerCompat.Stub { - private final Handler handler; - - public IMessengerCompatImpl(Handler handler) { - this.handler = handler; - } - - @Override - public void send(Message message) throws RemoteException { - message.arg2 = Binder.getCallingUid(); - handler.dispatchMessage(message); - } - } -} diff --git a/play-services-iid/build.gradle b/play-services-iid/build.gradle deleted file mode 100644 index c8960415..00000000 --- a/play-services-iid/build.gradle +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2013-2015 microG 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. - */ - -apply plugin: 'com.android.library' - -String getMyVersionName() { - def stdout = new ByteArrayOutputStream() - if (rootProject.file("gradlew").exists()) - exec { commandLine 'git', 'describe', '--tags', '--always', '--dirty'; standardOutput = stdout } - else // automatic build system, don't tag dirty - exec { commandLine 'git', 'describe', '--tags', '--always'; standardOutput = stdout } - return stdout.toString().trim().substring(1) -} - -android { - compileSdkVersion androidCompileSdk() - buildToolsVersion "$androidBuildVersionTools" - - defaultConfig { - versionName getMyVersionName() - minSdkVersion androidMinSdk() - targetSdkVersion androidTargetSdk() - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -dependencies { - api project(':play-services-base') - api project(':play-services-iid-api') -} diff --git a/play-services-iid/gradle.properties b/play-services-iid/gradle.properties deleted file mode 100644 index 2e179864..00000000 --- a/play-services-iid/gradle.properties +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright 2013-2016 microG 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. -# - -POM_NAME=Play Services IID Library -POM_DESCRIPTION=The Play Services Library module to access the InstanceID API - -POM_PACKAGING=aar - -POM_URL=https://github.com/microg/android_external_GmsLib - -POM_SCM_URL=https://github.com/microg/android_external_GmsLib -POM_SCM_CONNECTION=scm:git@github.com:microg/android_external_GmsLib.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:microg/android_external_GmsLib.git - -POM_LICENCE_NAME=The Apache Software License, Version 2.0 -POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt -POM_LICENCE_DIST=repo - -POM_DEVELOPER_ID=mar-v-in -POM_DEVELOPER_NAME=Marvin W - diff --git a/play-services-iid/src/main/AndroidManifest.xml b/play-services-iid/src/main/AndroidManifest.xml deleted file mode 100644 index 67377ff0..00000000 --- a/play-services-iid/src/main/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - diff --git a/play-services-iid/src/main/java/com/google/android/gms/iid/InstanceID.java b/play-services-iid/src/main/java/com/google/android/gms/iid/InstanceID.java deleted file mode 100644 index 8a4dbefa..00000000 --- a/play-services-iid/src/main/java/com/google/android/gms/iid/InstanceID.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.iid; - -import android.content.Context; -import android.os.Bundle; -import android.os.Looper; -import android.text.TextUtils; -import android.util.Base64; -import android.util.Log; - -import org.microg.gms.common.PublicApi; -import org.microg.gms.gcm.GcmConstants; -import org.microg.gms.iid.InstanceIdRpc; -import org.microg.gms.iid.InstanceIdStore; - -import java.io.IOException; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.HashMap; -import java.util.Map; - -import static org.microg.gms.gcm.GcmConstants.EXTRA_DELETE; -import static org.microg.gms.gcm.GcmConstants.EXTRA_SCOPE; -import static org.microg.gms.gcm.GcmConstants.EXTRA_SENDER; -import static org.microg.gms.gcm.GcmConstants.EXTRA_SUBSCIPTION; -import static org.microg.gms.gcm.GcmConstants.EXTRA_SUBTYPE; - -/** - * Instance ID provides a unique identifier for each app instance and a mechanism - * to authenticate and authorize actions (for example, sending a GCM message). - *

- * Instance ID is stable but may become invalid, if: - *

    - *
  • App deletes Instance ID
  • - *
  • Device is factory reset
  • - *
  • User uninstalls the app
  • - *
  • User clears app data
  • - *
- * If Instance ID has become invalid, the app can call {@link com.google.android.gms.iid.InstanceID#getId()} - * to request a new Instance ID. - * To prove ownership of Instance ID and to allow servers to access data or - * services associated with the app, call {@link com.google.android.gms.iid.InstanceID#getToken(java.lang.String, java.lang.String)}. - */ -@PublicApi -public class InstanceID { - /** - * Error returned when failed requests are retried too often. Use - * exponential backoff when retrying requests - */ - public static final String ERROR_BACKOFF = "RETRY_LATER"; - - /** - * Blocking methods must not be called on the main thread. - */ - public static final String ERROR_MAIN_THREAD = "MAIN_THREAD"; - - /** - * Tokens can't be generated. Only devices with Google Play are supported. - */ - public static final String ERROR_MISSING_INSTANCEID_SERVICE = "MISSING_INSTANCEID_SERVICE"; - - /** - * The device cannot read the response, or there was a server error. - * Application should retry the request later using exponential backoff - * and retry (on each subsequent failure increase delay before retrying). - */ - public static final String ERROR_SERVICE_NOT_AVAILABLE = GcmConstants.ERROR_SERVICE_NOT_AVAILABLE; - - /** - * Timeout waiting for a response. - */ - public static final String ERROR_TIMEOUT = "TIMEOUT"; - - private static final int RSA_KEY_SIZE = 2048; - private static final String TAG = "InstanceID"; - - private static InstanceIdStore storeInstance; - private static InstanceIdRpc rpc; - private static Map instances = new HashMap(); - - private final String subtype; - private KeyPair keyPair; - private long creationTime; - - private InstanceID(String subtype) { - this.subtype = subtype == null ? "" : subtype; - } - - /** - * Resets Instance ID and revokes all tokens. - * - * @throws IOException - */ - public void deleteInstanceID() throws IOException { - deleteToken("*", "*"); - creationTime = 0; - storeInstance.delete(subtype + "|"); - keyPair = null; - } - - /** - * Revokes access to a scope (action) for an entity previously - * authorized by {@link com.google.android.gms.iid.InstanceID#getToken(java.lang.String, java.lang.String)}. - *

- * Do not call this function on the main thread. - * - * @param authorizedEntity Entity that must no longer have access. - * @param scope Action that entity is no longer authorized to perform. - * @throws IOException if the request fails. - */ - public void deleteToken(String authorizedEntity, String scope) throws IOException { - deleteToken(authorizedEntity, scope, null); - } - - @PublicApi(exclude = true) - public void deleteToken(String authorizedEntity, String scope, Bundle extras) throws IOException { - if (Looper.getMainLooper() == Looper.myLooper()) throw new IOException(ERROR_MAIN_THREAD); - - storeInstance.delete(subtype, authorizedEntity, scope); - - if (extras == null) extras = new Bundle(); - extras.putString(EXTRA_SENDER, authorizedEntity); - extras.putString(EXTRA_SUBSCIPTION, authorizedEntity); - extras.putString(EXTRA_DELETE, "1"); - extras.putString("X-" + EXTRA_DELETE, "1"); - extras.putString(EXTRA_SUBTYPE, TextUtils.isEmpty(subtype) ? authorizedEntity : subtype); - extras.putString("X-" + EXTRA_SUBTYPE, TextUtils.isEmpty(subtype) ? authorizedEntity : subtype); - if (scope != null) extras.putString(EXTRA_SCOPE, scope); - - rpc.handleRegisterMessageResult(rpc.sendRegisterMessageBlocking(extras, getKeyPair())); - } - - /** - * Returns time when instance ID was created. - * - * @return Time when instance ID was created (milliseconds since Epoch). - */ - public long getCreationTime() { - if (creationTime == 0) { - String s = storeInstance.get(subtype, "cre"); - if (s != null) { - creationTime = Long.parseLong(s); - } - } - return creationTime; - } - - /** - * Returns a stable identifier that uniquely identifies the app instance. - * - * @return The identifier for the application instance. - */ - public String getId() { - return sha1KeyPair(getKeyPair()); - } - - /** - * Returns an instance of this class. - * - * @return InstanceID instance. - */ - public static InstanceID getInstance(Context context) { - String subtype = ""; - if (storeInstance == null) { - storeInstance = new InstanceIdStore(context.getApplicationContext()); - rpc = new InstanceIdRpc(context.getApplicationContext()); - } - InstanceID instance = instances.get(subtype); - if (instance == null) { - instance = new InstanceID(subtype); - instances.put(subtype, instance); - } - return instance; - } - - /** - * Returns a token that authorizes an Entity (example: cloud service) to perform - * an action on behalf of the application identified by Instance ID. - *

- * This is similar to an OAuth2 token except, it applies to the - * application instance instead of a user. - *

- * Do not call this function on the main thread. - * - * @param authorizedEntity Entity authorized by the token. - * @param scope Action authorized for authorizedEntity. - * @param extras additional parameters specific to each token scope. - * Bundle keys starting with 'GCM.' and 'GOOGLE.' are - * reserved. - * @return a token that can identify and authorize the instance of the - * application on the device. - * @throws IOException if the request fails. - */ - public String getToken(String authorizedEntity, String scope, Bundle extras) throws IOException { - if (Looper.getMainLooper() == Looper.myLooper()) throw new IOException(ERROR_MAIN_THREAD); - - throw new UnsupportedOperationException(); - } - - /** - * Returns a token that authorizes an Entity (example: cloud service) to perform - * an action on behalf of the application identified by Instance ID. - *

- * This is similar to an OAuth2 token except, it applies to the - * application instance instead of a user. - *

- * Do not call this function on the main thread. - * - * @param authorizedEntity Entity authorized by the token. - * @param scope Action authorized for authorizedEntity. - * @return a token that can identify and authorize the instance of the - * application on the device. - * @throws IOException if the request fails. - */ - public String getToken(String authorizedEntity, String scope) throws IOException { - return getToken(authorizedEntity, scope, null); - } - - @PublicApi(exclude = true) - public InstanceIdStore getStore() { - return storeInstance; - } - - @PublicApi(exclude = true) - public String requestToken(String authorizedEntity, String scope, Bundle extras) { - throw new UnsupportedOperationException(); - } - - private synchronized KeyPair getKeyPair() { - if (keyPair == null) { - keyPair = storeInstance.getKeyPair(subtype); - if (keyPair == null) { - try { - KeyPairGenerator rsaGenerator = KeyPairGenerator.getInstance("RSA"); - rsaGenerator.initialize(RSA_KEY_SIZE); - keyPair = rsaGenerator.generateKeyPair(); - creationTime = System.currentTimeMillis(); - storeInstance.put(subtype, keyPair, creationTime); - } catch (NoSuchAlgorithmException e) { - Log.w(TAG, e); - } - } - } - return keyPair; - } - - @PublicApi(exclude = true) - public static String sha1KeyPair(KeyPair keyPair) { - try { - byte[] digest = MessageDigest.getInstance("SHA1").digest(keyPair.getPublic().getEncoded()); - digest[0] = (byte) (112 + (0xF & digest[0]) & 0xFF); - return Base64.encodeToString(digest, 0, 8, Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING); - } catch (NoSuchAlgorithmException e) { - Log.w(TAG, e); - return null; - } - } -} \ No newline at end of file diff --git a/play-services-iid/src/main/java/com/google/android/gms/iid/InstanceIDListenerService.java b/play-services-iid/src/main/java/com/google/android/gms/iid/InstanceIDListenerService.java deleted file mode 100644 index a15baa0f..00000000 --- a/play-services-iid/src/main/java/com/google/android/gms/iid/InstanceIDListenerService.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.iid; - -import android.app.Service; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Handler; -import android.os.IBinder; -import android.os.Looper; -import android.os.Message; -import android.support.v4.content.WakefulBroadcastReceiver; - -import static org.microg.gms.gcm.GcmConstants.ACTION_C2DM_REGISTRATION; -import static org.microg.gms.gcm.GcmConstants.ACTION_INSTANCE_ID; -import static org.microg.gms.gcm.GcmConstants.EXTRA_FROM; -import static org.microg.gms.gcm.GcmConstants.EXTRA_GSF_INTENT; - -/** - * Base class to handle Instance ID service notifications on token - * refresh. - *

- * Any app using Instance ID or GCM must include a class extending - * InstanceIDListenerService and implement {@link com.google.android.gms.iid.InstanceIDListenerService#onTokenRefresh()}. - *

- * Include the following in the manifest: - *

- * 
- *     
- *         
- *     
- * 
- * Do not export this service. Instead, keep it private to prevent other apps - * accessing your service. - */ -public class InstanceIDListenerService extends Service { - - private BroadcastReceiver registrationReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - handleIntent(intent); - stop(); - } - }; - private MessengerCompat messengerCompat = new MessengerCompat(new Handler(Looper.getMainLooper()) { - @Override - public void handleMessage(Message msg) { - handleIntent((Intent) msg.obj); - } - }); - - private int counter = 0; - private int startId = -1; - - private void handleIntent(Intent intent) { - // TODO - } - - public IBinder onBind(Intent intent) { - if (intent != null && ACTION_INSTANCE_ID.equals(intent.getAction())) { - return messengerCompat.getBinder(); - } - return null; - } - - public void onCreate() { - IntentFilter filter = new IntentFilter(ACTION_C2DM_REGISTRATION); - filter.addCategory(getPackageName()); - registerReceiver(registrationReceiver, filter); - } - - public void onDestroy() { - unregisterReceiver(registrationReceiver); - } - - public int onStartCommand(Intent intent, int flags, int startId) { - synchronized (this) { - this.counter++; - if (startId > this.startId) this.startId = startId; - } - try { - if (intent != null) { - if (ACTION_INSTANCE_ID.equals(intent.getAction()) && intent.hasExtra(EXTRA_GSF_INTENT)) { - startService((Intent) intent.getParcelableExtra(EXTRA_GSF_INTENT)); - return START_STICKY; - } - - handleIntent(intent); - - if (intent.hasExtra(EXTRA_FROM)) - WakefulBroadcastReceiver.completeWakefulIntent(intent); - } - } finally { - stop(); - } - return START_NOT_STICKY; - } - - /** - * Called when the system determines that the tokens need to be refreshed. The application - * should call getToken() and send the tokens to all application servers. - *

- * This will not be called very frequently, it is needed for key rotation and to handle special - * cases. - *

- * The system will throttle the refresh event across all devices to avoid overloading - * application servers with token updates. - */ - public void onTokenRefresh() { - // To be overwritten - } - - private void stop() { - synchronized (this) { - counter--; - if (counter <= 0) { - stopSelf(startId); - } - } - } - -} \ No newline at end of file diff --git a/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java b/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java deleted file mode 100644 index 77f65f5e..00000000 --- a/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.iid; - -import android.app.PendingIntent; -import android.content.Context; -import android.content.Intent; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.os.Build; -import android.os.Bundle; -import android.os.ConditionVariable; -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.os.Messenger; -import android.os.Parcelable; -import android.os.RemoteException; -import android.os.SystemClock; -import android.text.TextUtils; -import android.util.Base64; -import android.util.Log; - -import com.google.android.gms.iid.InstanceID; -import com.google.android.gms.iid.MessengerCompat; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.security.GeneralSecurityException; -import java.security.KeyPair; -import java.security.PrivateKey; -import java.security.Signature; -import java.security.interfaces.RSAPrivateKey; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; - -import static android.content.pm.PackageManager.PERMISSION_GRANTED; -import static com.google.android.gms.iid.InstanceID.ERROR_BACKOFF; -import static com.google.android.gms.iid.InstanceID.ERROR_MISSING_INSTANCEID_SERVICE; -import static com.google.android.gms.iid.InstanceID.ERROR_SERVICE_NOT_AVAILABLE; -import static com.google.android.gms.iid.InstanceID.ERROR_TIMEOUT; -import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME; -import static org.microg.gms.common.Constants.GSF_PACKAGE_NAME; -import static org.microg.gms.common.Constants.MAX_REFERENCE_VERSION; -import static org.microg.gms.gcm.GcmConstants.ACTION_C2DM_REGISTER; -import static org.microg.gms.gcm.GcmConstants.ACTION_C2DM_REGISTRATION; -import static org.microg.gms.gcm.GcmConstants.ACTION_INSTANCE_ID; -import static org.microg.gms.gcm.GcmConstants.EXTRA_APP; -import static org.microg.gms.gcm.GcmConstants.EXTRA_APP_ID; -import static org.microg.gms.gcm.GcmConstants.EXTRA_APP_VERSION_CODE; -import static org.microg.gms.gcm.GcmConstants.EXTRA_APP_VERSION_NAME; -import static org.microg.gms.gcm.GcmConstants.EXTRA_CLIENT_VERSION; -import static org.microg.gms.gcm.GcmConstants.EXTRA_ERROR; -import static org.microg.gms.gcm.GcmConstants.EXTRA_GMS_VERSION; -import static org.microg.gms.gcm.GcmConstants.EXTRA_GSF_INTENT; -import static org.microg.gms.gcm.GcmConstants.EXTRA_IS_MESSENGER2; -import static org.microg.gms.gcm.GcmConstants.EXTRA_KID; -import static org.microg.gms.gcm.GcmConstants.EXTRA_MESSENGER; -import static org.microg.gms.gcm.GcmConstants.EXTRA_OS_VERSION; -import static org.microg.gms.gcm.GcmConstants.EXTRA_PUBLIC_KEY; -import static org.microg.gms.gcm.GcmConstants.EXTRA_REGISTRATION_ID; -import static org.microg.gms.gcm.GcmConstants.EXTRA_SIGNATURE; -import static org.microg.gms.gcm.GcmConstants.EXTRA_UNREGISTERED; -import static org.microg.gms.gcm.GcmConstants.EXTRA_USE_GSF; -import static org.microg.gms.gcm.GcmConstants.PERMISSION_RECEIVE; - -public class InstanceIdRpc { - private static final String TAG = "InstanceID/Rpc"; - - private static final int BLOCKING_WAIT_TIME = 30000; - - private static String iidPackageName; - private static int lastRequestId; - private static int retryCount; - private static Map blockingResponses = new HashMap(); - - private long nextAttempt; - private int interval; - private Context context; - private PendingIntent selfAuthToken; - private Messenger messenger; - private Messenger myMessenger; - private MessengerCompat messengerCompat; - - public InstanceIdRpc(Context context) { - this.context = context; - } - - public static String getIidPackageName(Context context) { - if (iidPackageName != null) { - return iidPackageName; - } - PackageManager packageManager = context.getPackageManager(); - for (ResolveInfo resolveInfo : packageManager.queryIntentServices(new Intent(ACTION_C2DM_REGISTER), 0)) { - if (packageManager.checkPermission(PERMISSION_RECEIVE, resolveInfo.serviceInfo.packageName) == PERMISSION_GRANTED) { - return iidPackageName = resolveInfo.serviceInfo.packageName; - } - } - try { - ApplicationInfo appInfo = packageManager.getApplicationInfo(GMS_PACKAGE_NAME, 0); - return iidPackageName = appInfo.packageName; - } catch (PackageManager.NameNotFoundException ignored) { - } - try { - ApplicationInfo appInfo = packageManager.getApplicationInfo(GSF_PACKAGE_NAME, 0); - return iidPackageName = appInfo.packageName; - } catch (PackageManager.NameNotFoundException ex3) { - Log.w(TAG, "Both Google Play Services and legacy GSF package are missing"); - return null; - } - } - - private static int getGmsVersionCode(final Context context) { - final PackageManager packageManager = context.getPackageManager(); - try { - return packageManager.getPackageInfo(getIidPackageName(context), 0).versionCode; - } catch (PackageManager.NameNotFoundException ex) { - return -1; - } - } - - private static int getSelfVersionCode(final Context context) { - try { - return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; - } catch (PackageManager.NameNotFoundException neverHappens) { - return 0; - } - } - - private static String getSelfVersionName(final Context context) { - try { - return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; - } catch (PackageManager.NameNotFoundException neverHappens) { - return null; - } - } - - void initialize() { - if (myMessenger != null) return; - getIidPackageName(context); - myMessenger = new Messenger(new Handler(Looper.getMainLooper()) { - @Override - public void handleMessage(Message msg) { - if (msg == null) { - return; - } - if (msg.obj instanceof Intent) { - Intent intent = (Intent) msg.obj; - intent.setExtrasClassLoader(MessengerCompat.class.getClassLoader()); - if (intent.hasExtra(EXTRA_MESSENGER)) { - Parcelable messengerCandidate = intent.getParcelableExtra(EXTRA_MESSENGER); - if (messengerCandidate instanceof MessengerCompat) { - messengerCompat = (MessengerCompat) messengerCandidate; - } else if (messengerCandidate instanceof Messenger) { - messenger = (Messenger) messengerCandidate; - } - } - handleResponseInternal(intent); - } else { - Log.w(TAG, "Dropping invalid message"); - } - } - }); - } - - public void handleResponseInternal(Intent resultIntent) { - if (resultIntent == null) return; - if (!ACTION_C2DM_REGISTRATION.equals(resultIntent.getAction()) && !ACTION_INSTANCE_ID.equals(resultIntent.getAction())) - return; - String result = resultIntent.getStringExtra(EXTRA_REGISTRATION_ID); - if (result == null) result = resultIntent.getStringExtra(EXTRA_UNREGISTERED); - if (result == null) { - handleError(resultIntent); - return; - } - retryCount = 0; - nextAttempt = 0; - interval = 0; - - String requestId = null; - if (result.startsWith("|")) { - // parse structured response - String[] split = result.split("\\|"); - if (!"ID".equals(split[1])) { - Log.w(TAG, "Unexpected structured response " + result); - } - requestId = split[2]; - if (split.length > 4) { - if ("SYNC".equals(split[3])) { - // TODO: sync - } else if("RST".equals(split[3])) { - // TODO: rst - resultIntent.removeExtra(EXTRA_REGISTRATION_ID); - return; - } - } - result = split[split.length-1]; - if (result.startsWith(":")) - result = result.substring(1); - resultIntent.putExtra(EXTRA_REGISTRATION_ID, result); - } - setResponse(requestId, resultIntent); - } - - private void handleError(Intent resultIntent) { - String error = resultIntent.getStringExtra("error"); - if (error == null) return; - String requestId = null; - if (error.startsWith("|")) { - // parse structured error message - String[] split = error.split("\\|"); - if (!"ID".equals(split[1])) { - Log.w(TAG, "Unexpected structured response " + error); - } - if (split.length > 2) { - requestId = split[2]; - error = split[3]; - if (error.startsWith(":")) - error = error.substring(1); - } else { - error = "UNKNOWN"; - } - resultIntent.putExtra("error", error); - } - setResponse(requestId, resultIntent); - long retryAfter = resultIntent.getLongExtra("Retry-After", 0); - if (retryAfter > 0) { - interval = (int) (retryAfter * 1000); - nextAttempt = SystemClock.elapsedRealtime() + interval; - Log.d(TAG, "Server requested retry delay: " + interval); - } else if (ERROR_SERVICE_NOT_AVAILABLE.equals(error) || "AUTHENTICATION_FAILED".equals(error) - && GSF_PACKAGE_NAME.equals(getIidPackageName(context))) { - retryCount++; - if (retryCount < 3) return; - if (retryCount == 3) interval = 1000 + new Random().nextInt(1000); - interval = interval * 2; - nextAttempt = SystemClock.elapsedRealtime() + interval; - Log.d(TAG, "Setting retry delay to " + interval); - } - } - - private synchronized PendingIntent getSelfAuthToken() { - if (selfAuthToken == null) { - Intent intent = new Intent(); - intent.setPackage("com.google.example.invalidpackage"); - selfAuthToken = PendingIntent.getBroadcast(context, 0, intent, 0); - } - return selfAuthToken; - } - - private static synchronized String getRequestId() { - return Integer.toString(lastRequestId++); - } - - private void sendRegisterMessage(Bundle data, KeyPair keyPair, String requestId) throws IOException { - long elapsedRealtime = SystemClock.elapsedRealtime(); - if (nextAttempt != 0 && elapsedRealtime <= nextAttempt) { - Log.w(TAG, "Had to wait for " + interval + ", that's still " + (nextAttempt - elapsedRealtime)); - throw new IOException(ERROR_BACKOFF); - } - initialize(); - if (iidPackageName == null) { - throw new IOException(ERROR_MISSING_INSTANCEID_SERVICE); - } - Intent intent = new Intent(ACTION_C2DM_REGISTER); - intent.setPackage(iidPackageName); - data.putString(EXTRA_GMS_VERSION, Integer.toString(getGmsVersionCode(context))); - data.putString(EXTRA_OS_VERSION, Integer.toString(Build.VERSION.SDK_INT)); - data.putString(EXTRA_APP_VERSION_CODE, Integer.toString(getSelfVersionCode(context))); - data.putString(EXTRA_APP_VERSION_NAME, getSelfVersionName(context)); - data.putString(EXTRA_CLIENT_VERSION, "iid-" + MAX_REFERENCE_VERSION); - data.putString(EXTRA_APP_ID, InstanceID.sha1KeyPair(keyPair)); - String pub = base64encode(keyPair.getPublic().getEncoded()); - data.putString(EXTRA_PUBLIC_KEY, pub); - data.putString(EXTRA_SIGNATURE, sign(keyPair, context.getPackageName(), pub)); - intent.putExtras(data); - intent.putExtra(EXTRA_APP, getSelfAuthToken()); - sendRequest(intent, requestId); - } - - private static String sign(KeyPair keyPair, String... payload) { - byte[] bytes; - try { - bytes = TextUtils.join("\n", payload).getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - Log.e(TAG, "Unable to encode", e); - return null; - } - PrivateKey privateKey = keyPair.getPrivate(); - try { - Signature signature = Signature.getInstance(privateKey instanceof RSAPrivateKey ? "SHA256withRSA" : "SHA256withECDSA"); - signature.initSign(privateKey); - signature.update(bytes); - return base64encode(signature.sign()); - } catch (GeneralSecurityException e) { - Log.e(TAG, "Unable to sign", e); - return null; - } - } - - private static String base64encode(byte[] bytes) { - return Base64.encodeToString(bytes, Base64.URL_SAFE + Base64.NO_PADDING + Base64.NO_WRAP); - } - - private void sendRequest(Intent intent, String requestId) { - intent.putExtra(EXTRA_KID, "|ID|" + requestId + "|"); - intent.putExtra("X-" + EXTRA_KID, "|ID|" + requestId + "|"); - Log.d(TAG, "Sending " + intent.getExtras()); - if (messenger != null) { - intent.putExtra(EXTRA_MESSENGER, myMessenger); - Message msg = Message.obtain(); - msg.obj = intent; - try { - messenger.send(msg); - return; - } catch (RemoteException e) { - Log.d(TAG, "Messenger failed, falling back to service"); - } - } - - boolean useGsf = iidPackageName.endsWith(".gsf"); - if (intent.hasExtra(EXTRA_USE_GSF)) - useGsf = "1".equals(intent.getStringExtra(EXTRA_USE_GSF)); - - if (useGsf) { - Intent holder = new Intent(ACTION_INSTANCE_ID); - holder.setPackage(context.getPackageName()); - holder.putExtra(EXTRA_GSF_INTENT, intent); - context.startService(holder); - } else { - intent.putExtra(EXTRA_MESSENGER, myMessenger); - intent.putExtra(EXTRA_IS_MESSENGER2, "1"); - if (messengerCompat != null) { - Message msg = Message.obtain(); - msg.obj = intent; - try { - messengerCompat.send(msg); - return; - } catch (RemoteException e) { - Log.d(TAG, "Messenger failed, falling back to service"); - } - } - context.startService(intent); - } - } - - public Intent sendRegisterMessageBlocking(Bundle data, KeyPair keyPair) throws IOException { - Intent intent = sendRegisterMessageBlockingInternal(data, keyPair); - if (intent != null && intent.hasExtra(EXTRA_MESSENGER)) { - // Now with a messenger - intent = sendRegisterMessageBlockingInternal(data, keyPair); - } - return intent; - } - - private Intent sendRegisterMessageBlockingInternal(Bundle data, KeyPair keyPair) throws IOException { - ConditionVariable cv = new ConditionVariable(); - String requestId = getRequestId(); - synchronized (InstanceIdRpc.class) { - blockingResponses.put(requestId, cv); - } - - sendRegisterMessage(data, keyPair, requestId); - - cv.block(BLOCKING_WAIT_TIME); - synchronized (InstanceIdRpc.class) { - Object res = blockingResponses.remove(requestId); - if (res instanceof Intent) { - return (Intent) res; - } else if (res instanceof String) { - throw new IOException((String) res); - } - Log.w(TAG, "No response " + res); - throw new IOException(ERROR_TIMEOUT); - } - } - - public String handleRegisterMessageResult(Intent resultIntent) throws IOException { - if (resultIntent == null) throw new IOException(ERROR_SERVICE_NOT_AVAILABLE); - String result = resultIntent.getStringExtra(EXTRA_REGISTRATION_ID); - if (result == null) result = resultIntent.getStringExtra(EXTRA_UNREGISTERED); - if (result != null) return result; - result = resultIntent.getStringExtra(EXTRA_ERROR); - throw new IOException(result != null ? result : ERROR_SERVICE_NOT_AVAILABLE); - } - - private void setResponse(String requestId, Object response) { - if (requestId == null) { - for (String r : blockingResponses.keySet()) { - setResponse(r, response); - } - } - Object old = blockingResponses.get(requestId); - blockingResponses.put(requestId, response); - if (old instanceof ConditionVariable) { - ((ConditionVariable) old).open(); - } else if (old instanceof Messenger) { - Message msg = Message.obtain(); - msg.obj = response; - try { - ((Messenger) old).send(msg); - } catch (RemoteException e) { - Log.w(TAG, "Failed to send response", e); - } - } - } -} diff --git a/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdStore.java b/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdStore.java deleted file mode 100644 index 65778936..00000000 --- a/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdStore.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG 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.iid; - -import android.content.Context; -import android.content.SharedPreferences; -import android.util.Base64; -import android.util.Log; - -import java.security.KeyFactory; -import java.security.KeyPair; -import java.security.spec.PKCS8EncodedKeySpec; -import java.security.spec.X509EncodedKeySpec; - -public class InstanceIdStore { - private static final String TAG = "InstanceID/Store"; - private static final String PREF_NAME = "com.google.android.gms.appid"; - - private Context context; - private SharedPreferences sharedPreferences; - - public InstanceIdStore(Context context) { - this.context = context; - this.sharedPreferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); - } - - public synchronized String get(String key) { - return sharedPreferences.getString(key, null); - } - - public String get(String subtype, String key) { - return get(subtype + "|S|" + key); - } - - public String get(String subtype, String authorizedEntity, String scope) { - return get(subtype + "|T|" + authorizedEntity + "|" + scope); - } - - public KeyPair getKeyPair(String subtype) { - String pub = get(subtype, "|P|"); - String priv = get(subtype, "|K|"); - if (pub == null || priv == null) { - return null; - } - try { - byte[] pubKey = Base64.decode(pub, Base64.URL_SAFE); - byte[] privKey = Base64.decode(priv, Base64.URL_SAFE); - KeyFactory rsaFactory = KeyFactory.getInstance("RSA"); - return new KeyPair(rsaFactory.generatePublic(new X509EncodedKeySpec(pubKey)), rsaFactory.generatePrivate(new PKCS8EncodedKeySpec(privKey))); - } catch (Exception e) { - Log.w(TAG, "Invalid key stored " + e); - return null; - } - } - - public synchronized void put(String key, String value) { - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putString(key, value); - editor.apply(); - } - - public void put(String subtype, String key, String value) { - put(subtype + "|S|" + key, value); - } - - public void put(String subtype, String authorizedEntity, String scope, String value) { - put(subtype + "|T|" + authorizedEntity + "|" + scope, value); - } - - public synchronized void put(String subtype, KeyPair keyPair, long timestamp) { - put(subtype, "|P|", Base64.encodeToString(keyPair.getPublic().getEncoded(), Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING)); - put(subtype, "|K|", Base64.encodeToString(keyPair.getPrivate().getEncoded(), Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING)); - put(subtype, "cre", Long.toString(timestamp)); - } - - public synchronized void delete() { - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.clear(); - editor.apply(); - } - - public synchronized void delete(String prefix) { - SharedPreferences.Editor editor = sharedPreferences.edit(); - for (String key : sharedPreferences.getAll().keySet()) { - if (key.startsWith(prefix)) { - editor.remove(key); - } - } - editor.apply(); - } - - public synchronized void delete(String subtype, String authorizedEntity, String scope) { - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.remove(subtype + "|T|" + authorizedEntity + "|" + scope); - editor.apply(); - } -} diff --git a/settings.gradle b/settings.gradle index 1d4a1b0d..38ea345a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,7 +3,6 @@ include ':play-services-basement' include ':play-services-api' include ':play-services-cast-api' include ':play-services-cast-framework-api' -include ':play-services-iid-api' include ':play-services-base' include ':play-services-tasks' From 31b6acd10e742e81c1cf96505b9f678f6f05b91f Mon Sep 17 00:00:00 2001 From: Venny Date: Fri, 17 Jul 2020 17:36:16 +0200 Subject: [PATCH 7/8] Revert "Remove iid service" This reverts commit dcefc8dd7b22e6f3858652f600b95277b6c205a8. Readd iid --- play-services-api/build.gradle | 1 + play-services-iid-api/build.gradle | 37 ++ play-services-iid-api/gradle.properties | 34 ++ .../src/main/AndroidManifest.xml | 18 + .../android/gms/iid/IMessengerCompat.aidl | 7 + .../android/gms/iid/MessengerCompat.java | 106 +++++ play-services-iid/build.gradle | 47 ++ play-services-iid/gradle.properties | 34 ++ .../src/main/AndroidManifest.xml | 24 + .../google/android/gms/iid/InstanceID.java | 275 ++++++++++++ .../gms/iid/InstanceIDListenerService.java | 138 ++++++ .../org/microg/gms/iid/InstanceIdRpc.java | 423 ++++++++++++++++++ .../org/microg/gms/iid/InstanceIdStore.java | 111 +++++ settings.gradle | 1 + 14 files changed, 1256 insertions(+) create mode 100644 play-services-iid-api/build.gradle create mode 100644 play-services-iid-api/gradle.properties create mode 100644 play-services-iid-api/src/main/AndroidManifest.xml create mode 100644 play-services-iid-api/src/main/aidl/com/google/android/gms/iid/IMessengerCompat.aidl create mode 100644 play-services-iid-api/src/main/java/com/google/android/gms/iid/MessengerCompat.java create mode 100644 play-services-iid/build.gradle create mode 100644 play-services-iid/gradle.properties create mode 100644 play-services-iid/src/main/AndroidManifest.xml create mode 100644 play-services-iid/src/main/java/com/google/android/gms/iid/InstanceID.java create mode 100644 play-services-iid/src/main/java/com/google/android/gms/iid/InstanceIDListenerService.java create mode 100644 play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java create mode 100644 play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdStore.java diff --git a/play-services-api/build.gradle b/play-services-api/build.gradle index 7f07c63c..5e627850 100644 --- a/play-services-api/build.gradle +++ b/play-services-api/build.gradle @@ -36,4 +36,5 @@ dependencies { api project(':play-services-basement') api project(':play-services-cast-api') api project(':play-services-cast-framework-api') + api project(':play-services-iid-api') } diff --git a/play-services-iid-api/build.gradle b/play-services-iid-api/build.gradle new file mode 100644 index 00000000..7d1eb81f --- /dev/null +++ b/play-services-iid-api/build.gradle @@ -0,0 +1,37 @@ +/* + * Copyright 2013-2015 microG 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. + */ + +apply plugin: 'com.android.library' + +android { + compileSdkVersion androidCompileSdk + buildToolsVersion "$androidBuildVersionTools" + + defaultConfig { + versionName version + minSdkVersion androidMinSdk + targetSdkVersion androidTargetSdk + } + + compileOptions { + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + } +} + +dependencies { + api project(':play-services-basement') +} diff --git a/play-services-iid-api/gradle.properties b/play-services-iid-api/gradle.properties new file mode 100644 index 00000000..d54aab99 --- /dev/null +++ b/play-services-iid-api/gradle.properties @@ -0,0 +1,34 @@ +# +# Copyright 2013-2016 microG 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. +# + +POM_NAME=Play Services Internal IID API +POM_DESCRIPTION=Interfaces and objects for IPC between Play Services Library and Play Services Core + +POM_PACKAGING=aar + +POM_URL=https://github.com/microg/android_external_GmsApi + +POM_SCM_URL=https://github.com/microg/android_external_GmsApi +POM_SCM_CONNECTION=scm:git@github.com:microg/android_external_GmsApi.git +POM_SCM_DEV_CONNECTION=scm:git@github.com:microg/android_external_GmsApi.git + +POM_LICENCE_NAME=The Apache Software License, Version 2.0 +POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENCE_DIST=repo + +POM_DEVELOPER_ID=mar-v-in +POM_DEVELOPER_NAME=Marvin W + diff --git a/play-services-iid-api/src/main/AndroidManifest.xml b/play-services-iid-api/src/main/AndroidManifest.xml new file mode 100644 index 00000000..e979258e --- /dev/null +++ b/play-services-iid-api/src/main/AndroidManifest.xml @@ -0,0 +1,18 @@ + + + + \ No newline at end of file diff --git a/play-services-iid-api/src/main/aidl/com/google/android/gms/iid/IMessengerCompat.aidl b/play-services-iid-api/src/main/aidl/com/google/android/gms/iid/IMessengerCompat.aidl new file mode 100644 index 00000000..3ebf38c1 --- /dev/null +++ b/play-services-iid-api/src/main/aidl/com/google/android/gms/iid/IMessengerCompat.aidl @@ -0,0 +1,7 @@ +package com.google.android.gms.iid; + +import android.os.Message; + +interface IMessengerCompat { + void send(in Message message); +} diff --git a/play-services-iid-api/src/main/java/com/google/android/gms/iid/MessengerCompat.java b/play-services-iid-api/src/main/java/com/google/android/gms/iid/MessengerCompat.java new file mode 100644 index 00000000..05bf4c8c --- /dev/null +++ b/play-services-iid-api/src/main/java/com/google/android/gms/iid/MessengerCompat.java @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2013-2017 microG 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.iid; + +import android.os.Binder; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; +import android.os.Messenger; +import android.os.Parcel; +import android.os.Parcelable; +import android.os.RemoteException; + +import static android.os.Build.VERSION.SDK_INT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; + +public class MessengerCompat implements Parcelable { + private Messenger messenger; + private IMessengerCompat messengerCompat; + + public MessengerCompat(IBinder binder) { + if (SDK_INT >= LOLLIPOP) { + messenger = new Messenger(binder); + } else { + messengerCompat = IMessengerCompat.Stub.asInterface(binder); + } + } + + public MessengerCompat(Handler handler) { + if (SDK_INT >= LOLLIPOP) { + messenger = new Messenger(handler); + } else { + messengerCompat = new IMessengerCompatImpl(handler); + } + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public boolean equals(Object o) { + return o instanceof MessengerCompat && ((MessengerCompat) o).getBinder().equals(getBinder()); + } + + public IBinder getBinder() { + return messenger != null ? messenger.getBinder() : messengerCompat.asBinder(); + } + + @Override + public int hashCode() { + return getBinder().hashCode(); + } + + public void send(Message message) throws RemoteException { + if (messenger != null) messenger.send(message); + else messengerCompat.send(message); + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeStrongBinder(getBinder()); + } + + public static final Creator CREATOR = new Creator() { + @Override + public MessengerCompat createFromParcel(Parcel source) { + IBinder binder = source.readStrongBinder(); + return binder != null ? new MessengerCompat(binder) : null; + } + + @Override + public MessengerCompat[] newArray(int size) { + return new MessengerCompat[size]; + } + }; + + private static class IMessengerCompatImpl extends IMessengerCompat.Stub { + private final Handler handler; + + public IMessengerCompatImpl(Handler handler) { + this.handler = handler; + } + + @Override + public void send(Message message) throws RemoteException { + message.arg2 = Binder.getCallingUid(); + handler.dispatchMessage(message); + } + } +} diff --git a/play-services-iid/build.gradle b/play-services-iid/build.gradle new file mode 100644 index 00000000..c8960415 --- /dev/null +++ b/play-services-iid/build.gradle @@ -0,0 +1,47 @@ +/* + * Copyright 2013-2015 microG 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. + */ + +apply plugin: 'com.android.library' + +String getMyVersionName() { + def stdout = new ByteArrayOutputStream() + if (rootProject.file("gradlew").exists()) + exec { commandLine 'git', 'describe', '--tags', '--always', '--dirty'; standardOutput = stdout } + else // automatic build system, don't tag dirty + exec { commandLine 'git', 'describe', '--tags', '--always'; standardOutput = stdout } + return stdout.toString().trim().substring(1) +} + +android { + compileSdkVersion androidCompileSdk() + buildToolsVersion "$androidBuildVersionTools" + + defaultConfig { + versionName getMyVersionName() + minSdkVersion androidMinSdk() + targetSdkVersion androidTargetSdk() + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + api project(':play-services-base') + api project(':play-services-iid-api') +} diff --git a/play-services-iid/gradle.properties b/play-services-iid/gradle.properties new file mode 100644 index 00000000..2e179864 --- /dev/null +++ b/play-services-iid/gradle.properties @@ -0,0 +1,34 @@ +# +# Copyright 2013-2016 microG 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. +# + +POM_NAME=Play Services IID Library +POM_DESCRIPTION=The Play Services Library module to access the InstanceID API + +POM_PACKAGING=aar + +POM_URL=https://github.com/microg/android_external_GmsLib + +POM_SCM_URL=https://github.com/microg/android_external_GmsLib +POM_SCM_CONNECTION=scm:git@github.com:microg/android_external_GmsLib.git +POM_SCM_DEV_CONNECTION=scm:git@github.com:microg/android_external_GmsLib.git + +POM_LICENCE_NAME=The Apache Software License, Version 2.0 +POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENCE_DIST=repo + +POM_DEVELOPER_ID=mar-v-in +POM_DEVELOPER_NAME=Marvin W + diff --git a/play-services-iid/src/main/AndroidManifest.xml b/play-services-iid/src/main/AndroidManifest.xml new file mode 100644 index 00000000..67377ff0 --- /dev/null +++ b/play-services-iid/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + diff --git a/play-services-iid/src/main/java/com/google/android/gms/iid/InstanceID.java b/play-services-iid/src/main/java/com/google/android/gms/iid/InstanceID.java new file mode 100644 index 00000000..8a4dbefa --- /dev/null +++ b/play-services-iid/src/main/java/com/google/android/gms/iid/InstanceID.java @@ -0,0 +1,275 @@ +/* + * Copyright (C) 2013-2017 microG 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.iid; + +import android.content.Context; +import android.os.Bundle; +import android.os.Looper; +import android.text.TextUtils; +import android.util.Base64; +import android.util.Log; + +import org.microg.gms.common.PublicApi; +import org.microg.gms.gcm.GcmConstants; +import org.microg.gms.iid.InstanceIdRpc; +import org.microg.gms.iid.InstanceIdStore; + +import java.io.IOException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.HashMap; +import java.util.Map; + +import static org.microg.gms.gcm.GcmConstants.EXTRA_DELETE; +import static org.microg.gms.gcm.GcmConstants.EXTRA_SCOPE; +import static org.microg.gms.gcm.GcmConstants.EXTRA_SENDER; +import static org.microg.gms.gcm.GcmConstants.EXTRA_SUBSCIPTION; +import static org.microg.gms.gcm.GcmConstants.EXTRA_SUBTYPE; + +/** + * Instance ID provides a unique identifier for each app instance and a mechanism + * to authenticate and authorize actions (for example, sending a GCM message). + *

+ * Instance ID is stable but may become invalid, if: + *

    + *
  • App deletes Instance ID
  • + *
  • Device is factory reset
  • + *
  • User uninstalls the app
  • + *
  • User clears app data
  • + *
+ * If Instance ID has become invalid, the app can call {@link com.google.android.gms.iid.InstanceID#getId()} + * to request a new Instance ID. + * To prove ownership of Instance ID and to allow servers to access data or + * services associated with the app, call {@link com.google.android.gms.iid.InstanceID#getToken(java.lang.String, java.lang.String)}. + */ +@PublicApi +public class InstanceID { + /** + * Error returned when failed requests are retried too often. Use + * exponential backoff when retrying requests + */ + public static final String ERROR_BACKOFF = "RETRY_LATER"; + + /** + * Blocking methods must not be called on the main thread. + */ + public static final String ERROR_MAIN_THREAD = "MAIN_THREAD"; + + /** + * Tokens can't be generated. Only devices with Google Play are supported. + */ + public static final String ERROR_MISSING_INSTANCEID_SERVICE = "MISSING_INSTANCEID_SERVICE"; + + /** + * The device cannot read the response, or there was a server error. + * Application should retry the request later using exponential backoff + * and retry (on each subsequent failure increase delay before retrying). + */ + public static final String ERROR_SERVICE_NOT_AVAILABLE = GcmConstants.ERROR_SERVICE_NOT_AVAILABLE; + + /** + * Timeout waiting for a response. + */ + public static final String ERROR_TIMEOUT = "TIMEOUT"; + + private static final int RSA_KEY_SIZE = 2048; + private static final String TAG = "InstanceID"; + + private static InstanceIdStore storeInstance; + private static InstanceIdRpc rpc; + private static Map instances = new HashMap(); + + private final String subtype; + private KeyPair keyPair; + private long creationTime; + + private InstanceID(String subtype) { + this.subtype = subtype == null ? "" : subtype; + } + + /** + * Resets Instance ID and revokes all tokens. + * + * @throws IOException + */ + public void deleteInstanceID() throws IOException { + deleteToken("*", "*"); + creationTime = 0; + storeInstance.delete(subtype + "|"); + keyPair = null; + } + + /** + * Revokes access to a scope (action) for an entity previously + * authorized by {@link com.google.android.gms.iid.InstanceID#getToken(java.lang.String, java.lang.String)}. + *

+ * Do not call this function on the main thread. + * + * @param authorizedEntity Entity that must no longer have access. + * @param scope Action that entity is no longer authorized to perform. + * @throws IOException if the request fails. + */ + public void deleteToken(String authorizedEntity, String scope) throws IOException { + deleteToken(authorizedEntity, scope, null); + } + + @PublicApi(exclude = true) + public void deleteToken(String authorizedEntity, String scope, Bundle extras) throws IOException { + if (Looper.getMainLooper() == Looper.myLooper()) throw new IOException(ERROR_MAIN_THREAD); + + storeInstance.delete(subtype, authorizedEntity, scope); + + if (extras == null) extras = new Bundle(); + extras.putString(EXTRA_SENDER, authorizedEntity); + extras.putString(EXTRA_SUBSCIPTION, authorizedEntity); + extras.putString(EXTRA_DELETE, "1"); + extras.putString("X-" + EXTRA_DELETE, "1"); + extras.putString(EXTRA_SUBTYPE, TextUtils.isEmpty(subtype) ? authorizedEntity : subtype); + extras.putString("X-" + EXTRA_SUBTYPE, TextUtils.isEmpty(subtype) ? authorizedEntity : subtype); + if (scope != null) extras.putString(EXTRA_SCOPE, scope); + + rpc.handleRegisterMessageResult(rpc.sendRegisterMessageBlocking(extras, getKeyPair())); + } + + /** + * Returns time when instance ID was created. + * + * @return Time when instance ID was created (milliseconds since Epoch). + */ + public long getCreationTime() { + if (creationTime == 0) { + String s = storeInstance.get(subtype, "cre"); + if (s != null) { + creationTime = Long.parseLong(s); + } + } + return creationTime; + } + + /** + * Returns a stable identifier that uniquely identifies the app instance. + * + * @return The identifier for the application instance. + */ + public String getId() { + return sha1KeyPair(getKeyPair()); + } + + /** + * Returns an instance of this class. + * + * @return InstanceID instance. + */ + public static InstanceID getInstance(Context context) { + String subtype = ""; + if (storeInstance == null) { + storeInstance = new InstanceIdStore(context.getApplicationContext()); + rpc = new InstanceIdRpc(context.getApplicationContext()); + } + InstanceID instance = instances.get(subtype); + if (instance == null) { + instance = new InstanceID(subtype); + instances.put(subtype, instance); + } + return instance; + } + + /** + * Returns a token that authorizes an Entity (example: cloud service) to perform + * an action on behalf of the application identified by Instance ID. + *

+ * This is similar to an OAuth2 token except, it applies to the + * application instance instead of a user. + *

+ * Do not call this function on the main thread. + * + * @param authorizedEntity Entity authorized by the token. + * @param scope Action authorized for authorizedEntity. + * @param extras additional parameters specific to each token scope. + * Bundle keys starting with 'GCM.' and 'GOOGLE.' are + * reserved. + * @return a token that can identify and authorize the instance of the + * application on the device. + * @throws IOException if the request fails. + */ + public String getToken(String authorizedEntity, String scope, Bundle extras) throws IOException { + if (Looper.getMainLooper() == Looper.myLooper()) throw new IOException(ERROR_MAIN_THREAD); + + throw new UnsupportedOperationException(); + } + + /** + * Returns a token that authorizes an Entity (example: cloud service) to perform + * an action on behalf of the application identified by Instance ID. + *

+ * This is similar to an OAuth2 token except, it applies to the + * application instance instead of a user. + *

+ * Do not call this function on the main thread. + * + * @param authorizedEntity Entity authorized by the token. + * @param scope Action authorized for authorizedEntity. + * @return a token that can identify and authorize the instance of the + * application on the device. + * @throws IOException if the request fails. + */ + public String getToken(String authorizedEntity, String scope) throws IOException { + return getToken(authorizedEntity, scope, null); + } + + @PublicApi(exclude = true) + public InstanceIdStore getStore() { + return storeInstance; + } + + @PublicApi(exclude = true) + public String requestToken(String authorizedEntity, String scope, Bundle extras) { + throw new UnsupportedOperationException(); + } + + private synchronized KeyPair getKeyPair() { + if (keyPair == null) { + keyPair = storeInstance.getKeyPair(subtype); + if (keyPair == null) { + try { + KeyPairGenerator rsaGenerator = KeyPairGenerator.getInstance("RSA"); + rsaGenerator.initialize(RSA_KEY_SIZE); + keyPair = rsaGenerator.generateKeyPair(); + creationTime = System.currentTimeMillis(); + storeInstance.put(subtype, keyPair, creationTime); + } catch (NoSuchAlgorithmException e) { + Log.w(TAG, e); + } + } + } + return keyPair; + } + + @PublicApi(exclude = true) + public static String sha1KeyPair(KeyPair keyPair) { + try { + byte[] digest = MessageDigest.getInstance("SHA1").digest(keyPair.getPublic().getEncoded()); + digest[0] = (byte) (112 + (0xF & digest[0]) & 0xFF); + return Base64.encodeToString(digest, 0, 8, Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING); + } catch (NoSuchAlgorithmException e) { + Log.w(TAG, e); + return null; + } + } +} \ No newline at end of file diff --git a/play-services-iid/src/main/java/com/google/android/gms/iid/InstanceIDListenerService.java b/play-services-iid/src/main/java/com/google/android/gms/iid/InstanceIDListenerService.java new file mode 100644 index 00000000..a15baa0f --- /dev/null +++ b/play-services-iid/src/main/java/com/google/android/gms/iid/InstanceIDListenerService.java @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2013-2017 microG 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.iid; + +import android.app.Service; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.Handler; +import android.os.IBinder; +import android.os.Looper; +import android.os.Message; +import android.support.v4.content.WakefulBroadcastReceiver; + +import static org.microg.gms.gcm.GcmConstants.ACTION_C2DM_REGISTRATION; +import static org.microg.gms.gcm.GcmConstants.ACTION_INSTANCE_ID; +import static org.microg.gms.gcm.GcmConstants.EXTRA_FROM; +import static org.microg.gms.gcm.GcmConstants.EXTRA_GSF_INTENT; + +/** + * Base class to handle Instance ID service notifications on token + * refresh. + *

+ * Any app using Instance ID or GCM must include a class extending + * InstanceIDListenerService and implement {@link com.google.android.gms.iid.InstanceIDListenerService#onTokenRefresh()}. + *

+ * Include the following in the manifest: + *

+ * 
+ *     
+ *         
+ *     
+ * 
+ * Do not export this service. Instead, keep it private to prevent other apps + * accessing your service. + */ +public class InstanceIDListenerService extends Service { + + private BroadcastReceiver registrationReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + handleIntent(intent); + stop(); + } + }; + private MessengerCompat messengerCompat = new MessengerCompat(new Handler(Looper.getMainLooper()) { + @Override + public void handleMessage(Message msg) { + handleIntent((Intent) msg.obj); + } + }); + + private int counter = 0; + private int startId = -1; + + private void handleIntent(Intent intent) { + // TODO + } + + public IBinder onBind(Intent intent) { + if (intent != null && ACTION_INSTANCE_ID.equals(intent.getAction())) { + return messengerCompat.getBinder(); + } + return null; + } + + public void onCreate() { + IntentFilter filter = new IntentFilter(ACTION_C2DM_REGISTRATION); + filter.addCategory(getPackageName()); + registerReceiver(registrationReceiver, filter); + } + + public void onDestroy() { + unregisterReceiver(registrationReceiver); + } + + public int onStartCommand(Intent intent, int flags, int startId) { + synchronized (this) { + this.counter++; + if (startId > this.startId) this.startId = startId; + } + try { + if (intent != null) { + if (ACTION_INSTANCE_ID.equals(intent.getAction()) && intent.hasExtra(EXTRA_GSF_INTENT)) { + startService((Intent) intent.getParcelableExtra(EXTRA_GSF_INTENT)); + return START_STICKY; + } + + handleIntent(intent); + + if (intent.hasExtra(EXTRA_FROM)) + WakefulBroadcastReceiver.completeWakefulIntent(intent); + } + } finally { + stop(); + } + return START_NOT_STICKY; + } + + /** + * Called when the system determines that the tokens need to be refreshed. The application + * should call getToken() and send the tokens to all application servers. + *

+ * This will not be called very frequently, it is needed for key rotation and to handle special + * cases. + *

+ * The system will throttle the refresh event across all devices to avoid overloading + * application servers with token updates. + */ + public void onTokenRefresh() { + // To be overwritten + } + + private void stop() { + synchronized (this) { + counter--; + if (counter <= 0) { + stopSelf(startId); + } + } + } + +} \ No newline at end of file diff --git a/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java b/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java new file mode 100644 index 00000000..77f65f5e --- /dev/null +++ b/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java @@ -0,0 +1,423 @@ +/* + * Copyright (C) 2013-2017 microG 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.iid; + +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.os.Build; +import android.os.Bundle; +import android.os.ConditionVariable; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.os.Messenger; +import android.os.Parcelable; +import android.os.RemoteException; +import android.os.SystemClock; +import android.text.TextUtils; +import android.util.Base64; +import android.util.Log; + +import com.google.android.gms.iid.InstanceID; +import com.google.android.gms.iid.MessengerCompat; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.GeneralSecurityException; +import java.security.KeyPair; +import java.security.PrivateKey; +import java.security.Signature; +import java.security.interfaces.RSAPrivateKey; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +import static android.content.pm.PackageManager.PERMISSION_GRANTED; +import static com.google.android.gms.iid.InstanceID.ERROR_BACKOFF; +import static com.google.android.gms.iid.InstanceID.ERROR_MISSING_INSTANCEID_SERVICE; +import static com.google.android.gms.iid.InstanceID.ERROR_SERVICE_NOT_AVAILABLE; +import static com.google.android.gms.iid.InstanceID.ERROR_TIMEOUT; +import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME; +import static org.microg.gms.common.Constants.GSF_PACKAGE_NAME; +import static org.microg.gms.common.Constants.MAX_REFERENCE_VERSION; +import static org.microg.gms.gcm.GcmConstants.ACTION_C2DM_REGISTER; +import static org.microg.gms.gcm.GcmConstants.ACTION_C2DM_REGISTRATION; +import static org.microg.gms.gcm.GcmConstants.ACTION_INSTANCE_ID; +import static org.microg.gms.gcm.GcmConstants.EXTRA_APP; +import static org.microg.gms.gcm.GcmConstants.EXTRA_APP_ID; +import static org.microg.gms.gcm.GcmConstants.EXTRA_APP_VERSION_CODE; +import static org.microg.gms.gcm.GcmConstants.EXTRA_APP_VERSION_NAME; +import static org.microg.gms.gcm.GcmConstants.EXTRA_CLIENT_VERSION; +import static org.microg.gms.gcm.GcmConstants.EXTRA_ERROR; +import static org.microg.gms.gcm.GcmConstants.EXTRA_GMS_VERSION; +import static org.microg.gms.gcm.GcmConstants.EXTRA_GSF_INTENT; +import static org.microg.gms.gcm.GcmConstants.EXTRA_IS_MESSENGER2; +import static org.microg.gms.gcm.GcmConstants.EXTRA_KID; +import static org.microg.gms.gcm.GcmConstants.EXTRA_MESSENGER; +import static org.microg.gms.gcm.GcmConstants.EXTRA_OS_VERSION; +import static org.microg.gms.gcm.GcmConstants.EXTRA_PUBLIC_KEY; +import static org.microg.gms.gcm.GcmConstants.EXTRA_REGISTRATION_ID; +import static org.microg.gms.gcm.GcmConstants.EXTRA_SIGNATURE; +import static org.microg.gms.gcm.GcmConstants.EXTRA_UNREGISTERED; +import static org.microg.gms.gcm.GcmConstants.EXTRA_USE_GSF; +import static org.microg.gms.gcm.GcmConstants.PERMISSION_RECEIVE; + +public class InstanceIdRpc { + private static final String TAG = "InstanceID/Rpc"; + + private static final int BLOCKING_WAIT_TIME = 30000; + + private static String iidPackageName; + private static int lastRequestId; + private static int retryCount; + private static Map blockingResponses = new HashMap(); + + private long nextAttempt; + private int interval; + private Context context; + private PendingIntent selfAuthToken; + private Messenger messenger; + private Messenger myMessenger; + private MessengerCompat messengerCompat; + + public InstanceIdRpc(Context context) { + this.context = context; + } + + public static String getIidPackageName(Context context) { + if (iidPackageName != null) { + return iidPackageName; + } + PackageManager packageManager = context.getPackageManager(); + for (ResolveInfo resolveInfo : packageManager.queryIntentServices(new Intent(ACTION_C2DM_REGISTER), 0)) { + if (packageManager.checkPermission(PERMISSION_RECEIVE, resolveInfo.serviceInfo.packageName) == PERMISSION_GRANTED) { + return iidPackageName = resolveInfo.serviceInfo.packageName; + } + } + try { + ApplicationInfo appInfo = packageManager.getApplicationInfo(GMS_PACKAGE_NAME, 0); + return iidPackageName = appInfo.packageName; + } catch (PackageManager.NameNotFoundException ignored) { + } + try { + ApplicationInfo appInfo = packageManager.getApplicationInfo(GSF_PACKAGE_NAME, 0); + return iidPackageName = appInfo.packageName; + } catch (PackageManager.NameNotFoundException ex3) { + Log.w(TAG, "Both Google Play Services and legacy GSF package are missing"); + return null; + } + } + + private static int getGmsVersionCode(final Context context) { + final PackageManager packageManager = context.getPackageManager(); + try { + return packageManager.getPackageInfo(getIidPackageName(context), 0).versionCode; + } catch (PackageManager.NameNotFoundException ex) { + return -1; + } + } + + private static int getSelfVersionCode(final Context context) { + try { + return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; + } catch (PackageManager.NameNotFoundException neverHappens) { + return 0; + } + } + + private static String getSelfVersionName(final Context context) { + try { + return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; + } catch (PackageManager.NameNotFoundException neverHappens) { + return null; + } + } + + void initialize() { + if (myMessenger != null) return; + getIidPackageName(context); + myMessenger = new Messenger(new Handler(Looper.getMainLooper()) { + @Override + public void handleMessage(Message msg) { + if (msg == null) { + return; + } + if (msg.obj instanceof Intent) { + Intent intent = (Intent) msg.obj; + intent.setExtrasClassLoader(MessengerCompat.class.getClassLoader()); + if (intent.hasExtra(EXTRA_MESSENGER)) { + Parcelable messengerCandidate = intent.getParcelableExtra(EXTRA_MESSENGER); + if (messengerCandidate instanceof MessengerCompat) { + messengerCompat = (MessengerCompat) messengerCandidate; + } else if (messengerCandidate instanceof Messenger) { + messenger = (Messenger) messengerCandidate; + } + } + handleResponseInternal(intent); + } else { + Log.w(TAG, "Dropping invalid message"); + } + } + }); + } + + public void handleResponseInternal(Intent resultIntent) { + if (resultIntent == null) return; + if (!ACTION_C2DM_REGISTRATION.equals(resultIntent.getAction()) && !ACTION_INSTANCE_ID.equals(resultIntent.getAction())) + return; + String result = resultIntent.getStringExtra(EXTRA_REGISTRATION_ID); + if (result == null) result = resultIntent.getStringExtra(EXTRA_UNREGISTERED); + if (result == null) { + handleError(resultIntent); + return; + } + retryCount = 0; + nextAttempt = 0; + interval = 0; + + String requestId = null; + if (result.startsWith("|")) { + // parse structured response + String[] split = result.split("\\|"); + if (!"ID".equals(split[1])) { + Log.w(TAG, "Unexpected structured response " + result); + } + requestId = split[2]; + if (split.length > 4) { + if ("SYNC".equals(split[3])) { + // TODO: sync + } else if("RST".equals(split[3])) { + // TODO: rst + resultIntent.removeExtra(EXTRA_REGISTRATION_ID); + return; + } + } + result = split[split.length-1]; + if (result.startsWith(":")) + result = result.substring(1); + resultIntent.putExtra(EXTRA_REGISTRATION_ID, result); + } + setResponse(requestId, resultIntent); + } + + private void handleError(Intent resultIntent) { + String error = resultIntent.getStringExtra("error"); + if (error == null) return; + String requestId = null; + if (error.startsWith("|")) { + // parse structured error message + String[] split = error.split("\\|"); + if (!"ID".equals(split[1])) { + Log.w(TAG, "Unexpected structured response " + error); + } + if (split.length > 2) { + requestId = split[2]; + error = split[3]; + if (error.startsWith(":")) + error = error.substring(1); + } else { + error = "UNKNOWN"; + } + resultIntent.putExtra("error", error); + } + setResponse(requestId, resultIntent); + long retryAfter = resultIntent.getLongExtra("Retry-After", 0); + if (retryAfter > 0) { + interval = (int) (retryAfter * 1000); + nextAttempt = SystemClock.elapsedRealtime() + interval; + Log.d(TAG, "Server requested retry delay: " + interval); + } else if (ERROR_SERVICE_NOT_AVAILABLE.equals(error) || "AUTHENTICATION_FAILED".equals(error) + && GSF_PACKAGE_NAME.equals(getIidPackageName(context))) { + retryCount++; + if (retryCount < 3) return; + if (retryCount == 3) interval = 1000 + new Random().nextInt(1000); + interval = interval * 2; + nextAttempt = SystemClock.elapsedRealtime() + interval; + Log.d(TAG, "Setting retry delay to " + interval); + } + } + + private synchronized PendingIntent getSelfAuthToken() { + if (selfAuthToken == null) { + Intent intent = new Intent(); + intent.setPackage("com.google.example.invalidpackage"); + selfAuthToken = PendingIntent.getBroadcast(context, 0, intent, 0); + } + return selfAuthToken; + } + + private static synchronized String getRequestId() { + return Integer.toString(lastRequestId++); + } + + private void sendRegisterMessage(Bundle data, KeyPair keyPair, String requestId) throws IOException { + long elapsedRealtime = SystemClock.elapsedRealtime(); + if (nextAttempt != 0 && elapsedRealtime <= nextAttempt) { + Log.w(TAG, "Had to wait for " + interval + ", that's still " + (nextAttempt - elapsedRealtime)); + throw new IOException(ERROR_BACKOFF); + } + initialize(); + if (iidPackageName == null) { + throw new IOException(ERROR_MISSING_INSTANCEID_SERVICE); + } + Intent intent = new Intent(ACTION_C2DM_REGISTER); + intent.setPackage(iidPackageName); + data.putString(EXTRA_GMS_VERSION, Integer.toString(getGmsVersionCode(context))); + data.putString(EXTRA_OS_VERSION, Integer.toString(Build.VERSION.SDK_INT)); + data.putString(EXTRA_APP_VERSION_CODE, Integer.toString(getSelfVersionCode(context))); + data.putString(EXTRA_APP_VERSION_NAME, getSelfVersionName(context)); + data.putString(EXTRA_CLIENT_VERSION, "iid-" + MAX_REFERENCE_VERSION); + data.putString(EXTRA_APP_ID, InstanceID.sha1KeyPair(keyPair)); + String pub = base64encode(keyPair.getPublic().getEncoded()); + data.putString(EXTRA_PUBLIC_KEY, pub); + data.putString(EXTRA_SIGNATURE, sign(keyPair, context.getPackageName(), pub)); + intent.putExtras(data); + intent.putExtra(EXTRA_APP, getSelfAuthToken()); + sendRequest(intent, requestId); + } + + private static String sign(KeyPair keyPair, String... payload) { + byte[] bytes; + try { + bytes = TextUtils.join("\n", payload).getBytes("UTF-8"); + } catch (UnsupportedEncodingException e) { + Log.e(TAG, "Unable to encode", e); + return null; + } + PrivateKey privateKey = keyPair.getPrivate(); + try { + Signature signature = Signature.getInstance(privateKey instanceof RSAPrivateKey ? "SHA256withRSA" : "SHA256withECDSA"); + signature.initSign(privateKey); + signature.update(bytes); + return base64encode(signature.sign()); + } catch (GeneralSecurityException e) { + Log.e(TAG, "Unable to sign", e); + return null; + } + } + + private static String base64encode(byte[] bytes) { + return Base64.encodeToString(bytes, Base64.URL_SAFE + Base64.NO_PADDING + Base64.NO_WRAP); + } + + private void sendRequest(Intent intent, String requestId) { + intent.putExtra(EXTRA_KID, "|ID|" + requestId + "|"); + intent.putExtra("X-" + EXTRA_KID, "|ID|" + requestId + "|"); + Log.d(TAG, "Sending " + intent.getExtras()); + if (messenger != null) { + intent.putExtra(EXTRA_MESSENGER, myMessenger); + Message msg = Message.obtain(); + msg.obj = intent; + try { + messenger.send(msg); + return; + } catch (RemoteException e) { + Log.d(TAG, "Messenger failed, falling back to service"); + } + } + + boolean useGsf = iidPackageName.endsWith(".gsf"); + if (intent.hasExtra(EXTRA_USE_GSF)) + useGsf = "1".equals(intent.getStringExtra(EXTRA_USE_GSF)); + + if (useGsf) { + Intent holder = new Intent(ACTION_INSTANCE_ID); + holder.setPackage(context.getPackageName()); + holder.putExtra(EXTRA_GSF_INTENT, intent); + context.startService(holder); + } else { + intent.putExtra(EXTRA_MESSENGER, myMessenger); + intent.putExtra(EXTRA_IS_MESSENGER2, "1"); + if (messengerCompat != null) { + Message msg = Message.obtain(); + msg.obj = intent; + try { + messengerCompat.send(msg); + return; + } catch (RemoteException e) { + Log.d(TAG, "Messenger failed, falling back to service"); + } + } + context.startService(intent); + } + } + + public Intent sendRegisterMessageBlocking(Bundle data, KeyPair keyPair) throws IOException { + Intent intent = sendRegisterMessageBlockingInternal(data, keyPair); + if (intent != null && intent.hasExtra(EXTRA_MESSENGER)) { + // Now with a messenger + intent = sendRegisterMessageBlockingInternal(data, keyPair); + } + return intent; + } + + private Intent sendRegisterMessageBlockingInternal(Bundle data, KeyPair keyPair) throws IOException { + ConditionVariable cv = new ConditionVariable(); + String requestId = getRequestId(); + synchronized (InstanceIdRpc.class) { + blockingResponses.put(requestId, cv); + } + + sendRegisterMessage(data, keyPair, requestId); + + cv.block(BLOCKING_WAIT_TIME); + synchronized (InstanceIdRpc.class) { + Object res = blockingResponses.remove(requestId); + if (res instanceof Intent) { + return (Intent) res; + } else if (res instanceof String) { + throw new IOException((String) res); + } + Log.w(TAG, "No response " + res); + throw new IOException(ERROR_TIMEOUT); + } + } + + public String handleRegisterMessageResult(Intent resultIntent) throws IOException { + if (resultIntent == null) throw new IOException(ERROR_SERVICE_NOT_AVAILABLE); + String result = resultIntent.getStringExtra(EXTRA_REGISTRATION_ID); + if (result == null) result = resultIntent.getStringExtra(EXTRA_UNREGISTERED); + if (result != null) return result; + result = resultIntent.getStringExtra(EXTRA_ERROR); + throw new IOException(result != null ? result : ERROR_SERVICE_NOT_AVAILABLE); + } + + private void setResponse(String requestId, Object response) { + if (requestId == null) { + for (String r : blockingResponses.keySet()) { + setResponse(r, response); + } + } + Object old = blockingResponses.get(requestId); + blockingResponses.put(requestId, response); + if (old instanceof ConditionVariable) { + ((ConditionVariable) old).open(); + } else if (old instanceof Messenger) { + Message msg = Message.obtain(); + msg.obj = response; + try { + ((Messenger) old).send(msg); + } catch (RemoteException e) { + Log.w(TAG, "Failed to send response", e); + } + } + } +} diff --git a/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdStore.java b/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdStore.java new file mode 100644 index 00000000..65778936 --- /dev/null +++ b/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdStore.java @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2013-2017 microG 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.iid; + +import android.content.Context; +import android.content.SharedPreferences; +import android.util.Base64; +import android.util.Log; + +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; + +public class InstanceIdStore { + private static final String TAG = "InstanceID/Store"; + private static final String PREF_NAME = "com.google.android.gms.appid"; + + private Context context; + private SharedPreferences sharedPreferences; + + public InstanceIdStore(Context context) { + this.context = context; + this.sharedPreferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); + } + + public synchronized String get(String key) { + return sharedPreferences.getString(key, null); + } + + public String get(String subtype, String key) { + return get(subtype + "|S|" + key); + } + + public String get(String subtype, String authorizedEntity, String scope) { + return get(subtype + "|T|" + authorizedEntity + "|" + scope); + } + + public KeyPair getKeyPair(String subtype) { + String pub = get(subtype, "|P|"); + String priv = get(subtype, "|K|"); + if (pub == null || priv == null) { + return null; + } + try { + byte[] pubKey = Base64.decode(pub, Base64.URL_SAFE); + byte[] privKey = Base64.decode(priv, Base64.URL_SAFE); + KeyFactory rsaFactory = KeyFactory.getInstance("RSA"); + return new KeyPair(rsaFactory.generatePublic(new X509EncodedKeySpec(pubKey)), rsaFactory.generatePrivate(new PKCS8EncodedKeySpec(privKey))); + } catch (Exception e) { + Log.w(TAG, "Invalid key stored " + e); + return null; + } + } + + public synchronized void put(String key, String value) { + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString(key, value); + editor.apply(); + } + + public void put(String subtype, String key, String value) { + put(subtype + "|S|" + key, value); + } + + public void put(String subtype, String authorizedEntity, String scope, String value) { + put(subtype + "|T|" + authorizedEntity + "|" + scope, value); + } + + public synchronized void put(String subtype, KeyPair keyPair, long timestamp) { + put(subtype, "|P|", Base64.encodeToString(keyPair.getPublic().getEncoded(), Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING)); + put(subtype, "|K|", Base64.encodeToString(keyPair.getPrivate().getEncoded(), Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING)); + put(subtype, "cre", Long.toString(timestamp)); + } + + public synchronized void delete() { + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.clear(); + editor.apply(); + } + + public synchronized void delete(String prefix) { + SharedPreferences.Editor editor = sharedPreferences.edit(); + for (String key : sharedPreferences.getAll().keySet()) { + if (key.startsWith(prefix)) { + editor.remove(key); + } + } + editor.apply(); + } + + public synchronized void delete(String subtype, String authorizedEntity, String scope) { + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.remove(subtype + "|T|" + authorizedEntity + "|" + scope); + editor.apply(); + } +} diff --git a/settings.gradle b/settings.gradle index 38ea345a..1d4a1b0d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,6 +3,7 @@ include ':play-services-basement' include ':play-services-api' include ':play-services-cast-api' include ':play-services-cast-framework-api' +include ':play-services-iid-api' include ':play-services-base' include ':play-services-tasks' From 50f817a161034dde2f1d641aeda55bb9ff2f6213 Mon Sep 17 00:00:00 2001 From: Venny Date: Fri, 17 Jul 2020 17:54:49 +0200 Subject: [PATCH 8/8] Add back measurement --- .../measurement/MeasurementBrokerService.java | 39 +++++++++++++++++++ .../measurement/MeasurementServiceImpl.java | 34 ++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 play-services-core/src/main/java/org/microg/gms/measurement/MeasurementBrokerService.java create mode 100644 play-services-core/src/main/java/org/microg/gms/measurement/MeasurementServiceImpl.java diff --git a/play-services-core/src/main/java/org/microg/gms/measurement/MeasurementBrokerService.java b/play-services-core/src/main/java/org/microg/gms/measurement/MeasurementBrokerService.java new file mode 100644 index 00000000..49dcda79 --- /dev/null +++ b/play-services-core/src/main/java/org/microg/gms/measurement/MeasurementBrokerService.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2018 microG 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.measurement; + +import android.os.RemoteException; +import android.util.Log; + +import com.google.android.gms.common.api.CommonStatusCodes; +import com.google.android.gms.common.api.Status; +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.GmsService; + +public class MeasurementBrokerService extends BaseService { + public MeasurementBrokerService() { + super("GmsMeasureBrokerSvc", GmsService.MEASUREMENT); + } + + @Override + public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { + callback.onPostInitComplete(CommonStatusCodes.SUCCESS, new MeasurementServiceImpl().asBinder(), null); + } +} diff --git a/play-services-core/src/main/java/org/microg/gms/measurement/MeasurementServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/measurement/MeasurementServiceImpl.java new file mode 100644 index 00000000..bba81666 --- /dev/null +++ b/play-services-core/src/main/java/org/microg/gms/measurement/MeasurementServiceImpl.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2018 microG 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.measurement; + +import android.os.Parcel; +import android.os.RemoteException; +import android.util.Log; + +import com.google.android.gms.measurement.internal.IMeasurementService; + +public class MeasurementServiceImpl extends IMeasurementService.Stub { + private static final String TAG = "GmsMeasureSvcImpl"; + + @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; + } +}