Search in sources :

Example 51 with PackageManager

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;
}
Also used : PackageManager(android.content.pm.PackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ApplicationInfo(android.content.pm.ApplicationInfo)

Example 52 with PackageManager

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);
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) PackageManager(android.content.pm.PackageManager) IPackageManager(android.content.pm.IPackageManager) UserManager(android.os.UserManager)

Example 53 with PackageManager

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;
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) Signature(android.content.pm.Signature) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) MessageDigest(java.security.MessageDigest)

Example 54 with PackageManager

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;
}
Also used : PackageManager(android.content.pm.PackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) PackageInfo(android.content.pm.PackageInfo) CalledByNative(org.chromium.base.CalledByNative)

Example 55 with PackageManager

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;
}
Also used : PackageManager(android.content.pm.PackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) PackageInfo(android.content.pm.PackageInfo) CalledByNative(org.chromium.base.CalledByNative)

Aggregations

PackageManager (android.content.pm.PackageManager)1482 Intent (android.content.Intent)505 ResolveInfo (android.content.pm.ResolveInfo)460 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)353 PackageInfo (android.content.pm.PackageInfo)270 ApplicationInfo (android.content.pm.ApplicationInfo)253 ComponentName (android.content.ComponentName)241 ArrayList (java.util.ArrayList)158 ActivityInfo (android.content.pm.ActivityInfo)140 IOException (java.io.IOException)127 RemoteException (android.os.RemoteException)105 Drawable (android.graphics.drawable.Drawable)94 IPackageManager (android.content.pm.IPackageManager)93 Resources (android.content.res.Resources)91 PendingIntent (android.app.PendingIntent)75 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Context (android.content.Context)68 Bundle (android.os.Bundle)60 HashMap (java.util.HashMap)55 ServiceInfo (android.content.pm.ServiceInfo)48