Loading AconfigFlags.bp +12 −0 Original line number Diff line number Diff line Loading @@ -236,6 +236,18 @@ java_aconfig_library { defaults: ["framework-minus-apex-aconfig-java-defaults"], } java_aconfig_library { name: "telecom_flags_core_java_aconfig_java_exported_lib", aconfig_declarations: "telecom_flags", mode: "exported", min_sdk_version: "30", defaults: ["framework-minus-apex-aconfig-java-defaults"], apex_available: [ "//apex_available:platform", "com.android.permission", ], } // Telephony java_aconfig_library { name: "telephony_flags_core_java_lib", Loading OWNERS +1 −0 Original line number Diff line number Diff line Loading @@ -52,3 +52,4 @@ per-file ADPF_OWNERS = file:/ADPF_OWNERS per-file GAME_MANAGER_OWNERS = file:/GAME_MANAGER_OWNERS per-file SDK_OWNERS = file:/SDK_OWNERS per-file PREUPLOAD_OWNERS = file:/PREUPLOAD_OWNERS per-file THERMAL_OWNERS = file:/THERMAL_OWNERS THERMAL_OWNERS +2 −3 Original line number Diff line number Diff line lpy@google.com wvw@google.com xwxw@google.com # Bug component: 826709 file:platform/frameworks/base:/ADPF_OWNERS No newline at end of file apex/jobscheduler/framework/java/android/app/job/JobServiceEngine.java +33 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.os.Message; import android.os.RemoteException; import android.util.Log; import com.android.internal.os.DebugStore; import com.android.internal.os.SomeArgs; import java.lang.ref.WeakReference; Loading Loading @@ -79,6 +80,9 @@ public abstract class JobServiceEngine { /** Message that the network to use has changed. */ private static final int MSG_INFORM_OF_NETWORK_CHANGE = 8; private static final boolean DEBUG_STORE_ENABLED = com.android.internal.os.Flags.debugStoreEnabled(); private final IJobService mBinder; /** Loading Loading @@ -125,6 +129,12 @@ public abstract class JobServiceEngine { JobServiceEngine service = mService.get(); if (service != null) { Message m = Message.obtain(service.mHandler, MSG_EXECUTE_JOB, jobParams); if (DEBUG_STORE_ENABLED) { DebugStore.recordScheduleStartJob( System.identityHashCode(m.obj), jobParams.getJobId(), jobParams.getJobNamespace()); } m.sendToTarget(); } } Loading @@ -144,6 +154,12 @@ public abstract class JobServiceEngine { JobServiceEngine service = mService.get(); if (service != null) { Message m = Message.obtain(service.mHandler, MSG_STOP_JOB, jobParams); if (DEBUG_STORE_ENABLED) { DebugStore.recordScheduleStopJob( System.identityHashCode(m.obj), jobParams.getJobId(), jobParams.getJobNamespace()); } m.sendToTarget(); } } Loading @@ -164,6 +180,11 @@ public abstract class JobServiceEngine { switch (msg.what) { case MSG_EXECUTE_JOB: { final JobParameters params = (JobParameters) msg.obj; long debugStoreId = -1; if (DEBUG_STORE_ENABLED) { debugStoreId = DebugStore.recordStartJob(System.identityHashCode(params)); } try { params.enableCleaner(); boolean workOngoing = JobServiceEngine.this.onStartJob(params); Loading @@ -174,17 +195,29 @@ public abstract class JobServiceEngine { } catch (Exception e) { Log.e(TAG, "Error while executing job: " + params.getJobId()); throw new RuntimeException(e); } finally { if (DEBUG_STORE_ENABLED) { DebugStore.recordEventEnd(debugStoreId); } } break; } case MSG_STOP_JOB: { final JobParameters params = (JobParameters) msg.obj; long debugStoreId = -1; if (DEBUG_STORE_ENABLED) { debugStoreId = DebugStore.recordStopJob(System.identityHashCode(params)); } try { boolean ret = JobServiceEngine.this.onStopJob(params); ackStopMessage(params, ret); } catch (Exception e) { Log.e(TAG, "Application unable to handle onStopJob.", e); throw new RuntimeException(e); } finally { if (DEBUG_STORE_ENABLED) { DebugStore.recordEventEnd(debugStoreId); } } break; } Loading apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +49 −7 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ import com.android.modules.expresslog.Histogram; import com.android.server.EventLogTags; import com.android.server.LocalServices; import com.android.server.job.controllers.JobStatus; import com.android.server.utils.AnrTimer; import java.util.Objects; Loading Loading @@ -319,6 +320,40 @@ public final class JobServiceContext implements ServiceConnection { } } // All instances of JobAnrTimer share the same arguments. private static final AnrTimer.Args sAnrTimerArgs = new AnrTimer.Args().enable(com.android.server.utils.Flags.anrTimerJobService()); /** * An AnrTimer for the JobServiceContext. There is one instance for each JobServiceContext * (these objects are not large). For convenience, simple no-argument methods are provided * which use 'this'. */ private class JobAnrTimer extends AnrTimer<JobCallback> { JobAnrTimer() { super(mCallbackHandler, MSG_TIMEOUT, "JobScheduler", sAnrTimerArgs); } public void start(long timeout) { start(mRunningCallback, /* pid */ 0, mRunningJob.getUid(), timeout); } public boolean cancel() { return cancel(mRunningCallback); } public void accept(TimeoutRecord tr) { accept(mRunningCallback, tr); } public boolean discard() { return discard(mRunningCallback); } } // The AnrTimer for this instance. private final JobAnrTimer mAnrTimer; JobServiceContext(JobSchedulerService service, JobConcurrencyManager concurrencyManager, JobNotificationCoordinator notificationCoordinator, IBatteryStats batteryStats, JobPackageTracker tracker, Looper looper) { Loading @@ -337,6 +372,7 @@ public final class JobServiceContext implements ServiceConnection { mAvailable = true; mVerb = VERB_FINISHED; mPreferredUid = NO_PREFERRED_UID; mAnrTimer = new JobAnrTimer(); } /** Loading Loading @@ -1177,6 +1213,7 @@ public final class JobServiceContext implements ServiceConnection { handleOpTimeoutLocked(); } else { JobCallback jc = (JobCallback)message.obj; mAnrTimer.discard(jc); StringBuilder sb = new StringBuilder(128); sb.append("Ignoring timeout of no longer active job"); if (jc.mStoppedReason != null) { Loading Loading @@ -1433,6 +1470,8 @@ public final class JobServiceContext implements ServiceConnection { mRunningJob.getUid())); break; case VERB_EXECUTING: // This is the tricky one. Some of banches here accept the timeout and some // discard it. if (mPendingStopReason != JobParameters.STOP_REASON_UNDEFINED) { if (mService.isReadyToBeExecutedLocked(mRunningJob, false)) { // Job became ready again while we were waiting to stop it (for example, Loading @@ -1447,6 +1486,7 @@ public final class JobServiceContext implements ServiceConnection { mParams.setStopReason(mPendingStopReason, mPendingInternalStopReason, mPendingDebugStopReason); sendStopMessageLocked(mPendingDebugStopReason); mAnrTimer.discard(); break; } } Loading Loading @@ -1481,6 +1521,7 @@ public final class JobServiceContext implements ServiceConnection { mParams.setStopReason(stopReason, internalStopReason, debugStopReason.toString()); sendStopMessageLocked(stopMessage.toString()); mAnrTimer.discard(); } else if (nowElapsed >= earliestStopTimeElapsed) { // We've given the app the minimum execution time. See if we should stop it or // let it continue running Loading Loading @@ -1522,6 +1563,7 @@ public final class JobServiceContext implements ServiceConnection { default: Slog.e(TAG, "Handling timeout for an invalid job state: " + getRunningJobNameLocked() + ", dropping."); mAnrTimer.discard(); closeAndCleanupJobLocked(false /* needsReschedule */, "invalid timeout"); } } Loading Loading @@ -1565,9 +1607,12 @@ public final class JobServiceContext implements ServiceConnection { debugReason); } if (triggerAnr) { final TimeoutRecord tr = TimeoutRecord.forJobService(anrMessage); mAnrTimer.accept(tr); mActivityManagerInternal.appNotResponding( mRunningJob.serviceProcessName, mRunningJob.getUid(), TimeoutRecord.forJobService(anrMessage)); mRunningJob.serviceProcessName, mRunningJob.getUid(), tr); } else { mAnrTimer.discard(); } closeAndCleanupJobLocked(reschedule, debugReason); } Loading Loading @@ -1763,8 +1808,6 @@ public final class JobServiceContext implements ServiceConnection { * on with life. */ private void scheduleOpTimeOutLocked() { removeOpTimeOutLocked(); final long timeoutMillis; switch (mVerb) { case VERB_EXECUTING: Loading Loading @@ -1799,13 +1842,12 @@ public final class JobServiceContext implements ServiceConnection { mRunningJob.getServiceComponent().getShortClassName() + "' jId: " + mParams.getJobId() + ", in " + (timeoutMillis / 1000) + " s"); } Message m = mCallbackHandler.obtainMessage(MSG_TIMEOUT, mRunningCallback); mCallbackHandler.sendMessageDelayed(m, timeoutMillis); mAnrTimer.start(timeoutMillis); mTimeoutElapsed = sElapsedRealtimeClock.millis() + timeoutMillis; } private void removeOpTimeOutLocked() { mCallbackHandler.removeMessages(MSG_TIMEOUT); mAnrTimer.cancel(); } void dumpLocked(IndentingPrintWriter pw, final long nowElapsed) { Loading Loading
AconfigFlags.bp +12 −0 Original line number Diff line number Diff line Loading @@ -236,6 +236,18 @@ java_aconfig_library { defaults: ["framework-minus-apex-aconfig-java-defaults"], } java_aconfig_library { name: "telecom_flags_core_java_aconfig_java_exported_lib", aconfig_declarations: "telecom_flags", mode: "exported", min_sdk_version: "30", defaults: ["framework-minus-apex-aconfig-java-defaults"], apex_available: [ "//apex_available:platform", "com.android.permission", ], } // Telephony java_aconfig_library { name: "telephony_flags_core_java_lib", Loading
OWNERS +1 −0 Original line number Diff line number Diff line Loading @@ -52,3 +52,4 @@ per-file ADPF_OWNERS = file:/ADPF_OWNERS per-file GAME_MANAGER_OWNERS = file:/GAME_MANAGER_OWNERS per-file SDK_OWNERS = file:/SDK_OWNERS per-file PREUPLOAD_OWNERS = file:/PREUPLOAD_OWNERS per-file THERMAL_OWNERS = file:/THERMAL_OWNERS
THERMAL_OWNERS +2 −3 Original line number Diff line number Diff line lpy@google.com wvw@google.com xwxw@google.com # Bug component: 826709 file:platform/frameworks/base:/ADPF_OWNERS No newline at end of file
apex/jobscheduler/framework/java/android/app/job/JobServiceEngine.java +33 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.os.Message; import android.os.RemoteException; import android.util.Log; import com.android.internal.os.DebugStore; import com.android.internal.os.SomeArgs; import java.lang.ref.WeakReference; Loading Loading @@ -79,6 +80,9 @@ public abstract class JobServiceEngine { /** Message that the network to use has changed. */ private static final int MSG_INFORM_OF_NETWORK_CHANGE = 8; private static final boolean DEBUG_STORE_ENABLED = com.android.internal.os.Flags.debugStoreEnabled(); private final IJobService mBinder; /** Loading Loading @@ -125,6 +129,12 @@ public abstract class JobServiceEngine { JobServiceEngine service = mService.get(); if (service != null) { Message m = Message.obtain(service.mHandler, MSG_EXECUTE_JOB, jobParams); if (DEBUG_STORE_ENABLED) { DebugStore.recordScheduleStartJob( System.identityHashCode(m.obj), jobParams.getJobId(), jobParams.getJobNamespace()); } m.sendToTarget(); } } Loading @@ -144,6 +154,12 @@ public abstract class JobServiceEngine { JobServiceEngine service = mService.get(); if (service != null) { Message m = Message.obtain(service.mHandler, MSG_STOP_JOB, jobParams); if (DEBUG_STORE_ENABLED) { DebugStore.recordScheduleStopJob( System.identityHashCode(m.obj), jobParams.getJobId(), jobParams.getJobNamespace()); } m.sendToTarget(); } } Loading @@ -164,6 +180,11 @@ public abstract class JobServiceEngine { switch (msg.what) { case MSG_EXECUTE_JOB: { final JobParameters params = (JobParameters) msg.obj; long debugStoreId = -1; if (DEBUG_STORE_ENABLED) { debugStoreId = DebugStore.recordStartJob(System.identityHashCode(params)); } try { params.enableCleaner(); boolean workOngoing = JobServiceEngine.this.onStartJob(params); Loading @@ -174,17 +195,29 @@ public abstract class JobServiceEngine { } catch (Exception e) { Log.e(TAG, "Error while executing job: " + params.getJobId()); throw new RuntimeException(e); } finally { if (DEBUG_STORE_ENABLED) { DebugStore.recordEventEnd(debugStoreId); } } break; } case MSG_STOP_JOB: { final JobParameters params = (JobParameters) msg.obj; long debugStoreId = -1; if (DEBUG_STORE_ENABLED) { debugStoreId = DebugStore.recordStopJob(System.identityHashCode(params)); } try { boolean ret = JobServiceEngine.this.onStopJob(params); ackStopMessage(params, ret); } catch (Exception e) { Log.e(TAG, "Application unable to handle onStopJob.", e); throw new RuntimeException(e); } finally { if (DEBUG_STORE_ENABLED) { DebugStore.recordEventEnd(debugStoreId); } } break; } Loading
apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +49 −7 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ import com.android.modules.expresslog.Histogram; import com.android.server.EventLogTags; import com.android.server.LocalServices; import com.android.server.job.controllers.JobStatus; import com.android.server.utils.AnrTimer; import java.util.Objects; Loading Loading @@ -319,6 +320,40 @@ public final class JobServiceContext implements ServiceConnection { } } // All instances of JobAnrTimer share the same arguments. private static final AnrTimer.Args sAnrTimerArgs = new AnrTimer.Args().enable(com.android.server.utils.Flags.anrTimerJobService()); /** * An AnrTimer for the JobServiceContext. There is one instance for each JobServiceContext * (these objects are not large). For convenience, simple no-argument methods are provided * which use 'this'. */ private class JobAnrTimer extends AnrTimer<JobCallback> { JobAnrTimer() { super(mCallbackHandler, MSG_TIMEOUT, "JobScheduler", sAnrTimerArgs); } public void start(long timeout) { start(mRunningCallback, /* pid */ 0, mRunningJob.getUid(), timeout); } public boolean cancel() { return cancel(mRunningCallback); } public void accept(TimeoutRecord tr) { accept(mRunningCallback, tr); } public boolean discard() { return discard(mRunningCallback); } } // The AnrTimer for this instance. private final JobAnrTimer mAnrTimer; JobServiceContext(JobSchedulerService service, JobConcurrencyManager concurrencyManager, JobNotificationCoordinator notificationCoordinator, IBatteryStats batteryStats, JobPackageTracker tracker, Looper looper) { Loading @@ -337,6 +372,7 @@ public final class JobServiceContext implements ServiceConnection { mAvailable = true; mVerb = VERB_FINISHED; mPreferredUid = NO_PREFERRED_UID; mAnrTimer = new JobAnrTimer(); } /** Loading Loading @@ -1177,6 +1213,7 @@ public final class JobServiceContext implements ServiceConnection { handleOpTimeoutLocked(); } else { JobCallback jc = (JobCallback)message.obj; mAnrTimer.discard(jc); StringBuilder sb = new StringBuilder(128); sb.append("Ignoring timeout of no longer active job"); if (jc.mStoppedReason != null) { Loading Loading @@ -1433,6 +1470,8 @@ public final class JobServiceContext implements ServiceConnection { mRunningJob.getUid())); break; case VERB_EXECUTING: // This is the tricky one. Some of banches here accept the timeout and some // discard it. if (mPendingStopReason != JobParameters.STOP_REASON_UNDEFINED) { if (mService.isReadyToBeExecutedLocked(mRunningJob, false)) { // Job became ready again while we were waiting to stop it (for example, Loading @@ -1447,6 +1486,7 @@ public final class JobServiceContext implements ServiceConnection { mParams.setStopReason(mPendingStopReason, mPendingInternalStopReason, mPendingDebugStopReason); sendStopMessageLocked(mPendingDebugStopReason); mAnrTimer.discard(); break; } } Loading Loading @@ -1481,6 +1521,7 @@ public final class JobServiceContext implements ServiceConnection { mParams.setStopReason(stopReason, internalStopReason, debugStopReason.toString()); sendStopMessageLocked(stopMessage.toString()); mAnrTimer.discard(); } else if (nowElapsed >= earliestStopTimeElapsed) { // We've given the app the minimum execution time. See if we should stop it or // let it continue running Loading Loading @@ -1522,6 +1563,7 @@ public final class JobServiceContext implements ServiceConnection { default: Slog.e(TAG, "Handling timeout for an invalid job state: " + getRunningJobNameLocked() + ", dropping."); mAnrTimer.discard(); closeAndCleanupJobLocked(false /* needsReschedule */, "invalid timeout"); } } Loading Loading @@ -1565,9 +1607,12 @@ public final class JobServiceContext implements ServiceConnection { debugReason); } if (triggerAnr) { final TimeoutRecord tr = TimeoutRecord.forJobService(anrMessage); mAnrTimer.accept(tr); mActivityManagerInternal.appNotResponding( mRunningJob.serviceProcessName, mRunningJob.getUid(), TimeoutRecord.forJobService(anrMessage)); mRunningJob.serviceProcessName, mRunningJob.getUid(), tr); } else { mAnrTimer.discard(); } closeAndCleanupJobLocked(reschedule, debugReason); } Loading Loading @@ -1763,8 +1808,6 @@ public final class JobServiceContext implements ServiceConnection { * on with life. */ private void scheduleOpTimeOutLocked() { removeOpTimeOutLocked(); final long timeoutMillis; switch (mVerb) { case VERB_EXECUTING: Loading Loading @@ -1799,13 +1842,12 @@ public final class JobServiceContext implements ServiceConnection { mRunningJob.getServiceComponent().getShortClassName() + "' jId: " + mParams.getJobId() + ", in " + (timeoutMillis / 1000) + " s"); } Message m = mCallbackHandler.obtainMessage(MSG_TIMEOUT, mRunningCallback); mCallbackHandler.sendMessageDelayed(m, timeoutMillis); mAnrTimer.start(timeoutMillis); mTimeoutElapsed = sElapsedRealtimeClock.millis() + timeoutMillis; } private void removeOpTimeOutLocked() { mCallbackHandler.removeMessages(MSG_TIMEOUT); mAnrTimer.cancel(); } void dumpLocked(IndentingPrintWriter pw, final long nowElapsed) { Loading