[core] Add reboot and force stop
This commit is contained in:
parent
9279fb03de
commit
e844450b23
|
|
@ -145,4 +145,14 @@ public class LSPManagerService extends ILSPManagerService.Stub {
|
|||
public PackageInfo getPackageInfo(String packageName, int flags, int uid) throws RemoteException {
|
||||
return PackageService.getPackageInfo(packageName, flags, uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceStopPackage(String packageName, int userId) throws RemoteException {
|
||||
ActivityManagerService.forceStopPackage(packageName, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reboot(boolean confirm, String reason, boolean wait) throws RemoteException {
|
||||
PowerService.reboot(confirm, reason, wait);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package io.github.lsposed.lspd.service;
|
||||
|
||||
import android.os.IBinder;
|
||||
import android.os.IPowerManager;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import static io.github.lsposed.lspd.service.ServiceManager.TAG;
|
||||
|
||||
public class PowerService {
|
||||
private static IPowerManager pm = null;
|
||||
private static IBinder binder = null;
|
||||
|
||||
public static IPowerManager getPowerManager() {
|
||||
if (binder == null && pm == null) {
|
||||
binder = ServiceManager.getService("power");
|
||||
if (binder == null) return null;
|
||||
try {
|
||||
binder.linkToDeath(new IBinder.DeathRecipient() {
|
||||
@Override
|
||||
public void binderDied() {
|
||||
Log.w(TAG, "pm is dead");
|
||||
binder.unlinkToDeath(this, 0);
|
||||
binder = null;
|
||||
pm = null;
|
||||
}
|
||||
}, 0);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, Log.getStackTraceString(e));
|
||||
}
|
||||
pm = IPowerManager.Stub.asInterface(binder);
|
||||
}
|
||||
return pm;
|
||||
}
|
||||
|
||||
public static void reboot(boolean confirm, String reason, boolean wait) {
|
||||
IPowerManager pm = getPowerManager();
|
||||
if (pm == null) return;
|
||||
pm.reboot(confirm, reason, wait);
|
||||
}
|
||||
}
|
||||
|
|
@ -32,6 +32,8 @@ public interface IActivityManager extends IInterface {
|
|||
String resultData, Bundle map, String[] requiredPermissions,
|
||||
int appOp, Bundle options, boolean serialized, boolean sticky, int userId);
|
||||
|
||||
void forceStopPackage(String packageName, int userId);
|
||||
|
||||
abstract class Stub extends Binder implements IActivityManager {
|
||||
|
||||
public static IActivityManager asInterface(IBinder obj) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package android.os;
|
||||
|
||||
public interface IPowerManager extends IInterface {
|
||||
void reboot(boolean confirm, String reason, boolean wait);
|
||||
|
||||
abstract class Stub extends Binder implements IPowerManager {
|
||||
|
||||
public static IPowerManager asInterface(IBinder obj) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,4 +44,8 @@ interface ILSPManagerService {
|
|||
boolean clearLogs(boolean verbose) = 21;
|
||||
|
||||
PackageInfo getPackageInfo(String packageName, int flags, int uid) = 22;
|
||||
|
||||
void forceStopPackage(String packageName, int userId) = 23;
|
||||
|
||||
void reboot(boolean confirm, String reason, boolean wait) = 24;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue