use of android.content.om.OverlayInfo in project android_frameworks_base by ResurrectionRemix.
the class OverlayManagerSettings method setState.
void setState(@NonNull final String packageName, final int userId, final int state, final boolean shouldWait) throws BadKeyException {
final SettingsItem item = select(packageName, userId);
if (item == null) {
throw new BadKeyException(packageName, userId);
}
final OverlayInfo previous = item.getOverlayInfo();
item.setState(state);
final OverlayInfo current = item.getOverlayInfo();
if (previous.state == STATE_NOT_APPROVED_UNKNOWN) {
notifyOverlayAdded(current, shouldWait);
notifySettingsChanged();
} else if (current.state != previous.state) {
notifyOverlayChanged(current, previous, shouldWait);
notifySettingsChanged();
}
}
use of android.content.om.OverlayInfo in project android_frameworks_base by ResurrectionRemix.
the class OverlayManagerServiceImpl method onGetEnabledOverlayPaths.
List<String> onGetEnabledOverlayPaths(@NonNull final String targetPackageName, final int userId) {
final List<OverlayInfo> overlays = mSettings.getOverlaysForTarget(targetPackageName, userId);
final List<String> paths = new ArrayList<>(overlays.size());
for (final OverlayInfo oi : overlays) {
if (oi.isEnabled()) {
paths.add(oi.baseCodePath);
}
}
return paths;
}
use of android.content.om.OverlayInfo in project android_frameworks_base by ResurrectionRemix.
the class OverlayManagerServiceImpl method onSwitchUser.
/*
* Call this when switching to a new Android user. Will return a list of
* target packages that must refresh their overlays. This list is the union
* of two sets: the set of targets with currently active overlays, and the
* set of targets that had, but no longer have, active overlays.
*/
List<String> onSwitchUser(final int newUserId) {
if (DEBUG) {
Slog.d(TAG, "onSwitchUser newUserId=" + newUserId);
}
final Set<String> packagesToUpdateAssets = new ArraySet<>();
final Map<String, List<OverlayInfo>> tmp = mSettings.getOverlaysForUser(newUserId);
final Map<String, OverlayInfo> storedOverlayInfos = new ArrayMap<>(tmp.size());
for (final List<OverlayInfo> chunk : tmp.values()) {
for (final OverlayInfo oi : chunk) {
storedOverlayInfos.put(oi.packageName, oi);
}
}
for (PackageInfo overlayPackage : mPackageManager.getOverlayPackages(newUserId)) {
final OverlayInfo oi = storedOverlayInfos.get(overlayPackage.packageName);
if (oi == null || !oi.targetPackageName.equals(overlayPackage.overlayTarget)) {
if (oi != null) {
packagesToUpdateAssets.add(oi.targetPackageName);
}
mSettings.init(overlayPackage.packageName, newUserId, overlayPackage.overlayTarget, overlayPackage.applicationInfo.getBaseCodePath());
}
try {
final PackageInfo targetPackage = mPackageManager.getPackageInfo(overlayPackage.overlayTarget, newUserId);
updateState(targetPackage, overlayPackage, newUserId);
} catch (OverlayManagerSettings.BadKeyException e) {
Slog.e(TAG, "failed to update settings", e);
mSettings.remove(overlayPackage.packageName, newUserId);
}
packagesToUpdateAssets.add(overlayPackage.overlayTarget);
storedOverlayInfos.remove(overlayPackage.packageName);
}
// installed and should be removed
for (final OverlayInfo oi : storedOverlayInfos.values()) {
mSettings.remove(oi.packageName, oi.userId);
removeIdmapIfPossible(oi);
packagesToUpdateAssets.add(oi.targetPackageName);
}
// remove target packages that are not installed
final Iterator<String> iter = packagesToUpdateAssets.iterator();
while (iter.hasNext()) {
String targetPackageName = iter.next();
if (mPackageManager.getPackageInfo(targetPackageName, newUserId) == null) {
iter.remove();
}
}
return new ArrayList<String>(packagesToUpdateAssets);
}
use of android.content.om.OverlayInfo in project android_frameworks_base by crdroidandroid.
the class OverlayManagerSettings method setUpgrading.
void setUpgrading(@NonNull final String packageName, final int userId, final boolean newValue) throws BadKeyException {
final SettingsItem item = select(packageName, userId);
if (item == null) {
throw new BadKeyException(packageName, userId);
}
if (newValue == item.isUpgrading()) {
// nothing to do
return;
}
if (newValue) {
final OverlayInfo oi = item.getOverlayInfo();
item.setUpgrading(true);
item.setState(STATE_NOT_APPROVED_UNKNOWN);
notifyOverlayRemoved(oi, false);
} else {
item.setUpgrading(false);
}
notifySettingsChanged();
}
use of android.content.om.OverlayInfo in project android_frameworks_base by crdroidandroid.
the class OverlayManagerSettings method setState.
void setState(@NonNull final String packageName, final int userId, final int state, final boolean shouldWait) throws BadKeyException {
final SettingsItem item = select(packageName, userId);
if (item == null) {
throw new BadKeyException(packageName, userId);
}
final OverlayInfo previous = item.getOverlayInfo();
item.setState(state);
final OverlayInfo current = item.getOverlayInfo();
if (previous.state == STATE_NOT_APPROVED_UNKNOWN) {
notifyOverlayAdded(current, shouldWait);
notifySettingsChanged();
} else if (current.state != previous.state) {
notifyOverlayChanged(current, previous, shouldWait);
notifySettingsChanged();
}
}
Aggregations