Merge change 414 into donut
* changes: location: Run LocationManagerService in a separate thread.
This commit is contained in:
@@ -60,6 +60,7 @@ import android.os.Binder;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
@@ -83,7 +84,7 @@ import com.android.server.am.BatteryStatsService;
|
|||||||
*
|
*
|
||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
public class LocationManagerService extends ILocationManager.Stub {
|
public class LocationManagerService extends ILocationManager.Stub implements Runnable {
|
||||||
private static final String TAG = "LocationManagerService";
|
private static final String TAG = "LocationManagerService";
|
||||||
private static final boolean LOCAL_LOGV = false;
|
private static final boolean LOCAL_LOGV = false;
|
||||||
|
|
||||||
@@ -613,14 +614,18 @@ public class LocationManagerService extends ILocationManager.Stub {
|
|||||||
public LocationManagerService(Context context) {
|
public LocationManagerService(Context context) {
|
||||||
super();
|
super();
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mLocationHandler = new LocationWorkerHandler();
|
|
||||||
|
Thread thread = new Thread(null, this, "LocationManagerService");
|
||||||
|
thread.start();
|
||||||
|
|
||||||
if (LOCAL_LOGV) {
|
if (LOCAL_LOGV) {
|
||||||
Log.v(TAG, "Constructed LocationManager Service");
|
Log.v(TAG, "Constructed LocationManager Service");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize() {
|
||||||
// Alarm manager, needs to be done before calling loadProviders() below
|
// Alarm manager, needs to be done before calling loadProviders() below
|
||||||
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
|
||||||
|
|
||||||
// Create a wake lock, needs to be done before calling loadProviders() below
|
// Create a wake lock, needs to be done before calling loadProviders() below
|
||||||
PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
||||||
@@ -634,7 +639,7 @@ public class LocationManagerService extends ILocationManager.Stub {
|
|||||||
IntentFilter networkIntentFilter = new IntentFilter();
|
IntentFilter networkIntentFilter = new IntentFilter();
|
||||||
networkIntentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
networkIntentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||||
networkIntentFilter.addAction(GpsLocationProvider.GPS_ENABLED_CHANGE_ACTION);
|
networkIntentFilter.addAction(GpsLocationProvider.GPS_ENABLED_CHANGE_ACTION);
|
||||||
context.registerReceiver(networkReceiver, networkIntentFilter);
|
mContext.registerReceiver(networkReceiver, networkIntentFilter);
|
||||||
|
|
||||||
// Register for power updates
|
// Register for power updates
|
||||||
PowerStateBroadcastReceiver powerStateReceiver = new PowerStateBroadcastReceiver();
|
PowerStateBroadcastReceiver powerStateReceiver = new PowerStateBroadcastReceiver();
|
||||||
@@ -642,7 +647,7 @@ public class LocationManagerService extends ILocationManager.Stub {
|
|||||||
intentFilter.addAction(ALARM_INTENT);
|
intentFilter.addAction(ALARM_INTENT);
|
||||||
intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
||||||
intentFilter.addAction(Intent.ACTION_PACKAGE_RESTARTED);
|
intentFilter.addAction(Intent.ACTION_PACKAGE_RESTARTED);
|
||||||
context.registerReceiver(powerStateReceiver, intentFilter);
|
mContext.registerReceiver(powerStateReceiver, intentFilter);
|
||||||
|
|
||||||
// listen for settings changes
|
// listen for settings changes
|
||||||
ContentResolver resolver = mContext.getContentResolver();
|
ContentResolver resolver = mContext.getContentResolver();
|
||||||
@@ -655,6 +660,15 @@ public class LocationManagerService extends ILocationManager.Stub {
|
|||||||
mSettings.addObserver(settingsObserver);
|
mSettings.addObserver(settingsObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
|
||||||
|
Looper.prepare();
|
||||||
|
mLocationHandler = new LocationWorkerHandler();
|
||||||
|
initialize();
|
||||||
|
Looper.loop();
|
||||||
|
}
|
||||||
|
|
||||||
public void setNetworkLocationProvider(ILocationProvider provider) {
|
public void setNetworkLocationProvider(ILocationProvider provider) {
|
||||||
if (Binder.getCallingUid() != Process.SYSTEM_UID) {
|
if (Binder.getCallingUid() != Process.SYSTEM_UID) {
|
||||||
throw new SecurityException(
|
throw new SecurityException(
|
||||||
|
|||||||
Reference in New Issue
Block a user