diff --git a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java index 23808f4cb..673c10149 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java @@ -12,18 +12,17 @@ import com.topjohnwu.magisk.utils.Logger; import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.Utils; -import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; public class SplashActivity extends AppCompatActivity { - +private SharedPreferences prefs; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplication()); + prefs = PreferenceManager.getDefaultSharedPreferences(getApplication()); if (prefs.getString("theme", "").equals("Dark")) { setTheme(R.style.AppTheme_dh); } @@ -31,35 +30,8 @@ public class SplashActivity extends AppCompatActivity { Logger.devLog = prefs.getBoolean("developer_logging", false); Logger.logShell = prefs.getBoolean("shell_logging", false); - // Set up default preferences,make sure we add "extra" blacklist entries. - int hideVersion = Utils.WhichHide(getApplication()); - List hideList; - Set set = new HashSet<>(); - switch (hideVersion) { - case 1: - hideList = Shell.su("/magisk/.core/magiskhide/list"); - set.addAll(hideList); - break; - case 2: - hideList = Shell.su("/su/suhide/list"); - break; - case 3: - hideList = Shell.su("/magisk/.core/magiskhide/list"); - hideList.addAll(Shell.su("/su/suhide/list")); - set.addAll(hideList); - } - if (!prefs.contains("auto_blacklist")) { - Logger.dev("SplashActivity: Setting default preferences for application"); - SharedPreferences.Editor editor = prefs.edit(); - set.add("com.google.android.apps.walletnfcrel"); - set.add("com.google.android.gms"); - set.add("com.google.commerce.tapandpay"); - editor.putStringSet("auto_blacklist", set); - editor.putBoolean("autoRootEnable", false); - editor.putBoolean("root", Utils.rootEnabled()); - editor.apply(); - } - + // Check and set preferences/hides + setupHideLists(); // Initialize prefs.edit() @@ -84,4 +56,64 @@ public class SplashActivity extends AppCompatActivity { }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); } + + private void setupHideLists() { + + Set set = null; + Set setOriginal = null; + List hideList = null; + List addList = null; + String listCmd, addCmd, addCmd2, rmCmd, rmCmd2; + + // Build list of apps currently listed, add to preferences + + int hideVersion = Utils.WhichHide(getApplication()); + + switch (hideVersion) { + case 1: + listCmd = "/magisk/.core/magiskhide/list"; + break; + case 2: + listCmd = "/su/suhide/list"; + break; + case 3: + listCmd = "/magisk/.core/magiskhide/list && /su/suhide/list"; + break; + default: + listCmd = ""; + + } + if (Shell.rootAccess()) { + hideList = Shell.su(listCmd); + } + // Set up default preferences,make sure we add "extra" blacklist entries. + + if (!prefs.contains("auto_blacklist")) { + Logger.dev("SplashActivity: Setting default preferences for application"); + set.add("com.google.android.apps.walletnfcrel"); + set.add("com.google.android.gms"); + set.add("com.google.commerce.tapandpay"); + + // Add current items to hide list + if (hideList != null) set.addAll(hideList); + SharedPreferences.Editor editor = prefs.edit(); + editor.putStringSet("auto_blacklist", set); + Logger.dev("SplashActivity: Adding entries " + set.toString()); + editor.apply(); + } + + setOriginal = prefs.getStringSet("auto_blacklist", set); + if (hideList != null) { + for (String item : hideList) { + if (!(setOriginal.contains(item))) { + addList.add(item); + } + } + } + + SharedPreferences.Editor editor = prefs.edit(); + editor.putStringSet("auto_blacklist", set); + editor.apply(); + + } } diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/ApplicationAdapter.java b/app/src/main/java/com/topjohnwu/magisk/utils/ApplicationAdapter.java index d8d14bca1..6c3684580 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/ApplicationAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/ApplicationAdapter.java @@ -103,7 +103,7 @@ public class ApplicationAdapter extends ArrayAdapter { Set set = prefs.getStringSet("auto_blacklist", null); if (set != null) { for (String string : set) { - if (string.equals(appToCheck)) { + if (string.contains(appToCheck)) { starter = true; } }