Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Requires permission android.permission.WRITE_SECURE_SETTINGS #5

Closed
CoderBuck opened this issue Apr 6, 2017 · 40 comments
Closed

Comments

@CoderBuck
Copy link

CoderBuck commented Apr 6, 2017

XiaoMi4 Android 6.0 MIUI8

$ ./gnirehtet rt
Starting gnirehtet...
'adb' reverse tcp:31416 tcp:31416
'adb' shell am startservice -a com.genymobile.gnirehtet.START
Starting service: Intent { act=com.genymobile.gnirehtet.START }
Error: Requires permission android.permission.WRITE_SECURE_SETTINGS
'java' -jar relay.jar
2017-04-06 17:31:05.886 I Main: Starting server...
Stopping gnirehtet...
'adb' shell am startservice -a com.genymobile.gnirehtet.STOP
Starting service: Intent { act=com.genymobile.gnirehtet.STOP }
Error: Requires permission android.permission.WRITE_SECURE_SETTINGS

[Edit by @rom1v] Solution: #302 (comment)

@rom1v
Copy link
Collaborator

rom1v commented Apr 6, 2017

Arf, it seems that your shell user does not have this permission… It should have it.

This requirement (a bit hacky) had been introduced by commit e7b8407 (the commit message provides some details).

Does anyone have an idea to get the same "restriction" without the WRITE_SECURE_SETTINGS permission?

@yashrajtalan
Copy link

yashrajtalan commented Apr 10, 2017

Have same issue with Xiaomi Redmi 3S Prime MIUI8 Android 6.0.1
Permissions granted to the app according to the phone are 'full network access' and 'view network connections'.

When I try
adb shell pm grant com.genymobile.gnirehtet android.permission.WRITE_SECURE_SETTINGS
I get
Operation not allowed: java.lang.SecurityException: grantRuntimePermission: Neither user 2000 nor current process has android.permission.GRANT_RUNTIME_PERMISSIONS.

@rom1v
Copy link
Collaborator

rom1v commented Apr 12, 2017

@CoderBuck @yashrajtalan Could you give the permissions of your Android shell, please?

First, locate Shell.apk:

$ adb shell pm list package -f com.android.shell
package:/system/priv-app/Shell/Shell.apk=com.android.shell

Then pull it:

adb pull /system/priv-app/Shell/Shell.apk

Finally, print its permissions:

aapt d permissions Shell.apk

(aapt is available in $ANDROID_SDK/build-tools/25.0.2/aapt, or there is an aapt package in Debian)

Maybe we could find a better permission which works also for your devices ;-)

@CoderBuck
Copy link
Author

CoderBuck commented Apr 12, 2017

$ adb shell pm list package -f com.android.shell
package:/system/priv-app/Shell/Shell.apk=com.android.shell

$ adb pull /system/priv-app/Shell/Shell.apk
adb: error: remote object 'D:/Develop/Git/Git/system/priv-app/Shell/Shell.apk' does not exist

@CoderBuck
Copy link
Author

I am not familiar with this ;-0

@rom1v
Copy link
Collaborator

rom1v commented Apr 12, 2017

@CoderBuck It seems you are using git bash on Windows: http://stackoverflow.com/questions/16344985/how-do-i-pass-an-absolute-path-to-the-adb-command-via-git-bash-for-windows

Try with cmd.exe instead, since git bash mangles pathes at some point.

EDIT: or:

adb pull //system/priv-app/Shell/Shell.apk

@CoderBuck
Copy link
Author

thanks ;-)

