Android 10 stacked USB permission when using intent-filter to start activity when USB attached - android-10.0

My setup
Pixel 3/Android 10 (but same problem on Samsung Galaxy S9/Android 9)
App targets API 29 (Android 10)
A USB device
On Android 10 there has been a change to the permission model, which means reading serial number for a USB device requires an explicit user permission, see: https://developer.android.com/preview/privacy/data-identifiers#usb-serial-user-permission.
So when receiving an intent that a USB device is attached I automatically request a permission to read the serial number (results in a permission dialog: "Allow X to access Virtual COM Port ?").
To also be able to launch the application when an appropriate USB device was attached it was previously possible to also do this (AndroidManifest.xml):
<activity
android:name="MainActivity"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
/>
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="#xml/my_device_filter"
/>
</activity>
... which results in a permission request dialog also when a new USB device is attached ("Open X to handle Com Port?").
But, as previously mentioned, the application must also request permission for reading the serial number which results in a second permission dialog.
These two dialogs are now stacked and if agreeing to the first dialog ("Open X to handle Virtual COM Port ?"), the second one ("Allow X to access COM Port ?") is dismissed automatically leading to broken functionality.
Any suggestions on how to handle these two permissions?

Related

SIM7000 ATD command returns ERROR, how to fix?

I'm currently working on a project that is required to dial a number in the event of a trigger, I have the dfrobot shield currently set up.
I have managed to get it to be connected to the network using 4g LTE and send an SMS. But when I send:
ATD+44XXXXXXXXX
It returns
ERROR
Is there any specific AT commands that need to be sent to enable dialling of phone numbers?
Current set up:
Arduino Uno
DFRobot SIM7000E
12v external input

AndroidThings BluetoothAdapter not always enabling

First let me say that AndroidThings is AMAZING! I like everything about the concept of getting Android into IOT. I am trying to bring AndroidThings to my company for use in production lines. Onto the question!
I have been trying to use Bluetooth low energy for communication with devices. I have gotten the Bluetooth working sometimes. That is I enable the Bluetooth adapter and it very quickly starts and I get scan results thereafter. Now say I do this another time, I check the adapter enable state, I try to enable and it just sits there. One way that seemed to work was to call BluetoothAdapter.disable() no matter what (maybe clearing something?) then performing a BluetoothAdapter.enable().
It seems like when using AndroidThings enabling the bluetooth hardware on the Pi is very 'finicky'. Also I have noticed that it may take up to 1 minutes to enable the Bluetooth.
Things to know:
I have tested this on multiple PIs.
I am using DP7 (though i saw this on DP6 also)
The main problem I am seeing is the enabling of the
bluetooth hardware (BluetoothAdapter)
Yes I have all of the required permissions:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Yes I have power cycled the PI after I have put the app
on it.
I have implemented a retry mechanism for enabling the adapter and it still sometimes does not work.
I have followed the bluetooth tutorial on the AndroidThings page and I still get inconsistent results.
Has anyone else seen this issue or related issues?
I think this issue is solved in the new updated version of Android Things (1.0.1,updated June 2018)
Resolved Issues:
Raspberry Pi 3 devices with UART hardware connected fail to boot up.
Bluetooth is disabled on the Raspberry Pi 3 due to an invalid hardware configuration. This hardware configuration is created by the starter kit settings in the Android Things Console.

Is there a way to test SocketMobile integration without actual scanner?

I have Android and iOS React Native app that requires user to scan barcodes. I am now working on integration with SocketMobile scanner.
Is there a way to test integration without actual scanner device? Maybe there's some kind of emulator?
Using the SDK you can enable a "SoftScan" device, which uses the built-in camera. The SoftScan device behaves just like a physical device and can be configured using the same APIs.
Enabling SoftScan
After ScanAPI is initialized; most likely inside ScanApiHelperNotification.onScanApiInitializeComplete()
mScanApiHelper.postSetSoftScanStatus(kSktScanEnableSoftScan, callback)
Once SoftScan is enabled, you will immediately receive a device arrival notification - in the same way you receive a device arrival notification when a physical device is connected via Bluetooth.
The SoftScan device does not support all the properties of a physical device and will return an unsupported error if you try to get/set one of the properties it does not support.
SoftScan uses the Barcode Scanner app, so make sure it is installed on your device

How Can IBM Bluemix Node-RED Iotout node be set up correctly to send command to Device (Arduino)?

I have an Arduino Uno that is successfully registered as a device with IBM IoTF. It can send information to the Bluemix Node-RED app without any issues now.
Now, I would like the Node-RED app to send commands to the device (the Arduino Uno). The Arduino is subscribed to the MQTT without any error. But, it is not receiving any commands from the Node-RED. I followed the directions at the link below to create another flow in Node-RED to show when a command is published and the commands are being shown, so they seem to be going to the MQTT broker. But, the device (Arduino) is not receiving them.
How can I figure out how to get this working?
Node-RED, IOT Foundation Out Node Not Sending Commands
I have the IBM IoT Out Node parameters set as follows:
Authentication: Bluemix Service
Output type: Device command
Device type: Arduino-tempsensor (this is the same string I used for the device type (name) when I registered it in IoTF)
Device ID: I put the MAC address here, should it be more
Command Type: status (I used the word "status" here. Does capitalization matter? Where should I get this value from? I used "status" because it is in the topic: "iot-2/cmd/status/fmt/json" is that correct?)
Format: json (does capitalization matter here?)
data: {"d":{"myName":"Arduino Uno", "temperature":989}} (I used this because it's JSON and I wanted to just see anything at the device)
Name: IBM IoT App Out
I typed up this whole question and then it occurred to me that the test flow to look for the published command should have all of the parameters set to exactly the same as the output. When I tried that, I was not getting the command message coming back. Then, I realized that my mac address (device ID) was capitalized in one place, but not the other. The MAC address (Device ID) I used to register the device was all in caps, so I make the Iot-out node for the command so that it was all capitalized and made the Iot-in node to test for the message so that it was all capitalized. Now it works! Then, I looked back at the device (which was printing to the serial monitor so I could see what was happening) and I am now seeing the messages! So, make sure your parameters follow the same capitaliztion!

android instrumentation: need to simulate a button click

The only issue is that the button resides in the com.android.systemui package, or so I imagine. It is the OK button that a user has to press in order to allow adb over USB. My touchscreen is dead, and I am controlling the phone through an USB mouse, so I am unable to click that OK button to enable debugging (non rooted phone). I was thinking that an instrumentation apk would do it, but... there goes trouble.
Another approach I have taken has been signing the instrumentation .apk with systemui's certificate. That has only led to Failure [INSTALL_FAILED_INVALID_INSTALL_LOCATION] though.
So, any way to click that button ?
What I ended up doing was to root my phone via kingroot apk, then install a wifi adb apk which, as it says, enabled adb over wifi andI was able to use the OTG mouse in order to accept that dialog asking for permission to adb into the phone.

Resources