From 6e82590e6085957ed806e31e1cec9698246c075f Mon Sep 17 00:00:00 2001 From: S1m Date: Sat, 11 May 2024 14:57:39 +0000 Subject: [PATCH] Lint: Apply suggestions --- .../gms/common/MultiConnectionKeeper.java | 28 +++++++++---------- .../java/org/microg/gms/common/Constants.java | 2 +- .../microg/gms/ui/MainSettingsActivity.java | 12 ++++---- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java b/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java index bc50a035d5..a820dd8ccd 100644 --- a/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java +++ b/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java @@ -43,15 +43,15 @@ import static android.os.Build.VERSION.SDK_INT; import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH; import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME; -import static org.microg.gms.common.Constants.MICROG_PACKAGE_NAME; +import static org.microg.gms.common.Constants.USER_MICROG_PACKAGE_NAME; import static org.microg.gms.common.Constants.GMS_PACKAGE_SIGNATURE_SHA1; import static org.microg.gms.common.Constants.GMS_SECONDARY_PACKAGE_SIGNATURE_SHA1; import static org.microg.gms.common.Constants.MICROG_PACKAGE_SIGNATURE_SHA1; public class MultiConnectionKeeper { private static final String TAG = "GmsMultiConKeeper"; - private static final String PREF_MASTER = "GmsMultiConKeeper"; - private static final String PREF_TARGET = "GmsMultiConKeeper_target"; + private static final String PREF_NAME = "org.microg.gms_connection"; + private static final String PREF_TARGET = "target"; private static final String[] GOOGLE_PRIMARY_KEYS = {GMS_PACKAGE_SIGNATURE_SHA1, GMS_SECONDARY_PACKAGE_SIGNATURE_SHA1}; private static final String[] MICROG_PRIMARY_KEYS = {MICROG_PACKAGE_SIGNATURE_SHA1}; @@ -59,7 +59,7 @@ public class MultiConnectionKeeper { private final Context context; - private final String gmsPackage; + private final String targetPackage; private final Map connections = new HashMap(); private Boolean isSystem(PackageManager pm, String packageId) throws PackageManager.NameNotFoundException { @@ -121,26 +121,26 @@ private String getTargetPackageWithoutPref() { Log.d(TAG, GMS_PACKAGE_NAME + " not found"); } try { - if (isMicrogSig(pm, MICROG_PACKAGE_NAME)) { - Log.d(TAG, MICROG_PACKAGE_NAME + " found !"); - return MICROG_PACKAGE_NAME; + if (isMicrogSig(pm, USER_MICROG_PACKAGE_NAME)) { + Log.d(TAG, USER_MICROG_PACKAGE_NAME + " found !"); + return USER_MICROG_PACKAGE_NAME; } else { - Log.w(TAG, MICROG_PACKAGE_NAME + " found with another signature"); + Log.w(TAG, USER_MICROG_PACKAGE_NAME + " found with another signature"); } } catch (PackageManager.NameNotFoundException e) { - Log.d(TAG, MICROG_PACKAGE_NAME + " not found"); + Log.d(TAG, USER_MICROG_PACKAGE_NAME + " not found"); } return null; } private String getTargetPackage() { - SharedPreferences prefs = context.getSharedPreferences(PREF_MASTER, Context.MODE_PRIVATE); + SharedPreferences prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); final String SELF = "SELF"; String target; if ((target = prefs.getString(PREF_TARGET, null)) != null) { switch (target) { case GMS_PACKAGE_NAME: - case MICROG_PACKAGE_NAME: + case USER_MICROG_PACKAGE_NAME: return target; case SELF: return null; @@ -156,7 +156,7 @@ private String getTargetPackage() { public MultiConnectionKeeper(Context context) { this.context = context; - gmsPackage = getTargetPackage(); + targetPackage = getTargetPackage(); } public synchronized static MultiConnectionKeeper getInstance(Context context) { @@ -251,8 +251,8 @@ public Connection(String actionString, boolean requireMicrog) { private Intent getIntent() { Intent intent; ResolveInfo resolveInfo; - if (gmsPackage != null) { - intent = new Intent(actionString).setPackage(gmsPackage); + if (targetPackage != null) { + intent = new Intent(actionString).setPackage(targetPackage); if ((resolveInfo = context.getPackageManager().resolveService(intent, 0)) != null) { if (requireMicrog && !isMicrog(resolveInfo)) { Log.w(TAG, "GMS service found for " + actionString + " but looks not like microG"); diff --git a/play-services-basement/src/main/java/org/microg/gms/common/Constants.java b/play-services-basement/src/main/java/org/microg/gms/common/Constants.java index 1f13b00852..c6ea9e002d 100644 --- a/play-services-basement/src/main/java/org/microg/gms/common/Constants.java +++ b/play-services-basement/src/main/java/org/microg/gms/common/Constants.java @@ -21,7 +21,7 @@ public class Constants { public static final int GMS_VERSION_CODE = (BuildConfig.VERSION_CODE / 1000) * 1000; public static final String GMS_PACKAGE_NAME = "com.google.android.gms"; - public static final String MICROG_PACKAGE_NAME = "org.microg.gms"; + public static final String USER_MICROG_PACKAGE_NAME = "org.microg.gms"; public static final String GSF_PACKAGE_NAME = "com.google.android.gsf"; public static final String GMS_PACKAGE_SIGNATURE_SHA1 = "38918a453d07199354f8b19af05ec6562ced5788"; public static final String GMS_SECONDARY_PACKAGE_SIGNATURE_SHA1 = "bd32424203e0fb25f36b57e5aa356f9bdd1da998"; diff --git a/play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java b/play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java index 8b6c5c077f..ecd6e51562 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java @@ -25,23 +25,23 @@ public class MainSettingsActivity extends AppCompatActivity { private AppBarConfiguration appBarConfiguration; - private static final String FirstRunMaster = "FirstRun"; - private static final String FirstRunPref = "FirstRun_pref"; + private static final String FIRST_RUN_MASTER = "org.microg.gms_firstRun"; + private static final String FIRST_RUN_PREF = "as_run"; private NavController getNavController() { return ((NavHostFragment)getSupportFragmentManager().findFragmentById(R.id.navhost)).getNavController(); } private void showDialogIfNeeded() { - SharedPreferences prefs = getSharedPreferences(FirstRunMaster, MODE_PRIVATE); - if (BuildConfig.APPLICATION_ID == Constants.MICROG_PACKAGE_NAME && - prefs.getBoolean(FirstRunPref, true)) { + SharedPreferences prefs = getSharedPreferences(FIRST_RUN_MASTER, MODE_PRIVATE); + if (BuildConfig.APPLICATION_ID == Constants.USER_MICROG_PACKAGE_NAME && + prefs.getBoolean(FIRST_RUN_PREF, true)) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.limited_services_dialog_information) .setTitle(R.string.limited_services_app_name) .setPositiveButton(R.string.limited_services_dialog_information_ack, (dialog, id) -> { - prefs.edit().putBoolean(FirstRunPref, false).apply(); + prefs.edit().putBoolean(FIRST_RUN_PREF, false).apply(); }); builder.create().show();