Java Code Examples for android.content.pm.ApplicationInfo#FLAG_SYSTEM
The following examples show how to use
android.content.pm.ApplicationInfo#FLAG_SYSTEM .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServicesHook.java From AdBlocker_Reborn with GNU General Public License v3.0 | 6 votes |
private void handleServiceStart(XC_MethodHook.MethodHookParam param, Intent serviceIntent) { if (serviceIntent != null) { ComponentName serviceName = serviceIntent.getComponent(); if (serviceName != null) { String packageName = serviceName.getPackageName(); String splitServicesName = serviceName.getClassName(); if (HookLoader.servicesList.contains(splitServicesName) && !PreferencesHelper.isWhitelisted(packageName) && !PreferencesHelper.whiteListElements().contains(splitServicesName)) { if (!PreferencesHelper.isDisableSystemApps()) { param.setResult(null); } else { try { ApplicationInfo info = ContextUtils.getSystemContext().getPackageManager().getApplicationInfo(packageName, 0); if ((info.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { param.setResult(null); } } catch (PackageManager.NameNotFoundException e) { return; } } LogUtils.logRecord("Service Block Success: " + serviceName.flattenToShortString()); } } } }
Example 2
Source File: PkgUtil.java From NanoIconPack with Apache License 2.0 | 6 votes |
public static boolean isSysApp(Context context, String pkgName) { if (context == null || TextUtils.isEmpty(pkgName)) { return false; } try { PackageManager packageManager = context.getPackageManager(); ApplicationInfo applicationInfo = packageManager.getPackageInfo(pkgName, 0).applicationInfo; // return (applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == ApplicationInfo.FLAG_SYSTEM; return ((ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) & applicationInfo.flags) != 0; } catch (Exception e) { e.printStackTrace(); } return false; }
Example 3
Source File: AppUtils.java From HgLauncher with GNU General Public License v3.0 | 6 votes |
/** * Checks with its package name, if an application is a system app, or is the app * is installed as a system app. * * @param packageManager PackageManager object used to receive application info. * @param componentName Application package name to check against. * * @return boolean True if the application is a system app, false if otherwise. */ public static boolean isSystemApp(PackageManager packageManager, String componentName) { try { ApplicationInfo appFlags = packageManager.getApplicationInfo( getPackageName(componentName), 0); if ((appFlags.flags & ApplicationInfo.FLAG_SYSTEM) == 1) { return true; } } catch (PackageManager.NameNotFoundException e) { Utils.sendLog(Utils.LogLevel.ERROR, e.toString()); return false; } return false; }
Example 4
Source File: AppUtils.java From RelaxFinger with GNU General Public License v2.0 | 6 votes |
/** * 根据进程名获取应用信息 * @param processNames * @return */ public static ApplicationInfo getApplicationInfoByProcessName(String processNames) { //获取所有包信息 //List<ApplicationInfo> applicationInfoList // = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); List<ApplicationInfo> applicationInfoList = pm.getInstalledApplications(0); for(ApplicationInfo applicationInfo : applicationInfoList) { if(applicationInfo.processName.equals(processNames) && (applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) <= 0) //只显示第三方的应用进程,不显示系统应用 //要显示所有应用进程,删去(applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) <= 0 即可 return applicationInfo; } return null; }
Example 5
Source File: RedClock.java From AppTroy with Apache License 2.0 | 6 votes |
@Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { if (loadPackageParam == null || (loadPackageParam.appInfo.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0) return; Log.d("cc", "loaded app " + loadPackageParam.packageName); if (loadPackageParam.isFirstApplication && !DUMPAPK.equals(loadPackageParam.packageName)){ Log.d("cc", "the package " + loadPackageParam.packageName + " has hooked"); Log.d("cc", "the target pid is " + android.os.Process.myPid()); PackageMetaInfo info = PackageMetaInfo.fromXposed(loadPackageParam); ModuleContext.getInstance().start(info); ApiMonitorHookManager.Default().startMonitor(); } hookDebug(); antiDebug(); }
Example 6
Source File: Settings.java From openboard with GNU General Public License v3.0 | 5 votes |
public static boolean readShowSetupWizardIcon(final SharedPreferences prefs, final Context context) { if (!prefs.contains(PREF_SHOW_SETUP_WIZARD_ICON)) { final ApplicationInfo appInfo = context.getApplicationInfo(); final boolean isApplicationInSystemImage = (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; // Default value return !isApplicationInSystemImage; } return prefs.getBoolean(PREF_SHOW_SETUP_WIZARD_ICON, false); }
Example 7
Source File: HookMain.java From renrenpay-android with Apache License 2.0 | 5 votes |
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { if (lpparam.appInfo == null || (lpparam.appInfo.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0) { return; } final String packageName = lpparam.packageName; final String processName = lpparam.processName; for (HookBase hookBase : HookList.getInstance().getmListHook()) { //下面的hookCountIndex为2是在vxp里的值,如果手机已root是在xp里运行请改为1,然后把我这行中文删除即可 hookBase.hook(packageName, processName, 1); //LogUtils.show("很多人在倒卖这套系统,大家请不要上当!QQ937013765"); } }
Example 8
Source File: Util.java From InviZible with GNU General Public License v3.0 | 5 votes |
static boolean isSystem(String packageName, Context context) { try { PackageManager pm = context.getPackageManager(); PackageInfo info = pm.getPackageInfo(packageName, 0); return ((info.applicationInfo.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0); } catch (PackageManager.NameNotFoundException ignore) { return false; } }
Example 9
Source File: apitils.java From stynico with MIT License | 5 votes |
/** * 判断应用是否是第三方应用 * * @param appInfo * @return */ public static boolean isThirdPartyApp(ApplicationInfo appInfo) { boolean flag = false; if ((appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) { // 可更新的系统应用 flag = true; } else if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { // 非系统应用(第三方:用户自己安装) flag = true; } return flag; }
Example 10
Source File: ApplicationManager.java From product-emm with Apache License 2.0 | 5 votes |
/** * Return the list of the package names of the apps(hidden and visible) that are user owned * * @return - list of package names of the apps that are not system apps */ public List<String> getAppsOfUser() { List<String> packagesInstalledByUser = new ArrayList<>(); int flags = PackageManager.GET_META_DATA | PackageManager.GET_SHARED_LIBRARY_FILES | PackageManager.GET_UNINSTALLED_PACKAGES; List<ApplicationInfo> applications = packageManager.getInstalledApplications(flags); for (ApplicationInfo appInfo : applications) { if (!((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1)) { packagesInstalledByUser.add(appInfo.packageName); } } return packagesInstalledByUser; }
Example 11
Source File: Settings.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
public static boolean readShowSetupWizardIcon(final SharedPreferences prefs, final Context context) { if (!prefs.contains(PREF_SHOW_SETUP_WIZARD_ICON)) { final ApplicationInfo appInfo = context.getApplicationInfo(); final boolean isApplicationInSystemImage = (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; // Default value return !isApplicationInSystemImage; } return prefs.getBoolean(PREF_SHOW_SETUP_WIZARD_ICON, false); }
Example 12
Source File: Un2Install_PackageUtil.java From zone-sdk with MIT License | 5 votes |
/** * whether packageName is system application */ public static boolean isSystemApplication(Context context, String packageName) { PackageManager packageManager = context.getPackageManager(); if (packageManager == null || packageName == null || packageName.length() == 0) { return false; } try { ApplicationInfo app = packageManager.getApplicationInfo(packageName, 0); return (app != null && (app.flags & ApplicationInfo.FLAG_SYSTEM) > 0); } catch (Exception e) { e.printStackTrace(); } return false; }
Example 13
Source File: AppManager.java From AndroidStudyDemo with GNU General Public License v2.0 | 5 votes |
/** * 获取系统中所有的应用 * * @param context 上下文 * @return 应用信息List */ public static List<PackageInfo> getAllApps(Context context) { List<PackageInfo> apps = new ArrayList<PackageInfo>(); PackageManager pManager = context.getPackageManager(); List<PackageInfo> paklist = pManager.getInstalledPackages(0); for (int i = 0; i < paklist.size(); i++) { PackageInfo pak = paklist.get(i); if ((pak.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) <= 0) { // customs applications apps.add(pak); } } return apps; }
Example 14
Source File: AppApplicationMgr.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
/** * 是否是系统应用 * * @param context * @param packageName * @return */ public static boolean isSystemApp(Context context, String packageName) { boolean isSys = false; PackageManager pm = context.getPackageManager(); try { ApplicationInfo applicationInfo = pm.getApplicationInfo(packageName, 0); if (applicationInfo != null && (applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0) { isSys = true; } } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); isSys = false; } return isSys; }
Example 15
Source File: DefaultInstaller.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
private boolean isSystem(Context context) { try { ApplicationInfo info = packageManager.getApplicationInfo(context.getPackageName(), PackageManager.PERMISSION_GRANTED); return (info.flags & ApplicationInfo.FLAG_SYSTEM) == ApplicationInfo.FLAG_SYSTEM; } catch (PackageManager.NameNotFoundException e) { throw new AssertionError("Aptoide application not found by package manager."); } }
Example 16
Source File: MyApplication.java From SoloPi with Apache License 2.0 | 5 votes |
/** * 重新加载应用列表 */ private void loadApplicationList() { // 后台加载下应用列表 List<ApplicationInfo> listPack = getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA); List<ApplicationInfo> removedItems = new ArrayList<>(); String selfPackage = getPackageName(); boolean displaySystemApp = SPService.getBoolean(SPService.KEY_DISPLAY_SYSTEM_APP, false); for (ApplicationInfo pack: listPack) { if (!displaySystemApp && (pack.flags & ApplicationInfo.FLAG_SYSTEM) > 0) { removedItems.add(pack); } // 移除自身 if (StringUtil.equals(selfPackage, pack.packageName)) { removedItems.add(pack); } } listPack.removeAll(removedItems); // 排序下 final Comparator c = Collator.getInstance(Locale.CHINA); Collections.sort(listPack, new Comparator<ApplicationInfo>() { @Override public int compare(ApplicationInfo o1, ApplicationInfo o2) { String n1 = o1.loadLabel(getPackageManager()).toString(); String n2 = o2.loadLabel(getPackageManager()).toString(); return c.compare(n1, n2); } }); packageList.clear(); packageList.addAll(listPack); }
Example 17
Source File: TaskController.java From batteryhub with Apache License 2.0 | 4 votes |
private boolean isSystemApp(PackageInfo packageInfo) { return packageInfo != null && (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; }
Example 18
Source File: AppInfoEngine.java From AppPlus with MIT License | 4 votes |
boolean isUserApp(PackageInfo packageInfo) { if(packageInfo == null)return false; int mask = ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP; return (packageInfo.applicationInfo.flags & mask) == 0; }
Example 19
Source File: AppListViewModel.java From island with Apache License 2.0 | 4 votes |
private static void cloneApp(final Context context, final IslandAppInfo app) { final String pkg = app.packageName; final IslandAppInfo app_in_profile = IslandAppListProvider.getInstance(context).get(pkg, Users.profile); if (app_in_profile != null && app_in_profile.isInstalled() && ! app_in_profile.enabled) { launchSystemAppSettings(context, app_in_profile); return; } if ((app.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { Analytics.$().event("clone_sys").with(ITEM_ID, pkg).send(); MethodShuttle.runInProfile(context, () -> new DevicePolicies(context).enableSystemApp(pkg)).thenAccept(enabled -> Toast.makeText(context, context.getString(enabled ? R.string.toast_successfully_cloned : R.string.toast_cannot_clone, app.getLabel()), enabled ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG).show() ).exceptionally(throwable -> { reportAndShowToastForInternalException(context, "Error cloning system app: " + pkg, throwable); return null; }); } final String source_dir = app.sourceDir; // Reduce the IPC cost for the shuttled method below MethodShuttle.runInProfile(context, () -> new IslandAppClones(context).cloneUserApp(pkg, source_dir, false)).thenAccept(result -> { switch (result) { case IslandAppClones.CLONE_RESULT_ALREADY_CLONED: if (app_in_profile != null && ! app_in_profile.shouldShowAsEnabled()) { // Actually frozen system app shown as disabled, just unfreeze it. MethodShuttle.runInProfile(context, () -> IslandManager.ensureAppHiddenState(context, pkg, false)).thenAccept(unfrozen -> { if (unfrozen) { app.stopTreatingHiddenSysAppAsDisabled(); Toast.makeText(context, context.getString(R.string.toast_successfully_cloned, app.getLabel()), Toast.LENGTH_SHORT).show(); } }).exceptionally(t -> { reportAndShowToastForInternalException(context, "Error unfreezing app: " + pkg, t); return null; }); } else Toast.makeText(context, R.string.toast_already_cloned, Toast.LENGTH_SHORT).show(); break; case IslandAppClones.CLONE_RESULT_NO_SYS_MARKET: final Activity activity = Activities.findActivityFrom(context); if (activity != null) Dialogs.buildAlert(activity, 0, R.string.dialog_clone_incapable_explanation) .setNeutralButton(R.string.dialog_button_learn_more, (d, w) -> WebContent.view(context, Config.URL_FAQ.get())) .setPositiveButton(android.R.string.cancel, null).show(); else Toast.makeText(context, R.string.dialog_clone_incapable_explanation, Toast.LENGTH_LONG).show(); break; case IslandAppClones.CLONE_RESULT_OK_INSTALL: Analytics.$().event("clone_install").with(ITEM_ID, pkg).send(); showExplanationBeforeCloning("clone-via-install-explained", context, R.string.dialog_clone_via_install_explanation, app); break; case IslandAppClones.CLONE_RESULT_OK_INSTALL_EXISTING: Analytics.$().event("clone_install_existing").with(ITEM_ID, pkg).send(); doCloneUserApp(context, app); // No explanation needed. break; case IslandAppClones.CLONE_RESULT_OK_GOOGLE_PLAY: Analytics.$().event("clone_via_play").with(ITEM_ID, pkg).send(); showExplanationBeforeCloning("clone-via-google-play-explained", context, R.string.dialog_clone_via_google_play_explanation, app); break; case IslandAppClones.CLONE_RESULT_UNKNOWN_SYS_MARKET: final Intent market_intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + pkg)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); final ActivityInfo market_info = market_intent.resolveActivityInfo(context.getPackageManager(), PackageManager.MATCH_DEFAULT_ONLY); if (market_info != null && (market_info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) Analytics.$().event("clone_via_market").with(ITEM_ID, pkg).with(ITEM_CATEGORY, market_info.packageName).send(); showExplanationBeforeCloning("clone-via-sys-market-explained", context, R.string.dialog_clone_via_sys_market_explanation, app); break; case IslandAppClones.CLONE_RESULT_NOT_FOUND: Toast.makeText(context, R.string.toast_internal_error, Toast.LENGTH_SHORT).show(); break; } }).exceptionally(t -> { reportAndShowToastForInternalException(context, "Error checking user app for cloning: " + pkg, t); return null; }); // Dry run to check prerequisites. }
Example 20
Source File: DefaultBrowserInfo.java From 365browser with Apache License 2.0 | 4 votes |
private static boolean isSystemPackage(ResolveInfo info) { return (info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; }