com.sonyericsson.permission.BLACKLISTED_USB_DEVICE

1k views Asked by At

I'm developing an app which connect to android usb device host. When connecting it to an Sony phone and trying to receive the android.hardware.usb.action.USB_DEVICE_ATTACHED by intent filter or directly in the broadcast receiver I receive the next message on Sony Z3 compact device (Android 5.0.2):

Permission Denial: receiving Intent {
act=android.hardware.usb.action.USB_DEVICE_ATTACHED flg=0x10 (has
extras) } to ProcessRecord{***anId**
**anId:my.app.package/u0anId} (pid=xxxxx, uid=xxxxx)
requires com.sonyericsson.permission.BLACKLISTED_USB_DEVICE due to
sender android (uid 1000)

Do I need to call a specific permission? Send a validation number with the request? Is it the usb device that need to send something special?

Can somebody tell me whats the matter? Thank you for trying to help.


1st UPDATE Thank's DDPWNAGE for reply... I'm turning arround with the Permission denial... trying to set

<permission 
    android:name="com.sonyericsson.permission.BLACKLISTED_USB_DEVICE"
    android:protectionLevel="signature" />

but this change nothing. I've set the device_filter

<resources>
    <usb-device vendor-id="xxxxx" product-id="xxxx"/>
</resources>

with in the manifest

<permission android:name="my.package.USB_PERMISSION" />
<uses-permission android:name="my.package.USB_PERMISSION" />

<uses-feature
    android:name="android.hardware.usb.host"
    android:required="false" />

I've also trying to set

<permission android:name="my.package.USB_PERMISSION"
    android:protectionLevel="signature" />

But I cannot figured out why the device should be in any blacklist of usb


2nd UPDATE

I realized that I also have this message before the Permission Denial :

Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1340 com.android.server.usb.UsbSettingsManager.blacklistedDeviceAttached:757 com.android.server.usb.UsbHostManager.endUsbDeviceAdded:303 com.android.server.usb.UsbHostManager.monitorUsbHostBus:-2 com.android.server.usb.UsbHostManager.access$000:54

When I look up in the UsbHostManager I didn't see any reason why on standard Android devices it works but on Sony devices I've this waring message. In the class we have these 2 methods which check the blacklisted devices :

private boolean isBlackListed(String deviceName) {
    int count = mHostBlacklist.length;
        for (int i = 0; i < count; i++) {
            if (deviceName.startsWith(mHostBlacklist[i])) {
                return true;
            }
        }
    return false;
}

/* returns true if the USB device should not be accessible by applications */
private boolean isBlackListed(int clazz, int subClass, int protocol) {
    // blacklist hubs
    if (clazz == UsbConstants.USB_CLASS_HUB) return true;
    // blacklist HID boot devices (mouse and keyboard)
    if (clazz == UsbConstants.USB_CLASS_HID &&
            subClass == UsbConstants.USB_INTERFACE_SUBCLASS_BOOT) {
        return true;
    }
    return false;
}

My device is not a USB_CLASS_HUB nor a USB_CLASS_HID, so the only things I see is that the device is in mHostBlacklist. But does each constructor have is own host blacklist or is this given by android?

mHostBlacklist = context.getResources().getStringArray(
            com.android.internal.R.array.config_usbHostBlacklist);

seems to be from android but is it customizable by contructors? And in this case why did Sony blacklist our usb device?

Somebody from Sony is here to help?

Thank you for your time.

1

There are 1 answers

0
DDPWNAGE On

Let me try and dissect that log:

Permission Denial: receiving Intent {

Something's receiving an Intent! What is it?

act=android.hardware.usb.action.USB_DEVICE_ATTACHED flg=0x10 (has extras) }

The action here is android.hardware.usb.action.USB_DEVICE_ATTACHED with flg (flag?) 0x10 (hex for 2), guessing that means it (has extras). Guessing that's the intent the reciever's trying to receive.

to ProcessRecord{***anId**
**anId:my.app.package/u0anID} (pid=xxxxx, uid=xxxxx)

Your app is the receiver of the object... got it.

requires com.sonyericsson.permission.BLACKLISTED_USB_DEVICE due to
sender android (uid 1000)

It seems like here's where your error is. In order to get the USB_DEVICE_ATTACHED event sent to your app, your app needs permission to get it first. Most importantly, it needs the BLACKLISTED_USB_DEVICE permission.

It may also be that your device was "blacklisted", but, why? See if BLACKLISTED_USB_DEVICE is a permission that can be enabled, and try again.

As a further hint: Your crash log begins with Permission Denial.