2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings;
19 import android.app.Activity;
20 import android.app.Fragment;
21 import android.content.Context;
22 import android.content.Intent;
23 import android.provider.SearchIndexableResource;
25 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
26 import com.android.settings.dashboard.DashboardFragment;
27 import com.android.settings.dashboard.SummaryLoader;
28 import com.android.settings.deviceinfo.AdditionalSystemUpdatePreferenceController;
29 import com.android.settings.deviceinfo.BasebandVersionPreferenceController;
30 import com.android.settings.deviceinfo.BuildNumberPreferenceController;
31 import com.android.settings.deviceinfo.DeviceModelPreferenceController;
32 import com.android.settings.deviceinfo.FccEquipmentIdPreferenceController;
33 import com.android.settings.deviceinfo.FeedbackPreferenceController;
34 import com.android.settings.deviceinfo.FirmwareVersionPreferenceController;
35 import com.android.settings.deviceinfo.KernelVersionPreferenceController;
36 import com.android.settings.deviceinfo.ManualPreferenceController;
37 import com.android.settings.deviceinfo.RegulatoryInfoPreferenceController;
38 import com.android.settings.deviceinfo.SELinuxStatusPreferenceController;
39 import com.android.settings.deviceinfo.SafetyInfoPreferenceController;
40 import com.android.settings.deviceinfo.SecurityPatchPreferenceController;
41 import com.android.settings.search.BaseSearchIndexProvider;
42 import com.android.settings.search.Indexable;
43 import com.android.settingslib.core.AbstractPreferenceController;
44 import com.android.settingslib.core.lifecycle.Lifecycle;
46 import java.util.ArrayList;
47 import java.util.Arrays;
48 import java.util.List;
50 public class DeviceInfoSettings extends DashboardFragment implements Indexable {
52 private static final String LOG_TAG = "DeviceInfoSettings";
54 private static final String KEY_LEGAL_CONTAINER = "legal_container";
57 public int getMetricsCategory() {
58 return MetricsEvent.DEVICEINFO;
62 protected int getHelpResource() {
63 return R.string.help_uri_about;
67 public void onActivityResult(int requestCode, int resultCode, Intent data) {
68 final BuildNumberPreferenceController buildNumberPreferenceController =
69 getPreferenceController(BuildNumberPreferenceController.class);
70 if (buildNumberPreferenceController.onActivityResult(requestCode, resultCode, data)) {
73 super.onActivityResult(requestCode, resultCode, data);
77 protected String getLogTag() {
82 protected int getPreferenceScreenResId() {
83 return R.xml.device_info_settings;
87 protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
88 return buildPreferenceControllers(context, getActivity(), this /* fragment */,
92 private static class SummaryProvider implements SummaryLoader.SummaryProvider {
94 private final SummaryLoader mSummaryLoader;
96 public SummaryProvider(SummaryLoader summaryLoader) {
97 mSummaryLoader = summaryLoader;
101 public void setListening(boolean listening) {
103 mSummaryLoader.setSummary(this, DeviceModelPreferenceController.getDeviceModel());
108 public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
109 = new SummaryLoader.SummaryProviderFactory() {
111 public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
112 SummaryLoader summaryLoader) {
113 return new SummaryProvider(summaryLoader);
117 private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
118 Activity activity, Fragment fragment, Lifecycle lifecycle) {
119 final List<AbstractPreferenceController> controllers = new ArrayList<>();
121 new BuildNumberPreferenceController(context, activity, fragment, lifecycle));
122 controllers.add(new AdditionalSystemUpdatePreferenceController(context));
123 controllers.add(new ManualPreferenceController(context));
124 controllers.add(new FeedbackPreferenceController(fragment, context));
125 controllers.add(new KernelVersionPreferenceController(context));
126 controllers.add(new BasebandVersionPreferenceController(context));
127 controllers.add(new FirmwareVersionPreferenceController(context, lifecycle));
128 controllers.add(new RegulatoryInfoPreferenceController(context));
129 controllers.add(new DeviceModelPreferenceController(context, fragment));
130 controllers.add(new SecurityPatchPreferenceController(context));
131 controllers.add(new FccEquipmentIdPreferenceController(context));
132 controllers.add(new SELinuxStatusPreferenceController(context));
133 controllers.add(new SafetyInfoPreferenceController(context));
140 public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
141 new BaseSearchIndexProvider() {
144 public List<SearchIndexableResource> getXmlResourcesToIndex(
145 Context context, boolean enabled) {
146 final SearchIndexableResource sir = new SearchIndexableResource(context);
147 sir.xmlResId = R.xml.device_info_settings;
148 return Arrays.asList(sir);
152 public List<AbstractPreferenceController> getPreferenceControllers(Context context) {
153 return buildPreferenceControllers(context, null /*activity */,
154 null /* fragment */, null /* lifecycle */);
158 public List<String> getNonIndexableKeys(Context context) {
159 List<String> keys = super.getNonIndexableKeys(context);
160 keys.add(KEY_LEGAL_CONTAINER);