Search in sources :

Example 21 with ArraySet

use of android.util.ArraySet in project platform_frameworks_base by android.

the class PackageManagerService method compareSignatures.

/**
     * Compares two sets of signatures. Returns:
     * <br />
     * {@link PackageManager#SIGNATURE_NEITHER_SIGNED}: if both signature sets are null,
     * <br />
     * {@link PackageManager#SIGNATURE_FIRST_NOT_SIGNED}: if the first signature set is null,
     * <br />
     * {@link PackageManager#SIGNATURE_SECOND_NOT_SIGNED}: if the second signature set is null,
     * <br />
     * {@link PackageManager#SIGNATURE_MATCH}: if the two signature sets are identical,
     * <br />
     * {@link PackageManager#SIGNATURE_NO_MATCH}: if the two signature sets differ.
     */
static int compareSignatures(Signature[] s1, Signature[] s2) {
    if (s1 == null) {
        return s2 == null ? PackageManager.SIGNATURE_NEITHER_SIGNED : PackageManager.SIGNATURE_FIRST_NOT_SIGNED;
    }
    if (s2 == null) {
        return PackageManager.SIGNATURE_SECOND_NOT_SIGNED;
    }
    if (s1.length != s2.length) {
        return PackageManager.SIGNATURE_NO_MATCH;
    }
    // Since both signature sets are of size 1, we can compare without HashSets.
    if (s1.length == 1) {
        return s1[0].equals(s2[0]) ? PackageManager.SIGNATURE_MATCH : PackageManager.SIGNATURE_NO_MATCH;
    }
    ArraySet<Signature> set1 = new ArraySet<Signature>();
    for (Signature sig : s1) {
        set1.add(sig);
    }
    ArraySet<Signature> set2 = new ArraySet<Signature>();
    for (Signature sig : s2) {
        set2.add(sig);
    }
    // Make sure s2 contains all signatures in s1.
    if (set1.equals(set2)) {
        return PackageManager.SIGNATURE_MATCH;
    }
    return PackageManager.SIGNATURE_NO_MATCH;
}
Also used : ArraySet(android.util.ArraySet) Signature(android.content.pm.Signature)

Example 22 with ArraySet

use of android.util.ArraySet in project platform_frameworks_base by android.

the class SharedStorageAgent method onFullBackup.

/**
     * Full backup of the shared-storage filesystem
     */
@Override
public void onFullBackup(FullBackupDataOutput output) throws IOException {
    // "primary" shared storage volume is first in the list.
    if (mVolumes != null) {
        if (DEBUG)
            Slog.i(TAG, "Backing up " + mVolumes.length + " shared volumes");
        // Ignore all apps' getExternalFilesDir() content; it is backed up as part of
        // each app-specific payload.
        ArraySet<String> externalFilesDirFilter = new ArraySet();
        final File externalAndroidRoot = new File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_ANDROID);
        externalFilesDirFilter.add(externalAndroidRoot.getCanonicalPath());
        for (int i = 0; i < mVolumes.length; i++) {
            StorageVolume v = mVolumes[i];
            // Express the contents of volume N this way in the tar stream:
            //     shared/N/path/to/file
            // The restore will then extract to the given volume
            String domain = FullBackup.SHARED_PREFIX + i;
            fullBackupFileTree(null, domain, v.getPath(), null, /* manifestExcludes */
            externalFilesDirFilter, /* systemExcludes */
            output);
        }
    }
}
Also used : StorageVolume(android.os.storage.StorageVolume) ArraySet(android.util.ArraySet) File(java.io.File)

Example 23 with ArraySet

use of android.util.ArraySet in project platform_frameworks_base by android.

the class TaskStack method computeComponentsRemoved.

/**
     * Computes the components of tasks in this stack that have been removed as a result of a change
     * in the specified package.
     */
