summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Martinz <amartinz@shiftphones.com>2018-04-20 14:06:22 (GMT)
committerAlexander Martinz <amartinz@shiftphones.com>2018-04-27 10:49:53 (GMT)
commit18f229a51a8aad1bd359af1dc7aefc39b42596a3 (patch)
treebd6ac66124fa0326b65a90de7cd6fbcb2c9bc782
parentcfe2ebcd4298e898f9b3099dfb7b72433a839ae8 (diff)
downloadandroid_packages_apps_Trebuchet-18f229a51a8aad1bd359af1dc7aefc39b42596a3.zip
android_packages_apps_Trebuchet-18f229a51a8aad1bd359af1dc7aefc39b42596a3.tar.gz
android_packages_apps_Trebuchet-18f229a51a8aad1bd359af1dc7aefc39b42596a3.tar.bz2
PredictiveAppsProvider: fix null pointer exception
If component is null, we call ComponentName#getPackageName() on a null object reference. Happened when opening an app while it was upgraded. ---------- Stacktrace: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.ComponentName.getPackageName()' on a null object reference at com.android.launcher3.allapps.PredictiveAppsProvider.buildComponentString(PredictiveAppsProvider.java:99) at com.android.launcher3.allapps.PredictiveAppsProvider.updateComponentCount(PredictiveAppsProvider.java:32) at com.android.launcher3.Launcher.startActivitySafely(Launcher.java:2764) at com.android.launcher3.Launcher.startAppShortcutOrInfoActivity(Launcher.java:2520) at com.android.launcher3.Launcher.onClick(Launcher.java:2352) at android.view.View.performClick(View.java:6320) at android.view.View$PerformClick.run(View.java:25087) at android.os.Handler.handleCallback(Handler.java:869) at android.os.Handler.dispatchMessage(Handler.java:101) at android.os.Looper.loop(Looper.java:206) at android.app.ActivityThread.main(ActivityThread.java:6733) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:845) ---------- Issue: BUGBASH-1524 Change-Id: I970453f5da87c36e9915b8c0bbe9f1cd2302ec93 Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
-rw-r--r--src/com/android/launcher3/allapps/PredictiveAppsProvider.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/com/android/launcher3/allapps/PredictiveAppsProvider.java b/src/com/android/launcher3/allapps/PredictiveAppsProvider.java
index ba39094..43d7115 100644
--- a/src/com/android/launcher3/allapps/PredictiveAppsProvider.java
+++ b/src/com/android/launcher3/allapps/PredictiveAppsProvider.java
@@ -4,6 +4,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Process;
+import android.util.Log;
import com.android.launcher3.AppInfo;
import com.android.launcher3.Utilities;
@@ -17,6 +18,8 @@ import java.util.List;
import java.util.Set;
public class PredictiveAppsProvider {
+ private static final String TAG = "PredictiveAppsProvider";
+
private static final int NUM_PREDICTIVE_APPS_TO_HOLD = 9; // since we can't have more than 9 columns
private static final String PREDICTIVE_APPS_KEY = "predictive_apps";
@@ -29,6 +32,11 @@ public class PredictiveAppsProvider {
}
public void updateComponentCount(ComponentName component) {
+ if (component == null) {
+ Log.w(TAG, "Can not update component count because component is null!");
+ return;
+ }
+
String key = buildComponentString(component);
long current = mPrefs.getLong(key, 0);