关于双卡双待手机的基站变化监听

cop007 2014-11-27 10:52:49
单卡手机只需调用TelephonyManager的listen就能够实现监听,代码如下:

TelephonyManager tel = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
tel.listen(new TelLocationListener(), PhoneStateListener.LISTEN_CELL_LOCATION);

public class TelLocationListener extends PhoneStateListener{
@Override
public void onCellLocationChanged(CellLocation location){
super.onCellLocationChanged(location);
..............


现在对一款三星双卡双待手机的基站更新进行监听,通过类投射发现该设备的隐藏函数,如:
public android.telephony.CellLocation android.telephony.TelephonyManager.getCellLocationDs(int)
public java.lang.String android.telephony.TelephonyManager.getDeviceIdDs(int)
public void android.telephony.TelephonyManager.listenDs(int,android.telephony.PhoneStateListener,int)
调用前两个函数能够成功获取双卡各自信息
本以为调用listenDs能够实现双卡各自监听,却无法截获,代码如下:

...
listenBySlot("listenDs",0,new TelLocationListener(),PhoneStateListener.LISTEN_CELL_LOCATION);
listenBySlot("listenDs",1,new TelLocationListener(),PhoneStateListener.LISTEN_CELL_LOCATION);
...

private void listenBySlot(String predictedMethodName, int slotID,PhoneStateListener phoneStateListener,int state) {
TelephonyManager telephony = (TelephonyManager)
mContext.getSystemService(Context.TELEPHONY_SERVICE);
try {
Class<?> telephonyClass = Class.forName(telephony.getClass().getName());
Class<?>[] parameter = new Class[3];
parameter[0] = int.class;
parameter[1] = PhoneStateListener.class;
parameter[2] = int.class;
Method listen = telephonyClass.getMethod(predictedMethodName,parameter);

Object[] obParameter = new Object[3];
obParameter[0] = slotID;
obParameter[1] = phoneStateListener;
obParameter[2] = state;
listen.invoke(telephony, obParameter);

} catch (Exception e) {
Log.i("sbox","\n" + e.getMessage());
//throw new GeminiMethodNotFoundException(predictedMethodName);
}
}

有谁能指点一二,万分感谢!
...全文
775 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
http://mp.weixin.qq.com/s?__biz=MzA4ODkwNjMwOA==&mid=201053405&idx=2&sn=39d18278d8331985dd8dfdd91783c60b&scene=1&from=singlemessage&isappinstalled=0#rd 看看这个文章哈 自己反编译下 先看看
cop007 2014-12-02
  • 打赏
  • 举报
回复
引用 1 楼 Harry211 的回复:
题主已经反编译了Framework层代码 ,使用反射调用,我们也是这么做的。 做双卡开发的过程中发现一个问题,有些地方厂商定制的api在那里放着,反射调用还是不好用。只能继续尝试其他方式调用。 不断的验证是否可行。 三星手机大部分使用了两个电话服务,phone 和 phone2 不知道你试没试过phone2
没有试过,能给段代码吗?我是通过这段代码获取隐藏函数的: public static void printTelephonyManagerMethodNamesForThisDevice( Context context) { TelephonyManager telephony = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); Class<?> telephonyClass; try { telephonyClass = Class.forName(telephony.getClass().getName()); Method[] methods = telephonyClass.getMethods(); for (int idx = 0; idx < methods.length; idx++) { Log.i("", "\n" + methods[idx] + " declared by " + methods[idx].getDeclaringClass()); } } catch (ClassNotFoundException e) { e.printStackTrace(); } }
  • 打赏
  • 举报
回复
QQ:2270967866 和服务邮箱: kapalai_service@21kunpeng.com
  • 打赏
  • 举报
回复
题主已经反编译了Framework层代码 ,使用反射调用,我们也是这么做的。 做双卡开发的过程中发现一个问题,有些地方厂商定制的api在那里放着,反射调用还是不好用。只能继续尝试其他方式调用。 不断的验证是否可行。 三星手机大部分使用了两个电话服务,phone 和 phone2 不知道你试没试过phone2

80,350

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