summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTanguy Pruvot <tanguy.pruvot@gmail.com>2011-11-04 20:15:16 +0100
committerdjMesias <djmesias@terra.es>2012-01-31 22:14:44 +0100
commit9db0389c07381b5b8e23e92e53507310a0cf825a (patch)
treed59c924545a2299cfb688cc24d76202b19f28296
parent4d91c2e3a1a9e92bc38f874f9ef07432eddffad8 (diff)
downloadframeworks_base-9db0389c07381b5b8e23e92e53507310a0cf825a.zip
frameworks_base-9db0389c07381b5b8e23e92e53507310a0cf825a.tar.gz
frameworks_base-9db0389c07381b5b8e23e92e53507310a0cf825a.tar.bz2
Ability to debug over Network (framework part)
Allow also the notification for ADB in tcp/ip mode Add a new notification message when this mode is enabled. translated: en,fr,de,es,ja,zh Note: This function can work without the Setting Part, its an official feature of adb. But require this change in your device init.rc : http://review.cyanogenmod.com/6034 Settings Part : http://review.cyanogenmod.com/7141 Change-Id: I875a5ba5db10c949be2372db0e13768fe9cb3c1f
-rw-r--r--core/java/android/provider/Settings.java5
-rw-r--r--core/res/res/values-de/strings.xml2
-rw-r--r--core/res/res/values-es/strings.xml6
-rw-r--r--core/res/res/values-fr/strings.xml6
-rw-r--r--core/res/res/values-ja/strings.xml4
-rw-r--r--core/res/res/values-zh-rCN/strings.xml2
-rw-r--r--core/res/res/values/strings.xml3
-rwxr-xr-xservices/java/com/android/server/NotificationManagerService.java67
-rw-r--r--services/java/com/android/server/SystemServer.java21
9 files changed, 92 insertions, 24 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index e8706fc..ff12308 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -3570,6 +3570,11 @@ public final class Settings {
public static final String ADB_ENABLED = "adb_enabled";
/**
+ * The TCP/IP port to run ADB on, or -1 for USB
+ */
+ public static final String ADB_PORT = "adb_port";
+
+ /**
* Whether to show ADB notifications.
* @hide
*/
diff --git a/core/res/res/values-de/strings.xml b/core/res/res/values-de/strings.xml
index 0007297..75b8d99 100644
--- a/core/res/res/values-de/strings.xml
+++ b/core/res/res/values-de/strings.xml
@@ -871,6 +871,8 @@
<string name="extmedia_format_button_format" msgid="4131064560127478695">"Formatieren"</string>
<string name="adb_active_notification_title" msgid="6729044778949189918">"USB-Debugging verbunden"</string>
<string name="adb_active_notification_message" msgid="8470296818270110396">"Zum deaktivieren auswählen"</string>
+ <string name="adb_net_enabled_notification_title">"Netzwerk-Debugging aktiviert"</string>
+ <string name="adb_net_enabled_notification_message">"Zum deaktivieren auswählen"</string>
<string name="select_input_method" msgid="6865512749462072765">"Eingabemethode auswählen"</string>
<string name="fast_scroll_alphabet" msgid="5433275485499039199">" ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
<string name="fast_scroll_numeric_alphabet" msgid="4030170524595123610">" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
diff --git a/core/res/res/values-es/strings.xml b/core/res/res/values-es/strings.xml
index 1171cdc..4a359eb 100644
--- a/core/res/res/values-es/strings.xml
+++ b/core/res/res/values-es/strings.xml
@@ -854,8 +854,10 @@
<string name="extmedia_format_message" product="nosdcard" msgid="8296908079722897772">"¿Quieres formatear el USB y borrar todos los archivos? Esta acción no se puede deshacer."</string>
<string name="extmedia_format_message" product="default" msgid="3621369962433523619">"¿Estás seguro de que quieres formatear la tarjeta SD? Se perderán todos los datos de la tarjeta."</string>
<string name="extmedia_format_button_format" msgid="4131064560127478695">"Formato"</string>
- <string name="adb_active_notification_title" msgid="6729044778949189918">"Dispositivo de depuración USB conectado"</string>
- <string name="adb_active_notification_message" msgid="8470296818270110396">"Seleccionar para inhabilitar la depuración USB"</string>
+ <string name="adb_active_notification_title" msgid="6729044778949189918">"Depuración USB activada"</string>
+ <string name="adb_active_notification_message" msgid="8470296818270110396">"Seleccionar para desactivar la depuración USB"</string>
+ <string name="adb_net_enabled_notification_title">Depuración sobre red activada</string>
+ <string name="adb_net_enabled_notification_message">Seleccionar para desactivar la depuración sobre red</string>
<string name="select_input_method" msgid="6865512749462072765">"Seleccionar método de introducción de texto"</string>
<string name="fast_scroll_alphabet" msgid="5433275485499039199">" ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
<string name="fast_scroll_numeric_alphabet" msgid="4030170524595123610">" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
diff --git a/core/res/res/values-fr/strings.xml b/core/res/res/values-fr/strings.xml
index a043543..afd887c 100644
--- a/core/res/res/values-fr/strings.xml
+++ b/core/res/res/values-fr/strings.xml
@@ -843,8 +843,10 @@
<string name="extmedia_format_message" product="nosdcard" msgid="8296908079722897772">"Formater la mémoire de stockage USB en effaçant tous les fichiers ? Cette action est irréversible."</string>
<string name="extmedia_format_message" product="default" msgid="3621369962433523619">"Voulez-vous vraiment formater la carte SD ? Toutes les données de cette carte seront perdues."</string>
<string name="extmedia_format_button_format" msgid="4131064560127478695">"Format"</string>
- <string name="adb_active_notification_title" msgid="6729044778949189918">"Débogage USB connecté"</string>
- <string name="adb_active_notification_message" msgid="8470296818270110396">"Sélectionnez cette option pour désactiver le débogage USB."</string>
+ <string name="adb_active_notification_title">Débogage via USB connecté</string>
+ <string name="adb_active_notification_message">Désactiver le débogage android USB (adb).</string>
+ <string name="adb_net_enabled_notification_title">Débogage via TCP/IP activé</string>
+ <string name="adb_net_enabled_notification_message">Désactiver le débogage android (adb).</string>
<string name="select_input_method" msgid="6865512749462072765">"Sélectionner un mode de saisie"</string>
<string name="fast_scroll_alphabet" msgid="5433275485499039199">" ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
<string name="fast_scroll_numeric_alphabet" msgid="4030170524595123610">" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
diff --git a/core/res/res/values-ja/strings.xml b/core/res/res/values-ja/strings.xml
index 73895aa..1c64dac 100644
--- a/core/res/res/values-ja/strings.xml
+++ b/core/res/res/values-ja/strings.xml
@@ -830,6 +830,10 @@
<string name="extmedia_format_button_format" msgid="4131064560127478695">"フォーマット"</string>
<string name="adb_active_notification_title" msgid="6729044778949189918">"USBデバッグが接続されました"</string>
<string name="adb_active_notification_message" msgid="8470296818270110396">"USBデバッグを無効にする場合に選択します。"</string>
+
+ <string name="adb_net_enabled_notification_title">ネットワークデバッグが有効になりました</string>
+ <string name="adb_net_enabled_notification_message">ネットワークデバッグを無効にする場合に選択します。</string>
+
<string name="select_input_method" msgid="6865512749462072765">"入力方法の選択"</string>
<string name="fast_scroll_alphabet" msgid="5433275485499039199">" ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
<string name="fast_scroll_numeric_alphabet" msgid="4030170524595123610">" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
diff --git a/core/res/res/values-zh-rCN/strings.xml b/core/res/res/values-zh-rCN/strings.xml
index 12fbc4d..2c66101 100644
--- a/core/res/res/values-zh-rCN/strings.xml
+++ b/core/res/res/values-zh-rCN/strings.xml
@@ -842,6 +842,8 @@
<string name="extmedia_format_button_format" msgid="4131064560127478695">"格式化"</string>
<string name="adb_active_notification_title" msgid="6729044778949189918">"已连接 USB 调试"</string>
<string name="adb_active_notification_message" msgid="8470296818270110396">"选择停用 USB 调试。"</string>
+ <string name="adb_net_enabled_notification_title">已开启网络调试</string>
+ <string name="adb_net_enabled_notification_message">选择停用网络调试.</string>
<string name="select_input_method" msgid="6865512749462072765">"选择输入法"</string>
<string name="fast_scroll_alphabet" msgid="5433275485499039199">" ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
<string name="fast_scroll_numeric_alphabet" msgid="4030170524595123610">" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 9d4c72f..e91d0d2 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2235,6 +2235,9 @@
<!-- Message of notification shown when ADB is actively connected to the phone. -->
<string name="adb_active_notification_message">Select to disable USB debugging.</string>
+ <string name="adb_net_enabled_notification_title">Network debugging enabled</string>
+ <string name="adb_net_enabled_notification_message">Select to disable network debugging.</string>
+
<!-- Used to replace %s in urls retreived from the signin server with locales. For Some -->
<!-- devices we don't support all the locales we ship to and need to replace the '%s' with a -->
<!-- locale string based on mcc values. By default (0-length string) we don't replace the %s -->
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index e102d62..785abb4 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -177,6 +177,7 @@ public class NotificationManagerService extends INotificationManager.Stub
// for adb connected notifications
private boolean mUsbConnected = false;
private boolean mAdbNotificationShown = false;
+ private boolean mAdbNotificationIsUsb = false;
private Notification mAdbNotification;
private final ArrayList<NotificationRecord> mNotificationList =
@@ -449,10 +450,18 @@ public class NotificationManagerService extends INotificationManager.Stub
}
} else if (action.equals(UsbManager.ACTION_USB_STATE)) {
Bundle extras = intent.getExtras();
+ ContentResolver resolver = mContext.getContentResolver();
+
mUsbConnected = extras.getBoolean(UsbManager.USB_CONNECTED);
- boolean adbEnabled = (UsbManager.USB_FUNCTION_ENABLED.equals(
- extras.getString(UsbManager.USB_FUNCTION_ADB)));
- updateAdbNotification(mUsbConnected && adbEnabled);
+ boolean adbUsbEnabled = (UsbManager.USB_FUNCTION_ENABLED.equals(
+ extras.getString(UsbManager.USB_FUNCTION_ADB)));
+
+ boolean adbEnabled = Settings.Secure.getInt(resolver,
+ Settings.Secure.ADB_ENABLED, 0) > 0;
+ boolean adbOverNetwork = Settings.Secure.getInt(resolver,
+ Settings.Secure.ADB_PORT, 0) > 0;
+
+ updateAdbNotification(adbUsbEnabled && mUsbConnected, adbEnabled && adbOverNetwork);
} else if (action.equals(Intent.ACTION_PACKAGE_REMOVED)
|| action.equals(Intent.ACTION_PACKAGE_RESTARTED)
|| (queryRestart=action.equals(Intent.ACTION_QUERY_PACKAGE_RESTART))
@@ -601,14 +610,20 @@ public class NotificationManagerService extends INotificationManager.Stub
Settings.Secure.ADB_ENABLED), false, this);
resolver.registerContentObserver(Settings.Secure.getUriFor(
Settings.Secure.ADB_NOTIFY), false, this);
+ resolver.registerContentObserver(Settings.Secure.getUriFor(
+ Settings.Secure.ADB_PORT), false, this);
}
@Override public void onChange(boolean selfChange) {
ContentResolver resolver = mContext.getContentResolver();
boolean adbEnabled = Settings.Secure.getInt(resolver,
Settings.Secure.ADB_ENABLED, 0) != 0;
+ boolean adbOverNetwork = Settings.Secure.getInt(resolver,
+ Settings.Secure.ADB_PORT, 0) > 0;
+
/* notify setting is checked inside updateAdbNotification() */
- updateAdbNotification(adbEnabled && mUsbConnected);
+ updateAdbNotification(adbEnabled && mUsbConnected,
+ adbEnabled && adbOverNetwork);
}
}
@@ -1741,35 +1756,51 @@ public class NotificationManagerService extends INotificationManager.Stub
// This is here instead of StatusBarPolicy because it is an important
// security feature that we don't want people customizing the platform
// to accidentally lose.
- private void updateAdbNotification(boolean adbEnabled) {
+ private void updateAdbNotification(boolean usbEnabled, boolean networkEnabled) {
if ("0".equals(SystemProperties.get("persist.adb.notify")) ||
Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ADB_NOTIFY, 1) == 0) {
- adbEnabled = false;
+ usbEnabled = false;
+ networkEnabled = false;
}
- if (adbEnabled) {
- if (!mAdbNotificationShown) {
+ if (usbEnabled || networkEnabled) {
+ boolean needUpdate = !mAdbNotificationShown ||
+ (networkEnabled && mAdbNotificationIsUsb) ||
+ (!networkEnabled && !mAdbNotificationIsUsb);
+
+ if (needUpdate) {
NotificationManager notificationManager = (NotificationManager) mContext
.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
Resources r = mContext.getResources();
- CharSequence title = r.getText(
- com.android.internal.R.string.adb_active_notification_title);
- CharSequence message = r.getText(
- com.android.internal.R.string.adb_active_notification_message);
+
+ /*
+ * Network takes precedence, as adbd doesn't listen to USB commands
+ * while it's switched to network
+ */
+ int titleId = networkEnabled ?
+ com.android.internal.R.string.adb_net_enabled_notification_title :
+ com.android.internal.R.string.adb_active_notification_title;
+ int messageId = networkEnabled ?
+ com.android.internal.R.string.adb_net_enabled_notification_message :
+ com.android.internal.R.string.adb_active_notification_message;
+
+ CharSequence title = r.getText(titleId);
+ CharSequence message = r.getText(messageId);
if (mAdbNotification == null) {
mAdbNotification = new Notification();
mAdbNotification.icon = com.android.internal.R.drawable.stat_sys_adb;
mAdbNotification.when = 0;
mAdbNotification.flags = Notification.FLAG_ONGOING_EVENT;
- mAdbNotification.tickerText = title;
mAdbNotification.defaults = 0; // please be quiet
mAdbNotification.sound = null;
mAdbNotification.vibrate = null;
}
+ mAdbNotification.tickerText = title;
+
Intent intent = new Intent(
Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
@@ -1785,19 +1816,17 @@ public class NotificationManagerService extends INotificationManager.Stub
mAdbNotification.setLatestEventInfo(mContext, title, message, pi);
mAdbNotificationShown = true;
- notificationManager.notify(
- com.android.internal.R.string.adb_active_notification_title,
- mAdbNotification);
+ mAdbNotificationIsUsb = !networkEnabled;
+
+ notificationManager.notify(mAdbNotification.icon, mAdbNotification);
}
}
-
} else if (mAdbNotificationShown) {
NotificationManager notificationManager = (NotificationManager) mContext
.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
mAdbNotificationShown = false;
- notificationManager.cancel(
- com.android.internal.R.string.adb_active_notification_title);
+ notificationManager.cancel(mAdbNotification.icon);
}
}
}
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 31266ee..86b2b70 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -84,7 +84,20 @@ class ServerThread extends Thread {
boolean enableAdb = (Settings.Secure.getInt(mContentResolver,
Settings.Secure.ADB_ENABLED, 0) > 0);
// setting this secure property will start or stop adbd
- SystemProperties.set("persist.service.adb.enable", enableAdb ? "1" : "0");
+ SystemProperties.set("persist.service.adb.enable", enableAdb ? "1" : "0");
+ }
+ }
+
+ private class AdbPortObserver extends ContentObserver {
+ public AdbPortObserver() {
+ super(null);
+ }
+ @Override
+ public void onChange(boolean selfChange) {
+ int adbPort = Settings.Secure.getInt(mContentResolver,
+ Settings.Secure.ADB_PORT, 0);
+ // setting this will control whether ADB runs on TCP/IP or USB
+ SystemProperties.set("service.adb.tcp.port", Integer.toString(adbPort));
}
}
@@ -548,10 +561,16 @@ class ServerThread extends Thread {
}
// make sure the ADB_ENABLED setting value matches the secure property value
+ Settings.Secure.putInt(mContentResolver, Settings.Secure.ADB_PORT,
+ Integer.parseInt(SystemProperties.get("service.adb.tcp.port", "-1")));
+
Settings.Secure.putInt(mContentResolver, Settings.Secure.ADB_ENABLED,
"1".equals(SystemProperties.get("persist.service.adb.enable")) ? 1 : 0);
// register observer to listen for settings changes
+ mContentResolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.ADB_PORT),
+ false, new AdbPortObserver());
+
mContentResolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.ADB_ENABLED),
false, new AdbSettingsObserver());