OSDN Git Service

Add null check in Launcher onNewIntent() before moveToDefaultScreen().
authorTony <twickham@google.com>
Mon, 26 Oct 2015 00:39:37 +0000 (17:39 -0700)
committerArne Coucheron <arco68@gmail.com>
Fri, 26 May 2017 22:17:08 +0000 (00:17 +0200)
commit5c6b5a27035a89b6633727e973144e101333af68
treef1344d3d43b8b662d17bd425ec45621e538a72d7
parent273db439991b7230f1adbf4502bc5f1ce01b211c
Add null check in Launcher onNewIntent() before moveToDefaultScreen().

There is a race condition that occurs primarily (maybe entirely) with
Android Auto, it seems because they hijack the Home intent or something
similar. I'm not exactly sure how Android Auto works, but if I pair my
phone with the Desktop Head Unit (car dashboard emulator), I can repro
the NPE fairly easily by simply force closing Android Auto and then
disconnecting my phone from the DHU. If I don't force close Android
Auto, then pressing home launches Android Auto or other apps that I
assume handle some custom intent, such as Car Home Ultra, instead of
normal Home intents such as Launcher3/Google Now Launcher. So I think
what's happening is that, when the phone is disconnected from the car,
Android Auto restores and launches the real home intent (Launcher 3)
around the same time that it destroys the previous home intent
(Android Auto, Car Home Ultra, etc.). This could cause the NPE if both
intents are actually Launcher 3, as is the case when Android Auto is
already closed, because mWorkspace is set to null in
Launcher#onDestroy() (something like onNewIntent() --> post() called
--> onDestroy() --> post() runs). This is consistent with the fact
that I can guarantee a repro if I use postDelayed() instead of post().

Long-winded explanation aside, I think this fix is safe, especially
since we already have a null check for mWorkspace in onNewIntent(),
just not inside the post().

Bug: 24610231

Change-Id: I42f75b83946f375d947be1961a1f2a03a3707a84
src/com/android/launcher3/Launcher.java