IM-A820L限制GSM,WCDMA上网的原理(其他泛泰机型可参考)7.13

定位到framework\com\android\internal\telephony\MMDataConnectionTracker.smali中

关键限制代码在isReadyForData()中

smali代码

    if-eqz v3, :cond_ec

    iget-boolean v6, p0, Lcom/android/internal/telephony/MMDataConnectionTracker;->isDataConnPopupAllowed:Z

    if-eqz v6, :cond_ec

    iget-boolean v6, p0, Lcom/android/internal/telephony/MMDataConnectionTracker;->isDataConnDialogDisplayed:Z

    if-nez v6, :cond_ec

    sget-object v6, Lcom/android/internal/telephony/CommandsInterface$RadioTechnology;->RADIO_TECH_LTE:Lcom/android/internal/telephony/CommandsInterface$RadioTechnology;

    if-eq v4, v6, :cond_235

    invoke-virtual {p0}, Lcom/android/internal/telephony/MMDataConnectionTracker;->isRadioTechEvdo()Z

    move-result v6

    if-eqz v6, :cond_262

    :cond_235
    iget-object v6, p0, Lcom/android/internal/telephony/MMDataConnectionTracker;->datalock:Ljava/lang/Object;

    monitor-enter v6

    :try_start_238
    const-string v7, "DATA"

    const-string v8, "[MMDataConnectionTracker] isReadyForData is True and isDataconnPopupAllowed is True "

    invoke-static {v7, v8}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    const-string v7, "DATA"

    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    const-string v9, "data conn popup showed, "

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    iget-boolean v9, p0, Lcom/android/internal/telephony/MMDataConnectionTracker;->isDataConnDialogDisplayed:Z

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    invoke-static {v7, v8}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    invoke-direct {p0}, Lcom/android/internal/telephony/MMDataConnectionTracker;->createDataConnectionDialog()V

    monitor-exit v6

    goto/16 :goto_ec

    :catchall_25f
    move-exception v7

    monitor-exit v6
    :try_end_261
    .catchall {:try_start_238 .. :try_end_261} :catchall_25f

    throw v7

    :cond_262
    const/4 v3, 0x0

    goto/16 :goto_ec

对应java代码
		if (flag && isDataConnPopupAllowed && !isDataConnDialogDisplayed)
		{
			int i4 = CommandsInterface.RadioTechnology.RADIO_TECH_LTE;
			if (i == i4 || isRadioTechEvdo())
				synchronized (datalock)
				{
					int j4 = Log.d("DATA", "[MMDataConnectionTracker] isReadyForData is True and isDataconnPopupAllowed is True ");
					StringBuilder stringbuilder14 = (new StringBuilder()).append("data conn popup showed, ");
					boolean flag14 = isDataConnDialogDisplayed;
					String s4 = stringbuilder14.append(flag14).toString();
					int k4 = Log.e("DATA", s4);
					createDataConnectionDialog();
				}
			else
				flag = false;
		}

可以看到
			int i4 = CommandsInterface.RadioTechnology.RADIO_TECH_LTE;
			if (i == i4 || isRadioTechEvdo())

这个是关键判断,若非LTE或Evdo则flag=false;也就是不能上网

那么我们只需要去掉这个判断就可以了

也就是去掉这段对应smali代码

    sget-object v6, Lcom/android/internal/telephony/CommandsInterface$RadioTechnology;->RADIO_TECH_LTE:Lcom/android/internal/telephony/CommandsInterface$RadioTechnology;

    if-eq v4, v6, :cond_235

    invoke-virtual {p0}, Lcom/android/internal/telephony/MMDataConnectionTracker;->isRadioTechEvdo()Z

    move-result v6

    if-eqz v6, :cond_262

这样做之后,开机时便可看到弹出的是否使用数据的对话框了


7.13增加

启用设置中灰色的网络选项

修改Phone.apk\com\android\phone\Settings.smali

.method setEnabledAlwyasonMenu()V
    .locals 2

    .prologue
    const-string v1, "alwayson_settings"

    invoke-direct {p0}, Lcom/android/phone/Settings;->isRoaming()Z

    move-result v0

    if-eqz v0, :cond_0

    const-string v0, "alwayson_settings"

    invoke-virtual {p0, v1}, Lcom/android/phone/Settings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v0

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Landroid/preference/Preference;->setEnabled(Z)V

    :goto_0
    return-void

    :cond_0
    const-string v0, "alwayson_settings"

    invoke-virtual {p0, v1}, Lcom/android/phone/Settings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v0

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Landroid/preference/Preference;->setEnabled(Z)V

    goto :goto_0
.end methodH
将上面19行的0x0改为0x1即可


转载请注明出处:http://blog.csdn.net/su_ky/article/details/7740166

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