1 /*
2  * Copyright (C) 2015 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.tv.settings.about;
18 
19 import android.app.tvsettings.TvSettingsEnums;
20 import android.content.Context;
21 
22 import androidx.annotation.Keep;
23 
24 import com.android.settingslib.core.AbstractPreferenceController;
25 import com.android.settingslib.core.lifecycle.Lifecycle;
26 import com.android.tv.settings.NopePreferenceController;
27 import com.android.tv.settings.PreferenceControllerFragment;
28 import com.android.tv.settings.R;
29 
30 import java.util.ArrayList;
31 import java.util.List;
32 
33 /**
34  * Fragment for showing device hardware info, such as MAC addresses and serial numbers
35  */
36 @Keep
37 public class StatusFragment extends PreferenceControllerFragment {
38 
39     private static final String KEY_BATTERY_STATUS = "battery_status";
40     private static final String KEY_BATTERY_LEVEL = "battery_level";
41 
newInstance()42     public static StatusFragment newInstance() {
43         return new StatusFragment();
44     }
45 
46     @Override
getPreferenceScreenResId()47     protected int getPreferenceScreenResId() {
48         return R.xml.device_info_status;
49     }
50 
51     @Override
onCreatePreferenceControllers(Context context)52     protected List<AbstractPreferenceController> onCreatePreferenceControllers(Context context) {
53         final List<AbstractPreferenceController> controllers = new ArrayList<>(10);
54         final Lifecycle lifecycle = getSettingsLifecycle();
55 
56         // TODO: detect if we have a battery or not
57         controllers.add(new NopePreferenceController(context, KEY_BATTERY_LEVEL));
58         controllers.add(new NopePreferenceController(context, KEY_BATTERY_STATUS));
59 
60         controllers.add(new SerialNumberPreferenceController(context));
61         controllers.add(new UptimePreferenceController(context, lifecycle));
62         controllers.add(new BluetoothAddressPreferenceController(context, lifecycle));
63         controllers.add(new IpAddressPreferenceController(context, lifecycle));
64         controllers.add(new MacAddressPreferenceController(context, lifecycle));
65         controllers.add(new ImsStatusPreferenceController(context, lifecycle));
66 
67         return controllers;
68     }
69 
getPageId()70     protected int getPageId() {
71         return TvSettingsEnums.SYSTEM_ABOUT_STATUS;
72     }
73 }
74