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
diff --git a/apex/jobscheduler/service/aconfig/job.aconfig b/apex/jobscheduler/service/aconfig/job.aconfig
index eb5502b..c65e506 100644
--- a/apex/jobscheduler/service/aconfig/job.aconfig
+++ b/apex/jobscheduler/service/aconfig/job.aconfig
@@ -5,4 +5,11 @@
     namespace: "backstage_power"
     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
diff --git a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
index 07475b4..2d972d0 100644
--- a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
+++ b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
@@ -4358,7 +4358,8 @@
         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