package: com.android.shell
uses-permission: name='android.permission.SEND_SMS'
uses-permission: name='android.permission.CALL_PHONE'
uses-permission: name='android.permission.READ_PHONE_STATE'
uses-permission: name='android.permission.READ_CONTACTS'
uses-permission: name='android.permission.WRITE_CONTACTS'
uses-permission: name='android.permission.READ_CALENDAR'
uses-permission: name='android.permission.WRITE_CALENDAR'
uses-permission: name='android.permission.READ_USER_DICTIONARY'
uses-permission: name='android.permission.WRITE_USER_DICTIONARY'
uses-permission: name='android.permission.ACCESS_FINE_LOCATION'
uses-permission: name='android.permission.ACCESS_COARSE_LOCATION'
uses-permission: name='android.permission.ACCESS_LOCATION_EXTRA_COMMANDS'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.ACCESS_WIFI_STATE'
uses-permission: name='android.permission.BLUETOOTH'
uses-permission: name='android.permission.EXPAND_STATUS_BAR'
uses-permission: name='android.permission.DISABLE_KEYGUARD'
uses-permission: name='android.permission.REAL_GET_TASKS'
uses-permission: name='android.permission.CHANGE_CONFIGURATION'
uses-permission: name='android.permission.REORDER_TASKS'
uses-permission: name='android.permission.SET_ANIMATION_SCALE'
uses-permission: name='android.permission.SET_PREFERRED_APPLICATIONS'
uses-permission: name='android.permission.WRITE_SETTINGS'
uses-permission: name='android.permission.WRITE_SECURE_SETTINGS'
uses-permission: name='android.permission.BROADCAST_STICKY'
uses-permission: name='android.permission.SET_DEBUG_APP'
uses-permission: name='android.permission.SET_PROCESS_LIMIT'
uses-permission: name='android.permission.SET_ALWAYS_FINISH'
uses-permission: name='android.permission.DUMP'
uses-permission: name='android.permission.SIGNAL_PERSISTENT_PROCESSES'
uses-permission: name='android.permission.KILL_BACKGROUND_PROCESSES'
uses-permission: name='android.permission.FORCE_BACK'
uses-permission: name='android.permission.BATTERY_STATS'
uses-permission: name='android.permission.INTERNAL_SYSTEM_WINDOW'
uses-permission: name='android.permission.INJECT_EVENTS'
uses-permission: name='android.permission.RETRIEVE_WINDOW_CONTENT'
uses-permission: name='android.permission.SET_ACTIVITY_WATCHER'
uses-permission: name='android.permission.READ_INPUT_STATE'
uses-permission: name='android.permission.SET_ORIENTATION'
uses-permission: name='android.permission.INSTALL_PACKAGES'
uses-permission: name='android.permission.MOVE_PACKAGE'
uses-permission: name='android.permission.CLEAR_APP_USER_DATA'
uses-permission: name='android.permission.DELETE_CACHE_FILES'
uses-permission: name='android.permission.DELETE_PACKAGES'
uses-permission: name='android.permission.ACCESS_SURFACE_FLINGER'
uses-permission: name='android.permission.READ_FRAME_BUFFER'
uses-permission: name='android.permission.DEVICE_POWER'
uses-permission: name='android.permission.INSTALL_LOCATION_PROVIDER'
uses-permission: name='android.permission.BACKUP'
uses-permission: name='android.permission.FORCE_STOP_PACKAGES'
uses-permission: name='android.permission.STOP_APP_SWITCHES'
uses-permission: name='android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY'
uses-permission: name='android.permission.GRANT_RUNTIME_PERMISSIONS'
uses-permission: name='android.permission.REVOKE_RUNTIME_PERMISSIONS'
uses-permission: name='android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS'
uses-permission: name='android.permission.SET_KEYBOARD_LAYOUT'
uses-permission: name='android.permission.GET_DETAILED_TASKS'
uses-permission: name='android.permission.SET_SCREEN_COMPATIBILITY'
uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE'
uses-permission: name='android.permission.WRITE_MEDIA_STORAGE'
uses-permission: name='android.permission.INTERACT_ACROSS_USERS'
uses-permission: name='android.permission.INTERACT_ACROSS_USERS_FULL'
uses-permission: name='android.permission.CREATE_USERS'
uses-permission: name='android.permission.MANAGE_DEVICE_ADMINS'
uses-permission: name='android.permission.BLUETOOTH_STACK'
uses-permission: name='android.permission.GET_ACCOUNTS'
uses-permission: name='android.permission.RETRIEVE_WINDOW_TOKEN'
uses-permission: name='android.permission.FRAME_STATS'
uses-permission: name='android.permission.BIND_APPWIDGET'
uses-permission: name='android.permission.UPDATE_APP_OPS_STATS'
uses-permission: name='android.permission.MODIFY_APPWIDGET_BIND_PERMISSIONS'
uses-permission: name='android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS'
uses-permission: name='android.permission.CHANGE_APP_IDLE_STATE'
uses-permission: name='android.permission.MOUNT_UNMOUNT_FILESYSTEMS'
uses-permission: name='android.permission.MOUNT_FORMAT_FILESYSTEMS'
uses-permission: name='android.permission.MODIFY_PHONE_STATE'
uses-permission: name='android.permission.REGISTER_CALL_PROVIDER'
uses-permission: name='android.permission.REGISTER_CONNECTION_MANAGER'
uses-permission: name='android.permission.REGISTER_SIM_SUBSCRIPTION'
uses-permission: name='android.permission.GET_APP_OPS_STATS'

