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

Commit ecdcbcf1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Refactor ServiceWatcher" into sc-dev am: 76f3adb4

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13743634

Change-Id: Ie5978dd29e47cdb7d2e9fdf9f7a99e344a8f8a24
parents 5e9efcd0 76f3adb4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import android.location.provider.ProviderProperties;
 * @hide
 */
interface ILocationProviderManager {
    void onInitialize(boolean allowed, in ProviderProperties properties, @nullable String packageName, @nullable String attributionTag);
    void onInitialize(boolean allowed, in ProviderProperties properties, @nullable String attributionTag);
    void onSetAllowed(boolean allowed);
    void onSetProperties(in ProviderProperties properties);

+1 −3
Original line number Diff line number Diff line
@@ -96,7 +96,6 @@ public abstract class LocationProviderBase {
            "com.android.location.service.FusedLocationProvider";

    private final String mTag;
    private final @Nullable String mPackageName;
    private final @Nullable String mAttributionTag;
    private final IBinder mBinder;

@@ -108,7 +107,6 @@ public abstract class LocationProviderBase {
    public LocationProviderBase(@NonNull Context context, @NonNull String tag,
            @NonNull ProviderProperties properties) {
        mTag = tag;
        mPackageName = context.getPackageName();
        mAttributionTag = context.getAttributionTag();
        mBinder = new Service();

@@ -305,7 +303,7 @@ public abstract class LocationProviderBase {
        public void setLocationProviderManager(ILocationProviderManager manager) {
            synchronized (mBinder) {
                try {
                    manager.onInitialize(mAllowed, mProperties, mPackageName, mAttributionTag);
                    manager.onInitialize(mAllowed, mProperties, mAttributionTag);
                } catch (RemoteException e) {
                    throw e.rethrowFromSystemServer();
                } catch (RuntimeException e) {
+1 −3
Original line number Diff line number Diff line
@@ -96,7 +96,6 @@ public abstract class LocationProviderBase {
    public static final String FUSED_PROVIDER = LocationManager.FUSED_PROVIDER;

    final String mTag;
    @Nullable final String mPackageName;
    @Nullable final String mAttributionTag;
    final IBinder mBinder;

@@ -133,7 +132,6 @@ public abstract class LocationProviderBase {
    public LocationProviderBase(Context context, String tag,
            ProviderPropertiesUnbundled properties) {
        mTag = tag;
        mPackageName = context != null ? context.getPackageName() : null;
        mAttributionTag = context != null ? context.getAttributionTag() : null;
        mBinder = new Service();

@@ -370,7 +368,7 @@ public abstract class LocationProviderBase {
        public void setLocationProviderManager(ILocationProviderManager manager) {
            synchronized (mBinder) {
                try {
                    manager.onInitialize(mAllowed, mProperties, mPackageName, mAttributionTag);
                    manager.onInitialize(mAllowed, mProperties, mAttributionTag);
                } catch (RemoteException e) {
                    throw e.rethrowFromSystemServer();
                } catch (RuntimeException e) {
+5 −13
Original line number Diff line number Diff line
@@ -151,20 +151,14 @@ public class FusedLocationServiceTest {
        }

        @Override
        public void onInitialize(boolean allowed, ProviderProperties properties, String packageName,
                String attributionTag) {

        }
        public void onInitialize(boolean allowed, ProviderProperties properties,
                String attributionTag) {}

        @Override
        public void onSetAllowed(boolean allowed) {

        }
        public void onSetAllowed(boolean allowed) {}

        @Override
        public void onSetProperties(ProviderProperties properties) {

        }
        public void onSetProperties(ProviderProperties properties) {}

        @Override
        public void onReportLocation(Location location) {
@@ -177,9 +171,7 @@ public class FusedLocationServiceTest {
        }

        @Override
        public void onFlushComplete() {

        }
        public void onFlushComplete() {}

        public Location getNextLocation(long timeoutMs) throws InterruptedException {
            return mLocations.poll(timeoutMs, TimeUnit.MILLISECONDS);
+8 −5
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.location.IGeocodeProvider;
import android.os.IBinder;
import android.os.RemoteException;

import com.android.server.servicewatcher.CurrentUserServiceSupplier;
import com.android.server.servicewatcher.ServiceWatcher;

import java.util.Collections;
@@ -54,9 +55,11 @@ public class GeocoderProxy {
    private final ServiceWatcher mServiceWatcher;

    private GeocoderProxy(Context context) {
        mServiceWatcher = new ServiceWatcher(context, SERVICE_ACTION, null, null,
        mServiceWatcher = ServiceWatcher.create(context, "GeocoderProxy",
                new CurrentUserServiceSupplier(context, SERVICE_ACTION,
                        com.android.internal.R.bool.config_enableGeocoderOverlay,
                com.android.internal.R.string.config_geocoderProviderPackageName);
                        com.android.internal.R.string.config_geocoderProviderPackageName),
                null);
    }

    private boolean register() {
@@ -72,7 +75,7 @@ public class GeocoderProxy {
     */
    public void getFromLocation(double latitude, double longitude, int maxResults,
            GeocoderParams params, IGeocodeListener listener) {
        mServiceWatcher.runOnBinder(new ServiceWatcher.BinderRunner() {
        mServiceWatcher.runOnBinder(new ServiceWatcher.BinderOperation() {
            @Override
            public void run(IBinder binder) throws RemoteException {
                IGeocodeProvider provider = IGeocodeProvider.Stub.asInterface(binder);
@@ -97,7 +100,7 @@ public class GeocoderProxy {
            double lowerLeftLatitude, double lowerLeftLongitude,
            double upperRightLatitude, double upperRightLongitude, int maxResults,
            GeocoderParams params, IGeocodeListener listener) {
        mServiceWatcher.runOnBinder(new ServiceWatcher.BinderRunner() {
        mServiceWatcher.runOnBinder(new ServiceWatcher.BinderOperation() {
            @Override
            public void run(IBinder binder) throws RemoteException {
                IGeocodeProvider provider = IGeocodeProvider.Stub.asInterface(binder);
Loading