Difficulty granting permission with adb / terminal - Android Q&A, Help & Troubleshooting

Per this issue, and specifically this comment, I'm trying to grant the BATTERY_STATS permission to GSam Battery Monitor. I've tried the adb command "pm grant com.gsamlabs.bbm android.permission.BATTERY_STATS" but can't get it to work. I've also tried "pm grant com.gsamlabs.bbm android.Manifest.permission.BATTERY_STATS" but the results are the same. Doing it through ConnectBot gives me the following error:
Operation not allowed: java.lang.SecurityException: grantRuntimePermission: Neither user 10338 nor current process has android.permission.GRANT_RUNTIME_PERMISSIONS.
Doing it through adb gives me this:
Bad argument: java.lang.IllegalArgumentException: Unknown package: com.gsamlabs.bbm
This is on a stock Moto Z Play, 7.1.1
kernel:
3.18.31-perf-g757c8d9
[email protected] #1
Build number NPN26.118-22

Are you running the pro version? Then it needs to be com.gsamlabs.bbm.pro
The error is because it can't find a package named com.gsamlabs.bbm, so I would investigate why that's occurring. Either there's a typo (I don't see one) or that's not the correct package name.
ConnectBot won't work because ConnectBot doesn't have superuser permissions. Unless your device is rooted it'll have to be done through adb or using a PC-side program which effectively does the same thing.

Thanks! I think that was it, as adding .pro to the end didn't give an error. But it didn't actually say it was successful, either. It just spit out all the adb usage info like if you just type "adb" with no parameters. Any idea how I know if it worked?

vertigo_2_20 said:
Thanks! I think that was it, as adding .pro to the end didn't give an error. But it didn't actually say it was successful, either. It just spit out all the adb usage info like if you just type "adb" with no parameters. Any idea how I know if it worked?
Click to expand...
Click to collapse
Do the advanced stats in BBM work now? Also, are you on the paid version of BBM? That's the pro version, iirc.
You are typing "adb -d shell pm grant com.gsamlabs.bbm.pro android.permission.BATTERY_STATS", right?

Got busy with other stuff and just now got back to this, but I got it working. The reason I got the output I did before was because I was typing an invalid command, since pm grant isn't one of the commands of adb.exe. I had to type adb shell THEN type the command, and then it worked (and I just noticed you said that, I must have overlooked that when I looked at it before since I was busy). Also, for anyone that might come across this trying to do this, GSam didn't automatically recognize that this was done. I had to go through the steps of having it show me how to do it and at the end of that it worked. One final note, I had to update to the latest SDK for it to work, the version I was using was too old. Thanks again for the help apraetor!

Yea, I had a feeling after re-reading your original post that you were missing the "adb -d shell" portion, glad it's working.
vertigo_2_20 said:
Got busy with other stuff and just now got back to this, but I got it working. The reason I got the output I did before was because I was typing an invalid command, since pm grant isn't one of the commands of adb.exe. I had to type adb shell THEN type the command, and then it worked (and I just noticed you said that, I must have overlooked that when I looked at it before since I was busy). Also, for anyone that might come across this trying to do this, GSam didn't automatically recognize that this was done. I had to go through the steps of having it show me how to do it and at the end of that it worked. One final note, I had to update to the latest SDK for it to work, the version I was using was too old. Thanks again for the help apraetor!
Click to expand...
Click to collapse

Related

Sysctl access

