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

Commit 20405655 authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Crash if lock isn't held when it should be. This will help

track down any errors.

Bug: 157682468
Test: n/a
Change-Id: Ie4ecc6d43de982abe145681116dc5b3956fceb82
parent 27630cbb
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -64,6 +64,7 @@ import android.location.LocationProvider;
import android.location.LocationRequest;
import android.location.LocationRequest;
import android.location.LocationTime;
import android.location.LocationTime;
import android.os.Binder;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.Handler;
@@ -1666,6 +1667,9 @@ public class LocationManagerService extends ILocationManager.Stub {
         * Note: must be constructed with lock held.
         * Note: must be constructed with lock held.
         */
         */
        private UpdateRecord(String provider, LocationRequest request, Receiver receiver) {
        private UpdateRecord(String provider, LocationRequest request, Receiver receiver) {
            if (Build.IS_DEBUGGABLE) {
                Preconditions.checkState(Thread.holdsLock(mLock));
            }
            mExpirationRealtimeMs = request.getExpirationRealtimeMs(SystemClock.elapsedRealtime());
            mExpirationRealtimeMs = request.getExpirationRealtimeMs(SystemClock.elapsedRealtime());
            mProvider = provider;
            mProvider = provider;
            mRealRequest = request;
            mRealRequest = request;
@@ -1703,6 +1707,10 @@ public class LocationManagerService extends ILocationManager.Stub {
         * Method to be called when a record will no longer be used.
         * Method to be called when a record will no longer be used.
         */
         */
        private void disposeLocked(boolean removeReceiver) {
        private void disposeLocked(boolean removeReceiver) {
            if (Build.IS_DEBUGGABLE) {
                Preconditions.checkState(Thread.holdsLock(mLock));
            }

            CallerIdentity identity = mReceiver.mCallerIdentity;
            CallerIdentity identity = mReceiver.mCallerIdentity;
            mRequestStatistics.stopRequesting(identity.packageName, identity.featureId, mProvider);
            mRequestStatistics.stopRequesting(identity.packageName, identity.featureId, mProvider);