Reboot Android phone via bluetooth? - android

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 !

Related

How to block specific urls in Android

I am developing a parental kind of App in which there is a requirement to block specific urls from all the browsers in the Device. I think this is an old question but couldn't find any solution yet on stack.
Do you have any working solutions. Assumption - The device is rooted.
Regards,
sha
I have two resources for you:
Since the device is rooted you can work directly with iptables. iptables will give you very precise control over all coming and going data packets. Check out open source projects like AFWall+ on GitHub for iptables in action.
If you want to be able to run your app on unrooted devices look into creating a fake VPN. You don't send any data to an actual VPN server, you simply use the VPN API to filter all the information coming and going. Check out Disconnect (whenever they actually share their open source code...) or OpenVPN which is what Disconnect builds on.

Autorun application when phone connected to pc

Is there a way to open an application from dekstop pc (such as an autorun) when the Android device is connected to pc?
Say that I have been creating an Android Application, and then the application is installed in my Android device (phone / tablet). And I want to give this application a special authority that will let the device to run the app automatically when the device is connected to pc.
Actually, the command that will be run by this app is only a command to open a web browser.
My question is:
How to give this application a special authority that will let the device to run the app automatically when the device is connected to pc?
Can someone give me a lighten?
Many thanks in advance!
You can register broadcast receiver that will wait for example for battery change state broadcast (see this: http://developer.android.com/training/monitoring-device-state/battery-monitoring.html). When such broadcast is received, determine if you are connected to PC and start proper activity.
I guess that you might need your application to work all time (have started sticky service) to make this work.

Purpose of Telephony Provider

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.

How to stop the phone from charging via USB programmatically

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

Broadcast message from Desktop PC to Android Device using WIFI connectivity

I want to transfer messages/file from desktop application to the Android device. My question is that can I connect desktop Wifi device with the Android WiFi device without any use of internet connection. I want to use it just like Bluetooth. Is this possible/feasible or not? If it is possible then how can I implement it? And what is the message limit to transfer message/file?
Note : I wanted to use it as real time application.
Kindly suggest me any good approach and if possible then how to do that.
Thanks and Regards Dhaval
Wifi Direct will solve your problem, but there are no public API's available yet for developers. You will have to wait until Google releases it (hopefully soon). Some more reading:
http://www.sfonge.com/forum/topic/when-will-android-open-wi-fi-direct-api
http://groups.google.com/group/android-developers/browse_thread/thread/eb62f0aa0eccf161
Have a look at the Android Notifier application and it's sourcecode.
If you either convince your PC to function as a wireless access point, or obtain a wireless access point, you can set up a network connection between the PC and an unmodified android device. Note that it is not necessary for their to be an upstream Internet connection feeding the PC or access point.
You would then need to write a server running on the phone which listens for inbound TCP connections from the PC. Any android application with internet permission can do this, provided that you use a port number in the unprivileged range. You may have problems with the wifi timing out and shutting down, so you may need to use a timer to periodically trigger a small network operation (ping the access point, etc) to keep it awake. Note that this will use up your battery (what android wants to shut down an idle wifi to prevent).
If you can get both the device and the PC to work with an "ad-hoc" wireless connection you would not need the access point or PC to function as one, however last I heard this required root-level mods to the android device.

Categories

Resources