Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Makes network mode toggle work. Port from CM9.

Added LTE_ONLY needed code to PhoneToggler.
Added LTE to the double check MODE_GLOBAL condition on Settings and
PhoneToggler.

Integrated patch by Danny Baumann to make PhoneToggler accept the same
values as are configurable in settings, from change:
http://review.cyanogenmod.com/#change,14120

Tested-by: Emerson Pinter
Signed-off-by: Emerson Pinter <dev@pinter.com.br>

*** Settings.java and PhoneToggler.java original authors:

commit 3e6b2ca4c969aedeefa9a10bb85e9c52bc43a574
Author: Emilio López <turl@tuxfamily.org>
Date:   Wed Sep 14 23:50:06 2011 +0000

    Phone: Double check mode before changing, part 2

    A modem might report world phone mode when it really is only GSM or
    CDMA capable, making the system switch to an invalid mode which
    will later break the telephony code.
    This simple check enforces the world phone overlay which is already
    in place and will only consider it a correct value in that case.

    This complements a commit with the same title by applying the same
    logic to another code path that uses similar checks.

    Change-Id: Ib7332511a693d40f53a79ba98844c9117871228a

commit 19215c8f614e30211b2aca1512bb8444da55bdda
Author: Emilio López <turl@tuxfamily.org>
Date:   Wed Sep 14 23:50:06 2011 +0000

    Phone: Double check mode before changing

    A modem might report world phone mode when it really is only GSM or
    CDMA capable, making the system switch to an invalid mode which
    will later break the telephony code.
    This simple check enforces the world phone overlay which is already
    in place and will only consider it a correct value in that case.

    Change-Id: Iedbc529497b2779f3a12ff56ca1b028cc9434227

commit 0d396f79514173e06c5334a40f23090933e0a806
Author: piaf <piaf@mediacenter-desktop.(none)>
Date:   Tue Aug 3 00:56:09 2010 +0100

    Added permission control for the 2G/3G switch

commit 5c85d5417a67b02be895a8878c7fa86bc992cd8e
Author: Mediacenter <mediacenter@mediacenter-desktop.(none)>
Date:   Sat Jul 31 01:45:03 2010 +0100

    Added support for Changing Phone network mode
    Todo: Add permission control

Change-Id: I84db8082b4e35262f1c6cdb8d1156f3cbf997a99

Conflicts:

	AndroidManifest.xml
	res/values-cs/strings.xml
	res/values-de/strings.xml
	res/values-es/strings.xml
	res/values-fr/strings.xml
	res/values-hu/strings.xml
	res/values-it/strings.xml
	res/values-ja/strings.xml
	res/values-ko/strings.xml
	res/values-nl/strings.xml
	res/values-pl/strings.xml
	res/values-pt/strings.xml
	res/values-sk/strings.xml
	res/values-sv/strings.xml
	res/values-tr/strings.xml
	res/values-uk/strings.xml
	res/values-zh-rCN/strings.xml
	res/values-zh-rTW/strings.xml
	res/values/strings.xml
	src/com/android/phone/MobileNetworkSettings.java
  • Loading branch information...
