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

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

Snap for 11432641 from 5713cf3a to 24Q2-release

Change-Id: I44c9ba5b4a4e83b8fc8cef0e3ca10b6e4c901836
parents 317f4f59 5713cf3a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -97,7 +97,6 @@ android_ravenwood_libgroup {
        "framework-minus-apex.ravenwood",
        "hoststubgen-helper-runtime.ravenwood",
        "hoststubgen-helper-framework-runtime.ravenwood",
        "core-libart-for-host",
        "all-updatable-modules-system-stubs",
        "junit",
        "truth",
+14 −4
Original line number Diff line number Diff line
@@ -20,10 +20,12 @@ import static android.view.View.MeasureSpec.UNSPECIFIED;

import android.graphics.Canvas;
import android.graphics.RecordingCanvas;
import android.graphics.RectF;
import android.graphics.RenderNode;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;
import android.text.NonEditableTextGenerator.TextType;
import android.view.View;
import android.widget.TextView;

import androidx.test.InstrumentationRegistry;
@@ -79,7 +81,7 @@ public class TextViewSetTextMeasurePerfTest {
        mCached = cached;
        mTextPaint = new TextPaint();
        mTextPaint.setTextSize(10);
        mLineWidth = Integer.MAX_VALUE;
        mLineWidth = 2048;
    }

    /**
@@ -106,7 +108,9 @@ public class TextViewSetTextMeasurePerfTest {
            state.resumeTiming();

            textView.setText(text);
            textView.measure(AT_MOST | mLineWidth, UNSPECIFIED);
            textView.measure(
                    View.MeasureSpec.makeMeasureSpec(mLineWidth, AT_MOST),
                    UNSPECIFIED);
        }
    }

@@ -129,10 +133,16 @@ public class TextViewSetTextMeasurePerfTest {
        while (state.keepRunning()) {

            state.pauseTiming();
            final RecordingCanvas canvas = node.start(1200, 200);
            int save = canvas.save();
            textView.setTextLocale(Locale.UK);
            textView.setTextLocale(Locale.US);
            textView.measure(
                    View.MeasureSpec.makeMeasureSpec(mLineWidth, AT_MOST),
                    UNSPECIFIED);
            RectF bounds = textView.getLayout().computeDrawingBoundingBox();
            final RecordingCanvas canvas = node.start(
                    (int) Math.ceil(bounds.width()),
                    (int) Math.ceil(bounds.height()));
            int save = canvas.save();
            if (!mCached) Canvas.freeTextLayoutCaches();
            state.resumeTiming();

+0 −7
Original line number Diff line number Diff line
@@ -27,10 +27,3 @@ flag {
    description: "Only relax a prefetch job's connectivity constraint when the device is charging and battery is not low"
    bug: "299329948"
}

flag {
    name: "throw_on_unsupported_bias_usage"
    namespace: "backstage_power"
    description: "Throw an exception if an unsupported app uses JobInfo.setBias"
    bug: "300477393"
}
+44 −6
Original line number Diff line number Diff line
@@ -485,6 +485,32 @@ public class JobSchedulerService extends com.android.server.SystemService

    private class ConstantsObserver implements DeviceConfig.OnPropertiesChangedListener,
            EconomyManagerInternal.TareStateChangeListener {
        @Nullable
        @GuardedBy("mLock")
        private DeviceConfig.Properties mLastPropertiesPulled;
        @GuardedBy("mLock")
        private boolean mCacheConfigChanges = false;

        @Nullable
        @GuardedBy("mLock")
        public String getValueLocked(String key) {
            if (mLastPropertiesPulled == null) {
                return null;
            }
            return mLastPropertiesPulled.getString(key, null);
        }

        @GuardedBy("mLock")
        public void setCacheConfigChangesLocked(boolean enabled) {
            if (enabled && !mCacheConfigChanges) {
                mLastPropertiesPulled =
                        DeviceConfig.getProperties(DeviceConfig.NAMESPACE_JOB_SCHEDULER);
            } else {
                mLastPropertiesPulled = null;
            }
            mCacheConfigChanges = enabled;
        }

        public void start() {
            DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_JOB_SCHEDULER,
                    AppSchedulingModuleThread.getExecutor(), this);
@@ -513,11 +539,15 @@ public class JobSchedulerService extends com.android.server.SystemService
            }

            synchronized (mLock) {
                if (mCacheConfigChanges) {
                    mLastPropertiesPulled =
                            DeviceConfig.getProperties(DeviceConfig.NAMESPACE_JOB_SCHEDULER);
                }
                for (String name : properties.getKeyset()) {
                    if (name == null) {
                        continue;
                    }
                    if (DEBUG) {
                    if (DEBUG || mCacheConfigChanges) {
                        Slog.d(TAG, "DeviceConfig " + name
                                + " changed to " + properties.getString(name, null));
                    }
@@ -4812,8 +4842,7 @@ public class JobSchedulerService extends com.android.server.SystemService
        private JobInfo enforceBuilderApiPermissions(int uid, int pid, JobInfo job) {
            if (job.getBias() != JobInfo.BIAS_DEFAULT
                        && !hasPermission(uid, pid, Manifest.permission.UPDATE_DEVICE_STATS)) {
                if (CompatChanges.isChangeEnabled(THROW_ON_UNSUPPORTED_BIAS_USAGE, uid)
                        && Flags.throwOnUnsupportedBiasUsage()) {
                if (CompatChanges.isChangeEnabled(THROW_ON_UNSUPPORTED_BIAS_USAGE, uid)) {
                    throw new SecurityException("Apps may not call setBias()");
                } else {
                    // We can't throw the exception. Log the issue and modify the job to remove
@@ -5554,6 +5583,18 @@ public class JobSchedulerService extends com.android.server.SystemService
        }
    }

    void setCacheConfigChanges(boolean enabled) {
        synchronized (mLock) {
            mConstantsObserver.setCacheConfigChangesLocked(enabled);
        }
    }

    String getConfigValue(String key) {
        synchronized (mLock) {
            return mConstantsObserver.getValueLocked(key);
        }
    }

    int getStorageSeq() {
        synchronized (mLock) {
            return mStorageController.getTracker().getSeq();
@@ -5865,9 +5906,6 @@ public class JobSchedulerService extends com.android.server.SystemService
            pw.print(Flags.FLAG_DO_NOT_FORCE_RUSH_EXECUTION_AT_BOOT,
                    Flags.doNotForceRushExecutionAtBoot());
            pw.println();
            pw.print(Flags.FLAG_THROW_ON_UNSUPPORTED_BIAS_USAGE,
                    Flags.throwOnUnsupportedBiasUsage());
            pw.println();
            pw.print(android.app.job.Flags.FLAG_BACKUP_JOBS_EXEMPTION,
                    android.app.job.Flags.backupJobsExemption());
            pw.println();
+53 −6
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.job;

import android.Manifest;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.AppGlobals;
@@ -66,6 +67,8 @@ public final class JobSchedulerShellCommand extends BasicShellCommandHandler {
                    return getBatteryCharging(pw);
                case "get-battery-not-low":
                    return getBatteryNotLow(pw);
                case "get-config-value":
                    return getConfigValue(pw);
                case "get-estimated-download-bytes":
                    return getEstimatedNetworkBytes(pw, BYTE_OPTION_DOWNLOAD);
                case "get-estimated-upload-bytes":
@@ -82,6 +85,8 @@ public final class JobSchedulerShellCommand extends BasicShellCommandHandler {
                    return getJobState(pw);
                case "heartbeat":
                    return doHeartbeat(pw);
                case "cache-config-changes":
                    return cacheConfigChanges(pw);
                case "reset-execution-quota":
                    return resetExecutionQuota(pw);
                case "reset-schedule-quota":
@@ -100,13 +105,16 @@ public final class JobSchedulerShellCommand extends BasicShellCommandHandler {
    }

    private void checkPermission(String operation) throws Exception {
        checkPermission(operation, Manifest.permission.CHANGE_APP_IDLE_STATE);
    }

    private void checkPermission(String operation, String permission) throws Exception {
        final int uid = Binder.getCallingUid();
        if (uid == 0) {
            // Root can do anything.
            return;
        }
        final int perm = mPM.checkUidPermission(
                "android.permission.CHANGE_APP_IDLE_STATE", uid);
        final int perm = mPM.checkUidPermission(permission, uid);
        if (perm != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException("Uid " + uid
                    + " not permitted to " + operation);
@@ -339,7 +347,7 @@ public final class JobSchedulerShellCommand extends BasicShellCommandHandler {
    }

    private int getAconfigFlagState(PrintWriter pw) throws Exception {
        checkPermission("get aconfig flag state");
        checkPermission("get aconfig flag state", Manifest.permission.DUMP);

        final String flagName = getNextArgRequired();

@@ -359,9 +367,6 @@ public final class JobSchedulerShellCommand extends BasicShellCommandHandler {
            case com.android.server.job.Flags.FLAG_DO_NOT_FORCE_RUSH_EXECUTION_AT_BOOT:
                pw.println(com.android.server.job.Flags.doNotForceRushExecutionAtBoot());
                break;
            case com.android.server.job.Flags.FLAG_THROW_ON_UNSUPPORTED_BIAS_USAGE:
                pw.println(com.android.server.job.Flags.throwOnUnsupportedBiasUsage());
                break;
            case android.app.job.Flags.FLAG_BACKUP_JOBS_EXEMPTION:
                pw.println(android.app.job.Flags.backupJobsExemption());
                break;
@@ -390,6 +395,20 @@ public final class JobSchedulerShellCommand extends BasicShellCommandHandler {
        return 0;
    }

    private int getConfigValue(PrintWriter pw) throws Exception {
        checkPermission("get device config value", Manifest.permission.DUMP);

        final String key = getNextArgRequired();

        final long ident = Binder.clearCallingIdentity();
        try {
            pw.println(mInternal.getConfigValue(key));
            return 0;
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
    }

    private int getEstimatedNetworkBytes(PrintWriter pw, int byteOption) throws Exception {
        checkPermission("get estimated bytes");

@@ -540,6 +559,28 @@ public final class JobSchedulerShellCommand extends BasicShellCommandHandler {
        return -1;
    }

    private int cacheConfigChanges(PrintWriter pw) throws Exception {
        checkPermission("change config caching", Manifest.permission.DUMP);
        String opt = getNextArgRequired();
        boolean enabled;
        if ("on".equals(opt)) {
            enabled = true;
        } else if ("off".equals(opt)) {
            enabled = false;
        } else {
            getErrPrintWriter().println("Error: unknown option " + opt);
            return 1;
        }
        final long ident = Binder.clearCallingIdentity();
        try {
            mInternal.setCacheConfigChanges(enabled);
            pw.println("Config caching " + (enabled ? "enabled" : "disabled"));
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
        return 0;
    }

    private int resetExecutionQuota(PrintWriter pw) throws Exception {
        checkPermission("reset execution quota");

@@ -726,6 +767,9 @@ public final class JobSchedulerShellCommand extends BasicShellCommandHandler {
        pw.println("         is null (no namespace).");
        pw.println("  heartbeat [num]");
        pw.println("    No longer used.");
        pw.println("  cache-config-changes [on|off]");
        pw.println("    Control caching the set of most recently processed config flags.");
        pw.println("    Off by default.  Turning on makes get-config-value useful.");
        pw.println("  monitor-battery [on|off]");
        pw.println("    Control monitoring of all battery changes.  Off by default.  Turning");
        pw.println("    on makes get-battery-seq useful.");
@@ -738,6 +782,9 @@ public final class JobSchedulerShellCommand extends BasicShellCommandHandler {
        pw.println("    Return whether the battery is currently considered to be charging.");
        pw.println("  get-battery-not-low");
        pw.println("    Return whether the battery is currently considered to not be low.");
        pw.println("  get-config-value KEY");
        pw.println("    Return the most recently processed and cached config value for the KEY.");
        pw.println("    Only useful if caching is turned on with cache-config-changes.");
        pw.println("  get-estimated-download-bytes [-u | --user USER_ID]"
                + " [-n | --namespace NAMESPACE] PACKAGE JOB_ID");
        pw.println("    Return the most recent estimated download bytes for the job.");
Loading