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
This commit is contained in:

committed by
The Android Open Source Project
parent
53566b140f
commit
e932f7f2a4
@ -43,7 +43,7 @@ LOCAL_SRC_FILES := $(filter-out \
|
||||
|
||||
## READ ME: ########################################################
|
||||
##
|
||||
## When updading this list of aidl files, consider if that aidl is
|
||||
## When updating this list of aidl files, consider if that aidl is
|
||||
## part of the SDK API. If it is, also add it to the list below that
|
||||
## is preprocessed and distributed with the SDK. This list should
|
||||
## not contain any aidl files for parcelables, but the one below should
|
||||
@ -110,8 +110,10 @@ LOCAL_SRC_FILES += \
|
||||
core/java/com/android/internal/view/IInputMethodSession.aidl \
|
||||
im/java/android/im/IImPlugin.aidl \
|
||||
location/java/android/location/IGpsStatusListener.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 \
|
||||
media/java/android/media/IAudioService.aidl \
|
||||
media/java/android/media/IMediaScannerListener.aidl \
|
||||
media/java/android/media/IMediaScannerService.aidl \
|
||||
|
@ -14,22 +14,23 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.internal.location;
|
||||
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.
|
||||
* 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 {
|
||||
oneway interface ILocationCollector {
|
||||
/**
|
||||
* Updates GPS location if collection is enabled
|
||||
*
|
||||
* @param location location object
|
||||
*/
|
||||
abstract public void updateLocation(Location location);
|
||||
void updateLocation(in Location location);
|
||||
}
|
@ -19,7 +19,9 @@ package android.location;
|
||||
import android.app.PendingIntent;
|
||||
import android.location.Address;
|
||||
import android.location.IGpsStatusListener;
|
||||
import android.location.ILocationCollector;
|
||||
import android.location.ILocationListener;
|
||||
import android.location.ILocationProvider;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
|
||||
@ -74,4 +76,8 @@ interface ILocationManager
|
||||
void clearTestProviderEnabled(String provider);
|
||||
void setTestProviderStatus(String provider, int status, in Bundle extras, long updateTime);
|
||||
void clearTestProviderStatus(String provider);
|
||||
|
||||
/* for installing Network Location Provider */
|
||||
void setNetworkLocationProvider(ILocationProvider provider);
|
||||
void setLocationCollector(ILocationCollector collector);
|
||||
}
|
||||
|
61
location/java/android/location/ILocationProvider.aidl
Normal file
61
location/java/android/location/ILocationProvider.aidl
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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;
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* An interface for location providers implemented outside of the system process.
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
interface ILocationProvider {
|
||||
|
||||
/* for LocationProvider */
|
||||
boolean requiresNetwork();
|
||||
boolean requiresSatellite();
|
||||
boolean requiresCell();
|
||||
boolean hasMonetaryCost();
|
||||
boolean supportsAltitude();
|
||||
boolean supportsSpeed();
|
||||
boolean supportsBearing();
|
||||
int getPowerRequirement();
|
||||
int getAccuracy();
|
||||
|
||||
/* for LocationProviderImpl */
|
||||
void enable();
|
||||
void disable();
|
||||
boolean isEnabled();
|
||||
int getStatus(out Bundle extras);
|
||||
long getStatusUpdateTime();
|
||||
void enableLocationTracking(boolean enable);
|
||||
void setMinTime(long minTime);
|
||||
void updateNetworkState(int state);
|
||||
boolean sendExtraCommand(String command, inout Bundle extras);
|
||||
|
||||
/* the following are only used for NetworkLocationProvider */
|
||||
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);
|
||||
}
|
@ -119,7 +119,7 @@ public abstract class LocationProviderImpl extends LocationProvider {
|
||||
try {
|
||||
mLocationManager.setLocation(location);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling ILocationManager.onLocationChanged");
|
||||
Log.e(TAG, "RemoteException calling ILocationManager.setLocation");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -45,8 +45,10 @@ import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.location.Address;
|
||||
import android.location.IGpsStatusListener;
|
||||
import android.location.ILocationCollector;
|
||||
import android.location.ILocationListener;
|
||||
import android.location.ILocationManager;
|
||||
import android.location.ILocationProvider;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.location.LocationProvider;
|
||||
@ -60,6 +62,7 @@ import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
@ -71,9 +74,7 @@ import android.util.SparseIntArray;
|
||||
|
||||
import com.android.internal.app.IBatteryStats;
|
||||
import com.android.internal.location.GpsLocationProvider;
|
||||
import com.android.internal.location.ILocationCollector;
|
||||
import com.android.internal.location.INetworkLocationManager;
|
||||
import com.android.internal.location.INetworkLocationProvider;
|
||||
import com.android.internal.location.LocationProviderProxy;
|
||||
import com.android.internal.location.MockProvider;
|
||||
import com.android.internal.location.TrackProvider;
|
||||
import com.android.server.am.BatteryStatsService;
|
||||
@ -84,8 +85,7 @@ import com.android.server.am.BatteryStatsService;
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
public class LocationManagerService extends ILocationManager.Stub
|
||||
implements INetworkLocationManager {
|
||||
public class LocationManagerService extends ILocationManager.Stub {
|
||||
private static final String TAG = "LocationManagerService";
|
||||
private static final boolean LOCAL_LOGV = false;
|
||||
|
||||
@ -127,8 +127,7 @@ public class LocationManagerService extends ILocationManager.Stub
|
||||
private final Context mContext;
|
||||
private GpsLocationProvider mGpsLocationProvider;
|
||||
private boolean mGpsNavigating;
|
||||
private LocationProviderImpl mNetworkLocationProvider;
|
||||
private INetworkLocationProvider mNetworkLocationInterface;
|
||||
private LocationProviderProxy mNetworkLocationProvider;
|
||||
private LocationWorkerHandler mLocationHandler;
|
||||
|
||||
// Handler messages
|
||||
@ -600,21 +599,31 @@ public class LocationManagerService extends ILocationManager.Stub
|
||||
mWifiLock = getWifiWakelockLocked();
|
||||
}
|
||||
|
||||
public void setNetworkLocationProvider(INetworkLocationProvider provider) {
|
||||
public void setNetworkLocationProvider(ILocationProvider provider) {
|
||||
if (Binder.getCallingUid() != Process.SYSTEM_UID) {
|
||||
throw new SecurityException(
|
||||
"Installing location providers outside of the system is not supported");
|
||||
}
|
||||
|
||||
synchronized (mLocationListeners) {
|
||||
mNetworkLocationInterface = provider;
|
||||
provider.addListener(getPackageNames());
|
||||
mNetworkLocationProvider = (LocationProviderImpl)provider;
|
||||
mNetworkLocationProvider =
|
||||
new LocationProviderProxy(LocationManager.NETWORK_PROVIDER, this, provider);
|
||||
mNetworkLocationProvider.addListener(getPackageNames());
|
||||
LocationProviderImpl.addProvider(mNetworkLocationProvider);
|
||||
updateProvidersLocked();
|
||||
|
||||
// notify NetworkLocationProvider of any events it might have missed
|
||||
mNetworkLocationProvider.updateNetworkState(mNetworkState);
|
||||
mNetworkLocationInterface.updateCellLockStatus(mCellWakeLockAcquired);
|
||||
mNetworkLocationProvider.updateCellLockStatus(mCellWakeLockAcquired);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLocationCollector(ILocationCollector collector) {
|
||||
if (Binder.getCallingUid() != Process.SYSTEM_UID) {
|
||||
throw new SecurityException(
|
||||
"Installing location collectors outside of the system is not supported");
|
||||
}
|
||||
|
||||
synchronized (mLocationListeners) {
|
||||
mCollector = collector;
|
||||
if (mGpsLocationProvider != null) {
|
||||
@ -1054,8 +1063,8 @@ public class LocationManagerService extends ILocationManager.Stub
|
||||
// Call dispose() on the obsolete update records.
|
||||
for (UpdateRecord record : oldRecords.values()) {
|
||||
if (record.mProvider.equals(LocationManager.NETWORK_PROVIDER)) {
|
||||
if (mNetworkLocationInterface != null) {
|
||||
mNetworkLocationInterface.removeListener(record.mPackages);
|
||||
if (mNetworkLocationProvider != null) {
|
||||
mNetworkLocationProvider.removeListener(record.mPackages);
|
||||
}
|
||||
}
|
||||
record.disposeLocked();
|
||||
@ -1544,7 +1553,7 @@ public class LocationManagerService extends ILocationManager.Stub
|
||||
}
|
||||
writeLastKnownLocationLocked(provider, location);
|
||||
|
||||
if (p instanceof INetworkLocationProvider) {
|
||||
if (LocationManager.NETWORK_PROVIDER.equals(p.getName())) {
|
||||
mWakeLockNetworkReceived = true;
|
||||
} else if (p instanceof GpsLocationProvider) {
|
||||
// Gps location received signal is in NetworkStateBroadcastReceiver
|
||||
@ -1902,8 +1911,8 @@ public class LocationManagerService extends ILocationManager.Stub
|
||||
}
|
||||
|
||||
// Notify NetworkLocationProvider
|
||||
if (mNetworkLocationInterface != null) {
|
||||
mNetworkLocationInterface.updateCellLockStatus(mCellWakeLockAcquired);
|
||||
if (mNetworkLocationProvider != null) {
|
||||
mNetworkLocationProvider.updateCellLockStatus(mCellWakeLockAcquired);
|
||||
}
|
||||
|
||||
// Acquire wifi lock
|
||||
@ -2048,8 +2057,8 @@ public class LocationManagerService extends ILocationManager.Stub
|
||||
}
|
||||
|
||||
// Notify NetworkLocationProvider
|
||||
if (mNetworkLocationInterface != null) {
|
||||
mNetworkLocationInterface.updateCellLockStatus(mCellWakeLockAcquired);
|
||||
if (mNetworkLocationProvider != null) {
|
||||
mNetworkLocationProvider.updateCellLockStatus(mCellWakeLockAcquired);
|
||||
}
|
||||
|
||||
// Release wake lock
|
||||
@ -2067,8 +2076,8 @@ public class LocationManagerService extends ILocationManager.Stub
|
||||
public String getFromLocation(double latitude, double longitude, int maxResults,
|
||||
String language, String country, String variant, String appName, List<Address> addrs) {
|
||||
synchronized (mLocationListeners) {
|
||||
if (mNetworkLocationInterface != null) {
|
||||
return mNetworkLocationInterface.getFromLocation(latitude, longitude, maxResults,
|
||||
if (mNetworkLocationProvider != null) {
|
||||
return mNetworkLocationProvider.getFromLocation(latitude, longitude, maxResults,
|
||||
language, country, variant, appName, addrs);
|
||||
} else {
|
||||
return null;
|
||||
@ -2081,8 +2090,8 @@ public class LocationManagerService extends ILocationManager.Stub
|
||||
double upperRightLatitude, double upperRightLongitude, int maxResults,
|
||||
String language, String country, String variant, String appName, List<Address> addrs) {
|
||||
synchronized (mLocationListeners) {
|
||||
if (mNetworkLocationInterface != null) {
|
||||
return mNetworkLocationInterface.getFromLocationName(locationName, lowerLeftLatitude,
|
||||
if (mNetworkLocationProvider != null) {
|
||||
return mNetworkLocationProvider.getFromLocationName(locationName, lowerLeftLatitude,
|
||||
lowerLeftLongitude, upperRightLatitude, upperRightLongitude, maxResults,
|
||||
language, country, variant, appName, addrs);
|
||||
} else {
|
||||
@ -2236,7 +2245,6 @@ public class LocationManagerService extends ILocationManager.Stub
|
||||
pw.println(" mGpsLocationProvider=" + mGpsLocationProvider);
|
||||
pw.println(" mGpsNavigating=" + mGpsNavigating);
|
||||
pw.println(" mNetworkLocationProvider=" + mNetworkLocationProvider);
|
||||
pw.println(" mNetworkLocationInterface=" + mNetworkLocationInterface);
|
||||
pw.println(" mCollector=" + mCollector);
|
||||
pw.println(" mAlarmInterval=" + mAlarmInterval
|
||||
+ " mScreenOn=" + mScreenOn
|
||||
|
Reference in New Issue
Block a user