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

Commit c0ed9adc authored by Jacky Wang's avatar Jacky Wang Committed by Android (Google) Code Review
Browse files

Merge "[Catalyst] Add tag contracts for device state" into main

parents 422e23ef ea71ac6c
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source 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 com.android.settings.contract

/**
 * Tag to be associated with screen, which indicates some preferences in the screen are related to
 * device state.
 *
 * Preferences associated with [TAG_DEVICE_STATE_PREFERENCE] are related to device state.
 */
const val TAG_DEVICE_STATE_SCREEN = "device_state_screen"

/**
 * Tag to be associated with preference, which contains certain device state.
 *
 * The screen should be associated with [TAG_DEVICE_STATE_SCREEN].
 */
const val TAG_DEVICE_STATE_PREFERENCE = "device_state_pref"
+5 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.content.Context
import android.content.pm.ApplicationInfo
import android.os.Bundle
import com.android.settings.R
import com.android.settings.contract.TAG_DEVICE_STATE_PREFERENCE
import com.android.settings.contract.TAG_DEVICE_STATE_SCREEN
import com.android.settings.flags.Flags
import com.android.settings.spa.app.storage.StorageType
import com.android.settingslib.datastore.KeyValueStore
@@ -65,6 +67,9 @@ class AppInfoStorageScreen(
    override val screenTitle: Int
        get() = R.string.storage_label

    override fun tags(context: Context) =
        arrayOf(TAG_DEVICE_STATE_SCREEN, TAG_DEVICE_STATE_PREFERENCE)

    override fun getTitle(context: Context): CharSequence? {
        return appInfo.loadLabel(context.packageManager).toString()
    }
+3 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.android.settings.Settings.StorageUseActivity
import com.android.settings.contract.TAG_DEVICE_STATE_SCREEN
import com.android.settings.flags.Flags
import com.android.settings.spa.app.storage.StorageType
import com.android.settingslib.metadata.PreferenceHierarchy
@@ -41,6 +42,8 @@ class AppStorageAppListScreen : PreferenceScreenCreator, PreferenceHierarchyGene
    override val title: Int
        get() = StorageType.Apps.titleResource

    override fun tags(context: Context) = arrayOf(TAG_DEVICE_STATE_SCREEN)

    override fun isFlagEnabled(context: Context) = Flags.catalystAppList()

    override fun hasCompleteHierarchy() = false