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

Commit c77f86a3 authored by Shamali P's avatar Shamali P
Browse files

Send NOT_KEYGUARD widget category exclusion filter to the widget picker

The newly added NOT_KEYGUARD category enables hosts that shows all
widgets to let widgets opt out from being displayed in keyguard like
surfaces.

Bug: 394047125
Test: Support app (see demos)
Flag: EXEMPT bugfix
Change-Id: Ied6d5f486eb8e17ba642431ead4baf63c9591f32
parent 242414e3
Loading
Loading
Loading
Loading
+19 −10
Original line number Diff line number Diff line
@@ -22,15 +22,24 @@ import android.appwidget.AppWidgetProviderInfo
 * The widget categories to display on communal hub (where categories is a bitfield with values that
 * match those in {@link AppWidgetProviderInfo}).
 */
@JvmInline
value class CommunalWidgetCategories(val categories: Int = defaultCategories) {
    fun contains(category: Int) = (categories and category) == category

    companion object {
        val defaultCategories: Int
object CommunalWidgetCategories {
    /**
     * Categories that are allowed on communal hub.
     * - Use "or" operator for including multiple categories.
     */
    val includedCategories: Int
        get() {
                return AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD or
                    AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN
            return AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN or
                AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD
        }

    /**
     * Categories to further filter included widgets by excluding certain opt-out categories.
     * - WIDGET_CATEGORY_NOT_KEYGUARD: widgets opted out of displaying on keyguard like surfaces.
     * - Use "and" operator for excluding multiple opt-out categories.
     */
    val excludedCategories: Int
        get() {
            return AppWidgetProviderInfo.WIDGET_CATEGORY_NOT_KEYGUARD.inv()
        }
}
+3 −1
Original line number Diff line number Diff line
@@ -241,8 +241,9 @@ constructor(
            )
            putExtra(
                AppWidgetManager.EXTRA_CATEGORY_FILTER,
                CommunalWidgetCategories.defaultCategories,
                CommunalWidgetCategories.includedCategories,
            )
            putExtra(EXTRA_CATEGORY_EXCLUSION_FILTER, CommunalWidgetCategories.excludedCategories)

            communalSettingsInteractor.workProfileUserDisallowedByDevicePolicy.value?.let {
                putExtra(EXTRA_USER_ID_FILTER, arrayListOf(it.id))
@@ -281,6 +282,7 @@ constructor(

        private const val EXTRA_DESIRED_WIDGET_WIDTH = "desired_widget_width"
        private const val EXTRA_DESIRED_WIDGET_HEIGHT = "desired_widget_height"
        private const val EXTRA_CATEGORY_EXCLUSION_FILTER = "category_exclusion_filter"
        private const val EXTRA_PICKER_TITLE = "picker_title"
        private const val EXTRA_PICKER_DESCRIPTION = "picker_description"
        private const val EXTRA_UI_SURFACE_KEY = "ui_surface"