Fix potential NPE and also add more log.

Test: Manual test, launch, tc.

Change-Id: I9e540ee8a0daa540ef1cc1b02a9a46c772773586
2 files changed