diff --git a/README.md b/README.md
index 90b361b6..29f47891 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
This fork tweaks MicroG to be usable by applications that require Google authentication such as [YouTube Vanced+](https://gitlab.com/cuynu/vancedx).
## Warning!
-Vanced+ microG probably does not works in ReVanced/RVX in future as recent changes from ReVanced/RVX to use with they specific MicroG called ReVanced MicroG with different package name !
+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)
## Notable changes
diff --git a/build.gradle b/build.gradle
index 0ef88b7d..bcf0bcbe 100644
--- a/build.gradle
+++ b/build.gradle
@@ -28,7 +28,7 @@ buildscript {
ext.wireVersion = '4.8.0'
- ext.androidBuildGradleVersion = '7.4.2'
+ ext.androidBuildGradleVersion = '8.0.2'
ext.androidBuildVersionTools = '33.0.2'
ext.androidMinSdk = 23
@@ -48,7 +48,7 @@ buildscript {
}
-def gmsVersion = "24.17.17"
+def gmsVersion = "25.09.34"
def gmsVersionCode = Integer.parseInt(gmsVersion.replaceAll('\\.', ''))
def ourVersionBase = "0.3.0"
diff --git a/fake-signature/build.gradle b/fake-signature/build.gradle
index 19f0fc40..e04d9893 100644
--- a/fake-signature/build.gradle
+++ b/fake-signature/build.gradle
@@ -17,8 +17,8 @@ android {
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
}
}
diff --git a/gradle.properties b/gradle.properties
index 976747da..126b7d28 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,3 +1,5 @@
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 afba1092..d64cd491 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 b1624c47..0e1ae8ce 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 65dcd68d..1aa94a42 100755
--- a/gradlew
+++ b/gradlew
@@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
-APP_HOME=$( cd "${APP_HOME:-./}" && 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"'
+# 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
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ 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.
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.
@@ -144,7 +145,7 @@ 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=SC3045
+ # shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
+ # shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi
-# 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.
+
+# 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.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
diff --git a/play-services-api/build.gradle b/play-services-api/build.gradle
index e254f48d..20d8bea5 100644
--- a/play-services-api/build.gradle
+++ b/play-services-api/build.gradle
@@ -26,9 +26,13 @@ android {
}
compileOptions {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
+ sourceCompatibility = 17
+ targetCompatibility = 17
}
+ 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 d4a4d07a..359a9b71 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-base-api/build.gradle b/play-services-base-api/build.gradle
index b806da4c..23b6b07c 100644
--- a/play-services-base-api/build.gradle
+++ b/play-services-base-api/build.gradle
@@ -34,7 +34,11 @@ android {
}
compileOptions {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
+ sourceCompatibility = 17
+ targetCompatibility = 17
}
+ 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 7c8eeef3..055d07d5 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-core/build.gradle b/play-services-base-core/build.gradle
index ad962700..34288f21 100644
--- a/play-services-base-core/build.gradle
+++ b/play-services-base-core/build.gradle
@@ -21,7 +21,6 @@ android {
buildToolsVersion androidBuildVersionTools
defaultConfig {
- versionName version
minSdkVersion androidMinSdk
targetSdkVersion androidTargetSdk
@@ -33,7 +32,8 @@ android {
}
compileOptions {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
+ sourceCompatibility = 17
+ targetCompatibility = 17
}
+ 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 39554ca3..369707e7 100644
--- a/play-services-base-core/src/main/AndroidManifest.xml
+++ b/play-services-base-core/src/main/AndroidManifest.xml
@@ -4,14 +4,20 @@
~ SPDX-License-Identifier: Apache-2.0
-->
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+
+
+ android:exported="true"
+ android:readPermission="${applicationId}.permission.READ_SETTINGS"
+ android:writePermission="${applicationId}.permission.WRITE_SETTINGS" />
+
+
+
+
+
+
\ 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
new file mode 100644
index 00000000..9818305b
--- /dev/null
+++ b/play-services-base-core/src/main/res/layout/preference_switch_bar.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/play-services-base/build.gradle b/play-services-base/build.gradle
index 8857d222..e1cff12a 100644
--- a/play-services-base/build.gradle
+++ b/play-services-base/build.gradle
@@ -26,9 +26,10 @@ android {
}
compileOptions {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
+ sourceCompatibility = 17
+ targetCompatibility = 17
}
+ 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 3ab02d97..c31f1c05 100644
--- a/play-services-base/src/main/AndroidManifest.xml
+++ b/play-services-base/src/main/AndroidManifest.xml
@@ -15,8 +15,7 @@
~ limitations under the License.
-->
-
+
-
+
diff --git a/play-services-core-proto/build.gradle b/play-services-core-proto/build.gradle
index 2cfb351e..6edfcb4b 100644
--- a/play-services-core-proto/build.gradle
+++ b/play-services-core-proto/build.gradle
@@ -21,9 +21,9 @@ sourceSets {
}
compileKotlin {
- kotlinOptions.jvmTarget = 1.8
+ kotlinOptions.jvmTarget = 17
}
compileTestKotlin {
- kotlinOptions.jvmTarget = 1.8
+ kotlinOptions.jvmTarget = 17
}
\ No newline at end of file
diff --git a/play-services-core/build.gradle b/play-services-core/build.gradle
index 5cb9aedd..22e0b42c 100644
--- a/play-services-core/build.gradle
+++ b/play-services-core/build.gradle
@@ -57,7 +57,7 @@ android {
defaultConfig {
versionName version
versionCode appVersionCode
- resConfigs 'xxhdpi'
+ resourceConfigurations += ['xxhdpi']
minSdkVersion androidMinSdk
targetSdkVersion androidTargetSdk
@@ -109,8 +109,8 @@ android {
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
}
packagingOptions {
diff --git a/play-services-core/microg-ui-tools/build.gradle b/play-services-core/microg-ui-tools/build.gradle
index b6b2018d..260aa6a5 100644
--- a/play-services-core/microg-ui-tools/build.gradle
+++ b/play-services-core/microg-ui-tools/build.gradle
@@ -28,14 +28,15 @@ android {
}
compileOptions {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
+ sourceCompatibility = 17
+ targetCompatibility = 17
}
lintOptions {
// TODO: Remove MissingTranslation once we have stable strings and proper translations.
disable 'MissingTranslation', 'GetLocales'
}
+ 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 004f299c..359a9b71 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 a771a9ea..2b0542a5 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,6 +19,7 @@ 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/res/layout/settings_activity.xml b/play-services-core/microg-ui-tools/src/main/res/layout/settings_activity.xml
index a664de26..e5f71828 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,6 +19,14 @@
android:layout_height="match_parent"
android:orientation="vertical">
+
+
+
@@ -53,7 +56,7 @@
-
+
@@ -62,7 +65,8 @@
-
+
@@ -90,7 +94,7 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:multiArch="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/Theme.App"
android:networkSecurityConfig="@xml/network_security_config"
tools:targetApi="r">
@@ -101,7 +105,7 @@
+ android:exported="true" />
@@ -116,13 +120,15 @@
-
+
-
+
@@ -150,6 +156,7 @@
@@ -161,6 +168,7 @@
@@ -173,6 +181,7 @@
@@ -185,6 +194,7 @@
@@ -208,6 +218,7 @@
@@ -220,7 +231,8 @@
-
+
@@ -278,6 +290,7 @@
@@ -285,19 +298,22 @@
-
+
-
+
-
+
@@ -305,7 +321,8 @@
@@ -336,10 +353,11 @@
@@ -362,7 +380,7 @@
android:name="com.google.android.gms.app.settings.GoogleSettingsLink"
android:process=":ui"
android:exported="true"
- android:targetActivity="org.microg.gms.ui.SettingsActivity"
+ android:targetActivity="org.microg.gms.ui.MainSettingsActivity"
android:taskAffinity="org.microg.gms.settings">
@@ -380,7 +398,8 @@
@@ -409,14 +428,16 @@
-
+
-
+
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 5d836001..f52b93c4 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.CheckinPrefs.hideLauncherIcon;
-import static org.microg.gms.checkin.CheckinPrefs.isSpoofingEnabled;
-import static org.microg.gms.checkin.CheckinPrefs.setSpoofingEnabled;
+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.common.Constants.GMS_PACKAGE_NAME;
import static org.microg.gms.common.Constants.GMS_VERSION_CODE;
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 89ee692f..fa4eb2bc 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);
- return null;
+ throw new NetworkErrorException(e);
}
return null;
}
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 dc67b444..b9432ac6 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.CheckinPrefs.isSpoofingEnabled;
+import static org.microg.gms.checkin.CheckinPreferences.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 (!CheckinPrefs.isEnabled(context))
+ if (!CheckinPreferences.isEnabled(context))
return null;
List accounts = new ArrayList<>();
AccountManager accountManager = AccountManager.get(context);
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 bd5bfabb..3f53ebcd 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 (CheckinPrefs.isEnabled(this)) {
+ if (CheckinPreferences.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_UPDATE_CURRENT);
+ PendingIntent pendingIntent = PendingIntent.getService(context, TriggerReceiver.class.getName().hashCode(), new Intent(context, TriggerReceiver.class), PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
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 752b8119..e41a954b 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
@@ -41,7 +41,7 @@ public class TriggerReceiver extends WakefulBroadcastReceiver {
try {
boolean force = "android.provider.Telephony.SECRET_CODE".equals(intent.getAction());
- if (CheckinPrefs.isEnabled(context) || force) {
+ if (CheckinPreferences.isEnabled(context) || force) {
if (LastCheckinInfo.read(context).getLastCheckin() > System.currentTimeMillis() - REGULAR_CHECKIN_INTERVAL && !force) {
CheckinService.schedule(context);
return;
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 f4766b4a..343d1721 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
@@ -209,7 +209,7 @@ 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), 0);
+ heartbeatIntent = PendingIntent.getService(this, 0, new Intent(ACTION_HEARTBEAT, null, this, McsService.class), PendingIntent.FLAG_IMMUTABLE);
alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
powerManager = (PowerManager) getSystemService(POWER_SERVICE);
if (checkSelfPermission("android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST") == PackageManager.PERMISSION_GRANTED) {
@@ -300,7 +300,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), 0);
+ PendingIntent pi = PendingIntent.getBroadcast(context, 1, new Intent(ACTION_RECONNECT, null, context, TriggerReceiver.class), PendingIntent.FLAG_IMMUTABLE);
alarmManager.setExactAndAllowWhileIdle(ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delay, pi);
}
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 e94b2f02..83d182aa 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
@@ -30,7 +30,7 @@ import android.util.Log;
import androidx.legacy.content.WakefulBroadcastReceiver;
-import org.microg.gms.checkin.CheckinPrefs;
+import org.microg.gms.checkin.CheckinPreferences;
import org.microg.gms.checkin.LastCheckinInfo;
import org.microg.gms.common.ForegroundServiceContext;
@@ -67,7 +67,7 @@ public class TriggerReceiver extends WakefulBroadcastReceiver {
if (LastCheckinInfo.read(context).getAndroidId() == 0) {
Log.d(TAG, "Ignoring " + intent + ": need to checkin first.");
- if (CheckinPrefs.isEnabled(context)) {
+ if (CheckinPreferences.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/ui/SettingsActivity.java b/play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java
old mode 100755
new mode 100644
similarity index 66%
rename from play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java
rename to play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java
index f0777081..b65b3806
--- a/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java
+++ b/play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java
@@ -1,7 +1,6 @@
package org.microg.gms.ui;
-import static android.os.Build.VERSION.SDK_INT;
-
+import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
@@ -11,10 +10,12 @@ 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;
-public class SettingsActivity extends AppCompatActivity {
+import static org.microg.gms.ui.settings.SettingsProviderKt.getAllSettingsProviders;
+
+public class MainSettingsActivity extends AppCompatActivity {
private AppBarConfiguration appBarConfiguration;
private NavController getNavController() {
@@ -24,10 +25,18 @@ public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.settings_root_activity);
- if (SDK_INT >= 31) {
- DynamicColors.applyToActivityIfAvailable(this);
+
+ 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());
+ }
+
appBarConfiguration = new AppBarConfiguration.Builder(getNavController().getGraph()).build();
NavigationUI.setupActionBarWithNavController(this, getNavController(), appBarConfiguration);
}
@@ -36,4 +45,4 @@ public class SettingsActivity 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/kotlin/org/microg/gms/checkin/CheckinPrefs.kt b/play-services-core/src/main/kotlin/org/microg/gms/checkin/CheckinPreferences.kt
similarity index 60%
rename from play-services-core/src/main/kotlin/org/microg/gms/checkin/CheckinPrefs.kt
rename to play-services-core/src/main/kotlin/org/microg/gms/checkin/CheckinPreferences.kt
index e2ab990a..eb78d498 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/checkin/CheckinPrefs.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/checkin/CheckinPreferences.kt
@@ -5,16 +5,21 @@
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
-object CheckinPrefs {
+object CheckinPreferences {
@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
}
}
@@ -22,7 +27,11 @@ object CheckinPrefs {
@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
}
}
@@ -41,4 +50,13 @@ object CheckinPrefs {
}
}
-}
+ @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/gcm/GcmPrefs.kt b/play-services-core/src/main/kotlin/org/microg/gms/gcm/GcmPrefs.kt
index 86e7a37d..c506ed62 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
@@ -71,6 +71,15 @@ 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)) {
@@ -79,6 +88,7 @@ data class GcmPrefs(
}
}
+
/**
* Call this whenever the enabled state of GCM has changed.
*/
@@ -178,5 +188,4 @@ 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 1f27e4b6..8d3b9a78 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.CheckinPrefs
+import org.microg.gms.checkin.CheckinPreferences
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 (!CheckinPrefs.isEnabled(context)) throw RuntimeException("Checkin disabled")
+ if (!CheckinPreferences.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 ->
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
new file mode 100644
index 00000000..c3cf6185
--- /dev/null
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/AppHeadingPreference.kt
@@ -0,0 +1,44 @@
+/*
+ * 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 de5020c0..1570c691 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,8 +11,9 @@ import android.util.DisplayMetrics
import android.widget.ImageView
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
+import android.content.pm.ApplicationInfo
-class AppIconPreference : Preference {
+class AppIconPreference : AppPreference {
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)
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
new file mode 100644
index 00000000..27626231
--- /dev/null
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/AppPreference.kt
@@ -0,0 +1,47 @@
+/*
+ * 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 17887575..8c668529 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,51 +5,163 @@
package org.microg.gms.ui
+
+import android.annotation.SuppressLint
+import android.net.Uri
import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import androidx.fragment.app.Fragment
+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 com.mgoogle.android.gms.databinding.DeviceRegistrationFragmentBinding
-import org.microg.gms.checkin.ServiceInfo
+import org.microg.gms.checkin.CheckinPreferences
import org.microg.gms.checkin.getCheckinServiceInfo
-import org.microg.gms.checkin.setCheckinServiceConfiguration
+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
-class DeviceRegistrationFragment : Fragment(R.layout.device_registration_fragment) {
- private lateinit var binding: DeviceRegistrationFragmentBinding
+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
- 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)
+ 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)
}
}
- 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
+ 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()
+ 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 {
- displayServiceInfo(getCheckinServiceInfo(appContext))
+ 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/DeviceRegistrationPreferencesFragment.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/DeviceRegistrationPreferencesFragment.kt
deleted file mode 100755
index a0b4ad13..00000000
--- a/play-services-core/src/main/kotlin/org/microg/gms/ui/DeviceRegistrationPreferencesFragment.kt
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * 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
deleted file mode 100755
index b66f1119..00000000
--- a/play-services-core/src/main/kotlin/org/microg/gms/ui/PreferenceSwitchBarCallback.kt
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * 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/PushNotificationAllAppsFragment.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAllAppsFragment.kt
index da3210e4..392e14d6 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,16 +56,12 @@ 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.title = applicationInfo?.loadLabel(context.packageManager) ?: app.packageName
+ pref.packageName = 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 f83a5e5d..780e85e1 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,58 +5,135 @@
package org.microg.gms.ui
-import android.content.Intent
-import android.net.Uri
+import android.annotation.SuppressLint
import android.os.Bundle
-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 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 com.mgoogle.android.gms.databinding.PushNotificationAppFragmentBinding
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+import org.microg.gms.gcm.GcmDatabase
+import org.microg.gms.gcm.PushRegisterManager
+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
-class PushNotificationAppFragment : Fragment(R.layout.push_notification_fragment) {
- lateinit var binding: PushNotificationAppFragmentBinding
- val packageName: String?
+ private lateinit var database: GcmDatabase
+ private val packageName: String?
get() = arguments?.getString("package")
- 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)
+ 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)
}
}
+ 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()
- val context = requireContext()
+ updateDetails()
+ }
+
+ private fun updateDetails() {
lifecycleScope.launchWhenResumed {
- 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)
+ 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()
}
}
-}
-interface PushNotificationAppFragmentCallbacks {
- fun onAppClicked()
-}
+ override fun onPause() {
+ super.onPause()
+ database.close()
+ }
+}
\ No newline at end of file
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
deleted file mode 100755
index 7106e506..00000000
--- a/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationAppPreferencesFragment.kt
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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 cb5aaa18..d05afb3d 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,61 +2,142 @@
* 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.view.*
-import androidx.fragment.app.Fragment
+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 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 com.mgoogle.android.gms.databinding.PushNotificationFragmentBinding
-import org.microg.gms.checkin.getCheckinServiceInfo
-import org.microg.gms.gcm.ServiceInfo
+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 org.microg.gms.gcm.getGcmServiceInfo
-import org.microg.gms.gcm.setGcmServiceConfiguration
-@Suppress("Warnings")
-class PushNotificationFragment : Fragment(R.layout.push_notification_fragment) {
- lateinit var binding: PushNotificationFragmentBinding
+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() }
- init {
- setHasOptionsMenu(true)
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ database = GcmDatabase(context)
}
- 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)
- }
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+ addPreferencesFromResource(R.xml.preferences_push_notifications)
+ }
+
+ @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
}
- return binding.root
- }
-
- 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))
+ switchBarPreference.setOnPreferenceChangeListener { _, newValue ->
+ val newStatus = newValue as Boolean
+ GcmPrefs.setEnabled(requireContext(), newStatus)
+ true
}
}
- 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.launchWhenResumed {
- displayServiceInfo(getGcmServiceInfo(appContext))
- binding.checkinEnabled = getCheckinServiceInfo(appContext).configuration.enabled
+ 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)
+ }
+ }
+ }
+
+ init {
+ setHasOptionsMenu(true)
+ }
+
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
menu.add(0, MENU_ADVANCED, 0, R.string.menu_advanced)
super.onCreateOptionsMenu(menu, inflater)
@@ -73,7 +154,7 @@ class PushNotificationFragment : Fragment(R.layout.push_notification_fragment) {
}
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
deleted file mode 100755
index da861c0b..00000000
--- a/play-services-core/src/main/kotlin/org/microg/gms/ui/PushNotificationPreferencesFragment.kt
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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.configuration.enabled
- pushStatus.summary = if (statusInfo.connected) {
- getString(R.string.gcm_network_state_connected, DateUtils.getRelativeTimeSpanString(statusInfo.startTimestamp, System.currentTimeMillis(), 0))
- } else {
- getString(R.string.gcm_network_state_disconnected)
- }
- }
- } catch (_: 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 86dd492d..e7f83c28 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
@@ -15,7 +15,7 @@ import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.SwitchPreferenceCompat
import com.mgoogle.android.gms.R
-import org.microg.gms.checkin.CheckinPrefs
+import org.microg.gms.checkin.CheckinPreferences
import org.microg.gms.gcm.GcmDatabase
import org.microg.gms.gcm.GcmPrefs
import org.microg.gms.settings.SettingsContract
@@ -39,11 +39,13 @@ class SettingsFragment : ResourceSettingsFragment() {
findNavController().navigate(requireContext(), R.id.openGcmSettings)
true
}
- findPreference(PREF_ABOUT)?.setOnPreferenceClickListener {
- findNavController().navigate(requireContext(), R.id.openAbout)
- true
+ findPreference(PREF_ABOUT)!!.apply {
+ onPreferenceClickListener = Preference.OnPreferenceClickListener {
+ findNavController().navigate(requireContext(), R.id.openAbout)
+ true
+ }
+ summary = getString(org.microg.tools.ui.R.string.about_version_str, AboutFragment.getSelfVersion(context))
}
- findPreference(PREF_ABOUT)?.summary = getString(R.string.about_version_str, AboutFragment.getSelfVersion(context))
findPreference(SettingsContract.CheckIn.HIDE_LAUNCHER_ICON)?.apply {
setOnPreferenceChangeListener { _, newValue ->
@@ -105,7 +107,7 @@ class SettingsFragment : ResourceSettingsFragment() {
findPreference(PREF_GCM)?.setSummary(R.string.service_status_disabled_short)
}
- findPreference(PREF_CHECKIN)?.setSummary(if (CheckinPrefs.isEnabled(context)) R.string.service_status_enabled_short else R.string.service_status_disabled_short)
+ findPreference(PREF_CHECKIN)?.setSummary(if (CheckinPreferences.isEnabled(context)) R.string.service_status_enabled_short else R.string.service_status_disabled_short)
lifecycleScope.launchWhenResumed {
val entries = getAllSettingsProviders(requireContext()).flatMap { it.getEntriesDynamic(requireContext()) }
@@ -124,6 +126,7 @@ class SettingsFragment : ResourceSettingsFragment() {
const val PREF_ABOUT = "pref_about"
const val PREF_GCM = "pref_gcm"
const val PREF_CHECKIN = "pref_checkin"
+ const val PREF_PLAY = "pref_play"
}
init {
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/SwitchBarPreference.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/SwitchBarPreference.kt
new file mode 100644
index 00000000..12802a1e
--- /dev/null
+++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/SwitchBarPreference.kt
@@ -0,0 +1,51 @@
+/*
+ * SPDX-FileCopyrightText: 2023 microG Project Team
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.microg.gms.ui
+
+import android.content.Context
+import android.util.AttributeSet
+import androidx.appcompat.widget.SwitchCompat
+import androidx.preference.PreferenceViewHolder
+import androidx.preference.TwoStatePreference
+import org.microg.gms.base.core.R
+
+// TODO
+class SwitchBarPreference : TwoStatePreference {
+ 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_switch_bar
+ }
+
+ override fun onBindViewHolder(holder: PreferenceViewHolder) {
+ super.onBindViewHolder(holder)
+ holder.isDividerAllowedBelow = false
+ holder.isDividerAllowedAbove = false
+ val switch = holder.findViewById(R.id.switch_widget) as SwitchCompat
+ switch.setOnCheckedChangeListener(null)
+ switch.isChecked = isChecked
+ switch.setOnCheckedChangeListener { view, isChecked ->
+ if (!callChangeListener(isChecked)) {
+ view.isChecked = !isChecked
+ return@setOnCheckedChangeListener
+ }
+ this.isChecked = isChecked
+ }
+ holder.itemView.setBackgroundColor(when {
+ isChecked -> androidx.appcompat.R.attr.colorControlActivated
+ isEnabled -> androidx.appcompat.R.attr.colorButtonNormal
+ else -> androidx.appcompat.R.attr.colorControlHighlight
+ })
+ }
+}
+
+@Deprecated("Get rid")
+interface PreferenceSwitchBarCallback {
+ fun onChecked(newStatus: Boolean)
+}
\ No newline at end of file
diff --git a/play-services-core/src/main/res/color/preferences_material_switch_color.xml b/play-services-core/src/main/res/color/preferences_material_switch_color.xml
new file mode 100644
index 00000000..1a6c9037
--- /dev/null
+++ b/play-services-core/src/main/res/color/preferences_material_switch_color.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/drawable/ic_play.xml b/play-services-core/src/main/res/drawable/ic_play.xml
new file mode 100644
index 00000000..9db10ec6
--- /dev/null
+++ b/play-services-core/src/main/res/drawable/ic_play.xml
@@ -0,0 +1,10 @@
+
+
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/layout/device_registration_fragment.xml b/play-services-core/src/main/res/layout/device_registration_fragment.xml
deleted file mode 100755
index fe6d1e51..00000000
--- a/play-services-core/src/main/res/layout/device_registration_fragment.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/play-services-core/src/main/res/layout/preference_app_heading.xml b/play-services-core/src/main/res/layout/preference_app_heading.xml
new file mode 100644
index 00000000..cb7e4edf
--- /dev/null
+++ b/play-services-core/src/main/res/layout/preference_app_heading.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/layout/preference_material_switch.xml b/play-services-core/src/main/res/layout/preference_material_switch.xml
new file mode 100644
index 00000000..071caab2
--- /dev/null
+++ b/play-services-core/src/main/res/layout/preference_material_switch.xml
@@ -0,0 +1,11 @@
+
+
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/layout/preference_switch_bar.xml b/play-services-core/src/main/res/layout/preference_switch_bar.xml
index d45909cd..9818305b 100755
--- a/play-services-core/src/main/res/layout/preference_switch_bar.xml
+++ b/play-services-core/src/main/res/layout/preference_switch_bar.xml
@@ -1,71 +1,42 @@
-
-
-
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ android:gravity="center"
+ android:orientation="horizontal"
+ android:paddingStart="?attr/listPreferredItemPaddingStart"
+ android:paddingLeft="?attr/listPreferredItemPaddingLeft"
+ android:paddingEnd="?attr/listPreferredItemPaddingEnd"
+ android:paddingRight="?attr/listPreferredItemPaddingRight"
+ tools:background="?attr/colorControlActivated">
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ app:thumbTint="?android:attr/textColorPrimaryInverse"
+ app:trackTint="?android:attr/textColorSecondaryInverse"
+ tools:checked="true" />
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/layout/push_notification_app_fragment.xml b/play-services-core/src/main/res/layout/push_notification_app_fragment.xml
deleted file mode 100755
index dcc6e7ad..00000000
--- a/play-services-core/src/main/res/layout/push_notification_app_fragment.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/play-services-core/src/main/res/layout/push_notification_fragment.xml b/play-services-core/src/main/res/layout/push_notification_fragment.xml
deleted file mode 100755
index fdd799bd..00000000
--- a/play-services-core/src/main/res/layout/push_notification_fragment.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/play-services-core/src/main/res/layout/settings_root_activity.xml b/play-services-core/src/main/res/layout/settings_root_activity.xml
index d854b3a3..18ea2241 100755
--- a/play-services-core/src/main/res/layout/settings_root_activity.xml
+++ b/play-services-core/src/main/res/layout/settings_root_activity.xml
@@ -9,6 +9,13 @@
android:layout_height="match_parent"
android:orientation="vertical">
+
+
+
+
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/values-night-v27/themes.xml b/play-services-core/src/main/res/values-night-v27/themes.xml
new file mode 100644
index 00000000..0b22714a
--- /dev/null
+++ b/play-services-core/src/main/res/values-night-v27/themes.xml
@@ -0,0 +1,9 @@
+
+
+
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/values-night-v31/themes.xml b/play-services-core/src/main/res/values-night-v31/themes.xml
index de5386e8..7f89bd04 100644
--- a/play-services-core/src/main/res/values-night-v31/themes.xml
+++ b/play-services-core/src/main/res/values-night-v31/themes.xml
@@ -1,14 +1,11 @@
+
-
-
-
-
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/values-v23/themes.xml b/play-services-core/src/main/res/values-v23/themes.xml
new file mode 100644
index 00000000..9009e5c5
--- /dev/null
+++ b/play-services-core/src/main/res/values-v23/themes.xml
@@ -0,0 +1,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/values-v27/themes.xml b/play-services-core/src/main/res/values-v27/themes.xml
new file mode 100644
index 00000000..434c86ec
--- /dev/null
+++ b/play-services-core/src/main/res/values-v27/themes.xml
@@ -0,0 +1,9 @@
+
+
+
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/values-v31/themes.xml b/play-services-core/src/main/res/values-v31/themes.xml
index 1719a989..6e96e2b4 100644
--- a/play-services-core/src/main/res/values-v31/themes.xml
+++ b/play-services-core/src/main/res/values-v31/themes.xml
@@ -1,13 +1,11 @@
+
-
-
-
-
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/values/themes.xml b/play-services-core/src/main/res/values/themes.xml
index d5cb5705..8e651928 100755
--- a/play-services-core/src/main/res/values/themes.xml
+++ b/play-services-core/src/main/res/values/themes.xml
@@ -22,6 +22,15 @@
- @color/m3_theme_primary_dark
+
+
+
+
+
+
+
+
+
+
+
diff --git a/play-services-core/src/main/res/xml/preferences_device_registration.xml b/play-services-core/src/main/res/xml/preferences_device_registration.xml
index ecd4b469..3fa45eb5 100755
--- a/play-services-core/src/main/res/xml/preferences_device_registration.xml
+++ b/play-services-core/src/main/res/xml/preferences_device_registration.xml
@@ -5,7 +5,14 @@
-->
+ xmlns:tools="http://schemas.android.com/tools"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+
+
+
@@ -13,16 +20,11 @@
android:key="pref_device_profile"
android:persistent="false"
android:title="@string/profile_name"
- tools:summary="Automatic (Google Pixel 3, Android 11)" />
+ tools:summary="Automatic" />
-
+ tools:summary="Last registration: XX hours ago" />
+ tools:summary="" />
+
-
+ android:summary="DD MM YYYY - monthly">
diff --git a/play-services-core/src/main/res/xml/preferences_push_notifications.xml b/play-services-core/src/main/res/xml/preferences_push_notifications.xml
index 9c250f95..416cfac8 100755
--- a/play-services-core/src/main/res/xml/preferences_push_notifications.xml
+++ b/play-services-core/src/main/res/xml/preferences_push_notifications.xml
@@ -7,6 +7,11 @@
+
+
diff --git a/play-services-core/src/main/res/xml/preferences_push_notifications_app.xml b/play-services-core/src/main/res/xml/preferences_push_notifications_app.xml
index 01d83e52..5cf81e5b 100755
--- a/play-services-core/src/main/res/xml/preferences_push_notifications_app.xml
+++ b/play-services-core/src/main/res/xml/preferences_push_notifications_app.xml
@@ -6,6 +6,11 @@
+
+
diff --git a/play-services-core/src/main/res/xml/profile_bullhead_27.xml b/play-services-core/src/main/res/xml/profile_bullhead_27.xml
deleted file mode 100644
index 186a4356..00000000
--- a/play-services-core/src/main/res/xml/profile_bullhead_27.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/play-services-core/src/main/res/xml/profile_googlevr.xml b/play-services-core/src/main/res/xml/profile_googlevr.xml
new file mode 100644
index 00000000..1d0c7fba
--- /dev/null
+++ b/play-services-core/src/main/res/xml/profile_googlevr.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/xml/profile_lineage_falcon_25.xml b/play-services-core/src/main/res/xml/profile_lineage_falcon_25.xml
deleted file mode 100644
index 57beb5d4..00000000
--- a/play-services-core/src/main/res/xml/profile_lineage_falcon_25.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/play-services-core/src/main/res/xml/profile_lineage_xperiaxz2.xml b/play-services-core/src/main/res/xml/profile_lineage_xperiaxz2.xml
new file mode 100644
index 00000000..6aa36bfa
--- /dev/null
+++ b/play-services-core/src/main/res/xml/profile_lineage_xperiaxz2.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/xml/profile_projectinfinityx_redminote7.xml b/play-services-core/src/main/res/xml/profile_projectinfinityx_redminote7.xml
new file mode 100644
index 00000000..f92014ae
--- /dev/null
+++ b/play-services-core/src/main/res/xml/profile_projectinfinityx_redminote7.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/play-services-core/src/main/res/xml/profile_redfin_33.xml b/play-services-core/src/main/res/xml/profile_redfin_33.xml
deleted file mode 100644
index 52c57f88..00000000
--- a/play-services-core/src/main/res/xml/profile_redfin_33.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/play-services-core/src/main/res/xml/profile_sdk_gphone64_x86_64_33.xml b/play-services-core/src/main/res/xml/profile_sdk_gphone64_x86_64_33.xml
deleted file mode 100644
index b616c365..00000000
--- a/play-services-core/src/main/res/xml/profile_sdk_gphone64_x86_64_33.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/play-services-iid-api/build.gradle b/play-services-iid-api/build.gradle
index 603c53b4..34ed3abb 100644
--- a/play-services-iid-api/build.gradle
+++ b/play-services-iid-api/build.gradle
@@ -26,9 +26,13 @@ android {
}
compileOptions {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
+ sourceCompatibility = 17
+ targetCompatibility = 17
}
+ buildFeatures {
+ aidl true
+ }
+ namespace 'org.microg.gms.iid.api'
}
dependencies {
diff --git a/play-services-iid-api/src/main/AndroidManifest.xml b/play-services-iid-api/src/main/AndroidManifest.xml
index e979258e..ca617cfb 100644
--- a/play-services-iid-api/src/main/AndroidManifest.xml
+++ b/play-services-iid-api/src/main/AndroidManifest.xml
@@ -15,4 +15,4 @@
~ limitations under the License.
-->
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/play-services-tasks/build.gradle b/play-services-tasks/build.gradle
index 0eb84bbf..068aeb92 100644
--- a/play-services-tasks/build.gradle
+++ b/play-services-tasks/build.gradle
@@ -22,9 +22,10 @@ android {
}
compileOptions {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
+ sourceCompatibility = 17
+ targetCompatibility = 17
}
+ namespace 'org.microg.gms.tasks'
}
dependencies {
diff --git a/play-services-tasks/src/main/AndroidManifest.xml b/play-services-tasks/src/main/AndroidManifest.xml
index c7b833fe..c256eb44 100644
--- a/play-services-tasks/src/main/AndroidManifest.xml
+++ b/play-services-tasks/src/main/AndroidManifest.xml
@@ -4,4 +4,4 @@
~ SPDX-License-Identifier: Apache-2.0
-->
-
+