Loading apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java +2 −1 Original line number Diff line number Diff line Loading @@ -2052,10 +2052,11 @@ public class AlarmManagerService extends SystemService { + " -- package not allowed to start"); return; } final int callerProcState = mActivityManagerInternal.getUidProcessState(callingUid); removeLocked(operation, directReceiver, REMOVE_REASON_UNDEFINED); incrementAlarmCount(a.uid); setImplLocked(a); MetricsHelper.pushAlarmScheduled(a); MetricsHelper.pushAlarmScheduled(a, callerProcState); } /** Loading apex/jobscheduler/service/java/com/android/server/alarm/MetricsHelper.java +4 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static com.android.internal.util.FrameworkStatsLog.ALARM_SCHEDULED__EXACT import static com.android.internal.util.FrameworkStatsLog.ALARM_SCHEDULED__EXACT_ALARM_ALLOWED_REASON__PERMISSION; import static com.android.server.alarm.AlarmManagerService.INDEFINITE_DELAY; import android.app.ActivityManager; import android.app.AlarmManager; import android.app.StatsManager; import android.content.Context; Loading Loading @@ -93,7 +94,7 @@ class MetricsHelper { } } static void pushAlarmScheduled(Alarm a) { static void pushAlarmScheduled(Alarm a, int callerProcState) { FrameworkStatsLog.write( FrameworkStatsLog.ALARM_SCHEDULED, a.uid, Loading @@ -103,7 +104,8 @@ class MetricsHelper { a.alarmClock != null, a.repeatInterval != 0, reasonToStatsReason(a.mExactAllowReason), AlarmManagerService.isRtc(a.type)); AlarmManagerService.isRtc(a.type), ActivityManager.processStateAmToProto(callerProcState)); } static void pushAlarmBatchDelivered(int numAlarms, int wakeups) { Loading apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +41 −4 Original line number Diff line number Diff line Loading @@ -116,6 +116,16 @@ public final class JobServiceContext implements ServiceConnection { @VisibleForTesting int mVerb; private boolean mCancelled; /** * True if the previous job on this context successfully finished (ie. called jobFinished or * dequeueWork with no work left). */ private boolean mPreviousJobHadSuccessfulFinish; /** * The last time a job on this context didn't finish successfully, in the elapsed realtime * timebase. */ private long mLastUnsuccessfulFinishElapsed; /** * All the information maintained about the job currently being executed. Loading Loading @@ -439,7 +449,9 @@ public final class JobServiceContext implements ServiceConnection { final long ident = Binder.clearCallingIdentity(); try { synchronized (mLock) { assertCallerLocked(cb); if (!assertCallerLocked(cb)) { return null; } if (mVerb == VERB_STOPPING || mVerb == VERB_FINISHED) { // This job is either all done, or on its way out. Either way, it // should not dispatch any more work. We will pick up any remaining Loading @@ -465,7 +477,11 @@ public final class JobServiceContext implements ServiceConnection { final long ident = Binder.clearCallingIdentity(); try { synchronized (mLock) { assertCallerLocked(cb); if (!assertCallerLocked(cb)) { // Return true instead of false here so we don't just kick the // Exception-throwing-can down the road to JobParameters.completeWork >:( return true; } return mRunningJob.completeWorkLocked(workId); } } finally { Loading Loading @@ -554,18 +570,34 @@ public final class JobServiceContext implements ServiceConnection { return true; } private void assertCallerLocked(JobCallback cb) { /** * Will throw a {@link SecurityException} if the callback is not for the currently running job, * but may decide not to throw an exception if the call from the previous job appears to be an * accident. * * @return true if the callback is for the current job, false otherwise */ private boolean assertCallerLocked(JobCallback cb) { if (!verifyCallerLocked(cb)) { final long nowElapsed = sElapsedRealtimeClock.millis(); if (!mPreviousJobHadSuccessfulFinish && (nowElapsed - mLastUnsuccessfulFinishElapsed) < 15_000L) { // Don't punish apps for race conditions return false; } // It's been long enough that the app should really not be calling into JS for the // stopped job. StringBuilder sb = new StringBuilder(128); sb.append("Caller no longer running"); if (cb.mStoppedReason != null) { sb.append(", last stopped "); TimeUtils.formatDuration(sElapsedRealtimeClock.millis() - cb.mStoppedTime, sb); TimeUtils.formatDuration(nowElapsed - cb.mStoppedTime, sb); sb.append(" because: "); sb.append(cb.mStoppedReason); } throw new SecurityException(sb.toString()); } return true; } /** Loading Loading @@ -911,6 +943,11 @@ public final class JobServiceContext implements ServiceConnection { applyStoppedReasonLocked(reason); completedJob = mRunningJob; final int internalStopReason = mParams.getInternalStopReasonCode(); mPreviousJobHadSuccessfulFinish = (internalStopReason == JobParameters.INTERNAL_STOP_REASON_SUCCESSFUL_FINISH); if (!mPreviousJobHadSuccessfulFinish) { mLastUnsuccessfulFinishElapsed = sElapsedRealtimeClock.millis(); } mJobPackageTracker.noteInactive(completedJob, internalStopReason, reason); FrameworkStatsLog.write_non_chained(FrameworkStatsLog.SCHEDULED_JOB_STATE_CHANGED, completedJob.getSourceUid(), null, completedJob.getBatteryName(), Loading core/java/android/os/Trace.java +0 −2 Original line number Diff line number Diff line Loading @@ -102,8 +102,6 @@ public final class Trace { /** @hide */ public static final long TRACE_TAG_RRO = 1L << 26; /** @hide */ public static final long TRACE_TAG_SYSPROP = 1L << 27; /** @hide */ public static final long TRACE_TAG_APEX_MANAGER = 1L << 18; private static final long TRACE_TAG_NOT_READY = 1L << 63; Loading core/java/android/service/wallpaper/WallpaperService.java +3 −0 Original line number Diff line number Diff line Loading @@ -1033,6 +1033,9 @@ public abstract class WallpaperService extends Service { .build(); updateSurfaceDimming(); } // Propagate transform hint from WM so we can use the right hint for the // first frame. mBbqSurfaceControl.setTransformHint(mSurfaceControl.getTransformHint()); Surface blastSurface = getOrCreateBLASTSurface(mSurfaceSize.x, mSurfaceSize.y, mFormat); // If blastSurface == null that means it hasn't changed since the last Loading Loading
apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java +2 −1 Original line number Diff line number Diff line Loading @@ -2052,10 +2052,11 @@ public class AlarmManagerService extends SystemService { + " -- package not allowed to start"); return; } final int callerProcState = mActivityManagerInternal.getUidProcessState(callingUid); removeLocked(operation, directReceiver, REMOVE_REASON_UNDEFINED); incrementAlarmCount(a.uid); setImplLocked(a); MetricsHelper.pushAlarmScheduled(a); MetricsHelper.pushAlarmScheduled(a, callerProcState); } /** Loading
apex/jobscheduler/service/java/com/android/server/alarm/MetricsHelper.java +4 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static com.android.internal.util.FrameworkStatsLog.ALARM_SCHEDULED__EXACT import static com.android.internal.util.FrameworkStatsLog.ALARM_SCHEDULED__EXACT_ALARM_ALLOWED_REASON__PERMISSION; import static com.android.server.alarm.AlarmManagerService.INDEFINITE_DELAY; import android.app.ActivityManager; import android.app.AlarmManager; import android.app.StatsManager; import android.content.Context; Loading Loading @@ -93,7 +94,7 @@ class MetricsHelper { } } static void pushAlarmScheduled(Alarm a) { static void pushAlarmScheduled(Alarm a, int callerProcState) { FrameworkStatsLog.write( FrameworkStatsLog.ALARM_SCHEDULED, a.uid, Loading @@ -103,7 +104,8 @@ class MetricsHelper { a.alarmClock != null, a.repeatInterval != 0, reasonToStatsReason(a.mExactAllowReason), AlarmManagerService.isRtc(a.type)); AlarmManagerService.isRtc(a.type), ActivityManager.processStateAmToProto(callerProcState)); } static void pushAlarmBatchDelivered(int numAlarms, int wakeups) { Loading
apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +41 −4 Original line number Diff line number Diff line Loading @@ -116,6 +116,16 @@ public final class JobServiceContext implements ServiceConnection { @VisibleForTesting int mVerb; private boolean mCancelled; /** * True if the previous job on this context successfully finished (ie. called jobFinished or * dequeueWork with no work left). */ private boolean mPreviousJobHadSuccessfulFinish; /** * The last time a job on this context didn't finish successfully, in the elapsed realtime * timebase. */ private long mLastUnsuccessfulFinishElapsed; /** * All the information maintained about the job currently being executed. Loading Loading @@ -439,7 +449,9 @@ public final class JobServiceContext implements ServiceConnection { final long ident = Binder.clearCallingIdentity(); try { synchronized (mLock) { assertCallerLocked(cb); if (!assertCallerLocked(cb)) { return null; } if (mVerb == VERB_STOPPING || mVerb == VERB_FINISHED) { // This job is either all done, or on its way out. Either way, it // should not dispatch any more work. We will pick up any remaining Loading @@ -465,7 +477,11 @@ public final class JobServiceContext implements ServiceConnection { final long ident = Binder.clearCallingIdentity(); try { synchronized (mLock) { assertCallerLocked(cb); if (!assertCallerLocked(cb)) { // Return true instead of false here so we don't just kick the // Exception-throwing-can down the road to JobParameters.completeWork >:( return true; } return mRunningJob.completeWorkLocked(workId); } } finally { Loading Loading @@ -554,18 +570,34 @@ public final class JobServiceContext implements ServiceConnection { return true; } private void assertCallerLocked(JobCallback cb) { /** * Will throw a {@link SecurityException} if the callback is not for the currently running job, * but may decide not to throw an exception if the call from the previous job appears to be an * accident. * * @return true if the callback is for the current job, false otherwise */ private boolean assertCallerLocked(JobCallback cb) { if (!verifyCallerLocked(cb)) { final long nowElapsed = sElapsedRealtimeClock.millis(); if (!mPreviousJobHadSuccessfulFinish && (nowElapsed - mLastUnsuccessfulFinishElapsed) < 15_000L) { // Don't punish apps for race conditions return false; } // It's been long enough that the app should really not be calling into JS for the // stopped job. StringBuilder sb = new StringBuilder(128); sb.append("Caller no longer running"); if (cb.mStoppedReason != null) { sb.append(", last stopped "); TimeUtils.formatDuration(sElapsedRealtimeClock.millis() - cb.mStoppedTime, sb); TimeUtils.formatDuration(nowElapsed - cb.mStoppedTime, sb); sb.append(" because: "); sb.append(cb.mStoppedReason); } throw new SecurityException(sb.toString()); } return true; } /** Loading Loading @@ -911,6 +943,11 @@ public final class JobServiceContext implements ServiceConnection { applyStoppedReasonLocked(reason); completedJob = mRunningJob; final int internalStopReason = mParams.getInternalStopReasonCode(); mPreviousJobHadSuccessfulFinish = (internalStopReason == JobParameters.INTERNAL_STOP_REASON_SUCCESSFUL_FINISH); if (!mPreviousJobHadSuccessfulFinish) { mLastUnsuccessfulFinishElapsed = sElapsedRealtimeClock.millis(); } mJobPackageTracker.noteInactive(completedJob, internalStopReason, reason); FrameworkStatsLog.write_non_chained(FrameworkStatsLog.SCHEDULED_JOB_STATE_CHANGED, completedJob.getSourceUid(), null, completedJob.getBatteryName(), Loading
core/java/android/os/Trace.java +0 −2 Original line number Diff line number Diff line Loading @@ -102,8 +102,6 @@ public final class Trace { /** @hide */ public static final long TRACE_TAG_RRO = 1L << 26; /** @hide */ public static final long TRACE_TAG_SYSPROP = 1L << 27; /** @hide */ public static final long TRACE_TAG_APEX_MANAGER = 1L << 18; private static final long TRACE_TAG_NOT_READY = 1L << 63; Loading
core/java/android/service/wallpaper/WallpaperService.java +3 −0 Original line number Diff line number Diff line Loading @@ -1033,6 +1033,9 @@ public abstract class WallpaperService extends Service { .build(); updateSurfaceDimming(); } // Propagate transform hint from WM so we can use the right hint for the // first frame. mBbqSurfaceControl.setTransformHint(mSurfaceControl.getTransformHint()); Surface blastSurface = getOrCreateBLASTSurface(mSurfaceSize.x, mSurfaceSize.y, mFormat); // If blastSurface == null that means it hasn't changed since the last Loading