Java源码示例:com.android.internal.util.ArrayUtils

示例1
/**
 * Only keep entries that match all specified filters.
 *
 * <p>This mutates the original structure in place. After this method is called,
 * size is the number of matching entries, and capacity is the previous capacity.
 * @param limitUid UID to filter for, or {@link #UID_ALL}.
 * @param limitIfaces Interfaces to filter for, or {@link #INTERFACES_ALL}.
 * @param limitTag Tag to filter for, or {@link #TAG_ALL}.
 */
public void filter(int limitUid, String[] limitIfaces, int limitTag) {
    if (limitUid == UID_ALL && limitTag == TAG_ALL && limitIfaces == INTERFACES_ALL) {
        return;
    }

    Entry entry = new Entry();
    int nextOutputEntry = 0;
    for (int i = 0; i < size; i++) {
        entry = getValues(i, entry);
        final boolean matches =
                (limitUid == UID_ALL || limitUid == entry.uid)
                && (limitTag == TAG_ALL || limitTag == entry.tag)
                && (limitIfaces == INTERFACES_ALL
                        || ArrayUtils.contains(limitIfaces, entry.iface));

        if (matches) {
            setValues(nextOutputEntry, entry);
            nextOutputEntry++;
        }
    }

    size = nextOutputEntry;
}
 
示例2
/**
 * Puts a key/value pair into the array, optimizing for the case where
 * the key is greater than all existing keys in the array.
 */
public void append(int key, int value) {
    if (mSize != 0 && key <= mKeys[mSize - 1]) {
        put(key, value);
        return;
    }

    int pos = mSize;
    if (pos >= mKeys.length) {
        int n = ArrayUtils.idealIntArraySize(pos + 1);

        int[] nkeys = new int[n];
        int[] nvalues = new int[n];

        // Log.e("SparseIntArray", "grow " + mKeys.length + " to " + n);
        System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
        System.arraycopy(mValues, 0, nvalues, 0, mValues.length);

        mKeys = nkeys;
        mValues = nvalues;
    }

    mKeys[pos] = key;
    mValues[pos] = value;
    mSize = pos + 1;
}
 
示例3
public PackageUserState(PackageUserState o) {
    ceDataInode = o.ceDataInode;
    installed = o.installed;
    stopped = o.stopped;
    notLaunched = o.notLaunched;
    hidden = o.hidden;
    suspended = o.suspended;
    instantApp = o.instantApp;
    virtualPreload = o.virtualPreload;
    enabled = o.enabled;
    lastDisableAppCaller = o.lastDisableAppCaller;
    domainVerificationStatus = o.domainVerificationStatus;
    appLinkGeneration = o.appLinkGeneration;
    categoryHint = o.categoryHint;
    installReason = o.installReason;
    disabledComponents = ArrayUtils.cloneOrNull(o.disabledComponents);
    enabledComponents = ArrayUtils.cloneOrNull(o.enabledComponents);
    overlayPaths =
        o.overlayPaths == null ? null : Arrays.copyOf(o.overlayPaths, o.overlayPaths.length);
}
 
示例4
public PackageUserState(PackageUserState o) {
    ceDataInode = o.ceDataInode;
    installed = o.installed;
    stopped = o.stopped;
    notLaunched = o.notLaunched;
    hidden = o.hidden;
    suspended = o.suspended;
    suspendingPackage = o.suspendingPackage;
    dialogMessage = o.dialogMessage;
    suspendedAppExtras = o.suspendedAppExtras;
    suspendedLauncherExtras = o.suspendedLauncherExtras;
    instantApp = o.instantApp;
    virtualPreload = o.virtualPreload;
    enabled = o.enabled;
    lastDisableAppCaller = o.lastDisableAppCaller;
    domainVerificationStatus = o.domainVerificationStatus;
    appLinkGeneration = o.appLinkGeneration;
    categoryHint = o.categoryHint;
    installReason = o.installReason;
    disabledComponents = ArrayUtils.cloneOrNull(o.disabledComponents);
    enabledComponents = ArrayUtils.cloneOrNull(o.enabledComponents);
    overlayPaths =
        o.overlayPaths == null ? null : Arrays.copyOf(o.overlayPaths, o.overlayPaths.length);
    harmfulAppWarning = o.harmfulAppWarning;
}
 
