Search in sources :

Example 86 with ArrayMap

use of android.util.ArrayMap in project android_frameworks_base by crdroidandroid.

the class ResourcesManager method applyNewResourceDirsLocked.

final void applyNewResourceDirsLocked(@NonNull final String baseCodePath, @NonNull final String[] newResourceDirs) {
    try {
        Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, "ResourcesManager#applyNewResourceDirsLocked");
        ApplicationPackageManager.configurationChanged();
        if (Process.myUid() == Process.SYSTEM_UID) {
            // Resources.getSystem() will *not* use overlays for applications.)
            if (FRAMEWORK_RESOURCES_PATH.equals(baseCodePath)) {
                final ResourcesKey key = new ResourcesKey(FRAMEWORK_RESOURCES_PATH, null, newResourceDirs, null, Display.DEFAULT_DISPLAY, null, null);
                final ResourcesImpl impl = createResourcesImpl(key);
                Resources.getSystem().setImpl(impl);
            }
        }
        final ArrayMap<ResourcesImpl, ResourcesKey> updatedResourceKeys = new ArrayMap<>();
        final int implCount = mResourceImpls.size();
        for (int i = 0; i < implCount; i++) {
            final ResourcesImpl impl = mResourceImpls.valueAt(i).get();
            final ResourcesKey key = mResourceImpls.keyAt(i);
            if (impl != null && key.mResDir != null && key.mResDir.equals(baseCodePath)) {
                updatedResourceKeys.put(impl, new ResourcesKey(key.mResDir, key.mSplitResDirs, newResourceDirs, key.mLibDirs, key.mDisplayId, key.mOverrideConfiguration, key.mCompatInfo));
            }
        }
        invalidatePath("/");
        redirectResourcesToNewImplLocked(updatedResourceKeys);
    } finally {
        Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
    }
}
Also used : ResourcesKey(android.content.res.ResourcesKey) ArrayMap(android.util.ArrayMap) ResourcesImpl(android.content.res.ResourcesImpl)

Example 87 with ArrayMap

use of android.util.ArrayMap in project android_frameworks_base by crdroidandroid.

the class ResourcesManager method appendLibAssetForMainAssetPath.

/**
     * Appends the library asset path to any ResourcesImpl object that contains the main
     * assetPath.
     * @param assetPath The main asset path for which to add the library asset path.
     * @param libAsset The library asset path to add.
     */
public void appendLibAssetForMainAssetPath(String assetPath, String libAsset) {
    synchronized (this) {
        // Record which ResourcesImpl need updating
        // (and what ResourcesKey they should update to).
        final ArrayMap<ResourcesImpl, ResourcesKey> updatedResourceKeys = new ArrayMap<>();
        final int implCount = mResourceImpls.size();
        for (int i = 0; i < implCount; i++) {
            final ResourcesKey key = mResourceImpls.keyAt(i);
            final WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i);
            final ResourcesImpl impl = weakImplRef != null ? weakImplRef.get() : null;
            if (impl != null && key.mResDir.equals(assetPath)) {
                if (!ArrayUtils.contains(key.mLibDirs, libAsset)) {
                    final int newLibAssetCount = 1 + (key.mLibDirs != null ? key.mLibDirs.length : 0);
                    final String[] newLibAssets = new String[newLibAssetCount];
                    if (key.mLibDirs != null) {
                        System.arraycopy(key.mLibDirs, 0, newLibAssets, 0, key.mLibDirs.length);
                    }
                    newLibAssets[newLibAssetCount - 1] = libAsset;
                    updatedResourceKeys.put(impl, new ResourcesKey(key.mResDir, key.mSplitResDirs, key.mOverlayDirs, newLibAssets, key.mDisplayId, key.mOverrideConfiguration, key.mCompatInfo));
                }
            }
        }
        redirectResourcesToNewImplLocked(updatedResourceKeys);
    }
}
Also used : ResourcesKey(android.content.res.ResourcesKey) ArrayMap(android.util.ArrayMap) ResourcesImpl(android.content.res.ResourcesImpl)

Example 88 with ArrayMap

use of android.util.ArrayMap in project android_frameworks_base by crdroidandroid.

the class BackStackRecord method mapEnteringSharedElements.

/**
     * Maps shared elements to views in the entering fragment.
     *
     * @param state The transition State as returned from {@link #beginTransition(
     * android.util.SparseArray, android.util.SparseArray, boolean)}.
     * @param inFragment The last fragment to be added.
     * @param isBack true if this is popping the back stack or false if this is a
     *               forward operation.
     */
private ArrayMap<String, View> mapEnteringSharedElements(TransitionState state, Fragment inFragment, boolean isBack) {
    ArrayMap<String, View> namedViews = new ArrayMap<String, View>();
    View root = inFragment.getView();
    if (root != null) {
        if (mSharedElementSourceNames != null) {
            root.findNamedViews(namedViews);
            if (isBack) {
                namedViews = remapNames(mSharedElementSourceNames, mSharedElementTargetNames, namedViews);
            } else {
                namedViews.retainAll(mSharedElementTargetNames);
            }
        }
    }
    return namedViews;
}
Also used : ArrayMap(android.util.ArrayMap) View(android.view.View)

Example 89 with ArrayMap

use of android.util.ArrayMap in project android_frameworks_base by crdroidandroid.

