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

Commit 05b801bd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix bug in checking getLastLocation identities" into tm-dev

parents 9667c081 d7ca4765
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -1127,7 +1127,7 @@ public class LocationManagerService extends ILocationManager.Stub implements
            if (provider != null && !provider.equals(manager.getName())) {
                continue;
            }
            CallerIdentity identity = manager.getIdentity();
            CallerIdentity identity = manager.getProviderIdentity();
            if (identity == null) {
                continue;
            }
@@ -1149,7 +1149,7 @@ public class LocationManagerService extends ILocationManager.Stub implements
            return Collections.emptyList();
        }

        CallerIdentity identity = manager.getIdentity();
        CallerIdentity identity = manager.getProviderIdentity();
        if (identity == null) {
            return Collections.emptyList();
        }
@@ -1536,7 +1536,7 @@ public class LocationManagerService extends ILocationManager.Stub implements
        if (!enabled) {
            PackageTagsList.Builder builder = new PackageTagsList.Builder();
            for (LocationProviderManager manager : mProviderManagers) {
                CallerIdentity identity = manager.getIdentity();
                CallerIdentity identity = manager.getProviderIdentity();
                if (identity != null) {
                    builder.add(identity.getPackageName(), identity.getAttributionTag());
                }
@@ -1624,7 +1624,7 @@ public class LocationManagerService extends ILocationManager.Stub implements
                if (provider != null && !provider.equals(manager.getName())) {
                    continue;
                }
                if (identity.equals(manager.getIdentity())) {
                if (identity.equals(manager.getProviderIdentity())) {
                    return true;
                }
            }
@@ -1665,7 +1665,7 @@ public class LocationManagerService extends ILocationManager.Stub implements
                if (listener != null) {
                    ArraySet<Integer> uids = new ArraySet<>(mProviderManagers.size());
                    for (LocationProviderManager manager : mProviderManagers) {
                        CallerIdentity identity = manager.getIdentity();
                        CallerIdentity identity = manager.getProviderIdentity();
                        if (identity != null) {
                            uids.add(identity.getUid());
                        }
+7 −6
Original line number Diff line number Diff line
@@ -1468,7 +1468,7 @@ public class LocationProviderManager extends
        return mProvider.getState();
    }

    public @Nullable CallerIdentity getIdentity() {
    public @Nullable CallerIdentity getProviderIdentity() {
        return mProvider.getState().identity;
    }

@@ -1607,7 +1607,7 @@ public class LocationProviderManager extends

    public @Nullable Location getLastLocation(LastLocationRequest request,
            CallerIdentity identity, @PermissionLevel int permissionLevel) {
        request = calculateLastLocationRequest(request);
        request = calculateLastLocationRequest(request, identity);

        if (!isActive(request.isBypass(), identity)) {
            return null;
@@ -1636,15 +1636,16 @@ public class LocationProviderManager extends
        return location;
    }

    private LastLocationRequest calculateLastLocationRequest(LastLocationRequest baseRequest) {
    private LastLocationRequest calculateLastLocationRequest(LastLocationRequest baseRequest,
            CallerIdentity identity) {
        LastLocationRequest.Builder builder = new LastLocationRequest.Builder(baseRequest);

        boolean locationSettingsIgnored = baseRequest.isLocationSettingsIgnored();
        if (locationSettingsIgnored) {
            // if we are not currently allowed use location settings ignored, disable it
            if (!mSettingsHelper.getIgnoreSettingsAllowlist().contains(
                    getIdentity().getPackageName(), getIdentity().getAttributionTag())
                    && !mLocationManagerInternal.isProvider(null, getIdentity())) {
                    identity.getPackageName(), identity.getAttributionTag())
                    && !mLocationManagerInternal.isProvider(null, identity)) {
                locationSettingsIgnored = false;
            }

@@ -1658,7 +1659,7 @@ public class LocationProviderManager extends
                Log.e(TAG, "adas gnss bypass request received in non-gps provider");
                adasGnssBypass = false;
            } else if (!mLocationSettings.getUserSettings(
                    getIdentity().getUserId()).isAdasGnssLocationEnabled()) {
                    identity.getUserId()).isAdasGnssLocationEnabled()) {
                adasGnssBypass = false;
            }

+2 −2
Original line number Diff line number Diff line
@@ -213,7 +213,7 @@ public class LocationProviderManagerTest {
    public void testProperties() {
        assertThat(mManager.getName()).isEqualTo(NAME);
        assertThat(mManager.getProperties()).isEqualTo(PROPERTIES);
        assertThat(mManager.getIdentity()).isEqualTo(IDENTITY);
        assertThat(mManager.getProviderIdentity()).isEqualTo(IDENTITY);
        assertThat(mManager.hasProvider()).isTrue();

        ProviderProperties newProperties = new ProviderProperties.Builder()
@@ -230,7 +230,7 @@ public class LocationProviderManagerTest {
        CallerIdentity newIdentity = CallerIdentity.forTest(OTHER_USER, 1, "otherpackage",
                "otherattribution");
        mProvider.setIdentity(newIdentity);
        assertThat(mManager.getIdentity()).isEqualTo(newIdentity);
        assertThat(mManager.getProviderIdentity()).isEqualTo(newIdentity);

        mManager.setRealProvider(null);
        assertThat(mManager.hasProvider()).isFalse();