HDMI for Channels

Looks like my quote got mangled.

Try

adb shell dumpsys package | grep -Eo "^[[:space:]]+[0-9a-f]+[[:space:]]+ com.nexstar.newsnation/[^[:space:]]+" | grep -oE "[^[:space:]]+$"

Also not sure why the forum is adding a space after the + before com

Yup, I figured that part out, but I have Haystack and Newsnation installed on my AndroidTV device and running both of these commands in Terminal unfortunately still yields no output:

adb -s 10.0.1.122 shell dumpsys package | grep -Eo "^[[:space:]]+[0-9a-f]+[[:space:]]+ com.haystack.android/[^[:space:]]+" | grep -oE "[^[:space:]]+$"
adb -s 10.0.1.122 shell dumpsys package | grep -Eo "^[[:space:]]+[0-9a-f]+[[:space:]]+ com.nexstar.newsnation/[^[:space:]]+" | grep -oE "[^[:space:]]+$"

This worked for me:

adb shell am start -a android.intent.action.VIEW -n com.haystack.android/.tv.ui.activities.LoadingActivity
1 Like

Maybe one of these will help?

com.newsnation.firetv/exo.PlayerActivity
com.newsnation.firetv/.DailyMotionPlayerActivity
com.newsnation.firetv/exo.PlayerActivity
com.newsnation.firetv/.DailyMotionPlayerActivity
com.newsnation.firetv/exo.PlayerActivity
com.newsnation.firetv/.DailyMotionPlayerActivity
com.newsnation.firetv/exo.PlayerActivity
com.newsnation.firetv/.DailyMotionPlayerActivity
com.newsnation.firetv/exo.PlayerActivity
com.newsnation.firetv/.DailyMotionPlayerActivity
com.newsnation.firetv/.SplashActivity

That worked for me too, for Haystack News. Sweet! Thanks.

But for NewsNation...

I tried those but they didn't help. Also tried replacing "com.newsnation.firetv" with "com.nexstar.newsnation" as that is the package name my devices report, but it still didn't launch the NewsNation app. Hmm. I will keep tinkering and will report back.

Has anyone here been successful finding an adb command to launch the NewsNation app?

Just discovered we can also be the cool kinds on the block and get the WeatherScan thing going.

Simply send the adb command:

adb shell am start -a android.intent.action.VIEW -d   https://weatherscan.net/            
1 Like

Thank you very much for your help. That did work for me wonderfully with Haystack. Now I will take some of your suggested troubleshooting here and put that toward other android apps I may be interested in launching.

2 Likes

Cool! What browser does it open in? My devices are saying they don't have an app for that, wondering what else I should install or sideload, hmm.

In my case it was Amazon Silk - Amazons browser on Fire TV Cube

Does Firefox exist in app store?

1 Like

Not in the search I just did. The Play Store lists a bunch of other browsers. I'm checking them out. Awhile back I remember sideloading Chrome on a different AndroidTV, not sure that's the way to go for this though.

I would rather have Chrome. Going to look into side loading that.

1 Like

In the interest of a teachable moment for me, could someone explain to me how do an IS_ASLEEP check in Windows .bat as opposed to .sh. I have done most of the .sh to .bat converting on my own concerning this project, but I'm not particularly skilled in either and would appreciate the insight. The code below is kind of from @cyoungers for .sh.

IS_ASLEEP=`adb -s 192.168.0.27:5555 shell dumpsys display | grep mScreenState=OFF`
if [ $IS_ASLEEP ];
then
adb -s 192.168.1.135 shell input keyevent KEYCODE_WAKEUP; sleep 2
fi

I just wanna do that, but in .bat.

Thanks.

Try timeout 5

Oh I'm not trying to figure out how to pause or sleep. I have those commands installed. I am trying to do the code to check to see if the device is asleep.

Oh, sorry. Not sure on that one.

adb -s %device% shell "dumpsys power | grep =Awake" >NUL
set ret=%errorlevel%
if "%ret%" == "1" adb -s %device% shell input keyevent KEYCODE_WAKEUP ; sleep 2
2 Likes

