use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class VrManagerService method isDefaultAllowed.
private boolean isDefaultAllowed(String packageName) {
PackageManager pm = mContext.getPackageManager();
ApplicationInfo info = null;
try {
info = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
} catch (NameNotFoundException e) {
}
if (info == null || !(info.isSystemApp() || info.isUpdatedSystemApp())) {
return false;
}
return true;
}
use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class WallpaperManagerService method isSetWallpaperAllowed.
@Override
public boolean isSetWallpaperAllowed(String callingPackage) {
final PackageManager pm = mContext.getPackageManager();
String[] uidPackages = pm.getPackagesForUid(Binder.getCallingUid());
boolean uidMatchPackage = Arrays.asList(uidPackages).contains(callingPackage);
if (!uidMatchPackage) {
// callingPackage was faked.
return false;
}
final DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class);
if (dpm.isDeviceOwnerApp(callingPackage) || dpm.isProfileOwnerApp(callingPackage)) {
return true;
}
final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
return !um.hasUserRestriction(UserManager.DISALLOW_SET_WALLPAPER);
}
use of android.content.pm.PackageManager in project chromeview by pwnall.
the class SelfBrailleClient method verifyPackage.
private boolean verifyPackage() {
PackageManager pm = mContext.getPackageManager();
PackageInfo pi;
try {
pi = pm.getPackageInfo(BRAILLE_BACK_PACKAGE, PackageManager.GET_SIGNATURES);
} catch (PackageManager.NameNotFoundException ex) {
Log.w(LOG_TAG, "Can't verify package " + BRAILLE_BACK_PACKAGE, ex);
return false;
}
MessageDigest digest;
try {
digest = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException ex) {
Log.e(LOG_TAG, "SHA-1 not supported", ex);
return false;
}
// Check if any of the certificates match our hash.
for (Signature signature : pi.signatures) {
digest.update(signature.toByteArray());
if (MessageDigest.isEqual(EYES_FREE_CERT_SHA1, digest.digest())) {
return true;
}
digest.reset();
}
if (mAllowDebugService) {
Log.w(LOG_TAG, String.format("*** %s connected to BrailleBack with invalid (debug?) " + "signature ***", mContext.getPackageName()));
return true;
}
return false;
}
use of android.content.pm.PackageManager in project chromeview by pwnall.
the class BuildInfo method getPackageVersionCode.
@CalledByNative
public static String getPackageVersionCode(Context context) {
String msg = "versionCode not available.";
try {
PackageManager pm = context.getPackageManager();
PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
msg = "" + pi.versionCode;
} catch (NameNotFoundException e) {
Log.d(TAG, msg);
}
return msg;
}
use of android.content.pm.PackageManager in project chromeview by pwnall.
the class BuildInfo method getPackageVersionName.
@CalledByNative
public static String getPackageVersionName(Context context) {
String msg = "versionName not available";
try {
PackageManager pm = context.getPackageManager();
PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
msg = pi.versionName;
} catch (NameNotFoundException e) {
Log.d(TAG, msg);
}
return msg;
}
Aggregations