Connect to RS232 from Android - No permission dialog or shell command - android

Objective
I'm developing a custom app for internal use on a rooted android mini-pc.
The goal (between others... so...many...others...) is to be able to turn on and off a tv using the serial port embeeded on the tv.
I'm using an FTDI UART RS232 serial usb cable for it.
Status
The application is working right now, using an android library (serial-driver) i can communicate with the tv, but the problem is that the device asks for permissions every install (and sometimes, weirdly, again on the same device), so it needs to be improved.
Issue
Since the device doesn't have mouse or keyboard by default, when this happens someone has to click the buttons, and since the device is normally hidden behind the screen, it can be really annoying.
My two bits
This problem, i feel, can be solved by two methods, but i still haven't been able to make them work.
Since the device is rooted, i might be able to modify an unknown (to me) parameter that allows me to bypass the permission request. For this i have tried to make an intent filter for the usb device, and to rewrite the interface that controlls this behaviour, both without success. Is there a way to make this android version more lenient about permissions?
I use for other reasons SuperSU inside the app, so i can use the full width of the might shell power. Using this i've been trying to send commands manually to the device (/dev/bus/usb/00X/00Y), but this haven't worked. My theory is that it's beacuse of the permissions of the device path, but even doing an unhealthy chmod 777 i cannot have them working.
So, that's my problem right now. I hope someone here can help me.
Additional data
Running: Custom Android 4.4.2 (Cannot be changed)
Needs to be doable solely from within the apk (but it can use shell commands)
We don't have the manufacturer signature to install it as a system app
We can use only one app, so i cannot have another one to move this one to /sys/apps, and i don't know if an app can do that to itself.
using Busybox stty -F /dev/.../ returns "Operation not permitted"

Related

Android Management API - boot device when power is conncted

So, as the title describes, I'm looking for a way to boot an Android device when the power charger is connected. We are making dedicated devices, in kiosk mode, and are using the Android Management API to setup everything on the device.
This covers most of our requirements, like preinstalling apps, disabling everything else, hooking it up to Managed Google Play, getting device reports etc... But for this power thing, I can't find any solutions in the docs.
The problem is that the physical power button isn't accessible to the user (don't ask my why :)), and when the battery drains they have to be able to power it up again, without unscrewing the case to get to the physical button.
I know this can be done in different ways, but I can't find anything that would work with Android Management API. I'm looking at this "fastboot" approach, since it seems pretty simple https://source.android.com/devices/bootloader/unlock-trusty#off-mode-charging
Initially, I though I could run this somehow using the devices/issueCommand endpoint https://developers.google.com/android/management/reference/rest/v1/enterprises.devices/issueCommand, but that seems to support only some predefined commands like: LOCK, RESET_PASSWORD and REBOOT.
Maybe I'm just missing something. If someone has another approach in mind, please share.
If it's any help, we also have the Android Management API hooked up to the PubSub API, and a topic there that the pulls the reports of the devices. Theoretically, I could listed to the "power connected" event there, and run some command on the device. But again, the problem is how to run this command on the device remotely.
Maybe a solution would be to make another app that will run as a background process that runs this command. I guess I would need to add it as "receiverActivity" in the policy. But the same problem remains... how to invoke this activity from the Android Management API.
The bottom line is that this needs to be fully automated. Running this command on each device manually is not an option.
Also, worth mentioning, this is an Ionic app. Although it's probably not impossible, we would like to keep this logic outside of the app itself. Ideal solution would be just to run some adb command remotely using the Android Management API.
Or maybe there is a good 3rd party app that does this, and I could install that app in the policy and invoke it somehow.
All suggestions are welcome. Maybe there is a simple solution that I've missed.
UPDATE AFTER COMMENTS: I'm not looking how the actual app can do this. I'm looking for a way to execute some "native" command when the device is initially setup from the Android Management API policy. So it should execute only once. When it sets up everything initially. It should edit some file on the device (or run some command) to enable this feature. Later, it shouldn't care if the device is turned on or not, or what apps are running on it. There are a few different ways how to do this suggested here https://android.stackexchange.com/questions/20021/automatically-power-on-android-when-the-charger-is-connected. I'm looking for a way to trigger one of these commands when the device is setup initially (only once). In other words, this should execute only when the device is enrolled. It shouldn't care about any apps running on the device.
So the "free" way to do this is using the fastboot commands. But from the AMA API this is currently not (and most likely ever) possible. This problem will always be hardware specific, since the bootloader is controlling the boot process, and the bootloader is custom made for each device.
There are options for different manufacturers though. Look into OEMConfig apps (which you can get in the Play Store for Work or from the manufacturer themselves).
Samsung has it's KNOX API, and the paid ProKiosk mode supports controlling Power Control.
Regarding the post in your question solving the problem, you will not be able to modify any files in the system since that's restricted to root. This will also never work for Managed Devices.
You could "half-automate" the process by setting up a raspberry pi or some other device with a script that waits for fastboot devices to get connected and executing the command. That way you just visit every device and put it into fastboot and plug in the device and you're off to the next one.
For clarification: adb and fastboot are two entirely different things. Fastboot is running while the device is in it's bootloader. Adb is running while the device has started android. It should technically be not possible to execute fastboot commands while android is started since the bootloader has already exited.

