Merge change 2182 into donut
* changes: location: Replace ILocationCollector interface with new ILocationProvider method
This commit is contained in:
@ -135,7 +135,6 @@ LOCAL_SRC_FILES += \
|
||||
location/java/android/location/IGeocodeProvider.aidl \
|
||||
location/java/android/location/IGpsStatusListener.aidl \
|
||||
location/java/android/location/IGpsStatusProvider.aidl \
|
||||
location/java/android/location/ILocationCollector.aidl \
|
||||
location/java/android/location/ILocationListener.aidl \
|
||||
location/java/android/location/ILocationManager.aidl \
|
||||
location/java/android/location/ILocationProvider.aidl \
|
||||
|
@ -529,17 +529,6 @@
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="INSTALL_LOCATION_COLLECTOR"
|
||||
type="java.lang.String"
|
||||
transient="false"
|
||||
volatile="false"
|
||||
value=""android.permission.INSTALL_LOCATION_COLLECTOR""
|
||||
static="true"
|
||||
final="true"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="INSTALL_LOCATION_PROVIDER"
|
||||
type="java.lang.String"
|
||||
transient="false"
|
||||
|
@ -220,12 +220,6 @@
|
||||
android:label="@string/permlab_installLocationProvider"
|
||||
android:description="@string/permdesc_installLocationProvider" />
|
||||
|
||||
<!-- Allows an application to install a location collector into the Location Manager -->
|
||||
<permission android:name="android.permission.INSTALL_LOCATION_COLLECTOR"
|
||||
android:protectionLevel="signatureOrSystem"
|
||||
android:label="@string/permlab_installLocationCollector"
|
||||
android:description="@string/permdesc_installLocationCollector" />
|
||||
|
||||
<!-- ======================================= -->
|
||||
<!-- Permissions for accessing networks -->
|
||||
<!-- ======================================= -->
|
||||
|
@ -769,13 +769,7 @@
|
||||
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||
<string name="permdesc_installLocationProvider">Create mock location sources for testing.
|
||||
Malicious applications can use this to override the location and/or status returned by real
|
||||
location sources such as GPS or Network providers.</string>
|
||||
|
||||
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||
<string name="permlab_installLocationCollector">permission to install a location collector</string>
|
||||
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||
<string name="permdesc_installLocationCollector">Create mock location sources for testing.
|
||||
Malicious applications can use this to monitor and report your location to an external source.</string>
|
||||
location sources such as GPS or Network providers or monitor and report your location to an external source.</string>
|
||||
|
||||
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||
<string name="permlab_accessFineLocation">fine (GPS) location</string>
|
||||
|
@ -133,7 +133,6 @@
|
||||
<assign-permission name="android.permission.READ_FRAME_BUFFER" uid="shell" />
|
||||
<assign-permission name="android.permission.DEVICE_POWER" uid="shell" />
|
||||
<assign-permission name="android.permission.INSTALL_LOCATION_PROVIDER" uid="shell" />
|
||||
<assign-permission name="android.permission.INSTALL_LOCATION_COLLECTOR" uid="shell" />
|
||||
|
||||
<assign-permission name="android.permission.MODIFY_AUDIO_SETTINGS" uid="media" />
|
||||
<assign-permission name="android.permission.ACCESS_DRM" uid="media" />
|
||||
|
@ -1,36 +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 android.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}
|
||||
*/
|
||||
oneway interface ILocationCollector {
|
||||
/**
|
||||
* Updates GPS location if collection is enabled
|
||||
*
|
||||
* @param location location object
|
||||
*/
|
||||
void updateLocation(in Location location);
|
||||
}
|
@ -20,7 +20,6 @@ import android.app.PendingIntent;
|
||||
import android.location.Address;
|
||||
import android.location.IGeocodeProvider;
|
||||
import android.location.IGpsStatusListener;
|
||||
import android.location.ILocationCollector;
|
||||
import android.location.ILocationListener;
|
||||
import android.location.ILocationProvider;
|
||||
import android.location.Location;
|
||||
@ -83,6 +82,5 @@ interface ILocationManager
|
||||
|
||||
/* for installing external Location Providers */
|
||||
void installLocationProvider(String name, ILocationProvider provider);
|
||||
void installLocationCollector(ILocationCollector collector);
|
||||
void installGeocodeProvider(IGeocodeProvider provider);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package android.location;
|
||||
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
@ -41,6 +42,7 @@ interface ILocationProvider {
|
||||
void enableLocationTracking(boolean enable);
|
||||
void setMinTime(long minTime);
|
||||
void updateNetworkState(int state);
|
||||
void updateLocation(in Location location);
|
||||
boolean sendExtraCommand(String command, inout Bundle extras);
|
||||
void addListener(int uid);
|
||||
void removeListener(int uid);
|
||||
|
@ -1278,27 +1278,6 @@ public class LocationManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs a location collector.
|
||||
*
|
||||
* @param provider Binder interface for the location collector
|
||||
*
|
||||
* @return true if the command succeeds.
|
||||
*
|
||||
* Requires the android.permission.INSTALL_LOCATION_COLLECTOR permission.
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
public boolean installLocationCollector(ILocationCollector collector) {
|
||||
try {
|
||||
mService.installLocationCollector(collector);
|
||||
return true;
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException in setLocationCollector: ", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs a geocoder server.
|
||||
*
|
||||
|
@ -405,6 +405,13 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called to inform us when another location provider returns a location.
|
||||
* Someday we might use this for network location injection to aid the GPS
|
||||
*/
|
||||
public void updateLocation(Location location) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the provider requires access to a
|
||||
* satellite-based positioning system (e.g., GPS), false
|
||||
|
@ -219,6 +219,14 @@ public class LocationProviderProxy implements IBinder.DeathRecipient {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLocation(Location location) {
|
||||
try {
|
||||
mProvider.updateLocation(location);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "updateLocation failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean sendExtraCommand(String command, Bundle extras) {
|
||||
try {
|
||||
return mProvider.sendExtraCommand(command, extras);
|
||||
|
@ -172,6 +172,9 @@ public class MockProvider extends ILocationProvider.Stub {
|
||||
public void updateNetworkState(int state) {
|
||||
}
|
||||
|
||||
public void updateLocation(Location location) {
|
||||
}
|
||||
|
||||
public boolean sendExtraCommand(String command, Bundle extras) {
|
||||
return false;
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ import android.location.Address;
|
||||
import android.location.IGeocodeProvider;
|
||||
import android.location.IGpsStatusListener;
|
||||
import android.location.IGpsStatusProvider;
|
||||
import android.location.ILocationCollector;
|
||||
import android.location.ILocationListener;
|
||||
import android.location.ILocationManager;
|
||||
import android.location.ILocationProvider;
|
||||
@ -107,8 +106,6 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
||||
android.Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS;
|
||||
private static final String INSTALL_LOCATION_PROVIDER =
|
||||
android.Manifest.permission.INSTALL_LOCATION_PROVIDER;
|
||||
private static final String INSTALL_LOCATION_COLLECTOR =
|
||||
android.Manifest.permission.INSTALL_LOCATION_COLLECTOR;
|
||||
|
||||
// Set of providers that are explicitly enabled
|
||||
private final Set<String> mEnabledProviders = new HashSet<String>();
|
||||
@ -171,9 +168,6 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
||||
private HashMap<String,Location> mLastKnownLocation =
|
||||
new HashMap<String,Location>();
|
||||
|
||||
// Location collector
|
||||
private ILocationCollector mCollector;
|
||||
|
||||
private int mNetworkState = LocationProvider.TEMPORARILY_UNAVAILABLE;
|
||||
|
||||
// for Settings change notification
|
||||
@ -630,16 +624,6 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
||||
}
|
||||
}
|
||||
|
||||
public void installLocationCollector(ILocationCollector collector) {
|
||||
if (mContext.checkCallingOrSelfPermission(INSTALL_LOCATION_COLLECTOR)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
throw new SecurityException("Requires INSTALL_LOCATION_COLLECTOR permission");
|
||||
}
|
||||
|
||||
// FIXME - only support one collector
|
||||
mCollector = collector;
|
||||
}
|
||||
|
||||
public void installGeocodeProvider(IGeocodeProvider provider) {
|
||||
if (mContext.checkCallingOrSelfPermission(INSTALL_LOCATION_PROVIDER)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
@ -1619,25 +1603,21 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
||||
|
||||
synchronized (mLock) {
|
||||
Location location = (Location) msg.obj;
|
||||
|
||||
if (mCollector != null &&
|
||||
LocationManager.GPS_PROVIDER.equals(location.getProvider())) {
|
||||
try {
|
||||
mCollector.updateLocation(location);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "mCollector.updateLocation failed");
|
||||
mCollector = null;
|
||||
}
|
||||
}
|
||||
|
||||
String provider = location.getProvider();
|
||||
if (!isAllowedBySettingsLocked(provider)) {
|
||||
return;
|
||||
|
||||
// notify other providers of the new location
|
||||
for (int i = mProviders.size() - 1; i >= 0; i--) {
|
||||
LocationProviderProxy proxy = mProviders.get(i);
|
||||
if (!provider.equals(proxy.getName())) {
|
||||
proxy.updateLocation(location);
|
||||
}
|
||||
}
|
||||
|
||||
if (isAllowedBySettingsLocked(provider)) {
|
||||
handleLocationChangedLocked(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Log, don't crash!
|
||||
Log.e(TAG, "Exception in LocationWorkerHandler.handleMessage:", e);
|
||||
@ -1935,7 +1915,6 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
||||
synchronized (mLock) {
|
||||
pw.println("Current Location Manager state:");
|
||||
pw.println(" sProvidersLoaded=" + sProvidersLoaded);
|
||||
pw.println(" mCollector=" + mCollector);
|
||||
pw.println(" Listeners:");
|
||||
int N = mReceivers.size();
|
||||
for (int i=0; i<N; i++) {
|
||||
|
@ -159,6 +159,9 @@ public class TestLocationProvider extends ILocationProvider.Stub {
|
||||
public void updateNetworkState(int state) {
|
||||
}
|
||||
|
||||
public void updateLocation(Location location) {
|
||||
}
|
||||
|
||||
public boolean sendExtraCommand(String command, Bundle extras) {
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user