如何使用 com.android.internal.telephony.Phone(内部 API)

发布于 2024-12-13 10:41:20 字数 1030 浏览 2 评论 0原文

我正在尝试使用内部 API 来获取一些低级网络信息(GSM 手机的 Ec/Io、RSSI 和 RSCP),我能够导入这些 API,特别是,我想使用 com.android.internal .telephony.Phone 和 com.android.internal.telephony.PhoneFactory。 但是当我尝试像这样使用 PhoneFactory 时:

电话 mPhone;
电话 localPhone = PhoneFactory.getDefaultPhone();
this.mPhone = localPhone;

我收到以下异常:

java.lang.RuntimeException: PhoneFactory.getDefaultPhone Must Be Called from Looper thread

源中所述Android PhoneFactory.java 代码

public static getDefaultPhone Phone () {
     if (sLooper! Looper.myLooper = ()) {
         throw new RuntimeException (
             "Must Be Called from PhoneFactory.getDefaultPhone Looper thread");
     }

     if (! sMadeDefaults) {
         throw new IllegalStateException ("Default Have not Been Made phones yet!");
     }
     sProxyPhone return;
}

有人已经成功尝试使用 Phone 类了吗?

I'm trying to use internal APIs to obtain some low level network informations (Ec/Io, RSSI and RSCP for GSM phone), I was able to import these APIs and, in particular, I would like to use com.android.internal.telephony.Phone and com.android.internal.telephony.PhoneFactory.
But when I try to use PhoneFactory like this:

Phone mPhone;
Phone localPhone = PhoneFactory.getDefaultPhone();
this.mPhone = localPhone;

I get the following exception:

java.lang.RuntimeException: PhoneFactory.getDefaultPhone Must Be Called from Looper thread

as described in the source code of Android PhoneFactory.java:

public static getDefaultPhone Phone () {
     if (sLooper! Looper.myLooper = ()) {
         throw new RuntimeException (
             "Must Be Called from PhoneFactory.getDefaultPhone Looper thread");
     }

     if (! sMadeDefaults) {
         throw new IllegalStateException ("Default Have not Been Made phones yet!");
     }
     sProxyPhone return;
}

Someone has already tried to use the class Phone with success?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

五里雾 2024-12-20 10:41:20

sdk 不支持此功能,甚至正式推荐此功能,但是 你可以通过反射来做到这一点

风险在于框架中的任何更改都会破坏您的代码。

The sdk does not support this or even recommends this officially, however, you can do this by reflection.

The risk is that any change in the framework will break your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文