Merge "[Output Switcher] Add new fields in metrics event" into udc-qpr-dev
This commit is contained in:
@@ -22,6 +22,7 @@ import static android.media.MediaRoute2Info.TYPE_DOCK;
|
||||
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 @@ public abstract class MediaDevice implements Comparable<MediaDevice> {
|
||||
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 @@ public abstract class MediaDevice implements Comparable<MediaDevice> {
|
||||
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 @@ public abstract class MediaDevice implements Comparable<MediaDevice> {
|
||||
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:
|
||||
|
||||
@@ -56,6 +56,7 @@ public class MediaOutputMetricLogger {
|
||||
* 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 @@ public class MediaOutputMetricLogger {
|
||||
|
||||
/**
|
||||
* 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 @@ public class MediaOutputMetricLogger {
|
||||
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 @@ public class MediaOutputMetricLogger {
|
||||
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 @@ public class MediaOutputMetricLogger {
|
||||
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 @@ public class MediaOutputMetricLogger {
|
||||
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 @@ public class MediaOutputMetricLogger {
|
||||
mWiredDeviceCount,
|
||||
mConnectedBluetoothDeviceCount,
|
||||
mRemoteDeviceCount,
|
||||
mAppliedDeviceCountWithinRemoteGroup);
|
||||
mAppliedDeviceCountWithinRemoteGroup,
|
||||
mTargetDevice.isSuggestedDevice(),
|
||||
mTargetDevice.hasOngoingSession());
|
||||
}
|
||||
|
||||
private void updateLoggingDeviceCount(List<MediaDevice> deviceList) {
|
||||
@@ -266,7 +219,7 @@ public class MediaOutputMetricLogger {
|
||||
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 @@ public class MediaOutputMetricLogger {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user