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 import com.android.systemui.shared.customization.data.SensorLocation 23 24 /** Contract definitions for querying content about keyguard quick affordances. */ 25 object CustomizationProviderContract { 26 27 const val AUTHORITY = "com.android.systemui.customization" 28 const val PERMISSION = "android.permission.CUSTOMIZE_SYSTEM_UI" 29 30 private val BASE_URI: Uri = 31 Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).build() 32 33 /** Namespace for lock screen shortcut (quick affordance) tables. */ 34 object LockScreenQuickAffordances { 35 36 const val NAMESPACE = "lockscreen_quickaffordance" 37 38 private val LOCK_SCREEN_QUICK_AFFORDANCE_BASE_URI: Uri = 39 BASE_URI.buildUpon().path(NAMESPACE).build() 40 qualifiedTablePathnull41 fun qualifiedTablePath(tableName: String): String { 42 return "$NAMESPACE/$tableName" 43 } 44 45 /** 46 * Table for slots. 47 * 48 * Slots are positions where affordances can be placed on the lock screen. Affordances that 49 * are placed on slots are said to be "selected". The system supports the idea of multiple 50 * affordances per slot, though the implementation may limit the number of affordances on 51 * each slot. 52 * 53 * Supported operations: 54 * - Query - to know which slots are available, query the [SlotTable.URI] [Uri]. The result 55 * set will contain rows with the [SlotTable.Columns] columns. 56 */ 57 object SlotTable { 58 const val TABLE_NAME = "slots" 59 val URI: Uri = 60 LOCK_SCREEN_QUICK_AFFORDANCE_BASE_URI.buildUpon().appendPath(TABLE_NAME).build() 61 62 object Columns { 63 /** String. Unique ID for this slot. */ 64 const val ID = "id" 65 /** Integer. The maximum number of affordances that can be placed in the slot. */ 66 const val CAPACITY = "capacity" 67 } 68 } 69 70 /** 71 * Table for affordances. 72 * 73 * Affordances are actions/buttons that the user can execute. They are placed on slots on 74 * the lock screen. 75 * 76 * Supported operations: 77 * - Query - to know about all the affordances that are available on the device, regardless 78 * of which ones are currently selected, query the [AffordanceTable.URI] [Uri]. The result 79 * set will contain rows, each with the columns specified in [AffordanceTable.Columns]. 80 */ 81 object AffordanceTable { 82 const val TABLE_NAME = "affordances" 83 val URI: Uri = 84 LOCK_SCREEN_QUICK_AFFORDANCE_BASE_URI.buildUpon().appendPath(TABLE_NAME).build() 85 86 object Columns { 87 /** String. Unique ID for this affordance. */ 88 const val ID = "id" 89 /** String. User-visible name for this affordance. */ 90 const val NAME = "name" 91 /** 92 * Integer. Resource ID for the drawable to load for this affordance. This is a 93 * resource ID from the system UI package. 94 */ 95 const val ICON = "icon" 96 /** Integer. `1` if the affordance is enabled or `0` if it disabled. */ 97 const val IS_ENABLED = "is_enabled" 98 /** 99 * String. Text to be shown to the user if the affordance is disabled and the user 100 * selects the affordance. 101 */ 102 const val ENABLEMENT_EXPLANATION = "enablement_explanation" 103 /** 104 * String. Optional label for a button that, when clicked, opens a destination 105 * activity where the user can re-enable the disabled affordance. 106 */ 107 const val ENABLEMENT_ACTION_TEXT = "enablement_action_text" 108 /** 109 * String. Optional URI-formatted `Intent` (formatted using 110 * `Intent#toUri(Intent.URI_INTENT_SCHEME)` used to start an activity that opens a 111 * destination where the user can re-enable the disabled affordance. 112 */ 113 const val ENABLEMENT_ACTION_INTENT = "enablement_action_intent" 114 /** 115 * Byte array. Optional parcelled `Intent` to use to start an activity that can be 116 * used to configure the affordance. 117 */ 118 const val CONFIGURE_INTENT = "configure_intent" 119 } 120 } 121 122 /** 123 * Table for selections. 124 * 125 * Selections are pairs of slot and affordance IDs. 126 * 127 * Supported operations: 128 * - Insert - to insert an affordance and place it in a slot, insert values for the columns 129 * into the [SelectionTable.URI] [Uri]. The maximum capacity rule is enforced by the 130 * system. Selecting a new affordance for a slot that is already full will automatically 131 * remove the oldest affordance from the slot. 132 * - Query - to know which affordances are set on which slots, query the 133 * [SelectionTable.URI] [Uri]. The result set will contain rows, each of which with the 134 * columns from [SelectionTable.Columns]. 135 * - Delete - to unselect an affordance, removing it from a slot, delete from the 136 * [SelectionTable.URI] [Uri], passing in values for each column. 137 */ 138 object SelectionTable { 139 const val TABLE_NAME = "selections" 140 val URI: Uri = 141 LOCK_SCREEN_QUICK_AFFORDANCE_BASE_URI.buildUpon().appendPath(TABLE_NAME).build() 142 143 object Columns { 144 /** String. Unique ID for the slot. */ 145 const val SLOT_ID = "slot_id" 146 /** String. Unique ID for the selected affordance. */ 147 const val AFFORDANCE_ID = "affordance_id" 148 /** String. Human-readable name for the affordance. */ 149 const val AFFORDANCE_NAME = "affordance_name" 150 } 151 } 152 } 153 154 /** 155 * Table for flags. 156 * 157 * Flags are key-value pairs. 158 * 159 * Supported operations: 160 * - Query - to know the values of flags, query the [FlagsTable.URI] [Uri]. The result set will 161 * contain rows, each of which with the columns from [FlagsTable.Columns]. 162 */ 163 object FlagsTable { 164 const val TABLE_NAME = "flags" 165 val URI: Uri = BASE_URI.buildUpon().path(TABLE_NAME).build() 166 167 /** 168 * Flag denoting whether the customizable lock screen quick affordances feature is enabled. 169 */ 170 const val FLAG_NAME_CUSTOM_LOCK_SCREEN_QUICK_AFFORDANCES_ENABLED = 171 "is_custom_lock_screen_quick_affordances_feature_enabled" 172 173 /** Flag denoting whether the customizable clocks feature is enabled. */ 174 const val FLAG_NAME_CUSTOM_CLOCKS_ENABLED = "is_custom_clocks_feature_enabled" 175 176 /** Flag denoting whether the Wallpaper preview should use the full screen UI. */ 177 const val FLAG_NAME_WALLPAPER_FULLSCREEN_PREVIEW = "wallpaper_fullscreen_preview" 178 179 /** Flag denoting whether the Monochromatic Theme is enabled. */ 180 const val FLAG_NAME_MONOCHROMATIC_THEME = "is_monochromatic_theme_enabled" 181 182 /** Flag denoting AI Wallpapers are enabled in wallpaper picker. */ 183 const val FLAG_NAME_WALLPAPER_PICKER_UI_FOR_AIWP = "wallpaper_picker_ui_for_aiwp" 184 185 /** Flag denoting transit clock are enabled in wallpaper picker. */ 186 const val FLAG_NAME_PAGE_TRANSITIONS = "wallpaper_picker_page_transitions" 187 188 /** Flag denoting adding apply button to wallpaper picker's grid preview page. */ 189 const val FLAG_NAME_GRID_APPLY_BUTTON = "wallpaper_picker_grid_apply_button" 190 191 /** Flag denoting whether preview loading animation is enabled. */ 192 const val FLAG_NAME_WALLPAPER_PICKER_PREVIEW_ANIMATION = 193 "wallpaper_picker_preview_animation" 194 195 object Columns { 196 /** String. Unique ID for the flag. */ 197 const val NAME = "name" 198 /** Int. Value of the flag. `1` means `true` and `0` means `false`. */ 199 const val VALUE = "value" 200 } 201 } 202 203 object RuntimeValuesTable { 204 const val TABLE_NAME = "runtime_values" 205 val URI: Uri = BASE_URI.buildUpon().path(TABLE_NAME).build() 206 207 /** 208 * This key corresponds to an Int value, where `1` means `true` and `0` means `false`. 209 * 210 * Whether the shade layout should be wide (true) or narrow (false). 211 * 212 * In a wide layout, notifications and quick settings each take up only half the screen 213 * width (whether they are shown at the same time or not). In a narrow layout, they can each 214 * be as wide as the entire screen. 215 */ 216 const val KEY_IS_SHADE_LAYOUT_WIDE = "is_shade_layout_wide" 217 /** 218 * This key corresponds to a String value, representing the string form of [SensorLocation], 219 * which contains the information of the UDFPS location. 220 */ 221 const val KEY_UDFPS_LOCATION = "udfps_location" 222 223 object Columns { 224 /** String. Unique ID for the value. */ 225 const val NAME = "name" 226 /** Type depends on the key name. */ 227 const val VALUE = "value" 228 } 229 } 230 } 231