xref: /aosp_15_r20/external/walt/docs/Development.md (revision bf47c6829f95be9dd55f4c5bbc44a71c90aad403)
1*bf47c682SAndroid Build Coastguard Worker## Setting up for WALT Android app development
2*bf47c682SAndroid Build Coastguard Worker
3*bf47c682SAndroid Build Coastguard WorkerIn general WALT Android app has no special requirements but since WALT usually takes up the only available USB connector on the phone, the typical development using ADB via USB becomes difficult. Below are some options to overcome this problem.
4*bf47c682SAndroid Build Coastguard Worker
5*bf47c682SAndroid Build Coastguard Worker
6*bf47c682SAndroid Build Coastguard Worker#### Using a USB hub and a USB Ethernet adapter
7*bf47c682SAndroid Build Coastguard Worker
8*bf47c682SAndroid Build Coastguard WorkerADB can work over TCP connections. The [official documentation](https://developer.android.com/studio/command-line/adb.html#wireless) assumes that the TCP connection is established over WiFi, but a wired Ethernet connection can be used in the same way and is reported to work much better with ADB. Android will recognize and use most USB-Ethernet adapters out of the box.
9*bf47c682SAndroid Build Coastguard Worker
10*bf47c682SAndroid Build Coastguard Worker1. With the phone connected you computer via USB, run `adb tcpip 5555` (you can replace 5555 with any port)
11*bf47c682SAndroid Build Coastguard Worker1. Disconnect the phone from USB
12*bf47c682SAndroid Build Coastguard Worker1. Connect a USB hub (preferably powered) to the phone using a [USB-C to USB-A-female adapter](https://store.google.com/product/usb_type_c_to_usb_standard_a_adapter)
13*bf47c682SAndroid Build Coastguard Worker   or a USB-OTG adapter.
14*bf47c682SAndroid Build Coastguard Worker1. Use the hub to connect WALT, Ethernet adapter and whatever other USB peripherals you might want to test using WALT
15*bf47c682SAndroid Build Coastguard Worker
16*bf47c682SAndroid Build Coastguard WorkerNote, this setup is sensitive to the order in which you connect the different components and adapters, experiments with it.
17*bf47c682SAndroid Build Coastguard Worker
18*bf47c682SAndroid Build Coastguard Worker
19*bf47c682SAndroid Build Coastguard Worker####  Using a ChromeOS device with Android
20*bf47c682SAndroid Build Coastguard Worker
21*bf47c682SAndroid Build Coastguard WorkerA ChromeOS device with Android (e.g. Asus Flip) is another convenient option.
22*bf47c682SAndroid Build Coastguard Worker
23*bf47c682SAndroid Build Coastguard WorkerSince Android on ChromeOS has no access to USB, it requires a TCP bridge script implemented in [walt.py](/pywalt/walt.py). Detailed instructions in [Chromeos.md](Chromeos.md).
24*bf47c682SAndroid Build Coastguard Worker
25*bf47c682SAndroid Build Coastguard WorkerIn order to set up your  for Android development, use either the
26*bf47c682SAndroid Build Coastguard Worker[official guide for Android development on ChromeOS](https://developer.android.com/topic/arc/index.html#setup).
27*bf47c682SAndroid Build Coastguard WorkerOr the following short list:
28*bf47c682SAndroid Build Coastguard Worker
29*bf47c682SAndroid Build Coastguard Worker1. Log in to Chromebook via a non-guest account, also avoid restricted corporate/managed accounts
30*bf47c682SAndroid Build Coastguard Worker1. Go to settings, scroll down to Google Play Store and click enable
31*bf47c682SAndroid Build Coastguard Worker1. Click Manage your Android preferences and enable ADB debugging like on a regular Android device:
32*bf47c682SAndroid Build Coastguard Worker  1. Click About device
33*bf47c682SAndroid Build Coastguard Worker  1. Keep tapping the build number until it says “You are now a developer” (7 taps)
34*bf47c682SAndroid Build Coastguard Worker  1. Go back and click on Developer options
35*bf47c682SAndroid Build Coastguard Worker  1. Enable ADB debugging
36*bf47c682SAndroid Build Coastguard Worker1. Get your Chromebook connected to a network so it would be accessible from you workstation
37*bf47c682SAndroid Build Coastguard Worker1. Switch Chromebook to terminal via ctrl+alt+f2 and log in as root
38*bf47c682SAndroid Build Coastguard Worker1. Run `ifconfig` to get the ip address of eth0 (or wlan0 if using wireless)
39*bf47c682SAndroid Build Coastguard Worker1. On your workstation, run `ssh root@ip_addr` to verify that Chromebook is accessible
40*bf47c682SAndroid Build Coastguard Worker1. Run `adb connect ip_addr:22`. From this point on Android studio and adb on your workstation should treat the Chromebook just like a regular Android device
41*bf47c682SAndroid Build Coastguard Worker1. Run the WALT TCP bridge (more details [here](ChromeOS.md))
42*bf47c682SAndroid Build Coastguard Worker  1. scp the pywalt folder from your workstation and run the following on the Chromebook:
43*bf47c682SAndroid Build Coastguard Worker  1. `iptables -A INPUT -p tcp --dport 50007 -j ACCEPT`
44*bf47c682SAndroid Build Coastguard Worker  1. `python walt.py -t bridge`
45