@rom1v
Copy link
Collaborator

rom1v commented Apr 12, 2017

OK so it declares using android.permission.WRITE_SECURE_SETTINGS.

Could you give the result of the following commands, please:

adb shell id
adb shell cat /proc/'$$'/status

EDIT: in fact, these commands will not help.

@CoderBuck
Copy link
Author

Ok.

adb shell id

* daemon not running. starting it now on port 5037 *
* daemon started successfully *
uid=2000(shell) gid=2000(shell) groups=2000(shell),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats) context=u:r:shell:s0

adb shell cat /proc/'$$'/status

/system/bin/sh: cat: /proc/$$/status: No such file or directory

@rom1v
Copy link
Collaborator

rom1v commented Apr 12, 2017

To summarize:

  1. android.permission.WRITE_SECURE_SETTINGS has protection level "signature"
  2. sending the intent from shell leads to error Requires permission android.permission.WRITE_SECURE_SETTINGS
  3. shell declares using the permission android.permission.WRITE_SECURE_SETTINGS

One possibility is that Shell.apk is not signed with the same signature as the ROM. Which is very strange…

@rom1v
Copy link
Collaborator

rom1v commented Apr 12, 2017

Could you replace android.permission.WRITE_SECURE_SETTINGS by android.permission.WRITE_SETTINGS (a permission with normal protection level) here, build, and try again, please?

If it works, it suggests that the problem is related to Shell.apk signature…

@CoderBuck
Copy link
Author

error

Error: Requires permission android.permission.WRITE_SETTINGS

@rom1v
Copy link
Collaborator

rom1v commented Apr 13, 2017

So you have a shell with no permissions… Can you find a permission listed from Shell.apk that does work?

@rom1v
Copy link
Collaborator

rom1v commented Apr 14, 2017

What about:

adb shell am startservice -a com.genymobile.gnirehtet.START --user 0
adb shell am startservice -a com.genymobile.gnirehtet.START --user -2
adb shell am startservice -a com.genymobile.gnirehtet.START --user -3

?

@rom1v
Copy link
Collaborator

rom1v commented Apr 14, 2017

The result of this command may also be interesting:

adb shell dumpsys package com.android.shell

@rom1v
Copy link
Collaborator

rom1v commented Apr 18, 2017

@CoderBuck @yashrajtalan Could you please give the result of:

adb shell dumpsys package com.android.shell

And also try these commands.

Thank you :)

@yashrajtalan
Copy link

The issue seems to be resolved by heading over to Developer Options on MIUI, and enabling the following:
USB debugging -Debug mode when USB is connected
Install via USB -Allow installing apps via USB
USB debugging (Security Settings)- Allow granting permissions and simulating input via USB debugging

The first was already enabled, and I installed the apk file manually so I didn't need the second option.

I'm guessing the issue can be pinned down to the last option, which allows granting the necessary permissions. @CoderBuck please confirm.

Thank you @rom1v for this amazing app. This is a worthy free replacement for ReverseTethering NoRoot.

@CoderBuck
Copy link
Author

@rom1v @yashrajtalan Sorry to replay late! @yashrajtalan you are right!

