源码路径:
frameworks\base\services\core\java\com\android\server\power\ShutdownThread.java
+private static final int MAX_SHUTDOWN_TIME = 5*1000; //增加 5s 可以适当调整以满足关机动画会播放完整
+ private static long shutdownTime = 0; //增加
private static void beginShutdownSequence(Context context) {
.....
File fileDefault = new File("/system/media/shutdownanimation.zip");
File file = new File("/data/theme/overlay/shutdownanimation.zip");
boolean hasShutdownAnimation = file.exists() || fileDefault.exists();
+shutdownTime = SystemClock.elapsedRealtime() + MAX_SHUTDOWN_TIME; //增加
......
}
public void run() {
+ long shutdownDelay = shutdownTime - SystemClock.elapsedRealtime();//增加
+if (shutdownDelay > 0) {//增加
+ Log.i(TAG, "Shutdown delay:"+shutdownDelay);//增加
+ SystemClock.sleep(shutdownDelay);//增加
+ }//增加
rebootOrShutdown(mReboot, mRebootReason);
}