Add NPE protection when finish Bug: 271524675 Test: local test Change-Id: I74bb54f2e591534b411589c150ce0bd993c2e6dd