Search in sources :

Example 21 with ParceledListSlice

use of android.content.pm.ParceledListSlice in project platform_packages_apps_Settings by BlissRoms.

the class ZenAccessSettings method getPackagesRequestingNotificationPolicyAccess.

private ArraySet<String> getPackagesRequestingNotificationPolicyAccess() {
    ArraySet<String> requestingPackages = new ArraySet<>();
    try {
        final String[] PERM = { android.Manifest.permission.ACCESS_NOTIFICATION_POLICY };
        final ParceledListSlice list = AppGlobals.getPackageManager().getPackagesHoldingPermissions(PERM, 0, /*flags*/
        ActivityManager.getCurrentUser());
        final List<PackageInfo> pkgs = list.getList();
        if (pkgs != null) {
            for (PackageInfo info : pkgs) {
                requestingPackages.add(info.packageName);
            }
        }
    } catch (RemoteException e) {
        Log.e(TAG, "Cannot reach packagemanager", e);
    }
    return requestingPackages;
}
Also used : ArraySet(android.util.ArraySet) PackageInfo(android.content.pm.PackageInfo) RemoteException(android.os.RemoteException) ParceledListSlice(android.content.pm.ParceledListSlice)

Example 22 with ParceledListSlice

use of android.content.pm.ParceledListSlice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NotificationChannelSliceTest method buildNotificationChannelGroups.

private ParceledListSlice<NotificationChannelGroup> buildNotificationChannelGroups(List<NotificationChannel> channels) {
    final NotificationChannelGroup notificationChannelGroup = new NotificationChannelGroup("group", "group");
    notificationChannelGroup.setBlocked(false);
    notificationChannelGroup.setChannels(channels);
    return new ParceledListSlice(Arrays.asList(notificationChannelGroup));
}
Also used : NotificationChannelGroup(android.app.NotificationChannelGroup) ParceledListSlice(android.content.pm.ParceledListSlice)

Example 23 with ParceledListSlice

use of android.content.pm.ParceledListSlice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenAccessController method getPackagesRequestingNotificationPolicyAccess.

public static Set<String> getPackagesRequestingNotificationPolicyAccess() {
    final ArraySet<String> requestingPackages = new ArraySet<>();
    try {
        final String[] PERM = { android.Manifest.permission.ACCESS_NOTIFICATION_POLICY };
        final ParceledListSlice list = AppGlobals.getPackageManager().getPackagesHoldingPermissions(PERM, 0, /*flags*/
        ActivityManager.getCurrentUser());
        final List<PackageInfo> pkgs = list.getList();
        if (pkgs != null) {
            for (PackageInfo info : pkgs) {
                requestingPackages.add(info.packageName);
            }
        }
    } catch (RemoteException e) {
        Log.e(TAG, "Cannot reach packagemanager", e);
    }
    return requestingPackages;
}
Also used : ArraySet(android.util.ArraySet) PackageInfo(android.content.pm.PackageInfo) RemoteException(android.os.RemoteException) ParceledListSlice(android.content.pm.ParceledListSlice)

Example 24 with ParceledListSlice

use of android.content.pm.ParceledListSlice in project platform_frameworks_base by android.

the class ActivityManagerService method getPersistedUriPermissions.

