Search in sources :

Example 96 with IPackageManager

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

the class RecentTasks method cleanupProtectedComponentTasksLocked.

/**
     * Clear out protected tasks from the list
     */
void cleanupProtectedComponentTasksLocked(int userId) {
    int recentsCount = size();
    if (recentsCount == 0) {
        // or just any empty list.
        return;
    }
    final IPackageManager pm = AppGlobals.getPackageManager();
    for (int i = recentsCount - 1; i >= 0; i--) {
        final TaskRecord task = get(i);
        if (userId != UserHandle.USER_ALL && task.userId != userId) {
            // Only look at tasks for the user ID of interest.
            continue;
        }
        try {
            if (task.realActivity != null && pm.isComponentProtected(null, -1, task.realActivity, userId)) {
                remove(i);
                task.removedFromRecents();
            }
        } catch (RemoteException e) {
        }
    }
}
Also used : IPackageManager(android.content.pm.IPackageManager) RemoteException(android.os.RemoteException)

Example 97 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)

Example 98 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 99 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 100 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)

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