I've tried to do as much research as possible but can't find an answer to this fairly simple question (want to figure this out before I'm going to set up the SDK and everything).I'm thinking about developing my first app and am wondering whether the BATTERY_STATUS_CHARGING from the BatteryManager contains only a get function or also a set function.
I wan't to make an app in which I can manually stop the phone from charging without unplugging it from the charger (via USB) and so am wondering whether this is actually possible.
No, Its not possible on unrooted devices. It uses Settings.System with ADB_ENABLED, but ADB_ENABLED is a Secure-System-Setting which can not be changed by a application.
Yes, It can be done on rooted phone.
There is need to add an permission android.permission.WRITE_SECURE_SETTINGS.
Same type of application on Google Play : https://play.google.com/store/apps/details?id=com.jim2&hl=en
You can hardwire it: 12 ohms in serial still makes the phone be recognized by the computer, yet slowly discharge. See attached Picture.
I know this thread is old but posting my ans anyways for someone reaching here later.. Try this:-
echo 0 > /sys/class/power_supply/batterycharging_enabled/charging_enabled
This is unfortunately not possible. Android only have read APIs for battery data. ADB_ENABLED will not help in this instance either as it's only to enable debugging over USB.
Battery charging control is internal to the Android kernel and battery IC modules. Manufacturers do change it from time to time, but it's not available to apps without root and without controlling the IC (integrated chip) modules through some tricky interface which would actually be different for almost every device out there!
At best if we're lucky, a sysfs interface might help do that, but again it requires root and may differ from device to device.
Use the below command to stop the charging of mobile/handheld when connected to USB:
adb shell dumpsys battery set ac 0; dumpsys battery set usb 0;
Use the below command to stop charging on Android 11.
device need to be rooted.
I'm using Termux but Linux Deploy can be also be used.
sudo nano /sys/class/power_supply/battery/charger.0/stop_charge
Change value to 1 to stop and 0 to start again
Related
The next command enables phone call recording in OnePlus phones (may be others too):
adb shell settings put global op_voice_recording_supported_by_mcc 1
But after reboot its effect is disabled. My phone is OnePlus 6T.
How to make this setting persistent?
jOnePlus Tools is an answer. This application sets settings up on every reboot.
https://forum.xda-developers.com/oneplus-5/themes/app-enable-call-recording-boot-t3634292
This link has other root-required methods you might want to try.
Unfortunately, I am also trying to find a way without root. As the setting automatically turns off, sometimes before reboot, when you have an active some-country sim card, my hypothesis is that there is a "checking" program going on under the hood. If there is an adb command to turn off that "checking", the result should be permanent.
I also have a 6T, and what I could see about what causes recording to be disabled, is any application installation made by PlayStore.
If you keep the automatic update function of the applications deactivated, the recording remains activated, but anytime you do any installation on the PlayStore, the recording will be disabled and you will need to enable it with the command again.
My project involves having a factory standard (e.g. NOT rooted) Android phone connected to a PC by both bluetooth and wifi but the phone itself is not physically accessible (it's in a locked plastic box) and is not intended for use by a person.
Is there any way to have an android phone reboot itself by sending it some sort of command over bluetooth or wifi?
Yes but it is tricky.
There are multiple case-scenario but the only condition is that the Bluetooth or the Wi-Fi connexion is established and maintained by a third-party app and that you have access to the code of this specific app (or even better, you are the developper of this app).
First thing first : the app in question must be able to receive a command either by Bluetooth or Wi-Fi that ask for a reboot.
If you don't have access to the app code or there are no third-party app involved (meaning its the OS (Android) itself that manages the connexion) that won't work at all.
Now, onto the tricky part.
The simplest way would be that the device in question is rooted and your app can be granted super-user (root) permission.
In that case, once it receives the reboot command, it can perform the rebooting process as follow :
Runtime.getRuntime().exec(new String[]{"/system/bin/su","-c","reboot
now"});
or
Runtime.getRuntime().exec(new String[]{"/system/xbin/su","-c","reboot
now"});
Because it might depend on where the su binaries are located.
In any case it might not work on all device so you should try which method works on the device you will be using.
Now, if you don't have a rooted device and/or you cannot root the device in question, you might be able to do it if and only if you sign your application as a system application.
More details here : https://stackoverflow.com/a/4966542/3535408
I hope it helps !
Some background information:
I have a certain yet to be released tablet and sadly the people who designed it seemed to have removed TelephonyProvider.apk
Here's how I've reached that conclusion :
When I go to More... in WIRELESS & NETWORKS there are no options to change APN, VPN or access Mobile networks. (Please note that the table has no facility to lodge a SIM card) However, on my Karbonn ST10 (Android 4.1.1) all these options are found. The certain tablet is currently on Android 4.2.2
When I used an app called APN shortcuts I was able to launch the APN configuration screen, however every time I changed the MCC or MNC number, the APN could not be saved and was deleted.
When I tried to read the contents of content://telephony/carriers I received a NullPointerException.
Questions:
What is the purpose of TelephonyProvider.apk?
Will it be possible to install it without root access? If so, how? (I'm pretty sure this can't be done, but if someone else knows a magical method please enlighten the world)
Can 3G data connections via dongles be established on this device which seems to be missing TelephonyProvider? Or will the ROM have to be edited and TelephonyProvider be installed.
I'm pretty sure this is a programming question, but if it belongs on Android Enthusiasts, please move it.
It's just an apk... you should be able to sideload it with adb without root with adb sideload <your apk>. It would just be removable since its not it /system/app, ie built in with the ROM. If the makers of your device disabled certain features on the device, which would explain possibly why those menus do not display in the Settings app, then TelephonyProvider may not be all that you need to get the connections you want to establish working.
Hope this helps.
Update:
These features are probably disabled on the device you are using. based on what you described.
From the PackageManager documentation.
FEATURE_TELEPHONY Feature for getSystemAvailableFeatures() and hasSystemFeature(String): The device has a telephony radio with data communication support.
FEATURE_WIFI Feature for getSystemAvailableFeatures() and hasSystemFeature(String): The device supports WiFi (802.11) networking.
Is it possible to disable Android on a device from emitting ALL log messages from ALL apps?
On a rooted device maybe. With your own ROM mod, certainly. Otherwise, no. Bear in mind the logs are kept even when your tools are not looking at those logs (e.g., device is disconnected from your development machine).
No, you cannot do this. Some devices (like Huawey's) got logging disabled and you have to do some magic to get this functionality restored, but this is just custom firmware modification by huawey.
On a Huawei device, you dial:
*#*#2846579#*#*
This will bring up an app where you can disable all log messages. I'm sure every device has some secret phone number that lets you do this. No rooting necessary.
I would like to programatically make my device answer to broadcast pings (i.e pinging 192.178.1.255) while connected to a wifi network.
Is there a way i can do that ? Maybe a listener that will ping back, or a flag to set somewhere?
Thanks.
Is there a way i can do that ?
In short: Yes. But it will take some good effort to integrate the necessary components.
The key problem is that you need to listen for ICMP network packets. Such functionality is not accessible from Java and would require either JNI code or an external program. (To my knowledge, it also requires a rooted device.)
You will need a library or program that can process network traffic, such as Jpcap (which would require some modification to work on Android). You could also install and run an instance of tcpdump in the background and parse its output.
It's not possible for an app to send/receive ICMP Echo Requests on Android. (Maybe there is a way on rooted devices)
But if your basic goal is to implement some kind of local device discovery functionality (and your code runs on all devices), you can use UDP broad/multicast messages instead.
I know this question is quite old now, but I came across this looking to for an answer and managed to work it out myself.
What I did was download a root file explorer (I used Root Browser from JRummy Apps) and navigate to /proc/sys/net/ipv4 edit icmp_echo_ignore_all so that it is a 1-line, 1-character file that simply says 0 (when I opened the file, it was set to 1)
No reboot, ICMP requests started working upon saving.