summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony <twickham@google.com>2015-10-25 17:39:37 -0700
committerTony Wickham <twickham@google.com>2015-10-26 01:31:53 +0000
commitc1739096b44770cd9a3894970f9e86b29043ead9 (patch)
treeab5eaa9e5678355a9b34382107e28480ac44577a
parent917d434c5ce93ae86b43a3825c9cbc3541843f5e (diff)
downloadandroid_packages_apps_Trebuchet-c1739096b44770cd9a3894970f9e86b29043ead9.tar.gz
android_packages_apps_Trebuchet-c1739096b44770cd9a3894970f9e86b29043ead9.tar.bz2
android_packages_apps_Trebuchet-c1739096b44770cd9a3894970f9e86b29043ead9.zip
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
-rw-r--r--src/com/android/launcher3/Launcher.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 6dc044d43..c7229f0ae 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1920,7 +1920,7 @@ public class Launcher extends Activity
final View v = getWindow().peekDecorView();
if (v != null && v.getWindowToken() != null) {
- InputMethodManager imm = (InputMethodManager)getSystemService(
+ InputMethodManager imm = (InputMethodManager) getSystemService(
INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
@@ -1959,7 +1959,9 @@ public class Launcher extends Activity
mWorkspace.post(new Runnable() {
@Override
public void run() {
- mWorkspace.moveToDefaultScreen(true);
+ if (mWorkspace != null) {
+ mWorkspace.moveToDefaultScreen(true);
+ }
}
});
}