android 7.0 系统关闭彩信过CTA测试的方法

 

CTA测试要求关闭彩信功能。

 

底层的关闭,彩信是用网络发送的,在http检测到是mms的UA的时候,就给他返回一下

alps\external\apache-http\android\src\android\net\http\AndroidHttpClient.java

 

    public static AndroidHttpClient newInstance(String userAgent, Context context) {

//增加以下
        if(userAgent.contains("Mms")||userAgent.contains("mms")){
             return  null;// newInstance("", null /* session cache */);
        }

 

也有使用okhttp的,同样的修改

Z:alps\external\okhttp\okhttp\src\main\java\com\squareup\okhttp\Connection.java

 

  private Request createTunnelRequest(Request request) throws IOException {
    HttpUrl tunnelUrl = new HttpUrl.Builder()
        .scheme("https")
        .host(request.httpUrl().host())
        .port(request.httpUrl().port())
        .build();
    Request.Builder result = new Request.Builder()
        .url(tunnelUrl)
        .header("Host", Util.hostHeader(tunnelUrl))
        .header("Proxy-Connection", "Keep-Alive"); // For HTTP/1.0 proxies like Squid.

    // Copy over the User-Agent header if it exists.
    String userAgent = request.header("User-Agent");

//增加以下
    if(userAgent.contains("Mms")||userAgent.contains("mms")){
             return  null;
    }
    if (userAgent != null) {
      result.header("User-Agent", userAgent);
    }

 

短信APP 本身去掉彩信添加附件的方法

[FAQ14861]mms去掉彩信功能
哥伦比亚某些运营商要求去除彩信功能,可以按照以下步骤修改
1.修改Compose_message_activity.xml文件中的 添加android:visibility="gone"
2.修改ComposeMessageActivity.java函数
A.修改onCreate函数,注释掉里面对initShareRessource的调用
B.修改onResume函数,注释掉如下代码:
if (mIsSmsEnabled) {
mShareButton.setClickable(true);
mShareButton.setImageResource(R.drawable.ipmsg_share);
} else {
mShareButton.setClickable(false);
mShareButton.setImageResource(R.drawable.ipmsg_share_disable);
}
C.修改onPrepareOptionsMenu函数,注释掉如下代码:
if (mIsSmsEnabled) {
if (!isSubjectEditorVisible()) {
menu.add(0, MENU_ADD_SUBJECT, 0,
R.string.add_subject).setIcon(R.drawable.ic_menu_edit);
}
}
3.修改SettingListActivity.java
A.修改setAdapter函数,注释掉settingList中的
getResources().getString(R.string.pref_setting_mms)
B.修改onListItemClick函数
将case 1:
Intent smsPreferenceIntent = new Intent(SettingListActivity.this,
SmsPreferenceActivity.class);
startActivity(smsPreferenceIntent);
break;
case 2:
Intent mmsPreferenceIntent = new Intent(SettingListActivity.this,
MmsPreferenceActivity.class);
startActivity(mmsPreferenceIntent);
break;
case 3:
Intent notificationPreferenceIntent = new Intent(SettingListActivity.this,
NotificationPreferenceActivity.class);
startActivity(notificationPreferenceIntent);
break;
case 4:
Intent generalPreferenceIntent = new Intent(SettingListActivity.this,
GeneralPreferenceActivity.class);
startActivity(generalPreferenceIntent);
break;
修改为:
case 1:
Intent smsPreferenceIntent = new Intent(SettingListActivity.this,
SmsPreferenceActivity.class);
startActivity(smsPreferenceIntent);
break;
case 2:
Intent notificationPreferenceIntent = new Intent(SettingListActivity.this,
NotificationPreferenceActivity.class);
startActivity(notificationPreferenceIntent);
break;
case 3:
Intent generalPreferenceIntent = new Intent(SettingListActivity.this,
GeneralPreferenceActivity.class);
startActivity(generalPreferenceIntent);
break;
4.修改MmsConfig.java的getMmsEnabled函数,将
return mMmsEnabled = 1?true:false;
修改为:return false;
5.修改/frameworks/opt/telephony/src/java/com/android/internal/telephony/WapPushOverSms.java
(1)把if (SmsManager.getDefault().getAutoPersisting()){
修改成
if (SmsManager.getDefault().getAutoPersisting() && !mimeType.equals(WspTypeDecoder.CONTENT_TYPE_B_MMS))
{
(2)把if (mimeType.equals(WspTypeDecoder.CONTENT_TYPE_B_MMS)) {
// MTK-START
Rlog.d(TAG, "WapPush set permission for RECEIVE_MMS");
// MTK-END
permission = android.Manifest.permission.RECEIVE_MMS;
appOp = AppOpsManager.OP_RECEIVE_MMS;
} 修改成
if (mimeType.equals(WspTypeDecoder.CONTENT_TYPE_B_MMS)) {
// MTK-START
//Rlog.d(TAG, "WapPush set permission for RECEIVE_MMS");
// MTK-END
//permission = android.Manifest.permission.RECEIVE_MMS;
//appOp = AppOpsManager.OP_RECEIVE_MMS;
Rlog.d(TAG, "WapPush ignore RECEIVE_MMS");
return Activity.RESULT_OK; //for ALPS02243345
}

你可能感兴趣的:(android,Android,Phone)