android.util.ArraySet Java Examples

The following examples show how to use android.util.ArraySet. 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: KeySetManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Determine if a package is signed by the given KeySet.
 *
 * Returns false if the package was not signed by all the
 * keys in the KeySet.
 *
 * Returns true if the package was signed by at least the
 * keys in the given KeySet.
 *
 * Note that this can return true for multiple KeySets.
 */
public boolean packageIsSignedByLPr(String packageName, KeySetHandle ks) {
    PackageSetting pkg = mPackages.get(packageName);
    if (pkg == null) {
        throw new NullPointerException("Invalid package name");
    }
    if (pkg.keySetData == null) {
        throw new NullPointerException("Package has no KeySet data");
    }
    long id = getIdByKeySetLPr(ks);
    if (id == KEYSET_NOT_FOUND) {
            return false;
    }
    ArraySet<Long> pkgKeys = mKeySetMapping.get(pkg.keySetData.getProperSigningKeySet());
    ArraySet<Long> testKeys = mKeySetMapping.get(id);
    return pkgKeys.containsAll(testKeys);
}
 
Example #2
Source File: AppOpsService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void scheduleOpActiveChangedIfNeededLocked(int code, int uid, String packageName,
        boolean active) {
    ArraySet<ActiveCallback> dispatchedCallbacks = null;
    final int callbackListCount = mActiveWatchers.size();
    for (int i = 0; i < callbackListCount; i++) {
        final SparseArray<ActiveCallback> callbacks = mActiveWatchers.valueAt(i);
        ActiveCallback callback = callbacks.get(code);
        if (callback != null) {
            if (callback.mWatchingUid >= 0 && callback.mWatchingUid != uid) {
                continue;
            }
            if (dispatchedCallbacks == null) {
                dispatchedCallbacks = new ArraySet<>();
            }
            dispatchedCallbacks.add(callback);
        }
    }
    if (dispatchedCallbacks == null) {
        return;
    }
    mHandler.sendMessage(PooledLambda.obtainMessage(
            AppOpsService::notifyOpActiveChanged,
            this, dispatchedCallbacks, code, uid, packageName, active));
}
 
Example #3
Source File: BackgroundDexOptService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private boolean runIdleOptimization(final JobParameters jobParams,
        final PackageManagerService pm, final ArraySet<String> pkgs) {
    new Thread("BackgroundDexOptService_IdleOptimization") {
        @Override
        public void run() {
            int result = idleOptimization(pm, pkgs, BackgroundDexOptService.this);
            if (result != OPTIMIZE_ABORT_BY_JOB_SCHEDULER) {
                Log.w(TAG, "Idle optimizations aborted because of space constraints.");
                // If we didn't abort we ran to completion (or stopped because of space).
                // Abandon our timeslice and do not reschedule.
                jobFinished(jobParams, /* reschedule */ false);
            }
        }
    }.start();
    return true;
}
 
Example #4
Source File: ActiveServices.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void updateServiceConnectionActivitiesLocked(ProcessRecord clientProc) {
    ArraySet<ProcessRecord> updatedProcesses = null;
    for (int i = 0; i < clientProc.connections.size(); i++) {
        final ConnectionRecord conn = clientProc.connections.valueAt(i);
        final ProcessRecord proc = conn.binding.service.app;
        if (proc == null || proc == clientProc) {
            continue;
        } else if (updatedProcesses == null) {
            updatedProcesses = new ArraySet<>();
        } else if (updatedProcesses.contains(proc)) {
            continue;
        }
        updatedProcesses.add(proc);
        updateServiceClientActivitiesLocked(proc, null, false);
    }
}
 
Example #5
Source File: EnabledComponentsObserver.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Rebuild the sets of allowed components for each current user profile.
 */
