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

Can't set user name by shizuku in emulator sdk 33 #107

Open
HuyMaster opened this issue Jun 28, 2024 · 2 comments
Open

Can't set user name by shizuku in emulator sdk 33 #107

HuyMaster opened this issue Jun 28, 2024 · 2 comments

Comments

@HuyMaster
Copy link

I use reference here

  1. Code
package android.os;

import android.content.pm.UserInfo;

import androidx.annotation.NonNull;

import java.util.List;

import dev.rikka.tools.refine.RefineAs;

@RefineAs(UserManager.class)
public class UserManagerHidden {
    public boolean isUserRunning(int userId) {
        throw new UnsupportedOperationException("Stub");
    }

    public boolean isUserUnlocked(int userId) {
        throw new UnsupportedOperationException("Stub");
    }

    public UserInfo getUserInfo(int userId) {
        throw new UnsupportedOperationException("Stub");
    }

    public boolean removeUser(int userId) {
        throw new UnsupportedOperationException("Stub");
    }

    public void setUserName(int userId, String name) {
        throw new UnsupportedOperationException("Stub");
    }

    public void setUserRestriction(String key, boolean value, UserHandle userHandle) {
        throw new UnsupportedOperationException("Stub");
    }

    public Bundle getUserRestrictions(UserHandle userHandle) {
        throw new UnsupportedOperationException("Stub");
    }

    public @NonNull List<UserInfo> getUsers() {
        throw new UnsupportedOperationException("Stub");
    }

    public @NonNull List<UserInfo> getAliveUsers() {
        throw new UnsupportedOperationException("Stub");
    }
}
  1. Log
java.lang.SecurityException: You need MANAGE_USERS permission to: rename users
                                                                                                         	at android.os.Parcel.createExceptionOrNull(Parcel.java:3011)
                                                                                                         	at android.os.Parcel.createException(Parcel.java:2995)
                                                                                                         	at android.os.Parcel.readException(Parcel.java:2978)
                                                                                                         	at android.os.Parcel.readException(Parcel.java:2920)
                                                                                                         	at android.os.IUserManager$Stub$Proxy.setUserName(IUserManager.java:1956)
                                                                                                         	at android.os.UserManager.setUserName(UserManager.java:4968)
                                                                                                         	at com.github.huymaster.controllerplus.data.UserDatabase.renameUser(User.kt:124)
                                                                                                         	at com.github.huymaster.controllerplus.activity.LoginActivity$MainContent$color$2$1.invoke-8_81llA(LoginActivity.kt:66)
                                                                                                         	at com.github.huymaster.controllerplus.activity.LoginActivity$MainContent$color$2$1.invoke(LoginActivity.kt:54)
                                                                                                         	at androidx.compose.animation.core.AnimateAsStateKt$animateValueAsState$3$1$1.invokeSuspend(AnimateAsState.kt:429)
                                                                                                         	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                         	at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:28)
                                                                                                         	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100)
                                                                                                         	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
                                                                                                         	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102)
                                                                                                         	at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
                                                                                                         	at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
                                                                                                         	at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
                                                                                                         	at android.os.Handler.handleCallback(Handler.java:942)
                                                                                                         	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                         	at android.os.Looper.loopOnce(Looper.java:201)
                                                                                                         	at android.os.Looper.loop(Looper.java:288)
                                                                                                         	at android.app.ActivityThread.main(ActivityThread.java:7872)
                                                                                                         	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                         	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                                                                                                         	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
                                                                                                         Caused by: android.os.RemoteException: Remote stack trace:
                                                                                                         	at com.android.server.pm.UserManagerService.checkManageUsersPermission(UserManagerService.java:2746)
                                                                                                         	at com.android.server.pm.UserManagerService.setUserName(UserManagerService.java:1871)
                                                                                                         	at android.os.IUserManager$Stub.onTransact(IUserManager.java:899)
                                                                                                         	at android.os.Binder.execTransactInternal(Binder.java:1280)
                                                                                                         	at android.os.Binder.execTransact(Binder.java:1244)

