Android TV Integration - Issuing adb root command

Hi there!

I have a wall-mounted Android POE-enabled tablet which I’ve successfully connected to the Android TV integration. The tablet contains an outer LED frame that can be controlled by issuing an ADB command to a mounted device ("echo w 0x05 > ./sys/devices/platform/led_con_h/zigbee_reset").
That mechanism enables me to show the status of the locking state of the alarm panel which is a great solution to remind everybody to unarm the panel.

In order to get the command successfully forwarded to the mounted device I need to elevate adbd having root access. This can be done by using the Android platform tools ("adb root") on my computer once connected to the device.

Anyway, each time the tablet is restarted, this elevation needs to be issued again. Is there a way to issue that command in the python ADB implementation that comes with the Android TV integration?

Welcome!
@Patrick_C Can you share the model of you Android POE device? Thx!

Sure, the model itself is a no-name chinese one. As with nearly all kind of chinese tablets, the tablet comes without any kind of security updates but is already pre-rooted and works for my intended usage like a charm (Fully Kiosk Browser locked, ADB via Ethernet).

I hope the admins are fine with posting a link to Aliexpress:

I came across another promising solution “ADB insecure” by Chainfire which has been repacked by someone at XDA-Developers to be compatible with Android 7+ devices. I will try that approach as well as I am not having the mood for dealing with modifying the bootloader on my own.

Interesting, thank you for the info. I hope your setup works to your expectations.

Can’t you just create an automation that runs adb root at HA startup?

Unfortunately my attempt with ADB insecure did not work.

The automation is a good idea. Did not think about that! Thank you.

The best trigger would be if the device was offline and went back online because the command needs to be executed after startup of the Android tablet. This should be easily done by either using the Ubiquiti integration or a simple ping test. The only thing I am really struggling with is to issue that adb root command via the python implementation. It seems to me that each command beside “HOME”, “UP”, etc. will be applied to the shell.

Hope someone can help me out.

Hi Patrick,

I think I bought the same panel. Did you solve the issue?
Can you activate the LED frame from another PC?

I also want to have the status of my Pi/Domoticz secure panel supported by ilumination of the LED frame. I use Dashticz in Firefox on the tablet.

Regards,

Fred

Hi Guys, thank you for you buying from us. I am Fiona from YIXU Industry CO., LTD, the manufacture of the tablet you bought. Please feel free to contact me if you need any technical support.
Also, for how to control the LED indicator, please refer to below page, hope it helps.

Below is the adb command for your reference too.

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;

public String adbcommand(String command) { //adb命令实现类
Process process = null;
DataOutputStream os = null;
String excresult = “”;
try {
process = Runtime.getRuntime().exec("su -c "+command );
os = new DataOutputStream(process.getOutputStream());
//os.writeBytes(command + “\n”);
//os.writeBytes(“exit\n”);
os.flush();

        BufferedReader in = new BufferedReader(new InputStreamReader(
                process.getInputStream()));
        StringBuffer stringBuffer = new StringBuffer();
        String line = null;
        while ((line = in.readLine()) != null) {
            stringBuffer.append(line + " ");
        }
        excresult = stringBuffer.toString();
        in.close();
        process.destroy();
    } catch (Exception e) {
        e.printStackTrace();
    }finally {

    }
    return excresult;

}

adbcommand(“echo 0 >sys/class/backlight/backlight/brightness”); 0-255

adbcommand(“echo w 0x03 > ./sys/devices/platform/led_con_h/zigbee_reset && echo w 0x04 > ./sys/devices/platform/led_con_h/zigbee_reset”);

adbcommand(“system/xbin/test 201301181659 201301181700 enable”); //时间必须为这种格式,
前面为关机时间(年月日时分),后面为开机时间。enable为起作用, disable不起作用。

//The time must be in this format,
The front is the shutdown time (year, month, day, hour and minute), and the back is the power-on time. enable works, disable does not work.

adbcommand(“dpm set-device-owner de.allnet.allnetmedicalfrontbutton/.DeviceAdmin”); //Add This

    DevicePolicyManager mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
    ComponentName testDeviceAdmin = new ComponentName(this, MainActivity.class);
    Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
    intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, testDeviceAdmin );
    intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "...");
    startActivity(intent);
service: androidtv.adb_command
data:
  command: su -c 'echo w 0x02 > ./sys/devices/platform/led_con_h/zigbee_reset'
target:
  entity_id: media_player.android_tv_10_0_3_155