处理上传异常,压缩后卸载原apk
This commit is contained in:
parent
827aaa21f8
commit
6d084c92e4
|
@ -39,6 +39,7 @@ import com.example.studyapp.utils.ShellUtils;
|
||||||
import com.example.studyapp.worker.CheckAccessibilityWorker;
|
import com.example.studyapp.worker.CheckAccessibilityWorker;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
@ -274,7 +275,11 @@ public class MainActivity extends AppCompatActivity {
|
||||||
LogFileUtil.logAndWrite(android.util.Log.DEBUG, "MainActivity", "----发送result------;" + currentScriptResult, null);
|
LogFileUtil.logAndWrite(android.util.Log.DEBUG, "MainActivity", "----发送result------;" + currentScriptResult, null);
|
||||||
if (currentScriptResult != null && !TextUtils.isEmpty(currentScriptResult)) {
|
if (currentScriptResult != null && !TextUtils.isEmpty(currentScriptResult)) {
|
||||||
TaskUtil.execSaveTask(this, androidId, taskId, currentScriptResult);
|
TaskUtil.execSaveTask(this, androidId, taskId, currentScriptResult);
|
||||||
|
try {
|
||||||
infoUpload(this, androidId, currentScriptResult);
|
infoUpload(this, androidId, currentScriptResult);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,6 +247,9 @@ public class TaskUtil {
|
||||||
zipFile.delete();
|
zipFile.delete();
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
//uninstall
|
||||||
|
String uninstall = "pm uninstall "+packAge;
|
||||||
|
String chmodResult = ShellUtils.execRootCmdAndGetResult(uninstall);
|
||||||
Log.e("TAG", "infoUpload compress finish: ");
|
Log.e("TAG", "infoUpload compress finish: ");
|
||||||
// 上传压缩文件
|
// 上传压缩文件
|
||||||
if (!zipFile.exists()) {
|
if (!zipFile.exists()) {
|
||||||
|
@ -257,9 +260,6 @@ public class TaskUtil {
|
||||||
String chmod = "chmod 777 \"" + safeNewPath + "\"";
|
String chmod = "chmod 777 \"" + safeNewPath + "\"";
|
||||||
uploadFile(zipFile);
|
uploadFile(zipFile);
|
||||||
|
|
||||||
//uninstall
|
|
||||||
String uninstall = "pm uninstall "+packAge;
|
|
||||||
String chmodResult = ShellUtils.execRootCmdAndGetResult(uninstall);
|
|
||||||
// 清理临时文件
|
// 清理临时文件
|
||||||
delFileSh(copiedAPKFile.getAbsolutePath());
|
delFileSh(copiedAPKFile.getAbsolutePath());
|
||||||
ShellUtils.execRootCmdAndGetResult(chmod);
|
ShellUtils.execRootCmdAndGetResult(chmod);
|
||||||
|
|
Loading…
Reference in New Issue