Remote Installation of IPTV App on Android TV Box N1 - Remote Viewing of Set-Top Box Screen, and More

N1RemoteControl

Practical test of remote assistance for an Android TV box, remote control of a set-top box (remote control of an Android TV), remote assistance in installing apps on a family member’s set-top box (including deletion, app management, etc.), and remote operation of the N1 TV box.

Usage

Remote control of a set-top box, installing IPTV apps on smart Android set-top boxes (or Android TVs) for the elderly.

Remote installation of apps on a family member’s set-top box, remote operation of the N1 TV box.

Acts as a remote controller, realizing most remote control functions.

Remote assistance for operating Android TV boxes.

How to Use

Steps

(Provided you have already configured remote access to your router, I have set up a remote penetration connection using frps and frpc, and then used NPM to reverse proxy the router’s web control page, this series of operations makes subsequent implementations much smoother)

  1. Activate the N1 Android TV box, turn it on, or use the set-top box remote control

    1. Find the IP address of the Android box (or Android TV) in the router
    2. Method to check if the device is activated, ping the box’s IP. If the box’s IP is pingable, skip this step.
  2. Set up the remote FRP server (server-side)

    1. See the specific article: Setting up FRP Intranet Penetration Service with Docker. Skip this step if you already have a usable frps server.
  3. Set up the frpc client on the router where the controlled-end set-top box is located

    1. See the specific article: Setting up FRP Intranet Penetration Service>Setting Application 4
  4. ADB connection command: adb connect 192.168.6.216:5555

    1. To check if it’s connected: adb devices, see if the device IP and port are listed
  5. [Optional] ADB installation command: adb -s 192.168.6.216:5555 install ***.apk

    Example installation of Perfect Player (Note: Use double quotes if the apk file and path are complex)

    adb -s 192.168.6.216:5555 install "~/Downloads/com.niklabs.pp_1.6.0.1-60105_minAPI16(arm64-v8a)(nodpi)_apkmirror.com.apk"

  6. Remote viewing of the screen and control: scrcpy --tcpip=192.168.6.216:5555

    1. See the specific article: Screen Mirroring from Android Phone to Computer, Controlling and Displaying Android Phone on Computer, Scrcpy Software for Phone and Computer Synchronization
    2. The goal of control is to operate the set-top box or TV with a mouse and keyboard. Click to open the app, click settings, and use the keyboard to input IPTV live sources.
    3. [Optional] Any other actions that can be performed locally with a remote control

Related Content

If you are interested in related topics such as Android TV boxes, the following content may be helpful:

Implementation Method

Real Problems

  1. To resolve the issue of connecting the set-top box to a secondary router on the second floor, while the smartphone for remote assistance is connected to the primary router on the first floor.
  2. How to determine the open ports for remote control?
    1. This needs to be open to scan the set-top box properly.

This issue cannot be resolved. The approach needs to be reconsidered (the strategy of not using remote control).

The principle is similar to remote controlling a smartphone, but it’s a bit more challenging. Too many security settings present obstacles to effective remote assistance for the elderly at home.

Steps/Methods/Complex Process

[Optional Step] Use QtScrcpy to activate the device:

  1. In QtScrcpy, set the wireless 192.168.6.216, port 5555, click “wireless connection”

    1. In the left-hand list, such as: Phone-192.168.6.216:5555; there should be an ADB run command; what exactly is it?
      1. adb run AdbProcessImpl::out:connected to 192.168.6.216:5555
      2. It’s actually equivalent to the adb command: adb connect 192.168.6.216:5555
    2. Click: Install sndcpy
    3. Click: Start Service
  2. Enter

    1
    scrcpy -e

    in Terminal

    1. The newly added device will be the device connected in the previous step (it will display the IP:port)

Indeed, the Android N1 set-top box can also be connected using scrcpy -e, enabling remote control. This allows remote configuration of apps on the N1 set-top box, preventing the elderly from struggling with the remote control (complex operations, such as configuring DIY sources using the virtual keyboard on the remote control).

Shortcomings/Flaws

  1. Sound does not transmit, but it doesn’t matter as it’s not intended for remote TV watching. Moreover, this N1 serves as a service that allows remote connection to watch IPTV and movies.

    1. The issue was due to the outdated version of the Android system on the box.

      1
      2
      3
      4
      [server] INFO: Device: [Phicomm] Phicomm p230 (Android 7.1.2)                                                       
      [server] WARN: Audio disabled: it is not supported before Android 11
      INFO: Renderer: metal
      WARN: Demuxer 'audio': stream explicitly disabled by the device
  2. The menu button on the box remote control cannot be used; only left-click is possible.

    1. This is not an issue; it’s sufficient. It only means the menu cannot be operated remotely, nothing more.

Next Step: FRP Mapping/Penetration

The next step is the prerequisite of FRP mapping out the 5555 port and configuring the frpc client; it’s also a form of penetration.

