Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote branch 'defy/rewrite' into rewrite

Conflicts:
	res/values-pt/strings.xml
	src/com/motorola/usb/UsbService.java

Change-Id: I55e77b504666ad8d27254022036dcb1f38b70e9a
  • Loading branch information...
commit c149fd0c1b2a563ad76deffcefca74a849dbef04 2 parents 21be3c2 + 6daa6b2
@nadlabak authored
Showing with 1,680 additions and 1,951 deletions.
  1. +3 −3 AndroidManifest.xml
  2. +4 −1 CleanSpec.mk
  3. BIN  bin/Usb.apk
  4. +17 −24 res/values-de/strings.xml
  5. +13 −24 res/values-el/strings.xml
  6. +14 −24 res/values-en-rGB/strings.xml
  7. +13 −24 res/values-es/strings.xml
  8. +15 −24 res/values-fr/strings.xml
  9. +13 −24 res/values-it/strings.xml
  10. +13 −24 res/values-ko/strings.xml
  11. +13 −24 res/values-nl/strings.xml
  12. +13 −24 res/values-pl/strings.xml
  13. +13 −24 res/values-pt-rPT/strings.xml
  14. +0 −11 res/values-pt/strings.xml
  15. +13 −24 res/values-ru/strings.xml
  16. +13 −0 res/values-sv/strings.xml
  17. +13 −24 res/values-tr/strings.xml
  18. +1 −12 res/values-zh-rCN/strings.xml
  19. +13 −24 res/values-zh-rTW/strings.xml
  20. +43 −0 res/values/config.xml
  21. +17 −24 res/values/strings.xml
  22. +42 −47 src/com/motorola/usb/UsbErrorActivity.java
  23. +181 −162 src/com/motorola/usb/UsbListener.java
  24. +103 −225 src/com/motorola/usb/UsbModeSelectionActivity.java
  25. +13 −13 src/com/motorola/usb/UsbReceiver.java
  26. +1,022 −1,141 src/com/motorola/usb/UsbService.java
  27. +62 −0 src/com/motorola/usb/UsbSettings.java
View
6 AndroidManifest.xml
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.motorola.usb">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.motorola.usb">
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
- <uses-permission android:name="com.motorola.android.permission.MOT_USB" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+<!--<uses-permission android:name="com.motorola.android.permission.MOT_USB" />-->
<application android:label="usb" android:persistent="true">
<activity android:theme="@style/UsbDialog" android:name="UsbModeSelectionActivity" android:excludeFromRecents="true" />
<activity android:theme="@style/UsbDialog" android:name="UsbErrorActivity" />
View
5 CleanSpec.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 The Android Open Source Project
+# Copyright (C) 2011 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -44,6 +44,9 @@
#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Usb_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/Usb_intermediates)
+
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
View
BIN  bin/Usb.apk
Binary file not shown
View
41 res/values-de/strings.xml
@@ -1,24 +1,17 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">OK</string>
- <string name="usb_cancel">Abbrechen</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">Verbindung für</string>
- <string name="usb_toast_phone_data_disabled">Telefondaten wird deaktiviert.</string>
- <string name="usb_no_memory_card_notification_title">Keine Speicherkarte vorhanden.</string>
- <string name="usb_no_memory_card_notification_message_title">Fehlende Speicherkarte</string>
- <string name="usb_no_memory_card_notification_message">Legen Sie eine Speicherkarte ein.</string>
- <string name="usb_selection_notification_title">USB-Verbindung</string>
- <string name="usb_selection_notification_message">Auswählen zum Verwalten Ihrer USB-Verbindung</string>
- <string name="usb_selection_notification_message_for_modem">Für Details und zum Trennen der Verbindung berühren</string>
- <string name="usb_connection">USB-Verbindung</string>
- <string name="usb_mode_ngp">Portal &amp; Tools</string>
- <string name="usb_mode_mtp">Synchronisierung von Windows Media</string>
- <string name="usb_mode_msc">Speicherkarten-Zugriff</string>
- <string name="usb_mode_modem">Telefon als Modem</string>
- <string name="usb_mode_none">Nur Laden</string>
- <string name="usb_toast_insert_card">Legen Sie eine Speicherkarte für Ihre Medien ein.</string>
- <string name="usb_progress_message">Wechseln zu</string>
- <string name="usb_error_message">Die USB-Verbindung kann nicht geändert werden zu</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_connecting">USB als \'%s\' verbunden.</string>
+ <string name="usb_toast_phone_data_disabled">Telefondaten werden deaktiviert.</string>
+ <string name="usb_selection_notification_title">USB-Verbindung</string>
+ <string name="usb_selection_notification_message">Auswählen zum Verwalten Ihrer USB-Verbindung</string>
+ <string name="usb_selection_notification_message_for_modem">Für Details und zum Trennen der Verbindung berühren</string>
+ <string name="usb_tethered_message">Die USB-Verbindung kann nicht geändert werden, während USB-Tethering aktiv ist.</string>
+ <string name="usb_connection">USB-Verbindung</string>
+ <string name="usb_mode_ngp">Portal &amp; Tools</string>
+ <string name="usb_mode_mtp">Synchronisierung von Windows Media</string>
+ <string name="usb_mode_msc">Speicherkarten-Zugriff</string>
+ <string name="usb_mode_rndis">USB-Tethering</string>
+ <string name="usb_mode_modem">Telefon als Modem</string>
+ <string name="usb_mode_none">Nur Laden</string>
+ <string name="usb_error_message">Die USB-Verbindung kann nicht zu \'%s\' geändert werden.</string>
+</resources>
View
37 res/values-el/strings.xml
@@ -1,24 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">OK</string>
- <string name="usb_cancel">Άκυρο</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">Σύνδεση για</string>
- <string name="usb_toast_phone_data_disabled">Τα δεδομένα του τηλεφώνου θα απενεργοποιηθούν.</string>
- <string name="usb_no_memory_card_notification_title">Δεν έχετε εισαγάγει κάρτα μνήμης</string>
- <string name="usb_no_memory_card_notification_message_title">Η κάρτα μνήμης λείπει</string>
- <string name="usb_no_memory_card_notification_message">Εισαγάγετε κάρτα μνήμης</string>
- <string name="usb_selection_notification_title">Σύνδεση USB</string>
- <string name="usb_selection_notification_message">Επιλέξτε το για να διαχειρίζεστε τη σύνδεση USB</string>
- <string name="usb_selection_notification_message_for_modem">Πατήστε το για να αποσυνδέσετε και να ενεργοποιήσετε ξανά τα εσωτερικά δεδομένα του τηλεφώνου</string>
- <string name="usb_connection">Σύνδεση USB</string>
- <string name="usb_mode_ngp">Πύλη και εργαλεία</string>
- <string name="usb_mode_mtp">Συγχρονισμός πολυμέσων των Windows</string>
- <string name="usb_mode_msc">Πρόσβαση στην κάρτας μνήμης</string>
- <string name="usb_mode_modem">Τηλέφωνο ως μόντεμ</string>
- <string name="usb_mode_none">Μόνο φόρτιση</string>
- <string name="usb_toast_insert_card">Εισαγάγετε κάρτα μνήμης για τα μέσα σας.</string>
- <string name="usb_progress_message">Αλλαγή σε</string>
- <string name="usb_error_message">Η σύνδεση USB δεν μπορεί να αλλάξει σε</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_phone_data_disabled">Τα δεδομένα του τηλεφώνου θα απενεργοποιηθούν.</string>
+ <string name="usb_selection_notification_title">Σύνδεση USB</string>
+ <string name="usb_selection_notification_message">Επιλέξτε το για να διαχειρίζεστε τη σύνδεση USB</string>
+ <string name="usb_selection_notification_message_for_modem">Πατήστε το για να αποσυνδέσετε και να ενεργοποιήσετε ξανά τα εσωτερικά δεδομένα του τηλεφώνου</string>
+ <string name="usb_connection">Σύνδεση USB</string>
+ <string name="usb_mode_ngp">Πύλη και εργαλεία</string>
+ <string name="usb_mode_mtp">Συγχρονισμός πολυμέσων των Windows</string>
+ <string name="usb_mode_msc">Πρόσβαση στην κάρτας μνήμης</string>
+ <string name="usb_mode_modem">Τηλέφωνο ως μόντεμ</string>
+ <string name="usb_mode_none">Μόνο φόρτιση</string>
+</resources>
View
38 res/values-en-rGB/strings.xml
@@ -1,24 +1,14 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">OK</string>
- <string name="usb_cancel">Cancel</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">Connecting for</string>
- <string name="usb_toast_phone_data_disabled">Phone data will be disabled.</string>
- <string name="usb_no_memory_card_notification_title">No memory card inserted</string>
- <string name="usb_no_memory_card_notification_message_title">Missing memory card</string>
- <string name="usb_no_memory_card_notification_message">Please insert memory card</string>
- <string name="usb_selection_notification_title">USB connection</string>
- <string name="usb_selection_notification_message">Select to manage your USB connection</string>
- <string name="usb_selection_notification_message_for_modem">Touch for details and to disconnect</string>
- <string name="usb_connection">USB connection</string>
- <string name="usb_mode_ngp">Portal &amp; tools</string>
- <string name="usb_mode_mtp">Windows media sync</string>
- <string name="usb_mode_msc">Memory card access</string>
- <string name="usb_mode_modem">Phone as modem</string>
- <string name="usb_mode_none">Charge only</string>
- <string name="usb_toast_insert_card">Please insert a memory card for your media.</string>
- <string name="usb_progress_message">Switching to</string>
- <string name="usb_error_message">The USB connection cannot change to</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_connecting">USB connected as %s.</string>
+ <string name="usb_toast_phone_data_disabled">Phone data will be disabled.</string>
+ <string name="usb_selection_notification_title">USB connection</string>
+ <string name="usb_selection_notification_message">Select to manage your USB connection</string>
+ <string name="usb_selection_notification_message_for_modem">Touch for details and to disconnect</string>
+ <string name="usb_connection">USB connection</string>
+ <string name="usb_mode_ngp">Portal &amp; tools</string>
+ <string name="usb_mode_mtp">Windows media sync</string>
+ <string name="usb_mode_msc">Memory card access</string>
+ <string name="usb_mode_modem">Phone as modem</string>
+ <string name="usb_mode_none">Charge only</string>
+</resources>
View
37 res/values-es/strings.xml
@@ -1,24 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">Aceptar</string>
- <string name="usb_cancel">Cancelar</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">Conectando para</string>
- <string name="usb_toast_phone_data_disabled">Los datos del teléfono se deshabilitarán.</string>
- <string name="usb_no_memory_card_notification_title">No se ha insertado ninguna tarjeta de memoria.</string>
- <string name="usb_no_memory_card_notification_message_title">Se ha perdido la tarjeta de memoria.</string>
- <string name="usb_no_memory_card_notification_message">Inserte la tarjeta de memoria</string>
- <string name="usb_selection_notification_title">Conexión USB</string>
- <string name="usb_selection_notification_message">Seleccionar para administrar la conexión USB</string>
- <string name="usb_selection_notification_message_for_modem">Toca para obtener más información y desconectar</string>
- <string name="usb_connection">Conexión USB</string>
- <string name="usb_mode_ngp">Portal y herramientas</string>
- <string name="usb_mode_mtp">Sincronización de Windows Media</string>
- <string name="usb_mode_msc">Acceso a tarjeta de memoria</string>
- <string name="usb_mode_modem">Teléfono como módem</string>
- <string name="usb_mode_none">Solo carga</string>
- <string name="usb_toast_insert_card">Introduce una tarjeta de memoria para los archivos multimedia.</string>
- <string name="usb_progress_message">Cambiando a</string>
- <string name="usb_error_message">La conexión USB no se puede cambiar a</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_phone_data_disabled">Los datos del teléfono se deshabilitarán.</string>
+ <string name="usb_selection_notification_title">Conexión USB</string>
+ <string name="usb_selection_notification_message">Seleccionar para administrar la conexión USB</string>
+ <string name="usb_selection_notification_message_for_modem">Toca para obtener más información y desconectar</string>
+ <string name="usb_connection">Conexión USB</string>
+ <string name="usb_mode_ngp">Portal y herramientas</string>
+ <string name="usb_mode_mtp">Sincronización de Windows Media</string>
+ <string name="usb_mode_msc">Acceso a tarjeta de memoria</string>
+ <string name="usb_mode_modem">Teléfono como módem</string>
+ <string name="usb_mode_none">Solo carga</string>
+</resources>
View
39 res/values-fr/strings.xml
@@ -1,24 +1,15 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">OK</string>
- <string name="usb_cancel">Annuler</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">Connexion pour</string>
- <string name="usb_toast_phone_data_disabled">Les données du téléphone vont être désactivées.</string>
- <string name="usb_no_memory_card_notification_title">Aucune carte mémoire insérée</string>
- <string name="usb_no_memory_card_notification_message_title">Carte mémoire manquante</string>
- <string name="usb_no_memory_card_notification_message">Insérez une carte mémoire</string>
- <string name="usb_selection_notification_title">Connexion USB</string>
- <string name="usb_selection_notification_message">Sélectionner pour gérer votre connexion USB</string>
- <string name="usb_selection_notification_message_for_modem">Touchez pour obtenir plus de détails et vous déconnecter</string>
- <string name="usb_connection">Connexion USB</string>
- <string name="usb_mode_ngp">Portail &amp; outils</string>
- <string name="usb_mode_mtp">Synchronisation Windows Media</string>
- <string name="usb_mode_msc">Accès à la carte mémoire</string>
- <string name="usb_mode_modem">Téléphone en tant que modem</string>
- <string name="usb_mode_none">Chargement uniquement</string>
- <string name="usb_toast_insert_card">Veuillez insérer une carte mémoire où stocker vos médias.</string>
- <string name="usb_progress_message">Passage à</string>
- <string name="usb_error_message">La connexion USB ne peut pas passer à</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_connecting">Connexion USB : %s</string>
+ <string name="usb_toast_phone_data_disabled">Les données du téléphone vont être désactivées.</string>
+ <string name="usb_selection_notification_title">Connexion USB</string>
+ <string name="usb_selection_notification_message">Sélectionner pour gérer votre connexion USB</string>
+ <string name="usb_selection_notification_message_for_modem">Touchez pour obtenir plus de détails et vous déconnecter</string>
+ <string name="usb_connection">Connexion USB</string>
+ <string name="usb_mode_ngp">Portail &amp; outils</string>
+ <string name="usb_mode_mtp">Synchronisation Windows Media</string>
+ <string name="usb_mode_msc">Accès à la carte mémoire</string>
+ <string name="usb_mode_rndis">Réseau USB</string>
+ <string name="usb_mode_modem">Téléphone en tant que modem</string>
+ <string name="usb_mode_none">Chargement uniquement</string>
+</resources>
View
37 res/values-it/strings.xml
@@ -1,24 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">OK</string>
- <string name="usb_cancel">Annulla</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">Connessione per</string>
- <string name="usb_toast_phone_data_disabled">I dati del telefono verranno disattivati.</string>
- <string name="usb_no_memory_card_notification_title">Nessuna scheda di memoria inserita</string>
- <string name="usb_no_memory_card_notification_message_title">Scheda di memoria mancante</string>
- <string name="usb_no_memory_card_notification_message">Inserisci scheda di memoria</string>
- <string name="usb_selection_notification_title">Connessione USB</string>
- <string name="usb_selection_notification_message">Seleziona per gestire connessione USB</string>
- <string name="usb_selection_notification_message_for_modem">Tocca per dettagli e per disconnettere</string>
- <string name="usb_connection">Connessione USB</string>
- <string name="usb_mode_ngp">Portale e strumenti</string>
- <string name="usb_mode_mtp">Sincronizzazione supporti Windows</string>
- <string name="usb_mode_msc">Accesso scheda di memoria</string>
- <string name="usb_mode_modem">Telefono come modem</string>
- <string name="usb_mode_none">Solo ricarica</string>
- <string name="usb_toast_insert_card">Inserisci la scheda di memoria e ricollega il cavo USB.</string>
- <string name="usb_progress_message">Passaggio a</string>
- <string name="usb_error_message">Impossibile modificare la connessione USB in</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_phone_data_disabled">I dati del telefono verranno disattivati.</string>
+ <string name="usb_selection_notification_title">Connessione USB</string>
+ <string name="usb_selection_notification_message">Seleziona per gestire connessione USB</string>
+ <string name="usb_selection_notification_message_for_modem">Tocca per dettagli e per disconnettere</string>
+ <string name="usb_connection">Connessione USB</string>
+ <string name="usb_mode_ngp">Portale e strumenti</string>
+ <string name="usb_mode_mtp">Sincronizzazione supporti Windows</string>
+ <string name="usb_mode_msc">Accesso scheda di memoria</string>
+ <string name="usb_mode_modem">Telefono come modem</string>
+ <string name="usb_mode_none">Solo ricarica</string>
+</resources>
View
37 res/values-ko/strings.xml
@@ -1,24 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">확인</string>
- <string name="usb_cancel">취소</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">USB 연결중</string>
- <string name="usb_toast_phone_data_disabled">휴대전화 데이터를 사용할 수 없게 됩니다.</string>
- <string name="usb_no_memory_card_notification_title">외장 메모리가 삽입되지 않았습니다</string>
- <string name="usb_no_memory_card_notification_message_title">외장 메모리 없음</string>
- <string name="usb_no_memory_card_notification_message">외장 메모리가 삽입해주십시오.</string>
- <string name="usb_selection_notification_title">USB 연결</string>
- <string name="usb_selection_notification_message">데이터 동기화\u0020</string>
- <string name="usb_selection_notification_message_for_modem">연결을 끊고 휴대전화 내부 데이터를 사용가능하게하시려면 탭하십시오</string>
- <string name="usb_connection">USB 연결</string>
- <string name="usb_mode_ngp">모토로라 휴대전화 도구</string>
- <string name="usb_mode_mtp">윈도우 미디어 동기화</string>
- <string name="usb_mode_msc">외장 메모리 관리</string>
- <string name="usb_mode_modem">모뎀으로 사용</string>
- <string name="usb_mode_none">없음</string>
- <string name="usb_toast_insert_card">미디어 외장 메모리를 삽입해주십시오.</string>
- <string name="usb_progress_message">로 변경</string>
- <string name="usb_error_message">USB 연결이 다음으로 변경될 수 없습니다\u0020</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_phone_data_disabled">휴대전화 데이터를 사용할 수 없게 됩니다.</string>
+ <string name="usb_selection_notification_title">USB 연결</string>
+ <string name="usb_selection_notification_message">데이터 동기화\u0020</string>
+ <string name="usb_selection_notification_message_for_modem">연결을 끊고 휴대전화 내부 데이터를 사용가능하게하시려면 탭하십시오</string>
+ <string name="usb_connection">USB 연결</string>
+ <string name="usb_mode_ngp">모토로라 휴대전화 도구</string>
+ <string name="usb_mode_mtp">윈도우 미디어 동기화</string>
+ <string name="usb_mode_msc">외장 메모리 관리</string>
+ <string name="usb_mode_modem">모뎀으로 사용</string>
+ <string name="usb_mode_none">없음</string>
+</resources>
View
37 res/values-nl/strings.xml
@@ -1,24 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">OK</string>
- <string name="usb_cancel">Annuleren</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">Verbinden voor</string>
- <string name="usb_toast_phone_data_disabled">Telefoongegevens worden uitgeschakeld.</string>
- <string name="usb_no_memory_card_notification_title">Geen geheugenkaart geplaatst</string>
- <string name="usb_no_memory_card_notification_message_title">Geheugenkaart ontbreekt</string>
- <string name="usb_no_memory_card_notification_message">Plaats een geheugenkaart</string>
- <string name="usb_selection_notification_title">USB-verbinding</string>
- <string name="usb_selection_notification_message">Selecteer dit om uw USB-verbinding te beheren</string>
- <string name="usb_selection_notification_message_for_modem">Raak aan om de verbinding te verbreken en de interne telefoongegevens opnieuw in te schakelen</string>
- <string name="usb_connection">USB-verbinding</string>
- <string name="usb_mode_ngp">Portal en hulpprogramma\'s</string>
- <string name="usb_mode_mtp">Windows Media Sync</string>
- <string name="usb_mode_msc">De geheugenkaart openen</string>
- <string name="usb_mode_modem">Telefoon als modem</string>
- <string name="usb_mode_none">Alleen opladen</string>
- <string name="usb_toast_insert_card">Plaats een geheugenkaart voor uw media.</string>
- <string name="usb_progress_message">Overschakelen op</string>
- <string name="usb_error_message">De USB-verbinding kan niet overschakelen op</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_phone_data_disabled">Telefoongegevens worden uitgeschakeld.</string>
+ <string name="usb_selection_notification_title">USB-verbinding</string>
+ <string name="usb_selection_notification_message">Selecteer dit om uw USB-verbinding te beheren</string>
+ <string name="usb_selection_notification_message_for_modem">Raak aan om de verbinding te verbreken en de interne telefoongegevens opnieuw in te schakelen</string>
+ <string name="usb_connection">USB-verbinding</string>
+ <string name="usb_mode_ngp">Portal en hulpprogramma\'s</string>
+ <string name="usb_mode_mtp">Windows Media Sync</string>
+ <string name="usb_mode_msc">De geheugenkaart openen</string>
+ <string name="usb_mode_modem">Telefoon als modem</string>
+ <string name="usb_mode_none">Alleen opladen</string>
+</resources>
View
37 res/values-pl/strings.xml
@@ -1,24 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">OK</string>
- <string name="usb_cancel">Anuluj</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">Podłączanie:</string>
- <string name="usb_toast_phone_data_disabled">Dane telefonu zostaną wyłączone.</string>
- <string name="usb_no_memory_card_notification_title">Nie włożono karty pamięci</string>
- <string name="usb_no_memory_card_notification_message_title">Brak karty pamięci</string>
- <string name="usb_no_memory_card_notification_message">Włóż kartę pamięci</string>
- <string name="usb_selection_notification_title">Połączenie USB</string>
- <string name="usb_selection_notification_message">Wybierz, aby zarządzać połączeniem USB.</string>
- <string name="usb_selection_notification_message_for_modem">Dotknij, aby rozłączyć i ponownie włączyć wewnętrzne dane telefonu</string>
- <string name="usb_connection">Połączenie USB</string>
- <string name="usb_mode_ngp">Portal i narzędzia</string>
- <string name="usb_mode_mtp">Windows Media Sync</string>
- <string name="usb_mode_msc">Dostęp do karty pamięci</string>
- <string name="usb_mode_modem">Telefon jako modem</string>
- <string name="usb_mode_none">Tylko ładowanie</string>
- <string name="usb_toast_insert_card">Włóż kartę pamięci na multimedia.</string>
- <string name="usb_progress_message">Przełączanie na</string>
- <string name="usb_error_message">Połączenia USB nie można zmienić na</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_phone_data_disabled">Dane telefonu zostaną wyłączone.</string>
+ <string name="usb_selection_notification_title">Połączenie USB</string>
+ <string name="usb_selection_notification_message">Wybierz, aby zarządzać połączeniem USB.</string>
+ <string name="usb_selection_notification_message_for_modem">Dotknij, aby rozłączyć i ponownie włączyć wewnętrzne dane telefonu</string>
+ <string name="usb_connection">Połączenie USB</string>
+ <string name="usb_mode_ngp">Portal i narzędzia</string>
+ <string name="usb_mode_mtp">Windows Media Sync</string>
+ <string name="usb_mode_msc">Dostęp do karty pamięci</string>
+ <string name="usb_mode_modem">Telefon jako modem</string>
+ <string name="usb_mode_none">Tylko ładowanie</string>
+</resources>
View
37 res/values-pt-rPT/strings.xml
@@ -1,24 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">OK</string>
- <string name="usb_cancel">Cancelar</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">A ligar para</string>
- <string name="usb_toast_phone_data_disabled">Dados do telefone serão desactivados.</string>
- <string name="usb_no_memory_card_notification_title">Nenhum cartão de memória inserido</string>
- <string name="usb_no_memory_card_notification_message_title">Falta cartão de memória</string>
- <string name="usb_no_memory_card_notification_message">Insira um cartão de memória</string>
- <string name="usb_selection_notification_title">Ligação USB</string>
- <string name="usb_selection_notification_message">Seleccionar para gerir a ligação USB</string>
- <string name="usb_selection_notification_message_for_modem">Toque para desligar e reactivar os dados internos de telefone</string>
- <string name="usb_connection">Ligação USB</string>
- <string name="usb_mode_ngp">Portal e ferramentas</string>
- <string name="usb_mode_mtp">Windows Media Sync</string>
- <string name="usb_mode_msc">Acesso a cartão de memória</string>
- <string name="usb_mode_modem">Telefone como Modem</string>
- <string name="usb_mode_none">Carregar apenas</string>
- <string name="usb_toast_insert_card">Insira um cartão de memória para suporte de armazenamento.</string>
- <string name="usb_progress_message">A mudar para</string>
- <string name="usb_error_message">A ligação USB não pode mudar para</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_phone_data_disabled">Dados do telefone serão desactivados.</string>
+ <string name="usb_selection_notification_title">Ligação USB</string>
+ <string name="usb_selection_notification_message">Seleccionar para gerir a ligação USB</string>
+ <string name="usb_selection_notification_message_for_modem">Toque para desligar e reactivar os dados internos de telefone</string>
+ <string name="usb_connection">Ligação USB</string>
+ <string name="usb_mode_ngp">Portal e ferramentas</string>
+ <string name="usb_mode_mtp">Windows Media Sync</string>
+ <string name="usb_mode_msc">Acesso a cartão de memória</string>
+ <string name="usb_mode_modem">Telefone como Modem</string>
+ <string name="usb_mode_none">Carregar apenas</string>
+</resources>
View
11 res/values-pt/strings.xml
@@ -1,14 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">OK</string>
- <string name="usb_cancel">Cancelar</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">Conectando para</string>
<string name="usb_toast_phone_data_disabled">Conexão de dados do telefone será desabilitado.</string>
- <string name="usb_no_memory_card_notification_title">Nenhum cartão de memória está inserido</string>
- <string name="usb_no_memory_card_notification_message_title">Faltando Cartão de Memória</string>
- <string name="usb_no_memory_card_notification_message">Por favor, insira um cartão de memória</string>
<string name="usb_selection_notification_title">Conexão USB</string>
<string name="usb_selection_notification_message">Selecione para gerenciar sua conexão USB</string>
<string name="usb_selection_notification_message_for_modem">Toque para desconectar e reativar conexão de dados interna do telefone</string>
@@ -18,7 +10,4 @@
<string name="usb_mode_msc">Acesso ao Cartão de Memória</string>
<string name="usb_mode_modem">Telefone como Modem</string>
<string name="usb_mode_none">Somente Carregar</string>
- <string name="usb_toast_insert_card">Por favor, inserir um cartão de memória para acessar a sua mídia.</string>
- <string name="usb_progress_message">Mudando para</string>
- <string name="usb_error_message">A conexão USB não pode ser mudada para</string>
</resources>
View
37 res/values-ru/strings.xml
@@ -1,24 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">ОК</string>
- <string name="usb_cancel">Отмена</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">Поключение USB в режиме</string>
- <string name="usb_toast_phone_data_disabled">Данные телефона отключены.</string>
- <string name="usb_no_memory_card_notification_title">Карта памяти не установлена</string>
- <string name="usb_no_memory_card_notification_message_title">Отсутствует карта памяти</string>
- <string name="usb_no_memory_card_notification_message">Установите карту памяти</string>
- <string name="usb_selection_notification_title">USB-подключение</string>
- <string name="usb_selection_notification_message">Выберите для управления подключением USB</string>
- <string name="usb_selection_notification_message_for_modem">Косн. для откл. и открытия внутр. данных телефона</string>
- <string name="usb_connection">USB подключение</string>
- <string name="usb_mode_ngp">Портал телефона</string>
- <string name="usb_mode_mtp">Синхронизация Windows Media</string>
- <string name="usb_mode_msc">Доступ к карте памяти</string>
- <string name="usb_mode_modem">Телефон как модем</string>
- <string name="usb_mode_none">Зарядка</string>
- <string name="usb_toast_insert_card">Вставьте карту памяти для медиа.</string>
- <string name="usb_progress_message">Перекл. на</string>
- <string name="usb_error_message">USB-подключение невозм. изменить на</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_phone_data_disabled">Данные телефона отключены.</string>
+ <string name="usb_selection_notification_title">USB-подключение</string>
+ <string name="usb_selection_notification_message">Выберите для управления подключением USB</string>
+ <string name="usb_selection_notification_message_for_modem">Косн. для откл. и открытия внутр. данных телефона</string>
+ <string name="usb_connection">USB подключение</string>
+ <string name="usb_mode_ngp">Портал телефона</string>
+ <string name="usb_mode_mtp">Синхронизация Windows Media</string>
+ <string name="usb_mode_msc">Доступ к карте памяти</string>
+ <string name="usb_mode_modem">Телефон как модем</string>
+ <string name="usb_mode_none">Зарядка</string>
+</resources>
View
13 res/values-sv/strings.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_phone_data_disabled">Telefonens interna datalagring kommer att inaktiveras.</string>
+ <string name="usb_selection_notification_title">USB-anslutning</string>
+ <string name="usb_selection_notification_message">Välj för att hantera USB-anslutning</string>
+ <string name="usb_selection_notification_message_for_modem">Tryck för att koppla från och återaktivera telefonens interna datalagring</string>
+ <string name="usb_connection">USB-anslutning</string>
+ <string name="usb_mode_ngp">Portal &amp; Verktyg</string>
+ <string name="usb_mode_mtp">Windows Mediasynk</string>
+ <string name="usb_mode_msc">Minneskortsåtkomst</string>
+ <string name="usb_mode_modem">Telefon som Modem</string>
+ <string name="usb_mode_none">Endast Laddning</string>
+</resources>
View
37 res/values-tr/strings.xml
@@ -1,24 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">Tamam</string>
- <string name="usb_cancel">İptal</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">Bağlanılıyor</string>
- <string name="usb_toast_phone_data_disabled">Telefondaki veriler devre dışı bırakılacak.</string>
- <string name="usb_no_memory_card_notification_title">Hafıza kartı takılı değil</string>
- <string name="usb_no_memory_card_notification_message_title">Hafıza Kartı Yok</string>
- <string name="usb_no_memory_card_notification_message">Lütfen hafıza kartını takın</string>
- <string name="usb_selection_notification_title">USB bağlantısı</string>
- <string name="usb_selection_notification_message">USB bağlantınızı yönetmek için seçin</string>
- <string name="usb_selection_notification_message_for_modem">Bağlantıyı kesip dahili telefon verilerini yeniden etkinleştirmek için dokunun</string>
- <string name="usb_connection">USB bağlantısı</string>
- <string name="usb_mode_ngp">Portal ve Araçlar</string>
- <string name="usb_mode_mtp">Windows Media Sync</string>
- <string name="usb_mode_msc">Hafıza Kartı Erişimi</string>
- <string name="usb_mode_modem">Telefonu Modem Olarak Kullan</string>
- <string name="usb_mode_none">Yalnızca Şarj Et</string>
- <string name="usb_toast_insert_card">Lütfen medyanız için bir hafıza kartı takın.</string>
- <string name="usb_progress_message">Geçiş yap:</string>
- <string name="usb_error_message">USB bağlantısı değiştirilemiyor:</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_phone_data_disabled">Telefondaki veriler devre dışı bırakılacak.</string>
+ <string name="usb_selection_notification_title">USB bağlantısı</string>
+ <string name="usb_selection_notification_message">USB bağlantınızı yönetmek için seçin</string>
+ <string name="usb_selection_notification_message_for_modem">Bağlantıyı kesip dahili telefon verilerini yeniden etkinleştirmek için dokunun</string>
+ <string name="usb_connection">USB bağlantısı</string>
+ <string name="usb_mode_ngp">Portal ve Araçlar</string>
+ <string name="usb_mode_mtp">Windows Media Sync</string>
+ <string name="usb_mode_msc">Hafıza Kartı Erişimi</string>
+ <string name="usb_mode_modem">Telefonu Modem Olarak Kullan</string>
+ <string name="usb_mode_none">Yalnızca Şarj Et</string>
+</resources>
View
13 res/values-zh-rCN/strings.xml
@@ -1,14 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">确定</string>
- <string name="usb_cancel">取消</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">正在连接USB为</string>
<string name="usb_toast_phone_data_disabled">手机数据将被禁用.</string>
- <string name="usb_no_memory_card_notification_title">未插入内存卡</string>
- <string name="usb_no_memory_card_notification_message_title">无内存卡</string>
- <string name="usb_no_memory_card_notification_message">请插入内存卡</string>
<string name="usb_selection_notification_title">USB连接</string>
<string name="usb_selection_notification_message">选择在计算机上管理媒体和数据同步</string>
<string name="usb_selection_notification_message_for_modem">点按断开连接后重新启用内部手机数据</string>
@@ -18,7 +10,4 @@
<string name="usb_mode_msc">USB大容量存储</string>
<string name="usb_mode_modem">将手机用作调制解调器</string>
<string name="usb_mode_none">无</string>
- <string name="usb_toast_insert_card">请插入内存卡,以便使用媒体功能.</string>
- <string name="usb_progress_message">正在切换至</string>
- <string name="usb_error_message">USB连接无法更改为</string>
-</resources>
+</resources>
View
37 res/values-zh-rTW/strings.xml
@@ -1,24 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">確定</string>
- <string name="usb_cancel">取消</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">連接以便</string>
- <string name="usb_toast_phone_data_disabled">將停用手機資料。</string>
- <string name="usb_no_memory_card_notification_title">未插入記憶卡</string>
- <string name="usb_no_memory_card_notification_message_title">記憶卡遺失</string>
- <string name="usb_no_memory_card_notification_message">請插入記憶卡</string>
- <string name="usb_selection_notification_title">USB 連線</string>
- <string name="usb_selection_notification_message">選取以管理 USB 連線</string>
- <string name="usb_selection_notification_message_for_modem">輕觸即可中斷連線並重新啟用內部手機資料</string>
- <string name="usb_connection">USB 連線</string>
- <string name="usb_mode_ngp">入口網站與工具</string>
- <string name="usb_mode_mtp">Windows Media Sync</string>
- <string name="usb_mode_msc">記憶卡存取</string>
- <string name="usb_mode_modem">將手機當數據機</string>
- <string name="usb_mode_none">不要掛載</string>
- <string name="usb_toast_insert_card">請插入包含媒體的記憶卡。</string>
- <string name="usb_progress_message">正在切換至</string>
- <string name="usb_error_message">USB 連線無法變更為</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_phone_data_disabled">將停用手機資料。</string>
+ <string name="usb_selection_notification_title">USB 連線</string>
+ <string name="usb_selection_notification_message">選取以管理 USB 連線</string>
+ <string name="usb_selection_notification_message_for_modem">輕觸即可中斷連線並重新啟用內部手機資料</string>
+ <string name="usb_connection">USB 連線</string>
+ <string name="usb_mode_ngp">入口網站與工具</string>
+ <string name="usb_mode_mtp">Windows Media Sync</string>
+ <string name="usb_mode_msc">記憶卡存取</string>
+ <string name="usb_mode_modem">將手機當數據機</string>
+ <string name="usb_mode_none">不要掛載</string>
+</resources>
View
43 res/values/config.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string-array name="usb_mode_entries" translatable="false">
+ <item>@string/usb_mode_ngp</item>
+ <item>@string/usb_mode_msc</item>
+ <item>@string/usb_mode_none</item>
+ </string-array>
+
+ <!-- Those values must match up with the mode constants in UsbService.java! -->
+ <integer-array name="usb_mode_values" translatable="false">
+ <item>0</item>
+ <item>2</item>
+ <item>5</item>
+ </integer-array>
+
+ <!-- Allow overriding the mode strings for certain modes. Format:
+ - usb_mode_override_values contains the overridden mode numbers
+ - usb_mode_override_modes contains the mode strings
+ - usb_mode_override_adb_modes contains the mode strings for ADB mode -->
+ <integer-array name="usb_mode_override_values">
+ <!-- example: <item>5</item> -->
+ </integer-array>
+
+ <string-array name="usb_mode_override_modes">
+ <!-- example: <item>usb_mode_msc</item> -->
+ </string-array>
+
+ <string-array name="usb_mode_override_adb_modes">
+ <!-- example: <item>usb_mode_msc_adb</item> -->
+ </string-array>
+
+ <!-- Default mode USB if nothing was configured by the user yet -->
+ <integer name="default_usb_mode">5</integer>
+
+ <!-- Whether to allow mode switching while tethered or not -->
+ <bool name="allow_mode_change_while_tethered">false</bool>
+
+ <!-- Whether a notification should be shown while USB is connected -->
+ <bool name="show_connection_notification">true</bool>
+
+ <!-- If the currently active USB state should be written to a file, put file name here -->
+ <string name="current_usb_state_file_name" translatable="false"></string>
+</resources>
View
41 res/values/strings.xml
@@ -1,24 +1,17 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources>
- <string name="usb_period">.</string>
- <string name="usb_ok">OK</string>
- <string name="usb_cancel">Cancel</string>
- <string name="usb_3_periods">...</string>
- <string name="usb_toast_connecting_to">Connecting for</string>
- <string name="usb_toast_phone_data_disabled">Phone data will be disabled.</string>
- <string name="usb_no_memory_card_notification_title">No memory card inserted</string>
- <string name="usb_no_memory_card_notification_message_title">Missing Memory Card</string>
- <string name="usb_no_memory_card_notification_message">Please insert memory card</string>
- <string name="usb_selection_notification_title">USB connection</string>
- <string name="usb_selection_notification_message">Select to manage your USB connection</string>
- <string name="usb_selection_notification_message_for_modem">Touch to disconnect and re-enable internal phone data</string>
- <string name="usb_connection">USB connection</string>
- <string name="usb_mode_ngp">Portal &amp; Tools</string>
- <string name="usb_mode_mtp">Windows Media Sync</string>
- <string name="usb_mode_msc">Memory Card Access</string>
- <string name="usb_mode_modem">Phone as Modem</string>
- <string name="usb_mode_none">Charge Only</string>
- <string name="usb_toast_insert_card">Please insert a memory card for your media.</string>
- <string name="usb_progress_message">Switching to</string>
- <string name="usb_error_message">The USB connection cannot change to</string>
-</resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="usb_toast_connecting">USB connected as %s.</string>
+ <string name="usb_toast_phone_data_disabled">Phone data will be disabled.</string>
+ <string name="usb_selection_notification_title">USB connection</string>
+ <string name="usb_selection_notification_message">Select to manage your USB connection</string>
+ <string name="usb_selection_notification_message_for_modem">Touch to disconnect and re-enable internal phone data</string>
+ <string name="usb_tethered_message">USB connection mode can not be changed while USB tethering is active</string>
+ <string name="usb_connection">USB connection</string>
+ <string name="usb_mode_ngp">Portal &amp; Tools</string>
+ <string name="usb_mode_mtp">Windows Media Sync</string>
+ <string name="usb_mode_msc">Memory Card Access</string>
+ <string name="usb_mode_rndis">USB Networking</string>
+ <string name="usb_mode_modem">Phone as Modem</string>
+ <string name="usb_mode_none">Charge Only</string>
+ <string name="usb_error_message">The USB connection cannot be changed to %s.</string>
+</resources>
View
89 src/com/motorola/usb/UsbErrorActivity.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2011 Skrilax_CZ
- * Decompilation of Motorola Usb.apk
+ * Based on Motorola Usb.apk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,57 +26,52 @@
import android.os.Bundle;
import android.util.Log;
import com.android.internal.app.AlertActivity;
-import com.android.internal.app.AlertController.AlertParams;
public class UsbErrorActivity extends AlertActivity
- implements DialogInterface.OnClickListener
+ implements DialogInterface.OnClickListener
{
- private BroadcastReceiver mUsbErrorReceiver;
+ private static final String TAG = "UsbErrorActivity";
- public UsbErrorActivity()
- {
- mUsbErrorReceiver = new BroadcastReceiver()
- {
- public void onReceive(Context context, Intent intent)
- {
- String action = intent.getAction();
- Log.d("UsbErrorActivity", "onReceive(), received Intent -- " + action);
- if (action.equals("com.motorola.intent.action.USB_CABLE_DETACHED"))
- finish();
- }
- };
- }
+ private BroadcastReceiver mUsbErrorReceiver;
- public void onClick(DialogInterface dialog, int which)
- {
- finish();
- }
+ public UsbErrorActivity() {
+ mUsbErrorReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ Log.d(TAG, "onReceive(), received Intent -- " + action);
+ if (action.equals(UsbService.ACTION_CABLE_DETACHED)) {
+ finish();
+ }
+ }
+ };
+ }
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction("com.motorola.intent.action.USB_CABLE_DETACHED");
-
- registerReceiver(mUsbErrorReceiver, intentFilter);
-
- mAlertParams.mIconId = com.android.internal.R.drawable.ic_dialog_usb;
- mAlertParams.mTitle = getString(R.string.usb_connection);
-
-
- mAlertParams.mMessage = getString(R.string.usb_error_message) + " " +
- getIntent().getStringExtra("USB_MODE_STRING") +
- getString(R.string.usb_period);
-
- mAlertParams.mPositiveButtonText = getString(R.string.usb_ok);
- mAlertParams.mPositiveButtonListener = this;
- setupAlert();
- }
+ public void onClick(DialogInterface dialog, int which) {
+ finish();
+ }
- protected void onDestroy()
- {
- super.onDestroy();
- unregisterReceiver(mUsbErrorReceiver);
- }
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addAction(UsbService.ACTION_CABLE_DETACHED);
+
+ registerReceiver(mUsbErrorReceiver, intentFilter);
+
+ mAlertParams.mIconId = com.android.internal.R.drawable.ic_dialog_usb;
+ mAlertParams.mTitle = getString(R.string.usb_connection);
+
+ mAlertParams.mMessage = getString(R.string.usb_error_message,
+ getIntent().getStringExtra(UsbService.EXTRA_ERROR_MODE_STRING));
+
+ mAlertParams.mPositiveButtonText = getString(com.android.internal.R.string.ok);
+ mAlertParams.mPositiveButtonListener = this;
+ setupAlert();
+ }
+
+ protected void onDestroy() {
+ super.onDestroy();
+ unregisterReceiver(mUsbErrorReceiver);
+ }
}
View
343 src/com/motorola/usb/UsbListener.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2011 Skrilax_CZ
- * Decompilation of Motorola Usb.apk
+ * Based on Motorola Usb.apk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,172 +19,191 @@
import android.net.LocalSocket;
import android.net.LocalSocketAddress;
+import android.os.Handler;
import android.os.SystemClock;
import android.util.Log;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-public final class UsbListener
- implements Runnable
+public final class UsbListener implements Runnable
{
- private OutputStream mOutputStream;
- private UsbService mUsbService;
-
- public UsbListener(UsbService service)
- {
- mUsbService = service;
- }
-
- private void handleEvent(String event)
- {
- Log.d("UsbListener", "handleEvent: " + event);
- if (event.length() == 0)
- Log.d("UsbListener", "discard invalid event from USBD");
-
- if (event.equals("cable_connected"))
- mUsbService.handleUsbCableAttachment();
- else if (event.equals("usb_enumerated"))
- mUsbService.handleUsbCableEnumerate();
- else if (event.equals("cable_connected_factory"))
- sendUsbModeSwitchCmd("usb_mode_ngp");
- else if (event.equals("get_descriptor"))
- mUsbService.handleGetDescriptor();
- else if (event.equals("cable_disconnected"))
- mUsbService.handleUsbCableDetachment();
- else if (event.equals("usbd_adb_status_on"))
- mUsbService.handleADBOnOff(true);
- else if (event.equals("usbd_adb_status_off"))
- mUsbService.handleADBOnOff(false);
- else if ((event.equals("usbd_start_ngp")) || (event.equals("usbd_start_mtp")) || (event.equals("usbd_start_msc_mount")) || (event.equals("usbd_start_acm")))
- mUsbService.handleStartService(event);
- else if ((event.equals("usbd_req_switch_ngp")) || (event.equals("usbd_req_switch_mtp")) || (event.equals("usbd_req_switch_msc")) || (event.equals("usbd_req_switch_modem")))
- mUsbService.handleUsbModeSwitchFromUsbd(event);
- else
- mUsbService.handleUsbModeSwitchComplete(event);
- }
-
- private void listenToSocket()
- {
- LocalSocket usbdScoket = null;
-
- try
- {
- usbdScoket = new LocalSocket();
- LocalSocketAddress.Namespace fsNamespace = LocalSocketAddress.Namespace.FILESYSTEM;
- LocalSocketAddress socketAddress = new LocalSocketAddress("/dev/socket/usbd", fsNamespace);
- usbdScoket.connect(socketAddress);
-
- InputStream usbdInputStream = usbdScoket.getInputStream();
- mOutputStream = usbdScoket.getOutputStream();
-
- byte[] buffer = new byte[100];
-
- while (true)
- {
- int count = usbdInputStream.read(buffer);
-
- if (count >= 0)
- {
- int i = 0;
- int k = 0;
-
- while (i < count)
- {
- if (buffer[i] == 0)
- {
- handleEvent(new String(buffer, k, i - k));
- k = i + 1;
- }
-
- i = i + 1;
- }
- }
- else
- break; //failure
- }
-
- }
- catch (IOException ex)
- {
- Log.e("UsbListener", "IOException, connect/read socket");
- }
-
- //clean up
- synchronized(this)
- {
- if (mOutputStream != null)
- {
- try
- {
- mOutputStream.close();
- }
- catch (IOException ex)
- {
- Log.w("UsbListener", "IOException closing output stream");
- }
-
- mOutputStream = null;
- }
-
- if (usbdScoket != null)
- {
- try
- {
- usbdScoket.close();
- }
- catch(IOException ex)
- {
- Log.w("UsbListener", "IOException closing socket");
- }
- }
-
- Log.e("UsbListener", "Failed to connect to usbd", new IllegalStateException());
- SystemClock.sleep(2000);
- }
- }
-
- private synchronized void writeCommand(String cmd, String arg)
- {
- if (mOutputStream == null)
- {
- Log.e("UsbListener", "No connection to usbd");
- return;
- }
-
- String line = cmd;
-
- if (arg != null)
- line = cmd + arg + "\0";
- else
- line = cmd + "\0";
-
- try
- {
- mOutputStream.write(line.getBytes());
- }
- catch (IOException ex)
- {
- Log.e("UsbListener", "IOException in writeCommand");
- }
- }
-
- public void run()
- {
- try
- {
- while (true)
- listenToSocket();
- }
- catch (Throwable ex)
- {
- Log.e("UsbListener", "Fatal error " + ex + " in UsbListener thread!");
- }
- }
-
- public void sendUsbModeSwitchCmd(String cmd)
- {
- Log.d("UsbListener", "received usb mode change command from UI: " + cmd);
- writeCommand(cmd, null);
- }
+ private static final String TAG = "UsbListener";
+
+ private OutputStream mOutputStream;
+ private Handler mHandler;
+
+ public static final String EVENT_CABLE_CONNECTED = "cable_connected";
+ public static final String EVENT_CABLE_CONNECTED_FACTORY = "cable_connected_factory";
+ public static final String EVENT_CABLE_DISCONNECTED = "cable_disconnected";
+ public static final String EVENT_ENUMERATED = "usb_enumerated";
+ public static final String EVENT_GET_DESCRIPTOR = "get_descriptor";
+ public static final String EVENT_ADB_ON = "usbd_adb_status_on";
+ public static final String EVENT_ADB_OFF = "usbd_adb_status_off";
+ public static final String EVENT_START_NGP = "usbd_start_ngp";
+ public static final String EVENT_START_MTP = "usbd_start_ngp";
+ public static final String EVENT_START_MSC = "usbd_start_msc_mount";
+ public static final String EVENT_START_ACM = "usbd_start_acm";
+ public static final String EVENT_START_MODEM = "usbd_start_modem";
+ public static final String EVENT_START_RNDIS = "usbd_start_rndis";
+ private static final String EVENT_START_PREFIX = "usbd_start_";
+ public static final String EVENT_REQ_NGP = "usbd_req_switch_ngp";
+ public static final String EVENT_REQ_MTP = "usbd_req_switch_mtp";
+ public static final String EVENT_REQ_MSC = "usbd_req_switch_msc";
+ public static final String EVENT_REQ_ACM = "usbd_req_switch_acm";
+ public static final String EVENT_REQ_MODEM = "usbd_req_switch_modem";
+ public static final String EVENT_REQ_RNDIS = "usbd_req_switch_rndis";
+ public static final String EVENT_REQ_NONE = "usbd_req_switch_none";
+ private static final String EVENT_REQ_PREFIX = "usbd_req_switch_";
+ private static final String SWITCH_OK_POSTFIX = ":ok";
+ private static final String SWITCH_FAIL_POSTFIX = ":fail";
+
+ public static final String MODE_NGP_ADB = "usb_mode_ngp_adb";
+ public static final String MODE_MTP_ADB = "usb_mode_mtp_adb";
+ public static final String MODE_MSC_ADB = "usb_mode_msc_adb";
+ public static final String MODE_RNDIS_ADB = "usb_mode_rndis_adb";
+ public static final String MODE_CHARGE_ADB = "usb_mode_charge_adb";
+ public static final String MODE_NGP = "usb_mode_ngp";
+ public static final String MODE_MTP = "usb_mode_mtp";
+ public static final String MODE_MSC = "usb_mode_msc";
+ public static final String MODE_RNDIS = "usb_mode_rndis";
+ public static final String MODE_MODEM = "usb_mode_modem";
+ public static final String MODE_CHARGE = "usb_mode_charge_only";
+
+ public static final String CMD_UNLOAD_DRIVER = "usb_unload_driver";
+
+ public UsbListener(Handler handler) {
+ mHandler = handler;
+ }
+
+ private void handleEvent(String event) {
+ Log.d(TAG, "handleEvent: " + event);
+
+ if (event.isEmpty()) {
+ Log.d(TAG, "discard invalid event from USBD");
+ return;
+ }
+
+ if (event.equals(EVENT_CABLE_CONNECTED)) {
+ mHandler.sendEmptyMessage(UsbService.MSG_CABLE_ATTACHED);
+ } else if (event.equals(EVENT_ENUMERATED)) {
+ mHandler.sendEmptyMessage(UsbService.MSG_ENUMERATED);
+ } else if (event.equals(EVENT_CABLE_CONNECTED_FACTORY)) {
+ sendUsbModeSwitchCmd(MODE_NGP);
+ } else if (event.equals(EVENT_GET_DESCRIPTOR)) {
+ mHandler.sendEmptyMessage(UsbService.MSG_GET_DESCRIPTOR);
+ } else if (event.equals(EVENT_CABLE_DISCONNECTED)) {
+ mHandler.sendEmptyMessage(UsbService.MSG_CABLE_DETACHED);
+ } else if (event.equals(EVENT_ADB_ON)) {
+ mHandler.sendMessage(mHandler.obtainMessage(UsbService.MSG_ADB_CHANGE, 1, 0));
+ } else if (event.equals(EVENT_ADB_OFF)) {
+ mHandler.sendMessage(mHandler.obtainMessage(UsbService.MSG_ADB_CHANGE, 0, 0));
+ } else if (event.startsWith(EVENT_START_PREFIX)) {
+ mHandler.sendMessage(mHandler.obtainMessage(UsbService.MSG_START_SERVICE, event));
+ } else if (event.startsWith(EVENT_REQ_PREFIX)) {
+ mHandler.sendMessage(mHandler.obtainMessage(UsbService.MSG_USBD_MODE_SWITCH, event));
+ } else if (event.contains(SWITCH_OK_POSTFIX)) {
+ mHandler.sendMessage(mHandler.obtainMessage(UsbService.MSG_MODE_SWITCH_COMPLETE, 1, 0));
+ } else if (event.contains(SWITCH_FAIL_POSTFIX)) {
+ mHandler.sendMessage(mHandler.obtainMessage(UsbService.MSG_MODE_SWITCH_COMPLETE, 0, 0));
+ } else {
+ Log.e(TAG, "Got invalid event " + event);
+ }
+ }
+
+ private void listenToSocket() {
+ LocalSocket usbdSocket = null;
+
+ try {
+ usbdSocket = new LocalSocket();
+ LocalSocketAddress socketAddress =
+ new LocalSocketAddress("/dev/socket/usbd", LocalSocketAddress.Namespace.FILESYSTEM);
+
+ usbdSocket.connect(socketAddress);
+
+ InputStream usbdInputStream = usbdSocket.getInputStream();
+ mOutputStream = usbdSocket.getOutputStream();
+
+ byte[] buffer = new byte[100];
+
+ while (true) {
+ int count = usbdInputStream.read(buffer);
+
+ if (count < 0) {
+ /* failure */
+ break;
+ }
+
+ int pos, start;
+ for (pos = 0, start = 0; pos < count; pos++) {
+ if (buffer[pos] == 0) {
+ handleEvent(new String(buffer, start, pos - start));
+ start = pos + 1;
+ }
+ }
+ }
+ } catch (IOException e) {
+ Log.e(TAG, "IOException, connect/read socket", e);
+ }
+
+ //clean up
+ synchronized(this) {
+ if (mOutputStream != null) {
+ try {
+ mOutputStream.close();
+ } catch (IOException e) {
+ Log.w(TAG, "IOException closing output stream", e);
+ }
+
+ mOutputStream = null;
+ }
+
+ if (usbdSocket != null) {
+ try {
+ usbdSocket.close();
+ } catch (IOException e) {
+ Log.w(TAG, "IOException closing socket", e);
+ }
+ }
+
+ Log.e(TAG, "Failed to connect to usbd", new IllegalStateException());
+ SystemClock.sleep(2000);
+ }
+ }
+
+ private synchronized void writeCommand(String cmd, String arg) {
+ if (mOutputStream == null) {
+ Log.e(TAG, "No connection to usbd");
+ return;
+ }
+
+ String line = cmd;
+ if (arg != null) {
+ line += arg;
+ }
+ line += '\0';
+
+ try {
+ mOutputStream.write(line.getBytes());
+ } catch (IOException e) {
+ Log.e(TAG, "IOException in writeCommand", e);
+ }
+ }
+
+ public void run() {
+ try {
+ while (true) {
+ listenToSocket();
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "Fatal error in UsbListener thread!", e);
+ }
+ }
+
+ public void sendUsbModeSwitchCmd(String cmd) {
+ if (cmd != null) {
+ Log.d(TAG, "received usb mode change command from UI: " + cmd);
+ writeCommand(cmd, null);
+ }
+ }
}
View
328 src/com/motorola/usb/UsbModeSelectionActivity.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2011 Skrilax_CZ
- * Decompilation of Motorola Usb.apk
+ * Based on Motorola Usb.apk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,252 +17,130 @@
package com.motorola.usb;
+import android.app.AlertDialog;
import android.content.BroadcastReceiver;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.Resources;
+import android.net.ConnectivityManager;
import android.os.Bundle;
-import android.os.SystemProperties;
-import android.provider.Settings.SettingNotFoundException;
-import android.provider.Settings.System;
-import android.telephony.TelephonyManager;
import android.util.Log;
+import android.widget.Toast;
+
import com.android.internal.app.AlertActivity;
-import com.android.internal.app.AlertController.AlertParams;
public class UsbModeSelectionActivity extends AlertActivity
- implements DialogInterface.OnClickListener
+ implements DialogInterface.OnClickListener
{
- private final int NO_ITEM = -1;
- private int currentUsbModeIndex;
-
- private boolean isModemAvailable = true;
- private boolean isNGPAvailable = true;
- private boolean isMtpAvailable = true;
-
- private String[] tmpArray;
- private int[] modeAtPosition = new int[]{ -1, -1, -1, -1, -1 };
- private int previousUsbModeIndex;
-
+ private static final String TAG = "UsbModeSelectionActivity";
+
+ private int currentUsbModeIndex;
+ private int previousUsbModeIndex;
+
+ private String[] mModeEntries;
+ private int[] mModeValues;
+
+ private DialogInterface.OnClickListener mUsbClickListener;
+ private BroadcastReceiver mUsbModeSwitchReceiver;
+
+ public UsbModeSelectionActivity() {
+ mUsbModeSwitchReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ Log.d(TAG, "onReceive(), received Intent -- " + action);
+ if (action.equals(UsbService.ACTION_CABLE_DETACHED)) {
+ finish();
+ }
+ }
+ };
+
+ mUsbClickListener = new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ currentUsbModeIndex = mModeValues[which];
+ Log.d(TAG, "onClick() -- " + which + "->" + currentUsbModeIndex);
+ }
+ };
+ }
+
+ private int getPositionFromMode(int mode) {
+ Log.d(TAG, "getPositionFromMode() -- " + mode);
+
+ for (int i = 0; i < mModeValues.length; i++) {
+ if (mode == mModeValues[i]) {
+ return i;
+ }
+ }
+
+ return 0;
+ }
+
+ public void onClick(DialogInterface dialog, int which) {
+ Log.d(TAG, "onClick() -- " + String.valueOf(which));
+
+ if (which == AlertDialog.BUTTON_POSITIVE) {
+ if (currentUsbModeIndex != previousUsbModeIndex) {
+ Intent intent = new Intent(UsbService.ACTION_MODE_SWITCH_FROM_UI);
+ intent.putExtra(UsbService.EXTRA_MODE_SWITCH_MODE, currentUsbModeIndex);
+ sendBroadcast(intent);
+ }
+ }
+ }
- private DialogInterface.OnClickListener mUsbClickListener;
- private BroadcastReceiver mUsbModeSwitchReceiver;
+ private boolean isUsbTethered() {
+ ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
+ String[] tetheredIfaces = cm.getTetheredIfaces();
+ String[] tetherableRegexs = cm.getTetherableUsbRegexs();
- public UsbModeSelectionActivity()
- {
-
- mUsbModeSwitchReceiver = new BroadcastReceiver()
- {
- public void onReceive(Context context, Intent intent)
- {
- String action = intent.getAction();
- Log.d("UsbModeSelectionActivity", "onReceive(), received Intent -- " + action);
- if (action.equals("com.motorola.intent.action.USB_CABLE_DETACHED"))
- finish();
- }
- };
-
- mUsbClickListener = new DialogInterface.OnClickListener()
- {
- public void onClick(DialogInterface dialog, int which)
- {
- Log.d("UsbModeSelectionActivity", "onClick() -- " + String.valueOf(which));
- currentUsbModeIndex = modeAtPosition[which];
- }
- };
- }
+ for (String iface : tetheredIfaces) {
+ for (String regex : tetherableRegexs) {
+ if (iface.matches(regex)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
- private void ReadPreviousUsbMode()
- {
- Log.d("UsbModeSelectionActivity", "ReadPreviousUsbMode()");
-
- try
- {
- int modeFromPC = System.getInt(getContentResolver(), "USB_MODE_FROM_PC");
-
- if ( modeFromPC == -1)
- {
- try
- {
- previousUsbModeIndex = System.getInt(getContentResolver(), "USB_SETTING");
- }
- catch (SettingNotFoundException ex)
- {
- previousUsbModeIndex = SystemProperties.getInt("ro.default_usb_mode", 0);
- System.putInt(getContentResolver(), "USB_SETTING", previousUsbModeIndex);
- }
- }
- else
- previousUsbModeIndex = modeFromPC;
- }
- catch (SettingNotFoundException ex)
- {
- try
- {
- previousUsbModeIndex = System.getInt(getContentResolver(), "USB_SETTING");
- }
- catch (SettingNotFoundException ex2)
- {
- previousUsbModeIndex = SystemProperties.getInt("ro.default_usb_mode", 0);
- System.putInt(getContentResolver(), "USB_SETTING", previousUsbModeIndex);
- }
- }
- }
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
- private boolean getModemAvailableFlex()
- {
- String str;
-
- if (TelephonyManager.getDefault().getPhoneType() == 1)
- {
- Log.d("UsbModeSelectionActivity", "umts phone");
- str = SystemProperties.get("ro.modem_available", "0");
- }
- else
- {
- Log.d("UsbModeSelectionActivity", "cdma phone");
- str = SystemProperties.get("ro.modem_available", "1");
- }
-
- return str.equals("1");
- }
+ Log.d(TAG, "onCreate()");
- private boolean getNGPAvailableFlex()
- {
- String str;
-
- if (TelephonyManager.getDefault().getPhoneType() == 1)
- {
- Log.d("UsbModeSelectionActivity", "umts phone");
- str = SystemProperties.get("ro.ngp_available", "1");
- }
- else
- {
- Log.d("UsbModeSelectionActivity", "cdma phone");
- str = SystemProperties.get("ro.ngp_available", "0");
- }
-
- return str.equals("1");
- }
-
- private boolean getMtpAvailableFlex()
- {
- return SystemProperties.get("ro.mtp_available", "1").equals("1");
- }
+ Resources res = getResources();
- private int getPositionFromMode(int mode)
- {
- int i = 0;
-
- while (true)
- {
- if (i < 5)
- {
- int j = modeAtPosition[i];
- if (j == mode)
- return i;
- }
- else
- return i;
-
- i = i + 1;
- }
- }
+ if (!res.getBoolean(R.bool.allow_mode_change_while_tethered) && isUsbTethered()) {
+ Toast.makeText(this, R.string.usb_tethered_message, Toast.LENGTH_LONG).show();
+ finish();
+ }
- public void onClick(DialogInterface dialog, int which)
- {
- Log.d("UsbModeSelectionActivity", "onClick() -- " + String.valueOf(which));
-
- if (which == -1 )
- {
- if (currentUsbModeIndex != previousUsbModeIndex)
- {
- Intent intent = new Intent("com.motorola.intent.action.USB_MODE_SWITCH_FROM_UI");
- intent.putExtra("USB_MODE_INDEX", String.valueOf(currentUsbModeIndex));
- sendBroadcast(intent);
- }
- }
- }
+ mModeEntries = res.getStringArray(R.array.usb_mode_entries);
+ mModeValues = res.getIntArray(R.array.usb_mode_values);
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- Log.d("UsbModeSelectionActivity", "onCreate()");
-
- isNGPAvailable = getNGPAvailableFlex();
- isModemAvailable = getModemAvailableFlex();
- isMtpAvailable = getMtpAvailableFlex();
+ previousUsbModeIndex = UsbSettings.readCurrentMode(this);
+ currentUsbModeIndex = previousUsbModeIndex;
- int len = 2;
-
- if (isNGPAvailable)
- len = len + 1;
+ mAlertParams.mIconId = com.android.internal.R.drawable.ic_dialog_usb;
+ mAlertParams.mTitle = getString(R.string.usb_connection);
+ mAlertParams.mItems = mModeEntries;
+ mAlertParams.mOnClickListener = mUsbClickListener;
+ mAlertParams.mCheckedItem = getPositionFromMode(previousUsbModeIndex);
+ mAlertParams.mIsSingleChoice = true;
+ mAlertParams.mPositiveButtonText = getString(com.android.internal.R.string.ok);
+ mAlertParams.mPositiveButtonListener = this;
+ mAlertParams.mNegativeButtonText = getString(com.android.internal.R.string.cancel);
+ mAlertParams.mNegativeButtonListener = this;
- if (isModemAvailable)
- len = len + 1;
-
- if (isMtpAvailable)
- len = len + 1;
+ setupAlert();
- tmpArray = new String[len];
-
- int j = 0;
-
- if (isNGPAvailable)
- {
- tmpArray[j] = getString(R.string.usb_mode_ngp);
- modeAtPosition[j] = UsbService.USB_MODE_NGP;
- j = j + 1;
- }
-
- if (isMtpAvailable)
- {
- tmpArray[j] = getString(R.string.usb_mode_mtp);
- modeAtPosition[j] = UsbService.USB_MODE_MTP;
- j = j + 1;
- }
-
- tmpArray[j] = getString(R.string.usb_mode_msc);
- modeAtPosition[j] = UsbService.USB_MODE_MSC;
- j = j + 1;
-
- if (isModemAvailable)
- {
- tmpArray[j] = getString(R.string.usb_mode_modem);
- modeAtPosition[j] = UsbService.USB_MODE_MODEM;
- j = j + 1;
- }
-
- tmpArray[j] = getString(R.string.usb_mode_none);
- modeAtPosition[j] = UsbService.USB_MODE_NONE;
- j = j + 1;
-
- ReadPreviousUsbMode();
-
- currentUsbModeIndex = previousUsbModeIndex;
- mAlertParams.mIconId = com.android.internal.R.drawable.ic_dialog_usb;
- mAlertParams.mTitle = getString(R.string.usb_connection);
- mAlertParams.mItems = tmpArray;
- mAlertParams.mOnClickListener = mUsbClickListener;
- mAlertParams.mCheckedItem = getPositionFromMode(previousUsbModeIndex);
- mAlertParams.mIsSingleChoice = true;
- mAlertParams.mPositiveButtonText = getString(R.string.usb_ok);
- mAlertParams.mPositiveButtonListener = this;
- mAlertParams.mNegativeButtonText = getString(R.string.usb_cancel);
- mAlertParams.mNegativeButtonListener = this;
-
- setupAlert();
-
- registerReceiver(mUsbModeSwitchReceiver, new IntentFilter("com.motorola.intent.action.USB_CABLE_DETACHED"));
- }
+ registerReceiver(mUsbModeSwitchReceiver, new IntentFilter(UsbService.ACTION_CABLE_DETACHED));
+ }
- protected void onDestroy()
- {
- super.onDestroy();
- unregisterReceiver(mUsbModeSwitchReceiver);
- }
+ protected void onDestroy()
+ {
+ super.onDestroy();
+ unregisterReceiver(mUsbModeSwitchReceiver);
+ }
}
View
26 src/com/motorola/usb/UsbReceiver.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2011 Skrilax_CZ
- * Decompilation of Motorola Usb.apk
+ * Based on Motorola Usb.apk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,21 +18,21 @@
package com.motorola.usb;
import android.content.BroadcastReceiver;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
-public class UsbReceiver extends BroadcastReceiver
-{
- public void onReceive(Context context, Intent intent)
- {
- String action = intent.getAction();
+public class UsbReceiver extends BroadcastReceiver {
+ private static final String TAG = "UsbReceiver";
- Log.d("UsbReceiver", "onReceive(), received intent -- " + action);
-
- if (action.equals("android.intent.action.BOOT_COMPLETED"))
- context.startService( new Intent("com.motorola.intent.action.USB_LAUNCH_USBSERVICE"));
-
- }
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+
+ Log.d(TAG, "onReceive(), received intent -- " + action);
+
+ if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
+ context.startService( new Intent(UsbService.ACTION_LAUNCH_SERVICE));
+ }
+ }
}
+
View
2,163 src/com/motorola/usb/UsbService.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2011 Skrilax_CZ
- * Decompilation of Motorola Usb.apk
+ * Based on Motorola Usb.apk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,1162 +22,1043 @@
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.Resources;
import android.os.Environment;
+import android.os.Handler;
import android.os.IBinder;
+import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
-import android.os.SystemProperties;
import android.os.UEventObserver;
import android.os.storage.IMountService;
-import android.os.storage.IMountService.Stub;
-import android.provider.Settings.SettingNotFoundException;
-import android.provider.Settings.System;
-import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
+
import com.android.internal.telephony.ITelephony;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.HashMap;
import java.util.Timer;
import java.util.TimerTask;
public class UsbService extends Service
{
- private static final int[] mUsbModeClassMapping = new int[]{ 3, 1, 2, 4, 4 };
- private static final String[] mUsbModeString = new String[]
- {
- "Motorola Phone Tools",
- "Windows Media Sync",
- "Memory Card Management",
- "Phone as Modem",
- "None",
- };
-
- private static final String[] mUsbModeSwitchCmdADBMapping = new String[]
- {
- "usb_mode_ngp_adb",
- "usb_mode_mtp_adb",
- "usb_mode_msc_adb",
- "usb_mode_ngp_adb",
- "usb_mode_msc_adb",
- };
- private static final String[] mUsbModeSwitchCmdMapping = new String[]
- {
- "usb_mode_ngp",
- "usb_mode_mtp",
- "usb_mode_msc",
- "usb_mode_ngp",
- "usb_mode_msc",
- };
- private static final String[] mUsbStateString = new String[]
- {
- "USB Idle State",
- "USB Wait Device Enum State",
- "USB Service Startup State",
- "USB In-Switch Wait DevNod Close State",
- "USB Detach Wait DevNod Close State",
- "USB Attach Wait DevNod Close State",
- };
-
- public static final int USB_STATE_IDLE = 0;
- public static final int USB_STATE_WAIT_ENUM = 1;
- public static final int USB_STATE_SERVICE_STARTUP = 2;
- public static final int USB_STATE_SWITCH_DEVNOD_CLOSE = 3;
- public static final int USB_STATE_DETACH_DEVNOD_CLOSE = 4;
- public static final int USB_STATE_ATTACH_DEVNOD_CLOSE = 5;
-
- public static final int USB_MODE_NGP = 0;
- public static final int USB_MODE_MTP = 1;
- public static final int USB_MODE_MSC = 2;
- public static final int USB_MODE_MODEM = 3;
- public static final int USB_MODE_NONE = 4;
-
- public static final int USB_SWITCH_FROM_IDLE = -1;
- public static final int USB_SWITCH_FROM_UI = 0;
- public static final int USB_SWITCH_FROM_AT_CMD = 1;
- public static final int USB_SWITCH_FROM_ADB = 2;
- public static final int USB_SWITCH_FROM_USBD = 3;
- public static final int USB_SWITCH_FROM_PHONE_UNLOCK = 4;
-
- private boolean pending_usblan_intent = false;
- private boolean atcmd_service_stopped = false;
- private boolean mtp_service_stopped = false;
- private boolean mUsbCableAttached = false;
- private boolean mADBEnabled = false;
- private int mADBStatusChangeMissedNumber = 0;
-
- private boolean mMediaMountedReceiverRegistered = false;
- private int mIsSwitchFrom = USB_SWITCH_FROM_IDLE;
- private int mUsbState = USB_STATE_IDLE;
- private int mNewUsbMode = USB_MODE_MSC;
- private int mCurrentUsbMode = USB_MODE_MSC;
-
- private String mUsbEvent;
- private UsbListener mUsbListener;
-
- private UEventObserver mUEventObserver;
- private ITelephony mPhoneService;
- private BroadcastReceiver mUsbServiceReceiver;
- private BroadcastReceiver mMediaMountedReceiver;
- private Notification mUsbConnectionNotification;
- private Timer mWait4DevCloseTimer;
-
- public UsbService()
- {
- mUsbServiceReceiver = new BroadcastReceiver()
- {
- public void onReceive(Context context, Intent intent)
- {
- String action = intent.getAction();
- Log.d("UsbService", "onReceive(), received intent:" + action);
-
- if (action.equals("com.motorola.intent.action.USB_ATCMD_DEV_CLOSED"))
- {
- atcmd_service_stopped = true;
- handleAtCmdMtpDevClosed();
- }
- else if (action.equals("com.motorola.intent.action.USB_MTP_EXIT_OK"))
- {
- mtp_service_stopped = true;
- handleAtCmdMtpDevClosed();
- }
- else if (action.equals("com.motorola.intent.action.SHOW_USB_CABLE_ATTACH_TOAST"))
- Toast.makeText(context, getToastStringForCableAttach(), 1).show();
- else if (action.equals("com.motorola.intent.action.SHOW_USB_MODE_SWITCH_TOAST"))
- Toast.makeText(context, getToastStringForModeSwitch(), 1).show();
- else if (action.equals("android.keyguard.intent.SHOW"))
- {
- //nothing ??? (the orignial has empty clause
- }
- else if (action.equals("android.keyguard.intent.HIDE"))
- handleUsbModeSwitchFromPhoneUnlock();
- else if (action.equals("com.motorola.intent.action.USB_MODE_SWITCH_FROM_UI"))
- {
- String indexStr = intent.getStringExtra("USB_MODE_INDEX");
- int index;
-
- try
- {
- index = Integer.valueOf(indexStr);
- if (index < USB_MODE_NGP || index > USB_MODE_NONE)
- index = USB_MODE_MSC;
- }
- catch(Exception ex)
- {
- index = USB_MODE_MSC;
- }
-
- setUsbModeFromUI(index);
- }
- else if(action.equals("com.motorola.intent.action.USB_MODE_SWITCH_FROM_ATCMD"))
- {
- String indexStr = intent.getStringExtra("USB_MODE_INDEX");
- int index;
-
- try
- {
- index = Integer.valueOf(indexStr);
- if (index < USB_MODE_NGP || index > USB_MODE_NONE)
- index = USB_MODE_MSC;
- }
- catch(Exception ex)
- {
- index = USB_MODE_MSC;
- }
-
- setUsbModeFromAtCmd(index);
- }
- }
- };
-
- mMediaMountedReceiver = new BroadcastReceiver()
- {
- public void onReceive(Context context, Intent intent)
- {
- String action = intent.getAction();
- int i = Log.d("UsbService", "onReceive(), received intent:" + action);
-
- if (action.equals("android.intent.action.MEDIA_MOUNTED"))
- startService(new Intent("com.motorola.intent.action.USB_MTP_CONNECTION"));
-
- }
- };
-
- mUEventObserver = new UEventObserver()
- {
- public void onUEvent(UEvent uevent)
- {
- Log.d("UsbService", "USBLAN Uevent: " + uevent.toString());
-
- if(Integer.parseInt(uevent.get("USB_CONNECT")) == 1)
- {
- Log.d("UsbService", "USBLAN enabled");
-
- if(mUsbState == USB_STATE_SERVICE_STARTUP)
- sendUsblanUpIntent();
- }
- else
- {
- Log.d("UsbService", "USBLAN disabled");
- sendUsblanDownIntent();
- }
- }
- };
- }
-
- private void DeviceEnumPostAction()
- {
- Log.d("UsbService", "DeviceEnumPostAction()");
- ReadCurrentUsbMode();
-
- switch (getUsbModeClass(mCurrentUsbMode))
- {
- case 0:
- StartAtCmdService();
- break;
-
- case 1:
- StartMtpService();
- break;
-
- case 2:
- EnterMassStorageMode();
- break;
-
- case 3:
- StartAtCmdService();
- StartMtpService();
- break;
- }
- }
-
- private void DeviceEnumPreAction()
- {
- Log.d("UsbService", "DeviceEnumPreAction()");
- ReadCurrentUsbMode();
-
- switch (getUsbModeClass(mCurrentUsbMode))
- {
- case 0:
- StartWaitDevNodeClosedTimer();
- StopAtCmdService();
- break;
-
- case 1:
- StartWaitDevNodeClosedTimer();
- StopMtpService();
- break;
-
- case 2:
- ExitMassStorageMode();
- mUsbEvent = "usb_devnode_closed";
- UsbEventHandler(mUsbEvent);
- break;
-
- case 3:
- StartWaitDevNodeClosedTimer();
- StopAtCmdService();
- StopMtpService();
- break;
-
- default:
- mUsbEvent = "usb_devnode_closed";
- UsbEventHandler(mUsbEvent);
- break;
- }
- }
-
- private void EnterMassStorageMode()
- {
- Log.d("UsbService", "EnterMassStorageMode()");
- IMountService mountService = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
-
- if (mountService != null)
- {
- try
- {
- mountService.setUsbMassStorageEnabled(true);
- }
- catch (RemoteException localRemoteException)
- {
- // ???????
- }
-
- sendBroadcast(new Intent("com.motorola.intent.action.USB_ENTER_MSC_MODE"));
- }
- }
-
- private void ExitMassStorageMode()
- {
- Log.d("UsbService", "EnterMassStorageMode()");
- IMountService mountService = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
-
- if (mountService != null)
- {
- try
- {
- mountService.setUsbMassStorageEnabled(false);
- }
- catch (RemoteException localRemoteException)
- {
- // ???????
- }
-
- sendBroadcast(new Intent("com.motorola.intent.action.USB_EXIT_MSC_MODE"));
- }
- }
-
- private void ReadCurrentUsbMode()
- {
- Log.d("UsbService", "ReadCurrentUsbMode()");
-
- try
- {
- int modeFromPC = System.getInt(getContentResolver(), "USB_MODE_FROM_PC");
-
- if (modeFromPC == -1)
- {
- try
- {
- mCurrentUsbMode = System.getInt(getContentResolver(), "USB_SETTING");
- Log.d("UsbService", "Current Usb Mode: " + mUsbModeString[mCurrentUsbMode]);
- }
- catch (SettingNotFoundException ex)
- {
- mCurrentUsbMode = SystemProperties.getInt("ro.default_usb_mode", 0);
- Log.d("UsbService", "read usb setting exception");
- System.putInt(getContentResolver(), "USB_SETTING", mCurrentUsbMode);
- }
- }
- else
- {
- mCurrentUsbMode = modeFromPC;
- Log.d("UsbService", "Current Usb Mode: " + mUsbModeString[mCurrentUsbMode]);
- }
- }
- catch (SettingNotFoundException ex)
- {
- try
- {
- mCurrentUsbMode = System.getInt(getContentResolver(), "USB_SETTING");
- Log.d("UsbService", "Current Usb Mode: " + mUsbModeString[mCurrentUsbMode]);
- }
- catch (SettingNotFoundException ex2)
- {
- mCurrentUsbMode = SystemProperties.getInt("ro.default_usb_mode", 0);
- Log.d("UsbService", "read usb setting exception");
- System.putInt(getContentResolver(), "USB_SETTING", mCurrentUsbMode);
- }
- }
- }
-
- private void StartAtCmdService()
- {
- Log.d("UsbService", "StartAtCmdService()");
- startService(new Intent("com.motorola.intent.action.USB_ATCMD_SERVICE_START"));
- }
-
- private void StartMtpService()
- {
- Log.d("UsbService", "StartMtpService()");
- String storageState = Environment.getExternalStorageState();
-
- if ((storageState.equals("shared")) || (storageState.equals("checking")))
- {
- Log.d("UsbService", "StartMtpService(), sd card currently shared or checking");
- IntentFilter myIntentFilter = new IntentFilter("android.intent.action.MEDIA_MOUNTED");
- myIntentFilter.addDataScheme("file");
- registerReceiver(mMediaMountedReceiver, myIntentFilter);
- mMediaMountedReceiverRegistered = true;
- }
- else
- {
- startService(new Intent("com.motorola.intent.action.USB_MTP_CONNECTION"));
- }
- }
-
- private void StartWaitDevNodeClosedTimer()
- {
- Log.d("UsbService", "StartWaitDevNodeClosedTimer()");
- mWait4DevCloseTimer = new Timer();
- mWait4DevCloseTimer.schedule(new TimerTask()
- {
- public void run()
- {
- WaitDevNodeClosedTimeout();
- }
-
- }, 2000);
- }
-
- private void StopAtCmdService()
- {
- Log.d("UsbService", "StopAtCmdService()");
- sendBroadcast(new Intent("com.motorola.intent.action.USB_ATCMD_SERVICE_STOP_OR_CLOSEDEV"));
- }
-
- private void StopMtpService()
- {
- Log.d("UsbService", "StopMtpService()");
- stopService(new Intent("com.motorola.intent.action.USB_MTP_CONNECTION"));
-
- if (mMediaMountedReceiverRegistered)
- {
- unregisterReceiver(mMediaMountedReceiver);
- mMediaMountedReceiverRegistered = false;
- }
- }
-
- private void StopWaitDevNodeClosedTimer()
- {
- Log.d("UsbService", "StopWaitDevNodeClosedTimer()");
- mWait4DevCloseTimer.cancel();
- }
-
- private synchronized void UsbEventHandler(String event)
- {
- Log.d("UsbService", "UsbEventHandler(), Received event: " + event);
- Log.d("UsbService", "Current Usb State: " + mUsbStateString[mUsbState]);
-
- ReadCurrentUsbMode();
-
- switch(mUsbState)
- {
- case USB_STATE_IDLE:
- if (event.equals("usb_cable_inserted"))
- {
- mUsbState = USB_STATE_WAIT_ENUM;
- if (mADBEnabled)
- mUsbListener.sendUsbModeSwitchCmd(getUsbModeSwitchCmdADB(mCurrentUsbMode));
- else
- mUsbListener.sendUsbModeSwitchCmd(getUsbModeSwitchCmd(mCurrentUsbMode));
-
- }
- else if (event.equals("usb_cable_enumerated"))
- {
- Log.d("UsbService", "Idle state, receive USB_CABLE_ENUMERATE_EVENT.");
- mUsbState = USB_STATE_SERVICE_STARTUP;
- mIsSwitchFrom = USB_SWITCH_FROM_IDLE;
- }
- break;
-
- case USB_STATE_WAIT_ENUM:
- if (event.equals("usb_cable_removed"))
- {
- if (mIsSwitchFrom == USB_SWITCH_FROM_UI)
- UsbModeSwitchFail();
-
- mUsbListener.sendUsbModeSwitchCmd("usb_unload_driver");
- mUsbState = USB_STATE_IDLE;
- mIsSwitchFrom = USB_SWITCH_FROM_IDLE;