summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/current.txt1
-rw-r--r--api/system-current.txt6
-rw-r--r--core/java/android/app/trust/ITrustListener.aidl2
-rw-r--r--core/java/android/app/trust/TrustManager.java22
-rw-r--r--core/java/android/nfc/IAppCallback.aidl4
-rw-r--r--core/java/android/nfc/NfcActivityManager.java15
-rw-r--r--core/java/android/nfc/NfcEvent.java9
-rw-r--r--core/java/android/os/BatteryStats.java200
-rw-r--r--core/java/android/service/gatekeeper/IGateKeeperService.aidl7
-rw-r--r--core/java/android/service/trust/ITrustAgentServiceCallback.aidl2
-rw-r--r--core/java/android/service/trust/TrustAgentService.java62
-rw-r--r--core/java/android/service/wallpaper/WallpaperService.java23
-rw-r--r--core/java/com/android/internal/app/IBatteryStats.aidl3
-rw-r--r--core/java/com/android/internal/os/BatteryStatsHelper.java17
-rw-r--r--core/java/com/android/internal/os/BatteryStatsImpl.java271
-rw-r--r--core/java/com/android/internal/os/WifiPowerCalculator.java2
-rw-r--r--core/java/com/android/internal/os/WifiPowerEstimator.java2
-rw-r--r--core/java/com/android/internal/widget/FloatingToolbar.java3
-rw-r--r--libs/hwui/OpenGLRenderer.cpp3
-rw-r--r--packages/DocumentsUI/res/layout/dialog_create_dir.xml3
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java26
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java9
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java4
-rw-r--r--packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java5
-rw-r--r--packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java14
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java5
-rw-r--r--services/core/java/com/android/server/LockSettingsService.java4
-rw-r--r--services/core/java/com/android/server/am/BatteryStatsService.java91
-rw-r--r--services/core/java/com/android/server/trust/TrustAgentWrapper.java20
-rw-r--r--services/core/java/com/android/server/trust/TrustArchive.java43
-rw-r--r--services/core/java/com/android/server/trust/TrustManagerService.java16
31 files changed, 435 insertions, 459 deletions
diff --git a/api/current.txt b/api/current.txt
index 12408b0..4375e6f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -19687,6 +19687,7 @@ package android.nfc {
public final class NfcEvent {
field public final android.nfc.NfcAdapter nfcAdapter;
+ field public final byte peerLlcpVersion;
}
public final class NfcManager {
diff --git a/api/system-current.txt b/api/system-current.txt
index 384837c..3639673 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -21575,6 +21575,7 @@ package android.nfc {
public final class NfcEvent {
field public final android.nfc.NfcAdapter nfcAdapter;
+ field public final byte peerLlcpVersion;
}
public final class NfcManager {
@@ -30942,7 +30943,8 @@ package android.service.trust {
public class TrustAgentService extends android.app.Service {
ctor public TrustAgentService();
- method public final void grantTrust(java.lang.CharSequence, long, boolean);
+ method public final deprecated void grantTrust(java.lang.CharSequence, long, boolean);
+ method public final void grantTrust(java.lang.CharSequence, long, int);
method public final android.os.IBinder onBind(android.content.Intent);
method public boolean onConfigure(java.util.List<android.os.PersistableBundle>);
method public void onDeviceLocked();
@@ -30951,6 +30953,8 @@ package android.service.trust {
method public void onUnlockAttempt(boolean);
method public final void revokeTrust();
method public final void setManagingTrust(boolean);
+ field public static final int FLAG_GRANT_TRUST_DISMISS_KEYGUARD = 2; // 0x2
+ field public static final int FLAG_GRANT_TRUST_INITIATED_BY_USER = 1; // 0x1
field public static final java.lang.String SERVICE_INTERFACE = "android.service.trust.TrustAgentService";
field public static final java.lang.String TRUST_AGENT_META_DATA = "android.service.trust.trustagent";
}
diff --git a/core/java/android/app/trust/ITrustListener.aidl b/core/java/android/app/trust/ITrustListener.aidl
index d80f58c..506dd12 100644
--- a/core/java/android/app/trust/ITrustListener.aidl
+++ b/core/java/android/app/trust/ITrustListener.aidl
@@ -22,6 +22,6 @@ package android.app.trust;
* {@hide}
*/
oneway interface ITrustListener {
- void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser);
+ void onTrustChanged(boolean enabled, int userId, int flags);
void onTrustManagedChanged(boolean managed, int userId);
} \ No newline at end of file
diff --git a/core/java/android/app/trust/TrustManager.java b/core/java/android/app/trust/TrustManager.java
index 705a144..b5c5317 100644
--- a/core/java/android/app/trust/TrustManager.java
+++ b/core/java/android/app/trust/TrustManager.java
@@ -34,7 +34,7 @@ public class TrustManager {
private static final int MSG_TRUST_MANAGED_CHANGED = 2;
private static final String TAG = "TrustManager";
- private static final String DATA_INITIATED_BY_USER = "initiatedByUser";
+ private static final String DATA_FLAGS = "initiatedByUser";
private final ITrustManager mService;
private final ArrayMap<TrustListener, ITrustListener> mTrustListeners;
@@ -109,11 +109,11 @@ public class TrustManager {
try {
ITrustListener.Stub iTrustListener = new ITrustListener.Stub() {
@Override
- public void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser) {
+ public void onTrustChanged(boolean enabled, int userId, int flags) {
Message m = mHandler.obtainMessage(MSG_TRUST_CHANGED, (enabled ? 1 : 0), userId,
trustListener);
- if (initiatedByUser) {
- m.getData().putBoolean(DATA_INITIATED_BY_USER, initiatedByUser);
+ if (flags != 0) {
+ m.getData().putInt(DATA_FLAGS, flags);
}
m.sendToTarget();
}
@@ -156,11 +156,8 @@ public class TrustManager {
public void handleMessage(Message msg) {
switch(msg.what) {
case MSG_TRUST_CHANGED:
- boolean initiatedByUser = msg.peekData() != null &&
- msg.peekData().getBoolean(DATA_INITIATED_BY_USER);
- ((TrustListener)msg.obj).onTrustChanged(
- msg.arg1 != 0, msg.arg2, initiatedByUser);
-
+ int flags = msg.peekData() != null ? msg.peekData().getInt(DATA_FLAGS) : 0;
+ ((TrustListener)msg.obj).onTrustChanged(msg.arg1 != 0, msg.arg2, flags);
break;
case MSG_TRUST_MANAGED_CHANGED:
((TrustListener)msg.obj).onTrustManagedChanged(msg.arg1 != 0, msg.arg2);
@@ -174,10 +171,11 @@ public class TrustManager {
* Reports that the trust state has changed.
* @param enabled if true, the system believes the environment to be trusted.
* @param userId the user, for which the trust changed.
- * @param initiatedByUser indicates that the user has explicitly initiated an action that
- * proves the user is about to use the device.
+ * @param flags flags specified by the trust agent when granting trust. See
+ * {@link android.service.trust.TrustAgentService#grantTrust(CharSequence, long, int)
+ * TrustAgentService.grantTrust(CharSequence, long, int)}.
*/
- void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser);
+ void onTrustChanged(boolean enabled, int userId, int flags);
/**
* Reports that whether trust is managed has changed
diff --git a/core/java/android/nfc/IAppCallback.aidl b/core/java/android/nfc/IAppCallback.aidl
index 9599308..c027d54 100644
--- a/core/java/android/nfc/IAppCallback.aidl
+++ b/core/java/android/nfc/IAppCallback.aidl
@@ -24,7 +24,7 @@ import android.nfc.Tag;
*/
interface IAppCallback
{
- BeamShareData createBeamShareData();
- void onNdefPushComplete();
+ BeamShareData createBeamShareData(byte peerLlcpVersion);
+ void onNdefPushComplete(byte peerLlcpVersion);
void onTagDiscovered(in Tag tag);
}
diff --git a/core/java/android/nfc/NfcActivityManager.java b/core/java/android/nfc/NfcActivityManager.java
index d009295..76bd0ec 100644
--- a/core/java/android/nfc/NfcActivityManager.java
+++ b/core/java/android/nfc/NfcActivityManager.java
@@ -46,7 +46,6 @@ public final class NfcActivityManager extends IAppCallback.Stub
static final Boolean DBG = false;
final NfcAdapter mAdapter;
- final NfcEvent mDefaultEvent; // cached NfcEvent (its currently always the same)
// All objects in the lists are protected by this
final List<NfcApplicationState> mApps; // Application(s) that have NFC state. Usually one
@@ -200,7 +199,6 @@ public final class NfcActivityManager extends IAppCallback.Stub
mAdapter = adapter;
mActivities = new LinkedList<NfcActivityState>();
mApps = new ArrayList<NfcApplicationState>(1); // Android VM usually has 1 app
- mDefaultEvent = new NfcEvent(mAdapter);
}
public void enableReaderMode(Activity activity, ReaderCallback callback, int flags,
@@ -354,13 +352,14 @@ public final class NfcActivityManager extends IAppCallback.Stub
/** Callback from NFC service, usually on binder thread */
@Override
- public BeamShareData createBeamShareData() {
+ public BeamShareData createBeamShareData(byte peerLlcpVersion) {
NfcAdapter.CreateNdefMessageCallback ndefCallback;
NfcAdapter.CreateBeamUrisCallback urisCallback;
NdefMessage message;
Activity activity;
Uri[] uris;
int flags;
+ NfcEvent event = new NfcEvent(mAdapter, peerLlcpVersion);
synchronized (NfcActivityManager.this) {
NfcActivityState state = findResumedActivityState();
if (state == null) return null;
@@ -375,10 +374,10 @@ public final class NfcActivityManager extends IAppCallback.Stub
// Make callbacks without lock
if (ndefCallback != null) {
- message = ndefCallback.createNdefMessage(mDefaultEvent);
+ message = ndefCallback.createNdefMessage(event);
}
if (urisCallback != null) {
- uris = urisCallback.createBeamUris(mDefaultEvent);
+ uris = urisCallback.createBeamUris(event);
if (uris != null) {
ArrayList<Uri> validUris = new ArrayList<Uri>();
for (Uri uri : uris) {
@@ -412,7 +411,7 @@ public final class NfcActivityManager extends IAppCallback.Stub
/** Callback from NFC service, usually on binder thread */
@Override
- public void onNdefPushComplete() {
+ public void onNdefPushComplete(byte peerLlcpVersion) {
NfcAdapter.OnNdefPushCompleteCallback callback;
synchronized (NfcActivityManager.this) {
NfcActivityState state = findResumedActivityState();
@@ -420,10 +419,10 @@ public final class NfcActivityManager extends IAppCallback.Stub
callback = state.onNdefPushCompleteCallback;
}
-
+ NfcEvent event = new NfcEvent(mAdapter, peerLlcpVersion);
// Make callback without lock
if (callback != null) {
- callback.onNdefPushComplete(mDefaultEvent);
+ callback.onNdefPushComplete(event);
}
}
diff --git a/core/java/android/nfc/NfcEvent.java b/core/java/android/nfc/NfcEvent.java
index 860700a..cf1d71a 100644
--- a/core/java/android/nfc/NfcEvent.java
+++ b/core/java/android/nfc/NfcEvent.java
@@ -38,7 +38,14 @@ public final class NfcEvent {
*/
public final NfcAdapter nfcAdapter;
- NfcEvent(NfcAdapter nfcAdapter) {
+ /**
+ * The LLCP version of the peer associated with the NFC event.
+ * The major version is in the top nibble, the minor version is in the bottom nibble.
+ */
+ public final byte peerLlcpVersion;
+
+ NfcEvent(NfcAdapter nfcAdapter, byte peerLlcpVersion) {
this.nfcAdapter = nfcAdapter;
+ this.peerLlcpVersion = peerLlcpVersion;
}
}
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 7c5ddee..4dfe0de 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -152,10 +152,15 @@ public abstract class BatteryStats implements Parcelable {
private static final String[] STAT_NAMES = { "l", "c", "u" };
/**
- * Bump the version on this if the checkin format changes.
+ * Current version of checkin data format.
+ */
+ static final String CHECKIN_VERSION = "14";
+
+ /**
+ * Old version, we hit 9 and ran out of room, need to remove.
*/
private static final int BATTERY_STATS_CHECKIN_VERSION = 9;
-
+
private static final long BYTES_PER_KB = 1024;
private static final long BYTES_PER_MB = 1048576; // 1024^2
private static final long BYTES_PER_GB = 1073741824; //1024^3
@@ -178,7 +183,9 @@ public abstract class BatteryStats implements Parcelable {
private static final String BATTERY_DATA = "bt";
private static final String BATTERY_DISCHARGE_DATA = "dc";
private static final String BATTERY_LEVEL_DATA = "lv";
+ private static final String GLOBAL_WIFI_DATA = "gwfl";
private static final String WIFI_DATA = "wfl";
+ private static final String GLOBAL_BLUETOOTH_DATA = "gble";
private static final String MISC_DATA = "m";
private static final String GLOBAL_NETWORK_DATA = "gn";
private static final String HISTORY_STRING_POOL = "hsp";
@@ -195,8 +202,6 @@ public abstract class BatteryStats implements Parcelable {
private static final String WIFI_SUPPL_STATE_COUNT_DATA = "wssc";
private static final String WIFI_SIGNAL_STRENGTH_TIME_DATA = "wsgt";
private static final String WIFI_SIGNAL_STRENGTH_COUNT_DATA = "wsgc";
- private static final String BLUETOOTH_STATE_TIME_DATA = "bst";
- private static final String BLUETOOTH_STATE_COUNT_DATA = "bsc";
private static final String POWER_USE_SUMMARY_DATA = "pws";
private static final String POWER_USE_ITEM_DATA = "pwi";
private static final String DISCHARGE_STEP_DATA = "dsd";
@@ -1055,22 +1060,23 @@ public abstract class BatteryStats implements Parcelable {
public static final int STATE_GPS_ON_FLAG = 1<<29;
public static final int STATE_WIFI_FULL_LOCK_FLAG = 1<<28;
public static final int STATE_WIFI_SCAN_FLAG = 1<<27;
- public static final int STATE_WIFI_MULTICAST_ON_FLAG = 1<<26;
+ public static final int STATE_WIFI_RADIO_ACTIVE_FLAG = 1<<26;
public static final int STATE_MOBILE_RADIO_ACTIVE_FLAG = 1<<25;
// These are on the lower bits used for the command; if they change
// we need to write another int of data.
public static final int STATE_SENSOR_ON_FLAG = 1<<23;
public static final int STATE_AUDIO_ON_FLAG = 1<<22;
public static final int STATE_PHONE_SCANNING_FLAG = 1<<21;
- public static final int STATE_SCREEN_ON_FLAG = 1<<20;
- public static final int STATE_BATTERY_PLUGGED_FLAG = 1<<19;
- public static final int STATE_PHONE_IN_CALL_FLAG = 1<<18;
- public static final int STATE_CHARGING_FLAG = 1<<17;
- public static final int STATE_BLUETOOTH_ON_FLAG = 1<<16;
+ public static final int STATE_SCREEN_ON_FLAG = 1<<20; // consider moving to states2
+ public static final int STATE_BATTERY_PLUGGED_FLAG = 1<<19; // consider moving to states2
+ // empty slot
+ // empty slot
+ public static final int STATE_WIFI_MULTICAST_ON_FLAG = 1<<16;
public static final int MOST_INTERESTING_STATES =
- STATE_BATTERY_PLUGGED_FLAG | STATE_SCREEN_ON_FLAG
- | STATE_PHONE_IN_CALL_FLAG | STATE_BLUETOOTH_ON_FLAG;
+ STATE_BATTERY_PLUGGED_FLAG | STATE_SCREEN_ON_FLAG;
+
+ public static final int SETTLE_TO_ZERO_STATES = 0xffff0000 & ~MOST_INTERESTING_STATES;
public int states;
@@ -1088,9 +1094,15 @@ public abstract class BatteryStats implements Parcelable {
public static final int STATE2_WIFI_ON_FLAG = 1<<28;
public static final int STATE2_FLASHLIGHT_FLAG = 1<<27;
public static final int STATE2_DEVICE_IDLE_FLAG = 1<<26;
+ public static final int STATE2_CHARGING_FLAG = 1<<25;
+ public static final int STATE2_PHONE_IN_CALL_FLAG = 1<<24;
+ public static final int STATE2_BLUETOOTH_ON_FLAG = 1<<23;
public static final int MOST_INTERESTING_STATES2 =
- STATE2_POWER_SAVE_FLAG | STATE2_WIFI_ON_FLAG | STATE2_DEVICE_IDLE_FLAG;
+ STATE2_POWER_SAVE_FLAG | STATE2_WIFI_ON_FLAG | STATE2_DEVICE_IDLE_FLAG
+ | STATE2_CHARGING_FLAG | STATE2_PHONE_IN_CALL_FLAG | STATE2_BLUETOOTH_ON_FLAG;
+
+ public static final int SETTLE_TO_ZERO_STATES2 = 0xffff0000 & ~MOST_INTERESTING_STATES2;
public int states2;
@@ -1137,8 +1149,10 @@ public abstract class BatteryStats implements Parcelable {
public static final int EVENT_PACKAGE_UNINSTALLED = 0x000d;
// Event for a package being uninstalled.
public static final int EVENT_ALARM = 0x000e;
+ // Record that we have decided we need to collect new stats data.
+ public static final int EVENT_COLLECT_EXTERNAL_STATS = 0x000f;
// Number of event types.
- public static final int EVENT_COUNT = 0x000f;
+ public static final int EVENT_COUNT = 0x0010;
// Mask to extract out only the type part of the event.
public static final int EVENT_TYPE_MASK = ~(EVENT_FLAG_START|EVENT_FLAG_FINISH);
@@ -1750,14 +1764,12 @@ public abstract class BatteryStats implements Parcelable {
new BitDescription(HistoryItem.STATE_WIFI_FULL_LOCK_FLAG, "wifi_full_lock", "Wl"),
new BitDescription(HistoryItem.STATE_WIFI_SCAN_FLAG, "wifi_scan", "Ws"),
new BitDescription(HistoryItem.STATE_WIFI_MULTICAST_ON_FLAG, "wifi_multicast", "Wm"),
+ new BitDescription(HistoryItem.STATE_WIFI_RADIO_ACTIVE_FLAG, "wifi_radio", "Wr"),
new BitDescription(HistoryItem.STATE_MOBILE_RADIO_ACTIVE_FLAG, "mobile_radio", "Pr"),
new BitDescription(HistoryItem.STATE_PHONE_SCANNING_FLAG, "phone_scanning", "Psc"),
new BitDescription(HistoryItem.STATE_AUDIO_ON_FLAG, "audio", "a"),
new BitDescription(HistoryItem.STATE_SCREEN_ON_FLAG, "screen", "S"),
new BitDescription(HistoryItem.STATE_BATTERY_PLUGGED_FLAG, "plugged", "BP"),
- new BitDescription(HistoryItem.STATE_PHONE_IN_CALL_FLAG, "phone_in_call", "Pcl"),
- new BitDescription(HistoryItem.STATE_CHARGING_FLAG, "charging", "ch"),
- new BitDescription(HistoryItem.STATE_BLUETOOTH_ON_FLAG, "bluetooth", "b"),
new BitDescription(HistoryItem.STATE_DATA_CONNECTION_MASK,
HistoryItem.STATE_DATA_CONNECTION_SHIFT, "data_conn", "Pcn",
DATA_CONNECTION_NAMES, DATA_CONNECTION_NAMES),
@@ -1778,10 +1790,13 @@ public abstract class BatteryStats implements Parcelable {
= new BitDescription[] {
new BitDescription(HistoryItem.STATE2_POWER_SAVE_FLAG, "power_save", "ps"),
new BitDescription(HistoryItem.STATE2_VIDEO_ON_FLAG, "video", "v"),
- new BitDescription(HistoryItem.STATE2_WIFI_RUNNING_FLAG, "wifi_running", "Wr"),
+ new BitDescription(HistoryItem.STATE2_WIFI_RUNNING_FLAG, "wifi_running", "Ww"),
new BitDescription(HistoryItem.STATE2_WIFI_ON_FLAG, "wifi", "W"),
new BitDescription(HistoryItem.STATE2_FLASHLIGHT_FLAG, "flashlight", "fl"),
new BitDescription(HistoryItem.STATE2_DEVICE_IDLE_FLAG, "device_idle", "di"),
+ new BitDescription(HistoryItem.STATE2_CHARGING_FLAG, "charging", "ch"),
+ new BitDescription(HistoryItem.STATE2_PHONE_IN_CALL_FLAG, "phone_in_call", "Pcl"),
+ new BitDescription(HistoryItem.STATE2_BLUETOOTH_ON_FLAG, "bluetooth", "b"),
new BitDescription(HistoryItem.STATE2_WIFI_SIGNAL_STRENGTH_MASK,
HistoryItem.STATE2_WIFI_SIGNAL_STRENGTH_SHIFT, "wifi_signal_strength", "Wss",
new String[] { "0", "1", "2", "3", "4" },
@@ -1793,12 +1808,12 @@ public abstract class BatteryStats implements Parcelable {
public static final String[] HISTORY_EVENT_NAMES = new String[] {
"null", "proc", "fg", "top", "sync", "wake_lock_in", "job", "user", "userfg", "conn",
- "motion", "active", "pkginst", "pkgunin", "alarm"
+ "motion", "active", "pkginst", "pkgunin", "alarm", "stats"
};
public static final String[] HISTORY_EVENT_CHECKIN_NAMES = new String[] {
"Enl", "Epr", "Efg", "Etp", "Esy", "Ewl", "Ejb", "Eur", "Euf", "Ecn",
- "Esm", "Eac", "Epi", "Epu", "Eal"
+ "Esm", "Eac", "Epi", "Epu", "Eal", "Est"
};
/**
@@ -1883,43 +1898,6 @@ public abstract class BatteryStats implements Parcelable {
public abstract int getWifiSignalStrengthCount(int strengthBin, int which);
/**
- * Returns the time in microseconds that bluetooth has been on while the device was
- * running on battery.
- *
- * {@hide}
- */
- public abstract long getBluetoothOnTime(long elapsedRealtimeUs, int which);
-
- public abstract int getBluetoothPingCount();
-
- public static final int BLUETOOTH_STATE_INACTIVE = 0;
- public static final int BLUETOOTH_STATE_LOW = 1;
- public static final int BLUETOOTH_STATE_MEDIUM = 2;
- public static final int BLUETOOTH_STATE_HIGH = 3;
-
- static final String[] BLUETOOTH_STATE_NAMES = {
- "inactive", "low", "med", "high"
- };
-
- public static final int NUM_BLUETOOTH_STATES = BLUETOOTH_STATE_HIGH +1;
-
- /**
- * Returns the time in microseconds that Bluetooth has been running in the
- * given active state.
- *
- * {@hide}
- */
- public abstract long getBluetoothStateTime(int bluetoothState,
- long elapsedRealtimeUs, int which);
-
- /**
- * Returns the number of times that Bluetooth has entered the given active state.
- *
- * {@hide}
- */
- public abstract int getBluetoothStateCount(int bluetoothState, int which);
-
- /**
* Returns the time in microseconds that the flashlight has been on while the device was
* running on battery.
*
@@ -2431,9 +2409,6 @@ public abstract class BatteryStats implements Parcelable {
final long deviceIdlingTime = getDeviceIdlingTime(rawRealtime, which);
final int connChanges = getNumConnectivityChange(which);
final long phoneOnTime = getPhoneOnTime(rawRealtime, which);
- final long wifiOnTime = getWifiOnTime(rawRealtime, which);
- final long wifiRunningTime = getGlobalWifiRunningTime(rawRealtime, which);
- final long bluetoothOnTime = getBluetoothOnTime(rawRealtime, which);
final StringBuilder sb = new StringBuilder(128);
@@ -2475,7 +2450,8 @@ public abstract class BatteryStats implements Parcelable {
}
}
}
-
+
+ // 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);
@@ -2484,19 +2460,34 @@ public abstract class BatteryStats implements Parcelable {
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);
-
- // Dump network stats
dumpLine(pw, 0 /* uid */, category, GLOBAL_NETWORK_DATA,
mobileRxTotalBytes, mobileTxTotalBytes, wifiRxTotalBytes, wifiTxTotalBytes,
mobileRxTotalPackets, mobileTxTotalPackets, wifiRxTotalPackets, wifiTxTotalPackets);
+ // Dump Wifi controller stats
+ final long wifiOnTime = getWifiOnTime(rawRealtime, which);
+ final long wifiRunningTime = getGlobalWifiRunningTime(rawRealtime, which);
+ final long wifiIdleTimeMs = getWifiControllerActivity(CONTROLLER_IDLE_TIME, which);
+ final long wifiRxTimeMs = getWifiControllerActivity(CONTROLLER_RX_TIME, which);
+ final long wifiTxTimeMs = getWifiControllerActivity(CONTROLLER_TX_TIME, which);
+ final long wifiPowerMaMs = getWifiControllerActivity(CONTROLLER_POWER_DRAIN, which);
+ dumpLine(pw, 0 /* uid */, category, GLOBAL_WIFI_DATA,
+ wifiOnTime / 1000, wifiRunningTime / 1000,
+ wifiIdleTimeMs, wifiRxTimeMs, wifiTxTimeMs, wifiPowerMaMs / (1000*60*60));
+
+ // Dump Bluetooth controller stats
+ final long btIdleTimeMs = getBluetoothControllerActivity(CONTROLLER_IDLE_TIME, which);
+ final long btRxTimeMs = getBluetoothControllerActivity(CONTROLLER_RX_TIME, which);
+ final long btTxTimeMs = getBluetoothControllerActivity(CONTROLLER_TX_TIME, which);
+ final long btPowerMaMs = getBluetoothControllerActivity(CONTROLLER_POWER_DRAIN, which);
+ dumpLine(pw, 0 /* uid */, category, GLOBAL_BLUETOOTH_DATA,
+ btIdleTimeMs, btRxTimeMs, btTxTimeMs, btPowerMaMs / (1000*60*60));
+
// Dump misc stats
dumpLine(pw, 0 /* uid */, category, MISC_DATA,
- screenOnTime / 1000, phoneOnTime / 1000, wifiOnTime / 1000,
- wifiRunningTime / 1000, bluetoothOnTime / 1000,
- mobileRxTotalBytes, mobileTxTotalBytes, wifiRxTotalBytes, wifiTxTotalBytes,
+ screenOnTime / 1000, phoneOnTime / 1000,
fullWakeLockTimeTotal / 1000, partialWakeLockTimeTotal / 1000,
- 0 /*legacy input event count*/, getMobileRadioActiveTime(rawRealtime, which) / 1000,
+ getMobileRadioActiveTime(rawRealtime, which) / 1000,
getMobileRadioActiveAdjustedTime(which) / 1000, interactiveTime / 1000,
powerSaveModeEnabledTime / 1000, connChanges, deviceIdleModeEnabledTime / 1000,
getDeviceIdleModeEnabledCount(which), deviceIdlingTime / 1000,
@@ -2566,17 +2557,6 @@ public abstract class BatteryStats implements Parcelable {
}
dumpLine(pw, 0 /* uid */, category, WIFI_SIGNAL_STRENGTH_COUNT_DATA, args);
- // Dump bluetooth state stats
- args = new Object[NUM_BLUETOOTH_STATES];
- for (int i=0; i<NUM_BLUETOOTH_STATES; i++) {
- args[i] = getBluetoothStateTime(i, rawRealtime, which) / 1000;
- }
- dumpLine(pw, 0 /* uid */, category, BLUETOOTH_STATE_TIME_DATA, args);
- for (int i=0; i<NUM_BLUETOOTH_STATES; i++) {
- args[i] = getBluetoothStateCount(i, which);
- }
- dumpLine(pw, 0 /* uid */, category, BLUETOOTH_STATE_COUNT_DATA, args);
-
if (which == STATS_SINCE_UNPLUGGED) {
dumpLine(pw, 0 /* uid */, category, BATTERY_LEVEL_DATA, getDischargeStartLevel(),
getDischargeCurrentLevel());
@@ -2681,6 +2661,7 @@ public abstract class BatteryStats implements Parcelable {
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);
@@ -2692,11 +2673,6 @@ public abstract class BatteryStats implements Parcelable {
final int mobileActiveCount = u.getMobileRadioActiveCount(which);
final long wifiPacketsRx = u.getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, which);
final long wifiPacketsTx = u.getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, which);
- 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 (mobileBytesRx > 0 || mobileBytesTx > 0 || wifiBytesRx > 0 || wifiBytesTx > 0
|| mobilePacketsRx > 0 || mobilePacketsTx > 0 || wifiPacketsRx > 0
|| wifiPacketsTx > 0 || mobileActiveTime > 0 || mobileActiveCount > 0) {
@@ -2707,10 +2683,19 @@ public abstract class BatteryStats implements Parcelable {
mobileActiveTime, mobileActiveCount);
}
+ 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);
+ final long uidWifiIdleTimeMs = u.getWifiControllerActivity(CONTROLLER_IDLE_TIME, which);
+ final long uidWifiRxTimeMs = u.getWifiControllerActivity(CONTROLLER_RX_TIME, which);
+ final long uidWifiTxTimeMs = u.getWifiControllerActivity(CONTROLLER_TX_TIME, which);
if (fullWifiLockOnTime != 0 || wifiScanTime != 0 || wifiScanCount != 0
- || uidWifiRunningTime != 0) {
+ || uidWifiRunningTime != 0 || uidWifiIdleTimeMs != 0 || uidWifiRxTimeMs != 0
+ || uidWifiTxTimeMs != 0) {
dumpLine(pw, uid, category, WIFI_DATA,
- fullWifiLockOnTime, wifiScanTime, uidWifiRunningTime, wifiScanCount);
+ fullWifiLockOnTime, wifiScanTime, uidWifiRunningTime, wifiScanCount,
+ uidWifiIdleTimeMs, uidWifiRxTimeMs, uidWifiTxTimeMs);
}
if (u.hasUserActivity()) {
@@ -2968,7 +2953,6 @@ public abstract class BatteryStats implements Parcelable {
final long phoneOnTime = getPhoneOnTime(rawRealtime, which);
final long wifiRunningTime = getGlobalWifiRunningTime(rawRealtime, which);
final long wifiOnTime = getWifiOnTime(rawRealtime, which);
- final long bluetoothOnTime = getBluetoothOnTime(rawRealtime, which);
sb.setLength(0);
sb.append(prefix);
sb.append(" Screen on: "); formatTimeMs(sb, screenOnTime / 1000);
@@ -3317,42 +3301,11 @@ public abstract class BatteryStats implements Parcelable {
sb.setLength(0);
sb.append(prefix);
- sb.append(" WiFi Energy use: ").append(BatteryStatsHelper.makemAh(
+ sb.append(" WiFi Power drain: ").append(BatteryStatsHelper.makemAh(
getWifiControllerActivity(CONTROLLER_POWER_DRAIN, which) / (double)(1000*60*60)));
sb.append(" mAh");
pw.println(sb.toString());
- sb.setLength(0);
- sb.append(prefix);
- sb.append(" Bluetooth on: "); formatTimeMs(sb, bluetoothOnTime / 1000);
- sb.append("("); sb.append(formatRatioLocked(bluetoothOnTime, whichBatteryRealtime));
- sb.append(")");
- pw.println(sb.toString());
-
- sb.setLength(0);
- sb.append(prefix);
- sb.append(" Bluetooth states:");
- didOne = false;
- for (int i=0; i<NUM_BLUETOOTH_STATES; i++) {
- final long time = getBluetoothStateTime(i, rawRealtime, which);
- if (time == 0) {
- continue;
- }
- sb.append("\n ");
- didOne = true;
- sb.append(BLUETOOTH_STATE_NAMES[i]);
- sb.append(" ");
- formatTimeMs(sb, time/1000);
- sb.append("(");
- sb.append(formatRatioLocked(time, whichBatteryRealtime));
- sb.append(") ");
- sb.append(getPhoneDataConnectionCount(i, which));
- sb.append("x");
- }
-
- if (!didOne) sb.append(" (no activity)");
- pw.println(sb.toString());
-
final long bluetoothIdleTimeMs =
getBluetoothControllerActivity(CONTROLLER_IDLE_TIME, which);
final long bluetoothRxTimeMs = getBluetoothControllerActivity(CONTROLLER_RX_TIME, which);
@@ -3384,6 +3337,14 @@ public abstract class BatteryStats implements Parcelable {
sb.append(")");
pw.println(sb.toString());
+ sb.setLength(0);
+ sb.append(prefix);
+ sb.append(" Bluetooth Power drain: ").append(BatteryStatsHelper.makemAh(
+ getBluetoothControllerActivity(CONTROLLER_POWER_DRAIN, which) /
+ (double)(1000*60*60)));
+ sb.append(" mAh");
+ pw.println(sb.toString());
+
pw.println();
if (which == STATS_SINCE_UNPLUGGED) {
@@ -4883,7 +4844,8 @@ public abstract class BatteryStats implements Parcelable {
prepareForDumpLocked();
dumpLine(pw, 0 /* uid */, "i" /* category */, VERSION_DATA,
- "13", getParcelVersion(), getStartPlatformVersion(), getEndPlatformVersion());
+ CHECKIN_VERSION, getParcelVersion(), getStartPlatformVersion(),
+ getEndPlatformVersion());
long now = getHistoryBaseTime() + SystemClock.elapsedRealtime();
diff --git a/core/java/android/service/gatekeeper/IGateKeeperService.aidl b/core/java/android/service/gatekeeper/IGateKeeperService.aidl
index 9edd04d..4f46701 100644
--- a/core/java/android/service/gatekeeper/IGateKeeperService.aidl
+++ b/core/java/android/service/gatekeeper/IGateKeeperService.aidl
@@ -69,4 +69,11 @@ interface IGateKeeperService {
* @param uid the Android user id
*/
long getSecureUserId(int uid);
+
+ /**
+ * Clears secure user id associated with the provided Android ID.
+ * Must be called when password is set to NONE.
+ * @param uid the Android user id.
+ */
+ void clearSecureUserId(int uid);
}
diff --git a/core/java/android/service/trust/ITrustAgentServiceCallback.aidl b/core/java/android/service/trust/ITrustAgentServiceCallback.aidl
index 76b2be0..ec66cc8 100644
--- a/core/java/android/service/trust/ITrustAgentServiceCallback.aidl
+++ b/core/java/android/service/trust/ITrustAgentServiceCallback.aidl
@@ -24,7 +24,7 @@ import android.os.UserHandle;
* @hide
*/
oneway interface ITrustAgentServiceCallback {
- void grantTrust(CharSequence message, long durationMs, boolean initiatedByUser);
+ void grantTrust(CharSequence message, long durationMs, int flags);
void revokeTrust();
void setManagingTrust(boolean managingTrust);
void onConfigureCompleted(boolean result, IBinder token);
diff --git a/core/java/android/service/trust/TrustAgentService.java b/core/java/android/service/trust/TrustAgentService.java
index a3178e2..9d7ffad 100644
--- a/core/java/android/service/trust/TrustAgentService.java
+++ b/core/java/android/service/trust/TrustAgentService.java
@@ -17,6 +17,7 @@
package android.service.trust;
import android.Manifest;
+import android.annotation.IntDef;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
import android.app.Service;
@@ -32,6 +33,8 @@ import android.os.RemoteException;
import android.util.Log;
import android.util.Slog;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.List;
/**
@@ -69,6 +72,7 @@ import java.util.List;
*/
@SystemApi
public class TrustAgentService extends Service {
+
private final String TAG = TrustAgentService.class.getSimpleName() +
"[" + getClass().getSimpleName() + "]";
private static final boolean DEBUG = false;
@@ -86,6 +90,34 @@ public class TrustAgentService extends Service {
*/
public static final String TRUST_AGENT_META_DATA = "android.service.trust.trustagent";
+
+ /**
+ * Flag for {@link #grantTrust(CharSequence, long, int)} indicating that trust is being granted
+ * as the direct result of user action - such as solving a security challenge. The hint is used
+ * by the system to optimize the experience. Behavior may vary by device and release, so
+ * one should only set this parameter if it meets the above criteria rather than relying on
+ * the behavior of any particular device or release.
+ */
+ public static final int FLAG_GRANT_TRUST_INITIATED_BY_USER = 1 << 0;
+
+ /**
+ * Flag for {@link #grantTrust(CharSequence, long, int)} indicating that the agent would like
+ * to dismiss the keyguard. When using this flag, the {@code TrustAgentService} must ensure
+ * it is only set in response to a direct user action with the expectation of dismissing the
+ * keyguard.
+ */
+ public static final int FLAG_GRANT_TRUST_DISMISS_KEYGUARD = 1 << 1;
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(flag = true,
+ value = {
+ FLAG_GRANT_TRUST_INITIATED_BY_USER,
+ FLAG_GRANT_TRUST_DISMISS_KEYGUARD,
+ })
+ public @interface GrantTrustFlags {}
+
+
private static final int MSG_UNLOCK_ATTEMPT = 1;
private static final int MSG_CONFIGURE = 2;
private static final int MSG_TRUST_TIMEOUT = 3;
@@ -228,11 +260,35 @@ public class TrustAgentService extends Service {
* direct result of user action - such as solving a security challenge. The hint is used
* by the system to optimize the experience. Behavior may vary by device and release, so
* one should only set this parameter if it meets the above criteria rather than relying on
- * the behavior of any particular device or release.
+ * the behavior of any particular device or release. Corresponds to
+ * {@link #FLAG_GRANT_TRUST_INITIATED_BY_USER}.
* @throws IllegalStateException if the agent is not currently managing trust.
+ *
+ * @deprecated use {@link #grantTrust(CharSequence, long, int)} instead.
*/
+ @Deprecated
public final void grantTrust(
final CharSequence message, final long durationMs, final boolean initiatedByUser) {
+ grantTrust(message, durationMs, initiatedByUser ? FLAG_GRANT_TRUST_INITIATED_BY_USER : 0);
+ }
+
+ /**
+ * Call to grant trust on the device.
+ *
+ * @param message describes why the device is trusted, e.g. "Trusted by location".
+ * @param durationMs amount of time in milliseconds to keep the device in a trusted state.
+ * Trust for this agent will automatically be revoked when the timeout expires unless
+ * extended by a subsequent call to this function. The timeout is measured from the
+ * invocation of this function as dictated by {@link SystemClock#elapsedRealtime())}.
+ * For security reasons, the value should be no larger than necessary.
+ * The value may be adjusted by the system as necessary to comply with a policy controlled
+ * by the system or {@link DevicePolicyManager} restrictions. See {@link #onTrustTimeout()}
+ * for determining when trust expires.
+ * @param flags TBDocumented
+ * @throws IllegalStateException if the agent is not currently managing trust.
+ */
+ public final void grantTrust(
+ final CharSequence message, final long durationMs, @GrantTrustFlags final int flags) {
synchronized (mLock) {
if (!mManagingTrust) {
throw new IllegalStateException("Cannot grant trust if agent is not managing trust."
@@ -240,7 +296,7 @@ public class TrustAgentService extends Service {
}
if (mCallback != null) {
try {
- mCallback.grantTrust(message.toString(), durationMs, initiatedByUser);
+ mCallback.grantTrust(message.toString(), durationMs, flags);
} catch (RemoteException e) {
onError("calling enableTrust()");
}
@@ -250,7 +306,7 @@ public class TrustAgentService extends Service {
mPendingGrantTrustTask = new Runnable() {
@Override
public void run() {
- grantTrust(message, durationMs, initiatedByUser);
+ grantTrust(message, durationMs, flags);
}
};
}
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index 1674950..016541f 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -17,6 +17,7 @@
package android.service.wallpaper;
import android.content.res.TypedArray;
+import android.graphics.Canvas;
import android.os.SystemProperties;
import android.view.WindowInsets;
@@ -185,6 +186,7 @@ public abstract class WallpaperService extends Service {
DisplayManager mDisplayManager;
Display mDisplay;
+ private int mDisplayState;
final BaseSurfaceHolder mSurfaceHolder = new BaseSurfaceHolder() {
{
@@ -228,7 +230,19 @@ public abstract class WallpaperService extends Service {
throw new UnsupportedOperationException(
"Wallpapers do not support keep screen on");
}
-
+
+ @Override
+ public Canvas lockCanvas() {
+ if (mDisplayState == Display.STATE_DOZE
+ || mDisplayState == Display.STATE_DOZE_SUSPEND) {
+ try {
+ mSession.pokeDrawLock(mWindow);
+ } catch (RemoteException e) {
+ // System server died, can be ignored.
+ }
+ }
+ return super.lockCanvas();
+ }
};
final class WallpaperInputEventReceiver extends InputEventReceiver {
@@ -831,9 +845,12 @@ public abstract class WallpaperService extends Service {
mWindow.setSession(mSession);
+ mLayout.packageName = getPackageName();
+
mDisplayManager = (DisplayManager)getSystemService(Context.DISPLAY_SERVICE);
mDisplayManager.registerDisplayListener(mDisplayListener, mCaller.getHandler());
mDisplay = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY);
+ mDisplayState = mDisplay.getState();
if (DEBUG) Log.v(TAG, "onCreate(): " + this);
onCreate(mSurfaceHolder);
@@ -873,8 +890,8 @@ public abstract class WallpaperService extends Service {
void reportVisibility() {
if (!mDestroyed) {
- boolean visible = mVisible
- & mDisplay != null && mDisplay.getState() != Display.STATE_OFF;
+ mDisplayState = mDisplay == null ? Display.STATE_UNKNOWN : mDisplay.getState();
+ boolean visible = mVisible && mDisplayState != Display.STATE_OFF;
if (mReportedVisible != visible) {
mReportedVisible = visible;
if (DEBUG) Log.v(TAG, "onVisibilityChanged(" + visible
diff --git a/core/java/com/android/internal/app/IBatteryStats.aidl b/core/java/com/android/internal/app/IBatteryStats.aidl
index 4f0e29e..7c5c565 100644
--- a/core/java/com/android/internal/app/IBatteryStats.aidl
+++ b/core/java/com/android/internal/app/IBatteryStats.aidl
@@ -95,9 +95,6 @@ interface IBatteryStats {
void noteWifiState(int wifiState, String accessPoint);
void noteWifiSupplicantStateChanged(int supplState, boolean failedAuth);
void noteWifiRssiChanged(int newRssi);
- void noteBluetoothOn();
- void noteBluetoothOff();
- void noteBluetoothState(int bluetoothState);
void noteFullWifiLockAcquired(int uid);
void noteFullWifiLockReleased(int uid);
void noteWifiScanStarted(int uid);
diff --git a/core/java/com/android/internal/os/BatteryStatsHelper.java b/core/java/com/android/internal/os/BatteryStatsHelper.java
index 59dbec6..a53d46c 100644
--- a/core/java/com/android/internal/os/BatteryStatsHelper.java
+++ b/core/java/com/android/internal/os/BatteryStatsHelper.java
@@ -136,6 +136,14 @@ public final class BatteryStatsHelper {
profile.getAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_TX) != 0;
}
+ public static boolean checkHasBluetoothPowerReporting(BatteryStats stats,
+ PowerProfile profile) {
+ return stats.hasBluetoothActivityReporting() &&
+ profile.getAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_IDLE) != 0 &&
+ profile.getAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_RX) != 0 &&
+ profile.getAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_TX) != 0;
+ }
+
public BatteryStatsHelper(Context context) {
this(context, true);
}
@@ -256,7 +264,8 @@ public final class BatteryStatsHelper {
}
public static String makemAh(double power) {
- if (power < .00001) return String.format("%.8f", power);
+ if (power == 0) return "0";
+ else if (power < .00001) return String.format("%.8f", power);
else if (power < .0001) return String.format("%.7f", power);
else if (power < .001) return String.format("%.6f", power);
else if (power < .01) return String.format("%.5f", power);
@@ -342,7 +351,11 @@ public final class BatteryStatsHelper {
mWifiPowerCalculator.reset();
if (mBluetoothPowerCalculator == null) {
- mBluetoothPowerCalculator = new BluetoothPowerCalculator();
+ if (checkHasBluetoothPowerReporting(mStats, mPowerProfile)) {
+ mBluetoothPowerCalculator = new BluetoothPowerCalculator();
+ } else {
+ mBluetoothPowerCalculator = new BluetoothPowerCalculator();
+ }
}
mBluetoothPowerCalculator.reset();
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 87605f6..405c861 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -19,8 +19,6 @@ package com.android.internal.os;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.bluetooth.BluetoothActivityEnergyInfo;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothHeadset;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
@@ -84,7 +82,6 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
@@ -107,7 +104,7 @@ public final class BatteryStatsImpl extends BatteryStats {
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
// Current on-disk Parcel version
- private static final int VERSION = 123 + (USE_OLD_HISTORY ? 1000 : 0);
+ private static final int VERSION = 125 + (USE_OLD_HISTORY ? 1000 : 0);
// Maximum number of items we will record in the history.
private static final int MAX_HISTORY_ITEMS = 2000;
@@ -176,7 +173,7 @@ public final class BatteryStatsImpl extends BatteryStats {
}
public interface ExternalStatsSync {
- void scheduleSync();
+ void scheduleSync(String reason);
}
public final MyHandler mHandler;
@@ -250,6 +247,8 @@ public final class BatteryStatsImpl extends BatteryStats {
int mNumHistoryTagChars = 0;
int mHistoryBufferLastPos = -1;
boolean mHistoryOverflow = false;
+ int mActiveHistoryStates = 0xffffffff;
+ int mActiveHistoryStates2 = 0xffffffff;
long mLastHistoryElapsedRealtime = 0;
long mTrackRunningHistoryElapsedRealtime = 0;
long mTrackRunningHistoryUptime = 0;
@@ -313,7 +312,7 @@ public final class BatteryStatsImpl extends BatteryStats {
int mWakeLockNesting;
boolean mWakeLockImportant;
- boolean mRecordAllHistory;
+ public boolean mRecordAllHistory;
boolean mNoAutoReset;
int mScreenState = Display.STATE_UNKNOWN;
@@ -384,12 +383,6 @@ public final class BatteryStatsImpl extends BatteryStats {
final StopwatchTimer[] mWifiSignalStrengthsTimer =
new StopwatchTimer[NUM_WIFI_SIGNAL_STRENGTH_BINS];
- boolean mBluetoothOn;
- StopwatchTimer mBluetoothOnTimer;
-
- int mBluetoothState = -1;
- final StopwatchTimer[] mBluetoothStateTimer = new StopwatchTimer[NUM_BLUETOOTH_STATES];
-
int mMobileRadioPowerState = DataConnectionRealTimeInfo.DC_POWER_STATE_LOW;
long mMobileRadioActiveStartTime;
StopwatchTimer mMobileRadioActiveTimer;
@@ -398,8 +391,7 @@ public final class BatteryStatsImpl extends BatteryStats {
LongSamplingCounter mMobileRadioActiveUnknownTime;
LongSamplingCounter mMobileRadioActiveUnknownCount;
- /** Bluetooth headset object */
- BluetoothHeadset mBtHeadset;
+ int mWifiRadioPowerState = DataConnectionRealTimeInfo.DC_POWER_STATE_LOW;
/**
* These provide time bases that discount the time the device is plugged
@@ -458,9 +450,6 @@ public final class BatteryStatsImpl extends BatteryStats {
long mLastWriteTime = 0; // Milliseconds
- private int mBluetoothPingCount;
- private int mBluetoothPingStart = -1;
-
private int mPhoneServiceState = -1;
private int mPhoneServiceStateRaw = -1;
private int mPhoneSimStateRaw = -1;
@@ -1803,32 +1792,6 @@ public final class BatteryStatsImpl extends BatteryStats {
return kwlt;
}
- private int getCurrentBluetoothPingCount() {
- if (mBtHeadset != null) {
- List<BluetoothDevice> deviceList = mBtHeadset.getConnectedDevices();
- if (deviceList.size() > 0) {
- return mBtHeadset.getBatteryUsageHint(deviceList.get(0));
- }
- }
- return -1;
- }
-
- public int getBluetoothPingCount() {
- if (mBluetoothPingStart == -1) {
- return mBluetoothPingCount;
- } else if (mBtHeadset != null) {
- return getCurrentBluetoothPingCount() - mBluetoothPingStart;
- }
- return 0;
- }
-
- public void setBtHeadset(BluetoothHeadset headset) {
- if (headset != null && mBtHeadset == null && isOnBattery() && mBluetoothPingStart == -1) {
- mBluetoothPingStart = getCurrentBluetoothPingCount();
- }
- mBtHeadset = headset;
- }
-
private int writeHistoryTag(HistoryTag tag) {
Integer idxObj = mHistoryTagPool.get(tag);
int idx;
@@ -2259,8 +2222,8 @@ public final class BatteryStatsImpl extends BatteryStats {
}
final long timeDiff = (mHistoryBaseTime+elapsedRealtimeMs) - mHistoryLastWritten.time;
- final int diffStates = mHistoryLastWritten.states^cur.states;
- final int diffStates2 = mHistoryLastWritten.states2^cur.states2;
+ final int diffStates = mHistoryLastWritten.states^(cur.states&mActiveHistoryStates);
+ final int diffStates2 = mHistoryLastWritten.states2^(cur.states2&mActiveHistoryStates2);
final int lastDiffStates = mHistoryLastWritten.states^mHistoryLastLastWritten.states;
final int lastDiffStates2 = mHistoryLastWritten.states2^mHistoryLastLastWritten.states2;
if (DEBUG) Slog.i(TAG, "ADD: tdelta=" + timeDiff + " diff="
@@ -2325,11 +2288,32 @@ public final class BatteryStatsImpl extends BatteryStats {
return;
}
+ // After overflow, we allow various bit-wise states to settle to 0.
+ boolean writeAnyway = false;
+ final int curStates = cur.states & HistoryItem.SETTLE_TO_ZERO_STATES
+ & mActiveHistoryStates;
+ if (mHistoryLastWritten.states != curStates) {
+ // mActiveHistoryStates keeps track of which bits in .states are now being
+ // forced to 0.
+ int old = mActiveHistoryStates;
+ mActiveHistoryStates &= curStates | ~HistoryItem.SETTLE_TO_ZERO_STATES;
+ writeAnyway |= old != mActiveHistoryStates;
+ }
+ final int curStates2 = cur.states2 & HistoryItem.SETTLE_TO_ZERO_STATES2
+ & mActiveHistoryStates2;
+ if (mHistoryLastWritten.states2 != curStates2) {
+ // mActiveHistoryStates2 keeps track of which bits in .states2 are now being
+ // forced to 0.
+ int old = mActiveHistoryStates2;
+ mActiveHistoryStates2 &= curStates2 | ~HistoryItem.SETTLE_TO_ZERO_STATES2;
+ writeAnyway |= old != mActiveHistoryStates2;
+ }
+
// Once we've reached the maximum number of items, we only
// record changes to the battery level and the most interesting states.
// Once we've reached the maximum maximum number of items, we only
// record changes to the battery level.
- if (mHistoryLastWritten.batteryLevel == cur.batteryLevel &&
+ if (!writeAnyway && mHistoryLastWritten.batteryLevel == cur.batteryLevel &&
(dataSize >= MAX_MAX_HISTORY_BUFFER
|| ((mHistoryLastWritten.states^cur.states)
& HistoryItem.MOST_INTERESTING_STATES) == 0
@@ -2360,6 +2344,8 @@ public final class BatteryStatsImpl extends BatteryStats {
mHistoryBufferLastPos = mHistoryBuffer.dataPosition();
mHistoryLastLastWritten.setTo(mHistoryLastWritten);
mHistoryLastWritten.setTo(mHistoryBaseTime + elapsedRealtimeMs, cmd, cur);
+ mHistoryLastWritten.states &= mActiveHistoryStates;
+ mHistoryLastWritten.states2 &= mActiveHistoryStates2;
writeHistoryDelta(mHistoryBuffer, mHistoryLastWritten, mHistoryLastLastWritten);
mLastHistoryElapsedRealtime = elapsedRealtimeMs;
cur.wakelockTag = null;
@@ -2411,8 +2397,8 @@ public final class BatteryStatsImpl extends BatteryStats {
// into one record.
if (mHistoryEnd != null && mHistoryEnd.cmd == HistoryItem.CMD_UPDATE
&& (mHistoryBaseTime+elapsedRealtimeMs) < (mHistoryEnd.time+1000)
- && ((mHistoryEnd.states^cur.states)&mChangedStates) == 0
- && ((mHistoryEnd.states2^cur.states2)&mChangedStates2) == 0) {
+ && ((mHistoryEnd.states^cur.states)&mChangedStates&mActiveHistoryStates) == 0
+ && ((mHistoryEnd.states2^cur.states2)&mChangedStates2&mActiveHistoryStates2) == 0) {
// If the current is the same as the one before, then we no
// longer need the entry.
if (mHistoryLastEnd != null && mHistoryLastEnd.cmd == HistoryItem.CMD_UPDATE
@@ -2424,8 +2410,8 @@ public final class BatteryStatsImpl extends BatteryStats {
mHistoryEnd = mHistoryLastEnd;
mHistoryLastEnd = null;
} else {
- mChangedStates |= mHistoryEnd.states^cur.states;
- mChangedStates2 |= mHistoryEnd.states^cur.states2;
+ mChangedStates |= mHistoryEnd.states^(cur.states&mActiveHistoryStates);
+ mChangedStates2 |= mHistoryEnd.states^(cur.states2&mActiveHistoryStates2);
mHistoryEnd.setTo(mHistoryEnd.time, HistoryItem.CMD_UPDATE, cur);
}
return;
@@ -2447,7 +2433,7 @@ public final class BatteryStatsImpl extends BatteryStats {
if (mHistoryEnd != null && mHistoryEnd.batteryLevel
== cur.batteryLevel &&
(mNumHistoryItems >= MAX_MAX_HISTORY_ITEMS
- || ((mHistoryEnd.states^cur.states)
+ || ((mHistoryEnd.states^(cur.states&mActiveHistoryStates))
& HistoryItem.MOST_INTERESTING_STATES) == 0)) {
return;
}
@@ -2456,7 +2442,7 @@ public final class BatteryStatsImpl extends BatteryStats {
addHistoryRecordLocked(elapsedRealtimeMs, HistoryItem.CMD_UPDATE);
}
- void addHistoryEventLocked(long elapsedRealtimeMs, long uptimeMs, int code,
+ public void addHistoryEventLocked(long elapsedRealtimeMs, long uptimeMs, int code,
String name, int uid) {
mHistoryCur.eventCode = code;
mHistoryCur.eventTag = mHistoryCur.localEventTag;
@@ -2515,23 +2501,15 @@ public final class BatteryStatsImpl extends BatteryStats {
mNumHistoryTagChars = 0;
mHistoryBufferLastPos = -1;
mHistoryOverflow = false;
+ mActiveHistoryStates = 0xffffffff;
+ mActiveHistoryStates2 = 0xffffffff;
mLastRecordedClockTime = 0;
mLastRecordedClockRealtime = 0;
}
public void updateTimeBasesLocked(boolean unplugged, boolean screenOff, long uptime,
long realtime) {
- if (mOnBatteryTimeBase.setRunning(unplugged, uptime, realtime)) {
- if (unplugged) {
- // Track bt headset ping count
- mBluetoothPingStart = getCurrentBluetoothPingCount();
- mBluetoothPingCount = 0;
- } else {
- // Track bt headset ping count
- mBluetoothPingCount = getBluetoothPingCount();
- mBluetoothPingStart = -1;
- }
- }
+ mOnBatteryTimeBase.setRunning(unplugged, uptime, realtime);
boolean unpluggedScreenOff = unplugged && screenOff;
if (unpluggedScreenOff != mOnBatteryScreenOffTimeBase.isRunning()) {
@@ -3396,7 +3374,7 @@ public final class BatteryStatsImpl extends BatteryStats {
if (!mPhoneOn) {
final long elapsedRealtime = SystemClock.elapsedRealtime();
final long uptime = SystemClock.uptimeMillis();
- mHistoryCur.states |= HistoryItem.STATE_PHONE_IN_CALL_FLAG;
+ mHistoryCur.states2 |= HistoryItem.STATE2_PHONE_IN_CALL_FLAG;
if (DEBUG_HISTORY) Slog.v(TAG, "Phone on to: "
+ Integer.toHexString(mHistoryCur.states));
addHistoryRecordLocked(elapsedRealtime, uptime);
@@ -3409,7 +3387,7 @@ public final class BatteryStatsImpl extends BatteryStats {
if (mPhoneOn) {
final long elapsedRealtime = SystemClock.elapsedRealtime();
final long uptime = SystemClock.uptimeMillis();
- mHistoryCur.states &= ~HistoryItem.STATE_PHONE_IN_CALL_FLAG;
+ mHistoryCur.states2 &= ~HistoryItem.STATE2_PHONE_IN_CALL_FLAG;
if (DEBUG_HISTORY) Slog.v(TAG, "Phone off to: "
+ Integer.toHexString(mHistoryCur.states));
addHistoryRecordLocked(elapsedRealtime, uptime);
@@ -3626,7 +3604,7 @@ public final class BatteryStatsImpl extends BatteryStats {
addHistoryRecordLocked(elapsedRealtime, uptime);
mWifiOn = true;
mWifiOnTimer.startRunningLocked(elapsedRealtime);
- scheduleSyncExternalStatsLocked();
+ scheduleSyncExternalStatsLocked("wifi-off");
}
}
@@ -3640,7 +3618,7 @@ public final class BatteryStatsImpl extends BatteryStats {
addHistoryRecordLocked(elapsedRealtime, uptime);
mWifiOn = false;
mWifiOnTimer.stopRunningLocked(elapsedRealtime);
- scheduleSyncExternalStatsLocked();
+ scheduleSyncExternalStatsLocked("wifi-on");
}
}
@@ -3788,6 +3766,25 @@ public final class BatteryStatsImpl extends BatteryStats {
}
}
+ public void noteWifiRadioPowerState(int powerState, long timestampNs) {
+ final long elapsedRealtime = SystemClock.elapsedRealtime();
+ final long uptime = SystemClock.uptimeMillis();
+ if (mWifiRadioPowerState != powerState) {
+ final boolean active =
+ powerState == DataConnectionRealTimeInfo.DC_POWER_STATE_MEDIUM
+ || powerState == DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH;
+ if (active) {
+ mHistoryCur.states |= HistoryItem.STATE_WIFI_RADIO_ACTIVE_FLAG;
+ } else {
+ mHistoryCur.states &= ~HistoryItem.STATE_WIFI_RADIO_ACTIVE_FLAG;
+ }
+ if (DEBUG_HISTORY) Slog.v(TAG, "Wifi network active " + active + " to: "
+ + Integer.toHexString(mHistoryCur.states));
+ addHistoryRecordLocked(elapsedRealtime, uptime);
+ mWifiRadioPowerState = powerState;
+ }
+ }
+
public void noteWifiRunningLocked(WorkSource ws) {
if (!mGlobalWifiRunning) {
final long elapsedRealtime = SystemClock.elapsedRealtime();
@@ -3803,7 +3800,7 @@ public final class BatteryStatsImpl extends BatteryStats {
int uid = mapUid(ws.get(i));
getUidStatsLocked(uid).noteWifiRunningLocked(elapsedRealtime);
}
- scheduleSyncExternalStatsLocked();
+ scheduleSyncExternalStatsLocked("wifi-running");
} else {
Log.w(TAG, "noteWifiRunningLocked -- called while WIFI running");
}
@@ -3842,7 +3839,7 @@ public final class BatteryStatsImpl extends BatteryStats {
int uid = mapUid(ws.get(i));
getUidStatsLocked(uid).noteWifiStoppedLocked(elapsedRealtime);
}
- scheduleSyncExternalStatsLocked();
+ scheduleSyncExternalStatsLocked("wifi-stopped");
} else {
Log.w(TAG, "noteWifiStoppedLocked -- called while WIFI not running");
}
@@ -3857,7 +3854,7 @@ public final class BatteryStatsImpl extends BatteryStats {
}
mWifiState = wifiState;
mWifiStateTimer[wifiState].startRunningLocked(elapsedRealtime);
- scheduleSyncExternalStatsLocked();
+ scheduleSyncExternalStatsLocked("wifi-state");
}
}
@@ -3919,46 +3916,6 @@ public final class BatteryStatsImpl extends BatteryStats {
}
}
- public void noteBluetoothOnLocked() {
- if (!mBluetoothOn) {
- final long elapsedRealtime = SystemClock.elapsedRealtime();
- final long uptime = SystemClock.uptimeMillis();
- mHistoryCur.states |= HistoryItem.STATE_BLUETOOTH_ON_FLAG;
- if (DEBUG_HISTORY) Slog.v(TAG, "Bluetooth on to: "
- + Integer.toHexString(mHistoryCur.states));
- addHistoryRecordLocked(elapsedRealtime, uptime);
- mBluetoothOn = true;
- mBluetoothOnTimer.startRunningLocked(elapsedRealtime);
- scheduleSyncExternalStatsLocked();
- }
- }
-
- public void noteBluetoothOffLocked() {
- if (mBluetoothOn) {
- final long elapsedRealtime = SystemClock.elapsedRealtime();
- final long uptime = SystemClock.uptimeMillis();
- mHistoryCur.states &= ~HistoryItem.STATE_BLUETOOTH_ON_FLAG;
- if (DEBUG_HISTORY) Slog.v(TAG, "Bluetooth off to: "
- + Integer.toHexString(mHistoryCur.states));
- addHistoryRecordLocked(elapsedRealtime, uptime);
- mBluetoothOn = false;
- mBluetoothOnTimer.stopRunningLocked(elapsedRealtime);
- scheduleSyncExternalStatsLocked();
- }
- }
-
- public void noteBluetoothStateLocked(int bluetoothState) {
- if (DEBUG) Log.i(TAG, "Bluetooth state -> " + bluetoothState);
- if (mBluetoothState != bluetoothState) {
- final long elapsedRealtime = SystemClock.elapsedRealtime();
- if (mBluetoothState >= 0) {
- mBluetoothStateTimer[mBluetoothState].stopRunningLocked(elapsedRealtime);
- }
- mBluetoothState = bluetoothState;
- mBluetoothStateTimer[bluetoothState].startRunningLocked(elapsedRealtime);
- }
- }
-
int mWifiFullLockNesting = 0;
public void noteFullWifiLockAcquiredLocked(int uid) {
@@ -4313,20 +4270,6 @@ public final class BatteryStatsImpl extends BatteryStats {
return mWifiSignalStrengthsTimer[strengthBin].getCountLocked(which);
}
- @Override public long getBluetoothOnTime(long elapsedRealtimeUs, int which) {
- return mBluetoothOnTimer.getTotalTimeLocked(elapsedRealtimeUs, which);
- }
-
- @Override public long getBluetoothStateTime(int bluetoothState,
- long elapsedRealtimeUs, int which) {
- return mBluetoothStateTimer[bluetoothState].getTotalTimeLocked(
- elapsedRealtimeUs, which);
- }
-
- @Override public int getBluetoothStateCount(int bluetoothState, int which) {
- return mBluetoothStateTimer[bluetoothState].getCountLocked(which);
- }
-
@Override public boolean hasBluetoothActivityReporting() {
return mHasBluetoothEnergyReporting;
}
@@ -6780,10 +6723,6 @@ public final class BatteryStatsImpl extends BatteryStats {
mWifiSignalStrengthsTimer[i] = new StopwatchTimer(null, -800-i, null,
mOnBatteryTimeBase);
}
- mBluetoothOnTimer = new StopwatchTimer(null, -6, null, mOnBatteryTimeBase);
- for (int i=0; i< NUM_BLUETOOTH_STATES; i++) {
- mBluetoothStateTimer[i] = new StopwatchTimer(null, -500-i, null, mOnBatteryTimeBase);
- }
mAudioOnTimer = new StopwatchTimer(null, -7, null, mOnBatteryTimeBase);
mVideoOnTimer = new StopwatchTimer(null, -8, null, mOnBatteryTimeBase);
mFlashlightOnTimer = new StopwatchTimer(null, -9, null, mOnBatteryTimeBase);
@@ -7399,10 +7338,6 @@ public final class BatteryStatsImpl extends BatteryStats {
for (int i=0; i<NUM_WIFI_SIGNAL_STRENGTH_BINS; i++) {
mWifiSignalStrengthsTimer[i].reset(false);
}
- mBluetoothOnTimer.reset(false);
- for (int i=0; i< NUM_BLUETOOTH_STATES; i++) {
- mBluetoothStateTimer[i].reset(false);
- }
for (int i=0; i< NUM_CONTROLLER_ACTIVITY_TYPES; i++) {
mBluetoothActivityCounters[i].reset(false);
mWifiActivityCounters[i].reset(false);
@@ -7727,16 +7662,12 @@ public final class BatteryStatsImpl extends BatteryStats {
mWifiActivityCounters[CONTROLLER_IDLE_TIME].addCountLocked(
info.getControllerIdleTimeMillis());
- final double powerDrainMaMs;
- if (mPowerProfile.getAveragePower(
- PowerProfile.POWER_WIFI_CONTROLLER_OPERATING_VOLTAGE) == 0) {
- powerDrainMaMs = 0.0;
- } else {
- powerDrainMaMs = info.getControllerEnergyUsed()
- / mPowerProfile.getAveragePower(
- PowerProfile.POWER_WIFI_CONTROLLER_OPERATING_VOLTAGE);
+ final double opVoltage = mPowerProfile.getAveragePower(
+ PowerProfile.POWER_WIFI_CONTROLLER_OPERATING_VOLTAGE);
+ if (opVoltage != 0) {
+ mWifiActivityCounters[CONTROLLER_POWER_DRAIN].addCountLocked(
+ (long)(info.getControllerEnergyUsed() / opVoltage));
}
- mWifiActivityCounters[CONTROLLER_POWER_DRAIN].addCountLocked((long) powerDrainMaMs);
}
}
@@ -7824,8 +7755,13 @@ public final class BatteryStatsImpl extends BatteryStats {
info.getControllerTxTimeMillis());
mBluetoothActivityCounters[CONTROLLER_IDLE_TIME].addCountLocked(
info.getControllerIdleTimeMillis());
- mBluetoothActivityCounters[CONTROLLER_POWER_DRAIN].addCountLocked(
- info.getControllerEnergyUsed());
+
+ final double opVoltage = mPowerProfile.getAveragePower(
+ PowerProfile.POWER_BLUETOOTH_CONTROLLER_OPERATING_VOLTAGE);
+ if (opVoltage != 0) {
+ mBluetoothActivityCounters[CONTROLLER_POWER_DRAIN].addCountLocked(
+ (long) (info.getControllerEnergyUsed() / opVoltage));
+ }
}
}
@@ -7871,9 +7807,9 @@ public final class BatteryStatsImpl extends BatteryStats {
if (mCharging != charging) {
mCharging = charging;
if (charging) {
- mHistoryCur.states |= HistoryItem.STATE_CHARGING_FLAG;
+ mHistoryCur.states2 |= HistoryItem.STATE2_CHARGING_FLAG;
} else {
- mHistoryCur.states &= ~HistoryItem.STATE_CHARGING_FLAG;
+ mHistoryCur.states2 &= ~HistoryItem.STATE2_CHARGING_FLAG;
}
mHandler.sendEmptyMessage(MSG_REPORT_CHARGING);
return true;
@@ -8039,9 +7975,9 @@ public final class BatteryStatsImpl extends BatteryStats {
}
}
- private void scheduleSyncExternalStatsLocked() {
+ private void scheduleSyncExternalStatsLocked(String reason) {
if (mExternalSync != null) {
- mExternalSync.scheduleSync();
+ mExternalSync.scheduleSync(reason);
}
}
@@ -8067,7 +8003,7 @@ public final class BatteryStatsImpl extends BatteryStats {
}
}
// Always start out assuming charging, that will be updated later.
- mHistoryCur.states |= HistoryItem.STATE_CHARGING_FLAG;
+ mHistoryCur.states2 |= HistoryItem.STATE2_CHARGING_FLAG;
mHistoryCur.batteryStatus = (byte)status;
mHistoryCur.batteryLevel = (byte)level;
mMaxChargeStepLevel = mMinDischargeStepLevel =
@@ -8109,7 +8045,7 @@ public final class BatteryStatsImpl extends BatteryStats {
// TODO(adamlesinski): Schedule the creation of a HistoryStepDetails record
// which will pull external stats.
- scheduleSyncExternalStatsLocked();
+ scheduleSyncExternalStatsLocked("battery-level");
}
if (mHistoryCur.batteryStatus != status) {
mHistoryCur.batteryStatus = (byte)status;
@@ -8910,6 +8846,7 @@ public final class BatteryStatsImpl extends BatteryStats {
mMobileRadioActiveAdjustedTime.readSummaryFromParcelLocked(in);
mMobileRadioActiveUnknownTime.readSummaryFromParcelLocked(in);
mMobileRadioActiveUnknownCount.readSummaryFromParcelLocked(in);
+ mWifiRadioPowerState = DataConnectionRealTimeInfo.DC_POWER_STATE_LOW;
mWifiOn = false;
mWifiOnTimer.readSummaryFromParcelLocked(in);
mGlobalWifiRunning = false;
@@ -8923,16 +8860,9 @@ public final class BatteryStatsImpl extends BatteryStats {
for (int i=0; i<NUM_WIFI_SIGNAL_STRENGTH_BINS; i++) {
mWifiSignalStrengthsTimer[i].readSummaryFromParcelLocked(in);
}
- mBluetoothOn = false;
- mBluetoothOnTimer.readSummaryFromParcelLocked(in);
- for (int i=0; i< NUM_BLUETOOTH_STATES; i++) {
- mBluetoothStateTimer[i].readSummaryFromParcelLocked(in);
- }
-
for (int i = 0; i < NUM_CONTROLLER_ACTIVITY_TYPES; i++) {
mBluetoothActivityCounters[i].readSummaryFromParcelLocked(in);
}
-
for (int i = 0; i < NUM_CONTROLLER_ACTIVITY_TYPES; i++) {
mWifiActivityCounters[i].readSummaryFromParcelLocked(in);
}
@@ -9246,10 +9176,6 @@ public final class BatteryStatsImpl extends BatteryStats {
for (int i=0; i<NUM_WIFI_SIGNAL_STRENGTH_BINS; i++) {
mWifiSignalStrengthsTimer[i].writeSummaryFromParcelLocked(out, NOWREAL_SYS);
}
- mBluetoothOnTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
- for (int i=0; i< NUM_BLUETOOTH_STATES; i++) {
- mBluetoothStateTimer[i].writeSummaryFromParcelLocked(out, NOWREAL_SYS);
- }
for (int i=0; i< NUM_CONTROLLER_ACTIVITY_TYPES; i++) {
mBluetoothActivityCounters[i].writeSummaryFromParcelLocked(out);
}
@@ -9542,6 +9468,7 @@ public final class BatteryStatsImpl extends BatteryStats {
mMobileRadioActiveAdjustedTime = new LongSamplingCounter(mOnBatteryTimeBase, in);
mMobileRadioActiveUnknownTime = new LongSamplingCounter(mOnBatteryTimeBase, in);
mMobileRadioActiveUnknownCount = new LongSamplingCounter(mOnBatteryTimeBase, in);
+ mWifiRadioPowerState = DataConnectionRealTimeInfo.DC_POWER_STATE_LOW;
mWifiOn = false;
mWifiOnTimer = new StopwatchTimer(null, -4, null, mOnBatteryTimeBase, in);
mGlobalWifiRunning = false;
@@ -9558,17 +9485,9 @@ public final class BatteryStatsImpl extends BatteryStats {
mWifiSignalStrengthsTimer[i] = new StopwatchTimer(null, -800-i,
null, mOnBatteryTimeBase, in);
}
- mBluetoothOn = false;
- mBluetoothOnTimer = new StopwatchTimer(null, -6, null, mOnBatteryTimeBase, in);
- for (int i=0; i< NUM_BLUETOOTH_STATES; i++) {
- mBluetoothStateTimer[i] = new StopwatchTimer(null, -500-i,
- null, mOnBatteryTimeBase, in);
- }
-
for (int i = 0; i < NUM_CONTROLLER_ACTIVITY_TYPES; i++) {
mBluetoothActivityCounters[i] = new LongSamplingCounter(mOnBatteryTimeBase, in);
}
-
for (int i = 0; i < NUM_CONTROLLER_ACTIVITY_TYPES; i++) {
mWifiActivityCounters[i] = new LongSamplingCounter(mOnBatteryTimeBase, in);
}
@@ -9598,9 +9517,6 @@ public final class BatteryStatsImpl extends BatteryStats {
mChargeStepTracker.readFromParcel(in);
mLastWriteTime = in.readLong();
- mBluetoothPingCount = in.readInt();
- mBluetoothPingStart = -1;
-
mKernelWakelockStats.clear();
int NKW = in.readInt();
for (int ikw = 0; ikw < NKW; ikw++) {
@@ -9718,10 +9634,6 @@ public final class BatteryStatsImpl extends BatteryStats {
for (int i=0; i<NUM_WIFI_SIGNAL_STRENGTH_BINS; i++) {
mWifiSignalStrengthsTimer[i].writeToParcel(out, uSecRealtime);
}
- mBluetoothOnTimer.writeToParcel(out, uSecRealtime);
- for (int i=0; i< NUM_BLUETOOTH_STATES; i++) {
- mBluetoothStateTimer[i].writeToParcel(out, uSecRealtime);
- }
for (int i=0; i< NUM_CONTROLLER_ACTIVITY_TYPES; i++) {
mBluetoothActivityCounters[i].writeToParcel(out);
}
@@ -9748,8 +9660,6 @@ public final class BatteryStatsImpl extends BatteryStats {
mChargeStepTracker.writeToParcel(out);
out.writeLong(mLastWriteTime);
- out.writeInt(getBluetoothPingCount());
-
if (inclUids) {
out.writeInt(mKernelWakelockStats.size());
for (Map.Entry<String, SamplingTimer> ent : mKernelWakelockStats.entrySet()) {
@@ -9851,6 +9761,7 @@ public final class BatteryStatsImpl extends BatteryStats {
mMobileRadioActiveTimer.logState(pr, " ");
pr.println("*** Mobile network active adjusted timer:");
mMobileRadioActiveAdjustedTime.logState(pr, " ");
+ pr.println("*** mWifiRadioPowerState=" + mWifiRadioPowerState);
pr.println("*** Wifi timer:");
mWifiOnTimer.logState(pr, " ");
pr.println("*** WifiRunning timer:");
@@ -9867,12 +9778,6 @@ public final class BatteryStatsImpl extends BatteryStats {
pr.println("*** Wifi signal strength #" + i + ":");
mWifiSignalStrengthsTimer[i].logState(pr, " ");
}
- pr.println("*** Bluetooth timer:");
- mBluetoothOnTimer.logState(pr, " ");
- for (int i=0; i< NUM_BLUETOOTH_STATES; i++) {
- pr.println("*** Bluetooth active type #" + i + ":");
- mBluetoothStateTimer[i].logState(pr, " ");
- }
pr.println("*** Flashlight timer:");
mFlashlightOnTimer.logState(pr, " ");
}
diff --git a/core/java/com/android/internal/os/WifiPowerCalculator.java b/core/java/com/android/internal/os/WifiPowerCalculator.java
index 4fb8b55..961b0df 100644
--- a/core/java/com/android/internal/os/WifiPowerCalculator.java
+++ b/core/java/com/android/internal/os/WifiPowerCalculator.java
@@ -71,7 +71,7 @@ public class WifiPowerCalculator extends PowerCalculator {
app.wifiRunningTimeMs = idleTimeMs + rxTimeMs + txTimeMs;
double powerDrain = stats.getWifiControllerActivity(BatteryStats.CONTROLLER_POWER_DRAIN,
- statsType) / (1000*60*60);
+ statsType) / (double)(1000*60*60);
if (powerDrain == 0) {
// Some controllers do not report power drain, so we can calculate it here.
powerDrain = ((idleTimeMs * mIdleCurrentMa) + (txTimeMs * mTxCurrentMa)
diff --git a/core/java/com/android/internal/os/WifiPowerEstimator.java b/core/java/com/android/internal/os/WifiPowerEstimator.java
index 0172367..c4e2ef6 100644
--- a/core/java/com/android/internal/os/WifiPowerEstimator.java
+++ b/core/java/com/android/internal/os/WifiPowerEstimator.java
@@ -63,7 +63,7 @@ public class WifiPowerEstimator extends PowerCalculator {
mTotalAppWifiRunningTimeMs += app.wifiRunningTimeMs;
final double wifiLockPower = (app.wifiRunningTimeMs * mWifiPowerOn) / (1000*60*60);
- final long wifiScanTimeMs = u.getWifiScanTime(rawRealtimeUs, statsType);
+ final long wifiScanTimeMs = u.getWifiScanTime(rawRealtimeUs, statsType) / 1000;
final double wifiScanPower = (wifiScanTimeMs * mWifiPowerScan) / (1000*60*60);
double wifiBatchScanPower = 0;
diff --git a/core/java/com/android/internal/widget/FloatingToolbar.java b/core/java/com/android/internal/widget/FloatingToolbar.java
index 0b1e0e5..1e96945 100644
--- a/core/java/com/android/internal/widget/FloatingToolbar.java
+++ b/core/java/com/android/internal/widget/FloatingToolbar.java
@@ -1070,7 +1070,8 @@ public final class FloatingToolbar {
private static PopupWindow createPopupWindow(View content) {
ViewGroup popupContentHolder = new LinearLayout(content.getContext());
PopupWindow popupWindow = new PopupWindow(popupContentHolder);
- popupWindow.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL);
+ popupWindow.setWindowLayoutType(
+ WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL);
popupWindow.setAnimationStyle(0);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
content.setLayoutParams(new ViewGroup.LayoutParams(
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index aa722d0..d06534e 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -1009,12 +1009,13 @@ void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) {
TextureVertex::set(mesh++, r->left, r->bottom, u1, v2);
TextureVertex::set(mesh++, r->right, r->bottom, u2, v2);
}
+ Rect modelRect = Rect(rect.getWidth(), rect.getHeight());
Glop glop;
GlopBuilder(mRenderState, mCaches, &glop)
.setMeshTexturedIndexedQuads(&quadVertices[0], count * 6)
.setFillLayer(layer->getTexture(), layer->getColorFilter(), getLayerAlpha(layer), layer->getMode(), Blend::ModeOrderSwap::NoSwap)
.setTransform(currentSnapshot()->getOrthoMatrix(), *currentTransform(), false)
- .setModelViewOffsetRectSnap(0, 0, rect)
+ .setModelViewOffsetRectSnap(rect.left, rect.top, modelRect)
.setRoundRectClipState(currentSnapshot()->roundRectClipState)
.build();
DRAW_DOUBLE_STENCIL_IF(!layer->hasDrawnSinceUpdate, renderGlop(glop));
diff --git a/packages/DocumentsUI/res/layout/dialog_create_dir.xml b/packages/DocumentsUI/res/layout/dialog_create_dir.xml
index 54e26b4..5ed476f 100644
--- a/packages/DocumentsUI/res/layout/dialog_create_dir.xml
+++ b/packages/DocumentsUI/res/layout/dialog_create_dir.xml
@@ -22,6 +22,7 @@
<EditText
android:id="@android:id/text1"
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="wrap_content"
+ android:inputType="text" />
</FrameLayout>
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
index a88497c..be71b034 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
@@ -23,6 +23,7 @@ import android.content.res.Resources;
import android.graphics.Canvas;
import android.media.AudioManager;
import android.os.SystemClock;
+import android.service.trust.TrustAgentService;
import android.telephony.TelephonyManager;
import android.util.AttributeSet;
import android.util.Log;
@@ -69,14 +70,27 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {
}
@Override
- public void onTrustInitiatedByUser(int userId) {
+ public void onTrustGrantedWithFlags(int flags, int userId) {
if (userId != mLockPatternUtils.getCurrentUser()) return;
if (!isAttachedToWindow()) return;
-
- if (isVisibleToUser()) {
- dismiss(false /* authenticated */);
- } else {
- mViewMediatorCallback.playTrustedSound();
+ boolean bouncerVisible = isVisibleToUser();
+ boolean initiatedByUser =
+ (flags & TrustAgentService.FLAG_GRANT_TRUST_INITIATED_BY_USER) != 0;
+ boolean dismissKeyguard =
+ (flags & TrustAgentService.FLAG_GRANT_TRUST_DISMISS_KEYGUARD) != 0;
+
+ if (initiatedByUser || dismissKeyguard) {
+ if (mViewMediatorCallback.isScreenOn() && (bouncerVisible || dismissKeyguard)) {
+ if (!bouncerVisible) {
+ // The trust agent dismissed the keyguard without the user proving
+ // that they are present (by swiping up to show the bouncer). That's fine if
+ // the user proved presence via some other way to the trust agent.
+ Log.i(TAG, "TrustAgent dismissed Keyguard.");
+ }
+ dismiss(false /* authenticated */);
+ } else {
+ mViewMediatorCallback.playTrustedSound();
+ }
}
}
};
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 50c9f2d..1eec532 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -58,12 +58,12 @@ import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintManager.AuthenticationCallback;
import android.hardware.fingerprint.FingerprintUtils;
import android.hardware.fingerprint.FingerprintManager.AuthenticationResult;
+import android.service.trust.TrustAgentService;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager;
import android.util.Log;
-import android.util.Slog;
import android.util.SparseBooleanArray;
import com.google.android.collect.Lists;
@@ -245,15 +245,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
private SparseBooleanArray mUserFaceUnlockRunning = new SparseBooleanArray();
@Override
- public void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser) {
+ public void onTrustChanged(boolean enabled, int userId, int flags) {
mUserHasTrust.put(userId, enabled);
-
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) {
cb.onTrustChanged(userId);
- if (enabled && initiatedByUser) {
- cb.onTrustInitiatedByUser(userId);
+ if (enabled && flags != 0) {
+ cb.onTrustGrantedWithFlags(flags, userId);
}
}
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
index 756a7a4..26e6973 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
@@ -171,9 +171,9 @@ public class KeyguardUpdateMonitorCallback {
public void onTrustManagedChanged(int userId) { }
/**
- * Called when the user has proved to a trust agent that they want to use the device.
+ * Called after trust was granted with non-zero flags.
*/
- public void onTrustInitiatedByUser(int userId) { }
+ public void onTrustGrantedWithFlags(int flags, int userId) { }
/**
* Called when a fingerprint is recognized.
diff --git a/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java
index 5bbcc8c..f5c809a 100644
--- a/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java
@@ -76,4 +76,9 @@ public interface ViewMediatorCallback {
* (legacy API)
*/
boolean isInputRestricted();
+
+ /**
+ * @return true if the screen is on
+ */
+ boolean isScreenOn();
}
diff --git a/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java b/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java
index e6a0dd7..b8f16e7 100644
--- a/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java
+++ b/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java
@@ -38,7 +38,7 @@ public class SampleTrustAgent extends TrustAgentService
* <pre>
* $ adb shell am broadcast -a action.sample_trust_agent.grant_trust\
* -e extra.message SampleTrust\
- * --el extra.duration 1000 --ez extra.init_by_user false
+ * --el extra.duration 1000 --ez extra.init_by_user false --ez extra.dismiss_keyguard false
* </pre>
*/
private static final boolean ALLOW_EXTERNAL_BROADCASTS = false;
@@ -51,6 +51,7 @@ public class SampleTrustAgent extends TrustAgentService
private static final String EXTRA_MESSAGE = "extra.message";
private static final String EXTRA_DURATION = "extra.duration";
private static final String EXTRA_INITIATED_BY_USER = "extra.init_by_user";
+ private static final String EXTRA_DISMISS_KEYGUARD = "extra.dismiss_keyguard";
private static final String PREFERENCE_REPORT_UNLOCK_ATTEMPTS
= "preference.report_unlock_attempts";
@@ -141,10 +142,17 @@ public class SampleTrustAgent extends TrustAgentService
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (ACTION_GRANT_TRUST.equals(action)) {
+ int flags = 0;
+ if (intent.getBooleanExtra(EXTRA_INITIATED_BY_USER, false)) {
+ flags |= TrustAgentService.FLAG_GRANT_TRUST_INITIATED_BY_USER;
+ }
+ if (intent.getBooleanExtra(EXTRA_DISMISS_KEYGUARD, false)) {
+ flags |= TrustAgentService.FLAG_GRANT_TRUST_DISMISS_KEYGUARD;
+ }
+
try {
grantTrust(intent.getStringExtra(EXTRA_MESSAGE),
- intent.getLongExtra(EXTRA_DURATION, 0),
- intent.getBooleanExtra(EXTRA_INITIATED_BY_USER, false));
+ intent.getLongExtra(EXTRA_DURATION, 0), flags);
} catch (IllegalStateException e) {
logAndShowToast("IllegalStateException: " + e.getMessage());
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 97a4c55..f16fb5c 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -505,6 +505,11 @@ public class KeyguardViewMediator extends SystemUI {
public boolean isInputRestricted() {
return KeyguardViewMediator.this.isInputRestricted();
}
+
+ @Override
+ public boolean isScreenOn() {
+ return mScreenOn;
+ }
};
public void userActivity() {
diff --git a/services/core/java/com/android/server/LockSettingsService.java b/services/core/java/com/android/server/LockSettingsService.java
index ee73b1a..16689ee 100644
--- a/services/core/java/com/android/server/LockSettingsService.java
+++ b/services/core/java/com/android/server/LockSettingsService.java
@@ -388,7 +388,9 @@ public class LockSettingsService extends ILockSettings.Stub {
byte[] currentHandle = getCurrentHandle(userId);
if (pattern == null) {
+ getGateKeeperService().clearSecureUserId(userId);
mStorage.writePatternHash(null, userId);
+ maybeUpdateKeystore(null, userId);
return;
}
@@ -414,7 +416,9 @@ public class LockSettingsService extends ILockSettings.Stub {
byte[] currentHandle = getCurrentHandle(userId);
if (password == null) {
+ getGateKeeperService().clearSecureUserId(userId);
mStorage.writePasswordHash(null, userId);
+ maybeUpdateKeystore(null, userId);
return;
}
diff --git a/services/core/java/com/android/server/am/BatteryStatsService.java b/services/core/java/com/android/server/am/BatteryStatsService.java
index bfc4fc7..905adc0 100644
--- a/services/core/java/com/android/server/am/BatteryStatsService.java
+++ b/services/core/java/com/android/server/am/BatteryStatsService.java
@@ -18,8 +18,6 @@ package com.android.server.am;
import android.bluetooth.BluetoothActivityEnergyInfo;
import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothHeadset;
-import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -40,7 +38,6 @@ import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.WorkSource;
-import android.telephony.DataConnectionRealTimeInfo;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.util.Slog;
@@ -71,8 +68,6 @@ public final class BatteryStatsService extends IBatteryStats.Stub
final BatteryStatsImpl mStats;
final BatteryStatsHandler mHandler;
Context mContext;
- private boolean mBluetoothPendingStats;
- private BluetoothHeadset mBluetoothHeadset;
PowerManagerInternal mPowerManagerInternal;
class BatteryStatsHandler extends Handler implements BatteryStatsImpl.ExternalStatsSync {
@@ -87,11 +82,11 @@ public final class BatteryStatsService extends IBatteryStats.Stub
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_SYNC_EXTERNAL_STATS:
- updateExternalStats();
+ updateExternalStats((String)msg.obj);
break;
case MSG_WRITE_TO_DISK:
- updateExternalStats();
+ updateExternalStats("write");
synchronized (mStats) {
mStats.writeAsyncLocked();
}
@@ -100,9 +95,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub
}
@Override
- public void scheduleSync() {
+ public void scheduleSync(String reason) {
if (!hasMessages(MSG_SYNC_EXTERNAL_STATS)) {
- sendEmptyMessage(MSG_SYNC_EXTERNAL_STATS);
+ Message msg = Message.obtain(this, MSG_SYNC_EXTERNAL_STATS, reason);
+ sendMessage(msg);
}
}
}
@@ -140,7 +136,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
public void shutdown() {
Slog.w("BatteryStats", "Writing battery stats before shutdown...");
- updateExternalStats();
+ updateExternalStats("shutdown");
synchronized (mStats) {
mStats.shutdownLocked();
}
@@ -231,7 +227,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
//Slog.i("foo", "SENDING BATTERY INFO:");
//mStats.dumpLocked(new LogPrinter(Log.INFO, "foo", Log.LOG_ID_SYSTEM));
Parcel out = Parcel.obtain();
- updateExternalStats();
+ updateExternalStats("get-stats");
synchronized (mStats) {
mStats.writeToParcel(out, 0);
}
@@ -246,7 +242,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
//Slog.i("foo", "SENDING BATTERY INFO:");
//mStats.dumpLocked(new LogPrinter(Log.INFO, "foo", Log.LOG_ID_SYSTEM));
Parcel out = Parcel.obtain();
- updateExternalStats();
+ updateExternalStats("get-stats");
synchronized (mStats) {
mStats.writeToParcel(out, 0);
}
@@ -569,7 +565,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub
// There was a change in WiFi power state.
// Collect data now for the past activity.
- mHandler.scheduleSync();
+ mHandler.scheduleSync("wifi-data");
+ synchronized (mStats) {
+ mStats.noteWifiRadioPowerState(powerState, tsNanos);
+ }
}
public void noteWifiRunning(WorkSource ws) {
@@ -614,56 +613,6 @@ public final class BatteryStatsService extends IBatteryStats.Stub
}
}
- public void noteBluetoothOn() {
- enforceCallingPermission();
- BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
- if (adapter != null) {
- adapter.getProfileProxy(mContext, mBluetoothProfileServiceListener,
- BluetoothProfile.HEADSET);
- }
- synchronized (mStats) {
- if (mBluetoothHeadset != null) {
- mStats.noteBluetoothOnLocked();
- mStats.setBtHeadset(mBluetoothHeadset);
- } else {
- mBluetoothPendingStats = true;
- }
- }
- }
-
- private BluetoothProfile.ServiceListener mBluetoothProfileServiceListener =
- new BluetoothProfile.ServiceListener() {
- public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mBluetoothHeadset = (BluetoothHeadset) proxy;
- synchronized (mStats) {
- if (mBluetoothPendingStats) {
- mStats.noteBluetoothOnLocked();
- mStats.setBtHeadset(mBluetoothHeadset);
- mBluetoothPendingStats = false;
- }
- }
- }
-
- public void onServiceDisconnected(int profile) {
- mBluetoothHeadset = null;
- }
- };
-
- public void noteBluetoothOff() {
- enforceCallingPermission();
- synchronized (mStats) {
- mBluetoothPendingStats = false;
- mStats.noteBluetoothOffLocked();
- }
- }
-
- public void noteBluetoothState(int bluetoothState) {
- enforceCallingPermission();
- synchronized (mStats) {
- mStats.noteBluetoothStateLocked(bluetoothState);
- }
- }
-
public void noteFullWifiLockAcquired(int uid) {
enforceCallingPermission();
synchronized (mStats) {
@@ -820,7 +769,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
// Sync external stats first as the battery has changed states. If we don't sync
// immediately here, we may not collect the relevant data later.
- updateExternalStats();
+ updateExternalStats("battery-state");
synchronized (mStats) {
mStats.setBatteryStateLocked(status, health, plugType, level, temp, volt);
}
@@ -974,9 +923,9 @@ public final class BatteryStatsService extends IBatteryStats.Stub
pw.println("Battery stats reset.");
noOutput = true;
}
- updateExternalStats();
+ updateExternalStats("dump");
} else if ("--write".equals(arg)) {
- updateExternalStats();
+ updateExternalStats("dump");
synchronized (mStats) {
mStats.writeSyncLocked();
pw.println("Battery stats written.");
@@ -1047,7 +996,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
}
// Fetch data from external sources and update the BatteryStatsImpl object with them.
- updateExternalStats();
+ updateExternalStats("dump");
if (useCheckinFormat) {
List<ApplicationInfo> apps = mContext.getPackageManager().getInstalledApplications(0);
@@ -1178,7 +1127,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
* We first grab a lock specific to this method, then once all the data has been collected,
* we grab the mStats lock and update the data.
*/
- void updateExternalStats() {
+ void updateExternalStats(String reason) {
synchronized (mExternalStatsLock) {
if (mContext == null) {
// We haven't started yet (which means the BatteryStatsImpl object has
@@ -1189,6 +1138,12 @@ public final class BatteryStatsService extends IBatteryStats.Stub
final WifiActivityEnergyInfo wifiEnergyInfo = pullWifiEnergyInfoLocked();
final BluetoothActivityEnergyInfo bluetoothEnergyInfo = pullBluetoothEnergyInfoLocked();
synchronized (mStats) {
+ if (mStats.mRecordAllHistory) {
+ final long elapsedRealtime = SystemClock.elapsedRealtime();
+ final long uptime = SystemClock.uptimeMillis();
+ mStats.addHistoryEventLocked(elapsedRealtime, uptime,
+ BatteryStats.HistoryItem.EVENT_COLLECT_EXTERNAL_STATS, reason, 0);
+ }
mStats.updateKernelWakelocksLocked();
mStats.updateMobileRadioStateLocked(SystemClock.elapsedRealtime());
mStats.updateWifiStateLocked(wifiEnergyInfo);
diff --git a/services/core/java/com/android/server/trust/TrustAgentWrapper.java b/services/core/java/com/android/server/trust/TrustAgentWrapper.java
index dec195d..fb7d186 100644
--- a/services/core/java/com/android/server/trust/TrustAgentWrapper.java
+++ b/services/core/java/com/android/server/trust/TrustAgentWrapper.java
@@ -116,7 +116,7 @@ public class TrustAgentWrapper {
}
mTrusted = true;
mMessage = (CharSequence) msg.obj;
- boolean initiatedByUser = msg.arg1 != 0;
+ int flags = msg.arg1;
long durationMs = msg.getData().getLong(DATA_DURATION);
if (durationMs > 0) {
final long duration;
@@ -141,8 +141,8 @@ public class TrustAgentWrapper {
}
mTrustManagerService.mArchive.logGrantTrust(mUserId, mName,
(mMessage != null ? mMessage.toString() : null),
- durationMs, initiatedByUser);
- mTrustManagerService.updateTrust(mUserId, initiatedByUser);
+ durationMs, flags);
+ mTrustManagerService.updateTrust(mUserId, flags);
break;
case MSG_TRUST_TIMEOUT:
if (DEBUG) Slog.v(TAG, "Trust timed out : " + mName.flattenToShortString());
@@ -156,7 +156,7 @@ public class TrustAgentWrapper {
if (msg.what == MSG_REVOKE_TRUST) {
mTrustManagerService.mArchive.logRevokeTrust(mUserId, mName);
}
- mTrustManagerService.updateTrust(mUserId, false);
+ mTrustManagerService.updateTrust(mUserId, 0);
break;
case MSG_RESTART_TIMEOUT:
destroy();
@@ -171,7 +171,7 @@ public class TrustAgentWrapper {
if (DEBUG) Log.v(TAG, "Re-enabling agent because it acknowledged "
+ "enabled features: " + mName);
mTrustDisabledByDpm = false;
- mTrustManagerService.updateTrust(mUserId, false);
+ mTrustManagerService.updateTrust(mUserId, 0);
}
} else {
if (DEBUG) Log.w(TAG, "Ignoring MSG_SET_TRUST_AGENT_FEATURES_COMPLETED "
@@ -185,7 +185,7 @@ public class TrustAgentWrapper {
mMessage = null;
}
mTrustManagerService.mArchive.logManagingTrust(mUserId, mName, mManagingTrust);
- mTrustManagerService.updateTrust(mUserId, false);
+ mTrustManagerService.updateTrust(mUserId, 0);
break;
}
}
@@ -194,12 +194,12 @@ public class TrustAgentWrapper {
private ITrustAgentServiceCallback mCallback = new ITrustAgentServiceCallback.Stub() {
@Override
- public void grantTrust(CharSequence userMessage, long durationMs, boolean initiatedByUser) {
+ public void grantTrust(CharSequence userMessage, long durationMs, int flags) {
if (DEBUG) Slog.v(TAG, "enableTrust(" + userMessage + ", durationMs = " + durationMs
- + ", initiatedByUser = " + initiatedByUser + ")");
+ + ", flags = " + flags + ")");
Message msg = mHandler.obtainMessage(
- MSG_GRANT_TRUST, initiatedByUser ? 1 : 0, 0, userMessage);
+ MSG_GRANT_TRUST, flags, 0, userMessage);
msg.getData().putLong(DATA_DURATION, durationMs);
msg.sendToTarget();
}
@@ -381,7 +381,7 @@ public class TrustAgentWrapper {
}
if (mTrustDisabledByDpm != trustDisabled) {
mTrustDisabledByDpm = trustDisabled;
- mTrustManagerService.updateTrust(mUserId, false);
+ mTrustManagerService.updateTrust(mUserId, 0);
}
return trustDisabled;
}
diff --git a/services/core/java/com/android/server/trust/TrustArchive.java b/services/core/java/com/android/server/trust/TrustArchive.java
index 7253716..fd63d48 100644
--- a/services/core/java/com/android/server/trust/TrustArchive.java
+++ b/services/core/java/com/android/server/trust/TrustArchive.java
@@ -19,6 +19,7 @@ package com.android.server.trust;
import android.content.ComponentName;
import android.os.SystemClock;
import android.os.UserHandle;
+import android.service.trust.TrustAgentService;
import android.util.TimeUtils;
import java.io.PrintWriter;
@@ -48,20 +49,20 @@ public class TrustArchive {
// grantTrust
final String message;
final long duration;
- final boolean userInitiated;
+ final int flags;
// managingTrust
final boolean managingTrust;
private Event(int type, int userId, ComponentName agent, String message,
- long duration, boolean userInitiated, boolean managingTrust) {
+ long duration, int flags, boolean managingTrust) {
this.type = type;
this.userId = userId;
this.agent = agent;
this.elapsedTimestamp = SystemClock.elapsedRealtime();
this.message = message;
this.duration = duration;
- this.userInitiated = userInitiated;
+ this.flags = flags;
this.managingTrust = managingTrust;
}
}
@@ -69,33 +70,33 @@ public class TrustArchive {
ArrayDeque<Event> mEvents = new ArrayDeque<Event>();
public void logGrantTrust(int userId, ComponentName agent, String message,
- long duration, boolean userInitiated) {
+ long duration, int flags) {
addEvent(new Event(TYPE_GRANT_TRUST, userId, agent, message, duration,
- userInitiated, false));
+ flags, false));
}
public void logRevokeTrust(int userId, ComponentName agent) {
- addEvent(new Event(TYPE_REVOKE_TRUST, userId, agent, null, 0, false, false));
+ addEvent(new Event(TYPE_REVOKE_TRUST, userId, agent, null, 0, 0, false));
}
public void logTrustTimeout(int userId, ComponentName agent) {
- addEvent(new Event(TYPE_TRUST_TIMEOUT, userId, agent, null, 0, false, false));
+ addEvent(new Event(TYPE_TRUST_TIMEOUT, userId, agent, null, 0, 0, false));
}
public void logAgentDied(int userId, ComponentName agent) {
- addEvent(new Event(TYPE_AGENT_DIED, userId, agent, null, 0, false, false));
+ addEvent(new Event(TYPE_AGENT_DIED, userId, agent, null, 0, 0, false));
}
public void logAgentConnected(int userId, ComponentName agent) {
- addEvent(new Event(TYPE_AGENT_CONNECTED, userId, agent, null, 0, false, false));
+ addEvent(new Event(TYPE_AGENT_CONNECTED, userId, agent, null, 0, 0, false));
}
public void logAgentStopped(int userId, ComponentName agent) {
- addEvent(new Event(TYPE_AGENT_STOPPED, userId, agent, null, 0, false, false));
+ addEvent(new Event(TYPE_AGENT_STOPPED, userId, agent, null, 0, 0, false));
}
public void logManagingTrust(int userId, ComponentName agent, boolean managing) {
- addEvent(new Event(TYPE_MANAGING_TRUST, userId, agent, null, 0, false, managing));
+ addEvent(new Event(TYPE_MANAGING_TRUST, userId, agent, null, 0, 0, managing));
}
private void addEvent(Event e) {
@@ -129,8 +130,8 @@ public class TrustArchive {
}
switch (ev.type) {
case TYPE_GRANT_TRUST:
- writer.printf(", message=\"%s\", duration=%s, initiatedByUser=%d",
- ev.message, formatDuration(ev.duration), ev.userInitiated ? 1 : 0);
+ writer.printf(", message=\"%s\", duration=%s, flags=%s",
+ ev.message, formatDuration(ev.duration), dumpGrantFlags(ev.flags));
break;
case TYPE_MANAGING_TRUST:
writer.printf(", managingTrust=" + ev.managingTrust);
@@ -184,4 +185,20 @@ public class TrustArchive {
return "Unknown(" + type + ")";
}
}
+
+ private String dumpGrantFlags(int flags) {
+ StringBuilder sb = new StringBuilder();
+ if ((flags & TrustAgentService.FLAG_GRANT_TRUST_INITIATED_BY_USER) != 0) {
+ if (sb.length() != 0) sb.append('|');
+ sb.append("INITIATED_BY_USER");
+ }
+ if ((flags & TrustAgentService.FLAG_GRANT_TRUST_DISMISS_KEYGUARD) != 0) {
+ if (sb.length() != 0) sb.append('|');
+ sb.append("DISMISS_KEYGUARD");
+ }
+ if (sb.length() == 0) {
+ sb.append('0');
+ }
+ return sb.toString();
+ }
}
diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java
index b38d33d..7d2fb43 100644
--- a/services/core/java/com/android/server/trust/TrustManagerService.java
+++ b/services/core/java/com/android/server/trust/TrustManagerService.java
@@ -179,11 +179,11 @@ public class TrustManagerService extends SystemService {
private void updateTrustAll() {
List<UserInfo> userInfos = mUserManager.getUsers(true /* excludeDying */);
for (UserInfo userInfo : userInfos) {
- updateTrust(userInfo.id, false);
+ updateTrust(userInfo.id, 0);
}
}
- public void updateTrust(int userId, boolean initiatedByUser) {
+ public void updateTrust(int userId, int flags) {
dispatchOnTrustManagedChanged(aggregateIsTrustManaged(userId), userId);
boolean trusted = aggregateIsTrusted(userId);
boolean changed;
@@ -191,7 +191,7 @@ public class TrustManagerService extends SystemService {
changed = mUserIsTrusted.get(userId) != trusted;
mUserIsTrusted.put(userId, trusted);
}
- dispatchOnTrustChanged(trusted, userId, initiatedByUser);
+ dispatchOnTrustChanged(trusted, userId, flags);
if (changed) {
refreshDeviceLockedForUser(userId);
}
@@ -281,7 +281,7 @@ public class TrustManagerService extends SystemService {
if (userId == UserHandle.USER_ALL) {
updateTrustAll();
} else {
- updateTrust(userId, false /* initiatedByUser */);
+ updateTrust(userId, 0);
}
}
}
@@ -394,7 +394,7 @@ public class TrustManagerService extends SystemService {
}
}
if (trustMayHaveChanged) {
- updateTrust(userId, false);
+ updateTrust(userId, 0);
}
refreshAgentList(userId);
}
@@ -587,11 +587,11 @@ public class TrustManagerService extends SystemService {
}
}
- private void dispatchOnTrustChanged(boolean enabled, int userId, boolean initiatedByUser) {
- if (!enabled) initiatedByUser = false;
+ private void dispatchOnTrustChanged(boolean enabled, int userId, int flags) {
+ if (!enabled) flags = 0;
for (int i = 0; i < mTrustListeners.size(); i++) {
try {
- mTrustListeners.get(i).onTrustChanged(enabled, userId, initiatedByUser);
+ mTrustListeners.get(i).onTrustChanged(enabled, userId, flags);
} catch (DeadObjectException e) {
Slog.d(TAG, "Removing dead TrustListener.");
mTrustListeners.remove(i);