Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Enabling wireless adb from within an application on the Oculus Quest

Discussion in 'VR' started by mattbenic, Sep 12, 2019.

  1. mattbenic

    mattbenic

    Joined:
    Nov 24, 2010
    Posts:
    38
    We are using scrcpy (https://github.com/Genymobile/scrcpy) to "cast" what our users see to a PC, this works great both tethered and untethered, but requires us to connect the quest to a PC to enable wireless adb access (adb tcpip 5555). This needs to happen at least after restarting the headset, and sometimes also when it wakes up. So we would like to initiate this from the headset. We thought we could run the equivalent of the above command when our app starts up (and maybe after receiving a wakeup notification).

    So in investigating this approach, I've found an equivalent to adb tcpip 5555 would be to set the system property adb reads that port from and restart adb. This should be possible on device with the following shell commands:

    Code (CSharp):
    1. /bin/setprop service.adb.tcp.port 5555
    2. /system/bin/stop adbd
    3. /system/bin/start adbd
    So I set about trying to do this with the System.Diagnostics namespace. Now I've run into two problems.
    First, using the following to run a command on device as follows (eg command = "/system/bin/setprop", arguments = "service.adb.tcp.port 5555"):

    Code (CSharp):
    1. private IEnumerator RunCommandCoroutine(string command, string arguments)
    2. {
    3.     ProcessStartInfo startInfo = new ProcessStartInfo()
    4.     {
    5.         FileName = command,
    6.         Arguments = arguments,
    7.         UseShellExecute = false,
    8.         RedirectStandardInput = true,
    9.         RedirectStandardOutput = true,
    10.         RedirectStandardError = true
    11.     };
    12.     PrintOutput(string.Format("Trying to run {0} with args {1}", startInfo.FileName, startInfo.Arguments));
    13.     Process process = Process.Start(startInfo);
    14.     process.OutputDataReceived += (s, e) => PrintOutput(string.Format("{0}: {1}", startInfo.FileName, e.Data));
    15.     process.ErrorDataReceived += (s, e) => PrintOutput(string.Format("{0}: {1}", startInfo.FileName, e.Data));
    16.     process.Exited += (s, e) => PrintOutput(string.Format("{0} Exited with code {1}", startInfo.FileName, process.ExitCode));
    17.    
    18.     // Commented out because the process seems to have already failed at this point, raising an exception
    19.     //PrintOutput(string.Format("{0} Started", process.ProcessName));
    20.     while (process != null && !process.HasExited)
    21.     {
    22.         yield return null;
    23.     }
    24. }
    The command just seems to be ignored by the device. Trying to access process.ProcessName immediately after Process.Start throws an exception that the process is invalid or has exited. I've tried with the most basic and accessible of commands (/system/bin/ls) and even that doesn't actually seem to run.

    Second, it appears that running 'start adbd' would require root access, which doesn't seem possible on the quest at the moment.

    So three questions here:
    1. Am I missing a much simpler option here?
    2. Has anyone successfully run a shell command on the quest using Process before, and if so how?
    3. Has anyone figured how to restart adb or any other process on the quest that isn't an activity in an apk?
     
  2. Yann_de_Couessin

    Yann_de_Couessin

    Joined:
    Jan 2, 2015
    Posts:
    39
    That's a great idea, what I was looking for. Following ....

    Another usefull workaround could be casting with scrcpy into another Unity App for training of local multiplayer purpose :

    Quest + phone or tablet :

    The phone could receive the scrcpy stream wirelessly, and also send some scenarios to the user and show an interface !
    I ran some OSC commands to avoir Unet matchmaking of fixed IP, and it works great with this free asset
     
    rahuxx likes this.
  3. Darkroll

    Darkroll

    Joined:
    Jul 29, 2017
    Posts:
    8
    Hi,
    Do you have any news ?
    Thanks
     
  4. mattbenic

    mattbenic

    Joined:
    Nov 24, 2010
    Posts:
    38
    Unfortunately not. I wasn't able to get this working. We also tried using Photon to stream frames directly to a custom client app on the PC, but the performance on that wasn't great.
     
  5. toibry

    toibry

    Joined:
    Oct 19, 2020
    Posts:
    4
    Hi there,

    I'm not a developer or anything but let's say that I'm just a researcher and a thinker who's interested on the subject, I need this for my Oculus Quest to enjoy full experience and after reading lot's of articles on the net, I came across your article and here I gathered what it looks like a puzzle, that I hopefully can solve by gathering all of the rest of the ideas.

    So to short things out, how about to establish a wireless connection to the targeted device and using a shell command app that could send the port opening, I know it's not what the main target to this subject but we can at least upgrade the solution to be as easy and as handy as possible using any near phone and app anytime. I was hoping also to find an app for iOS.

    by the way read lot's of articles that found a way actually to do this wirelessly, but yet to read them and have my notes on these article very soon.

    I'm following this article, thanks for opening this up it's really helpful :)
     
  6. toibry

    toibry

    Joined:
    Oct 19, 2020
    Posts:
    4
    Update:

    After reading many articles, found this one the best as I would think, and I feel that the next challenge will be finding the IP of the Oculus Quest from within using another compalied APK app into it that does this. Hope that I'm getting you guys anywhere near of making it possible. :rolleyes:
     
  7. toibry

    toibry

    Joined:
    Oct 19, 2020
    Posts:
    4
    Update: How about online emulator or debugging using browser that is included already on Oculus? o_O
     
  8. toibry

    toibry

    Joined:
    Oct 19, 2020
    Posts:
    4
    update: found this website, and credit goes to this guy :). Please guys let me know if you found something :oops: