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

Commit 7b8612d0 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android Git Automerger
Browse files

am 8c48834b: am 0d889cde: Merge "CountryDetector no longer requires location...

am 8c48834b: am 0d889cde: Merge "CountryDetector no longer requires location permissions." into mnc-dev

* commit '8c48834b':
  CountryDetector no longer requires location permissions.
parents 47d691ba 8c48834b
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -44,8 +44,6 @@ import android.util.Log;
 * You do not instantiate this class directly; instead, retrieve it through
 * You do not instantiate this class directly; instead, retrieve it through
 * {@link android.content.Context#getSystemService
 * {@link android.content.Context#getSystemService
 * Context.getSystemService(Context.COUNTRY_DETECTOR)}.
 * Context.getSystemService(Context.COUNTRY_DETECTOR)}.
 * <p>
 * Both ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permissions are needed.
 *
 *
 * @hide
 * @hide
 */
 */
+28 −12
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import android.location.Geocoder;
import android.location.Location;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationManager;
import android.os.Binder;
import android.os.Bundle;
import android.os.Bundle;
import android.util.Slog;
import android.util.Slog;


@@ -95,20 +96,32 @@ public class LocationBasedCountryDetector extends CountryDetectorBase {
     * Register a listener with a provider name
     * Register a listener with a provider name
     */
     */
    protected void registerListener(String provider, LocationListener listener) {
    protected void registerListener(String provider, LocationListener listener) {
        final long bid = Binder.clearCallingIdentity();
        try {
            mLocationManager.requestLocationUpdates(provider, 0, 0, listener);
            mLocationManager.requestLocationUpdates(provider, 0, 0, listener);
        } finally {
            Binder.restoreCallingIdentity(bid);
        }
    }
    }


    /**
    /**
     * Unregister an already registered listener
     * Unregister an already registered listener
     */
     */
    protected void unregisterListener(LocationListener listener) {
    protected void unregisterListener(LocationListener listener) {
        final long bid = Binder.clearCallingIdentity();
        try {
            mLocationManager.removeUpdates(listener);
            mLocationManager.removeUpdates(listener);
        } finally {
            Binder.restoreCallingIdentity(bid);
        }
    }
    }


    /**
    /**
     * @return the last known location from all providers
     * @return the last known location from all providers
     */
     */
    protected Location getLastKnownLocation() {
    protected Location getLastKnownLocation() {
        final long bid = Binder.clearCallingIdentity();
        try {
            List<String> providers = mLocationManager.getAllProviders();
            List<String> providers = mLocationManager.getAllProviders();
            Location bestLocation = null;
            Location bestLocation = null;
            for (String provider : providers) {
            for (String provider : providers) {
@@ -122,6 +135,9 @@ public class LocationBasedCountryDetector extends CountryDetectorBase {
                }
                }
            }
            }
            return bestLocation;
            return bestLocation;
        } finally {
            Binder.restoreCallingIdentity(bid);
        }
    }
    }


    /**
    /**