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

Commit ed7dd1dc authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

Exposes feature flag to wallpaper picker.

Wallpaper picker, through the shared library, can now query the feature
flag to know whether the customizable quick affordance feature is
enabled or not.

Bug: 254857639
Test: manually verified that turning the flag on and off on the system
UI side is reflected to WPPG with a visible or gone view and that
selecting affordances from WPPG still works

Change-Id: I2ea2baa4dbe935f1173648d673a64267ba8b0de2
parent 5a574a1d
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -108,4 +108,30 @@ object KeyguardQuickAffordanceProviderContract {
            const val AFFORDANCE_ID = "affordance_id"
        }
    }

    /**
     * Table for flags.
     *
     * Flags are key-value pairs.
     *
     * Supported operations:
     * - Query - to know the values of flags, query the [FlagsTable.URI] [Uri]. The result set will
     * contain rows, each of which with the columns from [FlagsTable.Columns].
     */
    object FlagsTable {
        const val TABLE_NAME = "flags"
        val URI: Uri = BASE_URI.buildUpon().path(TABLE_NAME).build()

        /**
         * Flag denoting whether the customizable lock screen quick affordances feature is enabled.
         */
        const val FLAG_NAME_FEATURE_ENABLED = "is_feature_enabled"

        object Columns {
            /** String. Unique ID for the flag. */
            const val NAME = "name"
            /** Int. Value of the flag. `1` means `true` and `0` means `false`. */
            const val VALUE = "value"
        }
    }
}
+32 −0
Original line number Diff line number Diff line
@@ -56,6 +56,11 @@ class KeyguardQuickAffordanceProvider :
                Contract.SelectionTable.TABLE_NAME,
                MATCH_CODE_ALL_SELECTIONS,
            )
            addURI(
                Contract.AUTHORITY,
                Contract.FlagsTable.TABLE_NAME,
                MATCH_CODE_ALL_FLAGS,
            )
        }

    override fun onCreate(): Boolean {
@@ -76,6 +81,7 @@ class KeyguardQuickAffordanceProvider :
            when (uriMatcher.match(uri)) {
                MATCH_CODE_ALL_SLOTS,
                MATCH_CODE_ALL_AFFORDANCES,
                MATCH_CODE_ALL_FLAGS,
                MATCH_CODE_ALL_SELECTIONS -> "vnd.android.cursor.dir/vnd."
                else -> null
            }
@@ -85,6 +91,7 @@ class KeyguardQuickAffordanceProvider :
                MATCH_CODE_ALL_SLOTS -> Contract.SlotTable.TABLE_NAME
                MATCH_CODE_ALL_AFFORDANCES -> Contract.AffordanceTable.TABLE_NAME
                MATCH_CODE_ALL_SELECTIONS -> Contract.SelectionTable.TABLE_NAME
                MATCH_CODE_ALL_FLAGS -> Contract.FlagsTable.TABLE_NAME
                else -> null
            }

@@ -114,6 +121,7 @@ class KeyguardQuickAffordanceProvider :
            MATCH_CODE_ALL_AFFORDANCES -> queryAffordances()
            MATCH_CODE_ALL_SLOTS -> querySlots()
            MATCH_CODE_ALL_SELECTIONS -> querySelections()
            MATCH_CODE_ALL_FLAGS -> queryFlags()
            else -> null
        }
    }
@@ -248,6 +256,29 @@ class KeyguardQuickAffordanceProvider :
            }
    }

    private fun queryFlags(): Cursor {
        return MatrixCursor(
                arrayOf(
                    Contract.FlagsTable.Columns.NAME,
                    Contract.FlagsTable.Columns.VALUE,
                )
            )
            .apply {
                interactor.getPickerFlags().forEach { flag ->
                    addRow(
                        arrayOf(
                            flag.name,
                            if (flag.value) {
                                1
                            } else {
                                0
                            },
                        )
                    )
                }
            }
    }

    private fun deleteSelection(
        uri: Uri,
        selectionArgs: Array<out String>?,
@@ -290,5 +321,6 @@ class KeyguardQuickAffordanceProvider :
        private const val MATCH_CODE_ALL_SLOTS = 1
        private const val MATCH_CODE_ALL_AFFORDANCES = 2
        private const val MATCH_CODE_ALL_SELECTIONS = 3
        private const val MATCH_CODE_ALL_FLAGS = 4
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -28,11 +28,13 @@ import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanc
import com.android.systemui.keyguard.data.repository.KeyguardQuickAffordanceRepository
import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordanceModel
import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceRegistry
import com.android.systemui.keyguard.shared.model.KeyguardPickerFlag
import com.android.systemui.keyguard.shared.model.KeyguardQuickAffordancePickerRepresentation
import com.android.systemui.keyguard.shared.model.KeyguardSlotPickerRepresentation
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.settings.UserTracker
import com.android.systemui.shared.keyguard.data.content.KeyguardQuickAffordanceProviderContract
import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots
import com.android.systemui.statusbar.policy.KeyguardStateController
import dagger.Lazy
@@ -314,6 +316,15 @@ constructor(
        return repository.get().getSlotPickerRepresentations()
    }

    fun getPickerFlags(): List<KeyguardPickerFlag> {
        return listOf(
            KeyguardPickerFlag(
                name = KeyguardQuickAffordanceProviderContract.FlagsTable.FLAG_NAME_FEATURE_ENABLED,
                value = featureFlags.isEnabled(Flags.CUSTOMIZABLE_LOCK_SCREEN_QUICK_AFFORDANCES),
            )
        )
    }

    companion object {
        private const val TAG = "KeyguardQuickAffordanceInteractor"
        private const val DELIMITER = "::"
+24 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.android.systemui.keyguard.shared.model

/** Represents a flag that's consumed by the settings or wallpaper picker app. */
data class KeyguardPickerFlag(
    val name: String,
    val value: Boolean,
)