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

Commit 484e0054 authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge "Merge "Light alarm activity tracing" into oc-mr1-dev am: e5fd75f3"...

Merge "Merge "Light alarm activity tracing" into oc-mr1-dev am: e5fd75f3" into oc-mr1-dev-plus-aosp
parents 45a10750 caca43b0
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PermissionInfo;
@@ -85,6 +84,7 @@ import static android.app.AlarmManager.RTC;
import static android.app.AlarmManager.ELAPSED_REALTIME_WAKEUP;
import static android.app.AlarmManager.ELAPSED_REALTIME;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.LocalLog;

@@ -1567,6 +1567,8 @@ 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.println();

            if (mInFlight.size() > 0) {
@@ -2939,7 +2941,18 @@ class AlarmManagerService extends SystemService {
        return bs;
    }

    /**
     * Canonical count of (operation.send() - onSendFinished()) and
     * listener send/complete/timeout invocations.
     * Guarded by the usual lock.
     */
    @GuardedBy("mLock")
    private int mSendCount = 0;
    @GuardedBy("mLock")
    private int mListenerCount = 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) {
@@ -3026,7 +3039,7 @@ class AlarmManagerService extends SystemService {
        @Override
        public void alarmComplete(IBinder who) {
            if (who == null) {
                Slog.w(TAG, "Invalid alarmComplete: uid=" + Binder.getCallingUid()
                mLog.w("Invalid alarmComplete: uid=" + Binder.getCallingUid()
                        + " pid=" + Binder.getCallingPid());
                return;
            }
@@ -3041,6 +3054,7 @@ class AlarmManagerService extends SystemService {
                            Slog.i(TAG, "alarmComplete() from " + who);
                        }
                        updateTrackingLocked(inflight);
                        mListenerCount--;
                    } else {
                        // Delivery timed out, and the timeout handling already took care of
                        // updating our tracking here, so we needn't do anything further.
@@ -3061,6 +3075,7 @@ class AlarmManagerService extends SystemService {
        public void onSendFinished(PendingIntent pi, Intent intent, int resultCode,
                String resultData, Bundle resultExtras) {
            synchronized (mLock) {
                mSendCount--;
                updateTrackingLocked(removeLocked(pi, intent));
            }
        }
@@ -3077,10 +3092,12 @@ class AlarmManagerService extends SystemService {
                        Slog.i(TAG, "Alarm listener " + who + " timed out in delivery");
                    }
                    updateTrackingLocked(inflight);
                    mListenerCount--;
                } else {
                    if (DEBUG_LISTENER_CALLBACK) {
                        Slog.i(TAG, "Spurious timeout of listener " + who);
                    }
                    mLog.w("Spurious timeout of listener " + who);
                }
            }
        }
@@ -3091,6 +3108,7 @@ class AlarmManagerService extends SystemService {
        public void deliverLocked(Alarm alarm, long nowELAPSED, boolean allowWhileIdle) {
            if (alarm.operation != null) {
                // PendingIntent alarm
                mSendCount++;
                try {
                    alarm.operation.send(getContext(), 0,
                            mBackgroundIntent.putExtra(
@@ -3107,10 +3125,12 @@ 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--;
                    return;
                }
            } else {
                // Direct listener callback alarm
                mListenerCount++;
                try {
                    if (DEBUG_LISTENER_CALLBACK) {
                        Slog.v(TAG, "Alarm to uid=" + alarm.uid