com.android.internal.annotations.GuardedBy Java Examples

The following examples show how to use com.android.internal.annotations.GuardedBy. 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: FingerprintsUserState.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@GuardedBy("this")
private void parseStateLocked(XmlPullParser parser)
        throws IOException, XmlPullParserException {
    final int outerDepth = parser.getDepth();
    int type;
    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
            && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
        if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
            continue;
        }

        String tagName = parser.getName();
        if (tagName.equals(TAG_FINGERPRINTS)) {
            parseFingerprintsLocked(parser);
        }
    }
}
 
Example #2
Source File: UserManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
@GuardedBy("mAppRestrictionsLock")
static void writeApplicationRestrictionsLAr(Bundle restrictions, AtomicFile restrictionsFile) {
    FileOutputStream fos = null;
    try {
        fos = restrictionsFile.startWrite();
        final BufferedOutputStream bos = new BufferedOutputStream(fos);

        final XmlSerializer serializer = new FastXmlSerializer();
        serializer.setOutput(bos, StandardCharsets.UTF_8.name());
        serializer.startDocument(null, true);
        serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);

        serializer.startTag(null, TAG_RESTRICTIONS);
        writeBundle(restrictions, serializer);
        serializer.endTag(null, TAG_RESTRICTIONS);

        serializer.endDocument();
        restrictionsFile.finishWrite(fos);
    } catch (Exception e) {
        restrictionsFile.failWrite(fos);
        Slog.e(LOG_TAG, "Error writing application restrictions list", e);
    }
}
 