示例5
public DateTimeKeyListener(@Nullable Locale locale) {
    final LinkedHashSet<Character> chars = new LinkedHashSet<>();
    // First add the digits. Then, add all the character in AM and PM markers. Finally, add all
    // the non-pattern characters seen in the patterns for "yMdhms" and "yMdHms".
    final boolean success = NumberKeyListener.addDigits(chars, locale)
                      && NumberKeyListener.addAmPmChars(chars, locale)
                      && NumberKeyListener.addFormatCharsFromSkeleton(
                          chars, locale, SKELETON_12HOUR, SYMBOLS_TO_IGNORE)
                      && NumberKeyListener.addFormatCharsFromSkeleton(
                          chars, locale, SKELETON_24HOUR, SYMBOLS_TO_IGNORE);
    if (success) {
        mCharacters = NumberKeyListener.collectionToArray(chars);
        if (locale != null && "en".equals(locale.getLanguage())) {
            // For backward compatibility reasons, assume we don't need advanced input for
            // English locales, although English locales literally also need a comma and perhaps
            // uppercase letters for AM and PM.
            mNeedsAdvancedInput = false;
        } else {
            mNeedsAdvancedInput = !ArrayUtils.containsAll(CHARACTERS, mCharacters);
        }
    } else {
        mCharacters = CHARACTERS;
        mNeedsAdvancedInput = false;
    }
}
 
示例6
@Override
public void unlockUserKey(int userId, int serialNumber, byte[] token, byte[] secret) {
    enforcePermission(android.Manifest.permission.STORAGE_INTERNAL);

    if (StorageManager.isFileEncryptedNativeOrEmulated()) {
        // When a user has secure lock screen, require secret to actually unlock.
        // This check is mostly in place for emulation mode.
        if (mLockPatternUtils.isSecure(userId) && ArrayUtils.isEmpty(secret)) {
            throw new IllegalStateException("Secret required to unlock secure user " + userId);
        }

        try {
            mVold.unlockUserKey(userId, serialNumber, encodeBytes(token),
                    encodeBytes(secret));
        } catch (Exception e) {
            Slog.wtf(TAG, e);
            return;
        }
    }

    synchronized (mLock) {
        mLocalUnlockedUsers = ArrayUtils.appendInt(mLocalUnlockedUsers, userId);
    }
}
 
示例7
public TimeKeyListener(@Nullable Locale locale) {
    final LinkedHashSet<Character> chars = new LinkedHashSet<>();
    // First add the digits. Then, add all the character in AM and PM markers. Finally, add all
    // the non-pattern characters seen in the patterns for "hms" and "Hms".
    final boolean success = NumberKeyListener.addDigits(chars, locale)
                      && NumberKeyListener.addAmPmChars(chars, locale)
                      && NumberKeyListener.addFormatCharsFromSkeleton(
                          chars, locale, SKELETON_12HOUR, SYMBOLS_TO_IGNORE)
                      && NumberKeyListener.addFormatCharsFromSkeleton(
                          chars, locale, SKELETON_24HOUR, SYMBOLS_TO_IGNORE);
    if (success) {
        mCharacters = NumberKeyListener.collectionToArray(chars);
        if (locale != null && "en".equals(locale.getLanguage())) {
            // For backward compatibility reasons, assume we don't need advanced input for
            // English locales, although English locales may need uppercase letters for
            // AM and PM.
            mNeedsAdvancedInput = false;
        } else {
            mNeedsAdvancedInput = !ArrayUtils.containsAll(CHARACTERS, mCharacters);
        }
    } else {
        mCharacters = CHARACTERS;
        mNeedsAdvancedInput = false;
    }
}
 
示例8
/**
 * Puts a key/value pair into the array, optimizing for the case where
 * the key is greater than all existing keys in the array.
 */
