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

Commit 73ace415 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11438811 from c3c62274 to 24Q2-release

Change-Id: I1eaf108e61cb45489d8909dff8e41e44251d3e14
parents c5cbd0c2 c3c62274
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ aconfig_srcjars = [
    ":android.service.controls.flags-aconfig-java{.generated_srcjars}",
    ":android.service.dreams.flags-aconfig-java{.generated_srcjars}",
    ":android.service.notification.flags-aconfig-java{.generated_srcjars}",
    ":android.service.appprediction.flags-aconfig-java{.generated_srcjars}",
    ":android.service.voice.flags-aconfig-java{.generated_srcjars}",
    ":android.speech.flags-aconfig-java{.generated_srcjars}",
    ":android.systemserver.flags-aconfig-java{.generated_srcjars}",
@@ -125,6 +126,7 @@ stubs_defaults {
        "android.provider.flags-aconfig",
        "android.security.flags-aconfig",
        "android.server.app.flags-aconfig",
        "android.service.appprediction.flags-aconfig",
        "android.service.autofill.flags-aconfig",
        "android.service.chooser.flags-aconfig",
        "android.service.controls.flags-aconfig",
@@ -726,6 +728,19 @@ java_aconfig_library {
    defaults: ["framework-minus-apex-aconfig-java-defaults"],
}

// App prediction
aconfig_declarations {
    name: "android.service.appprediction.flags-aconfig",
    package: "android.service.appprediction.flags",
    srcs: ["core/java/android/service/appprediction/flags/*.aconfig"],
}

java_aconfig_library {
    name: "android.service.appprediction.flags-aconfig-java",
    aconfig_declarations: "android.service.appprediction.flags-aconfig",
    defaults: ["framework-minus-apex-aconfig-java-defaults"],
}

// Controls
aconfig_declarations {
    name: "android.service.controls.flags-aconfig",
@@ -855,6 +870,13 @@ java_aconfig_library {
    defaults: ["framework-minus-apex-aconfig-java-defaults"],
}

java_aconfig_library {
    name: "device_policy_aconfig_flags_lib_host",
    aconfig_declarations: "device_policy_aconfig_flags",
    host_supported: true,
    defaults: ["framework-minus-apex-aconfig-java-defaults"],
}

cc_aconfig_library {
    name: "device_policy_aconfig_flags_c_lib",
    aconfig_declarations: "device_policy_aconfig_flags",
+3 −1
Original line number Diff line number Diff line
@@ -41,3 +41,5 @@ per-file *Ravenwood* = file:ravenwood/OWNERS
per-file PERFORMANCE_OWNERS = file:/PERFORMANCE_OWNERS

per-file PACKAGE_MANAGER_OWNERS = file:/PACKAGE_MANAGER_OWNERS

per-file WEAR_OWNERS = file:/WEAR_OWNERS
+1 −0
Original line number Diff line number Diff line
@@ -10,3 +10,4 @@ sadrul@google.com
rwmyers@google.com
nalmalki@google.com
shijianli@google.com
latkin@google.com
+5 −0
Original line number Diff line number Diff line
@@ -21,8 +21,11 @@ import static android.view.MotionEvent.ACTION_MOVE;
import static android.view.MotionEvent.ACTION_UP;
import static android.view.MotionEvent.TOOL_TYPE_FINGER;
import static android.view.MotionEvent.TOOL_TYPE_STYLUS;
import static android.view.inputmethod.Flags.initiationWithoutInputConnection;


import static org.junit.Assume.assumeFalse;

import android.app.Instrumentation;
import android.content.Context;
import android.perftests.utils.BenchmarkState;
@@ -186,6 +189,7 @@ public class HandwritingInitiatorPerfTest {

    @Test
    public void onInputConnectionCreated() {
        assumeFalse(initiationWithoutInputConnection());
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final View view = new View(mContext);
        final EditorInfo editorInfo = new EditorInfo();
@@ -199,6 +203,7 @@ public class HandwritingInitiatorPerfTest {

    @Test
    public void onInputConnectionClosed() {
        assumeFalse(initiationWithoutInputConnection());
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final View view = new View(mContext);
        while (state.keepRunning()) {
+58 −23
Original line number Diff line number Diff line
@@ -241,6 +241,8 @@ public final class FlexibilityController extends StateController {
        private static final long MAX_TIME_WINDOW_MS = 24 * HOUR_IN_MILLIS;
        private final JobScoreBucket[] mScoreBuckets = new JobScoreBucket[NUM_SCORE_BUCKETS];
        private int mScoreBucketIndex = 0;
        private long mCachedScoreExpirationTimeElapsed;
        private int mCachedScore;

        public void addScore(int add, long nowElapsed) {
            JobScoreBucket bucket = mScoreBuckets[mScoreBucketIndex];
@@ -248,10 +250,17 @@ public final class FlexibilityController extends StateController {
                bucket = new JobScoreBucket();
                bucket.startTimeElapsed = nowElapsed;
                mScoreBuckets[mScoreBucketIndex] = bucket;
                // Brand new bucket, there's nothing to remove from the score,
                // so just update the expiration time if needed.
                mCachedScoreExpirationTimeElapsed = Math.min(mCachedScoreExpirationTimeElapsed,
                        nowElapsed + MAX_TIME_WINDOW_MS);
            } else if (bucket.startTimeElapsed < nowElapsed - MAX_TIME_WINDOW_MS) {
                // The bucket is too old.
                bucket.reset();
                bucket.startTimeElapsed = nowElapsed;
                // Force a recalculation of the cached score instead of just updating the cached
                // value and time in case there are multiple stale buckets.
                mCachedScoreExpirationTimeElapsed = nowElapsed;
            } else if (bucket.startTimeElapsed
                    < nowElapsed - MAX_TIME_WINDOW_MS / NUM_SCORE_BUCKETS) {
                // The current bucket's duration has completed. Move on to the next bucket.
@@ -261,16 +270,26 @@ public final class FlexibilityController extends StateController {
            }

            bucket.score += add;
            mCachedScore += add;
        }

        public int getScore(long nowElapsed) {
            if (nowElapsed < mCachedScoreExpirationTimeElapsed) {
                return mCachedScore;
            }
            int score = 0;
            final long earliestElapsed = nowElapsed - MAX_TIME_WINDOW_MS;
            long earliestValidBucketTimeElapsed = Long.MAX_VALUE;
            for (JobScoreBucket bucket : mScoreBuckets) {
                if (bucket != null && bucket.startTimeElapsed >= earliestElapsed) {
                    score += bucket.score;
                    if (earliestValidBucketTimeElapsed > bucket.startTimeElapsed) {
                        earliestValidBucketTimeElapsed = bucket.startTimeElapsed;
                    }
                }
            }
            mCachedScore = score;
            mCachedScoreExpirationTimeElapsed = earliestValidBucketTimeElapsed + MAX_TIME_WINDOW_MS;
            return score;
        }

@@ -378,10 +397,16 @@ public final class FlexibilityController extends StateController {

    @Override
    public void prepareForExecutionLocked(JobStatus jobStatus) {
        if (jobStatus.lastEvaluatedBias == JobInfo.BIAS_TOP_APP) {
            // Don't include jobs for the TOP app in the score calculation.
            return;
        }
        // Use the job's requested priority to determine its score since that is what the developer
        // selected and it will be stable across job runs.
        final int score = mFallbackFlexibilityDeadlineScores
                .get(jobStatus.getJob().getPriority(), jobStatus.getJob().getPriority() / 100);
        final int priority = jobStatus.getJob().getPriority();
        final int score = mFallbackFlexibilityDeadlineScores.get(priority,
                FcConfig.DEFAULT_FALLBACK_FLEXIBILITY_DEADLINE_SCORES
                        .get(priority, priority / 100));
        JobScoreTracker jobScoreTracker =
                mJobScoreTrackers.get(jobStatus.getSourceUid(), jobStatus.getSourcePackageName());
        if (jobScoreTracker == null) {
@@ -394,6 +419,10 @@ public final class FlexibilityController extends StateController {

    @Override
    public void unprepareFromExecutionLocked(JobStatus jobStatus) {
        if (jobStatus.lastEvaluatedBias == JobInfo.BIAS_TOP_APP) {
            // Jobs for the TOP app are excluded from the score calculation.
            return;
        }
        // The job didn't actually start. Undo the score increase.
        JobScoreTracker jobScoreTracker =
                mJobScoreTrackers.get(jobStatus.getSourceUid(), jobStatus.getSourcePackageName());
@@ -401,8 +430,10 @@ public final class FlexibilityController extends StateController {
            Slog.e(TAG, "Unprepared a job that didn't result in a score change");
            return;
        }
        final int score = mFallbackFlexibilityDeadlineScores
                .get(jobStatus.getJob().getPriority(), jobStatus.getJob().getPriority() / 100);
        final int priority = jobStatus.getJob().getPriority();
        final int score = mFallbackFlexibilityDeadlineScores.get(priority,
                FcConfig.DEFAULT_FALLBACK_FLEXIBILITY_DEADLINE_SCORES
                        .get(priority, priority / 100));
        jobScoreTracker.addScore(-score, sElapsedRealtimeClock.millis());
    }

@@ -649,7 +680,7 @@ public final class FlexibilityController extends StateController {
                    (long) Math.scalb(mRescheduledJobDeadline, js.getNumPreviousAttempts() - 2),
                    mMaxRescheduledDeadline);
        }
        if (js.getLatestRunTimeElapsed() == JobStatus.NO_LATEST_RUNTIME) {

        // Intentionally use the effective priority here. If a job's priority was effectively
        // lowered, it will be less likely to run quickly given other policies in JobScheduler.
        // Thus, there's no need to further delay the job based on flex policy.
@@ -657,13 +688,16 @@ public final class FlexibilityController extends StateController {
        final int jobScore =
                getScoreLocked(js.getSourceUid(), js.getSourcePackageName(), nowElapsed);
        // Set an upper limit on the fallback deadline so that the delay doesn't become extreme.
            final long fallbackDeadlineMs = Math.min(3 * mFallbackFlexibilityDeadlineMs,
        final long fallbackDurationMs = Math.min(3 * mFallbackFlexibilityDeadlineMs,
                mFallbackFlexibilityDeadlines.get(jobPriority, mFallbackFlexibilityDeadlineMs)
                        + mFallbackFlexibilityAdditionalScoreTimeFactors
                                .get(jobPriority, MINUTE_IN_MILLIS) * jobScore);
            return earliest + fallbackDeadlineMs;
        final long fallbackDeadlineMs = earliest + fallbackDurationMs;

        if (js.getLatestRunTimeElapsed() == JobStatus.NO_LATEST_RUNTIME) {
            return fallbackDeadlineMs;
        }
        return js.getLatestRunTimeElapsed();
        return Math.max(fallbackDeadlineMs, js.getLatestRunTimeElapsed());
    }

    @VisibleForTesting
@@ -976,7 +1010,8 @@ public final class FlexibilityController extends StateController {
                    // Something has gone horribly wrong. This has only occurred on incorrectly
                    // configured tests, but add a check here for safety.
                    Slog.wtf(TAG, "Got invalid latest when scheduling alarm."
                            + " Prefetch=" + js.getJob().isPrefetch());
                            + " prefetch=" + js.getJob().isPrefetch()
                            + " periodic=" + js.getJob().isPeriodic());
                    // Since things have gone wrong, the safest and most reliable thing to do is
                    // stop applying flex policy to the job.
                    mFlexibilityTracker.setNumDroppedFlexibleConstraints(js,
@@ -991,7 +1026,7 @@ public final class FlexibilityController extends StateController {

                if (DEBUG) {
                    Slog.d(TAG, "scheduleDropNumConstraintsAlarm: "
                            + js.getSourcePackageName() + " " + js.getSourceUserId()
                            + js.toShortString()
                            + " numApplied: " + js.getNumAppliedFlexibleConstraints()
                            + " numRequired: " + js.getNumRequiredFlexibleConstraints()
                            + " numSatisfied: " + Integer.bitCount(
@@ -1199,11 +1234,11 @@ public final class FlexibilityController extends StateController {
            DEFAULT_FALLBACK_FLEXIBILITY_DEADLINE_ADDITIONAL_SCORE_TIME_FACTORS
                    .put(PRIORITY_MAX, 0);
            DEFAULT_FALLBACK_FLEXIBILITY_DEADLINE_ADDITIONAL_SCORE_TIME_FACTORS
                    .put(PRIORITY_HIGH, 4 * MINUTE_IN_MILLIS);
                    .put(PRIORITY_HIGH, 3 * MINUTE_IN_MILLIS);
            DEFAULT_FALLBACK_FLEXIBILITY_DEADLINE_ADDITIONAL_SCORE_TIME_FACTORS
                    .put(PRIORITY_DEFAULT, 3 * MINUTE_IN_MILLIS);
                    .put(PRIORITY_DEFAULT, 2 * MINUTE_IN_MILLIS);
            DEFAULT_FALLBACK_FLEXIBILITY_DEADLINE_ADDITIONAL_SCORE_TIME_FACTORS
                    .put(PRIORITY_LOW, 2 * MINUTE_IN_MILLIS);
                    .put(PRIORITY_LOW, 1 * MINUTE_IN_MILLIS);
            DEFAULT_FALLBACK_FLEXIBILITY_DEADLINE_ADDITIONAL_SCORE_TIME_FACTORS
                    .put(PRIORITY_MIN, 1 * MINUTE_IN_MILLIS);
            DEFAULT_PERCENTS_TO_DROP_FLEXIBLE_CONSTRAINTS
@@ -1220,7 +1255,7 @@ public final class FlexibilityController extends StateController {

        private static final long DEFAULT_MIN_TIME_BETWEEN_FLEXIBILITY_ALARMS_MS = MINUTE_IN_MILLIS;
        private static final long DEFAULT_RESCHEDULED_JOB_DEADLINE_MS = HOUR_IN_MILLIS;
        private static final long DEFAULT_MAX_RESCHEDULED_DEADLINE_MS = 5 * DAY_IN_MILLIS;
        private static final long DEFAULT_MAX_RESCHEDULED_DEADLINE_MS = DAY_IN_MILLIS;
        @VisibleForTesting
        static final long DEFAULT_UNSEEN_CONSTRAINT_GRACE_PERIOD_MS = 3 * DAY_IN_MILLIS;

Loading