Hey guys
One of the things im working on atm, having a bit of trouble trying to get a sysctl.conf I am working on to be loaded at startup
I've managed to generate the file, edit what i want, gotten it into /etc, but therein lies the problem
when i try to run systl -p, it keeps telling me the following:
sysctl: error setting key <insert sysctl key here>: Permission Denied
How can i overcome this? As soon as ive finished the work on this file, I'll be happy to share it with everyone
so no ideas?
Do you have superuser permissions (su, command prompt #) ?
When trying with this:
-p
Load in sysctl settings from the file specified or /etc/sysctl.conf if none given.
Perhaps this helps ?
-e
Use this option to ignore errors about unknown keys.
I try running su from command prompt
after using adb shell, all i get after running su is this
Brief 5sec delay, and permission denied. Thats what i dont get, I've Rooted the phone using the guide on the forums and everything went to the letter
*Shrugs* I dunno, tried the -p, thats what gives me the error i get.
Nutterpc said:
I try running su from command prompt
after using adb shell, all i get after running su is this
Brief 5sec delay, and permission denied. Thats what i dont get, I've Rooted the phone using the guide on the forums and everything went to the letter
*Shrugs* I dunno, tried the -p, thats what gives me the error i get.
Click to expand...
Click to collapse
Look at your phone to allow Superuser permission after entering su in the terminal or command
Sent from my X10i using XDA App
had a bit more of a fish round the net to see if anyone else ham similar issues
seems i was able to find the eventual root cause of it, was /system/bin/sh was set to secure mode, so i downloaded root explorer and changed the permissions
now the only thing is, how do i actually get the sysctl.conf im working on to be loaded at start, when i turn the phone on?
You might find something useful in this thread:
http://forum.xda-developers.com/showthread.php?t=523707

[Q] Imoseyon leanKernel V2.4

So I feel like a total Noob, which i am, but I cannot get this new Kernel to work for me. I do the following steps:
1) Open Terminal Emulator (install it from market if you don't have it).
2) Type "su" (without quotes) and hit enter.
3) Type "speedtweak.sh" (without quotes) and hit enter.
When I type in and I get speadtweak.sh and i get Speedtweak.sh not found... what in the world am I doing wrong?
when terminal boots up I get:
$ export PATH=/data/local/bin:$PATH
$
when your terminal boots up-
$ export PATH=/data/local/bin:$PATH
$
-- You need remember ALWAYS lower sensitive case characters
type su hit return
it will come up #
then
type speedtweak.sh hit return
There you will access the dialog output from speedtweak.sh.
Good luck
You have to install BusyBox. If you haven't it'll show up as "not found".
Having same issue. Busybox is installed even tried using adb shell. Any advice?
Did you install the kernel through Rom Manager or through Recovery? If it was through Rom Manager it could have been a bad flash.
Also, you can try this
I found this thread through google, searching for "speedtweak.sh not found." I dislike necroposting but I tried various suggestions found on multiple websites and none of them worked for me. I kept getting the same error code. Hopefully this will help someone else with the same issue. I don't know much about Linux/Unix so I am always extremely methodical about typing in commands precisely as they're posted, double-checking each step so I'm certain I did everything correctly.
I finally solved the issue for me by entering in the following in Terminal Emulator.
su
/sbin/speedtweak.sh
Typing in the full path for the speedtweak script worked for me. Perhaps someone with more experience can explain why that was necessary. Were we working in DOS, I'd know to add C:/sbin/ to the autoexec.bat path line... :silly:
Terminal emulator from the market had something changed in the last update so for some reason now you have to manually enter it or change the path in the settings.
Sent from my ADR6400L using Tapatalk 2

ADB Not Detecting Root

