Return empty set instead of null when user is not set.
- Avoid iterating over null set when checking components for user that isn't currently active. This can happen if the user is changed, and the enabled component set is queried before the set has been rebuilt to include components for the new current user. Bug: 30165350 Change-Id: I4dadad84e6bd2728bea5711b936cba91f6791c99
This commit is contained in:
@@ -215,7 +215,11 @@ public class EnabledComponentsObserver implements SettingChangeListener {
|
||||
*/
|
||||
public ArraySet<ComponentName> getInstalled(int userId) {
|
||||
synchronized (mLock) {
|
||||
return mInstalledSet.get(userId);
|
||||
ArraySet<ComponentName> ret = mInstalledSet.get(userId);
|
||||
if (ret == null) {
|
||||
return new ArraySet<ComponentName>();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +231,12 @@ public class EnabledComponentsObserver implements SettingChangeListener {
|
||||
*/
|
||||
public ArraySet<ComponentName> getEnabled(int userId) {
|
||||
synchronized (mLock) {
|
||||
return mEnabledSet.get(userId);
|
||||
ArraySet<ComponentName> ret = mEnabledSet.get(userId);
|
||||
if (ret == null) {
|
||||
return new ArraySet<ComponentName>();
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user