blob: 73cc0c593cda26e9275f70974d48ed2898042377 [file]
/*
* Copyright (C) 2026 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.binarytransparency
import android.app.settings.SettingsEnums
import android.content.Context
import com.android.settings.R
import com.android.settings.dashboard.DashboardFragment
/** Fragment for displaying device identifier information. */
class DeviceIdentifierFragment() : DashboardFragment() {
override fun getPreferenceScreenResId() = R.xml.binary_transparency_device_identifier
override fun getLogTag() = TAG
override fun getMetricsCategory() = SettingsEnums.ANDROID_OS_VERIFICATION
override fun onAttach(context: Context) {
super.onAttach(context)
use(DeviceIdentifierPreferenceController::class.java).setDeviceIdentifiersBundle(arguments)
}
// Enum class representing the device information keys in the device information category.
enum class DeviceIdentifier(val representation: String, val titleResId: Int) {
MODEL("model", R.string.model_info),
BOOT_HASH("verified_boot_hash", R.string.abt_device_information_verified_boot_hash),
IMEI("imei", R.string.status_imei);
fun getValue(buildInfo: Map<AttestationUtils.AttestedBuildInformation, String?>): String? {
return when (this) {
MODEL -> buildInfo[AttestationUtils.AttestedBuildInformation.MODEL_KEY]
BOOT_HASH ->
buildInfo[AttestationUtils.AttestedBuildInformation.VERIFIED_BOOT_HASH_KEY]
IMEI -> {
val imei1 =
buildInfo[AttestationUtils.AttestedBuildInformation.IMEI_KEY].orEmpty()
val imei2 =
buildInfo[AttestationUtils.AttestedBuildInformation.IMEI_2_KEY].orEmpty()
if (imei2.isNotEmpty()) "$imei1\n$imei2" else imei1
}
}
}
}
companion object {
private const val TAG = "DeviceIdentifierFragment"
}
}