Faced with the inability to locate the IP of the set-top box on the Padavan, as it is not in the WIFI network (connected via a wired connection), how to find the IP of the N1 box?

Through the Padavan UI query: Network Information > Traffic Monitoring https://k2pzl.carlzeng.com:4443/Main_BWMon.asp

1
Found the FRPS server at 192.168.6.116:6006, and frpc was port-mapped to 192.168.123.189:5555

By binding the set-top box’s IP to the MAC address in the DHCP on the router, the box’s IP won’t change, and frpc will always find the correct box IP when running (accurate positioning).

1
This way, `scrcpy -e` will display two clients!

Next Step: Remote Control with Scrcpy

How to install an app on the Android N1 set-top box using ADB commands

In theory, the ADB command can easily accomplish the goal of installing an app (I believe I wrote a method before: The Only Available Android Emulator on Apple M1)

  1. Place the app to be installed in a local directory on your computer (e.g., ~/Downloads)
  2. Use the command adb install /*.apk
  3. Specific process:
1
2
3
4
- adb devices                                                                               
List of devices attached
192.168.6.116:6006 offline
192.168.6.216:5555 device

At this point, it’s possible to manually select one of the devices from the list, as the next commands need a specific device to interact with.

1
- adb -s 7f1c864e shell

After executing the command, we can obtain shell execution permission for the Android device.

1
- adb -s 192.168.6.216:5555 install /Users/carlzeng/Downloads/Love\ TV\ 20231127/Love\ TV\  简约版.apk

This way, the desired app is successfully installed on the Android N1 set-top box.

Troubleshooting and Solutions

Inability to connect to the FRP-mapped SSH service

1
2
ssh admin@192.168.6.116 -p 6008                                                     
Unable to negotiate with 192.168.6.116 port 6008: no matching key exchange method found. Their offer: diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,kexguess2@matt.ucc.asn.au

After modifying ~/.ssh/config:

1
2
KexAlgorithms +diffie-hellman-group1-sha1                                                                         
Ciphers 3des-cbc

After the modification, the error became:

1
Unable to negotiate with 192.168.6.116 port 6008: no matching host key type found. Their offer: ssh-rsa,ssh-dss     

Finally, the resolution employed was:

1
2
3
ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa root@192.168.6.116 -p 6008

#The default password for K2P SSH is admin

This SSH error was inspired by: I get the error “no matching host key type found. Their offer: ssh-rsa” when trying to connect with SSH

The SSH password for K2P is the default admin (different from the password for logging into the web page), a risky backdoor action (it is advisable to disable the SSH service by default on the K2P device)

ADB Shell Shutdown

1
adb -s 192.168.6.216:5555 shell

After entering the shell, use the command:

To shut down: reboot -p

After shutdown, network wake cannot be used, is there a solution?

To restart: reboot

K2P Original Version and Flashing Note

The original K2P version is the most stable for wireless relay. The original version of the K2P system has a feature called “wireless expansion.” In other words, if you want to use the K2P for wireless relay, flash it back to the original version.

K2P Wireless Expansion

I used this original version but could not smoothly capture IPTV packets, it caught the tcpdump command tcpdump -i any -w /tmp/iptv.cap. I also downloaded Wireshark, but couldn’t download the iptv.cap from /tmp, and I found a solution (moved the file to or mounted it in the web’s static directory): mv /tmp/iptv.cap /www/luci-static/fonts/iptv.cap. However, I encountered mv: write error: No space left on device.

I also tried mount --bind /tmp/iptv.cap /www/web-static/fonts/iptv.cap, but encountered errors due to space constraints.

Thanks for the solution source: Backup Method for Phicomm K2P B1 Version (Broadcom Solution) 5Gbps Wireless Gigabit Router Original Firmware

Basically, what I’m looking for is packet capture.

Inspirations

Screen Mirroring from Android Phone to Computer, Controlling and Displaying Android Phone on Computer, Scrcpy Software for Phone and Computer Synchronization

Setting up FRP Intranet Penetration Service with Docker

Nginx Proxy Manager Repair Notes

How to Change the Default 80 Management Port of LEDE and X86_64 OpenWrt

Internet TV Resources - IPTV Live TV Station Sources

The Only Available Android Emulator on Apple M1

Further Reading and Application

Just now, I thought about sharing the set-top box and considered making scrcpy web-based. Then I searched and found that:

  1. Original: Smartphones can also be dockerized, creating a virtual smartphone in a webpage. But what are the applications of this? (What’s the use?)
  2. There is also ws-scrcpy, a scrcpy web prototype, a web client for Genymobile/scrcpy, and more.
    1. With this tool, the screen of the set-top box can be displayed in real-time on the Web (it’s just the basic application to watch TV and movies).
    2. Additionally, it allows for real-time remote viewing and control of Android system devices (such as: Android phones, Android TVs, Android set-top boxes…)

Web client prototype for scrcpy

Dockerizing Android Web Remote Desktop, Access through Browser

[Using Docker to Run ws-scrcpy: Realizing