RikkaApps / Shizuku-API

The API and the developer guide for Shizuku and Sui.
MIT License
1.05k stars 250 forks source link

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

Open HuyMaster opened 5 months ago

HuyMaster commented 5 months ago

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 commented 4 months ago

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 commented 4 months ago

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?