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

Commit 1169adbe authored by Sunny Shao's avatar Sunny Shao
Browse files

[Catalyst] Add the skeleton of the About phone > Model

NO_IFTTT=Catalyst only

Test: manual
Bug: 407440073
Flag: com.android.settings.flags.device_state
Change-Id: I978fb8ba601591ae4ee015e380eeedb00375ee36
parent 35181f53
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -19,11 +19,15 @@ package com.android.settings.deviceinfo.hardwareinfo;
import android.app.settings.SettingsEnums;
import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;

// LINT.IfChange
@SearchIndexable
public class HardwareInfoFragment extends DashboardFragment {

@@ -44,6 +48,11 @@ public class HardwareInfoFragment extends DashboardFragment {
        return TAG;
    }

    @Override
    public @Nullable String getPreferenceScreenBindingKey(@NonNull Context context) {
        return HardwareInfoScreen.KEY;
    }

    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider(R.xml.hardware_info) {

@@ -53,3 +62,4 @@ public class HardwareInfoFragment extends DashboardFragment {
                }
            };
}
// LINT.ThenChange(HardwareInfoScreen.kt)
+68 −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.deviceinfo.hardwareinfo

import android.content.Context
import androidx.preference.Preference
import com.android.settings.R
import com.android.settings.deviceinfo.HardwareInfoPreferenceController.getDeviceModel
import com.android.settings.flags.Flags
import com.android.settingslib.metadata.PreferenceAvailabilityProvider
import com.android.settingslib.metadata.PreferenceSummaryProvider
import com.android.settingslib.metadata.ProvidePreferenceScreen
import com.android.settingslib.metadata.preferenceHierarchy
import com.android.settingslib.preference.PreferenceBinding
import com.android.settingslib.preference.PreferenceScreenCreator

// LINT.IfChange
@ProvidePreferenceScreen(HardwareInfoScreen.KEY)
class HardwareInfoScreen :
    PreferenceScreenCreator,
    PreferenceBinding,
    PreferenceAvailabilityProvider,
    PreferenceSummaryProvider {
    override val key: String
        get() = KEY

    override val title: Int
        get() = R.string.model_info

    override val keywords: Int
        get() = R.string.keywords_model_and_hardware

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

    override fun hasCompleteHierarchy() = false

    override fun fragmentClass() = HardwareInfoFragment::class.java

    override fun isAvailable(context: Context) =
        context.resources.getBoolean(R.bool.config_show_device_model)

    override fun getSummary(context: Context): CharSequence? = getDeviceModel()

    override fun createWidget(context: Context): Preference {
        return super.createWidget(context).apply { isCopyingEnabled = true }
    }

    override fun getPreferenceHierarchy(context: Context) = preferenceHierarchy(context, this) {}

    companion object {
        const val KEY = "device_model"
    }
}
// LINT.ThenChange(HardwareInfoFragment.java)