From c178f80d4703a715ce4cfc4238e11cc6d38d2861 Mon Sep 17 00:00:00 2001 From: Soonil Nagarkar Date: Wed, 4 Mar 2020 11:02:51 -0800 Subject: Make calls for geocoder one way All calls out of system server must be oneway to prevent the system from being blocked by external code. Geocode has been the very last interface not to conform to this - this is now fixed. Bug: 146677166 Test: atest GeocoderTest Change-Id: Ib04d36a9b759f1737ebc2806e49f0bf1e53cea7c --- .../android/location/provider/GeocodeProvider.java | 35 +++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'location/lib') diff --git a/location/lib/java/com/android/location/provider/GeocodeProvider.java b/location/lib/java/com/android/location/provider/GeocodeProvider.java index f7f3d82169a7..05d793542202 100644 --- a/location/lib/java/com/android/location/provider/GeocodeProvider.java +++ b/location/lib/java/com/android/location/provider/GeocodeProvider.java @@ -16,12 +16,14 @@ package com.android.location.provider; -import android.os.IBinder; - import android.location.Address; import android.location.GeocoderParams; +import android.location.IGeocodeListener; import android.location.IGeocodeProvider; +import android.os.IBinder; +import android.os.RemoteException; +import java.util.ArrayList; import java.util.List; /** @@ -38,19 +40,32 @@ import java.util.List; public abstract class GeocodeProvider { private IGeocodeProvider.Stub mProvider = new IGeocodeProvider.Stub() { - public String getFromLocation(double latitude, double longitude, int maxResults, - GeocoderParams params, List
addrs) { - return GeocodeProvider.this.onGetFromLocation(latitude, longitude, maxResults, - params, addrs); + @Override + public void getFromLocation(double latitude, double longitude, int maxResults, + GeocoderParams params, IGeocodeListener listener) { + List
results = new ArrayList<>(); + String error = onGetFromLocation(latitude, longitude, maxResults, params, results); + try { + listener.onResults(error, results); + } catch (RemoteException e) { + // ignore + } } - public String getFromLocationName(String locationName, + @Override + public void getFromLocationName(String locationName, double lowerLeftLatitude, double lowerLeftLongitude, double upperRightLatitude, double upperRightLongitude, int maxResults, - GeocoderParams params, List
addrs) { - return GeocodeProvider.this.onGetFromLocationName(locationName, lowerLeftLatitude, + GeocoderParams params, IGeocodeListener listener) { + List
results = new ArrayList<>(); + String error = onGetFromLocationName(locationName, lowerLeftLatitude, lowerLeftLongitude, upperRightLatitude, upperRightLongitude, - maxResults, params, addrs); + maxResults, params, results); + try { + listener.onResults(error, results); + } catch (RemoteException e) { + // ignore + } } }; -- cgit v1.2.3-59-g8ed1b