location: Move geocoding support from ILocationProvider to a new interface.
Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
@@ -109,6 +109,7 @@ LOCAL_SRC_FILES += \
|
||||
core/java/com/android/internal/view/IInputMethodManager.aidl \
|
||||
core/java/com/android/internal/view/IInputMethodSession.aidl \
|
||||
im/java/android/im/IImPlugin.aidl \
|
||||
location/java/android/location/IGeocodeProvider.aidl \
|
||||
location/java/android/location/IGpsStatusListener.aidl \
|
||||
location/java/android/location/ILocationCollector.aidl \
|
||||
location/java/android/location/ILocationListener.aidl \
|
||||
|
||||
35
location/java/android/location/IGeocodeProvider.aidl
Normal file
35
location/java/android/location/IGeocodeProvider.aidl
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.location;
|
||||
|
||||
import android.location.Address;
|
||||
|
||||
/**
|
||||
* An interface for location providers implementing the Geocoder services.
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
interface IGeocodeProvider {
|
||||
|
||||
String getFromLocation(double latitude, double longitude, int maxResults,
|
||||
String language, String country, String variant, String appName, out List<Address> addrs);
|
||||
|
||||
String getFromLocationName(String locationName,
|
||||
double lowerLeftLatitude, double lowerLeftLongitude,
|
||||
double upperRightLatitude, double upperRightLongitude, int maxResults,
|
||||
String language, String country, String variant, String appName, out List<Address> addrs);
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package android.location;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.location.Address;
|
||||
import android.location.IGeocodeProvider;
|
||||
import android.location.IGpsStatusListener;
|
||||
import android.location.ILocationCollector;
|
||||
import android.location.ILocationListener;
|
||||
@@ -77,7 +78,8 @@ interface ILocationManager
|
||||
void setTestProviderStatus(String provider, int status, in Bundle extras, long updateTime);
|
||||
void clearTestProviderStatus(String provider);
|
||||
|
||||
/* for installing Network Location Provider */
|
||||
/* for installing external Location Providers */
|
||||
void setNetworkLocationProvider(ILocationProvider provider);
|
||||
void setLocationCollector(ILocationCollector collector);
|
||||
void setGeocodeProvider(IGeocodeProvider provider);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package android.location;
|
||||
|
||||
import android.location.Address;
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
@@ -52,10 +51,4 @@ interface ILocationProvider {
|
||||
void updateCellLockStatus(boolean acquired);
|
||||
void addListener(in String[] applications);
|
||||
void removeListener(in String[] applications);
|
||||
String getFromLocation(double latitude, double longitude, int maxResults,
|
||||
String language, String country, String variant, String appName, out List<Address> addrs);
|
||||
String getFromLocationName(String locationName,
|
||||
double lowerLeftLatitude, double lowerLeftLongitude,
|
||||
double upperRightLatitude, double upperRightLongitude, int maxResults,
|
||||
String language, String country, String variant, String appName, out List<Address> addrs);
|
||||
}
|
||||
|
||||
@@ -245,29 +245,4 @@ public class LocationProviderProxy extends LocationProviderImpl {
|
||||
Log.e(TAG, "removeListener failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getFromLocation(double latitude, double longitude, int maxResults,
|
||||
String language, String country, String variant, String appName, List<Address> addrs) {
|
||||
try {
|
||||
return mProvider.getFromLocation(latitude, longitude, maxResults, language, country,
|
||||
variant, appName, addrs);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "getFromLocation failed", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getFromLocationName(String locationName,
|
||||
double lowerLeftLatitude, double lowerLeftLongitude,
|
||||
double upperRightLatitude, double upperRightLongitude, int maxResults,
|
||||
String language, String country, String variant, String appName, List<Address> addrs) {
|
||||
try {
|
||||
return mProvider.getFromLocationName(locationName, lowerLeftLatitude,
|
||||
lowerLeftLongitude, upperRightLatitude, upperRightLongitude,
|
||||
maxResults, language, country, variant, appName, addrs);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "getFromLocationName failed", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.location.Address;
|
||||
import android.location.IGeocodeProvider;
|
||||
import android.location.IGpsStatusListener;
|
||||
import android.location.ILocationCollector;
|
||||
import android.location.ILocationListener;
|
||||
@@ -128,6 +129,7 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
private GpsLocationProvider mGpsLocationProvider;
|
||||
private boolean mGpsNavigating;
|
||||
private LocationProviderProxy mNetworkLocationProvider;
|
||||
private IGeocodeProvider mGeocodeProvider;
|
||||
private LocationWorkerHandler mLocationHandler;
|
||||
|
||||
// Handler messages
|
||||
@@ -632,6 +634,15 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
public void setGeocodeProvider(IGeocodeProvider provider) {
|
||||
if (Binder.getCallingUid() != Process.SYSTEM_UID) {
|
||||
throw new SecurityException(
|
||||
"Installing location providers outside of the system is not supported");
|
||||
}
|
||||
|
||||
mGeocodeProvider = provider;
|
||||
}
|
||||
|
||||
private WifiManager.WifiLock getWifiWakelockLocked() {
|
||||
if (mWifiLock == null && mWifiManager != null) {
|
||||
mWifiLock = mWifiManager.createWifiLock(WifiManager.WIFI_MODE_SCAN_ONLY, WIFILOCK_KEY);
|
||||
@@ -2074,30 +2085,34 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
// Geocoder
|
||||
|
||||
public String getFromLocation(double latitude, double longitude, int maxResults,
|
||||
String language, String country, String variant, String appName, List<Address> addrs) {
|
||||
synchronized (mLocationListeners) {
|
||||
if (mNetworkLocationProvider != null) {
|
||||
return mNetworkLocationProvider.getFromLocation(latitude, longitude, maxResults,
|
||||
language, country, variant, appName, addrs);
|
||||
} else {
|
||||
return null;
|
||||
String language, String country, String variant, String appName, List<Address> addrs) {
|
||||
if (mGeocodeProvider != null) {
|
||||
try {
|
||||
return mGeocodeProvider.getFromLocation(latitude, longitude, maxResults, language, country,
|
||||
variant, appName, addrs);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "getFromLocation failed", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public String getFromLocationName(String locationName,
|
||||
double lowerLeftLatitude, double lowerLeftLongitude,
|
||||
double upperRightLatitude, double upperRightLongitude, int maxResults,
|
||||
String language, String country, String variant, String appName, List<Address> addrs) {
|
||||
synchronized (mLocationListeners) {
|
||||
if (mNetworkLocationProvider != null) {
|
||||
return mNetworkLocationProvider.getFromLocationName(locationName, lowerLeftLatitude,
|
||||
lowerLeftLongitude, upperRightLatitude, upperRightLongitude, maxResults,
|
||||
language, country, variant, appName, addrs);
|
||||
} else {
|
||||
return null;
|
||||
double lowerLeftLatitude, double lowerLeftLongitude,
|
||||
double upperRightLatitude, double upperRightLongitude, int maxResults,
|
||||
String language, String country, String variant, String appName, List<Address> addrs) {
|
||||
|
||||
if (mGeocodeProvider != null) {
|
||||
try {
|
||||
return mGeocodeProvider.getFromLocationName(locationName, lowerLeftLatitude,
|
||||
lowerLeftLongitude, upperRightLatitude, upperRightLongitude,
|
||||
maxResults, language, country, variant, appName, addrs);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "getFromLocationName failed", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Mock Providers
|
||||
|
||||
Reference in New Issue
Block a user