A complete list of Python adb operation commands for Starlink fingerprint phones

Starlink fingerprint phone supports one-click new phone solution, and also supports overseas Tiktok. It also comes with a method to obtain TK username. The following is the adb operation command provided by the official website, which is simple and easy to use.

"""Someone who doesn't understand Earth V: TiktokLM or Tik382"""

import cv2
import ctypes
importsys
import os
import time
from xml.dom import minidom
import xml.etree.ElementTree as ET

#Load dynamic link library
import numpy as np


# myt rpc lib
class MytRpc(object):
    def __init__(self) -> None:
        # Replace self._lib_PATH with your own link library path
        self._lib_PATH = os.path.dirname(os.path.abspath(__file__)) + "/lib/libmytrpc.so"
        self._handle = 0
        self.ptr = None
        if os.path.exists(self._lib_PATH) == False:
            self._lib_PATH = os.path.dirname(os.path.abspath(__file__)) + "/libmytrpc.so"

    def __del__(self):
        if self._handle > 0:
            self._rpc.closeDevice(self._handle)

    # initialization
    def init(self, ip, port, timeout):
        ret = False
        # if os.path.exists(self._lib_PATH) == True:
        if sys.platform == "linux":
            self._rpc = ctypes.CDLL(self._lib_PATH)
        else:
            # self._rpc = ctypes.WinDLL(self._lib_PATH)
            self._rpc = ctypes.WinDLL('D:/small_et/x64/libmytrpc.dll')
        b_time = int(time.time())
        while True:
            self._handle = self._rpc.openDevice(bytes(ip, "utf-8"), port, 10)
            if self._handle > 0:
                ret = True
                print("rpc " + ip + " ok!")
                break
            else:
                now = int(time.time())
                if now - b_time > timeout:
                    print("rpc " + ip + " timeout " + str(timeout))
                    break
                else:
                    time.sleep(10)
        else:
            print("File not Found: " + self._lib_PATH)
        return ret

    # Release pointer memory
    def free_rpc(self):
        try:
            if self.ptr:
                print("Release pointer memory")
                self._rpc.freeRpcPtr(self.ptr)
        except Exception as e:
            print(e)

    # Excuting an order
    def exec_cmd(self, cmd):
        ret = False
        if self._handle > 0:
            # cmd = "pm install /data/local/TikTok_26.5.3_apkcombo.com.apk"
            # cmd = "ls"
            self._rpc.execCmd.restype = ctypes.c_char_p
            ptr = self._rpc.execCmd(self._handle, ctypes.c_int(1), ctypes.c_char_p(cmd.encode('utf-8')))
            if ptr is not None:
                ret = ptr.decode('utf-8')
                print("exec " + cmd + " :" + ret)
            else:
                ret = True
        return ret

    #Export node information
    # bDumpAll export all nodes 0 1
    def dumpNodeXml(self, bDumpAll):
        ret = False
        try:
            if self._handle > 0:
                self._rpc.dumpNodeXml.argtypes = [ctypes.c_long, ctypes.c_int]
                self._rpc.dumpNodeXml.restype = ctypes.c_void_p
                ptr = self._rpc.dumpNodeXml(self._handle, bDumpAll)
                p2 = ctypes.cast(ptr, ctypes.c_char_p)

                ret = p2.value.decode("utf-8")
                # Release pointer memory
                self._rpc.freeRpcPtr.argtypes = [ctypes.c_void_p]

                return ret
        except Exception as e:
            print(e)
            return ret
        # finally:
        # # Release pointer memory
        # self._rpc.freeRpcPtr(ptr)

    # Export screenshots as bytes array
    # type 0 png 1 jpg
    # quality Image quality 0-100
    # Return byte array
    def takeCaptrueCompress(self, type, quality):
        ret = False
        if self._handle > 0:
            dataLen = ctypes.c_int(0)
            ptr = self._rpc.takeCaptrueCompress(self._handle, type, quality, ctypes.byref(dataLen))
            if ptr:
                try:
                    # Convert ptr to bytes object
                    buf = ctypes.cast(ptr, ctypes.POINTER(ctypes.c_ubyte * dataLen.value)).contents
                    # Convert bytes object to image using OpenCV
                    img_array = bytes(buf)
                    ret = img_array
                    # img_np = np.frombuffer(img_array, dtype=np.uint8)
                    # img = cv2.imdecode(img_np, cv2.IMREAD_COLOR)

                    # # Display image
                    # cv2.imshow("Image", img)
                    #cv2.waitKey(0)
                finally:
                    # Release pointer memory
                    self._rpc.freeRpcPtr(ptr)
        return ret

    #Text input
    def sendText(self, text):
        ret = False
        if self._handle > 0:
            ret = self._rpc.takeCaptrueCompress(self._handle, ctypes.c_char_p(text.encode('utf-8')))
        return ret

    #Open the specified application
    def openApp(self, pkg):
        ret = False
        if self._handle > 0:
            ret = self._rpc.openApp(self._handle, ctypes.c_char_p(pkg.encode('utf-8')))
        return ret

    # Stop the specified application
    def stopApp(self, pkg):
        ret = False
        if self._handle > 0:
            ret = self._rpc.stopApp(self._handle, ctypes.c_char_p(pkg.encode('utf-8')))
        return ret

    # Get the orientation of the current screen
    # 4 directions (0,1,2,3)
    def getDisplayRotate(self):
        ret = False
        if self._handle > 0:
            ret = self._rpc.getDisplayRotate(self._handle)
        return ret

    # Press operation
    def touchDown(self, finger_id, x, y):
        ret = False
        if self._handle > 0:
            ret = self._rpc.touchDown(self._handle, finger_id, x, y)
        return ret

    # Pop up operation
    def touchUp(self, finger_id, x, y):
        ret = False
        if self._handle > 0:
            ret = self._rpc.touchUp(self._handle, finger_id, x, y)
        return ret

    # Sliding operation
    def touchMove(self, finger_id, x, y):
        ret = False
        if self._handle > 0:
            ret = self._rpc.touchMove(self._handle, finger_id, x, y)
        return ret

    # Click operation
    def touchClick(self, finger_id, x, y):
        ret = False
        if self._handle > 0:
            ret = self._rpc.touchClick(self._handle, finger_id, x, y)
        return ret

    # Key operation
    def keyPress(self, code):
        ret = False
        if self._handle > 0:
            ret = self._rpc.keyPress(self._handle, code)
        return ret


# Get username
def get_user_name(comm):
    try:
        rpc = MytRpc()
        # c_ip = "192.168.10.127"
        rpc_port = 9083
        if rpc.init(comm, rpc_port, 120):
            time.sleep(1)
            xml = rpc.dumpNodeXml(0)
            rpc.free_rpc()
            if xml:
                strs = xml.split("" resource-id="com.zhiliaoapp.musically:id/kcq"")
                if len(strs) > 1:
                    names = strs[0].split("@")
                    if len(names) > 1:
                        name = names[len(names) - 1]
                        return name

        return None
    except Exception as e:
        return None
        #doc = minidom.parseString(s)
        # et = ET.fromstring(s)
        # for chile in et[0]:
        # print(chile.attrib)
        # print("=======")