Check for null values when copying enforcedAdmin in QSTile.State.
Bug: 26612685
Change-Id: I8228d1dffc3623d3589b51c6c33f07cc53605ef2
diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java
index 2706e25..d8c21af 100644
--- a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java
@@ -233,6 +233,16 @@
this.userId = userId;
}
+ public EnforcedAdmin(EnforcedAdmin other) {
+ if (other == null) {
+ throw new IllegalArgumentException();
+ }
+ this.component = other.component;
+ this.userId = other.userId;
+ }
+
+ public EnforcedAdmin() {}
+
@Override
public boolean equals(Object object) {
if (object == this) return true;
@@ -255,12 +265,10 @@
public void copyTo(EnforcedAdmin other) {
if (other == null) {
- other = new EnforcedAdmin();
+ throw new IllegalArgumentException();
}
other.component = component;
other.userId = userId;
}
-
- public EnforcedAdmin() {}
}
}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
index de7c02d..56364e9 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
@@ -480,7 +480,13 @@
other.dualLabelContentDescription = dualLabelContentDescription;
other.autoMirrorDrawable = autoMirrorDrawable;
other.disabledByPolicy = disabledByPolicy;
- enforcedAdmin.copyTo(other.enforcedAdmin);
+ if (enforcedAdmin == null) {
+ other.enforcedAdmin = null;
+ } else if (other.enforcedAdmin == null) {
+ other.enforcedAdmin = new EnforcedAdmin(enforcedAdmin);
+ } else {
+ enforcedAdmin.copyTo(other.enforcedAdmin);
+ }
return changed;
}