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

Commit 11670004 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Fix alarm wakelock not being released."

parents 32e45ef3 6525ba86
Loading
Loading
Loading
Loading
+10 −16
Original line number Diff line number Diff line
@@ -439,8 +439,10 @@ class AlarmManagerService extends IAlarmManager.Stub {
        final Pair<String, ComponentName> mTarget;
        final BroadcastStats mBroadcastStats;
        final FilterStats mFilterStats;
        final int mUid;

        InFlight(AlarmManagerService service, PendingIntent pendingIntent, WorkSource workSource) {
        InFlight(AlarmManagerService service, PendingIntent pendingIntent,
                      WorkSource workSource, int uid) {
            mPendingIntent = pendingIntent;
            mWorkSource = workSource;
            Intent intent = pendingIntent.getIntent();
@@ -454,6 +456,7 @@ class AlarmManagerService extends IAlarmManager.Stub {
                mBroadcastStats.filterStats.put(mTarget, fs);
            }
            mFilterStats = fs;
            mUid = uid;
        }
    }

@@ -1350,7 +1353,7 @@ class AlarmManagerService extends IAlarmManager.Stub {
                                mWakeLock.acquire();
                            }
                            final InFlight inflight = new InFlight(AlarmManagerService.this,
                                    alarm.operation, alarm.workSource);
                                    alarm.operation, alarm.workSource, alarm.uid);
                            mInFlight.add(inflight);
                            mBroadcastRefCount++;
                            mTriggeredUids.add(new Integer(alarm.uid));
@@ -1604,9 +1607,11 @@ class AlarmManagerService extends IAlarmManager.Stub {
        public void onSendFinished(PendingIntent pi, Intent intent, int resultCode,
                String resultData, Bundle resultExtras) {
            synchronized (mLock) {
                int uid = 0;
                InFlight inflight = null;
                for (int i=0; i<mInFlight.size(); i++) {
                    if (mInFlight.get(i).mPendingIntent == pi) {
                        uid = mInFlight.get(i).mUid;
                        inflight = mInFlight.remove(i);
                        break;
                    }
@@ -1628,18 +1633,7 @@ class AlarmManagerService extends IAlarmManager.Stub {
                } else {
                    mLog.w("No in-flight alarm for " + pi + " " + intent);
                }
                String pkg = null;
                int uid = 0;
                try {
                    pkg = pi.getTargetPackage();
                    final PackageManager pm = mContext.getPackageManager();
                    ApplicationInfo appInfo =
                        pm.getApplicationInfo(pkg, PackageManager.GET_META_DATA);
                    uid = appInfo.uid;
                mTriggeredUids.remove(new Integer(uid));
                } catch (PackageManager.NameNotFoundException ex) {
                    Slog.w(TAG, "onSendFinished NameNotFoundException Pkg = " + pkg);
                }
                if(mBlockedUids.contains(new Integer(uid))) {
                    mBlockedUids.remove(new Integer(uid));
                } else {
+3 −1
Original line number Diff line number Diff line
@@ -835,11 +835,13 @@ public final class PowerManagerService extends IPowerManager.Stub
            if (DEBUG_SPEW) Slog.v(TAG, "updateBlockedUids: uid = "+uid +"isBlocked = "+isBlocked);
            if(isBlocked) {
                mBlockedUids.add(new Integer(uid));
                for (WakeLock wl : mWakeLocks) {
                for (int index = 0; index < mWakeLocks.size(); index++) {
                    WakeLock wl = mWakeLocks.get(index);
                    if(wl != null) {
                        // release the wakelock for the blocked uid
                        if (wl.mOwnerUid == uid || checkWorkSourceObjectId(uid, wl)) {
                            releaseWakeLockInternal(wl.mLock, wl.mFlags);
                            index--;
                            if (DEBUG_SPEW) Slog.v(TAG, "Internally releasing it");
                        }
                    }