public void append(int key, boolean value) {
    if (mSize != 0 && key <= mKeys[mSize - 1]) {
        put(key, value);
        return;
    }

    int pos = mSize;
    if (pos >= mKeys.length) {
        int n = ArrayUtils.idealIntArraySize(pos + 1);

        int[] nkeys = new int[n];
        boolean[] nvalues = new boolean[n];

        // Log.e("SparseBooleanArray", "grow " + mKeys.length + " to " + n);
        System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
        System.arraycopy(mValues, 0, nvalues, 0, mValues.length);

        mKeys = nkeys;
        mValues = nvalues;
    }

    mKeys[pos] = key;
    mValues[pos] = value;
    mSize = pos + 1;
}
 
示例9
/**
 * Returns {@code true} if a sync is pending.
 * @param recoveryAgentUid uid of the recovery agent.
 */
private boolean shouldCreateSnapshot(int recoveryAgentUid) {
    int[] types = mRecoverableKeyStoreDb.getRecoverySecretTypes(mUserId, recoveryAgentUid);
    if (!ArrayUtils.contains(types, KeyChainProtectionParams.TYPE_LOCKSCREEN)) {
        // Only lockscreen type is supported.
        // We will need to pass extra argument to KeySyncTask to support custom pass phrase.
        return false;
    }
    if (mCredentialUpdated) {
        // Sync credential if at least one snapshot was created.
        if (mRecoverableKeyStoreDb.getSnapshotVersion(mUserId, recoveryAgentUid) != null) {
            mRecoverableKeyStoreDb.setShouldCreateSnapshot(mUserId, recoveryAgentUid, true);
            return true;
        }
    }

    return mRecoverableKeyStoreDb.getShouldCreateSnapshot(mUserId, recoveryAgentUid);
}
 
示例10
private CredentialHash readPatternHashIfExists(int userId) {
    byte[] stored = readFile(getLockPatternFilename(userId));
    if (!ArrayUtils.isEmpty(stored)) {
        return new CredentialHash(stored, LockPatternUtils.CREDENTIAL_TYPE_PATTERN,
                CredentialHash.VERSION_GATEKEEPER);
    }

    stored = readFile(getBaseZeroLockPatternFilename(userId));
    if (!ArrayUtils.isEmpty(stored)) {
        return CredentialHash.createBaseZeroPattern(stored);
    }

    stored = readFile(getLegacyLockPatternFilename(userId));
    if (!ArrayUtils.isEmpty(stored)) {
        return new CredentialHash(stored, LockPatternUtils.CREDENTIAL_TYPE_PATTERN,
                CredentialHash.VERSION_LEGACY);
    }
    return null;
}
 
示例11
public boolean hasRestriction(int restriction, String packageName, int userId) {
    if (perUserRestrictions == null) {
        return false;
    }
    boolean[] restrictions = perUserRestrictions.get(userId);
    if (restrictions == null) {
        return false;
    }
    if (!restrictions[restriction]) {
        return false;
    }
    if (perUserExcludedPackages == null) {
        return true;
    }
    String[] perUserExclusions = perUserExcludedPackages.get(userId);
    if (perUserExclusions == null) {
        return true;
    }
    return !ArrayUtils.contains(perUserExclusions, packageName);
}
 
示例12
private int grantPermission(BasePermission permission, int userId) {
    if (hasPermission(permission.getName(), userId)) {
        return PERMISSION_OPERATION_FAILURE;
    }

    final boolean hasGids = !ArrayUtils.isEmpty(permission.computeGids(userId));
    final int[] oldGids = hasGids ? computeGids(userId) : NO_GIDS;

    PermissionData permissionData = ensurePermissionData(permission);

    if (!permissionData.grant(userId)) {
        return PERMISSION_OPERATION_FAILURE;
    }

    if (hasGids) {
        final int[] newGids = computeGids(userId);
        if (oldGids.length != newGids.length) {
            return PERMISSION_OPERATION_SUCCESS_GIDS_CHANGED;
        }
    }

    return PERMISSION_OPERATION_SUCCESS;
}
 
