Remove white list
This commit is contained in:
parent
1fc683ef3e
commit
4135c357d5
|
|
@ -70,9 +70,17 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.ViewHolder> impl
|
|||
}
|
||||
|
||||
private void loadApps() {
|
||||
checkedList = generateCheckedList();
|
||||
fullList = pm.getInstalledPackages(PackageManager.GET_META_DATA);
|
||||
List<PackageInfo> rmList = new ArrayList<>();
|
||||
for (PackageInfo info : fullList) {
|
||||
if (info.packageName.equals(((ScopeAdapter) this).modulePackageName)) {
|
||||
rmList.add(info);
|
||||
continue;
|
||||
}
|
||||
if (checkedList.contains(info.packageName)) {
|
||||
continue;
|
||||
}
|
||||
if (info.applicationInfo.category == ApplicationInfo.CATEGORY_GAME) {
|
||||
rmList.add(info);
|
||||
continue;
|
||||
|
|
@ -93,23 +101,12 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.ViewHolder> impl
|
|||
if (this instanceof ScopeAdapter) {
|
||||
if (info.packageName.equals(((ScopeAdapter) this).modulePackageName)) {
|
||||
rmList.add(info);
|
||||
continue;
|
||||
}
|
||||
List<String> list = AppHelper.getAppList();
|
||||
if (!list.contains(info.packageName)) {
|
||||
rmList.add(info);
|
||||
}
|
||||
} else {
|
||||
if (AppHelper.forceWhiteList.contains(info.packageName)) {
|
||||
rmList.add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rmList.size() > 0) {
|
||||
fullList.removeAll(rmList);
|
||||
}
|
||||
AppHelper.makeSurePath();
|
||||
checkedList = generateCheckedList();
|
||||
sortApps();
|
||||
showList = fullList;
|
||||
if (activity != null) {
|
||||
|
|
|
|||
|
|
@ -36,63 +36,12 @@ import static android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS;
|
|||
public class AppHelper {
|
||||
|
||||
private static final String BASE_PATH = Constants.getBaseDir();
|
||||
private static final String WHITE_LIST_PATH = "conf/whitelist/";
|
||||
private static final String SCOPE_LIST_PATH = "conf/%s.conf";
|
||||
|
||||
public static List<String> forceWhiteList = new ArrayList<>();
|
||||
|
||||
private static final HashMap<String, List<String>> scopeList = new HashMap<>();
|
||||
|
||||
public static void makeSurePath() {
|
||||
App.mkdir(WHITE_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 -> {
|
||||
if (!Files.isDirectory(path)) {
|
||||
list.add(path.getFileName().toString());
|
||||
}
|
||||
});
|
||||
forceWhiteList.forEach(s -> {
|
||||
if (!list.contains(s)) {
|
||||
createAppListFile(s, true);
|
||||
list.add(s);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
Files.delete(path);
|
||||
}
|
||||
} else if (add) {
|
||||
Files.createFile(path);
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean setPackageAppList(String packageName, boolean add) {
|
||||
if (!add && forceWhiteList.contains(packageName)) {
|
||||
return false;
|
||||
}
|
||||
return createAppListFile(packageName, add);
|
||||
}
|
||||
|
||||
public static void showMenu(@NonNull Context context,
|
||||
@NonNull FragmentManager fragmentManager,
|
||||
@NonNull View anchor,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ public class ScopeAdapter extends AppAdapter {
|
|||
|
||||
@Override
|
||||
public List<String> generateCheckedList() {
|
||||
AppHelper.makeSurePath();
|
||||
checkedList = AppHelper.getScopeList(modulePackageName);
|
||||
enabled = ModuleUtil.getInstance().isModuleEnabled(modulePackageName);
|
||||
activity.runOnUiThread(() -> masterSwitch.setChecked(enabled));
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
package io.github.lsposed.manager.adapters;
|
||||
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.github.lsposed.manager.R;
|
||||
import io.github.lsposed.manager.ui.activity.AppListActivity;
|
||||
|
||||
|
||||
public class WhiteListAdapter extends AppAdapter {
|
||||
|
||||
private List<String> checkedList;
|
||||
|
||||
public WhiteListAdapter(AppListActivity activity) {
|
||||
super(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> generateCheckedList() {
|
||||
AppHelper.makeSurePath();
|
||||
return checkedList = AppHelper.getAppList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCheckedChange(CompoundButton view, boolean isChecked, String packageName) {
|
||||
boolean success = AppHelper.setPackageAppList(packageName, isChecked);
|
||||
if (success) {
|
||||
if (isChecked) {
|
||||
checkedList.add(packageName);
|
||||
} else {
|
||||
checkedList.remove(packageName);
|
||||
}
|
||||
} else {
|
||||
activity.makeSnackBar(R.string.add_package_failed, Snackbar.LENGTH_SHORT);
|
||||
view.setChecked(!isChecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,6 @@ 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.ScopeAdapter;
|
||||
import io.github.lsposed.manager.adapters.WhiteListAdapter;
|
||||
import io.github.lsposed.manager.databinding.ActivityAppListBinding;
|
||||
import io.github.lsposed.manager.util.LinearLayoutManagerFix;
|
||||
import io.github.lsposed.manager.util.ModuleUtil;
|
||||
|
|
@ -60,10 +59,6 @@ public class AppListActivity extends BaseActivity {
|
|||
bar.setTitle(R.string.menu_scope);
|
||||
bar.setSubtitle(moduleName);
|
||||
appAdapter = new ScopeAdapter(this, modulePackageName, binding.masterSwitch);
|
||||
} else {
|
||||
bar.setTitle(R.string.title_white_list);
|
||||
binding.masterSwitch.setVisibility(View.GONE);
|
||||
appAdapter = new WhiteListAdapter(this);
|
||||
}
|
||||
appAdapter.setHasStableIds(true);
|
||||
binding.recyclerView.setAdapter(appAdapter);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ public class MainActivity extends BaseActivity {
|
|||
if (Light.setLightSourceAlpha(getWindow().getDecorView(), 0.01f, 0.029f)) {
|
||||
binding.status.setElevation(24);
|
||||
binding.modules.setElevation(12);
|
||||
binding.apps.setElevation(12);
|
||||
}
|
||||
});
|
||||
binding.modules.setOnClickListener(v -> {
|
||||
|
|
@ -43,11 +42,6 @@ public class MainActivity extends BaseActivity {
|
|||
intent.setClass(getApplicationContext(), ModulesActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
binding.apps.setOnClickListener(v -> {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(getApplicationContext(), AppListActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
binding.status.setOnClickListener(v -> {
|
||||
if (Constants.getXposedVersionCode() != -1) {
|
||||
new StatusDialogBuilder(this)
|
||||
|
|
@ -100,8 +94,5 @@ 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(R.string.Apps);
|
||||
int count = AppHelper.getAppList().size();
|
||||
binding.appsSummary.setText(getString(R.string.whitelist_summary, count));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,57 +166,6 @@
|
|||
</RelativeLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/apps"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="4dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="18dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingEnd="18dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/apps_icon"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:contentDescription="@string/Modules"
|
||||
app:srcCompat="@drawable/ic_apps" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/apps_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="25dp"
|
||||
android:layout_toEndOf="@id/apps_icon"
|
||||
android:text="@string/Apps"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/apps_summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/apps_title"
|
||||
android:layout_alignStart="@id/apps_title"
|
||||
android:layout_marginTop="2dp"
|
||||
android:text="@string/Apps"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textColor="@android:color/darker_gray" />
|
||||
</RelativeLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/logs"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -98,7 +98,6 @@
|
|||
<string name="not_logcat">此处仅显示 LSPosed 及模块相关日志信息\n如果您想抓取系统日志, 可以尝试我们的 Log Catcher Magisk 模块</string>
|
||||
|
||||
<!-- LSPd related -->
|
||||
<string name="title_white_list">白名单</string>
|
||||
<string name="add_package_failed">修改失败, 一个或多个设置阻止你继续修改</string>
|
||||
<string name="menu_title_compile_reset">取消优化</string>
|
||||
<string name="menu_title_compile_speed">以 Speed 模式优化应用</string>
|
||||
|
|
@ -153,7 +152,6 @@
|
|||
<string name="menu_show_system_apps">系统应用</string>
|
||||
<string name="menu_reboot">重启…</string>
|
||||
<string name="menu_sort">排序…</string>
|
||||
<string name="whitelist_summary">%d 个应用位于白名单中</string>
|
||||
<string name="enable_module">启用模块</string>
|
||||
<string name="no_scope_selected">未选择任何应用。继续?</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -97,7 +97,6 @@
|
|||
<string name="not_logcat">此處僅顯示 LSPosed 及模塊相關日誌信息\n如果您想抓取系統日誌, 可以嘗試我們的 Log Catcher Magisk 模塊</string>
|
||||
|
||||
<!-- LSPd related -->
|
||||
<string name="title_white_list">白名單</string>
|
||||
<string name="add_package_failed">修改失敗, 一個或多個設置阻止你繼續修改</string>
|
||||
<string name="menu_title_compile_reset">取消優化</string>
|
||||
<string name="menu_title_compile_speed">以 Speed 模式優化應用</string>
|
||||
|
|
|
|||
|
|
@ -97,7 +97,6 @@
|
|||
<string name="not_logcat">此處僅顯示 LSPosed 及模組相關日誌資訊\n如果您想抓取系統日誌, 可以嘗試我們的 Log Catcher Magisk 模組</string>
|
||||
|
||||
<!-- LSPd related -->
|
||||
<string name="title_white_list">允許名單</string>
|
||||
<string name="add_package_failed">修改失敗, 一個或多個設定阻止你繼續修改</string>
|
||||
<string name="menu_title_compile_reset">取消優化</string>
|
||||
<string name="menu_title_compile_speed">以 Speed 模式優化 App</string>
|
||||
|
|
|
|||
|
|
@ -112,7 +112,6 @@
|
|||
<string name="verified_boot_active">Verified Boot is active</string>
|
||||
|
||||
<!-- LSPd related -->
|
||||
<string name="title_white_list">White List</string>
|
||||
<string name="add_package_failed">Failed to edit, one or more settings prevent you from editing.</string>
|
||||
<string name="menu_title_compile_reset">De-optimize</string>
|
||||
<string name="menu_title_compile_speed">Optimize with Speed mode</string>
|
||||
|
|
@ -161,7 +160,6 @@
|
|||
<string name="menu_show_system_apps">System apps</string>
|
||||
<string name="menu_reboot">Reboot…</string>
|
||||
<string name="menu_sort">Sorting…</string>
|
||||
<string name="whitelist_summary">%d apps whitelisted</string>
|
||||
<string name="enable_module">Enable module</string>
|
||||
<string name="no_scope_selected">You did not select any app. Continue?</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Reference in New Issue