Hello,
When I run adb shell, it reports back with a "$,"even though I do have root. I'm running JoeyKrim Stock With Root ROM. Odexed...
I do have superuser installed with the latest binary, and latest official busybox. Terminal emulator even detects that I have root.
Basically everything works as it should, except adb. Anybody know what's going on?
Rydah805 said:
Hello,
When I run adb shell, it reports back with a "$,"even though I do have root. I'm running JoeyKrim Stock With Root ROM. Odexed...
I do have superuser installed with the latest binary, and latest official busybox. Terminal emulator even detects that I have root.
Basically everything works as it should, except adb. Anybody know what's going on?
Click to expand...
Click to collapse
When you type adb shell, does it immediately report back with a $, or does it pause for a few and then report back with a $? If it pauses for a few seconds, look down at your phone during that time. You may be being prompted with the super user request prompt, where you need to hit allow. I'm not sure why you need to do this sometimes, but I've had it happen before. If you don't look at the phone and hit 'allow', then it times out and doesn't give you root access. So type 'adb shell', check out your phone and see if your prompted, if so allow it, and you should be good. If that is not the case, then I'm unsure what could be causing it.
k2buckley said:
When you type adb shell, does it immediately report back with a $, or does it pause for a few and then report back with a $? If it pauses for a few seconds, look down at your phone during that time. You may be being prompted with the super user request prompt, where you need to hit allow. I'm not sure why you need to do this sometimes, but I've had it happen before. If you don't look at the phone and hit 'allow', then it times out and doesn't give you root access. So type 'adb shell', check out your phone and see if your prompted, if so allow it, and you should be good. If that is not the case, then I'm unsure what could be causing it.
Click to expand...
Click to collapse
Thanks, I'll test that out. I have a pin set on superuser. Maybe that's the issue.
Just checked, and it does it right away, and does not prompt... Sigh...
Rydah805 said:
Just checked, and it does it right away, and does not prompt... Sigh...
Click to expand...
Click to collapse
Very strange. I'm not sure. Has it happened on all roms, or just the one you're currently on?
Sent from my PG86100 using Tapatalk
Rydah805 said:
Just checked, and it does it right away, and does not prompt... Sigh...
Click to expand...
Click to collapse
The first time you type su from adb shell, Superuser will display a prompt on the screen to accept or deny the request. If you don't accept the request, in adb shell it will display, "Permission denied".
On the Superuser prompt, if you select deny, when typing su in adb shell the result will always be "Permission denied" until going into the Superuser app and changing "Unknown" to Allow. Not sure why the Superuser app labels adb shell as "Unknown".
Another option, inside the Superuser app, on the Settings tab, at the very bottom there is an option, update su binary. Sometimes using this update feature will resolve permission/installation issues with the su binary.
If you wanted to verify the installation of both Superuser and root as having been done properly, my free app Root Check from the market works well. Advanced Mode should provide all the details we'd need to troubleshoot further.
Hope that helps and appreciate your support!
joeykrim said:
The first time you type su from adb shell, Superuser will display a prompt on the screen to accept or deny the request. If you don't accept the request, in adb shell it will display, "Permission denied".
On the Superuser prompt, if you select deny, when typing su in adb shell the result will always be "Permission denied" until going into the Superuser app and changing "Unknown" to Allow. Not sure why the Superuser app labels adb shell as "Unknown".
Another option, inside the Superuser app, on the Settings tab, at the very bottom there is an option, update su binary. Sometimes using this update feature will resolve permission/installation issues with the su binary.
If you wanted to verify the installation of both Superuser and root as having been done properly, my free app Root Check from the market works well. Advanced Mode should provide all the details we'd need to troubleshoot further.
Hope that helps and appreciate your support!
Click to expand...
Click to collapse
Yep that does work on his rom the "type su" thing and thanks for your root check app Joey it's been super useful in trying to figure out stuff lately on the photon.... really appreciate all your contributions
joeykrim said:
The first time you type su from adb shell, Superuser will display a prompt on the screen to accept or deny the request. If you don't accept the request, in adb shell it will display, "Permission denied".
On the Superuser prompt, if you select deny, when typing su in adb shell the result will always be "Permission denied" until going into the Superuser app and changing "Unknown" to Allow. Not sure why the Superuser app labels adb shell as "Unknown".
Hope that helps and appreciate your support!
Click to expand...
Click to collapse
Got it! Thanks! Any idea why I had to do that with your rom though? On others, I didn't need to type Su and grant it. (Doesn't bother me though.)
Rydah805 said:
Got it! Thanks! Any idea why I had to do that with your rom though? On others, I didn't need to type Su and grant it. (Doesn't bother me though.)
Click to expand...
Click to collapse
Short answer: Since Superuser.apk is another developer's software, I didn't include it in my ROM as I didn't have his permission. I provide the superuser apk market link in my ROM OP for users. Instead of packaging Superuser apk, I used the su binary provided in AOSP as its source code is public and publically available for android usage.
Long answer: There is a free version of Superuser available thru the market and figured that would be the best way to load the Superuser apk. From personal experience as an android developer, when an app is provided with a ROM, it doesn't appear in the developer's market statistics and essentially is "off the radar". Which makes it more difficult to track which devices have loaded the software, which versions of android, etc and makes it more difficult to prioritize software upgrades to the application.
Hope I was able to explain and it helps!
joeykrim said:
Short answer: Since Superuser.apk is another developer's software, I didn't include it in my ROM as I didn't have his permission. I provide the superuser apk market link in my ROM OP for users. Instead of packaging Superuser apk, I used the su binary provided in AOSP as its source code is public and publically available for android usage.
Long answer: There is a free version of Superuser available thru the market and figured that would be the best way to load the Superuser apk. From personal experience as an android developer, when an app is provided with a ROM, it doesn't appear in the developer's market statistics and essentially is "off the radar". Which makes it more difficult to track which devices have loaded the software, which versions of android, etc and makes it more difficult to prioritize software upgrades to the application.
Hope I was able to explain and it helps!
Click to expand...
Click to collapse
Gotcha, I'm not complaining, just wondering why. I've always loved your roms over any others. Any way I can easily set it to use the superuser app binary over aosp binary?
ADB starting with root depends on the ro.secure property; if you type "getprop ro.secure" it should show either 0 meaning ADB keeps root or 1 meaning you have to use su for root. Just about all custom kernels/ROMs use unsecured boot.imgs but you can always change it yourself by modifying the default.prop file packed in the boot.img.
This is also what people are referring to when they say the kernel/boot.img/rom is secured or unsecured.
Rydah805 said:
Got it! Thanks! Any idea why I had to do that with your rom though? On others, I didn't need to type Su and grant it. (Doesn't bother me though.)
Click to expand...
Click to collapse
xHausx said:
ADB starting with root depends on the ro.secure property; if you type "getprop ro.secure" it should show either 0 meaning ADB keeps root or 1 meaning you have to use su for root. Just about all custom kernels/ROMs use unsecured boot.imgs but you can always change it yourself by modifying the default.prop file packed in the boot.img.
This is also what people are referring to when they say the kernel/boot.img/rom is secured or unsecured.
Click to expand...
Click to collapse
Rydah805 said:
Gotcha, I'm not complaining, just wondering why. I've always loved your roms over any others. Any way I can easily set it to use the superuser app binary over aosp binary?
Click to expand...
Click to collapse
Ah! Your question in the first quote above could be intrepreted two different ways. I provided one answer for one intrepretation and Haus provided the other answer for a different intrepretation!
I'll try and bring both together. There are two primary ways to access the shell interface on an android device.
1) Via adb shell. When typing adb shell and it opens the connection to the device, by android standard, it drops you to a shell with non root access reflected with the $ prompt. As Haus articulated above, this can be modified in the /default.prop file inside the ramdisk of the boot.img file. There are two options, have adb shell drop to root access or have adb shell drop to non root access. Many custom kernels modify this option so the user drops to root access.
In my kernel I'm using a non-modified stock kernel so it drops to non root access. I prefer to have to type su, once in the shell, to elevate to root access. Mainly because most functions I perform in adb shell I don't want root access for.
2) Via terminal emulator/connectbot. When accessing the shell directly on the device thru one of the common android applications, these generally open up a standard "sh" or non root shell. Then by typing "su" the user can elevate to root access (if the device has the su binary, etc.).
There are two main options for how to handle the "su" command inside a shell on the android device.
1) Superuser.apk - this application provides its own su binary, which hooks into the android application. Whenever su is called, the Superuser application is therefore called and allows the user to accept/deny root access requests.
2) su binary - from aosp or busybox. this is a version of the su binary more common to android developers in aosp, or the busybox version is more common to a generic linux version. the aosp version of su will grant any user/application root access. the busybox version will grant any user/application root access but does rely on an /etc/passwd and /etc/group file for permissions.
To answer your previous question, why you haven't had to type su on other custom ROMs, as Haus explained, they probably modified adb shell access in the /defult.prop file to automatically elevate adb shell to root priviledges.
To answer your last question regarding Superuser.apk and aosp su. Once you install the Superuser.apk file and it properly installs its own version of the su binary, it has now overwrite the previous aosp su binary. Superuser will now control all root access requests. Once you grant an application, adb shell, titantium backup, root explorer, or whatever application root access with Superuser, it will not prompt again and will handle every future request with the default action (grant/deny) provided.
Hope the extra details help!
Thanks, wasn't trying to be a pest. Just curious. The info in this thread is a nice thing to know.