thanks a lot!

@rom1v
Copy link
Collaborator

rom1v commented May 1, 2017

Great, thank you 👍 So I close the issue.

@Biswa96
Copy link

Biswa96 commented Oct 28, 2017

@yashrajtalan Your procedure requires MI account in Xiaomi Redmi phones. You just remove android.permission.WRITE_SECURE_SETTINGS in manifest file (mentioned in #40).

@SonalDalal
Copy link

@yashrajtalan,
Thanks a lot, your solution worked for me.

@rom1v
Copy link
Collaborator

rom1v commented Nov 19, 2021

See #302 (comment)

@predi
Copy link

predi commented Oct 17, 2022

On my OnePlus Nord 2T 5G (Android 12, OxygenOS 12.1), I also had to tick Developer options > Disable permission monitoring along with USB Debugging to get past a similar exception.

P.S.: apologies for reviving this old issue.

@flocsy
Copy link

flocsy commented Feb 26, 2023

I had the same problem on OnePlus 8t, and the solution was to go to the Developer Settings on the phone and enable:
Developer Options > Apps > Disable permission monitoring

@rezyyyy
Copy link

rezyyyy commented Mar 10, 2023

The issue seems to be resolved by heading over to Developer Options on MIUI, and enabling the following: USB debugging -Debug mode when USB is connected Install via USB -Allow installing apps via USB USB debugging (Security Settings)- Allow granting permissions and simulating input via USB debugging

The first was already enabled, and I installed the apk file manually so I didn't need the second option.

I'm guessing the issue can be pinned down to the last option, which allows granting the necessary permissions. @CoderBuck please confirm.

Thank you @rom1v for this amazing app. This is a worthy free replacement for ReverseTethering NoRoot.

Screenshot_2023-03-09-20-44-36-545_com android settings

turning on the install via usb option requires an internet connection and currently am unable to do that. Is there a way to do this without having to connect to the internet. Note: the option is turned on in the screenshot but it automatically switches off after a couple of seconds..

@HoussemNasri
Copy link

I had the same problem on OnePlus 8t, and the solution was to go to the Developer Settings on the phone and enable:
Developer Options > Apps > Disable permission monitoring

The same solution worked for Oppo.

@maciejkrol18
Copy link

maciejkrol18 commented Oct 7, 2023

I had the same problem on OnePlus 8t, and the solution was to go to the Developer Settings on the phone and enable:
Developer Options > Apps > Disable permission monitoring

Also works on OnePlus Nord

@onyedikachi-david
Copy link

I had the same problem on OnePlus 8t, and the solution was to go to the Developer Settings on the phone and enable: Developer Options > Apps > Disable permission monitoring

This solution worked for me. Thanks.
Oppo CPH2269

@zanjie1999
Copy link

Open this on Color OS can fix
打开禁止权限监控可以解决问题
image

@lordofscripts
Copy link

This:

Developer Options > Apps > Disable permission monitoring

does not work on my device (RMX3241) a realme 8 (ColorOS)

@lordofscripts
Copy link

Open this on Color OS can fix 打开禁止权限监控可以解决问题 image

That's in Chinese, can't understand any of it. could you at least put the translated text?

@zanjie1999
Copy link

zanjie1999 commented Sep 29, 2024

禁止权限监控

may be "Disable permission monitoring"? translated with google. you can find it next of "ShortcutManager"

@Julioevm
Copy link

The issue seems to be resolved by heading over to Developer Options on MIUI, and enabling the following: USB debugging -Debug mode when USB is connected Install via USB -Allow installing apps via USB USB debugging (Security Settings)- Allow granting permissions and simulating input via USB debugging

The first was already enabled, and I installed the apk file manually so I didn't need the second option.

I'm guessing the issue can be pinned down to the last option, which allows granting the necessary permissions. @CoderBuck please confirm.

Thank you @rom1v for this amazing app. This is a worthy free replacement for ReverseTethering NoRoot.

Any change to add this to the readme? It seems like a common issue with Xiaomi devices and would save a lot of people digging this information.

Thanks for the solution by the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests