diff options
| author | Dianne Hackborn <hackbod@google.com> | 2010-12-13 14:55:25 -0800 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2010-12-13 14:55:25 -0800 |
| commit | ccc714131359eb1022d8c6702b7d82ab9e93f27c (patch) | |
| tree | 150c9798fc3d0d5dfee9c83d75845014a5edf983 /core/java | |
| parent | ffdd591a829af7fddd36a7b80d2a3b8188c871a6 (diff) | |
| parent | 78e9f4cbaece783b7b87ce3fb0a157dae766012a (diff) | |
| download | frameworks_base-ccc714131359eb1022d8c6702b7d82ab9e93f27c.zip frameworks_base-ccc714131359eb1022d8c6702b7d82ab9e93f27c.tar.gz frameworks_base-ccc714131359eb1022d8c6702b7d82ab9e93f27c.tar.bz2 | |
resolved conflicts for merge of 78e9f4cb to master
Change-Id: I1135361e6d66f524c3f349e2bf1f31bd4191c634
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/content/pm/PackageParser.java | 2 | ||||
| -rw-r--r-- | core/java/android/os/BatteryStats.java | 35 | ||||
| -rw-r--r-- | core/java/com/android/internal/os/BatteryStatsImpl.java | 147 |
3 files changed, 130 insertions, 54 deletions
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 54dbe37..9cfe2db 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -191,7 +191,7 @@ public class PackageParser { pi.versionName = p.mVersionName; pi.sharedUserId = p.mSharedUserId; pi.sharedUserLabel = p.mSharedUserLabel; - pi.applicationInfo = p.applicationInfo; + pi.applicationInfo = generateApplicationInfo(p, flags); pi.installLocation = p.installLocation; pi.firstInstallTime = firstInstallTime; pi.lastUpdateTime = lastUpdateTime; diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java index 44f1757..7dd5e31 100644 --- a/core/java/android/os/BatteryStats.java +++ b/core/java/android/os/BatteryStats.java @@ -17,9 +17,12 @@ package android.os; import java.io.PrintWriter; +import java.util.ArrayList; import java.util.Formatter; +import java.util.List; import java.util.Map; +import android.content.pm.ApplicationInfo; import android.util.Log; import android.util.Printer; import android.util.SparseArray; @@ -120,6 +123,7 @@ public abstract class BatteryStats implements Parcelable { private static final long BYTES_PER_GB = 1073741824; //1024^3 + private static final String UID_DATA = "uid"; private static final String APK_DATA = "apk"; private static final String PROCESS_DATA = "pr"; private static final String SENSOR_DATA = "sr"; @@ -1463,7 +1467,7 @@ public abstract class BatteryStats implements Parcelable { for (int iu=0; iu<NU; iu++) { final int uid = uidStats.keyAt(iu); - if (reqUid >= 0 && uid != reqUid) { + if (reqUid >= 0 && uid != reqUid && uid != Process.SYSTEM_UID) { continue; } @@ -1880,7 +1884,7 @@ public abstract class BatteryStats implements Parcelable { } @SuppressWarnings("unused") - public void dumpCheckinLocked(PrintWriter pw, String[] args) { + public void dumpCheckinLocked(PrintWriter pw, String[] args, List<ApplicationInfo> apps) { boolean isUnpluggedOnly = false; for (String arg : args) { @@ -1890,6 +1894,33 @@ public abstract class BatteryStats implements Parcelable { } } + if (apps != null) { + SparseArray<ArrayList<String>> uids = new SparseArray<ArrayList<String>>(); + for (int i=0; i<apps.size(); i++) { + ApplicationInfo ai = apps.get(i); + ArrayList<String> pkgs = uids.get(ai.uid); + if (pkgs == null) { + pkgs = new ArrayList<String>(); + uids.put(ai.uid, pkgs); + } + pkgs.add(ai.packageName); + } + SparseArray<? extends Uid> uidStats = getUidStats(); + final int NU = uidStats.size(); + String[] lineArgs = new String[2]; + for (int i=0; i<NU; i++) { + int uid = uidStats.keyAt(i); + ArrayList<String> pkgs = uids.get(uid); + if (pkgs != null) { + for (int j=0; j<pkgs.size(); j++) { + lineArgs[0] = Integer.toString(uid); + lineArgs[1] = pkgs.get(j); + dumpLine(pw, 0 /* uid */, "i" /* category */, UID_DATA, + (Object[])lineArgs); + } + } + } + } if (isUnpluggedOnly) { dumpCheckinLocked(pw, STATS_SINCE_UNPLUGGED, -1); } diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 145feb5..284df1e 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -192,7 +192,8 @@ public final class BatteryStatsImpl extends BatteryStats { StopwatchTimer mVideoOnTimer; int mPhoneSignalStrengthBin = -1; - final StopwatchTimer[] mPhoneSignalStrengthsTimer = + int mPhoneSignalStrengthBinRaw = -1; + final StopwatchTimer[] mPhoneSignalStrengthsTimer = new StopwatchTimer[NUM_SIGNAL_STRENGTH_BINS]; StopwatchTimer mPhoneSignalScanningTimer; @@ -252,6 +253,8 @@ public final class BatteryStatsImpl extends BatteryStats { private int mBluetoothPingStart = -1; private int mPhoneServiceState = -1; + private int mPhoneServiceStateRaw = -1; + private int mPhoneSimStateRaw = -1; /* * Holds a SamplingTimer associated with each kernel wakelock name being tracked. @@ -1650,40 +1653,54 @@ public final class BatteryStatsImpl extends BatteryStats { } } - /** - * Telephony stack updates the phone state. - * @param state phone state from ServiceState.getState() - */ - public void notePhoneStateLocked(int state) { + private int fixPhoneServiceState(int state, int signalBin) { + if (mPhoneSimStateRaw == TelephonyManager.SIM_STATE_ABSENT) { + // In this case we will always be STATE_OUT_OF_SERVICE, so need + // to infer that we are scanning from other data. + if (state == ServiceState.STATE_OUT_OF_SERVICE + && signalBin > SIGNAL_STRENGTH_NONE_OR_UNKNOWN) { + state = ServiceState.STATE_IN_SERVICE; + } + } + + return state; + } + + private void updateAllPhoneStateLocked(int state, int simState, int bin) { boolean scanning = false; + boolean newHistory = false; + + mPhoneServiceStateRaw = state; + mPhoneSimStateRaw = simState; + mPhoneSignalStrengthBinRaw = bin; - int bin = mPhoneSignalStrengthBin; + if (simState == TelephonyManager.SIM_STATE_ABSENT) { + // In this case we will always be STATE_OUT_OF_SERVICE, so need + // to infer that we are scanning from other data. + if (state == ServiceState.STATE_OUT_OF_SERVICE + && bin > SIGNAL_STRENGTH_NONE_OR_UNKNOWN) { + state = ServiceState.STATE_IN_SERVICE; + } + } // If the phone is powered off, stop all timers. if (state == ServiceState.STATE_POWER_OFF) { - stopAllSignalStrengthTimersLocked(-1); + bin = -1; - // If we're back in service or continuing in service, restart the old timer. - } if (state == ServiceState.STATE_IN_SERVICE) { - if (bin == -1) bin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN; - if (!mPhoneSignalStrengthsTimer[bin].isRunningLocked()) { - mPhoneSignalStrengthsTimer[bin].startRunningLocked(this); - } + // If we are in service, make sure the correct signal string timer is running. + } else if (state == ServiceState.STATE_IN_SERVICE) { + // Bin will be changed below. // If we're out of service, we are in the lowest signal strength // bin and have the scanning bit set. } else if (state == ServiceState.STATE_OUT_OF_SERVICE) { scanning = true; - mPhoneSignalStrengthBin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN; - stopAllSignalStrengthTimersLocked(mPhoneSignalStrengthBin); - if (!mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].isRunningLocked()) { - mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].startRunningLocked(this); - } + bin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN; if (!mPhoneSignalScanningTimer.isRunningLocked()) { mHistoryCur.states |= HistoryItem.STATE_PHONE_SCANNING_FLAG; + newHistory = true; if (DEBUG_HISTORY) Slog.v(TAG, "Phone started scanning to: " + Integer.toHexString(mHistoryCur.states)); - addHistoryRecordLocked(SystemClock.elapsedRealtime()); mPhoneSignalScanningTimer.startRunningLocked(this); } } @@ -1694,7 +1711,7 @@ public final class BatteryStatsImpl extends BatteryStats { mHistoryCur.states &= ~HistoryItem.STATE_PHONE_SCANNING_FLAG; if (DEBUG_HISTORY) Slog.v(TAG, "Phone stopped scanning to: " + Integer.toHexString(mHistoryCur.states)); - addHistoryRecordLocked(SystemClock.elapsedRealtime()); + newHistory = true; mPhoneSignalScanningTimer.stopRunningLocked(this); } } @@ -1702,21 +1719,48 @@ public final class BatteryStatsImpl extends BatteryStats { if (mPhoneServiceState != state) { mHistoryCur.states = (mHistoryCur.states&~HistoryItem.STATE_PHONE_STATE_MASK) | (state << HistoryItem.STATE_PHONE_STATE_SHIFT); - if (DEBUG_HISTORY) Slog.v(TAG, "Phone state " + bin + " to: " + if (DEBUG_HISTORY) Slog.v(TAG, "Phone state " + state + " to: " + Integer.toHexString(mHistoryCur.states)); - addHistoryRecordLocked(SystemClock.elapsedRealtime()); + newHistory = true; mPhoneServiceState = state; } + + if (mPhoneSignalStrengthBin != bin) { + if (mPhoneSignalStrengthBin >= 0) { + mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].stopRunningLocked(this); + } + if (bin >= 0) { + if (!mPhoneSignalStrengthsTimer[bin].isRunningLocked()) { + mPhoneSignalStrengthsTimer[bin].startRunningLocked(this); + } + mHistoryCur.states = (mHistoryCur.states&~HistoryItem.STATE_SIGNAL_STRENGTH_MASK) + | (bin << HistoryItem.STATE_SIGNAL_STRENGTH_SHIFT); + if (DEBUG_HISTORY) Slog.v(TAG, "Signal strength " + bin + " to: " + + Integer.toHexString(mHistoryCur.states)); + newHistory = true; + } else { + stopAllSignalStrengthTimersLocked(-1); + } + mPhoneSignalStrengthBin = bin; + } + + if (newHistory) { + addHistoryRecordLocked(SystemClock.elapsedRealtime()); + } + } + + /** + * Telephony stack updates the phone state. + * @param state phone state from ServiceState.getState() + */ + public void notePhoneStateLocked(int state, int simState) { + updateAllPhoneStateLocked(state, simState, mPhoneSignalStrengthBinRaw); } public void notePhoneSignalStrengthLocked(SignalStrength signalStrength) { // Bin the strength. int bin; - if (mPhoneServiceState == ServiceState.STATE_POWER_OFF - || mPhoneServiceState == ServiceState.STATE_OUT_OF_SERVICE) { - // Ignore any signal strength changes when radio was turned off or out of service. - return; - } + if (!signalStrength.isGsm()) { int dBm = signalStrength.getCdmaDbm(); if (dBm >= -75) bin = SIGNAL_STRENGTH_GREAT; @@ -1732,18 +1776,8 @@ public final class BatteryStatsImpl extends BatteryStats { else if (asu >= 4) bin = SIGNAL_STRENGTH_MODERATE; else bin = SIGNAL_STRENGTH_POOR; } - if (mPhoneSignalStrengthBin != bin) { - mHistoryCur.states = (mHistoryCur.states&~HistoryItem.STATE_SIGNAL_STRENGTH_MASK) - | (bin << HistoryItem.STATE_SIGNAL_STRENGTH_SHIFT); - if (DEBUG_HISTORY) Slog.v(TAG, "Signal strength " + bin + " to: " - + Integer.toHexString(mHistoryCur.states)); - addHistoryRecordLocked(SystemClock.elapsedRealtime()); - if (mPhoneSignalStrengthBin >= 0) { - mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].stopRunningLocked(this); - } - mPhoneSignalStrengthBin = bin; - mPhoneSignalStrengthsTimer[bin].startRunningLocked(this); - } + + updateAllPhoneStateLocked(mPhoneServiceStateRaw, mPhoneSimStateRaw, bin); } public void notePhoneDataConnectionStateLocked(int dataType, boolean hasData) { @@ -3983,6 +4017,9 @@ public final class BatteryStatsImpl extends BatteryStats { } mKernelWakelockStats.clear(); } + + mLowDischargeAmountSinceCharge = 0; + mHighDischargeAmountSinceCharge = 0; clearHistoryLocked(); } @@ -4005,12 +4042,10 @@ public final class BatteryStatsImpl extends BatteryStats { // level to a now very high level). if (oldStatus == BatteryManager.BATTERY_STATUS_FULL || level >= 95 - || (mDischargeCurrentLevel < 30 && level >= 90)) { + || (mDischargeCurrentLevel < 20 && level >= 80)) { doWrite = true; resetAllStatsLocked(); mDischargeStartLevel = level; - mLowDischargeAmountSinceCharge = 0; - mHighDischargeAmountSinceCharge = 0; } updateKernelWakelocksLocked(); mHistoryCur.batteryLevel = (byte)level; @@ -4100,11 +4135,13 @@ public final class BatteryStatsImpl extends BatteryStats { mHistoryCur.batteryPlugType = (byte)plugType; changed = true; } - if (mHistoryCur.batteryTemperature != temp) { + if (temp >= (mHistoryCur.batteryTemperature+10) + || temp <= (mHistoryCur.batteryTemperature-10)) { mHistoryCur.batteryTemperature = (char)temp; changed = true; } - if (mHistoryCur.batteryVoltage != volt) { + if (volt > (mHistoryCur.batteryVoltage+20) + || volt < (mHistoryCur.batteryVoltage-20)) { mHistoryCur.batteryVoltage = (char)volt; changed = true; } @@ -4300,20 +4337,28 @@ public final class BatteryStatsImpl extends BatteryStats { } public int getDischargeCurrentLevelLocked() { - return mDischargeCurrentLevel; + return mDischargeCurrentLevel; } @Override public int getLowDischargeAmountSinceCharge() { synchronized(this) { - return mLowDischargeAmountSinceCharge; + int val = mLowDischargeAmountSinceCharge; + if (mOnBattery && mDischargeCurrentLevel < mDischargeUnplugLevel) { + val += mDischargeUnplugLevel-mDischargeCurrentLevel-1; + } + return val; } } @Override public int getHighDischargeAmountSinceCharge() { synchronized(this) { - return mHighDischargeAmountSinceCharge; + int val = mHighDischargeAmountSinceCharge; + if (mOnBattery && mDischargeCurrentLevel < mDischargeUnplugLevel) { + val += mDischargeUnplugLevel-mDischargeCurrentLevel; + } + return val; } } @@ -4815,9 +4860,9 @@ public final class BatteryStatsImpl extends BatteryStats { out.writeLong(computeRealtime(NOWREAL_SYS, STATS_SINCE_CHARGED)); out.writeInt(mDischargeUnplugLevel); out.writeInt(mDischargeCurrentLevel); - out.writeInt(mLowDischargeAmountSinceCharge); - out.writeInt(mHighDischargeAmountSinceCharge); - + out.writeInt(getLowDischargeAmountSinceCharge()); + out.writeInt(getHighDischargeAmountSinceCharge()); + mScreenOnTimer.writeSummaryFromParcelLocked(out, NOWREAL); for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) { mScreenBrightnessTimer[i].writeSummaryFromParcelLocked(out, NOWREAL); |
