Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatically add whitelist from activation scope #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

SwitchPreference prefWhiteListMode = findPreference("white_list_switch");
Objects.requireNonNull(prefWhiteListMode).setChecked(mWhiteListModeFlag.exists());
prefWhiteListMode.setOnPreferenceChangeListener((preference, newValue) -> setFlag(mWhiteListModeFlag, (boolean) newValue));
prefWhiteListMode.setOnPreferenceChangeListener((preference, newValue) -> {
if (!((boolean) newValue))
Objects.requireNonNull((SwitchPreference)findPreference("auto_add_whitelist_from_scope")).setChecked(false);
return setFlag(mWhiteListModeFlag, (boolean) newValue);
});

SwitchPreference prefVerboseLogs = findPreference("disable_verbose_log");
Objects.requireNonNull(prefVerboseLogs).setChecked(mDisableVerboseLogsFlag.exists());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import org.meowcat.edxposed.manager.R;
import org.meowcat.edxposed.manager.XposedApp;
import org.meowcat.edxposed.manager.util.ModuleUtil;
import org.meowcat.edxposed.manager.util.ToastUtil;
import org.meowcat.edxposed.manager.widget.MasterSwitch;
Expand All @@ -21,9 +22,14 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static org.meowcat.edxposed.manager.adapter.AppHelper.BASE_PATH;
import static org.meowcat.edxposed.manager.adapter.AppHelper.addPackageName;
import static org.meowcat.edxposed.manager.adapter.AppHelper.getWhiteList;
import static org.meowcat.edxposed.manager.adapter.AppHelper.removePackageName;

public class ActivationScopeAdapter extends AppAdapter {

Expand Down Expand Up @@ -127,15 +133,40 @@ public List<String> generateCheckedList() {
return checkedList;
}

private void addorremovewhitelist(Boolean addorremove, String pkgname) {
if (!XposedApp.getPreferences().getBoolean("auto_add_whitelist_from_scope", false)) return;
List<String> whiteList = getWhiteList();
Set<String> modulelist = new HashSet<>(ModuleUtil.getInstance().getModules().keySet());
modulelist.remove(modulePackageName);
Set<String> scopeofothermodule = new HashSet<>();
for (String othermodule : modulelist) {
scopeofothermodule.addAll(getScopeList(othermodule));
}

if (addorremove) {
if (!whiteList.contains(pkgname)) {
addPackageName(true, pkgname);
}
} else {
if (whiteList.contains(pkgname)) {
if (!scopeofothermodule.contains(pkgname)) {
removePackageName(true,pkgname);
}
}
}
}

@Override
protected void onCheckedChange(CompoundButton view, boolean isChecked, ApplicationInfo info) {
ModuleUtil moduleUtil = ModuleUtil.getInstance();
moduleUtil.updateModulesList(false, null);

if (isChecked) {
checkedList.add(info.packageName);
addorremovewhitelist(true, info.packageName);
} else {
checkedList.remove(info.packageName);
addorremovewhitelist(false, info.packageName);
}
if (!saveScopeList(modulePackageName, enabled, checkedList)) {
ToastUtil.showShortToast(context, R.string.add_package_failed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private void loadApps(List<String> removeList) {
}

if (this instanceof ActivationScopeAdapter) {
if (AppHelper.isWhiteListMode()) {
if (AppHelper.isWhiteListMode() & !XposedApp.getPreferences().getBoolean("auto_add_whitelist_from_scope", false)) {
List<String> whiteList = AppHelper.getWhiteList();
if (!whiteList.contains(info.packageName)) {
rmList.add(info);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@
<string name="take_while_cannot_resore">你确定要优化全部应用吗?\n\n这将需要一段时间, 并且无法恢复\n\n提示: 你可以在 Xposed Hide 中优化单个应用</string>
<string name="settings_title_enable_boot_image_deopt">禁用系统代码优化</string>
<string name="settings_summary_enable_boot_image_deopt">禁用系统代码的优化能使所有系统方法都可以被 hook 到, 但是会降低系统流畅度\n主要用于对比测试某个方法无法 hook 到是否为系统优化导致</string>
<string name="auto_add_whitelist_from_scope_title">自动从作用域设置白名单</string>
<string name="auto_add_whitelist_from_scope_summary">在作用域显示所有应用,白名单将根据作用域自动添加/删除</string>

<string name="settings_title_disable_verbose_log">禁用详细日志</string>
<string name="logs_verbose_disabled">详细日志已禁用</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@
<string name="compile_speed_msg">Optimizing …</string>
<string name="title_compat_list">Compat Mode</string>
<string name="white_list_mode_summary">Xposed Hide(Black): (Default) Selected app will NOT load modules\nXposed Hide(White): Only selected app load modules\nNote: using Xposed Hide might break system-wide modules\' functions</string>
<string name="auto_add_whitelist_from_scope_title">automatically add whitelist from activation scope</string>
<string name="auto_add_whitelist_from_scope_summary">all application will be showed in activation scope, whitelist will be automatically added/removed from activation scope</string>

<string name="coolapk">CoolApk</string>
<string name="website">Website</string>
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@
android:summary="@string/white_list_mode_summary"
android:title="@string/white_list_mode_title" />

<SwitchPreference
android:defaultValue="false"
android:key="auto_add_whitelist_from_scope"
android:title="@string/auto_add_whitelist_from_scope_title"
android:summary="@string/auto_add_whitelist_from_scope_summary"
android:dependency="white_list_switch"/>

<!-- <SwitchPreference-->
<!-- android:defaultValue="false"-->
<!-- android:key="is_dynamic_modules"-->
Expand Down