summaryrefslogtreecommitdiffstats
path: root/packages/FusedLocation
diff options
context:
space:
mode:
authorVictoria Lease <violets@google.com>2013-02-01 15:15:54 -0800
committerVictoria Lease <violets@google.com>2013-02-01 16:00:20 -0800
commit03cdd3d275499df3ef1059905899dcc5aaf2ab01 (patch)
tree92b7d65eb267d61d621696a431fa83277139e691 /packages/FusedLocation
parentf48a2d30c5d5f7c167310ff9ca1cd2310121be7c (diff)
downloadframeworks_base-03cdd3d275499df3ef1059905899dcc5aaf2ab01.zip
frameworks_base-03cdd3d275499df3ef1059905899dcc5aaf2ab01.tar.gz
frameworks_base-03cdd3d275499df3ef1059905899dcc5aaf2ab01.tar.bz2
dual-mode switching single/multiuser ServiceWatcher
This changelist revises LocationManager's previous multiuser system. Location provider services that are not multiuser-aware continue to run as before: ServiceWatcher binds to location provider services as the current active user. When the device switches from one user to another, ServiceWatcher unbinds from the old user's location provider service and binds to the new user's instance. Now, location provider services that are multiuser-aware or user-agnostic can declare "serviceIsMultiuser" metadata in their AndroidManifest.xml to prevent ServiceWatcher from performing this switching. These services will run as singleton services and will be expected to handle user switches on their own. With this feature in, I was able to switch FusedLocationProvider to run in multiuser mode, sharing the system_server process instead of running in its own process. The NetworkLocationProvider is unchanged, still running in singleuser mode, cheerfully oblivious to the possibility that there might be any user on the device besides the one it services. Bug: 8028045 Change-Id: I1a5bd032918419bab6edb46c62ff8c6811170654
Diffstat (limited to 'packages/FusedLocation')
-rw-r--r--packages/FusedLocation/Android.mk1
-rw-r--r--packages/FusedLocation/AndroidManifest.xml8
-rw-r--r--packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java17
-rw-r--r--packages/FusedLocation/src/com/android/location/fused/FusionEngine.java8
4 files changed, 31 insertions, 3 deletions
diff --git a/packages/FusedLocation/Android.mk b/packages/FusedLocation/Android.mk
index a81b9f1..318782f 100644
--- a/packages/FusedLocation/Android.mk
+++ b/packages/FusedLocation/Android.mk
@@ -23,6 +23,5 @@ LOCAL_JAVA_LIBRARIES := com.android.location.provider
LOCAL_PACKAGE_NAME := FusedLocation
LOCAL_CERTIFICATE := platform
-LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)
diff --git a/packages/FusedLocation/AndroidManifest.xml b/packages/FusedLocation/AndroidManifest.xml
index 779428e..6a4d4bf 100644
--- a/packages/FusedLocation/AndroidManifest.xml
+++ b/packages/FusedLocation/AndroidManifest.xml
@@ -18,14 +18,17 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.location.fused"
- coreApp="true">
+ coreApp="true"
+ android:sharedUserId="android.uid.system">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER" />
+ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
<application
- android:label="@string/app_label">
+ android:label="@string/app_label"
+ android:process="system">
<uses-library android:name="com.android.location.provider" />
@@ -39,6 +42,7 @@
<action android:name="com.android.location.service.FusedLocationProvider" />
</intent-filter>
<meta-data android:name="serviceVersion" android:value="0" />
+ <meta-data android:name="serviceIsMultiuser" android:value="true" />
</service>
</application>
</manifest>
diff --git a/packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java b/packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java
index 7918882..56feb47 100644
--- a/packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java
+++ b/packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java
@@ -24,13 +24,17 @@ import com.android.location.provider.LocationProviderBase;
import com.android.location.provider.ProviderPropertiesUnbundled;
import com.android.location.provider.ProviderRequestUnbundled;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.location.Criteria;
import android.location.LocationProvider;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
+import android.os.UserHandle;
import android.os.WorkSource;
public class FusedLocationProvider extends LocationProviderBase implements FusionEngine.Callback {
@@ -60,6 +64,19 @@ public class FusedLocationProvider extends LocationProviderBase implements Fusio
super(TAG, PROPERTIES);
mContext = context;
mEngine = new FusionEngine(context, Looper.myLooper());
+
+ // 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)) {
+ mEngine.switchUser();
+ }
+ }
+ }, UserHandle.ALL, intentFilter, null, mHandler);
}
/**
diff --git a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java
index f909158..4ba6c34 100644
--- a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java
+++ b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java
@@ -300,4 +300,12 @@ public class FusionEngine implements LocationListener {
s.append(" ").append(mStats.get(NETWORK)).append('\n');
pw.append(s);
}
+
+ /** Called on mLooper thread */
+ public void switchUser() {
+ // reset state to prevent location data leakage
+ mFusedLocation = null;
+ mGpsLocation = null;
+ mNetworkLocation = null;
+ }
}