mirror of
https://github.com/revanced/jadb.git
synced 2024-06-10 07:07:49 +02:00
add forceInstall for application already exist
add a way to remove installed apk fix issue
This commit is contained in:
parent
639ecdb633
commit
c52447e098
|
@ -46,26 +46,22 @@ public class PackageManager {
|
|||
if (!result.contains("Success")) throw new JadbException(getErrorMessage(operation, target, result));
|
||||
}
|
||||
|
||||
public void install(File apkFile) throws IOException, JadbException {
|
||||
public void install(File apkFile,boolean forceInstall) throws IOException, JadbException {
|
||||
RemoteFile remote = new RemoteFile("/sdcard/tmp/" + apkFile.getName());
|
||||
device.push(apkFile, remote);
|
||||
InputStream s = device.executeShell("pm", "install", Bash.quote(remote.getPath()));
|
||||
InputStream s;
|
||||
if(forceInstall){
|
||||
s= device.executeShell("pm", "install", "-r", Bash.quote(remote.getPath()));
|
||||
}else{
|
||||
s= device.executeShell("pm", "install", Bash.quote(remote.getPath()));
|
||||
}
|
||||
String result = Stream.readAll(s, Charset.forName("UTF-8"));
|
||||
// TODO: Remove remote file
|
||||
verifyOperation("install", apkFile.getName(), result);
|
||||
}
|
||||
|
||||
public void forceInstall(File apkFile) throws IOException, JadbException {
|
||||
RemoteFile remote = new RemoteFile("/sdcard/tmp/" + apkFile.getName());
|
||||
device.push(apkFile, remote);
|
||||
InputStream s = device.executeShell("pm", "install","-r", Bash.quote(remote.getPath()));
|
||||
String result = Stream.readAll(s, Charset.forName("UTF-8"));
|
||||
// TODO: Remove remote file
|
||||
s=device.executeShell("rm", "-f",Bash.quote(remote.getPath()));
|
||||
Stream.readAll(s, Charset.forName("UTF-8"));
|
||||
verifyOperation("install", apkFile.getName(), result);
|
||||
}
|
||||
|
||||
|
||||
public void uninstall(Package name) throws IOException, JadbException {
|
||||
InputStream s = device.executeShell("pm", "uninstall", name.toString());
|
||||
String result = Stream.readAll(s, Charset.forName("UTF-8"));
|
||||
|
|
Loading…
Reference in New Issue
Block a user