public void rebuildAll() {
    synchronized (mLock) {
        mInstalledSet.clear();
        mEnabledSet.clear();
        final int[] userIds = getCurrentProfileIds();
        for (int i : userIds) {
            ArraySet<ComponentName> implementingPackages = loadComponentNamesForUser(i);
            ArraySet<ComponentName> packagesFromSettings =
                    loadComponentNamesFromSetting(mSettingName, i);
            packagesFromSettings.retainAll(implementingPackages);

            mInstalledSet.put(i, implementingPackages);
            mEnabledSet.put(i, packagesFromSettings);

        }
    }
    sendSettingChanged();
}
 
Example #6
Source File: WallpaperController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Adjusts the wallpaper windows if the input display has a pending wallpaper layout or one of
 * the opening apps should be a wallpaper target.
 */
void adjustWallpaperWindowsForAppTransitionIfNeeded(DisplayContent dc,
        ArraySet<AppWindowToken> openingApps) {
    boolean adjust = false;
    if ((dc.pendingLayoutChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0) {
        adjust = true;
    } else {
        for (int i = openingApps.size() - 1; i >= 0; --i) {
            final AppWindowToken token = openingApps.valueAt(i);
            if (token.windowsCanBeWallpaperTarget()) {
                adjust = true;
                break;
            }
        }
    }

    if (adjust) {
        adjustWallpaperWindows(dc);
    }
}
 
Example #7
Source File: BackupAgent.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Check whether the xml yielded any <include/> tag for the provided <code>domainToken</code>.
 * If so, perform a {@link #fullBackupFileTree} which backs up the file or recurses if the path
 * is a directory, but only if all the required flags of the include rule are satisfied by
 * the transport.
 */
private void applyXmlFiltersAndDoFullBackupForDomain(String packageName, String domainToken,
        Map<String, Set<PathWithRequiredFlags>> includeMap,
        ArraySet<PathWithRequiredFlags> filterSet, ArraySet<String> traversalExcludeSet,
        FullBackupDataOutput data) throws IOException {
    if (includeMap == null || includeMap.size() == 0) {
        // Do entire sub-tree for the provided token.
        fullBackupFileTree(packageName, domainToken,
                FullBackup.getBackupScheme(this).tokenToDirectoryPath(domainToken),
                filterSet, traversalExcludeSet, data);
    } else if (includeMap.get(domainToken) != null) {
        // This will be null if the xml parsing didn't yield any rules for
        // this domain (there may still be rules for other domains).
        for (PathWithRequiredFlags includeFile : includeMap.get(domainToken)) {
            if (areIncludeRequiredTransportFlagsSatisfied(includeFile.getRequiredFlags(),
                    data.getTransportFlags())) {
                fullBackupFileTree(packageName, domainToken, includeFile.getPath(), filterSet,
                        traversalExcludeSet, data);
            }
        }
    }
}
 
Example #8
Source File: CalculationModule.java    From GNSS_Compare with Apache License 2.0 6 votes vote down vote up
/**
 * @param arrayList list generated by getConstructorArrayList
 * @return new calculation module based on the arrayList parameter
 * @throws NameAlreadyRegisteredException when the name is already registered
 * @throws NumberOfSeriesExceededLimitException when the number of created modules is exceeded
 */
public static CalculationModule fromConstructorArrayList(ArrayList<String> arrayList) throws NameAlreadyRegisteredException, NumberOfSeriesExceededLimitException {
    String name = arrayList.get(0);
    boolean valueOfActive = Boolean.parseBoolean(arrayList.get(1));
    boolean valueOfLogToFile = Boolean.parseBoolean(arrayList.get(2));
    String constellationClassName = arrayList.get(3);
    String pvtMethodClassName = arrayList.get(4);
    String fileLoggerClassName = arrayList.get(5);
    Set<String> correctionClassNames = new ArraySet<>();

    for(int i=6; i<arrayList.size(); i++)
        correctionClassNames.add(arrayList.get(i));

    CalculationModule createdModule = new CalculationModule(
            name,
            getConstellationClassFromName(constellationClassName),
            getCorrectionClassesFromNames(correctionClassNames),
            getPvtMethodClassFromName(pvtMethodClassName),
            getFileLoggerClassFromName(fileLoggerClassName));

    createdModule.active = valueOfActive;
    createdModule.logToFile = valueOfLogToFile;

    return createdModule;
}
 
Example #9
Source File: TaskSnapshotPersister.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
void write() {
    final ArraySet<Integer> newPersistedTaskIds;
    synchronized (mLock) {
        newPersistedTaskIds = new ArraySet<>(mPersistedTaskIdsSinceLastRemoveObsolete);
    }
    for (int userId : mRunningUserIds) {
        final File dir = getDirectory(userId);
        final String[] files = dir.list();
        if (files == null) {
            continue;
        }
        for (String file : files) {
            final int taskId = getTaskId(file);
            if (!mPersistentTaskIds.contains(taskId)
                    && !newPersistedTaskIds.contains(taskId)) {
                new File(dir, file).delete();
            }
        }
    }
}
 
Example #10
Source File: ShortcutService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Remove dangling bitmap files for a package.
 *
 * Note this method must be called with the lock held after calling
 * {@link ShortcutBitmapSaver#waitForAllSavesLocked()} to make sure there's no pending bitmap
 * saves are going on.
 */
private void cleanupDanglingBitmapFilesLocked(@UserIdInt int userId, @NonNull ShortcutUser user,
        @NonNull String packageName, @NonNull File path) {
    final ArraySet<String> usedFiles =
            user.getPackageShortcuts(packageName).getUsedBitmapFiles();

    for (File child : path.listFiles()) {
        if (!child.isFile()) {
            continue;
        }
        final String name = child.getName();
        if (!usedFiles.contains(name)) {
            if (DEBUG) {
                Slog.d(TAG, "Removing dangling bitmap file: " + child.getAbsolutePath());
            }
            child.delete();
        }
    }
}
 
Example #11
Source File: RecentTasks.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * @return the list of persistable task ids.
 */
void getPersistableTaskIds(ArraySet<Integer> persistentTaskIds) {
    final int size = mTasks.size();
    for (int i = 0; i < size; i++) {
        final TaskRecord task = mTasks.get(i);
        if (TaskPersister.DEBUG) Slog.d(TAG, "LazyTaskWriter: task=" + task
                + " persistable=" + task.isPersistable);
        final ActivityStack stack = task.getStack();
        if ((task.isPersistable || task.inRecents)
                && (stack == null || !stack.isHomeOrRecentsStack())) {
            if (TaskPersister.DEBUG) Slog.d(TAG, "adding to persistentTaskIds task=" + task);
            persistentTaskIds.add(task.taskId);
        } else {
            if (TaskPersister.DEBUG) Slog.d(TAG, "omitting from persistentTaskIds task="
                    + task);
        }
    }
}
 
Example #12
Source File: PendingIntent.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Register a listener to when this pendingIntent is cancelled. There are no guarantees on which
 * thread a listener will be called and it's up to the caller to synchronize. This may
 * trigger a synchronous binder call so should therefore usually be called on a background
 * thread.
 *
 * @hide
 */
public void registerCancelListener(CancelListener cancelListener) {
    synchronized (this) {
        if (mCancelReceiver == null) {
            mCancelReceiver = new IResultReceiver.Stub() {
                @Override
                public void send(int resultCode, Bundle resultData) throws RemoteException {
                    notifyCancelListeners();
                }
            };
        }
        if (mCancelListeners == null) {
            mCancelListeners = new ArraySet<>();
        }
        boolean wasEmpty = mCancelListeners.isEmpty();
        mCancelListeners.add(cancelListener);
        if (wasEmpty) {
            try {
                ActivityManager.getService().registerIntentSenderCancelListener(mTarget,
                        mCancelReceiver);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }
}
 
Example #13
Source File: PackageInstallerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void systemReady() {
    mAppOps = mContext.getSystemService(AppOpsManager.class);

    synchronized (mSessions) {
        readSessionsLocked();

        reconcileStagesLocked(StorageManager.UUID_PRIVATE_INTERNAL, false /*isInstant*/);
        reconcileStagesLocked(StorageManager.UUID_PRIVATE_INTERNAL, true /*isInstant*/);

        final ArraySet<File> unclaimedIcons = newArraySet(
                mSessionsDir.listFiles());

        // Ignore stages and icons claimed by active sessions
        for (int i = 0; i < mSessions.size(); i++) {
            final PackageInstallerSession session = mSessions.valueAt(i);
            unclaimedIcons.remove(buildAppIconFile(session.sessionId));
        }

        // Clean up orphaned icons
        for (File icon : unclaimedIcons) {
            Slog.w(TAG, "Deleting orphan icon " + icon);
            icon.delete();
        }
    }
}
 
Example #14
Source File: KeySetManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Informs the system that the given package was signed by the provided KeySet.
 */
void addSigningKeySetToPackageLPw(PackageSetting pkg,
        ArraySet<PublicKey> signingKeys) {

    /* check existing keyset for reuse or removal */
    long signingKeySetId = pkg.keySetData.getProperSigningKeySet();

    if (signingKeySetId != PackageKeySetData.KEYSET_UNASSIGNED) {
        ArraySet<PublicKey> existingKeys = getPublicKeysFromKeySetLPr(signingKeySetId);
        if (existingKeys != null && existingKeys.equals(signingKeys)) {

            /* no change in signing keys, leave PackageSetting alone */
            return;
        } else {

            /* old keyset no longer valid, remove ref */
            decrementKeySetLPw(signingKeySetId);
        }
    }

    /* create and add a new keyset */
    KeySetHandle ks = addKeySetLPw(signingKeys);
    long id = ks.getId();
    pkg.keySetData.setProperSigningKeySet(id);
    return;
}
 
Example #15
Source File: WindowSurfacePlacer.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * @return The window token that determines the animation theme.
 */
private AppWindowToken findAnimLayoutParamsToken(@TransitionType int transit,
        ArraySet<Integer> activityTypes) {
    AppWindowToken result;

    // Remote animations always win, but fullscreen tokens override non-fullscreen tokens.
    result = lookForHighestTokenWithFilter(mService.mClosingApps, mService.mOpeningApps,
            w -> w.getRemoteAnimationDefinition() != null
                    && w.getRemoteAnimationDefinition().hasTransition(transit, activityTypes));
    if (result != null) {
        return result;
    }
    result = lookForHighestTokenWithFilter(mService.mClosingApps, mService.mOpeningApps,
            w -> w.fillsParent() && w.findMainWindow() != null);
    if (result != null) {
        return result;
    }
    return lookForHighestTokenWithFilter(mService.mClosingApps, mService.mOpeningApps,
            w -> w.findMainWindow() != null);
}
 
Example #16
Source File: PackageInstallerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public static <E> ArraySet<E> newArraySet(E... elements) {
    final ArraySet<E> set = new ArraySet<E>();
    if (elements != null) {
        set.ensureCapacity(elements.length);
        Collections.addAll(set, elements);
    }
    return set;
}
 
Example #17
Source File: PolicyControl.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
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 #18
Source File: CaptureRequest.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void writeToParcel(Parcel dest, int flags) {
    int physicalCameraCount = mPhysicalCameraSettings.size();
    dest.writeInt(physicalCameraCount);
    //Logical camera id and settings always come first.
    dest.writeString(mLogicalCameraId);
    mLogicalCameraSettings.writeToParcel(dest, flags);
    for (Map.Entry<String, CameraMetadataNative> entry : mPhysicalCameraSettings.entrySet()) {
        if (entry.getKey().equals(mLogicalCameraId)) {
            continue;
        }
        dest.writeString(entry.getKey());
        entry.getValue().writeToParcel(dest, flags);
    }

    dest.writeInt(mIsReprocess ? 1 : 0);

    synchronized (mSurfacesLock) {
        final ArraySet<Surface> surfaces = mSurfaceConverted ? mEmptySurfaceSet : mSurfaceSet;
        dest.writeParcelableArray(surfaces.toArray(new Surface[surfaces.size()]), flags);
        if (mSurfaceConverted) {
            dest.writeInt(mStreamIdxArray.length);
            for (int i = 0; i < mStreamIdxArray.length; i++) {
                dest.writeInt(mStreamIdxArray[i]);
                dest.writeInt(mSurfaceIdxArray[i]);
            }
        } else {
            dest.writeInt(0);
        }
    }
}
 
Example #19
Source File: RemoteInput.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private RemoteInput(Parcel in) {
    mResultKey = in.readString();
    mLabel = in.readCharSequence();
    mChoices = in.readCharSequenceArray();
    mFlags = in.readInt();
    mExtras = in.readBundle();
    mAllowedDataTypes = (ArraySet<String>) in.readArraySet(null);
}
 
Example #20
Source File: VrManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a user, package, or setting changes that could affect whether or not the
 * currently bound VrListenerService is changed.
 */
@Override
public void onEnabledComponentChanged() {
    synchronized (mLock) {
        int currentUser = ActivityManager.getCurrentUser();
        // Update listeners
        ArraySet<ComponentName> enabledListeners = mComponentObserver.getEnabled(currentUser);

        ArraySet<String> enabledPackages = new ArraySet<>();
        for (ComponentName n : enabledListeners) {
            String pkg = n.getPackageName();
            if (isDefaultAllowed(pkg)) {
                enabledPackages.add(n.getPackageName());
            }
        }
        mNotifAccessManager.update(enabledPackages);

        if (!mVrModeAllowed) {
            return; // Don't do anything, we shouldn't be in VR mode.
        }

        // If there is a pending state change, we'd better deal with that first
        consumeAndApplyPendingStateLocked(false);

        if (mCurrentVrService == null) {
            return; // No active services
        }

        // There is an active service, update it if needed
        updateCurrentVrServiceLocked(mVrModeEnabled, mRunning2dInVr,
                mCurrentVrService.getComponent(), mCurrentVrService.getUserId(),
                mVrAppProcessId, mCurrentVrModeComponent);
    }
}
 
Example #21
Source File: PermissionManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private String[] getAppOpPermissionPackages(String permName) {
    if (mPackageManagerInt.getInstantAppPackageName(Binder.getCallingUid()) != null) {
        return null;
    }
    synchronized (mLock) {
        final ArraySet<String> pkgs = mSettings.mAppOpPermissionPackages.get(permName);
        if (pkgs == null) {
            return null;
        }
        return pkgs.toArray(new String[pkgs.size()]);
    }
}
 
Example #22
Source File: DefaultPermissionGrantPolicy.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void grantDefaultPermissionExceptions(int userId) {
    mHandler.removeMessages(MSG_READ_DEFAULT_PERMISSION_EXCEPTIONS);

    synchronized (mLock) {
        // mGrantExceptions is null only before the first read and then
        // it serves as a cache of the default grants that should be
        // performed for every user. If there is an entry then the app
        // is on the system image and supports runtime permissions.
        if (mGrantExceptions == null) {
            mGrantExceptions = readDefaultPermissionExceptionsLocked();
        }
    }

    Set<String> permissions = null;
    final int exceptionCount = mGrantExceptions.size();
    for (int i = 0; i < exceptionCount; i++) {
        String packageName = mGrantExceptions.keyAt(i);
        PackageParser.Package pkg = getSystemPackage(packageName);
        List<DefaultPermissionGrant> permissionGrants = mGrantExceptions.valueAt(i);
        final int permissionGrantCount = permissionGrants.size();
        for (int j = 0; j < permissionGrantCount; j++) {
            DefaultPermissionGrant permissionGrant = permissionGrants.get(j);
            if (permissions == null) {
                permissions = new ArraySet<>();
            } else {
                permissions.clear();
            }
            permissions.add(permissionGrant.name);
            grantRuntimePermissions(pkg, permissions,
                    permissionGrant.fixed, userId);
        }
    }
}
 
Example #23
Source File: KeyStoreCertificateSource.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public Set<X509Certificate> findAllByIssuerAndSignature(X509Certificate cert) {
    ensureInitialized();
    Set<java.security.cert.TrustAnchor> anchors = mIndex.findAllByIssuerAndSignature(cert);
    if (anchors.isEmpty()) {
        return Collections.<X509Certificate>emptySet();
    }
    Set<X509Certificate> certs = new ArraySet<X509Certificate>(anchors.size());
    for (java.security.cert.TrustAnchor anchor : anchors) {
        certs.add(anchor.getTrustedCert());
    }
    return certs;
}
 
Example #24
Source File: KeySetManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * This informs the system that the given package has defined a KeySet
 * alias in its manifest to be an upgradeKeySet.  This must be called
 * after all of the defined KeySets have been added.
 */
void addUpgradeKeySetsToPackageLPw(PackageSetting pkg,
        ArraySet<String> upgradeAliases) {
    final int uaSize = upgradeAliases.size();
    for (int i = 0; i < uaSize; i++) {
        pkg.keySetData.addUpgradeKeySet(upgradeAliases.valueAt(i));
    }
    return;
}
 
Example #25
Source File: TaskPersister.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void removeObsoleteFiles(ArraySet<Integer> persistentTaskIds) {
    int[] candidateUserIds;
    synchronized (mService) {
        // Remove only from directories of the users who have recents in memory synchronized
        // with persistent storage.
        candidateUserIds = mRecentTasks.usersWithRecentsLoadedLocked();
    }
    for (int userId : candidateUserIds) {
        removeObsoleteFiles(persistentTaskIds, getUserImagesDir(userId).listFiles());
        removeObsoleteFiles(persistentTaskIds, getUserTasksDir(userId).listFiles());
    }
}
 
Example #26
Source File: AppErrors.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void loadAppsNotReportingCrashesFromConfigLocked(String appsNotReportingCrashesConfig) {
    if (appsNotReportingCrashesConfig != null) {
        final String[] split = appsNotReportingCrashesConfig.split(",");
        if (split.length > 0) {
            mAppsNotReportingCrashes = new ArraySet<>();
            Collections.addAll(mAppsNotReportingCrashes, split);
        }
    }
}
 
Example #27
Source File: TaskPersister.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    ArraySet<Integer> persistentTaskIds = new ArraySet<>();
    while (true) {
        // We can't lock mService while holding TaskPersister.this, but we don't want to
        // call removeObsoleteFiles every time through the loop, only the last time before
        // going to sleep. The risk is that we call removeObsoleteFiles() successively.
        final boolean probablyDone;
        synchronized (TaskPersister.this) {
            probablyDone = mWriteQueue.isEmpty();
        }
        if (probablyDone) {
            if (DEBUG) Slog.d(TAG, "Looking for obsolete files.");
            persistentTaskIds.clear();
            synchronized (mService) {
                if (DEBUG) Slog.d(TAG, "mRecents=" + mRecentTasks);
                mRecentTasks.getPersistableTaskIds(persistentTaskIds);
                mService.mWindowManager.removeObsoleteTaskFiles(persistentTaskIds,
                        mRecentTasks.usersWithRecentsLoadedLocked());
            }
            removeObsoleteFiles(persistentTaskIds);
        }
        writeTaskIdsFiles();

        processNextItem();
    }
}
 
Example #28
Source File: AppOpsService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void evalForegroundWatchers(int op, SparseArray<ArraySet<ModeCallback>> watchers,
        SparseBooleanArray which) {
    boolean curValue = which.get(op, false);
    ArraySet<ModeCallback> callbacks = watchers.get(op);
    if (callbacks != null) {
        for (int cbi = callbacks.size() - 1; !curValue && cbi >= 0; cbi--) {
            if ((callbacks.valueAt(cbi).mFlags
                    & AppOpsManager.WATCH_FOREGROUND_CHANGES) != 0) {
                hasForegroundWatchers = true;
                curValue = true;
            }
        }
    }
    which.put(op, curValue);
}
 
Example #29
Source File: ShortcutInfo.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private static ArraySet<String> cloneCategories(Set<String> source) {
    if (source == null) {
        return null;
    }
    final ArraySet<String> ret = new ArraySet<>(source.size());
    for (CharSequence s : source) {
        if (!TextUtils.isEmpty(s)) {
            ret.add(s.toString().intern());
        }
    }
    return ret;
}
 
Example #30
Source File: FillEventHistory.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new event.
 *
 * @param eventType The type of the event
 * @param datasetId The dataset the event was on, or {@code null} if the event was on the
 *                  whole response.
 * @param clientState The client state associated with the event.
 * @param selectedDatasetIds The ids of datasets selected by the user.
 * @param ignoredDatasetIds The ids of datasets NOT select by the user.
 * @param changedFieldIds The ids of fields changed by the user.
 * @param changedDatasetIds The ids of the datasets that havd values matching the
 * respective entry on {@code changedFieldIds}.
 * @param manuallyFilledFieldIds The ids of fields that were manually entered by the user
 * and belonged to datasets.
 * @param manuallyFilledDatasetIds The ids of datasets that had values matching the
 * respective entry on {@code manuallyFilledFieldIds}.
 * @param detectedFieldClassifications the field classification matches.
 *
 * @throws IllegalArgumentException If the length of {@code changedFieldIds} and
 * {@code changedDatasetIds} doesn't match.
 * @throws IllegalArgumentException If the length of {@code manuallyFilledFieldIds} and
 * {@code manuallyFilledDatasetIds} doesn't match.
 *
 * @hide
 */
public Event(int eventType, @Nullable String datasetId, @Nullable Bundle clientState,
        @Nullable List<String> selectedDatasetIds,
        @Nullable ArraySet<String> ignoredDatasetIds,
        @Nullable ArrayList<AutofillId> changedFieldIds,
        @Nullable ArrayList<String> changedDatasetIds,
        @Nullable ArrayList<AutofillId> manuallyFilledFieldIds,
        @Nullable ArrayList<ArrayList<String>> manuallyFilledDatasetIds,
        @Nullable AutofillId[] detectedFieldIds,
        @Nullable FieldClassification[] detectedFieldClassifications) {
    mEventType = Preconditions.checkArgumentInRange(eventType, 0, TYPE_CONTEXT_COMMITTED,
            "eventType");
    mDatasetId = datasetId;
    mClientState = clientState;
    mSelectedDatasetIds = selectedDatasetIds;
    mIgnoredDatasetIds = ignoredDatasetIds;
    if (changedFieldIds != null) {
        Preconditions.checkArgument(!ArrayUtils.isEmpty(changedFieldIds)
                && changedDatasetIds != null
                && changedFieldIds.size() == changedDatasetIds.size(),
                "changed ids must have same length and not be empty");
    }
    mChangedFieldIds = changedFieldIds;
    mChangedDatasetIds = changedDatasetIds;
    if (manuallyFilledFieldIds != null) {
        Preconditions.checkArgument(!ArrayUtils.isEmpty(manuallyFilledFieldIds)
                && manuallyFilledDatasetIds != null
                && manuallyFilledFieldIds.size() == manuallyFilledDatasetIds.size(),
                "manually filled ids must have same length and not be empty");
    }
    mManuallyFilledFieldIds = manuallyFilledFieldIds;
    mManuallyFilledDatasetIds = manuallyFilledDatasetIds;

    mDetectedFieldIds = detectedFieldIds;
    mDetectedFieldClassifications = detectedFieldClassifications;
}