[core] Remove PowerService
This commit is contained in:
parent
818f576f25
commit
036b87caad
|
|
@ -212,9 +212,9 @@ public class ConfigManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean reboot(boolean confirm, String reason, boolean wait) {
|
public static boolean reboot(boolean shutdown) {
|
||||||
try {
|
try {
|
||||||
LSPManagerServiceHolder.getService().reboot(confirm, reason, wait);
|
LSPManagerServiceHolder.getService().reboot(shutdown);
|
||||||
return true;
|
return true;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(App.TAG, Log.getStackTraceString(e));
|
Log.e(App.TAG, Log.getStackTraceString(e));
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,7 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
|
||||||
ConfigManager.startActivityAsUserWithFeature(new Intent(ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", info.packageName, null)), module.userId);
|
ConfigManager.startActivityAsUserWithFeature(new Intent(ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", info.packageName, null)), module.userId);
|
||||||
} else if (itemId == R.id.menu_force_stop) {
|
} else if (itemId == R.id.menu_force_stop) {
|
||||||
if (info.packageName.equals("android")) {
|
if (info.packageName.equals("android")) {
|
||||||
ConfigManager.reboot(false, null, false);
|
ConfigManager.reboot(false);
|
||||||
} else {
|
} else {
|
||||||
new AlertDialog.Builder(activity)
|
new AlertDialog.Builder(activity)
|
||||||
.setTitle(R.string.force_stop_dlg_title)
|
.setTitle(R.string.force_stop_dlg_title)
|
||||||
|
|
@ -479,7 +479,7 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
|
||||||
buttonView.setChecked(!isChecked);
|
buttonView.setChecked(!isChecked);
|
||||||
} else if (appInfo.packageName.equals("android")) {
|
} else if (appInfo.packageName.equals("android")) {
|
||||||
Snackbar.make(fragment.binding.snackbar, R.string.reboot_required, Snackbar.LENGTH_SHORT)
|
Snackbar.make(fragment.binding.snackbar, R.string.reboot_required, Snackbar.LENGTH_SHORT)
|
||||||
.setAction(R.string.reboot, v -> ConfigManager.reboot(false, null, false))
|
.setAction(R.string.reboot, v -> ConfigManager.reboot(false))
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ public class SettingsFragment extends BaseFragment {
|
||||||
SettingsFragment fragment = (SettingsFragment) getParentFragment();
|
SettingsFragment fragment = (SettingsFragment) getParentFragment();
|
||||||
if (result && fragment != null) {
|
if (result && fragment != null) {
|
||||||
Snackbar.make(fragment.binding.snackbar, R.string.reboot_required, Snackbar.LENGTH_SHORT)
|
Snackbar.make(fragment.binding.snackbar, R.string.reboot_required, Snackbar.LENGTH_SHORT)
|
||||||
.setAction(R.string.reboot, v -> ConfigManager.reboot(false, null, false))
|
.setAction(R.string.reboot, v -> ConfigManager.reboot(false))
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ import org.lsposed.lspd.ILSPManagerService;
|
||||||
import org.lsposed.lspd.models.Application;
|
import org.lsposed.lspd.models.Application;
|
||||||
import org.lsposed.lspd.models.UserInfo;
|
import org.lsposed.lspd.models.UserInfo;
|
||||||
|
|
||||||
|
import java.io.FileDescriptor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -194,8 +195,9 @@ public class LSPManagerService extends ILSPManagerService.Stub {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reboot(boolean confirm, String reason, boolean wait) throws RemoteException {
|
public void reboot(boolean shutdown) {
|
||||||
PowerService.reboot(confirm, reason, wait);
|
var value = shutdown ? "shutdown" : "reboot";
|
||||||
|
SystemProperties.set("sys.powerctl", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
* <!--This file is part of LSPosed.
|
|
||||||
*
|
|
||||||
* LSPosed is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* LSPosed is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 LSPosed Contributors-->
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lsposed.lspd.service;
|
|
||||||
|
|
||||||
import static org.lsposed.lspd.service.ServiceManager.TAG;
|
|
||||||
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.os.IPowerManager;
|
|
||||||
import android.os.RemoteException;
|
|
||||||
import android.os.ServiceManager;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class PowerService {
|
|
||||||
private static IPowerManager pm = null;
|
|
||||||
private static IBinder binder = null;
|
|
||||||
private static final IBinder.DeathRecipient recipient = new IBinder.DeathRecipient() {
|
|
||||||
@Override
|
|
||||||
public void binderDied() {
|
|
||||||
Log.w(TAG, "pm is dead");
|
|
||||||
binder.unlinkToDeath(this, 0);
|
|
||||||
binder = null;
|
|
||||||
pm = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static IPowerManager getPowerManager() {
|
|
||||||
if (binder == null && pm == null) {
|
|
||||||
binder = ServiceManager.getService("power");
|
|
||||||
if (binder == null) return null;
|
|
||||||
try {
|
|
||||||
binder.linkToDeath(recipient, 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) throws RemoteException {
|
|
||||||
IPowerManager pm = getPowerManager();
|
|
||||||
if (pm == null) return;
|
|
||||||
pm.reboot(confirm, reason, wait);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -42,7 +42,7 @@ interface ILSPManagerService {
|
||||||
|
|
||||||
void forceStopPackage(String packageName, int userId) = 23;
|
void forceStopPackage(String packageName, int userId) = 23;
|
||||||
|
|
||||||
void reboot(boolean confirm, String reason, boolean wait) = 24;
|
void reboot(boolean shutdown) = 24;
|
||||||
|
|
||||||
boolean uninstallPackage(String packageName, int userId) = 25;
|
boolean uninstallPackage(String packageName, int userId) = 25;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue