Skip to content

Commit

Permalink
优化系统应用的卸载
Browse files Browse the repository at this point in the history
  • Loading branch information
ichtj committed Jun 28, 2024
1 parent 18ca009 commit b60a427
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import java.util.zip.ZipEntry;
Expand Down Expand Up @@ -370,11 +371,21 @@ public static void uninstall(String packageName) {
* @return
*/
public static boolean uninstallSilent(boolean isSys, boolean isReboot, String appName, String packageName) {
String apkPath="";
if (isSys){
try{
PackageManager packageManager =BaseIotUtils.getContext(). getPackageManager();
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
apkPath = new File(applicationInfo.sourceDir).getParent();
}catch(Throwable throwable){
}
}
String[] cmd = new String[]{
"mount -o rw,remount -t ext4 /system",
"rm -rf /system/priv-app/" + appName,
"rm -rf /system/app/" + appName,
"pm uninstall " + packageName,
(!apkPath.equals("")&&isSys)?"rm -rf "+apkPath+"*":"",
isReboot ? "reboot" : ""
};
ShellUtils.CommandResult commandResult = ShellUtils.execCommand(cmd, isRoot());
Expand Down

0 comments on commit b60a427

Please sign in to comment.