Search in sources :

Example 91 with IPackageManager

use of android.content.pm.IPackageManager in project android_frameworks_base by crdroidandroid.

the class RestrictedLockUtils method checkIfUninstallBlocked.

public static EnforcedAdmin checkIfUninstallBlocked(Context context, String packageName, int userId) {
    EnforcedAdmin allAppsControlDisallowedAdmin = checkIfRestrictionEnforced(context, UserManager.DISALLOW_APPS_CONTROL, userId);
    if (allAppsControlDisallowedAdmin != null) {
        return allAppsControlDisallowedAdmin;
    }
    EnforcedAdmin allAppsUninstallDisallowedAdmin = checkIfRestrictionEnforced(context, UserManager.DISALLOW_UNINSTALL_APPS, userId);
    if (allAppsUninstallDisallowedAdmin != null) {
        return allAppsUninstallDisallowedAdmin;
    }
    IPackageManager ipm = AppGlobals.getPackageManager();
    try {
        if (ipm.getBlockUninstallForUser(packageName, userId)) {
            return getProfileOrDeviceOwner(context, userId);
        }
    } catch (RemoteException e) {
    // Nothing to do
    }
    return null;
}
Also used : IPackageManager(android.content.pm.IPackageManager) RemoteException(android.os.RemoteException)

Example 92 with IPackageManager

use of android.content.pm.IPackageManager in project android_frameworks_base by crdroidandroid.

the class AccountManagerService method checkUidPermission.

private boolean checkUidPermission(String permission, int uid, String opPackageName) {
    final long identity = Binder.clearCallingIdentity();
    try {
        IPackageManager pm = ActivityThread.getPackageManager();
        if (pm.checkUidPermission(permission, uid) != PackageManager.PERMISSION_GRANTED) {
            return false;
        }
        final int opCode = AppOpsManager.permissionToOpCode(permission);
        return (opCode == AppOpsManager.OP_NONE || mAppOpsManager.noteOpNoThrow(opCode, uid, opPackageName) == AppOpsManager.MODE_ALLOWED);
    } catch (RemoteException e) {
    /* ignore - local call */
    } finally {
        Binder.restoreCallingIdentity(identity);
    }
    return false;
}
Also used : IPackageManager(android.content.pm.IPackageManager) RemoteException(android.os.RemoteException)

Example 93 with IPackageManager

use of android.content.pm.IPackageManager in project android_frameworks_base by crdroidandroid.

the class IntentFirewall method logIntent.

private static void logIntent(int intentType, Intent intent, int callerUid, String resolvedType) {
    // The component shouldn't be null, but let's double check just to be safe
    ComponentName cn = intent.getComponent();
    String shortComponent = null;
    if (cn != null) {
        shortComponent = cn.flattenToShortString();
    }
    String callerPackages = null;
    int callerPackageCount = 0;
    IPackageManager pm = AppGlobals.getPackageManager();
    if (pm != null) {
        try {
            String[] callerPackagesArray = pm.getPackagesForUid(callerUid);
            if (callerPackagesArray != null) {
                callerPackageCount = callerPackagesArray.length;
                callerPackages = joinPackages(callerPackagesArray);
            }
        } catch (RemoteException ex) {
            Slog.e(TAG, "Remote exception while retrieving packages", ex);
        }
    }
    EventLogTags.writeIfwIntentMatched(intentType, shortComponent, callerUid, callerPackageCount, callerPackages, intent.getAction(), resolvedType, intent.getDataString(), intent.getFlags());
}
Also used : IPackageManager(android.content.pm.IPackageManager) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException)

Example 94 with IPackageManager

use of android.content.pm.IPackageManager in project android_frameworks_base by crdroidandroid.

the class CardEmulation method getInstance.

/**
     * Helper to get an instance of this class.
     *
     * @param adapter A reference to an NfcAdapter object.
     * @return
     */
public static synchronized CardEmulation getInstance(NfcAdapter adapter) {
    if (adapter == null)
        throw new NullPointerException("NfcAdapter is null");
    Context context = adapter.getContext();
    if (context == null) {
        Log.e(TAG, "NfcAdapter context is null.");
        throw new UnsupportedOperationException();
    }
    if (!sIsInitialized) {
        IPackageManager pm = ActivityThread.getPackageManager();
        if (pm == null) {
            Log.e(TAG, "Cannot get PackageManager");
            throw new UnsupportedOperationException();
        }
        try {
            if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION, 0)) {
                Log.e(TAG, "This device does not support card emulation");
                throw new UnsupportedOperationException();
            }
        } catch (RemoteException e) {
            Log.e(TAG, "PackageManager query failed.");
            throw new UnsupportedOperationException();
        }
        sIsInitialized = true;
    }
    CardEmulation manager = sCardEmus.get(context);
    if (manager == null) {
        // Get card emu service
        INfcCardEmulation service = adapter.getCardEmulationService();
        if (service == null) {
            Log.e(TAG, "This device does not implement the INfcCardEmulation interface.");
            throw new UnsupportedOperationException();
        }
        manager = new CardEmulation(context, service);
        sCardEmus.put(context, manager);
    }
    return manager;
}
Also used : Context(android.content.Context) INfcCardEmulation(android.nfc.INfcCardEmulation) IPackageManager(android.content.pm.IPackageManager) RemoteException(android.os.RemoteException) INfcCardEmulation(android.nfc.INfcCardEmulation)

Example 95 with IPackageManager

use of android.content.pm.IPackageManager in project android_frameworks_base by crdroidandroid.

the class RetailDemoModeService method isDemoLauncherDisabled.

boolean isDemoLauncherDisabled() {
    int enabledState = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
    try {
        final IPackageManager iPm = AppGlobals.getPackageManager();
        final String demoLauncherComponent = getContext().getString(R.string.config_demoModeLauncherComponent);
        enabledState = iPm.getComponentEnabledSetting(ComponentName.unflattenFromString(demoLauncherComponent), mCurrentUserId);
    } catch (RemoteException re) {
        Slog.e(TAG, "Error retrieving demo launcher enabled setting", re);
    }
    return enabledState == PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
}
Also used : IPackageManager(android.content.pm.IPackageManager) RemoteException(android.os.RemoteException)

Aggregations

IPackageManager (android.content.pm.IPackageManager)192 RemoteException (android.os.RemoteException)182 ApplicationInfo (android.content.pm.ApplicationInfo)58 Point (android.graphics.Point)33 PackageInfo (android.content.pm.PackageInfo)32 ComponentName (android.content.ComponentName)29 Intent (android.content.Intent)26 ArrayList (java.util.ArrayList)20 PackageManager (android.content.pm.PackageManager)18 UserHandle (android.os.UserHandle)13 Context (android.content.Context)12 HashMap (java.util.HashMap)12 ProviderInfo (android.content.pm.ProviderInfo)10 PendingIntent (android.app.PendingIntent)9 HashSet (java.util.HashSet)9 UserManager (android.os.UserManager)8 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)7 ResolveInfo (android.content.pm.ResolveInfo)7 ActivityManager (android.app.ActivityManager)6 SpannableString (android.text.SpannableString)6