Is there any way to skip Android device setup wizard using ADB when device is on Android P?

I want to skip the Android P setup wizard programmatically to reach Home Screen to proceed doing other scripted jobs. Since the ADB already recognizes the device when plugged on first setup wizard page, I was trying to skip initial setup using it. Is there any way to do that using ADB or by other tools, potentially Python?
I think I may have tried this before and I don't believe there is. While the ADB recognizes that there is a device attached, that doesn't mean it can read it. The device would have to be set up completely before it would be able to interact and read/send data to the ADB.

Is it possible to control Android bluetooth device pairing via adb?

I'm looking into automating certain Bluetooth activities via adb.
I have been able to successfully enable and disable Bluetooth using information found here:
android enable disable bluetooth via command line
but need more capabilities and control than just enable/disable.
While looking for solutions I came across this post:
Need ADB command line to start a youtube video using browser
where chrome is controlled via intents/activities.
I've attempted a similar solution with Bluetooth by unpacking (using apktool) the Settings apk and the bluetooth apk, looking at their AndroidManifest.xml files for a list of their intents and activities - then using those intents and activities via adb,
e.g. (running shell as superuser)
am start -n "com.android.settings.bluetooth.RequestPermissionActivity/android.bluetooth.adapter.action.REQUEST_DISCOVERABLE"
Thus far, commands of this nature have either:
1) Failed outright, "unable to resolve intent" or similar issues
2) Led to a ">" prompt wherein I'm expected to give more input (though I'm not sure what I would enter there)
Ultimately, I'm seeking to control BT connections using adb (so as to be able to automate those tasks via scripts in the future).
I am using a Google Pixel 2 (rooted).
If I am on the right track, any guidance or advice would be appreciated.
If I'm going about this completely wrong, feel free to let me know (and hopefully let me know where I should be looking instead).

Inject touch events android

I've been playing around with adb and adb shell input <some input> for the last few hours (building funny little batch scripts that can basically controll my phone.
Since I cannot execute these commands on the device itself without a PC with ADB and I don't want to root my phone I have been looking for an alternative on how to automate user input on the device.
I found a great Tutorial here, however it states that I need a system level permission in order to inject input events into other apps.
Again, I don't want to root my phone and I want the app to be compatible with different devices, so I can't sign it with the platform-key.
Beginning to think it was impossible, I remembered an app that could do such a thing. The anti virus app CM Security is capable of starting the chrome browser and clearing the browser data.
I assume this is done with input injection, but I am not sure about it.

Android hardware debugging

I've bought a tablet recently. It's a SysTrade's Plug 10.1 (Chinese product of local company). It features a reasonable CPU and quite nice GPU, so I thought it would be great to hardware debug my applications. However, this feature seems not to work on my device...
At beginning I lacked the required vendor id so after a few phone calls to SysTrade I received one. But that code didn't work. So I've written a small app and got all 2-byte numbers which I copy-pasted to /etc/udev/rules.d/51-android.rules. The problem is that adb still can't see my device. What's important my HTC Wildfire is successfully recognized so rules are written well.
I know none who owns this tablet so I don't have a possibility to check whether all Plugs or only mine are affected. Any ideas would be highly appreciated...
PS. I'm developing on Linux (Ubuntu 12.10).
PS2. When I connect the device to PC it shows that hardware debugging is turned on, but adb doesn't see my device.
I've managed to successfully resolve the issue without rooting the device. The only needed action is to manually add an entry for the device vendorid in ~/.android/adb_usb.ini.
Normally it should be generated based on /etc/udev/rules.d/51-android.rules by android update adb command but it seems that this application failed. What's important, vendorid must be given in hex number specific format, which is: 0x(2-BYTE HEX) for example 0x2207.
Try running adb on root.
If that doesn't work you can still try to root your device(This may void warranty) and use app like adbWifi. I'm using the latter for debugging and it works: I can run my apps on my M-tech aTAB7t.

Categories

Resources