@Override
public ParceledListSlice<android.content.UriPermission> getPersistedUriPermissions(String packageName, boolean incoming) {
    enforceNotIsolatedCaller("getPersistedUriPermissions");
    Preconditions.checkNotNull(packageName, "packageName");
    final int callingUid = Binder.getCallingUid();
    final int callingUserId = UserHandle.getUserId(callingUid);
    final IPackageManager pm = AppGlobals.getPackageManager();
    try {
        final int packageUid = pm.getPackageUid(packageName, MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE, callingUserId);
        if (packageUid != callingUid) {
            throw new SecurityException("Package " + packageName + " does not belong to calling UID " + callingUid);
        }
    } catch (RemoteException e) {
        throw new SecurityException("Failed to verify package name ownership");
    }
    final ArrayList<android.content.UriPermission> result = Lists.newArrayList();
    synchronized (this) {
        if (incoming) {
            final ArrayMap<GrantUri, UriPermission> perms = mGrantedUriPermissions.get(callingUid);
            if (perms == null) {
                Slog.w(TAG, "No permission grants found for " + packageName);
            } else {
                for (UriPermission perm : perms.values()) {
                    if (packageName.equals(perm.targetPkg) && perm.persistedModeFlags != 0) {
                        result.add(perm.buildPersistedPublicApiObject());
                    }
                }
            }
        } else {
            final int size = mGrantedUriPermissions.size();
            for (int i = 0; i < size; i++) {
                final ArrayMap<GrantUri, UriPermission> perms = mGrantedUriPermissions.valueAt(i);
                for (UriPermission perm : perms.values()) {
                    if (packageName.equals(perm.sourcePkg) && perm.persistedModeFlags != 0) {
                        result.add(perm.buildPersistedPublicApiObject());
                    }
                }
            }
        }
    }
    return new ParceledListSlice<android.content.UriPermission>(result);
}
Also used : IPackageManager(android.content.pm.IPackageManager) RemoteException(android.os.RemoteException) Point(android.graphics.Point) ParceledListSlice(android.content.pm.ParceledListSlice)

Example 25 with ParceledListSlice

use of android.content.pm.ParceledListSlice in project platform_frameworks_base by android.

the class ActivityManagerService method getRecentTasks.