I tried on real device with sui and it works, but shizuku on the emulator doesn't
adb doesn't have enough permissions to change username?

@Hadinkof
Copy link

Hadinkof commented Jul 1, 2024

I use reference here

  1. Code
package android.os;

import android.content.pm.UserInfo;

import androidx.annotation.NonNull;

import java.util.List;

import dev.rikka.tools.refine.RefineAs;

@RefineAs(UserManager.class)
public class UserManagerHidden {
    public boolean isUserRunning(int userId) {
        throw new UnsupportedOperationException("Stub");
    }

    public boolean isUserUnlocked(int userId) {
        throw new UnsupportedOperationException("Stub");
    }

    public UserInfo getUserInfo(int userId) {
        throw new UnsupportedOperationException("Stub");
    }

    public boolean removeUser(int userId) {
        throw new UnsupportedOperationException("Stub");
    }

    public void setUserName(int userId, String name) {
        throw new UnsupportedOperationException("Stub");
    }

    public void setUserRestriction(String key, boolean value, UserHandle userHandle) {
        throw new UnsupportedOperationException("Stub");
    }

    public Bundle getUserRestrictions(UserHandle userHandle) {
        throw new UnsupportedOperationException("Stub");
    }

    public @NonNull List<UserInfo> getUsers() {
        throw new UnsupportedOperationException("Stub");
    }

    public @NonNull List<UserInfo> getAliveUsers() {
        throw new UnsupportedOperationException("Stub");
    }
}
  1. Log
java.lang.SecurityException: You need MANAGE_USERS permission to: rename users
                                                                                                         	at android.os.Parcel.createExceptionOrNull(Parcel.java:3011)
                                                                                                         	at android.os.Parcel.createException(Parcel.java:2995)
                                                                                                         	at android.os.Parcel.readException(Parcel.java:2978)
                                                                                                         	at android.os.Parcel.readException(Parcel.java:2920)
                                                                                                         	at android.os.IUserManager$Stub$Proxy.setUserName(IUserManager.java:1956)
                                                                                                         	at android.os.UserManager.setUserName(UserManager.java:4968)
                                                                                                         	at com.github.huymaster.controllerplus.data.UserDatabase.renameUser(User.kt:124)
                                                                                                         	at com.github.huymaster.controllerplus.activity.LoginActivity$MainContent$color$2$1.invoke-8_81llA(LoginActivity.kt:66)
                                                                                                         	at com.github.huymaster.controllerplus.activity.LoginActivity$MainContent$color$2$1.invoke(LoginActivity.kt:54)
                                                                                                         	at androidx.compose.animation.core.AnimateAsStateKt$animateValueAsState$3$1$1.invokeSuspend(AnimateAsState.kt:429)
                                                                                                         	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                         	at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:28)
                                                                                                         	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100)
                                                                                                         	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
                                                                                                         	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102)
                                                                                                         	at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
                                                                                                         	at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
                                                                                                         	at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
                                                                                                         	at android.os.Handler.handleCallback(Handler.java:942)
                                                                                                         	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                         	at android.os.Looper.loopOnce(Looper.java:201)
                                                                                                         	at android.os.Looper.loop(Looper.java:288)
                                                                                                         	at android.app.ActivityThread.main(ActivityThread.java:7872)
                                                                                                         	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                         	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                                                                                                         	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
                                                                                                         Caused by: android.os.RemoteException: Remote stack trace:
                                                                                                         	at com.android.server.pm.UserManagerService.checkManageUsersPermission(UserManagerService.java:2746)
                                                                                                         	at com.android.server.pm.UserManagerService.setUserName(UserManagerService.java:1871)
                                                                                                         	at android.os.IUserManager$Stub.onTransact(IUserManager.java:899)
                                                                                                         	at android.os.Binder.execTransactInternal(Binder.java:1280)
                                                                                                         	at android.os.Binder.execTransact(Binder.java:1244)

I tried on real device with sui and it works, but shizuku on the emulator doesn't
adb doesn't have enough permissions to change username?

