Merge "[Output Switcher] Add new fields in metrics event" into udc-qpr-dev
diff --git a/packages/SettingsLib/src/com/android/settingslib/media/MediaDevice.java b/packages/SettingsLib/src/com/android/settingslib/media/MediaDevice.java
index a9d15f3..ac93019 100644
--- a/packages/SettingsLib/src/com/android/settingslib/media/MediaDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/media/MediaDevice.java
@@ -22,6 +22,7 @@
import static android.media.MediaRoute2Info.TYPE_GROUP;
import static android.media.MediaRoute2Info.TYPE_HDMI;
import static android.media.MediaRoute2Info.TYPE_HEARING_AID;
+import static android.media.MediaRoute2Info.TYPE_REMOTE_AUDIO_VIDEO_RECEIVER;
import static android.media.MediaRoute2Info.TYPE_REMOTE_SPEAKER;
import static android.media.MediaRoute2Info.TYPE_REMOTE_TV;
import static android.media.MediaRoute2Info.TYPE_UNKNOWN;
@@ -83,7 +84,8 @@
MediaDeviceType.TYPE_FAST_PAIR_BLUETOOTH_DEVICE,
MediaDeviceType.TYPE_BLUETOOTH_DEVICE,
MediaDeviceType.TYPE_CAST_DEVICE,
- MediaDeviceType.TYPE_CAST_GROUP_DEVICE})
+ MediaDeviceType.TYPE_CAST_GROUP_DEVICE,
+ MediaDeviceType.TYPE_REMOTE_AUDIO_VIDEO_RECEIVER})
public @interface MediaDeviceType {
int TYPE_UNKNOWN = 0;
int TYPE_PHONE_DEVICE = 1;
@@ -93,6 +95,7 @@
int TYPE_BLUETOOTH_DEVICE = 5;
int TYPE_CAST_DEVICE = 6;
int TYPE_CAST_GROUP_DEVICE = 7;
+ int TYPE_REMOTE_AUDIO_VIDEO_RECEIVER = 8;
}
@Retention(RetentionPolicy.SOURCE)
@@ -161,6 +164,9 @@
case TYPE_BLE_HEADSET:
mType = MediaDeviceType.TYPE_BLUETOOTH_DEVICE;
break;
+ case TYPE_REMOTE_AUDIO_VIDEO_RECEIVER:
+ mType = MediaDeviceType.TYPE_REMOTE_AUDIO_VIDEO_RECEIVER;
+ break;
case TYPE_UNKNOWN:
case TYPE_REMOTE_TV:
case TYPE_REMOTE_SPEAKER:
diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputMetricLogger.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputMetricLogger.java
index 39d4e6e..412d1a3 100644
--- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputMetricLogger.java
+++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputMetricLogger.java
@@ -56,6 +56,7 @@
* Update the endpoints of a content switching operation.
* This method should be called before a switching operation, so the metric logger can track
* source and target devices.
+ *
* @param source the current connected media device
* @param target the target media device for content switching to
*/
@@ -72,37 +73,9 @@
/**
* Do the metric logging of content switching success.
+ *
* @param selectedDeviceType string representation of the target media device
- * @param deviceList media device list for device count updating
- */
- public void logOutputSuccess(String selectedDeviceType, List<MediaDevice> deviceList) {
- if (DEBUG) {
- Log.d(TAG, "logOutputSuccess - selected device: " + selectedDeviceType);
- }
-
- if (mSourceDevice == null && mTargetDevice == null) {
- return;
- }
-
- updateLoggingDeviceCount(deviceList);
-
- SysUiStatsLog.write(
- SysUiStatsLog.MEDIAOUTPUT_OP_SWITCH_REPORTED,
- getLoggingDeviceType(mSourceDevice, true),
- getLoggingDeviceType(mTargetDevice, false),
- SysUiStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__RESULT__OK,
- SysUiStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SUBRESULT__NO_ERROR,
- getLoggingPackageName(),
- mWiredDeviceCount,
- mConnectedBluetoothDeviceCount,
- mRemoteDeviceCount,
- mAppliedDeviceCountWithinRemoteGroup);
- }
-
- /**
- * Do the metric logging of content switching success.
- * @param selectedDeviceType string representation of the target media device
- * @param deviceItemList media item list for device count updating
+ * @param deviceItemList media item list for device count updating
*/
public void logOutputItemSuccess(String selectedDeviceType, List<MediaItem> deviceItemList) {
if (DEBUG) {
@@ -125,11 +98,14 @@
mWiredDeviceCount,
mConnectedBluetoothDeviceCount,
mRemoteDeviceCount,
- mAppliedDeviceCountWithinRemoteGroup);
+ mAppliedDeviceCountWithinRemoteGroup,
+ mTargetDevice.isSuggestedDevice(),
+ mTargetDevice.hasOngoingSession());
}
/**
* Do the metric logging of volume adjustment.
+ *
* @param source the device been adjusted
*/
public void logInteractionAdjustVolume(MediaDevice source) {
@@ -141,7 +117,8 @@
SysUiStatsLog.MEDIAOUTPUT_OP_INTERACTION_REPORT,
SysUiStatsLog.MEDIA_OUTPUT_OP_INTERACTION_REPORTED__INTERACTION_TYPE__ADJUST_VOLUME,
getInteractionDeviceType(source),
- getLoggingPackageName());
+ getLoggingPackageName(),
+ source.isSuggestedDevice());
}
/**
@@ -156,7 +133,8 @@
SysUiStatsLog.MEDIAOUTPUT_OP_INTERACTION_REPORT,
SysUiStatsLog.MEDIA_OUTPUT_OP_INTERACTION_REPORTED__INTERACTION_TYPE__STOP_CASTING,
SysUiStatsLog.MEDIA_OUTPUT_OP_INTERACTION_REPORTED__TARGET__UNKNOWN_TYPE,
- getLoggingPackageName());
+ getLoggingPackageName(),
+ /*isSuggestedDevice = */false);
}
/**
@@ -171,42 +149,15 @@
SysUiStatsLog.MEDIAOUTPUT_OP_INTERACTION_REPORT,
SysUiStatsLog.MEDIA_OUTPUT_OP_INTERACTION_REPORTED__INTERACTION_TYPE__EXPANSION,
getInteractionDeviceType(source),
- getLoggingPackageName());
- }
-
- /**
- * Do the metric logging of content switching failure.
- * @param deviceList media device list for device count updating
- * @param reason the reason of content switching failure
- */
- public void logOutputFailure(List<MediaDevice> deviceList, int reason) {
- if (DEBUG) {
- Log.e(TAG, "logRequestFailed - " + reason);
- }
-
- if (mSourceDevice == null && mTargetDevice == null) {
- return;
- }
-
- updateLoggingDeviceCount(deviceList);
-
- SysUiStatsLog.write(
- SysUiStatsLog.MEDIAOUTPUT_OP_SWITCH_REPORTED,
- getLoggingDeviceType(mSourceDevice, true),
- getLoggingDeviceType(mTargetDevice, false),
- SysUiStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__RESULT__ERROR,
- getLoggingSwitchOpSubResult(reason),
getLoggingPackageName(),
- mWiredDeviceCount,
- mConnectedBluetoothDeviceCount,
- mRemoteDeviceCount,
- mAppliedDeviceCountWithinRemoteGroup);
+ source.isSuggestedDevice());
}
/**
* Do the metric logging of content switching failure.
+ *
* @param deviceItemList media item list for device count updating
- * @param reason the reason of content switching failure
+ * @param reason the reason of content switching failure
*/
public void logOutputItemFailure(List<MediaItem> deviceItemList, int reason) {
if (DEBUG) {
@@ -229,7 +180,9 @@
mWiredDeviceCount,
mConnectedBluetoothDeviceCount,
mRemoteDeviceCount,
- mAppliedDeviceCountWithinRemoteGroup);
+ mAppliedDeviceCountWithinRemoteGroup,
+ mTargetDevice.isSuggestedDevice(),
+ mTargetDevice.hasOngoingSession());
}
private void updateLoggingDeviceCount(List<MediaDevice> deviceList) {
@@ -266,7 +219,7 @@
mWiredDeviceCount = mConnectedBluetoothDeviceCount = mRemoteDeviceCount = 0;
mAppliedDeviceCountWithinRemoteGroup = 0;
- for (MediaItem mediaItem: deviceItemList) {
+ for (MediaItem mediaItem : deviceItemList) {
if (mediaItem.getMediaDevice().isPresent()
&& mediaItem.getMediaDevice().get().isConnected()) {
switch (mediaItem.getMediaDevice().get().getDeviceType()) {
@@ -326,6 +279,10 @@
return isSourceDevice
? SysUiStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SOURCE__REMOTE_GROUP
: SysUiStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__TARGET__REMOTE_GROUP;
+ case MediaDevice.MediaDeviceType.TYPE_REMOTE_AUDIO_VIDEO_RECEIVER:
+ return isSourceDevice
+ ? SysUiStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SOURCE__AVR
+ : SysUiStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__TARGET__AVR;
default:
return isSourceDevice
? SysUiStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SOURCE__UNKNOWN_TYPE