diff options
author | Victoria Lease <violets@google.com> | 2013-02-05 09:45:16 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-02-05 09:45:16 -0800 |
commit | 63af7a113b9f47d9865a4c64488dd73a40711b7a (patch) | |
tree | 0490ddabb3098dd0c7abb673dbbe3dc59ba7a3a4 /packages | |
parent | 59b3cfee69050456dab2d1d74bfd91897de0fad5 (diff) | |
parent | 080df3f38fc47f15ad321fff00689dcd07e1d075 (diff) | |
download | frameworks_base-63af7a113b9f47d9865a4c64488dd73a40711b7a.zip frameworks_base-63af7a113b9f47d9865a4c64488dd73a40711b7a.tar.gz frameworks_base-63af7a113b9f47d9865a4c64488dd73a40711b7a.tar.bz2 |
am 080df3f3: Merge "dual-mode switching single/multiuser ServiceWatcher"
# Via Android (Google) Code Review (1) and Victoria Lease (1)
* commit '080df3f38fc47f15ad321fff00689dcd07e1d075':
dual-mode switching single/multiuser ServiceWatcher
Diffstat (limited to 'packages')
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; + } } |