RikkaApps / Sui

Modern super user interface implementation on Android.
GNU General Public License v3.0
2.39k stars 129 forks source link

BinderWrapper 遇到 IBinder.FLAG_ONEWAY 导致鉴权错误 #35

Open Mufanc opened 2 years ago

Mufanc commented 2 years ago

  该 Demo 的功能是设置 MIUI 的进程白名单,成功时会输出如下日志:

D/ProcessManager: update CL:[com.netease.cloudmusic]

  使用 Shizuku 时功能正常,输出如下日志:

D/Service: transact: uid=10527, descriptor=miui.IProcessManager, code=8

  使用 Sui 时发生鉴权错误,找到如下日志:

W/Service: Permission Denial: transactRemote from pid=0 is not an attached client

  已在多台设备上进行测试,均产生此问题。

  定位到打日志的位置,发现该错误由 clientRecord == null 引起,向上继续定位到 ClientManager#findClient(int uid, int pid)

public ClientRecord findClient(int uid, int pid) {
    for (ClientRecord clientRecord : clientRecords) {
        if (clientRecord.pid == pid && clientRecord.uid == uid) {
            return clientRecord;
        }
    }
    return null;
}

  可能是由于 oneway 导致此处 获取到的 pid 为 0,导致没有匹配到正确的 clientRecord

  不知道我的猜想是否正确,还请开发者帮忙看看。

RikkaW commented 2 years ago

试试 https://github.com/RikkaApps/Sui/runs/5954086487

Mufanc commented 2 years ago

正常了,非常感谢!