adb command for launching an app with security exception - android

When launching an app using adb command "am start intent.... ", I got an security exception stating that "java.lang.SecurityException: Permission Denial:", and the app doesn't get launched.
When I checked StackOverflow for solutions, I found solutions which are based on editing the manifest.xml file. I dont have any permissions to edit the file. Since am a user of that app and not a developer.
My questions are
1. Is there any way to escape this exception via adb commands. I need to escape this through commands, because its a third party app also I don't have access to manifest.xml file.
Else is there any other way to launch the app through adb command??

If you root your device you can gain root access/permissions by using su before your commands. This should prevent you from being denied due to permissions.

Related

Monkey throwing security exception even though they are disabled

He everyone, I am getting this exception
java.lang.SecurityException: Permission Denial: android.intent.action.CLOSE_SYSTEM_DIALOGS
and Im not sure where its coming from as the app im testing doesnt use android.intent.action.CLOSE_SYSTEM_DIALOGS
anywhwere
Maybe it is a 3rd party library somewhere.
I disabled security exceptions with
adb shell monkey -p package.name --ignore-security-exceptions -v -v 15000
but it still throws the exception.
Any help with this will be appreciated, thank you for your time
There is likely a permission issue within the program "Monkey" itself in which, is conflicting with the Android permission system. It appears to be the same type of error that would occur in Windows if you tried to run a program that required administrative rights.
If possible, try running as admin.

Root access works with adb, but root process on Android Studio doesn't (Android Things)

Currently I'am working on an aplication via Android Studio, that executes commands using the next sintaxis:
Process p = Runtime.getRuntime().exec(new String[] { "su", "-c", "ip link show"});
I'am working with the device IMX7D_PICO (it uses Android Things as SO). It is rooted, as is shown in the following pic:
But, when I run a command as root on Android Studio, I get the next error:
W/System.err: java.io.IOException: Cannot run program "su": error=13, Permission denied
W/System.err: at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:692)
at java.lang.Runtime.exec(Runtime.java:560)
I don't know why su works only on adb. In other hand, I know that there are others ways to obtain the data of ip link show, but the next step, it's open a socket RAW with the command that I said. So, I need to run process as su via Android Studio.
An app's process has less privileges compared to those of the shell's, resulting in
java.io.IOException: Cannot run program "su": error=13, Permission denied
For the permission to be granted you should install SuperSU app or alike and follow the app's prompts while your app is trying to su with Runtime.getRuntime().exec("su").
Once the process has gotten root you can grab the standard input of the root process and write the command(s) to it, reading its standard output. For more details see: execute shell command from android.
I don't know why su doesn't work. I 'suspect' that Android Things is using a single user that is root already, so maybe executing the command without using su would work.
On the other part of your question. Parsing the output of system commands is not the best way of getting info, in this case, you can probably get what you want using the Android class NetworkInterface https://developer.android.com/reference/java/net/NetworkInterface#getNetworkInterfaces().
You can manage raw sockets using the Android framework classes too.

android app can't root but shell can

I read lots of websites about how to root an android device and give the app root privileges.
Now I have installed superuser app. When I enter su in a console to the device then superuser comes to ask for rights. This looks fine.
But when I do Runtime.getRuntime().exec("su"); in my app nothing happens.
Error code is 1, message is permission denied. No superuser message appears. This looks like my app can't call su. Funny: when I let my app call Runtime.getRuntime().exec("su -v"); I get a result! (namely the su version).
Call to su only fails.
What am I missing?
Btw. I added permission android.permission.ACCESS_SUPERUSER to the manifest as stated somewhere.
There are so many threads about root privileges, but none of them explains what can go wrong.
Is this CyanogenMod? Look in the settings: you can choose whether to allow apps to request root, and whether to allow adb to do so. You might have got it set to "ADB only". If so, change it to "ADB and apps".
Your su -V tells you that you're successfully executing an external program; but su itself is refusing to let you become root.

android dumpsys permission denial

I have an application where I create a process and call the dumpsys telephony.registry command to get information about the mobile network status.
String[] cmds={"dumpsys telephony.registry"};
Process p = Runtime.getRuntime().exec(cmds [0]+"\n");
and then after that I parse the result of the command. For "ls" or other commands it works fine. For dupmsys I get Permission Denial: can't dump telephony.registry from pid-953, uid=10090. I get the same error results for dumpsys power or other dumpsys commands.
I have set DUMP permissions android.permission.DUMP in the android Manifest like suggested here
I think that I am doing this right since Android offers this feature here
I have also done the step described here to force eclipse to allow me to give my application DUMP permission in the manifest.
When I execute the dumpsys command I always get the same result
Permission Denial: can't dump telephony.registry from pid-953, uid=10090
Am I doing something wrong? Why does android OS still deny me access to the dump service ?
PS I have set min API 8 and I am testing the application on device running (ICS)
API 15
Why does android OS still deny me access to the dump service ?
Because that permission is flagged as android:protectionLevel="signature|system|development" (or signatureOrSystem using the old syntax) on Android 2.3+, and therefore cannot be held by ordinary Android SDK applications.
There's another (hacky) way to access dumpsys without rooting your device - through adb shell.
This will require allowing USB debugging, and finding the port of the adb service.
Enable USB debugging on your device. This option is found under Settings -> Developer Options.
Connect your device to a PC, and run the following command from the PC's shell/command line:
adb tcpip 12345. Then, from your devices shell, issue the command adb connect localhost:12345 from your application. You can now disconnect the device from USB.
Alternatively, you can scan the ports on your device one by one without USB connection, using adb connect localhost:<portnum> and find the port adb service is listening to.
Authorize USB debugging from the pop up confirmation dialog, if prompted. Check the "always" checkbox to do not require this step again.
Now, when you have access to the adb service, use adb shell dumpsys ... from your application code to get whatever service dump you need.
NOTE: You don't need the DUMP permission for that to work.
The android dev team decided to stop granting these permissions to third-party apps. Only system apps can now get them.
more details:https://code.google.com/p/acra/issues/detail?id=100
It reports private values of core Android services that you would never be able to typically obtain. Official document says "Not for use by third-party applications".
Add permission on your manifest "android.permission.DUMP". I have not tried it yet but it shows on adb shell that it is missing that permission

Root permission not granted to Android app for exceuting "su" command

I want to execute the "su" comand from an app..I have rooted the emulator and installed Superuser.apk(superuser 2.3.6.1)
Process pr= Runtime.getRuntime().exec("su");
process.waitFor();
Log.d("Ex.Value",Integer.toString(process.exitValue()));
But I'm getting 255 as the exit value which seems to be some error in executing "su".
I have included RootTools library (http://code.google.com/p/roottools/). When checked with the methods RootTools.isRootAvailable(), RootTools.isAccessGiven()...Its found that the emulator has SU, but my application is not granted Root permissions. Will it be the real issue?? ..If so Can you plz tell how to grant my app the Root permission?
When you execute 'su', you should have root access within that process. The app should then automatically ask for root permission to the user via a dialog box. This dialog box is provided by android but is only present in devices that have been rooted.
This blog post has an example that might help you:
http://www.stealthcopter.com/blog/2010/01/android-requesting-root-access-in-your-app/
The comments at the end are very informative as well.

Categories

Resources