summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server
diff options
context:
space:
mode:
authorVictoria Lease <violets@google.com>2012-10-01 17:46:26 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-01 17:46:27 -0700
commit3750db176adbaf3f9779df5eadf335f673b2ac4f (patch)
treec3dc41f075caedc0f858fb5dfa0c743ef8b37327 /services/java/com/android/server
parent6f354ed9994b4ea7612cc4499413de108dcac7d4 (diff)
parent38389b6cf7bd2ef49d2bd20ff1bca8677596590e (diff)
downloadframeworks_base-3750db176adbaf3f9779df5eadf335f673b2ac4f.zip
frameworks_base-3750db176adbaf3f9779df5eadf335f673b2ac4f.tar.gz
frameworks_base-3750db176adbaf3f9779df5eadf335f673b2ac4f.tar.bz2
Merge "Route GPS notifications to all users." into jb-mr1-dev
Diffstat (limited to 'services/java/com/android/server')
-rw-r--r--services/java/com/android/server/LocationManagerService.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index a1bd3c5..2197e31 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -17,9 +17,11 @@
package com.android.server;
import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -171,6 +173,9 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
private final ArrayList<LocationProviderProxy> mProxyProviders =
new ArrayList<LocationProviderProxy>();
+ // current active user on the device - other users are denied location data
+ private int mCurrentUserId = UserHandle.USER_OWNER;
+
public LocationManagerService(Context context) {
super();
mContext = context;
@@ -224,6 +229,20 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
});
mPackageMonitor.register(mContext, Looper.myLooper(), true);
+ // listen for user change
+ IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addAction(Intent.ACTION_USER_SWITCHED);
+
+ mContext.registerReceiverAsUser(new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (Intent.ACTION_USER_SWITCHED.equals(action)) {
+ switchUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0));
+ }
+ }
+ }, UserHandle.ALL, intentFilter, null, null);
+
updateProvidersLocked();
}
@@ -302,6 +321,19 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
}
/**
+ * Called when the device's active user changes.
+ * @param userId the new active user's UserId
+ */
+ private void switchUser(int userId) {
+ //Log.d("LocationManagerService", "switchUser(" + mCurrentUserId + " -> " + userId + ")"); // TODO: remove this
+ synchronized (mLock) {
+ // TODO: inform previous user's Receivers that they will no longer receive updates
+ mCurrentUserId = userId;
+ // TODO: inform new user's Receivers that they are back on the update train
+ }
+ }
+
+ /**
* A wrapper class holding either an ILocationListener or a PendingIntent to receive
* location updates.
*/