@HuyMaster HuyMaster reopened this Jul 4, 2024
@HuyMaster
Copy link
Author

I use reference here

  1. Code
package android.os;

import android.content.pm.UserInfo;

import androidx.annotation.NonNull;

import java.util.List;

import dev.rikka.tools.refine.RefineAs;

@RefineAs(UserManager.class)
public class UserManagerHidden {
    public boolean isUserRunning(int userId) {
        throw new UnsupportedOperationException("Stub");
    }

    public boolean isUserUnlocked(int userId) {
        throw new UnsupportedOperationException("Stub");
    }

    public UserInfo getUserInfo(int userId) {
        throw new UnsupportedOperationException("Stub");
    }

    public boolean removeUser(int userId) {
        throw new UnsupportedOperationException("Stub");
    }

    public void setUserName(int userId, String name) {
        throw new UnsupportedOperationException("Stub");
    }

    public void setUserRestriction(String key, boolean value, UserHandle userHandle) {
        throw new UnsupportedOperationException("Stub");
    }

    public Bundle getUserRestrictions(UserHandle userHandle) {
        throw new UnsupportedOperationException("Stub");
    }

    public @NonNull List<UserInfo> getUsers() {
        throw new UnsupportedOperationException("Stub");
    }

    public @NonNull List<UserInfo> getAliveUsers() {
        throw new UnsupportedOperationException("Stub");
    }
}
  1. Log
java.lang.SecurityException: You need MANAGE_USERS permission to: rename users
                                                                                                         	at android.os.Parcel.createExceptionOrNull(Parcel.java:3011)
                                                                                                         	at android.os.Parcel.createException(Parcel.java:2995)
                                                                                                         	at android.os.Parcel.readException(Parcel.java:2978)
                                                                                                         	at android.os.Parcel.readException(Parcel.java:2920)
                                                                                                         	at android.os.IUserManager$Stub$Proxy.setUserName(IUserManager.java:1956)
                                                                                                         	at android.os.UserManager.setUserName(UserManager.java:4968)
                                                                                                         	at com.github.huymaster.controllerplus.data.UserDatabase.renameUser(User.kt:124)
                                                                                                         	at com.github.huymaster.controllerplus.activity.LoginActivity$MainContent$color$2$1.invoke-8_81llA(LoginActivity.kt:66)
                                                                                                         	at com.github.huymaster.controllerplus.activity.LoginActivity$MainContent$color$2$1.invoke(LoginActivity.kt:54)
                                                                                                         	at androidx.compose.animation.core.AnimateAsStateKt$animateValueAsState$3$1$1.invokeSuspend(AnimateAsState.kt:429)
                                                                                                         	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                         	at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:28)
                                                                                                         	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100)
                                                                                                         	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
                                                                                                         	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102)
                                                                                                         	at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
                                                                                                         	at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
                                                                                                         	at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
                                                                                                         	at android.os.Handler.handleCallback(Handler.java:942)
                                                                                                         	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                         	at android.os.Looper.loopOnce(Looper.java:201)
                                                                                                         	at android.os.Looper.loop(Looper.java:288)
                                                                                                         	at android.app.ActivityThread.main(ActivityThread.java:7872)
                                                                                                         	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                         	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                                                                                                         	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
                                                                                                         Caused by: android.os.RemoteException: Remote stack trace:
                                                                                                         	at com.android.server.pm.UserManagerService.checkManageUsersPermission(UserManagerService.java:2746)
                                                                                                         	at com.android.server.pm.UserManagerService.setUserName(UserManagerService.java:1871)
                                                                                                         	at android.os.IUserManager$Stub.onTransact(IUserManager.java:899)
                                                                                                         	at android.os.Binder.execTransactInternal(Binder.java:1280)
                                                                                                         	at android.os.Binder.execTransact(Binder.java:1244)

I tried on real device with sui and it works, but shizuku on the emulator doesn't
adb doesn't have enough permissions to change username?

What is the effect of quoting my issue?

@Henrryxdjr Henrryxdjr mentioned this issue Oct 20, 2024
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

2 participants