Skip to content

Commit

Permalink
OplusStartingWindowManager: added date in log file
Browse files Browse the repository at this point in the history
Signed-off-by: DHD2280 <[email protected]>
  • Loading branch information
DHD2280 committed Dec 11, 2024
1 parent 3886980 commit 4d6c3b3
Showing 1 changed file with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
}
};
Expand All @@ -63,19 +64,18 @@ public OplusStartingWindowManager(Context context) {

@Override
public void updatePrefs(String... Key) {
if (Xprefs == null) return;

if (settingsUpdated) return;

mEnableLagFix = Xprefs.getBoolean("fix_lag_switch", false);
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
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down

0 comments on commit 4d6c3b3

Please sign in to comment.