List of usage examples for android.content.pm ApplicationInfo FLAG_DEBUGGABLE
int FLAG_DEBUGGABLE
To view the source code for android.content.pm ApplicationInfo FLAG_DEBUGGABLE.
Click Source Link
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
final private boolean initSettingParms() { boolean initialized = false; if (getPrefsMgr().getString(getString(R.string.settings_main_log_level), "-1").equals("-1")) { //first time PackageInfo packageInfo;/*w w w .j a v a 2 s . c om*/ String ddl = "0"; try { packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0); int flags = packageInfo.applicationInfo.flags; if ((flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) ddl = "2"; } catch (NameNotFoundException e) { e.printStackTrace(); } getPrefsMgr().edit().putString(getString(R.string.settings_main_log_level), ddl).commit(); getPrefsMgr().edit().putString(getString(R.string.settings_main_scheduler_max_task_count), "20") .commit(); getPrefsMgr().edit().putString(getString(R.string.settings_main_scheduler_thread_pool_count), "5") .commit(); getPrefsMgr().edit().putBoolean(getString(R.string.settings_main_enable_scheduler), true).commit(); getPrefsMgr().edit().putBoolean(getString(R.string.settings_main_restart_scheduler), false).commit(); getPrefsMgr().edit().putBoolean(getString(R.string.settings_main_device_admin), true).commit(); getPrefsMgr().edit().putBoolean(getString(R.string.settings_main_sample_recreate), false).commit(); getPrefsMgr().edit().putBoolean(getString(R.string.settings_main_scheduler_monitor), false).commit(); getPrefsMgr().edit() .putString(mContext.getString(R.string.settings_main_log_dir), Environment.getExternalStorageDirectory().toString() + "/" + APPLICATION_TAG + "/") .commit(); getPrefsMgr().edit() .putString(getString(R.string.settings_main_light_sensor_monitor_interval_time), "1000") .commit(); getPrefsMgr().edit().putString(getString(R.string.settings_main_light_sensor_monitor_active_time), "10") .commit(); getPrefsMgr().edit().putString(getString(R.string.settings_main_light_sensor_detect_thresh_hold), "30") .commit(); getPrefsMgr().edit().putString(getString(R.string.settings_main_light_sensor_ignore_time), "2") .commit(); initialized = true; } mEnvParms.loadSettingParms(mContext); return initialized; }
From source file:com.landenlabs.all_devtool.PackageFragment.java
boolean addPackageInfo(PackageInfo packInfo) { if (packInfo == null) return false; String packageName = packInfo.packageName.trim(); for (PackingItem item : m_workList) { if (item.fieldStr().equals(packageName)) { return false; }/*from w w w . j a v a2s. c o m*/ } ArrayListPairString pkgList = new ArrayListPairString(); String appName = packInfo.applicationInfo.loadLabel(getActivity().getPackageManager()).toString().trim(); long pkgSize = 0; addList(pkgList, "Version", packInfo.versionName); addList(pkgList, "VerCode", String.valueOf(packInfo.versionCode)); // addList(pkgList, "Directory", packInfo.applicationInfo.sourceDir); try { File file = new File(packInfo.applicationInfo.sourceDir); pkgSize = file.length(); addList(pkgList, "FileSize", NumberFormat.getNumberInstance(Locale.getDefault()).format(pkgSize)); } catch (Exception ex) { } if (!TextUtils.isEmpty(packInfo.applicationInfo.permission)) addList(pkgList, "Permission", packInfo.applicationInfo.permission); if (packInfo.applicationInfo.sharedLibraryFiles != null) addList(pkgList, "ShrLibs", packInfo.applicationInfo.sharedLibraryFiles.toString()); addList(pkgList, "TargetSDK", String.valueOf(packInfo.applicationInfo.targetSdkVersion)); m_date.setTime(packInfo.firstInstallTime); addList(pkgList, "Install First", s_timeFormat.format(m_date)); m_date.setTime(packInfo.lastUpdateTime); addList(pkgList, "Install Last", s_timeFormat.format(m_date)); if (packInfo.requestedPermissions != null) { // addList(pkgList, "RegPermissions", Arrays.toString(packInfo.requestedPermissions).replaceAll("[a-z]*", "").replaceAll(",", "\n")); addList(pkgList, m_regPermissionsStr, String.format(" #%d", packInfo.requestedPermissions.length)); if (false) { for (int pidx = 0; pidx != packInfo.requestedPermissions.length; pidx++) { String perm = packInfo.requestedPermissions[pidx].replaceAll("[a-z.]*", ""); if (perm.length() > 30) perm = perm.substring(0, 30); addList(pkgList, String.format(" %2d", pidx), perm); } } } if (packInfo.permissions != null) { addList(pkgList, m_permissionsStr, String.format(" #%d", packInfo.permissions.length)); } if (packInfo.activities != null) { addList(pkgList, m_activitiesStr, String.format(" #%d", packInfo.activities.length)); } if (packInfo.services != null) { addList(pkgList, m_servicesStr, String.format(" #%d", packInfo.services.length)); } if (Build.VERSION.SDK_INT > 21) { if (packInfo.splitNames != null && packInfo.splitNames.length != 0) { for (int splitIdx = 0; splitIdx != packInfo.splitNames.length; splitIdx++) { addList(pkgList, String.format(" SplitName%2d", splitIdx), packInfo.splitNames[splitIdx]); } } } addList(pkgList, "Apk File", packInfo.applicationInfo.publicSourceDir); StringBuilder flagStr = new StringBuilder(); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) flagStr.append(" Debug "); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_IS_GAME) != 0) flagStr.append(" Game "); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_ALLOW_BACKUP) != 0) flagStr.append(" AllowBackup "); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) flagStr.append(" System "); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_LARGE_HEAP) != 0) flagStr.append(" LargeHeap "); if (flagStr.length() != 0) { addList(pkgList, "Flags", flagStr.toString()); } if (packInfo.signatures != null) { String signatures = ""; for (android.content.pm.Signature sig : packInfo.signatures) { signatures = signatures + " " + sig.toCharsString(); } addList(pkgList, "Signature", signatures); } if (packInfo.providers != null) { addList(pkgList, m_providers, String.valueOf(packInfo.providers.length)); if (false) { String providers = ""; for (ProviderInfo providerInfo : packInfo.providers) { providers = providers + " " + providerInfo.name; } addList(pkgList, "Providers", providers); } } m_workList.add(new PackingItem(packInfo.packageName.trim(), pkgList, packInfo, pkgSize, appName)); return true; }
From source file:com.landenlabs.all_devtool.PackageFragment.java
/** * Load installed (user or system) packages. * * TODO - include/*from w w w.j ava 2 s . com*/ * /data/local/tmp * /sdcard/local/tmp ? * /storage/sdcardx/LOST.DIR/ * /sdcard/download * */ void loadCachedPackages() { try { // m_pkgUninstallBtn.setText(R.string.package_uninstall); m_uninstallResId = R.string.package_del_cache; m_pkgUninstallBtn.post(new Runnable() { @Override public void run() { updateUninstallBtn(); } }); m_workList = new ArrayList<PackingItem>(); // PackageManager.GET_SIGNATURES | PackageManager.GET_PERMISSIONS | PackageManager.GET_PROVIDERS; int flags1 = PackageManager.GET_META_DATA | PackageManager.GET_SHARED_LIBRARY_FILES | PackageManager.GET_INTENT_FILTERS; int flags2 = PackageManager.GET_META_DATA | PackageManager.GET_SHARED_LIBRARY_FILES; int flags3 = PackageManager.GET_META_DATA; int flags4 = 0; List<PackageInfo> packList = getActivity().getPackageManager().getInstalledPackages(flags1); /* packList = mergePackages(packList, getActivity().getPackageManager().getInstalledPackages(flags2)); packList = mergePackages(packList, getActivity().getPackageManager().getInstalledPackages(flags3)); packList = mergePackages(packList, getActivity().getPackageManager().getInstalledPackages(flags4)); */ if (packList != null) for (int idx = 0; idx < packList.size(); idx++) { PackageInfo packInfo = packList.get(idx); long cacheSize = 0; long fileCount = 0; if (packInfo == null || packInfo.lastUpdateTime <= 0) { continue; // Bad package } Context pkgContext; try { m_log.d(String.format("%3d/%d : %s", idx, packList.size(), packInfo.packageName)); pkgContext = getActivity().createPackageContext(packInfo.packageName, Context.CONTEXT_IGNORE_SECURITY); } catch (Exception ex) { m_log.e(ex.getLocalizedMessage()); continue; // Bad package } File cacheDirectory = null; Utils.DirSizeCount cacheDirSize = null; if (pkgContext.getCacheDir() != null) { cacheDirectory = pkgContext.getCacheDir(); } else { // cacheDirectory = new File(mContext.getPackageResourcePath()); if (pkgContext.getFilesDir() != null) { String dataPath = pkgContext.getFilesDir().getPath(); // "/data/data/" cacheDirectory = new File(dataPath, pkgContext.getPackageName() + "/cache"); } } if (cacheDirectory != null) { // cacheSize = cacheDirectory.length()/1024; cacheDirSize = Utils.getDirectorySize(cacheDirectory); if (true) { // Cache is not readable or empty, // Try and map cache dir to one of the sd storage paths for (String storageDir : m_storageDirs) { try { File cacheDirectory2 = new File(cacheDirectory.getCanonicalPath() .replace("/data/data", storageDir + "/Android/data")); if (cacheDirectory2.exists()) { cacheDirectory = cacheDirectory2; Utils.DirSizeCount dirSize = Utils.getDirectorySize(cacheDirectory2); if (cacheDirSize == null || dirSize.size > cacheDirSize.size) { cacheDirSize = dirSize; cacheDirectory = cacheDirectory2; } } } catch (Exception ex) { m_log.d(ex.getMessage()); } } } } else { m_log.d(packInfo.packageName + " missing cache dir"); } Utils.DirSizeCount datDirSize = null; if (packInfo.applicationInfo.dataDir != null) { try { datDirSize = Utils.getDirectorySize(new File(packInfo.applicationInfo.dataDir)); } catch (Exception ex) { } } /* Method getPackageSizeInfo; try { getPackageSizeInfo = getActivity().getPackageManager().getClass().getMethod( "getPackageSizeInfo", String.class, Class.forName("android.content.pm.IPackageStatsObserver")); getPackageSizeInfo.invoke(getActivity().getPackageManager(), packInfo.packageName, new IPackageStatsObserver() { @Override public void onGetStatsCompleted( PackageStats pStats, boolean succeeded) throws RemoteException { totalSize = totalSize + pStats.cacheSize; } } ); } catch (Exception e) { continue; } */ /* if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) */ { ArrayListPairString pkgList = new ArrayListPairString(); String appName = "unknown"; try { appName = packInfo.applicationInfo.loadLabel(getActivity().getPackageManager()) .toString().trim(); } catch (Exception ex) { m_log.e(ex.getLocalizedMessage()); } long pkgSize = 0; addList(pkgList, "Version", packInfo.versionName); addList(pkgList, "TargetSDK", String.valueOf(packInfo.applicationInfo.targetSdkVersion)); String installTyp = "auto"; if (Build.VERSION.SDK_INT >= 21) { switch (packInfo.installLocation) { case PackageInfo.INSTALL_LOCATION_AUTO: break; case PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY: installTyp = "internal"; break; case PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL: installTyp = "external"; break; } } addList(pkgList, "Install", installTyp); // Add application info. try { addList(pkgList, "Allow Backup", String.valueOf((packInfo.applicationInfo.flags & FLAG_ALLOW_BACKUP) != 0)); addList(pkgList, "Debuggable", String.valueOf( (packInfo.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0)); addList(pkgList, "External Storage", String.valueOf( (packInfo.applicationInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0)); String themeName = getResourceName(packInfo, packInfo.applicationInfo.theme); if (!TextUtils.isEmpty(themeName)) addList(pkgList, "Theme", themeName); } catch (Exception ex) { Log.d("foo", ex.getMessage()); } try { File file = new File(packInfo.applicationInfo.sourceDir); pkgSize = file.length(); } catch (Exception ex) { } addList(pkgList, "Apk File", packInfo.applicationInfo.publicSourceDir); addList(pkgList, "Apk Size", NumberFormat.getNumberInstance(Locale.getDefault()).format(pkgSize)); addList(pkgList, "Src Dir", packInfo.applicationInfo.sourceDir); addList(pkgList, "lib Dir", packInfo.applicationInfo.nativeLibraryDir); addList(pkgList, "dat Dir", packInfo.applicationInfo.dataDir); if (null != datDirSize) { addList(pkgList, "* Dir Size", NumberFormat.getNumberInstance(Locale.getDefault()).format(datDirSize.size)); addList(pkgList, "* File Count", NumberFormat.getNumberInstance(Locale.getDefault()).format(datDirSize.count)); } if (null != cacheDirectory) { addList(pkgList, "Cache", cacheDirectory.getCanonicalPath()); if (null != cacheDirSize) { cacheSize = cacheDirSize.size; addList(pkgList, "* Dir Size", NumberFormat.getNumberInstance(Locale.getDefault()) .format(cacheDirSize.size)); addList(pkgList, "* File Count", NumberFormat .getNumberInstance(Locale.getDefault()).format(cacheDirSize.count)); } } if (null != packInfo.applicationInfo.sharedLibraryFiles && packInfo.applicationInfo.sharedLibraryFiles.length != 0) { addList(pkgList, "ShareLibs", NumberFormat.getNumberInstance(Locale.getDefault()) .format(packInfo.applicationInfo.sharedLibraryFiles.length)); for (String shrLibStr : packInfo.applicationInfo.sharedLibraryFiles) { addList(pkgList, " ", shrLibStr); } } if (true) { // packInfo.configPreferences; use with flag= GET_CONFIGURATIONS; // packInfo.providers use with GET_PROVIDERS; List<IntentFilter> outFilters = new ArrayList<IntentFilter>(); List<ComponentName> outActivities = new ArrayList<ComponentName>(); int num = getActivity().getPackageManager().getPreferredActivities(outFilters, outActivities, packInfo.packageName); if (num > 0) { addList(pkgList, "Preferred #", String.valueOf(num)); } } /* if (null != cacheDirectory) */ // if (cacheDirSize != null) { m_workList.add(new PackingItem(packInfo.packageName.trim(), pkgList, packInfo, cacheSize, appName)); } } } } catch (Exception ex) { m_log.e(ex.getMessage()); } }
From source file:android.content.pm.PackageParser.java
/** * Parse the {@code application} XML tree at the current parse location in a * <em>base APK</em> manifest. * <p>//from www .j av a 2 s . c o m * When adding new features, carefully consider if they should also be * supported by split APKs. */ private boolean parseBaseApplication(Package owner, Resources res, XmlPullParser parser, AttributeSet attrs, int flags, String[] outError) throws XmlPullParserException, IOException { final ApplicationInfo ai = owner.applicationInfo; final String pkgName = owner.applicationInfo.packageName; TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestApplication); String name = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_name, 0); if (name != null) { ai.className = buildClassName(pkgName, name, outError); if (ai.className == null) { sa.recycle(); mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } } String manageSpaceActivity = sa.getNonConfigurationString( com.android.internal.R.styleable.AndroidManifestApplication_manageSpaceActivity, Configuration.NATIVE_CONFIG_VERSION); if (manageSpaceActivity != null) { ai.manageSpaceActivityName = buildClassName(pkgName, manageSpaceActivity, outError); } boolean allowBackup = sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_allowBackup, true); if (allowBackup) { ai.flags |= ApplicationInfo.FLAG_ALLOW_BACKUP; // backupAgent, killAfterRestore, fullBackupContent and restoreAnyVersion are only // relevant if backup is possible for the given application. String backupAgent = sa.getNonConfigurationString( com.android.internal.R.styleable.AndroidManifestApplication_backupAgent, Configuration.NATIVE_CONFIG_VERSION); if (backupAgent != null) { ai.backupAgentName = buildClassName(pkgName, backupAgent, outError); if (DEBUG_BACKUP) { Slog.v(TAG, "android:backupAgent = " + ai.backupAgentName + " from " + pkgName + "+" + backupAgent); } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_killAfterRestore, true)) { ai.flags |= ApplicationInfo.FLAG_KILL_AFTER_RESTORE; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_restoreAnyVersion, false)) { ai.flags |= ApplicationInfo.FLAG_RESTORE_ANY_VERSION; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_fullBackupOnly, false)) { ai.flags |= ApplicationInfo.FLAG_FULL_BACKUP_ONLY; } } TypedValue v = sa .peekValue(com.android.internal.R.styleable.AndroidManifestApplication_fullBackupContent); if (v != null && (ai.fullBackupContent = v.resourceId) == 0) { if (DEBUG_BACKUP) { Slog.v(TAG, "fullBackupContent specified as boolean=" + (v.data == 0 ? "false" : "true")); } // "false" => -1, "true" => 0 ai.fullBackupContent = (v.data == 0 ? -1 : 0); } if (DEBUG_BACKUP) { Slog.v(TAG, "fullBackupContent=" + ai.fullBackupContent + " for " + pkgName); } } TypedValue v = sa.peekValue(com.android.internal.R.styleable.AndroidManifestApplication_label); if (v != null && (ai.labelRes = v.resourceId) == 0) { ai.nonLocalizedLabel = v.coerceToString(); } ai.icon = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_icon, 0); ai.logo = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_logo, 0); ai.banner = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_banner, 0); ai.theme = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_theme, 0); ai.descriptionRes = sa .getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_description, 0); if ((flags & PARSE_IS_SYSTEM) != 0) { if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_persistent, false)) { ai.flags |= ApplicationInfo.FLAG_PERSISTENT; } } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_requiredForAllUsers, false)) { owner.mRequiredForAllUsers = true; } String restrictedAccountType = sa .getString(com.android.internal.R.styleable.AndroidManifestApplication_restrictedAccountType); if (restrictedAccountType != null && restrictedAccountType.length() > 0) { owner.mRestrictedAccountType = restrictedAccountType; } String requiredAccountType = sa .getString(com.android.internal.R.styleable.AndroidManifestApplication_requiredAccountType); if (requiredAccountType != null && requiredAccountType.length() > 0) { owner.mRequiredAccountType = requiredAccountType; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_debuggable, false)) { ai.flags |= ApplicationInfo.FLAG_DEBUGGABLE; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_vmSafeMode, false)) { ai.flags |= ApplicationInfo.FLAG_VM_SAFE_MODE; } owner.baseHardwareAccelerated = sa.getBoolean( com.android.internal.R.styleable.AndroidManifestApplication_hardwareAccelerated, owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH); if (owner.baseHardwareAccelerated) { ai.flags |= ApplicationInfo.FLAG_HARDWARE_ACCELERATED; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_hasCode, true)) { ai.flags |= ApplicationInfo.FLAG_HAS_CODE; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_allowTaskReparenting, false)) { ai.flags |= ApplicationInfo.FLAG_ALLOW_TASK_REPARENTING; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_allowClearUserData, true)) { ai.flags |= ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_testOnly, false)) { ai.flags |= ApplicationInfo.FLAG_TEST_ONLY; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_largeHeap, false)) { ai.flags |= ApplicationInfo.FLAG_LARGE_HEAP; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_usesCleartextTraffic, true)) { ai.flags |= ApplicationInfo.FLAG_USES_CLEARTEXT_TRAFFIC; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_supportsRtl, false /* default is no RTL support*/)) { ai.flags |= ApplicationInfo.FLAG_SUPPORTS_RTL; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_multiArch, false)) { ai.flags |= ApplicationInfo.FLAG_MULTIARCH; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_extractNativeLibs, true)) { ai.flags |= ApplicationInfo.FLAG_EXTRACT_NATIVE_LIBS; } String str; str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_permission, 0); ai.permission = (str != null && str.length() > 0) ? str.intern() : null; if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.FROYO) { str = sa.getNonConfigurationString( com.android.internal.R.styleable.AndroidManifestApplication_taskAffinity, Configuration.NATIVE_CONFIG_VERSION); } else { // Some older apps have been seen to use a resource reference // here that on older builds was ignored (with a warning). We // need to continue to do this for them so they don't break. str = sa.getNonResourceString(com.android.internal.R.styleable.AndroidManifestApplication_taskAffinity); } ai.taskAffinity = buildTaskAffinityName(ai.packageName, ai.packageName, str, outError); if (outError[0] == null) { CharSequence pname; if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.FROYO) { pname = sa.getNonConfigurationString( com.android.internal.R.styleable.AndroidManifestApplication_process, Configuration.NATIVE_CONFIG_VERSION); } else { // Some older apps have been seen to use a resource reference // here that on older builds was ignored (with a warning). We // need to continue to do this for them so they don't break. pname = sa .getNonResourceString(com.android.internal.R.styleable.AndroidManifestApplication_process); } ai.processName = buildProcessName(ai.packageName, null, pname, flags, mSeparateProcesses, outError); ai.enabled = sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_enabled, true); if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_isGame, false)) { ai.flags |= ApplicationInfo.FLAG_IS_GAME; } if (false) { if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_cantSaveState, false)) { ai.privateFlags |= ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE; // A heavy-weight application can not be in a custom process. // We can do direct compare because we intern all strings. if (ai.processName != null && ai.processName != ai.packageName) { outError[0] = "cantSaveState applications can not use custom processes"; } } } } ai.uiOptions = sa.getInt(com.android.internal.R.styleable.AndroidManifestApplication_uiOptions, 0); sa.recycle(); if (outError[0] != null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } final int innerDepth = parser.getDepth(); int type; while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) { if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { continue; } String tagName = parser.getName(); if (tagName.equals("activity")) { Activity a = parseActivity(owner, res, parser, attrs, flags, outError, false, owner.baseHardwareAccelerated); if (a == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.activities.add(a); } else if (tagName.equals("receiver")) { Activity a = parseActivity(owner, res, parser, attrs, flags, outError, true, false); if (a == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.receivers.add(a); } else if (tagName.equals("service")) { Service s = parseService(owner, res, parser, attrs, flags, outError); if (s == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.services.add(s); } else if (tagName.equals("provider")) { Provider p = parseProvider(owner, res, parser, attrs, flags, outError); if (p == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.providers.add(p); } else if (tagName.equals("activity-alias")) { Activity a = parseActivityAlias(owner, res, parser, attrs, flags, outError); if (a == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.activities.add(a); } else if (parser.getName().equals("meta-data")) { // note: application meta-data is stored off to the side, so it can // remain null in the primary copy (we like to avoid extra copies because // it can be large) if ((owner.mAppMetaData = parseMetaData(res, parser, attrs, owner.mAppMetaData, outError)) == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } } else if (tagName.equals("library")) { sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestLibrary); // Note: don't allow this value to be a reference to a resource // that may change. String lname = sa .getNonResourceString(com.android.internal.R.styleable.AndroidManifestLibrary_name); sa.recycle(); if (lname != null) { lname = lname.intern(); if (!ArrayUtils.contains(owner.libraryNames, lname)) { owner.libraryNames = ArrayUtils.add(owner.libraryNames, lname); } } XmlUtils.skipCurrentTag(parser); } else if (tagName.equals("uses-library")) { sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestUsesLibrary); // Note: don't allow this value to be a reference to a resource // that may change. String lname = sa .getNonResourceString(com.android.internal.R.styleable.AndroidManifestUsesLibrary_name); boolean req = sa.getBoolean(com.android.internal.R.styleable.AndroidManifestUsesLibrary_required, true); sa.recycle(); if (lname != null) { lname = lname.intern(); if (req) { owner.usesLibraries = ArrayUtils.add(owner.usesLibraries, lname); } else { owner.usesOptionalLibraries = ArrayUtils.add(owner.usesOptionalLibraries, lname); } } XmlUtils.skipCurrentTag(parser); } else if (tagName.equals("uses-package")) { // Dependencies for app installers; we don't currently try to // enforce this. XmlUtils.skipCurrentTag(parser); } else { if (!RIGID_PARSER) { Slog.w(TAG, "Unknown element under <application>: " + tagName + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } else { outError[0] = "Bad element under <application>: " + tagName; mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } } } modifySharedLibrariesForBackwardCompatibility(owner); if (hasDomainURLs(owner)) { owner.applicationInfo.privateFlags |= ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS; } else { owner.applicationInfo.privateFlags &= ~ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS; } return true; }
From source file:de.vanita5.twittnuker.util.Utils.java
public static boolean isDebuggable(final Context context) { if (context == null) return false; final ApplicationInfo info; try {/*from w w w .j ava 2s . c o m*/ info = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0); } catch (final NameNotFoundException e) { return false; } return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; }
From source file:org.getlantern.firetweet.util.Utils.java
public static boolean isDebuggable(final Context context) { if (context == null) return false; final ApplicationInfo info; try {/*from w w w .j av a2 s . c o m*/ info = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0); } catch (final NameNotFoundException e) { Crashlytics.logException(e); return false; } return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; }