6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

再起動したあと自動的にadb tcpipを有効化する (root化必要)

Posted at

モチベ

scrcpyするときにいちいちUSBつないでtcpipするのめんどくさい

環境

Nexus 5 無印 (タッチスクリーンが壊れてる)
Android 6.0.1 Mashmallow

手順

  1. adb shell
  2. su
  3. setprop persist.adb.tcp.port 5555
  4. 端末再起動して adb shell getprop で persist.adb.tcp.port があればOK

ソース

This will make it persistent:

setprop persist.adb.tcp.port 5555

    // If one of these properties is set, also listen on that port
    // If one of the properties isn't set and we couldn't listen on usb,
    // listen on the default port.
    property_get("service.adb.tcp.port", value, "");
    if (!value[0]) {
        property_get("persist.adb.tcp.port", value, "");
    }
    if (sscanf(value, "%d", &port) == 1 && port > 0) {
        printf("using port=%d\n", port);
        // listen on TCP port specified by service.adb.tcp.port property
        local_init(port);
    } else if (!usb) {
        // listen on default port
        local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT);
    }

To answer your 2 last questions, according to several sources (1, 2, 3), thoses are stored in /data/property/. I couldn't find an offical reference about this location though.

For you, that would be in /data/property/persist.adb.tcp.port.

余談

  • https://forum.xda-developers.com/showthread.php?t=635102
    によると service.adb.tcp.port でも行けるみたいな感じだが再起動したら消えてしまった
  • ssh root@192.168.3.109 -L 5555:localhost:5037 みたいな感じでadbdへSSH Port Forwardingするのは妙案だと思った。これならrootなくても行ける?だれか試して。今回scrcpyはなるべくオーバーヘッド下げたいので正攻法でやった。
6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?