the class PackageParser method parseClusterPackageLite.

private static PackageLite parseClusterPackageLite(File packageDir, int flags) throws PackageParserException {
    final File[] files = packageDir.listFiles();
    if (ArrayUtils.isEmpty(files)) {
        throw new PackageParserException(INSTALL_PARSE_FAILED_NOT_APK, "No packages found in split");
    }
    String packageName = null;
    int versionCode = 0;
    final ArrayMap<String, ApkLite> apks = new ArrayMap<>();
    for (File file : files) {
        if (isApkFile(file)) {
            final ApkLite lite = parseApkLite(file, flags);
            // consistent with the first one we encounter.
            if (packageName == null) {
                packageName = lite.packageName;
                versionCode = lite.versionCode;
            } else {
                if (!packageName.equals(lite.packageName)) {
                    throw new PackageParserException(INSTALL_PARSE_FAILED_BAD_MANIFEST, "Inconsistent package " + lite.packageName + " in " + file + "; expected " + packageName);
                }
                if (versionCode != lite.versionCode) {
                    throw new PackageParserException(INSTALL_PARSE_FAILED_BAD_MANIFEST, "Inconsistent version " + lite.versionCode + " in " + file + "; expected " + versionCode);
                }
            }
            // Assert that each split is defined only once
            if (apks.put(lite.splitName, lite) != null) {
                throw new PackageParserException(INSTALL_PARSE_FAILED_BAD_MANIFEST, "Split name " + lite.splitName + " defined more than once; most recent was " + file);
            }
        }
    }
    final ApkLite baseApk = apks.remove(null);
    if (baseApk == null) {
        throw new PackageParserException(INSTALL_PARSE_FAILED_BAD_MANIFEST, "Missing base APK in " + packageDir);
    }
    // Always apply deterministic ordering based on splitName
    final int size = apks.size();
    String[] splitNames = null;
    String[] splitCodePaths = null;
    int[] splitRevisionCodes = null;
    if (size > 0) {
        splitNames = new String[size];
        splitCodePaths = new String[size];
        splitRevisionCodes = new int[size];
        splitNames = apks.keySet().toArray(splitNames);
        Arrays.sort(splitNames, sSplitNameComparator);
        for (int i = 0; i < size; i++) {
            splitCodePaths[i] = apks.get(splitNames[i]).codePath;
            splitRevisionCodes[i] = apks.get(splitNames[i]).revisionCode;
        }
    }
    final String codePath = packageDir.getAbsolutePath();
    return new PackageLite(codePath, baseApk, splitNames, splitCodePaths, splitRevisionCodes);
}
Also used : ArrayMap(android.util.ArrayMap) StrictJarFile(android.util.jar.StrictJarFile) File(java.io.File)

Example 90 with ArrayMap

use of android.util.ArrayMap in project android_frameworks_base by crdroidandroid.

the class InputMethodUtils method parseInputMethodsAndSubtypesString.

/**
     * Parses the setting stored input methods and subtypes string value.
     *
     * @param inputMethodsAndSubtypesString The input method subtypes value stored in settings.
     * @return Map from input method ID to set of input method subtypes IDs.
     */
@VisibleForTesting
public static ArrayMap<String, ArraySet<String>> parseInputMethodsAndSubtypesString(@Nullable final String inputMethodsAndSubtypesString) {
    final ArrayMap<String, ArraySet<String>> imeMap = new ArrayMap<>();
    if (TextUtils.isEmpty(inputMethodsAndSubtypesString)) {
        return imeMap;
    }
    final SimpleStringSplitter typeSplitter = new SimpleStringSplitter(INPUT_METHOD_SEPARATOR);
    final SimpleStringSplitter subtypeSplitter = new SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATOR);
    List<Pair<String, ArrayList<String>>> allImeSettings = InputMethodSettings.buildInputMethodsAndSubtypeList(inputMethodsAndSubtypesString, typeSplitter, subtypeSplitter);
    for (Pair<String, ArrayList<String>> ime : allImeSettings) {
        ArraySet<String> subtypes = new ArraySet<>();
        if (ime.second != null) {
            subtypes.addAll(ime.second);
        }
        imeMap.put(ime.first, subtypes);
    }
    return imeMap;
}
Also used : ArraySet(android.util.ArraySet) ArrayList(java.util.ArrayList) ArrayMap(android.util.ArrayMap) SimpleStringSplitter(android.text.TextUtils.SimpleStringSplitter) Pair(android.util.Pair) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Aggregations

ArrayMap (android.util.ArrayMap)365 ArraySet (android.util.ArraySet)77 ArrayList (java.util.ArrayList)75 PublicKey (java.security.PublicKey)49 HashMap (java.util.HashMap)32 Preference (android.support.v7.preference.Preference)30 IOException (java.io.IOException)30 Map (java.util.Map)29 HashSet (java.util.HashSet)28 Intent (android.content.Intent)24 Test (org.junit.Test)24 ComponentName (android.content.ComponentName)22 RemoteException (android.os.RemoteException)22 Field (java.lang.reflect.Field)21 Activity (android.app.Activity)20 SparseArray (android.util.SparseArray)18 List (java.util.List)18 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)18 Point (android.graphics.Point)17 Method (java.lang.reflect.Method)17