1 /*
2  * Copyright (C) 2020 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.settings.development;
18 
19 import android.app.settings.SettingsEnums;
20 import android.content.Context;
21 import android.debug.PairDevice;
22 import android.os.Bundle;
23 
24 import com.android.settings.R;
25 import com.android.settings.dashboard.DashboardFragment;
26 import com.android.settingslib.core.AbstractPreferenceController;
27 
28 import java.util.ArrayList;
29 import java.util.List;
30 
31 /**
32  * Fragment shown when clicking on a paired device in the Wireless
33  * Debugging fragment.
34  */
35 public class AdbDeviceDetailsFragment extends DashboardFragment implements
36         DeveloperOptionAwareMixin {
37     private static final String TAG = "AdbDeviceDetailsFrag";
38     private PairDevice mPairedDevice;
39 
AdbDeviceDetailsFragment()40     public AdbDeviceDetailsFragment() {
41         super();
42     }
43 
44     @Override
onAttach(Context context)45     public void onAttach(Context context) {
46         // Get the paired device stored in the extras
47         Bundle bundle = getArguments();
48         if (bundle.containsKey(AdbPairedDevicePreference.PAIRED_DEVICE_EXTRA)) {
49             mPairedDevice = (PairDevice) bundle.getParcelable(
50                     AdbPairedDevicePreference.PAIRED_DEVICE_EXTRA);
51         }
52         super.onAttach(context);
53     }
54 
55     @Override
getMetricsCategory()56     public int getMetricsCategory() {
57         return SettingsEnums.ADB_WIRELESS_DEVICE_DETAILS;
58     }
59 
60     @Override
getLogTag()61     protected String getLogTag() {
62         return TAG;
63     }
64 
65     @Override
getPreferenceScreenResId()66     protected int getPreferenceScreenResId() {
67         return R.xml.adb_device_details_fragment;
68     }
69 
70     @Override
createPreferenceControllers(Context context)71     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
72         final List<AbstractPreferenceController> controllers = new ArrayList<>();
73         controllers.add(new AdbDeviceDetailsHeaderController(mPairedDevice, context, this));
74         controllers.add(new AdbDeviceDetailsActionController(mPairedDevice, context, this));
75         controllers.add(new AdbDeviceDetailsFingerprintController(mPairedDevice, context, this));
76 
77         return controllers;
78     }
79 }
80