android.util.SparseBooleanArray#delete ( )源码实例Demo

下面列出了android.util.SparseBooleanArray#delete ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: InstantAppRegistry.java
private void removeInstantAppLPw(@UserIdInt int userId, int instantAppId) {
    // remove from the installed list
    if (mInstalledInstantAppUids == null) {
        return; // no instant apps on the system
    }
    final SparseBooleanArray instantAppList = mInstalledInstantAppUids.get(userId);
    if (instantAppList == null) {
        return;
    }

    instantAppList.delete(instantAppId);

    // remove any grants
    if (mInstantGrants == null) {
        return; // no grants on the system
    }
    final SparseArray<SparseBooleanArray> targetAppList = mInstantGrants.get(userId);
    if (targetAppList == null) {
        return; // no grants for this user
    }
    for (int i = targetAppList.size() - 1; i >= 0; --i) {
        targetAppList.valueAt(i).delete(instantAppId);
    }
}
 
源代码2 项目: android_9.0.0_r45   文件: AppStateTracker.java
private static boolean removeUidFromArray(SparseBooleanArray array, int uid, boolean remove) {
    if (UserHandle.isCore(uid)) {
        return false;
    }
    if (!array.get(uid)) {
        return false;
    }
    if (remove) {
        array.delete(uid);
    } else {
        array.put(uid, false);
    }
    return true;
}
 
private void setUidOnMeteredNetworkList(int uid, boolean blacklist, boolean enable) {
    mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);

    // silently discard when control disabled
    // TODO: eventually migrate to be always enabled
    if (!mBandwidthControlEnabled) return;

    final String chain = blacklist ? "naughtyapps" : "niceapps";
    final String suffix = enable ? "add" : "remove";

    synchronized (mQuotaLock) {
        boolean oldEnable;
        SparseBooleanArray quotaList;
        synchronized (mRulesLock) {
            quotaList = blacklist ? mUidRejectOnMetered : mUidAllowOnMetered;
            oldEnable = quotaList.get(uid, false);
        }
        if (oldEnable == enable) {
            // TODO: eventually consider throwing
            return;
        }

        Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "inetd bandwidth");
        try {
            mConnector.execute("bandwidth", suffix + chain, uid);
            synchronized (mRulesLock) {
                if (enable) {
                    quotaList.put(uid, true);
                } else {
                    quotaList.delete(uid);
                }
            }
        } catch (NativeDaemonConnectorException e) {
            throw e.rethrowAsParcelableException();
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
        }
    }
}