Java Code Examples for android.util.ArraySet#size()
The following examples show how to use
android.util.ArraySet#size() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ManagedServices.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private @NonNull ArraySet<ComponentName> loadComponentNamesFromValues( ArraySet<String> approved, int userId) { if (approved == null || approved.size() == 0) return new ArraySet<>(); ArraySet<ComponentName> result = new ArraySet<>(approved.size()); for (int i = 0; i < approved.size(); i++) { final String packageOrComponent = approved.valueAt(i); if (!TextUtils.isEmpty(packageOrComponent)) { ComponentName component = ComponentName.unflattenFromString(packageOrComponent); if (component != null) { result.add(component); } else { result.addAll(queryPackageForServices(packageOrComponent, userId)); } } } return result; }
Example 2
Source File: WindowSurfacePlacer.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private AppWindowToken lookForHighestTokenWithFilter(ArraySet<AppWindowToken> array1, ArraySet<AppWindowToken> array2, Predicate<AppWindowToken> filter) { final int array1count = array1.size(); final int count = array1count + array2.size(); int bestPrefixOrderIndex = Integer.MIN_VALUE; AppWindowToken bestToken = null; for (int i = 0; i < count; i++) { final AppWindowToken wtoken = i < array1count ? array1.valueAt(i) : array2.valueAt(i - array1count); final int prefixOrderIndex = wtoken.getPrefixOrderIndex(); if (filter.test(wtoken) && prefixOrderIndex > bestPrefixOrderIndex) { bestPrefixOrderIndex = prefixOrderIndex; bestToken = wtoken; } } return bestToken; }
Example 3
Source File: KeySetManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void decrementKeySetLPw(long id) { KeySetHandle ks = mKeySets.get(id); if (ks == null) { /* nothing to do */ return; } if (ks.decrRefCountLPw() <= 0) { ArraySet<Long> pubKeys = mKeySetMapping.get(id); final int pkSize = pubKeys.size(); for (int i = 0; i < pkSize; i++) { decrementPublicKeyLPw(pubKeys.valueAt(i)); } mKeySets.delete(id); mKeySetMapping.delete(id); } }
Example 4
Source File: ManagedServices.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
protected List<String> getAllowedPackages(int userId) { final List<String> allowedPackages = new ArrayList<>(); final ArrayMap<Boolean, ArraySet<String>> allowedByType = mApproved.getOrDefault(userId, new ArrayMap<>()); for (int i = 0; i < allowedByType.size(); i++) { final ArraySet<String> allowed = allowedByType.valueAt(i); for (int j = 0; j < allowed.size(); j++) { String pkgName = getPackageName(allowed.valueAt(j)); if (!TextUtils.isEmpty(pkgName)) { allowedPackages.add(pkgName); } } } return allowedPackages; }
Example 5
Source File: AppOpsService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void commitUidPendingStateLocked(UidState uidState) { final boolean lastForeground = uidState.state <= UID_STATE_LAST_NON_RESTRICTED; final boolean nowForeground = uidState.pendingState <= UID_STATE_LAST_NON_RESTRICTED; uidState.state = uidState.pendingState; uidState.pendingStateCommitTime = 0; if (uidState.hasForegroundWatchers && lastForeground != nowForeground) { for (int fgi = uidState.foregroundOps.size() - 1; fgi >= 0; fgi--) { if (!uidState.foregroundOps.valueAt(fgi)) { continue; } final int code = uidState.foregroundOps.keyAt(fgi); final ArraySet<ModeCallback> callbacks = mOpModeWatchers.get(code); if (callbacks != null) { for (int cbi = callbacks.size() - 1; cbi >= 0; cbi--) { final ModeCallback callback = callbacks.valueAt(cbi); if ((callback.mFlags & AppOpsManager.WATCH_FOREGROUND_CHANGES) == 0 || !callback.isWatchingUid(uidState.uid)) { continue; } boolean doAllPackages = uidState.opModes != null && uidState.opModes.get(code) == AppOpsManager.MODE_FOREGROUND; if (uidState.pkgOps != null) { for (int pkgi = uidState.pkgOps.size() - 1; pkgi >= 0; pkgi--) { final Op op = uidState.pkgOps.valueAt(pkgi).get(code); if (doAllPackages || (op != null && op.mode == AppOpsManager.MODE_FOREGROUND)) { mHandler.sendMessage(PooledLambda.obtainMessage( AppOpsService::notifyOpChanged, this, callback, code, uidState.uid, uidState.pkgOps.keyAt(pkgi))); } } } } } } } }
Example 6
Source File: ShortcutLauncher.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public void dump(@NonNull PrintWriter pw, @NonNull String prefix, DumpFilter filter) { pw.println(); pw.print(prefix); pw.print("Launcher: "); pw.print(getPackageName()); pw.print(" Package user: "); pw.print(getPackageUserId()); pw.print(" Owner user: "); pw.print(getOwnerUserId()); pw.println(); getPackageInfo().dump(pw, prefix + " "); pw.println(); final int size = mPinnedShortcuts.size(); for (int i = 0; i < size; i++) { pw.println(); final PackageWithUser pu = mPinnedShortcuts.keyAt(i); pw.print(prefix); pw.print(" "); pw.print("Package: "); pw.print(pu.packageName); pw.print(" User: "); pw.println(pu.userId); final ArraySet<String> ids = mPinnedShortcuts.valueAt(i); final int idSize = ids.size(); for (int j = 0; j < idSize; j++) { pw.print(prefix); pw.print(" Pinned: "); pw.print(ids.valueAt(j)); pw.println(); } } }
Example 7
Source File: PolicyControl.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void dump(String name, ArraySet<String> set, PrintWriter pw) { pw.print(name); pw.print("=("); final int n = set.size(); for (int i = 0; i < n; i++) { if (i > 0) pw.print(','); pw.print(set.valueAt(i)); } pw.print(')'); }
Example 8
Source File: JobStore.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public void forEachJob(int callingUid, Consumer<JobStatus> functor) { ArraySet<JobStatus> jobs = mJobs.get(callingUid); if (jobs != null) { for (int i = jobs.size() - 1; i >= 0; i--) { functor.accept(jobs.valueAt(i)); } } }
Example 9
Source File: FragmentManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Any fragments that were removed because they have been postponed should have their views * made invisible by setting their transition alpha to 0. * * @param fragments The fragments that were added during operation execution. Only the ones * that are no longer added will have their transition alpha changed. */ private void makeRemovedFragmentsInvisible(ArraySet<Fragment> fragments) { final int numAdded = fragments.size(); for (int i = 0; i < numAdded; i++) { final Fragment fragment = fragments.valueAt(i); if (!fragment.mAdded) { final View view = fragment.getView(); view.setTransitionAlpha(0f); } } }
Example 10
Source File: JobStore.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public List<JobStatus> getAllJobs() { ArrayList<JobStatus> allJobs = new ArrayList<JobStatus>(size()); for (int i = mJobs.size() - 1; i >= 0; i--) { ArraySet<JobStatus> jobs = mJobs.valueAt(i); if (jobs != null) { // Use a for loop over the ArraySet, so we don't need to make its // optional collection class iterator implementation or have to go // through a temporary array from toArray(). for (int j = jobs.size() - 1; j >= 0; j--) { allJobs.add(jobs.valueAt(j)); } } } return allJobs; }
Example 11
Source File: AppOpsService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void notifyOpChanged(ArraySet<ModeCallback> callbacks, int code, int uid, String packageName) { for (int i = 0; i < callbacks.size(); i++) { final ModeCallback callback = callbacks.valueAt(i); notifyOpChanged(callback, code, uid, packageName); } }
Example 12
Source File: AppOpsService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private static HashMap<ModeCallback, ArrayList<ChangeRec>> addCallbacks( HashMap<ModeCallback, ArrayList<ChangeRec>> callbacks, int op, int uid, String packageName, ArraySet<ModeCallback> cbs) { if (cbs == null) { return callbacks; } if (callbacks == null) { callbacks = new HashMap<>(); } boolean duplicate = false; final int N = cbs.size(); for (int i=0; i<N; i++) { ModeCallback cb = cbs.valueAt(i); ArrayList<ChangeRec> reports = callbacks.get(cb); if (reports == null) { reports = new ArrayList<>(); callbacks.put(cb, reports); } else { final int reportCount = reports.size(); for (int j = 0; j < reportCount; j++) { ChangeRec report = reports.get(j); if (report.op == op && report.pkg.equals(packageName)) { duplicate = true; break; } } } if (!duplicate) { reports.add(new ChangeRec(op, uid, packageName)); } } return callbacks; }
Example 13
Source File: WindowSurfacePlacer.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private boolean canBeWallpaperTarget(ArraySet<AppWindowToken> apps) { for (int i = apps.size() - 1; i >= 0; i--) { if (apps.valueAt(i).windowsCanBeWallpaperTarget()) { return true; } } return false; }
Example 14
Source File: WindowSurfacePlacer.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private boolean containsVoiceInteraction(ArraySet<AppWindowToken> apps) { for (int i = apps.size() - 1; i >= 0; i--) { if (apps.valueAt(i).mVoiceInteraction) { return true; } } return false; }
Example 15
Source File: WindowSurfacePlacer.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * @return The set of {@link WindowConfiguration.ActivityType}s contained in the set of apps in * {@code array1} and {@code array2}. */ private ArraySet<Integer> collectActivityTypes(ArraySet<AppWindowToken> array1, ArraySet<AppWindowToken> array2) { final ArraySet<Integer> result = new ArraySet<>(); for (int i = array1.size() - 1; i >= 0; i--) { result.add(array1.valueAt(i).getActivityType()); } for (int i = array2.size() - 1; i >= 0; i--) { result.add(array2.valueAt(i).getActivityType()); } return result; }
Example 16
Source File: TaskSnapshotController.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Retrieves all closing tasks based on the list of closing apps during an app transition. */ @VisibleForTesting void getClosingTasks(ArraySet<AppWindowToken> closingApps, ArraySet<Task> outClosingTasks) { outClosingTasks.clear(); for (int i = closingApps.size() - 1; i >= 0; i--) { final AppWindowToken atoken = closingApps.valueAt(i); final Task task = atoken.getTask(); // If the task of the app is not visible anymore, it means no other app in that task // is opening. Thus, the task is closing. if (task != null && !task.isVisible() && !mSkipClosingAppSnapshotTasks.contains(task)) { outClosingTasks.add(task); } } }
Example 17
Source File: Parcel.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Write an array set to the parcel. * * @param val The array set to write. * * @hide */ public void writeArraySet(@Nullable ArraySet<? extends Object> val) { final int size = (val != null) ? val.size() : -1; writeInt(size); for (int i = 0; i < size; i++) { writeValue(val.valueAt(i)); } }
Example 18
Source File: PendingIntent.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void notifyCancelListeners() { ArraySet<CancelListener> cancelListeners; synchronized (this) { cancelListeners = new ArraySet<>(mCancelListeners); } int size = cancelListeners.size(); for (int i = 0; i < size; i++) { cancelListeners.valueAt(i).onCancelled(this); } }
Example 19
Source File: VrManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public void onBootPhase(int phase) { if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) { LocalServices.getService(ActivityManagerInternal.class) .registerScreenObserver(this); mNotificationManager = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); synchronized (mLock) { Looper looper = Looper.getMainLooper(); Handler handler = new Handler(looper); ArrayList<EnabledComponentChangeListener> listeners = new ArrayList<>(); listeners.add(this); mComponentObserver = EnabledComponentsObserver.build(mContext, handler, Settings.Secure.ENABLED_VR_LISTENERS, looper, android.Manifest.permission.BIND_VR_LISTENER_SERVICE, VrListenerService.SERVICE_INTERFACE, mLock, listeners); mComponentObserver.rebuildAll(); } //TODO: something more robust than picking the first one ArraySet<ComponentName> defaultVrComponents = SystemConfig.getInstance().getDefaultVrComponents(); if (defaultVrComponents.size() > 0) { mDefaultVrService = defaultVrComponents.valueAt(0); } else { Slog.i(TAG, "No default vr listener service found."); } DisplayManager dm = (DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE); mVr2dDisplay = new Vr2dDisplay( dm, LocalServices.getService(ActivityManagerInternal.class), LocalServices.getService(WindowManagerInternal.class), mVrManager); mVr2dDisplay.init(getContext(), mBootsToVr); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_USER_UNLOCKED); getContext().registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_USER_UNLOCKED.equals(intent.getAction())) { VrManagerService.this.setUserUnlocked(); } } }, intentFilter); } }
Example 20
Source File: ZenModeConfig.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private Diff diff(ZenModeConfig to) { final Diff d = new Diff(); if (to == null) { return d.addLine("config", "delete"); } if (user != to.user) { d.addLine("user", user, to.user); } if (allowAlarms != to.allowAlarms) { d.addLine("allowAlarms", allowAlarms, to.allowAlarms); } if (allowMedia != to.allowMedia) { d.addLine("allowMedia", allowMedia, to.allowMedia); } if (allowSystem != to.allowSystem) { d.addLine("allowSystem", allowSystem, to.allowSystem); } if (allowCalls != to.allowCalls) { d.addLine("allowCalls", allowCalls, to.allowCalls); } if (allowReminders != to.allowReminders) { d.addLine("allowReminders", allowReminders, to.allowReminders); } if (allowEvents != to.allowEvents) { d.addLine("allowEvents", allowEvents, to.allowEvents); } if (allowRepeatCallers != to.allowRepeatCallers) { d.addLine("allowRepeatCallers", allowRepeatCallers, to.allowRepeatCallers); } if (allowMessages != to.allowMessages) { d.addLine("allowMessages", allowMessages, to.allowMessages); } if (allowCallsFrom != to.allowCallsFrom) { d.addLine("allowCallsFrom", allowCallsFrom, to.allowCallsFrom); } if (allowMessagesFrom != to.allowMessagesFrom) { d.addLine("allowMessagesFrom", allowMessagesFrom, to.allowMessagesFrom); } if (suppressedVisualEffects != to.suppressedVisualEffects) { d.addLine("suppressedVisualEffects", suppressedVisualEffects, to.suppressedVisualEffects); } final ArraySet<String> allRules = new ArraySet<>(); addKeys(allRules, automaticRules); addKeys(allRules, to.automaticRules); final int N = allRules.size(); for (int i = 0; i < N; i++) { final String rule = allRules.valueAt(i); final ZenRule fromRule = automaticRules != null ? automaticRules.get(rule) : null; final ZenRule toRule = to.automaticRules != null ? to.automaticRules.get(rule) : null; ZenRule.appendDiff(d, "automaticRule[" + rule + "]", fromRule, toRule); } ZenRule.appendDiff(d, "manualRule", manualRule, to.manualRule); if (areChannelsBypassingDnd != to.areChannelsBypassingDnd) { d.addLine("areChannelsBypassingDnd", areChannelsBypassingDnd, to.areChannelsBypassingDnd); } return d; }