diff options
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/trust/ITrustListener.aidl | 2 | ||||
| -rw-r--r-- | core/java/android/app/trust/TrustManager.java | 22 | ||||
| -rw-r--r-- | core/java/android/nfc/IAppCallback.aidl | 4 | ||||
| -rw-r--r-- | core/java/android/nfc/NfcActivityManager.java | 15 | ||||
| -rw-r--r-- | core/java/android/nfc/NfcEvent.java | 9 | ||||
| -rw-r--r-- | core/java/android/os/BatteryStats.java | 200 | ||||
| -rw-r--r-- | core/java/android/service/gatekeeper/IGateKeeperService.aidl | 7 | ||||
| -rw-r--r-- | core/java/android/service/trust/ITrustAgentServiceCallback.aidl | 2 | ||||
| -rw-r--r-- | core/java/android/service/trust/TrustAgentService.java | 62 | ||||
| -rw-r--r-- | core/java/android/service/wallpaper/WallpaperService.java | 23 |
10 files changed, 196 insertions, 150 deletions
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 |
