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

Commit 1dd25fd8 authored by Matthew Fritze's avatar Matthew Fritze Committed by Andrew Sapperstein
Browse files

Add isSliceable API to BasePrefController

Only support explicitly approved Settings Slices,
dictated by controllers which return true for the new
method isSliceable.

Updating the supported settings to a whitelist means that
the method to return all available slices must be updated,
and checking slicability when we index slices.

Test: robotests
Change-Id: I85848c2cdf3e151fa94b33dd1dc5c0374ef94b5b
Merged-In: Ib2b9690cdd0036b5cc4a1cb846c52bce7c824ab9
Fixes: 79779103
parent a419c471
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -90,6 +90,11 @@ public class AccessibilitySlicePreferenceController extends TogglePreferenceCont
        return getAccessibilityServiceInfo() == null ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
    }

    @Override
    public boolean isSliceable() {
        return true;
    }

    private AccessibilityServiceInfo getAccessibilityServiceInfo() {
        final AccessibilityManager accessibilityManager = mContext.getSystemService(
                AccessibilityManager.class);
+17 −0
Original line number Diff line number Diff line
@@ -229,6 +229,23 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
        return null;
    }

    /**
     * Determines if the controller should be used as a Slice.
     * <p>
     *     Important criteria for a Slice are:
     *     - Must be secure
     *     - Must not be a privacy leak
     *     - Must be understandable as a stand-alone Setting.
     * <p>
     *     This does not guarantee the setting is available. {@link #isAvailable()} should sill be
     *     called.
     *
     * @return {@code true} if the controller should be used externally as a Slice.
     */
    public boolean isSliceable() {
        return false;
    }

    /**
     * Updates non-indexable keys for search provider.
     *
+6 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;

import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
@@ -53,6 +54,11 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
        return isAvailable(mConfig) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
    }

    @Override
    public boolean isSliceable() {
        return TextUtils.equals(getPreferenceKey(), "ambient_display_always_on");
    }

    @Override
    public boolean isChecked() {
        return mConfig.alwaysOnEnabled(MY_USER);
+6 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.text.TextUtils;

import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
@@ -89,6 +90,11 @@ public class AmbientDisplayNotificationsPreferenceController extends
        return mConfig.pulseOnNotificationAvailable() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
    }

    @Override
    public boolean isSliceable() {
        return TextUtils.equals(getPreferenceKey(), "ambient_display_notification");
    }

    @Override
    //TODO (b/69808376): Remove result payload
    public ResultPayload getResultPayload() {
+6 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ package com.android.settings.display;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.text.TextUtils;

import com.android.settings.DisplaySettings;
import com.android.settings.core.TogglePreferenceController;
@@ -60,6 +61,11 @@ public class AutoBrightnessPreferenceController extends TogglePreferenceControll
                : UNSUPPORTED_ON_DEVICE;
    }

    @Override
    public boolean isSliceable() {
        return TextUtils.equals(getPreferenceKey(), "auto_brightness");
    }

    @Override
    public ResultPayload getResultPayload() {
        // TODO remove result payload
Loading