Search in sources :

Example 16 with OverlayInfo

use of android.content.om.OverlayInfo in project android_frameworks_base by DirtyUnicorns.

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);
}
Also used : OverlayInfo(android.content.om.OverlayInfo)

Example 17 with OverlayInfo

use of android.content.om.OverlayInfo in project android_frameworks_base by DirtyUnicorns.

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;
}
Also used : OverlayInfo(android.content.om.OverlayInfo) ArrayList(java.util.ArrayList)

Example 18 with OverlayInfo

use of android.content.om.OverlayInfo in project android_frameworks_base by DirtyUnicorns.

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);
}
Also used : ArraySet(android.util.ArraySet) PackageInfo(android.content.pm.PackageInfo) ArrayList(java.util.ArrayList) ArrayMap(android.util.ArrayMap) OverlayInfo(android.content.om.OverlayInfo) ArrayList(java.util.ArrayList) List(java.util.List)

Example 19 with OverlayInfo

use of android.content.om.OverlayInfo in project android_frameworks_base by AOSPA.

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();
    }
}
Also used : OverlayInfo(android.content.om.OverlayInfo)

Example 20 with OverlayInfo

use of android.content.om.OverlayInfo in project android_frameworks_base by AOSPA.

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();
}
Also used : OverlayInfo(android.content.om.OverlayInfo)

Aggregations

OverlayInfo (android.content.om.OverlayInfo)41 PackageInfo (android.content.pm.PackageInfo)12 ArrayList (java.util.ArrayList)9 List (java.util.List)5 ArrayMap (android.util.ArrayMap)4 ArraySet (android.util.ArraySet)4 IOverlayManager (android.content.om.IOverlayManager)1 LocaleList (android.os.LocaleList)1 RemoteCallbackList (android.os.RemoteCallbackList)1 RemoteException (android.os.RemoteException)1