Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82a477e1 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6306509 from b1f2e3d0 to mainline-release

Change-Id: I4901b261694118fa1e9e82f927236842c4600e0b
parents 06edd6a5 b1f2e3d0
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -791,10 +791,6 @@ java_library {
        "libphonenumber-platform",
        "tagsoup",
        "rappor",
        "libtextclassifier-java",
    ],
    required: [
        "libtextclassifier",
    ],
    dxflags: ["--core-library"],
}
+0 −2
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@ public class TextClassificationManagerPerfTest {
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            textClassificationManager.getTextClassifier();
            textClassificationManager.invalidateForTesting();
        }
    }

@@ -90,7 +89,6 @@ public class TextClassificationManagerPerfTest {
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            textClassificationManager.getTextClassifier();
            textClassificationManager.invalidateForTesting();
        }
    }

+4 −2
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import android.annotation.UserIdInt;
import android.app.usage.AppStandbyInfo;
import android.app.usage.UsageEvents;
import android.app.usage.UsageStatsManager.StandbyBuckets;
import android.app.usage.UsageStatsManager.SystemForcedReasons;
import android.content.Context;
import android.os.Looper;

@@ -123,9 +124,10 @@ public interface AppStandbyInternal {
     * appropriate time.
     *
     * @param restrictReason The restrictReason for restricting the app. Should be one of the
     *                       UsageStatsManager.REASON_SUB_RESTRICT_* reasons.
     *                       UsageStatsManager.REASON_SUB_FORCED_SYSTEM_FLAG_* reasons.
     */
    void restrictApp(@NonNull String packageName, int userId, int restrictReason);
    void restrictApp(@NonNull String packageName, int userId,
            @SystemForcedReasons int restrictReason);

    void addActiveDeviceAdmin(String adminPkg, int userId);

+1 −1
Original line number Diff line number Diff line
@@ -974,7 +974,7 @@ public class JobSchedulerService extends com.android.server.SystemService
            if (!mQuotaTracker.isWithinQuota(userId, pkg, QUOTA_TRACKER_SCHEDULE_PERSISTED_TAG)) {
                Slog.e(TAG, userId + "-" + pkg + " has called schedule() too many times");
                mAppStandbyInternal.restrictApp(
                        pkg, userId, UsageStatsManager.REASON_SUB_RESTRICT_BUGGY);
                        pkg, userId, UsageStatsManager.REASON_SUB_FORCED_SYSTEM_FLAG_BUGGY);
                if (mConstants.API_QUOTA_SCHEDULE_THROW_EXCEPTION) {
                    final boolean isDebuggable;
                    synchronized (mLock) {
+43 −12
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import android.app.AppGlobals;
import android.app.usage.AppStandbyInfo;
import android.app.usage.UsageEvents;
import android.app.usage.UsageStatsManager.StandbyBuckets;
import android.app.usage.UsageStatsManager.SystemForcedReasons;
import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
@@ -1153,6 +1154,13 @@ public class AppStandbyController implements AppStandbyInternal {
        }
    }

    @VisibleForTesting
    int getAppStandbyBucketReason(String packageName, int userId, long elapsedRealtime) {
        synchronized (mAppIdleLock) {
            return mAppIdleHistory.getAppStandbyReason(packageName, userId, elapsedRealtime);
        }
    }

    @Override
    public List<AppStandbyInfo> getAppStandbyBuckets(int userId) {
        synchronized (mAppIdleLock) {
@@ -1161,7 +1169,8 @@ public class AppStandbyController implements AppStandbyInternal {
    }

    @Override
    public void restrictApp(@NonNull String packageName, int userId, int restrictReason) {
    public void restrictApp(@NonNull String packageName, int userId,
            @SystemForcedReasons int restrictReason) {
        // If the package is not installed, don't allow the bucket to be set.
        if (!mInjector.isPackageInstalled(packageName, 0, userId)) {
            Slog.e(TAG, "Tried to restrict uninstalled app: " + packageName);
@@ -1248,31 +1257,53 @@ public class AppStandbyController implements AppStandbyInternal {
            // Don't allow changing bucket if higher than ACTIVE
            if (app.currentBucket < STANDBY_BUCKET_ACTIVE) return;

            // Don't allow prediction to change from/to NEVER or from RESTRICTED.
            if ((app.currentBucket == STANDBY_BUCKET_NEVER
                    || app.currentBucket == STANDBY_BUCKET_RESTRICTED
                    || newBucket == STANDBY_BUCKET_NEVER)
            // Don't allow prediction to change from/to NEVER.
            if ((app.currentBucket == STANDBY_BUCKET_NEVER || newBucket == STANDBY_BUCKET_NEVER)
                    && predicted) {
                return;
            }

            final boolean wasForcedBySystem =
                    (app.bucketingReason & REASON_MAIN_MASK) == REASON_MAIN_FORCED_BY_SYSTEM;

            // If the bucket was forced, don't allow prediction to override
            if (predicted
                    && ((app.bucketingReason & REASON_MAIN_MASK) == REASON_MAIN_FORCED_BY_USER
                    || (app.bucketingReason & REASON_MAIN_MASK) == REASON_MAIN_FORCED_BY_SYSTEM)) {
                    || wasForcedBySystem)) {
                return;
            }

            final boolean isForcedBySystem =
                    (reason & REASON_MAIN_MASK) == REASON_MAIN_FORCED_BY_SYSTEM;

            if (app.currentBucket == newBucket && wasForcedBySystem && isForcedBySystem) {
                mAppIdleHistory
                        .noteRestrictionAttempt(packageName, userId, elapsedRealtime, reason);
                // Keep track of all restricting reasons
                reason = REASON_MAIN_FORCED_BY_SYSTEM
                        | (app.bucketingReason & REASON_SUB_MASK)
                        | (reason & REASON_SUB_MASK);
                mAppIdleHistory.setAppStandbyBucket(packageName, userId, elapsedRealtime,
                        newBucket, reason, resetTimeout);
                return;
            }

            final boolean isForcedByUser =
                    (reason & REASON_MAIN_MASK) == REASON_MAIN_FORCED_BY_USER;

            // If the current bucket is RESTRICTED, only user force or usage should bring it out,
            // unless the app was put into the bucket due to timing out.
            if (app.currentBucket == STANDBY_BUCKET_RESTRICTED && !isUserUsage(reason)
                    && !isForcedByUser
                    && (app.bucketingReason & REASON_MAIN_MASK) != REASON_MAIN_TIMEOUT) {
            if (app.currentBucket == STANDBY_BUCKET_RESTRICTED) {
                if ((app.bucketingReason & REASON_MAIN_MASK) == REASON_MAIN_TIMEOUT) {
                    if (predicted && newBucket >= STANDBY_BUCKET_RARE) {
                        // Predicting into RARE or below means we don't expect the user to use the
                        // app anytime soon, so don't elevate it from RESTRICTED.
                        return;
                    }
                } else if (!isUserUsage(reason) && !isForcedByUser) {
                    // If the current bucket is RESTRICTED, only user force or usage should bring
                    // it out, unless the app was put into the bucket due to timing out.
                    return;
                }
            }

            if (newBucket == STANDBY_BUCKET_RESTRICTED) {
                mAppIdleHistory
Loading