How can I suppress the USB permissions dialog? - android

I am developing an application in which I am communicating with an USB device.
When I connect the USB device for the first time and run the application, it asks for the USB permission.
I want to suppress that dialog so it won't prompt the user anymore. I know that it asks for user permission as per the results I've found so far, however I want to know whether the dialog can be suppressed.
Is their any way by which the user can assign the permissions at install time and wont get that USB permission dialog box?

I think that the answer is that it is not possible.
I have not found a way to suppress this so far. I think that this is primarily down to the fact that the permission is granted to a specific device and of course the device is not likely to be known at install time.
What you would effectively need is a blanket "any USB device" permission and I certainly have not found such a thing so far.

I can take none of the credit for this, but the answer is that it can be done using an intent-filter on USB_DEVICE_ATTACHED - see USB device access pop-up supression? for the solution, including a handy demo app.

Related

Android Save permission for a USB device across detach, re-attach

Struggling a bit with Android >=10's UsbDevice class and detecting re-attachment of the same USB device. Prior to Android 10, I could use UsbDevice.getSerialNumber to get a unique handle for a USB device (if it had one). UsbDevice.getDeviceName tends to change from attach to attach e.g. /dev/bus/usb/001/002, /dev/bus/usb/001/003. For Android >=10 you need to ask for user USB permission before calling getSerialNumber. Without having a manifest intent filter for the USB device type and saving the App as the preferred client this is now very messy - a new Permission Request dialogue is needed for each re-attach. Has anyone found a workaround for this? USB OTG connectors are not the most secure so yank then re-plug is a reasonable thing to want to do.

Bluetooth Pairing Without users' confirmation

Can I pair smartphone over Bluetooth without a need to confirm this in user interface, accept to pair this devices. I use android studio. I don't need to exchange data over them, I need just pairing without any action. And then safely pair with smartphone over Bluetooth without any user's action?
Yes and no, but you shouldn't anyway.
The only way to do this in Android is by using the BLUETOOTH_PRIVILEGED permission, which, as you can see, is only granted to apps in /system/priv-app/ or apps signed by the platform key of the device.
So unless you have root and can move your app to /system/priv-app/, you can't do what you want. Even if you can do this, however, don't. It's not a good user experience when someone installs an app, only for it to move itself to the system partition and start pairing without any notification.

Android Bluetooth Discoverbility Dialog

when I want to connect a Bluetooth device I have to turn on the visibility of my device.
Is there a possibility to prevent the dialog which asks for permission to start visibility for a given time?
It should only start and not ask for permission.
Thanks for your help;)
Its a security mechanism of android. You cant remove it. But you can pair your devices, this causes that the dialogue isnt shown anymore.

Unable to trigger Broadcast SMS receiver in MIUI Rom

I have tested my code on Emulator as well as CM9 ROM. Everything works fine. But when I run my app on MIUI v3.6.28 Android Version 4.1.2 it doesn't trigger the SMS receiver.
I searched around on StackOverflow but couldnt find suitable answer except one mentioning about Phone manufacturers implementing internal classes themselves to avoid such behaviour. And MIUI being Xiami ROM maybe that is true. But then how would Go SMS and Handcent SMS work on these devices ?
http://miuiandroid.com/community/threads/sms-notification-not-working.16464/
This might solve the problem. I did not check it since I have moved to cm again for testing . but seems to solve exactly what I need. And description makes sense.
Miui takes preference and takes away the SMS before any other app can receive it.
In Xiaomi devices, you just have to add your app to Autostart list, to do so, follow these simple steps given below:
Open Security app on your phone.
Tap on Permissions, it'll show youtwo options: Autostart and Permissions.
Tap on Autostart, it'll show you list of apps with on or off toggle
buttons.
Turn on toggle of your app, you're done!
Note : When ran through your app via USB permissions is denied by
default for READ_SMS. You need to enable permission in Permission tab
of Security app for your app.

How to reset android by program?

How to reset android phone to original status by program?
or Can we use adb to trigger sth?
Many thanks for replying~
Apart from through the Device Administration API, you cannot simply invoke a call and completely factory reset a device, that I'm aware of.
There happens to be a android.permission.MASTER_CLEAR permission, but in order for the system to actually grant you that, your app will need to have 'signature' or 'signatureOrSystem' permissions, according to a Google Groups thread. The only way to get one of those is to sign the app against the same certificate as the system, which basically means you either have to work for a device manufacturer or compile and sign your own firmware.
I remember that on API8 (2.2) or later, through the DeviceAdmin API, you can perform a factory reset.
But this is extremely dangerous to the users, isn't it?

Categories

Resources