version:2.6

fix:隐藏不需要的应用
update:
This commit is contained in:
2022-02-23 09:57:42 +08:00
parent 7e37ab1104
commit 7d50cb709b
4 changed files with 58 additions and 3 deletions

View File

@@ -1217,6 +1217,55 @@ public class JGYUtils {
}
HashSet<String> showAppList = new HashSet<String>() {{
this.add("com.android.calendar");
this.add("com.android.contacts");
this.add("com.android.deskclock");
this.add("com.android.camera2");
this.add("com.android.messaging");
this.add("com.android.music");
this.add("com.android.settings");
// this.add("org.chromium.browser");
this.add("com.aoleyun.browser");
this.add("com.aoleyun.os");
this.add("com.android.calculator2");
this.add("com.android.dialer");
this.add("com.android.documentsui");
this.add("com.android.soundrecorder");
this.add("com.sprd.sprdnote");
this.add("com.aoleyun.appstore");
this.add("com.aoleyun.info");
this.add("com.aoleyun.sn");
this.add("com.android.gallery3d");
}};
/**
* 隐藏系统所有应用
* 除了设置,图库、视频、设置、文件管理器、通话、短信、日历、时钟、计算器
*/
public void hideSystemAPP() {
PackageManager pm = mContext.getPackageManager();
Intent filterIntent = new Intent(Intent.ACTION_MAIN, null);
//Intent.CATEGORY_LAUNCHER主要的过滤条件
filterIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> apps = pm.queryIntentActivities(filterIntent, 0);
for (ResolveInfo resolveInfo : apps) {
String pkg = resolveInfo.activityInfo.packageName;
Log.e(TAG, "hideSystemAPP: " + pkg);
if (!ApkUtils.isSystemApp(mContext, pkg)) {
continue;
}
if (!showAppList.contains(pkg)) {
pm.setApplicationEnabledSetting(pkg, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
Log.e(TAG, "hideSystemAPP: " + "disable: " + pkg);
} else {
pm.setApplicationEnabledSetting(pkg, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
Log.e(TAG, "hideSystemAPP: " + "enable: " + pkg);
}
}
}
/**
* 从Manifest中获取meta-data值
* https://blog.csdn.net/yue_233/article/details/91453451