안 드 로 이 드 가 기 계 를 다시 시작 하 는 것 에 대해 이전 작업 은 수정 사항 을 표시 합 니 다.
시스템 이 재 부팅 될 때 Activity Manager Service 에서 Task Persister 류 의 restore Tasks Locked 방법 으로 읽 습 니 다. 다음 코드 를 보십시오. Activity Manager Service 가 원본 코드 에 있 는 위치:. / framework / base / services / core / java / com / android / server / am / Activity Manager Service. java:
[java] view plain copy
public void systemReady(final Runnable goingCallback) {
synchronized(this) {
if (mSystemReady) {
// If we're done calling all the receivers, run the next "boot phase" passed in
// by the SystemServer
if (goingCallback != null) {
goingCallback.run();
}
return;
}
mLocalDeviceIdleController
= LocalServices.getService(DeviceIdleController.LocalService.class);
// Make sure we have the current profile info, since it is needed for
// security checks.
updateCurrentProfileIdsLocked();
mRecentTasks.clear();
mRecentTasks.addAll(mTaskPersister.restoreTasksLocked());
mRecentTasks.cleanupLocked(UserHandle.USER_ALL);
mTaskPersister.startPersisting();
// ,
}
현재 고객 에 게 필요 한 것 은 장치 가 재 부팅 될 때 지난번 에 저 장 된 응용 프로그램 을 표시 하지 않 아 도 된다 는 것 이다.이 수 요 는 간단 합 니 다. Task Persister 클래스 에 저 장 된 데 이 터 를 삭제 하 는 방법 을 추가 합 니 다. Activity Manager Service 가 초기 화 될 때 호출 하면 됩 니 다. 코드 를 보 세 요. Task Persister 에 삭제 하 는 방법 을 추가 합 니 다.
[java] view plain copy
private void removeAllTasks(File[] files) { if (files == null) { Slog.e(TAG, "File error accessing recents directory (too many files open?)."); return; }
for (int fileNdx = 0; fileNdx < files.length; ++fileNdx) {
File file = files[fileNdx];
file.delete();
}
}
public void removeAllTasks() {
removeAllTasks(sTasksDir.listFiles());
removeAllTasks(sImagesDir.listFiles());
}
Activity Manager Service 클래스 가 초기 화 될 때 호출:
[java] view plain copy
public void systemReady(final Runnable goingCallback) { synchronized(this) { if (mSystemReady) { // If we're done calling all the receivers, run the next "boot phase" passed in // by the SystemServer if (goingCallback != null) { goingCallback.run(); } return; }
mLocalDeviceIdleController
= LocalServices.getService(DeviceIdleController.LocalService.class);
// Make sure we have the current profile info, since it is needed for
// security checks.
updateCurrentProfileIdsLocked();
/ / 여기 서 데 이 터 를 읽 기 전에 mTaskPersister. removeAllTasks () 를 삭제 합 니 다.
mRecentTasks.clear();
mRecentTasks.addAll(mTaskPersister.restoreTasksLocked());
mRecentTasks.cleanupLocked(UserHandle.USER_ALL);
mTaskPersister.startPersisting();
} / / 부분 코드 생략, 핵심 부분 유지
이렇게 됐 습 니 다. Task Persister 와 Activity Manager Service 의 소스 코드 를 보고 더 깊이 알 수 있 습 니 다.