1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 package com.android.systemui.shared.customization.data.content 19 20 import android.content.ContentResolver 21 import android.net.Uri 22 23 /** Contract definitions for querying content about keyguard quick affordances. */ 24 object CustomizationProviderContract { 25 26 const val AUTHORITY = "com.android.systemui.customization" 27 const val PERMISSION = "android.permission.CUSTOMIZE_SYSTEM_UI" 28 29 private val BASE_URI: Uri = 30 Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).build() 31 32 /** Namespace for lock screen shortcut (quick affordance) tables. */ 33 object LockScreenQuickAffordances { 34 35 const val NAMESPACE = "lockscreen_quickaffordance" 36 37 private val LOCK_SCREEN_QUICK_AFFORDANCE_BASE_URI: Uri = 38 BASE_URI.buildUpon().path(NAMESPACE).build() 39 qualifiedTablePathnull40 fun qualifiedTablePath(tableName: String): String { 41 return "$NAMESPACE/$tableName" 42 } 43 44 /** 45 * Table for slots. 46 * 47 * Slots are positions where affordances can be placed on the lock screen. Affordances that 48 * are placed on slots are said to be "selected". The system supports the idea of multiple 49 * affordances per slot, though the implementation may limit the number of affordances on 50 * each slot. 51 * 52 * Supported operations: 53 * - Query - to know which slots are available, query the [SlotTable.URI] [Uri]. The result 54 * set will contain rows with the [SlotTable.Columns] columns. 55 */ 56 object SlotTable { 57 const val TABLE_NAME = "slots" 58 val URI: Uri = 59 LOCK_SCREEN_QUICK_AFFORDANCE_BASE_URI.buildUpon().appendPath(TABLE_NAME).build() 60 61 object Columns { 62 /** String. Unique ID for this slot. */ 63 const val ID = "id" 64 /** Integer. The maximum number of affordances that can be placed in the slot. */ 65 const val CAPACITY = "capacity" 66 } 67 } 68 69 /** 70 * Table for affordances. 71 * 72 * Affordances are actions/buttons that the user can execute. They are placed on slots on 73 * the lock screen. 74 * 75 * Supported operations: 76 * - Query - to know about all the affordances that are available on the device, regardless 77 * of which ones are currently selected, query the [AffordanceTable.URI] [Uri]. The result 78 * set will contain rows, each with the columns specified in [AffordanceTable.Columns]. 79 */ 80 object AffordanceTable { 81 const val TABLE_NAME = "affordances" 82 val URI: Uri = 83 LOCK_SCREEN_QUICK_AFFORDANCE_BASE_URI.buildUpon().appendPath(TABLE_NAME).build() 84 const val ENABLEMENT_INSTRUCTIONS_DELIMITER = "][" 85 const val COMPONENT_NAME_SEPARATOR = "/" 86 87 object Columns { 88 /** String. Unique ID for this affordance. */ 89 const val ID = "id" 90 /** String. User-visible name for this affordance. */ 91 const val NAME = "name" 92 /** 93 * Integer. Resource ID for the drawable to load for this affordance. This is a 94 * resource ID from the system UI package. 95 */ 96 const val ICON = "icon" 97 /** Integer. `1` if the affordance is enabled or `0` if it disabled. */ 98 const val IS_ENABLED = "is_enabled" 99 /** 100 * String. List of strings, delimited by [ENABLEMENT_INSTRUCTIONS_DELIMITER] to be 101 * shown to the user if the affordance is disabled and the user selects the 102 * affordance. 103 */ 104 const val ENABLEMENT_INSTRUCTIONS = "enablement_instructions" 105 /** 106 * String. Optional label for a button that, when clicked, opens a destination 107 * activity where the user can re-enable the disabled affordance. 108 */ 109 const val ENABLEMENT_ACTION_TEXT = "enablement_action_text" 110 /** 111 * String. Optional package name and activity action string, delimited by 112 * [COMPONENT_NAME_SEPARATOR] to use with an `Intent` to start an activity that 113 * opens a destination where the user can re-enable the disabled affordance. 114 */ 115 const val ENABLEMENT_COMPONENT_NAME = "enablement_action_intent" 116 /** 117 * Byte array. Optional parcelled `Intent` to use to start an activity that can be 118 * used to configure the affordance. 119 */ 120 const val CONFIGURE_INTENT = "configure_intent" 121 } 122 } 123 124 /** 125 * Table for selections. 126 * 127 * Selections are pairs of slot and affordance IDs. 128 * 129 * Supported operations: 130 * - Insert - to insert an affordance and place it in a slot, insert values for the columns 131 * into the [SelectionTable.URI] [Uri]. The maximum capacity rule is enforced by the 132 * system. Selecting a new affordance for a slot that is already full will automatically 133 * remove the oldest affordance from the slot. 134 * - Query - to know which affordances are set on which slots, query the 135 * [SelectionTable.URI] [Uri]. The result set will contain rows, each of which with the 136 * columns from [SelectionTable.Columns]. 137 * - Delete - to unselect an affordance, removing it from a slot, delete from the 138 * [SelectionTable.URI] [Uri], passing in values for each column. 139 */ 140 object SelectionTable { 141 const val TABLE_NAME = "selections" 142 val URI: Uri = 143 LOCK_SCREEN_QUICK_AFFORDANCE_BASE_URI.buildUpon().appendPath(TABLE_NAME).build() 144 145 object Columns { 146 /** String. Unique ID for the slot. */ 147 const val SLOT_ID = "slot_id" 148 /** String. Unique ID for the selected affordance. */ 149 const val AFFORDANCE_ID = "affordance_id" 150 /** String. Human-readable name for the affordance. */ 151 const val AFFORDANCE_NAME = "affordance_name" 152 } 153 } 154 } 155 156 /** 157 * Table for flags. 158 * 159 * Flags are key-value pairs. 160 * 161 * Supported operations: 162 * - Query - to know the values of flags, query the [FlagsTable.URI] [Uri]. The result set will 163 * contain rows, each of which with the columns from [FlagsTable.Columns]. 164 */ 165 object FlagsTable { 166 const val TABLE_NAME = "flags" 167 val URI: Uri = BASE_URI.buildUpon().path(TABLE_NAME).build() 168 169 /** Flag denoting whether the Wallpaper Picker should use the new, revamped UI. */ 170 const val FLAG_NAME_REVAMPED_WALLPAPER_UI = "revamped_wallpaper_ui" 171 172 /** 173 * Flag denoting whether the customizable lock screen quick affordances feature is enabled. 174 */ 175 const val FLAG_NAME_CUSTOM_LOCK_SCREEN_QUICK_AFFORDANCES_ENABLED = 176 "is_custom_lock_screen_quick_affordances_feature_enabled" 177 178 /** Flag denoting whether the customizable clocks feature is enabled. */ 179 const val FLAG_NAME_CUSTOM_CLOCKS_ENABLED = "is_custom_clocks_feature_enabled" 180 181 /** Flag denoting whether the Wallpaper preview should use the full screen UI. */ 182 const val FLAG_NAME_WALLPAPER_FULLSCREEN_PREVIEW = "wallpaper_fullscreen_preview" 183 184 /** Flag denoting whether the Monochromatic Theme is enabled. */ 185 const val FLAG_NAME_MONOCHROMATIC_THEME = "is_monochromatic_theme_enabled" 186 187 /** Flag denoting AI Wallpapers are enabled in wallpaper picker. */ 188 const val FLAG_NAME_WALLPAPER_PICKER_UI_FOR_AIWP = "wallpaper_picker_ui_for_aiwp" 189 190 object Columns { 191 /** String. Unique ID for the flag. */ 192 const val NAME = "name" 193 /** Int. Value of the flag. `1` means `true` and `0` means `false`. */ 194 const val VALUE = "value" 195 } 196 } 197 } 198