diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml
new file mode 100644
index 00000000..1913b6f2
--- /dev/null
+++ b/.github/workflows/debug.yml
@@ -0,0 +1,37 @@
+name: Debug APK Builder
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ branches:
+ - master
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v1
+ - name: JDK 8 Setup
+ uses: actions/setup-java@v1
+ with:
+ java-version: 11.0.8
+
+ - name: Install NDK
+ run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.0.6113669"
+
+ - name: Grant rights
+ run: chmod +x ./gradlew
+
+ - name: Build project
+ run: ./gradlew build
+
+ - name: Build APK
+ run: ./gradlew assembleDebug
+
+ - name: Upload to Artifacts
+ uses: actions/upload-artifact@v2
+ with:
+ name: 'MicroG'
+ path: play-services-core/build/outputs/apk/debug/play-services-core-debug.apk
\ No newline at end of file
diff --git a/README.md b/README.md
index 29f47891..b0b2112a 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,16 @@
-# Vanced+ MicroG
+# Vanced MicroG
-This fork tweaks MicroG to be usable by applications that require Google authentication such as [YouTube Vanced+](https://gitlab.com/cuynu/vancedx).
+
+[](https://github.com/inotia00/VancedMicroG/releases) [](https://github.com/inotia00/VancedMicroG/releases)
-## Warning!
-Vanced+ microG are currently **DOES NOT WORK** with ReVanced/RVX as they now uses their own ReVanced microG with specific package name! However, there are workaround : [Issues #15](https://gitlab.com/cuynu/VancedxMicroG/-/issues/15#note_1837372638)
+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.
+
+This fork tweaks MicroG to be usable by applications that require Google authentication such as Vanced.
## Notable changes
- 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 or device with Google Play Services pre-installed
+- Package name changed from `com.google.android.gms` to `com.mgoogle.android.gms` to support installation alongside the official MicroG
- Removed unnecessary features:
- Ads
- Analytics
@@ -32,4 +34,4 @@ Vanced+ microG are currently **DOES NOT WORK** with ReVanced/RVX as they now use
## Credits
- Source Code for MicroG 0.2.25.224113 was provided by [@OxrxL](https://github.com/OxrxL)
-- [@shadow578](https://github.com/shadow578)'s commit used to apply `SPOOFED_PACKAGE_SIGNATURE`
+- [@shadow578](https://github.com/shadow578)'s commit used to apply ReVanced's `SPOOFED_PACKAGE_SIGNATURE`
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index bcf0bcbe..accd8069 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,16 +4,11 @@
*/
buildscript {
- ext.applicationNamespace = "com.google.android.gms"
- ext.basePackageName = "com.mgoogle"
-
- ext.safeParcelVersion = '1.7.1'
-
- ext.kotlinVersion = '1.7.21'
+ ext.kotlinVersion = '1.7.20'
ext.coroutineVersion = '1.6.4'
ext.annotationVersion = '1.5.0'
- ext.appcompatVersion = '1.6.1'
+ ext.appcompatVersion = '1.5.1'
ext.coreVersion = '1.9.0'
ext.collectionVersion = '1.3.0-dev01'
ext.fragmentVersion = '1.5.5'
@@ -25,14 +20,14 @@ buildscript {
ext.circleimageviewVersion = '3.1.0'
ext.volleyVersion = '1.2.1'
- ext.wireVersion = '4.8.0'
+ ext.wireVersion = '4.4.3'
- ext.androidBuildGradleVersion = '8.0.2'
- ext.androidBuildVersionTools = '33.0.2'
+ ext.androidBuildGradleVersion = '7.3.1'
+ ext.androidBuildVersionTools = '33.0.1'
ext.androidMinSdk = 23
- ext.androidTargetSdk = 30
+ ext.androidTargetSdk = 29
ext.androidCompileSdk = 33
repositories {
@@ -47,13 +42,22 @@ buildscript {
}
}
+def execResult(...args) {
+ def stdout = new ByteArrayOutputStream()
+ exec {
+ commandLine args
+ standardOutput = stdout
+ }
+ return stdout.toString()
+}
-def gmsVersion = "25.09.34"
+def gmsVersion = "22.49.13"
def gmsVersionCode = Integer.parseInt(gmsVersion.replaceAll('\\.', ''))
-def ourVersionBase = "0.3.0"
+def ourVersionBase = "0.2.26"
+def ourVersionMinor = 52
-def ourVersionCode = gmsVersionCode * 1000
+def ourVersionCode = gmsVersionCode * 1000 + ourVersionMinor
def ourVersionName = "$ourVersionBase.$gmsVersionCode"
allprojects {
@@ -70,13 +74,4 @@ subprojects {
mavenCentral()
google()
}
- afterEvaluate {
- // Temporary hack for Android Studio
- if (project.plugins.hasPlugin('com.android.base')) {
- dependencies {
- compileOnly "org.microg:safe-parcel:$safeParcelVersion"
- testCompileOnly "org.microg:safe-parcel:$safeParcelVersion"
- }
- }
- }
}
\ No newline at end of file
diff --git a/fake-signature/build.gradle b/fake-signature/build.gradle
deleted file mode 100644
index e04d9893..00000000
--- a/fake-signature/build.gradle
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-apply plugin: 'com.android.library'
-
-android {
- namespace "org.microg.signature.fake"
-
- compileSdkVersion androidCompileSdk
- buildToolsVersion androidBuildVersionTools
-
- defaultConfig {
- minSdkVersion androidMinSdk
- targetSdkVersion androidTargetSdk
- }
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_17
- targetCompatibility JavaVersion.VERSION_17
- }
-}
-
-dependencies {
-}
diff --git a/fake-signature/src/main/AndroidManifest.xml b/fake-signature/src/main/AndroidManifest.xml
deleted file mode 100644
index 1b3ae15d..00000000
--- a/fake-signature/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,1159 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/fake-signature/src/main/res/values/arrays.xml b/fake-signature/src/main/res/values/arrays.xml
deleted file mode 100644
index 315cce58..00000000
--- a/fake-signature/src/main/res/values/arrays.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
- - com.google.android.gms
- - com.android.vending
- - com.spotify.music
-
-
- - com.truecaller
-
-
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index 126b7d28..976747da 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,5 +1,3 @@
android.useAndroidX=true
+android.disableAutomaticComponentCreation=true
org.gradle.jvmargs=-Xmx2048m -XX:+UseParallelGC
-android.defaults.buildfeatures.buildconfig=true
-android.nonTransitiveRClass=false
-android.nonFinalResIds=false
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index d64cd491..62d4c053 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 0e1ae8ce..d38c612c 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,6 @@
+#Mon Dec 22 22:27:19 CET 2022
distributionBase=GRADLE_USER_HOME
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
-networkTimeout=10000
-validateDistributionUrl=true
-zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
diff --git a/gradlew b/gradlew
index 1aa94a42..60cf9e8c 100755
--- a/gradlew
+++ b/gradlew
@@ -1,5 +1,6 @@
#!/bin/sh
+# SPDX-License-Identifier: Apache-2.0
#
# Copyright © 2015-2021 the original authors.
#
@@ -55,7 +56,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,11 +81,13 @@ do
esac
done
-# This is normally unused
-# shellcheck disable=SC2034
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+
+APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}
-# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -125,35 +128,26 @@ if [ -n "$JAVA_HOME" ] ; then
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
- if ! command -v java >/dev/null 2>&1
- then
- die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
- fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
- # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
- # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -198,15 +192,11 @@ if "$cygwin" || "$msys" ; then
done
fi
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
-# Collect all arguments for the java command:
-# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
-# and any embedded shellness will be escaped.
-# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
-# treated as '${Hostname}' itself on the command line.
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
@@ -214,12 +204,6 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
-# Stop when "xargs" is not available.
-if ! command -v xargs >/dev/null 2>&1
-then
- die "xargs is not available"
-fi
-
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
@@ -246,4 +230,4 @@ eval "set -- $(
tr '\n' ' '
)" '"$@"'
-exec "$JAVACMD" "$@"
+exec "$JAVACMD" "$@"
\ No newline at end of file
diff --git a/gradlew.bat b/gradlew.bat
index 93e3f59f..5093609d 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
-@if "%DEBUG%"=="" @echo off
+@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,8 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%"=="" set DIRNAME=.
-@rem This is normally unused
+if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -41,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if %ERRORLEVEL% equ 0 goto execute
+if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -55,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto execute
+if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -65,6 +64,21 @@ echo location of your Java installation.
goto fail
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
:execute
@rem Setup the command line
@@ -72,19 +86,17 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
+if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
-set EXIT_CODE=%ERRORLEVEL%
-if %EXIT_CODE% equ 0 set EXIT_CODE=1
-if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
-exit /b %EXIT_CODE%
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/play-services-api/build.gradle b/play-services-api/build.gradle
index 20d8bea5..e254f48d 100644
--- a/play-services-api/build.gradle
+++ b/play-services-api/build.gradle
@@ -26,13 +26,9 @@ android {
}
compileOptions {
- sourceCompatibility = 17
- targetCompatibility = 17
+ sourceCompatibility = 1.8
+ targetCompatibility = 1.8
}
- buildFeatures {
- aidl true
- }
- namespace 'org.microg.gms.api'
}
dependencies {
diff --git a/play-services-api/src/main/AndroidManifest.xml b/play-services-api/src/main/AndroidManifest.xml
index 359a9b71..d4a4d07a 100644
--- a/play-services-api/src/main/AndroidManifest.xml
+++ b/play-services-api/src/main/AndroidManifest.xml
@@ -15,4 +15,4 @@
~ limitations under the License.
-->
-
+
diff --git a/play-services-api/src/main/aidl/com/google/android/auth/IAuthManagerService.aidl b/play-services-api/src/main/aidl/com/google/android/auth/IAuthManagerService.aidl
index d6afdf80..ae33a334 100644
--- a/play-services-api/src/main/aidl/com/google/android/auth/IAuthManagerService.aidl
+++ b/play-services-api/src/main/aidl/com/google/android/auth/IAuthManagerService.aidl
@@ -7,7 +7,7 @@ import com.google.android.gms.auth.AccountChangeEventsResponse;
import com.google.android.gms.auth.AccountChangeEventsRequest;
import com.google.android.gms.auth.GetHubTokenRequest;
import com.google.android.gms.auth.GetHubTokenInternalResponse;
-import com.google.android.gms.auth.HasCapabilitiesRequest;
+import com.google.android.gms.auth.HasCababilitiesRequest;
interface IAuthManagerService {
Bundle getToken(String accountName, String scope, in Bundle extras) = 0;
@@ -18,6 +18,6 @@ interface IAuthManagerService {
Bundle getAccounts(in Bundle extras) = 5;
Bundle removeAccount(in Account account) = 6;
Bundle requestGoogleAccountsAccess(String packageName) = 7;
- int hasCapabilities(in HasCapabilitiesRequest request) = 8;
+ int hasCapabilities(in HasCababilitiesRequest request) = 8;
GetHubTokenInternalResponse getHubToken(in GetHubTokenRequest request, in Bundle extras) = 9;
}
diff --git a/play-services-api/src/main/aidl/com/google/android/gms/auth/HasCapabilitiesRequest.aidl b/play-services-api/src/main/aidl/com/google/android/gms/auth/HasCababilitiesRequest.aidl
similarity index 52%
rename from play-services-api/src/main/aidl/com/google/android/gms/auth/HasCapabilitiesRequest.aidl
rename to play-services-api/src/main/aidl/com/google/android/gms/auth/HasCababilitiesRequest.aidl
index b6cb6b9d..c0c080cd 100644
--- a/play-services-api/src/main/aidl/com/google/android/gms/auth/HasCapabilitiesRequest.aidl
+++ b/play-services-api/src/main/aidl/com/google/android/gms/auth/HasCababilitiesRequest.aidl
@@ -1,3 +1,3 @@
package com.google.android.gms.auth;
-parcelable HasCapabilitiesRequest;
+parcelable HasCababilitiesRequest;
diff --git a/play-services-api/src/main/aidl/com/google/android/gms/common/internal/GoogleCertificatesQuery.aidl b/play-services-api/src/main/aidl/com/google/android/gms/common/internal/GoogleCertificatesQuery.aidl
new file mode 100644
index 00000000..ae02e068
--- /dev/null
+++ b/play-services-api/src/main/aidl/com/google/android/gms/common/internal/GoogleCertificatesQuery.aidl
@@ -0,0 +1,3 @@
+package com.google.android.gms.common.internal;
+
+parcelable GoogleCertificatesQuery;
\ No newline at end of file
diff --git a/play-services-basement/src/main/aidl/com/google/android/gms/common/internal/ICertData.aidl b/play-services-api/src/main/aidl/com/google/android/gms/common/internal/ICertData.aidl
similarity index 100%
rename from play-services-basement/src/main/aidl/com/google/android/gms/common/internal/ICertData.aidl
rename to play-services-api/src/main/aidl/com/google/android/gms/common/internal/ICertData.aidl
diff --git a/play-services-api/src/main/aidl/com/google/android/gms/common/internal/IGoogleCertificatesApi.aidl b/play-services-api/src/main/aidl/com/google/android/gms/common/internal/IGoogleCertificatesApi.aidl
new file mode 100644
index 00000000..da539f32
--- /dev/null
+++ b/play-services-api/src/main/aidl/com/google/android/gms/common/internal/IGoogleCertificatesApi.aidl
@@ -0,0 +1,12 @@
+package com.google.android.gms.common.internal;
+
+import com.google.android.gms.common.internal.GoogleCertificatesQuery;
+import com.google.android.gms.dynamic.IObjectWrapper;
+
+interface IGoogleCertificatesApi {
+ IObjectWrapper getGoogleCertficates();
+ IObjectWrapper getGoogleReleaseCertificates();
+ boolean isGoogleReleaseSigned(String packageName, IObjectWrapper certData);
+ boolean isGoogleSigned(String packageName, IObjectWrapper certData);
+ boolean isGoogleOrPlatformSigned(in GoogleCertificatesQuery query, IObjectWrapper packageManager);
+}
\ No newline at end of file
diff --git a/play-services-basement/src/main/aidl/com/google/android/gms/common/internal/ISignInButtonCreator.aidl b/play-services-api/src/main/aidl/com/google/android/gms/common/internal/ISignInButtonCreator.aidl
similarity index 100%
rename from play-services-basement/src/main/aidl/com/google/android/gms/common/internal/ISignInButtonCreator.aidl
rename to play-services-api/src/main/aidl/com/google/android/gms/common/internal/ISignInButtonCreator.aidl
diff --git a/play-services-api/src/main/java/com/google/android/gms/auth/HasCapabilitiesRequest.java b/play-services-api/src/main/java/com/google/android/gms/auth/HasCababilitiesRequest.java
similarity index 63%
rename from play-services-api/src/main/java/com/google/android/gms/auth/HasCapabilitiesRequest.java
rename to play-services-api/src/main/java/com/google/android/gms/auth/HasCababilitiesRequest.java
index e35ca6d7..27b94732 100644
--- a/play-services-api/src/main/java/com/google/android/gms/auth/HasCapabilitiesRequest.java
+++ b/play-services-api/src/main/java/com/google/android/gms/auth/HasCababilitiesRequest.java
@@ -9,10 +9,10 @@ import android.accounts.Account;
import org.microg.safeparcel.AutoSafeParcelable;
-public class HasCapabilitiesRequest extends AutoSafeParcelable {
+public class HasCababilitiesRequest extends AutoSafeParcelable {
@Field(1)
public Account account;
@Field(2)
public String[] capabilities;
- public static final Creator CREATOR = new AutoCreator<>(HasCapabilitiesRequest.class);
+ public static final Creator CREATOR = new AutoCreator<>(HasCababilitiesRequest.class);
}
diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/internal/CertData.java b/play-services-api/src/main/java/com/google/android/gms/common/internal/CertData.java
similarity index 100%
rename from play-services-basement/src/main/java/com/google/android/gms/common/internal/CertData.java
rename to play-services-api/src/main/java/com/google/android/gms/common/internal/CertData.java
diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/GoogleCertificatesQuery.java b/play-services-api/src/main/java/com/google/android/gms/common/internal/GoogleCertificatesQuery.java
similarity index 57%
rename from play-services-basement/src/main/java/com/google/android/gms/common/GoogleCertificatesQuery.java
rename to play-services-api/src/main/java/com/google/android/gms/common/internal/GoogleCertificatesQuery.java
index dce40a90..c8240279 100644
--- a/play-services-basement/src/main/java/com/google/android/gms/common/GoogleCertificatesQuery.java
+++ b/play-services-api/src/main/java/com/google/android/gms/common/internal/GoogleCertificatesQuery.java
@@ -1,38 +1,41 @@
/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.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 com.google.android.gms.common;
+package com.google.android.gms.common.internal;
import android.os.IBinder;
-import android.os.Parcel;
import android.os.RemoteException;
-import androidx.annotation.NonNull;
-import com.google.android.gms.common.internal.CertData;
-import com.google.android.gms.common.internal.ICertData;
-import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
-import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
-import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter;
+
import com.google.android.gms.dynamic.IObjectWrapper;
import com.google.android.gms.dynamic.ObjectWrapper;
-import org.microg.gms.common.Hide;
-@Hide
-@SafeParcelable.Class
-public class GoogleCertificatesQuery extends AbstractSafeParcelable {
- @Field(value = 1, getterName = "getCallingPackage")
- String callingPackage;
- @Field(2)
- IBinder certDataBinder;
+import org.microg.safeparcel.AutoSafeParcelable;
+import org.microg.safeparcel.SafeParceled;
+
+public class GoogleCertificatesQuery extends AutoSafeParcelable {
+ @SafeParceled(1)
+ private String packageName;
+ @SafeParceled(2)
+ private IBinder certDataBinder;
private CertData certData;
- @Field(3)
- boolean allowTestKeys;
- @Field(4)
- boolean ignoreTestKeysOverride;
+ @SafeParceled(3)
+ private boolean allowNonRelease;
- public String getCallingPackage() {
- return callingPackage;
+ public String getPackageName() {
+ return packageName;
}
public CertData getCertData() {
@@ -68,10 +71,5 @@ public class GoogleCertificatesQuery extends AbstractSafeParcelable {
return certData;
}
- @Override
- public void writeToParcel(@NonNull Parcel dest, int flags) {
- CREATOR.writeToParcel(this, dest, flags);
- }
-
- public static final SafeParcelableCreatorAndWriter CREATOR = findCreator(GoogleCertificatesQuery.class);
+ public static final Creator CREATOR = new AutoCreator(GoogleCertificatesQuery.class);
}
diff --git a/play-services-base-api/build.gradle b/play-services-base-api/build.gradle
index 23b6b07c..b806da4c 100644
--- a/play-services-base-api/build.gradle
+++ b/play-services-base-api/build.gradle
@@ -34,11 +34,7 @@ android {
}
compileOptions {
- sourceCompatibility = 17
- targetCompatibility = 17
+ sourceCompatibility = 1.8
+ targetCompatibility = 1.8
}
- buildFeatures {
- aidl true
- }
- namespace 'org.microg.gms.base.api'
}
\ No newline at end of file
diff --git a/play-services-base-api/src/main/AndroidManifest.xml b/play-services-base-api/src/main/AndroidManifest.xml
index 055d07d5..7c8eeef3 100644
--- a/play-services-base-api/src/main/AndroidManifest.xml
+++ b/play-services-base-api/src/main/AndroidManifest.xml
@@ -3,4 +3,4 @@
~ SPDX-FileCopyrightText: 2020, microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->
-
+
diff --git a/play-services-base-api/src/main/java/com/google/android/gms/common/data/DataHolder.java b/play-services-base-api/src/main/java/com/google/android/gms/common/data/DataHolder.java
index 4af2bcf1..f7b8e46a 100644
--- a/play-services-base-api/src/main/java/com/google/android/gms/common/data/DataHolder.java
+++ b/play-services-base-api/src/main/java/com/google/android/gms/common/data/DataHolder.java
@@ -18,12 +18,8 @@ package com.google.android.gms.common.data;
import android.annotation.SuppressLint;
import android.content.ContentValues;
-import android.database.AbstractWindowedCursor;
-import android.database.CharArrayBuffer;
import android.database.Cursor;
import android.database.CursorWindow;
-import android.net.Uri;
-import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
@@ -45,9 +41,6 @@ import java.util.Map;
*/
@PublicApi(until = "1")
public class DataHolder extends AutoSafeParcelable implements Closeable {
- @SafeParceled(1000)
- private final int versionCode = 1;
-
@SafeParceled(1)
private final String[] columns;
@@ -69,13 +62,6 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
protected static final int FIELD_TYPE_STRING = 3;
protected static final int FIELD_TYPE_BLOB = 4;
- private DataHolder() {
- columns = null;
- windows = null;
- statusCode = 0;
- metadata = null;
- }
-
/**
* Creates a data holder with the specified data.
*
@@ -92,17 +78,6 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
validateContents();
}
- /**
- * Creates a data holder wrapping the provided cursor, with provided status code and metadata.
- *
- * @param cursor The cursor containing the data.
- * @param statusCode The status code of this {@link DataHolder}.
- * @param metadata The metadata associated with this {@link DataHolder} (may be null).
- */
- public DataHolder(AbstractWindowedCursor cursor, int statusCode, Bundle metadata) {
- this(cursor.getColumnNames(), createCursorWindows(cursor), statusCode, metadata);
- }
-
/**
* Creates a data holder wrapping the provided cursor, with provided status code and metadata.
*
@@ -135,23 +110,7 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
return builder(columns, null);
}
- /**
- * @param statusCode The status code of this {@link DataHolder}.
- * @param metadata The metadata associated with this {@link DataHolder} (may be null).
- * @return An empty {@link DataHolder} object with the given status and metadata.
- */
- public static DataHolder empty(int statusCode, Bundle metadata) {
- return new DataHolder(new String[0], new CursorWindow[0], statusCode, metadata);
- }
-
- /**
- * @param statusCode The status code of this {@link DataHolder}.
- * @return An empty {@link DataHolder} object with the given status and null metadata.
- */
- public static DataHolder empty(int statusCode) {
- return empty(statusCode, null);
- }
-
+ @SuppressWarnings("deprecation")
@SuppressLint({"NewApi", "ObsoleteSdkInt"})
static int getCursorType(Cursor cursor, int i) {
return cursor.getType(i);
@@ -172,20 +131,6 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
}
}
- /**
- * Copies the String content in the given column at the provided position into a {@link CharArrayBuffer}.
- * This will throw an {@link IllegalArgumentException} if the column does not exist, the
- * position is invalid, or the data holder has been closed.
- *
- * @param column The column to retrieve.
- * @param row The row to retrieve the data from.
- * @param windowIndex Index of the cursor window to extract the data from.
- * @param dataOut The {@link CharArrayBuffer} to copy into.
- */
- public void copyToBuffer(String column, int row, int windowIndex, CharArrayBuffer dataOut) {
- throw new RuntimeException("Not yet available");
- }
-
@SuppressWarnings("deprecation")
private static CursorWindow[] createCursorWindows(Builder builder) {
if (builder.columns.length == 0) return new CursorWindow[0];
@@ -278,34 +223,6 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
return windows.toArray(new CursorWindow[0]);
}
- /**
- * Retrieves the boolean value for a given column at the provided position.
- * This will throw an {@link IllegalArgumentException} if the column does not exist, the
- * position is invalid, or the data holder has been closed.
- *
- * @param column The column to retrieve.
- * @param row The row to retrieve the data from.
- * @param windowIndex Index of the cursor window to extract the data from.
- * @return The boolean value in that column.
- */
- public boolean getBoolean(String column, int row, int windowIndex) {
- return windows[windowIndex].getLong(row, columnIndices.get(column)) == 1;
- }
-
- /**
- * Retrieves the byte array value for a given column at the provided position.
- * This will throw an {@link IllegalArgumentException} if the column does not exist, the
- * position is invalid, or the data holder has been closed.
- *
- * @param column The column to retrieve.
- * @param row The row to retrieve the data from.
- * @param windowIndex Index of the cursor window to extract the data from.
- * @return The byte array value in that column.
- */
- public byte[] getByteArray(String column, int row, int windowIndex) {
- return windows[windowIndex].getBlob(row, columnIndices.get(column));
- }
-
/**
* Gets the number of rows in the data holder.
*
@@ -321,38 +238,6 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
return c;
}
- /**
- * Retrieves the integer value for a given column at the provided position.
- * This will throw an {@link IllegalArgumentException} if the column does not exist, the
- * position is invalid, or the data holder has been closed.
- *
- * @param column The column to retrieve.
- * @param row The row to retrieve the data from.
- * @param windowIndex Index of the cursor window to extract the data from.
- * @return The integer value in that column.
- */
- public int getInteger(String column, int row, int windowIndex) {
- return windows[windowIndex].getInt(row, columnIndices.get(column));
- }
-
- /**
- * Retrieves the long value for a given column at the provided position.
- * This will throw an {@link IllegalArgumentException} if the column does not exist, the
- * position is invalid, or the data holder has been closed.
- *
- * @param column The column to retrieve.
- * @param row The row to retrieve the data from.
- * @param windowIndex Index of the cursor window to extract the data from.
- * @return The long value in that column.
- */
- public long getLong(String column, int row, int windowIndex) {
- return windows[windowIndex].getLong(row, columnIndices.get(column));
- }
-
- public int getStatusCode() {
- return statusCode;
- }
-
/**
* Retrieves the string value for a given column at the provided position.
* This will throw an {@link IllegalArgumentException} if the column does not exist, the
@@ -367,42 +252,6 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
return windows[windowIndex].getString(row, columnIndices.get(column));
}
- /**
- * Returns whether the given column at the provided position contains null.
- * This will throw an {@link IllegalArgumentException} if the column does not exist, the
- * position is invalid, or the data holder has been closed.
- *
- * @param column The column to retrieve.
- * @param row The row to retrieve the data from.
- * @param windowIndex Index of the cursor window to extract the data from.
- * @return Whether the column value is null at this position.
- */
- public boolean isNull(String column, int row, int windowIndex) {
- return windows[windowIndex].isNull(row, columnIndices.get(column));
- }
-
- public boolean isClosed() {
- synchronized (this) {
- return closed;
- }
- }
-
- /**
- * Retrieves the column data at the provided position as a URI if possible, checking for null values.
- * This will throw an {@link IllegalArgumentException} if the column does not exist, the
- * position is invalid, or the data holder has been closed.
- *
- * @param column The column to retrieve.
- * @param row The row to retrieve the data from.
- * @param windowIndex Index of the cursor window to extract the data from.
- * @return The column data as a URI, or null if not present.
- */
- public Uri parseUri(String column, int row, int windowIndex) {
- String string = getString(column, row, windowIndex);
- if (string != null) return Uri.parse(string);
- return null;
- }
-
@Override
public String toString() {
return "DataHolder{" +
@@ -466,18 +315,6 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
return rows.size();
}
- /**
- * Sort the rows in this builder based on the standard data type comparisons for the value in the provided column.
- * Calling this multiple times with the same column will not change the sort order of the builder.
- * Note that any data which is added after this call will not be sorted.
- *
- * @param sortColumn The column to sort the rows in this builder by.
- * @return {@link DataHolder.Builder} to continue construction.
- */
- public Builder sort(String sortColumn) {
- throw new RuntimeException("Not yet implemented");
- }
-
/**
* Add a new row of data to the {@link DataHolder} this {@link DataHolder.Builder} will create. Note that the data must contain an entry for all columns
*
diff --git a/play-services-base-core/build.gradle b/play-services-base-core/build.gradle
index 34288f21..a0849ff8 100644
--- a/play-services-base-core/build.gradle
+++ b/play-services-base-core/build.gradle
@@ -21,10 +21,9 @@ android {
buildToolsVersion androidBuildVersionTools
defaultConfig {
+ versionName version
minSdkVersion androidMinSdk
targetSdkVersion androidTargetSdk
-
- buildConfigField "String", "BASE_PACKAGE_NAME", "\"$basePackageName\""
}
sourceSets {
@@ -32,8 +31,7 @@ android {
}
compileOptions {
- sourceCompatibility = 17
- targetCompatibility = 17
+ sourceCompatibility = 1.8
+ targetCompatibility = 1.8
}
- namespace 'org.microg.gms.base.core'
}
\ No newline at end of file
diff --git a/play-services-base-core/src/main/AndroidManifest.xml b/play-services-base-core/src/main/AndroidManifest.xml
index 369707e7..de583c4d 100644
--- a/play-services-base-core/src/main/AndroidManifest.xml
+++ b/play-services-base-core/src/main/AndroidManifest.xml
@@ -3,26 +3,11 @@
~ SPDX-FileCopyrightText: 2020, microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->
-
-
-
-
-
+
-
-
+ android:exported="false" />
diff --git a/play-services-base-core/src/main/java/org/microg/gms/AbstractGmsServiceBroker.java b/play-services-base-core/src/main/java/org/microg/gms/AbstractGmsServiceBroker.java
index a0ff2b99..1cd39310 100644
--- a/play-services-base-core/src/main/java/org/microg/gms/AbstractGmsServiceBroker.java
+++ b/play-services-base-core/src/main/java/org/microg/gms/AbstractGmsServiceBroker.java
@@ -18,6 +18,7 @@ package org.microg.gms;
import android.accounts.Account;
import android.os.Bundle;
+import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;
@@ -28,7 +29,6 @@ import com.google.android.gms.common.internal.IGmsCallbacks;
import com.google.android.gms.common.internal.IGmsServiceBroker;
import com.google.android.gms.common.internal.ValidateAccountRequest;
-import org.microg.gms.base.core.BuildConfig;
import org.microg.gms.common.GmsService;
import java.util.EnumSet;
@@ -77,7 +77,7 @@ public abstract class AbstractGmsServiceBroker extends IGmsServiceBroker.Stub {
request.gmsVersion = gmsVersion;
request.packageName = packageName;
request.extras = extras;
- request.account = accountName == null ? null : new Account(accountName, BuildConfig.BASE_PACKAGE_NAME);
+ request.account = accountName == null ? null : new Account(accountName, "com.mgoogle");
request.scopes = scopes == null ? null : scopesFromStringArray(scopes);
getService(callback, request);
}
diff --git a/play-services-base-core/src/main/java/org/microg/gms/common/DeviceConfiguration.java b/play-services-base-core/src/main/java/org/microg/gms/common/DeviceConfiguration.java
index 55bffb3c..d4ab5940 100644
--- a/play-services-base-core/src/main/java/org/microg/gms/common/DeviceConfiguration.java
+++ b/play-services-base-core/src/main/java/org/microg/gms/common/DeviceConfiguration.java
@@ -16,8 +16,6 @@
package org.microg.gms.common;
-import android.annotation.SuppressLint;
-
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
@@ -28,8 +26,6 @@ import android.opengl.GLES10;
import android.os.Build;
import android.util.DisplayMetrics;
-import org.microg.gms.profile.ProfileManager;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -60,7 +56,6 @@ public class DeviceConfiguration {
public int widthPixels;
public DeviceConfiguration(Context context) {
- ProfileManager.ensureInitialized(context);
ConfigurationInfo configurationInfo = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getDeviceConfigurationInfo();
touchScreen = configurationInfo.reqTouchScreen;
keyboardType = configurationInfo.reqKeyboardType;
@@ -83,35 +78,29 @@ public class DeviceConfiguration {
}
Collections.sort(sharedLibraries);
availableFeatures = new ArrayList<>();
- packageManager.getSystemAvailableFeatures();
- for (FeatureInfo featureInfo : packageManager.getSystemAvailableFeatures()) {
- if (featureInfo != null && featureInfo.name != null)
- availableFeatures.add(featureInfo.name);
+ if (packageManager.getSystemAvailableFeatures() != null) {
+ for (FeatureInfo featureInfo : packageManager.getSystemAvailableFeatures()) {
+ if (featureInfo != null && featureInfo.name != null) availableFeatures.add(featureInfo.name);
+ }
}
Collections.sort(availableFeatures);
this.nativePlatforms = getNativePlatforms();
widthPixels = displayMetrics.widthPixels;
heightPixels = displayMetrics.heightPixels;
- locales = getLocales(context);
+ locales = new ArrayList<>(Arrays.asList(context.getAssets().getLocales()));
+ for (int i = 0; i < locales.size(); i++) {
+ locales.set(i, locales.get(i).replace("-", "_"));
+ }
+ Collections.sort(locales);
Set glExtensions = new HashSet<>();
addEglExtensions(glExtensions);
this.glExtensions = new ArrayList<>(glExtensions);
Collections.sort(this.glExtensions);
}
- @SuppressLint("GetLocales")
- private static List getLocales(Context context) {
- List locales = new ArrayList();
- locales.addAll(Arrays.asList(context.getAssets().getLocales()));
- for (int i = 0; i < locales.size(); i++) {
- locales.set(i, locales.get(i).replace("-", "_"));
- }
- Collections.sort(locales);
- return locales;
- }
-
- @SuppressWarnings({"InlinedApi"})
+ @SuppressWarnings({"deprecation", "InlinedApi"})
private static List getNativePlatforms() {
+ List nativePlatforms;
return Arrays.asList(Build.SUPPORTED_ABIS);
}
diff --git a/play-services-base-core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java b/play-services-base-core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java
index 417ad6f7..c7a2ff52 100644
--- a/play-services-base-core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java
+++ b/play-services-base-core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java
@@ -1,7 +1,5 @@
package org.microg.gms.common;
-import static android.os.Build.VERSION.SDK_INT;
-
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationChannel;
@@ -13,6 +11,7 @@ import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.net.Uri;
+import android.os.Build;
import android.os.PowerManager;
import android.provider.Settings;
import android.util.Log;
@@ -34,7 +33,7 @@ public class ForegroundServiceContext extends ContextWrapper {
if (!isIgnoringBatteryOptimizations()) {
Log.d(TAG, "Starting in foreground mode.");
service.putExtra(EXTRA_FOREGROUND, true);
- if (SDK_INT >= 26) {
+ if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return super.startForegroundService(service);
} else {
return super.startService(service);
@@ -76,7 +75,7 @@ public class ForegroundServiceContext extends ContextWrapper {
String serviceName = getServiceName(service);
Log.d(tag, "Started " + serviceName + " in foreground mode.");
try {
- Notification notification = buildForegroundNotification(service);
+ Notification notification = buildForegroundNotification(service, serviceName);
service.startForeground(serviceName.hashCode(), notification);
Log.d(tag, "Notification: " + notification);
} catch (Exception e) {
@@ -86,9 +85,9 @@ public class ForegroundServiceContext extends ContextWrapper {
}
@SuppressLint("BatteryLife")
- private static Notification buildForegroundNotification(Context context) {
+ private static Notification buildForegroundNotification(Context context, String serviceName) {
Intent notificationIntent = new Intent();
- if (SDK_INT >= 31) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
notificationIntent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
notificationIntent.setData(Uri.parse("package:" + context.getPackageName()));
} else {
@@ -98,8 +97,8 @@ public class ForegroundServiceContext extends ContextWrapper {
PendingIntent notificationPendingIntent = PendingIntent.getActivity(context,
0,
notificationIntent,
- PendingIntent.FLAG_IMMUTABLE);
- if (SDK_INT >= 26) {
+ 0);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel Channel = new NotificationChannel("foreground-service",
context.getResources().getString(R.string.notification_service_name),
NotificationManager.IMPORTANCE_LOW);
diff --git a/play-services-base-core/src/main/java/org/microg/gms/common/PackageUtils.java b/play-services-base-core/src/main/java/org/microg/gms/common/PackageUtils.java
index 03fd8b93..50d112d0 100644
--- a/play-services-base-core/src/main/java/org/microg/gms/common/PackageUtils.java
+++ b/play-services-base-core/src/main/java/org/microg/gms/common/PackageUtils.java
@@ -16,10 +16,6 @@
package org.microg.gms.common;
-import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME;
-import static org.microg.gms.common.Constants.GMS_PACKAGE_SIGNATURE_SHA1;
-
-import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.Application;
import android.app.PendingIntent;
@@ -32,8 +28,6 @@ import android.util.Log;
import androidx.annotation.Nullable;
-import org.microg.gms.base.core.BuildConfig;
-
import java.lang.reflect.Method;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -41,25 +35,28 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
+
+import static android.os.Build.VERSION.SDK_INT;
+import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME;
+import static org.microg.gms.common.Constants.GMS_PACKAGE_SIGNATURE_SHA1;
+import static org.microg.gms.common.Constants.GMS_SECONDARY_PACKAGE_SIGNATURE_SHA1;
public class PackageUtils {
private static final String GOOGLE_PLATFORM_KEY = GMS_PACKAGE_SIGNATURE_SHA1;
- private static final String GOOGLE_LEGACY_KEY = "58e1c4133f7441ec3d2c270270a14802da47ba0e"; // Seems to be no longer used.
- private static final String[] GOOGLE_PRIMARY_KEYS = {GOOGLE_PLATFORM_KEY, "24bb24c05e47e0aefa68a58a766179d9b613a600", "afb0fed5eeaebdd86f56a97742f4b6b33ef59875", "61226bdb57cc32c8a2a9ef71f7bc9548e95dcc0b", "3a82b5ee26bc46bf68113d920e610cd090198d4a"};
+ private static final String GOOGLE_PLATFORM_KEY_2 = GMS_SECONDARY_PACKAGE_SIGNATURE_SHA1;
+ private static final String GOOGLE_APP_KEY = "24bb24c05e47e0aefa68a58a766179d9b613a600";
+ private static final String[] GOOGLE_PRIMARY_KEYS = {GOOGLE_PLATFORM_KEY, GOOGLE_PLATFORM_KEY_2, GOOGLE_APP_KEY};
- public static final Map KNOWN_GOOGLE_PACKAGES;
+ private static final Map KNOWN_GOOGLE_PACKAGES;
static {
KNOWN_GOOGLE_PACKAGES = new HashMap<>();
- KNOWN_GOOGLE_PACKAGES.put("com.google.android.apps.youtube", "24bb24c05e47e0aefa68a58a766179d9b613a600");
KNOWN_GOOGLE_PACKAGES.put("com.google.android.apps.youtube.music", "afb0fed5eeaebdd86f56a97742f4b6b33ef59875");
}
public static boolean isGooglePackage(Context context, String packageName) {
String signatureDigest = firstSignatureDigest(context, packageName);
- packageName = PackageSpoofUtils.spoofPackageName(context.getPackageManager(), packageName);
return isGooglePackage(packageName, signatureDigest);
}
@@ -76,7 +73,7 @@ public class PackageUtils {
if (signatureDigest == null) return false;
if (Arrays.asList(GOOGLE_PRIMARY_KEYS).contains(signatureDigest)) return true;
if (!KNOWN_GOOGLE_PACKAGES.containsKey(packageName)) return false;
- return Objects.equals(KNOWN_GOOGLE_PACKAGES.get(packageName), signatureDigest);
+ return KNOWN_GOOGLE_PACKAGES.get(packageName).equals(signatureDigest);
}
public static void assertExtendedAccess(Context context) {
@@ -86,14 +83,14 @@ public class PackageUtils {
public static boolean callerHasExtendedAccess(Context context) {
String[] packagesForUid = context.getPackageManager().getPackagesForUid(Binder.getCallingUid());
- if (packagesForUid != null) {
+ if (packagesForUid != null && packagesForUid.length != 0) {
for (String packageName : packagesForUid) {
packageName = PackageSpoofUtils.spoofPackageName(context.getPackageManager(), packageName);
if (isGooglePackage(context, packageName) || GMS_PACKAGE_NAME.equals(packageName))
return true;
}
}
- return context.checkCallingPermission(BuildConfig.BASE_PACKAGE_NAME + ".gms.EXTENDED_ACCESS") == PackageManager.PERMISSION_GRANTED;
+ return context.checkCallingPermission("org.mgoogle.gms.EXTENDED_ACCESS") == PackageManager.PERMISSION_GRANTED;
}
public static void checkPackageUid(Context context, String packageName, int callingUid) {
@@ -123,9 +120,9 @@ public class PackageUtils {
try {
info = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
} catch (PackageManager.NameNotFoundException e) {
- return KNOWN_GOOGLE_PACKAGES.get(packageName);
+ return null;
}
- if (info != null && info.signatures != null) {
+ if (info != null && info.signatures != null && info.signatures.length > 0) {
for (Signature sig : info.signatures) {
String digest = sha1sum(sig.toByteArray());
if (digest != null) {
@@ -150,7 +147,7 @@ public class PackageUtils {
} catch (PackageManager.NameNotFoundException e) {
return null;
}
- if (info != null && info.signatures != null) {
+ if (info != null && info.signatures != null && info.signatures.length > 0) {
for (Signature sig : info.signatures) {
byte[] digest = sha1bytes(sig.toByteArray());
if (digest != null) {
@@ -181,7 +178,10 @@ public class PackageUtils {
} catch (final NoSuchAlgorithmException e) {
return null;
}
- return md.digest(bytes);
+ if (md != null) {
+ return md.digest(bytes);
+ }
+ return null;
}
@Nullable
@@ -220,7 +220,7 @@ public class PackageUtils {
if (suggestedCallerPid > 0 && suggestedCallerPid != callingPid) {
throw new SecurityException("suggested PID [" + suggestedCallerPid + "] and real calling PID [" + callingPid + "] mismatch!");
}
- return getAndCheckPackage(context, suggestedPackageName, callingUid, callingPid);
+ return getAndCheckPackage(context, suggestedPackageName, callingUid, Binder.getCallingPid());
}
@Nullable
@@ -252,6 +252,7 @@ public class PackageUtils {
}
@Nullable
+ @Deprecated
public static String packageFromProcessId(Context context, int pid) {
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
if (manager == null) return null;
@@ -276,6 +277,7 @@ public class PackageUtils {
return null;
}
+ @SuppressWarnings("deprecation")
public static String packageFromPendingIntent(PendingIntent pi) {
if (pi == null) return null;
return pi.getCreatorPackage();
@@ -285,10 +287,8 @@ public class PackageUtils {
if (android.os.Build.VERSION.SDK_INT >= 28)
return Application.getProcessName();
try {
- @SuppressLint("PrivateApi")
Class> activityThread = Class.forName("android.app.ActivityThread");
String methodName = "currentProcessName";
- @SuppressLint("DiscouragedPrivateApi")
Method getProcessName = activityThread.getDeclaredMethod(methodName);
return (String) getProcessName.invoke(null);
} catch (Exception e) {
@@ -333,12 +333,17 @@ public class PackageUtils {
} catch (final NoSuchAlgorithmException e) {
return null;
}
- bytes = md.digest(bytes);
- StringBuilder sb = new StringBuilder(2 * bytes.length);
- for (byte b : bytes) {
- sb.append(String.format("%02x", b));
+ if (md != null) {
+ bytes = md.digest(bytes);
+ if (bytes != null) {
+ StringBuilder sb = new StringBuilder(2 * bytes.length);
+ for (byte b : bytes) {
+ sb.append(String.format("%02x", b));
+ }
+ return sb.toString();
+ }
}
- return sb.toString();
+ return null;
}
public static int versionCode(Context context, String packageName) {
diff --git a/play-services-base-core/src/main/kotlin/org/microg/gms/common/PackageSpoofUtils.kt b/play-services-base-core/src/main/kotlin/org/microg/gms/common/PackageSpoofUtils.kt
index 7aec1077..94ec088d 100644
--- a/play-services-base-core/src/main/kotlin/org/microg/gms/common/PackageSpoofUtils.kt
+++ b/play-services-base-core/src/main/kotlin/org/microg/gms/common/PackageSpoofUtils.kt
@@ -4,17 +4,15 @@ import android.content.pm.PackageManager
import android.os.Bundle
import android.util.Log
-import org.microg.gms.base.core.BuildConfig
-
/**
* utilities to spoof package information
*/
internal object PackageSpoofUtils {
private const val TAG = "SpoofUtils"
private const val META_SPOOF_PACKAGE_NAME =
- "${BuildConfig.BASE_PACKAGE_NAME}.android.gms.SPOOFED_PACKAGE_NAME"
+ "com.mgoogle.android.gms.SPOOFED_PACKAGE_NAME"
private const val META_SPOOF_PACKAGE_SIGNATURE =
- "${BuildConfig.BASE_PACKAGE_NAME}.android.gms.SPOOFED_PACKAGE_SIGNATURE"
+ "com.mgoogle.android.gms.SPOOFED_PACKAGE_SIGNATURE"
private val spoofedPackageNameCache = HashMap()
private val spoofedPackageSignatureCache = HashMap()
@@ -141,7 +139,6 @@ internal object PackageSpoofUtils {
* @param packageName name of the package to get metadata of
* @return package metadata bundle
*/
- @Suppress("DEPRECATION")
private fun getPackageMetadata(packageManager: PackageManager, packageName: String): Bundle? {
return try {
// PackageManager.getPackageInfo() has been deprecated in targetSdkVersion 30+
diff --git a/play-services-base-core/src/main/kotlin/org/microg/gms/profile/Build.kt b/play-services-base-core/src/main/kotlin/org/microg/gms/profile/Build.kt
index 725e0d6a..a52059a9 100644
--- a/play-services-base-core/src/main/kotlin/org/microg/gms/profile/Build.kt
+++ b/play-services-base-core/src/main/kotlin/org/microg/gms/profile/Build.kt
@@ -24,6 +24,7 @@ object Build {
var CPU_ABI2: String? = null
@JvmField
+ @TargetApi(21)
var SUPPORTED_ABIS: Array = emptyArray()
@JvmField
@@ -89,9 +90,6 @@ object Build {
@JvmField
var SECURITY_PATCH: String? = null
-
- @JvmField
- var DEVICE_INITIAL_SDK_INT: Int = 0
}
fun generateWebViewUserAgentString(original: String): String {
diff --git a/play-services-base-core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt b/play-services-base-core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt
index 76286eab..ed756017 100644
--- a/play-services-base-core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt
+++ b/play-services-base-core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt
@@ -10,8 +10,8 @@ import android.content.Context
import android.content.res.XmlResourceParser
import android.util.Log
import org.microg.gms.utils.FileXmlResourceParser
-import org.microg.gms.settings.SettingsContract
-import org.microg.gms.settings.SettingsContract.Profile
+import org.microg.mgms.settings.SettingsContract
+import org.microg.mgms.settings.SettingsContract.Profile
import org.xmlpull.v1.XmlPullParser
import java.io.File
import java.util.*
@@ -68,60 +68,43 @@ object ProfileManager {
PROFILE_AUTO -> false
PROFILE_REAL -> false
PROFILE_NATIVE -> true
- else -> {
- val parser = getProfileXml(context, profile)
- if (parser != null) {
- try {
- var next = parser.next()
- while (next != XmlPullParser.END_DOCUMENT) {
- when (next) {
- XmlPullParser.START_TAG -> when (parser.name) {
- "profile" -> {
- return@runCatching parser.getAttributeBooleanValue(null, "auto", false)
- }
- }
+ else -> getProfileXml(context, profile)?.use {
+ var next = it.next()
+ while (next != XmlPullParser.END_DOCUMENT) {
+ when (next) {
+ XmlPullParser.START_TAG -> when (it.name) {
+ "profile" -> {
+ return@use it.getAttributeBooleanValue(null, "auto", false)
}
- next = parser.next()
}
- } finally {
- parser.close()
}
- false
- } else {
- false
+ next = it.next()
}
- }
+ } == true
}
}.getOrDefault(false)
- fun getActiveProfileData(context: Context): Map =
- getProfileData(context, getProfile(context), getRealData())
-
private fun getProfileData(context: Context, profile: String, realData: Map): Map {
try {
if (profile in listOf(PROFILE_REAL, PROFILE_NATIVE)) return realData
- if (profile != PROFILE_USER && getProfileResId(context, profile) == 0) return realData
+ val profileResId = getProfileResId(context, profile)
+ if (profileResId == 0) return realData
val resultData = mutableMapOf()
resultData.putAll(realData)
- val parser = getProfileXml(context, profile)
- if (parser != null) {
- try {
- var next = parser.next()
- while (next != XmlPullParser.END_DOCUMENT) {
- when (next) {
- XmlPullParser.START_TAG -> when (parser.name) {
- "data" -> {
- val key = parser.getAttributeValue(null, "key")
- val value = parser.getAttributeValue(null, "value")
- resultData[key] = value
- Log.d(TAG, "Overwrite from profile: $key = $value")
- }
+ getProfileXml(context, profile)?.use {
+ var next = it.next()
+ while (next != XmlPullParser.END_DOCUMENT) {
+ when (next) {
+ XmlPullParser.START_TAG -> when (it.name) {
+ "data" -> {
+ val key = it.getAttributeValue(null, "key")
+ val value = it.getAttributeValue(null, "value")
+ resultData[key] = value
+ Log.d(TAG, "Overwrite from profile: $key = $value")
}
}
- next = parser.next()
}
- } finally {
- parser.close()
+ next = it.next()
}
}
return resultData
@@ -169,20 +152,15 @@ object ProfileManager {
// From profile
try {
- val parser = getProfileXml(context, profile)
- if (parser != null) {
- try {
- var next = parser.next()
- while (next != XmlPullParser.END_DOCUMENT) {
- when (next) {
- XmlPullParser.START_TAG -> when (parser.name) {
- "serial" -> return parser.getAttributeValue(null, "template")
- }
+ getProfileXml(context, profile)?.use {
+ var next = it.next()
+ while (next != XmlPullParser.END_DOCUMENT) {
+ when (next) {
+ XmlPullParser.START_TAG -> when (it.name) {
+ "serial" -> return it.getAttributeValue(null, "template")
}
- next = parser.next()
}
- } finally {
- parser.close()
+ next = it.next()
}
}
} catch (e: Exception) {
@@ -205,7 +183,6 @@ object ProfileManager {
return serial
}
- @SuppressLint("BlockedPrivateApi")
private fun getRealData(): Map = mutableMapOf(
"Build.BOARD" to android.os.Build.BOARD,
"Build.BOOTLOADER" to android.os.Build.BOOTLOADER,
@@ -239,15 +216,9 @@ object ProfileManager {
if (android.os.Build.VERSION.SDK_INT >= 23) {
put("Build.VERSION.SECURITY_PATCH", android.os.Build.VERSION.SECURITY_PATCH)
}
- try {
- val field = android.os.Build.VERSION::class.java.getDeclaredField("DEVICE_INITIAL_SDK_INT")
- field.isAccessible = true
- put("Build.VERSION.DEVICE_INITIAL_SDK_INT", field.getInt(null).toString())
- } catch (ignored: Exception) {
- }
}
- fun applyProfileData(profileData: Map) {
+ private fun applyProfileData(profileData: Map) {
fun applyStringField(key: String, valueSetter: (String) -> Unit) = profileData[key]?.let { valueSetter(it) }
fun applyIntField(key: String, valueSetter: (Int) -> Unit) = profileData[key]?.toIntOrNull()?.let { valueSetter(it) }
fun applyLongField(key: String, valueSetter: (Long) -> Unit) = profileData[key]?.toLongOrNull()?.let { valueSetter(it) }
@@ -277,7 +248,6 @@ object ProfileManager {
applyStringField("Build.VERSION.RELEASE") { Build.VERSION.RELEASE = it }
applyStringField("Build.VERSION.SDK") { Build.VERSION.SDK = it }
applyIntField("Build.VERSION.SDK_INT") { Build.VERSION.SDK_INT = it }
- applyIntField("Build.VERSION.DEVICE_INITIAL_SDK_INT") { Build.VERSION.DEVICE_INITIAL_SDK_INT = it }
if (android.os.Build.VERSION.SDK_INT >= 21) {
Build.SUPPORTED_ABIS = profileData["Build.SUPPORTED_ABIS"]?.split(",")?.toTypedArray() ?: emptyArray()
} else {
@@ -305,26 +275,19 @@ object ProfileManager {
fun getProfileName(context: Context, profile: String): String? = getProfileName { getProfileXml(context, profile) }
- private fun getProfileName(parserCreator: () -> XmlResourceParser?): String? {
- val parser = parserCreator()
- if (parser != null) {
- try {
- var next = parser.next()
- while (next != XmlPullParser.END_DOCUMENT) {
- when (next) {
- XmlPullParser.START_TAG -> when (parser.name) {
- "profile" -> {
- return parser.getAttributeValue(null, "name")
- }
- }
+ private fun getProfileName(parserCreator: () -> XmlResourceParser?): String? = parserCreator()?.use {
+ var next = it.next()
+ while (next != XmlPullParser.END_DOCUMENT) {
+ when (next) {
+ XmlPullParser.START_TAG -> when (it.name) {
+ "profile" -> {
+ return@use it.getAttributeValue(null, "name")
}
- next = parser.next()
}
- } finally {
- parser.close()
}
+ next = it.next()
}
- return null
+ null
}
fun setProfile(context: Context, profile: String?) {
@@ -342,7 +305,7 @@ object ProfileManager {
val profileName = getProfileName { FileXmlResourceParser(file) } ?: return false
try {
Log.d(TAG, "Importing user profile '$profileName'")
- file.copyTo(getUserProfileFile(context), overwrite = true)
+ file.copyTo(getUserProfileFile(context))
if (activeProfile == PROFILE_USER) applyProfile(context, PROFILE_USER)
return true
} catch (e: Exception) {
diff --git a/play-services-base-core/src/main/kotlin/org/microg/gms/profile/ProfileProvider.kt b/play-services-base-core/src/main/kotlin/org/microg/gms/profile/ProfileProvider.kt
deleted file mode 100644
index 53e4149f..00000000
--- a/play-services-base-core/src/main/kotlin/org/microg/gms/profile/ProfileProvider.kt
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 e Foundation
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package org.microg.gms.profile
-
-import android.content.ContentProvider
-import android.content.ContentValues
-import android.database.Cursor
-import android.database.MatrixCursor
-import android.net.Uri
-import org.microg.gms.settings.SettingsContract
-
-class ProfileProvider : ContentProvider() {
-
- val COLUMN_ID = "profile_id"
- val COLUMN_VALUE = "profile_value"
-
- override fun onCreate(): Boolean {
- ProfileManager.ensureInitialized(context!!)
- return true
- }
-
- override fun query(
- uri: Uri,
- projection: Array?,
- selection: String?,
- selectionArgs: Array?,
- sortOrder: String?
- ): Cursor =
- MatrixCursor(arrayOf(COLUMN_ID, COLUMN_VALUE)).apply {
- ProfileManager.getActiveProfileData(context!!).entries
- .forEach {
- addRow(arrayOf(it.key, it.value))
- }
- }
-
- override fun getType(uri: Uri): String {
- return "vnd.android.cursor.item/vnd.${SettingsContract.getAuthority(context!!)}.${uri.path}"
- }
-
- override fun insert(uri: Uri, values: ContentValues?): Nothing = throw UnsupportedOperationException()
-
- override fun delete(uri: Uri, selection: String?, selectionArgs: Array?): Nothing =
- throw UnsupportedOperationException()
-
- override fun update(
- uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array?
- ): Nothing = throw UnsupportedOperationException()
-
-}
diff --git a/play-services-base-core/src/main/kotlin/org/microg/gms/settings/MetaDataPreferences.kt b/play-services-base-core/src/main/kotlin/org/microg/gms/settings/MetaDataPreferences.kt
deleted file mode 100644
index 1e21f6d9..00000000
--- a/play-services-base-core/src/main/kotlin/org/microg/gms/settings/MetaDataPreferences.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package org.microg.gms.settings
-
-import android.content.Context
-import android.content.SharedPreferences
-import android.content.pm.PackageManager.GET_META_DATA
-import android.os.Bundle
-
-class MetaDataPreferences(private val context: Context, private val prefix: String = "") : SharedPreferences {
- private val metaData by lazy {
- runCatching { context.packageManager.getApplicationInfo(context.packageName, GET_META_DATA) }.getOrNull()?.metaData ?: Bundle.EMPTY
- }
-
- override fun getAll(): Map = metaData.keySet().filter { it.startsWith(prefix) }.associate { it.substring(prefix.length) to metaData.get(it) }
-
- override fun getString(key: String, defValue: String?): String? = metaData.getString(prefix + key, defValue)
-
- override fun getStringSet(key: String, defValues: Set?): Set? = metaData.getStringArray(prefix + key)?.toSet() ?: defValues
-
- override fun getInt(key: String?, defValue: Int): Int = metaData.getInt(prefix + key, defValue)
-
- override fun getLong(key: String?, defValue: Long): Long = metaData.getLong(prefix + key, defValue)
-
- override fun getFloat(key: String?, defValue: Float): Float = metaData.getFloat(prefix + key, defValue)
-
- override fun getBoolean(key: String?, defValue: Boolean): Boolean = metaData.getBoolean(prefix + key, defValue)
-
- override fun contains(key: String?): Boolean = metaData.containsKey(prefix + key)
-
- override fun edit(): SharedPreferences.Editor {
- throw UnsupportedOperationException()
- }
-
- override fun registerOnSharedPreferenceChangeListener(listener: SharedPreferences.OnSharedPreferenceChangeListener?) {
- throw UnsupportedOperationException()
- }
-
- override fun unregisterOnSharedPreferenceChangeListener(listener: SharedPreferences.OnSharedPreferenceChangeListener?) {
- throw UnsupportedOperationException()
- }
-}
\ No newline at end of file
diff --git a/play-services-base-core/src/main/kotlin/org/microg/gms/utils/BinderUtils.kt b/play-services-base-core/src/main/kotlin/org/microg/gms/utils/BinderUtils.kt
index 226bb431..79e8ff8f 100644
--- a/play-services-base-core/src/main/kotlin/org/microg/gms/utils/BinderUtils.kt
+++ b/play-services-base-core/src/main/kotlin/org/microg/gms/utils/BinderUtils.kt
@@ -12,13 +12,13 @@ import android.util.Log
private const val TAG = "BinderUtils"
-fun IBinder.warnOnTransactionIssues(code: Int, reply: Parcel?, flags: Int, tag: String = TAG, base: () -> Boolean): Boolean {
+fun IBinder.warnOnTransactionIssues(code: Int, reply: Parcel?, flags: Int, base: () -> Boolean): Boolean {
if (base.invoke()) {
if ((flags and Binder.FLAG_ONEWAY) > 0 && (reply?.dataSize() ?: 0) > 0) {
- Log.w(tag, "Method $code in $interfaceDescriptor is oneway, but returned data")
+ Log.w(TAG, "Method $code in $interfaceDescriptor is oneway, but returned data")
}
return true
}
- Log.w(tag, "Unknown method $code in $interfaceDescriptor, skipping")
+ Log.w(TAG, "Unknown method $code in $interfaceDescriptor, skipping")
return (flags and Binder.FLAG_ONEWAY) > 0 // Don't return false on oneway transaction to suppress warning
}
diff --git a/play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt b/play-services-base-core/src/main/kotlin/org/microg/mgms/settings/SettingsContract.kt
similarity index 97%
rename from play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt
rename to play-services-base-core/src/main/kotlin/org/microg/mgms/settings/SettingsContract.kt
index 8851d1a1..841b47a0 100644
--- a/play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt
+++ b/play-services-base-core/src/main/kotlin/org/microg/mgms/settings/SettingsContract.kt
@@ -1,4 +1,4 @@
-package org.microg.gms.settings
+package org.microg.mgms.settings
import android.content.ContentValues
import android.content.Context
@@ -22,6 +22,7 @@ object SettingsContract {
const val SECURITY_TOKEN = "securityToken"
const val VERSION_INFO = "versionInfo"
const val DEVICE_DATA_VERSION_INFO = "deviceDataVersionInfo"
+
const val BRAND_SPOOF = "brandSpoof"
const val HIDE_LAUNCHER_ICON = "hideLauncherIcon"
@@ -80,12 +81,10 @@ object SettingsContract {
const val TRUST_GOOGLE = "auth_manager_trust_google"
const val VISIBLE = "auth_manager_visible"
- const val INCLUDE_ANDROID_ID = "auth_include_android_id"
val PROJECTION = arrayOf(
TRUST_GOOGLE,
VISIBLE,
- INCLUDE_ANDROID_ID,
)
}
diff --git a/play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsProvider.kt b/play-services-base-core/src/main/kotlin/org/microg/mgms/settings/SettingsProvider.kt
similarity index 90%
rename from play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsProvider.kt
rename to play-services-base-core/src/main/kotlin/org/microg/mgms/settings/SettingsProvider.kt
index 39dc00e1..f1829b2c 100644
--- a/play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsProvider.kt
+++ b/play-services-base-core/src/main/kotlin/org/microg/mgms/settings/SettingsProvider.kt
@@ -4,7 +4,7 @@
*/
@file:Suppress("DEPRECATION")
-package org.microg.gms.settings
+package org.microg.mgms.settings
import android.content.ContentProvider
import android.content.ContentValues
@@ -16,20 +16,21 @@ import android.database.MatrixCursor
import android.net.Uri
import android.preference.PreferenceManager
import org.microg.gms.common.PackageUtils.warnIfNotMainProcess
-import org.microg.gms.settings.SettingsContract.Auth
-import org.microg.gms.settings.SettingsContract.CheckIn
-import org.microg.gms.settings.SettingsContract.Gcm
-import org.microg.gms.settings.SettingsContract.Profile
-import org.microg.gms.settings.SettingsContract.getAuthority
+import org.microg.mgms.settings.SettingsContract.Auth
+import org.microg.mgms.settings.SettingsContract.CheckIn
+import org.microg.mgms.settings.SettingsContract.Gcm
+import org.microg.mgms.settings.SettingsContract.Profile
+import org.microg.mgms.settings.SettingsContract.getAuthority
import java.io.File
-private const val SETTINGS_PREFIX = "org.microg.gms.settings."
-
/**
* All settings access should go through this [ContentProvider],
* because it provides safe access from different processes which normal [SharedPreferences] don't.
*/
class SettingsProvider : ContentProvider() {
+ companion object {
+ const val INTERVAL = 1 * 60 * 1000 // 1 minute
+ }
private val preferences: SharedPreferences by lazy {
PreferenceManager.getDefaultSharedPreferences(context)
@@ -49,10 +50,6 @@ class SettingsProvider : ContentProvider() {
}
}
- private val metaDataPreferences: SharedPreferences by lazy {
- MetaDataPreferences(context!!, SETTINGS_PREFIX)
- }
-
override fun onCreate(): Boolean {
return true
}
@@ -100,7 +97,7 @@ class SettingsProvider : ContentProvider() {
CheckIn.VERSION_INFO -> checkInPrefs.getString(key, "") ?: ""
CheckIn.DEVICE_DATA_VERSION_INFO -> checkInPrefs.getString(key, "") ?: ""
CheckIn.BRAND_SPOOF -> getSettingsBoolean(key, false)
- CheckIn.HIDE_LAUNCHER_ICON -> getSettingsBoolean(key, true)
+ CheckIn.HIDE_LAUNCHER_ICON -> getSettingsBoolean(key, false)
else -> throw IllegalArgumentException()
}
}
@@ -168,9 +165,9 @@ class SettingsProvider : ContentProvider() {
Gcm.NETWORK_ROAMING -> Integer.parseInt(preferences.getString(key, "0") ?: "0")
Gcm.NETWORK_OTHER -> Integer.parseInt(preferences.getString(key, "0") ?: "0")
- Gcm.LEARNT_MOBILE -> preferences.getInt(key, 300000)
- Gcm.LEARNT_WIFI -> preferences.getInt(key, 300000)
- Gcm.LEARNT_OTHER -> preferences.getInt(key, 300000)
+ Gcm.LEARNT_MOBILE -> preferences.getInt(key, Companion.INTERVAL)
+ Gcm.LEARNT_WIFI -> preferences.getInt(key, Companion.INTERVAL)
+ Gcm.LEARNT_OTHER -> preferences.getInt(key, Companion.INTERVAL)
else -> throw IllegalArgumentException("Unknown key: $key")
}
@@ -205,7 +202,6 @@ class SettingsProvider : ContentProvider() {
when (key) {
Auth.TRUST_GOOGLE -> getSettingsBoolean(key, true)
Auth.VISIBLE -> getSettingsBoolean(key, false)
- Auth.INCLUDE_ANDROID_ID -> getSettingsBoolean(key, true)
else -> throw IllegalArgumentException("Unknown key: $key")
}
}
@@ -217,7 +213,6 @@ class SettingsProvider : ContentProvider() {
when (key) {
Auth.TRUST_GOOGLE -> editor.putBoolean(key, value as Boolean)
Auth.VISIBLE -> editor.putBoolean(key, value as Boolean)
- Auth.INCLUDE_ANDROID_ID -> editor.putBoolean(key, value as Boolean)
else -> throw IllegalArgumentException("Unknown key: $key")
}
}
@@ -272,12 +267,12 @@ class SettingsProvider : ContentProvider() {
* @return the current setting as [Int], because [ContentProvider] does not support [Boolean].
*/
private fun getSettingsBoolean(key: String, def: Boolean): Int {
- return listOf(preferences, systemDefaultPreferences, metaDataPreferences).getBooleanAsInt(key, def)
+ return listOf(preferences, systemDefaultPreferences).getBooleanAsInt(key, def)
}
- private fun getSettingsString(key: String, def: String? = null): String? = listOf(preferences, systemDefaultPreferences, metaDataPreferences).getString(key, def)
- private fun getSettingsInt(key: String, def: Int): Int = listOf(preferences, systemDefaultPreferences, metaDataPreferences).getInt(key, def)
- private fun getSettingsLong(key: String, def: Long): Long = listOf(preferences, systemDefaultPreferences, metaDataPreferences).getLong(key, def)
+ private fun getSettingsString(key: String, def: String? = null): String? = listOf(preferences, systemDefaultPreferences).getString(key, def)
+ private fun getSettingsInt(key: String, def: Int): Int = listOf(preferences, systemDefaultPreferences).getInt(key, def)
+ private fun getSettingsLong(key: String, def: Long): Long = listOf(preferences, systemDefaultPreferences).getLong(key, def)
private fun List.getString(key: String, def: String?): String? = foldRight(def) { preferences, defValue -> preferences?.getString(key, defValue) ?: defValue }
private fun List.getInt(key: String, def: Int): Int = foldRight(def) { preferences, defValue -> preferences?.getInt(key, defValue) ?: defValue }
diff --git a/play-services-base-core/src/main/res/layout/preference_app_heading.xml b/play-services-base-core/src/main/res/layout/preference_app_heading.xml
deleted file mode 100644
index cb7e4edf..00000000
--- a/play-services-base-core/src/main/res/layout/preference_app_heading.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/play-services-base-core/src/main/res/layout/preference_switch_bar.xml b/play-services-base-core/src/main/res/layout/preference_switch_bar.xml
deleted file mode 100644
index 9818305b..00000000
--- a/play-services-base-core/src/main/res/layout/preference_switch_bar.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/play-services-base/build.gradle b/play-services-base/build.gradle
index e1cff12a..8857d222 100644
--- a/play-services-base/build.gradle
+++ b/play-services-base/build.gradle
@@ -26,10 +26,9 @@ android {
}
compileOptions {
- sourceCompatibility = 17
- targetCompatibility = 17
+ sourceCompatibility = 1.8
+ targetCompatibility = 1.8
}
- namespace 'org.microg.gms.base'
}
dependencies {
diff --git a/play-services-base/src/main/AndroidManifest.xml b/play-services-base/src/main/AndroidManifest.xml
index c31f1c05..3ab02d97 100644
--- a/play-services-base/src/main/AndroidManifest.xml
+++ b/play-services-base/src/main/AndroidManifest.xml
@@ -15,7 +15,8 @@
~ limitations under the License.
-->
-
+
CREATOR = new AutoCreator(AccountInfo.class);
+ public static final Creator CREATOR = new AutoCreator<>(AccountInfo.class);
}
diff --git a/play-services-base/src/main/java/com/google/android/gms/common/api/Api.java b/play-services-base/src/main/java/com/google/android/gms/common/api/Api.java
index fd91a375..065fff8a 100644
--- a/play-services-base/src/main/java/com/google/android/gms/common/api/Api.java
+++ b/play-services-base/src/main/java/com/google/android/gms/common/api/Api.java
@@ -20,7 +20,6 @@ import android.accounts.Account;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
-import org.microg.gms.common.Hide;
import org.microg.gms.common.PublicApi;
import org.microg.gms.common.api.ApiClientBuilder;
@@ -101,14 +100,4 @@ public final class Api {
}
}
- @Hide
- public interface Client {
- void connect();
-
- void disconnect();
-
- boolean isConnected();
-
- boolean isConnecting();
- }
}
diff --git a/play-services-base/src/main/java/com/google/android/gms/common/api/GoogleApi.java b/play-services-base/src/main/java/com/google/android/gms/common/api/GoogleApi.java
index 4a33737c..54e2c63a 100644
--- a/play-services-base/src/main/java/com/google/android/gms/common/api/GoogleApi.java
+++ b/play-services-base/src/main/java/com/google/android/gms/common/api/GoogleApi.java
@@ -11,18 +11,16 @@ import com.google.android.gms.common.api.internal.ApiKey;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.TaskCompletionSource;
-import org.microg.gms.common.Hide;
import org.microg.gms.common.PublicApi;
+import org.microg.gms.common.api.ApiClient;
import org.microg.gms.common.api.GoogleApiManager;
import org.microg.gms.common.api.PendingGoogleApiCall;
@PublicApi
public abstract class GoogleApi implements HasApiKey {
- private GoogleApiManager manager;
- @Hide
+ private final GoogleApiManager manager;
+ @PublicApi(exclude = true)
public Api api;
- @Hide
- public O options;
@PublicApi(exclude = true)
protected GoogleApi(Context context, Api api) {
@@ -31,14 +29,7 @@ public abstract class GoogleApi implements HasApiKey api, O options) {
- this.api = api;
- this.manager = GoogleApiManager.getInstance(context);
- this.options = options;
- }
-
- @PublicApi(exclude = true)
- protected Task scheduleTask(PendingGoogleApiCall apiCall) {
+ protected Task scheduleTask(PendingGoogleApiCall apiCall) {
TaskCompletionSource completionSource = new TaskCompletionSource<>();
manager.scheduleTask(this, apiCall, completionSource);
return completionSource.getTask();
@@ -52,6 +43,6 @@ public abstract class GoogleApi implements HasApiKey apis = new HashMap();
- private final Set connectionCallbacks = new HashSet();
- private final Set connectionFailedListeners = new HashSet();
- private final Set scopes = new HashSet();
+ private final Map apis = new HashMap<>();
+ private final Set connectionCallbacks = new HashSet<>();
+ private final Set connectionFailedListeners = new HashSet<>();
+ private final Set scopes = new HashSet<>();
private String accountName;
private int clientId = -1;
private FragmentActivity fragmentActivity;
@@ -364,12 +364,7 @@ public interface GoogleApiClient {
}
private ApiClientSettings getClientSettings() {
- ApiClientSettings clientSettings = new ApiClientSettings();
- clientSettings.accountName = accountName;
- clientSettings.scopes = new HashSet<>(scopes);
- clientSettings.gravityForPopups = gravityForPopups;
- clientSettings.viewForPopups = viewForPopups;
- return clientSettings;
+ return null;
}
public Builder enableAutoManage(FragmentActivity fragmentActivity, int cliendId,
@@ -449,8 +444,6 @@ public interface GoogleApiClient {
* A suspension cause informing you that a peer device connection was lost.
*/
int CAUSE_NETWORK_LOST = 2;
-
- void onConnected(Bundle connectionHint);
}
/**
diff --git a/play-services-base/src/main/java/com/google/android/gms/common/api/PendingResult.java b/play-services-base/src/main/java/com/google/android/gms/common/api/PendingResult.java
index ec162920..e3881366 100644
--- a/play-services-base/src/main/java/com/google/android/gms/common/api/PendingResult.java
+++ b/play-services-base/src/main/java/com/google/android/gms/common/api/PendingResult.java
@@ -40,20 +40,20 @@ public interface PendingResult {
* Blocks until the task is completed. This is not allowed on the UI thread. The returned
* result object can have an additional failure mode of INTERRUPTED.
*/
- public R await();
+ R await();
/**
* Blocks until the task is completed or has timed out waiting for the result. This is not
* allowed on the UI thread. The returned result object can have an additional failure mode
* of either INTERRUPTED or TIMEOUT.
*/
- public R await(long time, TimeUnit unit);
+ R await(long time, TimeUnit unit);
- public void cancel();
+ void cancel();
- public boolean isCanceled();
+ boolean isCanceled();
- public void setResultCallback(ResultCallback callback, long time, TimeUnit unit);
+ void setResultCallback(ResultCallback callback, long time, TimeUnit unit);
- public void setResultCallback(ResultCallback callback);
+ void setResultCallback(ResultCallback callback);
}
diff --git a/play-services-base/src/main/java/org/microg/gms/common/DummyApiClient.java b/play-services-base/src/main/java/org/microg/gms/common/DummyApiClient.java
index c527866f..132a6148 100644
--- a/play-services-base/src/main/java/org/microg/gms/common/DummyApiClient.java
+++ b/play-services-base/src/main/java/org/microg/gms/common/DummyApiClient.java
@@ -16,9 +16,9 @@
package org.microg.gms.common;
-import com.google.android.gms.common.api.Api;
+import org.microg.gms.common.api.ApiClient;
-public class DummyApiClient implements Api.Client {
+public class DummyApiClient implements ApiClient {
private boolean connected = false;
@Override
diff --git a/play-services-base/src/main/java/org/microg/gms/common/GmsClient.java b/play-services-base/src/main/java/org/microg/gms/common/GmsClient.java
index e5b71717..8b816fd8 100644
--- a/play-services-base/src/main/java/org/microg/gms/common/GmsClient.java
+++ b/play-services-base/src/main/java/org/microg/gms/common/GmsClient.java
@@ -27,17 +27,16 @@ import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.common.ConnectionResult;
-import com.google.android.gms.common.api.Api;
import com.google.android.gms.common.api.CommonStatusCodes;
-import com.google.android.gms.common.internal.ConnectionInfo;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import com.google.android.gms.common.internal.IGmsServiceBroker;
+import org.microg.gms.common.api.ApiClient;
import org.microg.gms.common.api.ConnectionCallbacks;
import org.microg.gms.common.api.OnConnectionFailedListener;
-public abstract class GmsClient implements Api.Client {
+public abstract class GmsClient implements ApiClient {
private static final String TAG = "GmsClient";
private final Context context;
@@ -48,9 +47,6 @@ public abstract class GmsClient implements Api.Client {
private I serviceInterface;
private final String actionString;
- protected boolean requireMicrog;
- protected String packageName;
-
protected int serviceId = -1;
protected Account account = null;
protected Bundle extras = new Bundle();
@@ -60,8 +56,6 @@ public abstract class GmsClient implements Api.Client {
this.callbacks = callbacks;
this.connectionFailedListener = connectionFailedListener;
this.actionString = actionString;
- this.requireMicrog = false;
- this.packageName = context.getPackageName();
}
protected void onConnectedToBroker(IGmsServiceBroker broker, GmsCallbacks callbacks) throws RemoteException {
@@ -69,7 +63,8 @@ public abstract class GmsClient implements Api.Client {
throw new IllegalStateException("Service ID not set in constructor and onConnectedToBroker not implemented");
}
GetServiceRequest request = new GetServiceRequest(serviceId);
- request.packageName = packageName;
+ request.extras = new Bundle();
+ request.packageName = context.getPackageName();
request.account = account;
request.extras = extras;
broker.getService(callbacks, request);
@@ -88,7 +83,7 @@ public abstract class GmsClient implements Api.Client {
MultiConnectionKeeper.getInstance(context).unbind(actionString, serviceConnection);
}
serviceConnection = new GmsServiceConnection();
- if (!MultiConnectionKeeper.getInstance(context).bind(actionString, serviceConnection, requireMicrog)) {
+ if (!MultiConnectionKeeper.getInstance(context).bind(actionString, serviceConnection)) {
state = ConnectionState.ERROR;
handleConnectionFailed();
}
@@ -189,16 +184,5 @@ public abstract class GmsClient implements Api.Client {
callbacks.onConnected(params);
}
}
-
- @Override
- public void onAccountValidationComplete(int statusCode, Bundle params) throws RemoteException {
- Log.d(TAG, "GmsCallbacks : onAccountValidationComplete");
- }
-
- @Override
- public void onPostInitCompleteWithConnectionInfo(int statusCode, IBinder binder, ConnectionInfo info) throws RemoteException {
- onPostInitComplete(statusCode, binder, info == null ? null : info.params);
- }
}
-
}
diff --git a/play-services-base/src/main/java/org/microg/gms/common/GmsConnector.java b/play-services-base/src/main/java/org/microg/gms/common/GmsConnector.java
index b77c6d2c..9a56566c 100644
--- a/play-services-base/src/main/java/org/microg/gms/common/GmsConnector.java
+++ b/play-services-base/src/main/java/org/microg/gms/common/GmsConnector.java
@@ -27,9 +27,10 @@ import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.Result;
import org.microg.gms.common.api.AbstractPendingResult;
+import org.microg.gms.common.api.ApiClient;
import org.microg.gms.common.api.GoogleApiClientImpl;
-public class GmsConnector {
+public class GmsConnector {
private static final String TAG = "GmsConnector";
private final GoogleApiClientImpl apiClient;
@@ -42,8 +43,8 @@ public class GmsConnector {
this.callback = callback;
}
- public static PendingResult call(GoogleApiClient client, Api api, GmsConnector.Callback callback) {
- return new GmsConnector(client, api, callback).connect();
+ public static PendingResult call(GoogleApiClient client, Api api, GmsConnector.Callback callback) {
+ return new GmsConnector<>(client, api, callback).connect();
}
public AbstractPendingResult connect() {
@@ -51,7 +52,7 @@ public class GmsConnector {
apiClient.incrementUsageCounter();
apiClient.getApiConnection(api);
Looper looper = apiClient.getLooper();
- final AbstractPendingResult result = new AbstractPendingResult(looper);
+ final AbstractPendingResult result = new AbstractPendingResult<>(looper);
Message msg = new Message();
msg.obj = result;
new Handler(looper).sendMessage(msg);
@@ -77,12 +78,9 @@ public class GmsConnector {
final AbstractPendingResult result = (AbstractPendingResult) msg.obj;
try {
C connection = (C) apiClient.getApiConnection(api);
- callback.onClientAvailable(connection, new GmsConnector.Callback.ResultProvider() {
- @Override
- public void onResultAvailable(R realResult) {
- result.deliverResult(realResult);
- apiClient.decrementUsageCounter();
- }
+ callback.onClientAvailable(connection, realResult -> {
+ result.deliverResult(realResult);
+ apiClient.decrementUsageCounter();
});
} catch (RemoteException ignored) {
diff --git a/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java b/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java
index 616224bf..913291f4 100644
--- a/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java
+++ b/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java
@@ -16,15 +16,13 @@
package org.microg.gms.common;
+import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME;
+
import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PermissionInfo;
-import android.content.pm.ResolveInfo;
import android.os.IBinder;
import android.util.Log;
@@ -33,15 +31,14 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME;
-
public class MultiConnectionKeeper {
private static final String TAG = "GmsMultiConKeeper";
+ @SuppressLint("StaticFieldLeak")
private static MultiConnectionKeeper INSTANCE;
private final Context context;
- private final Map connections = new HashMap();
+ private final Map connections = new HashMap<>();
public MultiConnectionKeeper(Context context) {
this.context = context;
@@ -49,17 +46,13 @@ public class MultiConnectionKeeper {
public synchronized static MultiConnectionKeeper getInstance(Context context) {
if (INSTANCE == null)
- INSTANCE = new MultiConnectionKeeper(context.getApplicationContext());
+ INSTANCE = new MultiConnectionKeeper(context);
return INSTANCE;
}
public synchronized boolean bind(String action, ServiceConnection connection) {
- return bind(action, connection, false);
- }
-
- public synchronized boolean bind(String action, ServiceConnection connection, boolean requireMicrog) {
+ Log.d(TAG, "bind(" + action + ", " + connection + ")");
Connection con = connections.get(action);
- Log.d(TAG, "bind(" + action + ", " + connection + ", " + requireMicrog + ") has=" + (con != null));
if (con != null) {
if (!con.forwardsConnection(connection)) {
con.addConnectionForward(connection);
@@ -67,12 +60,11 @@ public class MultiConnectionKeeper {
con.bind();
}
} else {
- con = new Connection(action, requireMicrog);
+ con = new Connection(action);
con.addConnectionForward(connection);
con.bind();
connections.put(action, con);
}
- Log.d(TAG, "bind() : bound=" + con.isBound());
return con.isBound();
}
@@ -81,26 +73,21 @@ public class MultiConnectionKeeper {
Connection con = connections.get(action);
if (con != null) {
con.removeConnectionForward(connection);
- if (con.isBound()) {
- if (!con.hasForwards()) {
- con.unbind();
- connections.remove(action);
- } else {
- Log.d(TAG, "Not unbinding for " + connection + ": has pending other bindings on action " + action);
- }
+ if (!con.hasForwards() && con.isBound()) {
+ con.unbind();
+ connections.remove(action);
}
}
}
public class Connection {
private final String actionString;
- private final boolean requireMicrog;
- private final Set connectionForwards = new HashSet();
+ private final Set connectionForwards = new HashSet<>();
private boolean bound = false;
private boolean connected = false;
private IBinder binder;
private ComponentName component;
- private ServiceConnection serviceConnection = new ServiceConnection() {
+ private final ServiceConnection serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
Log.d(TAG, "Connection(" + actionString + ") : ServiceConnection : " +
@@ -128,12 +115,7 @@ public class MultiConnectionKeeper {
};
public Connection(String actionString) {
- this(actionString, false);
- }
-
- public Connection(String actionString, boolean requireMicrog) {
this.actionString = actionString;
- this.requireMicrog = requireMicrog;
}
@SuppressLint("InlinedApi")
@@ -142,53 +124,29 @@ public class MultiConnectionKeeper {
Intent gmsIntent = new Intent(actionString).setPackage(GMS_PACKAGE_NAME);
Intent selfIntent = new Intent(actionString).setPackage(context.getPackageName());
Intent intent;
- ResolveInfo resolveInfo;
- if ((resolveInfo = context.getPackageManager().resolveService(gmsIntent, 0)) == null) {
+ if (context.getPackageManager().resolveService(gmsIntent, 0) == null) {
Log.w(TAG, "No GMS service found for " + actionString);
if (context.getPackageManager().resolveService(selfIntent, 0) != null) {
- Log.d(TAG, "Found service for " + actionString + " in self package, using it instead");
+ Log.d(TAG, "Found service for "+actionString+" in self package, using it instead");
intent = selfIntent;
} else {
return;
}
- } else if (requireMicrog && !isMicrog(resolveInfo)) {
- Log.w(TAG, "GMS service found for " + actionString + " but looks not like microG");
- if (context.getPackageManager().resolveService(selfIntent, 0) != null) {
- Log.d(TAG, "Found service for " + actionString + " in self package, using it instead");
- intent = selfIntent;
- } else {
- intent = gmsIntent;
- }
} else {
intent = gmsIntent;
}
- int flags = Context.BIND_AUTO_CREATE | Context.BIND_DEBUG_UNBIND | Context.BIND_ADJUST_WITH_ACTIVITY;
+ int flags = Context.BIND_AUTO_CREATE;
+ flags |= Context.BIND_ADJUST_WITH_ACTIVITY;
bound = context.bindService(intent, serviceConnection, flags);
- Log.d(TAG, "Connection(" + actionString + ") : bind() : bindService=" + bound);
if (!bound) {
context.unbindService(serviceConnection);
}
}
- public boolean isMicrog(ResolveInfo resolveInfo) {
- if (resolveInfo == null || resolveInfo.serviceInfo == null) return false;
- if (resolveInfo.serviceInfo.name.startsWith("org.microg.")) return true;
- try {
- PermissionInfo info = context.getPackageManager().getPermissionInfo("org.microg.gms.EXTENDED_ACCESS", 0);
- return info.packageName.equals(resolveInfo.serviceInfo.packageName);
- } catch (PackageManager.NameNotFoundException e) {
- return false;
- }
- }
-
public boolean isBound() {
return bound;
}
- public IBinder getBinder() {
- return binder;
- }
-
public void unbind() {
Log.d(TAG, "Connection(" + actionString + ") : unbind()");
try {
diff --git a/play-services-base/src/main/java/org/microg/gms/common/api/AbstractPendingResult.java b/play-services-base/src/main/java/org/microg/gms/common/api/AbstractPendingResult.java
index 15aac9e3..560f3681 100644
--- a/play-services-base/src/main/java/org/microg/gms/common/api/AbstractPendingResult.java
+++ b/play-services-base/src/main/java/org/microg/gms/common/api/AbstractPendingResult.java
@@ -34,7 +34,7 @@ public class AbstractPendingResult implements PendingResult
private ResultCallback resultCallback;
public AbstractPendingResult(Looper looper) {
- handler = new ResultCallbackHandler(looper);
+ handler = new ResultCallbackHandler<>(looper);
}
private R getResult() {
diff --git a/play-services-base/src/main/java/org/microg/gms/common/api/ApiClient.java b/play-services-base/src/main/java/org/microg/gms/common/api/ApiClient.java
new file mode 100644
index 00000000..602e150e
--- /dev/null
+++ b/play-services-base/src/main/java/org/microg/gms/common/api/ApiClient.java
@@ -0,0 +1,27 @@
+/*
+ * 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.common.api;
+
+public interface ApiClient {
+ void connect();
+
+ void disconnect();
+
+ boolean isConnected();
+
+ boolean isConnecting();
+}
diff --git a/play-services-base/src/main/java/org/microg/gms/common/api/ApiClientBuilder.java b/play-services-base/src/main/java/org/microg/gms/common/api/ApiClientBuilder.java
index 18336fa5..b5aa386f 100644
--- a/play-services-base/src/main/java/org/microg/gms/common/api/ApiClientBuilder.java
+++ b/play-services-base/src/main/java/org/microg/gms/common/api/ApiClientBuilder.java
@@ -22,5 +22,5 @@ import android.os.Looper;
import com.google.android.gms.common.api.Api;
public interface ApiClientBuilder {
- Api.Client build(O options, Context context, Looper looper, ApiClientSettings clientSettings, ConnectionCallbacks callbacks, OnConnectionFailedListener connectionFailedListener);
+ ApiClient build(O options, Context context, Looper looper, ApiClientSettings clientSettings, ConnectionCallbacks callbacks, OnConnectionFailedListener connectionFailedListener);
}
diff --git a/play-services-base/src/main/java/org/microg/gms/common/api/ApiClientSettings.java b/play-services-base/src/main/java/org/microg/gms/common/api/ApiClientSettings.java
index af67e799..d1e314a7 100644
--- a/play-services-base/src/main/java/org/microg/gms/common/api/ApiClientSettings.java
+++ b/play-services-base/src/main/java/org/microg/gms/common/api/ApiClientSettings.java
@@ -5,15 +5,5 @@
package org.microg.gms.common.api;
-import android.view.View;
-
-import java.util.Set;
-
public class ApiClientSettings {
- public String accountName;
- public String packageName;
- public Integer sessionId;
- public Set scopes;
- public int gravityForPopups;
- public View viewForPopups;
}
diff --git a/play-services-base/src/main/java/org/microg/gms/common/api/GoogleApiClientImpl.java b/play-services-base/src/main/java/org/microg/gms/common/api/GoogleApiClientImpl.java
index 2dffa374..e59f68f6 100644
--- a/play-services-base/src/main/java/org/microg/gms/common/api/GoogleApiClientImpl.java
+++ b/play-services-base/src/main/java/org/microg/gms/common/api/GoogleApiClientImpl.java
@@ -19,11 +19,10 @@ package org.microg.gms.common.api;
import android.content.Context;
import android.os.Bundle;
import android.os.Looper;
+import android.util.Log;
import androidx.fragment.app.FragmentActivity;
-import android.util.Log;
-
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.Api;
import com.google.android.gms.common.api.GoogleApiClient;
@@ -42,10 +41,10 @@ public class GoogleApiClientImpl implements GoogleApiClient {
private final Context context;
private final Looper looper;
private final ApiClientSettings clientSettings;
- private final Map apis = new HashMap();
- private final Map apiConnections = new HashMap();
- private final Set connectionCallbacks = new HashSet();
- private final Set connectionFailedListeners = new HashSet();
+ private final Map apis = new HashMap<>();
+ private final Map apiConnections = new HashMap<>();
+ private final Set connectionCallbacks = new HashSet<>();
+ private final Set connectionFailedListeners = new HashSet<>();
private final int clientId;
private final ConnectionCallbacks baseConnectionCallbacks = new ConnectionCallbacks() {
@Override
@@ -64,16 +63,12 @@ public class GoogleApiClientImpl implements GoogleApiClient {
}
}
};
- private final OnConnectionFailedListener baseConnectionFailedListener = new
- OnConnectionFailedListener() {
- @Override
- public void onConnectionFailed(ConnectionResult result) {
- Log.d(TAG, "OnConnectionFailedListener : onConnectionFailed()");
- for (OnConnectionFailedListener listener : connectionFailedListeners) {
- listener.onConnectionFailed(result);
- }
- }
- };
+ private final OnConnectionFailedListener baseConnectionFailedListener = result -> {
+ Log.d(TAG, "OnConnectionFailedListener : onConnectionFailed()");
+ for (OnConnectionFailedListener listener : connectionFailedListeners) {
+ listener.onConnectionFailed(result);
+ }
+ };
private int usageCounter = 0;
private boolean shouldDisconnect = false;
@@ -89,10 +84,6 @@ public class GoogleApiClientImpl implements GoogleApiClient {
this.connectionFailedListeners.addAll(connectionFailedListeners);
this.clientId = clientId;
- if (this.clientSettings.sessionId == null) {
- this.clientSettings.sessionId = hashCode();
- }
-
for (Api api : apis.keySet()) {
apiConnections.put(api, api.getBuilder().build(apis.get(api), context, looper, clientSettings, baseConnectionCallbacks, baseConnectionFailedListener));
}
@@ -111,7 +102,7 @@ public class GoogleApiClientImpl implements GoogleApiClient {
return looper;
}
- public Api.Client getApiConnection(Api api) {
+ public ApiClient getApiConnection(Api api) {
return apiConnections.get(api);
}
@@ -141,7 +132,7 @@ public class GoogleApiClientImpl implements GoogleApiClient {
Log.d(TAG, "Already connected/connecting, nothing to do");
return;
}
- for (Api.Client connection : apiConnections.values()) {
+ for (ApiClient connection : apiConnections.values()) {
if (!connection.isConnected()) {
connection.connect();
}
@@ -154,7 +145,7 @@ public class GoogleApiClientImpl implements GoogleApiClient {
shouldDisconnect = true;
} else {
Log.d(TAG, "disconnect()");
- for (Api.Client connection : apiConnections.values()) {
+ for (ApiClient connection : apiConnections.values()) {
if (connection.isConnected()) {
connection.disconnect();
}
@@ -164,7 +155,7 @@ public class GoogleApiClientImpl implements GoogleApiClient {
@Override
public synchronized boolean isConnected() {
- for (Api.Client connection : apiConnections.values()) {
+ for (ApiClient connection : apiConnections.values()) {
if (!connection.isConnected()) return false;
}
return true;
@@ -172,7 +163,7 @@ public class GoogleApiClientImpl implements GoogleApiClient {
@Override
public synchronized boolean isConnecting() {
- for (Api.Client connection : apiConnections.values()) {
+ for (ApiClient connection : apiConnections.values()) {
if (connection.isConnecting()) return true;
}
return false;
diff --git a/play-services-base/src/main/java/org/microg/gms/common/api/GoogleApiManager.java b/play-services-base/src/main/java/org/microg/gms/common/api/GoogleApiManager.java
index 5cf7933e..4e05aa75 100644
--- a/play-services-base/src/main/java/org/microg/gms/common/api/GoogleApiManager.java
+++ b/play-services-base/src/main/java/org/microg/gms/common/api/GoogleApiManager.java
@@ -11,19 +11,19 @@ import android.os.Bundle;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.Api;
import com.google.android.gms.common.api.GoogleApi;
-import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.TaskCompletionSource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
public class GoogleApiManager {
private static GoogleApiManager instance;
- private Context context;
- private Map clientMap = new HashMap<>();
- private Map>> waitingApiCallMap = new HashMap<>();
+ private final Context context;
+ private final Map clientMap = new HashMap<>();
+ private final Map>> waitingApiCallMap = new HashMap<>();
private GoogleApiManager(Context context) {
this.context = context;
@@ -34,30 +34,26 @@ public class GoogleApiManager {
return instance;
}
- private synchronized A clientForApi(GoogleApi api) {
+ private synchronized A clientForApi(GoogleApi api) {
ApiInstance apiInstance = new ApiInstance(api);
if (clientMap.containsKey(apiInstance)) {
return (A) clientMap.get(apiInstance);
} else {
- Api.Client client = api.api.getBuilder().build(api.getOptions(), context, context.getMainLooper(), null, new ConnectionCallback(apiInstance), new ConnectionFailedListener(apiInstance));
+ ApiClient client = api.api.getBuilder().build(api.getOptions(), context, context.getMainLooper(), null, new ConnectionCallback(apiInstance), new ConnectionFailedListener(apiInstance));
clientMap.put(apiInstance, client);
waitingApiCallMap.put(apiInstance, new ArrayList<>());
return (A) client;
}
}
- public synchronized void scheduleTask(GoogleApi api, PendingGoogleApiCall apiCall, TaskCompletionSource completionSource) {
+ public synchronized void scheduleTask(GoogleApi api, PendingGoogleApiCall apiCall, TaskCompletionSource completionSource) {
A client = clientForApi(api);
boolean connecting = client.isConnecting();
boolean connected = client.isConnected();
if (connected) {
- try {
- apiCall.execute(client, completionSource);
- } catch (Exception e) {
- completionSource.setException(e);
- }
+ apiCall.execute(client, completionSource);
} else {
- waitingApiCallMap.get(new ApiInstance(api)).add(new WaitingApiCall((PendingGoogleApiCall) apiCall, completionSource));
+ waitingApiCallMap.get(new ApiInstance(api)).add(new WaitingApiCall<>((PendingGoogleApiCall) apiCall, completionSource));
if (!connecting) {
client.connect();
}
@@ -67,11 +63,7 @@ public class GoogleApiManager {
private synchronized void onInstanceConnected(ApiInstance apiInstance, Bundle connectionHint) {
List> waitingApiCalls = waitingApiCallMap.get(apiInstance);
for (WaitingApiCall> waitingApiCall : waitingApiCalls) {
- try {
- waitingApiCall.execute(clientMap.get(apiInstance));
- } catch (Exception e) {
- waitingApiCall.failed(e);
- }
+ waitingApiCall.execute(clientMap.get(apiInstance));
}
waitingApiCalls.clear();
}
@@ -89,7 +81,7 @@ public class GoogleApiManager {
}
private class ConnectionCallback implements ConnectionCallbacks {
- private ApiInstance apiInstance;
+ private final ApiInstance apiInstance;
public ConnectionCallback(ApiInstance apiInstance) {
this.apiInstance = apiInstance;
@@ -107,7 +99,7 @@ public class GoogleApiManager {
}
private class ConnectionFailedListener implements OnConnectionFailedListener {
- private ApiInstance apiInstance;
+ private final ApiInstance apiInstance;
public ConnectionFailedListener(ApiInstance apiInstance) {
this.apiInstance = apiInstance;
@@ -120,15 +112,15 @@ public class GoogleApiManager {
}
private static class WaitingApiCall {
- private PendingGoogleApiCall apiCall;
- private TaskCompletionSource completionSource;
+ private final PendingGoogleApiCall apiCall;
+ private final TaskCompletionSource completionSource;
- public WaitingApiCall(PendingGoogleApiCall apiCall, TaskCompletionSource completionSource) {
+ public WaitingApiCall(PendingGoogleApiCall apiCall, TaskCompletionSource completionSource) {
this.apiCall = apiCall;
this.completionSource = completionSource;
}
- public void execute(Api.Client client) throws Exception {
+ public void execute(ApiClient client) {
apiCall.execute(client, completionSource);
}
@@ -143,8 +135,8 @@ public class GoogleApiManager {
WaitingApiCall> that = (WaitingApiCall>) o;
- if (apiCall != null ? !apiCall.equals(that.apiCall) : that.apiCall != null) return false;
- return completionSource != null ? completionSource.equals(that.completionSource) : that.completionSource == null;
+ if (!Objects.equals(apiCall, that.apiCall)) return false;
+ return Objects.equals(completionSource, that.completionSource);
}
@Override
@@ -156,8 +148,8 @@ public class GoogleApiManager {
}
private static class ApiInstance {
- private Class> apiClass;
- private Api.ApiOptions apiOptions;
+ private final Class> apiClass;
+ private final Api.ApiOptions apiOptions;
public ApiInstance(Class> apiClass, Api.ApiOptions apiOptions) {
this.apiClass = apiClass;
@@ -175,8 +167,8 @@ public class GoogleApiManager {
ApiInstance that = (ApiInstance) o;
- if (apiClass != null ? !apiClass.equals(that.apiClass) : that.apiClass != null) return false;
- return apiOptions != null ? apiOptions.equals(that.apiOptions) : that.apiOptions == null;
+ if (!Objects.equals(apiClass, that.apiClass)) return false;
+ return Objects.equals(apiOptions, that.apiOptions);
}
@Override
diff --git a/play-services-base/src/main/java/org/microg/gms/common/api/ReturningGoogleApiCall.java b/play-services-base/src/main/java/org/microg/gms/common/api/InstantGoogleApiCall.java
similarity index 77%
rename from play-services-base/src/main/java/org/microg/gms/common/api/ReturningGoogleApiCall.java
rename to play-services-base/src/main/java/org/microg/gms/common/api/InstantGoogleApiCall.java
index f836b9d4..5e813d8b 100644
--- a/play-services-base/src/main/java/org/microg/gms/common/api/ReturningGoogleApiCall.java
+++ b/play-services-base/src/main/java/org/microg/gms/common/api/InstantGoogleApiCall.java
@@ -5,10 +5,9 @@
package org.microg.gms.common.api;
-import com.google.android.gms.common.api.Api;
import com.google.android.gms.tasks.TaskCompletionSource;
-public interface ReturningGoogleApiCall extends PendingGoogleApiCall {
+public interface InstantGoogleApiCall extends PendingGoogleApiCall {
R execute(A client) throws Exception;
@Override
diff --git a/play-services-base/src/main/java/org/microg/gms/common/api/PendingGoogleApiCall.java b/play-services-base/src/main/java/org/microg/gms/common/api/PendingGoogleApiCall.java
index 578d02b9..8c92abd7 100644
--- a/play-services-base/src/main/java/org/microg/gms/common/api/PendingGoogleApiCall.java
+++ b/play-services-base/src/main/java/org/microg/gms/common/api/PendingGoogleApiCall.java
@@ -5,9 +5,8 @@
package org.microg.gms.common.api;
-import com.google.android.gms.common.api.Api;
import com.google.android.gms.tasks.TaskCompletionSource;
-public interface PendingGoogleApiCall {
- void execute(A client, TaskCompletionSource completionSource) throws Exception;
+public interface PendingGoogleApiCall {
+ void execute(A client, TaskCompletionSource completionSource);
}
diff --git a/play-services-base/src/main/java/org/microg/gms/common/api/ResultCallbackHandler.java b/play-services-base/src/main/java/org/microg/gms/common/api/ResultCallbackHandler.java
index c19c849c..1ddb4d47 100644
--- a/play-services-base/src/main/java/org/microg/gms/common/api/ResultCallbackHandler.java
+++ b/play-services-base/src/main/java/org/microg/gms/common/api/ResultCallbackHandler.java
@@ -50,7 +50,7 @@ class ResultCallbackHandler extends Handler {
public void sendResultCallback(ResultCallback callback, R result) {
Message message = new Message();
message.what = CALLBACK_ON_COMPLETE;
- message.obj = new OnCompleteObject(callback, result);
+ message.obj = new OnCompleteObject<>(callback, result);
sendMessage(message);
}
diff --git a/play-services-base/src/main/java/org/microg/gms/common/api/VoidReturningGoogleApiCall.java b/play-services-base/src/main/java/org/microg/gms/common/api/VoidReturningGoogleApiCall.java
deleted file mode 100644
index ee8cbf66..00000000
--- a/play-services-base/src/main/java/org/microg/gms/common/api/VoidReturningGoogleApiCall.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2022 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package org.microg.gms.common.api;
-
-import com.google.android.gms.common.api.Api;
-import com.google.android.gms.tasks.TaskCompletionSource;
-
-public interface VoidReturningGoogleApiCall extends PendingGoogleApiCall{
- void execute(A client) throws Exception;
-
- @Override
- default void execute(A client, TaskCompletionSource completionSource) {
- try {
- execute(client);
- completionSource.setResult(null);
- } catch (Exception e) {
- completionSource.setException(e);
- }
- }
-}
diff --git a/play-services-basement/build.gradle b/play-services-basement/build.gradle
index 9884e3c9..9499e1c3 100644
--- a/play-services-basement/build.gradle
+++ b/play-services-basement/build.gradle
@@ -18,7 +18,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
dependencies {
- api "org.microg:safe-parcel:$safeParcelVersion"
+ api "org.microg:safe-parcel:1.7.0"
// Dependencies from play-services-basement:18.0.0
api "androidx.collection:collection:$collectionVersion"
@@ -39,12 +39,10 @@ android {
minSdkVersion androidMinSdk
targetSdkVersion androidTargetSdk
buildConfigField "int", "VERSION_CODE", "$appVersionCode"
- buildConfigField "String", "BASE_PACKAGE_NAME", "\"$basePackageName\""
}
buildFeatures {
viewBinding = true
- aidl true
}
sourceSets {
@@ -52,8 +50,7 @@ android {
}
compileOptions {
- sourceCompatibility = 17
- targetCompatibility = 17
+ sourceCompatibility = 1.8
+ targetCompatibility = 1.8
}
- namespace 'org.microg.gms.basement'
}
\ No newline at end of file
diff --git a/play-services-basement/src/main/AndroidManifest.xml b/play-services-basement/src/main/AndroidManifest.xml
index 359a9b71..bd436773 100644
--- a/play-services-basement/src/main/AndroidManifest.xml
+++ b/play-services-basement/src/main/AndroidManifest.xml
@@ -15,4 +15,4 @@
~ limitations under the License.
-->
-
+
diff --git a/play-services-basement/src/main/aidl/com/google/android/gms/common/ConnectionResult.aidl b/play-services-basement/src/main/aidl/com/google/android/gms/common/ConnectionResult.aidl
deleted file mode 100644
index e46e6d5d..00000000
--- a/play-services-basement/src/main/aidl/com/google/android/gms/common/ConnectionResult.aidl
+++ /dev/null
@@ -1,3 +0,0 @@
-package com.google.android.gms.common;
-
-parcelable ConnectionResult;
\ No newline at end of file
diff --git a/play-services-basement/src/main/aidl/com/google/android/gms/common/GoogleCertificatesLookupQuery.aidl b/play-services-basement/src/main/aidl/com/google/android/gms/common/GoogleCertificatesLookupQuery.aidl
deleted file mode 100644
index fab15aa1..00000000
--- a/play-services-basement/src/main/aidl/com/google/android/gms/common/GoogleCertificatesLookupQuery.aidl
+++ /dev/null
@@ -1,3 +0,0 @@
-package com.google.android.gms.common;
-
-parcelable GoogleCertificatesLookupQuery;
\ No newline at end of file
diff --git a/play-services-basement/src/main/aidl/com/google/android/gms/common/GoogleCertificatesLookupResponse.aidl b/play-services-basement/src/main/aidl/com/google/android/gms/common/GoogleCertificatesLookupResponse.aidl
deleted file mode 100644
index e9b4bff3..00000000
--- a/play-services-basement/src/main/aidl/com/google/android/gms/common/GoogleCertificatesLookupResponse.aidl
+++ /dev/null
@@ -1,3 +0,0 @@
-package com.google.android.gms.common;
-
-parcelable GoogleCertificatesLookupResponse;
\ No newline at end of file
diff --git a/play-services-basement/src/main/aidl/com/google/android/gms/common/GoogleCertificatesQuery.aidl b/play-services-basement/src/main/aidl/com/google/android/gms/common/GoogleCertificatesQuery.aidl
deleted file mode 100644
index e6aedfef..00000000
--- a/play-services-basement/src/main/aidl/com/google/android/gms/common/GoogleCertificatesQuery.aidl
+++ /dev/null
@@ -1,3 +0,0 @@
-package com.google.android.gms.common;
-
-parcelable GoogleCertificatesQuery;
\ No newline at end of file
diff --git a/play-services-basement/src/main/aidl/com/google/android/gms/common/internal/ConnectionInfo.aidl b/play-services-basement/src/main/aidl/com/google/android/gms/common/internal/ConnectionInfo.aidl
deleted file mode 100644
index b393f11d..00000000
--- a/play-services-basement/src/main/aidl/com/google/android/gms/common/internal/ConnectionInfo.aidl
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2020, microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.google.android.gms.common.internal;
-parcelable ConnectionInfo;
diff --git a/play-services-basement/src/main/aidl/com/google/android/gms/common/internal/IGmsCallbacks.aidl b/play-services-basement/src/main/aidl/com/google/android/gms/common/internal/IGmsCallbacks.aidl
index 8fe63347..b0210281 100644
--- a/play-services-basement/src/main/aidl/com/google/android/gms/common/internal/IGmsCallbacks.aidl
+++ b/play-services-basement/src/main/aidl/com/google/android/gms/common/internal/IGmsCallbacks.aidl
@@ -1,15 +1,7 @@
-/*
- * SPDX-FileCopyrightText: 2020, microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
package com.google.android.gms.common.internal;
import android.os.Bundle;
-import com.google.android.gms.common.internal.ConnectionInfo;
interface IGmsCallbacks {
void onPostInitComplete(int statusCode, IBinder binder, in Bundle params);
- void onAccountValidationComplete(int statusCode, in Bundle params);
- void onPostInitCompleteWithConnectionInfo(int statusCode, IBinder binder, in ConnectionInfo info);
}
diff --git a/play-services-basement/src/main/aidl/com/google/android/gms/common/internal/IGoogleCertificatesApi.aidl b/play-services-basement/src/main/aidl/com/google/android/gms/common/internal/IGoogleCertificatesApi.aidl
deleted file mode 100644
index 6d54ad26..00000000
--- a/play-services-basement/src/main/aidl/com/google/android/gms/common/internal/IGoogleCertificatesApi.aidl
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.google.android.gms.common.internal;
-
-import com.google.android.gms.common.GoogleCertificatesLookupQuery;
-import com.google.android.gms.common.GoogleCertificatesLookupResponse;
-import com.google.android.gms.common.GoogleCertificatesQuery;
-import com.google.android.gms.dynamic.IObjectWrapper;
-
-interface IGoogleCertificatesApi {
- IObjectWrapper getGoogleCertificates() = 0;
- IObjectWrapper getGoogleReleaseCertificates() = 1;
- boolean isGoogleReleaseSigned(String packageName, IObjectWrapper certData) = 2;
- boolean isGoogleSigned(String packageName, IObjectWrapper certData) = 3;
- boolean isGoogleOrPlatformSigned(in GoogleCertificatesQuery query, IObjectWrapper packageManager) = 4;
- GoogleCertificatesLookupResponse isPackageGoogleOrPlatformSigned(in GoogleCertificatesLookupQuery query) = 5;
- boolean isPackageGoogleOrPlatformSignedAvailable() = 6;
- GoogleCertificatesLookupResponse queryPackageSigned(in GoogleCertificatesLookupQuery query) = 7;
- boolean isFineGrainedPackageVerificationAvailable() = 8;
-}
\ No newline at end of file
diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/GoogleCertificatesLookupQuery.java b/play-services-basement/src/main/java/com/google/android/gms/common/GoogleCertificatesLookupQuery.java
deleted file mode 100644
index ab8da97a..00000000
--- a/play-services-basement/src/main/java/com/google/android/gms/common/GoogleCertificatesLookupQuery.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.google.android.gms.common;
-
-import android.content.Context;
-import android.os.Parcel;
-import androidx.annotation.NonNull;
-import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
-import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
-import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter;
-import com.google.android.gms.dynamic.IObjectWrapper;
-import com.google.android.gms.dynamic.ObjectWrapper;
-
-@SafeParcelable.Class
-public class GoogleCertificatesLookupQuery extends AbstractSafeParcelable {
- @Field(value = 1, getterName = "getCallingPackage")
- String callingPackage;
- @Field(2)
- boolean allowTestKeys;
- @Field(3)
- boolean ignoreTestKeysOverride;
- @Field(4)
- IObjectWrapper contextWrapper;
- private Context context;
- @Field(5)
- boolean isChimeraPackage;
- @Field(6)
- boolean includeHashesInErrorMessage;
-
- public String getCallingPackage() {
- return callingPackage;
- }
-
- public Context getContext() {
- if (context == null && contextWrapper != null) {
- context = ObjectWrapper.unwrapTyped(contextWrapper, Context.class);
- }
- return context;
- }
-
- @Override
- public void writeToParcel(@NonNull Parcel dest, int flags) {
- CREATOR.writeToParcel(this, dest, flags);
- }
-
- public static final SafeParcelableCreatorAndWriter CREATOR = findCreator(GoogleCertificatesLookupQuery.class);
-}
diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/GoogleCertificatesLookupResponse.java b/play-services-basement/src/main/java/com/google/android/gms/common/GoogleCertificatesLookupResponse.java
deleted file mode 100644
index 90e0ee3a..00000000
--- a/play-services-basement/src/main/java/com/google/android/gms/common/GoogleCertificatesLookupResponse.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.google.android.gms.common;
-
-import android.os.Parcel;
-import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
-import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
-import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter;
-
-@SafeParcelable.Class
-public class GoogleCertificatesLookupResponse extends AbstractSafeParcelable {
- @Field(1)
- public final boolean result;
- @Field(2)
- public final String errorMessage;
- @Field(3)
- public final int statusValue;
- @Field(4)
- public final int firstPartyStatusValue;
-
- @Constructor
- public GoogleCertificatesLookupResponse(@Param(1) boolean result, @Param(2) String errorMessage, @Param(3) int statusValue, @Param(4) int firstPartyStatusValue) {
- this.result = result;
- this.errorMessage = errorMessage;
- this.statusValue = statusValue;
- this.firstPartyStatusValue = firstPartyStatusValue;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- CREATOR.writeToParcel(this, out, flags);
- }
-
- public static final SafeParcelableCreatorAndWriter CREATOR = findCreator(GoogleCertificatesLookupResponse.class);
-}
diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/internal/ConnectionInfo.java b/play-services-basement/src/main/java/com/google/android/gms/common/internal/ConnectionInfo.java
deleted file mode 100644
index 19326d08..00000000
--- a/play-services-basement/src/main/java/com/google/android/gms/common/internal/ConnectionInfo.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2020, microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.google.android.gms.common.internal;
-
-import android.os.Bundle;
-import android.os.Parcel;
-import androidx.annotation.NonNull;
-import com.google.android.gms.common.Feature;
-import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
-import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
-import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter;
-
-@SafeParcelable.Class
-public class ConnectionInfo extends AbstractSafeParcelable {
- @Field(1)
- public Bundle params;
- @Field(2)
- public Feature[] features;
- @Field(3)
- public int unknown3;
-
- @Override
- public void writeToParcel(@NonNull Parcel dest, int flags) {
- CREATOR.writeToParcel(this, dest, flags);
- }
-
- public static final SafeParcelableCreatorAndWriter CREATOR = findCreator(ConnectionInfo.class);
-}
diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/internal/GetServiceRequest.java b/play-services-basement/src/main/java/com/google/android/gms/common/internal/GetServiceRequest.java
index 9df8735c..a203a99f 100644
--- a/play-services-basement/src/main/java/com/google/android/gms/common/internal/GetServiceRequest.java
+++ b/play-services-basement/src/main/java/com/google/android/gms/common/internal/GetServiceRequest.java
@@ -31,7 +31,7 @@ import java.util.Arrays;
public class GetServiceRequest extends AutoSafeParcelable {
@Field(1)
- private final int versionCode = 6;
+ private final int versionCode = 4;
@Field(2)
public final int serviceId;
@Field(3)
@@ -47,7 +47,6 @@ public class GetServiceRequest extends AutoSafeParcelable {
@Field(8)
public Account account;
@Field(9)
- @Deprecated
private long field9;
@Field(10)
public Feature[] defaultFeatures;
@@ -60,7 +59,7 @@ public class GetServiceRequest extends AutoSafeParcelable {
@Field(14)
private boolean field14;
@Field(15)
- private String attributionTag;
+ private String field15;
private GetServiceRequest() {
serviceId = -1;
diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/internal/ValidateAccountRequest.java b/play-services-basement/src/main/java/com/google/android/gms/common/internal/ValidateAccountRequest.java
index 1cf0ecc1..75e59d95 100644
--- a/play-services-basement/src/main/java/com/google/android/gms/common/internal/ValidateAccountRequest.java
+++ b/play-services-basement/src/main/java/com/google/android/gms/common/internal/ValidateAccountRequest.java
@@ -16,18 +16,8 @@
package com.google.android.gms.common.internal;
-import android.os.Parcel;
-import androidx.annotation.NonNull;
-import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
-import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
-import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter;
+import org.microg.safeparcel.AutoSafeParcelable;
-@SafeParcelable.Class
-public class ValidateAccountRequest extends AbstractSafeParcelable {
- @Override
- public void writeToParcel(@NonNull Parcel dest, int flags) {
- CREATOR.writeToParcel(this, dest, flags);
- }
-
- public static SafeParcelableCreatorAndWriter CREATOR = findCreator(ValidateAccountRequest.class);
+public class ValidateAccountRequest extends AutoSafeParcelable {
+ public static Creator CREATOR = new AutoCreator<>(ValidateAccountRequest.class);
}
diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/AbstractSafeParcelable.java b/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/AbstractSafeParcelable.java
deleted file mode 100644
index ec7d84d5..00000000
--- a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/AbstractSafeParcelable.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.google.android.gms.common.internal.safeparcel;
-
-public abstract class AbstractSafeParcelable implements SafeParcelable {
-
- @SuppressWarnings("unchecked")
- public static SafeParcelableCreatorAndWriter findCreator(java.lang.Class tClass) {
- String creatorClassName = tClass.getName() + "$000Creator";
- try {
- return (SafeParcelableCreatorAndWriter) java.lang.Class.forName(creatorClassName).newInstance();
- } catch (Exception e) {
- throw new RuntimeException("No Creator found for " + tClass.getName(), e);
- }
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-}
diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelReader.java b/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelReader.java
deleted file mode 100644
index 226f50e8..00000000
--- a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelReader.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2015, microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.google.android.gms.common.internal.safeparcel;
-
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-@SuppressWarnings("MagicNumber")
-public final class SafeParcelReader {
-
- private SafeParcelReader() {
- }
-
- @Deprecated
- public static int halfOf(int i) {
- return i & 0xFFFF;
- }
-
- public static int getFieldId(int header) {
- return header & 0xFFFF;
- }
-
- @Deprecated
- public static int readSingleInt(Parcel parcel) {
- return parcel.readInt();
- }
-
- public static int readHeader(Parcel parcel) {
- return parcel.readInt();
- }
-
- private static int readSize(Parcel parcel, int header) {
- if ((header & 0xFFFF0000) != 0xFFFF0000)
- return header >> 16 & 0xFFFF;
- return parcel.readInt();
- }
-
- private static void readExpectedSize(Parcel parcel, int header, int expectedSize) {
- int i = readSize(parcel, header);
- if (i != expectedSize)
- throw new ReadException("Expected size " + expectedSize + " got " + i + " (0x" + Integer.toHexString(i) + ")", parcel);
- }
-
- @Deprecated
- public static int readStart(Parcel parcel) {
- return readObjectHeader(parcel);
- }
-
- public static int readObjectHeader(Parcel parcel) {
- int header = readHeader(parcel);
- int size = readSize(parcel, header);
- int start = parcel.dataPosition();
- if (getFieldId(header) != SafeParcelable.SAFE_PARCEL_OBJECT_MAGIC)
- throw new ReadException("Expected object header. Got 0x" + Integer.toHexString(header), parcel);
- int end = start + size;
- if ((end < start) || (end > parcel.dataSize()))
- throw new ReadException("Size read is invalid start=" + start + " end=" + end, parcel);
- return end;
- }
-
- public static int readInt(Parcel parcel, int header) {
- readExpectedSize(parcel, header, 4);
- return parcel.readInt();
- }
-
- public static byte readByte(Parcel parcel, int header) {
- readExpectedSize(parcel, header, 4);
- return (byte) parcel.readInt();
- }
-
- public static short readShort(Parcel parcel, int header) {
- readExpectedSize(parcel, header, 4);
- return (short) parcel.readInt();
- }
-
- public static boolean readBool(Parcel parcel, int header) {
- readExpectedSize(parcel, header, 4);
- return parcel.readInt() != 0;
- }
-
- public static long readLong(Parcel parcel, int header) {
- readExpectedSize(parcel, header, 8);
- return parcel.readLong();
- }
-
- public static float readFloat(Parcel parcel, int header) {
- readExpectedSize(parcel, header, 4);
- return parcel.readFloat();
- }
-
- public static double readDouble(Parcel parcel, int header) {
- readExpectedSize(parcel, header, 8);
- return parcel.readDouble();
- }
-
- public static String readString(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- String string = parcel.readString();
- parcel.setDataPosition(start + size);
- return string;
- }
-
- public static IBinder readBinder(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- IBinder binder = parcel.readStrongBinder();
- parcel.setDataPosition(start + size);
- return binder;
- }
-
- public static T readParcelable(Parcel parcel, int header, Parcelable.Creator creator) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- T t = creator.createFromParcel(parcel);
- parcel.setDataPosition(start + size);
- return t;
- }
-
- public static ArrayList readList(Parcel parcel, int header, ClassLoader classLoader) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- ArrayList list = parcel.readArrayList(classLoader);
- parcel.setDataPosition(start + size);
- return list;
- }
-
- public static HashMap readMap(Parcel parcel, int header, ClassLoader classLoader) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- HashMap map = parcel.readHashMap(classLoader);
- parcel.setDataPosition(start + size);
- return map;
- }
-
- public static ArrayList readParcelableList(Parcel parcel, int header, Parcelable.Creator creator) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- ArrayList list = parcel.createTypedArrayList(creator);
- parcel.setDataPosition(start + size);
- return list;
- }
-
- public static ArrayList readStringList(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- ArrayList list = parcel.createStringArrayList();
- parcel.setDataPosition(start + size);
- return list;
- }
-
- public static ArrayList readIntegerList(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- int length = parcel.readInt();
- ArrayList list = new ArrayList<>(length);
- for (int i = 0; i < length; i++) {
- list.add(parcel.readInt());
- }
- parcel.setDataPosition(start + size);
- return list;
- }
-
- public static ArrayList readLongList(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- int length = parcel.readInt();
- ArrayList list = new ArrayList<>(length);
- for (int i = 0; i < length; i++) {
- list.add(parcel.readLong());
- }
- parcel.setDataPosition(start + size);
- return list;
- }
-
- public static ArrayList readFloatList(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- int length = parcel.readInt();
- ArrayList list = new ArrayList<>(length);
- for (int i = 0; i < length; i++) {
- list.add(parcel.readFloat());
- }
- parcel.setDataPosition(start + size);
- return list;
- }
-
- public static ArrayList readDoubleList(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- int length = parcel.readInt();
- ArrayList list = new ArrayList<>(length);
- for (int i = 0; i < length; i++) {
- list.add(parcel.readDouble());
- }
- parcel.setDataPosition(start + size);
- return list;
- }
-
- public static ArrayList readBooleanList(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- int length = parcel.readInt();
- ArrayList list = new ArrayList<>(length);
- for (int i = 0; i < length; i++) {
- list.add(parcel.readInt() != 0);
- }
- parcel.setDataPosition(start + size);
- return list;
- }
-
- public static T[] readParcelableArray(Parcel parcel, int header, Parcelable.Creator creator) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- T[] arr = parcel.createTypedArray(creator);
- parcel.setDataPosition(start + size);
- return arr;
- }
-
- public static String[] readStringArray(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- String[] arr = parcel.createStringArray();
- parcel.setDataPosition(start + size);
- return arr;
- }
-
- public static byte[] readByteArray(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- byte[] arr = parcel.createByteArray();
- parcel.setDataPosition(start + size);
- return arr;
- }
-
- public static byte[][] readByteArrayArray(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- int length = parcel.readInt();
- byte[][] arr = new byte[length][];
- for (int i = 0; i < length; i++) {
- arr[i] = parcel.createByteArray();
- }
- parcel.setDataPosition(start + size);
- return arr;
- }
-
- public static float[] readFloatArray(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- float[] arr = parcel.createFloatArray();
- parcel.setDataPosition(start + size);
- return arr;
- }
-
- public static int[] readIntArray(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- int[] arr = parcel.createIntArray();
- parcel.setDataPosition(start + size);
- return arr;
- }
-
- public static Bundle readBundle(Parcel parcel, int header, ClassLoader classLoader) {
- int size = readSize(parcel, header);
- if (size == 0)
- return null;
- int start = parcel.dataPosition();
- Bundle bundle = parcel.readBundle(classLoader);
- parcel.setDataPosition(start + size);
- return bundle;
- }
-
- public static void skip(Parcel parcel, int header) {
- int size = readSize(parcel, header);
- parcel.setDataPosition(parcel.dataPosition() + size);
- }
-
- public static class ReadException extends RuntimeException {
- public ReadException(String message, Parcel parcel) {
- super(message);
- }
- }
-}
\ No newline at end of file
diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelWriter.java b/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelWriter.java
deleted file mode 100644
index b2f96116..00000000
--- a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelWriter.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2015, microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.google.android.gms.common.internal.safeparcel;
-
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import java.util.List;
-import java.util.Map;
-
-@SuppressWarnings("MagicNumber")
-public final class SafeParcelWriter {
-
- private SafeParcelWriter() {
- }
-
- private static void writeHeader(Parcel parcel, int fieldId, int size) {
- if (size >= 0xFFFF) {
- parcel.writeInt(0xFFFF0000 | fieldId);
- parcel.writeInt(size);
- } else {
- parcel.writeInt(size << 16 | fieldId);
- }
- }
-
- @Deprecated
- public static int writeStart(Parcel parcel) {
- return writeObjectHeader(parcel);
- }
-
- public static int writeObjectHeader(Parcel parcel) {
- writeHeader(parcel, SafeParcelable.SAFE_PARCEL_OBJECT_MAGIC, 0xFFFF);
- return parcel.dataPosition();
- }
-
- private static int writeObjectHeader(Parcel parcel, int fieldId) {
- writeHeader(parcel, fieldId, 0xFFFF);
- return parcel.dataPosition();
- }
-
- @Deprecated
- public static void writeEnd(Parcel parcel, int start) {
- finishObjectHeader(parcel, start);
- }
-
- public static void finishObjectHeader(Parcel parcel, int start) {
- int end = parcel.dataPosition();
- int length = end - start;
- parcel.setDataPosition(start - 4);
- parcel.writeInt(length);
- parcel.setDataPosition(end);
- }
-
- public static void write(Parcel parcel, int fieldId, Boolean val) {
- if (val == null) return;
- writeHeader(parcel, fieldId, 4);
- parcel.writeInt(val ? 1 : 0);
- }
-
- public static void write(Parcel parcel, int fieldId, Byte val) {
- if (val == null) return;
- writeHeader(parcel, fieldId, 4);
- parcel.writeInt(val);
- }
-
- public static void write(Parcel parcel, int fieldId, Short val) {
- if (val == null) return;
- writeHeader(parcel, fieldId, 4);
- parcel.writeInt(val);
- }
-
- public static void write(Parcel parcel, int fieldId, Integer val) {
- if (val == null) return;
- writeHeader(parcel, fieldId, 4);
- parcel.writeInt(val);
- }
-
- public static void write(Parcel parcel, int fieldId, Long val) {
- if (val == null) return;
- writeHeader(parcel, fieldId, 8);
- parcel.writeLong(val);
- }
-
- public static void write(Parcel parcel, int fieldId, Float val) {
- if (val == null) return;
- writeHeader(parcel, fieldId, 4);
- parcel.writeFloat(val);
- }
-
- public static void write(Parcel parcel, int fieldId, Double val) {
- if (val == null) return;
- writeHeader(parcel, fieldId, 8);
- parcel.writeDouble(val);
- }
-
- public static void write(Parcel parcel, int fieldId, String val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeString(val);
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void write(Parcel parcel, int fieldId, Parcelable val, int flags, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- val.writeToParcel(parcel, flags);
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void write(Parcel parcel, int fieldId, Bundle val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeBundle(val);
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void write(Parcel parcel, int fieldId, byte[] val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeByteArray(val);
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void write(Parcel parcel, int fieldId, byte[][] val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeInt(val.length);
- for (byte[] arr : val) {
- parcel.writeByteArray(arr);
- }
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void write(Parcel parcel, int fieldId, float[] val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeFloatArray(val);
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void write(Parcel parcel, int fieldId, int[] val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeIntArray(val);
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void write(Parcel parcel, int fieldId, String[] val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeStringArray(val);
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void writeStringList(Parcel parcel, int fieldId, List val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeStringList(val);
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void writeIntegerList(Parcel parcel, int fieldId, List val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeInt(val.size());
- for (Integer i : val) {
- parcel.writeInt(i);
- }
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void writeLongList(Parcel parcel, int fieldId, List val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeInt(val.size());
- for (Long l : val) {
- parcel.writeLong(l);
- }
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void writeFloatList(Parcel parcel, int fieldId, List val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeInt(val.size());
- for (Float f : val) {
- parcel.writeFloat(f);
- }
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void writeDoubleList(Parcel parcel, int fieldId, List val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeInt(val.size());
- for (Double d : val) {
- parcel.writeDouble(d);
- }
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void writeBooleanList(Parcel parcel, int fieldId, List val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeInt(val.size());
- for (Boolean b : val) {
- parcel.writeInt(b ? 1 : 0);
- }
- finishObjectHeader(parcel, start);
- }
- }
-
- private static void writeArrayPart(Parcel parcel, T val, int flags) {
- int before = parcel.dataPosition();
- parcel.writeInt(1);
- int start = parcel.dataPosition();
- val.writeToParcel(parcel, flags);
- int end = parcel.dataPosition();
- parcel.setDataPosition(before);
- parcel.writeInt(end - start);
- parcel.setDataPosition(end);
- }
-
- public static void write(Parcel parcel, int fieldId, T[] val, int flags, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeInt(val.length);
- for (T t : val) {
- if (t == null) {
- parcel.writeInt(0);
- } else {
- writeArrayPart(parcel, t, flags);
- }
- }
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void write(Parcel parcel, int fieldId, List val, int flags, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeInt(val.size());
- for (T t : val) {
- if (t == null) {
- parcel.writeInt(0);
- } else {
- writeArrayPart(parcel, t, flags);
- }
- }
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void write(Parcel parcel, int fieldId, Parcel val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.appendFrom(val, 0, val.dataSize());
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void write(Parcel parcel, int fieldId, List val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeList(val);
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void write(Parcel parcel, int fieldId, Map val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeMap(val);
- finishObjectHeader(parcel, start);
- }
- }
-
- public static void write(Parcel parcel, int fieldId, IBinder val, boolean mayNull) {
- if (val == null) {
- if (mayNull) {
- writeHeader(parcel, fieldId, 0);
- }
- } else {
- int start = writeObjectHeader(parcel, fieldId);
- parcel.writeStrongBinder(val);
- finishObjectHeader(parcel, start);
- }
- }
-
-}
\ No newline at end of file
diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelable.java b/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelable.java
deleted file mode 100644
index 0d8d1cc0..00000000
--- a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelable.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.google.android.gms.common.internal.safeparcel;
-
-import android.os.Parcelable;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-public interface SafeParcelable extends Parcelable {
- int SAFE_PARCEL_OBJECT_MAGIC = 0x4F45;
-
- @Target(ElementType.TYPE)
- @interface Class {
- }
-
- @Target(ElementType.CONSTRUCTOR)
- @interface Constructor {
-
- }
-
- @Target(ElementType.PARAMETER)
- @interface Param {
- int value();
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.FIELD)
- @interface Field {
- int value();
-
- boolean mayNull() default false;
-
- java.lang.Class> subClass() default SafeParcelable.class;
-
- boolean useValueParcel() default false;
-
- boolean useDirectList() default false;
-
- long versionCode() default -1;
-
- String defaultValue() default "";
-
- String type() default "";
-
- String getterName() default "";
-
- String getter() default "";
- }
-}
diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelableCreatorAndWriter.java b/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelableCreatorAndWriter.java
deleted file mode 100644
index 6afaa9c6..00000000
--- a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelableCreatorAndWriter.java
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.google.android.gms.common.internal.safeparcel;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-public interface SafeParcelableCreatorAndWriter extends Parcelable.Creator {
- void writeToParcel(T object, Parcel parcel, int flags);
-}
diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelableSerializer.java b/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelableSerializer.java
deleted file mode 100644
index 66b8b4d5..00000000
--- a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/SafeParcelableSerializer.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.google.android.gms.common.internal.safeparcel;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-public class SafeParcelableSerializer {
- public static T deserializeFromBytes(byte[] bytes, Parcelable.Creator tCreator) {
- if (bytes == null) return null;
- Parcel parcel = Parcel.obtain();
- parcel.unmarshall(bytes, 0, bytes.length);
- parcel.setDataPosition(0);
- T parcelable = tCreator.createFromParcel(parcel);
- parcel.recycle();
- return parcelable;
- }
-
- public static byte[] serializeToBytes(T parcelable) {
- if (parcelable == null) return null;
- Parcel parcel = Parcel.obtain();
- parcelable.writeToParcel(parcel, 0);
- byte[] bytes = parcel.marshall();
- parcel.recycle();
- return bytes;
- }
-}
diff --git a/play-services-basement/src/main/java/com/google/android/gms/dynamic/ObjectWrapper.java b/play-services-basement/src/main/java/com/google/android/gms/dynamic/ObjectWrapper.java
index 4bc96034..649af71b 100644
--- a/play-services-basement/src/main/java/com/google/android/gms/dynamic/ObjectWrapper.java
+++ b/play-services-basement/src/main/java/com/google/android/gms/dynamic/ObjectWrapper.java
@@ -18,7 +18,6 @@ package com.google.android.gms.dynamic;
import android.os.IBinder;
-import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.reflect.Field;
@@ -35,13 +34,37 @@ public class ObjectWrapper extends IObjectWrapper.Stub {
if (obj == null) {
return null;
}
-
if (obj instanceof ObjectWrapper) {
- return ((ObjectWrapper>) obj).t;
+ return ((ObjectWrapper) obj).t;
+ }
+ IBinder binder = obj.asBinder();
+ Field[] fields = binder.getClass().getDeclaredFields();
+
+ if (fields.length < 1) {
+ throw new IllegalArgumentException("No fields were found");
}
- IBinder binder = obj.asBinder();
- Field field = getField(binder);
+ // Ignore synthetic field(s) from JaCoCo or elsewhere
+ // https://www.jacoco.org/jacoco/trunk/doc/faq.html
+
+ @Nullable
+ Field field = null;
+
+ for (Field currentField : fields) {
+ if (currentField.isSynthetic()) {
+ continue;
+ }
+
+ if (field == null) {
+ field = currentField;
+ } else {
+ throw new IllegalArgumentException("Too many non-synthetic fields were found");
+ }
+ }
+
+ if (field == null) {
+ throw new IllegalArgumentException("No non-synthetic fields were found");
+ }
if (!field.isAccessible()) {
field.setAccessible(true);
@@ -62,35 +85,6 @@ public class ObjectWrapper extends IObjectWrapper.Stub {
}
}
- @NonNull
- private static Field getField(IBinder binder) {
- Field[] fields = binder.getClass().getDeclaredFields();
-
- if (fields.length < 1) {
- throw new IllegalArgumentException("No fields were found");
- }
-
- @Nullable
- Field field = null;
-
- for (Field currentField : fields) {
- if (currentField.isSynthetic()) {
- continue;
- }
-
- if (field == null) {
- field = currentField;
- } else {
- throw new IllegalArgumentException("Too many non-synthetic fields were found");
- }
- }
-
- if (field == null) {
- throw new IllegalArgumentException("No non-synthetic fields were found");
- }
- return field;
- }
-
@Nullable
public static T unwrapTyped(IObjectWrapper obj, Class clazz) {
try {
@@ -101,6 +95,6 @@ public class ObjectWrapper extends IObjectWrapper.Stub {
}
public static ObjectWrapper wrap(T t) {
- return new ObjectWrapper<>(t);
+ return new ObjectWrapper(t);
}
-}
+}
\ No newline at end of file
diff --git a/play-services-basement/src/main/java/org/microg/gms/auth/AuthConstants.java b/play-services-basement/src/main/java/org/microg/gms/auth/AuthConstants.java
index 6cac0d45..52c1dc72 100644
--- a/play-services-basement/src/main/java/org/microg/gms/auth/AuthConstants.java
+++ b/play-services-basement/src/main/java/org/microg/gms/auth/AuthConstants.java
@@ -16,8 +16,6 @@
package org.microg.gms.auth;
-import org.microg.gms.basement.BuildConfig;
-
public class AuthConstants {
public static final String DEFAULT_ACCOUNT = "<>";
public static final String SCOPE_GET_ACCOUNT_ID = "^^_account_id_^^";
@@ -25,5 +23,5 @@ public class AuthConstants {
public static final String PROVIDER_METHOD_CLEAR_PASSWORD = "clear_password";
public static final String PROVIDER_EXTRA_CLEAR_PASSWORD = "clear_password";
public static final String PROVIDER_EXTRA_ACCOUNTS = "accounts";
- public static final String DEFAULT_ACCOUNT_TYPE = BuildConfig.BASE_PACKAGE_NAME;
+ public static final String DEFAULT_ACCOUNT_TYPE = "com.mgoogle";
}
diff --git a/play-services-basement/src/main/java/org/microg/gms/common/Constants.java b/play-services-basement/src/main/java/org/microg/gms/common/Constants.java
index a905f2bc..217ea437 100644
--- a/play-services-basement/src/main/java/org/microg/gms/common/Constants.java
+++ b/play-services-basement/src/main/java/org/microg/gms/common/Constants.java
@@ -21,8 +21,10 @@ import org.microg.gms.basement.BuildConfig;
public class Constants {
public static final int GMS_VERSION_CODE = (BuildConfig.VERSION_CODE / 1000) * 1000;
public static final String GMS_PACKAGE_NAME = "com.google.android.gms";
- public static final String GSF_PACKAGE_NAME = BuildConfig.BASE_PACKAGE_NAME + ".android.gsf";
+ public static final String GSF_PACKAGE_NAME = "com.mgoogle.android.gsf";
public static final String GMS_PACKAGE_SIGNATURE_SHA1 = "38918a453d07199354f8b19af05ec6562ced5788";
+ public static final String GMS_SECONDARY_PACKAGE_SIGNATURE_SHA1 = "bd32424203e0fb25f36b57e5aa356f9bdd1da998";
+
@Deprecated
public static final int MAX_REFERENCE_VERSION = GMS_VERSION_CODE;
}
diff --git a/play-services-basement/src/main/java/org/microg/gms/common/GmsService.java b/play-services-basement/src/main/java/org/microg/gms/common/GmsService.java
index efdbb1d2..c9b11ad1 100644
--- a/play-services-basement/src/main/java/org/microg/gms/common/GmsService.java
+++ b/play-services-basement/src/main/java/org/microg/gms/common/GmsService.java
@@ -19,156 +19,15 @@ package org.microg.gms.common;
public enum GmsService {
UNKNOWN(-2),
ANY(-1),
- GAMES(1, "com.google.android.gms.games.service.START", "com.google.android.gms.games.internal.connect.service.START"),
- PLUS(2, "com.google.android.gms.plus.service.START", "com.google.android.gms.plus.service.internal.START"),
- PANORAMA(3, "com.google.android.gms.panorama.service.START"),
- WALLET(4, "com.google.android.gms.wallet.service.BIND"),
PEOPLE(5, "com.google.android.gms.people.service.START"),
- LOCATION(6),
- APPSTATE(7, "com.google.android.gms.appstate.service.START"),
- ADREQUEST(8, "com.google.android.gms.ads.service.START"),
ACCOUNT(9, "com.google.android.gms.accounts.ACCOUNT_SERVICE"),
- CAST(10, "com.google.android.gms.cast.service.BIND_CAST_DEVICE_CONTROLLER_SERVICE"),
- DRIVE(11, "com.google.android.gms.drive.ApiService.START"),
ADDRESS(12, "com.google.android.gms.identity.service.BIND"),
- CAR(13, "com.google.android.gms.car.service.START"),
- WEARABLE(14, "com.google.android.gms.wearable.BIND"),
AUTH_PROXY(16, "com.google.android.gms.auth.service.START"),
- FITNESS(17, "com.google.android.gms.fitness.GoogleFitnessService.START"),
- REMINDERS(18, "com.google.android.gms.reminders.service.START"),
- LIGHTWEIGHT_INDEX(19, "com.google.android.gms.icing.LIGHTWEIGHT_INDEX_SERVICE"),
- DEVICE_CONNECTION(20, "com.google.android.gms.deviceconnection.service.START"),
INDEX(21, "com.google.android.gms.icing.INDEX_SERVICE"),
- LOCATION_REPORTING(22, "com.google.android.gms.location.reporting.service.START", "com.google.android.location.reporting.service.START"),
- LOCATION_MANAGER(23, "com.google.android.location.internal.GoogleLocationManagerService.START"),
- PLAY_LOG(24, "com.google.android.gms.playlog.service.START"),
- DROIDGUARD(25, "com.google.android.gms.droidguard.service.START"),
- LOCKBOX(26, "com.google.android.gms.lockbox.service.START"),
- CAST_MIRRORING(27, "com.google.android.gms.cast_mirroring.service.START"),
- NETWORK_QUALITY(28, "com.google.android.gms.mdm.services.START"),
- FEEDBACK(29, "com.google.android.gms.feedback.internal.IFeedbackService"),
- SEARCH_ADMINISTRATION(30),
- PHOTO_AUTO_BACKUP(31, "com.google.android.gms.photos.autobackup.service.START"),
- SEARCH_QUERIES(32),
- SEARCH_GLOBAL(33),
- UDC(35, "com.google.android.gms.udc.service.START"),
- SEARCH_CORPORA(36),
- DEVICE_MANAGER(37, "com.google.android.gms.mdm.services.DeviceManagerApiService.START"),
- PSEUDONYMOUS_ID(38, "com.google.android.gms.pseudonymous.service.START"),
COMMON(39, "com.google.android.gms.common.service.START"),
- CLEARCUT_LOGGER(40, "com.google.android.gms.clearcut.service.START"),
- USAGE_REPORTING(41, "com.google.android.gms.usagereporting.service.START"),
- KIDS(42, "com.google.android.gms.kids.service.START"),
- DOWNLOAD(43, "com.google.android.gms.common.download.START"),
SIGN_IN(44, "com.google.android.gms.signin.service.START"),
- SAFETY_NET_CLIENT(45, "com.google.android.gms.safetynet.service.START"),
- GSERVICES(46, "com.google.android.gms.ads.gservice.START"),
- CONTEXT_MANAGER(47, "com.google.android.contextmanager.service.ContextManagerService.START"),
- AUDIO_MODEM(48, "com.google.android.gms.audiomodem.service.AudioModemService.START"),
- NEARBY_SHARING(49, "com.google.android.gms.nearby.sharing.service.NearbySharingService.START"),
- LIGHTWEIGHT_NETWORK_QUALITY(50, "com.google.android.gms.herrevad.services.LightweightNetworkQualityAndroidService.START"),
- PHENOTYPE(51, "com.google.android.gms.phenotype.service.START"),
- VOICE_UNLOCK(52, "com.google.android.gms.speech.service.START"),
- NEARBY_CONNECTIONS(54, "com.google.android.gms.nearby.connection.service.START"),
- FITNESS_SENSORS(55, "com.google.android.gms.fitness.SensorsApi"),
- FITNESS_RECORDING(56, "com.google.android.gms.fitness.RecordingApi"),
- FITNESS_HISTORY(57, "com.google.android.gms.fitness.HistoryApi"),
- FITNESS_SESSIONS(58, "com.google.android.gms.fitness.SessionsApi"),
- FITNESS_BLE(59, "com.google.android.gms.fitness.BleApi"),
- FITNESS_CONFIG(60, "com.google.android.gms.fitness.ConfigApi"),
- FITNESS_INTERNAL(61, "com.google.android.gms.fitness.InternalApi"),
- NEARBY_MESSAGES(62, "com.google.android.gms.nearby.messages.service.NearbyMessagesService.START"),
- HELP(63, "com.google.android.gms.googlehelp.service.GoogleHelpService.START"),
- CONFIG(64, "com.google.android.gms.config.START"),
- GEODATA(65, "com.google.android.gms.location.places.GeoDataApi"),
- SEARCH_IME(66),
- PLACE_DETECTION(67, "com.google.android.gms.location.places.PlaceDetectionApi"),
CREDENTIALS(68, "com.google.android.gms.auth.api.credentials.service.START"),
- NEARBY_BOOTSTRAP(69, "com.google.android.gms.nearby.bootstrap.service.NearbyBootstrapService.START"),
- PLUS_INTERNAL(70),
- SOURCE_DEVICE(75, "com.google.android.gms.smartdevice.d2d.SourceDeviceService.START"),
- TARGET_DEVICE(76, "com.google.android.gms.smartdevice.d2d.TargetDeviceService.START"),
- APP_INVITE(77, "com.google.android.gms.appinvite.service.START"),
- TAP_AND_PAY(79, "com.google.android.gms.tapandpay.service.BIND"),
- CHROME_SYNC(80, "com.google.android.gms.chromesync.service.START"),
- ACCOUNTS(81, "com.google.android.gms.smartdevice.setup.accounts.AccountsService.START"),
- CAST_REMOTE_DISPLAY(83, "com.google.android.gms.cast.remote_display.service.START"),
- TRUST_AGENT(85, "com.google.android.gms.trustagent.StateApi.START"),
- AUTH_SIGN_IN(91, "com.google.android.gms.auth.api.signin.service.START"),
- MEASUREMENT(93, "com.google.android.gms.measurement.START"),
- FREIGHTER(98, "com.google.android.gms.freighter.service.START"),
- GUNS(110, "com.google.android.gms.notifications.service.START"),
- BLE(111, "com.google.android.gms.beacon.internal.IBleService.START"),
- FIREBASE_AUTH(112, "com.google.firebase.auth.api.gms.service.START"),
- APP_INDEXING(113),
- GASS(116, "com.google.android.gms.gass.START"),
- WORK_ACCOUNT(120),
- INSTANT_APPS(121, "com.google.android.gms.instantapps.START"),
- CAST_FIRSTPATY(122, "com.google.android.gms.cast.firstparty.START"),
- AD_CACHE(123, "com.google.android.gms.ads.service.CACHE"),
- SMS_RETRIEVER(126, "com.google.android.gms.auth.api.phone.service.SmsRetrieverApiService.START"),
- CRYPT_AUTH(129, "com.google.android.gms.auth.cryptauth.cryptauthservice.START"),
- DYNAMIC_LINKS(131, "com.google.firebase.dynamiclinks.service.START"),
- FONTS(132, "com.google.android.gms.fonts.service.START"),
- ROMANESCO(135, "com.google.android.gms.romanesco.service.START"),
- TRAINER(139, "com.google.android.gms.learning.trainer.START"),
- FIDO2_REGULAR(148, "com.google.android.gms.fido.fido2.regular.START"),
- FIDO2_PRIVILEGED(149, "com.google.android.gms.fido.fido2.privileged.START"),
- DATA_DOWNLOAD(152, "com.google.android.mdd.service.START"),
- ACCOUNT_DATA(153, "com.google.android.gms.auth.account.data.service.START"),
- CONSTELLATION(155, "com.google.android.gms.constellation.service.START"),
- AUDIT(154, "com.google.android.gms.audit.service.START"),
- SYSTEM_UPDATE(157, "com.google.android.gms.update.START_API_SERVICE"),
- MOBSTORE(160, "com.google.android.mobstore.service.START"),
- USER_LOCATION(163, "com.google.android.gms.userlocation.service.START"),
- AD_HTTP(166, "com.google.android.gms.ads.service.HTTP"),
- LANGUAGE_PROFILE(167, "com.google.android.gms.languageprofile.service.START"),
- MDNS(168, "com.google.android.gms.mdns.service.START"),
- FIDO2_ZEROPARTY(180, "com.google.android.gms.fido.fido2.zeroparty.START"),
- G1_RESTORE(181, "com.google.android.gms.backup.G1_RESTORE"),
- G1_BACKUP(182, "com.google.android.gms.backup.G1_BACKUP"),
- OSS_LICENSES(185, "com.google.android.gms.oss.licenses.service.START"),
- PAYSE(188, "com.google.android.gms.payse.service.BIND"),
- RCS(189, "com.google.android.gms.rcs.START"),
- CARRIER_AUTH(191, "com.google.android.gms.carrierauth.service.START"),
- SYSTEM_UPDATE_SINGLE_UESR(192, "com.google.android.gms.update.START_SINGLE_USER_API_SERVICE"),
- APP_USAGE(193, "com.google.android.gms.appusage.service.START"),
- NEARBY_SHARING_2(194, "com.google.android.gms.nearby.sharing.START_SERVICE"),
- AD_CONSENT_LOOKUP(195, "com.google.android.gms.ads.service.CONSENT_LOOKUP"),
- CREDENTIAL_MANAGER(196, "com.google.android.gms.credential.manager.service.firstparty.START"),
- PHONE_INTERNAL(197, "com.google.android.gms.auth.api.phone.service.InternalService.START"),
- PAY(198, "com.google.android.gms.pay.service.BIND"),
- ASTERISM(199, "com.google.android.gms.asterism.service.START"),
- MODULE_RESTORE(201, "com.google.android.gms.backup.GMS_MODULE_RESTORE"),
- FACS_CACHE(202, "com.google.android.gms.facs.cache.service.START"),
- RECAPTCHA(205, "com.google.android.gms.recaptcha.service.START"),
- CONTACT_SYNC(208, "com.google.android.gms.people.contactssync.service.START"),
IDENTITY_SIGN_IN(212, "com.google.android.gms.auth.api.identity.service.signin.START"),
- CREDENTIAL_STORE(214, "com.google.android.gms.fido.credentialstore.internal_service.START"),
- MDI_SYNC(215, "com.google.android.gms.mdisync.service.START"),
- EVENT_ATTESTATION(216, "com.google.android.gms.ads.identifier.service.EVENT_ATTESTATION"),
- SCHEDULER(218, "com.google.android.gms.scheduler.ACTION_PROXY_SCHEDULE"),
- AUTHORIZATION(219, "com.google.android.gms.auth.api.identity.service.authorization.START"),
- FACS_SYNC(220, "com.google.android.gms.facs.internal.service.START"),
- AUTH_CONFIG_SYNC(221, "com.google.android.gms.auth.config.service.START"),
- CREDENTIAL_SAVING(223, "com.google.android.gms.auth.api.identity.service.credentialsaving.START"),
- GOOGLE_AUTH(224, "com.google.android.gms.auth.account.authapi.START"),
- ENTERPRISE_LOADER(225, "com.google.android.gms.enterprise.loader.service.START"),
- THUNDERBIRD(226, "com.google.android.gms.thunderbird.service.START"),
- NEARBY_EXPOSURE(236, "com.google.android.gms.nearby.exposurenotification.START"),
- GMS_COMPLIANCE(257, "com.google.android.gms.gmscompliance.service.START"),
- FIDO_SOURCE_DEVICE(262, "com.google.android.gms.fido.sourcedevice.service.START"),
- FAST_PAIR(265, "com.google.android.gms.nearby.fastpair.START"),
- MATCHSTICK_LIGHTER(268, "com.google.android.gms.matchstick.lighter.service.START"),
- FIDO_TARGET_DEVICE_INTERNAL(269, "com.google.android.gms.fido.targetdevice.internal_service.START"),
- TELEMETRY(270, "com.google.android.gms.common.telemetry.service.START"),
- SECOND_DEVICE_AUTH(275, "com.google.android.gms.setup.auth.SecondDeviceAuth.START"),
- LOCATION_SHARING_REPORTER(277, "com.google.android.gms.locationsharingreporter.service.START"),
- OCR(279, "com.google.android.gms.ocr.service.START"),
- POTOKENS(285, "com.google.android.gms.potokens.service.START"),
- OCR_INTERNAL(281, "com.google.android.gms.ocr.service.internal.START"),
- IN_APP_REACH(315, "com.google.android.gms.inappreach.service.START"),
- APP_ERRORS(334, "com.google.android.gms.apperrors.service.START_APP_ERROR"),
;
public int SERVICE_ID;
@@ -210,4 +69,4 @@ public enum GmsService {
if (this != UNKNOWN) return toString();
return "UNKNOWN(" + serviceId + ")";
}
-}
+}
\ No newline at end of file
diff --git a/play-services-basement/src/main/java/org/microg/gms/common/Hide.java b/play-services-basement/src/main/java/org/microg/gms/common/Hide.java
deleted file mode 100644
index e15414b5..00000000
--- a/play-services-basement/src/main/java/org/microg/gms/common/Hide.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package org.microg.gms.common;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Hide the class, method or field from the public API.
- */
-@Retention(RetentionPolicy.SOURCE)
-@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
-public @interface Hide {
-}
diff --git a/play-services-basement/src/main/java/org/microg/gms/common/PublicApi.java b/play-services-basement/src/main/java/org/microg/gms/common/PublicApi.java
index a7fb9b44..92663979 100644
--- a/play-services-basement/src/main/java/org/microg/gms/common/PublicApi.java
+++ b/play-services-basement/src/main/java/org/microg/gms/common/PublicApi.java
@@ -43,8 +43,6 @@ public @interface PublicApi {
* marked as public api.
*
* @return true if the method or field is not part of the public api
- * @deprecated use {@link Hide} instead
*/
- @Deprecated
boolean exclude() default false;
}
diff --git a/play-services-basement/src/main/java/org/microg/gms/gcm/GcmConstants.java b/play-services-basement/src/main/java/org/microg/gms/gcm/GcmConstants.java
index 00117d4e..d96fe90a 100644
--- a/play-services-basement/src/main/java/org/microg/gms/gcm/GcmConstants.java
+++ b/play-services-basement/src/main/java/org/microg/gms/gcm/GcmConstants.java
@@ -16,80 +16,29 @@
package org.microg.gms.gcm;
-import org.microg.gms.basement.BuildConfig;
-
public final class GcmConstants {
- public static final String ACTION_C2DM_RECEIVE = BuildConfig.BASE_PACKAGE_NAME + ".android.c2dm.intent.RECEIVE";
- public static final String ACTION_C2DM_REGISTER = BuildConfig.BASE_PACKAGE_NAME + ".android.c2dm.intent.REGISTER";
- public static final String ACTION_C2DM_REGISTRATION = BuildConfig.BASE_PACKAGE_NAME + ".android.c2dm.intent.REGISTRATION";
- public static final String ACTION_C2DM_UNREGISTER = BuildConfig.BASE_PACKAGE_NAME + ".android.c2dm.intent.UNREGISTER";
- public static final String ACTION_GCM_SEND = BuildConfig.BASE_PACKAGE_NAME + ".android.gcm.intent.SEND";
- public static final String ACTION_NOTIFICATION_OPEN = BuildConfig.BASE_PACKAGE_NAME + ".android.gms.gcm.NOTIFICATION_OPEN";
- public static final String ACTION_NOTIFICATION_DISMISS = BuildConfig.BASE_PACKAGE_NAME + ".android.gms.gcm.NOTIFICATION_DISMISS";
- public static final String ACTION_SCHEDULE = BuildConfig.BASE_PACKAGE_NAME + ".android.gms.gcm.ACTION_SCHEDULE";
- public static final String ACTION_TASK_READY = BuildConfig.BASE_PACKAGE_NAME + ".android.gms.gcm.ACTION_TASK_READY";
- public static final String ACTION_TASK_INITIALZE = BuildConfig.BASE_PACKAGE_NAME + ".android.gms.gcm.SERVICE_ACTION_INITIALIZE";
- public static final String ACTION_INSTANCE_ID = BuildConfig.BASE_PACKAGE_NAME + ".android.gms.iid.InstanceID";
+ public static final String ACTION_C2DM_RECEIVE = "com.mgoogle.android.c2dm.intent.RECEIVE";
+ public static final String ACTION_C2DM_REGISTER = "com.mgoogle.android.c2dm.intent.REGISTER";
+ public static final String ACTION_C2DM_REGISTRATION = "com.mgoogle.android.c2dm.intent.REGISTRATION";
+ public static final String ACTION_C2DM_UNREGISTER = "com.mgoogle.android.c2dm.intent.UNREGISTER";
public static final String EXTRA_APP = "app";
public static final String EXTRA_APP_OVERRIDE = "org.microg.gms.gcm.APP_OVERRIDE";
- public static final String EXTRA_APP_ID = "appid";
- public static final String EXTRA_APP_VERSION_CODE = "app_ver";
public static final String EXTRA_APP_VERSION_NAME = "app_ver_name";
- public static final String EXTRA_CLIENT_VERSION = "cliv";
- public static final String EXTRA_COMPONENT = "component";
public static final String EXTRA_COLLAPSE_KEY = "collapse_key";
- public static final String EXTRA_DELAY = "google.delay";
public static final String EXTRA_DELETE = "delete";
public static final String EXTRA_ERROR = "error";
public static final String EXTRA_FROM = "from";
- public static final String EXTRA_GSF_INTENT = "GSF";
- public static final String EXTRA_GMS_VERSION = "gmsv";
- public static final String EXTRA_IS_MESSENGER2 = "messenger2";
public static final String EXTRA_KID = "kid";
public static final String EXTRA_MESSENGER = "google.messenger";
- public static final String EXTRA_MESSAGE_TYPE = "message_type";
public static final String EXTRA_MESSAGE_ID = "google.message_id";
- public static final String EXTRA_OS_VERSION = "osv";
- public static final String EXTRA_PENDING_INTENT = BuildConfig.BASE_PACKAGE_NAME + ".android.gms.gcm.PENDING_INTENT";
- public static final String EXTRA_PUBLIC_KEY = "pub2";
- public static final String EXTRA_RAWDATA = "rawData";
- public static final String EXTRA_RAWDATA_BASE64 = "gcm.rawData64";
public static final String EXTRA_REGISTRATION_ID = "registration_id";
public static final String EXTRA_RETRY_AFTER = "Retry-After";
- public static final String EXTRA_SCHEDULER_ACTION = "scheduler_action";
- public static final String EXTRA_SCOPE = "scope";
public static final String EXTRA_SENDER = "sender";
- public static final String EXTRA_SENDER_LEGACY = "legacy.sender";
public static final String EXTRA_SEND_TO = "google.to";
public static final String EXTRA_SEND_FROM = "google.from";
- public static final String EXTRA_SIGNATURE = "sig";
- public static final String EXTRA_SUBSCIPTION = "subscription";
- public static final String EXTRA_SUBTYPE = "subtype";
- public static final String EXTRA_USE_GSF = "useGsf";
- public static final String EXTRA_TAG = "tag";
- public static final String EXTRA_TOPIC = "gcm.topic";
public static final String EXTRA_TTL = "google.ttl";
public static final String EXTRA_UNREGISTERED = "unregistered";
- public static final String MESSAGE_TYPE_GCM = "gcm";
- public static final String MESSAGE_TYPE_DELETED_MESSAGE = "deleted_message";
- public static final String MESSAGE_TYPE_SEND_ERROR = "send_error";
- public static final String MESSAGE_TYPE_SEND_EVENT = "send_event";
-
- public static final String SCHEDULER_ACTION_CANCEL = "CANCEL_TASK";
- public static final String SCHEDULER_ACTION_CANCEL_ALL = "CANCEL_ALL";
- public static final String SCHEDULER_ACTION_SCHEDULE = "SCHEDULE_TASK";
-
- public static final String PERMISSION_GTALK = BuildConfig.BASE_PACKAGE_NAME + ".android.gtalkservice.permission.GTALK_SERVICE";
- public static final String PERMISSION_NETWORK_TASK = BuildConfig.BASE_PACKAGE_NAME + ".android.gms.permission.BIND_NETWORK_TASK_SERVICE";
- public static final String PERMISSION_RECEIVE = BuildConfig.BASE_PACKAGE_NAME + ".android.c2dm.permission.RECEIVE";
- public static final String PERMISSION_SEND = BuildConfig.BASE_PACKAGE_NAME + ".android.c2dm.permission.SEND";
-
public static final String ERROR_SERVICE_NOT_AVAILABLE = "SERVICE_NOT_AVAILABLE";
-
- public static final String INSTANCE_ID_SCOPE_GCM = "GCM";
-
- public static final String GCMID_INSTANCE_ID = "google.com/iid";
- public static final String GCMID_REFRESH = "gcm.googleapis.com/refresh";
}
diff --git a/play-services-core-proto/build.gradle b/play-services-core-proto/build.gradle
index 6edfcb4b..2cfb351e 100644
--- a/play-services-core-proto/build.gradle
+++ b/play-services-core-proto/build.gradle
@@ -21,9 +21,9 @@ sourceSets {
}
compileKotlin {
- kotlinOptions.jvmTarget = 17
+ kotlinOptions.jvmTarget = 1.8
}
compileTestKotlin {
- kotlinOptions.jvmTarget = 17
+ kotlinOptions.jvmTarget = 1.8
}
\ No newline at end of file
diff --git a/play-services-core/build.gradle b/play-services-core/build.gradle
index 22e0b42c..a1232546 100644
--- a/play-services-core/build.gradle
+++ b/play-services-core/build.gradle
@@ -23,8 +23,6 @@ dependencies {
implementation "de.hdodenhof:circleimageview:$circleimageviewVersion"
implementation "androidx.webkit:webkit:$webkitVersion"
- implementation project(':fake-signature')
-
implementation project(':play-services-base-core')
implementation project(':play-services-core-proto')
implementation project(':play-services-core:microg-ui-tools') // deprecated
@@ -49,41 +47,21 @@ dependencies {
}
android {
- namespace "${basePackageName}.android.gms"
-
compileSdkVersion androidCompileSdk
buildToolsVersion androidBuildVersionTools
defaultConfig {
versionName version
versionCode appVersionCode
- resourceConfigurations += ['xxhdpi']
+ resConfigs 'xxhdpi'
minSdkVersion androidMinSdk
targetSdkVersion androidTargetSdk
- buildConfigField "String", "BASE_PACKAGE_NAME", "\"$basePackageName\""
-
- multiDexEnabled true
- multiDexKeepProguard file('multidex-keep.pro')
-
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
- buildConfigField "String", "APPLICATION_NAMESPACE", "\"${android.namespace}\""
- buildConfigField "String", "BASE_PACKAGE_NAME", "\"$basePackageName\""
- manifestPlaceholders = [
- basePackageName: "$basePackageName"
- ]
-
- // provide package name to xml resources
- resValue "string", "var_authenticator_account_type", "$basePackageName"
- resValue "string", "var_contact_syncadapter_account_type", "$basePackageName"
- resValue "string", "var_pref_auth_action_security_settings", "${basePackageName}.android.gms.accountsettings.SECURITY_SETTINGS"
- resValue "string", "var_pref_auth_action_privacy_settings", "${basePackageName}.android.gms.accountsettings.PRIVACY_SETTINGS"
- resValue "string", "var_pref_auth_action_preferences_settings", "${basePackageName}.android.gms.accountsettings.ACCOUNT_PREFERENCES_SETTINGS"
- resValue "string", "var_pref_start_gms_package", "${basePackageName}.android.gms"
}
buildFeatures {
@@ -98,7 +76,7 @@ android {
}
lintOptions {
- disable 'MissingTranslation', 'GetLocales', 'BatteryLife', 'ImpliedQuantity', 'MissingQuantity', 'InvalidWakeLockTag', 'Range'
+ disable 'MissingTranslation', 'BatteryLife', 'ImpliedQuantity', 'MissingQuantity', 'InvalidWakeLockTag', 'Range'
}
buildTypes {
@@ -109,14 +87,14 @@ android {
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_17
- targetCompatibility JavaVersion.VERSION_17
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/ASL2.0'
jniLibs {
- useLegacyPackaging true
+ useLegacyPackaging false
}
}
}
diff --git a/play-services-core/microg-ui-tools/build.gradle b/play-services-core/microg-ui-tools/build.gradle
index 260aa6a5..d0dbd48f 100644
--- a/play-services-core/microg-ui-tools/build.gradle
+++ b/play-services-core/microg-ui-tools/build.gradle
@@ -23,20 +23,17 @@ android {
defaultConfig {
minSdkVersion androidMinSdk
targetSdkVersion androidTargetSdk
-
- buildConfigField "String", "GMS_APPLICATION_NAMESPACE", "\"$applicationNamespace\""
}
compileOptions {
- sourceCompatibility = 17
- targetCompatibility = 17
+ sourceCompatibility = 1.8
+ targetCompatibility = 1.8
}
lintOptions {
// TODO: Remove MissingTranslation once we have stable strings and proper translations.
- disable 'MissingTranslation', 'GetLocales'
+ disable 'MissingTranslation'
}
- namespace 'org.microg.tools.ui'
}
dependencies {
diff --git a/play-services-core/microg-ui-tools/src/main/AndroidManifest.xml b/play-services-core/microg-ui-tools/src/main/AndroidManifest.xml
index 359a9b71..004f299c 100644
--- a/play-services-core/microg-ui-tools/src/main/AndroidManifest.xml
+++ b/play-services-core/microg-ui-tools/src/main/AndroidManifest.xml
@@ -15,4 +15,4 @@
~ limitations under the License.
-->
-
+
diff --git a/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/AbstractSettingsActivity.java b/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/AbstractSettingsActivity.java
index 2b0542a5..a771a9ea 100644
--- a/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/AbstractSettingsActivity.java
+++ b/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/AbstractSettingsActivity.java
@@ -3,7 +3,7 @@ package org.microg.tools.ui;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.ViewGroup;
-import androidx.appcompat.widget.Toolbar;
+
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
@@ -19,7 +19,6 @@ public abstract class AbstractSettingsActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
- setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
if (showHomeAsUp) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
diff --git a/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/SwitchBar.java b/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/SwitchBar.java
index b9144222..0a30f683 100644
--- a/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/SwitchBar.java
+++ b/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/SwitchBar.java
@@ -116,39 +116,12 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
mSwitch.setChecked(checked);
}
- public void setCheckedInternal(boolean checked) {
- setTextViewLabel(checked);
- mSwitch.setCheckedInternal(checked);
- }
-
- public boolean isChecked() {
- return mSwitch.isChecked();
- }
-
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
mTextView.setEnabled(enabled);
mSwitch.setEnabled(enabled);
}
- public final ToggleSwitch getSwitch() {
- return mSwitch;
- }
-
- public void show() {
- if (!isShowing()) {
- setVisibility(View.VISIBLE);
- mSwitch.setOnCheckedChangeListener(this);
- }
- }
-
- public void hide() {
- if (isShowing()) {
- setVisibility(View.GONE);
- mSwitch.setOnCheckedChangeListener(null);
- }
- }
-
public boolean isShowing() {
return (getVisibility() == View.VISIBLE);
}
@@ -178,13 +151,6 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
mSwitchChangeListeners.add(listener);
}
- public void removeOnSwitchChangeListener(OnSwitchChangeListener listener) {
- if (!mSwitchChangeListeners.contains(listener)) {
- throw new IllegalStateException("Cannot remove OnSwitchChangeListener");
- }
- mSwitchChangeListeners.remove(listener);
- }
-
static class SavedState extends BaseSavedState {
boolean checked;
boolean visible;
diff --git a/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/SwitchBarResourceSettingsFragment.java b/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/SwitchBarResourceSettingsFragment.java
index f590aa25..c6cadb2f 100644
--- a/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/SwitchBarResourceSettingsFragment.java
+++ b/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/SwitchBarResourceSettingsFragment.java
@@ -21,27 +21,30 @@ import android.os.Bundle;
import com.google.android.material.switchmaterial.SwitchMaterial;
public abstract class SwitchBarResourceSettingsFragment extends ResourceSettingsFragment implements SwitchBar.OnSwitchChangeListener {
- private final SwitchMaterial switchMaterial;
+ protected SwitchBar switchBar;
+ private SwitchMaterial switchMaterial;
private boolean listenerSetup = false;
- protected SwitchBarResourceSettingsFragment(SwitchMaterial switchMaterial) {
- this.switchMaterial = switchMaterial;
- }
-
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
+
+// switchBar = activity.getSwitchBar();
+// switchBar.show();
+// switchMaterial = switchBar.getSwitch();
}
@Override
public void onDestroyView() {
super.onDestroyView();
+// switchBar.hide();
}
@Override
public void onResume() {
super.onResume();
if (!listenerSetup) {
+// switchBar.addOnSwitchChangeListener(this);
listenerSetup = true;
}
}
@@ -49,6 +52,7 @@ public abstract class SwitchBarResourceSettingsFragment extends ResourceSettings
@Override
public void onPause() {
if (listenerSetup) {
+// switchBar.removeOnSwitchChangeListener(this);
listenerSetup = false;
}
super.onPause();
diff --git a/play-services-core/microg-ui-tools/src/main/res/layout/settings_activity.xml b/play-services-core/microg-ui-tools/src/main/res/layout/settings_activity.xml
index e5f71828..a664de26 100644
--- a/play-services-core/microg-ui-tools/src/main/res/layout/settings_activity.xml
+++ b/play-services-core/microg-ui-tools/src/main/res/layout/settings_activity.xml
@@ -19,14 +19,6 @@
android:layout_height="match_parent"
android:orientation="vertical">
-
-
-
diff --git a/play-services-core/multidex-keep.pro b/play-services-core/multidex-keep.pro
deleted file mode 100644
index 0cd8699e..00000000
--- a/play-services-core/multidex-keep.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-# Make sure maps is in the primary dex file
--keep class com.google.android.gms.maps.** { *; }
--keep class org.microg.gms.maps.** { *; }
--keep class com.mapbox.** { *; }
--keep class org.oscim.** { *; }
-
-# Keep Conscrypt in the primary dex file otherwise it will error out on legacy Android versions
--keep class com.google.android.gms.common.security.ProviderInstallerImpl { *; }
--keep class com.google.android.gms.org.conscrypt.** { *; }
diff --git a/play-services-core/proguard-rules.pro b/play-services-core/proguard-rules.pro
index 923a7661..9b421ddd 100644
--- a/play-services-core/proguard-rules.pro
+++ b/play-services-core/proguard-rules.pro
@@ -21,13 +21,10 @@
# Keep dynamically loaded GMS classes
-keep public class com.google.android.gms.common.security.ProviderInstallerImpl { public *; }
--keep public class com.google.android.gms.dynamic.IObjectWrapper { public *; }
--keep public class com.google.android.gms.dynamite.descriptors.** { public *; }
# Keep AutoSafeParcelables
-keep public class * extends org.microg.safeparcel.AutoSafeParcelable {
@org.microg.safeparcel.SafeParceled *;
- (...);
}
# Keep form data
diff --git a/play-services-core/src/main/AndroidManifest.xml b/play-services-core/src/main/AndroidManifest.xml
index 5a42409c..0cbed7c6 100644
--- a/play-services-core/src/main/AndroidManifest.xml
+++ b/play-services-core/src/main/AndroidManifest.xml
@@ -15,48 +15,42 @@
~ limitations under the License.
-->
+ xmlns:tools="http://schemas.android.com/tools"
+ package="com.mgoogle.android.gms">
-
-
+
@@ -65,17 +59,15 @@
-
-
-
-
+
+
+
-
+
@@ -94,41 +86,42 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:multiArch="true"
- android:theme="@style/Theme.App"
- android:networkSecurityConfig="@xml/network_security_config"
- tools:targetApi="r">
+ android:theme="@style/AppTheme"
+ android:networkSecurityConfig="@xml/network_security_config">
-
+
+
+
+ android:exported="false" />
-
+
-
+
@@ -139,16 +132,15 @@
-
+
-
@@ -156,11 +148,10 @@
-
-
+
+
@@ -168,10 +159,9 @@
-
+
@@ -181,7 +171,6 @@
@@ -194,7 +183,6 @@
@@ -218,7 +206,6 @@
@@ -231,13 +218,12 @@
-
+
-
+
+ android:process=":ui">
@@ -263,7 +248,7 @@
@@ -285,12 +270,11 @@
@@ -298,22 +282,19 @@
-
+
-
+
-
+
@@ -321,8 +302,7 @@
@@ -353,11 +333,10 @@
@@ -375,15 +354,6 @@
android:resource="@string/gms_settings_summary" />
-
-
-
-
-
-
+ android:taskAffinity="org.microg.gms.settings">
-
+
-
-
-
-
-
-
-
-
-
-
+
-
+
diff --git a/play-services-core/src/main/java/com/google/android/gms/chimera/DynamiteModuleInitializer.java b/play-services-core/src/main/java/com/google/android/gms/chimera/DynamiteModuleInitializer.java
deleted file mode 100644
index 3605e8ac..00000000
--- a/play-services-core/src/main/java/com/google/android/gms/chimera/DynamiteModuleInitializer.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.google.android.gms.chimera;
-
-import android.annotation.SuppressLint;
-import android.util.Log;
-import androidx.annotation.Keep;
-
-import android.content.Context;
-
-@Keep
-public class DynamiteModuleInitializer {
- private static final String TAG = "DynamiteModule";
-
- public static void initializeModuleV1(Context context) {
- initializeModuleV2(context, "com.google.android.gms".equals(context.getPackageName()));
- }
-
- public static void initializeModuleV2(Context context, boolean withGmsPackage) {
- Log.d(TAG, "initializeModuleV2 context: " + context + ", withGmsPackage: " + withGmsPackage);
- }
-}
diff --git a/play-services-core/src/main/java/com/google/android/gms/common/GoogleCertificatesImpl.java b/play-services-core/src/main/java/com/google/android/gms/common/GoogleCertificatesImpl.java
new file mode 100644
index 00000000..7ab30bc3
--- /dev/null
+++ b/play-services-core/src/main/java/com/google/android/gms/common/GoogleCertificatesImpl.java
@@ -0,0 +1,70 @@
+/*
+ * 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 com.google.android.gms.common;
+
+import android.content.pm.PackageManager;
+import android.os.RemoteException;
+import android.util.Log;
+
+import androidx.annotation.Keep;
+
+import com.google.android.gms.common.internal.GoogleCertificatesQuery;
+import com.google.android.gms.common.internal.IGoogleCertificatesApi;
+import com.google.android.gms.dynamic.IObjectWrapper;
+import com.google.android.gms.dynamic.ObjectWrapper;
+
+import org.microg.gms.common.PackageUtils;
+
+@Keep
+public class GoogleCertificatesImpl extends IGoogleCertificatesApi.Stub {
+ private static final String TAG = "GmsCertImpl";
+
+ @Override
+ public IObjectWrapper getGoogleCertficates() throws RemoteException {
+ Log.d(TAG, "unimplemented Method: getGoogleCertficates");
+ return null;
+ }
+
+ @Override
+ public IObjectWrapper getGoogleReleaseCertificates() throws RemoteException {
+ Log.d(TAG, "unimplemented Method: getGoogleReleaseCertificates");
+ return null;
+ }
+
+ @Override
+ public boolean isGoogleReleaseSigned(String packageName, IObjectWrapper certData) throws RemoteException {
+ return PackageUtils.isGooglePackage(packageName, ObjectWrapper.unwrapTyped(certData, byte[].class));
+ }
+
+ @Override
+ public boolean isGoogleSigned(String packageName, IObjectWrapper certData) throws RemoteException {
+ return PackageUtils.isGooglePackage(packageName, ObjectWrapper.unwrapTyped(certData, byte[].class));
+ }
+
+ @Override
+ public boolean isGoogleOrPlatformSigned(GoogleCertificatesQuery query, IObjectWrapper packageManager) throws RemoteException {
+ PackageManager pm = ObjectWrapper.unwrapTyped(packageManager, PackageManager.class);
+ if (query == null || query.getPackageName() == null) {
+ return false;
+ } else if (query.getCertData() == null) {
+ if (pm == null) return false;
+ return PackageUtils.isGooglePackage(pm, query.getPackageName());
+ } else {
+ return PackageUtils.isGooglePackage(query.getPackageName(), query.getCertData().getBytes());
+ }
+ }
+}
diff --git a/play-services-core/src/main/java/com/google/android/gms/common/security/ProviderInstallerImpl.java b/play-services-core/src/main/java/com/google/android/gms/common/security/ProviderInstallerImpl.java
index 0270e626..e25391e5 100644
--- a/play-services-core/src/main/java/com/google/android/gms/common/security/ProviderInstallerImpl.java
+++ b/play-services-core/src/main/java/com/google/android/gms/common/security/ProviderInstallerImpl.java
@@ -5,12 +5,11 @@
package com.google.android.gms.common.security;
-import static android.os.Build.VERSION.SDK_INT;
import static com.google.android.gms.security.ProviderInstaller.PROVIDER_NAME;
-import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.ApplicationInfo;
+import android.os.Build;
import android.os.Process;
import android.util.Log;
@@ -54,14 +53,13 @@ public class ProviderInstallerImpl {
String packageName = PackageUtils.packageFromProcessId(context, Process.myPid());
if (packageName != null && packageName.contains(".")) return packageName;
try {
- @SuppressLint("DiscouragedPrivateApi")
Method getBasePackageName = Context.class.getDeclaredMethod("getBasePackageName");
packageName = (String) getBasePackageName.invoke(context);
if (packageName != null) return packageName;
- } catch (Exception ignored) {
+ } catch (Exception e) {
}
- if (SDK_INT >= 29) {
+ if (Build.VERSION.SDK_INT >= 29) {
return context.getOpPackageName();
}
Context applicationContext = context.getApplicationContext();
diff --git a/play-services-core/src/main/java/org/microg/gms/auth/AccountContentProvider.java b/play-services-core/src/main/java/org/microg/gms/auth/AccountContentProvider.java
index 9274f439..9c96646b 100644
--- a/play-services-core/src/main/java/org/microg/gms/auth/AccountContentProvider.java
+++ b/play-services-core/src/main/java/org/microg/gms/auth/AccountContentProvider.java
@@ -17,7 +17,6 @@
package org.microg.gms.auth;
import static android.accounts.AccountManager.VISIBILITY_VISIBLE;
-import static android.os.Build.VERSION.SDK_INT;
import android.Manifest;
import android.accounts.Account;
@@ -28,6 +27,7 @@ import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Binder;
+import android.os.Build;
import android.os.Bundle;
import android.util.Log;
@@ -36,7 +36,6 @@ import androidx.annotation.Nullable;
import org.microg.gms.common.PackageUtils;
import java.util.Arrays;
-import java.util.Objects;
import static org.microg.gms.auth.AuthConstants.DEFAULT_ACCOUNT_TYPE;
import static org.microg.gms.auth.AuthConstants.PROVIDER_EXTRA_ACCOUNTS;
@@ -55,10 +54,11 @@ public class AccountContentProvider extends ContentProvider {
@Nullable
@Override
public Bundle call(String method, String arg, Bundle extras) {
- String suggestedPackageName = getCallingPackage();
+ String suggestedPackageName;
+ suggestedPackageName = getCallingPackage();
String packageName = PackageUtils.getAndCheckCallingPackage(getContext(), suggestedPackageName);
Log.d(TAG, "Call " + method + " from " + packageName + " with arg " + arg);
- if (!PackageUtils.callerHasExtendedAccess(Objects.requireNonNull(getContext()))) {
+ if (!PackageUtils.callerHasExtendedAccess(getContext())) {
String[] packagesForUid = getContext().getPackageManager().getPackagesForUid(Binder.getCallingUid());
if (packagesForUid != null && packagesForUid.length != 0)
Log.w(TAG, "Not granting extended access to " + Arrays.toString(packagesForUid)
@@ -72,10 +72,10 @@ public class AccountContentProvider extends ContentProvider {
if (arg != null && (arg.equals(DEFAULT_ACCOUNT_TYPE) || arg.startsWith(DEFAULT_ACCOUNT_TYPE + "."))) {
AccountManager am = AccountManager.get(getContext());
accounts = am.getAccountsByTypeForPackage(arg, packageName);
- if (accounts.length == 0) {
+ if (accounts == null || accounts.length == 0) {
accounts = am.getAccountsByType(arg);
}
- if (SDK_INT >= 26 && arg.equals(DEFAULT_ACCOUNT_TYPE)) {
+ if (Build.VERSION.SDK_INT >= 26 && accounts != null && arg.equals(DEFAULT_ACCOUNT_TYPE)) {
for (Account account : accounts) {
if (am.getAccountVisibility(account, packageName) == AccountManager.VISIBILITY_UNDEFINED) {
Log.d(TAG, "Make account " + account + " visible to " + packageName);
diff --git a/play-services-core/src/main/java/org/microg/gms/auth/AuthManager.java b/play-services-core/src/main/java/org/microg/gms/auth/AuthManager.java
index 57b6a516..73adeabf 100644
--- a/play-services-core/src/main/java/org/microg/gms/auth/AuthManager.java
+++ b/play-services-core/src/main/java/org/microg/gms/auth/AuthManager.java
@@ -18,25 +18,24 @@ package org.microg.gms.auth;
import static android.content.pm.ApplicationInfo.FLAG_SYSTEM;
import static android.content.pm.ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
-import static android.os.Build.VERSION.SDK_INT;
import static org.microg.gms.auth.AuthPrefs.isTrustGooglePermitted;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.os.Build;
import android.util.Log;
-import org.microg.gms.base.core.BuildConfig;
import org.microg.gms.common.PackageUtils;
-import org.microg.gms.settings.SettingsContract;
+import org.microg.mgms.settings.SettingsContract;
import java.io.IOException;
public class AuthManager {
private static final String TAG = "GmsAuthManager";
- public static final String PERMISSION_TREE_BASE = BuildConfig.BASE_PACKAGE_NAME + ".android.googleapps.permission.GOOGLE_AUTH.";
+ public static final String PERMISSION_TREE_BASE = "com.mgoogle.android.googleapps.permission.GOOGLE_AUTH.";
public static final String PREF_AUTH_VISIBLE = SettingsContract.Auth.VISIBLE;
public static final int ONE_HOUR_IN_SECONDS = 60 * 60;
@@ -105,7 +104,7 @@ public class AuthManager {
public void setPermitted(boolean value) {
setUserData(buildPermKey(), value ? "1" : "0");
- if (SDK_INT >= 26 && value && packageName != null) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && value && packageName != null) {
// Make account persistently visible as we already granted access
accountManager.setAccountVisibility(getAccount(), packageName, AccountManager.VISIBILITY_VISIBLE);
}
@@ -170,7 +169,7 @@ public class AuthManager {
public void setAuthToken(String service, String auth) {
getAccountManager().setAuthToken(getAccount(), buildTokenKey(service), auth);
- if (SDK_INT >= 26 && packageName != null && auth != null) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && packageName != null && auth != null) {
// Make account persistently visible as we already granted access
accountManager.setAccountVisibility(getAccount(), packageName, AccountManager.VISIBILITY_VISIBLE);
}
diff --git a/play-services-core/src/main/java/org/microg/gms/auth/AuthManagerServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/auth/AuthManagerServiceImpl.java
index 7f57a370..622ff4a0 100644
--- a/play-services-core/src/main/java/org/microg/gms/auth/AuthManagerServiceImpl.java
+++ b/play-services-core/src/main/java/org/microg/gms/auth/AuthManagerServiceImpl.java
@@ -18,6 +18,8 @@ package org.microg.gms.auth;
import android.accounts.Account;
import android.accounts.AccountManager;
+import android.accounts.AuthenticatorException;
+import android.accounts.OperationCanceledException;
import android.annotation.SuppressLint;
import android.app.NotificationManager;
import android.app.PendingIntent;
@@ -38,7 +40,7 @@ import com.google.android.gms.auth.AccountChangeEventsRequest;
import com.google.android.gms.auth.AccountChangeEventsResponse;
import com.google.android.gms.auth.GetHubTokenInternalResponse;
import com.google.android.gms.auth.GetHubTokenRequest;
-import com.google.android.gms.auth.HasCapabilitiesRequest;
+import com.google.android.gms.auth.HasCababilitiesRequest;
import com.google.android.gms.auth.TokenData;
import com.google.android.gms.common.api.Scope;
@@ -50,8 +52,11 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import static android.accounts.AccountManager.*;
-import static android.os.Build.VERSION.SDK_INT;
+import static android.accounts.AccountManager.KEY_ACCOUNTS;
+import static android.accounts.AccountManager.KEY_ACCOUNT_NAME;
+import static android.accounts.AccountManager.KEY_ACCOUNT_TYPE;
+import static android.accounts.AccountManager.KEY_AUTHTOKEN;
+import static android.accounts.AccountManager.KEY_CALLER_PID;
public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
private static final String TAG = "GmsAuthManagerSvc";
@@ -67,8 +72,6 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
public static final String KEY_REQUEST_VISIBLE_ACTIVITIES = "request_visible_actions";
public static final String KEY_SUPPRESS_PROGRESS_SCREEN = "suppressProgressScreen";
public static final String KEY_SYNC_EXTRAS = "sync_extras";
- public static final String KEY_DELEGATION_TYPE = "delegation_type";
- public static final String KEY_DELEGATEE_USER_ID = "delegatee_user_id";
public static final String KEY_ERROR = "Error";
public static final String KEY_USER_RECOVERY_INTENT = "userRecoveryIntent";
@@ -115,8 +118,7 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
packageName = PackageUtils.getAndCheckCallingPackage(context, packageName, extras.getInt(KEY_CALLER_UID, 0), extras.getInt(KEY_CALLER_PID, 0));
boolean notify = extras.getBoolean(KEY_HANDLE_NOTIFICATION, false);
- if (!AuthConstants.SCOPE_GET_ACCOUNT_ID.equals(scope))
- Log.d(TAG, "getToken: account:" + account.name + " scope:" + scope + " extras:" + extras + ", notify: " + notify);
+ Log.d(TAG, "getToken: account:" + account.name + " scope:" + scope + " extras:" + extras + ", notify: " + notify);
/*
* TODO: This scope seems to be invalid (according to https://developers.google.com/oauthplayground/),
@@ -124,7 +126,6 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
*/
scope = scope.replace("https://www.googleapis.com/auth/identity.plus.page.impersonation ", "");
- assert packageName != null;
AuthManager authManager = new AuthManager(context, account.name, packageName, scope);
Bundle result = new Bundle();
result.putString(KEY_ACCOUNT_NAME, account.name);
@@ -179,22 +180,12 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
@Override
public Bundle requestGoogleAccountsAccess(String packageName) throws RemoteException {
- PackageUtils.assertExtendedAccess(context);
- if (SDK_INT >= 26) {
- for (Account account : get(context).getAccountsByType(AuthConstants.DEFAULT_ACCOUNT_TYPE)) {
- AccountManager.get(context).setAccountVisibility(account, packageName, VISIBILITY_VISIBLE);
- }
- Bundle res = new Bundle();
- res.putString("Error", "Ok");
- return res;
- } else {
- Log.w(TAG, "Not implemented: requestGoogleAccountsAccess(" + packageName + ")");
- }
+ Log.w(TAG, "Not implemented: requestGoogleAccountsAccess(" + packageName + ")");
return null;
}
@Override
- public int hasCapabilities(HasCapabilitiesRequest request) throws RemoteException {
+ public int hasCapabilities(HasCababilitiesRequest request) throws RemoteException {
Log.w(TAG, "Not implemented: hasCapabilities(" + request.account + ", " + Arrays.toString(request.capabilities) + ")");
return 1;
}
@@ -214,11 +205,7 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
Log.d(TAG, "clearToken: token:" + token + " extras:" + extras);
AccountManager.get(context).invalidateAuthToken(AuthConstants.DEFAULT_ACCOUNT_TYPE, token);
-
- Bundle res = new Bundle();
- res.putString("Error", "Ok");
- res.putBoolean("booleanResult", true);
- return res;
+ return null;
}
@Override
diff --git a/play-services-core/src/main/java/org/microg/gms/auth/AuthRequest.java b/play-services-core/src/main/java/org/microg/gms/auth/AuthRequest.java
index e1b4749a..55ff536b 100644
--- a/play-services-core/src/main/java/org/microg/gms/auth/AuthRequest.java
+++ b/play-services-core/src/main/java/org/microg/gms/auth/AuthRequest.java
@@ -113,9 +113,7 @@ public class AuthRequest extends HttpFormClient.Request {
public AuthRequest fromContext(Context context) {
build(context);
locale(Utils.getLocale(context));
- if (AuthPrefs.shouldIncludeAndroidId(context)) {
- androidIdHex = Long.toHexString(LastCheckinInfo.read(context).getAndroidId());
- }
+ androidIdHex = Long.toHexString(LastCheckinInfo.read(context).getAndroidId());
return this;
}
diff --git a/play-services-core/src/main/java/org/microg/gms/auth/login/LoginActivity.java b/play-services-core/src/main/java/org/microg/gms/auth/login/LoginActivity.java
index f52b93c4..095496b0 100644
--- a/play-services-core/src/main/java/org/microg/gms/auth/login/LoginActivity.java
+++ b/play-services-core/src/main/java/org/microg/gms/auth/login/LoginActivity.java
@@ -25,9 +25,9 @@ import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT;
import static org.microg.gms.auth.AuthPrefs.isAuthVisible;
-import static org.microg.gms.checkin.CheckinPreferences.hideLauncherIcon;
-import static org.microg.gms.checkin.CheckinPreferences.isSpoofingEnabled;
-import static org.microg.gms.checkin.CheckinPreferences.setSpoofingEnabled;
+import static org.microg.gms.checkin.CheckinPrefs.hideLauncherIcon;
+import static org.microg.gms.checkin.CheckinPrefs.isSpoofingEnabled;
+import static org.microg.gms.checkin.CheckinPrefs.setSpoofingEnabled;
import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME;
import static org.microg.gms.common.Constants.GMS_VERSION_CODE;
@@ -283,10 +283,6 @@ public class LoginActivity extends AssistantActivity {
webView.loadUrl(buildUrl(tmpl, Utils.getLocale(this)));
}
- protected void runScript(String js) {
- runOnUiThread(() -> webView.loadUrl("javascript:" + js));
- }
-
private void closeWeb(boolean programmaticAuth) {
setMessage(R.string.auth_finalize);
runOnUiThread(() -> webView.setVisibility(INVISIBLE));
@@ -422,32 +418,12 @@ public class LoginActivity extends AssistantActivity {
Log.d(TAG, "JSBridge: addAccount");
}
- @JavascriptInterface
- public final void attemptLogin(String accountName, String password) {
- Log.d(TAG, "JSBridge: attemptLogin");
- }
-
- @JavascriptInterface
- public void backupSyncOptIn(String accountName) {
- Log.d(TAG, "JSBridge: backupSyncOptIn");
- }
-
- @JavascriptInterface
- public void clearOldLoginAttempts() {
- Log.d(TAG, "JSBridge: clearOldLoginAttempts");
- }
-
@JavascriptInterface
public final void closeView() {
Log.d(TAG, "JSBridge: closeView");
closeWeb(false);
}
- @JavascriptInterface
- public void fetchIIDToken(String entity) {
- Log.d(TAG, "JSBridge: fetchIIDToken");
- }
-
@JavascriptInterface
public final String fetchVerifiedPhoneNumber() {
Log.d(TAG, "JSBridge: fetchVerifiedPhoneNumber");
@@ -482,17 +458,12 @@ public class LoginActivity extends AssistantActivity {
@JavascriptInterface
public final int getAuthModuleVersionCode() {
- return GMS_VERSION_CODE;
+ return 1;
}
@JavascriptInterface
public final int getBuildVersionSdk() {
- return Build.VERSION.SDK_INT;
- }
-
- @JavascriptInterface
- public int getDeviceContactsCount() {
- return -1;
+ return SDK_INT;
}
@JavascriptInterface
@@ -566,40 +537,15 @@ public class LoginActivity extends AssistantActivity {
}
@JavascriptInterface
- public final void setAccountIdentifier(String accountName) {
+ public final void setAccountIdentifier(String accountIdentifier) {
Log.d(TAG, "JSBridge: setAccountIdentifier");
}
- @JavascriptInterface
- public void setAllActionsEnabled(boolean z) {
- Log.d(TAG, "JSBridge: setAllActionsEnabled");
- }
-
@JavascriptInterface
public final void setNewAccountCreated() {
Log.d(TAG, "JSBridge: setNewAccountCreated");
}
- @JavascriptInterface
- public void setPrimaryActionEnabled(boolean z) {
- Log.d(TAG, "JSBridge: setPrimaryActionEnabled");
- }
-
- @JavascriptInterface
- public void setPrimaryActionLabel(String str, int i) {
- Log.d(TAG, "JSBridge: setPrimaryActionLabel: " + str);
- }
-
- @JavascriptInterface
- public void setSecondaryActionEnabled(boolean z) {
- Log.d(TAG, "JSBridge: setSecondaryActionEnabled");
- }
-
- @JavascriptInterface
- public void setSecondaryActionLabel(String str, int i) {
- Log.d(TAG, "JSBridge: setSecondaryActionLabel: " + str);
- }
-
@JavascriptInterface
public final void showKeyboard() {
inputMethodManager.showSoftInput(webView, SHOW_IMPLICIT);
diff --git a/play-services-core/src/main/java/org/microg/gms/auth/loginservice/AccountAuthenticator.java b/play-services-core/src/main/java/org/microg/gms/auth/loginservice/AccountAuthenticator.java
index fa4eb2bc..89ee692f 100644
--- a/play-services-core/src/main/java/org/microg/gms/auth/loginservice/AccountAuthenticator.java
+++ b/play-services-core/src/main/java/org/microg/gms/auth/loginservice/AccountAuthenticator.java
@@ -104,7 +104,7 @@ class AccountAuthenticator extends AbstractAccountAuthenticator {
}
} catch (Exception e) {
Log.w(TAG, e);
- throw new NetworkErrorException(e);
+ return null;
}
return null;
}
diff --git a/play-services-core/src/main/java/org/microg/gms/checkin/CheckinClient.java b/play-services-core/src/main/java/org/microg/gms/checkin/CheckinClient.java
index df7c245b..98598a09 100755
--- a/play-services-core/src/main/java/org/microg/gms/checkin/CheckinClient.java
+++ b/play-services-core/src/main/java/org/microg/gms/checkin/CheckinClient.java
@@ -80,7 +80,8 @@ public class CheckinClient {
DeviceIdentifier deviceIdent, PhoneInfo phoneInfo,
LastCheckinInfo checkinInfo, Locale locale,
List accounts, Boolean brandSpoof) {
- CheckinRequest.Builder builder = new CheckinRequest.Builder()
+ CheckinRequest.Builder builder;
+ builder = new CheckinRequest.Builder()
.accountCookie(new ArrayList<>())
.androidId(checkinInfo.getAndroidId())
.checkin(new CheckinRequest.Checkin.Builder()
@@ -136,7 +137,7 @@ public class CheckinClient {
.loggingId(new Random().nextLong()) // TODO: static
.meid(deviceIdent.meid)
.otaCert(Collections.singletonList("71Q6Rn2DDZl1zPDVaaeEHItd"))
- .serial(Build.SERIAL != null && !Build.SERIAL.isEmpty() ? Build.SERIAL : null)
+ .serial(Build.SERIAL)
.timeZone(TimeZone.getDefault().getID())
.userName((String) TODO)
.userSerialNumber((Integer) TODO)
diff --git a/play-services-core/src/main/java/org/microg/gms/checkin/CheckinManager.java b/play-services-core/src/main/java/org/microg/gms/checkin/CheckinManager.java
index b9432ac6..355800d1 100755
--- a/play-services-core/src/main/java/org/microg/gms/checkin/CheckinManager.java
+++ b/play-services-core/src/main/java/org/microg/gms/checkin/CheckinManager.java
@@ -16,7 +16,7 @@
package org.microg.gms.checkin;
-import static org.microg.gms.checkin.CheckinPreferences.isSpoofingEnabled;
+import static org.microg.gms.checkin.CheckinPrefs.isSpoofingEnabled;
import android.accounts.Account;
import android.accounts.AccountManager;
@@ -43,7 +43,7 @@ public class CheckinManager {
LastCheckinInfo info = LastCheckinInfo.read(context);
if (!force && info.getLastCheckin() > System.currentTimeMillis() - MIN_CHECKIN_INTERVAL)
return null;
- if (!CheckinPreferences.isEnabled(context))
+ if (!CheckinPrefs.isEnabled(context))
return null;
List accounts = new ArrayList<>();
AccountManager accountManager = AccountManager.get(context);
@@ -71,8 +71,7 @@ public class CheckinManager {
ContentResolver resolver = context.getContentResolver();
for (CheckinResponse.GservicesSetting setting : response.setting) {
- if (setting.name != null && setting.value_ != null)
- GServices.setString(resolver, setting.name.utf8(), setting.value_.utf8());
+ GServices.setString(resolver, setting.name.utf8(), setting.value_.utf8());
}
return info;
diff --git a/play-services-core/src/main/java/org/microg/gms/checkin/CheckinService.java b/play-services-core/src/main/java/org/microg/gms/checkin/CheckinService.java
index 3f53ebcd..bd5bfabb 100755
--- a/play-services-core/src/main/java/org/microg/gms/checkin/CheckinService.java
+++ b/play-services-core/src/main/java/org/microg/gms/checkin/CheckinService.java
@@ -80,7 +80,7 @@ public class CheckinService extends IntentService {
protected void onHandleIntent(Intent intent) {
try {
ForegroundServiceContext.completeForegroundService(this, intent, TAG);
- if (CheckinPreferences.isEnabled(this)) {
+ if (CheckinPrefs.isEnabled(this)) {
LastCheckinInfo info = CheckinManager.checkin(this, intent.getBooleanExtra(EXTRA_FORCE_CHECKIN, false));
if (info != null) {
Log.d(TAG, "Checked in as " + Long.toHexString(info.getAndroidId()));
@@ -124,7 +124,7 @@ public class CheckinService extends IntentService {
static void schedule(Context context) {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
- PendingIntent pendingIntent = PendingIntent.getService(context, TriggerReceiver.class.getName().hashCode(), new Intent(context, TriggerReceiver.class), PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
+ PendingIntent pendingIntent = PendingIntent.getService(context, TriggerReceiver.class.getName().hashCode(), new Intent(context, TriggerReceiver.class), PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT);
alarmManager.set(AlarmManager.RTC, Math.max(LastCheckinInfo.read(context).getLastCheckin() + REGULAR_CHECKIN_INTERVAL, System.currentTimeMillis() + BACKUP_CHECKIN_DELAY), pendingIntent);
}
}
diff --git a/play-services-core/src/main/java/org/microg/gms/checkin/TriggerReceiver.java b/play-services-core/src/main/java/org/microg/gms/checkin/TriggerReceiver.java
index e41a954b..4b6551bd 100755
--- a/play-services-core/src/main/java/org/microg/gms/checkin/TriggerReceiver.java
+++ b/play-services-core/src/main/java/org/microg/gms/checkin/TriggerReceiver.java
@@ -18,6 +18,7 @@ package org.microg.gms.checkin;
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
+import static android.os.Build.VERSION.SDK_INT;
import static org.microg.gms.checkin.CheckinService.EXTRA_FORCE_CHECKIN;
import static org.microg.gms.checkin.CheckinService.REGULAR_CHECKIN_INTERVAL;
@@ -41,7 +42,7 @@ public class TriggerReceiver extends WakefulBroadcastReceiver {
try {
boolean force = "android.provider.Telephony.SECRET_CODE".equals(intent.getAction());
- if (CheckinPreferences.isEnabled(context) || force) {
+ if (CheckinPrefs.isEnabled(context) || force) {
if (LastCheckinInfo.read(context).getLastCheckin() > System.currentTimeMillis() - REGULAR_CHECKIN_INTERVAL && !force) {
CheckinService.schedule(context);
return;
@@ -53,7 +54,7 @@ public class TriggerReceiver extends WakefulBroadcastReceiver {
Intent subIntent = new Intent(context, CheckinService.class);
subIntent.putExtra(EXTRA_FORCE_CHECKIN, force);
startWakefulService(new ForegroundServiceContext(context), subIntent);
- } else {
+ } else if (SDK_INT >= 23) {
// no network, register a network callback to retry when we have internet
NetworkRequest networkRequest = new NetworkRequest.Builder()
.addCapability(NET_CAPABILITY_INTERNET)
diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/GcmDatabase.java b/play-services-core/src/main/java/org/microg/gms/gcm/GcmDatabase.java
index d19ce6ea..d9881dd8 100644
--- a/play-services-core/src/main/java/org/microg/gms/gcm/GcmDatabase.java
+++ b/play-services-core/src/main/java/org/microg/gms/gcm/GcmDatabase.java
@@ -10,6 +10,7 @@ import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
+import android.os.Build;
import android.text.TextUtils;
import java.util.ArrayList;
@@ -54,7 +55,9 @@ public class GcmDatabase extends SQLiteOpenHelper {
public GcmDatabase(Context context) {
super(context, DB_NAME, null, DB_VERSION);
this.context = context;
- this.setWriteAheadLoggingEnabled(true);
+ if (Build.VERSION.SDK_INT >= 16) {
+ this.setWriteAheadLoggingEnabled(true);
+ }
}
public static class App {
diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java b/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java
index 343d1721..6a6889ff 100644
--- a/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java
+++ b/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java
@@ -19,42 +19,8 @@ package org.microg.gms.gcm;
import static android.app.AlarmManager.ELAPSED_REALTIME_WAKEUP;
import static android.os.Build.VERSION.SDK_INT;
import static org.microg.gms.common.PackageUtils.warnIfNotPersistentProcess;
-import static org.microg.gms.gcm.GcmConstants.ACTION_C2DM_RECEIVE;
-import static org.microg.gms.gcm.GcmConstants.EXTRA_APP;
-import static org.microg.gms.gcm.GcmConstants.EXTRA_APP_OVERRIDE;
-import static org.microg.gms.gcm.GcmConstants.EXTRA_COLLAPSE_KEY;
-import static org.microg.gms.gcm.GcmConstants.EXTRA_FROM;
-import static org.microg.gms.gcm.GcmConstants.EXTRA_MESSAGE_ID;
-import static org.microg.gms.gcm.GcmConstants.EXTRA_MESSENGER;
-import static org.microg.gms.gcm.GcmConstants.EXTRA_RAWDATA;
-import static org.microg.gms.gcm.GcmConstants.EXTRA_RAWDATA_BASE64;
-import static org.microg.gms.gcm.GcmConstants.EXTRA_REGISTRATION_ID;
-import static org.microg.gms.gcm.GcmConstants.EXTRA_SEND_FROM;
-import static org.microg.gms.gcm.GcmConstants.EXTRA_SEND_TO;
-import static org.microg.gms.gcm.GcmConstants.EXTRA_TTL;
-import static org.microg.gms.gcm.McsConstants.ACTION_ACK;
-import static org.microg.gms.gcm.McsConstants.ACTION_CONNECT;
-import static org.microg.gms.gcm.McsConstants.ACTION_HEARTBEAT;
-import static org.microg.gms.gcm.McsConstants.ACTION_RECONNECT;
-import static org.microg.gms.gcm.McsConstants.ACTION_SEND;
-import static org.microg.gms.gcm.McsConstants.EXTRA_REASON;
-import static org.microg.gms.gcm.McsConstants.MCS_CLOSE_TAG;
-import static org.microg.gms.gcm.McsConstants.MCS_DATA_MESSAGE_STANZA_TAG;
-import static org.microg.gms.gcm.McsConstants.MCS_HEARTBEAT_ACK_TAG;
-import static org.microg.gms.gcm.McsConstants.MCS_HEARTBEAT_PING_TAG;
-import static org.microg.gms.gcm.McsConstants.MCS_IQ_STANZA_TAG;
-import static org.microg.gms.gcm.McsConstants.MCS_LOGIN_REQUEST_TAG;
-import static org.microg.gms.gcm.McsConstants.MCS_LOGIN_RESPONSE_TAG;
-import static org.microg.gms.gcm.McsConstants.MSG_ACK;
-import static org.microg.gms.gcm.McsConstants.MSG_CONNECT;
-import static org.microg.gms.gcm.McsConstants.MSG_HEARTBEAT;
-import static org.microg.gms.gcm.McsConstants.MSG_INPUT;
-import static org.microg.gms.gcm.McsConstants.MSG_INPUT_ERROR;
-import static org.microg.gms.gcm.McsConstants.MSG_OUTPUT;
-import static org.microg.gms.gcm.McsConstants.MSG_OUTPUT_DONE;
-import static org.microg.gms.gcm.McsConstants.MSG_OUTPUT_ERROR;
-import static org.microg.gms.gcm.McsConstants.MSG_OUTPUT_READY;
-import static org.microg.gms.gcm.McsConstants.MSG_TEARDOWN;
+import static org.microg.gms.gcm.GcmConstants.*;
+import static org.microg.gms.gcm.McsConstants.*;
import android.annotation.SuppressLint;
import android.app.AlarmManager;
@@ -68,16 +34,15 @@ import android.content.pm.PermissionInfo;
import android.content.pm.ResolveInfo;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
-import android.os.Messenger;
import android.os.Parcelable;
import android.os.PowerManager;
import android.os.SystemClock;
import android.os.UserHandle;
-import android.util.Base64;
import android.util.Log;
import androidx.annotation.Nullable;
@@ -101,6 +66,7 @@ import org.microg.gms.gcm.mcs.IqStanza;
import org.microg.gms.gcm.mcs.LoginRequest;
import org.microg.gms.gcm.mcs.LoginResponse;
import org.microg.gms.gcm.mcs.Setting;
+import org.microg.mgms.settings.SettingsProvider;
import java.io.Closeable;
import java.lang.reflect.Field;
@@ -110,7 +76,6 @@ import java.net.SocketException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import javax.net.ssl.SSLContext;
@@ -171,10 +136,10 @@ public class McsService extends Service implements Handler.Callback {
@Nullable
private Method addPowerSaveTempWhitelistAppMethod;
@Nullable
- @RequiresApi(31)
+ @RequiresApi(Build.VERSION_CODES.S)
private Object powerExemptionManager;
@Nullable
- @RequiresApi(31)
+ @RequiresApi(Build.VERSION_CODES.S)
private Method addToTemporaryAllowListMethod;
private class HandlerThread extends Thread {
@@ -189,7 +154,7 @@ public class McsService extends Service implements Handler.Callback {
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "mcs");
wakeLock.setReferenceCounted(false);
synchronized (McsService.class) {
- rootHandler = new Handler(Objects.requireNonNull(Looper.myLooper()), McsService.this);
+ rootHandler = new Handler(Looper.myLooper(), McsService.this);
if (connectIntent != null) {
rootHandler.sendMessage(rootHandler.obtainMessage(MSG_CONNECT, connectIntent));
WakefulBroadcastReceiver.completeWakefulIntent(connectIntent);
@@ -209,12 +174,12 @@ public class McsService extends Service implements Handler.Callback {
super.onCreate();
TriggerReceiver.register(this);
database = new GcmDatabase(this);
- heartbeatIntent = PendingIntent.getService(this, 0, new Intent(ACTION_HEARTBEAT, null, this, McsService.class), PendingIntent.FLAG_IMMUTABLE);
+ heartbeatIntent = PendingIntent.getService(this, 0, new Intent(ACTION_HEARTBEAT, null, this, McsService.class), 0);
alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
powerManager = (PowerManager) getSystemService(POWER_SERVICE);
if (checkSelfPermission("android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST") == PackageManager.PERMISSION_GRANTED) {
try {
- if (SDK_INT >= 31) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
Class> powerExemptionManagerClass = Class.forName("android.os.PowerExemptionManager");
powerExemptionManager = getSystemService(powerExemptionManagerClass);
addToTemporaryAllowListMethod =
@@ -300,7 +265,7 @@ public class McsService extends Service implements Handler.Callback {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
long delay = getCurrentDelay();
logd(context, "Scheduling reconnect in " + delay / 1000 + " seconds...");
- PendingIntent pi = PendingIntent.getBroadcast(context, 1, new Intent(ACTION_RECONNECT, null, context, TriggerReceiver.class), PendingIntent.FLAG_IMMUTABLE);
+ PendingIntent pi = PendingIntent.getBroadcast(context, 1, new Intent(ACTION_RECONNECT, null, context, TriggerReceiver.class), 0);
alarmManager.setExactAndAllowWhileIdle(ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delay, pi);
}
@@ -312,13 +277,14 @@ public class McsService extends Service implements Handler.Callback {
closeAll();
}
logd(context, "Scheduling heartbeat in " + heartbeatMs / 1000 + " seconds...");
+ // This is supposed to work even when running in idle and without battery optimization disabled
alarmManager.setExactAndAllowWhileIdle(ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + heartbeatMs, heartbeatIntent);
}
public synchronized static long getCurrentDelay() {
long delay = currentDelay == 0 ? 5000 : currentDelay;
- if (currentDelay < 60000) currentDelay += 10000;
- if (currentDelay >= 60000 && currentDelay < 600000) currentDelay += 60000;
+ if (currentDelay < SettingsProvider.INTERVAL) currentDelay += 10000;
+ if (currentDelay >= SettingsProvider.INTERVAL && currentDelay < 600000) currentDelay += SettingsProvider.INTERVAL;
return delay;
}
@@ -358,7 +324,6 @@ public class McsService extends Service implements Handler.Callback {
String messageId = intent.getStringExtra(EXTRA_MESSAGE_ID);
String collapseKey = intent.getStringExtra(EXTRA_COLLAPSE_KEY);
- Messenger messenger = intent.getParcelableExtra(EXTRA_MESSENGER);
intent.removeExtra(EXTRA_MESSENGER);
Parcelable app = intent.getParcelableExtra(EXTRA_APP);
@@ -376,16 +341,8 @@ public class McsService extends Service implements Handler.Callback {
}
intent.removeExtra(EXTRA_APP);
- int ttl;
try {
- if (intent.hasExtra(EXTRA_TTL)) {
- ttl = Integer.parseInt(intent.getStringExtra(EXTRA_TTL));
- if (ttl < 0 || ttl > maxTtl) {
- ttl = maxTtl;
- }
- } else {
- ttl = maxTtl;
- }
+ intent.hasExtra(EXTRA_TTL);
} catch (NumberFormatException e) {
// TODO: error TtlUnsupported
Log.w(TAG, e);
@@ -578,17 +535,15 @@ public class McsService extends Service implements Handler.Callback {
intent.setAction(ACTION_C2DM_RECEIVE);
intent.putExtra(EXTRA_FROM, msg.from);
intent.putExtra(EXTRA_MESSAGE_ID, msg.id);
- if (msg.persistent_id != null) intent.putExtra(EXTRA_MESSAGE_ID, msg.persistent_id);
- if (msg.token != null) intent.putExtra(EXTRA_COLLAPSE_KEY, msg.token);
- if (msg.raw_data != null) {
- intent.putExtra(EXTRA_RAWDATA_BASE64, Base64.encodeToString(msg.raw_data.toByteArray(), Base64.DEFAULT));
- intent.putExtra(EXTRA_RAWDATA, msg.raw_data.toByteArray());
+ if (msg.persistent_id != null) {
+ intent.putExtra(EXTRA_MESSAGE_ID, msg.persistent_id);
}
if (app.wakeForDelivery) {
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
} else {
intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
}
+ if (msg.token != null) intent.putExtra(EXTRA_COLLAPSE_KEY, msg.token);
for (AppData appData : msg.app_data) {
intent.putExtra(appData.key, appData.value_);
}
@@ -612,7 +567,7 @@ public class McsService extends Service implements Handler.Callback {
sendOrderedBroadcast(intent, null);
} else {
List infos = getPackageManager().queryBroadcastReceivers(intent, PackageManager.GET_RESOLVED_FILTER);
- if (infos.isEmpty()) {
+ if (infos == null || infos.isEmpty()) {
logd(this, "No target for message, wut?");
} else {
for (ResolveInfo resolveInfo : infos) {
@@ -634,7 +589,7 @@ public class McsService extends Service implements Handler.Callback {
}
private void addPowerSaveTempWhitelistApp(String packageName) {
- if (SDK_INT >= 31) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
try {
if (addToTemporaryAllowListMethod != null && powerExemptionManager != null) {
logd(this, "Adding app " + packageName + " to the temp allowlist");
@@ -678,12 +633,12 @@ public class McsService extends Service implements Handler.Callback {
rootHandler.sendMessage(rootHandler.obtainMessage(MSG_OUTPUT, type, 0, message));
}
- private void sendOutputStream(int arg, Object obj) {
+ private void sendOutputStream(int what, int arg, Object obj) {
McsOutputStream os = outputStream;
if (os != null && os.isAlive()) {
Handler outputHandler = os.getHandler();
if (outputHandler != null)
- outputHandler.sendMessage(outputHandler.obtainMessage(McsConstants.MSG_OUTPUT, arg, 0, obj));
+ outputHandler.sendMessage(outputHandler.obtainMessage(what, arg, 0, obj));
}
}
@@ -694,7 +649,7 @@ public class McsService extends Service implements Handler.Callback {
handleInput(msg.arg1, (Message) msg.obj);
return true;
case MSG_OUTPUT:
- sendOutputStream(msg.arg1, msg.obj);
+ sendOutputStream(MSG_OUTPUT, msg.arg1, msg.obj);
return true;
case MSG_INPUT_ERROR:
case MSG_OUTPUT_ERROR:
diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterManager.java b/play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterManager.java
index bc93194e..1dcfec44 100644
--- a/play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterManager.java
+++ b/play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterManager.java
@@ -147,7 +147,7 @@ public class PushRegisterManager {
resultBundle.putString(EXTRA_REGISTRATION_ID, attachRequestId(response.token, requestId));
}
} else {
- if (!request.app.equals(response.deleted) && !request.app.equals(response.token) && !request.sender.equals(response.token)) {
+ if (!request.app.equals(response.deleted) && !request.app.equals(response.token)) {
database.noteAppRegistrationError(request.app, response.responseText);
resultBundle.putString(EXTRA_ERROR, attachRequestId(ERROR_SERVICE_NOT_AVAILABLE, requestId));
} else {
diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/RegisterRequest.java b/play-services-core/src/main/java/org/microg/gms/gcm/RegisterRequest.java
index 80c7fd83..dbc21088 100644
--- a/play-services-core/src/main/java/org/microg/gms/gcm/RegisterRequest.java
+++ b/play-services-core/src/main/java/org/microg/gms/gcm/RegisterRequest.java
@@ -123,7 +123,7 @@ public class RegisterRequest extends HttpFormClient.Request {
public RegisterRequest extraParams(Bundle extraBundle) {
for (String key : extraBundle.keySet()) {
- if (!key.equals(GcmConstants.EXTRA_SENDER) && !key.equals(GcmConstants.EXTRA_DELETE) && !key.equals(GcmConstants.EXTRA_APP)) {
+ if (!key.equals(GcmConstants.EXTRA_SENDER) && !key.equals(GcmConstants.EXTRA_DELETE)) {
extraParam(key, extraBundle.getString(key));
}
}
diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/TriggerReceiver.java b/play-services-core/src/main/java/org/microg/gms/gcm/TriggerReceiver.java
index 83d182aa..245d5c2a 100644
--- a/play-services-core/src/main/java/org/microg/gms/gcm/TriggerReceiver.java
+++ b/play-services-core/src/main/java/org/microg/gms/gcm/TriggerReceiver.java
@@ -17,6 +17,7 @@
package org.microg.gms.gcm;
import static android.os.Build.VERSION.SDK_INT;
+import static android.os.Build.VERSION_CODES.N;
import static org.microg.gms.gcm.McsConstants.ACTION_CONNECT;
import static org.microg.gms.gcm.McsConstants.ACTION_HEARTBEAT;
import static org.microg.gms.gcm.McsConstants.EXTRA_REASON;
@@ -30,7 +31,7 @@ import android.util.Log;
import androidx.legacy.content.WakefulBroadcastReceiver;
-import org.microg.gms.checkin.CheckinPreferences;
+import org.microg.gms.checkin.CheckinPrefs;
import org.microg.gms.checkin.LastCheckinInfo;
import org.microg.gms.common.ForegroundServiceContext;
@@ -43,7 +44,7 @@ public class TriggerReceiver extends WakefulBroadcastReceiver {
* "Project Svelte" is just there to f**k things up...
*/
public synchronized static void register(Context context) {
- if (SDK_INT >= 24 && !registered) {
+ if (SDK_INT >= N && !registered) {
IntentFilter intentFilter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
context.getApplicationContext().registerReceiver(new TriggerReceiver(), intentFilter);
registered = true;
@@ -67,7 +68,7 @@ public class TriggerReceiver extends WakefulBroadcastReceiver {
if (LastCheckinInfo.read(context).getAndroidId() == 0) {
Log.d(TAG, "Ignoring " + intent + ": need to checkin first.");
- if (CheckinPreferences.isEnabled(context)) {
+ if (CheckinPrefs.isEnabled(context)) {
// Do a check-in if we are not actually checked in,
// but should be, e.g. cleared app data
Log.d(TAG, "Requesting check-in...");
diff --git a/play-services-core/src/main/java/org/microg/gms/gservices/GServices.java b/play-services-core/src/main/java/org/microg/gms/gservices/GServices.java
index 5c811f28..79543f47 100644
--- a/play-services-core/src/main/java/org/microg/gms/gservices/GServices.java
+++ b/play-services-core/src/main/java/org/microg/gms/gservices/GServices.java
@@ -21,12 +21,10 @@ import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
-import org.microg.gms.base.core.BuildConfig;
-
public class GServices {
- public static final Uri CONTENT_URI = Uri.parse("content://" + BuildConfig.BASE_PACKAGE_NAME + ".android.gsf.gservices");
- public static final Uri MAIN_URI = Uri.parse("content://" + BuildConfig.BASE_PACKAGE_NAME + ".android.gsf.gservices/main");
- public static final Uri OVERRIDE_URI = Uri.parse("content://" + BuildConfig.BASE_PACKAGE_NAME + ".android.gsf.gservices/override");
+ public static final Uri CONTENT_URI = Uri.parse("content://com.mgoogle.android.gsf.gservices");
+ public static final Uri MAIN_URI = Uri.parse("content://com.mgoogle.android.gsf.gservices/main");
+ public static final Uri OVERRIDE_URI = Uri.parse("content://com.mgoogle.android.gsf.gservices/override");
public static int setString(ContentResolver resolver, String key, String value) {
ContentValues values = new ContentValues();
diff --git a/play-services-core/src/main/java/org/microg/gms/gservices/GServicesProvider.java b/play-services-core/src/main/java/org/microg/gms/gservices/GServicesProvider.java
index 3d3a8189..2a95655b 100644
--- a/play-services-core/src/main/java/org/microg/gms/gservices/GServicesProvider.java
+++ b/play-services-core/src/main/java/org/microg/gms/gservices/GServicesProvider.java
@@ -29,8 +29,6 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import org.microg.gms.base.core.BuildConfig;
-
/**
* Originally found in Google Services Framework (com.google.android.gsf), this provides a generic
* key-value store, that is written by the checkin service and read from various Google Apps.
@@ -39,7 +37,7 @@ import org.microg.gms.base.core.BuildConfig;
* if certain "experiments" are enabled on the device.
*/
public class GServicesProvider extends ContentProvider {
- public static final Uri CONTENT_URI = Uri.parse("content://" + BuildConfig.BASE_PACKAGE_NAME + ".android.gsf.gservices/");
+ public static final Uri CONTENT_URI = Uri.parse("content://com.mgoogle.android.gsf.gservices/");
public static final Uri MAIN_URI = Uri.withAppendedPath(CONTENT_URI, "main");
public static final Uri OVERRIDE_URI = Uri.withAppendedPath(CONTENT_URI, "override");
public static final Uri PREFIX_URI = Uri.withAppendedPath(CONTENT_URI, "prefix");
diff --git a/play-services-core/src/main/java/org/microg/gms/ui/LegacyAccountSettingsActivity.java b/play-services-core/src/main/java/org/microg/gms/ui/AccountSettingsActivity.java
old mode 100644
new mode 100755
similarity index 91%
rename from play-services-core/src/main/java/org/microg/gms/ui/LegacyAccountSettingsActivity.java
rename to play-services-core/src/main/java/org/microg/gms/ui/AccountSettingsActivity.java
index fc015f5e..fa099d49
--- a/play-services-core/src/main/java/org/microg/gms/ui/LegacyAccountSettingsActivity.java
+++ b/play-services-core/src/main/java/org/microg/gms/ui/AccountSettingsActivity.java
@@ -18,6 +18,7 @@ package org.microg.gms.ui;
import android.accounts.Account;
import android.accounts.AccountManager;
+import android.os.Build;
import android.os.Bundle;
import androidx.annotation.Nullable;
@@ -33,10 +34,9 @@ import org.microg.tools.ui.ResourceSettingsFragment;
import static android.accounts.AccountManager.PACKAGE_NAME_KEY_LEGACY_NOT_VISIBLE;
import static android.accounts.AccountManager.VISIBILITY_NOT_VISIBLE;
import static android.accounts.AccountManager.VISIBILITY_VISIBLE;
-import static android.os.Build.VERSION.SDK_INT;
import static org.microg.gms.auth.AuthManager.PREF_AUTH_VISIBLE;
-public class LegacyAccountSettingsActivity extends AbstractSettingsActivity {
+public class AccountSettingsActivity extends AbstractSettingsActivity {
@Override
protected Fragment getFragment() {
@@ -45,7 +45,7 @@ public class LegacyAccountSettingsActivity extends AbstractSettingsActivity {
public static class AccountSettingsFragment extends ResourceSettingsFragment {
public AccountSettingsFragment() {
- preferencesResource = R.xml.preferences_google_more;
+ preferencesResource = R.xml.preferences_account;
}
@Override
@@ -53,7 +53,7 @@ public class LegacyAccountSettingsActivity extends AbstractSettingsActivity {
super.onCreatePreferences(savedInstanceState, rootKey);
Preference pref = findPreference(PREF_AUTH_VISIBLE);
if (pref != null) {
- if (SDK_INT < 26) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
pref.setVisible(false);
} else {
pref.setOnPreferenceChangeListener((preference, newValue) -> {
diff --git a/play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java b/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java
old mode 100644
new mode 100755
similarity index 66%
rename from play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java
rename to play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java
index b65b3806..c60833ec
--- a/play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java
+++ b/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java
@@ -1,6 +1,6 @@
package org.microg.gms.ui;
-import android.content.Intent;
+import android.os.Build;
import android.os.Bundle;
import androidx.annotation.Nullable;
@@ -10,12 +10,10 @@ import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
+import com.google.android.material.color.DynamicColors;
import com.mgoogle.android.gms.R;
-import org.microg.gms.ui.settings.SettingsProvider;
-import static org.microg.gms.ui.settings.SettingsProviderKt.getAllSettingsProviders;
-
-public class MainSettingsActivity extends AppCompatActivity {
+public class SettingsActivity extends AppCompatActivity {
private AppBarConfiguration appBarConfiguration;
private NavController getNavController() {
@@ -25,18 +23,10 @@ public class MainSettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
- Intent intent = getIntent();
- for (SettingsProvider settingsProvider : getAllSettingsProviders(this)) {
- settingsProvider.preProcessSettingsIntent(intent);
- }
-
setContentView(R.layout.settings_root_activity);
-
- for (SettingsProvider settingsProvider : getAllSettingsProviders(this)) {
- settingsProvider.extendNavigation(getNavController());
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
+ DynamicColors.applyToActivityIfAvailable(this);
}
-
appBarConfiguration = new AppBarConfiguration.Builder(getNavController().getGraph()).build();
NavigationUI.setupActionBarWithNavController(this, getNavController(), appBarConfiguration);
}
@@ -45,4 +35,4 @@ public class MainSettingsActivity extends AppCompatActivity {
public boolean onSupportNavigateUp() {
return NavigationUI.navigateUp(getNavController(), appBarConfiguration) || super.onSupportNavigateUp();
}
-}
\ No newline at end of file
+}
diff --git a/play-services-core/src/main/java/org/microg/gms/settings/GoogleSettingsProvider.java b/play-services-core/src/main/java/org/microg/mgms/settings/GoogleSettingsProvider.java
similarity index 97%
rename from play-services-core/src/main/java/org/microg/gms/settings/GoogleSettingsProvider.java
rename to play-services-core/src/main/java/org/microg/mgms/settings/GoogleSettingsProvider.java
index da3e5094..3ab7f51c 100644
--- a/play-services-core/src/main/java/org/microg/gms/settings/GoogleSettingsProvider.java
+++ b/play-services-core/src/main/java/org/microg/mgms/settings/GoogleSettingsProvider.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.microg.gms.settings;
+package org.microg.mgms.settings;
import android.content.ContentProvider;
import android.content.ContentValues;
diff --git a/play-services-core/src/main/java/org/microg/tools/AccountPickerActivity.java b/play-services-core/src/main/java/org/microg/tools/AccountPickerActivity.java
index 69d87394..4c596f32 100755
--- a/play-services-core/src/main/java/org/microg/tools/AccountPickerActivity.java
+++ b/play-services-core/src/main/java/org/microg/tools/AccountPickerActivity.java
@@ -16,15 +16,16 @@
package org.microg.tools;
+import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
-import androidx.appcompat.app.AppCompatActivity;
/**
* This is just an activity that forwards to the systems native account picker
*/
-public class AccountPickerActivity extends AppCompatActivity {
+public class AccountPickerActivity extends Activity {
+ private static final int REQUEST_CODE = AccountPickerActivity.class.hashCode();
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -35,8 +36,16 @@ public class AccountPickerActivity extends AppCompatActivity {
ComponentName.unflattenFromString("android/.accounts.ChooseTypeAndAccountActivity");
intent.setClassName(componentName.getPackageName(), componentName.getClassName());
intent.putExtras(extras);
- intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
- startActivity(intent);
- finish();
+ startActivityForResult(intent, REQUEST_CODE);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_CODE) {
+ setResult(resultCode, data);
+ finish();
+ } else {
+ super.onActivityResult(requestCode, resultCode, data);
+ }
}
}
diff --git a/play-services-core/src/main/kotlin/com/google/android/gms/common/GoogleCertificatesImpl.kt b/play-services-core/src/main/kotlin/com/google/android/gms/common/GoogleCertificatesImpl.kt
deleted file mode 100644
index e1fb7a21..00000000
--- a/play-services-core/src/main/kotlin/com/google/android/gms/common/GoogleCertificatesImpl.kt
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-package com.google.android.gms.common
-
-import android.content.pm.PackageManager
-import android.os.IBinder
-import android.os.Parcel
-import android.util.Log
-import androidx.annotation.Keep
-import com.google.android.gms.common.internal.CertData
-import com.google.android.gms.common.internal.IGoogleCertificatesApi
-import com.google.android.gms.dynamic.IObjectWrapper
-import com.google.android.gms.dynamic.ObjectWrapper
-import org.microg.gms.common.PackageUtils
-import org.microg.gms.utils.warnOnTransactionIssues
-
-private const val TAG = "GoogleCertificates"
-
-@Keep
-class GoogleCertificatesImpl : IGoogleCertificatesApi.Stub() {
- private val googleCertificates = emptySet()
- private val googleReleaseCertificates = emptySet()
-
- override fun getGoogleCertificates(): IObjectWrapper {
- Log.d(TAG, "unimplemented Method: getGoogleCertificates")
- return ObjectWrapper.wrap(googleCertificates.toTypedArray())
- }
-
- override fun getGoogleReleaseCertificates(): IObjectWrapper {
- Log.d(TAG, "unimplemented Method: getGoogleReleaseCertificates")
- return ObjectWrapper.wrap(googleReleaseCertificates.toTypedArray())
- }
-
- override fun isGoogleReleaseSigned(packageName: String, certData: IObjectWrapper): Boolean {
- return PackageUtils.isGooglePackage(packageName, ObjectWrapper.unwrapTyped(certData, ByteArray::class.java))
- }
-
- override fun isGoogleSigned(packageName: String, certData: IObjectWrapper): Boolean {
- return PackageUtils.isGooglePackage(packageName, ObjectWrapper.unwrapTyped(certData, ByteArray::class.java))
- }
-
- override fun isGoogleOrPlatformSigned(query: GoogleCertificatesQuery, packageManager: IObjectWrapper): Boolean {
- val pm = ObjectWrapper.unwrapTyped(packageManager, PackageManager::class.java)
- return if (query == null || query.callingPackage == null) {
- false
- } else if (query.getCertData() == null) {
- if (pm == null) false else PackageUtils.isGooglePackage(pm, query.callingPackage)
- } else {
- PackageUtils.isGooglePackage(query.callingPackage, query.getCertData().bytes)
- }
- }
-
- override fun isPackageGoogleOrPlatformSigned(query: GoogleCertificatesLookupQuery): GoogleCertificatesLookupResponse {
- return certificateLookup(query, true)
- }
-
- override fun isPackageGoogleOrPlatformSignedAvailable(): Boolean {
- return true
- }
-
- override fun queryPackageSigned(query: GoogleCertificatesLookupQuery): GoogleCertificatesLookupResponse {
- if (!isFineGrainedPackageVerificationAvailable) throw IllegalStateException("API unavailable")
- return certificateLookup(query, false)
- }
-
- override fun isFineGrainedPackageVerificationAvailable(): Boolean {
- return true
- }
-
- private fun certificateLookup(query: GoogleCertificatesLookupQuery, allowPlatform: Boolean): GoogleCertificatesLookupResponse {
- val context = query.context
- ?: return GoogleCertificatesLookupResponse(false, "context is null", 5, 1)
- val packageManager = context.packageManager
- ?: return GoogleCertificatesLookupResponse(false, "context has no package manager", 5, 1)
- val callingPackage = query.callingPackage
- ?: return GoogleCertificatesLookupResponse(false, "callingPackage is null", 5, 1)
- val signatureDigest = PackageUtils.firstSignatureDigest(packageManager, callingPackage)
- ?: return GoogleCertificatesLookupResponse(false, "callingPackage not found", 4, 1)
- return if (PackageUtils.isGooglePackage(callingPackage, signatureDigest)) {
- GoogleCertificatesLookupResponse(true, null, 1, 3)
- } else {
- GoogleCertificatesLookupResponse(false, "not allowed", 2, 1)
- }
- }
-
- override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean =
- warnOnTransactionIssues(code, reply, flags, TAG) { super.onTransact(code, data, reply, flags) }
-}
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/accountsettings/ui/LoaderActivity.kt b/play-services-core/src/main/kotlin/org/microg/gms/accountsettings/ui/LoaderActivity.kt
deleted file mode 100644
index c1a4a2da..00000000
--- a/play-services-core/src/main/kotlin/org/microg/gms/accountsettings/ui/LoaderActivity.kt
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package org.microg.gms.accountsettings.ui
-
-import android.accounts.AccountManager
-import android.content.Intent
-import android.content.Intent.ACTION_VIEW
-import android.content.Intent.CATEGORY_BROWSABLE
-import android.content.Intent.FLAG_ACTIVITY_FORWARD_RESULT
-import android.net.Uri
-import android.os.Bundle
-import android.util.Log
-import androidx.appcompat.app.AppCompatActivity
-import org.microg.gms.auth.AuthConstants.DEFAULT_ACCOUNT_TYPE
-import org.microg.gms.common.PackageUtils
-import org.microg.tools.AccountPickerActivity
-
-private const val TAG = "AccountSettingsLoader"
-
-private val ALLOWED_FALLBACK_PREFIXES = setOf("https://myaccount.google.com/", "https://takeout.google.com/")
-private val BROWSABLE_SCREEN_IDS = setOf(1, 200, 400, 502, 527, 10003, 10050, 12700, 12701)
-private val ACCOUNT_CHOOSER_URI = Uri.parse("https://accounts.google.com/AccountChooser")
-
-private const val QUERY_PARAM_CONTINUE = "continue"
-private const val QUERY_PARAM_LANG = "hl"
-private const val QUERY_PARAM_EMAIL = "Email"
-
-private const val EXTRA_ALLOWABLE_ACCOUNT_TYPES = "allowableAccountTypes"
-
-private const val REQUEST_ACCOUNT_PICKER = 1
-
-@Suppress("DEPRECATION")
-class LoaderActivity : AppCompatActivity() {
- private var canAskForAccount = false
-
- private fun launchFallback() {
- val fallbackUrl = intent?.getStringExtra(EXTRA_FALLBACK_URL)
-
- if (fallbackUrl == null) {
- Log.d(TAG, "No fallback")
- finishResult(RESULT_CANCELED)
- } else if (fallbackUrl in ALLOWED_FALLBACK_PREFIXES) {
- // TODO: Error screen?
- Log.d(TAG, "Illegal fallback url")
- finishResult(RESULT_CANCELED)
- } else {
- val fallbackAuth = intent?.getBooleanExtra(EXTRA_FALLBACK_AUTH, false) ?: false
- val uri = if (fallbackAuth) {
- val builder = ACCOUNT_CHOOSER_URI.buildUpon().appendQueryParameter(QUERY_PARAM_CONTINUE, fallbackUrl)
- val accountName = intent?.getStringExtra(EXTRA_ACCOUNT_NAME)
- if (!accountName.isNullOrBlank()) {
- builder.appendQueryParameter(QUERY_PARAM_EMAIL, accountName)
- }
- val lang = Uri.parse(fallbackUrl).getQueryParameter(QUERY_PARAM_LANG)
- if (lang != null) {
- builder.appendQueryParameter(QUERY_PARAM_LANG, lang)
- }
- builder.build()
- } else {
- Uri.parse(fallbackUrl)
- }
- Log.d(TAG, "Opening fallback $fallbackUrl")
- val intent = Intent(ACTION_VIEW, uri).apply { addCategory(CATEGORY_BROWSABLE) }
- startActivity(intent)
- finishResult(RESULT_OK)
- }
- }
-
- private fun launchMain() {
- val requestedAccountName = intent.getStringExtra(EXTRA_ACCOUNT_NAME)
- val ignoreAccount = intent?.getBooleanExtra(EXTRA_IGNORE_ACCOUNT, false) ?: false
- val accounts = AccountManager.get(this).getAccountsByType(DEFAULT_ACCOUNT_TYPE)
- val account = if (requestedAccountName != null) {
- val account = accounts.find { it.name == requestedAccountName }
- if (account == null) {
- // TODO: Error screen?
- Log.d(TAG, "Account not found: $requestedAccountName")
- return finishResult(RESULT_CANCELED)
- }
- account
- } else if (accounts.isEmpty()) {
- if (intent?.getStringExtra(EXTRA_FALLBACK_URL) != null) {
- return launchFallback()
- } else {
- // TODO: Error screen?
- Log.d(TAG, "No account configured")
- return finishResult(RESULT_CANCELED)
- }
- } else if (accounts.size > 1) {
- if (canAskForAccount) {
- val intent = Intent(this, AccountPickerActivity::class.java)
- intent.putExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES, arrayOf(DEFAULT_ACCOUNT_TYPE))
- startActivityForResult(intent, REQUEST_ACCOUNT_PICKER)
- canAskForAccount = false
- return
- } else {
- return finishResult(RESULT_CANCELED)
- }
- } else {
- accounts.first()
- }
-
- val intent = Intent(this, MainActivity::class.java).apply {
- action = intent.action
- if (intent.hasExtra(EXTRA_THEME_CHOICE)) putExtra(EXTRA_THEME_CHOICE, intent.getIntExtra(EXTRA_THEME_CHOICE, 0))
- putExtra(EXTRA_ACCOUNT_NAME, account.name)
- if (ignoreAccount) putExtra(EXTRA_IGNORE_ACCOUNT, true)
- putExtra(EXTRA_SCREEN_ID, intent.getIntExtra(EXTRA_SCREEN_ID, 1))
- for (it in intent.extras?.keySet().orEmpty()) {
- if (it.startsWith(EXTRA_SCREEN_OPTIONS_PREFIX)) putExtra(it, intent.getStringExtra(it))
- }
- putExtra(EXTRA_CALLING_PACKAGE_NAME, callingActivity?.packageName)
- if (intent.action != ACTION_BROWSE_SETTINGS) {
- addFlags(FLAG_ACTIVITY_FORWARD_RESULT)
- }
- }
-
- startActivity(intent)
-
- if (!isFinishing && !isChangingConfigurations) {
- finishResult(RESULT_OK)
- }
- }
-
- @Deprecated("Deprecated in Java")
- override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
- if (requestCode == REQUEST_ACCOUNT_PICKER) {
- if (resultCode == RESULT_OK && data?.hasExtra(AccountManager.KEY_ACCOUNT_NAME) == true) {
- intent.putExtra(EXTRA_ACCOUNT_NAME, data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME))
- launchMain()
- } else {
- finishResult(resultCode)
- }
- } else {
- super.onActivityResult(requestCode, resultCode, data)
- }
- }
-
- override fun onCreate(savedInstanceState: Bundle?) {
- canAskForAccount = true
- val extras = intent?.extras?.also { it.keySet() }
- Log.d(TAG, "Invoked with ${intent.action} and extras $extras")
-
- super.onCreate(savedInstanceState)
-
- val isMainAllowed = if (intent == null || intent.action != ACTION_BROWSE_SETTINGS)
- PackageUtils.isGooglePackage(this, callingActivity?.packageName)
- else
- extras?.getInt(EXTRA_SCREEN_ID, -1) in BROWSABLE_SCREEN_IDS
-
- if (!isMainAllowed) {
- launchFallback()
- } else if (!isFinishing && !isChangingConfigurations){
- launchMain()
- }
- }
-
- private fun finishResult(resultCode: Int) {
- setResult(resultCode)
- finish()
- }
-}
\ No newline at end of file
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/accountsettings/ui/MainActivity.kt b/play-services-core/src/main/kotlin/org/microg/gms/accountsettings/ui/MainActivity.kt
deleted file mode 100644
index 441a2e3b..00000000
--- a/play-services-core/src/main/kotlin/org/microg/gms/accountsettings/ui/MainActivity.kt
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package org.microg.gms.accountsettings.ui
-
-import android.accounts.Account
-import android.accounts.AccountManager
-import android.os.Bundle
-import android.util.Log
-import android.view.View
-import android.webkit.WebView
-import android.widget.ProgressBar
-import android.widget.RelativeLayout
-import android.widget.RelativeLayout.LayoutParams.MATCH_PARENT
-import android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT
-import androidx.appcompat.app.AppCompatActivity
-import org.microg.gms.auth.AuthConstants
-import org.microg.gms.common.Constants
-
-private const val TAG = "AccountSettings"
-
-// TODO: There likely is some API to figure those out...
-private val SCREEN_ID_TO_URL = hashMapOf(
- 1 to "https://myaccount.google.com",
- 200 to "https://myaccount.google.com/privacycheckup",
- 203 to "https://myaccount.google.com/email",
- 204 to "https://myaccount.google.com/phone",
- 205 to "https://myaccount.google.com/birthday",
- 206 to "https://myaccount.google.com/gender",
- 210 to "https://myaccount.google.com/locationsharing",
- 214 to "https://myaccount.google.com/dashboard",
- 215 to "https://takeout.google.com",
- 216 to "https://myaccount.google.com/inactive",
- 219 to "https://myactivity.google.com/myactivity",
- 220 to "https://www.google.com/maps/timeline",
- 224 to "https://myactivity.google.com/activitycontrols?settings=search",
- 227 to "https://myactivity.google.com/activitycontrols?settings=location",
- 231 to "https://myactivity.google.com/activitycontrols?settings=youtube",
- 235 to "https://myactivity.google.com/activitycontrols/youtube",
- 238 to "https://www.google.com/setting/search/privateresults/",
- 241 to "https://myaccount.google.com/communication-preferences",
- 300 to "https://myaccount.google.com/language",
- 301 to "https://drive.google.com/settings/storage",
- 302 to "https://myaccount.google.com/deleteservices",
- 303 to "https://myaccount.google.com/deleteaccount",
- 307 to "https://payments.google.com/payments/home",
- 308 to "https://myaccount.google.com/subscriptions",
- 309 to "https://myaccount.google.com/purchases",
- 310 to "https://myaccount.google.com/reservations",
- 312 to "https://myaccount.google.com/accessibility",
- 313 to "https://myaccount.google.com/inputtools",
- 400 to "https://myaccount.google.com/security-checkup/",
- 401 to "https://myaccount.google.com/signinoptions/password",
- 403 to "https://myaccount.google.com/signinoptions/two-step-verification",
- 406 to "https://myaccount.google.com/signinoptions/rescuephone",
- 407 to "https://myaccount.google.com/recovery/email",
- 409 to "https://myaccount.google.com/notifications",
- 410 to "https://myaccount.google.com/device-activity",
- 417 to "https://myaccount.google.com/find-your-phone",
- 425 to "https://myaccount.google.com/account-enhanced-safe-browsing",
- 426 to "https://myaccount.google.com/two-step-verification/authenticator",
- 427 to "https://myaccount.google.com/two-step-verification/backup-codes",
- 429 to "https://myaccount.google.com/two-step-verification/security-keys",
- 430 to "https://myaccount.google.com/two-step-verification/prompt",
- 431 to "https://myaccount.google.com/connections",
- 432 to "https://myaccount.google.com/two-step-verification/phone-numbers",
- 433 to "https://myaccount.google.com/signinoptions/passkeys",
- 437 to "https://myaccount.google.com/signinoptions/passwordoptional",
- 500 to "https://policies.google.com/privacy",
- 503 to "https://policies.google.com/terms",
- 519 to "https://myaccount.google.com/yourdata/maps",
- 520 to "https://myaccount.google.com/yourdata/search",
- 530 to "https://fit.google.com/privacy/settings",
- 547 to "https://myactivity.google.com/product/search",
- 562 to "https://myaccount.google.com/yourdata/youtube",
- 10003 to "https://myaccount.google.com/personal-info",
- 10004 to "https://myaccount.google.com/data-and-privacy",
- 10005 to "https://myaccount.google.com/people-and-sharing",
- 10006 to "https://myaccount.google.com/security",
- 10007 to "https://myaccount.google.com/payments-and-subscriptions",
- 10015 to "https://support.google.com/accounts",
- 10050 to "https://myaccount.google.com/profile",
- 10090 to "https://myaccount.google.com/profile/name",
- 10704 to "https://www.google.com/account/about",
- 10706 to "https://myaccount.google.com/profile/profiles-summary",
- 10728 to "https://myaccount.google.com/data-and-privacy/how-data-improves-experience",
- 10729 to "https://myaccount.google.com/data-and-privacy/data-visibility",
- 10759 to "https://myaccount.google.com/address/home",
- 10760 to "https://myaccount.google.com/address/work",
-)
-
-private val ALLOWED_WEB_PREFIXES = setOf(
- "https://accounts.google.com/",
- "https://myaccount.google.com/",
- "https://one.google.com/",
- "https://myactivity.google.com/",
- "https://timeline.google.com/",
- "https://takeout.google.com/",
- "https://www.google.com/maps/timeline",
- "https://www.google.com/setting/",
- "https://drive.google.com/settings/",
- "https://drive.google.com/accounts/",
- "https://drive.google.com/u/1/settings/",
- "https://payments.google.com/",
- "https://policies.google.com/",
- "https://fit.google.com/privacy/settings",
- "https://maps.google.com/maps/timeline"
-)
-
-private val ACTION_TO_SCREEN_ID = hashMapOf(
- ACTION_MY_ACCOUNT to 1,
- ACTION_ACCOUNT_PREFERENCES_SETTINGS to 1,
- ACTION_SECURITY_SETTINGS to 10006,
- ACTION_PRIVACY_SETTINGS to 10004,
-)
-
-@Suppress("DEPRECATION")
-class MainActivity : AppCompatActivity() {
- private lateinit var webView: WebView
-
- private fun getSelectedAccountName(): String? = null
-
- override fun onCreate(savedInstanceState: Bundle?) {
- val extras = intent?.extras?.also { it.keySet() }
- Log.d(TAG, "Invoked with ${intent.action} and extras $extras")
- super.onCreate(savedInstanceState)
-
- val screenId = intent?.getIntExtra(EXTRA_SCREEN_ID, -1).takeIf { it != -1 } ?: ACTION_TO_SCREEN_ID[intent.action] ?: 1
- val screenOptions = intent.extras?.keySet().orEmpty()
- .filter { it.startsWith(EXTRA_SCREEN_OPTIONS_PREFIX) }
- .map { it.substring(EXTRA_SCREEN_OPTIONS_PREFIX.length) to intent.getStringExtra(it) }
- .toMap()
-
- val callingPackage = intent?.getStringExtra(EXTRA_CALLING_PACKAGE_NAME) ?: callingActivity?.packageName ?: Constants.GMS_PACKAGE_NAME
-
- val ignoreAccount = intent?.getBooleanExtra(EXTRA_IGNORE_ACCOUNT, false) ?: false
- val accountName = if (ignoreAccount) null else {
- val accounts = AccountManager.get(this).getAccountsByType(AuthConstants.DEFAULT_ACCOUNT_TYPE)
- val accountName = intent.getStringExtra(EXTRA_ACCOUNT_NAME) ?: intent.getParcelableExtra("account")?.name ?: getSelectedAccountName()
- accounts.find { it.name.equals(accountName) }?.name
- }
-
- if (accountName == null) {
- Log.w(TAG, "No account, going without!")
- }
-
- if (screenId in SCREEN_ID_TO_URL) {
- val layout = RelativeLayout(this)
- layout.addView(ProgressBar(this).apply {
- layoutParams = RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply {
- addRule(RelativeLayout.CENTER_HORIZONTAL)
- addRule(RelativeLayout.CENTER_VERTICAL)
- }
- isIndeterminate = true
- })
- webView = WebView(this).apply {
- layoutParams = RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
- visibility = View.INVISIBLE
- }
- layout.addView(webView)
- setContentView(layout)
- WebViewHelper(this, webView, ALLOWED_WEB_PREFIXES).openWebView(SCREEN_ID_TO_URL[screenId], accountName)
- setResult(RESULT_OK)
- } else {
- Log.w(TAG, "Unknown screen id, can't open corresponding web page")
- setResult(RESULT_CANCELED)
- finish()
- }
- }
-
- override fun onDestroy() {
- super.onDestroy()
- }
-
- @Deprecated("Deprecated in Java")
- override fun onBackPressed() {
- if (this::webView.isInitialized && webView.canGoBack()) {
- webView.goBack()
- } else {
- super.onBackPressed()
- }
- }
-}
\ No newline at end of file
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/accountsettings/ui/WebViewHelper.kt b/play-services-core/src/main/kotlin/org/microg/gms/accountsettings/ui/WebViewHelper.kt
deleted file mode 100644
index 7ce98e9c..00000000
--- a/play-services-core/src/main/kotlin/org/microg/gms/accountsettings/ui/WebViewHelper.kt
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package org.microg.gms.accountsettings.ui
-
-import android.content.Intent
-import android.content.Intent.URI_INTENT_SCHEME
-import android.net.Uri
-import android.util.Log
-import android.view.View
-import android.webkit.WebResourceRequest
-import android.webkit.WebSettings
-import android.webkit.WebView
-import androidx.appcompat.app.AppCompatActivity
-import androidx.lifecycle.lifecycleScope
-import androidx.webkit.WebResourceErrorCompat
-import androidx.webkit.WebViewClientCompat
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
-import org.microg.gms.auth.AuthManager
-import org.microg.gms.common.Constants.GMS_PACKAGE_NAME
-import org.microg.gms.common.PackageUtils
-import java.net.URLEncoder
-import java.util.*
-
-private const val TAG = "AccountSettingsWebView"
-
-class WebViewHelper(private val activity: AppCompatActivity, private val webView: WebView, private val allowedPrefixes: Set = emptySet()) {
- fun openWebView(url: String?, accountName: String?) {
- prepareWebViewSettings(webView.settings)
- webView.webViewClient = object : WebViewClientCompat() {
- override fun onReceivedError(view: WebView, request: WebResourceRequest, error: WebResourceErrorCompat) {
- Log.w(TAG, "Error loading: $error")
- }
-
- override fun onPageFinished(view: WebView?, url: String?) {
- super.onPageFinished(view, url)
- webView.visibility = View.VISIBLE
- }
-
- @Deprecated("Deprecated in Java")
- override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
- Log.d(TAG, "Navigating to $url")
- if (url.startsWith("intent:")) {
- try {
- val intent = Intent.parseUri(url, URI_INTENT_SCHEME)
- if (intent.`package` == GMS_PACKAGE_NAME || PackageUtils.isGooglePackage(activity, intent.`package`)) {
- // Only allow to start Google packages
- activity.startActivity(intent)
- } else {
- Log.w(TAG, "Ignoring request to start non-Google app")
- }
- } catch (e: Exception) {
- Log.w(TAG, "Error invoking intent", e)
- }
- return false
- }
- if (allowedPrefixes.isNotEmpty() && allowedPrefixes.none { url.startsWith(it) }) {
- try {
- activity.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)).apply { addCategory(Intent.CATEGORY_BROWSABLE) })
- } catch (e: Exception) {
- Log.w(TAG, "Error forwarding to browser", e)
- }
- return true
- }
- return false
- }
- }
-
- val urlWithLanguage: String? = addLanguageParam(url)
- if (accountName != null) {
- activity.lifecycleScope.launch {
- withContext(Dispatchers.IO) {
- openWebWithAccount(accountName, urlWithLanguage)
- }
- }
- } else {
- loadWebViewUrl(urlWithLanguage)
- }
- }
-
- private fun loadWebViewUrl(url: String?) {
- if (url != null) {
- webView.loadUrl(url)
- } else {
- activity.finish()
- }
- }
-
- private fun addLanguageParam(url: String?): String? {
- val language = Locale.getDefault().language
- return if (language.isNotEmpty()) {
- Uri.parse(url).buildUpon().appendQueryParameter("hl", language).toString()
- } else {
- url
- }
- }
-
- private fun openWebWithAccount(accountName: String, url: String?) {
- try {
- val service = "weblogin:continue=" + URLEncoder.encode(url, "utf-8")
- val authManager = AuthManager(activity, accountName, GMS_PACKAGE_NAME, service)
- val authUrl = authManager.requestAuth(false)?.auth
- if (authUrl?.contains("WILL_NOT_SIGN_IN") == true) {
- throw RuntimeException("Would not sign in")
- }
- Log.d(TAG, "Opening $authUrl")
- webView.post {
- loadWebViewUrl(authUrl)
- }
- } catch (e: Exception) {
- Log.w(TAG, "Failed to get weblogin auth.", e)
- activity.finish()
- }
- }
-
- private fun prepareWebViewSettings(settings: WebSettings) {
- settings.javaScriptEnabled = true
- settings.setSupportMultipleWindows(false)
- settings.allowFileAccess = false
- settings.databaseEnabled = false
- settings.setNeedInitialFocus(false)
- settings.useWideViewPort = false
- settings.setSupportZoom(false)
- settings.javaScriptCanOpenWindowsAutomatically = false
- }
-}
\ No newline at end of file
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/accountsettings/ui/extensions.kt b/play-services-core/src/main/kotlin/org/microg/gms/accountsettings/ui/extensions.kt
deleted file mode 100644
index 5ca88fe7..00000000
--- a/play-services-core/src/main/kotlin/org/microg/gms/accountsettings/ui/extensions.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package org.microg.gms.accountsettings.ui
-
-const val ACTION_BROWSE_SETTINGS = "com.google.android.gms.accountsettings.action.BROWSE_SETTINGS"
-const val ACTION_MY_ACCOUNT = "com.google.android.gms.accountsettings.MY_ACCOUNT"
-const val ACTION_ACCOUNT_PREFERENCES_SETTINGS = "com.google.android.gms.accountsettings.ACCOUNT_PREFERENCES_SETTINGS"
-const val ACTION_PRIVACY_SETTINGS = "com.google.android.gms.accountsettings.PRIVACY_SETTINGS"
-const val ACTION_SECURITY_SETTINGS = "com.google.android.gms.accountsettings.SECURITY_SETTINGS"
-
-const val EXTRA_CALLING_PACKAGE_NAME = "extra.callingPackageName"
-const val EXTRA_IGNORE_ACCOUNT = "extra.ignoreAccount"
-const val EXTRA_ACCOUNT_NAME = "extra.accountName"
-const val EXTRA_SCREEN_ID = "extra.screenId"
-const val EXTRA_SCREEN_OPTIONS_PREFIX = "extra.screen."
-const val EXTRA_FALLBACK_URL = "extra.fallbackUrl"
-const val EXTRA_FALLBACK_AUTH = "extra.fallbackAuth"
-const val EXTRA_THEME_CHOICE = "extra.themeChoice"
-
-const val OPTION_SCREEN_FLAVOR = "screenFlavor"
\ No newline at end of file
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/auth/AuthPrefs.kt b/play-services-core/src/main/kotlin/org/microg/gms/auth/AuthPrefs.kt
index ba5d2b2e..5406bf2a 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/auth/AuthPrefs.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/auth/AuthPrefs.kt
@@ -1,8 +1,8 @@
package org.microg.gms.auth
import android.content.Context
-import org.microg.gms.settings.SettingsContract
-import org.microg.gms.settings.SettingsContract.Auth
+import org.microg.mgms.settings.SettingsContract
+import org.microg.mgms.settings.SettingsContract.Auth
object AuthPrefs {
@@ -20,11 +20,4 @@ object AuthPrefs {
}
}
- @JvmStatic
- fun shouldIncludeAndroidId(context: Context): Boolean {
- return SettingsContract.getSettings(context, Auth.getContentUri(context), arrayOf(Auth.INCLUDE_ANDROID_ID)) { c ->
- c.getInt(0) != 0
- }
- }
-
}
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/auth/appcert/AppCertManager.kt b/play-services-core/src/main/kotlin/org/microg/gms/auth/appcert/AppCertManager.kt
index c99b3cc3..8e5d5036 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/auth/appcert/AppCertManager.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/auth/appcert/AppCertManager.kt
@@ -29,8 +29,8 @@ import org.microg.gms.gcm.RegisterRequest
import org.microg.gms.gcm.completeRegisterRequest
import org.microg.gms.profile.Build
import org.microg.gms.profile.ProfileManager
-import org.microg.gms.settings.SettingsContract.CheckIn
-import org.microg.gms.settings.SettingsContract.getSettings
+import org.microg.mgms.settings.SettingsContract.CheckIn
+import org.microg.mgms.settings.SettingsContract.getSettings
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
import kotlin.random.Random
@@ -97,11 +97,7 @@ class AppCertManager(private val context: Context) {
}
override fun deliverError(error: VolleyError) {
- if (error.networkResponse != null) {
- Log.d(TAG, "Error: ${Base64.encodeToString(error.networkResponse.data, 2)}")
- } else {
- Log.d(TAG, "Error: ${error.message}")
- }
+ Log.d(TAG, "Error: ${Base64.encodeToString(error.networkResponse.data, 2)}")
deviceKeyCacheTime = 0
deferredResponse.complete(null)
}
@@ -154,12 +150,11 @@ class AppCertManager(private val context: Context) {
)
} else {
Log.d(TAG, "Using fallback spatula header based on Android ID")
- val androidId = getSettings(context, CheckIn.getContentUri(context), arrayOf(CheckIn.ANDROID_ID)) { cursor: Cursor -> cursor.getLong(0) }
+ val androidId = getSettings(context, CheckIn.getContentUri(context), arrayOf(CheckIn.ANDROID_ID, CheckIn.SECURITY_TOKEN)) { cursor: Cursor -> cursor.getLong(0) }
SpatulaHeaderProto(
packageInfo = SpatulaHeaderProto.PackageInfo(packageName, packageCertificateHash),
deviceId = androidId
)
- return null // TODO
}
Log.d(TAG, "Spatula Header: $proto")
return Base64.encodeToString(proto.encode(), Base64.NO_WRAP)
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/auth/appcert/AppCertService.kt b/play-services-core/src/main/kotlin/org/microg/gms/auth/appcert/AppCertService.kt
index 9b14af49..e73017e2 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/auth/appcert/AppCertService.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/auth/appcert/AppCertService.kt
@@ -38,5 +38,5 @@ class AppCertServiceImpl(private val context: Context) : IAppCertService.Stub()
return runBlocking { manager.getSpatulaHeader(packageName) }
}
- override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags, TAG) { super.onTransact(code, data, reply, flags) }
+ override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags) { super.onTransact(code, data, reply, flags) }
}
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/auth/credentials/CredentialsService.kt b/play-services-core/src/main/kotlin/org/microg/gms/auth/credentials/CredentialsService.kt
index 4e933426..adc0370b 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/auth/credentials/CredentialsService.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/auth/credentials/CredentialsService.kt
@@ -52,5 +52,5 @@ class CredentialsServiceImpl : ICredentialsService.Stub() {
callbacks.onStatus(Status.SUCCESS)
}
- override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags, TAG) { super.onTransact(code, data, reply, flags) }
+ override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags) { super.onTransact(code, data, reply, flags) }
}
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/auth/proxy/AuthProxyService.kt b/play-services-core/src/main/kotlin/org/microg/gms/auth/proxy/AuthProxyService.kt
index ede33d26..e1cedd59 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/auth/proxy/AuthProxyService.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/auth/proxy/AuthProxyService.kt
@@ -59,5 +59,5 @@ class AuthServiceImpl(private val context: Context, private val lifecycle: Lifec
override fun getLifecycle(): Lifecycle = lifecycle
- override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags, TAG) { super.onTransact(code, data, reply, flags) }
+ override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags) { super.onTransact(code, data, reply, flags) }
}
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/checkin/CheckinPreferences.kt b/play-services-core/src/main/kotlin/org/microg/gms/checkin/CheckinPrefs.kt
similarity index 51%
rename from play-services-core/src/main/kotlin/org/microg/gms/checkin/CheckinPreferences.kt
rename to play-services-core/src/main/kotlin/org/microg/gms/checkin/CheckinPrefs.kt
index eb78d498..2953ed60 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/checkin/CheckinPreferences.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/checkin/CheckinPrefs.kt
@@ -5,21 +5,16 @@
package org.microg.gms.checkin
import android.content.Context
-import android.content.Intent
-import org.microg.gms.settings.SettingsContract
-import org.microg.gms.settings.SettingsContract.CheckIn
-import org.microg.gms.settings.SettingsContract.setSettings
+import org.microg.mgms.settings.SettingsContract
+import org.microg.mgms.settings.SettingsContract.CheckIn
+import org.microg.mgms.settings.SettingsContract.setSettings
-object CheckinPreferences {
+object CheckinPrefs {
@JvmStatic
fun isEnabled(context: Context): Boolean {
val projection = arrayOf(CheckIn.ENABLED)
- return SettingsContract.getSettings(
- context,
- CheckIn.getContentUri(context),
- projection
- ) { c ->
+ return SettingsContract.getSettings(context, CheckIn.getContentUri(context), projection) { c ->
c.getInt(0) != 0
}
}
@@ -27,11 +22,7 @@ object CheckinPreferences {
@JvmStatic
fun isSpoofingEnabled(context: Context): Boolean {
val projection = arrayOf(CheckIn.BRAND_SPOOF)
- return SettingsContract.getSettings(
- context,
- CheckIn.getContentUri(context),
- projection
- ) { c ->
+ return SettingsContract.getSettings(context, CheckIn.getContentUri(context), projection) { c ->
c.getInt(0) != 0
}
}
@@ -50,13 +41,4 @@ object CheckinPreferences {
}
}
- @JvmStatic
- fun setEnabled(context: Context, enabled: Boolean) {
- SettingsContract.setSettings(context, CheckIn.getContentUri(context)) {
- put(CheckIn.ENABLED, enabled)
- }
- if (enabled) {
- context.sendOrderedBroadcast(Intent(context, TriggerReceiver::class.java), null)
- }
- }
-}
\ No newline at end of file
+}
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/checkin/LastCheckinInfo.kt b/play-services-core/src/main/kotlin/org/microg/gms/checkin/LastCheckinInfo.kt
index ab2dc042..b3056893 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/checkin/LastCheckinInfo.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/checkin/LastCheckinInfo.kt
@@ -16,8 +16,8 @@
package org.microg.gms.checkin
import android.content.Context
-import org.microg.gms.settings.SettingsContract
-import org.microg.gms.settings.SettingsContract.CheckIn
+import org.microg.mgms.settings.SettingsContract
+import org.microg.mgms.settings.SettingsContract.CheckIn
data class LastCheckinInfo(
val lastCheckin: Long,
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/checkin/ServiceInfo.kt b/play-services-core/src/main/kotlin/org/microg/gms/checkin/ServiceInfo.kt
index d42c9e03..1637643b 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/checkin/ServiceInfo.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/checkin/ServiceInfo.kt
@@ -9,9 +9,9 @@ import android.content.Context
import android.content.Intent
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
-import org.microg.gms.settings.SettingsContract.CheckIn
-import org.microg.gms.settings.SettingsContract.getSettings
-import org.microg.gms.settings.SettingsContract.setSettings
+import org.microg.mgms.settings.SettingsContract.CheckIn
+import org.microg.mgms.settings.SettingsContract.getSettings
+import org.microg.mgms.settings.SettingsContract.setSettings
import java.io.Serializable
data class ServiceInfo(val configuration: ServiceConfiguration, val lastCheckin: Long, val androidId: Long) : Serializable
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/gcm/GcmPrefs.kt b/play-services-core/src/main/kotlin/org/microg/gms/gcm/GcmPrefs.kt
index c506ed62..b2402779 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/gcm/GcmPrefs.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/gcm/GcmPrefs.kt
@@ -8,11 +8,10 @@ import android.net.ConnectivityManager
import android.net.NetworkInfo
import android.util.Log
import org.microg.gms.gcm.TriggerReceiver.FORCE_TRY_RECONNECT
-import org.microg.gms.settings.SettingsContract
-import org.microg.gms.settings.SettingsContract.Gcm
-import org.microg.gms.settings.SettingsContract.setSettings
-import kotlin.math.max
-import kotlin.math.min
+import org.microg.mgms.settings.SettingsContract
+import org.microg.mgms.settings.SettingsContract.Gcm
+import org.microg.mgms.settings.SettingsContract.setSettings
+import org.microg.mgms.settings.SettingsProvider
data class GcmPrefs(
val isGcmLogEnabled: Boolean,
@@ -38,9 +37,6 @@ data class GcmPrefs(
const val PREF_NETWORK_ROAMING = Gcm.NETWORK_ROAMING
const val PREF_NETWORK_OTHER = Gcm.NETWORK_OTHER
- private const val MIN_INTERVAL = 5 * 60 * 1000 // 5 minutes
- private const val MAX_INTERVAL = 15 * 60 * 1000 // 15 minutes
-
@JvmStatic
fun get(context: Context): GcmPrefs {
return SettingsContract.getSettings(context, Gcm.getContentUri(context), Gcm.PROJECTION) { c ->
@@ -71,15 +67,6 @@ data class GcmPrefs(
gcmPrefs.setEnabled(context, config.enabled)
}
- fun setEnabled(context: Context, enabled: Boolean) {
- val prefs = get(context)
- setSettings(context, Gcm.getContentUri(context)) {
- put(Gcm.ENABLE_GCM, enabled)
- }
- prefs.setEnabled(context, enabled)
- }
-
-
@JvmStatic
fun clearLastPersistedId(context: Context) {
setSettings(context, Gcm.getContentUri(context)) {
@@ -88,7 +75,6 @@ data class GcmPrefs(
}
}
-
/**
* Call this whenever the enabled state of GCM has changed.
*/
@@ -102,7 +88,6 @@ data class GcmPrefs(
}
}
- @Suppress("DEPRECATION")
fun getNetworkPrefForInfo(info: NetworkInfo?): String {
if (info == null) return PREF_NETWORK_OTHER
return if (info.isRoaming) PREF_NETWORK_ROAMING else when (info.type) {
@@ -112,20 +97,19 @@ data class GcmPrefs(
}
}
- @Suppress("DEPRECATION")
fun getHeartbeatMsFor(info: NetworkInfo?): Int {
return getHeartbeatMsFor(getNetworkPrefForInfo(info))
}
fun getHeartbeatMsFor(pref: String): Int {
return if (PREF_NETWORK_ROAMING == pref) {
- if (networkRoaming != 0) networkRoaming * 60000 else learntMobileInterval
+ if (networkRoaming != 0) networkRoaming * SettingsProvider.INTERVAL else learntMobileInterval
} else if (PREF_NETWORK_MOBILE == pref) {
- if (networkMobile != 0) networkMobile * 60000 else learntMobileInterval
+ if (networkMobile != 0) networkMobile * SettingsProvider.INTERVAL else learntMobileInterval
} else if (PREF_NETWORK_WIFI == pref) {
- if (networkWifi != 0) networkWifi * 60000 else learntWifiInterval
+ if (networkWifi != 0) networkWifi * SettingsProvider.INTERVAL else learntWifiInterval
} else {
- if (networkOther != 0) networkOther * 60000 else learntOtherInterval
+ if (networkOther != 0) networkOther * SettingsProvider.INTERVAL else learntOtherInterval
}
}
@@ -134,15 +118,15 @@ data class GcmPrefs(
when (pref) {
PREF_NETWORK_MOBILE, PREF_NETWORK_ROAMING -> setSettings(context, Gcm.getContentUri(context)) {
val newInterval = (learntMobileInterval * 0.95).toInt()
- put(Gcm.LEARNT_MOBILE, max(MIN_INTERVAL, min(newInterval, MAX_INTERVAL)))
+ put(Gcm.LEARNT_MOBILE, newInterval)
}
PREF_NETWORK_WIFI -> setSettings(context, Gcm.getContentUri(context)) {
- val newInterval = (learntWifiInterval * 0.95).toInt()
- put(Gcm.LEARNT_WIFI, max(MIN_INTERVAL, min(newInterval, MAX_INTERVAL)))
+ val newInterval = (learntMobileInterval * 0.95).toInt()
+ put(Gcm.LEARNT_WIFI, newInterval)
}
else -> setSettings(context, Gcm.getContentUri(context)) {
- val newInterval = (learntOtherInterval * 0.95).toInt()
- put(Gcm.LEARNT_OTHER, max(MIN_INTERVAL, min(newInterval, MAX_INTERVAL)))
+ val newInterval = (learntMobileInterval * 0.95).toInt()
+ put(Gcm.LEARNT_OTHER, newInterval)
}
}
}
@@ -152,32 +136,28 @@ data class GcmPrefs(
when (pref) {
PREF_NETWORK_MOBILE, PREF_NETWORK_ROAMING -> {
if (time > learntMobileInterval / 4 * 3) {
- val newInterval = (learntMobileInterval * 1.02).toInt()
setSettings(context, Gcm.getContentUri(context)) {
- put(Gcm.LEARNT_MOBILE, max(MIN_INTERVAL, min(newInterval, MAX_INTERVAL)))
+ put(Gcm.LEARNT_MOBILE, SettingsProvider.INTERVAL)
}
}
}
PREF_NETWORK_WIFI -> {
if (time > learntWifiInterval / 4 * 3) {
- val newInterval = (learntWifiInterval * 1.02).toInt()
setSettings(context, Gcm.getContentUri(context)) {
- put(Gcm.LEARNT_WIFI, max(MIN_INTERVAL, min(newInterval, MAX_INTERVAL)))
+ put(Gcm.LEARNT_WIFI, SettingsProvider.INTERVAL)
}
}
}
else -> {
if (time > learntOtherInterval / 4 * 3) {
- val newInterval = (learntOtherInterval * 1.02).toInt()
setSettings(context, Gcm.getContentUri(context)) {
- put(Gcm.LEARNT_OTHER, max(MIN_INTERVAL, min(newInterval, MAX_INTERVAL)))
+ put(Gcm.LEARNT_OTHER, SettingsProvider.INTERVAL)
}
}
}
}
}
- @Suppress("DEPRECATION")
fun isEnabledFor(info: NetworkInfo?): Boolean {
return isEnabled && info != null && getHeartbeatMsFor(info) >= 0
}
@@ -188,4 +168,5 @@ data class GcmPrefs(
put(Gcm.LAST_PERSISTENT_ID, newId)
}
}
+
}
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt b/play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt
index 8d3b9a78..d3e519bd 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt
@@ -16,7 +16,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleService
import androidx.lifecycle.lifecycleScope
-import org.microg.gms.checkin.CheckinPreferences
+import org.microg.gms.checkin.CheckinPrefs
import org.microg.gms.checkin.CheckinService
import org.microg.gms.checkin.LastCheckinInfo
import org.microg.gms.common.ForegroundServiceContext
@@ -29,7 +29,7 @@ import kotlin.coroutines.suspendCoroutine
private const val TAG = "GmsGcmRegister"
private suspend fun ensureCheckinIsUpToDate(context: Context) {
- if (!CheckinPreferences.isEnabled(context)) throw RuntimeException("Checkin disabled")
+ if (!CheckinPrefs.isEnabled(context)) throw RuntimeException("Checkin disabled")
val lastCheckin = LastCheckinInfo.read(context).lastCheckin
if (lastCheckin < System.currentTimeMillis() - CheckinService.MAX_VALID_CHECKIN_AGE) {
val resultData: Bundle = suspendCoroutine { continuation ->
@@ -51,7 +51,7 @@ private suspend fun ensureCheckinIsUpToDate(context: Context) {
}
}
-private fun ensureAppRegistrationAllowed(context: Context, database: GcmDatabase, packageName: String) {
+private suspend fun ensureAppRegistrationAllowed(context: Context, database: GcmDatabase, packageName: String) {
if (!GcmPrefs.get(context).isEnabled) throw RuntimeException("GCM disabled")
val app = database.getApp(packageName)
if (app?.allowRegister == false) {
@@ -65,7 +65,7 @@ suspend fun completeRegisterRequest(context: Context, database: GcmDatabase, req
private val Intent.requestId: String?
get() {
- val kidString = getStringExtra(EXTRA_KID) ?: return null
+ val kidString = getStringExtra(GcmConstants.EXTRA_KID) ?: return null
if (kidString.startsWith("|")) {
val kid = kidString.split("\\|".toRegex()).toTypedArray()
if (kid.size >= 3 && "ID" == kid[1]) {
@@ -245,7 +245,7 @@ internal class PushRegisterHandler(private val context: Context, private val dat
get() {
val intent = Intent()
intent.setPackage("com.google.example.invalidpackage")
- return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_IMMUTABLE)
+ return PendingIntent.getBroadcast(context, 0, intent, 0)
}
override fun handleMessage(msg: Message) {
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/AppHeadingPreference.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/AppHeadingPreference.kt
deleted file mode 100644
index c3cf6185..00000000
--- a/play-services-core/src/main/kotlin/org/microg/gms/ui/AppHeadingPreference.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-package org.microg.gms.ui
-import android.content.Context
-import android.content.Intent
-import android.content.pm.ApplicationInfo
-import android.net.Uri
-import android.provider.Settings
-import android.util.AttributeSet
-import android.util.Log
-import android.view.View
-import android.widget.ImageView
-import androidx.appcompat.content.res.AppCompatResources
-import androidx.preference.Preference
-import androidx.preference.PreferenceViewHolder
-import org.microg.gms.base.core.R
-class AppHeadingPreference : AppPreference, Preference.OnPreferenceClickListener {
- constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
- constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
- constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
- constructor(context: Context) : super(context)
- init {
- layoutResource = R.layout.preference_app_heading
- onPreferenceClickListener = this
- }
- override fun onPreferenceClick(preference: Preference): Boolean {
- if (packageName != null) {
- val intent = Intent()
- intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
- val uri: Uri = Uri.fromParts("package", packageName, null)
- intent.data = uri
- try {
- context.startActivity(intent)
- } catch (e: Exception) {
- Log.w(TAG, "Failed to launch app", e)
- }
- return true
- } else {
- return false
- }
- }
-}
\ No newline at end of file
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/AppIconPreference.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/AppIconPreference.kt
index 1570c691..ef30f876 100755
--- a/play-services-core/src/main/kotlin/org/microg/gms/ui/AppIconPreference.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/AppIconPreference.kt
@@ -11,10 +11,10 @@ import android.util.DisplayMetrics
import android.widget.ImageView
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
-import android.content.pm.ApplicationInfo
-class AppIconPreference : AppPreference {
- constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
+class AppIconPreference : Preference {
+ constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(
+ context, attrs, defStyleAttr, defStyleRes)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context) : super(context)
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/AppPreference.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/AppPreference.kt
deleted file mode 100644
index 27626231..00000000
--- a/play-services-core/src/main/kotlin/org/microg/gms/ui/AppPreference.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 microG Project Team
- * SPDX-License-Identifier: Apache-2.0
- */
-package org.microg.gms.ui
-import android.content.Context
-import android.content.pm.ApplicationInfo
-import android.util.AttributeSet
-import androidx.appcompat.content.res.AppCompatResources
-import androidx.preference.Preference
-abstract class AppPreference : Preference {
- constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
- constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
- constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
- constructor(context: Context) : super(context)
- init {
- isPersistent = false
- }
- private var packageNameField: String? = null
- var applicationInfo: ApplicationInfo?
- get() = context.packageManager.getApplicationInfoIfExists(packageNameField)
- set(value) {
- if (value == null && packageNameField != null) {
- title = null
- icon = null
- } else if (value != null) {
- val pm = context.packageManager
- title = value.loadLabel(pm) ?: value.packageName
- icon = value.loadIcon(pm) ?: AppCompatResources.getDrawable(context, android.R.mipmap.sym_def_app_icon)
- }
- packageNameField = value?.packageName
- }
- var packageName: String?
- get() = packageNameField
- set(value) {
- if (value == null && packageNameField != null) {
- title = null
- icon = null
- } else if (value != null) {
- val pm = context.packageManager
- val applicationInfo = pm.getApplicationInfoIfExists(value)
- title = applicationInfo?.loadLabel(pm)?.toString() ?: value
- icon = applicationInfo?.loadIcon(pm) ?: AppCompatResources.getDrawable(context, android.R.mipmap.sym_def_app_icon)
- }
- packageNameField = value
- }
-}
\ No newline at end of file
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/DeviceRegistrationFragment.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/DeviceRegistrationFragment.kt
index 8c668529..17887575 100755
--- a/play-services-core/src/main/kotlin/org/microg/gms/ui/DeviceRegistrationFragment.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/DeviceRegistrationFragment.kt
@@ -5,163 +5,51 @@
package org.microg.gms.ui
-
-import android.annotation.SuppressLint
-import android.net.Uri
import android.os.Bundle
-import android.os.Handler
-import android.text.format.DateUtils
-import android.util.Log
-import androidx.activity.result.ActivityResultLauncher
-import androidx.activity.result.contract.ActivityResultContracts
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
-import androidx.preference.ListPreference
-import androidx.preference.Preference
-import androidx.preference.PreferenceCategory
-import androidx.preference.PreferenceFragmentCompat
import com.mgoogle.android.gms.R
-import org.microg.gms.checkin.CheckinPreferences
+import com.mgoogle.android.gms.databinding.DeviceRegistrationFragmentBinding
+import org.microg.gms.checkin.ServiceInfo
import org.microg.gms.checkin.getCheckinServiceInfo
-import org.microg.gms.profile.ProfileManager
-import org.microg.gms.profile.ProfileManager.PROFILE_AUTO
-import org.microg.gms.profile.ProfileManager.PROFILE_NATIVE
-import org.microg.gms.profile.ProfileManager.PROFILE_REAL
-import org.microg.gms.profile.ProfileManager.PROFILE_SYSTEM
-import org.microg.gms.profile.ProfileManager.PROFILE_USER
-import java.io.File
-import java.io.FileOutputStream
+import org.microg.gms.checkin.setCheckinServiceConfiguration
-class DeviceRegistrationFragment : PreferenceFragmentCompat() {
- private lateinit var switchBarPreference: SwitchBarPreference
- private lateinit var deviceProfile: ListPreference
- private lateinit var importProfile: Preference
- private lateinit var serial: Preference
- private lateinit var statusCategory: PreferenceCategory
- private lateinit var status: Preference
- private lateinit var androidId: Preference
- private val handler = Handler()
- private val updateRunnable = Runnable { updateStatus() }
- private lateinit var profileFileImport: ActivityResultLauncher
+class DeviceRegistrationFragment : Fragment(R.layout.device_registration_fragment) {
+ private lateinit var binding: DeviceRegistrationFragmentBinding
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- profileFileImport = registerForActivityResult(ActivityResultContracts.GetContent(), this::onFileSelected)
- }
- private fun onFileSelected(uri: Uri?) {
- if (uri == null) return
- try {
- val context = requireContext()
- val file = File.createTempFile("profile_", ".xml", context.cacheDir)
- context.contentResolver.openInputStream(uri)?.use { inputStream ->
- FileOutputStream(file).use { inputStream.copyTo(it) }
- }
- val success = ProfileManager.importUserProfile(context, file)
- file.delete()
- if (success && ProfileManager.isAutoProfile(context, PROFILE_USER)) {
- ProfileManager.setProfile(context, PROFILE_USER)
- }
- updateStatus()
- } catch (e: Exception) {
- Log.w(TAG, e)
- }
- }
- override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
- addPreferencesFromResource(R.xml.preferences_device_registration)
- }
- @SuppressLint("RestrictedApi")
- override fun onBindPreferences() {
- switchBarPreference = preferenceScreen.findPreference("pref_checkin_enabled") ?: switchBarPreference
- deviceProfile = preferenceScreen.findPreference("pref_device_profile") ?: deviceProfile
- importProfile = preferenceScreen.findPreference("pref_device_profile_import") ?: importProfile
- serial = preferenceScreen.findPreference("pref_device_serial") ?: serial
- statusCategory = preferenceScreen.findPreference("prefcat_device_registration_status") ?: statusCategory
- status = preferenceScreen.findPreference("pref_device_registration_status") ?: status
- androidId = preferenceScreen.findPreference("pref_device_registration_android_id") ?: androidId
- deviceProfile.setOnPreferenceChangeListener { _, newValue ->
- ProfileManager.setProfile(requireContext(), newValue as String? ?: PROFILE_AUTO)
- updateStatus()
- true
- }
- importProfile.setOnPreferenceClickListener {
- profileFileImport.launch("text/xml")
- true
- }
- switchBarPreference.setOnPreferenceChangeListener { _, newValue ->
- val newStatus = newValue as Boolean
- CheckinPreferences.setEnabled(requireContext(), newStatus)
- true
- }
- }
- private fun configureProfilePreference() {
- val context = requireContext()
- val configuredProfile = ProfileManager.getConfiguredProfile(context)
- val autoProfile = ProfileManager.getAutoProfile(context)
- val autoProfileName = when (autoProfile) {
- PROFILE_NATIVE -> getString(R.string.profile_name_native)
- PROFILE_REAL -> getString(R.string.profile_name_real)
- else -> ProfileManager.getProfileName(context, autoProfile)
- }
- val profiles =
- mutableListOf(PROFILE_AUTO, PROFILE_NATIVE, PROFILE_REAL)
- val profileNames = mutableListOf(getString(R.string.profile_name_auto, autoProfileName), getString(R.string.profile_name_native), getString(R.string.profile_name_real))
- if (ProfileManager.hasProfile(context, PROFILE_SYSTEM)) {
- profiles.add(PROFILE_SYSTEM)
- profileNames.add(getString(R.string.profile_name_system, ProfileManager.getProfileName(context, PROFILE_SYSTEM)))
- }
- if (ProfileManager.hasProfile(context, PROFILE_USER)) {
- profiles.add(PROFILE_USER)
- profileNames.add(getString(R.string.profile_name_user, ProfileManager.getProfileName(context, PROFILE_USER)))
- }
- for (profile in R.xml::class.java.declaredFields.map { it.name }
- .filter { it.startsWith("profile_") }
- .map { it.substring(8) }
- .sorted()) {
- val profileName = ProfileManager.getProfileName(context, profile)
- if (profileName != null) {
- profiles.add(profile)
- profileNames.add(profileName)
+ override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ binding = DeviceRegistrationFragmentBinding.inflate(inflater, container, false)
+ binding.switchBarCallback = object : PreferenceSwitchBarCallback {
+ override fun onChecked(newStatus: Boolean) {
+ setEnabled(newStatus)
}
}
- deviceProfile.entryValues = profiles.toTypedArray()
- deviceProfile.entries = profileNames.toTypedArray()
- deviceProfile.value = configuredProfile
- deviceProfile.summary =
- profiles.indexOf(configuredProfile).takeIf { it >= 0 }?.let { profileNames[it] } ?: "Unknown"
+ return binding.root
+ }
+
+ fun setEnabled(newStatus: Boolean) {
+ val appContext = requireContext().applicationContext
+ lifecycleScope.launchWhenResumed {
+ val info = getCheckinServiceInfo(appContext)
+ val newConfiguration = info.configuration.copy(enabled = newStatus)
+ setCheckinServiceConfiguration(appContext, newConfiguration)
+ displayServiceInfo(info.copy(configuration = newConfiguration))
+ }
+ }
+
+ private fun displayServiceInfo(serviceInfo: ServiceInfo) {
+ binding.checkinEnabled = serviceInfo.configuration.enabled
}
override fun onResume() {
super.onResume()
- switchBarPreference.isChecked = CheckinPreferences.isEnabled(requireContext())
- updateStatus()
- }
- override fun onPause() {
- super.onPause()
- handler.removeCallbacks(updateRunnable)
- }
- private fun updateStatus() {
- handler.removeCallbacks(updateRunnable)
- handler.postDelayed(updateRunnable, UPDATE_INTERVAL)
val appContext = requireContext().applicationContext
lifecycleScope.launchWhenResumed {
- configureProfilePreference()
- serial.summary = ProfileManager.getSerial(appContext)
- val serviceInfo = getCheckinServiceInfo(appContext)
- statusCategory.isVisible = serviceInfo.configuration.enabled
- if (serviceInfo.lastCheckin > 0) {
- status.summary = getString(
- R.string.checkin_last_registration,
- DateUtils.getRelativeTimeSpanString(serviceInfo.lastCheckin, System.currentTimeMillis(), 0)
- )
- androidId.isVisible = true
- androidId.summary = serviceInfo.androidId.toString(16)
- } else {
- status.summary = getString(R.string.checkin_not_registered)
- androidId.isVisible = false
- }
+ displayServiceInfo(getCheckinServiceInfo(appContext))
}
}
- companion object {
- private const val UPDATE_INTERVAL = 1000L
- }
}
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/DeviceRegistrationPreferencesFragment.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/DeviceRegistrationPreferencesFragment.kt
new file mode 100755
index 00000000..a0b4ad13
--- /dev/null
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/DeviceRegistrationPreferencesFragment.kt
@@ -0,0 +1,164 @@
+/*
+ * SPDX-FileCopyrightText: 2020, microG Project Team
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.microg.gms.ui
+
+import android.annotation.SuppressLint
+import android.net.Uri
+import android.os.Bundle
+import android.os.Handler
+import android.text.format.DateUtils
+import android.util.Log
+import androidx.activity.result.ActivityResultLauncher
+import androidx.activity.result.contract.ActivityResultContracts
+import androidx.lifecycle.lifecycleScope
+import androidx.preference.ListPreference
+import androidx.preference.Preference
+import androidx.preference.PreferenceCategory
+import androidx.preference.PreferenceFragmentCompat
+import com.mgoogle.android.gms.R
+import org.microg.gms.checkin.getCheckinServiceInfo
+import org.microg.gms.profile.ProfileManager
+import org.microg.gms.profile.ProfileManager.PROFILE_AUTO
+import org.microg.gms.profile.ProfileManager.PROFILE_NATIVE
+import org.microg.gms.profile.ProfileManager.PROFILE_REAL
+import org.microg.gms.profile.ProfileManager.PROFILE_SYSTEM
+import org.microg.gms.profile.ProfileManager.PROFILE_USER
+import java.io.File
+import java.io.FileOutputStream
+
+@Suppress("Warnings")
+class DeviceRegistrationPreferencesFragment : PreferenceFragmentCompat() {
+ private lateinit var deviceProfile: ListPreference
+ private lateinit var importProfile: Preference
+ private lateinit var serial: Preference
+ private lateinit var statusCategory: PreferenceCategory
+ private lateinit var status: Preference
+ private lateinit var androidId: Preference
+ private val handler = Handler()
+ private val updateRunnable = Runnable { updateStatus() }
+ private lateinit var profileFileImport: ActivityResultLauncher
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ profileFileImport = registerForActivityResult(ActivityResultContracts.GetContent(), this::onFileSelected)
+ }
+
+ private fun onFileSelected(uri: Uri?) {
+ if (uri == null) return
+ try {
+ val context = requireContext()
+ val file = File.createTempFile("profile_", ".xml", context.cacheDir)
+ context.contentResolver.openInputStream(uri)?.use { inputStream ->
+ FileOutputStream(file).use { inputStream.copyTo(it) }
+ }
+ val success = ProfileManager.importUserProfile(context, file)
+ file.delete()
+ if (success && ProfileManager.isAutoProfile(context, PROFILE_USER)) {
+ ProfileManager.setProfile(context, PROFILE_USER)
+ }
+ updateStatus()
+ } catch (e: Exception) {
+ Log.w(TAG, e)
+ }
+ }
+
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+ addPreferencesFromResource(R.xml.preferences_device_registration)
+ }
+
+ @SuppressLint("RestrictedApi")
+ override fun onBindPreferences() {
+ deviceProfile = preferenceScreen.findPreference("pref_device_profile") ?: deviceProfile
+ importProfile = preferenceScreen.findPreference("pref_device_profile_import") ?: importProfile
+ serial = preferenceScreen.findPreference("pref_device_serial") ?: serial
+ statusCategory = preferenceScreen.findPreference("prefcat_device_registration_status") ?: statusCategory
+ status = preferenceScreen.findPreference("pref_device_registration_status") ?: status
+ androidId = preferenceScreen.findPreference("pref_device_registration_android_id") ?: androidId
+
+ deviceProfile.setOnPreferenceChangeListener { _, newValue ->
+ ProfileManager.setProfile(requireContext(), newValue as String? ?: PROFILE_AUTO)
+ updateStatus()
+ true
+ }
+ importProfile.setOnPreferenceClickListener {
+ profileFileImport.launch("text/xml")
+ true
+ }
+ }
+
+ private fun configureProfilePreference() {
+ val context = requireContext()
+ val configuredProfile = ProfileManager.getConfiguredProfile(context)
+ val autoProfileName = when (val autoProfile = ProfileManager.getAutoProfile(context)) {
+ PROFILE_NATIVE -> getString(R.string.profile_name_native)
+ PROFILE_REAL -> getString(R.string.profile_name_real)
+ else -> ProfileManager.getProfileName(context, autoProfile)
+ }
+ val profiles =
+ mutableListOf(PROFILE_AUTO, PROFILE_NATIVE, PROFILE_REAL)
+ val profileNames = mutableListOf(getString(R.string.profile_name_auto, autoProfileName), getString(R.string.profile_name_native), getString(R.string.profile_name_real))
+ if (ProfileManager.hasProfile(context, PROFILE_SYSTEM)) {
+ profiles.add(PROFILE_SYSTEM)
+ profileNames.add(getString(R.string.profile_name_system, ProfileManager.getProfileName(context, PROFILE_SYSTEM)))
+ }
+ if (ProfileManager.hasProfile(context, PROFILE_USER)) {
+ profiles.add(PROFILE_USER)
+ profileNames.add(getString(R.string.profile_name_user, ProfileManager.getProfileName(context, PROFILE_USER)))
+ }
+ for (profile in R.xml::class.java.declaredFields.map { it.name }
+ .filter { it.startsWith("profile_") }
+ .map { it.substring(8) }
+ .sorted()) {
+ val profileName = ProfileManager.getProfileName(context, profile)
+ if (profileName != null) {
+ profiles.add(profile)
+ profileNames.add(profileName)
+ }
+ }
+ deviceProfile.entryValues = profiles.toTypedArray()
+ deviceProfile.entries = profileNames.toTypedArray()
+ deviceProfile.value = configuredProfile
+ deviceProfile.summary =
+ profiles.indexOf(configuredProfile).takeIf { it >= 0 }?.let { profileNames[it] } ?: "Unknown"
+ }
+
+ override fun onResume() {
+ super.onResume()
+ updateStatus()
+ }
+
+ override fun onPause() {
+ super.onPause()
+ handler.removeCallbacks(updateRunnable)
+ }
+
+ private fun updateStatus() {
+ handler.removeCallbacks(updateRunnable)
+ handler.postDelayed(updateRunnable, UPDATE_INTERVAL)
+ val appContext = requireContext().applicationContext
+ lifecycleScope.launchWhenResumed {
+ configureProfilePreference()
+ serial.summary = ProfileManager.getSerial(appContext)
+ val serviceInfo = getCheckinServiceInfo(appContext)
+ statusCategory.isVisible = serviceInfo.configuration.enabled
+ if (serviceInfo.lastCheckin > 0) {
+ status.summary = getString(
+ R.string.checkin_last_registration,
+ DateUtils.getRelativeTimeSpanString(serviceInfo.lastCheckin, System.currentTimeMillis(), 0)
+ )
+ androidId.isVisible = true
+ androidId.summary = serviceInfo.androidId.toString(16)
+ } else {
+ status.summary = getString(R.string.checkin_not_registered)
+ androidId.isVisible = false
+ }
+ }
+ }
+
+ companion object {
+ private const val UPDATE_INTERVAL = 1000L
+ }
+}
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/PreferenceSwitchBarCallback.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/PreferenceSwitchBarCallback.kt
new file mode 100755
index 00000000..b66f1119
--- /dev/null
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/PreferenceSwitchBarCallback.kt
@@ -0,0 +1,10 @@
+/*
+ * SPDX-FileCopyrightText: 2020, microG Project Team
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.microg.gms.ui
+
+interface PreferenceSwitchBarCallback {
+ fun onChecked(newStatus: Boolean)
+}
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAdvancedFragment.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAdvancedFragment.kt
index 55b730f6..d3cef96f 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAdvancedFragment.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAdvancedFragment.kt
@@ -14,7 +14,7 @@ import com.mgoogle.android.gms.R
import org.microg.gms.gcm.GcmPrefs
import org.microg.gms.gcm.getGcmServiceInfo
import org.microg.gms.gcm.setGcmServiceConfiguration
-import org.microg.gms.settings.SettingsProvider
+import org.microg.mgms.settings.SettingsProvider
class PushNotificationAdvancedFragment : PreferenceFragmentCompat() {
private lateinit var networkMobile: ListPreference
@@ -37,7 +37,7 @@ class PushNotificationAdvancedFragment : PreferenceFragmentCompat() {
val appContext = requireContext().applicationContext
lifecycleScope.launchWhenResumed {
(newValue as? String)?.toIntOrNull()?.let {
- setGcmServiceConfiguration(appContext, getGcmServiceInfo(appContext).configuration.copy(mobile = it))
+ setGcmServiceConfiguration(requireContext(), getGcmServiceInfo(appContext).configuration.copy(mobile = it))
}
updateContent()
}
@@ -47,7 +47,7 @@ class PushNotificationAdvancedFragment : PreferenceFragmentCompat() {
val appContext = requireContext().applicationContext
lifecycleScope.launchWhenResumed {
(newValue as? String)?.toIntOrNull()?.let {
- setGcmServiceConfiguration(appContext, getGcmServiceInfo(appContext).configuration.copy(wifi = it))
+ setGcmServiceConfiguration(appContext, getGcmServiceInfo(requireContext()).configuration.copy(wifi = it))
}
updateContent()
}
@@ -57,7 +57,7 @@ class PushNotificationAdvancedFragment : PreferenceFragmentCompat() {
val appContext = requireContext().applicationContext
lifecycleScope.launchWhenResumed {
(newValue as? String)?.toIntOrNull()?.let {
- setGcmServiceConfiguration(appContext, getGcmServiceInfo(appContext).configuration.copy(roaming = it))
+ setGcmServiceConfiguration(appContext, getGcmServiceInfo(requireContext()).configuration.copy(roaming = it))
}
updateContent()
}
@@ -67,7 +67,7 @@ class PushNotificationAdvancedFragment : PreferenceFragmentCompat() {
val appContext = requireContext().applicationContext
lifecycleScope.launchWhenResumed {
(newValue as? String)?.toIntOrNull()?.let {
- setGcmServiceConfiguration(appContext, getGcmServiceInfo(appContext).configuration.copy(other = it))
+ setGcmServiceConfiguration(appContext, getGcmServiceInfo(requireContext()).configuration.copy(other = it))
}
updateContent()
}
@@ -98,13 +98,13 @@ class PushNotificationAdvancedFragment : PreferenceFragmentCompat() {
private fun getSummaryString(value: Int, learnt: Int): String = when (value) {
-1 -> getString(R.string.service_status_disabled_short)
0 -> getString(R.string.service_status_enabled_short) + " / " + getString(R.string.gcm_status_pref_default) + ": " + getHeartbeatString(learnt)
- else -> getString(R.string.service_status_enabled_short) + " / " + getString(R.string.gcm_status_pref_manual) + ": " + getHeartbeatString(value * 60000)
+ else -> getString(R.string.service_status_enabled_short) + " / " + getString(R.string.gcm_status_pref_manual) + ": " + getHeartbeatString(value * SettingsProvider.INTERVAL)
}
private fun getHeartbeatString(heartbeatMs: Int): String {
return if (heartbeatMs < 120000) {
(heartbeatMs / 1000).toString() + " " + getString(R.string.gcm_status_pref_sec)
- } else (heartbeatMs / 60000).toString() + " " + getString(R.string.gcm_status_pref_min)
+ } else (heartbeatMs / SettingsProvider.INTERVAL).toString() + " " + getString(R.string.gcm_status_pref_min)
}
companion object {
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAllAppsFragment.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAllAppsFragment.kt
index 392e14d6..da3210e4 100755
--- a/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAllAppsFragment.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAllAppsFragment.kt
@@ -56,12 +56,16 @@ class PushNotificationAllAppsFragment : PreferenceFragmentCompat() {
lifecycleScope.launchWhenResumed {
val apps = withContext(Dispatchers.IO) {
val res = database.appList.map { app ->
+ app to context.packageManager.getApplicationInfoIfExists(app.packageName)
+ }.map { (app, applicationInfo) ->
val pref = AppIconPreference(context)
- pref.packageName = app.packageName
+ pref.title = applicationInfo?.loadLabel(context.packageManager) ?: app.packageName
pref.summary = when {
app.lastMessageTimestamp > 0 -> getString(R.string.gcm_last_message_at, DateUtils.getRelativeTimeSpanString(app.lastMessageTimestamp))
else -> null
}
+ pref.icon = applicationInfo?.loadIcon(context.packageManager)
+ ?: AppCompatResources.getDrawable(context, android.R.mipmap.sym_def_app_icon)
pref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
findNavController().navigate(requireContext(), R.id.openGcmAppDetailsFromAll, bundleOf(
"package" to app.packageName
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAppFragment.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAppFragment.kt
index 780e85e1..f83a5e5d 100755
--- a/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAppFragment.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAppFragment.kt
@@ -5,135 +5,58 @@
package org.microg.gms.ui
-import android.annotation.SuppressLint
+import android.content.Intent
+import android.net.Uri
import android.os.Bundle
-import android.text.format.DateUtils
-import androidx.appcompat.app.AlertDialog
+import android.provider.Settings
+import android.util.Log
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.appcompat.content.res.AppCompatResources
+import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
-import androidx.preference.Preference
-import androidx.preference.PreferenceCategory
-import androidx.preference.PreferenceFragmentCompat
-import androidx.preference.TwoStatePreference
import com.mgoogle.android.gms.R
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.withContext
-import org.microg.gms.gcm.GcmDatabase
-import org.microg.gms.gcm.PushRegisterManager
+import com.mgoogle.android.gms.databinding.PushNotificationAppFragmentBinding
-class PushNotificationAppFragment : PreferenceFragmentCompat() {
- private lateinit var appHeadingPreference: AppHeadingPreference
- private lateinit var wakeForDelivery: TwoStatePreference
- private lateinit var allowRegister: TwoStatePreference
- private lateinit var status: Preference
- private lateinit var unregister: Preference
- private lateinit var unregisterCat: PreferenceCategory
- private lateinit var database: GcmDatabase
- private val packageName: String?
+class PushNotificationAppFragment : Fragment(R.layout.push_notification_fragment) {
+ lateinit var binding: PushNotificationAppFragmentBinding
+ val packageName: String?
get() = arguments?.getString("package")
- override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
- addPreferencesFromResource(R.xml.preferences_push_notifications_app)
- }
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- database = GcmDatabase(context)
- }
-
- @SuppressLint("RestrictedApi")
- override fun onBindPreferences() {
- appHeadingPreference = preferenceScreen.findPreference("pref_push_app_heading") ?: appHeadingPreference
- wakeForDelivery = preferenceScreen.findPreference("pref_push_app_wake_for_delivery") ?: wakeForDelivery
- allowRegister = preferenceScreen.findPreference("pref_push_app_allow_register") ?: allowRegister
- unregister = preferenceScreen.findPreference("pref_push_app_unregister") ?: unregister
- unregisterCat = preferenceScreen.findPreference("prefcat_push_app_unregister") ?: unregisterCat
- status = preferenceScreen.findPreference("pref_push_app_status") ?: status
- wakeForDelivery.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
- database.setAppWakeForDelivery(packageName, newValue as Boolean)
- database.close()
- true
- }
- allowRegister.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
- val enabled = newValue as? Boolean ?: return@OnPreferenceChangeListener false
- if (!enabled) {
- val registrations = packageName?.let { database.getRegistrationsByApp(it) } ?: emptyList()
- if (registrations.isNotEmpty()) {
- showUnregisterConfirm(R.string.gcm_unregister_after_deny_message)
+ override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ binding = PushNotificationAppFragmentBinding.inflate(inflater, container, false)
+ binding.callbacks = object : PushNotificationAppFragmentCallbacks {
+ override fun onAppClicked() {
+ val intent = Intent()
+ intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
+ val uri: Uri = Uri.fromParts("package", packageName, null)
+ intent.data = uri
+ try {
+ context!!.startActivity(intent)
+ } catch (e: Exception) {
+ Log.w(TAG, "Failed to launch app", e)
}
}
- database.setAppAllowRegister(packageName, enabled)
- database.close()
- true
- }
- unregister.onPreferenceClickListener = Preference.OnPreferenceClickListener {
- showUnregisterConfirm(R.string.gcm_unregister_confirm_message)
- true
- }
- }
-
-
- private fun showUnregisterConfirm(unregisterConfirmDesc: Int) {
- val pm = requireContext().packageManager
- val applicationInfo = pm.getApplicationInfoIfExists(packageName)
- AlertDialog.Builder(requireContext())
- .setTitle(getString(R.string.gcm_unregister_confirm_title, applicationInfo?.loadLabel(pm)
- ?: packageName))
- .setMessage(unregisterConfirmDesc)
- .setPositiveButton(android.R.string.yes) { _, _ -> unregister() }
- .setNegativeButton(android.R.string.no) { _, _ -> }.show()
- }
-
- private fun unregister() {
- lifecycleScope.launchWhenResumed {
- withContext(Dispatchers.IO) {
- for (registration in database.getRegistrationsByApp(packageName)) {
- PushRegisterManager.unregister(context, registration.packageName, registration.signature, null, null)
- }
- }
- updateDetails()
}
+ childFragmentManager.findFragmentById(R.id.sub_preferences)?.arguments = arguments
+ return binding.root
}
override fun onResume() {
super.onResume()
- updateDetails()
- }
-
- private fun updateDetails() {
+ val context = requireContext()
lifecycleScope.launchWhenResumed {
- appHeadingPreference.packageName = packageName
- val app = packageName?.let { database.getApp(it) }
- wakeForDelivery.isChecked = app?.wakeForDelivery ?: true
- allowRegister.isChecked = app?.allowRegister ?: true
- val registrations = packageName?.let { database.getRegistrationsByApp(it) } ?: emptyList()
- unregisterCat.isVisible = registrations.isNotEmpty()
-
- val sb = StringBuilder()
- if ((app?.totalMessageCount ?: 0L) == 0L) {
- sb.append(getString(R.string.gcm_no_message_yet))
- } else {
- sb.append(getString(R.string.gcm_messages_counter, app?.totalMessageCount, app?.totalMessageBytes))
- if (app?.lastMessageTimestamp != 0L) {
- sb.append("\n").append(getString(R.string.gcm_last_message_at, DateUtils.getRelativeDateTimeString(context, app?.lastMessageTimestamp ?: 0L, DateUtils.MINUTE_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, DateUtils.FORMAT_SHOW_TIME)))
- }
- }
- for (registration in registrations) {
- sb.append("\n")
- if (registration.timestamp == 0L) {
- sb.append(getString(R.string.gcm_registered))
- } else {
- sb.append(getString(R.string.gcm_registered_since, DateUtils.getRelativeDateTimeString(context, registration.timestamp, DateUtils.MINUTE_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, DateUtils.FORMAT_SHOW_TIME)))
- }
- }
- status.summary = sb.toString()
-
- database.close()
+ val pm = context.packageManager
+ val applicationInfo = pm.getApplicationInfoIfExists(packageName)
+ binding.appName = applicationInfo?.loadLabel(pm)?.toString() ?: packageName
+ binding.appIcon = applicationInfo?.loadIcon(pm)
+ ?: AppCompatResources.getDrawable(context, android.R.mipmap.sym_def_app_icon)
}
}
+}
- override fun onPause() {
- super.onPause()
- database.close()
- }
-}
\ No newline at end of file
+interface PushNotificationAppFragmentCallbacks {
+ fun onAppClicked()
+}
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAppPreferencesFragment.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAppPreferencesFragment.kt
new file mode 100755
index 00000000..7106e506
--- /dev/null
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAppPreferencesFragment.kt
@@ -0,0 +1,137 @@
+/*
+ * SPDX-FileCopyrightText: 2020, microG Project Team
+ * SPDX-License-Identifier: Apache-2.0
+ */
+@file:Suppress("DEPRECATION")
+
+package org.microg.gms.ui
+
+import android.annotation.SuppressLint
+import android.os.Bundle
+import android.text.format.DateUtils
+import androidx.appcompat.app.AlertDialog
+import androidx.lifecycle.lifecycleScope
+import androidx.preference.Preference
+import androidx.preference.PreferenceCategory
+import androidx.preference.PreferenceFragmentCompat
+import androidx.preference.TwoStatePreference
+import com.mgoogle.android.gms.R
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+import org.microg.gms.gcm.GcmDatabase
+import org.microg.gms.gcm.PushRegisterManager
+
+class PushNotificationAppPreferencesFragment : PreferenceFragmentCompat() {
+ private lateinit var wakeForDelivery: TwoStatePreference
+ private lateinit var allowRegister: TwoStatePreference
+ private lateinit var status: Preference
+ private lateinit var unregister: Preference
+ private lateinit var unregisterCat: PreferenceCategory
+
+ private lateinit var database: GcmDatabase
+ private val packageName: String?
+ get() = arguments?.getString("package")
+
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+ addPreferencesFromResource(R.xml.preferences_push_notifications_app)
+ }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ database = GcmDatabase(context)
+ }
+
+ @SuppressLint("RestrictedApi")
+ override fun onBindPreferences() {
+ wakeForDelivery = preferenceScreen.findPreference("pref_push_app_wake_for_delivery") ?: wakeForDelivery
+ allowRegister = preferenceScreen.findPreference("pref_push_app_allow_register") ?: allowRegister
+ unregister = preferenceScreen.findPreference("pref_push_app_unregister") ?: unregister
+ unregisterCat = preferenceScreen.findPreference("prefcat_push_app_unregister") ?: unregisterCat
+ status = preferenceScreen.findPreference("pref_push_app_status") ?: status
+ wakeForDelivery.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
+ database.setAppWakeForDelivery(packageName, newValue as Boolean)
+ database.close()
+ true
+ }
+ allowRegister.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
+ val enabled = newValue as? Boolean ?: return@OnPreferenceChangeListener false
+ if (!enabled) {
+ val registrations = packageName?.let { database.getRegistrationsByApp(it) } ?: emptyList()
+ if (registrations.isNotEmpty()) {
+ showUnregisterConfirm(R.string.gcm_unregister_after_deny_message)
+ }
+ }
+ database.setAppAllowRegister(packageName, enabled)
+ database.close()
+ true
+ }
+ unregister.onPreferenceClickListener = Preference.OnPreferenceClickListener {
+ showUnregisterConfirm(R.string.gcm_unregister_confirm_message)
+ true
+ }
+ }
+
+
+ private fun showUnregisterConfirm(unregisterConfirmDesc: Int) {
+ val pm = requireContext().packageManager
+ val applicationInfo = pm.getApplicationInfoIfExists(packageName)
+ AlertDialog.Builder(requireContext())
+ .setTitle(getString(R.string.gcm_unregister_confirm_title, applicationInfo?.loadLabel(pm)
+ ?: packageName))
+ .setMessage(unregisterConfirmDesc)
+ .setPositiveButton(android.R.string.yes) { _, _ -> unregister() }
+ .setNegativeButton(android.R.string.no) { _, _ -> }.show()
+ }
+
+ private fun unregister() {
+ lifecycleScope.launchWhenResumed {
+ withContext(Dispatchers.IO) {
+ for (registration in database.getRegistrationsByApp(packageName)) {
+ PushRegisterManager.unregister(context, registration.packageName, registration.signature, null, null)
+ }
+ }
+ updateDetails()
+ }
+ }
+
+ override fun onResume() {
+ super.onResume()
+ updateDetails()
+ }
+
+ private fun updateDetails() {
+ lifecycleScope.launchWhenResumed {
+ val app = packageName?.let { database.getApp(it) }
+ wakeForDelivery.isChecked = app?.wakeForDelivery ?: true
+ allowRegister.isChecked = app?.allowRegister ?: true
+ val registrations = packageName?.let { database.getRegistrationsByApp(it) } ?: emptyList()
+ unregisterCat.isVisible = registrations.isNotEmpty()
+
+ val sb = StringBuilder()
+ if ((app?.totalMessageCount ?: 0L) == 0L) {
+ sb.append(getString(R.string.gcm_no_message_yet))
+ } else {
+ sb.append(getString(R.string.gcm_messages_counter, app?.totalMessageCount, app?.totalMessageBytes))
+ if (app?.lastMessageTimestamp != 0L) {
+ sb.append("\n").append(getString(R.string.gcm_last_message_at, DateUtils.getRelativeDateTimeString(context, app?.lastMessageTimestamp ?: 0L, DateUtils.MINUTE_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, DateUtils.FORMAT_SHOW_TIME)))
+ }
+ }
+ for (registration in registrations) {
+ sb.append("\n")
+ if (registration.timestamp == 0L) {
+ sb.append(getString(R.string.gcm_registered))
+ } else {
+ sb.append(getString(R.string.gcm_registered_since, DateUtils.getRelativeDateTimeString(context, registration.timestamp, DateUtils.MINUTE_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, DateUtils.FORMAT_SHOW_TIME)))
+ }
+ }
+ status.summary = sb.toString()
+
+ database.close()
+ }
+ }
+
+ override fun onPause() {
+ super.onPause()
+ database.close()
+ }
+}
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationFragment.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationFragment.kt
index d05afb3d..cb5aaa18 100755
--- a/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationFragment.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationFragment.kt
@@ -2,142 +2,61 @@
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/
-
package org.microg.gms.ui
-import android.annotation.SuppressLint
import android.os.Bundle
-import android.os.Handler
-import android.text.format.DateUtils
-import android.view.Menu
-import android.view.MenuInflater
-import android.view.MenuItem
-import androidx.core.os.bundleOf
+import android.view.*
+import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
-import androidx.preference.Preference
-import androidx.preference.PreferenceCategory
-import androidx.preference.PreferenceFragmentCompat
import com.mgoogle.android.gms.R
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.withContext
-import org.microg.gms.checkin.CheckinPreferences
-import org.microg.gms.gcm.GcmDatabase
-import org.microg.gms.gcm.GcmPrefs
+import com.mgoogle.android.gms.databinding.PushNotificationFragmentBinding
+import org.microg.gms.checkin.getCheckinServiceInfo
+import org.microg.gms.gcm.ServiceInfo
import org.microg.gms.gcm.getGcmServiceInfo
+import org.microg.gms.gcm.setGcmServiceConfiguration
-class PushNotificationFragment : PreferenceFragmentCompat() {
- private lateinit var switchBarPreference: SwitchBarPreference
- private lateinit var pushStatusCategory: PreferenceCategory
- private lateinit var pushStatus: Preference
- private lateinit var pushApps: PreferenceCategory
- private lateinit var pushAppsAll: Preference
- private lateinit var pushAppsNone: Preference
- private lateinit var database: GcmDatabase
- private val handler = Handler()
- private val updateRunnable = Runnable { updateStatus() }
+@Suppress("Warnings")
+class PushNotificationFragment : Fragment(R.layout.push_notification_fragment) {
+ lateinit var binding: PushNotificationFragmentBinding
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- database = GcmDatabase(context)
+ init {
+ setHasOptionsMenu(true)
}
- override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
- addPreferencesFromResource(R.xml.preferences_push_notifications)
+ override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ binding = PushNotificationFragmentBinding.inflate(inflater, container, false)
+ binding.switchBarCallback = object : PreferenceSwitchBarCallback {
+ override fun onChecked(newStatus: Boolean) {
+ setEnabled(newStatus)
+ }
+ }
+ return binding.root
}
- @SuppressLint("RestrictedApi")
- override fun onBindPreferences() {
- switchBarPreference = preferenceScreen.findPreference("pref_push_enabled") ?: switchBarPreference
- pushStatusCategory = preferenceScreen.findPreference("prefcat_push_status") ?: pushStatusCategory
- pushStatus = preferenceScreen.findPreference("pref_push_status") ?: pushStatus
- pushApps = preferenceScreen.findPreference("prefcat_push_apps") ?: pushApps
- pushAppsAll = preferenceScreen.findPreference("pref_push_apps_all") ?: pushAppsAll
- pushAppsNone = preferenceScreen.findPreference("pref_push_apps_none") ?: pushAppsNone
- pushAppsAll.setOnPreferenceClickListener {
- findNavController().navigate(requireContext(), R.id.openAllGcmApps)
- true
- }
- switchBarPreference.setOnPreferenceChangeListener { _, newValue ->
- val newStatus = newValue as Boolean
- GcmPrefs.setEnabled(requireContext(), newStatus)
- true
+ fun setEnabled(newStatus: Boolean) {
+ val appContext = requireContext().applicationContext
+ lifecycleScope.launchWhenResumed {
+ val info = getGcmServiceInfo(appContext)
+ val newConfiguration = info.configuration.copy(enabled = newStatus)
+ setGcmServiceConfiguration(appContext, newConfiguration)
+ displayServiceInfo(info.copy(configuration = newConfiguration))
}
}
+ private fun displayServiceInfo(serviceInfo: ServiceInfo) {
+ binding.gcmEnabled = serviceInfo.configuration.enabled
+ }
+
override fun onResume() {
super.onResume()
-
- switchBarPreference.isEnabled = CheckinPreferences.isEnabled(requireContext())
- switchBarPreference.isChecked = GcmPrefs.get(requireContext()).isEnabled
-
- updateStatus()
- updateContent()
- }
-
- override fun onPause() {
- super.onPause()
- database.close()
- handler.removeCallbacks(updateRunnable)
- }
-
- private fun updateStatus() {
- handler.postDelayed(updateRunnable, UPDATE_INTERVAL)
val appContext = requireContext().applicationContext
- lifecycleScope.launchWhenStarted {
- val statusInfo = getGcmServiceInfo(appContext)
- switchBarPreference.isChecked = statusInfo.configuration.enabled
- pushStatusCategory.isVisible = statusInfo != null && statusInfo.configuration.enabled
- pushStatus.summary = if (statusInfo != null && statusInfo.connected) {
- appContext.getString(R.string.gcm_network_state_connected, DateUtils.getRelativeTimeSpanString(statusInfo.startTimestamp, System.currentTimeMillis(), 0))
- } else {
- appContext.getString(R.string.gcm_network_state_disconnected)
- }
- }
- }
-
- private fun updateContent() {
lifecycleScope.launchWhenResumed {
- val context = requireContext()
- val (apps, showAll) = withContext(Dispatchers.IO) {
- val apps = database.appList.sortedByDescending { it.lastMessageTimestamp }
- val res = apps.map { app ->
- app to context.packageManager.getApplicationInfoIfExists(app.packageName)
- }.mapNotNull { (app, info) ->
- if (info == null) null else app to info
- }.take(3).mapIndexed { idx, (app, applicationInfo) ->
- val pref = AppIconPreference(context)
- pref.order = idx
- pref.applicationInfo = applicationInfo
- pref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
- findNavController().navigate(requireContext(), R.id.openGcmAppDetails, bundleOf(
- "package" to app.packageName
- ))
- true
- }
- pref.key = "pref_push_app_" + app.packageName
- pref
- }.let { it to (it.size < apps.size) }
- database.close()
- res
- }
- pushAppsAll.isVisible = showAll
- pushApps.removeAll()
- for (app in apps) {
- pushApps.addPreference(app)
- }
- if (showAll) {
- pushApps.addPreference(pushAppsAll)
- } else if (apps.isEmpty()) {
- pushApps.addPreference(pushAppsNone)
- }
+ displayServiceInfo(getGcmServiceInfo(appContext))
+ binding.checkinEnabled = getCheckinServiceInfo(appContext).configuration.enabled
}
}
- init {
- setHasOptionsMenu(true)
- }
-
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
menu.add(0, MENU_ADVANCED, 0, R.string.menu_advanced)
super.onCreateOptionsMenu(menu, inflater)
@@ -154,7 +73,7 @@ class PushNotificationFragment : PreferenceFragmentCompat() {
}
companion object {
- private const val UPDATE_INTERVAL = 1000L
private const val MENU_ADVANCED = Menu.FIRST
}
-}
\ No newline at end of file
+}
+
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationPreferencesFragment.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationPreferencesFragment.kt
new file mode 100755
index 00000000..1a5caae1
--- /dev/null
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationPreferencesFragment.kt
@@ -0,0 +1,128 @@
+/*
+ * SPDX-FileCopyrightText: 2020, microG Project Team
+ * SPDX-License-Identifier: Apache-2.0
+ */
+@file:Suppress("DEPRECATION")
+
+package org.microg.gms.ui
+
+import android.annotation.SuppressLint
+import android.os.Bundle
+import android.os.Handler
+import android.text.format.DateUtils
+import androidx.core.os.bundleOf
+import androidx.lifecycle.lifecycleScope
+import androidx.navigation.fragment.findNavController
+import androidx.preference.Preference
+import androidx.preference.PreferenceCategory
+import androidx.preference.PreferenceFragmentCompat
+import com.mgoogle.android.gms.R
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+import org.microg.gms.gcm.GcmDatabase
+import org.microg.gms.gcm.getGcmServiceInfo
+
+class PushNotificationPreferencesFragment : PreferenceFragmentCompat() {
+ private lateinit var pushStatusCategory: PreferenceCategory
+ private lateinit var pushStatus: Preference
+ private lateinit var pushApps: PreferenceCategory
+ private lateinit var pushAppsAll: Preference
+ private lateinit var pushAppsNone: Preference
+ private lateinit var database: GcmDatabase
+ private val handler = Handler()
+ private val updateRunnable = Runnable { updateStatus() }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ database = GcmDatabase(context)
+ }
+
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+ addPreferencesFromResource(R.xml.preferences_push_notifications)
+ }
+
+ @SuppressLint("RestrictedApi")
+ override fun onBindPreferences() {
+ pushStatusCategory = preferenceScreen.findPreference("prefcat_push_status") ?: pushStatusCategory
+ pushStatus = preferenceScreen.findPreference("pref_push_status") ?: pushStatus
+ pushApps = preferenceScreen.findPreference("prefcat_push_apps") ?: pushApps
+ pushAppsAll = preferenceScreen.findPreference("pref_push_apps_all") ?: pushAppsAll
+ pushAppsNone = preferenceScreen.findPreference("pref_push_apps_none") ?: pushAppsNone
+ pushAppsAll.onPreferenceClickListener = Preference.OnPreferenceClickListener {
+ findNavController().navigate(requireContext(), R.id.openAllGcmApps)
+ true
+ }
+ }
+
+ override fun onResume() {
+ super.onResume()
+ updateStatus()
+ updateContent()
+ }
+
+ override fun onPause() {
+ super.onPause()
+ database.close()
+ handler.removeCallbacks(updateRunnable)
+ }
+
+ private fun updateStatus() {
+ try {
+ handler.postDelayed(updateRunnable, UPDATE_INTERVAL)
+ val appContext = requireContext().applicationContext
+ lifecycleScope.launchWhenStarted {
+ val statusInfo = getGcmServiceInfo(appContext)
+ pushStatusCategory.isVisible = statusInfo != null && statusInfo.configuration.enabled
+ pushStatus.summary = if (statusInfo.connected) {
+ appContext.getString(R.string.gcm_network_state_connected, DateUtils.getRelativeTimeSpanString(statusInfo.startTimestamp, System.currentTimeMillis(), 0))
+ } else {
+ appContext.getString(R.string.gcm_network_state_disconnected)
+ }
+ }
+ } catch (e: Exception) {}
+ }
+
+ private fun updateContent() {
+ val appContext = requireContext().applicationContext
+ val context = requireContext()
+ lifecycleScope.launchWhenResumed {
+ val (apps, showAll) = withContext(Dispatchers.IO) {
+ val apps = database.appList.sortedByDescending { it.lastMessageTimestamp }
+ val res = apps.map { app ->
+ app to appContext.packageManager.getApplicationInfoIfExists(app.packageName)
+ }.mapNotNull { (app, info) ->
+ if (info == null) null else app to info
+ }.take(3).mapIndexed { idx, (app, applicationInfo) ->
+ val pref = AppIconPreference(appContext)
+ pref.order = idx
+ pref.title = applicationInfo.loadLabel(appContext.packageManager)
+ pref.icon = applicationInfo.loadIcon(appContext.packageManager)
+ pref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
+ findNavController().navigate(context, R.id.openGcmAppDetails, bundleOf(
+ "package" to app.packageName
+ ))
+ true
+ }
+ pref.key = "pref_push_app_" + app.packageName
+ pref
+ }.let { it to (it.size < apps.size) }
+ database.close()
+ res
+ }
+ pushAppsAll.isVisible = showAll
+ pushApps.removeAll()
+ for (app in apps) {
+ pushApps.addPreference(app)
+ }
+ if (showAll) {
+ pushApps.addPreference(pushAppsAll)
+ } else if (apps.isEmpty()) {
+ pushApps.addPreference(pushAppsNone)
+ }
+ }
+ }
+
+ companion object {
+ private const val UPDATE_INTERVAL = 1000L
+ }
+}
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/SettingsFragment.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/SettingsFragment.kt
index e7f83c28..848e702b 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/ui/SettingsFragment.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/SettingsFragment.kt
@@ -8,25 +8,21 @@
package org.microg.gms.ui
import android.content.ComponentName
+import android.content.Context
import android.content.pm.PackageManager
import android.os.Bundle
-import android.util.Log
import androidx.preference.Preference
-import androidx.preference.PreferenceCategory
import androidx.preference.SwitchPreferenceCompat
import com.mgoogle.android.gms.R
-import org.microg.gms.checkin.CheckinPreferences
+import org.microg.gms.checkin.CheckinPrefs
import org.microg.gms.gcm.GcmDatabase
-import org.microg.gms.gcm.GcmPrefs
-import org.microg.gms.settings.SettingsContract
-import org.microg.gms.ui.settings.SettingsProvider
-import org.microg.gms.ui.settings.getAllSettingsProviders
+import org.microg.gms.gcm.getGcmServiceInfo
+import org.microg.mgms.settings.SettingsContract
import org.microg.tools.ui.ResourceSettingsFragment
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
class SettingsFragment : ResourceSettingsFragment() {
- private val createdPreferences = mutableListOf