[Q] Commands that work in terminal, but not when put in script

Hi everyone,
I am having a general conundrum that is really setting me back. My device(s) are my HTC One (rooted) and and CS968 (rooted) mini-pc. I've tried the following on both devices and always get the same thing. I don't think its device specific:
I am trying to install an APK. When I go into Terminal Emulator and get su permissions, I type in the following command "pm install /sdcard/directory/of/apk/target.apk" and it works, success, the apk is installed.
If I write a .sh script with the EXACT same syntax, I always get the infamous "INSTALL_FAILED_INVALID_URI" error. I cannot for the life of me figure out why.
Yes, I have searched every corner of this forum and google for solutions to this problem. They all end with the conclusion that you need to re-flash your rom (???) which seems very improbable to me. What makes my case different is that, like I said, the command works just fine when manually entered into Terminal Emulator, but when executed from a script, is when I get this bizzare error. I am at my wits end.
If anyone could shine some light on this for me I would greatly appreciate it.
Thank you

Question Unable to set device owner [SOLVED]

I'm trying to set IceBox as device owner so I can free/unfreeze apps without root. This has worked on some other normal android phones for me in the past, but on the n20 5G i get
Code:
java.lang.IllegalStateException: Unexpected @ProvisioningPreCondition 99
at android.os.Parcel.createExceptionOrNull(Parcel.java:2397)
at android.os.Parcel.createException(Parcel.java:2373)
at android.os.Parcel.readException(Parcel.java:2356)
at android.os.Parcel.readException(Parcel.java:2298)
at android.app.admin.IDevicePolicyManager$Stub$Proxy.setDeviceOwner(IDevicePolicyManager.java:8665)
at com.android.commands.dpm.Dpm.runSetDeviceOwner(Dpm.java:203)
at com.android.commands.dpm.Dpm.onRun(Dpm.java:115)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:60)
at com.android.commands.dpm.Dpm.main(Dpm.java:41)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:419)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.devicepolicy.DevicePolicyManagerService.enforceCanSetDeviceOwnerLocked(DevicePolicyManagerService.java:9682)
at com.android.server.devicepolicy.DevicePolicyManagerService.setDeviceOwner(DevicePolicyManagerService.java:8700)
at android.app.admin.IDevicePolicyManager$Stub.onTransact(IDevicePolicyManager.java:3582)
at android.os.Binder.execTransactInternal(Binder.java:1196)
at android.os.Binder.execTransact(Binder.java:1143)
There are no accounts or users on the device.
I've managed to solve this on my own. For the Nord 20 5G, you need to use
Code:
adb shell dpm set-profile-owner
instead of
Code:
adb shell set-device-owner
like on other android devices and like how it is written in their installation docs.
So the command I used was
Code:
adb shell dpm set-profile-owner --user current --name IceBox com.catchingnow.icebox/.receiver.DPMReceiver
I hope this will help others
awesome, i was actually wondering this myself as i had difficulties doing the exact same a few months ago, not sure if it was icebox or not as i cant remember now but didnt end up using it anyways and didnt have the time to really research this. thanks for the tip @Crystawth
PsYk0n4uT said:
awesome, i was actually wondering this myself as i had difficulties doing the exact same a few months ago, not sure if it was icebox or not as i cant remember now but didnt end up using it anyways and didnt have the time to really research this. thanks for the tip @Crystawth
Click to expand...
Click to collapse
Yea I really didn't want to go through the trouble of rooting it since the only functionality I really wanted on it was to freeze apps.
It's a new phone for my wife, and she just doesn't need root. She's an App-oholic though, so freezing is kind of important! She also wants to use Google pay, and I didn't want to have to get it working with root.
I discovered how to get it working by reading through the ADB docs and through the Island install docs and gave it a try throwing together the command, and it worked.
I just hope my adventure can help others who want to do this, but don't need/want root.
Crystawth said:
I've managed to solve this on my own. For the Nord 20 5G, you need to use
Code:
adb shell dpm set-profile-owner
instead of
Code:
adb shell set-device-owner
like on other android devices and like how it is written in their installation docs.
So the command I used was
Code:
adb shell dpm set-profile-owner --user current --name IceBox com.catchingnow.icebox/.receiver.DPMReceiver
I hope this will help others
Click to expand...
Click to collapse
it work, thank you
I got this error
"calling identity is not authorized"
while tring this command
[ adb shell dpm set-device-owner com.catchingnow.icebox/.receiver.DPMReceiver]
Ù’
Andro nagy8654 said:
I got this error
"calling identity is not authorized"
while tring this command
[ adb shell dpm set-device-owner com.catchingnow.icebox/.receiver.DPMReceiver]
Click to expand...
Click to collapse
As i stated in my post above. you must use set-profile-owner NOT set-device-owner. You must also do this with no accounts on the device.

Categories

Resources