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;
}
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));
}
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;
}
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);
}
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);
}
}
Aggregations