diff --git a/app/src/main/java/com/fox2code/mmm/AppUpdateManager.java b/app/src/main/java/com/fox2code/mmm/AppUpdateManager.java index b02c5af..578bc9a 100644 --- a/app/src/main/java/com/fox2code/mmm/AppUpdateManager.java +++ b/app/src/main/java/com/fox2code/mmm/AppUpdateManager.java @@ -111,9 +111,9 @@ public class AppUpdateManager { this.latestPreRelease = ""; this.preReleaseNewer = false; } - if (BuildConfig.DEBUG) Log.d(TAG, "Latest release: " + latestRelease); - if (BuildConfig.DEBUG) Log.d(TAG, "Latest pre-release: " + latestPreRelease); - if (BuildConfig.DEBUG) Log.d(TAG, "Latest pre-release newer: " + preReleaseNewer); + if (BuildConfig.DEBUG) Log.i(TAG, "Latest release: " + latestRelease); + if (BuildConfig.DEBUG) Log.i(TAG, "Latest pre-release: " + latestPreRelease); + if (BuildConfig.DEBUG) Log.i(TAG, "Latest pre-release newer: " + preReleaseNewer); this.lastChecked = System.currentTimeMillis(); this.lastCheckSuccess = true; } catch (Exception ioe) { @@ -125,6 +125,7 @@ public class AppUpdateManager { } public void checkUpdateCompat() { + if (BuildConfig.DEBUG) Log.i(TAG, "Checking compatibility flags"); if (this.compatFile.exists()) { long lastUpdate = this.compatFile.lastModified(); if (lastUpdate <= System.currentTimeMillis() && lastUpdate + 600_000L > System.currentTimeMillis()) { @@ -132,20 +133,26 @@ public class AppUpdateManager { } } try { + if (BuildConfig.DEBUG) Log.i(TAG, "Downloading compatibility flags"); JSONObject object = new JSONObject(new String(Http.doHttpGet(COMPAT_API_URL, false), StandardCharsets.UTF_8)); if (object.isNull("body")) { + if (BuildConfig.DEBUG) Log.i(TAG, "Compatibility flags not found"); compatDataId.clear(); Files.write(compatFile, new byte[0]); return; } + if (BuildConfig.DEBUG) Log.i(TAG, "Parsing compatibility flags"); byte[] rawData = object.getString("body").getBytes(StandardCharsets.UTF_8); this.parseCompatibilityFlags(new ByteArrayInputStream(rawData)); Files.write(compatFile, rawData); if (!BuildConfig.ENABLE_AUTO_UPDATER) this.lastCheckSuccess = true; + if (BuildConfig.DEBUG) Log.i(TAG, "Compatibility flags update finishing"); + return; } catch (Exception e) { if (!BuildConfig.ENABLE_AUTO_UPDATER) this.lastCheckSuccess = false; Log.e("AppUpdateManager", "Failed to update compat list", e); } + if (BuildConfig.DEBUG) Log.i(TAG, "Compatibility flags updated"); } public boolean peekShouldUpdate() { diff --git a/app/src/main/java/com/fox2code/mmm/MainActivity.java b/app/src/main/java/com/fox2code/mmm/MainActivity.java index 98b5977..9e96bb8 100644 --- a/app/src/main/java/com/fox2code/mmm/MainActivity.java +++ b/app/src/main/java/com/fox2code/mmm/MainActivity.java @@ -88,7 +88,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe private CardView searchCard; private SearchView searchView; private boolean initMode; - private boolean doSetupRestarting; + private boolean doSetupRestarting = false; private boolean urlFactoryInstalled = false; public MainActivity() { @@ -123,6 +123,9 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe Log.e(TAG, "Failed to install CronetURLStreamHandlerFactory", t); } } + if (doSetupRestarting) { + doSetupRestarting = false; + } BackgroundUpdateChecker.onMainActivityCreate(this); super.onCreate(savedInstanceState); this.setActionBarExtraMenuButton(R.drawable.ic_baseline_settings_24, v -> { @@ -158,7 +161,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe this.actionBarBlur.setBackground(this.actionBarBackground); BlurUtils.setupBlur(this.actionBarBlur, this, R.id.blur_frame); this.updateBlurState(); - checkShowInitialSetup(); this.moduleList.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override @@ -206,8 +208,15 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe } public void commonNext() { + if (BuildConfig.DEBUG) { + Log.i(TAG, "Common next"); + moduleViewListBuilder.addNotification(NotificationType.DEBUG); + } updateScreenInsets(); // Fix an edge case if (waitInitialSetupFinished()) { + if (BuildConfig.DEBUG) { + Log.i(TAG, "Initial setup not finished, waiting..."); + } return; } swipeRefreshBlocker = System.currentTimeMillis() + 5_000L; @@ -231,16 +240,16 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe } Log.i(TAG, "Scanning for modules!"); if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Initialize Update"); + Log.i("NoodleDebug", "Initialize Update"); final int max = ModuleManager.getINSTANCE().getUpdatableModuleCount(); if (RepoManager.getINSTANCE().getCustomRepoManager().needUpdate()) { Log.w(TAG, "Need update on create?"); } if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Check Update Compat"); + Log.i("NoodleDebug", "Check Update Compat"); AppUpdateManager.getAppUpdateManager().checkUpdateCompat(); if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Check Update"); + Log.i("NoodleDebug", "Check Update"); RepoManager.getINSTANCE().update(value -> runOnUiThread(max == 0 ? () -> progressIndicator.setProgressCompat((int) (value * PRECISION), true) : () -> progressIndicator.setProgressCompat((int) (value * PRECISION * 0.75F), true))); NotificationType.NEED_CAPTCHA_ANDROIDACY.autoAdd(moduleViewListBuilder); @@ -252,11 +261,11 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe // Compatibility data still needs to be updated AppUpdateManager appUpdateManager = AppUpdateManager.getAppUpdateManager(); if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Check App Update"); + Log.i("NoodleDebug", "Check App Update"); if (BuildConfig.ENABLE_AUTO_UPDATER && appUpdateManager.checkUpdate(true)) moduleViewListBuilder.addNotification(NotificationType.UPDATE_AVAILABLE); if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Check Json Update"); + Log.i("NoodleDebug", "Check Json Update"); if (max != 0) { int current = 0; @@ -264,7 +273,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe for (LocalModuleInfo localModuleInfo : ModuleManager.getINSTANCE().getModules().values()) { if (localModuleInfo.updateJson != null) { if (BuildConfig.DEBUG) - Log.d("NoodleDebug", localModuleInfo.id); + Log.i("NoodleDebug", localModuleInfo.id); try { localModuleInfo.checkModuleUpdate(); } catch ( @@ -286,7 +295,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe updateScreenInsets(getResources().getConfiguration()); }); if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Apply"); + Log.i("NoodleDebug", "Apply"); RepoManager.getINSTANCE().runAfterUpdate(moduleViewListBuilder::appendRemoteModules); moduleViewListBuilder.applyTo(moduleList, moduleViewAdapter); @@ -302,11 +311,11 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe SharedPreferences preferences = getSharedPreferences("sentry", MODE_PRIVATE); String lastExitReason = preferences.getString("lastExitReason", ""); if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Last Exit Reason: " + lastExitReason); + Log.i("NoodleDebug", "Last Exit Reason: " + lastExitReason); if (lastExitReason.equals("crash")) { String lastEventId = preferences.getString("lastEventId", ""); if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Last Event ID: " + lastEventId); + Log.i("NoodleDebug", "Last Event ID: " + lastEventId); if (!lastEventId.equals("")) { // Three edit texts for the user to enter their email, name and a description of the issue EditText email = new EditText(this); @@ -360,7 +369,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe connection.connect(); // For debug builds, log the response code and response body if (BuildConfig.DEBUG) { - Log.d("NoodleDebug", "Response Code: " + connection.getResponseCode()); + Log.i("NoodleDebug", "Response Code: " + connection.getResponseCode()); } // Check if the request was successful if (connection.getResponseCode() == 200) { @@ -415,7 +424,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe //this.actionBarBlur.invalidate(); this.overScrollInsetTop = combinedBarsHeight; this.overScrollInsetBottom = bottomInset; - Log.d(TAG, "( " + bottomInset + ", " + this.searchCard.getHeight() + ")"); + Log.i(TAG, "( " + bottomInset + ", " + this.searchCard.getHeight() + ")"); } private void updateBlurState() { @@ -498,7 +507,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe progressIndicator.setMax(PRECISION); }); if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Check Update"); + Log.i("NoodleDebug", "Check Update"); RepoManager.getINSTANCE().update(value -> runOnUiThread(() -> progressIndicator.setProgressCompat((int) (value * PRECISION), true))); runOnUiThread(() -> { progressIndicator.setProgressCompat(PRECISION, true); @@ -506,7 +515,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe }); } if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Apply"); + Log.i("NoodleDebug", "Apply"); RepoManager.getINSTANCE().runAfterUpdate(moduleViewListBuilder::appendRemoteModules); Log.i(TAG, "Common Before applyTo"); moduleViewListBuilder.applyTo(moduleList, moduleViewAdapter); @@ -528,7 +537,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe return; // Do not double scan } if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Refresh"); + Log.i("NoodleDebug", "Refresh"); this.progressIndicator.setVisibility(View.VISIBLE); this.progressIndicator.setProgressCompat(0, false); this.swipeRefreshBlocker = System.currentTimeMillis() + 5_000L; @@ -547,17 +556,17 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe // Compatibility data still needs to be updated AppUpdateManager appUpdateManager = AppUpdateManager.getAppUpdateManager(); if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Check App Update"); + Log.i("NoodleDebug", "Check App Update"); if (BuildConfig.ENABLE_AUTO_UPDATER && appUpdateManager.checkUpdate(true)) moduleViewListBuilder.addNotification(NotificationType.UPDATE_AVAILABLE); if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Check Json Update"); + Log.i("NoodleDebug", "Check Json Update"); if (max != 0) { int current = 0; for (LocalModuleInfo localModuleInfo : ModuleManager.getINSTANCE().getModules().values()) { if (localModuleInfo.updateJson != null) { if (BuildConfig.DEBUG) - Log.d("NoodleDebug", localModuleInfo.id); + Log.i("NoodleDebug", localModuleInfo.id); try { localModuleInfo.checkModuleUpdate(); } catch ( @@ -572,7 +581,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe } } if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Apply"); + Log.i("NoodleDebug", "Apply"); runOnUiThread(() -> { this.progressIndicator.setVisibility(View.GONE); this.swipeRefreshLayout.setRefreshing(false); @@ -631,18 +640,18 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe @SuppressLint("RestrictedApi") private void ensurePermissions() { if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Ensure Permissions"); + Log.i("NoodleDebug", "Ensure Permissions"); // First, check if user has said don't ask again by checking if pref_dont_ask_again_notification_permission is true if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean("pref_dont_ask_again_notification_permission", false)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Request Notification Permission"); + Log.i("NoodleDebug", "Request Notification Permission"); if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.POST_NOTIFICATIONS)) { // Show a dialog explaining why we need this permission, which is to show // notifications for updates runOnUiThread(() -> { if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Show Notification Permission Dialog"); + Log.i("NoodleDebug", "Show Notification Permission Dialog"); MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this); builder.setTitle(R.string.permission_notification_title); builder.setMessage(R.string.permission_notification_message); @@ -655,25 +664,27 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe builder.setPositiveButton(R.string.permission_notification_grant, (dialog, which) -> { // Request the permission this.requestPermissions(new String[]{Manifest.permission.POST_NOTIFICATIONS}, 0); + doSetupNowRunning = false; }); builder.setNegativeButton(R.string.cancel, (dialog, which) -> { // Set pref_background_update_check to false and dismiss dialog SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.edit().putBoolean("pref_background_update_check", false).apply(); dialog.dismiss(); + doSetupNowRunning = false; }); builder.show(); if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Show Notification Permission Dialog Done"); + Log.i("NoodleDebug", "Show Notification Permission Dialog Done"); }); } else { // Request the permission if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Request Notification Permission"); + Log.i("NoodleDebug", "Request Notification Permission"); this.requestPermissions(new String[]{Manifest.permission.POST_NOTIFICATIONS}, 0); if (BuildConfig.DEBUG) { // Log if granted via onRequestPermissionsResult - Log.d("NoodleDebug", "Request Notification Permission Done. Result: " + (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED)); + Log.i("NoodleDebug", "Request Notification Permission Done. Result: " + (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED)); } doSetupNowRunning = false; } @@ -712,7 +723,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe } } else { if (BuildConfig.DEBUG) - Log.d("NoodleDebug", "Notification Permission Already Granted or Don't Ask Again"); + Log.i("NoodleDebug", "Notification Permission Already Granted or Don't Ask Again"); doSetupNowRunning = false; } } @@ -721,12 +732,12 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe @SuppressLint({"InflateParams", "RestrictedApi", "UnspecifiedImmutableFlag", "ApplySharedPref"}) private void checkShowInitialSetup() { if (BuildConfig.DEBUG) - Log.d("SetupWizard", "Do setup now"); + Log.i("SetupWizard", "Do setup now"); // Check if this is the first launch SharedPreferences prefs = MainApplication.getSharedPreferences(); boolean firstLaunch = prefs.getBoolean("first_launch", true); if (BuildConfig.DEBUG) - Log.d("SetupWizard", "First launch: " + firstLaunch); + Log.i("SetupWizard", "First launch: " + firstLaunch); if (firstLaunch) { doSetupNowRunning = true; // Show setup box @@ -744,11 +755,11 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe prefs.edit().putBoolean("first_launch", false).putBoolean("pref_background_update_check", ((MaterialSwitch) Objects.requireNonNull(((AlertDialog) dialog).findViewById(R.id.setup_background_update_check))).isChecked()).putBoolean("pref_crash_reporting", ((MaterialSwitch) Objects.requireNonNull(((AlertDialog) dialog).findViewById(R.id.setup_crash_reporting))).isChecked()).putBoolean("pref_androidacy_repo_enabled", ((MaterialSwitch) Objects.requireNonNull(((AlertDialog) dialog).findViewById(R.id.setup_androidacy_repo))).isChecked()).putBoolean("pref_magisk_alt_repo_enabled", ((MaterialSwitch) Objects.requireNonNull(((AlertDialog) dialog).findViewById(R.id.setup_magisk_alt_repo))).isChecked()).commit(); // For debug builds, log the preferences if (BuildConfig.DEBUG) { - Log.d("SetupWizard", "First launch: " + prefs.getBoolean("first_launch", true)); - Log.d("SetupWizard", "Background update check: " + prefs.getBoolean("pref_background_update_check", false)); - Log.d("SetupWizard", "Crash reporting: " + prefs.getBoolean("pref_crash_reporting", false)); - Log.d("SetupWizard", "Androidacy repo: " + prefs.getBoolean("pref_androidacy_repo_enabled", false)); - Log.d("SetupWizard", "Magisk alt repo: " + prefs.getBoolean("pref_magisk_alt_repo_enabled", false)); + Log.i("SetupWizard", "First launch: " + prefs.getBoolean("first_launch", true)); + Log.i("SetupWizard", "Background update check: " + prefs.getBoolean("pref_background_update_check", false)); + Log.i("SetupWizard", "Crash reporting: " + prefs.getBoolean("pref_crash_reporting", false)); + Log.i("SetupWizard", "Androidacy repo: " + prefs.getBoolean("pref_androidacy_repo_enabled", false)); + Log.i("SetupWizard", "Magisk alt repo: " + prefs.getBoolean("pref_magisk_alt_repo_enabled", false)); } dialog.dismiss(); // Sleep for 100ms. Who knows, it might fix it? @@ -787,7 +798,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe */ private boolean waitInitialSetupFinished() { if (BuildConfig.DEBUG) - Log.d("SetupWizard", "waitInitialSetupFinished"); + Log.i("SetupWizard", "waitInitialSetupFinished"); if (doSetupNowRunning) updateScreenInsets(); // Fix an edge case try { diff --git a/app/src/main/java/com/fox2code/mmm/MainApplication.java b/app/src/main/java/com/fox2code/mmm/MainApplication.java index 2fe8227..bc14195 100644 --- a/app/src/main/java/com/fox2code/mmm/MainApplication.java +++ b/app/src/main/java/com/fox2code/mmm/MainApplication.java @@ -306,9 +306,9 @@ public class MainApplication extends FoxApplication implements androidx.work.Con fontRequestEmojiCompatConfig.setMetadataLoadStrategy(EmojiCompat.LOAD_STRATEGY_MANUAL); EmojiCompat emojiCompat = EmojiCompat.init(fontRequestEmojiCompatConfig); new Thread(() -> { - Log.d("MainApplication", "Loading emoji compat..."); + Log.i("MainApplication", "Loading emoji compat..."); emojiCompat.load(); - Log.d("MainApplication", "Emoji compat loaded!"); + Log.i("MainApplication", "Emoji compat loaded!"); }, "Emoji compat init.").start(); } SentryMain.initialize(this); diff --git a/app/src/main/java/com/fox2code/mmm/NotificationType.java b/app/src/main/java/com/fox2code/mmm/NotificationType.java index 57ed5a5..56761e2 100644 --- a/app/src/main/java/com/fox2code/mmm/NotificationType.java +++ b/app/src/main/java/com/fox2code/mmm/NotificationType.java @@ -26,6 +26,12 @@ interface NotificationTypeCst { } public enum NotificationType implements NotificationTypeCst { + DEBUG(R.string.debug_build, R.drawable.ic_baseline_bug_report_24) { + @Override + public boolean shouldRemove() { + return BuildConfig.DEBUG; + } + }, SHOWCASE_MODE(R.string.showcase_mode, R.drawable.ic_baseline_lock_24, R.attr.colorPrimary, R.attr.colorOnPrimary) { @Override diff --git a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyActivity.java b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyActivity.java index bab4ffe..6e88b91 100644 --- a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyActivity.java +++ b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyActivity.java @@ -254,7 +254,7 @@ public final class AndroidacyActivity extends FoxActivity { Log.e(TAG, consoleMessage.message()); break; case DEBUG: - Log.d(TAG, consoleMessage.message()); + Log.i(TAG, consoleMessage.message()); break; } } @@ -377,12 +377,12 @@ public final class AndroidacyActivity extends FoxActivity { private boolean megaIntercept(String pageUrl, String fileUrl) { if (pageUrl == null || fileUrl == null) return false; if (this.isFileUrl(fileUrl)) { - Log.d(TAG, "megaIntercept(" + AndroidacyUtil.hideToken(pageUrl) + ", " + AndroidacyUtil.hideToken(fileUrl) + ")"); + Log.i(TAG, "megaIntercept(" + AndroidacyUtil.hideToken(pageUrl) + ", " + AndroidacyUtil.hideToken(fileUrl) + ")"); } else return false; final AndroidacyWebAPI androidacyWebAPI = this.androidacyWebAPI; String moduleId = AndroidacyUtil.getModuleId(fileUrl); if (moduleId == null) { - Log.d(TAG, "No module id?"); + Log.i(TAG, "No module id?"); // Re-open the page this.webView.loadUrl(pageUrl + "&force_refresh=" + System.currentTimeMillis()); } diff --git a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java index b9258ae..e2b2dbc 100644 --- a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java +++ b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java @@ -251,7 +251,7 @@ public final class AndroidacyRepoData extends RepoData { @Override protected List populate(JSONObject jsonObject) throws JSONException, NoSuchAlgorithmException { if (BuildConfig.DEBUG) { - Log.d(TAG, "AndroidacyRepoData populate start"); + Log.i(TAG, "AndroidacyRepoData populate start"); } if (!jsonObject.getString("status").equals("success")) throw new JSONException("Response is not a success!"); @@ -330,7 +330,7 @@ public final class AndroidacyRepoData extends RepoData { String config = jsonObject.optString("config", ""); moduleInfo.config = config.isEmpty() ? null : config; PropUtils.applyFallbacks(moduleInfo); // Apply fallbacks - // Log.d(TAG, + // Log.i(TAG, // "Module " + moduleInfo.name + " " + moduleInfo.id + " " + moduleInfo // .version + " " + moduleInfo.versionCode); } diff --git a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyWebAPI.java b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyWebAPI.java index 13ca53b..af42596 100644 --- a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyWebAPI.java +++ b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyWebAPI.java @@ -63,7 +63,7 @@ public class AndroidacyWebAPI { void openNativeModuleDialogRaw(String moduleUrl, String moduleId, String installTitle, String checksum, boolean canInstall) { - if (BuildConfig.DEBUG) Log.d(TAG, "ModuleDialog, downloadUrl: " + AndroidacyUtil.hideToken(moduleUrl) + + if (BuildConfig.DEBUG) Log.i(TAG, "ModuleDialog, downloadUrl: " + AndroidacyUtil.hideToken(moduleUrl) + ", moduleId: " + moduleId + ", installTitle: " + installTitle + ", checksum: " + checksum + ", canInstall: " + canInstall); this.downloadMode = false; @@ -145,7 +145,7 @@ public class AndroidacyWebAPI { void notifyCompatModeRaw(int value) { if (this.consumedAction) return; - if (BuildConfig.DEBUG) Log.d(TAG, "Androidacy Compat mode: " + value); + if (BuildConfig.DEBUG) Log.i(TAG, "Androidacy Compat mode: " + value); this.notifiedCompatMode = value; if (value < 0) { value = 0; @@ -180,7 +180,7 @@ public class AndroidacyWebAPI { if (this.consumedAction) return; this.consumedAction = true; this.downloadMode = false; - if (BuildConfig.DEBUG) Log.d(TAG, "Received openUrl request: " + url); + if (BuildConfig.DEBUG) Log.i(TAG, "Received openUrl request: " + url); if (Uri.parse(url).getScheme().equals("https")) { IntentHelper.openUrl(this.activity, url); } @@ -194,7 +194,7 @@ public class AndroidacyWebAPI { if (this.consumedAction) return; this.consumedAction = true; this.downloadMode = false; - if (BuildConfig.DEBUG) Log.d(TAG, "Received openCustomTab request: " + url); + if (BuildConfig.DEBUG) Log.i(TAG, "Received openCustomTab request: " + url); if (Uri.parse(url).getScheme().equals("https")) { IntentHelper.openCustomTab(this.activity, url); } @@ -238,7 +238,7 @@ public class AndroidacyWebAPI { } this.consumedAction = true; this.downloadMode = false; - if (BuildConfig.DEBUG) Log.d(TAG, "Received install request: " + + if (BuildConfig.DEBUG) Log.i(TAG, "Received install request: " + moduleUrl + " " + installTitle + " " + checksum); if (!AndroidacyUtil.isAndroidacyLink(moduleUrl)) { this.forceQuitRaw("Non Androidacy module link used on Androidacy"); diff --git a/app/src/main/java/com/fox2code/mmm/installer/InstallerActivity.java b/app/src/main/java/com/fox2code/mmm/installer/InstallerActivity.java index 07cd4b7..09bf325 100644 --- a/app/src/main/java/com/fox2code/mmm/installer/InstallerActivity.java +++ b/app/src/main/java/com/fox2code/mmm/installer/InstallerActivity.java @@ -179,7 +179,7 @@ public class InstallerActivity extends FoxActivity { if (this.canceled) return; androidacyBlame = urlMode && AndroidacyUtil.isAndroidacyFileUrl(target); if (checksum != null && !checksum.isEmpty()) { - Log.d(TAG, "Checking for checksum: " + checksum); + Log.i(TAG, "Checking for checksum: " + checksum); this.runOnUiThread(() -> this.installerTerminal.addLine("- Checking file integrity")); if (!Hashes.checkSumMatch(rawModule, checksum)) { this.setInstallStateFinished(false, @@ -304,7 +304,7 @@ public class InstallerActivity extends FoxActivity { } } } catch (Exception e) { - Log.d(TAG, "Failed ot extract install script via java code", e); + Log.i(TAG, "Failed ot extract install script via java code", e); } installerMonitor = new InstallerMonitor(installScript); installJob = Shell.cmd("export MMM_EXT_SUPPORT=1", @@ -541,7 +541,7 @@ public class InstallerActivity extends FoxActivity { @Override public void onAddElement(String s) { if (!this.enabled) return; - Log.d(TAG, "MSG: " + s); + Log.i(TAG, "MSG: " + s); if ("#!useExt".equals(s.trim()) && !this.noExtension) { this.useExt = true; return; @@ -694,7 +694,7 @@ public class InstallerActivity extends FoxActivity { @Override public void onAddElement(String s) { - Log.d(TAG, "Monitor: " + s); + Log.i(TAG, "Monitor: " + s); this.lastCommand = s; } diff --git a/app/src/main/java/com/fox2code/mmm/installer/InstallerInitializer.java b/app/src/main/java/com/fox2code/mmm/installer/InstallerInitializer.java index d5af961..b5eda4c 100644 --- a/app/src/main/java/com/fox2code/mmm/installer/InstallerInitializer.java +++ b/app/src/main/java/com/fox2code/mmm/installer/InstallerInitializer.java @@ -138,9 +138,9 @@ public class InstallerInitializer extends Shell.Initializer { return null; } MAGISK_PATH = output.size() < 3 ? "" : output.get(2); - Log.d(TAG, "Magisk runtime path: " + MAGISK_PATH); + Log.i(TAG, "Magisk runtime path: " + MAGISK_PATH); MAGISK_VERSION_CODE = Integer.parseInt(output.get(1)); - Log.d(TAG, "Magisk version code: " + MAGISK_VERSION_CODE); + Log.i(TAG, "Magisk version code: " + MAGISK_VERSION_CODE); if (MAGISK_VERSION_CODE >= Constants.MAGISK_VER_CODE_FLAT_MODULES && MAGISK_VERSION_CODE < Constants.MAGISK_VER_CODE_PATH_SUPPORT && (MAGISK_PATH.isEmpty() || !new File(MAGISK_PATH).exists())) { diff --git a/app/src/main/java/com/fox2code/mmm/manager/ModuleManager.java b/app/src/main/java/com/fox2code/mmm/manager/ModuleManager.java index 3d8888a..8e24781 100644 --- a/app/src/main/java/com/fox2code/mmm/manager/ModuleManager.java +++ b/app/src/main/java/com/fox2code/mmm/manager/ModuleManager.java @@ -70,12 +70,12 @@ public final class ModuleManager extends SyncManager { if (!FORCE_NEED_FALLBACK && needFallback) { Log.e(TAG, "Failed to detect modules folder, using fallback instead."); } - if (BuildConfig.DEBUG) Log.d("NoodleDebug", "Scan"); + if (BuildConfig.DEBUG) Log.i("NoodleDebug", "Scan"); if (modules != null) { for (String module : modules) { if (!new SuFile("/data/adb/modules/" + module).isDirectory()) continue; // Ignore non directory files inside modules folder - if (BuildConfig.DEBUG) Log.d("NoodleDebug", module); + if (BuildConfig.DEBUG) Log.i("NoodleDebug", module); LocalModuleInfo moduleInfo = moduleInfos.get(module); if (moduleInfo == null) { moduleInfo = new LocalModuleInfo(module); @@ -113,18 +113,18 @@ public final class ModuleManager extends SyncManager { PropUtils.readProperties(moduleInfo, "/data/adb/modules/" + module + "/module.prop", true); } catch (Exception e) { - if (BuildConfig.DEBUG) Log.d(TAG, "Failed to parse metadata!", e); + if (BuildConfig.DEBUG) Log.i(TAG, "Failed to parse metadata!", e); moduleInfo.flags |= FLAG_MM_INVALID; } } } - if (BuildConfig.DEBUG) Log.d("NoodleDebug", "Scan update"); + if (BuildConfig.DEBUG) Log.i("NoodleDebug", "Scan update"); String[] modules_update = new SuFile("/data/adb/modules_update").list(); if (modules_update != null) { for (String module : modules_update) { if (!new SuFile("/data/adb/modules_update/" + module).isDirectory()) continue; // Ignore non directory files inside modules folder - if (BuildConfig.DEBUG) Log.d("NoodleDebug", module); + if (BuildConfig.DEBUG) Log.i("NoodleDebug", module); LocalModuleInfo moduleInfo = moduleInfos.get(module); if (moduleInfo == null) { moduleInfo = new LocalModuleInfo(module); @@ -136,18 +136,18 @@ public final class ModuleManager extends SyncManager { PropUtils.readProperties(moduleInfo, "/data/adb/modules_update/" + module + "/module.prop", true); } catch (Exception e) { - if (BuildConfig.DEBUG) Log.d(TAG, "Failed to parse metadata!", e); + if (BuildConfig.DEBUG) Log.i(TAG, "Failed to parse metadata!", e); moduleInfo.flags |= FLAG_MM_INVALID; } } } - if (BuildConfig.DEBUG) Log.d("NoodleDebug", "Finalize scan"); + if (BuildConfig.DEBUG) Log.i("NoodleDebug", "Finalize scan"); this.updatableModuleCount = 0; Iterator moduleInfoIterator = this.moduleInfos.values().iterator(); while (moduleInfoIterator.hasNext()) { LocalModuleInfo moduleInfo = moduleInfoIterator.next(); - if (BuildConfig.DEBUG) Log.d("NoodleDebug", moduleInfo.id); + if (BuildConfig.DEBUG) Log.i("NoodleDebug", moduleInfo.id); if ((moduleInfo.flags & FLAG_MM_UNPROCESSED) != 0) { moduleInfoIterator.remove(); continue; // Don't process fallbacks if unreferenced diff --git a/app/src/main/java/com/fox2code/mmm/markdown/MarkdownActivity.java b/app/src/main/java/com/fox2code/mmm/markdown/MarkdownActivity.java index 2ee481f..e495575 100644 --- a/app/src/main/java/com/fox2code/mmm/markdown/MarkdownActivity.java +++ b/app/src/main/java/com/fox2code/mmm/markdown/MarkdownActivity.java @@ -36,7 +36,6 @@ import java.nio.charset.StandardCharsets; import java.util.HashMap; import eightbitlab.com.blurview.BlurView; -import eightbitlab.com.blurview.RenderScriptBlur; public class MarkdownActivity extends FoxActivity { private static final String TAG = "MarkdownActivity"; @@ -147,11 +146,11 @@ public class MarkdownActivity extends FoxActivity { new Thread(() -> { try { - Log.d(TAG, "Downloading"); + Log.i(TAG, "Downloading"); byte[] rawMarkdown = getRawMarkdown(url); - Log.d(TAG, "Encoding"); + Log.i(TAG, "Encoding"); String markdown = new String(rawMarkdown, StandardCharsets.UTF_8); - Log.d(TAG, "Done!"); + Log.i(TAG, "Done!"); runOnUiThread(() -> { findViewById(R.id.markdownFooter) .setMinimumHeight(this.getNavigationBarHeight()); diff --git a/app/src/main/java/com/fox2code/mmm/markdown/MarkdownUrlLinker.java b/app/src/main/java/com/fox2code/mmm/markdown/MarkdownUrlLinker.java index 575c860..8e75ac3 100644 --- a/app/src/main/java/com/fox2code/mmm/markdown/MarkdownUrlLinker.java +++ b/app/src/main/java/com/fox2code/mmm/markdown/MarkdownUrlLinker.java @@ -29,7 +29,7 @@ public class MarkdownUrlLinker { linkifyTasks.add(new LinkifyTask(index, end)); extra += (end - index) + 4; if (BuildConfig.DEBUG) { - Log.d(TAG, "Linkify url: " + url.substring(index, end)); + Log.i(TAG, "Linkify url: " + url.substring(index, end)); } } } @@ -45,7 +45,7 @@ public class MarkdownUrlLinker { prev = linkifyTask; } if (prev.end != url.length()) stringBuilder.append(url, prev.end, url.length()); - Log.d(TAG, "Added Markdown link to " + linkifyTasks.size() + " urls"); + Log.i(TAG, "Added Markdown link to " + linkifyTasks.size() + " urls"); return stringBuilder.toString(); } diff --git a/app/src/main/java/com/fox2code/mmm/module/ActionButtonType.java b/app/src/main/java/com/fox2code/mmm/module/ActionButtonType.java index 58376fc..e3031bd 100644 --- a/app/src/main/java/com/fox2code/mmm/module/ActionButtonType.java +++ b/app/src/main/java/com/fox2code/mmm/module/ActionButtonType.java @@ -112,7 +112,7 @@ public enum ActionButtonType { } else { builder.setMessage(desc); } - Log.d("Test", "URL: " + updateZipUrl); + Log.i("Test", "URL: " + updateZipUrl); builder.setNegativeButton(R.string.download_module, (x, y) -> { IntentHelper.openCustomTab(button.getContext(), updateZipUrl); }); @@ -164,7 +164,7 @@ public enum ActionButtonType { doActionLong(button, moduleHolder); return; } - Log.d("ActionButtonType", Integer.toHexString(moduleHolder.moduleInfo.flags)); + Log.i("ActionButtonType", Integer.toHexString(moduleHolder.moduleInfo.flags)); if (!ModuleManager.getINSTANCE().setUninstallState(moduleHolder.moduleInfo, !moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_UNINSTALLING))) { Log.e("ActionButtonType", "Failed to switch uninstalled state!"); diff --git a/app/src/main/java/com/fox2code/mmm/repo/RepoData.java b/app/src/main/java/com/fox2code/mmm/repo/RepoData.java index 7820678..d736b28 100644 --- a/app/src/main/java/com/fox2code/mmm/repo/RepoData.java +++ b/app/src/main/java/com/fox2code/mmm/repo/RepoData.java @@ -209,7 +209,7 @@ public class RepoData extends XRepo { public void setEnabled(boolean enabled) { this.enabled = enabled && !this.forceHide; if (BuildConfig.DEBUG) { - Log.d("RepoData", + Log.i("RepoData", "Repo " + this.id + " enabled: " + this.enabled + " (forced: " + this.forceHide + ") with preferenceID: " + this.getPreferenceId()); } MainApplication.getSharedPreferences().edit() @@ -223,7 +223,7 @@ public class RepoData extends XRepo { } this.forceHide = AppUpdateManager.shouldForceHide(this.id); if (BuildConfig.DEBUG) { - Log.d("RepoData", + Log.i("RepoData", "Repo " + this.id + " update enabled: " + this.enabled + " (forced: " + this.forceHide + ") with preferenceID: " + this.getPreferenceId()); } this.enabled = (!this.forceHide) && MainApplication.getSharedPreferences() diff --git a/app/src/main/java/com/fox2code/mmm/repo/RepoManager.java b/app/src/main/java/com/fox2code/mmm/repo/RepoManager.java index 203775e..3375c60 100644 --- a/app/src/main/java/com/fox2code/mmm/repo/RepoManager.java +++ b/app/src/main/java/com/fox2code/mmm/repo/RepoManager.java @@ -232,18 +232,18 @@ public final class RepoManager extends SyncManager { RepoUpdater[] repoUpdaters = new RepoUpdater[repoDatas.length]; int moduleToUpdate = 0; for (int i = 0; i < repoDatas.length; i++) { - if (BuildConfig.DEBUG) Log.d("RepoManager", "Fetching: " + repoDatas[i].getName()); + if (BuildConfig.DEBUG) Log.i("RepoManager", "Fetching: " + repoDatas[i].getName()); moduleToUpdate += (repoUpdaters[i] = new RepoUpdater(repoDatas[i])).fetchIndex(); updateListener.update(STEP1 / repoDatas.length * (i + 1)); } - if (BuildConfig.DEBUG) Log.d("RepoManag3er", "Updating meta-data"); + if (BuildConfig.DEBUG) Log.i("RepoManag3er", "Updating meta-data"); int updatedModules = 0; boolean allowLowQualityModules = MainApplication.isDisableLowQualityModuleFilter(); for (int i = 0; i < repoUpdaters.length; i++) { // Check if the repo is enabled if (!repoUpdaters[i].repoData.isEnabled()) { - if (BuildConfig.DEBUG) Log.d("RepoManager", + if (BuildConfig.DEBUG) Log.i("RepoManager", "Skipping disabled repo: " + repoUpdaters[i].repoData.getName()); // Remove the repo from the list try { @@ -256,7 +256,7 @@ public final class RepoManager extends SyncManager { } List repoModules = repoUpdaters[i].toUpdate(); RepoData repoData = repoDatas[i]; - if (BuildConfig.DEBUG) Log.d("RepoManager", "Registering " + repoData.getName()); + if (BuildConfig.DEBUG) Log.i("RepoManager", "Registering " + repoData.getName()); for (RepoModule repoModule : repoModules) { try { if (repoModule.propUrl != null && @@ -295,7 +295,7 @@ public final class RepoManager extends SyncManager { } } } - if (BuildConfig.DEBUG) Log.d("RepoManager", "Finishing update"); + if (BuildConfig.DEBUG) Log.i("RepoManager", "Finishing update"); this.hasInternet = false; // Check if we have internet connection // Attempt to contact connectivitycheck.gstatic.com/generate_204 @@ -318,11 +318,11 @@ public final class RepoManager extends SyncManager { for (int i = 0; i < repoDatas.length; i++) { // If repo is not enabled, skip if (!repoDatas[i].isEnabled()) { - if (BuildConfig.DEBUG) Log.d("RepoManager", + if (BuildConfig.DEBUG) Log.i("RepoManager", "Skipping " + repoDatas[i].getName() + " because it's disabled"); continue; } - if (BuildConfig.DEBUG) Log.d("RepoManager", + if (BuildConfig.DEBUG) Log.i("RepoManager", "Finishing: " + repoUpdaters[i].repoData.getName()); this.repoLastSuccess = repoUpdaters[i].finish(); if (!this.repoLastSuccess) { diff --git a/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java b/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java index befc5c3..76abda3 100644 --- a/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java +++ b/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java @@ -10,7 +10,6 @@ import org.json.JSONObject; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -83,7 +82,7 @@ public class RepoUpdater { try { Files.write(this.repoData.metaDataCache, this.indexRaw); if (BuildConfig.DEBUG) { - Log.d(TAG, "Wrote index of " + this.repoData.id); + Log.i(TAG, "Wrote index of " + this.repoData.id); } } catch (IOException e) { e.printStackTrace(); diff --git a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java index 0ed1f7b..e75ac46 100644 --- a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java +++ b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java @@ -126,7 +126,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { } if (BuildConfig.DEBUG) { - Log.d(TAG, "getDevicePerformanceClass: androidVersion=" + androidVersion + " cpuCount=" + cpuCount + " memoryClass=" + memoryClass + " maxCpuFreq=" + maxCpuFreq + " devicePerformanceClass=" + devicePerformanceClass); + Log.i(TAG, "getDevicePerformanceClass: androidVersion=" + androidVersion + " cpuCount=" + cpuCount + " memoryClass=" + memoryClass + " maxCpuFreq=" + maxCpuFreq + " devicePerformanceClass=" + devicePerformanceClass); } return devicePerformanceClass; @@ -177,7 +177,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { // If transparent theme(s) are set, disable monet if (themePreference.getValue().equals("transparent_light")) { if (BuildConfig.DEBUG) { - Log.d(TAG, "Transparent theme is set, disabling monet"); + Log.i(TAG, "Transparent theme is set, disabling monet"); } findPreference("pref_enable_monet").setEnabled(false); // Toggle monet off @@ -201,7 +201,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { }); themePreference.setOnPreferenceChangeListener((preference, newValue) -> { if (BuildConfig.DEBUG) { - Log.d(TAG, "Theme changed, refreshing activity. New value: " + newValue); + Log.i(TAG, "Theme changed, refreshing activity. New value: " + newValue); } // Immediately save SharedPreferences.Editor editor = @@ -210,7 +210,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { // If theme contains "transparent" then disable monet if (newValue.toString().contains("transparent")) { if (BuildConfig.DEBUG) { - Log.d(TAG, "Transparent theme is being set, disabling monet"); + Log.i(TAG, "Transparent theme is being set, disabling monet"); } // Show a dialogue warning the user about issues with transparent themes and // that blur/monet will be disabled @@ -285,7 +285,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { AlarmManager mgr = (AlarmManager) requireContext().getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent); if (BuildConfig.DEBUG) { - Log.d(TAG, "Restarting app to save crash reporting preference: " + newValue); + Log.i(TAG, "Restarting app to save crash reporting preference: " + newValue); } System.exit(0); // Exit app process }); @@ -397,7 +397,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { if (!SentryMain.IS_SENTRY_INSTALLED || !BuildConfig.DEBUG || InstallerInitializer.peekMagiskPath() == null) { // Hide the pref_crash option if not in debug mode - stop users from purposely crashing the app - Log.d(TAG, String.format("Sentry installed: %s, debug: %s, magisk path: %s", + Log.i(TAG, String.format("Sentry installed: %s, debug: %s, magisk path: %s", SentryMain.IS_SENTRY_INSTALLED, BuildConfig.DEBUG, InstallerInitializer.peekMagiskPath())); Objects.requireNonNull((Preference) findPreference("pref_test_crash")).setVisible(false); // Find pref_clear_data and set it invisible @@ -663,7 +663,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { AlarmManager mgr = (AlarmManager) requireContext().getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent); if (BuildConfig.DEBUG) { - Log.d(TAG, "Restarting app to save staging endpoint preference: " + newValue); + Log.i(TAG, "Restarting app to save staging endpoint preference: " + newValue); } System.exit(0); // Exit app process }) @@ -695,7 +695,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { AlarmManager mgr = (AlarmManager) requireContext().getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent); if (BuildConfig.DEBUG) { - Log.d(TAG, "Restarting app to save staging endpoint preference: " + newValue); + Log.i(TAG, "Restarting app to save staging endpoint preference: " + newValue); } System.exit(0); // Exit app process }) @@ -728,7 +728,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { return false; }); } - String[] originalApiKeyRef = new String[]{MainApplication.getINSTANCE().getSharedPreferences("androidacy", 0).getString("pref_androidacy_api_token", null)}; + String[] originalApiKeyRef = new String[]{MainApplication.getINSTANCE().getSharedPreferences("androidacy", 0).getString("pref_androidacy_api_token", "")}; // Get the dummy pref_androidacy_repo_api_token EditTextPreference EditTextPreference prefAndroidacyRepoApiKey = Objects.requireNonNull(findPreference("pref_androidacy_api_token")); prefAndroidacyRepoApiKey.setTitle(R.string.api_key); @@ -748,6 +748,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { }); prefAndroidacyRepoApiKey.setPositiveButtonText(R.string.save_api_key); prefAndroidacyRepoApiKey.setOnPreferenceChangeListener((preference, newValue) -> { + // Make sure originalApiKeyRef is not null if (originalApiKeyRef[0].equals(newValue)) return true; // get original api key String apiKey = String.valueOf(newValue); @@ -781,7 +782,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { AlarmManager mgr = (AlarmManager) requireContext().getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent); if (BuildConfig.DEBUG) { - Log.d(TAG, "Restarting app to save token preference: " + newValue); + Log.i(TAG, "Restarting app to save token preference: " + newValue); } System.exit(0); // Exit app process }) @@ -834,7 +835,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { AlarmManager mgr = (AlarmManager) requireContext().getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent); if (BuildConfig.DEBUG) { - Log.d(TAG, "Restarting app to save token preference: " + newValue); + Log.i(TAG, "Restarting app to save token preference: " + newValue); } System.exit(0); // Exit app process }) diff --git a/app/src/main/java/com/fox2code/mmm/utils/ExternalHelper.java b/app/src/main/java/com/fox2code/mmm/utils/ExternalHelper.java index 75be7ff..a2a4471 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/ExternalHelper.java +++ b/app/src/main/java/com/fox2code/mmm/utils/ExternalHelper.java @@ -40,13 +40,13 @@ public final class ExternalHelper { List resolveInfos = context.getPackageManager() .queryIntentActivities(intent, PackageManager.GET_RESOLVED_FILTER); if (resolveInfos == null || resolveInfos.isEmpty()) { - Log.d(TAG, "No external provider installed!"); + Log.i(TAG, "No external provider installed!"); label = TEST_MODE ? "External" : null; multi = TEST_MODE; fallback = null; } else { ResolveInfo resolveInfo = resolveInfos.get(0); - Log.d(TAG, "Found external provider: " + resolveInfo.activityInfo.packageName); + Log.i(TAG, "Found external provider: " + resolveInfo.activityInfo.packageName); fallback = new ComponentName( resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name); diff --git a/app/src/main/java/com/fox2code/mmm/utils/Hashes.java b/app/src/main/java/com/fox2code/mmm/utils/Hashes.java index 26e39fa..8c2e207 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/Hashes.java +++ b/app/src/main/java/com/fox2code/mmm/utils/Hashes.java @@ -87,7 +87,7 @@ public class Hashes { checksum.length() * 8 + "bit checksums"); return false; } - Log.d(TAG, "Checksum result (data: " + hash+ ",expected: " + checksum + ")"); + Log.i(TAG, "Checksum result (data: " + hash+ ",expected: " + checksum + ")"); return hash.equals(checksum.toLowerCase(Locale.ROOT)); } @@ -116,7 +116,7 @@ public class Hashes { } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } - Log.d(TAG, "Checksum result (data: " + hash + ",expected: " + checksum + ")"); + Log.i(TAG, "Checksum result (data: " + hash + ",expected: " + checksum + ")"); return hash.equals(checksum.toLowerCase(Locale.ROOT)); } diff --git a/app/src/main/java/com/fox2code/mmm/utils/Http.java b/app/src/main/java/com/fox2code/mmm/utils/Http.java index a775cda..3fd5ee7 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/Http.java +++ b/app/src/main/java/com/fox2code/mmm/utils/Http.java @@ -230,7 +230,6 @@ public class Http { @SuppressLint("RestrictedApi") @SuppressWarnings("resource") public static byte[] doHttpGet(String url, boolean allowCache) throws IOException { - checkNeedBlockAndroidacyRequest(url); Response response = (allowCache ? getHttpClientWithCache() : getHttpClient()).newCall(new Request.Builder().url(url).get().build()).execute(); // 200/204 == success, 304 == cache valid if (response.code() != 200 && response.code() != 204 && (response.code() != 304 || !allowCache)) { @@ -238,6 +237,7 @@ public class Http { checkNeedCaptchaAndroidacy(url, response.code()); // If it's a 401, and an androidacy link, it's probably an invalid token if (response.code() == 401 && AndroidacyUtil.isAndroidacyLink(url)) { + // Regenerate the token throw new HttpException("Androidacy token is invalid", 401); } throw new HttpException(response.code()); @@ -257,8 +257,7 @@ public class Http { @SuppressWarnings("resource") private static Object doHttpPostRaw(String url, String data, boolean allowCache) throws IOException { - if (BuildConfig.DEBUG) Log.d(TAG, "POST " + url + " " + data); - checkNeedBlockAndroidacyRequest(url); + if (BuildConfig.DEBUG) Log.i(TAG, "POST " + url + " " + data); Response response; response = (allowCache ? getHttpClientWithCache() : getHttpClient()).newCall(new Request.Builder().url(url).post(JsonRequestBody.from(data)).header("Content-Type", "application/json").build()).execute(); if (response.isRedirect()) { @@ -281,8 +280,7 @@ public class Http { } public static byte[] doHttpGet(String url, ProgressListener progressListener) throws IOException { - if (BuildConfig.DEBUG) Log.d("Http", "Progress URL: " + url); - checkNeedBlockAndroidacyRequest(url); + if (BuildConfig.DEBUG) Log.i("Http", "GET " + url.split("\\?")[0]); Response response = getHttpClient().newCall(new Request.Builder().url(url).get().build()).execute(); if (response.code() != 200 && response.code() != 204) { Log.e(TAG, "Failed to fetch " + url + ", code: " + response.code()); @@ -302,7 +300,7 @@ public class Http { final long UPDATE_INTERVAL = 100; long nextUpdate = System.currentTimeMillis() + UPDATE_INTERVAL; long currentUpdate; - Log.d("Http", "Target: " + target + " Divider: " + divider); + Log.i("Http", "Target: " + target + " Divider: " + divider); progressListener.onUpdate(0, (int) (target / divider), false); while (true) { int read = inputStream.read(buff); @@ -331,7 +329,7 @@ public class Http { } public static void setDoh(boolean doh) { - Log.d(TAG, "DoH: " + Http.doh + " -> " + doh); + Log.i(TAG, "DoH: " + Http.doh + " -> " + doh); Http.doh = doh; } diff --git a/app/src/main/java/com/fox2code/mmm/utils/IntentHelper.java b/app/src/main/java/com/fox2code/mmm/utils/IntentHelper.java index 38ced15..4c89330 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/IntentHelper.java +++ b/app/src/main/java/com/fox2code/mmm/utils/IntentHelper.java @@ -155,7 +155,7 @@ public class IntentHelper { .to(new CallbackList() { @Override public void onAddElement(String str) { - Log.d(TAG, "LSPosed: " + str); + Log.i(TAG, "LSPosed: " + str); } }).submit(); return; @@ -360,7 +360,7 @@ public class IntentHelper { callback.onReceived(destination, null, RESPONSE_ERROR); return; } - Log.d(TAG, "FilePicker returned " + uri); + Log.i(TAG, "FilePicker returned " + uri); if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())) { callback.onReceived(destination, uri, RESPONSE_URL); @@ -390,7 +390,7 @@ public class IntentHelper { } outputStream = new FileOutputStream(destination); Files.copy(inputStream, outputStream); - Log.d(TAG, "File saved at " + destination); + Log.i(TAG, "File saved at " + destination); success = true; } catch (Exception e) { Log.e(TAG, "failed copy of " + uri, e); diff --git a/app/src/main/java/com/fox2code/mmm/utils/ProcessHelper.java b/app/src/main/java/com/fox2code/mmm/utils/ProcessHelper.java index 69e7f6f..ede43a4 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/ProcessHelper.java +++ b/app/src/main/java/com/fox2code/mmm/utils/ProcessHelper.java @@ -7,8 +7,10 @@ import android.content.Intent; import com.fox2code.mmm.MainActivity; +import java.util.concurrent.ThreadLocalRandom; + public class ProcessHelper { - private static final int sPendingIntentId = 123456; + private static final int sPendingIntentId = ThreadLocalRandom.current().nextInt(100, 1000000 + 1); public static void restartApplicationProcess(Context context) { Intent mStartActivity = new Intent(context, MainActivity.class); diff --git a/app/src/main/java/com/fox2code/mmm/utils/PropUtils.java b/app/src/main/java/com/fox2code/mmm/utils/PropUtils.java index 14086df..568f76f 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/PropUtils.java +++ b/app/src/main/java/com/fox2code/mmm/utils/PropUtils.java @@ -342,7 +342,7 @@ public class PropUtils { } } } catch (IOException e) { - Log.d("PropUtils", "Failed to get moduleId", e); + Log.i("PropUtils", "Failed to get moduleId", e); } return moduleId; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ee982d2..5a3e9d7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -236,5 +236,5 @@ Skip Enabling blur on lower-end device You are trying to enable blur on a device that may not perform well with it.\nYou may enable it, but this may lead to a poor user experience and we recommend you don\'t. - This repo has less restrictions and reviews, which may lead to lower quality modules. Pretty barebones but has a lot of modules.You are about to reboot your device. If you\'ve saved your work, hit ok to continue. Otherwise, hit cancel.Package %s is missing for module config, so we cannot launch it.Clear app dataClear app data?You\'re about to clear the app data. Please confirm this action. + This repo has less restrictions and reviews, which may lead to lower quality modules. Pretty barebones but has a lot of modules.You are about to reboot your device. If you\'ve saved your work, hit ok to continue. Otherwise, hit cancel.Package %s is missing for module config, so we cannot launch it.Clear app dataClear app data?You\'re about to clear the app data. Please confirm this action.This is a debug build. Expect some bugs and worse performance.