Merge "PackageSetting now owns its PackageUserState" into sc-dev am: edb6d7f8a8
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15363235 Change-Id: Id388edd1555ed66b7bcdd937e78f5768381a211b
This commit is contained in:
@@ -176,6 +176,10 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
name = orig.name;
|
name = orig.name;
|
||||||
realName = orig.realName;
|
realName = orig.realName;
|
||||||
doCopy(orig);
|
doCopy(orig);
|
||||||
|
// Clone the user states.
|
||||||
|
for (int i = 0; i < mUserState.size(); i++) {
|
||||||
|
mUserState.put(mUserState.keyAt(i), new PackageUserState(mUserState.valueAt(i)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInstallerPackageName(String packageName) {
|
public void setInstallerPackageName(String packageName) {
|
||||||
@@ -314,6 +318,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
|
|
||||||
void setInstalled(boolean inst, int userId) {
|
void setInstalled(boolean inst, int userId) {
|
||||||
modifyUserState(userId).installed = inst;
|
modifyUserState(userId).installed = inst;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean getInstalled(int userId) {
|
boolean getInstalled(int userId) {
|
||||||
@@ -326,6 +331,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
|
|
||||||
void setInstallReason(int installReason, int userId) {
|
void setInstallReason(int installReason, int userId) {
|
||||||
modifyUserState(userId).installReason = installReason;
|
modifyUserState(userId).installReason = installReason;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getUninstallReason(int userId) {
|
int getUninstallReason(int userId) {
|
||||||
@@ -334,10 +340,13 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
|
|
||||||
void setUninstallReason(@UninstallReason int uninstallReason, int userId) {
|
void setUninstallReason(@UninstallReason int uninstallReason, int userId) {
|
||||||
modifyUserState(userId).uninstallReason = uninstallReason;
|
modifyUserState(userId).uninstallReason = uninstallReason;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean setOverlayPaths(OverlayPaths overlayPaths, int userId) {
|
boolean setOverlayPaths(OverlayPaths overlayPaths, int userId) {
|
||||||
return modifyUserState(userId).setOverlayPaths(overlayPaths);
|
boolean returnValue = modifyUserState(userId).setOverlayPaths(overlayPaths);
|
||||||
|
onChanged();
|
||||||
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
OverlayPaths getOverlayPaths(int userId) {
|
OverlayPaths getOverlayPaths(int userId) {
|
||||||
@@ -346,7 +355,10 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
|
|
||||||
boolean setOverlayPathsForLibrary(String libName, OverlayPaths overlayPaths,
|
boolean setOverlayPathsForLibrary(String libName, OverlayPaths overlayPaths,
|
||||||
int userId) {
|
int userId) {
|
||||||
return modifyUserState(userId).setSharedLibraryOverlayPaths(libName, overlayPaths);
|
boolean returnValue = modifyUserState(userId)
|
||||||
|
.setSharedLibraryOverlayPaths(libName, overlayPaths);
|
||||||
|
onChanged();
|
||||||
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, OverlayPaths> getOverlayPathsForLibrary(int userId) {
|
Map<String, OverlayPaths> getOverlayPathsForLibrary(int userId) {
|
||||||
@@ -395,6 +407,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
|
|
||||||
void setCeDataInode(long ceDataInode, int userId) {
|
void setCeDataInode(long ceDataInode, int userId) {
|
||||||
modifyUserState(userId).ceDataInode = ceDataInode;
|
modifyUserState(userId).ceDataInode = ceDataInode;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean getStopped(int userId) {
|
boolean getStopped(int userId) {
|
||||||
@@ -403,6 +416,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
|
|
||||||
void setStopped(boolean stop, int userId) {
|
void setStopped(boolean stop, int userId) {
|
||||||
modifyUserState(userId).stopped = stop;
|
modifyUserState(userId).stopped = stop;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean getNotLaunched(int userId) {
|
boolean getNotLaunched(int userId) {
|
||||||
@@ -411,6 +425,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
|
|
||||||
void setNotLaunched(boolean stop, int userId) {
|
void setNotLaunched(boolean stop, int userId) {
|
||||||
modifyUserState(userId).notLaunched = stop;
|
modifyUserState(userId).notLaunched = stop;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean getHidden(int userId) {
|
boolean getHidden(int userId) {
|
||||||
@@ -419,6 +434,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
|
|
||||||
void setHidden(boolean hidden, int userId) {
|
void setHidden(boolean hidden, int userId) {
|
||||||
modifyUserState(userId).hidden = hidden;
|
modifyUserState(userId).hidden = hidden;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getDistractionFlags(int userId) {
|
int getDistractionFlags(int userId) {
|
||||||
@@ -427,6 +443,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
|
|
||||||
void setDistractionFlags(int distractionFlags, int userId) {
|
void setDistractionFlags(int distractionFlags, int userId) {
|
||||||
modifyUserState(userId).distractionFlags = distractionFlags;
|
modifyUserState(userId).distractionFlags = distractionFlags;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean getSuspended(int userId) {
|
boolean getSuspended(int userId) {
|
||||||
@@ -487,6 +504,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
|
|
||||||
void setInstantApp(boolean instantApp, int userId) {
|
void setInstantApp(boolean instantApp, int userId) {
|
||||||
modifyUserState(userId).instantApp = instantApp;
|
modifyUserState(userId).instantApp = instantApp;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean getVirtulalPreload(int userId) {
|
boolean getVirtulalPreload(int userId) {
|
||||||
@@ -495,6 +513,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
|
|
||||||
void setVirtualPreload(boolean virtualPreload, int userId) {
|
void setVirtualPreload(boolean virtualPreload, int userId) {
|
||||||
modifyUserState(userId).virtualPreload = virtualPreload;
|
modifyUserState(userId).virtualPreload = virtualPreload;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUserState(int userId, long ceDataInode, int enabled, boolean installed, boolean stopped,
|
void setUserState(int userId, long ceDataInode, int enabled, boolean installed, boolean stopped,
|
||||||
@@ -547,20 +566,24 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
|
|
||||||
void setEnabledComponents(ArraySet<String> components, int userId) {
|
void setEnabledComponents(ArraySet<String> components, int userId) {
|
||||||
modifyUserState(userId).enabledComponents = components;
|
modifyUserState(userId).enabledComponents = components;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDisabledComponents(ArraySet<String> components, int userId) {
|
void setDisabledComponents(ArraySet<String> components, int userId) {
|
||||||
modifyUserState(userId).disabledComponents = components;
|
modifyUserState(userId).disabledComponents = components;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEnabledComponentsCopy(ArraySet<String> components, int userId) {
|
void setEnabledComponentsCopy(ArraySet<String> components, int userId) {
|
||||||
modifyUserState(userId).enabledComponents = components != null
|
modifyUserState(userId).enabledComponents = components != null
|
||||||
? new ArraySet<String>(components) : null;
|
? new ArraySet<String>(components) : null;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDisabledComponentsCopy(ArraySet<String> components, int userId) {
|
void setDisabledComponentsCopy(ArraySet<String> components, int userId) {
|
||||||
modifyUserState(userId).disabledComponents = components != null
|
modifyUserState(userId).disabledComponents = components != null
|
||||||
? new ArraySet<String>(components) : null;
|
? new ArraySet<String>(components) : null;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageUserState modifyUserStateComponents(int userId, boolean disabled, boolean enabled) {
|
PackageUserState modifyUserStateComponents(int userId, boolean disabled, boolean enabled) {
|
||||||
@@ -582,10 +605,12 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
|
|
||||||
void addDisabledComponent(String componentClassName, int userId) {
|
void addDisabledComponent(String componentClassName, int userId) {
|
||||||
modifyUserStateComponents(userId, true, false).disabledComponents.add(componentClassName);
|
modifyUserStateComponents(userId, true, false).disabledComponents.add(componentClassName);
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addEnabledComponent(String componentClassName, int userId) {
|
void addEnabledComponent(String componentClassName, int userId) {
|
||||||
modifyUserStateComponents(userId, false, true).enabledComponents.add(componentClassName);
|
modifyUserStateComponents(userId, false, true).enabledComponents.add(componentClassName);
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean enableComponentLPw(String componentClassName, int userId) {
|
boolean enableComponentLPw(String componentClassName, int userId) {
|
||||||
@@ -593,6 +618,9 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
boolean changed = state.disabledComponents != null
|
boolean changed = state.disabledComponents != null
|
||||||
? state.disabledComponents.remove(componentClassName) : false;
|
? state.disabledComponents.remove(componentClassName) : false;
|
||||||
changed |= state.enabledComponents.add(componentClassName);
|
changed |= state.enabledComponents.add(componentClassName);
|
||||||
|
if (changed) {
|
||||||
|
onChanged();
|
||||||
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -601,6 +629,9 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
boolean changed = state.enabledComponents != null
|
boolean changed = state.enabledComponents != null
|
||||||
? state.enabledComponents.remove(componentClassName) : false;
|
? state.enabledComponents.remove(componentClassName) : false;
|
||||||
changed |= state.disabledComponents.add(componentClassName);
|
changed |= state.disabledComponents.add(componentClassName);
|
||||||
|
if (changed) {
|
||||||
|
onChanged();
|
||||||
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -610,6 +641,9 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
? state.disabledComponents.remove(componentClassName) : false;
|
? state.disabledComponents.remove(componentClassName) : false;
|
||||||
changed |= state.enabledComponents != null
|
changed |= state.enabledComponents != null
|
||||||
? state.enabledComponents.remove(componentClassName) : false;
|
? state.enabledComponents.remove(componentClassName) : false;
|
||||||
|
if (changed) {
|
||||||
|
onChanged();
|
||||||
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,6 +735,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
PackageSettingBase setPath(@NonNull File path) {
|
PackageSettingBase setPath(@NonNull File path) {
|
||||||
this.mPath = path;
|
this.mPath = path;
|
||||||
this.mPathString = path.toString();
|
this.mPathString = path.toString();
|
||||||
|
onChanged();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,7 +757,9 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
|
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
|
||||||
public boolean overrideNonLocalizedLabelAndIcon(@NonNull ComponentName component,
|
public boolean overrideNonLocalizedLabelAndIcon(@NonNull ComponentName component,
|
||||||
@Nullable String label, @Nullable Integer icon, @UserIdInt int userId) {
|
@Nullable String label, @Nullable Integer icon, @UserIdInt int userId) {
|
||||||
return modifyUserState(userId).overrideLabelAndIcon(component, label, icon);
|
boolean returnValue = modifyUserState(userId).overrideLabelAndIcon(component, label, icon);
|
||||||
|
onChanged();
|
||||||
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -732,6 +769,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
*/
|
*/
|
||||||
public void resetOverrideComponentLabelIcon(@UserIdInt int userId) {
|
public void resetOverrideComponentLabelIcon(@UserIdInt int userId) {
|
||||||
modifyUserState(userId).resetOverrideComponentLabelIcon();
|
modifyUserState(userId).resetOverrideComponentLabelIcon();
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -741,6 +779,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
*/
|
*/
|
||||||
public void setSplashScreenTheme(@UserIdInt int userId, @Nullable String themeName) {
|
public void setSplashScreenTheme(@UserIdInt int userId, @Nullable String themeName) {
|
||||||
modifyUserState(userId).splashScreenTheme = themeName;
|
modifyUserState(userId).splashScreenTheme = themeName;
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -776,6 +815,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
*/
|
*/
|
||||||
public void setStatesOnCommit() {
|
public void setStatesOnCommit() {
|
||||||
incrementalStates.onCommit(IncrementalManager.isIncrementalPath(getPathString()));
|
incrementalStates.onCommit(IncrementalManager.isIncrementalPath(getPathString()));
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -783,6 +823,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
*/
|
*/
|
||||||
public void setIncrementalStatesCallback(IncrementalStates.Callback callback) {
|
public void setIncrementalStatesCallback(IncrementalStates.Callback callback) {
|
||||||
incrementalStates.setCallback(callback);
|
incrementalStates.setCallback(callback);
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -791,6 +832,7 @@ public abstract class PackageSettingBase extends SettingBase {
|
|||||||
*/
|
*/
|
||||||
public void setLoadingProgress(float progress) {
|
public void setLoadingProgress(float progress) {
|
||||||
incrementalStates.setProgress(progress);
|
incrementalStates.setProgress(progress);
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getFirstInstallTime() {
|
public long getFirstInstallTime() {
|
||||||
|
|||||||
Reference in New Issue
Block a user