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

Commit 0028af98 authored by Kweku Adams's avatar Kweku Adams
Browse files

Throw the SecurityException only on V+ builds.

U builds shouldn't treat apps targeting V+ differently from apps
targeting U. Make sure the target SDK gated exception is only thrown on
V+ builds.

Bug: 300477393
Test: atest CtsJobSchedulerTestCases:JobInfoTest
Change-Id: I6d02e2d3d37f7dd06d63801da3352c357415e222
parent 418c3175
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -6,3 +6,10 @@ 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"
}
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -4358,7 +4358,8 @@ 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)) {
                if (CompatChanges.isChangeEnabled(THROW_ON_UNSUPPORTED_BIAS_USAGE, uid)
                        && Flags.throwOnUnsupportedBiasUsage()) {
                    throw new SecurityException("Apps may not call setBias()");
                } else {
                    // We can't throw the exception. Log the issue and modify the job to remove