use of android.util.SparseBooleanArray in project platform_frameworks_base by android.
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.SparseBooleanArray in project platform_frameworks_base by android.
the class MultiSelectManagerTest method testProvisionalSelection_Cancel.
public void testProvisionalSelection_Cancel() {
mManager.toggleSelection(items.get(1));
mManager.toggleSelection(items.get(2));
Selection s = mManager.getSelection();
SparseBooleanArray provisional = new SparseBooleanArray();
provisional.append(3, true);
provisional.append(4, true);
s.setProvisionalSelection(getItemIds(provisional));
s.cancelProvisionalSelection();
// Original selection should remain.
assertSelection(items.get(1), items.get(2));
}
use of android.util.SparseBooleanArray in project platform_frameworks_base by android.
the class MultiSelectManagerTest method testProvisionalSelection_IntersectsExistingProvisionalSelection.
public void testProvisionalSelection_IntersectsExistingProvisionalSelection() {
Selection s = mManager.getSelection();
SparseBooleanArray provisional = new SparseBooleanArray();
provisional.append(1, true);
provisional.append(2, true);
s.setProvisionalSelection(getItemIds(provisional));
provisional.clear();
provisional.append(1, true);
s.setProvisionalSelection(getItemIds(provisional));
assertSelection(items.get(1));
}
use of android.util.SparseBooleanArray in project platform_frameworks_base by android.
the class MultiSelectManagerTest method testProvisionalSelection_Apply.
public void testProvisionalSelection_Apply() {
Selection s = mManager.getSelection();
SparseBooleanArray provisional = new SparseBooleanArray();
provisional.append(1, true);
provisional.append(2, true);
s.setProvisionalSelection(getItemIds(provisional));
s.applyProvisionalSelection();
assertSelection(items.get(1), items.get(2));
}
use of android.util.SparseBooleanArray in project platform_frameworks_base by android.
the class MultiSelectManagerTest method testProvisionalSelection_Replace.
public void testProvisionalSelection_Replace() {
Selection s = mManager.getSelection();
SparseBooleanArray provisional = new SparseBooleanArray();
provisional.append(1, true);
provisional.append(2, true);
s.setProvisionalSelection(getItemIds(provisional));
provisional.clear();
provisional.append(3, true);
provisional.append(4, true);
s.setProvisionalSelection(getItemIds(provisional));
assertSelection(items.get(3), items.get(4));
}
Aggregations