Example #3
Source File: MediaFocusControl.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Helper function
 * Pre-conditions: focus stack is not empty, there is one or more locked focus owner
 *                 at the top of the focus stack
 * Push the focus requester onto the audio focus stack at the first position immediately
 * following the locked focus owners.
 * @return {@link AudioManager#AUDIOFOCUS_REQUEST_GRANTED} or
 *     {@link AudioManager#AUDIOFOCUS_REQUEST_DELAYED}
 */
@GuardedBy("mAudioFocusLock")
private int pushBelowLockedFocusOwners(FocusRequester nfr) {
    int lastLockedFocusOwnerIndex = mFocusStack.size();
    for (int index = mFocusStack.size()-1; index >= 0; index--) {
        if (isLockedFocusOwner(mFocusStack.elementAt(index))) {
            lastLockedFocusOwnerIndex = index;
        }
    }
    if (lastLockedFocusOwnerIndex == mFocusStack.size()) {
        // this should not happen, but handle it and log an error
        Log.e(TAG, "No exclusive focus owner found in propagateFocusLossFromGain_syncAf()",
                new Exception());
        // no exclusive owner, push at top of stack, focus is granted, propagate change
        propagateFocusLossFromGain_syncAf(nfr.getGainRequest(), nfr, false /*forceDuck*/);
        mFocusStack.push(nfr);
        return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
    } else {
        mFocusStack.insertElementAt(nfr, lastLockedFocusOwnerIndex);
        return AudioManager.AUDIOFOCUS_REQUEST_DELAYED;
    }
}
 
Example #4
Source File: PackageStatusStorage.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@GuardedBy("this")
private PackageStatus getPackageStatusLocked() throws ParseException {
    try (FileInputStream fis = mPackageStatusFile.openRead()) {
        XmlPullParser parser = parseToPackageStatusTag(fis);
        Integer checkStatus = getNullableIntAttribute(parser, ATTRIBUTE_CHECK_STATUS);
        if (checkStatus == null) {
            return null;
        }
        int updateAppVersion = getIntAttribute(parser, ATTRIBUTE_UPDATE_APP_VERSION);
        int dataAppVersion = getIntAttribute(parser, ATTRIBUTE_DATA_APP_VERSION);
        return new PackageStatus(checkStatus,
                new PackageVersions(updateAppVersion, dataAppVersion));
    } catch (IOException e) {
        ParseException e2 = new ParseException("Error reading package status", 0);
        e2.initCause(e);
        throw e2;
    }
}
 
Example #5
Source File: ShortcutService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@GuardedBy("mLock")
private void saveUserInternalLocked(@UserIdInt int userId, OutputStream os,
        boolean forBackup) throws IOException, XmlPullParserException {

    final BufferedOutputStream bos = new BufferedOutputStream(os);

    // Write to XML
    XmlSerializer out = new FastXmlSerializer();
    out.setOutput(bos, StandardCharsets.UTF_8.name());
    out.startDocument(null, true);

    getUserShortcutsLocked(userId).saveToXml(out, forBackup);

    out.endDocument();

    bos.flush();
    os.flush();
}
 
Example #6
Source File: AppStateTracker.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Add to / remove from {@link #mRunAnyRestrictedPackages}.
 */
@GuardedBy("mLock")
boolean updateForcedAppStandbyUidPackageLocked(int uid, @NonNull String packageName,
        boolean restricted) {
    final int index = findForcedAppStandbyUidPackageIndexLocked(uid, packageName);
    final boolean wasRestricted = index >= 0;
    if (wasRestricted == restricted) {
        return false;
    }
    if (restricted) {
        mRunAnyRestrictedPackages.add(Pair.create(uid, packageName));
    } else {
        mRunAnyRestrictedPackages.removeAt(index);
    }
    return true;
}
 
Example #7
Source File: IpSecService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Removes a reference to this resource. If the resultant reference count is zero, the
 * underlying resources are freed, and references to all child resources are also dropped
 * recursively (resulting in them freeing their resources and children, etcetera)
 *
 * <p>This method also sets the reference count to an invalid value (-1) to signify that it
 * has been fully released. Any subsequent calls to this method will result in an
 * IllegalStateException being thrown due to resource already having been previously
 * released
 */
@VisibleForTesting
@GuardedBy("IpSecService.this")
public void releaseReference() throws RemoteException {
    mRefCount--;

    if (mRefCount > 0) {
        return;
    } else if (mRefCount < 0) {
        throw new IllegalStateException(
                "Invalid operation - resource has already been released.");
    }

    // Cleanup own resources
    mResource.freeUnderlyingResources();

    // Cleanup child resources as needed
    for (RefcountedResource<? extends IResource> child : mChildren) {
        child.releaseReference();
    }

    // Enforce that resource cleanup can only be called once
    // By decrementing the refcount (from 0 to -1), the next call will throw an
    // IllegalStateException - it has already been released fully.
    mRefCount--;
}
 
Example #8
Source File: NetworkStatsService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Clean up {@link #mUidRecorder} after UID is removed.
 */
@GuardedBy("mStatsLock")
private void removeUidsLocked(int... uids) {
    if (LOGV) Slog.v(TAG, "removeUidsLocked() for UIDs " + Arrays.toString(uids));

    // Perform one last poll before removing
    performPollLocked(FLAG_PERSIST_ALL);

    mUidRecorder.removeUidsLocked(uids);
    mUidTagRecorder.removeUidsLocked(uids);

    // Clear kernel stats associated with UID
    for (int uid : uids) {
        resetKernelUidStats(uid);
    }
}
 
Example #9
Source File: ContentService.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@GuardedBy("mCache")
private void invalidateCacheLocked(int userId, String providerPackageName, Uri uri) {
    ArrayMap<String, ArrayMap<Pair<String, Uri>, Bundle>> userCache = mCache.get(userId);
    if (userCache == null) return;

    ArrayMap<Pair<String, Uri>, Bundle> packageCache = userCache.get(providerPackageName);
    if (packageCache == null) return;

    if (uri != null) {
        for (int i = 0; i < packageCache.size();) {
            final Pair<String, Uri> key = packageCache.keyAt(i);
            if (key.second != null && key.second.toString().startsWith(uri.toString())) {
                if (DEBUG) Slog.d(TAG, "Invalidating cache for key " + key);
                packageCache.removeAt(i);
            } else {
                i++;
            }
        }
    } else {
        if (DEBUG) Slog.d(TAG, "Invalidating cache for package " + providerPackageName);
        packageCache.clear();
    }
}
 
Example #10
Source File: FingerprintsUserState.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@GuardedBy("this")
private void parseFingerprintsLocked(XmlPullParser parser)
        throws IOException, XmlPullParserException {

    final int outerDepth = parser.getDepth();
    int type;
    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
            && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
        if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
            continue;
        }

        String tagName = parser.getName();
        if (tagName.equals(TAG_FINGERPRINT)) {
            String name = parser.getAttributeValue(null, ATTR_NAME);
            String groupId = parser.getAttributeValue(null, ATTR_GROUP_ID);
            String fingerId = parser.getAttributeValue(null, ATTR_FINGER_ID);
            String deviceId = parser.getAttributeValue(null, ATTR_DEVICE_ID);
            mFingerprints.add(new Fingerprint(name, Integer.parseInt(groupId),
                    Integer.parseInt(fingerId), Integer.parseInt(deviceId)));
        }
    }
}
 
Example #11
Source File: ComponentResolver.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@GuardedBy("mLock")
private void addServicesLocked(PackageParser.Package pkg, boolean chatty) {
    final int servicesSize = pkg.services.size();
    StringBuilder r = null;
    for (int i = 0; i < servicesSize; i++) {
        PackageParser.Service s = pkg.services.get(i);
        s.info.processName = fixProcessName(pkg.applicationInfo.processName,
                s.info.processName);
        mServices.addService(s);
        if (DEBUG_PACKAGE_SCANNING && chatty) {
            if (r == null) {
                r = new StringBuilder(256);
            } else {
                r.append(' ');
            }
            r.append(s.info.name);
        }
    }
    if (DEBUG_PACKAGE_SCANNING && chatty) {
        Log.d(TAG, "  Services: " + (r == null ? "<NONE>" : r));
    }
}
 
Example #12
Source File: JobServiceContext.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * A job can be in various states when a cancel request comes in:
 * VERB_BINDING    -> Cancelled before bind completed. Mark as cancelled and wait for
 *                    {@link #onServiceConnected(android.content.ComponentName, android.os.IBinder)}
 *     _STARTING   -> Mark as cancelled and wait for
 *                    {@link JobServiceContext#doAcknowledgeStartMessage}
 *     _EXECUTING  -> call {@link #sendStopMessageLocked}}, but only if there are no callbacks
 *                      in the message queue.
 *     _ENDING     -> No point in doing anything here, so we ignore.
 */
@GuardedBy("mLock")
private void handleCancelLocked(String reason) {
    if (JobSchedulerService.DEBUG) {
        Slog.d(TAG, "Handling cancel for: " + mRunningJob.getJobId() + " "
                + VERB_STRINGS[mVerb]);
    }
    switch (mVerb) {
        case VERB_BINDING:
        case VERB_STARTING:
            mCancelled = true;
            applyStoppedReasonLocked(reason);
            break;
        case VERB_EXECUTING:
            sendStopMessageLocked(reason);
            break;
        case VERB_STOPPING:
            // Nada.
            break;
        default:
            Slog.e(TAG, "Cancelling a job without a valid verb: " + mVerb);
            break;
    }
}
 
Example #13
Source File: JobServiceContext.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@GuardedBy("mLock")
void doCallbackLocked(boolean reschedule, String reason) {
    if (DEBUG) {
        Slog.d(TAG, "doCallback of : " + mRunningJob
                + " v:" + VERB_STRINGS[mVerb]);
    }
    removeOpTimeOutLocked();

    if (mVerb == VERB_STARTING) {
        handleStartedLocked(reschedule);
    } else if (mVerb == VERB_EXECUTING ||
            mVerb == VERB_STOPPING) {
        handleFinishedLocked(reschedule, reason);
    } else {
        if (DEBUG) {
            Slog.d(TAG, "Unrecognised callback: " + mRunningJob);
        }
    }
}
 
Example #14
Source File: PackageInstallerSession.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mLock")
private void assertPreparedAndNotCommittedOrDestroyedLocked(String cookie) {
    assertPreparedAndNotDestroyedLocked(cookie);
    if (mCommitted) {
        throw new SecurityException(cookie + " not allowed after commit");
    }
}
 
Example #15
Source File: PackageInstallerSession.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mLock")
private void dumpLocked(IndentingPrintWriter pw) {
    pw.println("Session " + sessionId + ":");
    pw.increaseIndent();

    pw.printPair("userId", userId);
    pw.printPair("mOriginalInstallerUid", mOriginalInstallerUid);
    pw.printPair("mInstallerPackageName", mInstallerPackageName);
    pw.printPair("mInstallerUid", mInstallerUid);
    pw.printPair("createdMillis", createdMillis);
    pw.printPair("stageDir", stageDir);
    pw.printPair("stageCid", stageCid);
    pw.println();

    params.dump(pw);

    pw.printPair("mClientProgress", mClientProgress);
    pw.printPair("mProgress", mProgress);
    pw.printPair("mSealed", mSealed);
    pw.printPair("mPermissionsManuallyAccepted", mPermissionsManuallyAccepted);
    pw.printPair("mRelinquished", mRelinquished);
    pw.printPair("mDestroyed", mDestroyed);
    pw.printPair("mFds", mFds.size());
    pw.printPair("mBridges", mBridges.size());
    pw.printPair("mFinalStatus", mFinalStatus);
    pw.printPair("mFinalMessage", mFinalMessage);
    pw.println();

    pw.decreaseIndent();
}
 
Example #16
Source File: NetworkStatsService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Sample recent statistics summary into {@link EventLog}.
 */
@GuardedBy("mStatsLock")
private void performSampleLocked() {
    // TODO: migrate trustedtime fixes to separate binary log events
    final long currentTime = mClock.millis();

    NetworkTemplate template;
    NetworkStats.Entry devTotal;
    NetworkStats.Entry xtTotal;
    NetworkStats.Entry uidTotal;

    // collect mobile sample
    template = buildTemplateMobileWildcard();
    devTotal = mDevRecorder.getTotalSinceBootLocked(template);
    xtTotal = mXtRecorder.getTotalSinceBootLocked(template);
    uidTotal = mUidRecorder.getTotalSinceBootLocked(template);

    EventLogTags.writeNetstatsMobileSample(
            devTotal.rxBytes, devTotal.rxPackets, devTotal.txBytes, devTotal.txPackets,
            xtTotal.rxBytes, xtTotal.rxPackets, xtTotal.txBytes, xtTotal.txPackets,
            uidTotal.rxBytes, uidTotal.rxPackets, uidTotal.txBytes, uidTotal.txPackets,
            currentTime);

    // collect wifi sample
    template = buildTemplateWifiWildcard();
    devTotal = mDevRecorder.getTotalSinceBootLocked(template);
    xtTotal = mXtRecorder.getTotalSinceBootLocked(template);
    uidTotal = mUidRecorder.getTotalSinceBootLocked(template);

    EventLogTags.writeNetstatsWifiSample(
            devTotal.rxBytes, devTotal.rxPackets, devTotal.txBytes, devTotal.txPackets,
            xtTotal.rxBytes, xtTotal.rxPackets, xtTotal.txBytes, xtTotal.txPackets,
            uidTotal.rxBytes, uidTotal.rxPackets, uidTotal.txBytes, uidTotal.txPackets,
            currentTime);
}
 
Example #17
Source File: PackageInstallerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mSessions")
private int allocateSessionIdLocked() {
    int n = 0;
    int sessionId;
    do {
        sessionId = mRandom.nextInt(Integer.MAX_VALUE - 1) + 1;
        if (!mAllocatedSessions.get(sessionId, false)) {
            mAllocatedSessions.put(sessionId, true);
            return sessionId;
        }
    } while (n++ < 32);

    throw new IllegalStateException("Failed to allocate session ID");
}
 
Example #18
Source File: AutofillManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mLock")
void notifyViewExitedLocked(@NonNull View view) {
    ensureServiceClientAddedIfNeededLocked();

    if (mEnabled && isActiveLocked()) {
        // dont notify exited when Activity is already in background
        if (!isClientDisablingEnterExitEvent()) {
            final AutofillId id = view.getAutofillId();

            // Update focus on existing session.
            updateSessionLocked(id, null, null, ACTION_VIEW_EXITED, 0);
        }
    }
}
 
Example #19
Source File: UserManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mRestrictionsLock")
private void invalidateEffectiveUserRestrictionsLR(int userId) {
    if (DBG) {
        Log.d(LOG_TAG, "invalidateEffectiveUserRestrictions userId=" + userId);
    }
    mCachedEffectiveUserRestrictions.remove(userId);
}
 
Example #20
Source File: WebViewZygote.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("sLock")
private static void stopZygoteLocked() {
    if (sZygote != null) {
        // Close the connection and kill the zygote process. This will not cause
        // child processes to be killed by itself. But if this is called in response to
        // setMultiprocessEnabled() or onWebViewProviderChanged(), the WebViewUpdater
        // will kill all processes that depend on the WebView package.
        sZygote.close();
        Process.killProcess(sZygote.getPid());
        sZygote = null;
    }
}
 
Example #21
Source File: InstantAppResolverConnection.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mLock")
private void handleBinderDiedLocked() {
    if (mRemoteInstance != null) {
        try {
            mRemoteInstance.asBinder().unlinkToDeath(this, 0 /*flags*/);
        } catch (NoSuchElementException ignore) { }
    }
    mRemoteInstance = null;
}
 
Example #22
Source File: ShortcutService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** Return the per-user per-package state.  Use this when the caller is a publisher. */
@GuardedBy("mLock")
@NonNull
ShortcutPackage getPackageShortcutsForPublisherLocked(
        @NonNull String packageName, @UserIdInt int userId) {
    final ShortcutPackage ret = getUserShortcutsLocked(userId).getPackageShortcuts(packageName);
    ret.getUser().onCalledByPublisher(packageName);
    return ret;
}
 
Example #23
Source File: SQLiteConnectionPool.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mLock")
private void closeConnectionAndLogExceptionsLocked(SQLiteConnection connection) {
    try {
        connection.close(); // might throw
        if (mIdleConnectionHandler != null) {
            mIdleConnectionHandler.connectionClosed(connection);
        }
    } catch (RuntimeException ex) {
        Log.e(TAG, "Failed to close connection, its fate is now in the hands "
                + "of the merciful GC: " + connection, ex);
    }
}
 
Example #24
Source File: Vpn.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Load the always-on package and lockdown config from Settings.Secure
 */
@GuardedBy("this")
private void loadAlwaysOnPackage() {
    final long token = Binder.clearCallingIdentity();
    try {
        final String alwaysOnPackage = mSystemServices.settingsSecureGetStringForUser(
                Settings.Secure.ALWAYS_ON_VPN_APP, mUserHandle);
        final boolean alwaysOnLockdown = mSystemServices.settingsSecureGetIntForUser(
                Settings.Secure.ALWAYS_ON_VPN_LOCKDOWN, 0 /*default*/, mUserHandle) != 0;
        setAlwaysOnPackageInternal(alwaysOnPackage, alwaysOnLockdown);
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
 
Example #25
Source File: SQLiteConnectionPool.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mLock")
private void closeAvailableConnectionsAndLogExceptionsLocked() {
    closeAvailableNonPrimaryConnectionsAndLogExceptionsLocked();

    if (mAvailablePrimaryConnection != null) {
        closeConnectionAndLogExceptionsLocked(mAvailablePrimaryConnection);
        mAvailablePrimaryConnection = null;
    }
}
 
Example #26
Source File: InstantAppResolverConnection.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mLock")
private void waitForBindLocked(String token) throws TimeoutException, InterruptedException {
    final long startMillis = SystemClock.uptimeMillis();
    while (mBindState != STATE_IDLE) {
        if (mRemoteInstance != null) {
            break;
        }
        final long elapsedMillis = SystemClock.uptimeMillis() - startMillis;
        final long remainingMillis = BIND_SERVICE_TIMEOUT_MS - elapsedMillis;
        if (remainingMillis <= 0) {
            throw new TimeoutException("[" + token + "] Didn't bind to resolver in time!");
        }
        mLock.wait(remainingMillis);
    }
}
 
Example #27
Source File: StatsCompanionService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("sStatsdLock")
private final void informAllUidsLocked(Context context) throws RemoteException {
    UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
    PackageManager pm = context.getPackageManager();
    final List<UserInfo> users = um.getUsers(true);
    if (DEBUG) {
        Slog.d(TAG, "Iterating over " + users.size() + " profiles.");
    }

    List<Integer> uids = new ArrayList<>();
    List<Long> versions = new ArrayList<>();
    List<String> apps = new ArrayList<>();

    // Add in all the apps for every user/profile.
    for (UserInfo profile : users) {
        List<PackageInfo> pi =
            pm.getInstalledPackagesAsUser(PackageManager.MATCH_KNOWN_PACKAGES, profile.id);
        for (int j = 0; j < pi.size(); j++) {
            if (pi.get(j).applicationInfo != null) {
                uids.add(pi.get(j).applicationInfo.uid);
                versions.add(pi.get(j).getLongVersionCode());
                apps.add(pi.get(j).packageName);
            }
        }
    }
    sStatsd.informAllUidData(toIntArray(uids), toLongArray(versions), apps.toArray(new
            String[apps.size()]));
    if (DEBUG) {
        Slog.d(TAG, "Sent data for " + uids.size() + " apps");
    }
}
 
Example #28
Source File: JobServiceContext.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** Process MSG_TIMEOUT here. */
@GuardedBy("mLock")
private void handleOpTimeoutLocked() {
    switch (mVerb) {
        case VERB_BINDING:
            Slog.w(TAG, "Time-out while trying to bind " + getRunningJobNameLocked()
                    + ", dropping.");
            closeAndCleanupJobLocked(false /* needsReschedule */, "timed out while binding");
            break;
        case VERB_STARTING:
            // Client unresponsive - wedged or failed to respond in time. We don't really
            // know what happened so let's log it and notify the JobScheduler
            // FINISHED/NO-RETRY.
            Slog.w(TAG, "No response from client for onStartJob "
                    + getRunningJobNameLocked());
            closeAndCleanupJobLocked(false /* needsReschedule */, "timed out while starting");
            break;
        case VERB_STOPPING:
            // At least we got somewhere, so fail but ask the JobScheduler to reschedule.
            Slog.w(TAG, "No response from client for onStopJob "
                    + getRunningJobNameLocked());
            closeAndCleanupJobLocked(true /* needsReschedule */, "timed out while stopping");
            break;
        case VERB_EXECUTING:
            // Not an error - client ran out of time.
            Slog.i(TAG, "Client timed out while executing (no jobFinished received), " +
                    "sending onStop: " + getRunningJobNameLocked());
            mParams.setStopReason(JobParameters.REASON_TIMEOUT, "client timed out");
            sendStopMessageLocked("timeout while executing");
            break;
        default:
            Slog.e(TAG, "Handling timeout for an invalid job state: "
                    + getRunningJobNameLocked() + ", dropping.");
            closeAndCleanupJobLocked(false /* needsReschedule */, "invalid timeout");
    }
}
 
Example #29
Source File: JobServiceContext.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * VERB_EXECUTING  -> Client called jobFinished(), clean up and notify done.
 *     _STOPPING   -> Successful finish, clean up and notify done.
 *     _STARTING   -> Error
 *     _PENDING    -> Error
 */
@GuardedBy("mLock")
private void handleFinishedLocked(boolean reschedule, String reason) {
    switch (mVerb) {
        case VERB_EXECUTING:
        case VERB_STOPPING:
            closeAndCleanupJobLocked(reschedule, reason);
            break;
        default:
            Slog.e(TAG, "Got an execution complete message for a job that wasn't being" +
                    "executed. Was " + VERB_STRINGS[mVerb] + ".");
    }
}
 
Example #30
Source File: AutofillManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mLock")
private void addEnteredIdLocked(@NonNull AutofillId id) {
    if (mEnteredIds == null) {
        mEnteredIds = new ArraySet<>(1);
    }
    mEnteredIds.add(id);
}