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

Commit 8b95b820 authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Fix noteOp ordering

Ensure noteOp() is only invoked if a non-null location will actually be
delivered.

Bug: 243736675
Test: none
Change-Id: Ibe808f09bf28145af83ae7599337b8d50e37d8d8
parent 4aa3999f
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -1734,12 +1734,6 @@ public class LocationProviderManager extends
            return null;
        }

        // lastly - note app ops
        if (!mAppOpsHelper.noteOpNoThrow(LocationPermissions.asAppOp(permissionLevel),
                identity)) {
            return null;
        }

        Location location = getPermittedLocation(
                getLastLocationUnsafe(
                        identity.getUserId(),
@@ -1748,11 +1742,19 @@ public class LocationProviderManager extends
                        Long.MAX_VALUE),
                permissionLevel);

        if (location != null && identity.getPid() == Process.myPid()) {
        if (location != null) {
            // lastly - note app ops
            if (!mAppOpsHelper.noteOpNoThrow(LocationPermissions.asAppOp(permissionLevel),
                    identity)) {
                return null;
            }

            // if delivering to the same process, make a copy of the location first (since
            // location is mutable)
            if (identity.getPid() == Process.myPid()) {
                location = new Location(location);
            }
        }

        return location;
    }