Migrate "Kernel version" preference
Bug: 365886251 Flag: com.android.settings.flags.catalyst_firmware_version Test: Unit Change-Id: Icb50e2d5200f7de40b6f8383c114982cd45d34b5
This commit is contained in:
@@ -51,7 +51,7 @@ class FirmwareVersionScreen : PreferenceScreenCreator, PreferenceSummaryProvider
|
||||
+PreferenceWidget("security_key", R.string.security_patch)
|
||||
+PreferenceWidget("module_version", R.string.module_version)
|
||||
+BasebandVersionPreference()
|
||||
+PreferenceWidget("kernel_version", R.string.kernel_version)
|
||||
+KernelVersionPreference()
|
||||
+PreferenceWidget("os_build_number", R.string.build_number)
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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.firmwareversion
|
||||
|
||||
import android.content.Context
|
||||
import androidx.preference.Preference
|
||||
import com.android.settings.R
|
||||
import com.android.settingslib.DeviceInfoUtils
|
||||
import com.android.settingslib.metadata.PreferenceMetadata
|
||||
import com.android.settingslib.metadata.PreferenceSummaryProvider
|
||||
import com.android.settingslib.preference.PreferenceBinding
|
||||
|
||||
// LINT.IfChange
|
||||
class KernelVersionPreference : PreferenceMetadata, PreferenceSummaryProvider, PreferenceBinding {
|
||||
|
||||
override val key: String
|
||||
get() = "kernel_version"
|
||||
|
||||
override val title: Int
|
||||
get() = R.string.kernel_version
|
||||
|
||||
override fun getSummary(context: Context): CharSequence? =
|
||||
DeviceInfoUtils.getFormattedKernelVersion(context)
|
||||
|
||||
override fun bind(preference: Preference, metadata: PreferenceMetadata) {
|
||||
super.bind(preference, metadata)
|
||||
preference.isSelectable = false
|
||||
preference.isCopyingEnabled = true
|
||||
}
|
||||
}
|
||||
// LINT.ThenChange(KernelVersionPreferenceController.java)
|
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.DeviceInfoUtils;
|
||||
|
||||
// LINT.IfChange
|
||||
public class KernelVersionPreferenceController extends BasePreferenceController {
|
||||
|
||||
public KernelVersionPreferenceController(Context context, String preferenceKey) {
|
||||
@@ -37,3 +38,4 @@ public class KernelVersionPreferenceController extends BasePreferenceController
|
||||
return DeviceInfoUtils.getFormattedKernelVersion(mContext);
|
||||
}
|
||||
}
|
||||
// LINT.ThenChange(KernelVersionPreference.kt)
|
||||
|
@@ -29,6 +29,7 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
// LINT.IfChange
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class KernelVersionPreferenceControllerTest {
|
||||
|
||||
@@ -49,3 +50,4 @@ public class KernelVersionPreferenceControllerTest {
|
||||
DeviceInfoUtils.getFormattedKernelVersion(mContext));
|
||||
}
|
||||
}
|
||||
// LINT.ThenChange(KernelVersionPreferenceTest.kt)
|
||||
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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.firmwareversion
|
||||
|
||||
import android.content.Context
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import com.android.settingslib.DeviceInfoUtils
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
||||
// LINT.IfChange
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class KernelVersionPreferenceTest {
|
||||
private val context: Context = ApplicationProvider.getApplicationContext()
|
||||
|
||||
private val kernelVersionPreference = KernelVersionPreference()
|
||||
|
||||
@Test
|
||||
fun getSummary() {
|
||||
assertThat(kernelVersionPreference.getSummary(context))
|
||||
.isEqualTo(DeviceInfoUtils.getFormattedKernelVersion(context))
|
||||
}
|
||||
}
|
||||
// LINT.ThenChange(KernelVersionPreferenceControllerTest.java)
|
Reference in New Issue
Block a user