Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4466f716 authored by Todd Kennedy's avatar Todd Kennedy Committed by Android (Google) Code Review
Browse files

Merge "setup content observer statically"

parents c1bf0688 e4a8dbd8
Loading
Loading
Loading
Loading
+16 −21
Original line number Diff line number Diff line
@@ -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,17 +1637,14 @@ 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);
            final Uri uri =
                    Settings.Global.getUriFor(Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED);
            context.getContentResolver().registerContentObserver(uri, false, new ContentObserver(
                    context.getMainThreadHandler()) {
                @Override
@@ -1661,6 +1655,7 @@ public class AppOpsManager {
                }
            });
        }
    }

    /**
     * Retrieve the default mode for the app op.