mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-11-19 02:29:25 +01:00
Move UI into separate process
This commit is contained in:
parent
60cc63ed60
commit
c88832213c
@ -17,6 +17,7 @@
|
|||||||
package org.microg.gms.common;
|
package org.microg.gms.common;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
import android.app.Application;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
@ -26,6 +27,7 @@ import android.os.Binder;
|
|||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -230,6 +232,19 @@ public class PackageUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getProcessName() {
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= 28)
|
||||||
|
return Application.getProcessName();
|
||||||
|
try {
|
||||||
|
Class<?> activityThread = Class.forName("android.app.ActivityThread");
|
||||||
|
String methodName = android.os.Build.VERSION.SDK_INT >= 18 ? "currentProcessName" : "currentPackageName";
|
||||||
|
Method getProcessName = activityThread.getDeclaredMethod(methodName);
|
||||||
|
return (String) getProcessName.invoke(null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String sha1sum(byte[] bytes) {
|
public static String sha1sum(byte[] bytes) {
|
||||||
MessageDigest md;
|
MessageDigest md;
|
||||||
try {
|
try {
|
||||||
|
@ -129,11 +129,11 @@
|
|||||||
|
|
||||||
<!-- Location -->
|
<!-- Location -->
|
||||||
|
|
||||||
<activity android:name="org.microg.nlp.ui.BackendSettingsActivity" />
|
<activity android:name="org.microg.nlp.ui.BackendSettingsActivity" android:process=":ui" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.microg.gms.ui.PlacePickerActivity"
|
android:name="org.microg.gms.ui.PlacePickerActivity"
|
||||||
android:exported="true"
|
android:exported="true" android:process=":ui"
|
||||||
android:label="@string/pick_place_title"
|
android:label="@string/pick_place_title"
|
||||||
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
|
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@ -238,6 +238,8 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<receiver android:name="org.microg.gms.gcm.StatusInfoProvider" />
|
||||||
|
|
||||||
<receiver android:name="org.microg.gms.gcm.TriggerReceiver">
|
<receiver android:name="org.microg.gms.gcm.TriggerReceiver">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
@ -346,7 +348,8 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name="org.microg.tools.AccountPickerActivity"
|
android:name="org.microg.tools.AccountPickerActivity"
|
||||||
android:excludeFromRecents="true"
|
android:excludeFromRecents="true"
|
||||||
android:exported="true">
|
android:exported="true"
|
||||||
|
android:process=":ui">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="com.google.android.gms.common.account.CHOOSE_ACCOUNT" />
|
<action android:name="com.google.android.gms.common.account.CHOOSE_ACCOUNT" />
|
||||||
|
|
||||||
@ -358,6 +361,7 @@
|
|||||||
android:name="org.microg.gms.auth.login.LoginActivity"
|
android:name="org.microg.gms.auth.login.LoginActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
android:process=":ui"
|
||||||
android:theme="@style/Theme.LoginBlue">
|
android:theme="@style/Theme.LoginBlue">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="com.google.android.gms.auth.login.LOGIN" />
|
<action android:name="com.google.android.gms.auth.login.LOGIN" />
|
||||||
@ -370,6 +374,7 @@
|
|||||||
android:name="org.microg.gms.auth.AskPermissionActivity"
|
android:name="org.microg.gms.auth.AskPermissionActivity"
|
||||||
android:excludeFromRecents="true"
|
android:excludeFromRecents="true"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
android:process=":ui"
|
||||||
android:theme="@style/Theme.AppCompat.DayNight.Dialog" />
|
android:theme="@style/Theme.AppCompat.DayNight.Dialog" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
@ -378,7 +383,8 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".auth.TokenActivity"
|
android:name=".auth.TokenActivity"
|
||||||
android:exported="true" />
|
android:exported="true"
|
||||||
|
android:process=":ui" />
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="org.microg.gms.auth.AccountContentProvider"
|
android:name="org.microg.gms.auth.AccountContentProvider"
|
||||||
@ -396,6 +402,7 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.microg.gms.games.UpgradeActivity"
|
android:name="org.microg.gms.games.UpgradeActivity"
|
||||||
|
android:process=":ui"
|
||||||
android:theme="@style/Theme.AppCompat.DayNight.Dialog">
|
android:theme="@style/Theme.AppCompat.DayNight.Dialog">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="com.google.android.gms.games.PLAY_GAMES_UPGRADE" />
|
<action android:name="com.google.android.gms.games.PLAY_GAMES_UPGRADE" />
|
||||||
@ -422,6 +429,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name="org.microg.gms.ui.ExposureNotificationsConfirmActivity"
|
android:name="org.microg.gms.ui.ExposureNotificationsConfirmActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
|
android:process=":ui"
|
||||||
android:theme="@style/Theme.AppCompat.DayNight.Dialog.Alert.NoActionBar">
|
android:theme="@style/Theme.AppCompat.DayNight.Dialog.Alert.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="org.microg.gms.nearby.exposurenotification.CONFIRM" />
|
<action android:name="org.microg.gms.nearby.exposurenotification.CONFIRM" />
|
||||||
@ -433,6 +441,7 @@
|
|||||||
android:name="org.microg.gms.ui.SettingsActivity"
|
android:name="org.microg.gms.ui.SettingsActivity"
|
||||||
android:icon="@mipmap/ic_microg_settings"
|
android:icon="@mipmap/ic_microg_settings"
|
||||||
android:label="@string/gms_settings_name"
|
android:label="@string/gms_settings_name"
|
||||||
|
android:process=":ui"
|
||||||
android:roundIcon="@mipmap/ic_microg_settings">
|
android:roundIcon="@mipmap/ic_microg_settings">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
@ -441,6 +450,7 @@
|
|||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
|
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
|
||||||
<action android:name="com.google.android.gms.settings.EXPOSURE_NOTIFICATION_SETTINGS" />
|
<action android:name="com.google.android.gms.settings.EXPOSURE_NOTIFICATION_SETTINGS" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
@ -449,6 +459,7 @@
|
|||||||
android:name="org.microg.gms.ui.SettingsDashboardActivity"
|
android:name="org.microg.gms.ui.SettingsDashboardActivity"
|
||||||
android:icon="@mipmap/ic_microg_settings"
|
android:icon="@mipmap/ic_microg_settings"
|
||||||
android:label="Legacy microG Settings"
|
android:label="Legacy microG Settings"
|
||||||
|
android:process=":ui"
|
||||||
android:roundIcon="@mipmap/ic_microg_settings" />
|
android:roundIcon="@mipmap/ic_microg_settings" />
|
||||||
|
|
||||||
<!-- microG Settings embedded in System Settings on SDK 23 and newer -->
|
<!-- microG Settings embedded in System Settings on SDK 23 and newer -->
|
||||||
@ -456,6 +467,7 @@
|
|||||||
android:name="org.microg.gms.ui.SettingsActivityLink"
|
android:name="org.microg.gms.ui.SettingsActivityLink"
|
||||||
android:icon="@drawable/microg_light_color_24"
|
android:icon="@drawable/microg_light_color_24"
|
||||||
android:label="@string/gms_settings_name"
|
android:label="@string/gms_settings_name"
|
||||||
|
android:process=":ui"
|
||||||
android:targetActivity="org.microg.gms.ui.SettingsActivity">
|
android:targetActivity="org.microg.gms.ui.SettingsActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="com.android.settings.action.EXTRA_SETTINGS" />
|
<action android:name="com.android.settings.action.EXTRA_SETTINGS" />
|
||||||
@ -475,25 +487,32 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name="org.microg.gms.ui.AskPushPermission"
|
android:name="org.microg.gms.ui.AskPushPermission"
|
||||||
android:excludeFromRecents="true"
|
android:excludeFromRecents="true"
|
||||||
|
android:process=":ui"
|
||||||
android:theme="@style/Theme.AppCompat.DayNight.Dialog.Alert" />
|
android:theme="@style/Theme.AppCompat.DayNight.Dialog.Alert" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.microg.gms.ui.AboutFragment$AsActivity"
|
android:name="org.microg.gms.ui.AboutFragment$AsActivity"
|
||||||
android:label="@string/pref_about_title" />
|
android:label="@string/pref_about_title"
|
||||||
|
android:process=":ui" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.microg.gms.ui.GoogleMoreFragment$AsActivity"
|
android:name="org.microg.gms.ui.GoogleMoreFragment$AsActivity"
|
||||||
android:label="@string/gms_settings_name" />
|
android:label="@string/gms_settings_name"
|
||||||
|
android:process=":ui" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.microg.gms.ui.SafetyNetAdvancedFragment$AsActivity"
|
android:name="org.microg.gms.ui.SafetyNetAdvancedFragment$AsActivity"
|
||||||
android:label="@string/service_name_snet" />
|
android:label="@string/service_name_snet"
|
||||||
|
android:process=":ui" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.microg.gms.ui.SelfCheckFragment$AsActivity"
|
android:name="org.microg.gms.ui.SelfCheckFragment$AsActivity"
|
||||||
android:label="@string/self_check_title" />
|
android:label="@string/self_check_title"
|
||||||
|
android:process=":ui" />
|
||||||
|
|
||||||
<activity android:name="org.microg.gms.ui.AccountSettingsActivity">
|
<activity
|
||||||
|
android:name="org.microg.gms.ui.AccountSettingsActivity"
|
||||||
|
android:process=":ui">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="com.google.android.gms.accountsettings.ACCOUNT_PREFERENCES_SETTINGS" />
|
<action android:name="com.google.android.gms.accountsettings.ACCOUNT_PREFERENCES_SETTINGS" />
|
||||||
<action android:name="com.google.android.gms.accountsettings.PRIVACY_SETTINGS" />
|
<action android:name="com.google.android.gms.accountsettings.PRIVACY_SETTINGS" />
|
||||||
@ -503,7 +522,9 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="org.microg.gms.ui.LocationSettingsActivity">
|
<activity
|
||||||
|
android:name="org.microg.gms.ui.LocationSettingsActivity"
|
||||||
|
android:process=":ui">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="com.google.android.gms.location.settings.LOCATION_HISTORY" />
|
<action android:name="com.google.android.gms.location.settings.LOCATION_HISTORY" />
|
||||||
<action android:name="com.google.android.location.settings.LOCATION_REPORTING_SETTINGS" />
|
<action android:name="com.google.android.location.settings.LOCATION_REPORTING_SETTINGS" />
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.microg.gms.gcm
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
|
import android.util.Log
|
||||||
|
import java.io.Serializable
|
||||||
|
import kotlin.coroutines.resume
|
||||||
|
import kotlin.coroutines.suspendCoroutine
|
||||||
|
|
||||||
|
private const val ACTION_STATUS_INFO_REQUEST = "org.microg.gms.STATUS_INFO_REQUEST"
|
||||||
|
private const val ACTION_STATUS_INFO_RESPONSE = "org.microg.gms.STATUS_INFO_RESPONSE"
|
||||||
|
private const val EXTRA_STATUS_INFO = "org.microg.gms.STATUS_INFO"
|
||||||
|
private const val TAG = "GmsGcmStatusInfo"
|
||||||
|
|
||||||
|
data class StatusInfo(val connected: Boolean, val startTimestamp: Long) : Serializable
|
||||||
|
|
||||||
|
class StatusInfoProvider : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
try {
|
||||||
|
context.sendOrderedBroadcast(Intent(ACTION_STATUS_INFO_RESPONSE).apply {
|
||||||
|
setPackage(context.packageName)
|
||||||
|
putExtra(EXTRA_STATUS_INFO, StatusInfo(McsService.isConnected(), McsService.getStartTimestamp()))
|
||||||
|
}, null)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.w(TAG, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun getStatusInfo(context: Context): StatusInfo? = suspendCoroutine {
|
||||||
|
context.registerReceiver(object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context, intent: Intent?) {
|
||||||
|
try {
|
||||||
|
it.resume(intent?.getSerializableExtra(EXTRA_STATUS_INFO) as? StatusInfo)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.w(TAG, e)
|
||||||
|
}
|
||||||
|
context.unregisterReceiver(this)
|
||||||
|
}
|
||||||
|
}, IntentFilter(ACTION_STATUS_INFO_RESPONSE))
|
||||||
|
try {
|
||||||
|
context.sendOrderedBroadcast(Intent(context, StatusInfoProvider::class.java), null)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
it.resume(null)
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,7 @@ import kotlinx.coroutines.withContext
|
|||||||
import org.microg.gms.gcm.GcmDatabase
|
import org.microg.gms.gcm.GcmDatabase
|
||||||
import org.microg.gms.gcm.GcmPrefs
|
import org.microg.gms.gcm.GcmPrefs
|
||||||
import org.microg.gms.gcm.McsService
|
import org.microg.gms.gcm.McsService
|
||||||
|
import org.microg.gms.gcm.getStatusInfo
|
||||||
|
|
||||||
class PushNotificationPreferencesFragment : PreferenceFragmentCompat() {
|
class PushNotificationPreferencesFragment : PreferenceFragmentCompat() {
|
||||||
private lateinit var pushStatusCategory: PreferenceCategory
|
private lateinit var pushStatusCategory: PreferenceCategory
|
||||||
@ -67,10 +68,13 @@ class PushNotificationPreferencesFragment : PreferenceFragmentCompat() {
|
|||||||
private fun updateStatus() {
|
private fun updateStatus() {
|
||||||
handler.postDelayed(updateRunnable, UPDATE_INTERVAL)
|
handler.postDelayed(updateRunnable, UPDATE_INTERVAL)
|
||||||
pushStatusCategory.isVisible = GcmPrefs.get(context).isEnabled
|
pushStatusCategory.isVisible = GcmPrefs.get(context).isEnabled
|
||||||
pushStatus.summary = if (McsService.isConnected()) {
|
lifecycleScope.launchWhenStarted {
|
||||||
getString(R.string.gcm_network_state_connected, DateUtils.getRelativeTimeSpanString(McsService.getStartTimestamp(), System.currentTimeMillis(), 0))
|
val statusInfo = getStatusInfo(requireContext())
|
||||||
} else {
|
pushStatus.summary = if (statusInfo != null && statusInfo.connected) {
|
||||||
getString(R.string.gcm_network_state_disconnected)
|
getString(R.string.gcm_network_state_connected, DateUtils.getRelativeTimeSpanString(statusInfo.startTimestamp, System.currentTimeMillis(), 0))
|
||||||
|
} else {
|
||||||
|
getString(R.string.gcm_network_state_disconnected)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user