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

Commit 8486fc70 authored by Wei Wang's avatar Wei Wang
Browse files

Fix an issue that appOps was called before location delivery check.

noteOp notes a location delivery to appOps and will cause an icon to
show up. It should only be called when LocationManagerService is ready
to deliver a location to the client.

Bug: 122559674
Test: Manual
Change-Id: I5c13b35e492638186ba22ba4e6ba8abcd21027d6
parent 391c30c1
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -3210,18 +3210,6 @@ public class LocationManagerService extends ILocationManager.Stub {
                continue;
            }

            if (!reportLocationAccessNoThrow(
                    receiver.mCallerIdentity.mPid,
                    receiver.mCallerIdentity.mUid,
                    receiver.mCallerIdentity.mPackageName,
                    receiver.mAllowedResolutionLevel)) {
                if (D) {
                    Log.d(TAG, "skipping loc update for no op app: " +
                            receiver.mCallerIdentity.mPackageName);
                }
                continue;
            }

            Location notifyLocation;
            if (receiver.mAllowedResolutionLevel < RESOLUTION_LEVEL_FINE) {
                notifyLocation = coarseLocation;  // use coarse location
@@ -3238,6 +3226,20 @@ public class LocationManagerService extends ILocationManager.Stub {
                    } else {
                        lastLoc.set(notifyLocation);
                    }
                    // Report location access before delivering location to the client. This will
                    // note location delivery to appOps, so it should be called only when a
                    // location is really being delivered to the client.
                    if (!reportLocationAccessNoThrow(
                            receiver.mCallerIdentity.mPid,
                            receiver.mCallerIdentity.mUid,
                            receiver.mCallerIdentity.mPackageName,
                            receiver.mAllowedResolutionLevel)) {
                        if (D) {
                            Log.d(TAG, "skipping loc update for no op app: "
                                    + receiver.mCallerIdentity.mPackageName);
                        }
                        continue;
                    }
                    if (!receiver.callLocationChangedLocked(notifyLocation)) {
                        Slog.w(TAG, "RemoteException calling onLocationChanged on "
                                + receiver);