blob: 93f93c70f3f3081ac75cc4bdf54dbd9c17ad8ac3 [file] [log] [blame]
Mike Lockwood24236072010-06-23 17:36:36 -04001/*
2 * Copyright (C) 2010 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
Mike Lockwoodc4308f02011-03-01 08:04:54 -080018package android.hardware.usb;
Mike Lockwood24236072010-06-23 17:36:36 -040019
Mike Lockwood3a68b832011-03-08 10:08:59 -050020import android.app.PendingIntent;
21import android.content.Context;
Mike Lockwoode7d511e2010-12-30 13:39:37 -050022import android.os.Bundle;
23import android.os.ParcelFileDescriptor;
24import android.os.RemoteException;
Mike Lockwood02e45692011-06-14 15:43:51 -040025import android.os.SystemProperties;
Mike Lockwoode7d511e2010-12-30 13:39:37 -050026import android.util.Log;
27
Mike Lockwoode7d511e2010-12-30 13:39:37 -050028import java.util.HashMap;
Mike Lockwood08bff3b2010-08-31 13:27:05 -040029
Mike Lockwood24236072010-06-23 17:36:36 -040030/**
Mike Lockwood11dd5ae2011-04-01 14:00:08 -040031 * This class allows you to access the state of USB and communicate with USB devices.
32 * Currently only host mode is supported in the public API.
Mike Lockwoode7d511e2010-12-30 13:39:37 -050033 *
34 * <p>You can obtain an instance of this class by calling
35 * {@link android.content.Context#getSystemService(java.lang.String) Context.getSystemService()}.
36 *
37 * {@samplecode
Joe Fernandez3aef8e1d2011-12-20 10:38:34 -080038 * UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);}
39 *
40 * <div class="special reference">
41 * <h3>Developer Guides</h3>
42 * <p>For more information about communicating with USB hardware, read the
43 * <a href="{@docRoot}guide/topics/usb/index.html">USB</a> developer guide.</p>
44 * </div>
Mike Lockwood24236072010-06-23 17:36:36 -040045 */
Mike Lockwood770126a2010-12-09 22:30:37 -080046public class UsbManager {
Mike Lockwoode7d511e2010-12-30 13:39:37 -050047 private static final String TAG = "UsbManager";
48
Mike Lockwood24236072010-06-23 17:36:36 -040049 /**
Mike Lockwoode7d511e2010-12-30 13:39:37 -050050 * Broadcast Action: A sticky broadcast for USB state change events when in device mode.
Mike Lockwood709981e2010-06-28 09:58:58 -040051 *
Mike Lockwoodb92df0f2010-12-10 16:19:32 -080052 * This is a sticky broadcast for clients that includes USB connected/disconnected state,
Mike Lockwood9182d3c2011-02-15 09:50:22 -050053 * <ul>
54 * <li> {@link #USB_CONNECTED} boolean indicating whether USB is connected or disconnected.
Mike Lockwood02e45692011-06-14 15:43:51 -040055 * <li> {@link #USB_CONFIGURED} boolean indicating whether USB is configured.
Mike Lockwood9eb014a2011-06-08 09:17:45 -070056 * currently zero if not configured, one for configured.
57 * <li> {@link #USB_FUNCTION_MASS_STORAGE} boolean extra indicating whether the
58 * mass storage function is enabled
59 * <li> {@link #USB_FUNCTION_ADB} boolean extra indicating whether the
60 * adb function is enabled
61 * <li> {@link #USB_FUNCTION_RNDIS} boolean extra indicating whether the
62 * RNDIS ethernet function is enabled
63 * <li> {@link #USB_FUNCTION_MTP} boolean extra indicating whether the
64 * MTP function is enabled
65 * <li> {@link #USB_FUNCTION_PTP} boolean extra indicating whether the
66 * PTP function is enabled
67 * <li> {@link #USB_FUNCTION_PTP} boolean extra indicating whether the
68 * accessory function is enabled
Mike Lockwood9182d3c2011-02-15 09:50:22 -050069 * </ul>
Mike Lockwooda75075e12011-03-11 11:26:11 -050070 *
71 * {@hide}
Mike Lockwood709981e2010-06-28 09:58:58 -040072 */
73 public static final String ACTION_USB_STATE =
Mike Lockwoodc4308f02011-03-01 08:04:54 -080074 "android.hardware.usb.action.USB_STATE";
Mike Lockwood709981e2010-06-28 09:58:58 -040075
Mike Lockwoode7d511e2010-12-30 13:39:37 -050076 /**
77 * Broadcast Action: A broadcast for USB device attached event.
78 *
79 * This intent is sent when a USB device is attached to the USB bus when in host mode.
Mike Lockwood9182d3c2011-02-15 09:50:22 -050080 * <ul>
Mike Lockwoodc4308f02011-03-01 08:04:54 -080081 * <li> {@link #EXTRA_DEVICE} containing the {@link android.hardware.usb.UsbDevice}
Mike Lockwood9182d3c2011-02-15 09:50:22 -050082 * for the attached device
83 * </ul>
Mike Lockwoode7d511e2010-12-30 13:39:37 -050084 */
85 public static final String ACTION_USB_DEVICE_ATTACHED =
Mike Lockwoodc4308f02011-03-01 08:04:54 -080086 "android.hardware.usb.action.USB_DEVICE_ATTACHED";
Mike Lockwoode7d511e2010-12-30 13:39:37 -050087
88 /**
89 * Broadcast Action: A broadcast for USB device detached event.
90 *
91 * This intent is sent when a USB device is detached from the USB bus when in host mode.
Mike Lockwood9182d3c2011-02-15 09:50:22 -050092 * <ul>
Mike Lockwoodc4308f02011-03-01 08:04:54 -080093 * <li> {@link #EXTRA_DEVICE} containing the {@link android.hardware.usb.UsbDevice}
Mike Lockwood188d00b2011-02-23 13:14:33 -080094 * for the detached device
Mike Lockwood9182d3c2011-02-15 09:50:22 -050095 * </ul>
Mike Lockwoode7d511e2010-12-30 13:39:37 -050096 */
97 public static final String ACTION_USB_DEVICE_DETACHED =
Mike Lockwoodc4308f02011-03-01 08:04:54 -080098 "android.hardware.usb.action.USB_DEVICE_DETACHED";
Mike Lockwoode7d511e2010-12-30 13:39:37 -050099
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500100 /**
101 * Broadcast Action: A broadcast for USB accessory attached event.
102 *
103 * This intent is sent when a USB accessory is attached.
104 * <ul>
Mike Lockwoodc4308f02011-03-01 08:04:54 -0800105 * <li> {@link #EXTRA_ACCESSORY} containing the {@link android.hardware.usb.UsbAccessory}
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500106 * for the attached accessory
107 * </ul>
108 */
109 public static final String ACTION_USB_ACCESSORY_ATTACHED =
Mike Lockwoodc4308f02011-03-01 08:04:54 -0800110 "android.hardware.usb.action.USB_ACCESSORY_ATTACHED";
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500111
112 /**
113 * Broadcast Action: A broadcast for USB accessory detached event.
114 *
115 * This intent is sent when a USB accessory is detached.
116 * <ul>
Mike Lockwood980f0432011-03-09 15:49:13 -0500117 * <li> {@link #EXTRA_ACCESSORY} containing the {@link UsbAccessory}
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500118 * for the attached accessory that was detached
119 * </ul>
120 */
121 public static final String ACTION_USB_ACCESSORY_DETACHED =
Mike Lockwoodc4308f02011-03-01 08:04:54 -0800122 "android.hardware.usb.action.USB_ACCESSORY_DETACHED";
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500123
Mike Lockwood709981e2010-06-28 09:58:58 -0400124 /**
125 * Boolean extra indicating whether USB is connected or disconnected.
126 * Used in extras for the {@link #ACTION_USB_STATE} broadcast.
Mike Lockwooda75075e12011-03-11 11:26:11 -0500127 *
128 * {@hide}
Mike Lockwood709981e2010-06-28 09:58:58 -0400129 */
130 public static final String USB_CONNECTED = "connected";
Mike Lockwood24236072010-06-23 17:36:36 -0400131
132 /**
Mike Lockwood02e45692011-06-14 15:43:51 -0400133 * Boolean extra indicating whether USB is configured.
Mike Lockwoodb92df0f2010-12-10 16:19:32 -0800134 * Used in extras for the {@link #ACTION_USB_STATE} broadcast.
Mike Lockwooda75075e12011-03-11 11:26:11 -0500135 *
136 * {@hide}
Mike Lockwoodb92df0f2010-12-10 16:19:32 -0800137 */
Mike Lockwood02e45692011-06-14 15:43:51 -0400138 public static final String USB_CONFIGURED = "configured";
Mike Lockwoodb92df0f2010-12-10 16:19:32 -0800139
140 /**
Mike Lockwood24236072010-06-23 17:36:36 -0400141 * Name of the USB mass storage USB function.
Mike Lockwoodb92df0f2010-12-10 16:19:32 -0800142 * Used in extras for the {@link #ACTION_USB_STATE} broadcast
Mike Lockwooda75075e12011-03-11 11:26:11 -0500143 *
144 * {@hide}
Mike Lockwood24236072010-06-23 17:36:36 -0400145 */
146 public static final String USB_FUNCTION_MASS_STORAGE = "mass_storage";
147
148 /**
149 * Name of the adb USB function.
Mike Lockwoodb92df0f2010-12-10 16:19:32 -0800150 * Used in extras for the {@link #ACTION_USB_STATE} broadcast
Mike Lockwooda75075e12011-03-11 11:26:11 -0500151 *
152 * {@hide}
Mike Lockwood24236072010-06-23 17:36:36 -0400153 */
154 public static final String USB_FUNCTION_ADB = "adb";
155
156 /**
157 * Name of the RNDIS ethernet USB function.
Mike Lockwoodb92df0f2010-12-10 16:19:32 -0800158 * Used in extras for the {@link #ACTION_USB_STATE} broadcast
Mike Lockwooda75075e12011-03-11 11:26:11 -0500159 *
160 * {@hide}
Mike Lockwood24236072010-06-23 17:36:36 -0400161 */
162 public static final String USB_FUNCTION_RNDIS = "rndis";
163
164 /**
165 * Name of the MTP USB function.
Mike Lockwoodb92df0f2010-12-10 16:19:32 -0800166 * Used in extras for the {@link #ACTION_USB_STATE} broadcast
Mike Lockwooda75075e12011-03-11 11:26:11 -0500167 *
168 * {@hide}
Mike Lockwood24236072010-06-23 17:36:36 -0400169 */
170 public static final String USB_FUNCTION_MTP = "mtp";
171
172 /**
Mike Lockwood9eb014a2011-06-08 09:17:45 -0700173 * Name of the PTP USB function.
174 * Used in extras for the {@link #ACTION_USB_STATE} broadcast
175 *
176 * {@hide}
177 */
178 public static final String USB_FUNCTION_PTP = "ptp";
179
180 /**
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500181 * Name of the Accessory USB function.
Mike Lockwoodb92df0f2010-12-10 16:19:32 -0800182 * Used in extras for the {@link #ACTION_USB_STATE} broadcast
Mike Lockwooda75075e12011-03-11 11:26:11 -0500183 *
184 * {@hide}
Mike Lockwood24236072010-06-23 17:36:36 -0400185 */
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500186 public static final String USB_FUNCTION_ACCESSORY = "accessory";
187
188 /**
Mike Lockwoode7d511e2010-12-30 13:39:37 -0500189 * Name of extra for {@link #ACTION_USB_DEVICE_ATTACHED} and
Mike Lockwood02eb8742011-02-27 09:10:37 -0800190 * {@link #ACTION_USB_DEVICE_DETACHED} broadcasts
Mike Lockwoode7d511e2010-12-30 13:39:37 -0500191 * containing the UsbDevice object for the device.
192 */
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500193
Mike Lockwoode7d511e2010-12-30 13:39:37 -0500194 public static final String EXTRA_DEVICE = "device";
195
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500196 /**
Mike Lockwood02eb8742011-02-27 09:10:37 -0800197 * Name of extra for {@link #ACTION_USB_ACCESSORY_ATTACHED} and
198 * {@link #ACTION_USB_ACCESSORY_DETACHED} broadcasts
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500199 * containing the UsbAccessory object for the accessory.
200 */
201 public static final String EXTRA_ACCESSORY = "accessory";
202
Mike Lockwood3a68b832011-03-08 10:08:59 -0500203 /**
204 * Name of extra added to the {@link android.app.PendingIntent}
Mike Lockwood980f0432011-03-09 15:49:13 -0500205 * passed into {@link #requestPermission(UsbDevice, PendingIntent)}
206 * or {@link #requestPermission(UsbAccessory, PendingIntent)}
Mike Lockwood3a68b832011-03-08 10:08:59 -0500207 * containing a boolean value indicating whether the user granted permission or not.
208 */
209 public static final String EXTRA_PERMISSION_GRANTED = "permission";
210
211 private final Context mContext;
212 private final IUsbManager mService;
Mike Lockwoode7d511e2010-12-30 13:39:37 -0500213
214 /**
215 * {@hide}
216 */
Mike Lockwood3a68b832011-03-08 10:08:59 -0500217 public UsbManager(Context context, IUsbManager service) {
218 mContext = context;
Mike Lockwoode7d511e2010-12-30 13:39:37 -0500219 mService = service;
220 }
221
222 /**
223 * Returns a HashMap containing all USB devices currently attached.
224 * USB device name is the key for the returned HashMap.
225 * The result will be empty if no devices are attached, or if
226 * USB host mode is inactive or unsupported.
227 *
228 * @return HashMap containing all connected USB devices.
229 */
230 public HashMap<String,UsbDevice> getDeviceList() {
231 Bundle bundle = new Bundle();
232 try {
233 mService.getDeviceList(bundle);
234 HashMap<String,UsbDevice> result = new HashMap<String,UsbDevice>();
235 for (String name : bundle.keySet()) {
236 result.put(name, (UsbDevice)bundle.get(name));
237 }
238 return result;
239 } catch (RemoteException e) {
240 Log.e(TAG, "RemoteException in getDeviceList", e);
241 return null;
242 }
243 }
244
245 /**
246 * Opens the device so it can be used to send and receive
Mike Lockwoodc4308f02011-03-01 08:04:54 -0800247 * data using {@link android.hardware.usb.UsbRequest}.
Mike Lockwoode7d511e2010-12-30 13:39:37 -0500248 *
249 * @param device the device to open
250 * @return true if we successfully opened the device
251 */
Mike Lockwoodacc29cc2011-03-11 08:18:08 -0500252 public UsbDeviceConnection openDevice(UsbDevice device) {
Mike Lockwoode7d511e2010-12-30 13:39:37 -0500253 try {
Mike Lockwoodacc29cc2011-03-11 08:18:08 -0500254 String deviceName = device.getDeviceName();
255 ParcelFileDescriptor pfd = mService.openDevice(deviceName);
256 if (pfd != null) {
257 UsbDeviceConnection connection = new UsbDeviceConnection(device);
258 boolean result = connection.open(deviceName, pfd);
259 pfd.close();
260 if (result) {
261 return connection;
262 }
Mike Lockwoode7d511e2010-12-30 13:39:37 -0500263 }
Mike Lockwoode7d511e2010-12-30 13:39:37 -0500264 } catch (Exception e) {
265 Log.e(TAG, "exception in UsbManager.openDevice", e);
Mike Lockwoode7d511e2010-12-30 13:39:37 -0500266 }
Mike Lockwoodacc29cc2011-03-11 08:18:08 -0500267 return null;
Mike Lockwoode7d511e2010-12-30 13:39:37 -0500268 }
269
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500270 /**
271 * Returns a list of currently attached USB accessories.
272 * (in the current implementation there can be at most one)
273 *
274 * @return list of USB accessories, or null if none are attached.
275 */
276 public UsbAccessory[] getAccessoryList() {
277 try {
278 UsbAccessory accessory = mService.getCurrentAccessory();
279 if (accessory == null) {
280 return null;
281 } else {
282 return new UsbAccessory[] { accessory };
283 }
284 } catch (RemoteException e) {
Mike Lockwood3a68b832011-03-08 10:08:59 -0500285 Log.e(TAG, "RemoteException in getAccessoryList", e);
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500286 return null;
287 }
288 }
289
290 /**
291 * Opens a file descriptor for reading and writing data to the USB accessory.
292 *
293 * @param accessory the USB accessory to open
294 * @return file descriptor, or null if the accessor could not be opened.
295 */
296 public ParcelFileDescriptor openAccessory(UsbAccessory accessory) {
297 try {
Mike Lockwood02eb8742011-02-27 09:10:37 -0800298 return mService.openAccessory(accessory);
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500299 } catch (RemoteException e) {
Mike Lockwood3a68b832011-03-08 10:08:59 -0500300 Log.e(TAG, "RemoteException in openAccessory", e);
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500301 return null;
302 }
303 }
304
Mike Lockwood3a68b832011-03-08 10:08:59 -0500305 /**
306 * Returns true if the caller has permission to access the device.
Mike Lockwoodc6f23e82011-03-09 12:05:20 -0500307 * Permission might have been granted temporarily via
Mike Lockwood980f0432011-03-09 15:49:13 -0500308 * {@link #requestPermission(UsbDevice, PendingIntent)} or
Mike Lockwoodc6f23e82011-03-09 12:05:20 -0500309 * by the user choosing the caller as the default application for the device.
Mike Lockwood3a68b832011-03-08 10:08:59 -0500310 *
311 * @param device to check permissions for
312 * @return true if caller has permission
313 */
314 public boolean hasPermission(UsbDevice device) {
315 try {
316 return mService.hasDevicePermission(device);
317 } catch (RemoteException e) {
318 Log.e(TAG, "RemoteException in hasPermission", e);
319 return false;
320 }
321 }
322
323 /**
324 * Returns true if the caller has permission to access the accessory.
Mike Lockwoodc6f23e82011-03-09 12:05:20 -0500325 * Permission might have been granted temporarily via
Mike Lockwood980f0432011-03-09 15:49:13 -0500326 * {@link #requestPermission(UsbAccessory, PendingIntent)} or
Mike Lockwoodc6f23e82011-03-09 12:05:20 -0500327 * by the user choosing the caller as the default application for the accessory.
Mike Lockwood3a68b832011-03-08 10:08:59 -0500328 *
329 * @param accessory to check permissions for
330 * @return true if caller has permission
331 */
332 public boolean hasPermission(UsbAccessory accessory) {
333 try {
334 return mService.hasAccessoryPermission(accessory);
335 } catch (RemoteException e) {
336 Log.e(TAG, "RemoteException in hasPermission", e);
337 return false;
338 }
339 }
340
341 /**
Mike Lockwoodc6f23e82011-03-09 12:05:20 -0500342 * Requests temporary permission for the given package to access the device.
Mike Lockwood3a68b832011-03-08 10:08:59 -0500343 * This may result in a system dialog being displayed to the user
344 * if permission had not already been granted.
345 * Success or failure is returned via the {@link android.app.PendingIntent} pi.
Mike Lockwoodc6f23e82011-03-09 12:05:20 -0500346 * If successful, this grants the caller permission to access the device only
347 * until the device is disconnected.
348 *
Mike Lockwood3a68b832011-03-08 10:08:59 -0500349 * The following extras will be added to pi:
350 * <ul>
351 * <li> {@link #EXTRA_DEVICE} containing the device passed into this call
352 * <li> {@link #EXTRA_PERMISSION_GRANTED} containing boolean indicating whether
353 * permission was granted by the user
354 * </ul>
355 *
356 * @param device to request permissions for
357 * @param pi PendingIntent for returning result
358 */
359 public void requestPermission(UsbDevice device, PendingIntent pi) {
360 try {
361 mService.requestDevicePermission(device, mContext.getPackageName(), pi);
362 } catch (RemoteException e) {
363 Log.e(TAG, "RemoteException in requestPermission", e);
364 }
365 }
366
367 /**
Mike Lockwoodc6f23e82011-03-09 12:05:20 -0500368 * Requests temporary permission for the given package to access the accessory.
Mike Lockwood3a68b832011-03-08 10:08:59 -0500369 * This may result in a system dialog being displayed to the user
370 * if permission had not already been granted.
371 * Success or failure is returned via the {@link android.app.PendingIntent} pi.
Mike Lockwood62cfeeb2011-03-11 18:39:03 -0500372 * If successful, this grants the caller permission to access the accessory only
Mike Lockwoodc6f23e82011-03-09 12:05:20 -0500373 * until the device is disconnected.
374 *
Mike Lockwood3a68b832011-03-08 10:08:59 -0500375 * The following extras will be added to pi:
376 * <ul>
377 * <li> {@link #EXTRA_ACCESSORY} containing the accessory passed into this call
378 * <li> {@link #EXTRA_PERMISSION_GRANTED} containing boolean indicating whether
379 * permission was granted by the user
380 * </ul>
381 *
382 * @param accessory to request permissions for
383 * @param pi PendingIntent for returning result
384 */
385 public void requestPermission(UsbAccessory accessory, PendingIntent pi) {
386 try {
387 mService.requestAccessoryPermission(accessory, mContext.getPackageName(), pi);
388 } catch (RemoteException e) {
389 Log.e(TAG, "RemoteException in requestPermission", e);
390 }
391 }
392
Mike Lockwood02e45692011-06-14 15:43:51 -0400393 private static boolean propertyContainsFunction(String property, String function) {
394 String functions = SystemProperties.get(property, "");
395 int index = functions.indexOf(function);
396 if (index < 0) return false;
397 if (index > 0 && functions.charAt(index - 1) != ',') return false;
398 int charAfter = index + function.length();
399 if (charAfter < functions.length() && functions.charAt(charAfter) != ',') return false;
400 return true;
Mike Lockwood08bff3b2010-08-31 13:27:05 -0400401 }
402
403 /**
404 * Returns true if the specified USB function is currently enabled.
Mike Lockwoode7d511e2010-12-30 13:39:37 -0500405 *
406 * @param function name of the USB function
407 * @return true if the USB function is enabled.
Mike Lockwooda75075e12011-03-11 11:26:11 -0500408 *
409 * {@hide}
Mike Lockwood08bff3b2010-08-31 13:27:05 -0400410 */
Mike Lockwood02e45692011-06-14 15:43:51 -0400411 public boolean isFunctionEnabled(String function) {
412 return propertyContainsFunction("sys.usb.config", function);
413 }
414
415 /**
Mike Lockwoode51099f2011-08-02 12:54:49 -0400416 * Returns the current default USB function.
417 *
418 * @return name of the default function.
419 *
420 * {@hide}
421 */
422 public String getDefaultFunction() {
423 String functions = SystemProperties.get("persist.sys.usb.config", "");
424 int commaIndex = functions.indexOf(',');
425 if (commaIndex > 0) {
426 return functions.substring(0, commaIndex);
427 } else {
428 return functions;
429 }
430 }
431
432 /**
Mike Lockwoodf59717d2011-06-22 15:19:33 -0400433 * Sets the current USB function.
Mike Lockwood875c24b2011-07-18 10:54:32 -0700434 * If function is null, then the current function is set to the default function.
Mike Lockwood02e45692011-06-14 15:43:51 -0400435 *
Mike Lockwood875c24b2011-07-18 10:54:32 -0700436 * @param function name of the USB function, or null to restore the default function
437 * @param makeDefault true if the function should be set as the new default function
Mike Lockwood02e45692011-06-14 15:43:51 -0400438 *
439 * {@hide}
440 */
Mike Lockwoodf59717d2011-06-22 15:19:33 -0400441 public void setCurrentFunction(String function, boolean makeDefault) {
Mike Lockwood08bff3b2010-08-31 13:27:05 -0400442 try {
Mike Lockwoodf59717d2011-06-22 15:19:33 -0400443 mService.setCurrentFunction(function, makeDefault);
Mike Lockwood02e45692011-06-14 15:43:51 -0400444 } catch (RemoteException e) {
Mike Lockwoodf59717d2011-06-22 15:19:33 -0400445 Log.e(TAG, "RemoteException in setCurrentFunction", e);
Mike Lockwood02e45692011-06-14 15:43:51 -0400446 }
447 }
448
449 /**
450 * Sets the file path for USB mass storage backing file.
451 *
452 * @param path backing file path
453 *
454 * {@hide}
455 */
456 public void setMassStorageBackingFile(String path) {
457 try {
458 mService.setMassStorageBackingFile(path);
459 } catch (RemoteException e) {
460 Log.e(TAG, "RemoteException in setDefaultFunction", e);
Mike Lockwood9182d3c2011-02-15 09:50:22 -0500461 }
462 }
Mike Lockwood24236072010-06-23 17:36:36 -0400463}