commit 724feb74d649c7cfbc6e5f9ba5ae366dd548b7a4 1 parent c646db4
@epinter epinter authored Whitehawkx committed
View
12 AndroidManifest.xml
@@ -506,6 +506,13 @@
android:configChanges="orientation|screenSize|keyboardHidden">
</activity>
+ <receiver android:name="com.android.phone.PhoneToggler" android:permission="com.android.phone.CHANGE_NETWORK_MODE">
+ <intent-filter>
+ <action android:name="com.android.internal.telephony.REQUEST_NETWORK_MODE" />
+ <action android:name="com.android.internal.telephony.MODIFY_NETWORK_MODE" />
+ </intent-filter>
+ </receiver>
+
<activity android:name="RespondViaSmsManager$Settings"
android:label="@string/respond_via_sms_setting_title"
android:configChanges="orientation|screenSize|keyboardHidden"
@@ -531,4 +538,9 @@
</receiver>
</application>
+ <permission android:name="com.android.phone.CHANGE_NETWORK_MODE"
+ android:label="@string/perm_change_mobile_network"
+ android:description="@string/perm_change_mobile_network_desc"
+ android:permissionGroup="android.permission-group.COST_MONEY"
+ android:protectionLevel="dangerous" />
</manifest>
View
34 res/values-cs/strings.xml
@@ -612,24 +612,28 @@
<string name="voicemail_notification_vibrate_when_title" msgid="8361970092063604886">"Vibrace"</string>
<string name="voicemail_notification_vibarte_when_dialog_title" msgid="5739583146522136440">"Vibrace"</string>
<string name="voicemail_notification_ringtone_title" msgid="2512535133814478358">"Vyzvánění"</string>
- <string-array name="voicemail_notification_vibrate_when_entries">
- <item msgid="468237575962916558">"Vždy"</item>
- <item msgid="1595097872875714252">"Pouze v tichém režimu"</item>
- <item msgid="1458182414036878616">"Nikdy"</item>
- </string-array>
+ <string-array name="voicemail_notification_vibrate_when_entries">
+ <item msgid="468237575962916558">"Vždy"</item>
+ <item msgid="1595097872875714252">"Pouze v tichém režimu"</item>
+ <item msgid="1458182414036878616">"Nikdy"</item>
+ </string-array>
<string name="ringtone_title" msgid="6374978286202084684">"Vyzváněcí tón telefonu"</string>
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"Vibrace při vyzvánění"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"Tóny při dotyku číselníku"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"Vyzvánění"</string>
- <string name="ring_delay_title">Opožděné vyzvánění</string>
- <string name="ring_delay_summary">Nastavit zpoždění vyzvánění</string>
- <string-array name="ring_delay_entries">
- <item>Zpoždění vypnuto</item>
- <item>3 sekundy</item>
- <item>6 sekund</item>
- <item>9 sekund</item>
- </string-array>
- <string name="dialer_ui_settings_title">Nastavení vytáčení</string>
- <string name="dialer_ui_settings_summary">Možnosti číselníku vytáčení</string>
+ <string name="ring_delay_title">Opožděné vyzvánění</string>
+ <string name="ring_delay_summary">Nastavit zpoždění vyzvánění</string>
+ <string-array name="ring_delay_entries">
+ <item>Zpoždění vypnuto</item>
+ <item>3 sekundy</item>
+ <item>6 sekund</item>
+ <item>9 sekund</item>
+ </string-array>
+
+ <string name="dialer_ui_settings_title">Nastavení vytáčení</string>
+ <string name="dialer_ui_settings_summary">Možnosti číselníku vytáčení</string>
+
+ <string name="perm_change_mobile_network">Změnit typ sítě (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">Aplikace s tímto oprávněním může kdykoliv změnit mezi 2G data a 3G data. 3G je rychlejší, ale náročnější na využití baterie a také může stát více peněz.</string>
</resources>
View
2  res/values-de/strings.xml
@@ -625,4 +625,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"Beim Klingeln vibrieren"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"Wähltastentöne"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"Klingelton"</string>
+ <string name="perm_change_mobile_network">Mobilfunkstandard wechseln (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">Anwendungen mit dieser Berechtigung können jederzeit zwischen 2G- und 3G-Netz wechseln. 3G ist schneller, verbraucht mehr Batterieladung und kann teurer sein</string>
</resources>
View
2  res/values-es/strings.xml
@@ -625,4 +625,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"Vibrar al sonar"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"Sonar al marcar número"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"Tono"</string>
+ <string name="perm_change_mobile_network">Cambiar red (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">Las aplicaciones con este permiso, pueden en cualquier momento, cambiar entre datos 2G y 3G. 3G es rápido, consume mas batería, y puede costarte mas dinero.</string>
</resources>
View
2  res/values-fr/strings.xml
@@ -621,4 +621,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"Mode Vibreur lorsque le téléphone sonne"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"Numérotation sonore"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"Sonnerie"</string>
+ <string name="perm_change_mobile_network">Changer la technologie réseau (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">Les applications possédant cette permission peuvent à chaque instant changer entre les technologies 2G et 3G. La 3G est plus rapide, consomme plus de batterie, et peut également vous coûter plus</string>
</resources>
View
2  res/values-hu/strings.xml
@@ -621,4 +621,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"Csengetéskor rezegjen"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"Tárcsázó érintési hangjai"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"Csengőhang"</string>
+ <string name="perm_change_mobile_network">Hálózat módosítása (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">Az ilyen engedéllyel rendelkező alkalmazás, bármikor válthat 2G és 3G közt. A 3G gyorsabb, jobban meríti az akkumulátort, és több pénzbe is kerülhet a nagyobb adatforgalom miatt.</string>
</resources>
View
2  res/values-it/strings.xml
@@ -625,4 +625,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"Vibrazione quando squilla"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"Toni tastierino numerico"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"Suoneria"</string>
+ <string name="perm_change_mobile_network">Cambia rete (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">Un\'applicazione con questo permesso può passare da 2G a 3G e viceversa in qualsiasi momento. Il 3G è più veloce, consuma più batteria e può anche farti spendere di più.</string>
</resources>
View
2  res/values-ja/strings.xml
@@ -621,4 +621,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"着信時のバイブレーション"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"ダイヤルパッドのタッチ操作音"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"着信音"</string>
+ <string name="perm_change_mobile_network">ネットワークを変更(2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">この権限を許可されたアプリケーションは、いつでも2G/3Gデータの切り替えが可能です。3Gは高速ですが、バッテリ消費が増加します。また、キャリアの課金も増加することがあります。</string>
</resources>
View
2  res/values-ko/strings.xml
@@ -621,4 +621,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"전화 수신 시 진동"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"다이얼패드 터치음"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"벨소리"</string>
+ <string name="perm_change_mobile_network">네트워크 바꾸기 (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">이 권한을 가진 어플리케이션은 아무 때나 2G 데이터와 3G 데이터를 선택할 수 있습니다. 3G는 더 빠르지만 배터리를 더 많이 소모하며 요금이 더 많이 나올 수 있습니다.</string>
</resources>
View
2  res/values-nl/strings.xml
@@ -621,4 +621,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"Trillen bij bellen"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"DTMF-tonen kiestoetsen"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"Beltoon"</string>
+ <string name="perm_change_mobile_network">Verander netwerk (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">Applicatie met deze toegang kan op elk moment wisselen tussen 2G en 3G. 3G is sneller, verbruikt meer stroom en kan duurder zijn.</string>
</resources>
View
2  res/values-pl/strings.xml
@@ -621,4 +621,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"Wibracje i dzwonek"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"Dźwięki wybierania numeru"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"Dzwonek"</string>
+ <string name="perm_change_mobile_network">Zmień sieć (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">Aplikacja ma możliwość przełącania się między siecią 2G i 3G. 3G jest szybsze, ale zużywa szybciej baterię.</string>
</resources>
View
2  res/values-pt/strings.xml
@@ -621,4 +621,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"Vibrar quando estiver tocando"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"Tons de toque do teclado numérico"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"Toque"</string>
+ <string name="perm_change_mobile_network">Alternar rede de dados (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">Aplicação com está permissão pode a qualquer momento, alterar entre dados 2G and 3G. 3G é mais rápido, consome mais bateria, e também pode gastar mais seu dinheiro.</string>
</resources>
View
2  res/values-sk/strings.xml
@@ -621,4 +621,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"Vibrovať pri zvonení"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"Zvuky pri dotyku na číselnú klávesnicu"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"Tón zvonenia"</string>
+ <string name="perm_change_mobile_network">Zmeniť sieť (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">Aplikácia s týmito povoleniami môže kedykoľvek zmeniť sieť medzi 2G a 3G. 3G je rýchlejšie, viac využíva batériu, a taktiež Vás môže stáť viac peňazí.</string>
</resources>
View
2  res/values-sv/strings.xml
@@ -627,4 +627,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"Mobilen vibrerar när det ringer"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"Knappljud"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"Ringsignal"</string>
+ <string name="perm_change_mobile_network">Byt nätverk (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">En applikation med denna tillåtelse kan, när som helst, byta mellan 2G data och 3G data. 3G är snabbare, förbrukar mer batteri och kan också kosta dig mer pengar.</string>
</resources>
View
30 res/values-tr/strings.xml
@@ -39,9 +39,9 @@
<string name="audio_mode_earpiece">Mobil cihaz kulaklığı</string>
<string name="audio_mode_wired_headset">Kablolu kulaklık</string>
<string name="audio_mode_bluetooth">Bluetooth</string>
- <string name="wait_prompt_str">"Şu zil sesleri gönderilsin mi?
+ <string name="wait_prompt_str">"Şu zil sesleri gönderilsin mi?
"</string>
- <string name="pause_prompt_str">"Sayı tonları gönderiliyor
+ <string name="pause_prompt_str">"Sayı tonları gönderiliyor
"</string>
<string name="send_button">Gönder</string>
<string name="pause_prompt_yes">Evet</string>
@@ -115,11 +115,11 @@
<string name="disable">Devre Dışı Bırak</string>
<string name="change_num">Güncelle</string>
<string name="vm_changed">Sesli mesaj numarası değiştirildi.</string>
- <string name="vm_change_failed">"Sesli mesaj numarası değiştirilemedi.
+ <string name="vm_change_failed">"Sesli mesaj numarası değiştirilemedi.
Bu sorun devam ederse operatörünüzle bağlantı kurun."</string>
- <string name="fw_change_failed">"Yönlendirme numarası değiştirilemedi.
+ <string name="fw_change_failed">"Yönlendirme numarası değiştirilemedi.
Bu sorun devam ederse operatörünüzle bağlantı kurun."</string>
- <string name="fw_get_in_vm_failed">"Mevcut yönlendirme numarası ayarları alınıp kaydedilemedi.
+ <string name="fw_get_in_vm_failed">"Mevcut yönlendirme numarası ayarları alınıp kaydedilemedi.
Yine de yeni sağlayıcıya geçilsin mi?"</string>
<string name="no_change">Hiçbir değişiklik yapılmadı.</string>
<string name="sum_voicemail_choose_provider">Sesli mesaj hizmetini seç</string>
@@ -165,12 +165,12 @@ Yine de yeni sağlayıcıya geçilsin mi?"</string>
<string name="throttle_time_frame">Veri kullanım dönemi</string>
<string name="throttle_rate">Veri hızı politikası</string>
<string name="throttle_help">Daha fazla bilgi edinin</string>
- <string name="throttle_status_subtext">"%1$s (٪%2$d) / %3$s dönem maksimumu
+ <string name="throttle_status_subtext">"%1$s (٪%2$d) / %3$s dönem maksimumu
Bir sonraki dönem %4$d gün sonra başlıyor (%5$s)"</string>
<string name="throttle_data_usage_subtext">Maksimum dönem %1$s (٪%2$d) / %3$s</string>
- <string name="throttle_data_rate_reduced_subtext">"Maksimum değer %1$s aşıldı
+ <string name="throttle_data_rate_reduced_subtext">"Maksimum değer %1$s aşıldı
Veri hızı %2$d Kb/s'ye düşürüldü"</string>
- <string name="throttle_time_frame_subtext">"Dönemin tamamlanan bölümü:٪ %1$d
+ <string name="throttle_time_frame_subtext">"Dönemin tamamlanan bölümü:٪ %1$d
Bir sonraki dönem %2$d gün sonra başlıyor (%3$s)"</string>
<string name="throttle_rate_subtext">"Veri kullanım sınırı aşılırsa veri hızı %1$d Kb/s'ye düşürülür"</string>
<string name="throttle_help_subtext">Operatörünüzün mobil ağ üzerinden veri kullanımı politikası hakkında daha fazla bilgi edinin</string>
@@ -395,8 +395,8 @@ Bir sonraki dönem %2$d gün sonra başlıyor (%3$s)"</string>
<string name="dtmf_tones_summary">DTMF seslerinin uzunluğunu ayarla</string>
<string name="network_message">Ağ mesajı</string>
<string name="ota_title_activate">Telefonunuzu aktive edin</string>
- <string name="ota_touch_activate">"Telefon hizmetinizin aktive edilmesi için özel bir çağrı yapılması gerekiyor.
-
+ <string name="ota_touch_activate">"Telefon hizmetinizin aktive edilmesi için özel bir çağrı yapılması gerekiyor.
+
“Aktive Et”e bastıktan sonra, telefonunuzun aktive edilmesi için sağlanan talimatları dinleyin."</string>
<string name="ota_skip_activation_dialog_title">Etkinleştirme atlansın mı?</string>
<string name="ota_skip_activation_dialog_message">Etkinleştirmeyi atlarsanız, arama yapamaz veya mobil veri ağlarına bağlanamazsınız (yine de Kablosuz ağlara bağlanabilirsiniz). Telefonunuzu etkinleştirinceye kadar, telefonu her açışınızda ürünü etkinleştirip etkinleştirmeyeceğiniz sorulur.</string>
@@ -409,9 +409,9 @@ Bir sonraki dönem %2$d gün sonra başlıyor (%3$s)"</string>
<string name="ota_progress">Telefonunuz programlanırken lütfen bekleyin.</string>
<string name="ota_failure">Programlama başarısız</string>
<string name="ota_successful">Telefonunuz şimdi aktive edildi. Hizmetin başlaması 15 dakika sürebilir.</string>
- <string name="ota_unsuccessful">"Telefonunuz etkinleştirilemedi.
-Daha iyi çeken bir yer (pencere kenarı veya dış mekan) bulmanız gerekebilir.
-
+ <string name="ota_unsuccessful">"Telefonunuz etkinleştirilemedi.
+Daha iyi çeken bir yer (pencere kenarı veya dış mekan) bulmanız gerekebilir.
+
Tekrar deneyin veya daha fazla seçenek için müşteri hizmetlerini arayın."</string>
<string name="ota_spc_failure">AŞIRI SPC HATASI</string>
<string name="ota_call_end">Geri</string>
@@ -536,8 +536,8 @@ Tekrar deneyin veya daha fazla seçenek için müşteri hizmetlerini arayın."</
<string name="description_target_answer">Yanıtla</string>
<string name="description_target_send_sms">SMS gönder</string>
<string name="description_target_decline">Reddet</string>
- <string name="per_change_mobile_network">Ağ değiştirme (2G/3G)</string>
- <string name="per_change_mobile_network_desc">Bu bağlantı ile herhangi bir zamanda 2G ile 3G arasında geçiş yapabilirsiniz.3G bağlantısı daha hızlı olmasının yanında daha fazla batarya ve ücret tüketimine neden olacaktır.</string>
+ <string name="perm_change_mobile_network">Ağ değiştirme (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">Bu bağlantı ile herhangi bir zamanda 2G ile 3G arasında geçiş yapabilirsiniz.3G bağlantısı daha hızlı olmasının yanında daha fazla batarya ve ücret tüketimine neden olacaktır.</string>
<string name="voicemail_notification_vibrate_when_title">Titreşim</string>
<string name="voicemail_notification_vibarte_when_dialog_title">Titreşim</string>
<string name="voicemail_notification_ringtone_title">Zil sesi</string>
View
2  res/values-uk/strings.xml
@@ -621,4 +621,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"Вібрувати під час дзвінка"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"Звук клавіш"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"Мелодія"</string>
+ <string name="perm_change_mobile_network">Змінення режиму мережі (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">Програма з цими правами може в будь-який момент змінити режим мережі. 3G швидше, але споживає більше енергії, а також може тарифікуватися дорожче.</string>
</resources>
View
2  res/values-zh-rCN/strings.xml
@@ -639,4 +639,6 @@
<string name="noise_suppression_title">噪声抑制</string>
<string name="noise_suppression_summary">抑制通话时的环境噪声</string>
<!-- End Noise suppression -->
+ <string name="perm_change_mobile_network">2G/3G移动网络切换</string>
+ <string name="perm_change_mobile_network_desc">获得该权限的应用程序可以在任何时候在2G/3G移动网络之间切换。使用3G网络存取资料的速度会比较快,但是也会相应消耗比较多的电量并消耗您更多金钱。</string>
</resources>
View
2  res/values-zh-rTW/strings.xml
@@ -625,4 +625,6 @@
<string name="vibrate_on_ring_title" msgid="9197564612065258960">"鈴響時震動"</string>
<string name="dtmf_tone_enable_title" msgid="827601042915852989">"撥號鍵盤觸控音效"</string>
<string name="preference_category_ringtone" msgid="9007490591910078324">"鈴聲"</string>
+ <string name="perm_change_mobile_network">切換行動網路(2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">被授予此權限的應用程式能夠於任何時候在 2G 及 3G 行動網路之間進行切換。使用 3G 行動網路取存資料的速度會比較快,但相對的會消耗較多的電池電量,亦會令您花費較多的金錢。</string>
</resources>
View
3  res/values/strings.xml
@@ -1509,4 +1509,7 @@
<string name="phone_number_label">My phone number</string>
<string name="phone_number_summary">Set the phone number for this device</string>
+
+ <string name="perm_change_mobile_network">Change network (2G/3G)</string>
+ <string name="perm_change_mobile_network_desc">Application with this permission can, at any time, change between 2G data and 3G data. 3G is faster, consumes more battery, and can also cost you more money.</string>
</resources>
View
22 src/com/android/phone/MobileNetworkSettings.java
@@ -173,6 +173,10 @@ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preferen
(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
cm.setMobileDataEnabled(mButtonDataEnabled.isChecked());
+
+ Intent intent = new Intent(PhoneToggler.MOBILE_DATA_CHANGED);
+ intent.putExtra(PhoneToggler.NETWORK_MODE, mButtonDataEnabled.isChecked());
+ mPhone.getContext().sendBroadcast(intent);
return true;
} else if (preference == mLteDataServicePref) {
String tmpl = android.provider.Settings.Secure.getString(getContentResolver(),
@@ -385,6 +389,10 @@ public boolean onPreferenceChange(Preference preference, Object objValue) {
//Set the modem network mode
mPhone.setPreferredNetworkType(modemNetworkMode, mHandler
.obtainMessage(MyHandler.MESSAGE_SET_PREFERRED_NETWORK_TYPE));
+
+ Intent intent = new Intent(PhoneToggler.NETWORK_MODE_CHANGED);
+ intent.putExtra(PhoneToggler.NETWORK_MODE, buttonNetworkMode);
+ mPhone.getContext().sendBroadcast(intent, PhoneToggler.CHANGE_NETWORK_MODE_PERM);
}
}
@@ -431,6 +439,7 @@ private void handleGetPreferredNetworkTypeResponse(Message msg) {
settingsNetworkMode);
}
+ boolean isLteOnCdma = mPhone.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE;
//check that modemNetworkMode is from an accepted value
if (modemNetworkMode == Phone.NT_MODE_WCDMA_PREF ||
modemNetworkMode == Phone.NT_MODE_GSM_ONLY ||
@@ -442,7 +451,10 @@ private void handleGetPreferredNetworkTypeResponse(Message msg) {
modemNetworkMode == Phone.NT_MODE_LTE_CDMA_EVDO ||
modemNetworkMode == Phone.NT_MODE_LTE_CMDA_EVDO_GSM_WCDMA ||
modemNetworkMode == Phone.NT_MODE_LTE_GSM_WCDMA ||
- modemNetworkMode == Phone.NT_MODE_GLOBAL ) {
+ //A modem might report world phone sometimes
+ //but it's not true. Double check here
+ ((getResources().getBoolean(R.bool.world_phone) == true || isLteOnCdma) &&
+ modemNetworkMode == Phone.NT_MODE_GLOBAL) ) {
if (DBG) {
log("handleGetPreferredNetworkTypeResponse: if 1: modemNetworkMode = " +
modemNetworkMode);
@@ -471,6 +483,10 @@ private void handleGetPreferredNetworkTypeResponse(Message msg) {
UpdatePreferredNetworkModeSummary(modemNetworkMode);
// changes the mButtonPreferredNetworkMode accordingly to modemNetworkMode
mButtonPreferredNetworkMode.setValue(Integer.toString(modemNetworkMode));
+
+ Intent intent = new Intent(PhoneToggler.NETWORK_MODE_CHANGED);
+ intent.putExtra(PhoneToggler.NETWORK_MODE, modemNetworkMode);
+ mPhone.getContext().sendBroadcast(intent, PhoneToggler.CHANGE_NETWORK_MODE_PERM);
} else if (modemNetworkMode == Phone.NT_MODE_LTE_ONLY) {
// LTE Only mode not yet supported on UI, but could be used for testing
if (DBG) log("handleGetPreferredNetworkTypeResponse: lte only: no action");
@@ -490,6 +506,10 @@ private void handleSetPreferredNetworkTypeResponse(Message msg) {
android.provider.Settings.Secure.putInt(mPhone.getContext().getContentResolver(),
android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
networkMode );
+
+ Intent intent = new Intent(PhoneToggler.NETWORK_MODE_CHANGED);
+ intent.putExtra(PhoneToggler.NETWORK_MODE, networkMode);
+ mPhone.getContext().sendBroadcast(intent, PhoneToggler.CHANGE_NETWORK_MODE_PERM);
} else {
mPhone.getPreferredNetworkType(obtainMessage(MESSAGE_GET_PREFERRED_NETWORK_TYPE));
}
View
181 src/com/android/phone/PhoneToggler.java
@@ -0,0 +1,181 @@
+package com.android.phone;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.AsyncResult;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+
+import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneFactory;
+
+public class PhoneToggler extends BroadcastReceiver {
+
+ /** Used for brodcasting network data change and receive new mode **/
+ public static final String NETWORK_MODE_CHANGED="com.android.internal.telephony.NETWORK_MODE_CHANGED";
+ public static final String REQUEST_NETWORK_MODE="com.android.internal.telephony.REQUEST_NETWORK_MODE";
+ public static final String MODIFY_NETWORK_MODE="com.android.internal.telephony.MODIFY_NETWORK_MODE";
+ public static final String MOBILE_DATA_CHANGED="com.android.internal.telephony.MOBILE_DATA_CHANGED";
+ public static final String NETWORK_MODE = "networkMode";
+
+ public static final String CHANGE_NETWORK_MODE_PERM= "com.android.phone.CHANGE_NETWORK_MODE";
+ private static final String LOG_TAG = "PhoneToggler";
+ private static final boolean DBG = true;
+
+ private Phone mPhone;
+ private MyHandler mHandler;
+
+
+ private Phone getPhone() {
+ if (mPhone==null) mPhone = PhoneFactory.getDefaultPhone();
+ return mPhone;
+ }
+
+ private MyHandler getHandler() {
+ if (mHandler==null) mHandler = new MyHandler();
+ return mHandler;
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(MODIFY_NETWORK_MODE)) {
+ if (DBG) Log.d(LOG_TAG,"Got modify intent");
+ if (intent.getExtras()!=null) {
+ int networkMode = intent.getExtras().getInt(NETWORK_MODE);
+ boolean networkModeOk = false;
+ int phoneType = getPhone().getPhoneType();
+ boolean isLteOnCdma = getPhone().getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE;
+
+ if (phoneType == Phone.PHONE_TYPE_GSM) {
+ if (networkMode == Phone.NT_MODE_GSM_ONLY
+ || networkMode == Phone.NT_MODE_GSM_UMTS
+ || networkMode == Phone.NT_MODE_WCDMA_PREF
+ || networkMode == Phone.NT_MODE_WCDMA_ONLY) {
+ networkModeOk = true;
+ }
+ } else if (phoneType == Phone.PHONE_TYPE_CDMA) {
+ if (networkMode == Phone.NT_MODE_CDMA
+ || networkMode == Phone.NT_MODE_CDMA_NO_EVDO
+ || networkMode == Phone.NT_MODE_EVDO_NO_CDMA) {
+ networkModeOk = true;
+ }
+ }
+ if (context.getResources().getBoolean(R.bool.world_phone) || isLteOnCdma) {
+ if (networkMode == Phone.NT_MODE_GLOBAL) {
+ networkModeOk = true;
+ }
+ }
+
+ if (networkModeOk) {
+ if (DBG) Log.d(LOG_TAG,"Will modify it to: "+networkMode);
+ changeNetworkMode(networkMode);
+ if (DBG) Log.d(LOG_TAG,"Accepted modification of network mode to : "+networkMode);
+ } else {
+ Log.e(LOG_TAG,"Not accepted network mode: "+networkMode);
+ }
+ }
+ } else if (intent.getAction().equals(REQUEST_NETWORK_MODE)) {
+ if (DBG) Log.d(LOG_TAG,"Sending Intent with current phone network mode");
+ triggerIntent();
+ } else {
+ Log.e(LOG_TAG,"Not accepted intent: "+intent.getAction());
+ }
+ }
+
+ private void changeNetworkMode(int modemNetworkMode) {
+ getPhone().setPreferredNetworkType(modemNetworkMode, getHandler()
+ .obtainMessage(MyHandler.MESSAGE_SET_PREFERRED_NETWORK_TYPE));
+
+ }
+
+ private void triggerIntent() {
+ getPhone().getPreferredNetworkType(getHandler()
+ .obtainMessage(MyHandler.MESSAGE_GET_PREFERRED_NETWORK_TYPE));
+ }
+
+ private class MyHandler extends Handler {
+
+ private static final int MESSAGE_GET_PREFERRED_NETWORK_TYPE = 0;
+ private static final int MESSAGE_SET_PREFERRED_NETWORK_TYPE = 1;
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MESSAGE_GET_PREFERRED_NETWORK_TYPE:
+ handleGetPreferredNetworkTypeResponse(msg);
+ break;
+
+ case MESSAGE_SET_PREFERRED_NETWORK_TYPE:
+ handleSetPreferredNetworkTypeResponse(msg);
+ break;
+ }
+ }
+
+ private void handleGetPreferredNetworkTypeResponse(Message msg) {
+ AsyncResult ar = (AsyncResult) msg.obj;
+
+ if (ar.exception == null) {
+ int modemNetworkMode = ((int[])ar.result)[0];
+ if (DBG) Log.d(LOG_TAG,"handleGetPreferredNetworkTypeResponse: modemNetworkMode = "+modemNetworkMode);
+ int settingsNetworkMode = android.provider.Settings.Secure.getInt(
+ getPhone().getContext().getContentResolver(),
+ android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
+ MobileNetworkSettings.preferredNetworkMode);
+
+ if (DBG) Log.d(LOG_TAG,"handleGetPreferredNetworkTypeReponse: settingsNetworkMode = "+settingsNetworkMode);
+
+ //check that modemNetworkMode is from an accepted value
+ if (modemNetworkMode == Phone.NT_MODE_WCDMA_PREF ||
+ modemNetworkMode == Phone.NT_MODE_GSM_ONLY ||
+ modemNetworkMode == Phone.NT_MODE_WCDMA_ONLY ||
+ modemNetworkMode == Phone.NT_MODE_GSM_UMTS ||
+ modemNetworkMode == Phone.NT_MODE_CDMA ||
+ modemNetworkMode == Phone.NT_MODE_CDMA_NO_EVDO ||
+ modemNetworkMode == Phone.NT_MODE_EVDO_NO_CDMA ||
+ //A modem might report world phone sometimes
+ //but it's not true. Double check here
+ (getPhone().getContext().getResources().getBoolean(R.bool.world_phone) == true &&
+ modemNetworkMode == Phone.NT_MODE_GLOBAL) ) {
+ if (DBG) Log.d(LOG_TAG,"handleGetPreferredNetworkTypeResponse: if 1: modemNetworkMode = "+modemNetworkMode);
+
+ //check changes in modemNetworkMode and updates settingsNetworkMode
+ if (modemNetworkMode != settingsNetworkMode) {
+ if (DBG) Log.d(LOG_TAG,"handleGetPreferredNetworkTypeResponse: if 2: modemNetworkMode != settingsNetworkMode");
+ settingsNetworkMode = modemNetworkMode;
+ if (DBG) Log.d(LOG_TAG,"handleGetPreferredNetworkTypeResponse: if 2: settingsNetworkMode = "+settingsNetworkMode);
+
+ //changes the Settings.System accordingly to modemNetworkMode
+ android.provider.Settings.Secure.putInt(
+ getPhone().getContext().getContentResolver(),
+ android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
+ settingsNetworkMode );
+ }
+ Intent intent = new Intent(NETWORK_MODE_CHANGED);
+ intent.putExtra(NETWORK_MODE, settingsNetworkMode);
+ getPhone().getContext().sendBroadcast(intent,CHANGE_NETWORK_MODE_PERM);
+ } else if (modemNetworkMode == Phone.NT_MODE_LTE_ONLY) {
+ if (DBG) Log.d(LOG_TAG,"handleGetPreferredNetworkTypeResponse: lte only: no action");
+ } else {
+ if (DBG) Log.d(LOG_TAG,"handleGetPreferredNetworkTypeResponse: else: reset to default");
+ resetNetworkModeToDefault();
+ }
+ }
+ }
+
+ private void handleSetPreferredNetworkTypeResponse(Message msg) {
+ //PSAFS - TODO: For now no status is stored, so we will always get the real status from Phone.
+ getPhone().getPreferredNetworkType(obtainMessage(MESSAGE_GET_PREFERRED_NETWORK_TYPE));
+ }
+
+ private void resetNetworkModeToDefault() {
+ android.provider.Settings.Secure.putInt(getPhone().getContext().getContentResolver(),
+ android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
+ MobileNetworkSettings.preferredNetworkMode );
+ //Set the Modem
+ getPhone().setPreferredNetworkType(MobileNetworkSettings.preferredNetworkMode,
+ this.obtainMessage(MyHandler.MESSAGE_SET_PREFERRED_NETWORK_TYPE));
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.