frameworks/base/…/MdmPolicy.java
写好接口供上层调用
public void shutingdown(){
RebootShutdownControl.doshutdown(mContext);
}
public void reboot(){
android.util.Log.d(TAG,"reboot()",new Exception());
RebootShutdownControl.doreboot(mContext);
}
frameworks/base/…/RebootShutdownControl.java
具体实现
class RebootShutdownControl {
public static void doreboot(Context context) {
IPowerManager mPowerManager = IPowerManager.Stub.asInterface(ServiceManager.getService("power"));
try{
mPowerManager.reboot(false, null, true);
}catch (Exception e){
Log.d("RebootShutdownControl","重启失败");
}
}
public static void doshutdown(Context context) {
IPowerManager mPowerManager = IPowerManager.Stub.asInterface(ServiceManager.getService("power"));
try{
mPowerManager.shutdown(false, null, false);
}catch (Exception e){
Log.d("RebootShutdownControl","关机失败");
}
}
}