老套路先看图
说下原理:
使用adb命令启动server然后传递参数,service拿到参数后可以根据需求实现模拟控制APP
看代码
package cn.yhsh.adbinputserver.service;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import cn.yhsh.adbinputserver.utils.CommendUtils;
/**
* @author xiayiye5
* @date 2022/1/19 11:38
* adb输入传参使用方法如下 包名/启动的service全路径
* 播放 adb shell am start-foreground-service -n cn.yhsh.adbinputserve