summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/util
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2016-08-24 16:23:09 -0700
committerHyunyoung Song <hyunyoungs@google.com>2016-08-24 16:23:09 -0700
commitada6cbe4efc709360ebfd0ecba2d7a80d9d55cd0 (patch)
tree2345519bd0a7e54b7f446ee84deb3ea58559ab67 /src/com/android/launcher3/util
parent527c27c04e116b9697d959090b2e4fc5f941abfb (diff)
downloadandroid_packages_apps_Trebuchet-ada6cbe4efc709360ebfd0ecba2d7a80d9d55cd0.tar.gz
android_packages_apps_Trebuchet-ada6cbe4efc709360ebfd0ecba2d7a80d9d55cd0.tar.bz2
android_packages_apps_Trebuchet-ada6cbe4efc709360ebfd0ecba2d7a80d9d55cd0.zip
Prevent against NPE inside ComponentKey
b/31063280 Change-Id: I71254fc1a3244fd6834ebf65923d194f17afc1ba
Diffstat (limited to 'src/com/android/launcher3/util')
-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();