@Override
public ParceledListSlice<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags, int userId) {
    final int callingUid = Binder.getCallingUid();
    userId = mUserController.handleIncomingUser(Binder.getCallingPid(), callingUid, userId, false, ALLOW_FULL_ONLY, "getRecentTasks", null);
    final boolean includeProfiles = (flags & ActivityManager.RECENT_INCLUDE_PROFILES) != 0;
    final boolean withExcluded = (flags & ActivityManager.RECENT_WITH_EXCLUDED) != 0;
    synchronized (this) {
        final boolean allowed = isGetTasksAllowed("getRecentTasks", Binder.getCallingPid(), callingUid);
        final boolean detailed = checkCallingPermission(android.Manifest.permission.GET_DETAILED_TASKS) == PackageManager.PERMISSION_GRANTED;
        if (!isUserRunning(userId, ActivityManager.FLAG_AND_UNLOCKED)) {
            Slog.i(TAG, "user " + userId + " is still locked. Cannot load recents");
            return ParceledListSlice.emptyList();
        }
        mRecentTasks.loadUserRecentsLocked(userId);
        final int recentsCount = mRecentTasks.size();
        ArrayList<ActivityManager.RecentTaskInfo> res = new ArrayList<>(maxNum < recentsCount ? maxNum : recentsCount);
        final Set<Integer> includedUsers;
        if (includeProfiles) {
            includedUsers = mUserController.getProfileIds(userId);
        } else {
            includedUsers = new HashSet<>();
        }
        includedUsers.add(Integer.valueOf(userId));
        for (int i = 0; i < recentsCount && maxNum > 0; i++) {
            TaskRecord tr = mRecentTasks.get(i);
            // Only add calling user or related users recent tasks
            if (!includedUsers.contains(Integer.valueOf(tr.userId))) {
                if (DEBUG_RECENTS)
                    Slog.d(TAG_RECENTS, "Skipping, not user: " + tr);
                continue;
            }
            if (tr.realActivitySuspended) {
                if (DEBUG_RECENTS)
                    Slog.d(TAG_RECENTS, "Skipping, activity suspended: " + tr);
                continue;
            }
            if (i == 0 || withExcluded || (tr.intent == null) || ((tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) {
                if (!allowed) {
                    // allow them to see a small subset of tasks -- their own and home.
                    if (!tr.isHomeTask() && tr.effectiveUid != callingUid) {
                        if (DEBUG_RECENTS)
                            Slog.d(TAG_RECENTS, "Skipping, not allowed: " + tr);
                        continue;
                    }
                }
                if ((flags & ActivityManager.RECENT_IGNORE_HOME_STACK_TASKS) != 0) {
                    if (tr.stack != null && tr.stack.isHomeStack()) {
                        if (DEBUG_RECENTS)
                            Slog.d(TAG_RECENTS, "Skipping, home stack task: " + tr);
                        continue;
                    }
                }
                if ((flags & ActivityManager.RECENT_INGORE_DOCKED_STACK_TOP_TASK) != 0) {
                    final ActivityStack stack = tr.stack;
                    if (stack != null && stack.isDockedStack() && stack.topTask() == tr) {
                        if (DEBUG_RECENTS)
                            Slog.d(TAG_RECENTS, "Skipping, top task in docked stack: " + tr);
                        continue;
                    }
                }
                if ((flags & ActivityManager.RECENT_INGORE_PINNED_STACK_TASKS) != 0) {
                    if (tr.stack != null && tr.stack.isPinnedStack()) {
                        if (DEBUG_RECENTS)
                            Slog.d(TAG_RECENTS, "Skipping, pinned stack task: " + tr);
                        continue;
                    }
                }
                if (tr.autoRemoveRecents && tr.getTopActivity() == null) {
                    // Don't include auto remove tasks that are finished or finishing.
                    if (DEBUG_RECENTS)
                        Slog.d(TAG_RECENTS, "Skipping, auto-remove without activity: " + tr);
                    continue;
                }
                if ((flags & ActivityManager.RECENT_IGNORE_UNAVAILABLE) != 0 && !tr.isAvailable) {
                    if (DEBUG_RECENTS)
                        Slog.d(TAG_RECENTS, "Skipping, unavail real act: " + tr);
                    continue;
                }
                if (!tr.mUserSetupComplete) {
                    // Don't include task launched while user is not done setting-up.
                    if (DEBUG_RECENTS)
                        Slog.d(TAG_RECENTS, "Skipping, user setup not complete: " + tr);
                    continue;
                }
                ActivityManager.RecentTaskInfo rti = createRecentTaskInfoFromTaskRecord(tr);
                if (!detailed) {
                    rti.baseIntent.replaceExtras((Bundle) null);
                }
                res.add(rti);
                maxNum--;
            }
        }
        return new ParceledListSlice<>(res);
    }
}
Also used : ArrayList(java.util.ArrayList) ActivityManager(android.app.ActivityManager) Point(android.graphics.Point) ParceledListSlice(android.content.pm.ParceledListSlice)

Aggregations

ParceledListSlice (android.content.pm.ParceledListSlice)43 ArrayList (java.util.ArrayList)24 Point (android.graphics.Point)16 IPackageInstallerSession (android.content.pm.IPackageInstallerSession)10 PackageInfo (android.content.pm.PackageInfo)10 SessionInfo (android.content.pm.PackageInstaller.SessionInfo)10 RemoteException (android.os.RemoteException)9 PackageParser (android.content.pm.PackageParser)7 ArraySet (android.util.ArraySet)7 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)5 PendingHostUpdate (android.appwidget.PendingHostUpdate)5 LongSparseArray (android.util.LongSparseArray)5 IAppWidgetHost (com.android.internal.appwidget.IAppWidgetHost)5 WidgetBackupProvider (com.android.server.WidgetBackupProvider)5 NonNull (android.annotation.NonNull)4 ActivityManager (android.app.ActivityManager)2 ApplicationInfo (android.content.pm.ApplicationInfo)2 EphemeralApplicationInfo (android.content.pm.EphemeralApplicationInfo)2 FeatureInfo (android.content.pm.FeatureInfo)2 IPackageManager (android.content.pm.IPackageManager)2