diff options
Diffstat (limited to 'core/java/com/android/internal')
6 files changed, 109 insertions, 37 deletions
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 28cc13f..d0a169e 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -106,7 +106,7 @@ public class BatteryStatsImpl extends BatteryStats { private static final int MAGIC = 0xBA757475; // 'BATSTATS' // Current on-disk Parcel version - private static final int VERSION = 132 + (USE_OLD_HISTORY ? 1000 : 0); + private static final int VERSION = 133 + (USE_OLD_HISTORY ? 1000 : 0); // Maximum number of items we will record in the history. private static final int MAX_HISTORY_ITEMS = 2000; @@ -1969,8 +1969,14 @@ public class BatteryStatsImpl extends BatteryStats { private int buildBatteryLevelInt(HistoryItem h) { return ((((int)h.batteryLevel)<<25)&0xfe000000) - | ((((int)h.batteryTemperature)<<14)&0x01ff8000) - | ((((int)h.batteryVoltage)<<1)&0x00007fff); + | ((((int)h.batteryTemperature)<<15)&0x01ff8000) + | ((((int)h.batteryVoltage)<<1)&0x00007ffe); + } + + private void readBatteryLevelInt(int batteryLevelInt, HistoryItem out) { + out.batteryLevel = (byte)((batteryLevelInt & 0xfe000000) >>> 25); + out.batteryTemperature = (short)((batteryLevelInt & 0x01ff8000) >>> 15); + out.batteryVoltage = (char)((batteryLevelInt & 0x00007ffe) >>> 1); } private int buildStateInt(HistoryItem h) { @@ -2111,9 +2117,7 @@ public class BatteryStatsImpl extends BatteryStats { final int batteryLevelInt; if ((firstToken&DELTA_BATTERY_LEVEL_FLAG) != 0) { batteryLevelInt = src.readInt(); - cur.batteryLevel = (byte)((batteryLevelInt>>25)&0x7f); - cur.batteryTemperature = (short)((batteryLevelInt<<7)>>21); - cur.batteryVoltage = (char)(batteryLevelInt&0x3fff); + readBatteryLevelInt(batteryLevelInt, cur); cur.numReadInts += 1; if (DEBUG) Slog.i(TAG, "READ DELTA: batteryToken=0x" + Integer.toHexString(batteryLevelInt) @@ -7710,26 +7714,35 @@ public class BatteryStatsImpl extends BatteryStats { } final Uid u = getUidStatsLocked(mapUid(entry.uid)); - u.noteNetworkActivityLocked(NETWORK_WIFI_RX_DATA, entry.rxBytes, - entry.rxPackets); - u.noteNetworkActivityLocked(NETWORK_WIFI_TX_DATA, entry.txBytes, - entry.txPackets); - rxPackets.put(u.getUid(), entry.rxPackets); - txPackets.put(u.getUid(), entry.txPackets); - - // Sum the total number of packets so that the Rx Power and Tx Power can - // be evenly distributed amongst the apps. - totalRxPackets += entry.rxPackets; - totalTxPackets += entry.txPackets; - - mNetworkByteActivityCounters[NETWORK_WIFI_RX_DATA].addCountLocked( - entry.rxBytes); - mNetworkByteActivityCounters[NETWORK_WIFI_TX_DATA].addCountLocked( - entry.txBytes); - mNetworkPacketActivityCounters[NETWORK_WIFI_RX_DATA].addCountLocked( - entry.rxPackets); - mNetworkPacketActivityCounters[NETWORK_WIFI_TX_DATA].addCountLocked( - entry.txPackets); + if (entry.rxBytes != 0) { + u.noteNetworkActivityLocked(NETWORK_WIFI_RX_DATA, entry.rxBytes, + entry.rxPackets); + mNetworkByteActivityCounters[NETWORK_WIFI_RX_DATA].addCountLocked( + entry.rxBytes); + mNetworkPacketActivityCounters[NETWORK_WIFI_RX_DATA].addCountLocked( + entry.rxPackets); + + rxPackets.put(u.getUid(), entry.rxPackets); + + // Sum the total number of packets so that the Rx Power can + // be evenly distributed amongst the apps. + totalRxPackets += entry.rxPackets; + } + + if (entry.txBytes != 0) { + u.noteNetworkActivityLocked(NETWORK_WIFI_TX_DATA, entry.txBytes, + entry.txPackets); + mNetworkByteActivityCounters[NETWORK_WIFI_TX_DATA].addCountLocked( + entry.txBytes); + mNetworkPacketActivityCounters[NETWORK_WIFI_TX_DATA].addCountLocked( + entry.txPackets); + + txPackets.put(u.getUid(), entry.txPackets); + + // Sum the total number of packets so that the Tx Power can + // be evenly distributed amongst the apps. + totalTxPackets += entry.txPackets; + } } } diff --git a/core/java/com/android/internal/os/KernelCpuSpeedReader.java b/core/java/com/android/internal/os/KernelCpuSpeedReader.java index 5b776ac..3f6ebb9 100644 --- a/core/java/com/android/internal/os/KernelCpuSpeedReader.java +++ b/core/java/com/android/internal/os/KernelCpuSpeedReader.java @@ -16,8 +16,11 @@ package com.android.internal.os; import android.text.TextUtils; +import android.system.OsConstants; import android.util.Slog; +import libcore.io.Libcore; + import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; @@ -29,7 +32,7 @@ import java.util.Arrays; * * freq time * - * where time is measured in 1/100 seconds. + * where time is measured in jiffies. */ public class KernelCpuSpeedReader { private static final String TAG = "KernelCpuSpeedReader"; @@ -38,6 +41,9 @@ public class KernelCpuSpeedReader { private final long[] mLastSpeedTimes; private final long[] mDeltaSpeedTimes; + // How long a CPU jiffy is in milliseconds. + private final long mJiffyMillis; + /** * @param cpuNumber The cpu (cpu0, cpu1, etc) whose state to read. */ @@ -46,6 +52,8 @@ public class KernelCpuSpeedReader { cpuNumber); mLastSpeedTimes = new long[numSpeedSteps]; mDeltaSpeedTimes = new long[numSpeedSteps]; + long jiffyHz = Libcore.os.sysconf(OsConstants._SC_CLK_TCK); + mJiffyMillis = 1000/jiffyHz; } /** @@ -62,8 +70,7 @@ public class KernelCpuSpeedReader { splitter.setString(line); Long.parseLong(splitter.next()); - // The proc file reports time in 1/100 sec, so convert to milliseconds. - long time = Long.parseLong(splitter.next()) * 10; + long time = Long.parseLong(splitter.next()) * mJiffyMillis; if (time < mLastSpeedTimes[speedIndex]) { // The stats reset when the cpu hotplugged. That means that the time // we read is offset from 0, so the time is the delta. diff --git a/core/java/com/android/internal/os/ProcessCpuTracker.java b/core/java/com/android/internal/os/ProcessCpuTracker.java index bf97f1f..d831902 100644 --- a/core/java/com/android/internal/os/ProcessCpuTracker.java +++ b/core/java/com/android/internal/os/ProcessCpuTracker.java @@ -67,10 +67,10 @@ public class ProcessCpuTracker { static final int PROCESS_STAT_UTIME = 2; static final int PROCESS_STAT_STIME = 3; - /** Stores user time and system time in 100ths of a second. */ + /** Stores user time and system time in jiffies. */ private final long[] mProcessStatsData = new long[4]; - /** Stores user time and system time in 100ths of a second. Used for + /** Stores user time and system time in jiffies. Used for * public API to retrieve CPU use for a process. Must lock while in use. */ private final long[] mSinglePidStatsData = new long[4]; diff --git a/core/java/com/android/internal/util/StateMachine.java b/core/java/com/android/internal/util/StateMachine.java index 447292c..be78a12 100644 --- a/core/java/com/android/internal/util/StateMachine.java +++ b/core/java/com/android/internal/util/StateMachine.java @@ -1879,6 +1879,33 @@ public class StateMachine { } /** + * Check if there are any pending messages with code 'what' in deferred messages queue. + */ + protected final boolean hasDeferredMessages(int what) { + SmHandler smh = mSmHandler; + if (smh == null) return false; + + Iterator<Message> iterator = smh.mDeferredMessages.iterator(); + while (iterator.hasNext()) { + Message msg = iterator.next(); + if (msg.what == what) return true; + } + + return false; + } + + /** + * Check if there are any pending posts of messages with code 'what' in + * the message queue. This does NOT check messages in deferred message queue. + */ + protected final boolean hasMessages(int what) { + SmHandler smh = mSmHandler; + if (smh == null) return false; + + return smh.hasMessages(what); + } + + /** * Validate that the message was sent by * {@link StateMachine#quit} or {@link StateMachine#quitNow}. * */ diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index be827a4..d9c2a92 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -64,6 +64,11 @@ public class LockPatternUtils { private static final boolean DEBUG = false; /** + * The key to identify when the lock pattern enabled flag is being acccessed for legacy reasons. + */ + public static final String LEGACY_LOCK_PATTERN_ENABLED = "legacy_lock_pattern_enabled"; + + /** * The number of incorrect attempts before which we fall back on an alternative * method of verifying the user, and resetting their lock pattern. */ @@ -1011,6 +1016,19 @@ public class LockPatternUtils { return isLockPatternEnabled(getKeyguardStoredPasswordQuality(userId), userId); } + @Deprecated + public boolean isLegacyLockPatternEnabled(int userId) { + // Note: this value should default to {@code true} to avoid any reset that might result. + // We must use a special key to read this value, since it will by default return the value + // based on the new logic. + return getBoolean(LEGACY_LOCK_PATTERN_ENABLED, true, userId); + } + + @Deprecated + public void setLegacyLockPatternEnabled(int userId) { + setBoolean(Settings.Secure.LOCK_PATTERN_ENABLED, true, userId); + } + private boolean isLockPatternEnabled(int mode, int userId) { return mode == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING && savedPatternExists(userId); diff --git a/core/java/com/android/internal/widget/SwipeDismissLayout.java b/core/java/com/android/internal/widget/SwipeDismissLayout.java index 35ed63b..d88f479 100644 --- a/core/java/com/android/internal/widget/SwipeDismissLayout.java +++ b/core/java/com/android/internal/widget/SwipeDismissLayout.java @@ -89,14 +89,21 @@ public class SwipeDismissLayout extends FrameLayout { } }; private BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() { + private Runnable mRunnable = new Runnable() { + @Override + public void run() { + if (mDismissed) { + dismiss(); + } else { + cancel(); + } + resetMembers(); + } + }; + @Override public void onReceive(Context context, Intent intent) { - if (mDismissed) { - dismiss(); - } else { - cancel(); - } - resetMembers(); + post(mRunnable); } }; private IntentFilter mScreenOffFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF); |