version:beta

fix:
update:增加一些电量设置
This commit is contained in:
2022-07-23 10:05:30 +08:00
parent 5edeeb6fd4
commit 66787bb6a7
5 changed files with 451 additions and 18 deletions

View File

@@ -99,5 +99,47 @@ public class CmdUtil {
'}';
}
}
/**
* 执行 adb 命令
*
* @param cmd 命令
* @return
*/
public static StringBuffer shellExec(String cmd) {
Runtime mRuntime = Runtime.getRuntime(); //执行命令的方法
try {
//Process中封装了返回的结果和执行错误的结果
Process mProcess = mRuntime.exec(cmd); //加入参数
//使用BufferReader缓冲各个字符实现高效读取
//InputStreamReader将执行命令后得到的字节流数据转化为字符流
//mProcess.getInputStream()获取命令执行后的的字节流结果
BufferedReader mReader = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
//实例化一个字符缓冲区
StringBuffer mRespBuff = new StringBuffer();
//实例化并初始化一个大小为1024的字符缓冲区char类型
char[] buff = new char[1024];
int ch = 0;
//read()方法读取内容到buff缓冲区中大小为buff的大小返回一个整型值即内容的长度
//如果长度不为null
while ((ch = mReader.read(buff)) != -1) {
//就将缓冲区buff的内容填进字符缓冲区
mRespBuff.append(buff, 0, ch);
}
//结束缓冲
mReader.close();
Log.i("shell", "shellExec: " + mRespBuff);
//弹出结果
// Log.i("shell", "执行命令: " + cmd + "执行成功");
return mRespBuff;
} catch (IOException e) {
// 异常处理
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}

View File

@@ -31,6 +31,7 @@ public class ForegroundAppUtil {
}
public static void openTopApp(Context context) {
Log.e(TAG, "openTopApp: " + System.currentTimeMillis());
String topAppName = Settings.Global.getString(context.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY);
if (TextUtils.isEmpty(topAppName)) {
return;