Merge "Revert "adb: create shell protocol class.""
diff --git a/adb/Android.mk b/adb/Android.mk
index 0ec7416..7789035 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -265,8 +265,6 @@
 
 LOCAL_MODULE := adbd
 
-LOCAL_INIT_RC := adbd.rc
-
 LOCAL_FORCE_STATIC_EXECUTABLE := true
 LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)
 LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)
diff --git a/adb/adb.cpp b/adb/adb.cpp
index a6b539f..0bd95a3 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -1133,9 +1133,27 @@
     }
 
     if (!strcmp(service, "features")) {
-        SendOkay(reply_fd);
-        SendProtocolString(
-            reply_fd, android::base::Join(supported_features(), '\n'));
+        std::string error_msg;
+        atransport* t = acquire_one_transport(kCsAny, type, serial, &error_msg);
+        if (t != nullptr) {
+            SendOkay(reply_fd, android::base::Join(t->features(), '\n'));
+        } else {
+            SendFail(reply_fd, error_msg);
+        }
+        return 0;
+    }
+
+    if (!strncmp(service, "check-feature:", strlen("check-feature:"))) {
+        std::string error_msg;
+        atransport* t = acquire_one_transport(kCsAny, type, serial, &error_msg);
+        if (t && t->CanUseFeature(service + strlen("check-feature:"))) {
+            // We could potentially extend this to reply with the feature
+            // version if that becomes necessary.
+            SendOkay(reply_fd, "1");
+        } else {
+            // Empty response means unsupported feature.
+            SendOkay(reply_fd, "");
+        }
         return 0;
     }
 
diff --git a/adb/adbd.rc b/adb/adbd.rc
deleted file mode 100644
index b91d8b5..0000000
--- a/adb/adbd.rc
+++ /dev/null
@@ -1,14 +0,0 @@
-on post-fs-data
-    mkdir /data/misc/adb 02750 system shell
-    mkdir /data/adb 0700 root root
-
-# adbd is controlled via property triggers in init.<platform>.usb.rc
-service adbd /sbin/adbd --root_seclabel=u:r:su:s0
-    class core
-    socket adbd stream 660 system system
-    disabled
-    seclabel u:r:adbd:s0
-
-# adbd on at boot in emulator
-on property:ro.kernel.qemu=1
-    start adbd
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index 86f9263..4fe0c25 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -1444,7 +1444,7 @@
         return 0;
     }
     else if (!strcmp(argv[0], "features")) {
-        return adb_query_command("host:features");
+        return adb_query_command(format_host_command("features", transport_type, serial));
     }
 
     usage();
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 7a806f5..5f1169d 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -493,13 +493,3 @@
 service flash_recovery /system/bin/install-recovery.sh
     class main
     oneshot
-
-service uncrypt /system/bin/uncrypt
-    class main
-    disabled
-    oneshot
-
-service pre-recovery /system/bin/uncrypt --reboot
-    class main
-    disabled
-    oneshot
diff --git a/rootdir/init.usb.rc b/rootdir/init.usb.rc
index e290ca4..4e6f2a8 100644
--- a/rootdir/init.usb.rc
+++ b/rootdir/init.usb.rc
@@ -8,6 +8,19 @@
     chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file
     chown system system /sys/class/android_usb/android0/f_rndis/ethaddr
     chmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddr
+    mkdir /data/misc/adb 02750 system shell
+    mkdir /data/adb 0700 root root
+
+# adbd is controlled via property triggers in init.<platform>.usb.rc
+service adbd /sbin/adbd --root_seclabel=u:r:su:s0
+    class core
+    socket adbd stream 660 system system
+    disabled
+    seclabel u:r:adbd:s0
+
+# adbd on at boot in emulator
+on property:ro.kernel.qemu=1
+    start adbd
 
 # Used to disable USB when switching states
 on property:sys.usb.config=none