use of android.content.om.OverlayInfo in project android_frameworks_base by AOSPA.
the class OverlayManagerServiceImpl method removeIdmapIfPossible.
private void removeIdmapIfPossible(@NonNull final OverlayInfo oi) {
if (!mIdmapManager.idmapExists(oi)) {
return;
}
final List<Integer> userIds = mSettings.getUsers();
for (final int userId : userIds) {
try {
final OverlayInfo tmp = mSettings.getOverlayInfo(oi.packageName, userId);
if (tmp != null && tmp.isEnabled()) {
// someone is still using the idmap file -> we cannot remove it
return;
}
} catch (OverlayManagerSettings.BadKeyException e) {
// intentionally left empty
}
}
mIdmapManager.removeIdmap(oi, oi.userId);
}
use of android.content.om.OverlayInfo in project android_frameworks_base by AOSPA.
the class OverlayManagerServiceImpl method onOverlayPackageUpgrading.
void onOverlayPackageUpgrading(@NonNull final String packageName, final int userId) {
if (DEBUG) {
Slog.d(TAG, "onOverlayPackageUpgrading packageName=" + packageName + " userId=" + userId);
}
try {
final OverlayInfo oi = mSettings.getOverlayInfo(packageName, userId);
mSettings.setUpgrading(packageName, userId, true);
removeIdmapIfPossible(oi);
} catch (OverlayManagerSettings.BadKeyException e) {
Slog.e(TAG, "failed to update settings", e);
mSettings.remove(packageName, userId);
}
}
use of android.content.om.OverlayInfo in project android_frameworks_base by AOSPA.
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 AOSPA.
the class OverlayManagerServiceImpl method onOverlayPackageRemoved.
void onOverlayPackageRemoved(@NonNull final String packageName, final int userId) {
if (DEBUG) {
Slog.d(TAG, "onOverlayPackageRemoved packageName=" + packageName + " userId=" + userId);
}
try {
final OverlayInfo oi = mSettings.getOverlayInfo(packageName, userId);
mSettings.remove(packageName, userId);
removeIdmapIfPossible(oi);
} catch (OverlayManagerSettings.BadKeyException e) {
Slog.e(TAG, "failed to remove overlay package", e);
}
}
use of android.content.om.OverlayInfo in project android_frameworks_base by AOSPA.
the class OverlayManagerServiceImpl method onSetEnabled.
boolean onSetEnabled(@NonNull final String packageName, final boolean enable, final int userId, final boolean shouldWait) {
if (DEBUG) {
Slog.d(TAG, String.format("onSetEnabled packageName=%s enable=%s userId=%d", packageName, enable, userId));
}
final PackageInfo overlayPackage = mPackageManager.getPackageInfo(packageName, userId);
if (overlayPackage == null) {
return false;
}
try {
final OverlayInfo oi = mSettings.getOverlayInfo(packageName, userId);
final PackageInfo targetPackage = mPackageManager.getPackageInfo(oi.targetPackageName, userId);
mSettings.setEnabled(packageName, userId, enable);
updateState(targetPackage, overlayPackage, userId, shouldWait);
return true;
} catch (OverlayManagerSettings.BadKeyException e) {
return false;
}
}
Aggregations