示例13
private void resizeFor(int size) {
    final int oldLength = mText.length;
    if (size + 1 <= oldLength) {
        return;
    }

    char[] newText = ArrayUtils.newUnpaddedCharArray(GrowingArrayUtils.growSize(size));
    System.arraycopy(mText, 0, newText, 0, mGapStart);
    final int newLength = newText.length;
    final int delta = newLength - oldLength;
    final int after = oldLength - (mGapStart + mGapLength);
    System.arraycopy(mText, oldLength - after, newText, newLength - after, after);
    mText = newText;

    mGapLength += delta;
    if (mGapLength < 1)
        new Exception("mGapLength < 1").printStackTrace();

    if (mSpanCount != 0) {
        for (int i = 0; i < mSpanCount; i++) {
            if (mSpanStarts[i] > mGapStart) mSpanStarts[i] += delta;
            if (mSpanEnds[i] > mGapStart) mSpanEnds[i] += delta;
        }
        calcMax(treeRoot());
    }
}
 
示例14
/**
 * Displays the package file for a package.
 * @param pckg
 */
private int displayPackageFilePath(String pckg, int userId) throws RemoteException {
    PackageInfo info = mInterface.getPackageInfo(pckg, 0, userId);
    if (info != null && info.applicationInfo != null) {
        final PrintWriter pw = getOutPrintWriter();
        pw.print("package:");
        pw.println(info.applicationInfo.sourceDir);
        if (!ArrayUtils.isEmpty(info.applicationInfo.splitSourceDirs)) {
            for (String splitSourceDir : info.applicationInfo.splitSourceDirs) {
                pw.print("package:");
                pw.println(splitSourceDir);
            }
        }
        return 0;
    }
    return 1;
}
 
示例15
/**
 * Finalize an {@link AccessibilityNodeInfo} before passing it to the client.
 *
 * @param info The info.
 * @param connectionId The id of the connection to the system.
 * @param bypassCache Whether or not to bypass the cache. The node is added to the cache if
 *                    this value is {@code false}
 * @param packageNames The valid package names a node can come from.
 */
private void finalizeAndCacheAccessibilityNodeInfo(AccessibilityNodeInfo info,
        int connectionId, boolean bypassCache, String[] packageNames) {
    if (info != null) {
        info.setConnectionId(connectionId);
        // Empty array means any package name is Okay
        if (!ArrayUtils.isEmpty(packageNames)) {
            CharSequence packageName = info.getPackageName();
            if (packageName == null
                    || !ArrayUtils.contains(packageNames, packageName.toString())) {
                // If the node package not one of the valid ones, pick the top one - this
                // is one of the packages running in the introspected UID.
                info.setPackageName(packageNames[0]);
            }
        }
        info.setSealed(true);
        if (!bypassCache) {
            sAccessibilityCache.add(info);
        }
    }
}
 
示例16
/**
 * Remove any {@link NetworkStatsHistory} attributed to the requested UID,
 * moving any {@link NetworkStats#TAG_NONE} series to
 * {@link TrafficStats#UID_REMOVED}.
 */
public void removeUids(int[] uids) {
    final ArrayList<Key> knownKeys = Lists.newArrayList();
    knownKeys.addAll(mStats.keySet());

    // migrate all UID stats into special "removed" bucket
    for (Key key : knownKeys) {
        if (ArrayUtils.contains(uids, key.uid)) {
            // only migrate combined TAG_NONE history
            if (key.tag == TAG_NONE) {
                final NetworkStatsHistory uidHistory = mStats.get(key);
                final NetworkStatsHistory removedHistory = findOrCreateHistory(
                        key.ident, UID_REMOVED, SET_DEFAULT, TAG_NONE);
                removedHistory.recordEntireHistory(uidHistory);
            }
            mStats.remove(key);
            mDirty = true;
        }
    }
}
 
示例17
/**
 * Clean up {@link #mUidRecorder} after user is removed.
 */
