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

Commit 440c6837 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Move AOD settings to Display page, add wallpaper option" into main

parents 4c362285 aa42fc88
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -3333,8 +3333,22 @@
    <string name="doze_summary">When screen is dark, it turns on for new notifications</string>
    <!-- [CHAR LIMIT=30] Display settings screen, setting option name to change whether the always-on ambient display feature is enabled. -->
    <string name="doze_always_on_title">Always show time and info</string>
    <!-- [CHAR LIMIT=30] Display settings screen, setting option name to change whether the always-on ambient display feature is enabled. -->
    <string name="doze_always_on_title2">Always-on display</string>
    <!-- [CHAR LIMIT=NONE] Display settings screen, setting description for the always-on ambient display feature. -->
    <string name="doze_always_on_summary">Increased battery usage</string>
    <!-- [CHAR LIMIT=NONE] Display settings screen, setting description for the always-on ambient display feature with wallpaper visible on AOD. -->
    <string name="doze_always_on_summary_with_wallpaper">Show lock screen wallpaper when screen is off</string>
    <!-- [CHAR LIMIT=NONE] Display settings screen, setting description for the always-on ambient display feature with wallpaper not visible on AOD. -->
    <string name="doze_always_on_summary_without_wallpaper">Hide lock screen wallpaper when screen is off</string>
    <!-- [CHAR LIMIT=NONE] Display settings screen, always-on display, long description-->
    <string name="doze_always_on_summary_long">Always-on display shows the time, date, and more when the screen is off</string>
    <!-- [CHAR LIMIT=50] Title for a group of settings related to the wallpaper on always-on display-->
    <string name="doze_always_on_wallpaper_options">Wallpaper options</string>
    <!-- [CHAR LIMIT=50] Title for always-on display that will enable the wallpaper to be visible-->
    <string name="doze_always_on_wallpaper_title">Show lock screen wallpaper</string>
    <!-- [CHAR LIMIT=NONE] Description for always-on display that will enable the wallpaper to be visible-->
    <string name="doze_always_on_wallpaper_description">Lock screen wallpaper is visible with always-on display</string>
    <!-- [CHAR LIMIT=30] Display and accessibility settings screens, setting option name to force bold text. -->
    <string name="force_bold_text">Bold text</string>
    <!-- [CHAR LIMIT=30] Sound & display settings screen, setting option name to change font size -->
+9 −0
Original line number Diff line number Diff line
@@ -54,6 +54,15 @@
            settings:keywords="@string/keywords_ambient_display_screen"
            settings:controller="com.android.settings.security.screenlock.LockScreenPreferenceController"/>

        <com.android.settingslib.PrimarySwitchPreference
            android:key="ambient_display_always_on_screen"
            android:title="@string/doze_always_on_title"
            android:summary="@string/doze_always_on_summary"
            android:fragment="com.android.settings.display.AmbientPreferenceFragment"
            settings:keywords="@string/keywords_always_show_time_info"
            settings:controller="com.android.settings.display.AmbientDisplayAlwaysOnPreferenceScreenController"
            settings:userRestriction="no_ambient_display" />

        <com.android.settingslib.RestrictedPreference
            android:fragment="com.android.settings.display.FoldLockBehaviorSettings"
            android:key="fold_lock_behavior"
+8 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.settings.display;
import static android.provider.Settings.Secure.DOZE_ALWAYS_ON;
import static android.provider.Settings.Secure.DOZE_WAKE_DISPLAY_GESTURE;

import static com.android.systemui.shared.Flags.ambientAod;

