2

I'm trying to update my APN settings using:

adb shell "su -c 'content update --uri content://telephony/carriers --bind name:s:\""SDR"\" --bind apn:s:"SDR-internet"'"

The first time I run this command I receive a superuser request from the package: com.android.shell. I can grant this manually but I'm hoping to automate the process for practice and knowledge.

I've tried to use the following to list all permissions, but can't find superuser:

adb shell pm dump package com.android.shell 

I attempted the following:

adb shell pm grant com.android.shell android.permission.SUPERUSER
adb shell pm grant com.android.shell android.permission.REQUEST_SUPERUSER
adb shell pm grant com.android.shell android.permission.ACCESS_SUPERUSER

But receive an error:

    Exception occurred while executing:
java.lang.IllegalArgumentException: Unknown permission: android.permission.REQUEST_SUPERUSER
    at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermission(PermissionManagerService.java:1398)
    at com.android.server.pm.permission.PermissionManagerService.access$900(PermissionManagerService.java:89)
    at com.android.server.pm.permission.PermissionManagerService$PermissionManagerInternalImpl.grantRuntimePermission(PermissionManagerService.java:2093)
    at com.android.server.pm.PackageManagerService.grantRuntimePermission(PackageManagerService.java:5411)
    at com.android.server.pm.PackageManagerShellCommand.runGrantRevokePermission(PackageManagerShellCommand.java:1730)
    at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:217)
    at android.os.ShellCommand.exec(ShellCommand.java:103)
    at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21330)
    at android.os.Binder.shellCommand(Binder.java:634)
    at android.os.Binder.onTransact(Binder.java:532)
    at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:2821)
    at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:3856)
    at android.os.Binder.execTransact(Binder.java:731)

Edit:

I tried:

adb shell su cat /data/adb/magisk.db

Which gave:

    SQLite format 3@  

�                      .�
�       �-�d
N�tablehidelisthidelist
CREATE TABLE hidelist (process TEXT, PRIMARY KEY(process))/ Cindexsqlite_autoindex_hidelist_1hidelist
                             X�tablestringsstringCREATE TABLE strings (key TEXT, value TEXT, PRIMARY KEY(key))-Aindexsqlite_autoindex_strings_1stringsZ�tablesettingssettingsCREATE TABLE settings (key TEXT, value INT, PRIMARY tablelogslogsCREATE TABLE logs (from_uid INT, package_name TEXT, app_name TEXT, from_pid INT, to_uid INT, action INT, time INT, command TEXT)��tablepoliciespoliciesCREATE TABLE policies (uid INT, package_name TEXT, policy INT, until INT, logging INT, notification INT, PRIMARY KEY(uid))/Cindexsqlite_autoind��/ies_1pol�com.android.shell
���7�/    )�com.android.shellShell�l��uR/system/bin/sh7 /    )�com.an!�id.shmagiskhidel��?5/system/bin/sh
��!magiskhide
��6ucom.google.android.gms/.droidguard.DroidGuardService

That's pretty ugly, so I tried using sqlite3 but it provides no tables? I was expecting a list of something at the very least.

sqlite> .mode line
sqlite> .headers on
sqlite> .tables
sqlite> 

I'm using Magisk Manager v18.

  • What is the root manager app you are using? (SuperSU, Superuser, or some other one?) – Supersonic Sep 4 at 14:13
1

android.permission.ACCESS_SUPERUSER was defined by SuperSU but:

Due to changes in Android 5.0 Lollipop, this permission has been deprecated and is completely ignored from SuperSU v2.30 onwards

Also only app which declares a permission in its AndroidManifest.xml file can be granted that permission. Shell (com.android.shell) is an AOSP's dummy app to define UID for adbd, it must not have any such third party permission in its Manifest.

Magisk doesn't use this or any other such permission at all. So you have to grant the permission through user interface. Or try to modify database or configuration file directly where permission preferences are stored. In case of Magisk it's sqlite3 database (/data/adb/magisk.db):

~# sqlite3 /data/adb/magisk.db .tables
hidelist  logs      policies  settings  strings
~# sqlite3 /data/adb/magisk.db '.mode column' '.headers on' 'select * from policies'
uid         package_name  policy      until       logging     notification
----------  ------------  ----------  ----------  ----------  ------------
10146       com.termux    2           0           1           1    
~# sqlite3 /data/adb/magisk.db "INSERT INTO policies (uid,package_name,policy,until,logging,notification) VALUES(2000,'com.android.shell',2,0,1,1)"
~# sqlite3 /data/adb/magisk.db '.mode column' '.headers on' 'select * from policies'
uid         package_name  policy      until       logging     notification
----------  ------------  ----------  ----------  ----------  ------------
10146       com.termux    2           0           1           1           
2000        com.android.  2           0           1           1           
~# sqlite3 /data/adb/magisk.db 'DELETE FROM policies WHERE uid = 2000'
  • For help on SQLite: sqlite.org
  • Above commands are working at the moment but Magisk may change database location, table names, table structures etc. any time.
  • Values may possibly be cached in running processes. So your changes may get ignored or overwritten. In that case putting a modified database from recovery (with proper permissions) may work. I didn't try though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.