关于sms center number 中心默认号码是如何设置的,一个硕大的问号.
来源:互联网 发布:利用淘宝赚钱灰色项目 编辑:程序博客网 时间:2024/06/06 00:55
刚入门的菜鸟,android 4.4 不知道短信中心的号码默认值是如何设置的
首先我找到了将短信中心号码设置到控件上显示的地方:
文件名:SimSettingPreferenceActivity.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); mPhoneId = this.getIntent().getIntExtra(Phone.PHONE_ID, TelephonyManager.getDefaultPhoneId()); mTelephonyManager = MmsApp.getApplication().getTelephonyManager(mPhoneId); if (MessageUtils.OS_DEBUG) { Log.d(TAG, "onCreate() -->> Start activity for phoneId = " + mPhoneId); } addPreferencesFromResource(R.xml.setting_sim_preferences); createResource(); ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP); setMessagePreferences(); //modify for Bug 620828 begin mSoftKeyPanel=new SoftKeyPanel(this); mSoftKeyPanel.setCaption(null,getString(R.string.menu_select), getString(R.string.menu_back)); //modify for Bug 620828 end
private void createResource() { mManageSimPref = findPreference("pref_key_manage_sim_messages"); mSmsDeliveryReportPref = (CheckBoxPreference) findPreference("pref_key_sms_delivery_reports"); mStoreSmsOnSim = (CheckBoxPreference) findPreference("pref_key_store_sms_on_sim"); mMmsDeliveryReportPref = (CheckBoxPreference)findPreference("pref_key_mms_delivery_reports"); mMmsReadReportPref = (CheckBoxPreference)findPreference("pref_key_mms_read_reports"); mSmscPref = findPreference("pref_key_sim_smsc"); mMmsAutoCheckPref = (CheckBoxPreference)findPreference("pref_key_mms_auto_retrieval"); mMmsDuringPref = (CheckBoxPreference)findPreference("pref_key_mms_retrieval_during_roaming"); mMmsValidityPref = (ListPreference)findPreference("pref_key_mms_validity_input_sim"); mMmsValidityPref.setOnPreferenceChangeListener(this); mSmsValidityPref = (ListPreference)findPreference("pref_key_sms_validity"); mSmsValidityPref.setOnPreferenceChangeListener(this); mMmsPriorityPref = (ListPreference)findPreference("pref_key_mms_priority"); mMmsPriorityPref.setOnPreferenceChangeListener(this); }
private void setMessagePreferences() {.......................... if (isMultiSim && isValidPhoneId(mPhoneId)) { mSmscPref.setTitle(getString(R.string.pref_title_manage_simx_smsc, mPhoneId+1)); mSmscPref.setSummary(getSmscString(mPhoneId)); } else { mSmscPref.setSummary(getSmscString(-1)); }.......................}
private String getSmscString(int phoneId) { String smscStr = ""; // SPRD: Modify for bug261680 @{ TelephonyManager telephonyManager; if (phoneId == -1) { telephonyManager = MmsApp.getApplication().getTelephonyManager(); } else { telephonyManager = MmsApp.getApplication().getTelephonyManager(phoneId); } if (!mSupportOrange) { smscStr = telephonyManager.getSmsc(); //短信中心号码默认获取处 if ((smscStr == null || smscStr.equals("") || smscStr.equals("refresh error")) && isCMCCSim(phoneId)) { smscStr = CMCC_DEFAULT_SMSC; } }else{ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(SimSettingPreferenceActivity.this); if (TelephonyManager.isMultiSim()) { smscStr = sharedPreferences.getString( SimSettingPreferenceActivity.SMS_CENTER_ACTIVATED_STR_SIMX[phoneId], ""); } else { smscStr = sharedPreferences.getString( SimSettingPreferenceActivity.SMS_CENTER_ACTIVATED_STR, ""); } } // @} return smscStr; }
在TelephonyManager.java中:
public String getSmsc() { try { return getISprdTelephony().getSmsc(); //getISprdTelephony 方法返回的是一个ISprdTelephony.aidl服务,实现getISprdTelephony.aidl的类是:SprdPhoneInterfaceManger.java } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { return null; } }
在SprdPhoneInterfaceManager.java中真正去获得Smsc:
public String getSmsc() { enforceModifyPermission(); final GetSetSMSC getSMSC = new GetSetSMSC(mPhone, null); getSMSC.start(); return getSMSC.getSmsc(); } public boolean setSmsc(String smscAddr) { enforceModifyPermission(); final GetSetSMSC getSMSC = new GetSetSMSC(mPhone, smscAddr); getSMSC.start(); return getSMSC.setSmsc(); }
private static class GetSetSMSC extends Thread { private final Phone mPhone; private final String mSmscStr; private boolean mDone = false; private String mResult; private boolean bResult = false; private Handler mHandler; // For async handler to identify request type private static final int QUERY_SMSC_DONE = 100; private static final int UPDATE_SMSC_DONE = 101; public GetSetSMSC(Phone phone, String SmscStr) { mPhone = phone; mSmscStr = SmscStr; } @Override public void run() { Looper.prepare(); synchronized (GetSetSMSC.this) { mHandler = new Handler() { @Override public void handleMessage(Message msg) { AsyncResult ar = (AsyncResult) msg.obj; switch (msg.what) { case QUERY_SMSC_DONE: Log.d(LOG_TAG, "[smsc]QUERY_SMSC_DONE"); synchronized (GetSetSMSC.this) { if (ar.exception == null) { mResult = (String)ar.result; } else { mResult = "refresh error"; } mDone = true; GetSetSMSC.this.notifyAll(); } getLooper().quit(); break; case UPDATE_SMSC_DONE: Log.d(LOG_TAG, "[smsc]UPDATE_SMSC_DONE"); synchronized (GetSetSMSC.this) { bResult = (ar.exception == null); mDone = true; GetSetSMSC.this.notifyAll(); } getLooper().quit(); break; } } }; GetSetSMSC.this.notifyAll(); } Looper.loop(); } synchronized String getSmsc() { while (mHandler == null) { try { wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } mPhone.getSmscAddress(mHandler.obtainMessage(QUERY_SMSC_DONE)); while (!mDone) { try { Log.d(LOG_TAG, "[smsc]wait get for done"); wait(); } catch (InterruptedException e) { // Restore the interrupted status Thread.currentThread().interrupt(); } } Log.d(LOG_TAG, "[smsc]get done"); return mResult; } synchronized boolean setSmsc() { while (mHandler == null) { try { wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } mPhone.setSmscAddress(mSmscStr, mHandler.obtainMessage(UPDATE_SMSC_DONE)); while (!mDone) { try { Log.d(LOG_TAG, "[smsc]wait set for done"); wait(); } catch (InterruptedException e) { // Restore the interrupted status Thread.currentThread().interrupt(); } } Log.d(LOG_TAG, "[smsc]set done. result = "+bResult); return bResult; } }
最后走到这里就没思路了,按我的思路应该是在开机初始化的时候,系统会默认setSmsAddress()设置一个地址最后通知UPDATE_SMSC_DONE,
最后到RIL那边发送.最后就可以在getSmsc()中getSmscAddress(mHandler.obtainMessage(QUERY_SMSC_DONE))中获取一个String类型的mResult。
可是代码全局搜索setSmscAddress没有找到相关紧要的设置项,是从SIM卡中自动获取的???还是我的思路不对呢?
不过最后问了同事,短信中心号码不要改,改了可能会出问题,客户需求不靠谱啊,关键我自己想知道结果是哪里给的值。
阅读全文
0 0
- 关于sms center number 中心默认号码是如何设置的,一个硕大的问号.
- 关于SAP的号码范围(number range)
- 关于SAP的号码范围(number range)
- 关于SAP的号码范围(number range)
- 关于SAP的号码范围(number range)
- 关于SAP的号码范围(number range)
- 短信中心号码的读取
- IOS NSNotification Center 通知中心的使用
- 如何解决mysql插入的中文全是问号?????
- C# 给你一个移动联通电信的号段,你如何去判断用户输入的号码是哪个?
- 暗恋---一个美丽的问号
- 一个问号?引发的调试
- 关于tortoiseSVN的问号问题
- 关于类型后面的问号
- 设置ExpandableListView 默认是展开的
- Ubuntu 软件中心(software center)的安装和卸载
- android 预置默认的语音信箱号码
- android 预置默认的语音信箱号码
- Ubuntu 16.04安装iBus中文输入法pinyin及问题
- Triangle
- AC_automaton 模板
- Android-RecyclerView实现购物车简单功能
- Ansible
- 关于sms center number 中心默认号码是如何设置的,一个硕大的问号.
- nginx安全与性能优化(下部)
- 如何在 Java 中正确使用 wait, notify 和 notifyAll – 以生产者消费者模型为例
- 理解var声明
- SQL的自定义排序 order by 的巧用
- RaspberryPi2B使用bcm2835c库控制GPIO
- 洛谷 P1558 色板游戏
- 二叉树线索化
- 学习C语言的第二天