summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2016-08-24 23:30:04 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-08-24 23:30:05 +0000
commitc760da5688be2dc0b5afe690685fc91d6d56ab0c (patch)
tree9540f6161c87135a58375ca8f74d528c333855da /src
parentd56b157004c32becdc73ea69625b98c959a34745 (diff)
parentada6cbe4efc709360ebfd0ecba2d7a80d9d55cd0 (diff)
downloadandroid_packages_apps_Trebuchet-c760da5688be2dc0b5afe690685fc91d6d56ab0c.tar.gz
android_packages_apps_Trebuchet-c760da5688be2dc0b5afe690685fc91d6d56ab0c.tar.bz2
android_packages_apps_Trebuchet-c760da5688be2dc0b5afe690685fc91d6d56ab0c.zip
Merge "Prevent against NPE inside ComponentKey" into ub-launcher3-calgary-polish
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/util/ComponentKey.java6
-rw-r--r--src/com/android/launcher3/util/Preconditions.java6
2 files changed, 10 insertions, 2 deletions
diff --git a/src/com/android/launcher3/util/ComponentKey.java b/src/com/android/launcher3/util/ComponentKey.java
index 144b411fa..5882f217d 100644
--- a/src/com/android/launcher3/util/ComponentKey.java
+++ b/src/com/android/launcher3/util/ComponentKey.java
@@ -32,8 +32,8 @@ public class ComponentKey {
private final int mHashCode;
public ComponentKey(ComponentName componentName, UserHandleCompat user) {
- assert (componentName != null);
- assert (user != null);
+ Preconditions.assertNotNull(componentName);
+ Preconditions.assertNotNull(user);
this.componentName = componentName;
this.user = user;
mHashCode = Arrays.hashCode(new Object[] {componentName, user});
@@ -58,6 +58,8 @@ public class ComponentKey {
componentName = ComponentName.unflattenFromString(componentKeyStr);
user = UserHandleCompat.myUserHandle();
}
+ Preconditions.assertNotNull(componentName);
+ Preconditions.assertNotNull(user);
mHashCode = Arrays.hashCode(new Object[] {componentName, user});
}
diff --git a/src/com/android/launcher3/util/Preconditions.java b/src/com/android/launcher3/util/Preconditions.java
index 3760c6372..89353e110 100644
--- a/src/com/android/launcher3/util/Preconditions.java
+++ b/src/com/android/launcher3/util/Preconditions.java
@@ -26,6 +26,12 @@ import com.android.launcher3.config.ProviderConfig;
*/
public class Preconditions {
+ public static void assertNotNull(Object o) {
+ if (ProviderConfig.IS_DOGFOOD_BUILD && o == null) {
+ throw new IllegalStateException();
+ }
+ }
+
public static void assertWorkerThread() {
if (ProviderConfig.IS_DOGFOOD_BUILD && !isSameLooper(LauncherModel.getWorkerLooper())) {
throw new IllegalStateException();