Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe1649ff authored by Tanguy Pruvot's avatar Tanguy Pruvot Committed by DvTonder
Browse files

Framework: Forward port ADB over network (Part 2 of 2)

Includes:
- ADB Over Network, integration of the adb-host mode (already present)
  The feature can be used/tested without the Settings part:

    setprop service.adb.tcp.port 5555

  Note: This ADB setting is not persistent (for security purpose) and
  require init.rc implementation event like this : http://bit.ly/AdbTcpIP

  Author: Tanguy Pruvot
  Id: I5c61a53948349c785356cb5aae165110d75e3074

Change-Id: I101216c5b8ddff5040d9eeaf35afefc5cd98bbf3
parent eb6cde75
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1171,9 +1171,9 @@
    <string name="extmedia_format_message" product="nosdcard" msgid="3934016853425761078">"Tous les fichiers stockés sur la mémoire de stockage USB vont être effacés. Cette action est irréversible."</string>
    <string name="extmedia_format_message" product="default" msgid="14131895027543830">"Toutes les données stockées sur votre 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 activé"</string>
    <string name="adb_active_notification_message" msgid="1016654627626476142">"Appuyez pour désactiver le débogage USB."</string>
    <string name="select_input_method" msgid="4653387336791222978">"Sélectionnez le mode de saisie"</string>
    <string name="adb_active_notification_title">Débogage android activé</string>
    <string name="adb_active_notification_message">Désactiver le débogage android (adb).</string>
    <string name="select_input_method">"Sélectionner le mode de saisie"</string>
    <string name="configure_input_methods" msgid="9091652157722495116">"Configurer les modes de saisie"</string>
    <string name="use_physical_keyboard" msgid="6203112478095117625">"Clavier physique"</string>
    <string name="hardware" msgid="7517821086888990278">"Matériel"</string>
+2 −2
Original line number Diff line number Diff line
@@ -3328,9 +3328,9 @@
    <string name="extmedia_format_button_format">Format</string>

    <!-- Title of notification shown when ADB is actively connected to the phone. -->
    <string name="adb_active_notification_title">USB debugging connected</string>
    <string name="adb_active_notification_title">Android debugging enabled</string>
    <!-- Message of notification shown when ADB is actively connected to the phone. -->
    <string name="adb_active_notification_message">Touch to disable USB debugging.</string>
    <string name="adb_active_notification_message">Select to disable 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    -->
+25 −0
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.IPackageManager;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.database.Cursor;
import android.media.AudioService;
import android.net.wifi.p2p.WifiP2pService;
import android.os.Handler;
@@ -40,6 +42,7 @@ import android.os.StrictMode;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
import android.server.search.SearchManagerService;
import android.service.dreams.DreamService;
import android.util.DisplayMetrics;
@@ -86,6 +89,19 @@ class ServerThread extends Thread {
        Log.wtf(TAG, "BOOT FAILURE " + msg, e);
    }

    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));
        }
    }

    @Override
    public void run() {
        EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_SYSTEM_RUN,
@@ -768,6 +784,15 @@ 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")));

        // register observer to listen for settings changes
        mContentResolver.registerContentObserver(
            Settings.Secure.getUriFor(Settings.Secure.ADB_PORT),
            false, new AdbPortObserver());

        // Before things start rolling, be sure we have decided whether
        // we are in safe mode.
        final boolean safeMode = wm.detectSafeMode();
+4 −0
Original line number Diff line number Diff line
@@ -371,6 +371,10 @@ public class UsbDeviceManager {
                        }
                );

                mContentResolver.registerContentObserver(
                        Settings.Secure.getUriFor(Settings.Secure.ADB_PORT),
                                false, new AdbSettingsObserver());

                // Watch for USB configuration changes
                mUEventObserver.startObserving(USB_STATE_MATCH);
                mUEventObserver.startObserving(ACCESSORY_START_MATCH);