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 package com.android.settingslib.spa.search 17 18 /** 19 * Intent action used to identify SpaSearchProvider instances. This is used in the {@code 20 * <intent-filter>} of a {@code <provider>}. 21 */ 22 const val PROVIDER_INTERFACE = "android.content.action.SPA_SEARCH_PROVIDER" 23 24 /** ContentProvider path for search static data */ 25 const val SEARCH_STATIC_DATA = "search_static_data" 26 27 /** ContentProvider path for search dynamic data */ 28 const val SEARCH_DYNAMIC_DATA = "search_dynamic_data" 29 30 /** ContentProvider path for search immutable status */ 31 const val SEARCH_IMMUTABLE_STATUS = "search_immutable_status" 32 33 /** ContentProvider path for search mutable status */ 34 const val SEARCH_MUTABLE_STATUS = "search_mutable_status" 35 36 /** ContentProvider path for search static row */ 37 const val SEARCH_STATIC_ROW = "search_static_row" 38 39 /** ContentProvider path for search dynamic row */ 40 const val SEARCH_DYNAMIC_ROW = "search_dynamic_row" 41 42 43 /** Enum to define all column names in provider. */ 44 enum class ColumnEnum(val id: String) { 45 ENTRY_ID("entryId"), 46 ENTRY_LABEL("entryLabel"), 47 SEARCH_TITLE("searchTitle"), 48 SEARCH_KEYWORD("searchKw"), 49 SEARCH_PATH("searchPath"), 50 INTENT_TARGET_PACKAGE("intentTargetPackage"), 51 INTENT_TARGET_CLASS("intentTargetClass"), 52 INTENT_EXTRAS("intentExtras"), 53 SLICE_URI("sliceUri"), 54 ENTRY_DISABLED("entryDisabled"), 55 } 56 57 /** Enum to define all queries supported in the provider. */ 58 @SuppressWarnings("Immutable") 59 enum class QueryEnum( 60 val queryPath: String, 61 val columnNames: List<ColumnEnum> 62 ) { 63 SEARCH_STATIC_DATA_QUERY( 64 SEARCH_STATIC_DATA, 65 listOf( 66 ColumnEnum.ENTRY_ID, 67 ColumnEnum.ENTRY_LABEL, 68 ColumnEnum.SEARCH_TITLE, 69 ColumnEnum.SEARCH_KEYWORD, 70 ColumnEnum.SEARCH_PATH, 71 ColumnEnum.INTENT_TARGET_PACKAGE, 72 ColumnEnum.INTENT_TARGET_CLASS, 73 ColumnEnum.INTENT_EXTRAS, 74 ColumnEnum.SLICE_URI, 75 ) 76 ), 77 SEARCH_DYNAMIC_DATA_QUERY( 78 SEARCH_DYNAMIC_DATA, 79 listOf( 80 ColumnEnum.ENTRY_ID, 81 ColumnEnum.ENTRY_LABEL, 82 ColumnEnum.SEARCH_TITLE, 83 ColumnEnum.SEARCH_KEYWORD, 84 ColumnEnum.SEARCH_PATH, 85 ColumnEnum.INTENT_TARGET_PACKAGE, 86 ColumnEnum.INTENT_TARGET_CLASS, 87 ColumnEnum.INTENT_EXTRAS, 88 ColumnEnum.SLICE_URI, 89 ) 90 ), 91 SEARCH_IMMUTABLE_STATUS_DATA_QUERY( 92 SEARCH_IMMUTABLE_STATUS, 93 listOf( 94 ColumnEnum.ENTRY_ID, 95 ColumnEnum.ENTRY_LABEL, 96 ColumnEnum.ENTRY_DISABLED, 97 ) 98 ), 99 SEARCH_MUTABLE_STATUS_DATA_QUERY( 100 SEARCH_MUTABLE_STATUS, 101 listOf( 102 ColumnEnum.ENTRY_ID, 103 ColumnEnum.ENTRY_LABEL, 104 ColumnEnum.ENTRY_DISABLED, 105 ) 106 ), 107 SEARCH_STATIC_ROW_QUERY( 108 SEARCH_STATIC_ROW, 109 listOf( 110 ColumnEnum.ENTRY_ID, 111 ColumnEnum.ENTRY_LABEL, 112 ColumnEnum.SEARCH_TITLE, 113 ColumnEnum.SEARCH_KEYWORD, 114 ColumnEnum.SEARCH_PATH, 115 ColumnEnum.INTENT_TARGET_PACKAGE, 116 ColumnEnum.INTENT_TARGET_CLASS, 117 ColumnEnum.INTENT_EXTRAS, 118 ColumnEnum.SLICE_URI, 119 ColumnEnum.ENTRY_DISABLED, 120 ) 121 ), 122 SEARCH_DYNAMIC_ROW_QUERY( 123 SEARCH_DYNAMIC_ROW, 124 listOf( 125 ColumnEnum.ENTRY_ID, 126 ColumnEnum.ENTRY_LABEL, 127 ColumnEnum.SEARCH_TITLE, 128 ColumnEnum.SEARCH_KEYWORD, 129 ColumnEnum.SEARCH_PATH, 130 ColumnEnum.INTENT_TARGET_PACKAGE, 131 ColumnEnum.INTENT_TARGET_CLASS, 132 ColumnEnum.INTENT_EXTRAS, 133 ColumnEnum.SLICE_URI, 134 ColumnEnum.ENTRY_DISABLED, 135 ) 136 ), 137 } 138