From: LuK1337 Date: Sat, 12 Mar 2022 16:37:01 +0000 (+0000) Subject: SamsungDAP: Add a basic search indexables provider X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d8a3e3d52f3f73da47d0608c0fffe25933350877;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung.git SamsungDAP: Add a basic search indexables provider Change-Id: Ibab1cb6e0b3803afc95452fa36a991103fc557ab --- diff --git a/dap/AndroidManifest.xml b/dap/AndroidManifest.xml index f9cd0f2..faf11ef 100644 --- a/dap/AndroidManifest.xml +++ b/dap/AndroidManifest.xml @@ -42,6 +42,18 @@ android:value="com.android.settings.category.ia.sound" /> + + + + + + diff --git a/dap/src/org/lineageos/dap/DolbySearchIndexablesProvider.kt b/dap/src/org/lineageos/dap/DolbySearchIndexablesProvider.kt new file mode 100644 index 0000000..5d6933e --- /dev/null +++ b/dap/src/org/lineageos/dap/DolbySearchIndexablesProvider.kt @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2022 The LineageOS 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 org.lineageos.dap + +import android.database.Cursor +import android.database.MatrixCursor +import android.provider.SearchIndexableResource +import android.provider.SearchIndexablesProvider +import android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_CLASS_NAME +import android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_ICON_RESID +import android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_ACTION +import android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS +import android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE +import android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RANK +import android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RESID +import android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS +import android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS +import android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLUMNS + +class DolbySearchIndexablesProvider : SearchIndexablesProvider() { + override fun onCreate(): Boolean = true + + override fun queryXmlResources(projection: Array?): Cursor { + val cursor = MatrixCursor(INDEXABLES_XML_RES_COLUMNS) + INDEXABLE_RES.forEach { + cursor.addRow(generateResourceRef(it)) + } + return cursor + } + + override fun queryRawData(projection: Array?): Cursor { + return MatrixCursor(INDEXABLES_RAW_COLUMNS) + } + + override fun queryNonIndexableKeys(projection: Array?): Cursor { + return MatrixCursor(NON_INDEXABLES_KEYS_COLUMNS) + } + + private fun generateResourceRef(sir: SearchIndexableResource): Array { + val ref = arrayOfNulls(7) + ref[COLUMN_INDEX_XML_RES_RANK] = sir.rank + ref[COLUMN_INDEX_XML_RES_RESID] = sir.xmlResId + ref[COLUMN_INDEX_XML_RES_CLASS_NAME] = null + ref[COLUMN_INDEX_XML_RES_ICON_RESID] = sir.iconResId + ref[COLUMN_INDEX_XML_RES_INTENT_ACTION] = "com.android.settings.action.EXTRA_SETTINGS" + ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE] = "org.lineageos.dap" + ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS] = sir.className + return ref + } + + companion object { + private const val TAG = "DolbySearchIndexablesProvider" + + private val INDEXABLE_RES = arrayOf( + SearchIndexableResource( + 1, R.xml.dolby_settings, DolbyActivity::class.java.name, 0 + ) + ) + } +}