Debian Codegraph @

core/java/android/debug/AdbManager.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2018 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 android.debug;
18
19 import android.annotation.RequiresPermission;
20 import android.annotation.SystemApi;
21 import android.annotation.SystemService;
22 import android.content.Context;
23 import android.os.RemoteException;
24
25 /**
26 * This class allows the control of ADB-related functions.
27 * @hide
28 */
29 @SystemApi
30 @SystemService(Context.ADB_SERVICE)
31 public class AdbManager {
32 private static final String TAG = "AdbManager";
33
34 /**
35 * Action indicating the state change of wireless debugging. Can be either
36 * STATUS_CONNECTED
37 * STATUS_DISCONNECTED
38 *
39 * @hide
40 */
41 @RequiresPermission(android.Manifest.permission.MANAGE_DEBUGGING)
42 public static final String WIRELESS_DEBUG_STATE_CHANGED_ACTION =
43 "com.android.server.adb.WIRELESS_DEBUG_STATUS";
44
45 /**
46 * Contains the list of paired devices.
47 *
48 * @hide
49 */
50 @RequiresPermission(android.Manifest.permission.MANAGE_DEBUGGING)
51 public static final String WIRELESS_DEBUG_PAIRED_DEVICES_ACTION =
52 "com.android.server.adb.WIRELESS_DEBUG_PAIRED_DEVICES";
53
54 /**
55 * Action indicating the status of a pairing. Can be either
56 * WIRELESS_STATUS_FAIL
57 * WIRELESS_STATUS_SUCCESS
58 * WIRELESS_STATUS_CANCELLED
59 * WIRELESS_STATUS_PAIRING_CODE
60 * WIRELESS_STATUS_CONNECTED
61 *
62 * @hide
63 */
64 @RequiresPermission(android.Manifest.permission.MANAGE_DEBUGGING)
65 public static final String WIRELESS_DEBUG_PAIRING_RESULT_ACTION =
66 "com.android.server.adb.WIRELESS_DEBUG_PAIRING_RESULT";
67
68 /**
69 * Extra containing the PairDevice map of paired/pairing devices.
70 *
71 * @hide
72 */
73 public static final String WIRELESS_DEVICES_EXTRA = "devices_map";
74
75 /**
76 * The status of the pairing/unpairing.
77 *
78 * @hide
79 */
80 public static final String WIRELESS_STATUS_EXTRA = "status";
81
82 /**
83 * The PairDevice.
84 *
85 * @hide
86 */
87 public static final String WIRELESS_PAIR_DEVICE_EXTRA = "pair_device";
88
89 /**
90 * The six-digit pairing code.
91 *
92 * @hide
93 */
94 public static final String WIRELESS_PAIRING_CODE_EXTRA = "pairing_code";
95
96 /**
97 * The adb connection/pairing port that was opened.
98 *
99 * @hide
100 */
101 public static final String WIRELESS_DEBUG_PORT_EXTRA = "adb_port";
102
103 /**
104 * Status indicating the pairing/unpairing failed.
105 *
106 * @hide
107 */
108 public static final int WIRELESS_STATUS_FAIL = 0;
109
110 /**
111 * Status indicating the pairing/unpairing succeeded.
112 *
113 * @hide
114 */
115 public static final int WIRELESS_STATUS_SUCCESS = 1;
116
117 /**
118 * Status indicating the pairing/unpairing was cancelled.
119 *
120 * @hide
121 */
122 public static final int WIRELESS_STATUS_CANCELLED = 2;
123
124 /**
125 * Status indicating the pairing code for pairing.
126 *
127 * @hide
128 */
129 public static final int WIRELESS_STATUS_PAIRING_CODE = 3;
130
131 /**
132 * Status indicating wireless debugging is connected.
133 *
134 * @hide
135 */
136 public static final int WIRELESS_STATUS_CONNECTED = 4;
137
138 /**
139 * Status indicating wireless debugging is disconnected.
140 *
141 * @hide
142 */
143 public static final int WIRELESS_STATUS_DISCONNECTED = 5;
144
145 private final Context mContext;
146 private final IAdbManager mService;
147
148 /**
149 * {@hide}
150 */
151 public AdbManager(Context context, IAdbManager service) {
152 mContext = context;
153 mService = service;
154 }
155
156 /**
157 * @return true if the device supports secure ADB over Wi-Fi.
158 * @hide
159 */
160 @SystemApi
161 @RequiresPermission(android.Manifest.permission.MANAGE_DEBUGGING)
162 public boolean isAdbWifiSupported() {
163 try {
164 return mService.isAdbWifiSupported();
165 } catch (RemoteException e) {
166 throw e.rethrowFromSystemServer();
167 }
168 }
169
170 /**
171 * @return true if the device supports secure ADB over Wi-Fi and device pairing by
172 * QR code.
173 * @hide
174 */
175 @SystemApi
176 @RequiresPermission(android.Manifest.permission.MANAGE_DEBUGGING)
177 public boolean isAdbWifiQrSupported() {
178 try {
179 return mService.isAdbWifiQrSupported();
180 } catch (RemoteException e) {
181 throw e.rethrowFromSystemServer();
182 }
183 }
184 }