From 8d58c21d48327769c0152bfa8a5670bd10d5f6fe Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Fri, 20 Oct 2017 14:33:18 +0200 Subject: Fix issues with TRON app transition logging There was a case where a app launch started activity A. A step in the UI finished A and started B in the same task. Next time A was started it immediately finished itself, putting B at the top of the task. Now, this launch was considered aborted because A was finished during launching, making it invisible. We fix this by modifying the logic to only abort the launch if the full task is not visible anymore after an activity has been set to invisible. There is another case where an app launches A, finishes A, and then launches B. In this case the home gets visible in between so we don't consider this an app launch anymore, and correctly cancel the logging. However it's still useful to know that this is happening to expose it to the developer, so we log any cancel events, no matter where they are coming from. Test: Launch Snapchat, click Sign Up, click home, relaunch Snapchat from home Test: Open slow app and press home quickly to test cancel. Change-Id: I211636c97fd6785adb3fe443a8ffa1ae766946a4 Merged-In: I211636c97fd6785adb3fe443a8ffa1ae766946a4 Fixes: 67094673 (cherry picked from commit a9d408214cd73709ff25f235cf6817eaaf7a23d6) --- proto/src/metrics_constants.proto | 4 + .../server/am/ActivityManagerDebugConfig.java | 1 + .../android/server/am/ActivityMetricsLogger.java | 90 +++++++++++++++++++--- .../java/com/android/server/am/ActivityRecord.java | 2 +- .../android/server/am/ActivityStackSupervisor.java | 12 ++- .../java/com/android/server/am/TaskRecord.java | 10 +++ 6 files changed, 105 insertions(+), 14 deletions(-) diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto index 81a23f0afa3f..cbd2f75e46d5 100644 --- a/proto/src/metrics_constants.proto +++ b/proto/src/metrics_constants.proto @@ -4567,6 +4567,10 @@ message MetricsEvent { // OS: O MR COLOR_MODE_SETTINGS = 1143; + // Enclosing category for group of APP_TRANSITION_FOO events, + // logged when we cancel an app transition. + APP_TRANSITION_CANCELLED = 1144; + // ---- End O-MR1 Constants, all O-MR1 constants go above this line ---- // Add new aosp constants above this line. diff --git a/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java b/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java index 3a9bf1258d12..276f0efb570e 100644 --- a/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java +++ b/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java @@ -94,6 +94,7 @@ class ActivityManagerDebugConfig { static final boolean DEBUG_USAGE_STATS = DEBUG_ALL || false; static final boolean DEBUG_PERMISSIONS_REVIEW = DEBUG_ALL || false; static final boolean DEBUG_WHITELISTS = DEBUG_ALL || false; + static final boolean DEBUG_METRICS = DEBUG_ALL || false; static final String POSTFIX_ADD_REMOVE = (APPEND_CATEGORY_NAME) ? "_AddRemove" : ""; static final String POSTFIX_APP = (APPEND_CATEGORY_NAME) ? "_App" : ""; diff --git a/services/core/java/com/android/server/am/ActivityMetricsLogger.java b/services/core/java/com/android/server/am/ActivityMetricsLogger.java index f396e9ef44a5..a8038747aa2a 100644 --- a/services/core/java/com/android/server/am/ActivityMetricsLogger.java +++ b/services/core/java/com/android/server/am/ActivityMetricsLogger.java @@ -12,6 +12,7 @@ import static android.app.ActivityManagerInternal.APP_TRANSITION_TIMEOUT; import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION; import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION_BIND_APPLICATION_DELAY_MS; import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION_CALLING_PACKAGE_NAME; +import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION_CANCELLED; import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION_DELAY_MS; import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION_DEVICE_UPTIME_SECONDS; import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION_IS_EPHEMERAL; @@ -27,6 +28,7 @@ import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.TYPE_T import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.TYPE_TRANSITION_REPORTED_DRAWN_NO_BUNDLE; import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.TYPE_TRANSITION_REPORTED_DRAWN_WITH_BUNDLE; import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.TYPE_TRANSITION_WARM_LAUNCH; +import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_METRICS; import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM; import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.am.ActivityStack.STACK_INVISIBLE; @@ -34,12 +36,16 @@ import static com.android.server.am.ActivityStack.STACK_INVISIBLE; import android.app.ActivityManager.StackId; import android.content.Context; import android.metrics.LogMaker; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; import android.os.SystemClock; import android.util.Slog; import android.util.SparseArray; import android.util.SparseIntArray; import com.android.internal.logging.MetricsLogger; +import com.android.internal.os.SomeArgs; import java.util.ArrayList; @@ -60,6 +66,8 @@ class ActivityMetricsLogger { private static final long INVALID_START_TIME = -1; + private static final int MSG_CHECK_VISIBILITY = 0; + // Preallocated strings we are sending to tron, so we don't have to allocate a new one every // time we log. private static final String[] TRON_WINDOW_STATE_VARZ_STRINGS = { @@ -80,6 +88,23 @@ class ActivityMetricsLogger { private final SparseArray mStackTransitionInfo = new SparseArray<>(); private final SparseArray mLastStackTransitionInfo = new SparseArray<>(); + private final H mHandler; + private final class H extends Handler { + + public H(Looper looper) { + super(looper); + } + + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_CHECK_VISIBILITY: + final SomeArgs args = (SomeArgs) msg.obj; + checkVisibility((TaskRecord) args.arg1, (ActivityRecord) args.arg2); + break; + } + } + }; private final class StackTransitionInfo { private ActivityRecord launchedActivity; @@ -93,10 +118,11 @@ class ActivityMetricsLogger { private boolean loggedStartingWindowDrawn; } - ActivityMetricsLogger(ActivityStackSupervisor supervisor, Context context) { + ActivityMetricsLogger(ActivityStackSupervisor supervisor, Context context, Looper looper) { mLastLogTimeSecs = SystemClock.elapsedRealtime() / 1000; mSupervisor = supervisor; mContext = context; + mHandler = new H(looper); } void logWindowState() { @@ -142,6 +168,7 @@ class ActivityMetricsLogger { */ void notifyActivityLaunching() { if (!isAnyTransitionActive()) { + if (DEBUG_METRICS) Slog.i(TAG, "notifyActivityLaunching"); mCurrentTransitionStartTime = SystemClock.uptimeMillis(); mLastTransitionStartTime = mCurrentTransitionStartTime; } @@ -199,6 +226,12 @@ class ActivityMetricsLogger { private void notifyActivityLaunched(int resultCode, ActivityRecord launchedActivity, boolean processRunning, boolean processSwitch) { + if (DEBUG_METRICS) Slog.i(TAG, "notifyActivityLaunched" + + " resultCode=" + resultCode + + " launchedActivity=" + launchedActivity + + " processRunning=" + processRunning + + " processSwitch=" + processSwitch); + // If we are already in an existing transition, only update the activity name, but not the // other attributes. final int stackId = launchedActivity != null && launchedActivity.getStack() != null @@ -227,6 +260,8 @@ class ActivityMetricsLogger { return; } + if (DEBUG_METRICS) Slog.i(TAG, "notifyActivityLaunched successful"); + final StackTransitionInfo newInfo = new StackTransitionInfo(); newInfo.launchedActivity = launchedActivity; newInfo.currentTransitionProcessRunning = processRunning; @@ -240,6 +275,8 @@ class ActivityMetricsLogger { * Notifies the tracker that all windows of the app have been drawn. */ void notifyWindowsDrawn(int stackId, long timestamp) { + if (DEBUG_METRICS) Slog.i(TAG, "notifyWindowsDrawn stackId=" + stackId); + final StackTransitionInfo info = mStackTransitionInfo.get(stackId); if (info == null || info.loggedWindowsDrawn) { return; @@ -273,6 +310,7 @@ class ActivityMetricsLogger { if (!isAnyTransitionActive() || mLoggedTransitionStarting) { return; } + if (DEBUG_METRICS) Slog.i(TAG, "notifyTransitionStarting"); mCurrentTransitionDelayMs = calculateDelay(timestamp); mLoggedTransitionStarting = true; for (int index = stackIdReasons.size() - 1; index >= 0; index--) { @@ -292,17 +330,37 @@ class ActivityMetricsLogger { * Notifies the tracker that the visibility of an app is changing. * * @param activityRecord the app that is changing its visibility - * @param visible whether it's going to be visible or not */ - void notifyVisibilityChanged(ActivityRecord activityRecord, boolean visible) { + void notifyVisibilityChanged(ActivityRecord activityRecord) { final StackTransitionInfo info = mStackTransitionInfo.get(activityRecord.getStackId()); + if (info == null) { + return; + } + if (info.launchedActivity != activityRecord) { + return; + } + final TaskRecord t = activityRecord.getTask(); + final SomeArgs args = SomeArgs.obtain(); + args.arg1 = t; + args.arg2 = activityRecord; + mHandler.obtainMessage(MSG_CHECK_VISIBILITY, args).sendToTarget(); + } - // If we have an active transition that's waiting on a certain activity that will be - // invisible now, we'll never get onWindowsDrawn, so abort the transition if necessary. - if (info != null && !visible && info.launchedActivity == activityRecord) { - mStackTransitionInfo.remove(activityRecord.getStackId()); - if (mStackTransitionInfo.size() == 0) { - reset(true /* abort */); + private void checkVisibility(TaskRecord t, ActivityRecord r) { + synchronized (mSupervisor.mService) { + + final StackTransitionInfo info = mStackTransitionInfo.get(r.getStackId()); + + // If we have an active transition that's waiting on a certain activity that will be + // invisible now, we'll never get onWindowsDrawn, so abort the transition if necessary. + if (info != null && !t.isVisible()) { + if (DEBUG_METRICS) Slog.i(TAG, "notifyVisibilityChanged to invisible" + + " activity=" + r); + logAppTransitionCancel(info); + mStackTransitionInfo.remove(r.getStackId()); + if (mStackTransitionInfo.size() == 0) { + reset(true /* abort */); + } } } } @@ -338,6 +396,7 @@ class ActivityMetricsLogger { } private void reset(boolean abort) { + if (DEBUG_METRICS) Slog.i(TAG, "reset abort=" + abort); if (!abort && isAnyTransitionActive()) { logAppTransitionMultiEvents(); } @@ -358,7 +417,20 @@ class ActivityMetricsLogger { return (int) (timestamp - mCurrentTransitionStartTime); } + private void logAppTransitionCancel(StackTransitionInfo info) { + final int type = getTransitionType(info); + if (type == -1) { + return; + } + final LogMaker builder = new LogMaker(APP_TRANSITION_CANCELLED); + builder.setPackageName(info.launchedActivity.packageName); + builder.setType(type); + builder.addTaggedData(FIELD_CLASS_NAME, info.launchedActivity.info.name); + mMetricsLogger.write(builder); + } + private void logAppTransitionMultiEvents() { + if (DEBUG_METRICS) Slog.i(TAG, "logging transition events"); for (int index = mStackTransitionInfo.size() - 1; index >= 0; index--) { final StackTransitionInfo info = mStackTransitionInfo.valueAt(index); final int type = getTransitionType(info); diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java index be281df3a445..ee23d6328f10 100644 --- a/services/core/java/com/android/server/am/ActivityRecord.java +++ b/services/core/java/com/android/server/am/ActivityRecord.java @@ -1585,7 +1585,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo void setVisibility(boolean visible) { mWindowContainerController.setVisibility(visible, mDeferHidingClient); - mStackSupervisor.mActivityMetricsLogger.notifyVisibilityChanged(this, visible); + mStackSupervisor.mActivityMetricsLogger.notifyVisibilityChanged(this); } // TODO: Look into merging with #setVisibility() diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index b2dc3e6a8b69..795d7dde78a0 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -606,7 +606,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D public ActivityStackSupervisor(ActivityManagerService service, Looper looper) { mService = service; mHandler = new ActivityStackSupervisorHandler(looper); - mActivityMetricsLogger = new ActivityMetricsLogger(this, mService.mContext); + mActivityMetricsLogger = new ActivityMetricsLogger(this, mService.mContext, looper); mKeyguardController = new KeyguardController(service, this); } @@ -4836,9 +4836,13 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D mService.mActivityStarter.sendPowerHintForLaunchStartIfNeeded(true /* forceSend */, targetActivity); mActivityMetricsLogger.notifyActivityLaunching(); - mService.moveTaskToFrontLocked(task.taskId, 0, bOptions, true /* fromRecents */); - mActivityMetricsLogger.notifyActivityLaunched(ActivityManager.START_TASK_TO_FRONT, - targetActivity); + try { + mService.moveTaskToFrontLocked(task.taskId, 0, bOptions, + true /* fromRecents */); + } finally { + mActivityMetricsLogger.notifyActivityLaunched(START_TASK_TO_FRONT, + targetActivity); + } // If we are launching the task in the docked stack, put it into resizing mode so // the window renders full-screen with the background filling the void. Also only diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java index eadc8a6eadba..f83310954c3d 100644 --- a/services/core/java/com/android/server/am/TaskRecord.java +++ b/services/core/java/com/android/server/am/TaskRecord.java @@ -1151,6 +1151,16 @@ final class TaskRecord extends ConfigurationContainer implements TaskWindowConta return null; } + boolean isVisible() { + for (int i = mActivities.size() - 1; i >= 0; --i) { + final ActivityRecord r = mActivities.get(i); + if (r.visible) { + return true; + } + } + return false; + } + void getAllRunningVisibleActivitiesLocked(ArrayList outActivities) { if (mStack != null) { for (int activityNdx = mActivities.size() - 1; activityNdx >= 0; --activityNdx) { -- cgit v1.2.3 From 70854ebd2e1f1af3b00b9c74ae468d8c36415536 Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Mon, 4 Dec 2017 07:53:31 -0800 Subject: [AWARE] Make PeerHandle comparable/hashable Add public equals()/hash() methods to PeerHandle. Allows the handle to be used across multiple calls/sessions. (partial cherry-pick of commit 3d33d7495ffbf12966299df8359d71a6f0926e7a) (cherry-pick of commit 0d49c0dda8bfef0267d81e8490e4882e51a15af4) Bug: 68931709 Test: builds, unit test, integration test Change-Id: I87df50edb948a7afc90e496165013235ddca1e48 Merged-In: Idc59269d4275181ed6d9a793213c681dc4e98134 Merged-In: I6848acda9bfef306b8feaae6987ff18f7bc2e6ec (cherry picked from commit 4454bda052aea4087880674bb0e0f81ce2647009) --- wifi/java/android/net/wifi/aware/PeerHandle.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/wifi/java/android/net/wifi/aware/PeerHandle.java b/wifi/java/android/net/wifi/aware/PeerHandle.java index cd45c524934a..b525212ed0a8 100644 --- a/wifi/java/android/net/wifi/aware/PeerHandle.java +++ b/wifi/java/android/net/wifi/aware/PeerHandle.java @@ -32,4 +32,22 @@ public class PeerHandle { /** @hide */ public int peerId; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + + if (!(o instanceof PeerHandle)) { + return false; + } + + return peerId == ((PeerHandle) o).peerId; + } + + @Override + public int hashCode() { + return peerId; + } } -- cgit v1.2.3 From 10bb5dd7a128d0ce0be461bc3b3f9da640e64494 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Wed, 6 Dec 2017 16:27:53 -0800 Subject: Add assisted dialing properties to the framework. These properties allow the feature to be propogated from the outgoing call broadcast, to the connection, to the call, and finally to the call log as a feature. Test: no existing unit tests found. could use some pointers Bug: 35963245 Merged-In: I84343fb0cda16514c01997fd71d1e819b5b7eebb Change-Id: I086e761ada9a57dca61c3a412561ee54255d6260 (cherry picked from commit 9765e89e1ed533d844583bae5de0026452bf9e70) --- core/java/android/provider/CallLog.java | 6 ++++++ telecomm/java/android/telecom/Call.java | 12 +++++++++++- telecomm/java/android/telecom/Connection.java | 8 +++++++- telecomm/java/android/telecom/TelecomManager.java | 8 ++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java index a8acb976a637..766ad8454e6f 100644 --- a/core/java/android/provider/CallLog.java +++ b/core/java/android/provider/CallLog.java @@ -223,6 +223,12 @@ public class CallLog { /** Call was WIFI call. */ public static final int FEATURES_WIFI = 0x8; + /** + * Indicates the call underwent Assisted Dialing. + * @hide + */ + public static final Integer FEATURES_ASSISTED_DIALING_USED = 0x10; + /** * The phone number as the user entered it. *

Type: TEXT

diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index e13bd6193719..6114a20d079b 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -416,8 +416,15 @@ public final class Call { */ public static final int PROPERTY_SELF_MANAGED = 0x00000100; + /** + * Indicates the call used Assisted Dialing. + * See also {@link Connection#PROPERTY_ASSISTED_DIALING_USED} + * @hide + */ + public static final int PROPERTY_ASSISTED_DIALING_USED = 0x00000200; + //****************************************************************************************** - // Next PROPERTY value: 0x00000200 + // Next PROPERTY value: 0x00000400 //****************************************************************************************** private final String mTelecomCallId; @@ -577,6 +584,9 @@ public final class Call { if(hasProperty(properties, PROPERTY_HAS_CDMA_VOICE_PRIVACY)) { builder.append(" PROPERTY_HAS_CDMA_VOICE_PRIVACY"); } + if(hasProperty(properties, PROPERTY_ASSISTED_DIALING_USED)) { + builder.append(" PROPERTY_ASSISTED_DIALING_USED"); + } builder.append("]"); return builder.toString(); } diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index ef760a053c54..abbf5df9d07a 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -401,8 +401,14 @@ public abstract class Connection extends Conferenceable { @TestApi public static final int PROPERTY_IS_RTT = 1 << 8; + /** + * Set by the framework to indicate that a connection is using assisted dialing. + * @hide + */ + public static final int PROPERTY_ASSISTED_DIALING_USED = 1 << 9; + //********************************************************************************************** - // Next PROPERTY value: 1<<9 + // Next PROPERTY value: 1<<10 //********************************************************************************************** /** diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index b1eedf5cad4b..53ebbe47d23a 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -581,6 +581,14 @@ public class TelecomManager { public static final String EXTRA_CALL_BACK_INTENT = "android.telecom.extra.CALL_BACK_INTENT"; + /** + * The boolean indicated by this extra controls whether or not a call is eligible to undergo + * assisted dialing. This extra is stored under {@link #EXTRA_OUTGOING_CALL_EXTRAS}. + * @hide + */ + public static final String EXTRA_USE_ASSISTED_DIALING = + "android.telecom.extra.USE_ASSISTED_DIALING"; + /** * The following 4 constants define how properties such as phone numbers and names are * displayed to the user. -- cgit v1.2.3 From 133adf7c549502a51a1f6b1f125911e11e002b74 Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Mon, 9 Oct 2017 10:27:44 -0700 Subject: [PASSPOINT] Add metrics to determine deployment/avail of Passpoint Add metrics which will help determine Passpoint availability in the wild. The metrics measure the percentage of time a Passpoint network is visible to user - by collecting historgrams of observations per scan result. (cherry-pick of commit c462a7a4c15ca7c35002c84de4ff115be12b28a1) Bug: 66951771 Test: unit test Merged-In: I8c91f490a533f90a4f0630e1cb461e1d2643358b Change-Id: I08367ab2c45900c76b65cea980a9b4a335b3dcdb (cherry picked from commit 8c88b5e2e17fdee5eb192c4bb388472878b79811) --- proto/src/wifi.proto | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/proto/src/wifi.proto b/proto/src/wifi.proto index 54eba2b332a4..ee0c04331da2 100644 --- a/proto/src/wifi.proto +++ b/proto/src/wifi.proto @@ -336,6 +336,34 @@ message WifiLog { // Count of connection attempts that were initiated unsuccessfully optional int32 num_open_network_connect_message_failed_to_send = 82; + + // Histogram counting instances of scans with N many HotSpot 2.0 R1 APs + repeated NumConnectableNetworksBucket observed_hotspot_r1_aps_in_scan_histogram = 83; + + // Histogram counting instances of scans with N many HotSpot 2.0 R2 APs + repeated NumConnectableNetworksBucket observed_hotspot_r2_aps_in_scan_histogram = 84; + + // Histogram counting instances of scans with N many unique HotSpot 2.0 R1 ESS. + // Where ESS is defined as the (HESSID, ANQP Domain ID), (SSID, ANQP Domain ID) or + // (SSID, BSSID) tuple depending on AP configuration (in the above priority + // order). + repeated NumConnectableNetworksBucket observed_hotspot_r1_ess_in_scan_histogram = 85; + + // Histogram counting instances of scans with N many unique HotSpot 2.0 R2 ESS. + // Where ESS is defined as the (HESSID, ANQP Domain ID), (SSID, ANQP Domain ID) or + // (SSID, BSSID) tuple depending on AP configuration (in the above priority + // order). + repeated NumConnectableNetworksBucket observed_hotspot_r2_ess_in_scan_histogram = 86; + + // Histogram counting number of HotSpot 2.0 R1 APs per observed ESS in a scan + // (one value added per unique ESS - potentially multiple counts per single + // scan!) + repeated NumConnectableNetworksBucket observed_hotspot_r1_aps_per_ess_in_scan_histogram = 87; + + // Histogram counting number of HotSpot 2.0 R2 APs per observed ESS in a scan + // (one value added per unique ESS - potentially multiple counts per single + // scan!) + repeated NumConnectableNetworksBucket observed_hotspot_r2_aps_per_ess_in_scan_histogram = 88; } // Information that gets logged for every WiFi connection. -- cgit v1.2.3 From bb3b8176eb1c4bf2175d12946b63e612295fa71d Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Mon, 30 Oct 2017 11:09:25 -0700 Subject: Turn default gradient into solid black Test: visual Bug: 66957450 Change-Id: I6a34a35912e4dd4594565f88636ce89689d26f2f (cherry picked from commit e7476addecb4fec6abd08cfb7aa27c473ce5c1f0) (cherry picked from commit 12dad0c4fc5fc8f0988dca0fffd2d26f2cb04195) --- core/java/com/android/internal/colorextraction/types/Tonal.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/java/com/android/internal/colorextraction/types/Tonal.java b/core/java/com/android/internal/colorextraction/types/Tonal.java index e6ef10b3b7c6..71baaf177eac 100644 --- a/core/java/com/android/internal/colorextraction/types/Tonal.java +++ b/core/java/com/android/internal/colorextraction/types/Tonal.java @@ -51,9 +51,11 @@ public class Tonal implements ExtractionType { private static final boolean DEBUG = true; + public static final int THRESHOLD_COLOR_LIGHT = 0xffe0e0e0; public static final int MAIN_COLOR_LIGHT = 0xffe0e0e0; public static final int SECONDARY_COLOR_LIGHT = 0xff9e9e9e; - public static final int MAIN_COLOR_DARK = 0xff212121; + public static final int THRESHOLD_COLOR_DARK = 0xff212121; + public static final int MAIN_COLOR_DARK = 0xff000000; public static final int SECONDARY_COLOR_DARK = 0xff000000; private final TonalPalette mGreyPalette; @@ -197,12 +199,12 @@ public class Tonal implements ExtractionType { // light fallback or darker than our dark fallback. ColorUtils.colorToHSL(mainColor, mTmpHSL); final float mainLuminosity = mTmpHSL[2]; - ColorUtils.colorToHSL(MAIN_COLOR_LIGHT, mTmpHSL); + ColorUtils.colorToHSL(THRESHOLD_COLOR_LIGHT, mTmpHSL); final float lightLuminosity = mTmpHSL[2]; if (mainLuminosity > lightLuminosity) { return false; } - ColorUtils.colorToHSL(MAIN_COLOR_DARK, mTmpHSL); + ColorUtils.colorToHSL(THRESHOLD_COLOR_DARK, mTmpHSL); final float darkLuminosity = mTmpHSL[2]; if (mainLuminosity < darkLuminosity) { return false; -- cgit v1.2.3 From dda9bbf3d137a2eb7dbc4b7b7907a916bd6dc1e0 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Thu, 14 Dec 2017 14:06:15 -0800 Subject: Add support for notification of LTE to WIFI handover for video calls. Test: Manual, added new unit tests. Bug: 65490850 Change-Id: I7afbd2d1e783aae425ac3fe640a6e92d1600b9a5 (cherry picked from commit 5ce0d3a6b590c59855f9a8091e62d7e8361d0dd8) --- telephony/java/android/telephony/CarrierConfigManager.java | 14 ++++++++++++++ telephony/java/android/telephony/TelephonyManager.java | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 450a0c66d2e9..53e506bd0004 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -330,6 +330,19 @@ public class CarrierConfigManager { public static final String KEY_NOTIFY_HANDOVER_VIDEO_FROM_WIFI_TO_LTE_BOOL = "notify_handover_video_from_wifi_to_lte_bool"; + /** + * Flag specifying whether the carrier wants to notify the user when a VT call has been handed + * over from LTE to WIFI. + *

+ * The handover notification is sent as a + * {@link TelephonyManager#EVENT_HANDOVER_VIDEO_FROM_LTE_TO_WIFI} + * {@link android.telecom.Connection} event, which an {@link android.telecom.InCallService} + * should use to trigger the display of a user-facing message. + * @hide + */ + public static final String KEY_NOTIFY_HANDOVER_VIDEO_FROM_LTE_TO_WIFI_BOOL = + "notify_handover_video_from_lte_to_wifi_bool"; + /** * Flag specifying whether the carrier supports downgrading a video call (tx, rx or tx/rx) * directly to an audio call. @@ -1594,6 +1607,7 @@ public class CarrierConfigManager { sDefaults.putBoolean(KEY_CARRIER_VOLTE_AVAILABLE_BOOL, false); sDefaults.putBoolean(KEY_CARRIER_VT_AVAILABLE_BOOL, false); sDefaults.putBoolean(KEY_NOTIFY_HANDOVER_VIDEO_FROM_WIFI_TO_LTE_BOOL, false); + sDefaults.putBoolean(KEY_NOTIFY_HANDOVER_VIDEO_FROM_LTE_TO_WIFI_BOOL, false); sDefaults.putBoolean(KEY_SUPPORT_DOWNGRADE_VT_TO_AUDIO_BOOL, true); sDefaults.putString(KEY_DEFAULT_VM_NUMBER_STRING, ""); sDefaults.putBoolean(KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, true); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 011d76b0a545..c9afb9f9ea31 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -826,6 +826,17 @@ public class TelephonyManager { public static final String EVENT_HANDOVER_VIDEO_FROM_WIFI_TO_LTE = "android.telephony.event.EVENT_HANDOVER_VIDEO_FROM_WIFI_TO_LTE"; + /** + * {@link android.telecom.Connection} event used to indicate that an IMS call has be + * successfully handed over from LTE to WIFI. + *

+ * Sent via {@link android.telecom.Connection#sendConnectionEvent(String, Bundle)}. + * The {@link Bundle} parameter is expected to be null when this connection event is used. + * @hide + */ + public static final String EVENT_HANDOVER_VIDEO_FROM_LTE_TO_WIFI = + "android.telephony.event.EVENT_HANDOVER_VIDEO_FROM_LTE_TO_WIFI"; + /** * {@link android.telecom.Connection} event used to indicate that an IMS call failed to be * handed over from LTE to WIFI. -- cgit v1.2.3 From d88103dbae9b97ba526e4b7813a943904af45d04 Mon Sep 17 00:00:00 2001 From: jackqdyulei Date: Tue, 24 Oct 2017 16:32:58 -0700 Subject: Add metric for anomaly detection ACTION_APP_STOP_AND_BACKGROUND_CHECK FIELD_ANOMALY_ACTION_TYPE ANOMALY_TYPE_WAKELOCK ANOMALY_TYPE_WAKEUP_ALARM ANOMALY_TYPE_UNOPTIMIZED_BT Bug: 68215016 Test: Build Merged-In: I66f0465a3b89713060948af31c370e9ac894e0ff Change-Id: I66f0465a3b89713060948af31c370e9ac894e0ff (cherry picked from commit 7d36b386902117eaec68679499342e35fa7743e9) --- proto/src/metrics_constants.proto | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto index cbd2f75e46d5..cb7d8730e9bf 100644 --- a/proto/src/metrics_constants.proto +++ b/proto/src/metrics_constants.proto @@ -4573,6 +4573,31 @@ message MetricsEvent { // ---- End O-MR1 Constants, all O-MR1 constants go above this line ---- + // ACTION: Stop an app and turn on background check + // CATEGORY: SETTINGS + // OS: P + ACTION_APP_STOP_AND_BACKGROUND_CHECK = 1233; + + // FIELD: The action type for each anomaly + // CATEGORY: SETTINGS + // OS: P + FIELD_ANOMALY_ACTION_TYPE = 1234; + + // OPEN: Settings -> Battery -> Wakelock anomaly + // CATEGORY: SETTINGS + // OS: P + ANOMALY_TYPE_WAKELOCK = 1235; + + // OPEN: Settings -> Battery -> Wakeup alarm anomaly + // CATEGORY: SETTINGS + // OS: P + ANOMALY_TYPE_WAKEUP_ALARM = 1236; + + // OPEN: Settings -> Battery -> Unoptimized bt anomaly + // CATEGORY: SETTINGS + // OS: P + ANOMALY_TYPE_UNOPTIMIZED_BT = 1237; + // Add new aosp constants above this line. // END OF AOSP CONSTANTS } -- cgit v1.2.3 From 7cad2e507fecb502d8bac4e1194bf3153f3c74e6 Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Thu, 18 Jan 2018 15:21:36 -0800 Subject: Fixed AUTOFILL_UI_LATENCY metric. This metric was using the RESERVED_FOR_LOGBUILDER_COUNTER and hence was not being picked up. Bug: 71863561 Fixes: 72175011 Test: adb shell logcat -b events | grep sysui | grep 1136 Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases Change-Id: I34f701ff5336a413477fd14172d16d8d1e5403ad (cherry picked from commit b659adb3f3d13049ca1c08fcec2d419ffd7a386b) --- proto/src/metrics_constants.proto | 6 +++++- services/autofill/java/com/android/server/autofill/Session.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto index cb7d8730e9bf..a27515c0266d 100644 --- a/proto/src/metrics_constants.proto +++ b/proto/src/metrics_constants.proto @@ -4532,7 +4532,8 @@ message MetricsEvent { // OS: O MR AUTOFILL_SERVICE_DISABLED_SELF = 1135; - // Counter showing how long it took (in ms) to show the autofill UI after a field was focused + // Reports how long it took to show the autofill UI after a field was focused + // Tag FIELD_AUTOFILL_DURATION: Duration in ms // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request // Package: Package of the autofill service // OS: O MR @@ -4571,6 +4572,9 @@ message MetricsEvent { // logged when we cancel an app transition. APP_TRANSITION_CANCELLED = 1144; + // Tag of a field representing a duration on autofill-related metrics. + FIELD_AUTOFILL_DURATION = 1145; + // ---- End O-MR1 Constants, all O-MR1 constants go above this line ---- // ACTION: Stop an app and turn on background check diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 905db6734a73..de2950dd5985 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -1387,7 +1387,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState mUiLatencyHistory.log(historyLog.toString()); final LogMaker metricsLog = newLogMaker(MetricsEvent.AUTOFILL_UI_LATENCY) - .setCounterValue((int) duration); + .addTaggedData(MetricsEvent.FIELD_AUTOFILL_DURATION, duration); mMetricsLogger.write(metricsLog); } } -- cgit v1.2.3 From 433354bec74b8458f1dd03ac30543ffd0ff6b68f Mon Sep 17 00:00:00 2001 From: Michael Plass Date: Fri, 6 Oct 2017 10:29:51 -0700 Subject: Metrics wifi.proto for connected wifi score (cherry picked from commit bb367b689605d0ca3641984b4d59bbe13e6861df) Bug: 67429363 Bug: 71708302 Test: Wifi unit tests Change-Id: I2993a02e7b3199c2b50dc2ddb7704fc5b6364025 Merged-In: I315613b8ea3aa1d02810ae376c76083d80865d31 (cherry picked from commit 1b8fe6ef73cdeff9ad7faf6bf695657c9b8df7ff) --- proto/src/wifi.proto | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/proto/src/wifi.proto b/proto/src/wifi.proto index ee0c04331da2..9d25055d6d5a 100644 --- a/proto/src/wifi.proto +++ b/proto/src/wifi.proto @@ -673,6 +673,10 @@ message StaEvent { // Framework initiated disconnect. Sometimes generated to give an extra reason for a disconnect // Should typically be followed by a NETWORK_DISCONNECTION_EVENT with a local_gen = true TYPE_FRAMEWORK_DISCONNECT = 15; + + // The NetworkAgent score for wifi has changed in a way that may impact + // connectivity + TYPE_SCORE_BREACH = 16; } enum FrameworkDisconnectReason { @@ -784,6 +788,9 @@ message StaEvent { // Authentication failure reason, as reported by WifiManager (calculated from state & deauth code) optional AuthFailureReason auth_failure_reason = 13 [default = AUTH_FAILURE_UNKNOWN]; + + // NetworkAgent score of connected wifi + optional int32 last_score = 14 [default = -1]; } // Wi-Fi Aware metrics -- cgit v1.2.3 From 4525320403bfb85eb1629f9b43718970491f98ed Mon Sep 17 00:00:00 2001 From: Svet Ganov Date: Wed, 6 Dec 2017 23:45:38 -0800 Subject: Use correct user id for permission check for instant foreground service Test: cts-tradefed run cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.EphemeralTest#testStartForegrondService bug: 68275646 Bug: 71366502 Change-Id: I196522c49ae8a7e0ec07bf631f04bae51e96db5b cherry pick from: https://android-review.googlesource.com/c/platform/frameworks/base/+/559340 (cherry picked from commit e32c238ce76151dd6221e6762f841c8f721c45f7) Change-Id: Idfeae038d42b9dee9f6f57203f2bdb0764f51877 (cherry picked from commit d967610fb865ce2ac5f8c379a13e21feee98fbe0) --- services/core/java/com/android/server/am/ActiveServices.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index 90ad8a5d0131..9d823a726afe 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -1043,8 +1043,8 @@ public final class ActiveServices { try { if (AppGlobals.getPackageManager().checkPermission( android.Manifest.permission.INSTANT_APP_FOREGROUND_SERVICE, - r.appInfo.packageName, - r.appInfo.uid) != PackageManager.PERMISSION_GRANTED) { + r.appInfo.packageName, UserHandle.getUserId(r.appInfo.uid)) + != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Instant app " + r.appInfo.packageName + " does not have permission to create foreground" + "services"); -- cgit v1.2.3 From b796cd32a45bcc0763c50cc1a0cc8236153dcea3 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Thu, 7 Dec 2017 22:56:03 -0800 Subject: Fix bad type for txPower in PeriodicAdvertisingReport serialization Bug: 69634768 Test: compilation Change-Id: Icedfbaf1ba933637e935ada0fd98aea42c73f2b2 Merged-In: Icedfbaf1ba933637e935ada0fd98aea42c73f2b2 (cherry picked from commit 5332988c62e2f2ededb29ac3bfc4774551fe956f) --- core/java/android/bluetooth/le/PeriodicAdvertisingReport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/bluetooth/le/PeriodicAdvertisingReport.java b/core/java/android/bluetooth/le/PeriodicAdvertisingReport.java index 51b93cbd64dc..6fc8d553946e 100644 --- a/core/java/android/bluetooth/le/PeriodicAdvertisingReport.java +++ b/core/java/android/bluetooth/le/PeriodicAdvertisingReport.java @@ -71,7 +71,7 @@ public final class PeriodicAdvertisingReport implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(syncHandle); - dest.writeLong(txPower); + dest.writeInt(txPower); dest.writeInt(rssi); dest.writeInt(dataStatus); if (data != null) { -- cgit v1.2.3 From 47ebfaa2196aaf4fbeeec34f1a1c5be415cf041b Mon Sep 17 00:00:00 2001 From: Shuzhen Wang Date: Fri, 8 Dec 2017 12:16:49 -0800 Subject: OutputConfiguration: Fix missing mIsShared in parcel read Test: Camera CTS Bug: 69683251 Merged-In: I7ea4aa8ed4baa5a5e7d25a0073361d827ba86c13 Change-Id: I7ea4aa8ed4baa5a5e7d25a0073361d827ba86c13 (cherry picked from commit 4304a02ac990c1af5fb8f479bdd2b04c8af4fddb) --- core/java/android/hardware/camera2/params/OutputConfiguration.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/java/android/hardware/camera2/params/OutputConfiguration.java b/core/java/android/hardware/camera2/params/OutputConfiguration.java index 2b317d679d1c..05c4dc378890 100644 --- a/core/java/android/hardware/camera2/params/OutputConfiguration.java +++ b/core/java/android/hardware/camera2/params/OutputConfiguration.java @@ -409,6 +409,7 @@ public final class OutputConfiguration implements Parcelable { this.mConfiguredSize = other.mConfiguredSize; this.mConfiguredGenerationId = other.mConfiguredGenerationId; this.mIsDeferredConfig = other.mIsDeferredConfig; + this.mIsShared = other.mIsShared; } /** @@ -421,6 +422,7 @@ public final class OutputConfiguration implements Parcelable { int width = source.readInt(); int height = source.readInt(); boolean isDeferred = source.readInt() == 1; + boolean isShared = source.readInt() == 1; ArrayList surfaces = new ArrayList(); source.readTypedList(surfaces, Surface.CREATOR); @@ -431,6 +433,7 @@ public final class OutputConfiguration implements Parcelable { mSurfaces = surfaces; mConfiguredSize = new Size(width, height); mIsDeferredConfig = isDeferred; + mIsShared = isShared; mSurfaces = surfaces; if (mSurfaces.size() > 0) { mSurfaceType = SURFACE_TYPE_UNKNOWN; -- cgit v1.2.3 From a2a36541f0b3603335e74da0a8d2b6a9d5bcec3f Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Thu, 9 Nov 2017 17:12:17 -0800 Subject: Check for null-terminator in ResStringPool::string8At All other stringAt methods check for null termination. Be consistent so that upper levels don't end up with huge corrupt strings. Bug: 62537081 Test: none Change-Id: I17bdfb0c1e34507b66c6cad651bbdb12c5d4c417 (cherry picked from commit 3d35a0ea307693a97583a61973e729a5e7db2687) (cherry picked from commit 97f8cb01149b35b1832c7f9efe85ff19edf1083e) (cherry picked from commit 5ec65ae909a85d13d03c030be357c8c14a50d306) --- libs/androidfw/ResourceTypes.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index 0782269d7de1..733ffb180b3b 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -813,7 +813,13 @@ const char* ResStringPool::string8At(size_t idx, size_t* outLen) const *outLen = encLen; if ((uint32_t)(str+encLen-strings) < mStringPoolSize) { - return (const char*)str; + // Reject malformed (non null-terminated) strings + if (str[encLen] != 0x00) { + ALOGW("Bad string block: string #%d is not null-terminated", + (int)idx); + return NULL; + } + return (const char*)str; } else { ALOGW("Bad string block: string #%d extends to %d, past end at %d\n", (int)idx, (int)(str+encLen-strings), (int)mStringPoolSize); -- cgit v1.2.3 From 0b57631939f5824afef06517df723d2e766e0159 Mon Sep 17 00:00:00 2001 From: Adam Vartanian Date: Wed, 31 Jan 2018 11:05:10 +0000 Subject: Adjust URI host parsing to stop on \ character. The WHATWG URL parsing algorithm [1] used by browsers says that for "special" URL schemes (which is basically all commonly-used hierarchical schemes, including http, https, ftp, and file), the host portion ends if a \ character is seen, whereas this class previously continued to consider characters part of the hostname. This meant that a malicious URL could be seen as having a "safe" host when viewed by an app but navigate to a different host when passed to a browser. [1] https://url.spec.whatwg.org/#host-state Bug: 71360761 Test: vogar frameworks/base/core/tests/coretests/src/android/net/UriTest.java (on NYC branch) Test: cts -m CtsNetTestCases (on NYC branch) Change-Id: Id53f7054d1be8d59bbcc7e219159e59a2425106e (cherry picked from commit fa3afbd0e7a9a0d8fc8c55ceefdb4ddf9d0115af) --- core/java/android/net/Uri.java | 8 ++++++++ core/tests/coretests/src/android/net/UriTest.java | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/core/java/android/net/Uri.java b/core/java/android/net/Uri.java index 9edcc0e9b8d4..5ca3a4106a2d 100644 --- a/core/java/android/net/Uri.java +++ b/core/java/android/net/Uri.java @@ -720,6 +720,10 @@ public abstract class Uri implements Parcelable, Comparable { LOOP: while (end < length) { switch (uriString.charAt(end)) { case '/': // Start of path + case '\\':// Start of path + // Per http://url.spec.whatwg.org/#host-state, the \ character + // is treated as if it were a / character when encountered in a + // host case '?': // Start of query case '#': // Start of fragment break LOOP; @@ -758,6 +762,10 @@ public abstract class Uri implements Parcelable, Comparable { case '#': // Start of fragment return ""; // Empty path. case '/': // Start of path! + case '\\':// Start of path! + // Per http://url.spec.whatwg.org/#host-state, the \ character + // is treated as if it were a / character when encountered in a + // host break LOOP; } pathStart++; diff --git a/core/tests/coretests/src/android/net/UriTest.java b/core/tests/coretests/src/android/net/UriTest.java index 27b7f9e185bb..ea0347d67ad7 100644 --- a/core/tests/coretests/src/android/net/UriTest.java +++ b/core/tests/coretests/src/android/net/UriTest.java @@ -192,6 +192,12 @@ public class UriTest extends TestCase { assertEquals("a:a@example.com:a@example2.com", uri.getAuthority()); assertEquals("example2.com", uri.getHost()); assertEquals(-1, uri.getPort()); + assertEquals("/path", uri.getPath()); + + uri = Uri.parse("http://a.foo.com\\.example.com/path"); + assertEquals("a.foo.com", uri.getHost()); + assertEquals(-1, uri.getPort()); + assertEquals("\\.example.com/path", uri.getPath()); } @SmallTest -- cgit v1.2.3 From a4e80ee2cdae43fb92d3560924bce5e33cdb9c4c Mon Sep 17 00:00:00 2001 From: Daniel Nishi Date: Thu, 14 Sep 2017 17:10:00 -0700 Subject: Update diskstats to break out code & data. This updates both the text-based diskstats and the proto-based diskstats to both have both an aggregated and line-itemed view of app sizes. Formerly, the code and data sizes were rolled up into the same category and now they are separated. Bug: 63908720 Test: FrameworksServicesTest passes Merged-In: I1434327ffde6ad1f31243218c5201a80f9725a63 (cherry picked from commit b6cc838142d2390eaec99670bb6caf6bee0ec96f) (cherry picked from commit 41a5ae86f1d51204995af617ef3d1f31b178a618) Change-Id: I0d21ecc0ded5d715e3b5a478e78de2ba1f7e9ec2 --- core/proto/android/service/diskstats.proto | 8 ++++++-- .../core/java/com/android/server/DiskStatsService.java | 16 +++++++++++++--- .../java/com/android/server/storage/AppCollector.java | 2 +- .../com/android/server/storage/DiskStatsFileLogger.java | 14 ++++++++++++-- .../server/storage/DiskStatsLoggingServiceTest.java | 4 +++- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/core/proto/android/service/diskstats.proto b/core/proto/android/service/diskstats.proto index 4d865264d19e..4057e45430fe 100644 --- a/core/proto/android/service/diskstats.proto +++ b/core/proto/android/service/diskstats.proto @@ -47,7 +47,7 @@ message DiskStatsServiceDumpProto { } message DiskStatsCachedValuesProto { - // Total app data size, in kilobytes + // Total app code size, in kilobytes int64 agg_apps_size = 1; // Total app cache size, in kilobytes int64 agg_apps_cache_size = 2; @@ -65,15 +65,19 @@ message DiskStatsCachedValuesProto { int64 other_size = 8; // Sizes of individual packages repeated DiskStatsAppSizesProto app_sizes = 9; + // Total app data size, in kilobytes + int64 agg_apps_data_size = 10; } message DiskStatsAppSizesProto { // Name of the package string package_name = 1; - // App's data size in kilobytes + // App's code size in kilobytes int64 app_size = 2; // App's cache size in kilobytes int64 cache_size = 3; + // App's data size in kilobytes + int64 app_data_size = 4; } message DiskStatsFreeSpaceProto { diff --git a/services/core/java/com/android/server/DiskStatsService.java b/services/core/java/com/android/server/DiskStatsService.java index 800081e51c9a..2d2c6b0bc8b3 100644 --- a/services/core/java/com/android/server/DiskStatsService.java +++ b/services/core/java/com/android/server/DiskStatsService.java @@ -202,6 +202,8 @@ public class DiskStatsService extends Binder { JSONObject json = new JSONObject(jsonString); pw.print("App Size: "); pw.println(json.getLong(DiskStatsFileLogger.APP_SIZE_AGG_KEY)); + pw.print("App Data Size: "); + pw.println(json.getLong(DiskStatsFileLogger.APP_DATA_SIZE_AGG_KEY)); pw.print("App Cache Size: "); pw.println(json.getLong(DiskStatsFileLogger.APP_CACHE_AGG_KEY)); pw.print("Photos Size: "); @@ -220,6 +222,8 @@ public class DiskStatsService extends Binder { pw.println(json.getJSONArray(DiskStatsFileLogger.PACKAGE_NAMES_KEY)); pw.print("App Sizes: "); pw.println(json.getJSONArray(DiskStatsFileLogger.APP_SIZES_KEY)); + pw.print("App Data Sizes: "); + pw.println(json.getJSONArray(DiskStatsFileLogger.APP_DATA_KEY)); pw.print("Cache Sizes: "); pw.println(json.getJSONArray(DiskStatsFileLogger.APP_CACHES_KEY)); } catch (IOException | JSONException e) { @@ -235,6 +239,8 @@ public class DiskStatsService extends Binder { proto.write(DiskStatsCachedValuesProto.AGG_APPS_SIZE, json.getLong(DiskStatsFileLogger.APP_SIZE_AGG_KEY)); + proto.write(DiskStatsCachedValuesProto.AGG_APPS_DATA_SIZE, + json.getLong(DiskStatsFileLogger.APP_DATA_SIZE_AGG_KEY)); proto.write(DiskStatsCachedValuesProto.AGG_APPS_CACHE_SIZE, json.getLong(DiskStatsFileLogger.APP_CACHE_AGG_KEY)); proto.write(DiskStatsCachedValuesProto.PHOTOS_SIZE, @@ -252,22 +258,26 @@ public class DiskStatsService extends Binder { JSONArray packageNamesArray = json.getJSONArray(DiskStatsFileLogger.PACKAGE_NAMES_KEY); JSONArray appSizesArray = json.getJSONArray(DiskStatsFileLogger.APP_SIZES_KEY); + JSONArray appDataSizesArray = json.getJSONArray(DiskStatsFileLogger.APP_DATA_KEY); JSONArray cacheSizesArray = json.getJSONArray(DiskStatsFileLogger.APP_CACHES_KEY); final int len = packageNamesArray.length(); - if (len == appSizesArray.length() && len == cacheSizesArray.length()) { + if (len == appSizesArray.length() + && len == appDataSizesArray.length() + && len == cacheSizesArray.length()) { for (int i = 0; i < len; i++) { long packageToken = proto.start(DiskStatsCachedValuesProto.APP_SIZES); proto.write(DiskStatsAppSizesProto.PACKAGE_NAME, packageNamesArray.getString(i)); proto.write(DiskStatsAppSizesProto.APP_SIZE, appSizesArray.getLong(i)); + proto.write(DiskStatsAppSizesProto.APP_DATA_SIZE, appDataSizesArray.getLong(i)); proto.write(DiskStatsAppSizesProto.CACHE_SIZE, cacheSizesArray.getLong(i)); proto.end(packageToken); } } else { - Slog.wtf(TAG, "Sizes of packageNamesArray, appSizesArray and cacheSizesArray " - + "are not the same"); + Slog.wtf(TAG, "Sizes of packageNamesArray, appSizesArray, appDataSizesArray " + + " and cacheSizesArray are not the same"); } proto.end(cachedValuesToken); diff --git a/services/core/java/com/android/server/storage/AppCollector.java b/services/core/java/com/android/server/storage/AppCollector.java index 03b754f777b3..0b51f9cc7b7c 100644 --- a/services/core/java/com/android/server/storage/AppCollector.java +++ b/services/core/java/com/android/server/storage/AppCollector.java @@ -135,7 +135,7 @@ public class AppCollector { PackageStats packageStats = new PackageStats(app.packageName, user.id); packageStats.cacheSize = storageStats.getCacheBytes(); - packageStats.codeSize = storageStats.getCodeBytes(); + packageStats.codeSize = storageStats.getAppBytes(); packageStats.dataSize = storageStats.getDataBytes(); stats.add(packageStats); } catch (NameNotFoundException | IOException e) { diff --git a/services/core/java/com/android/server/storage/DiskStatsFileLogger.java b/services/core/java/com/android/server/storage/DiskStatsFileLogger.java index 0094ab5559d8..1db3ec4ca506 100644 --- a/services/core/java/com/android/server/storage/DiskStatsFileLogger.java +++ b/services/core/java/com/android/server/storage/DiskStatsFileLogger.java @@ -56,10 +56,12 @@ public class DiskStatsFileLogger { public static final String SYSTEM_KEY = "systemSize"; public static final String MISC_KEY = "otherSize"; public static final String APP_SIZE_AGG_KEY = "appSize"; + public static final String APP_DATA_SIZE_AGG_KEY = "appDataSize"; public static final String APP_CACHE_AGG_KEY = "cacheSize"; public static final String PACKAGE_NAMES_KEY = "packageNames"; public static final String APP_SIZES_KEY = "appSizes"; public static final String APP_CACHES_KEY = "cacheSizes"; + public static final String APP_DATA_KEY = "appDataSizes"; public static final String LAST_QUERY_TIMESTAMP_KEY = "queryTime"; private MeasurementResult mResult; @@ -114,31 +116,39 @@ public class DiskStatsFileLogger { private void addAppsToJson(JSONObject json) throws JSONException { JSONArray names = new JSONArray(); JSONArray appSizeList = new JSONArray(); + JSONArray appDataSizeList = new JSONArray(); JSONArray cacheSizeList = new JSONArray(); long appSizeSum = 0L; + long appDataSizeSum = 0L; long cacheSizeSum = 0L; boolean isExternal = Environment.isExternalStorageEmulated(); for (Map.Entry entry : filterOnlyPrimaryUser().entrySet()) { PackageStats stat = entry.getValue(); - long appSize = stat.codeSize + stat.dataSize; + long appSize = stat.codeSize; + long appDataSize = stat.dataSize; long cacheSize = stat.cacheSize; if (isExternal) { - appSize += stat.externalCodeSize + stat.externalDataSize; + appSize += stat.externalCodeSize; + appDataSize += stat.externalDataSize; cacheSize += stat.externalCacheSize; } appSizeSum += appSize; + appDataSizeSum += appDataSize; cacheSizeSum += cacheSize; names.put(stat.packageName); appSizeList.put(appSize); + appDataSizeList.put(appDataSize); cacheSizeList.put(cacheSize); } json.put(PACKAGE_NAMES_KEY, names); json.put(APP_SIZES_KEY, appSizeList); json.put(APP_CACHES_KEY, cacheSizeList); + json.put(APP_DATA_KEY, appDataSizeList); json.put(APP_SIZE_AGG_KEY, appSizeSum); json.put(APP_CACHE_AGG_KEY, cacheSizeSum); + json.put(APP_DATA_SIZE_AGG_KEY, appDataSizeSum); } /** diff --git a/services/tests/servicestests/src/com/android/server/storage/DiskStatsLoggingServiceTest.java b/services/tests/servicestests/src/com/android/server/storage/DiskStatsLoggingServiceTest.java index 375edf3cb5ae..b647b99df894 100644 --- a/services/tests/servicestests/src/com/android/server/storage/DiskStatsLoggingServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/storage/DiskStatsLoggingServiceTest.java @@ -149,11 +149,13 @@ public class DiskStatsLoggingServiceTest extends AndroidTestCase { assertThat(json.getLong(DiskStatsFileLogger.DOWNLOADS_KEY)).isEqualTo(3L); assertThat(json.getLong(DiskStatsFileLogger.SYSTEM_KEY)).isEqualTo(10L); assertThat(json.getLong(DiskStatsFileLogger.MISC_KEY)).isEqualTo(7L); - assertThat(json.getLong(DiskStatsFileLogger.APP_SIZE_AGG_KEY)).isEqualTo(15L); + assertThat(json.getLong(DiskStatsFileLogger.APP_SIZE_AGG_KEY)).isEqualTo(10L); + assertThat(json.getLong(DiskStatsFileLogger.APP_DATA_SIZE_AGG_KEY)).isEqualTo(5L); assertThat(json.getLong(DiskStatsFileLogger.APP_CACHE_AGG_KEY)).isEqualTo(55L); assertThat( json.getJSONArray(DiskStatsFileLogger.PACKAGE_NAMES_KEY).length()).isEqualTo(1L); assertThat(json.getJSONArray(DiskStatsFileLogger.APP_SIZES_KEY).length()).isEqualTo(1L); + assertThat(json.getJSONArray(DiskStatsFileLogger.APP_DATA_KEY).length()).isEqualTo(1L); assertThat(json.getJSONArray(DiskStatsFileLogger.APP_CACHES_KEY).length()).isEqualTo(1L); } -- cgit v1.2.3 From 09ba8fdffd9c8d74fdc6bfb51bcebc27fc43884a Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Wed, 7 Feb 2018 08:10:08 +0000 Subject: Fix VerifyCredentialResponse parcelling code There was an asymmetry between parcelling and unparcelling of VerifyCredentialResponse that could lead to type confusion if packed with other objects in a Parcel. Test: none Bug: 71714464 Change-Id: Icff68879e249422ccca49f2bb7db85c35b4cb353 (cherry picked from commit 54813e988884f0d604d5358569f10feda8622f46) --- core/java/com/android/internal/widget/VerifyCredentialResponse.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/java/com/android/internal/widget/VerifyCredentialResponse.java b/core/java/com/android/internal/widget/VerifyCredentialResponse.java index ad6020c0846c..7d1c70647092 100644 --- a/core/java/com/android/internal/widget/VerifyCredentialResponse.java +++ b/core/java/com/android/internal/widget/VerifyCredentialResponse.java @@ -98,6 +98,8 @@ public final class VerifyCredentialResponse implements Parcelable { if (mPayload != null) { dest.writeInt(mPayload.length); dest.writeByteArray(mPayload); + } else { + dest.writeInt(0); } } } -- cgit v1.2.3 From 5a3d2708cd2289a4882927c0e2cb0d3c21a99c02 Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Fri, 2 Feb 2018 08:07:20 -0800 Subject: [RTT] ParcelableRttResults parcel code fix ParcelableRttResults was unparceled incorrectly. Bug: 70398564 Test: exploit provided in bug no longer works Change-Id: Ifd6de547e9861bbebc399b43d0cc2899a8160813 (cherry picked from commit e1e5a2409c8bef2481e68d9329f87bb8037afa45) --- wifi/java/android/net/wifi/RttManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wifi/java/android/net/wifi/RttManager.java b/wifi/java/android/net/wifi/RttManager.java index dc5ba0cc83b5..12a8ddf9fcdc 100644 --- a/wifi/java/android/net/wifi/RttManager.java +++ b/wifi/java/android/net/wifi/RttManager.java @@ -847,8 +847,8 @@ public class RttManager { } dest.writeByte(result.LCR.id); if (result.LCR.id != (byte) 0xFF) { - dest.writeInt((byte) result.LCR.data.length); - dest.writeByte(result.LCR.id); + dest.writeByte((byte) result.LCR.data.length); + dest.writeByteArray(result.LCR.data); } dest.writeByte(result.secure ? (byte) 1 : 0); } -- cgit v1.2.3 From fef1a3e7ca5ab18ede42c5729661459fcd691e09 Mon Sep 17 00:00:00 2001 From: Chad Brubaker Date: Sat, 23 Dec 2017 20:06:44 -0800 Subject: Relax Instant Apps Settings whitelist enforcement The strict whitelist of settings for Instant Apps is leading to too much unintended breakage, remove the enforcement until better infrastructure can be added to make sure settings that should be whitelisted are. Bug: 71009655 Test: Coming in a follow up (cherry picked from commit b6108d621002d4de708ae526e7c2bc95dabef080) Change-Id: Iaa1d71331407cee86c10105c1e5668ffd0c925a1 (cherry picked from commit 26ae1d359e02fe5871177c9adfc90ca571fd0f86) --- .../providers/settings/SettingsProvider.java | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index 7d7f9ae7f19e..04be92e73b38 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -1687,18 +1687,9 @@ public class SettingsProvider extends ContentProvider { } private List getSettingsNamesLocked(int settingsType, int userId) { - boolean instantApp; - if (UserHandle.getAppId(Binder.getCallingUid()) < Process.FIRST_APPLICATION_UID) { - instantApp = false; - } else { - ApplicationInfo ai = getCallingApplicationInfoOrThrow(); - instantApp = ai.isInstantApp(); - } - if (instantApp) { - return new ArrayList(getInstantAppAccessibleSettings(settingsType)); - } else { - return mSettingsRegistry.getSettingsNamesLocked(settingsType, userId); - } + // Don't enforce the instant app whitelist for now -- its too prone to unintended breakage + // in the current form. + return mSettingsRegistry.getSettingsNamesLocked(settingsType, userId); } private void enforceSettingReadable(String settingName, int settingsType, int userId) { @@ -1711,8 +1702,10 @@ public class SettingsProvider extends ContentProvider { } if (!getInstantAppAccessibleSettings(settingsType).contains(settingName) && !getOverlayInstantAppAccessibleSettings(settingsType).contains(settingName)) { - throw new SecurityException("Setting " + settingName + " is not accessible from" - + " ephemeral package " + getCallingPackage()); + // Don't enforce the instant app whitelist for now -- its too prone to unintended + // breakage in the current form. + Slog.w(LOG_TAG, "Instant App " + ai.packageName + + " trying to access unexposed setting, this will be an error in the future."); } } -- cgit v1.2.3 From 0748edce4a8741611d0d856534ec8a5abeb920e5 Mon Sep 17 00:00:00 2001 From: Ryan Lothian Date: Mon, 4 Dec 2017 11:56:58 -0500 Subject: Handle onBindingDied in notification manager On Android, if the process containing the service being bound to crashes before the bind succeeds, the app doing the binding won't get a success or failure callback. When that happens in this code, this leaves notif. manager thinking that a binding is in progress, so it never attempts to rebind until the device is rebooted. Bug: 69064494 Test: manual, crashed listener on proc start, verified not unbound forever Change-Id: Id2082744208e21a709d9453365f282449a2e9407 (cherry picked from commit 4a86a51b672617b02994fc812e4f96342daf424e) (cherry picked from commit 1936097afc3188ed5f2bb4e7211bb404364eeb38) --- .../server/notification/ManagedServices.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/services/core/java/com/android/server/notification/ManagedServices.java b/services/core/java/com/android/server/notification/ManagedServices.java index b7b91a76ebf3..625764cea550 100644 --- a/services/core/java/com/android/server/notification/ManagedServices.java +++ b/services/core/java/com/android/server/notification/ManagedServices.java @@ -39,8 +39,10 @@ import android.content.pm.ServiceInfo; import android.content.pm.UserInfo; import android.os.Binder; import android.os.Build; +import android.os.Handler; import android.os.IBinder; import android.os.IInterface; +import android.os.Looper; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; @@ -82,6 +84,7 @@ abstract public class ManagedServices { protected final String TAG = getClass().getSimpleName(); protected final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); + private static final int ON_BINDING_DIED_REBIND_DELAY_MS = 10000; protected static final String ENABLED_SERVICES_SEPARATOR = ":"; /** @@ -101,12 +104,15 @@ abstract public class ManagedServices { private final IPackageManager mPm; private final UserManager mUm; private final Config mConfig; + private final Handler mHandler = new Handler(Looper.getMainLooper()); // contains connections to all connected services, including app services // and system services private final ArrayList mServices = new ArrayList<>(); // things that will be put into mServices as soon as they're ready private final ArrayList mServicesBinding = new ArrayList<>(); + private final ArraySet mServicesRebinding = new ArraySet<>(); + // lists the component names of all enabled (and therefore potentially connected) // app services for current profiles. private ArraySet mEnabledServicesForCurrentProfiles @@ -823,6 +829,7 @@ abstract public class ManagedServices { final String servicesBindingTag = name.toString() + "/" + userid; if (mServicesBinding.contains(servicesBindingTag)) { + Slog.v(TAG, "Not registering " + name + " as bind is already in progress"); // stop registering this thing already! we're working on it return; } @@ -871,6 +878,7 @@ abstract public class ManagedServices { boolean added = false; ManagedServiceInfo info = null; synchronized (mMutex) { + mServicesRebinding.remove(servicesBindingTag); mServicesBinding.remove(servicesBindingTag); try { mService = asInterface(binder); @@ -892,6 +900,27 @@ abstract public class ManagedServices { mServicesBinding.remove(servicesBindingTag); Slog.v(TAG, getCaption() + " connection lost: " + name); } + + @Override + public void onBindingDied(ComponentName name) { + Slog.w(TAG, getCaption() + " binding died: " + name); + synchronized (mMutex) { + mServicesBinding.remove(servicesBindingTag); + mContext.unbindService(this); + if (!mServicesRebinding.contains(servicesBindingTag)) { + mServicesRebinding.add(servicesBindingTag); + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + registerService(name, userid); + } + }, ON_BINDING_DIED_REBIND_DELAY_MS); + } else { + Slog.v(TAG, getCaption() + " not rebinding as " + + "a previous rebind attempt was made: " + name); + } + } + } }; if (!mContext.bindServiceAsUser(intent, serviceConnection, -- cgit v1.2.3 From db0f5100c9bdf8d0d26554f8e4aa3d4238757cb3 Mon Sep 17 00:00:00 2001 From: Eric Enslen Date: Wed, 7 Feb 2018 18:03:53 -0800 Subject: fix isActiveNetworkMetered with VPNs Bug: 72871435 Test: flashed and verified, also ran runtest framework-net Change-Id: I69319a7db269489053426bb2d41574180be2d43d (cherry picked from commit c81ef199549c552003e78a2b9383d5d38aaed8d0) --- services/core/java/com/android/server/ConnectivityService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 9afa825a7d37..c1801b80af0d 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -1339,7 +1339,8 @@ public class ConnectivityService extends IConnectivityManager.Stub public boolean isActiveNetworkMetered() { enforceAccessPermission(); - final NetworkCapabilities caps = getNetworkCapabilities(getActiveNetwork()); + final int uid = Binder.getCallingUid(); + final NetworkCapabilities caps = getUnfilteredActiveNetworkState(uid).networkCapabilities; if (caps != null) { return !caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED); } else { -- cgit v1.2.3