import android.annotation.ColorInt;
import android.app.PendingIntent;
import android.content.ContentResolver;
@@ -73,12 +75,17 @@ public class AlwaysOnDisplaySlice implements CustomSliceable {
        @ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
        final boolean isChecked = mConfig.alwaysOnEnabled(MY_USER);

        int title = R.string.doze_always_on_title;
        if (ambientAod()) {
            title = R.string.doze_always_on_title2;
        }

        return new ListBuilder(mContext, CustomSliceRegistry.ALWAYS_ON_SLICE_URI,
                ListBuilder.INFINITY)
                .setAccentColor(color)
                .setKeywords(getKeywords())
                .addRow(new ListBuilder.RowBuilder()
                        .setTitle(mContext.getText(R.string.doze_always_on_title))
                        .setTitle(mContext.getText(title))
                        .setSubtitle(mContext.getText(R.string.doze_always_on_summary))
                        .setPrimaryAction(
                                SliceAction.createToggle(toggleAction, null /* actionTitle */,
+10 −53
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.display

import android.app.settings.SettingsEnums.ACTION_AMBIENT_DISPLAY_ALWAYS_ON
@@ -22,18 +21,14 @@ import android.hardware.display.AmbientDisplayConfiguration
import android.os.SystemProperties
import android.os.UserHandle
import android.os.UserManager
import android.provider.Settings.Secure.DOZE_ALWAYS_ON
import com.android.settings.R
import com.android.settings.contract.KEY_AMBIENT_DISPLAY_ALWAYS_ON
import com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController.isAodSuppressedByBedtime
import com.android.settings.display.ambient.AmbientDisplayStorage
import com.android.settings.metrics.PreferenceActionMetricsProvider
import com.android.settings.restriction.PreferenceRestrictionMixin
import com.android.settingslib.datastore.AbstractKeyedDataObservable
import com.android.settingslib.datastore.HandlerExecutor
import com.android.settingslib.datastore.KeyValueStore
import com.android.settingslib.datastore.KeyedObserver
import com.android.settingslib.datastore.SettingsSecureStore
import com.android.settingslib.datastore.SettingsStore
import com.android.settingslib.metadata.PreferenceAvailabilityProvider
import com.android.settingslib.metadata.PreferenceSummaryProvider
import com.android.settingslib.metadata.ReadWritePermit
@@ -41,6 +36,10 @@ import com.android.settingslib.metadata.SensitivityLevel
import com.android.settingslib.metadata.SwitchPreference

// LINT.IfChange
/**
 * Contains the SwitchPreference for use on the Lock screen page. It is being migrated to
 * [AmbientDisplayAlwaysOnPreferenceScreen].
 */
class AmbientDisplayAlwaysOnPreference :
    SwitchPreference(KEY, R.string.doze_always_on_title, R.string.doze_always_on_summary),
    PreferenceActionMetricsProvider,
@@ -73,7 +72,7 @@ class AmbientDisplayAlwaysOnPreference :
            }
        )

    override fun storage(context: Context): KeyValueStore = Storage(context)
    override fun storage(context: Context): KeyValueStore = AmbientDisplayStorage(context)

    override fun getReadPermissions(context: Context) = SettingsSecureStore.getReadPermissions()

@@ -82,58 +81,16 @@ class AmbientDisplayAlwaysOnPreference :
    override fun getReadPermit(context: Context, callingPid: Int, callingUid: Int) =
        ReadWritePermit.ALLOW

    override fun getWritePermit(
        context: Context,
        value: Boolean?,
        callingPid: Int,
        callingUid: Int,
    ) = ReadWritePermit.ALLOW
    override fun getWritePermit(context: Context, callingPid: Int, callingUid: Int) =
        ReadWritePermit.ALLOW

    override val sensitivityLevel
        get() = SensitivityLevel.NO_SENSITIVITY

    /**
     * Datastore of the preference.
     *
     * The preference key and underlying storage key are the different, leverage
     * [AbstractKeyedDataObservable] to redirect data change event.
     */
    @Suppress("UNCHECKED_CAST")
    class Storage(
        private val context: Context,
        private val settingsStore: SettingsStore = SettingsSecureStore.get(context),
    ) : AbstractKeyedDataObservable<String>(), KeyedObserver<String>, KeyValueStore {

        override fun contains(key: String) = settingsStore.contains(DOZE_ALWAYS_ON)

        override fun <T : Any> getDefaultValue(key: String, valueType: Class<T>) =
            context.resources.getBoolean(com.android.internal.R.bool.config_dozeAlwaysOnEnabled)
                as T

        override fun <T : Any> getValue(key: String, valueType: Class<T>) =
            settingsStore.getValue(DOZE_ALWAYS_ON, valueType) ?: getDefaultValue(key, valueType)

        override fun <T : Any> setValue(key: String, valueType: Class<T>, value: T?) =
            settingsStore.setValue(DOZE_ALWAYS_ON, valueType, value)

        override fun onFirstObserverAdded() {
            // observe the underlying storage key
            settingsStore.addObserver(DOZE_ALWAYS_ON, this, HandlerExecutor.main)
        }

        override fun onKeyChanged(key: String, reason: Int) {
            // forward data change to preference hierarchy key
            notifyChange(KEY, reason)
        }

        override fun onLastObserverRemoved() {
            settingsStore.removeObserver(DOZE_ALWAYS_ON, this)
        }
    }

    companion object {
        const val KEY = KEY_AMBIENT_DISPLAY_ALWAYS_ON
        private const val PROP_AWARE_AVAILABLE = "ro.vendor.aware_available"
        const val PROP_AWARE_AVAILABLE = "ro.vendor.aware_available"
    }
}

// LINT.ThenChange(AmbientDisplayAlwaysOnPreferenceController.java)
+8 −1
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.settings.display;

import static com.android.systemui.shared.Flags.ambientAod;

import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.display.AmbientDisplayConfiguration;
@@ -45,9 +47,14 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
        super(context, key);
    }

    protected boolean ambientAodMigration() {
        return !ambientAod();
    }

    @Override
    public int getAvailabilityStatus() {
        return isAvailable(getConfig())
        return ambientAodMigration()
                && isAvailable(getConfig())
                && !SystemProperties.getBoolean(PROP_AWARE_AVAILABLE, false) ?
                AVAILABLE : UNSUPPORTED_ON_DEVICE;
    }
Loading