use of android.util.ArrayMap in project android_frameworks_base by crdroidandroid.
the class CaptivePortalLoginActivity method setWebViewProxy.
// Find WebView's proxy BroadcastReceiver and prompt it to read proxy system properties.
private void setWebViewProxy() {
LoadedApk loadedApk = getApplication().mLoadedApk;
try {
Field receiversField = LoadedApk.class.getDeclaredField("mReceivers");
receiversField.setAccessible(true);
ArrayMap receivers = (ArrayMap) receiversField.get(loadedApk);
for (Object receiverMap : receivers.values()) {
for (Object rec : ((ArrayMap) receiverMap).keySet()) {
Class clazz = rec.getClass();
if (clazz.getName().contains("ProxyChangeListener")) {
Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class);
Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
onReceiveMethod.invoke(rec, getApplicationContext(), intent);
Log.v(TAG, "Prompting WebView proxy reload.");
}
}
}
} catch (Exception e) {
Log.e(TAG, "Exception while setting WebView proxy: " + e);
}
}
use of android.util.ArrayMap in project android_frameworks_base by crdroidandroid.
the class BatteryStats method dumpCheckinLocked.
/**
* Checkin server version of dump to produce more compact, computer-readable log.
*
* NOTE: all times are expressed in 'ms'.
*/
public final void dumpCheckinLocked(Context context, PrintWriter pw, int which, int reqUid, boolean wifiOnly) {
final long rawUptime = SystemClock.uptimeMillis() * 1000;
final long rawRealtime = SystemClock.elapsedRealtime() * 1000;
final long batteryUptime = getBatteryUptime(rawUptime);
final long whichBatteryUptime = computeBatteryUptime(rawUptime, which);
final long whichBatteryRealtime = computeBatteryRealtime(rawRealtime, which);
final long whichBatteryScreenOffUptime = computeBatteryScreenOffUptime(rawUptime, which);
final long whichBatteryScreenOffRealtime = computeBatteryScreenOffRealtime(rawRealtime, which);
final long totalRealtime = computeRealtime(rawRealtime, which);
final long totalUptime = computeUptime(rawUptime, which);
final long screenOnTime = getScreenOnTime(rawRealtime, which);
final long interactiveTime = getInteractiveTime(rawRealtime, which);
final long powerSaveModeEnabledTime = getPowerSaveModeEnabledTime(rawRealtime, which);
final long deviceIdleModeLightTime = getDeviceIdleModeTime(DEVICE_IDLE_MODE_LIGHT, rawRealtime, which);
final long deviceIdleModeFullTime = getDeviceIdleModeTime(DEVICE_IDLE_MODE_DEEP, rawRealtime, which);
final long deviceLightIdlingTime = getDeviceIdlingTime(DEVICE_IDLE_MODE_LIGHT, rawRealtime, which);
final long deviceIdlingTime = getDeviceIdlingTime(DEVICE_IDLE_MODE_DEEP, rawRealtime, which);
final int connChanges = getNumConnectivityChange(which);
final long phoneOnTime = getPhoneOnTime(rawRealtime, which);
final long dischargeCount = getDischargeCoulombCounter().getCountLocked(which);
final long dischargeScreenOffCount = getDischargeScreenOffCoulombCounter().getCountLocked(which);
final StringBuilder sb = new StringBuilder(128);
final SparseArray<? extends Uid> uidStats = getUidStats();
final int NU = uidStats.size();
final String category = STAT_NAMES[which];
// Dump "battery" stat
dumpLine(pw, 0, /* uid */
category, BATTERY_DATA, which == STATS_SINCE_CHARGED ? getStartCount() : "N/A", whichBatteryRealtime / 1000, whichBatteryUptime / 1000, totalRealtime / 1000, totalUptime / 1000, getStartClockTime(), whichBatteryScreenOffRealtime / 1000, whichBatteryScreenOffUptime / 1000, getEstimatedBatteryCapacity());
// Calculate wakelock times across all uids.
long fullWakeLockTimeTotal = 0;
long partialWakeLockTimeTotal = 0;
for (int iu = 0; iu < NU; iu++) {
final Uid u = uidStats.valueAt(iu);
final ArrayMap<String, ? extends BatteryStats.Uid.Wakelock> wakelocks = u.getWakelockStats();
for (int iw = wakelocks.size() - 1; iw >= 0; iw--) {
final Uid.Wakelock wl = wakelocks.valueAt(iw);
final Timer fullWakeTimer = wl.getWakeTime(WAKE_TYPE_FULL);
if (fullWakeTimer != null) {
fullWakeLockTimeTotal += fullWakeTimer.getTotalTimeLocked(rawRealtime, which);
}
final Timer partialWakeTimer = wl.getWakeTime(WAKE_TYPE_PARTIAL);
if (partialWakeTimer != null) {
partialWakeLockTimeTotal += partialWakeTimer.getTotalTimeLocked(rawRealtime, which);
}
}
}
// Dump network stats
final long mobileRxTotalBytes = getNetworkActivityBytes(NETWORK_MOBILE_RX_DATA, which);
final long mobileTxTotalBytes = getNetworkActivityBytes(NETWORK_MOBILE_TX_DATA, which);
final long wifiRxTotalBytes = getNetworkActivityBytes(NETWORK_WIFI_RX_DATA, which);
final long wifiTxTotalBytes = getNetworkActivityBytes(NETWORK_WIFI_TX_DATA, which);
final long mobileRxTotalPackets = getNetworkActivityPackets(NETWORK_MOBILE_RX_DATA, which);
final long mobileTxTotalPackets = getNetworkActivityPackets(NETWORK_MOBILE_TX_DATA, which);
final long wifiRxTotalPackets = getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, which);
final long wifiTxTotalPackets = getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, which);
final long btRxTotalBytes = getNetworkActivityBytes(NETWORK_BT_RX_DATA, which);
final long btTxTotalBytes = getNetworkActivityBytes(NETWORK_BT_TX_DATA, which);
dumpLine(pw, 0, /* uid */
category, GLOBAL_NETWORK_DATA, mobileRxTotalBytes, mobileTxTotalBytes, wifiRxTotalBytes, wifiTxTotalBytes, mobileRxTotalPackets, mobileTxTotalPackets, wifiRxTotalPackets, wifiTxTotalPackets, btRxTotalBytes, btTxTotalBytes);
// Dump Modem controller stats
dumpControllerActivityLine(pw, 0, /* uid */
category, GLOBAL_MODEM_CONTROLLER_DATA, getModemControllerActivity(), which);
// Dump Wifi controller stats
final long wifiOnTime = getWifiOnTime(rawRealtime, which);
final long wifiRunningTime = getGlobalWifiRunningTime(rawRealtime, which);
dumpLine(pw, 0, /* uid */
category, GLOBAL_WIFI_DATA, wifiOnTime / 1000, wifiRunningTime / 1000, /* legacy fields follow, keep at 0 */
0, 0, 0);
dumpControllerActivityLine(pw, 0, /* uid */
category, GLOBAL_WIFI_CONTROLLER_DATA, getWifiControllerActivity(), which);
// Dump Bluetooth controller stats
dumpControllerActivityLine(pw, 0, /* uid */
category, GLOBAL_BLUETOOTH_CONTROLLER_DATA, getBluetoothControllerActivity(), which);
// Dump misc stats
dumpLine(pw, 0, /* uid */
category, MISC_DATA, screenOnTime / 1000, phoneOnTime / 1000, fullWakeLockTimeTotal / 1000, partialWakeLockTimeTotal / 1000, getMobileRadioActiveTime(rawRealtime, which) / 1000, getMobileRadioActiveAdjustedTime(which) / 1000, interactiveTime / 1000, powerSaveModeEnabledTime / 1000, connChanges, deviceIdleModeFullTime / 1000, getDeviceIdleModeCount(DEVICE_IDLE_MODE_DEEP, which), deviceIdlingTime / 1000, getDeviceIdlingCount(DEVICE_IDLE_MODE_DEEP, which), getMobileRadioActiveCount(which), getMobileRadioActiveUnknownTime(which) / 1000, deviceIdleModeLightTime / 1000, getDeviceIdleModeCount(DEVICE_IDLE_MODE_LIGHT, which), deviceLightIdlingTime / 1000, getDeviceIdlingCount(DEVICE_IDLE_MODE_LIGHT, which), getLongestDeviceIdleModeTime(DEVICE_IDLE_MODE_LIGHT), getLongestDeviceIdleModeTime(DEVICE_IDLE_MODE_DEEP));
// Dump screen brightness stats
Object[] args = new Object[NUM_SCREEN_BRIGHTNESS_BINS];
for (int i = 0; i < NUM_SCREEN_BRIGHTNESS_BINS; i++) {
args[i] = getScreenBrightnessTime(i, rawRealtime, which) / 1000;
}
dumpLine(pw, 0, /* uid */
category, SCREEN_BRIGHTNESS_DATA, args);
// Dump signal strength stats
args = new Object[SignalStrength.NUM_SIGNAL_STRENGTH_BINS];
for (int i = 0; i < SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
args[i] = getPhoneSignalStrengthTime(i, rawRealtime, which) / 1000;
}
dumpLine(pw, 0, /* uid */
category, SIGNAL_STRENGTH_TIME_DATA, args);
dumpLine(pw, 0, /* uid */
category, SIGNAL_SCANNING_TIME_DATA, getPhoneSignalScanningTime(rawRealtime, which) / 1000);
for (int i = 0; i < SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
args[i] = getPhoneSignalStrengthCount(i, which);
}
dumpLine(pw, 0, /* uid */
category, SIGNAL_STRENGTH_COUNT_DATA, args);
// Dump network type stats
args = new Object[NUM_DATA_CONNECTION_TYPES];
for (int i = 0; i < NUM_DATA_CONNECTION_TYPES; i++) {
args[i] = getPhoneDataConnectionTime(i, rawRealtime, which) / 1000;
}
dumpLine(pw, 0, /* uid */
category, DATA_CONNECTION_TIME_DATA, args);
for (int i = 0; i < NUM_DATA_CONNECTION_TYPES; i++) {
args[i] = getPhoneDataConnectionCount(i, which);
}
dumpLine(pw, 0, /* uid */
category, DATA_CONNECTION_COUNT_DATA, args);
// Dump wifi state stats
args = new Object[NUM_WIFI_STATES];
for (int i = 0; i < NUM_WIFI_STATES; i++) {
args[i] = getWifiStateTime(i, rawRealtime, which) / 1000;
}
dumpLine(pw, 0, /* uid */
category, WIFI_STATE_TIME_DATA, args);
for (int i = 0; i < NUM_WIFI_STATES; i++) {
args[i] = getWifiStateCount(i, which);
}
dumpLine(pw, 0, /* uid */
category, WIFI_STATE_COUNT_DATA, args);
// Dump wifi suppl state stats
args = new Object[NUM_WIFI_SUPPL_STATES];
for (int i = 0; i < NUM_WIFI_SUPPL_STATES; i++) {
args[i] = getWifiSupplStateTime(i, rawRealtime, which) / 1000;
}
dumpLine(pw, 0, /* uid */
category, WIFI_SUPPL_STATE_TIME_DATA, args);
for (int i = 0; i < NUM_WIFI_SUPPL_STATES; i++) {
args[i] = getWifiSupplStateCount(i, which);
}
dumpLine(pw, 0, /* uid */
category, WIFI_SUPPL_STATE_COUNT_DATA, args);
// Dump wifi signal strength stats
args = new Object[NUM_WIFI_SIGNAL_STRENGTH_BINS];
for (int i = 0; i < NUM_WIFI_SIGNAL_STRENGTH_BINS; i++) {
args[i] = getWifiSignalStrengthTime(i, rawRealtime, which) / 1000;
}
dumpLine(pw, 0, /* uid */
category, WIFI_SIGNAL_STRENGTH_TIME_DATA, args);
for (int i = 0; i < NUM_WIFI_SIGNAL_STRENGTH_BINS; i++) {
args[i] = getWifiSignalStrengthCount(i, which);
}
dumpLine(pw, 0, /* uid */
category, WIFI_SIGNAL_STRENGTH_COUNT_DATA, args);
if (which == STATS_SINCE_UNPLUGGED) {
dumpLine(pw, 0, /* uid */
category, BATTERY_LEVEL_DATA, getDischargeStartLevel(), getDischargeCurrentLevel());
}
if (which == STATS_SINCE_UNPLUGGED) {
dumpLine(pw, 0, /* uid */
category, BATTERY_DISCHARGE_DATA, getDischargeStartLevel() - getDischargeCurrentLevel(), getDischargeStartLevel() - getDischargeCurrentLevel(), getDischargeAmountScreenOn(), getDischargeAmountScreenOff(), dischargeCount / 1000, dischargeScreenOffCount / 1000);
} else {
dumpLine(pw, 0, /* uid */
category, BATTERY_DISCHARGE_DATA, getLowDischargeAmountSinceCharge(), getHighDischargeAmountSinceCharge(), getDischargeAmountScreenOnSinceCharge(), getDischargeAmountScreenOffSinceCharge(), dischargeCount / 1000, dischargeScreenOffCount / 1000);
}
if (reqUid < 0) {
final Map<String, ? extends Timer> kernelWakelocks = getKernelWakelockStats();
if (kernelWakelocks.size() > 0) {
for (Map.Entry<String, ? extends Timer> ent : kernelWakelocks.entrySet()) {
sb.setLength(0);
printWakeLockCheckin(sb, ent.getValue(), rawRealtime, null, which, "");
dumpLine(pw, 0, /* uid */
category, KERNEL_WAKELOCK_DATA, ent.getKey(), sb.toString());
}
}
final Map<String, ? extends Timer> wakeupReasons = getWakeupReasonStats();
if (wakeupReasons.size() > 0) {
for (Map.Entry<String, ? extends Timer> ent : wakeupReasons.entrySet()) {
// Not doing the regular wake lock formatting to remain compatible
// with the old checkin format.
long totalTimeMicros = ent.getValue().getTotalTimeLocked(rawRealtime, which);
int count = ent.getValue().getCountLocked(which);
dumpLine(pw, 0, /* uid */
category, WAKEUP_REASON_DATA, "\"" + ent.getKey() + "\"", (totalTimeMicros + 500) / 1000, count);
}
}
}
final BatteryStatsHelper helper = new BatteryStatsHelper(context, false, wifiOnly);
helper.create(this);
helper.refreshStats(which, UserHandle.USER_ALL);
final List<BatterySipper> sippers = helper.getUsageList();
if (sippers != null && sippers.size() > 0) {
dumpLine(pw, 0, /* uid */
category, POWER_USE_SUMMARY_DATA, BatteryStatsHelper.makemAh(helper.getPowerProfile().getBatteryCapacity()), BatteryStatsHelper.makemAh(helper.getComputedPower()), BatteryStatsHelper.makemAh(helper.getMinDrainedPower()), BatteryStatsHelper.makemAh(helper.getMaxDrainedPower()));
for (int i = 0; i < sippers.size(); i++) {
final BatterySipper bs = sippers.get(i);
int uid = 0;
String label;
switch(bs.drainType) {
case IDLE:
label = "idle";
break;
case CELL:
label = "cell";
break;
case PHONE:
label = "phone";
break;
case WIFI:
label = "wifi";
break;
case BLUETOOTH:
label = "blue";
break;
case SCREEN:
label = "scrn";
break;
case FLASHLIGHT:
label = "flashlight";
break;
case APP:
uid = bs.uidObj.getUid();
label = "uid";
break;
case USER:
uid = UserHandle.getUid(bs.userId, 0);
label = "user";
break;
case UNACCOUNTED:
label = "unacc";
break;
case OVERCOUNTED:
label = "over";
break;
case CAMERA:
label = "camera";
break;
default:
label = "???";
}
dumpLine(pw, uid, category, POWER_USE_ITEM_DATA, label, BatteryStatsHelper.makemAh(bs.totalPowerMah));
}
}
for (int iu = 0; iu < NU; iu++) {
final int uid = uidStats.keyAt(iu);
if (reqUid >= 0 && uid != reqUid) {
continue;
}
final Uid u = uidStats.valueAt(iu);
// Dump Network stats per uid, if any
final long mobileBytesRx = u.getNetworkActivityBytes(NETWORK_MOBILE_RX_DATA, which);
final long mobileBytesTx = u.getNetworkActivityBytes(NETWORK_MOBILE_TX_DATA, which);
final long wifiBytesRx = u.getNetworkActivityBytes(NETWORK_WIFI_RX_DATA, which);
final long wifiBytesTx = u.getNetworkActivityBytes(NETWORK_WIFI_TX_DATA, which);
final long mobilePacketsRx = u.getNetworkActivityPackets(NETWORK_MOBILE_RX_DATA, which);
final long mobilePacketsTx = u.getNetworkActivityPackets(NETWORK_MOBILE_TX_DATA, which);
final long mobileActiveTime = u.getMobileRadioActiveTime(which);
final int mobileActiveCount = u.getMobileRadioActiveCount(which);
final long mobileWakeup = u.getMobileRadioApWakeupCount(which);
final long wifiPacketsRx = u.getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, which);
final long wifiPacketsTx = u.getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, which);
final long wifiWakeup = u.getWifiRadioApWakeupCount(which);
final long btBytesRx = u.getNetworkActivityBytes(NETWORK_BT_RX_DATA, which);
final long btBytesTx = u.getNetworkActivityBytes(NETWORK_BT_TX_DATA, which);
if (mobileBytesRx > 0 || mobileBytesTx > 0 || wifiBytesRx > 0 || wifiBytesTx > 0 || mobilePacketsRx > 0 || mobilePacketsTx > 0 || wifiPacketsRx > 0 || wifiPacketsTx > 0 || mobileActiveTime > 0 || mobileActiveCount > 0 || btBytesRx > 0 || btBytesTx > 0 || mobileWakeup > 0 || wifiWakeup > 0) {
dumpLine(pw, uid, category, NETWORK_DATA, mobileBytesRx, mobileBytesTx, wifiBytesRx, wifiBytesTx, mobilePacketsRx, mobilePacketsTx, wifiPacketsRx, wifiPacketsTx, mobileActiveTime, mobileActiveCount, btBytesRx, btBytesTx, mobileWakeup, wifiWakeup);
}
// Dump modem controller data, per UID.
dumpControllerActivityLine(pw, uid, category, MODEM_CONTROLLER_DATA, u.getModemControllerActivity(), which);
// Dump Wifi controller data, per UID.
final long fullWifiLockOnTime = u.getFullWifiLockTime(rawRealtime, which);
final long wifiScanTime = u.getWifiScanTime(rawRealtime, which);
final int wifiScanCount = u.getWifiScanCount(which);
final long uidWifiRunningTime = u.getWifiRunningTime(rawRealtime, which);
if (fullWifiLockOnTime != 0 || wifiScanTime != 0 || wifiScanCount != 0 || uidWifiRunningTime != 0) {
dumpLine(pw, uid, category, WIFI_DATA, fullWifiLockOnTime, wifiScanTime, uidWifiRunningTime, wifiScanCount, /* legacy fields follow, keep at 0 */
0, 0, 0);
}
dumpControllerActivityLine(pw, uid, category, WIFI_CONTROLLER_DATA, u.getWifiControllerActivity(), which);
dumpTimer(pw, uid, category, BLUETOOTH_MISC_DATA, u.getBluetoothScanTimer(), rawRealtime, which);
dumpControllerActivityLine(pw, uid, category, BLUETOOTH_CONTROLLER_DATA, u.getBluetoothControllerActivity(), which);
if (u.hasUserActivity()) {
args = new Object[Uid.NUM_USER_ACTIVITY_TYPES];
boolean hasData = false;
for (int i = 0; i < Uid.NUM_USER_ACTIVITY_TYPES; i++) {
int val = u.getUserActivityCount(i, which);
args[i] = val;
if (val != 0)
hasData = true;
}
if (hasData) {
dumpLine(pw, uid, /* uid */
category, USER_ACTIVITY_DATA, args);
}
}
final ArrayMap<String, ? extends Uid.Wakelock> wakelocks = u.getWakelockStats();
for (int iw = wakelocks.size() - 1; iw >= 0; iw--) {
final Uid.Wakelock wl = wakelocks.valueAt(iw);
String linePrefix = "";
sb.setLength(0);
linePrefix = printWakeLockCheckin(sb, wl.getWakeTime(WAKE_TYPE_FULL), rawRealtime, "f", which, linePrefix);
linePrefix = printWakeLockCheckin(sb, wl.getWakeTime(WAKE_TYPE_PARTIAL), rawRealtime, "p", which, linePrefix);
linePrefix = printWakeLockCheckin(sb, wl.getWakeTime(WAKE_TYPE_WINDOW), rawRealtime, "w", which, linePrefix);
// Only log if we had at lease one wakelock...
if (sb.length() > 0) {
String name = wakelocks.keyAt(iw);
if (name.indexOf(',') >= 0) {
name = name.replace(',', '_');
}
dumpLine(pw, uid, category, WAKELOCK_DATA, name, sb.toString());
}
}
final ArrayMap<String, ? extends Timer> syncs = u.getSyncStats();
for (int isy = syncs.size() - 1; isy >= 0; isy--) {
final Timer timer = syncs.valueAt(isy);
// Convert from microseconds to milliseconds with rounding
final long totalTime = (timer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000;
final int count = timer.getCountLocked(which);
if (totalTime != 0) {
dumpLine(pw, uid, category, SYNC_DATA, syncs.keyAt(isy), totalTime, count);
}
}
final ArrayMap<String, ? extends Timer> jobs = u.getJobStats();
for (int ij = jobs.size() - 1; ij >= 0; ij--) {
final Timer timer = jobs.valueAt(ij);
// Convert from microseconds to milliseconds with rounding
final long totalTime = (timer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000;
final int count = timer.getCountLocked(which);
if (totalTime != 0) {
dumpLine(pw, uid, category, JOB_DATA, jobs.keyAt(ij), totalTime, count);
}
}
dumpTimer(pw, uid, category, FLASHLIGHT_DATA, u.getFlashlightTurnedOnTimer(), rawRealtime, which);
dumpTimer(pw, uid, category, CAMERA_DATA, u.getCameraTurnedOnTimer(), rawRealtime, which);
dumpTimer(pw, uid, category, VIDEO_DATA, u.getVideoTurnedOnTimer(), rawRealtime, which);
dumpTimer(pw, uid, category, AUDIO_DATA, u.getAudioTurnedOnTimer(), rawRealtime, which);
final SparseArray<? extends BatteryStats.Uid.Sensor> sensors = u.getSensorStats();
final int NSE = sensors.size();
for (int ise = 0; ise < NSE; ise++) {
final Uid.Sensor se = sensors.valueAt(ise);
final int sensorNumber = sensors.keyAt(ise);
final Timer timer = se.getSensorTime();
if (timer != null) {
// Convert from microseconds to milliseconds with rounding
final long totalTime = (timer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000;
final int count = timer.getCountLocked(which);
if (totalTime != 0) {
dumpLine(pw, uid, category, SENSOR_DATA, sensorNumber, totalTime, count);
}
}
}
dumpTimer(pw, uid, category, VIBRATOR_DATA, u.getVibratorOnTimer(), rawRealtime, which);
dumpTimer(pw, uid, category, FOREGROUND_DATA, u.getForegroundActivityTimer(), rawRealtime, which);
final Object[] stateTimes = new Object[Uid.NUM_PROCESS_STATE];
long totalStateTime = 0;
for (int ips = 0; ips < Uid.NUM_PROCESS_STATE; ips++) {
final long time = u.getProcessStateTime(ips, rawRealtime, which);
totalStateTime += time;
stateTimes[ips] = (time + 500) / 1000;
}
if (totalStateTime > 0) {
dumpLine(pw, uid, category, STATE_TIME_DATA, stateTimes);
}
final long userCpuTimeUs = u.getUserCpuTimeUs(which);
final long systemCpuTimeUs = u.getSystemCpuTimeUs(which);
final long powerCpuMaUs = u.getCpuPowerMaUs(which);
if (userCpuTimeUs > 0 || systemCpuTimeUs > 0 || powerCpuMaUs > 0) {
dumpLine(pw, uid, category, CPU_DATA, userCpuTimeUs / 1000, systemCpuTimeUs / 1000, powerCpuMaUs / 1000);
}
final ArrayMap<String, ? extends BatteryStats.Uid.Proc> processStats = u.getProcessStats();
for (int ipr = processStats.size() - 1; ipr >= 0; ipr--) {
final Uid.Proc ps = processStats.valueAt(ipr);
final long userMillis = ps.getUserTime(which);
final long systemMillis = ps.getSystemTime(which);
final long foregroundMillis = ps.getForegroundTime(which);
final int starts = ps.getStarts(which);
final int numCrashes = ps.getNumCrashes(which);
final int numAnrs = ps.getNumAnrs(which);
if (userMillis != 0 || systemMillis != 0 || foregroundMillis != 0 || starts != 0 || numAnrs != 0 || numCrashes != 0) {
dumpLine(pw, uid, category, PROCESS_DATA, processStats.keyAt(ipr), userMillis, systemMillis, foregroundMillis, starts, numAnrs, numCrashes);
}
}
final ArrayMap<String, ? extends BatteryStats.Uid.Pkg> packageStats = u.getPackageStats();
for (int ipkg = packageStats.size() - 1; ipkg >= 0; ipkg--) {
final Uid.Pkg ps = packageStats.valueAt(ipkg);
int wakeups = 0;
final ArrayMap<String, ? extends Counter> alarms = ps.getWakeupAlarmStats();
for (int iwa = alarms.size() - 1; iwa >= 0; iwa--) {
int count = alarms.valueAt(iwa).getCountLocked(which);
wakeups += count;
String name = alarms.keyAt(iwa).replace(',', '_');
dumpLine(pw, uid, category, WAKEUP_ALARM_DATA, name, count);
}
final ArrayMap<String, ? extends Uid.Pkg.Serv> serviceStats = ps.getServiceStats();
for (int isvc = serviceStats.size() - 1; isvc >= 0; isvc--) {
final BatteryStats.Uid.Pkg.Serv ss = serviceStats.valueAt(isvc);
final long startTime = ss.getStartTime(batteryUptime, which);
final int starts = ss.getStarts(which);
final int launches = ss.getLaunches(which);
if (startTime != 0 || starts != 0 || launches != 0) {
dumpLine(pw, uid, category, APK_DATA, // wakeup alarms
wakeups, // Apk
packageStats.keyAt(ipkg), // service
serviceStats.keyAt(isvc), // time spent started, in ms
startTime / 1000, starts, launches);
}
}
}
}
}
use of android.util.ArrayMap in project android_frameworks_base by crdroidandroid.
the class NetworkSecurityConfig method getTrustAnchors.
public Set<TrustAnchor> getTrustAnchors() {
synchronized (mAnchorsLock) {
if (mAnchors != null) {
return mAnchors;
}
// Merge trust anchors based on the X509Certificate.
// If we see the same certificate in two TrustAnchors, one with overridesPins and one
// without, the one with overridesPins wins.
// Because mCertificatesEntryRefs is sorted with all overridesPins anchors coming first
// this can be simplified to just using the first occurrence of a certificate.
Map<X509Certificate, TrustAnchor> anchorMap = new ArrayMap<>();
for (CertificatesEntryRef ref : mCertificatesEntryRefs) {
Set<TrustAnchor> anchors = ref.getTrustAnchors();
for (TrustAnchor anchor : anchors) {
X509Certificate cert = anchor.certificate;
if (!anchorMap.containsKey(cert)) {
anchorMap.put(cert, anchor);
}
}
}
ArraySet<TrustAnchor> anchors = new ArraySet<TrustAnchor>(anchorMap.size());
anchors.addAll(anchorMap.values());
mAnchors = anchors;
return mAnchors;
}
}
use of android.util.ArrayMap in project android_frameworks_base by crdroidandroid.
the class NetworkSecurityTrustManager method checkPins.
private void checkPins(List<X509Certificate> chain) throws CertificateException {
PinSet pinSet = mNetworkSecurityConfig.getPins();
if (pinSet.pins.isEmpty() || System.currentTimeMillis() > pinSet.expirationTime || !isPinningEnforced(chain)) {
return;
}
Set<String> pinAlgorithms = pinSet.getPinAlgorithms();
Map<String, MessageDigest> digestMap = new ArrayMap<String, MessageDigest>(pinAlgorithms.size());
for (int i = chain.size() - 1; i >= 0; i--) {
X509Certificate cert = chain.get(i);
byte[] encodedSPKI = cert.getPublicKey().getEncoded();
for (String algorithm : pinAlgorithms) {
MessageDigest md = digestMap.get(algorithm);
if (md == null) {
try {
md = MessageDigest.getInstance(algorithm);
} catch (GeneralSecurityException e) {
throw new RuntimeException(e);
}
digestMap.put(algorithm, md);
}
if (pinSet.pins.contains(new Pin(algorithm, md.digest(encodedSPKI)))) {
return;
}
}
}
// TODO: Throw a subclass of CertificateException which indicates a pinning failure.
throw new CertificateException("Pin verification failed");
}
use of android.util.ArrayMap in project android_frameworks_base by crdroidandroid.
the class ShortcutPackage method sortShortcutsToActivities.
/**
* Build a list of shortcuts for each target activity and return as a map. The result won't
* contain "floating" shortcuts because they don't belong on any activities.
*/
private ArrayMap<ComponentName, ArrayList<ShortcutInfo>> sortShortcutsToActivities() {
final ArrayMap<ComponentName, ArrayList<ShortcutInfo>> activitiesToShortcuts = new ArrayMap<>();
for (int i = mShortcuts.size() - 1; i >= 0; i--) {
final ShortcutInfo si = mShortcuts.valueAt(i);
if (si.isFloating()) {
// Ignore floating shortcuts, which are not tied to any activities.
continue;
}
final ComponentName activity = si.getActivity();
ArrayList<ShortcutInfo> list = activitiesToShortcuts.get(activity);
if (list == null) {
list = new ArrayList<>();
activitiesToShortcuts.put(activity, list);
}
list.add(si);
}
return activitiesToShortcuts;
}
Aggregations