@GuardedBy("mStatsLock")
private void removeUserLocked(int userId) {
    if (LOGV) Slog.v(TAG, "removeUserLocked() for userId=" + userId);

    // Build list of UIDs that we should clean up
    int[] uids = new int[0];
    final List<ApplicationInfo> apps = mContext.getPackageManager().getInstalledApplications(
            PackageManager.MATCH_ANY_USER
            | PackageManager.MATCH_DISABLED_COMPONENTS);
    for (ApplicationInfo app : apps) {
        final int uid = UserHandle.getUid(userId, app.uid);
        uids = ArrayUtils.appendInt(uids, uid);
    }

    removeUidsLocked(uids);
}
 
示例18
/**
 * Adds the WebView asset path to {@link android.content.res.AssetManager}.
 */
public void addWebViewAssetPath(Context context) {
    final String newAssetPath = WebViewFactory.getLoadedPackageInfo().applicationInfo.sourceDir;

    final ApplicationInfo appInfo = context.getApplicationInfo();
    final String[] libs = appInfo.sharedLibraryFiles;
    if (!ArrayUtils.contains(libs, newAssetPath)) {
        // Build the new library asset path list.
        final int newLibAssetsCount = 1 + (libs != null ? libs.length : 0);
        final String[] newLibAssets = new String[newLibAssetsCount];
        if (libs != null) {
            System.arraycopy(libs, 0, newLibAssets, 0, libs.length);
        }
        newLibAssets[newLibAssetsCount - 1] = newAssetPath;

        // Update the ApplicationInfo object with the new list.
        // We know this will persist and future Resources created via ResourcesManager
        // will include the shared library because this ApplicationInfo comes from the
        // underlying LoadedApk in ContextImpl, which does not change during the life of the
        // application.
        appInfo.sharedLibraryFiles = newLibAssets;

        // Update existing Resources with the WebView library.
        ResourcesManager.getInstance().appendLibAssetForMainAssetPath(
                appInfo.getBaseResourcePath(), newAssetPath);
    }
}
 
示例19
public PackageUserState(PackageUserState o) {
    ceDataInode = o.ceDataInode;
    installed = o.installed;
    stopped = o.stopped;
    notLaunched = o.notLaunched;
    hidden = o.hidden;
    suspended = o.suspended;
    blockUninstall = o.blockUninstall;
    enabled = o.enabled;
    lastDisableAppCaller = o.lastDisableAppCaller;
    domainVerificationStatus = o.domainVerificationStatus;
    appLinkGeneration = o.appLinkGeneration;
    disabledComponents = ArrayUtils.cloneOrNull(o.disabledComponents);
    enabledComponents = ArrayUtils.cloneOrNull(o.enabledComponents);
}
 
示例20
/**
 * Ensures capacity to append at least <code>count</code> values.
 */
private void ensureCapacity(int count) {
    final int currentSize = mSize;
    final int minCapacity = currentSize + count;
    if (minCapacity >= mValues.length) {
        final int targetCap = currentSize + (currentSize < (MIN_CAPACITY_INCREMENT / 2) ?
                MIN_CAPACITY_INCREMENT : currentSize >> 1);
        final int newCapacity = targetCap > minCapacity ? targetCap : minCapacity;
        final long[] newValues = ArrayUtils.newUnpaddedLongArray(newCapacity);
        System.arraycopy(mValues, 0, newValues, 0, currentSize);
        mValues = newValues;
    }
}
 
示例21
/**
 * Adds a mapping from the specified key to the specified value,
 * replacing the previous mapping from the specified key if there
 * was one.
 */
public void put(int key, int value) {
    int i = ContainerHelpers.binarySearch(mKeys, mSize, key);

    if (i >= 0) {
        mValues[i] = value;
    } else {
        i = ~i;

        if (mSize >= mKeys.length) {
            int n = ArrayUtils.idealIntArraySize(mSize + 1);

            int[] nkeys = new int[n];
            int[] nvalues = new int[n];

            // Log.e("SparseIntArray", "grow " + mKeys.length + " to " + n);
            System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
            System.arraycopy(mValues, 0, nvalues, 0, mValues.length);

            mKeys = nkeys;
            mValues = nvalues;
        }

        if (mSize - i != 0) {
            // Log.e("SparseIntArray", "move " + (mSize - i));
            System.arraycopy(mKeys, i, mKeys, i + 1, mSize - i);
            System.arraycopy(mValues, i, mValues, i + 1, mSize - i);
        }

        mKeys[i] = key;
        mValues[i] = value;
        mSize++;
    }
}
 
