From 4d6c3b3d3246f7dfdada84945aabfe4193ef5086 Mon Sep 17 00:00:00 2001 From: DHD2280 Date: Wed, 11 Dec 2024 20:32:50 +0100 Subject: [PATCH] OplusStartingWindowManager: added date in log file Signed-off-by: DHD2280 --- .../framework/OplusStartingWindowManager.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/framework/OplusStartingWindowManager.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/framework/OplusStartingWindowManager.java index 545a8f249..f4b7bfdb6 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/framework/OplusStartingWindowManager.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/framework/OplusStartingWindowManager.java @@ -6,6 +6,7 @@ import static it.dhd.oxygencustomizer.utils.Constants.Packages.FRAMEWORK; import static it.dhd.oxygencustomizer.xposed.XPrefs.Xprefs; +import android.annotation.SuppressLint; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -21,6 +22,7 @@ import java.util.Set; import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.callbacks.XC_LoadPackage; import it.dhd.oxygencustomizer.utils.Constants; import it.dhd.oxygencustomizer.xposed.XPLauncher; @@ -30,7 +32,6 @@ public class OplusStartingWindowManager extends XposedMods { private final static String listenPackage = FRAMEWORK; - private final static String TAG = "Oxygen Customizer - OplusStartingWindowManager: "; private final String LOG_FILE = Environment.getExternalStorageDirectory() + "/.oxygen_customizer/OplusStartingWindowManager_fix.log"; private boolean mEnableLagFix = false; private boolean mForceAllApps = false; @@ -44,14 +45,14 @@ public void onReceive(Context context, Intent intent) { if (action == null) return; String className = intent.getStringExtra("class"); if (action.equals(Constants.ACTION_SETTINGS_CHANGED)) { - if (!TextUtils.isEmpty(className) && className.equals(OplusStartingWindowManager.class.getSimpleName())) { - log("OplusStartingWindowManager: Intent received - will update preferences"); + if (!TextUtils.isEmpty(className) && className.equals(this.getClass().getSimpleName())) { + log("Intent received - will update preferences"); settingsUpdated = false; updatePrefs(); } } } catch (Throwable t) { - log("OplusStartingWindowManager: " + t.getMessage()); + log(t); } } }; @@ -63,7 +64,6 @@ public OplusStartingWindowManager(Context context) { @Override public void updatePrefs(String... Key) { - if (Xprefs == null) return; if (settingsUpdated) return; @@ -71,11 +71,11 @@ public void updatePrefs(String... Key) { mForceAllApps = Xprefs.getBoolean("fix_lag_force_all_apps", false); mLagFixApps = Xprefs.getStringSet("lag_fix_apps", null); - XPLauncher.enqueueProxyCommand((proxy) -> { - proxy.runCommand("echo " + getFormattedDate() + " - updatePrefs: Enabled Lag Fix: " + mEnableLagFix + " Force All Apps: " + mForceAllApps + " Lag Fix Apps: " + mLagFixApps + " >> " + LOG_FILE); - }); - - settingsUpdated = true; + log("Enabled Lag Fix: " + mEnableLagFix + " Force All Apps: " + mForceAllApps + " Lag Fix Apps: " + mLagFixApps); + try { + XPLauncher.enqueueProxyCommand((proxy) -> proxy.runCommand("echo " + getFormattedDate() + " - updatePrefs: Enabled Lag Fix: " + mEnableLagFix + " Force All Apps: " + mForceAllApps + " Lag Fix Apps: " + mLagFixApps + " >> " + LOG_FILE)); + } catch (Throwable ignored) { + } } @Override @@ -116,7 +116,7 @@ protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Th String layer = (String) param.args[0]; if (TextUtils.isEmpty(layer)) { XPLauncher.enqueueProxyCommand((proxy) -> - proxy.runCommand("echo " + getFormattedDate() + " - layer is empty, return false >> " + LOG_FILE)); + proxy.runCommand("echo " + getFormattedDate() + " - layer is empty, return >> " + LOG_FILE)); return; } if (mLagFixApps != null) { @@ -136,14 +136,13 @@ protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Th } }); } catch (Throwable t) { - log(" error: " + t.getMessage()); + log(t); } - } private String getFormattedDate() { - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss:SSS"); + @SuppressLint("SimpleDateFormat") SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-HH:mm:ss:SSS"); Date now = new Date(); return sdf.format(now); }