You are wise @Edwin_Perez. Thank you very much. Works like a charm now.

If anyone is interested this my current prebmitunes.bat

@echo off
set IP=192.168.1.135:5555
set WAKE=input keyevent KEYCODE_WAKEUP
set HOME=input keyevent KEYCODE_HOME

adb connect %IP%

adb -s %IP% shell "dumpsys power | grep =Awake" >NUL
set ret=%errorlevel%
if "%ret%" == "1" adb -s %IP% shell %WAKE% ; sleep 3
adb -s %IP% shell %HOME%

With the awake check, I put in a 3 second pause to let the device wake up before continuing running scripts. Strictly speaking it looks like any keyevent will wake the device but I choose to stick with the dedicated wakeup command. I only put the devices asleep once daily as a "clean up" operation.

Lots happening with the @KompilerDJ (@sullrich on GitHub) fork of the original androidhdmi-for-channels repository, which I am now building Docker versions of the project against. With the Docker version of the project, there's no need to install Go or ADB directly on the host, so it's a couple of steps easier to get up-and-running with this extension.

The M3U data has been made generic, and is hosted by the container -- so no need to add custom channels tuning and guide data in Channels DVR, you can just use the URL http://[hostname or ip]:[port]/m3u/[appname]. And, as previously mentioned the scripts have been made generic, so it's no longer necessary to have script variations for each virtual tuner.

So far, only @KompilerDJ and I have contributed scripts for a particular streaming device and app combinations, but I'm confident more of you will add to the script code base so that not everyone has to start from scratch. :slight_smile: It's now also possible to use the channel name from the M3U for tuning in a couple of different ways, either as an input to a search box if the app doesn't support URL style tunning, or as UUID or other unique identifier -- which supports having a single, generic tuning statement in bmitune.sh.

So, for example here are my current scripts for firetv/directv:

#!/bin/bash
#prebmitune.sh for firetv/directv

STREAMERIP="$1"
ADB_CMD="adb -s $1 shell"
WAKE="input keyevent KEYCODE_WAKEUP"
HOME="input keyevent KEYCODE_HOME"
APP_LAUNCH="tv.youi.clientapp.AppActivity"
APP_NAME="com.att.tv"
APP_PID=$($ADB_CMD pidof $APP_NAME)

adb connect $STREAMERIP

if [ ! -z $APP_PID ]; then
  $ADB_CMD $WAKE
  $ADB_CMD am start -n $APP_NAME/$APP_LAUNCH
  echo "Waking $STREAMERIP"
  touch /tmp/wake
else
  $ADB_CMD $WAKE
  $ADB_CMD am start -n $APP_NAME/$APP_LAUNCH
  echo "Starting $APP_NAME on $STREAMERIP"
fi
#!/bin/bash
#bmitune.sh for firetv/directv

ADB_CMD="adb -s $2 shell"
CHANNEL=\""$1\""
CHANNEL_NAME=$(awk -F, '/channel-id='"$CHANNEL"'/ {print $2}' m3u/directv.m3u)
CHANNEL_NAME=$(echo $CHANNEL_NAME | sed 's/^/"/;s/$/"/')
SEARCH="input keyevent 20; sleep 3; input keyevent 22 22 22 22; input keyevent 20; sleep 3; input keyevent 66; sleep 2"
SELECT="input keyevent 85; sleep 3; input keyevent 20 20 66"

#Variable delay based on whether app was running or needed to be launched
if [ -f /tmp/wake ]; then
  sleep 8 
  rm /tmp/wake
else
  sleep 24 
fi

#Tuning is based on channel name values from directv.m3u.
$ADB_CMD $SEARCH
$ADB_CMD input text $CHANNEL_NAME
$ADB_CMD $SELECT
#!/bin/bash
#stopbmitune.sh for firetv/directv

STREAMERIP="$1"
ADB_CMD="adb -s $1 shell"
STOP="input keyevent KEYCODE_HOME"
SLEEP="input keyevent KEYCODE_SLEEP"

