Skip to content

Commit

Permalink
Lint: Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
p1gp1g authored and mar-v-in committed Sep 28, 2024
1 parent 3520b31 commit 6e82590
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@
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};
private static MultiConnectionKeeper INSTANCE;

private final Context context;

private final String gmsPackage;
private final String targetPackage;
private final Map<String, Connection> connections = new HashMap<String, Connection>();

private Boolean isSystem(PackageManager pm, String packageId) throws PackageManager.NameNotFoundException {
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 6e82590

Please sign in to comment.