summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Christopher Tate <ctate@google.com> 2017-08-19 00:15:33 +0000
committer android-build-merger <android-build-merger@google.com> 2017-08-19 00:15:33 +0000
commit8a04ed4c46e3e339cf94592c72dc49ab866bee6b (patch)
tree3793052954d91c9e602771068a0fbdf89a365033
parent4a0e643ebe6c3c0a67b5a7c7fec321c8aeb4931d (diff)
parent39a7fe7939ce53fdd94b8282cbb8933c9e1e6d6d (diff)
Merge "Improve alarm in-flight diagnostics" into oc-mr1-dev
am: 39a7fe7939 Change-Id: Iaeddac03bcf98c1d714c96b54344d8cf874682d2
-rw-r--r--services/core/java/com/android/server/AlarmManagerService.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index be4d1064ec9c..bfa10f28b431 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -850,6 +850,7 @@ class AlarmManagerService extends SystemService {
static final class InFlight {
final PendingIntent mPendingIntent;
+ final long mWhenElapsed;
final IBinder mListener;
final WorkSource mWorkSource;
final int mUid;
@@ -862,6 +863,7 @@ class AlarmManagerService extends SystemService {
WorkSource workSource, int uid, String alarmPkg, int alarmType, String tag,
long nowELAPSED) {
mPendingIntent = pendingIntent;
+ mWhenElapsed = nowELAPSED;
mListener = listener != null ? listener.asBinder() : null;
mWorkSource = workSource;
mUid = uid;
@@ -883,6 +885,7 @@ class AlarmManagerService extends SystemService {
public String toString() {
return "InFlight{"
+ "pendingIntent=" + mPendingIntent
+ + ", when=" + mWhenElapsed
+ ", workSource=" + mWorkSource
+ ", uid=" + mUid
+ ", tag=" + mTag
@@ -1567,8 +1570,10 @@ class AlarmManagerService extends SystemService {
pw.println();
pw.print(" Broadcast ref count: "); pw.println(mBroadcastRefCount);
- pw.print(" PendingIntent send/finish count: "); pw.println(mSendCount);
- pw.print(" Listener send/complete count: "); pw.println(mListenerCount);
+ pw.print(" PendingIntent send count: "); pw.println(mSendCount);
+ pw.print(" PendingIntent finish count: "); pw.println(mSendFinishCount);
+ pw.print(" Listener send count: "); pw.println(mListenerCount);
+ pw.print(" Listener finish count: "); pw.println(mListenerFinishCount);
pw.println();
if (mInFlight.size() > 0) {
@@ -2949,13 +2954,17 @@ class AlarmManagerService extends SystemService {
@GuardedBy("mLock")
private int mSendCount = 0;
@GuardedBy("mLock")
+ private int mSendFinishCount = 0;
+ @GuardedBy("mLock")
private int mListenerCount = 0;
+ @GuardedBy("mLock")
+ private int mListenerFinishCount = 0;
class DeliveryTracker extends IAlarmCompleteListener.Stub implements PendingIntent.OnFinished {
private InFlight removeLocked(PendingIntent pi, Intent intent) {
for (int i = 0; i < mInFlight.size(); i++) {
- if (mInFlight.get(i).mPendingIntent == pi) {
+ if (mInFlight.get(i).mPendingIntent.equals(pi)) {
return mInFlight.remove(i);
}
}
@@ -3054,7 +3063,7 @@ class AlarmManagerService extends SystemService {
Slog.i(TAG, "alarmComplete() from " + who);
}
updateTrackingLocked(inflight);
- mListenerCount--;
+ mListenerFinishCount++;
} else {
// Delivery timed out, and the timeout handling already took care of
// updating our tracking here, so we needn't do anything further.
@@ -3075,7 +3084,7 @@ class AlarmManagerService extends SystemService {
public void onSendFinished(PendingIntent pi, Intent intent, int resultCode,
String resultData, Bundle resultExtras) {
synchronized (mLock) {
- mSendCount--;
+ mSendFinishCount++;
updateTrackingLocked(removeLocked(pi, intent));
}
}
@@ -3092,7 +3101,7 @@ class AlarmManagerService extends SystemService {
Slog.i(TAG, "Alarm listener " + who + " timed out in delivery");
}
updateTrackingLocked(inflight);
- mListenerCount--;
+ mListenerFinishCount++;
} else {
if (DEBUG_LISTENER_CALLBACK) {
Slog.i(TAG, "Spurious timeout of listener " + who);
@@ -3125,7 +3134,7 @@ class AlarmManagerService extends SystemService {
// 'finished' callback won't be invoked. We also don't need
// to do any wakelock or stats tracking, so we have nothing
// left to do here but go on to the next thing.
- mSendCount--;
+ mSendFinishCount++;
return;
}
} else {
@@ -3150,6 +3159,7 @@ class AlarmManagerService extends SystemService {
// alarm was not possible, so we have no wakelock or timeout or
// stats management to do. It threw before we posted the delayed
// timeout message, so we're done here.
+ mListenerFinishCount++;
return;
}
}