Search in sources :

Example 16 with IntArray

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

the class ExploreByTouchHelper method createNodeForHost.

/**
     * Constructs and returns an {@link AccessibilityNodeInfo} for the
     * host view populated with its virtual descendants.
     *
     * @return An {@link AccessibilityNodeInfo} for the parent node.
     */
private AccessibilityNodeInfo createNodeForHost() {
    final AccessibilityNodeInfo node = AccessibilityNodeInfo.obtain(mView);
    mView.onInitializeAccessibilityNodeInfo(node);
    final int realNodeCount = node.getChildCount();
    // Allow the client to populate the host node.
    onPopulateNodeForHost(node);
    // Add the virtual descendants.
    if (mTempArray == null) {
        mTempArray = new IntArray();
    } else {
        mTempArray.clear();
    }
    final IntArray virtualViewIds = mTempArray;
    getVisibleVirtualViews(virtualViewIds);
    if (realNodeCount > 0 && virtualViewIds.size() > 0) {
        throw new RuntimeException("Views cannot have both real and virtual children");
    }
    final int N = virtualViewIds.size();
    for (int i = 0; i < N; i++) {
        node.addChild(mView, virtualViewIds.get(i));
    }
    return node;
}
Also used : IntArray(android.util.IntArray) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)

Example 17 with IntArray

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

the class UserController method getUsersToStopLocked.

/**
     * Determines the list of users that should be stopped together with the specified
     * {@code userId}. The returned list includes {@code userId}.
     */
@NonNull
private int[] getUsersToStopLocked(int userId) {
    int startedUsersSize = mStartedUsers.size();
    IntArray userIds = new IntArray();
    userIds.add(userId);
    synchronized (mUserProfileGroupIdsSelfLocked) {
        int userGroupId = mUserProfileGroupIdsSelfLocked.get(userId, UserInfo.NO_PROFILE_GROUP_ID);
        for (int i = 0; i < startedUsersSize; i++) {
            UserState uss = mStartedUsers.valueAt(i);
            int startedUserId = uss.mHandle.getIdentifier();
            // Skip unrelated users (profileGroupId mismatch)
            int startedUserGroupId = mUserProfileGroupIdsSelfLocked.get(startedUserId, UserInfo.NO_PROFILE_GROUP_ID);
            boolean sameGroup = (userGroupId != UserInfo.NO_PROFILE_GROUP_ID) && (userGroupId == startedUserGroupId);
            // userId has already been added
            boolean sameUserId = startedUserId == userId;
            if (!sameGroup || sameUserId) {
                continue;
            }
            userIds.add(startedUserId);
        }
    }
    return userIds.toArray();
}
Also used : IntArray(android.util.IntArray) SparseIntArray(android.util.SparseIntArray) NonNull(android.annotation.NonNull)

Example 18 with IntArray

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

the class NetworkStatsCollection method getRelevantUids.

public int[] getRelevantUids(@NetworkStatsAccess.Level int accessLevel, final int callerUid) {
    IntArray uids = new IntArray();
    for (int i = 0; i < mStats.size(); i++) {
        final Key key = mStats.keyAt(i);
        if (NetworkStatsAccess.isAccessibleToUser(key.uid, callerUid, accessLevel)) {
            int j = uids.binarySearch(key.uid);
            if (j < 0) {
                j = ~j;
                uids.add(j, key.uid);
            }
        }
    }
    return uids.toArray();
}
Also used : IntArray(android.util.IntArray)

Example 19 with IntArray

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

the class UserController method getUsersToStopLocked.

/**
     * Determines the list of users that should be stopped together with the specified
     * {@code userId}. The returned list includes {@code userId}.
     */
@NonNull
private int[] getUsersToStopLocked(int userId) {
    int startedUsersSize = mStartedUsers.size();
    IntArray userIds = new IntArray();
    userIds.add(userId);
    synchronized (mUserProfileGroupIdsSelfLocked) {
        int userGroupId = mUserProfileGroupIdsSelfLocked.get(userId, UserInfo.NO_PROFILE_GROUP_ID);
        for (int i = 0; i < startedUsersSize; i++) {
            UserState uss = mStartedUsers.valueAt(i);
            int startedUserId = uss.mHandle.getIdentifier();
            // Skip unrelated users (profileGroupId mismatch)
            int startedUserGroupId = mUserProfileGroupIdsSelfLocked.get(startedUserId, UserInfo.NO_PROFILE_GROUP_ID);
            boolean sameGroup = (userGroupId != UserInfo.NO_PROFILE_GROUP_ID) && (userGroupId == startedUserGroupId);
            // userId has already been added
            boolean sameUserId = startedUserId == userId;
            if (!sameGroup || sameUserId) {
                continue;
            }
            userIds.add(startedUserId);
        }
    }
    return userIds.toArray();
}
Also used : IntArray(android.util.IntArray) SparseIntArray(android.util.SparseIntArray) NonNull(android.annotation.NonNull)

Example 20 with IntArray

use of android.util.IntArray in project android_frameworks_base by AOSPA.

the class UserController method getUsersToStopLocked.

/**
     * Determines the list of users that should be stopped together with the specified
     * {@code userId}. The returned list includes {@code userId}.
     */
@NonNull
private int[] getUsersToStopLocked(int userId) {
    int startedUsersSize = mStartedUsers.size();
    IntArray userIds = new IntArray();
    userIds.add(userId);
    synchronized (mUserProfileGroupIdsSelfLocked) {
        int userGroupId = mUserProfileGroupIdsSelfLocked.get(userId, UserInfo.NO_PROFILE_GROUP_ID);
        for (int i = 0; i < startedUsersSize; i++) {
            UserState uss = mStartedUsers.valueAt(i);
            int startedUserId = uss.mHandle.getIdentifier();
            // Skip unrelated users (profileGroupId mismatch)
            int startedUserGroupId = mUserProfileGroupIdsSelfLocked.get(startedUserId, UserInfo.NO_PROFILE_GROUP_ID);
            boolean sameGroup = (userGroupId != UserInfo.NO_PROFILE_GROUP_ID) && (userGroupId == startedUserGroupId);
            // userId has already been added
            boolean sameUserId = startedUserId == userId;
            if (!sameGroup || sameUserId) {
                continue;
            }
            userIds.add(startedUserId);
        }
    }
    return userIds.toArray();
}
Also used : IntArray(android.util.IntArray) SparseIntArray(android.util.SparseIntArray) NonNull(android.annotation.NonNull)

Aggregations

IntArray (android.util.IntArray)37 SparseIntArray (android.util.SparseIntArray)13 UserInfo (android.content.pm.UserInfo)8 NonNull (android.annotation.NonNull)5 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)5 NetworkStatsHistory (android.net.NetworkStatsHistory)5 RemoteException (android.os.RemoteException)5 AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)5 ComponentName (android.content.ComponentName)4 PackageManagerInternal (android.content.pm.PackageManagerInternal)4 PhoneAccountHandle (android.telecom.PhoneAccountHandle)4 TelecomManager (android.telecom.TelecomManager)4 ArrayList (java.util.ArrayList)4