Start bluetooth from termux command line - android

Is it possible to enable/start bluetooth from command-line within the termux terminal on a non-rooted phone/tablet running Android 8?
Use case: Enable bluetooth and connect to my keyboard when I run termux.
I guess I could use tasker to achieve something similar but last time I used tasker, it has a significant impact on battery life.
Regards

No, this is not currently possible. Someone needs to do some android programming and make termux able to use the android bluetooth API.
See https://github.com/termux/termux-app/issues/235 for an open feature request.

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 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).

Control beaglebone black (linux) with android smartphone through usb cable

I have a beaglebone-black/raspberry-pi that is running a basic command line linux system. I am currently operating the board with a keyboard (usb) an an lcd screen (hdmi). Now I want to control the board with my android smartphone through a usb cable instead of keyboard and screen.
Example. There is an application on my android phone say Linux Terminal. That application sends command strings to the terminal running on board, receives the output and displays it.
I can develop android applications and I am also very fluent with C and linux but I am not very good with interfaces (usb) and drivers etc. I have never used a driver in programming.
I wanted to ask is it even possible. If so, is there any existing tool that can do this. If no such tool exists , then give me a brief outline of the whole process (which drivers to use etc).
I think this is what you are looking for:
Termius
JuiceSSH or
Connectbot
There is also a documentation for Termius:
https://www.raspberrypi.org/documentation/remote-access/ssh/android.md
Best regards,
Ben

Connect remotely to an Android device via adb

I'm just testing the adb and I'm wondering if this is possible.
I mean, let's say I have adb installed on a aws instance, whatever the Ip it may be.
Then from there, I want to connect to my Android device via adb I don't know if adb connect can do the trick having the external Ip of the device.
From what I've learned, seems like it is possible, but it's kind of confusing.
Also, I see it's possible to connect without having the device rooted.
But most tutorials or examples are based on wifi, I just want to know if there is a workaround or even a command which can make this possible remotely.
Any ideas?
Thanks in advance!
I would try looking into Vysor. The main purpose of this tool is to be able to control an Android device remotely, but it also provides an option to share the adb connection to the device without a root. Its a powerful tool, that as many applications.

Send AT command from Android to USB port

Hello fellow programmers,
I've got a question regarding the realisation of an app which should be able to send AT commands via USB to a connected hardware.
Is it possible to send these commands over USB without root? I would not want to have rooted phones as target market as I want the application to be useable for the average Android platform. Is there any solution out there which you know and can give some links to that?
cheers
herom
If the phones support the optional usb host api then likely yes. You will probably need a USB-OTG style adapter cable which grounds the extra pin to help put the phone in host mode.
If not, no, unless you have one that can be made a usb host via kernel modifications (requiring root, likely kernel reflashing, and possibly a special cable to inject power)

Categories

Resources