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

Commit 167f9d41 authored by Chaohui Wang's avatar Chaohui Wang Committed by Android (Google) Code Review
Browse files

Merge "New countryIfOriginLabel" into main

parents f2f44f50 87318b10
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import com.android.settings.deviceinfo.regulatory.RegulatoryInfo.getRegulatoryInfo
import com.android.settings.overlay.FeatureFactory.Companion.featureFactory

/**
 * [Activity] that displays regulatory information for the "Regulatory information"
@@ -53,8 +54,8 @@ class RegulatoryInfoDisplayActivity : Activity() {
            return
        }

        val regulatoryText = resources.getText(R.string.regulatory_info_text)
        if (regulatoryText.isNotEmpty()) {
        val regulatoryText = getRegulatoryText()
        if (!regulatoryText.isNullOrEmpty()) {
            builder.setMessage(regulatoryText)
            val dialog = builder.show()
            // we have to show the dialog first, or the setGravity() call will throw a NPE
@@ -64,4 +65,10 @@ class RegulatoryInfoDisplayActivity : Activity() {
            finish()
        }
    }

    private fun getRegulatoryText(): CharSequence? {
        val regulatoryInfoText = resources.getText(R.string.regulatory_info_text)
        if (regulatoryInfoText.isNotBlank()) return regulatoryInfoText
        return featureFactory.hardwareInfoFeatureProvider?.countryIfOriginLabel
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -23,4 +23,9 @@ interface HardwareInfoFeatureProvider {
     * Returns the manufactured year
     */
    val manufacturedYear: String?

    /**
     * The country of origin label.
     */
    val countryIfOriginLabel: String
}
+0 −24
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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

/**
 * Feature provider for hardware info
 */
object HardwareInfoFeatureProviderImpl : HardwareInfoFeatureProvider {
    override val manufacturedYear: String?
        get() = null
}
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -22,7 +22,8 @@ import com.android.settings.overlay.FeatureFactory.Companion.featureFactory
/** Preference controller for Manufactured Year. */
class ManufacturedYearPreferenceController(context: Context, preferenceKey: String) :
    BasePreferenceController(context, preferenceKey) {
    private val year: String? = featureFactory.hardwareInfoFeatureProvider.manufacturedYear

    private val year: String? = featureFactory.hardwareInfoFeatureProvider?.manufacturedYear

    override fun getAvailabilityStatus(): Int =
        if (!year.isNullOrEmpty()) AVAILABLE else UNSUPPORTED_ON_DEVICE
+5 −6
Original line number Diff line number Diff line
@@ -23,8 +23,7 @@ import android.os.SystemProperties
import androidx.annotation.DrawableRes
import androidx.annotation.VisibleForTesting
import com.android.settings.R


import com.android.settings.overlay.FeatureFactory.Companion.featureFactory

/** To load Regulatory Info from device. */
object RegulatoryInfo {
@@ -38,10 +37,10 @@ object RegulatoryInfo {

    /** Gets the regulatory drawable. */
    fun Context.getRegulatoryInfo(): Drawable? {
        val sku = getSku()
        val sku = getSku().lowercase()
        if (sku.isNotBlank()) {
            // When hardware coo property exists, use regulatory_info_<sku>_<coo> resource if valid.
            val coo = getCoo()
            val coo = getCoo().lowercase()
            if (coo.isNotBlank()) {
                getRegulatoryInfo("${REGULATORY_INFO_RESOURCE}_${sku}_$coo")?.let { return it }
            }
@@ -51,9 +50,9 @@ object RegulatoryInfo {
        return getRegulatoryInfo(REGULATORY_INFO_RESOURCE)
    }

    private fun getCoo(): String = SystemProperties.get(KEY_COO).lowercase()
    fun getCoo(): String = SystemProperties.get(KEY_COO)

    private fun getSku(): String = SystemProperties.get(KEY_SKU).lowercase()
    fun getSku(): String = SystemProperties.get(KEY_SKU)

    private fun Context.getRegulatoryInfo(fileName: String): Drawable? {
        val overlayPackageName =
Loading