gpt4 book ai didi

java - 在 Android 中阻止调用

转载 作者:太空宇宙 更新时间:2023-11-04 14:45:16 25 4
gpt4 key购买 nike

我正在尝试开发一个基本代码来阻止 Android 中的调用。我的代码最初可以工作,但现在不行了。

阻止所有调用的代码

    @Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
try {
Class<?> c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);

ITelephony是使用的接口(interface)

        telephony = (ITelephony) m.invoke(tm);

无法调用任何可用函数

        telephony.endCall();
telephony.notifyAll();
} catch (Exception e) {
// TODO: handle exception
}
}

最佳答案

当你这样做时:

m.setAccessible(true);

您实际上正在尝试绕过 Java 安全性。在某些具有旧 Android 版本的设备上,它可能可以工作,但在更多锁定的设备上,不能保证它可以工作。

关于java - 在 Android 中阻止调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24469475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com