Search in sources :

Example 1 with IntArray

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

the class NetworkStats method startUserUidEnumeration.

/**
     * Starts uid enumeration for current user.
     * @throws RemoteException
     */
void startUserUidEnumeration() throws RemoteException {
    // TODO: getRelevantUids should be sensitive to time interval. When that's done,
    //       the filtering logic below can be removed.
    int[] uids = mSession.getRelevantUids();
    // Filtering of uids with empty history.
    IntArray filteredUids = new IntArray(uids.length);
    for (int uid : uids) {
        try {
            NetworkStatsHistory history = mSession.getHistoryIntervalForUid(mTemplate, uid, android.net.NetworkStats.SET_ALL, android.net.NetworkStats.TAG_NONE, NetworkStatsHistory.FIELD_ALL, mStartTimeStamp, mEndTimeStamp);
            if (history != null && history.size() > 0) {
                filteredUids.add(uid);
            }
        } catch (RemoteException e) {
            Log.w(TAG, "Error while getting history of uid " + uid, e);
        }
    }
    mUids = filteredUids.toArray();
    mUidOrUidIndex = -1;
    stepHistory();
}
Also used : IntArray(android.util.IntArray) NetworkStatsHistory(android.net.NetworkStatsHistory) RemoteException(android.os.RemoteException)

Example 2 with IntArray

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

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 3 with IntArray

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

the class UserManagerService method getProfileIdsLU.

/**
     *  Assume permissions already checked and caller's identity cleared
     */
private IntArray getProfileIdsLU(int userId, boolean enabledOnly) {
    UserInfo user = getUserInfoLU(userId);
    IntArray result = new IntArray(mUsers.size());
    if (user == null) {
        // Probably a dying user
        return result;
    }
    final int userSize = mUsers.size();
    for (int i = 0; i < userSize; i++) {
        UserInfo profile = mUsers.valueAt(i).info;
        if (!isProfileOf(user, profile)) {
            continue;
        }
        if (enabledOnly && !profile.isEnabled()) {
            continue;
        }
        if (mRemovingUserIds.get(profile.id)) {
            continue;
        }
        if (profile.partial) {
            continue;
        }
        result.add(profile.id);
    }
    return result;
}
Also used : IntArray(android.util.IntArray) SparseIntArray(android.util.SparseIntArray) UserInfo(android.content.pm.UserInfo)

Example 4 with IntArray

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

the class UserManagerService method getProfilesLU.

/** Assume permissions already checked and caller's identity cleared */
private List<UserInfo> getProfilesLU(int userId, boolean enabledOnly, boolean fullInfo) {
    IntArray profileIds = getProfileIdsLU(userId, enabledOnly);
    ArrayList<UserInfo> users = new ArrayList<>(profileIds.size());
    for (int i = 0; i < profileIds.size(); i++) {
        int profileId = profileIds.get(i);
        UserInfo userInfo = mUsers.get(profileId).info;
        // If full info is not required - clear PII data to prevent 3P apps from reading it
        if (!fullInfo) {
            userInfo = new UserInfo(userInfo);
            userInfo.name = null;
            userInfo.iconPath = null;
        } else {
            userInfo = userWithName(userInfo);
        }
        users.add(userInfo);
    }
    return users;
}
Also used : IntArray(android.util.IntArray) SparseIntArray(android.util.SparseIntArray) ArrayList(java.util.ArrayList) UserInfo(android.content.pm.UserInfo)

Example 5 with IntArray

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

the class TelecomLoaderService method registerDefaultAppProviders.

private void registerDefaultAppProviders() {
    final PackageManagerInternal packageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
    // Set a callback for the package manager to query the default sms app.
    packageManagerInternal.setSmsAppPackagesProvider(new PackageManagerInternal.PackagesProvider() {

        @Override
        public String[] getPackages(int userId) {
            synchronized (mLock) {
                if (mServiceConnection == null) {
                    if (mDefaultSmsAppRequests == null) {
                        mDefaultSmsAppRequests = new IntArray();
                    }
                    mDefaultSmsAppRequests.add(userId);
                    return null;
                }
            }
            ComponentName smsComponent = SmsApplication.getDefaultSmsApplication(mContext, true);
            if (smsComponent != null) {
                return new String[] { smsComponent.getPackageName() };
            }
            return null;
        }
    });
    // Set a callback for the package manager to query the default dialer app.
    packageManagerInternal.setDialerAppPackagesProvider(new PackageManagerInternal.PackagesProvider() {

        @Override
        public String[] getPackages(int userId) {
            synchronized (mLock) {
                if (mServiceConnection == null) {
                    if (mDefaultDialerAppRequests == null) {
                        mDefaultDialerAppRequests = new IntArray();
                    }
                    mDefaultDialerAppRequests.add(userId);
                    return null;
                }
            }
            String packageName = DefaultDialerManager.getDefaultDialerApplication(mContext);
            if (packageName != null) {
                return new String[] { packageName };
            }
            return null;
        }
    });
    // Set a callback for the package manager to query the default sim call manager.
    packageManagerInternal.setSimCallManagerPackagesProvider(new PackageManagerInternal.PackagesProvider() {

        @Override
        public String[] getPackages(int userId) {
            synchronized (mLock) {
                if (mServiceConnection == null) {
                    if (mDefaultSimCallManagerRequests == null) {
                        mDefaultSimCallManagerRequests = new IntArray();
                    }
                    mDefaultSimCallManagerRequests.add(userId);
                    return null;
                }
            }
            TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
            PhoneAccountHandle phoneAccount = telecomManager.getSimCallManager(userId);
            if (phoneAccount != null) {
                return new String[] { phoneAccount.getComponentName().getPackageName() };
            }
            return null;
        }
    });
}
Also used : IntArray(android.util.IntArray) PhoneAccountHandle(android.telecom.PhoneAccountHandle) PackageManagerInternal(android.content.pm.PackageManagerInternal) ComponentName(android.content.ComponentName) TelecomManager(android.telecom.TelecomManager)

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