diff options
author | Mike Lockwood <> | 2009-04-06 10:51:26 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-04-06 10:51:26 -0700 |
commit | e932f7f2a47b770c636443d411436bd29cc4bb43 (patch) | |
tree | 75a53e7d58fd8b9524aa22e370854e4c65bba17e /location/java/com/android | |
parent | 53566b140ffa7b1e2f522ab1cdec13c74f8779e7 (diff) | |
download | frameworks_base-e932f7f2a47b770c636443d411436bd29cc4bb43.zip frameworks_base-e932f7f2a47b770c636443d411436bd29cc4bb43.tar.gz frameworks_base-e932f7f2a47b770c636443d411436bd29cc4bb43.tar.bz2 |
AI 144663: Use Binder interfaces between NetworkLocationManager and LocationManagerService.
This fixes a hack that was added when NetworkLocationManager was moved out of the framework.
This also lays the groundwork for supporting location providers outside of the system process.
BUG=1729031
Automated import of CL 144663
Diffstat (limited to 'location/java/com/android')
5 files changed, 279 insertions, 130 deletions
diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java index d09318a..8a33574 100644 --- a/location/java/com/android/internal/location/GpsLocationProvider.java +++ b/location/java/com/android/internal/location/GpsLocationProvider.java @@ -22,6 +22,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.location.Criteria; import android.location.IGpsStatusListener; +import android.location.ILocationCollector; import android.location.ILocationManager; import android.location.Location; import android.location.LocationManager; @@ -678,7 +679,11 @@ public class GpsLocationProvider extends LocationProviderImpl { // Send to collector if ((flags & LOCATION_HAS_LAT_LONG) == LOCATION_HAS_LAT_LONG && mCollector != null) { - mCollector.updateLocation(mLocation); + try { + mCollector.updateLocation(mLocation); + } catch (RemoteException e) { + Log.w(TAG, "mCollector.updateLocation failed"); + } } } diff --git a/location/java/com/android/internal/location/ILocationCollector.java b/location/java/com/android/internal/location/ILocationCollector.java deleted file mode 100644 index 2196144..0000000 --- a/location/java/com/android/internal/location/ILocationCollector.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 com.android.internal.location; - -import android.location.Location; - -/** - * Listens for GPS and cell/wifi changes and anonymously uploads to server for - * improving quality of service of NetworkLocationProvider. This service is only enabled when - * the user has enabled the network location provider. - * - * {@hide} - */ -public interface ILocationCollector { - /** - * Updates GPS location if collection is enabled - * - * @param location location object - */ - abstract public void updateLocation(Location location); -} diff --git a/location/java/com/android/internal/location/INetworkLocationManager.java b/location/java/com/android/internal/location/INetworkLocationManager.java deleted file mode 100644 index e487556..0000000 --- a/location/java/com/android/internal/location/INetworkLocationManager.java +++ /dev/null @@ -1,30 +0,0 @@ - /* - * 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 com.android.internal.location; - -import android.content.Context; - -/** - * Used to register network location and collection services - * with the Location Manager Service. - * - * {@hide} - */ -public interface INetworkLocationManager { - void setNetworkLocationProvider(INetworkLocationProvider provider); - void setLocationCollector(ILocationCollector collector); -}
\ No newline at end of file diff --git a/location/java/com/android/internal/location/INetworkLocationProvider.java b/location/java/com/android/internal/location/INetworkLocationProvider.java deleted file mode 100644 index 937ab4d..0000000 --- a/location/java/com/android/internal/location/INetworkLocationProvider.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 com.android.internal.location; - -import android.location.Address; -import android.location.Location; -import android.net.wifi.ScanResult; - -import java.util.List; - -/** - * Interface for network location provider - * - * {@hide} - */ -public interface INetworkLocationProvider { - - /** - * Updates the current cell lock status. - * - * @param acquired true if a cell lock has been acquired - */ - abstract public void updateCellLockStatus(boolean acquired); - - /** - * Adds a list of application clients - * Only used by the NetworkLocationProvider - * - * @param applications list of package names - */ - abstract public void addListener(String[] applications); - - /** - * Removes a list of application clients - * Only used by the NetworkLocationProvider - * - * @param applications list of package names - */ - abstract public void removeListener(String[] applications); - - - abstract public String getFromLocation(double latitude, double longitude, int maxResults, - String language, String country, String variant, String appName, List<Address> addrs); - - abstract 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); - -} diff --git a/location/java/com/android/internal/location/LocationProviderProxy.java b/location/java/com/android/internal/location/LocationProviderProxy.java new file mode 100644 index 0000000..1f4940f --- /dev/null +++ b/location/java/com/android/internal/location/LocationProviderProxy.java @@ -0,0 +1,273 @@ +/* + * 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 com.android.internal.location; + +import android.location.Address; +import android.location.ILocationManager; +import android.location.ILocationProvider; +import android.location.Location; +import android.location.LocationManager; +import android.location.LocationProviderImpl; +import android.os.Bundle; +import android.os.RemoteException; +import android.util.Log; + +import java.util.List; + +/** + * A class for proxying remote ILocationProvider implementations. + * + * {@hide} + */ +public class LocationProviderProxy extends LocationProviderImpl { + + private static final String TAG = "LocationProviderProxy"; + + private final ILocationProvider mProvider; + + public LocationProviderProxy(String name, ILocationManager locationManager, + ILocationProvider provider) { + super(name, locationManager); + mProvider = provider; + } + + @Override + public boolean requiresNetwork() { + try { + return mProvider.requiresNetwork(); + } catch (RemoteException e) { + Log.e(TAG, "requiresNetwork failed", e); + return false; + } + } + + @Override + public boolean requiresSatellite() { + try { + return mProvider.requiresSatellite(); + } catch (RemoteException e) { + Log.e(TAG, "requiresSatellite failed", e); + return false; + } + } + + @Override + public boolean requiresCell() { + try { + return mProvider.requiresCell(); + } catch (RemoteException e) { + Log.e(TAG, "requiresCell failed", e); + return false; + } + } + + @Override + public boolean hasMonetaryCost() { + try { + return mProvider.hasMonetaryCost(); + } catch (RemoteException e) { + Log.e(TAG, "hasMonetaryCost failed", e); + return false; + } + } + + @Override + public boolean supportsAltitude() { + try { + return mProvider.supportsAltitude(); + } catch (RemoteException e) { + Log.e(TAG, "supportsAltitude failed", e); + return false; + } + } + + @Override + public boolean supportsSpeed() { + try { + return mProvider.supportsSpeed(); + } catch (RemoteException e) { + Log.e(TAG, "supportsSpeed failed", e); + return false; + } + } + + @Override + public boolean supportsBearing() { + try { + return mProvider.supportsBearing(); + } catch (RemoteException e) { + Log.e(TAG, "supportsBearing failed", e); + return false; + } + } + + @Override + public int getPowerRequirement() { + try { + return mProvider.getPowerRequirement(); + } catch (RemoteException e) { + Log.e(TAG, "getPowerRequirement failed", e); + return 0; + } + } + + @Override + public int getAccuracy() { + try { + return mProvider.getAccuracy(); + } catch (RemoteException e) { + Log.e(TAG, "getAccuracy failed", e); + return 0; + } + } + + @Override + public void enable() { + try { + mProvider.enable(); + } catch (RemoteException e) { + Log.e(TAG, "enable failed", e); + } + } + + @Override + public void disable() { + try { + mProvider.disable(); + } catch (RemoteException e) { + Log.e(TAG, "disable failed", e); + } + } + + @Override + public boolean isEnabled() { + try { + return mProvider.isEnabled(); + } catch (RemoteException e) { + Log.e(TAG, "isEnabled failed", e); + return false; + } + } + + @Override + public int getStatus(Bundle extras) { + try { + return mProvider.getStatus(extras); + } catch (RemoteException e) { + Log.e(TAG, "getStatus failed", e); + return 0; + } + } + + @Override + public long getStatusUpdateTime() { + try { + return mProvider.getStatusUpdateTime(); + } catch (RemoteException e) { + Log.e(TAG, "getStatusUpdateTime failed", e); + return 0; + } + } + + @Override + public void enableLocationTracking(boolean enable) { + try { + super.enableLocationTracking(enable); + mProvider.enableLocationTracking(enable); + } catch (RemoteException e) { + Log.e(TAG, "enableLocationTracking failed", e); + } + } + + @Override + public void setMinTime(long minTime) { + try { + super.setMinTime(minTime); + mProvider.setMinTime(minTime); + } catch (RemoteException e) { + Log.e(TAG, "setMinTime failed", e); + } + } + + @Override + public void updateNetworkState(int state) { + try { + mProvider.updateNetworkState(state); + } catch (RemoteException e) { + Log.e(TAG, "updateNetworkState failed", e); + } + } + + @Override + public boolean sendExtraCommand(String command, Bundle extras) { + try { + return mProvider.sendExtraCommand(command, extras); + } catch (RemoteException e) { + Log.e(TAG, "sendExtraCommand failed", e); + return false; + } + } + + public void updateCellLockStatus(boolean acquired) { + try { + mProvider.updateCellLockStatus(acquired); + } catch (RemoteException e) { + Log.e(TAG, "updateCellLockStatus failed", e); + } + } + + public void addListener(String[] applications) { + try { + mProvider.addListener(applications); + } catch (RemoteException e) { + Log.e(TAG, "addListener failed", e); + } + } + + public void removeListener(String[] applications) { + try { + mProvider.removeListener(applications); + } catch (RemoteException e) { + 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; + } + } +} |