public ArraySet<ComponentName> computeComponentsRemoved(String packageName, int userId) {
    // Identify all the tasks that should be removed as a result of the package being removed.
    // Using a set to ensure that we callback once per unique component.
    SystemServicesProxy ssp = Recents.getSystemServices();
    ArraySet<ComponentName> existingComponents = new ArraySet<>();
    ArraySet<ComponentName> removedComponents = new ArraySet<>();
    ArrayList<Task.TaskKey> taskKeys = getTaskKeys();
    int taskKeyCount = taskKeys.size();
    for (int i = 0; i < taskKeyCount; i++) {
        Task.TaskKey t = taskKeys.get(i);
        // Skip if this doesn't apply to the current user
        if (t.userId != userId)
            continue;
        ComponentName cn = t.getComponent();
        if (cn.getPackageName().equals(packageName)) {
            if (existingComponents.contains(cn)) {
                // If we know that the component still exists in the package, then skip
                continue;
            }
            if (ssp.getActivityInfo(cn, userId) != null) {
                existingComponents.add(cn);
            } else {
                removedComponents.add(cn);
            }
        }
    }
    return removedComponents;
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) ArraySet(android.util.ArraySet) ComponentName(android.content.ComponentName) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 24 with ArraySet

use of android.util.ArraySet in project platform_frameworks_base by android.

the class CastControllerImpl method getCastDevices.

@Override
public Set<CastDevice> getCastDevices() {
    final ArraySet<CastDevice> devices = new ArraySet<CastDevice>();
    synchronized (mProjectionLock) {
        if (mProjection != null) {
            final CastDevice device = new CastDevice();
            device.id = mProjection.getPackageName();
            device.name = getAppName(mProjection.getPackageName());
            device.description = mContext.getString(R.string.quick_settings_casting);
            device.state = CastDevice.STATE_CONNECTED;
            device.tag = mProjection;
            devices.add(device);
            return devices;
        }
    }
    synchronized (mRoutes) {
        for (RouteInfo route : mRoutes.values()) {
            final CastDevice device = new CastDevice();
            device.id = route.getTag().toString();
            final CharSequence name = route.getName(mContext);
            device.name = name != null ? name.toString() : null;
            final CharSequence description = route.getDescription();
            device.description = description != null ? description.toString() : null;
            device.state = route.isConnecting() ? CastDevice.STATE_CONNECTING : route.isSelected() ? CastDevice.STATE_CONNECTED : CastDevice.STATE_DISCONNECTED;
            device.tag = route;
            devices.add(device);
        }
    }
    return devices;
}
Also used : ArraySet(android.util.ArraySet) RouteInfo(android.media.MediaRouter.RouteInfo)

Example 25 with ArraySet

use of android.util.ArraySet in project platform_frameworks_base by android.

the class AppWidgetServiceImpl method onWidgetProviderAddedOrChangedLocked.

/**
     * Checks if the provider is assigned and updates the mWidgetPackages to track packages
     * that have bound widgets.
     */
void onWidgetProviderAddedOrChangedLocked(Widget widget) {
    if (widget.provider == null)
        return;
    int userId = widget.provider.getUserId();
    ArraySet<String> packages = mWidgetPackages.get(userId);
    if (packages == null) {
        mWidgetPackages.put(userId, packages = new ArraySet<String>());
    }
    packages.add(widget.provider.info.provider.getPackageName());
    // is currently masked, if so mask the widget.
    if (widget.provider.isMaskedLocked()) {
        maskWidgetsViewsLocked(widget.provider, widget);
    } else {
        widget.clearMaskedViewsLocked();
    }
}
Also used : ArraySet(android.util.ArraySet) Point(android.graphics.Point)

Aggregations

ArraySet (android.util.ArraySet)431 PublicKey (java.security.PublicKey)94 ComponentName (android.content.ComponentName)73 ArrayMap (android.util.ArrayMap)73 ArrayList (java.util.ArrayList)66 Pair (android.util.Pair)47 File (java.io.File)33 SSLContext (javax.net.ssl.SSLContext)32 Intent (android.content.Intent)30 RemoteException (android.os.RemoteException)29 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)28 ResolveInfo (android.content.pm.ResolveInfo)25 Point (android.graphics.Point)24 IOException (java.io.IOException)23 UserInfo (android.content.pm.UserInfo)21 X509Certificate (java.security.cert.X509Certificate)20 ContentResolver (android.content.ContentResolver)16 PackageManager (android.content.pm.PackageManager)15 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)15 SparseArray (android.util.SparseArray)15