[manager-service] Add uninstallPackage
This commit is contained in:
parent
cc6155b496
commit
d6ea773aa8
|
|
@ -20,10 +20,14 @@
|
|||
package io.github.lsposed.lspd.service;
|
||||
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.VersionedPackage;
|
||||
import android.os.IBinder;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
import de.robv.android.xposed.XposedBridge;
|
||||
|
|
@ -32,6 +36,8 @@ import io.github.lsposed.lspd.BuildConfig;
|
|||
import io.github.lsposed.lspd.ILSPManagerService;
|
||||
import io.github.lsposed.lspd.utils.ParceledListSlice;
|
||||
|
||||
import static io.github.lsposed.lspd.service.ServiceManager.TAG;
|
||||
|
||||
public class LSPManagerService extends ILSPManagerService.Stub {
|
||||
|
||||
LSPManagerService() {
|
||||
|
|
@ -155,4 +161,15 @@ public class LSPManagerService extends ILSPManagerService.Stub {
|
|||
public void reboot(boolean confirm, String reason, boolean wait) throws RemoteException {
|
||||
PowerService.reboot(confirm, reason, wait);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean uninstallPackage(String packageName) throws RemoteException {
|
||||
try {
|
||||
PackageService.uninstallPackage(new VersionedPackage(packageName, PackageManager.VERSION_CODE_HIGHEST));
|
||||
return true;
|
||||
} catch (InterruptedException | InvocationTargetException | NoSuchMethodException | InstantiationException | IllegalAccessException e) {
|
||||
Log.e(TAG, e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ public class PackageService {
|
|||
}
|
||||
}
|
||||
|
||||
private static void uninstallPackage(VersionedPackage versionedPackage) throws RemoteException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
|
||||
public static void uninstallPackage(VersionedPackage versionedPackage) throws RemoteException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
pm.getPackageInstaller().uninstallExistingPackage(versionedPackage, "com.android.shell", new IntentSenderAdaptor() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class PowerService {
|
|||
return pm;
|
||||
}
|
||||
|
||||
public static void reboot(boolean confirm, String reason, boolean wait) {
|
||||
public static void reboot(boolean confirm, String reason, boolean wait) throws RemoteException {
|
||||
IPowerManager pm = getPowerManager();
|
||||
if (pm == null) return;
|
||||
pm.reboot(confirm, reason, wait);
|
||||
|
|
|
|||
|
|
@ -48,4 +48,6 @@ interface ILSPManagerService {
|
|||
void forceStopPackage(String packageName, int userId) = 23;
|
||||
|
||||
void reboot(boolean confirm, String reason, boolean wait) = 24;
|
||||
|
||||
boolean uninstallPackage(String packageName) = 25;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue