1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package com.android.car.settings.system; 18 19 import android.os.Build; 20 import android.os.Bundle; 21 22 import androidx.car.widget.ListItem; 23 import androidx.car.widget.ListItemProvider; 24 import androidx.car.widget.TextListItem; 25 26 import com.android.car.settings.R; 27 import com.android.car.settings.common.ListItemSettingsFragment; 28 import com.android.settingslib.DeviceInfoUtils; 29 30 import java.util.ArrayList; 31 import java.util.List; 32 33 /** 34 * Shows basic info about the system and provide some actions like update, reset etc. 35 */ 36 public class AboutSettingsFragment extends ListItemSettingsFragment { 37 38 private ListItemProvider mItemProvider; 39 getInstance()40 public static AboutSettingsFragment getInstance() { 41 AboutSettingsFragment aboutSettingsFragment = new AboutSettingsFragment(); 42 Bundle bundle = ListItemSettingsFragment.getBundle(); 43 bundle.putInt(EXTRA_TITLE_ID, R.string.about_settings); 44 aboutSettingsFragment.setArguments(bundle); 45 return aboutSettingsFragment; 46 } 47 48 @Override onActivityCreated(Bundle savedInstanceState)49 public void onActivityCreated(Bundle savedInstanceState) { 50 mItemProvider = new ListItemProvider.ListProvider(getListItems()); 51 // super.onActivityCreated() will need itemProvider, so call it after the provider 52 // is initialized. 53 super.onActivityCreated(savedInstanceState); 54 } 55 56 @Override getItemProvider()57 public ListItemProvider getItemProvider() { 58 return mItemProvider; 59 } 60 getListItems()61 private List<ListItem> getListItems() { 62 List<ListItem> listItems = new ArrayList<>(); 63 TextListItem modelItem = new TextListItem(getContext()); 64 modelItem.setTitle(getString(R.string.model_info)); 65 modelItem.setBody(Build.MODEL + DeviceInfoUtils.getMsvSuffix()); 66 listItems.add(modelItem); 67 68 TextListItem androidVersionItem = new TextListItem(getContext()); 69 androidVersionItem.setTitle(getString(R.string.firmware_version)); 70 androidVersionItem.setBody(getString(R.string.about_summary, Build.VERSION.RELEASE)); 71 listItems.add(androidVersionItem); 72 73 TextListItem securityLevelItem = new TextListItem(getContext()); 74 securityLevelItem.setTitle(getString(R.string.security_patch)); 75 securityLevelItem.setBody(DeviceInfoUtils.getSecurityPatch()); 76 listItems.add(securityLevelItem); 77 78 TextListItem kernelVersionItem = new TextListItem(getContext()); 79 kernelVersionItem.setTitle(getString(R.string.kernel_version)); 80 kernelVersionItem.setBody(DeviceInfoUtils.getFormattedKernelVersion(getContext())); 81 listItems.add(kernelVersionItem); 82 83 TextListItem buildNumberItem = new TextListItem(getContext()); 84 buildNumberItem.setTitle(getString(R.string.build_number)); 85 buildNumberItem.setBody(Build.DISPLAY); 86 listItems.add(buildNumberItem); 87 return listItems; 88 } 89 } 90