List of usage examples for android.content.pm ApplicationInfo PRIVATE_FLAG_PRIVILEGED
int PRIVATE_FLAG_PRIVILEGED
To view the source code for android.content.pm ApplicationInfo PRIVATE_FLAG_PRIVILEGED.
Click Source Link
From source file:com.android.packageinstaller.PackageInstallerActivity.java
private boolean isInstallRequestFromUnknownSource(Intent intent) { String callerPackage = getCallingPackage(); if (callerPackage != null && intent.getBooleanExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, false)) { try {/* w ww. ja v a 2 s . c o m*/ mSourceInfo = mPm.getApplicationInfo(callerPackage, 0); if (mSourceInfo != null) { if ((mSourceInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0) { // Privileged apps are not considered an unknown source. return false; } } } catch (NameNotFoundException e) { } } return true; }
From source file:com.android.packageinstaller.PackageInstallerActivity.java
/** Get the originating uid if possible, or VerificationParams.NO_UID if not available */ private int getOriginatingUid(Intent intent) { // The originating uid from the intent. We only trust/use this if it comes from a // system application int uidFromIntent = intent.getIntExtra(Intent.EXTRA_ORIGINATING_UID, VerificationParams.NO_UID); // Get the source info from the calling package, if available. This will be the // definitive calling package, but it only works if the intent was started using // startActivityForResult, ApplicationInfo sourceInfo = getSourceInfo(); if (sourceInfo != null) { if (uidFromIntent != VerificationParams.NO_UID && (mSourceInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0) { return uidFromIntent; }// w w w .jav a2 s . c o m // We either didn't get a uid in the intent, or we don't trust it. Use the // uid of the calling package instead. return sourceInfo.uid; } // We couldn't get the specific calling package. Let's get the uid instead int callingUid; try { callingUid = ActivityManagerNative.getDefault().getLaunchedFromUid(getActivityToken()); } catch (android.os.RemoteException ex) { Log.w(TAG, "Could not determine the launching uid."); // nothing else we can do return VerificationParams.NO_UID; } // If we got a uid from the intent, we need to verify that the caller is a // privileged system package before we use it if (uidFromIntent != VerificationParams.NO_UID) { String[] callingPackages = mPm.getPackagesForUid(callingUid); if (callingPackages != null) { for (String packageName : callingPackages) { try { ApplicationInfo applicationInfo = mPm.getApplicationInfo(packageName, 0); if ((applicationInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0) { return uidFromIntent; } } catch (NameNotFoundException ex) { // ignore it, and try the next package } } } } // We either didn't get a uid from the intent, or we don't trust it. Use the // calling uid instead. return callingUid; }