Fix NPE when leaving kids mode

Do not apply leash operations if we are leaving kids mode since the root task will be deleted.

Bug: 242873681
Test: 1. Select 3-button nav mode
      2. enable kids mode by below command:
         adb shell setting put secure nav_bar_kids_mode 1
      3. Swtich to gesture nav mode to exit kids mode and no crash
Change-Id: I04cab6854a40bcae42b8c83db2e6866e4f558cca
This commit is contained in:
Shawn Lin
2022-08-22 07:12:45 +00:00
parent f215542792
commit e01635e68f

View File

@@ -316,11 +316,13 @@ public class KidsModeTaskOrganizer extends ShellTaskOrganizer {
true /* onTop */);
wct.reorder(rootToken, mEnabled /* onTop */);
mSyncQueue.queue(wct);
final SurfaceControl rootLeash = mLaunchRootLeash;
mSyncQueue.runInSync(t -> {
t.setPosition(rootLeash, taskBounds.left, taskBounds.top);
t.setWindowCrop(rootLeash, taskBounds.width(), taskBounds.height());
});
if (mEnabled) {
final SurfaceControl rootLeash = mLaunchRootLeash;
mSyncQueue.runInSync(t -> {
t.setPosition(rootLeash, taskBounds.left, taskBounds.top);
t.setWindowCrop(rootLeash, taskBounds.width(), taskBounds.height());
});
}
}
private Rect calculateBounds() {