Skip to content

Commit

Permalink
opt: add Try to fix LSPosed log service
Browse files Browse the repository at this point in the history
  • Loading branch information
Sevtinge committed Aug 30, 2024
1 parent 749756d commit e23187b
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
new Thread(() -> SearchHelper.getAllMods(MainActivity.this, savedInstanceState != null)).start();
Helpers.checkXposedActivateState(this);
if (!IS_LOGGER_ALIVE && BuildConfig.BUILD_TYPE != "release") {
if (!IS_LOGGER_ALIVE && BuildConfig.BUILD_TYPE != "release" && !mPrefs.getBoolean("prefs_key_development_close_log_alert_dialog", false)) {
handler.post(() -> new AlertDialog.Builder(context)
.setCancelable(false)
.setTitle(getResources().getString(R.string.warn))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package com.sevtinge.hyperceiler.ui.fragment.base.settings.development;

import static com.sevtinge.hyperceiler.utils.log.LogManager.fixLsposedLogService;
import static com.sevtinge.hyperceiler.utils.shell.ShellUtils.safeExecCommandWithRoot;

import android.os.Handler;
Expand Down Expand Up @@ -47,6 +48,7 @@ public class DevelopmentFragment extends SettingsPreferenceFragment implements P

Preference mCmdR;
Preference mDeleteAllDexKitCache;
Preference mFixLsposedLog;

public interface EditDialogCallback {
void onInputReceived(String command);
Expand All @@ -61,8 +63,10 @@ public int getContentResId() {
public void initPrefs() {
mCmdR = findPreference("prefs_key_development_cmd_r");
mDeleteAllDexKitCache = findPreference("prefs_key_development_delete_all_dexkit_cache");
mFixLsposedLog = findPreference("prefs_key_development_fix_lsposed_log");
mCmdR.setOnPreferenceClickListener(this);
mDeleteAllDexKitCache.setOnPreferenceClickListener(this);
mFixLsposedLog.setOnPreferenceClickListener(this);
}

@Override
Expand All @@ -82,6 +86,14 @@ public void onInputReceived(String command) {
Toast.makeText(getActivity(), R.string.delete_all_dexkit_cache_success, Toast.LENGTH_LONG).show();
});
}
case "prefs_key_development_fix_lsposed_log" -> {
String fixReturn = fixLsposedLogService();
if (fixReturn.equals("SUCCESS")) {
Toast.makeText(getActivity(), R.string.success, Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getActivity(), getString(R.string.failed) + ": " + fixReturn, Toast.LENGTH_LONG).show();
}
}
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,14 @@ public static boolean isLoggerAlive() {
LOGGER_CHECKER_ERR_CODE = "WITHOUT_CODE";
return false;
}

public static String fixLsposedLogService() {
try {
safeExecCommandWithRoot("resetprop -n persist.log.tag.LSPosed V");
safeExecCommandWithRoot("resetprop -n persist.log.tag.LSPosed-Bridge V");
return "SUCCESS";
} catch (Exception e) {
return e.toString();
}
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,17 @@
<string name="prefs_6">检查共享首选项</string>
<string name="prefs_7">移除指定 Key</string>

<string name="success">成功</string>
<string name="failed">失败</string>

<string name="development">开发者选项</string>
<string name="development_ui">界面元素测试</string>
<string name="development_debug_info">调试信息</string>
<string name="development_prefs">共享首选项</string>
<string name="development_cmd_r">使用 root 的模拟终端</string>
<string name="development_delete_all_dexkit_cache">删除全部 DexKit 缓存</string>
<string name="development_close_log_alert_dialog">禁用 Logger Live 弹窗</string>
<string name="development_fix_lsposed_log">尝试修复 LSPosed Log 服务</string>

<string name="settings_show_title">显示</string>
<string name="settings_data_title">备份与恢复</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
<string name="prefs_5">Select type</string>
<string name="prefs_6">Check sharing preferences</string>
<string name="prefs_7">Remove specified key</string>
<string name="success">Success</string>
<string name="failed">Failed</string>
<string name="help">Help</string>
<string name="settings">Settings</string>
<string name="about">About</string>
Expand All @@ -101,6 +103,8 @@
<string name="development_prefs">Share preference</string>
<string name="development_cmd_r">CMD with root</string>
<string name="development_delete_all_dexkit_cache">Delete all DexKit cache</string>
<string name="development_close_log_alert_dialog">Disable logger live alert dialog</string>
<string name="development_fix_lsposed_log">Try to fix LSPosed log service</string>
<string name="about_privacy">Privacy Policy</string>
<string name="about_protocol">User Agreement</string>
<string name="settings_show_title">Show</string>
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/xml/prefs_development.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,13 @@
android:key="prefs_key_development_delete_all_dexkit_cache"
android:title="@string/development_delete_all_dexkit_cache" />

<SwitchPreference
android:title="@string/development_close_log_alert_dialog"
android:key="prefs_key_development_close_log_alert_dialog"
android:defaultValue="false" />

<Preference
android:key="prefs_key_development_fix_lsposed_log"
android:title="@string/development_fix_lsposed_log" />

</PreferenceScreen>

0 comments on commit e23187b

Please sign in to comment.