use of android.util.SparseIntArray in project android_frameworks_base by DirtyUnicorns.
the class TableRow method mapIndexAndColumns.
private void mapIndexAndColumns() {
if (mColumnToChildIndex == null) {
int virtualCount = 0;
final int count = getChildCount();
mColumnToChildIndex = new SparseIntArray();
final SparseIntArray columnToChild = mColumnToChildIndex;
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
final LayoutParams layoutParams = (LayoutParams) child.getLayoutParams();
if (layoutParams.column >= virtualCount) {
virtualCount = layoutParams.column;
}
for (int j = 0; j < layoutParams.span; j++) {
columnToChild.put(virtualCount++, i);
}
}
mNumColumns = virtualCount;
}
}
use of android.util.SparseIntArray in project android_frameworks_base by DirtyUnicorns.
the class ExifInterface method getTagDefinitionsForTagId.
protected int[] getTagDefinitionsForTagId(short tagId) {
int[] ifds = IfdData.getIfds();
int[] defs = new int[ifds.length];
int counter = 0;
SparseIntArray infos = getTagInfo();
for (int i : ifds) {
int def = defineTag(i, tagId);
if (infos.get(def) != DEFINITION_NULL) {
defs[counter++] = def;
}
}
if (counter == 0) {
return null;
}
return Arrays.copyOfRange(defs, 0, counter);
}
use of android.util.SparseIntArray in project android_frameworks_base by DirtyUnicorns.
the class ExifInterface method getTagInfo.
protected SparseIntArray getTagInfo() {
if (mTagInfo == null) {
mTagInfo = new SparseIntArray();
initTagInfo();
}
return mTagInfo;
}
use of android.util.SparseIntArray in project android_frameworks_base by DirtyUnicorns.
the class NetworkManagementService method prepareNativeDaemon.
/**
* Prepare native daemon once connected, enabling modules and pushing any
* existing in-memory rules.
*/
private void prepareNativeDaemon() {
mBandwidthControlEnabled = false;
// only enable bandwidth control when support exists
final boolean hasKernelSupport = new File("/proc/net/xt_qtaguid/ctrl").exists();
if (hasKernelSupport) {
Slog.d(TAG, "enabling bandwidth control");
try {
mConnector.execute("bandwidth", "enable");
mBandwidthControlEnabled = true;
} catch (NativeDaemonConnectorException e) {
Log.wtf(TAG, "problem enabling bandwidth controls", e);
}
} else {
Slog.i(TAG, "not enabling bandwidth control");
}
SystemProperties.set(PROP_QTAGUID_ENABLED, mBandwidthControlEnabled ? "1" : "0");
if (mBandwidthControlEnabled) {
try {
getBatteryStats().noteNetworkStatsEnabled();
} catch (RemoteException e) {
}
}
try {
mConnector.execute("strict", "enable");
mStrictEnabled = true;
} catch (NativeDaemonConnectorException e) {
Log.wtf(TAG, "Failed strict enable", e);
}
// push any existing quota or UID rules
synchronized (mQuotaLock) {
setDataSaverModeEnabled(mDataSaverMode);
int size = mActiveQuotas.size();
if (size > 0) {
if (DBG)
Slog.d(TAG, "Pushing " + size + " active quota rules");
final HashMap<String, Long> activeQuotas = mActiveQuotas;
mActiveQuotas = Maps.newHashMap();
for (Map.Entry<String, Long> entry : activeQuotas.entrySet()) {
setInterfaceQuota(entry.getKey(), entry.getValue());
}
}
size = mActiveAlerts.size();
if (size > 0) {
if (DBG)
Slog.d(TAG, "Pushing " + size + " active alert rules");
final HashMap<String, Long> activeAlerts = mActiveAlerts;
mActiveAlerts = Maps.newHashMap();
for (Map.Entry<String, Long> entry : activeAlerts.entrySet()) {
setInterfaceAlert(entry.getKey(), entry.getValue());
}
}
size = mUidRejectOnMetered.size();
if (size > 0) {
if (DBG)
Slog.d(TAG, "Pushing " + size + " UIDs to metered whitelist rules");
final SparseBooleanArray uidRejectOnQuota = mUidRejectOnMetered;
mUidRejectOnMetered = new SparseBooleanArray();
for (int i = 0; i < uidRejectOnQuota.size(); i++) {
setUidMeteredNetworkBlacklist(uidRejectOnQuota.keyAt(i), uidRejectOnQuota.valueAt(i));
}
}
size = mUidAllowOnMetered.size();
if (size > 0) {
if (DBG)
Slog.d(TAG, "Pushing " + size + " UIDs to metered blacklist rules");
final SparseBooleanArray uidAcceptOnQuota = mUidAllowOnMetered;
mUidAllowOnMetered = new SparseBooleanArray();
for (int i = 0; i < uidAcceptOnQuota.size(); i++) {
setUidMeteredNetworkWhitelist(uidAcceptOnQuota.keyAt(i), uidAcceptOnQuota.valueAt(i));
}
}
size = mUidCleartextPolicy.size();
if (size > 0) {
if (DBG)
Slog.d(TAG, "Pushing " + size + " active UID cleartext policies");
final SparseIntArray local = mUidCleartextPolicy;
mUidCleartextPolicy = new SparseIntArray();
for (int i = 0; i < local.size(); i++) {
setUidCleartextNetworkPolicy(local.keyAt(i), local.valueAt(i));
}
}
setFirewallEnabled(mFirewallEnabled || LockdownVpnTracker.isEnabled());
syncFirewallChainLocked(FIREWALL_CHAIN_NONE, mUidFirewallRules, "");
syncFirewallChainLocked(FIREWALL_CHAIN_STANDBY, mUidFirewallStandbyRules, "standby ");
syncFirewallChainLocked(FIREWALL_CHAIN_DOZABLE, mUidFirewallDozableRules, "dozable ");
syncFirewallChainLocked(FIREWALL_CHAIN_POWERSAVE, mUidFirewallPowerSaveRules, "powersave ");
if (mFirewallChainStates.get(FIREWALL_CHAIN_STANDBY)) {
setFirewallChainEnabled(FIREWALL_CHAIN_STANDBY, true);
}
if (mFirewallChainStates.get(FIREWALL_CHAIN_DOZABLE)) {
setFirewallChainEnabled(FIREWALL_CHAIN_DOZABLE, true);
}
if (mFirewallChainStates.get(FIREWALL_CHAIN_POWERSAVE)) {
setFirewallChainEnabled(FIREWALL_CHAIN_POWERSAVE, true);
}
}
}
use of android.util.SparseIntArray in project android_frameworks_base by DirtyUnicorns.
the class NetworkManagementService method closeSocketsForFirewallChainLocked.
private void closeSocketsForFirewallChainLocked(int chain, String chainName) {
// UID ranges to close sockets on.
UidRange[] ranges;
// UID ranges whose sockets we won't touch.
int[] exemptUids;
final SparseIntArray rules = getUidFirewallRules(chain);
int numUids = 0;
if (getFirewallType(chain) == FIREWALL_TYPE_WHITELIST) {
// Close all sockets on all non-system UIDs...
ranges = new UidRange[] { // specify their ranges here.
new UidRange(Process.FIRST_APPLICATION_UID, Integer.MAX_VALUE) };
// ... except for the UIDs that have allow rules.
exemptUids = new int[rules.size()];
for (int i = 0; i < exemptUids.length; i++) {
if (rules.valueAt(i) == NetworkPolicyManager.FIREWALL_RULE_ALLOW) {
exemptUids[numUids] = rules.keyAt(i);
numUids++;
}
}
// fix setFirewallEnabled to grab mQuotaLock and clear rules.
if (numUids != exemptUids.length) {
exemptUids = Arrays.copyOf(exemptUids, numUids);
}
} else {
// Close sockets for every UID that has a deny rule...
ranges = new UidRange[rules.size()];
for (int i = 0; i < ranges.length; i++) {
if (rules.valueAt(i) == NetworkPolicyManager.FIREWALL_RULE_DENY) {
int uid = rules.keyAt(i);
ranges[numUids] = new UidRange(uid, uid);
numUids++;
}
}
// As above; usually numUids == ranges.length, but not always.
if (numUids != ranges.length) {
ranges = Arrays.copyOf(ranges, numUids);
}
// ... with no exceptions.
exemptUids = new int[0];
}
try {
mNetdService.socketDestroy(ranges, exemptUids);
} catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Error closing sockets after enabling chain " + chainName + ": " + e);
}
}
Aggregations