示例22
/**
 * Creates a new LongSparseArray containing no mappings that will not
 * require any additional memory allocation to store the specified
 * number of mappings.  If you supply an initial capacity of 0, the
 * sparse array will be initialized with a light-weight representation
 * not requiring any additional array allocations.
 */
public LongSparseArray(int initialCapacity) {
    if (initialCapacity == 0) {
        mKeys = EmptyArray.LONG;
        mValues = EmptyArray.OBJECT;
    } else {
        mKeys = ArrayUtils.newUnpaddedLongArray(initialCapacity);
        mValues = ArrayUtils.newUnpaddedObjectArray(initialCapacity);
    }
    mSize = 0;
}
 
示例23
/**
 * Add filtering by certain bits of {@link BluetoothDevice#getUuids()}
 *
 * A device with any uuid matching the given bits is considered passing
 *
 * @param serviceUuid the values for the bits to match
 * @param serviceUuidMask if provided, only those bits would have to match.
 */
@NonNull
public Builder addServiceUuid(
        @Nullable ParcelUuid serviceUuid, @Nullable ParcelUuid serviceUuidMask) {
    checkNotUsed();
    mServiceUuid = ArrayUtils.add(mServiceUuid, serviceUuid);
    mServiceUuidMask = ArrayUtils.add(mServiceUuidMask, serviceUuidMask);
    return this;
}
 
示例24
/**
 * Creates a new SparseIntArray containing no mappings that will not
 * require any additional memory allocation to store the specified
 * number of mappings.  If you supply an initial capacity of 0, the
 * sparse array will be initialized with a light-weight representation
 * not requiring any additional array allocations.
 */
public SparseIntArray(int initialCapacity) {
    if (initialCapacity == 0) {
        mKeys = ContainerHelpers.EMPTY_INTS;
        mValues = ContainerHelpers.EMPTY_INTS;
    } else {
        initialCapacity = ArrayUtils.idealIntArraySize(initialCapacity);
        mKeys = new int[initialCapacity];
        mValues = new int[initialCapacity];
    }
    mSize = 0;
}
 
示例25
/**
 * Set the tracked views.
 *
 * @param trackedIds The views to be tracked
 */
TrackedViews(@Nullable AutofillId[] trackedIds) {
    final AutofillClient client = getClient();
    if (!ArrayUtils.isEmpty(trackedIds) && client != null) {
        final boolean[] isVisible;

        if (client.autofillClientIsVisibleForAutofill()) {
            if (sVerbose) Log.v(TAG, "client is visible, check tracked ids");
            isVisible = client.autofillClientGetViewVisibility(trackedIds);
        } else {
            // All false
            isVisible = new boolean[trackedIds.length];
        }

        final int numIds = trackedIds.length;
        for (int i = 0; i < numIds; i++) {
            final AutofillId id = trackedIds[i];

            if (isVisible[i]) {
                mVisibleTrackedIds = addToSet(mVisibleTrackedIds, id);
            } else {
                mInvisibleTrackedIds = addToSet(mInvisibleTrackedIds, id);
            }
        }
    }

    if (sVerbose) {
        Log.v(TAG, "TrackedViews(trackedIds=" + Arrays.toString(trackedIds) + "): "
                + " mVisibleTrackedIds=" + mVisibleTrackedIds
                + " mInvisibleTrackedIds=" + mInvisibleTrackedIds);
    }

    if (mVisibleTrackedIds == null) {
        finishSessionLocked();
    }
}
 
示例26
/**
 * Used by DynamicLayout.
 */
/* package */ StaticLayout(@Nullable CharSequence text) {
    super(text, null, 0, null, 0, 0);

    mColumns = COLUMNS_ELLIPSIZE;
    mLineDirections = ArrayUtils.newUnpaddedArray(Directions.class, 2);
    mLines  = ArrayUtils.newUnpaddedIntArray(2 * mColumns);
}
 
示例27
/**
 * @hide
 * Returns the package names of syncadapters that match a given user and authority.
 */
