List of usage examples for android.content.pm ApplicationInfo FLAG_UPDATED_SYSTEM_APP
int FLAG_UPDATED_SYSTEM_APP
To view the source code for android.content.pm ApplicationInfo FLAG_UPDATED_SYSTEM_APP.
Click Source Link
From source file:org.durka.hallmonitor.CoreStateManager.java
CoreStateManager(Context context) { mAppContext = context;//from w ww. ja v a 2 s .c o m mPowerManager = (PowerManager) mAppContext.getSystemService(Context.POWER_SERVICE); daPartialWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "CoreStateManager"); daPartialWakeLock.setReferenceCounted(false); globalPartialWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "CoreReceiver"); globalPartialWakeLock.setReferenceCounted(true); preference_all = PreferenceManager.getDefaultSharedPreferences(mAppContext); // Enable access to sleep mode systemApp = (mAppContext.getApplicationInfo().flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0; if (systemApp) { Log.d(LOG_TAG, "We are a system app."); } else { Log.d(LOG_TAG, "We are not a system app."); preference_all.edit().putBoolean("pref_internal_power_management", false).commit(); } refreshAdminApp(); refreshRootApp(); refreshLockMode(); refreshOsPowerManagement(); refreshInternalPowerManagement(); refreshInternalService(); if (preference_all.getBoolean("pref_proximity", false)) { forceCheckCoverState = true; } hmAppWidgetManager = new HMAppWidgetManager(this); if (preference_all.getBoolean("pref_default_widget", false)) { int widgetId = preference_all.getInt("default_widget_id", -1); if (widgetId == -1) { registerWidget("default"); } else { createWidget("default"); } } if (preference_all.getBoolean("pref_media_widget", false)) { audioManager = (AudioManager) mAppContext.getSystemService(Context.AUDIO_SERVICE); int widgetId = preference_all.getInt("media_widget_id", -1); if (widgetId == -1) { registerWidget("media"); } else { createWidget("media"); } } this.hardwareAccelerated = preference_all.getBoolean("pref_hardwareAccelerated", false); // we might have missed a phone-state revelation phone_ringing = ((TelephonyManager) mAppContext.getSystemService(Context.TELEPHONY_SERVICE)) .getCallState() == TelephonyManager.CALL_STATE_RINGING; // we might have missed an alarm alert // TODO: find a way // alarm_firing = // ((TelephonyManager) // mAppContext.getSystemService(Context.TELEPHONY_SERVICE)).getCallState() // == TelephonyManager.CALL_STATE_RINGING; Intent stateIntent = mAppContext.registerReceiver(null, new IntentFilter(CoreReceiver.TORCH_STATE_CHANGED)); torch_on = stateIntent != null && stateIntent.getIntExtra("state", 0) != 0; init = true; }
From source file:com.dnielfe.manager.AppManager.java
private void get_downloaded_apps() { List<ApplicationInfo> all_apps = pm.getInstalledApplications(PackageManager.GET_META_DATA); if (!mAppList.isEmpty()) mAppList.clear();/*from ww w. jav a 2 s. c o m*/ for (ApplicationInfo appInfo : all_apps) { if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0 && (appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 0 && appInfo.flags != 0) mAppList.add(appInfo); } // Sorting ListView showing Installed Applications Collections.sort(mAppList, new ApplicationInfo.DisplayNameComparator(pm)); // update UI initActionBar(); mAdapter.notifyDataSetChanged(); }
From source file:android_network.hetnet.vpn_service.Util.java
public static boolean isSystem(String packageName, Context context) { try {/* w w w. j a v a 2s . c o m*/ PackageManager pm = context.getPackageManager(); PackageInfo info = pm.getPackageInfo(packageName, 0); return ((info.applicationInfo.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0); /* PackageInfo pkg = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES); PackageInfo sys = pm.getPackageInfo("android", PackageManager.GET_SIGNATURES); return (pkg != null && pkg.signatures != null && pkg.signatures.length > 0 && sys.signatures.length > 0 && sys.signatures[0].equals(pkg.signatures[0])); */ } catch (PackageManager.NameNotFoundException ignore) { return false; } }
From source file:org.mozilla.gecko.GeckoApp.java
String[] getPluginDirectories() { // we don't support Honeycomb if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && Build.VERSION.SDK_INT < 14 /*Build.VERSION_CODES.ICE_CREAM_SANDWICH*/ ) return new String[0]; Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - start of getPluginDirectories"); ArrayList<String> directories = new ArrayList<String>(); PackageManager pm = mAppContext.getPackageManager(); List<ResolveInfo> plugins = pm.queryIntentServices(new Intent(PLUGIN_ACTION), PackageManager.GET_SERVICES | PackageManager.GET_META_DATA); synchronized (mPackageInfoCache) { // clear the list of existing packageInfo objects mPackageInfoCache.clear();/* w w w. j ava 2s . com*/ for (ResolveInfo info : plugins) { // retrieve the plugin's service information ServiceInfo serviceInfo = info.serviceInfo; if (serviceInfo == null) { Log.w(LOGTAG, "Ignore bad plugin"); continue; } // Blacklist HTC's flash lite. // See bug #704516 - We're not quite sure what Flash Lite does, // but loading it causes Flash to give errors and fail to draw. if (serviceInfo.packageName.equals("com.htc.flashliteplugin")) { Log.w(LOGTAG, "Skipping HTC's flash lite plugin"); continue; } Log.w(LOGTAG, "Loading plugin: " + serviceInfo.packageName); // retrieve information from the plugin's manifest PackageInfo pkgInfo; try { pkgInfo = pm.getPackageInfo(serviceInfo.packageName, PackageManager.GET_PERMISSIONS | PackageManager.GET_SIGNATURES); } catch (Exception e) { Log.w(LOGTAG, "Can't find plugin: " + serviceInfo.packageName); continue; } if (pkgInfo == null) { Log.w(LOGTAG, "Loading plugin: " + serviceInfo.packageName + ". Could not load package information."); continue; } /* * find the location of the plugin's shared library. The default * is to assume the app is either a user installed app or an * updated system app. In both of these cases the library is * stored in the app's data directory. */ String directory = pkgInfo.applicationInfo.dataDir + "/lib"; final int appFlags = pkgInfo.applicationInfo.flags; final int updatedSystemFlags = ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP; // preloaded system app with no user updates if ((appFlags & updatedSystemFlags) == ApplicationInfo.FLAG_SYSTEM) { directory = PLUGIN_SYSTEM_LIB + pkgInfo.packageName; } // check if the plugin has the required permissions String permissions[] = pkgInfo.requestedPermissions; if (permissions == null) { Log.w(LOGTAG, "Loading plugin: " + serviceInfo.packageName + ". Does not have required permission."); continue; } boolean permissionOk = false; for (String permit : permissions) { if (PLUGIN_PERMISSION.equals(permit)) { permissionOk = true; break; } } if (!permissionOk) { Log.w(LOGTAG, "Loading plugin: " + serviceInfo.packageName + ". Does not have required permission (2)."); continue; } // check to ensure the plugin is properly signed Signature signatures[] = pkgInfo.signatures; if (signatures == null) { Log.w(LOGTAG, "Loading plugin: " + serviceInfo.packageName + ". Not signed."); continue; } // determine the type of plugin from the manifest if (serviceInfo.metaData == null) { Log.e(LOGTAG, "The plugin '" + serviceInfo.name + "' has no type defined"); continue; } String pluginType = serviceInfo.metaData.getString(PLUGIN_TYPE); if (!TYPE_NATIVE.equals(pluginType)) { Log.e(LOGTAG, "Unrecognized plugin type: " + pluginType); continue; } try { Class<?> cls = getPluginClass(serviceInfo.packageName, serviceInfo.name); //TODO implement any requirements of the plugin class here! boolean classFound = true; if (!classFound) { Log.e(LOGTAG, "The plugin's class' " + serviceInfo.name + "' does not extend the appropriate class."); continue; } } catch (NameNotFoundException e) { Log.e(LOGTAG, "Can't find plugin: " + serviceInfo.packageName); continue; } catch (ClassNotFoundException e) { Log.e(LOGTAG, "Can't find plugin's class: " + serviceInfo.name); continue; } // if all checks have passed then make the plugin available mPackageInfoCache.add(pkgInfo); directories.add(directory); } } String[] result = directories.toArray(new String[directories.size()]); Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - end of getPluginDirectories"); return result; }
From source file:android.content.pm.PackageParser.java
public static PackageInfo generatePackageInfo(PackageParser.Package p, int gids[], int flags, long firstInstallTime, long lastUpdateTime, Set<String> grantedPermissions, PackageUserState state, int userId) { if (!checkUseInstalledOrHidden(flags, state)) { return null; }//from www .jav a 2 s . c o m PackageInfo pi = new PackageInfo(); pi.packageName = p.packageName; pi.splitNames = p.splitNames; pi.versionCode = p.mVersionCode; pi.baseRevisionCode = p.baseRevisionCode; pi.splitRevisionCodes = p.splitRevisionCodes; pi.versionName = p.mVersionName; pi.sharedUserId = p.mSharedUserId; pi.sharedUserLabel = p.mSharedUserLabel; pi.applicationInfo = generateApplicationInfo(p, flags, state, userId); pi.installLocation = p.installLocation; pi.coreApp = p.coreApp; if ((pi.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0 || (pi.applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) { pi.requiredForAllUsers = p.mRequiredForAllUsers; } pi.restrictedAccountType = p.mRestrictedAccountType; pi.requiredAccountType = p.mRequiredAccountType; pi.overlayTarget = p.mOverlayTarget; pi.firstInstallTime = firstInstallTime; pi.lastUpdateTime = lastUpdateTime; if ((flags & PackageManager.GET_GIDS) != 0) { pi.gids = gids; } if ((flags & PackageManager.GET_CONFIGURATIONS) != 0) { int N = p.configPreferences != null ? p.configPreferences.size() : 0; if (N > 0) { pi.configPreferences = new ConfigurationInfo[N]; p.configPreferences.toArray(pi.configPreferences); } N = p.reqFeatures != null ? p.reqFeatures.size() : 0; if (N > 0) { pi.reqFeatures = new FeatureInfo[N]; p.reqFeatures.toArray(pi.reqFeatures); } N = p.featureGroups != null ? p.featureGroups.size() : 0; if (N > 0) { pi.featureGroups = new FeatureGroupInfo[N]; p.featureGroups.toArray(pi.featureGroups); } } if ((flags & PackageManager.GET_ACTIVITIES) != 0) { int N = p.activities.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.activities = new ActivityInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.activities.get(i).info.enabled) num++; } pi.activities = new ActivityInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Activity activity = p.activities.get(i); if (activity.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.activities[j++] = generateActivityInfo(p.activities.get(i), flags, state, userId); } } } } if ((flags & PackageManager.GET_RECEIVERS) != 0) { int N = p.receivers.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.receivers = new ActivityInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.receivers.get(i).info.enabled) num++; } pi.receivers = new ActivityInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Activity activity = p.receivers.get(i); if (activity.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.receivers[j++] = generateActivityInfo(p.receivers.get(i), flags, state, userId); } } } } if ((flags & PackageManager.GET_SERVICES) != 0) { int N = p.services.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.services = new ServiceInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.services.get(i).info.enabled) num++; } pi.services = new ServiceInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Service service = p.services.get(i); if (service.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.services[j++] = generateServiceInfo(p.services.get(i), flags, state, userId); } } } } if ((flags & PackageManager.GET_PROVIDERS) != 0) { int N = p.providers.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.providers = new ProviderInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.providers.get(i).info.enabled) num++; } pi.providers = new ProviderInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Provider provider = p.providers.get(i); if (provider.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.providers[j++] = generateProviderInfo(p.providers.get(i), flags, state, userId); } } } } if ((flags & PackageManager.GET_INSTRUMENTATION) != 0) { int N = p.instrumentation.size(); if (N > 0) { pi.instrumentation = new InstrumentationInfo[N]; for (int i = 0; i < N; i++) { pi.instrumentation[i] = generateInstrumentationInfo(p.instrumentation.get(i), flags); } } } if ((flags & PackageManager.GET_PERMISSIONS) != 0) { int N = p.permissions.size(); if (N > 0) { pi.permissions = new PermissionInfo[N]; for (int i = 0; i < N; i++) { pi.permissions[i] = generatePermissionInfo(p.permissions.get(i), flags); } } N = p.requestedPermissions.size(); if (N > 0) { pi.requestedPermissions = new String[N]; pi.requestedPermissionsFlags = new int[N]; for (int i = 0; i < N; i++) { final String perm = p.requestedPermissions.get(i); pi.requestedPermissions[i] = perm; // The notion of required permissions is deprecated but for compatibility. pi.requestedPermissionsFlags[i] |= PackageInfo.REQUESTED_PERMISSION_REQUIRED; if (grantedPermissions != null && grantedPermissions.contains(perm)) { pi.requestedPermissionsFlags[i] |= PackageInfo.REQUESTED_PERMISSION_GRANTED; } } } } if ((flags & PackageManager.GET_SIGNATURES) != 0) { int N = (p.mSignatures != null) ? p.mSignatures.length : 0; if (N > 0) { pi.signatures = new Signature[N]; System.arraycopy(p.mSignatures, 0, pi.signatures, 0, N); } } return pi; }
From source file:com.android.wfds.printservice.WPrintService.java
private static synchronized void loadLibraries(ApplicationInfo appInfo) { if (!mLibrariesLoaded) { if (((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) || ((appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0)) { System.loadLibrary("wfdscrypto"); System.loadLibrary("wfdsssl"); System.loadLibrary("wfdsjpeg"); System.loadLibrary("wfdspng"); System.loadLibrary("wfdscups"); System.loadLibrary("wfds"); } else {/* ww w. j a v a 2s.c o m*/ System.load(Environment.getRootDirectory() + "/lib/libwfdscrypto.so"); System.load(Environment.getRootDirectory() + "/lib/libwfdsssl.so"); System.load(Environment.getRootDirectory() + "/lib/libwfdsjpeg.so"); System.load(Environment.getRootDirectory() + "/lib/libwfdspng.so"); System.load(Environment.getRootDirectory() + "/lib/libwfdscups.so"); System.load(Environment.getRootDirectory() + "/lib/libwfds.so"); } mLibrariesLoaded = true; } }