We've bought some custom android tablets, that we're going to use as kiosk tablets. For our kiosk app to work properly the app needs root access.
How can I check if the device is rooted properly?
And how can I root it if it isn't?
Things that point to that the device IS rooted:
When I ADB shell into the tablet the line starts with "#" (I read somewhere that this means that the tablet is rooted).
When I run "su" in the shell nothing happens (no errors).
This file exist /system/xbin/su"
Things that point to that the device IS NOT rooted:
I have installed Root Checker, it says "Sorry! This device does not
have root access"
When I run the following code in our app, which I know for a fact is working on
other rooted devices:
Process process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(cmd + "\n");
I get an error: "java.io.IOException: write failed: EPIPE (Broken pipe)".
Had to try a number of different root tools. Turns out KingRoot (https://kingroot.net/) did the job. Afterwards Root Checker says that it is rooted correctly and my app works again.
There is this nice guide which you can follow to check if the phone is rooted or not.
Link to website
Related
I'm trying to read the MSR information from an android device with userDebug build , and it requires root permission. I have tried adding :process = Runtime.getRuntime().exec("su"); and when i debugged the program ,the variable process is getting initialized with NULL. And I have made some function call to read the MSR value by specifying its path /dev/msr*,and when i run the program the log window shows Permission denied. So is there any way to get into root permission via an app without having a rooted android device?
So is there any way to get into root permission via an app without having a rooted android device?
By definition, no.
process = Runtime.getRuntime().exec("su");
su command is to run the shell commands in Super user mode.
If the device is rooted, this command causes SuperUser to show a dialog, which lets you either Allow or Block it from root access.
So is there any way to get into root permission via an app without
having a rooted android device?
There is no official way to do this. If your app needs SuperUser access, then you can build one click root method like rooting apps and can ask the user to root first.
I recently jumped into an android development tutorials and doing my own app for the sake of learning. I want to get root permissions within my code in a proper way. So not by calling /system/xbin/su but by using something like seteuid(0). Unfortunately seteuid method does not work for me.
I am testing app on a real device, which I rooted, enabled debugging mode and well I clearly see that when using a call to /system/xbin/su my app requests root permissions from system, which does not happen with seteuid and seteguid (setuid and setguid do not work either but I would not expect those to do it as they are capable only in lowering the permissions).
Please, advice on where to look for a proper code implementation for requesting root permissions like it would do a top notch developer. Maybe some native api call? Or does everyone just use a call to su to get the needed access?
The usual way in Linux of elevating privileges -- that is, to run an application with greater privileges than the logged-in user -- is to set the SUID flag on the executable (e.g., chmod ug+s ...). This will make the process take the identity of the binary's owner (usually root), rather than the logged-in user.
This is tricky to do effectively on Android, even on a rooted device. First, you won't be able to install an app using the usual (APK) mechanisms that includes binaries with SUID permissions. Second, an Android app is not an executable in the usual sense -- a single executable handles the launching of all apps.
Still, if you want to experiment on the command line, it should be possible to set the SUID flag on binaries, in at least some filesystem locations.
If you have a rooted Android, then very likely there is some infrastructure already in place to control privilege elevation. Most likely the "su" command will work (because there will be kernel mods to make it work), and it will be provided either with credentials or with some other way to control which apps can use it. I believe that, as you suggest, calling "su" is the usual way to do privilege elevation in apps on rooted Android. It is fraught with difficulties, however. There's a document https://su.chainfire.eu/ that explains how "su" is typically implemented in rooted Android devices, and gives some guidance on how to use it properly.
Just in case posting my solution to the problem which I did in Java (no native code is needed here):
protected void hideRoot() throws IOException, InterruptedException {
Process p = Runtime.getRuntime().exec("su");
DataOutputStream dos = new DataOutputStream(p.getOutputStream());
dos.writeBytes("mount -o remount,rw /system\n");
dos.writeBytes("mv /system/xbin/su /system/xbin/suhidden\n");
dos.writeBytes("exit\n");
dos.flush();
p.waitFor();
}
I am now trying to run the Android CTS 7.0 on Google Nexus 6 (AOS:7).
There is an fail in the item "CtsCarrierApiTestCases"
The error message is:
android.carrierapi.cts.CarrierApiTest#testHasCarrierPrivileges
fail
junit.framework.AssertionFailedError: This test requires a SIM card with carrier privilege rule on it.
We had checked the following Android web page:
https://source.android.com/devices/tech/config/uicc.html#prepare_uicc
According to the above link, we need to add the CarrierPrivileges to the UICC card and this has to be done through the Telephone System provider.
Unfortunately, till now we do not have the contact to our system provider here in Taiwan.
Any chance that we can do this by our won in the lab?
We are thinking to buy a card reader and a blank SIM card, could this be a direction?
Any advice is welcome and thanks in advance.
I had encountered same issue. Some cts tests are only allowed for system priviledged apps or if app has UICC carrier privileges.
In both options are not availabe, as a workaround, /AOSP/platform/packages/services/Telephony/src/com/android/phone/PhoneInterfaceManager.java can be tweaked as shown below to disable permission checking in source code.
After aplying patch, run "mmm platform/packages/services/Telephony/" followed by "adb remount && adb sync" to update system priviledged app /system/priv-app/TeleService/TeleService.apk.
One time device reboot is required afterwards.
private void enforceModifyPermissionOrCarrierPrivilege(int subId) {
+ log("CTS CarrierPrivilege Allowed Patch");
+ return;
int permission = mApp.checkCallingOrSelfPermission(
There are command line flags (or "switches") that Chromium (and Chrome) accept in order to enable particular features or modify otherwise default functionality.
Chromium Command Line Switches
Run Chromium with flags
Tried Chrome 41.0.xx and Chromium 43.0.xxx shell with:
# echo "chrome <flags>" > /data/local/tmp/android-webview-command-line
# echo "chrome <flags>" > /data/local/tmp/content-shell-command-line
Any idea how to run chrome with flags on Android or directly add these into default profile.
Want to add --sync-url flag to use my sync server instead of google sync servers. chrome://flags only enable/disable flags but wont let you add new flag.
New method added in Chrome 661 that works for a production build on unrooted devices.
Using adb, write the flags to /data/local/tmp/chrome-command-line.
For example:
~$ adb shell 'echo --unsafely-treat-insecure-origin-as-secure=http://a.test > /data/local/tmp/chrome-command-line'
In chrome://flags, turn on enable-command-line-on-non-rooted-devices.
Force stop Chrome (the relaunch now button will not trigger the reading of the flags file, even though the danger snackbar will disagree).
Verify in chrome://version that this worked.
https://www.chromium.org/developers/how-tos/run-chromium-with-flags#TOC-Android
What you're doing is correct, but seems like you're writing the switches to the wrong file for Chrome (and note that the file that you write the switches to may vary based on the OS version [or maybe phone?] ).
I tried this on two different phones, and had to write to two different files! Hopefully one of them will work for you:
Phone 1: Nexus 6 with Android 6.0.1
Simply do the following in adb shell:
echo "chrome --sync-url" > /data/local/tmp/chrome-command-line'
Phone 2: MotoG with Android 4.4.4
This is a bit trickier. It turned out that Chrome actually reads the switches from /data/local/chrome-command-line (not in the tmp subdirectory!). Now the issue is that on an unrooted phone you won't have permission to write to this file! So I had to root my phone* and use su to write to the file:
adb shell
su
echo "chrome --sync-url" > /data/local/chrome-command-line
*Rooting an Android phone is actually very easy and takes only a few minutes. There are a number of one click apps for rooting your phone (e.g. KingoRoot). For the case of MotoG, I had to do a few more steps to root, following this)
I needed insecure origin flag for testing of service workers on mobile device. However, for some reason these flags did not work on mobile chrome. Behaviour similar to insecure origin flag can be achieved by port forwarding.
You can find further info in my original answer here: https://stackoverflow.com/a/56146180/5048121
This does not apply exclusively on service workers, if you need https behavior on mobile device, you can combine it for example with allow-insecure-localhost flag or use self-signed certificate for localhost on server and get rid of cert errors on mobile chrome.
You need chromium debug build in order to use these switches.
I'm trying to use touch screen with developer board running Android 2.2. I have manufacturer's instructions and I need to enable uinput process which should be visible in Android under /dev/input as uinput.
I have checked this using menuconfig:
CONFIG_INPUT_UINPUT: y/m
Device Drivers --->
Input Device Support --->
Miscellaneous devices --->
User level driver support
And the driver is already enabled but uinput is still not visible in /dev/input.
I have process uinput in /dev but it is owned by bluetooth.
Is there a way to install uinput process?
It turns out that driver was looking in both places (/dev and /dev/input) so this wasn't necessary. In case someone still needs that file to be in /dev/input location you can create symlink by putting this at the end of init.rc file:
service ln /system/bin/ln -s /dev/uinput /dev/input/uinput
user root
group root