android - 未经授权的调用者错误

标签 android root vpn android-virtual-device

我一直在编写一些使用调用 IConnectivityManager.startLegacyVpn 的反射的代码

我得到的错误是 java.lang.SecurityException: Unauthorized Caller

查看 android 源代码,我看到这是挂起我的代码:

if (Binder.getCallingUid() != Process.SYSTEM_UID) { 引发上述异常 }

我的问题是,如果我 root 我的 AVD 并在系统/应用程序中安装我的应用程序,这是否足以解决此错误?

如果是这样,关于如何执行此操作的任何提示(每次我尝试将我的 apk 移动到系统/应用程序文件夹时,当我单击应用程序图标时它说应用程序未安装。

谢谢!

最佳答案

我有同样的问题,在android 4.01开源之后,我看到了这样的东西:

public synchronized LegacyVpnInfo getLegacyVpnInfo() {
    // Only system user can call this method.

    if (Binder.getCallingUid() != Process.SYSTEM_UID) {
        throw new SecurityException("Unauthorized Caller");
    }
    return (mLegacyVpnRunner == null) ? null : mLegacyVpnRunner.getInfo();
}

或者,

// Only system user can revoke a package.
if (Binder.getCallingUid() != Process.SYSTEM_UID) {
    throw new SecurityException("Unauthorized Caller");
}

或者,

public void protect(ParcelFileDescriptor socket, String interfaze) throws Exception {
    PackageManager pm = mContext.getPackageManager();

    ApplicationInfo app = pm.getApplicationInfo(mPackage, 0);

    if (Binder.getCallingUid() != app.uid) {
        throw new SecurityException("Unauthorized Caller");
    }

    jniProtect(socket.getFd(), interfaze);
}

但是,上面的这些代码块属于 com.android.server.connectivity.Vpn

(类 Vpn),未在接口(interface) IConnectivityManager 中定义。

我也在 startLegacyVpnInfo() 函数中找到,但我看不到任何涉及异常的东西

“未经授权的调用者”,所以我想知道为什么 startLegacyVpnInfo() 函数会抛出这个异常?

有什么解决办法吗?

关于android - 未经授权的调用者错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11887265/

相关文章:

android - 如何在 RxJava 中链接具有不同间隔的可观察量?

android - 防止应用程序在 Root设备上被杀死

java - 点击事件处理程序: How to change shape type on click

amazon-web-services - AWS : Can't ping from VPN to instance in other region

android - 如何在循环中的linearlayout中添加多个textview

android - 异步更新 View

android - Play 商店中的促销图片和特色图片有什么区别

android - root 后 Logcat 不工作

objective-c - 如何在 iOS 上使用 Objective-C 触发按需 VPN

python - 通过 python 通过 vpn 连接路由特定流量