@TestApi
public static String[] getSyncAdapterPackagesForAuthorityAsUser(String authority,
        @UserIdInt int userId) {
    try {
        return getContentService().getSyncAdapterPackagesForAuthorityAsUser(authority, userId);
    } catch (RemoteException e) {
    }
    return ArrayUtils.emptyArray(String.class);
}
 
示例28
/**
 * Test if the given component is considered enabled.
 */
public boolean isEnabled(ComponentInfo componentInfo, int flags) {
    if ((flags & MATCH_DISABLED_COMPONENTS) != 0) {
        return true;
    }

    // First check if the overall package is disabled; if the package is
    // enabled then fall through to check specific component
    switch (this.enabled) {
        case COMPONENT_ENABLED_STATE_DISABLED:
        case COMPONENT_ENABLED_STATE_DISABLED_USER:
            return false;
        case COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED:
            if ((flags & MATCH_DISABLED_UNTIL_USED_COMPONENTS) == 0) {
                return false;
            }
        case COMPONENT_ENABLED_STATE_DEFAULT:
            if (!componentInfo.applicationInfo.enabled) {
                return false;
            }
        case COMPONENT_ENABLED_STATE_ENABLED:
            break;
    }

    // Check if component has explicit state before falling through to
    // the manifest default
    if (ArrayUtils.contains(this.enabledComponents, componentInfo.name)) {
        return true;
    }
    if (ArrayUtils.contains(this.disabledComponents, componentInfo.name)) {
        return false;
    }

    return componentInfo.enabled;
}
 
示例29
@VisibleForTesting
public PackageUserState(PackageUserState o) {
    ceDataInode = o.ceDataInode;
    installed = o.installed;
    stopped = o.stopped;
    notLaunched = o.notLaunched;
    hidden = o.hidden;
    distractionFlags = o.distractionFlags;
    suspended = o.suspended;
    suspendingPackage = o.suspendingPackage;
    dialogInfo = o.dialogInfo;
    suspendedAppExtras = o.suspendedAppExtras;
    suspendedLauncherExtras = o.suspendedLauncherExtras;
    instantApp = o.instantApp;
    virtualPreload = o.virtualPreload;
    enabled = o.enabled;
    lastDisableAppCaller = o.lastDisableAppCaller;
    domainVerificationStatus = o.domainVerificationStatus;
    appLinkGeneration = o.appLinkGeneration;
    categoryHint = o.categoryHint;
    installReason = o.installReason;
    disabledComponents = ArrayUtils.cloneOrNull(o.disabledComponents);
    enabledComponents = ArrayUtils.cloneOrNull(o.enabledComponents);
    overlayPaths =
        o.overlayPaths == null ? null : Arrays.copyOf(o.overlayPaths, o.overlayPaths.length);
    harmfulAppWarning = o.harmfulAppWarning;
}
 
示例30
public ObserverEntry(IContentObserver o, boolean n, Object observersLock,
                     int _uid, int _pid, int _userHandle, Uri uri) {
    this.observersLock = observersLock;
    observer = o;
    uid = _uid;
    pid = _pid;
    userHandle = _userHandle;
    notifyForDescendants = n;

    final int entries = sObserverDeathDispatcher.linkToDeath(observer, this);
    if (entries == -1) {
        binderDied();
    } else if (entries == TOO_MANY_OBSERVERS_THRESHOLD) {
        boolean alreadyDetected;

        synchronized (sObserverLeakDetectedUid) {
            alreadyDetected = sObserverLeakDetectedUid.contains(uid);
            if (!alreadyDetected) {
                sObserverLeakDetectedUid.add(uid);
            }
        }
        if (!alreadyDetected) {
            String caller = null;
            try {
                caller = ArrayUtils.firstOrNull(AppGlobals.getPackageManager()
                        .getPackagesForUid(uid));
            } catch (RemoteException ignore) {
            }
            Slog.wtf(TAG, "Observer registered too many times. Leak? cpid=" + pid
                    + " cuid=" + uid
                    + " cpkg=" + caller
                    + " url=" + uri);
        }
    }

}