#Stop Video
$ADB_CMD $STOP; sleep 2
echo "Streaming stopped for $STREAMERIP"
$ADB_CMD $SLEEP
echo "Sleep initiated for $STREAMERIP"

Pretty simple right?

And here's the latest annotated docker compose for this container:

version: '3.9'
services:
  androidhdmi-for-channels:
    image: bnhf/androidhdmi-for-channels:alpha
    container_name: ah4channels-alpha
    hostname: ah4channels
    dns_search: localdomain # Specify the name of your LAN's domain, usually local or localdomain
    ports:
      - 5037:5037 # Port used by adb-server
      - 7654:7654 # Port used by Channels androidhdmi-for-channels proxy
    environment:
      - IPADDRESS=${IPADDRESS} # Hostname or IP address to be used in M3U file
      - NUMBER_TUNERS=${NUMBER_TUNERS} # Number of tuners you'd like defined 1, 2, 3 or 4 supported
      - TUNER1_IP=${TUNER1_IP} # Streaming device #1 with adb port in the form hostname:port or ip:port
      - TUNER2_IP=${TUNER2_IP} # Streaming device #2 with adb port in the form hostname:port or ip:port
      - TUNER3_IP=${TUNER3_IP} # Streaming device #3 with adb port in the form hostname:port or ip:port
      - TUNER4_IP=${TUNER4_IP} # Streaming device #4 with adb port in the form hostname:port or ip:port
      - TUNER1_URL=${TUNER1_URL} # Full URL for tuner #1 in the form http://hostname/stream or http://ip/stream
      - TUNER2_URL=${TUNER2_URL} # Full URL for tuner #2 in the form http://hostname/stream or http://ip/stream
      - TUNER3_URL=${TUNER3_URL} # Full URL for tuner #3 in the form http://hostname/stream or http://ip/stream
      - TUNER4_URL=${TUNER4_URL} # Full URL for tuner #4 in the form http://hostname/stream or http://ip/stream
      - STREAMER_APP=${STREAMER_APP} # Streaming device name and streaming app you're using in the form streamer/app (use lowercase with slash between as shown)
    volumes:
      - /data2/androidhdmi-for-channels:/opt/scripts # pre/stop/bmitune.sh scripts will be stored in this bound host directory under streamer/app
      - /data/adb:/root/.android # Persistent data directory for adb keys
    restart: unless-stopped

And the environment variables I'm using:

IPADDRESS=htpc6
NUMBER_TUNERS=1
TUNER1_IP=amazon-1170239ab:5555
TUNER1_URL=http://encoder_14121/0.ts
STREAMER_APP=firetv/directv

For those looking to jump start their androidhdmi-for-channels project, in the immortal words of the Mandalorian: "This is the way"

4 Likes

I appreciate you two putting in all this work. :pray: It was such a struggle for me to get my setup working, and it seems stable right now, that I'm afraid to touch it to try this method. But if you ever get speed in tuning improvements (but perhaps that is streaming-device constrained), I'd go for it.

1 Like

I encountered a new issue using the traditional (go) method of doing this: - something got stale with the adb session and I saw "adb.exe: device unauthorized" - I had to do a "adb kill-server" in order to resume - here's the output of trying to run the scripts manually in this state:

already connected to 192.168.2.43:5555
already connected to 192.168.2.43:5555
already connected to 192.168.2.43:5555
adb.exe: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
adb.exe: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
adb.exe: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
adb.exe: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.

C:\chdvr-hdmi>adb kill-server

C:\chdvr-hdmi>adb connect 192.168.2.43

  • daemon not running; starting now at tcp:5037
  • daemon started successfully
    connected to 192.168.2.43:5555

C:\chdvr-hdmi>stopbmitune.bat

C:\chdvr-hdmi>adb devices
List of devices attached
192.168.2.43:5555 device

Would it make sense to add 'adb kill-server' to the end of the stopbmitune.bat script? Or to the start of the prebmitune.bat script?