summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Todd Kennedy <toddke@google.com> 2018-11-14 09:22:05 -0800
committer Todd Kennedy <toddke@google.com> 2018-11-14 09:22:05 -0800
commite4a8dbd80b4f5c26b6e5dadb5b31a2169d3fefab (patch)
tree813dd2f69a39fbcbfd54df980a6cea4e5ad27b22
parent755cc6653430e0172b00377ef6c4dc1a1a8dc0b6 (diff)
setup content observer statically
Instead of waiting for the first time we get the app op default mode, just register the content observer for the sms & call log restriction. This is temporary code anyway and will be removed according to a STOPSHIP comment. So, the minor hit taken during system start is okay for now. Test: Device boots. Change-Id: I55cc57ddfe80acf304b5126db16f5813a97c7042 Fixes: 119080532
-rw-r--r--core/java/android/app/AppOpsManager.java37
1 files changed, 16 insertions, 21 deletions
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index 2be5dc966746..9e109c534ba9 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -1625,9 +1625,6 @@ public class AppOpsManager {
case AppOpsManager.OP_READ_CALL_LOG:
case AppOpsManager.OP_WRITE_CALL_LOG:
case AppOpsManager.OP_PROCESS_OUTGOING_CALLS: {
- if (sSmsAndCallLogRestrictionEnabled.get() < 0) {
- startWatchingSmsRestrictionEnabled();
- }
if (sSmsAndCallLogRestrictionEnabled.get() == 1) {
return AppOpsManager.MODE_DEFAULT;
}
@@ -1640,26 +1637,24 @@ public class AppOpsManager {
private static final AtomicInteger sSmsAndCallLogRestrictionEnabled = new AtomicInteger(-1);
// STOPSHIP b/118520006: Hardcode the default values once the feature is stable.
- private static void startWatchingSmsRestrictionEnabled() {
+ static {
final Context context = ActivityThread.currentApplication();
- if (context == null) {
- // Should never happen
- return;
+ if (context != null) {
+ sSmsAndCallLogRestrictionEnabled.set(ActivityThread.currentActivityThread()
+ .getIntCoreSetting(Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED, 0));
+
+ final Uri uri =
+ Settings.Global.getUriFor(Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED);
+ context.getContentResolver().registerContentObserver(uri, false, new ContentObserver(
+ context.getMainThreadHandler()) {
+ @Override
+ public void onChange(boolean selfChange) {
+ sSmsAndCallLogRestrictionEnabled.set(Settings.Global.getInt(
+ context.getContentResolver(),
+ Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED, 0));
+ }
+ });
}
-
- sSmsAndCallLogRestrictionEnabled.set(ActivityThread.currentActivityThread()
- .getIntCoreSetting(Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED, 0));
-
- final Uri uri = Settings.Global.getUriFor(Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED);
- context.getContentResolver().registerContentObserver(uri, false, new ContentObserver(
- context.getMainThreadHandler()) {
- @Override
- public void onChange(boolean selfChange) {
- sSmsAndCallLogRestrictionEnabled.set(Settings.Global.getInt(
- context.getContentResolver(),
- Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED, 0));
- }
- });
}
/**