diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-02-21 22:27:18 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-02-21 22:27:18 +0000 |
commit | fdc11c9eced899c6de2186f0799714183dc42d17 (patch) | |
tree | 7a2273c16b6bec1bb0b17497fc85613abb0df177 | |
parent | 9a9e9a59a5a1c07f9b03eade09641f34a46939ae (diff) | |
parent | 41ace3ba2459b3b26ed5cd5666ddb336dd1a3ea5 (diff) |
Merge "Revert "Revert "Add feature ids to system server services that requset location."""
6 files changed, 32 insertions, 11 deletions
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 814b8acd63ac..61d229807d0d 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -4979,6 +4979,16 @@ <permission android:name="android.permission.ACCESS_LOCUS_ID_USAGE_STATS" android:protectionLevel="signature|appPredictor" /> + <!-- Feature Id for Country Detector. --> + <feature android:featureId="CountryDetector" android:label="@string/country_detector"/> + <!-- Feature Id for Location service. --> + <feature android:featureId="LocationService" android:label="@string/location_service"/> + <!-- Feature Id for Sensor Notification service. --> + <feature android:featureId="SensorNotificationService" + android:label="@string/sensor_notification_service"/> + <!-- Feature Id for Twilight service. --> + <feature android:featureId="TwilightService" android:label="@string/twilight_service"/> + <application android:process="system" android:persistent="true" android:hasCode="false" diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 144573641654..df1f46f10967 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -421,6 +421,14 @@ [CHAR LIMIT=NONE] --> <string name="location_changed_notification_text">Tap to see your location settings.</string> + <!-- Feature Id for Country Detector. [CHAR LIMIT=NONE]--> + <string name="country_detector">Country Detector</string> + <!-- Feature Id for Location service. [CHAR LIMIT=NONE]--> + <string name="location_service">Location Service</string> + <!-- Feature Id for Sensor Notification service. [CHAR LIMIT=NONE]--> + <string name="sensor_notification_service">Sensor Notification Service</string> + <!-- Feature Id for Twilight service. [CHAR LIMIT=NONE]--> + <string name="twilight_service">Twilight Service</string> <!-- Factory reset warning dialog strings--> <skip /> <!-- Shows up in the dialog's title to warn about an impeding factory reset. [CHAR LIMIT=NONE] --> diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java index 2804d79ef56f..acd40395f611 100644 --- a/services/core/java/com/android/server/LocationManagerService.java +++ b/services/core/java/com/android/server/LocationManagerService.java @@ -200,6 +200,8 @@ public class LocationManagerService extends ILocationManager.Stub { // time private static final int MAX_PROVIDER_SCHEDULING_JITTER_MS = 100; + private static final String FEATURE_ID = "LocationService"; + private static final LocationRequest DEFAULT_LOCATION_REQUEST = new LocationRequest(); private final Object mLock = new Object(); @@ -244,7 +246,7 @@ public class LocationManagerService extends ILocationManager.Stub { private int mBatterySaverMode; private LocationManagerService(Context context) { - mContext = context; + mContext = context.createFeatureContext(FEATURE_ID); mHandler = FgThread.getHandler(); mLocalService = new LocalService(); diff --git a/services/core/java/com/android/server/SensorNotificationService.java b/services/core/java/com/android/server/SensorNotificationService.java index 7f5befabc576..9082dca1022c 100644 --- a/services/core/java/com/android/server/SensorNotificationService.java +++ b/services/core/java/com/android/server/SensorNotificationService.java @@ -16,10 +16,8 @@ package com.android.server; -import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.content.IntentFilter; import android.hardware.GeomagneticField; import android.hardware.Sensor; import android.hardware.SensorAdditionalInfo; @@ -31,9 +29,7 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.os.SystemClock; -import android.os.SystemProperties; import android.os.UserHandle; -import android.provider.Settings; import android.util.Slog; public class SensorNotificationService extends SystemService @@ -52,6 +48,8 @@ public class SensorNotificationService extends SystemService private static final long MILLIS_2010_1_1 = 1262358000000l; + private static final String FEATURE_ID = "SensorNotificationService"; + private Context mContext; private SensorManager mSensorManager; private LocationManager mLocationManager; @@ -61,8 +59,8 @@ public class SensorNotificationService extends SystemService private long mLocalGeomagneticFieldUpdateTime = -LOCATION_MIN_TIME; public SensorNotificationService(Context context) { - super(context); - mContext = context; + super(context.createFeatureContext(FEATURE_ID)); + mContext = getContext(); } public void onStart() { diff --git a/services/core/java/com/android/server/location/CountryDetectorBase.java b/services/core/java/com/android/server/location/CountryDetectorBase.java index 8326ef949858..b158388281d8 100644 --- a/services/core/java/com/android/server/location/CountryDetectorBase.java +++ b/services/core/java/com/android/server/location/CountryDetectorBase.java @@ -31,13 +31,15 @@ import android.os.Handler; * @hide */ public abstract class CountryDetectorBase { + private static final String FEATURE_ID = "CountryDetector"; + protected final Handler mHandler; protected final Context mContext; protected CountryListener mListener; protected Country mDetectedCountry; - public CountryDetectorBase(Context ctx) { - mContext = ctx; + public CountryDetectorBase(Context context) { + mContext = context.createFeatureContext(FEATURE_ID); mHandler = new Handler(); } @@ -45,7 +47,7 @@ public abstract class CountryDetectorBase { * Start detecting the country that the user is in. * * @return the country if it is available immediately, otherwise null should - * be returned. + * be returned. */ public abstract Country detectCountry(); diff --git a/services/core/java/com/android/server/twilight/TwilightService.java b/services/core/java/com/android/server/twilight/TwilightService.java index e72ba8d9f01b..761fbf8a0622 100644 --- a/services/core/java/com/android/server/twilight/TwilightService.java +++ b/services/core/java/com/android/server/twilight/TwilightService.java @@ -50,6 +50,7 @@ public final class TwilightService extends SystemService implements AlarmManager.OnAlarmListener, Handler.Callback, LocationListener { private static final String TAG = "TwilightService"; + private static final String FEATURE_ID = "TwilightService"; private static final boolean DEBUG = false; private static final int MSG_START_LISTENING = 1; @@ -73,7 +74,7 @@ public final class TwilightService extends SystemService protected TwilightState mLastTwilightState; public TwilightService(Context context) { - super(context); + super(context.createFeatureContext(FEATURE_ID)); mHandler = new Handler(Looper.getMainLooper(), this); } |