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

Commit 5bf0a8f9 authored by Rafael Higuera Silva's avatar Rafael Higuera Silva Committed by Android (Google) Code Review
Browse files

Merge "Fix include location data to check for coarse location first."

parents 8efdb703 22ca59c4
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -1036,12 +1036,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                callingFeatureId, callback, eventList, notifyNow, subId);
    }

    private void listen(String callingPackage, @Nullable String callingFeatureId,
            IPhoneStateListener callback, Set<Integer> events, boolean notifyNow, int subId) {
        listen(false, false, callingPackage,
                callingFeatureId, callback, events, notifyNow, subId);
    }

    private void listen(boolean renounceFineLocationAccess,
            boolean renounceCoarseLocationAccess, String callingPackage,
            @Nullable String callingFeatureId, IPhoneStateListener callback,
+15 −19
Original line number Diff line number Diff line
@@ -12172,15 +12172,7 @@ public class TelephonyManager {
    })
    @RequiresFeature(PackageManager.FEATURE_TELEPHONY_RADIO_ACCESS)
    public @Nullable ServiceState getServiceState() {
        if (getRenouncedPermissions().contains(Manifest.permission.ACCESS_FINE_LOCATION))  {
            if (getRenouncedPermissions().contains(Manifest.permission.ACCESS_COARSE_LOCATION)) {
                return getServiceState(INCLUDE_LOCATION_DATA_NONE);
            } else {
                return getServiceState(INCLUDE_LOCATION_DATA_COARSE);
            }
        }
        return getServiceState(INCLUDE_LOCATION_DATA_FINE);
        return getServiceState(getLocationData());
    }
    /**
@@ -16171,19 +16163,23 @@ public class TelephonyManager {
     */
    public void registerTelephonyCallback(@NonNull @CallbackExecutor Executor executor,
            @NonNull TelephonyCallback callback) {
        if (getRenouncedPermissions().contains(Manifest.permission.ACCESS_FINE_LOCATION))  {
            if (getRenouncedPermissions().contains(Manifest.permission.ACCESS_COARSE_LOCATION)) {
                registerTelephonyCallback(INCLUDE_LOCATION_DATA_NONE, executor, callback);
                return;
        registerTelephonyCallback(getLocationData(), executor, callback);
    }
    private int getLocationData() {
        boolean renounceCoarseLocation =
                getRenouncedPermissions().contains(Manifest.permission.ACCESS_COARSE_LOCATION);
        boolean renounceFineLocation =
                getRenouncedPermissions().contains(Manifest.permission.ACCESS_FINE_LOCATION);
        if (renounceCoarseLocation) {
            return INCLUDE_LOCATION_DATA_NONE;
        } else if (renounceFineLocation) {
            return INCLUDE_LOCATION_DATA_COARSE;
        } else {
                registerTelephonyCallback(INCLUDE_LOCATION_DATA_COARSE, executor, callback);
                return;
            return INCLUDE_LOCATION_DATA_FINE;
        }
    }
        registerTelephonyCallback(INCLUDE_LOCATION_DATA_FINE, executor, callback);
    }
    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = {"INCLUDE_LOCATION_DATA_"}, value = {