Remove black list
This commit is contained in:
parent
62fb91a469
commit
cb7057e6db
|
|
@ -9,16 +9,15 @@ import android.os.Looper;
|
|||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import io.github.lsposed.manager.ui.activity.CrashReportActivity;
|
||||
import io.github.lsposed.manager.util.CompileUtil;
|
||||
import io.github.lsposed.manager.util.ModuleUtil;
|
||||
import io.github.lsposed.manager.util.NotificationUtil;
|
||||
import io.github.lsposed.manager.util.RebootUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import rikka.shizuku.Shizuku;
|
||||
import rikka.sui.Sui;
|
||||
|
||||
|
|
@ -42,11 +41,12 @@ public class App extends Application {
|
|||
if (requestCode < 10) {
|
||||
RebootUtil.onRequestPermissionsResult(requestCode, grantResult);
|
||||
} else {
|
||||
CompileUtil.onRequestPermissionsResult(requestCode, grantResult);
|
||||
CompileUtil.onRequestPermissionsResult(requestCode - 10, grantResult);
|
||||
}
|
||||
}
|
||||
|
||||
public static int checkPermission(int code) {
|
||||
public static int checkPermission(int code, int from) {
|
||||
int requestCode = code + from * 10;
|
||||
try {
|
||||
if (!Shizuku.isPreV11() && Shizuku.getVersion() >= 11) {
|
||||
if (Shizuku.checkSelfPermission() == PERMISSION_GRANTED) {
|
||||
|
|
@ -54,7 +54,7 @@ public class App extends Application {
|
|||
} else if (Shizuku.shouldShowRequestPermissionRationale()) {
|
||||
return -1;
|
||||
} else {
|
||||
Shizuku.requestPermission(code);
|
||||
Shizuku.requestPermission(requestCode);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,18 +77,10 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.ViewHolder> impl
|
|||
List<PackageInfo> rmList = new ArrayList<>();
|
||||
for (PackageInfo info : fullList) {
|
||||
if (this instanceof ScopeAdapter) {
|
||||
boolean white = AppHelper.isWhiteListMode();
|
||||
List<String> list = AppHelper.getAppList(white);
|
||||
if (white) {
|
||||
if (!list.contains(info.packageName)) {
|
||||
rmList.add(info);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (list.contains(info.packageName)) {
|
||||
rmList.add(info);
|
||||
continue;
|
||||
}
|
||||
List<String> list = AppHelper.getAppList();
|
||||
if (!list.contains(info.packageName)) {
|
||||
rmList.add(info);
|
||||
continue;
|
||||
}
|
||||
if (info.packageName.equals(((ScopeAdapter) this).modulePackageName)) {
|
||||
rmList.add(info);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import androidx.annotation.NonNull;
|
|||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
|
@ -32,9 +31,7 @@ public class AppHelper {
|
|||
|
||||
private static final String BASE_PATH = Constants.getBaseDir();
|
||||
private static final String WHITE_LIST_PATH = "conf/whitelist/";
|
||||
private static final String BLACK_LIST_PATH = "conf/blacklist/";
|
||||
private static final String SCOPE_LIST_PATH = "conf/%s.conf";
|
||||
private static final String WHITE_LIST_MODE = "conf/usewhitelist";
|
||||
|
||||
public static List<String> forceWhiteList = new ArrayList<>();
|
||||
|
||||
|
|
@ -42,15 +39,10 @@ public class AppHelper {
|
|||
|
||||
public static void makeSurePath() {
|
||||
App.mkdir(WHITE_LIST_PATH);
|
||||
App.mkdir(BLACK_LIST_PATH);
|
||||
}
|
||||
|
||||
public static boolean isWhiteListMode() {
|
||||
return new File(BASE_PATH + WHITE_LIST_MODE).exists();
|
||||
}
|
||||
|
||||
public static List<String> getAppList(boolean white) {
|
||||
Path dir = Paths.get(BASE_PATH + (white ? WHITE_LIST_PATH : BLACK_LIST_PATH));
|
||||
public static List<String> getAppList() {
|
||||
Path dir = Paths.get(BASE_PATH + (WHITE_LIST_PATH));
|
||||
List<String> list = new ArrayList<>();
|
||||
try {
|
||||
Files.list(dir).forEach(path -> {
|
||||
|
|
@ -59,13 +51,8 @@ public class AppHelper {
|
|||
}
|
||||
});
|
||||
forceWhiteList.forEach(s -> {
|
||||
if (list.contains(s)) {
|
||||
if (!white) {
|
||||
createAppListFile(s, false, false);
|
||||
list.remove(s);
|
||||
}
|
||||
} else if (white) {
|
||||
createAppListFile(s, true, true);
|
||||
if (!list.contains(s)) {
|
||||
createAppListFile(s, true);
|
||||
list.add(s);
|
||||
}
|
||||
});
|
||||
|
|
@ -76,8 +63,8 @@ public class AppHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean createAppListFile(String packageName, boolean white, boolean add) {
|
||||
Path path = Paths.get(BASE_PATH + (white ? WHITE_LIST_PATH : BLACK_LIST_PATH) + packageName);
|
||||
private static boolean createAppListFile(String packageName, boolean add) {
|
||||
Path path = Paths.get(BASE_PATH + (WHITE_LIST_PATH) + packageName);
|
||||
try {
|
||||
if (Files.exists(path)) {
|
||||
if (!add) {
|
||||
|
|
@ -94,18 +81,10 @@ public class AppHelper {
|
|||
}
|
||||
|
||||
static boolean setPackageAppList(String packageName, boolean add) {
|
||||
return setPackageAppList(packageName, isWhiteListMode(), add);
|
||||
}
|
||||
|
||||
static boolean setPackageAppList(String packageName, boolean white, boolean add) {
|
||||
if (add && !white && forceWhiteList.contains(packageName)) {
|
||||
createAppListFile(packageName, false, false);
|
||||
if (!add && forceWhiteList.contains(packageName)) {
|
||||
return false;
|
||||
}
|
||||
if (!add && white && forceWhiteList.contains(packageName)) {
|
||||
return false;
|
||||
}
|
||||
return createAppListFile(packageName, white, add);
|
||||
return createAppListFile(packageName, add);
|
||||
}
|
||||
|
||||
public static void showMenu(@NonNull Context context,
|
||||
|
|
|
|||
|
|
@ -10,18 +10,18 @@ import io.github.lsposed.manager.R;
|
|||
import io.github.lsposed.manager.ui.activity.AppListActivity;
|
||||
|
||||
|
||||
public class BlackListAdapter extends AppAdapter {
|
||||
public class WhiteListAdapter extends AppAdapter {
|
||||
|
||||
private List<String> checkedList;
|
||||
|
||||
public BlackListAdapter(AppListActivity activity) {
|
||||
public WhiteListAdapter(AppListActivity activity) {
|
||||
super(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> generateCheckedList() {
|
||||
AppHelper.makeSurePath();
|
||||
return checkedList = AppHelper.getAppList(AppHelper.isWhiteListMode());
|
||||
return checkedList = AppHelper.getAppList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -20,9 +20,8 @@ import com.google.android.material.snackbar.Snackbar;
|
|||
|
||||
import io.github.lsposed.manager.R;
|
||||
import io.github.lsposed.manager.adapters.AppAdapter;
|
||||
import io.github.lsposed.manager.adapters.AppHelper;
|
||||
import io.github.lsposed.manager.adapters.BlackListAdapter;
|
||||
import io.github.lsposed.manager.adapters.ScopeAdapter;
|
||||
import io.github.lsposed.manager.adapters.WhiteListAdapter;
|
||||
import io.github.lsposed.manager.databinding.ActivityScopeListBinding;
|
||||
import io.github.lsposed.manager.util.LinearLayoutManagerFix;
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
|
||||
|
|
@ -58,9 +57,9 @@ public class AppListActivity extends BaseActivity {
|
|||
bar.setSubtitle(moduleName);
|
||||
appAdapter = new ScopeAdapter(this, modulePackageName, binding.masterSwitch);
|
||||
} else {
|
||||
bar.setTitle(AppHelper.isWhiteListMode() ? R.string.title_white_list : R.string.title_black_list);
|
||||
bar.setTitle(R.string.title_white_list);
|
||||
binding.masterSwitch.setVisibility(View.GONE);
|
||||
appAdapter = new BlackListAdapter(this);
|
||||
appAdapter = new WhiteListAdapter(this);
|
||||
}
|
||||
appAdapter.setHasStableIds(true);
|
||||
binding.recyclerView.setAdapter(appAdapter);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import androidx.core.content.ContextCompat;
|
|||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import io.github.lsposed.manager.Constants;
|
||||
import io.github.lsposed.manager.R;
|
||||
import io.github.lsposed.manager.adapters.AppHelper;
|
||||
|
|
@ -20,8 +22,6 @@ import io.github.lsposed.manager.util.ModuleUtil;
|
|||
import io.github.lsposed.manager.util.NavUtil;
|
||||
import io.github.lsposed.manager.util.light.Light;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class MainActivity extends BaseActivity {
|
||||
ActivityMainBinding binding;
|
||||
|
||||
|
|
@ -100,8 +100,8 @@ public class MainActivity extends BaseActivity {
|
|||
protected void onResume() {
|
||||
super.onResume();
|
||||
binding.modulesSummary.setText(String.format(getString(R.string.ModulesDetail), ModuleUtil.getInstance().getEnabledModules().size()));
|
||||
binding.appsTitle.setText(AppHelper.isWhiteListMode() ? R.string.title_white_list : R.string.title_black_list);
|
||||
int count = AppHelper.getAppList(AppHelper.isWhiteListMode()).size();
|
||||
binding.appsSummary.setText(getString(AppHelper.isWhiteListMode() ? R.string.whitelist_summary : R.string.blacklist_summary, count));
|
||||
binding.appsTitle.setText(R.string.Apps);
|
||||
int count = AppHelper.getAppList().size();
|
||||
binding.appsSummary.setText(getString(R.string.whitelist_summary, count));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,16 +17,16 @@ import androidx.preference.SwitchPreferenceCompat;
|
|||
import com.takisoft.preferencex.PreferenceFragmentCompat;
|
||||
import com.takisoft.preferencex.SimpleMenuPreference;
|
||||
|
||||
import io.github.lsposed.manager.Constants;
|
||||
import io.github.lsposed.manager.R;
|
||||
import io.github.lsposed.manager.databinding.ActivitySettingsBinding;
|
||||
import io.github.lsposed.manager.ui.widget.IntegerListPreference;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import io.github.lsposed.manager.Constants;
|
||||
import io.github.lsposed.manager.R;
|
||||
import io.github.lsposed.manager.databinding.ActivitySettingsBinding;
|
||||
import io.github.lsposed.manager.ui.widget.IntegerListPreference;
|
||||
|
||||
public class SettingsActivity extends BaseActivity {
|
||||
private static final String KEY_PREFIX = SettingsActivity.class.getName() + '.';
|
||||
private static final String EXTRA_SAVED_INSTANCE_STATE = KEY_PREFIX + "SAVED_INSTANCE_STATE";
|
||||
|
|
@ -102,7 +102,6 @@ public class SettingsActivity extends BaseActivity {
|
|||
public static class SettingsFragment extends PreferenceFragmentCompat {
|
||||
private static final Path enableResourcesFlag = Paths.get(Constants.getBaseDir(), "conf/enable_resources");
|
||||
private static final Path deoptBootFlag = Paths.get(Constants.getBaseDir(), "conf/deoptbootimage");
|
||||
private static final Path whiteListModeFlag = Paths.get(Constants.getBaseDir(), "conf/usewhitelist");
|
||||
private static final Path disableVerboseLogsFlag = Paths.get(Constants.getBaseDir(), "conf/disable_verbose_log");
|
||||
private static final Path disableModulesLogsFlag = Paths.get(Constants.getBaseDir() + "conf/disable_modules_log");
|
||||
private static final Path variantFlag = Paths.get(Constants.getBaseDir()).getParent().resolve("variant");
|
||||
|
|
@ -111,12 +110,6 @@ public class SettingsActivity extends BaseActivity {
|
|||
public void onCreatePreferencesFix(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.prefs);
|
||||
|
||||
SwitchPreferenceCompat prefWhiteListMode = findPreference("white_list_switch");
|
||||
if (prefWhiteListMode != null) {
|
||||
prefWhiteListMode.setChecked(Files.exists(whiteListModeFlag));
|
||||
prefWhiteListMode.setOnPreferenceChangeListener(new OnFlagChangeListener(whiteListModeFlag));
|
||||
}
|
||||
|
||||
SwitchPreferenceCompat prefVerboseLogs = findPreference("disable_verbose_log");
|
||||
if (prefVerboseLogs != null) {
|
||||
prefVerboseLogs.setChecked(Files.exists(disableVerboseLogsFlag));
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
|||
@SuppressWarnings("deprecation")
|
||||
public class CompileDialogFragment extends AppCompatDialogFragment {
|
||||
|
||||
// TODO:
|
||||
private static final String COMPILE_COMMAND_PREFIX = "cmd package ";
|
||||
private static final String COMPILE_RESET_COMMAND = COMPILE_COMMAND_PREFIX + "compile --reset ";
|
||||
private static final String COMPILE_SPEED_COMMAND = COMPILE_COMMAND_PREFIX + "compile -f -m speed ";
|
||||
|
|
@ -85,7 +86,7 @@ public class CompileDialogFragment extends AppCompatDialogFragment {
|
|||
}
|
||||
|
||||
public void onRequestPermissionsResult(int requestCode, int grantResult) {
|
||||
CompileUtil.CompileType mode = CompileUtil.CompileType.values()[(requestCode - 1) / 10];
|
||||
CompileUtil.CompileType mode = CompileUtil.CompileType.values()[requestCode];
|
||||
if (grantResult == PERMISSION_GRANTED) {
|
||||
AsyncTask.THREAD_POOL_EXECUTOR.execute(() -> {
|
||||
try {
|
||||
|
|
@ -128,8 +129,7 @@ public class CompileDialogFragment extends AppCompatDialogFragment {
|
|||
if (arguments != null) {
|
||||
int type = arguments.getInt(KEY_TYPE);
|
||||
appInfo = arguments.getParcelable(KEY_APP_INFO);
|
||||
type = type * 10 + 1;
|
||||
int result = App.checkPermission(type);
|
||||
int result = App.checkPermission(type, 1);
|
||||
switch (result) {
|
||||
case 0:
|
||||
onRequestPermissionsResult(type, PERMISSION_GRANTED);
|
||||
|
|
|
|||
|
|
@ -14,12 +14,11 @@ import androidx.fragment.app.FragmentManager;
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.topjohnwu.superuser.Shell;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.github.lsposed.manager.App;
|
||||
import io.github.lsposed.manager.R;
|
||||
import io.github.lsposed.manager.ui.fragment.CompileDialogFragment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import rikka.shizuku.ShizukuBinderWrapper;
|
||||
import rikka.shizuku.ShizukuSystemProperties;
|
||||
import rikka.shizuku.SystemServiceHelper;
|
||||
|
|
@ -29,6 +28,7 @@ import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CompileUtil {
|
||||
// TODO:
|
||||
|
||||
public enum CompileType {
|
||||
RESET,
|
||||
|
|
@ -58,7 +58,7 @@ public class CompileUtil {
|
|||
private static Activity sActivity;
|
||||
|
||||
public static void onRequestPermissionsResult(int requestCode, int grantResult) {
|
||||
CompileUtil.CompileType mode = CompileUtil.CompileType.values()[(requestCode - 1) / 10];
|
||||
CompileUtil.CompileType mode = CompileUtil.CompileType.values()[requestCode];
|
||||
if (mode == CompileType.DEXOPT_ALL || mode == CompileType.SPEED_ALL) {
|
||||
AlertDialog dialog = new MaterialAlertDialogBuilder(sActivity)
|
||||
.setTitle(R.string.speed_now)
|
||||
|
|
@ -125,8 +125,8 @@ public class CompileUtil {
|
|||
|
||||
public static void compileAllDexopt(Activity activity) {
|
||||
sActivity = activity;
|
||||
int type = CompileType.DEXOPT_ALL.ordinal() * 10 + 1;
|
||||
int result = App.checkPermission(type);
|
||||
int type = CompileType.DEXOPT_ALL.ordinal();
|
||||
int result = App.checkPermission(type, 1);
|
||||
switch (result) {
|
||||
case 0:
|
||||
onRequestPermissionsResult(type, PERMISSION_GRANTED);
|
||||
|
|
@ -139,8 +139,8 @@ public class CompileUtil {
|
|||
|
||||
public static void compileAllSpeed(Activity activity) {
|
||||
sActivity = activity;
|
||||
int type = CompileType.SPEED_ALL.ordinal() * 10 + 1;
|
||||
int result = App.checkPermission(type);
|
||||
int type = CompileType.SPEED_ALL.ordinal();
|
||||
int result = App.checkPermission(type, 1);
|
||||
switch (result) {
|
||||
case 0:
|
||||
onRequestPermissionsResult(type, PERMISSION_GRANTED);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import com.topjohnwu.superuser.Shell;
|
|||
|
||||
import io.github.lsposed.manager.App;
|
||||
import io.github.lsposed.manager.BuildConfig;
|
||||
|
||||
import rikka.shizuku.ShizukuBinderWrapper;
|
||||
import rikka.shizuku.ShizukuSystemProperties;
|
||||
import rikka.shizuku.SystemServiceHelper;
|
||||
|
|
@ -61,7 +60,7 @@ public class RebootUtil {
|
|||
|
||||
|
||||
public static void reboot(RebootType mode) {
|
||||
int result = App.checkPermission(mode.ordinal());
|
||||
int result = App.checkPermission(mode.ordinal(), 0);
|
||||
switch (result) {
|
||||
case 0:
|
||||
onRequestPermissionsResult(mode.ordinal(), PERMISSION_GRANTED);
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@
|
|||
<string name="compile_failed">优化失败或返回值为空</string>
|
||||
<string name="compile_failed_with_info">优化失败: </string>
|
||||
<string name="hook_modules">强制添加模块</string>
|
||||
<string name="hook_modules_summary">强制将模块添加进白名单并移出黑名单\n关闭此选项并不会移除已勾选的应用标识</string>
|
||||
<string name="hook_modules_summary">强制将模块添加进白名单\n关闭此选项并不会移除已勾选的应用标识</string>
|
||||
<string name="not_installed">未安装</string>
|
||||
<string name="support_group_telegram_channel">Telegram 频道: @LSPosed</string>
|
||||
<string name="reboot_system">重启至系统</string>
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@
|
|||
<string name="app_stop">停止</string>
|
||||
<string name="compile_failed">優化失敗或返回值為空</string>
|
||||
<string name="hook_modules">強制添加模塊</string>
|
||||
<string name="hook_modules_summary">強制將模塊添加進白名單並移出黑名單\n關閉此選項並不會移除已勾選的應用標識</string>
|
||||
<string name="hook_modules_summary">強制將模塊添加進白名單\n關閉此選項並不會移除已勾選的應用標識</string>
|
||||
<string name="not_installed">未安裝</string>
|
||||
<string name="support_group_telegram_channel">Telegram 頻道: @LSPosed</string>
|
||||
<string name="reboot_system">重啟至系統</string>
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@
|
|||
<string name="app_stop">停止</string>
|
||||
<string name="compile_failed">優化失敗或返回值為空</string>
|
||||
<string name="hook_modules">強制新增模組</string>
|
||||
<string name="hook_modules_summary">強制將模組新增進白允許名單並移出封鎖名單\n關閉此選項並不會移除已勾選的 App 標識</string>
|
||||
<string name="hook_modules_summary">強制將模組新增進白允許名單\n關閉此選項並不會移除已勾選的 App 標識</string>
|
||||
<string name="not_installed">未安裝</string>
|
||||
<string name="support_group_telegram_channel">Telegram 頻道: @LSPosed</string>
|
||||
<string name="reboot_system">重啟至系統</string>
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@
|
|||
<string name="compile_failed">Optimization failed or return value is empty</string>
|
||||
<string name="compile_failed_with_info">Optimization failed: </string>
|
||||
<string name="hook_modules">Force hook modules</string>
|
||||
<string name="hook_modules_summary">Force add modules to white-list and remove from black list\nClosing this option does not remove added modules from white list</string>
|
||||
<string name="hook_modules_summary">Force add modules to white list\nClosing this option does not remove added modules from white list</string>
|
||||
<string name="not_installed">Not installed</string>
|
||||
<string name="support_group_telegram_channel">Telegram Channel: @LSPosed</string>
|
||||
<string name="reboot_system">Reboot to System</string>
|
||||
|
|
|
|||
|
|
@ -76,14 +76,6 @@
|
|||
android:persistent="false"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="white_list_switch"
|
||||
android:summary="@string/white_list_mode_summary"
|
||||
android:title="@string/white_list_mode_title"
|
||||
android:persistent="false"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="enable_boot_image_deopt"
|
||||
|
|
|
|||
Loading…
Reference in New Issue