diff options
-rw-r--r-- | api/current.xml | 22 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageManager.java | 15 | ||||
-rw-r--r-- | core/res/res/values/config.xml | 3 | ||||
-rw-r--r-- | data/etc/android.hardware.usb.accessory.xml | 20 | ||||
-rw-r--r-- | data/etc/android.hardware.usb.host.xml | 21 | ||||
-rw-r--r-- | services/java/com/android/server/usb/UsbService.java | 10 |
6 files changed, 85 insertions, 6 deletions
diff --git a/api/current.xml b/api/current.xml index f797496..007b0b1 100644 --- a/api/current.xml +++ b/api/current.xml @@ -61256,6 +61256,28 @@ visibility="public" > </field> +<field name="FEATURE_USB_ACCESSORY" + type="java.lang.String" + transient="false" + volatile="false" + value=""android.hardware.usb.accessory"" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="FEATURE_USB_HOST" + type="java.lang.String" + transient="false" + volatile="false" + value=""android.hardware.usb.host"" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="FEATURE_WIFI" type="java.lang.String" transient="false" diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index a589216..7525749 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -785,6 +785,21 @@ public abstract class PackageManager { /** * Feature for {@link #getSystemAvailableFeatures} and + * {@link #hasSystemFeature}: The device supports connecting to USB devices + * as the USB host. + */ + @SdkConstant(SdkConstantType.FEATURE) + public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; + + /** + * Feature for {@link #getSystemAvailableFeatures} and + * {@link #hasSystemFeature}: The device supports connecting to USB accessories. + */ + @SdkConstant(SdkConstantType.FEATURE) + public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; + + /** + * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The SIP API is enabled on the device. */ @SdkConstant(SdkConstantType.FEATURE) diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index cb44a3a..c815758 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -296,9 +296,6 @@ <!-- Indicate whether the SD card is accessible without removing the battery. --> <bool name="config_batterySdCardAccessibility">false</bool> - <!-- Indicate whether the device has USB host support. --> - <bool name="config_hasUsbHostSupport">false</bool> - <!-- List of file paths for USB host busses to exclude from USB host support. For example, if the first USB bus on the device is used to communicate with the modem or some other restricted hardware, add "/dev/bus/usb/001/" diff --git a/data/etc/android.hardware.usb.accessory.xml b/data/etc/android.hardware.usb.accessory.xml new file mode 100644 index 0000000..29df966 --- /dev/null +++ b/data/etc/android.hardware.usb.accessory.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- This is the standard feature indicating that the device supports USB accessories. --> +<permissions> + <feature name="android.hardware.usb.accessory" /> +</permissions> diff --git a/data/etc/android.hardware.usb.host.xml b/data/etc/android.hardware.usb.host.xml new file mode 100644 index 0000000..b0ca82c --- /dev/null +++ b/data/etc/android.hardware.usb.host.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- This is the standard feature indicating that the device can communicate + with USB devices as the USB host. --> +<permissions> + <feature name="android.hardware.usb.host" /> +</permissions> diff --git a/services/java/com/android/server/usb/UsbService.java b/services/java/com/android/server/usb/UsbService.java index de4ac03..a093d95 100644 --- a/services/java/com/android/server/usb/UsbService.java +++ b/services/java/com/android/server/usb/UsbService.java @@ -108,13 +108,15 @@ public class UsbService extends IUsbManager.Stub { private final Context mContext; private final Object mLock = new Object(); private final UsbDeviceSettingsManager mDeviceManager; + private final boolean mHasUsbHost; + private final boolean mHasUsbAccessory; /* * Handles USB function enable/disable events (device mode) */ private final void functionEnabledLocked(String function, boolean enabled) { boolean enteringAccessoryMode = - (enabled && UsbManager.USB_FUNCTION_ACCESSORY.equals(function)); + (mHasUsbAccessory && enabled && UsbManager.USB_FUNCTION_ACCESSORY.equals(function)); if (enteringAccessoryMode) { // keep a list of functions to reenable after exiting accessory mode @@ -207,6 +209,9 @@ public class UsbService extends IUsbManager.Stub { public UsbService(Context context) { mContext = context; mDeviceManager = new UsbDeviceSettingsManager(context); + PackageManager pm = mContext.getPackageManager(); + mHasUsbHost = pm.hasSystemFeature(PackageManager.FEATURE_USB_HOST); + mHasUsbAccessory = pm.hasSystemFeature(PackageManager.FEATURE_USB_ACCESSORY); mHostBlacklist = context.getResources().getStringArray( com.android.internal.R.array.config_usbHostBlacklist); @@ -378,8 +383,7 @@ public class UsbService extends IUsbManager.Stub { public void systemReady() { synchronized (mLock) { - if (mContext.getResources().getBoolean( - com.android.internal.R.bool.config_hasUsbHostSupport)) { + if (mHasUsbHost) { // start monitoring for connected USB devices initHostSupport(); } |