Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f52f04f authored by Robert Luo's avatar Robert Luo
Browse files

Add data collection and metrics for Media Output Switcher - 1/n

Fixes: 147792668
Test: ./out/host/linux-x86/bin/statsd_testdrive Atom_ID
Change-Id: Ia2cff1d9150811e60a9d04025d090c28eec6980c
parent c45de5ab
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import "frameworks/base/cmds/statsd/src/atom_field_options.proto";
import "frameworks/base/core/proto/android/app/enums.proto";
import "frameworks/base/core/proto/android/app/job/enums.proto";
import "frameworks/base/core/proto/android/app/settings_enums.proto";
import "frameworks/base/core/proto/android/app/media_output_enum.proto";
import "frameworks/base/core/proto/android/app/tvsettings_enums.proto";
import "frameworks/base/core/proto/android/bluetooth/a2dp/enums.proto";
import "frameworks/base/core/proto/android/bluetooth/enums.proto";
@@ -441,6 +442,8 @@ message Atom {
        EvsUsageStatsReported evs_usage_stats_reported = 274 [(module) = "evs"];
        AudioPowerUsageDataReported audio_power_usage_data_reported = 275;
        TvTunerStateChanged tv_tuner_state_changed = 276 [(module) = "framework"];
        MediaOutputOpSwitchReported mediaoutput_op_switch_reported =
            277 [(module) = "settings"];
        SdkExtensionStatus sdk_extension_status = 354;

        // StatsdStats tracks platform atoms with ids upto 500.
@@ -9864,3 +9867,40 @@ message BytesTransferByTagAndMetered {

    optional int64 tx_packets = 7;
}

/*
 * Logs when the Media Output Switcher finishes a media switch operation.
 *
 * Logged from:
 *  packages/apps/Settings/src/com/android/settings/media/MediaOutputSliceWorker.java
 */
message MediaOutputOpSwitchReported {
    // Source medium type before switching.
    optional android.app.settings.mediaoutput.MediumType source = 1;

    // Target medium type after switching.
    optional android.app.settings.mediaoutput.MediumType target = 2;

    // The result of switching.
    optional android.app.settings.mediaoutput.SwitchResult result = 3;

    // The detail code of a switching result.
    optional android.app.settings.mediaoutput.SubResult subresult = 4;

    /*
     * The package name of a pre-installed app, whose media session is being switched.
     */
    optional string media_session_package_name = 5;

    // The amount of available wired devices when a switching is being performed.
    optional int32 available_wired_device_count = 6;

    // The amount of available Bluetooth devices a switching is being performed.
    optional int32 available_bt_device_count = 7;

    // The amount of available remote devices when a switching is being performed.
    optional int32 available_remote_device_count = 8;

    // The amount of applied devices within a remote dynamic group after a switching is done.
    optional int32 applied_device_count_within_remote_group = 9;
}
+65 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package android.app.settings.mediaoutput;
option java_multiple_files = true;

/**
 * The medium type specified in an output switching operation.
 */
enum MediumType {
    UNKNOWN_TYPE = 0;
    BUILTIN_SPEAKER = 1;
    WIRED_3POINT5_MM_AUDIO = 100;
    WIRED_3POINT5_MM_HEADSET = 101;
    WIRED_3POINT5_MM_HEADPHONES = 102;
    USB_C_AUDIO = 200;
    USB_C_DEVICE = 201;
    USB_C_HEADSET = 202;
    USB_C_ACCESSORY = 203;
    USB_C_DOCK = 204;
    USB_C_HDMI = 205;
    BLUETOOTH = 300;
    BLUETOOTH_HEARING_AID = 301;
    BLUETOOTH_A2DP = 302;
    REMOTE_SINGLE = 400;
    REMOTE_TV = 401;
    REMOTE_SPEAKER = 402;
    REMOTE_GROUP = 500;
    REMOTE_DYNAMIC_GROUP = 501;
};

/**
 * The result of an output switching operation.
 */
enum SwitchResult {
    ERROR = 0;
    OK = 1;
};

/**
 * The sub result of an output switching operation.
 */
enum SubResult {
    UNKNOWN_ERROR = 0;
    NO_ERROR = 1;
    REJECTED = 2;
    NETWORK_ERROR = 3;
    ROUTE_NOT_AVAILABLE = 4;
    INVALID_COMMAND = 5;
}
+5 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.settingslib.media;

import static android.media.MediaRoute2ProviderService.REASON_UNKNOWN_ERROR;

import android.app.Notification;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
@@ -448,6 +450,8 @@ public class LocalMediaManager implements BluetoothCallback {
            if (mOnTransferBluetoothDevice != null && mOnTransferBluetoothDevice.isConnected()) {
                connectDevice(mOnTransferBluetoothDevice);
                mOnTransferBluetoothDevice.setState(MediaDeviceState.STATE_CONNECTED);
                dispatchSelectedDeviceStateChanged(mOnTransferBluetoothDevice,
                        MediaDeviceState.STATE_CONNECTED);
                mOnTransferBluetoothDevice = null;
            }
        }
@@ -626,6 +630,7 @@ public class LocalMediaManager implements BluetoothCallback {
                // Failed to connect
                mOnTransferBluetoothDevice.setState(MediaDeviceState.STATE_DISCONNECTED);
                mOnTransferBluetoothDevice = null;
                dispatchOnRequestFailed(REASON_UNKNOWN_ERROR);
            }
            dispatchDeviceAttributesChanged();
        }
+3 −1
Original line number Diff line number Diff line
@@ -49,7 +49,8 @@ public abstract class MediaDevice implements Comparable<MediaDevice> {
    private static final String TAG = "MediaDevice";

    @Retention(RetentionPolicy.SOURCE)
    @IntDef({MediaDeviceType.TYPE_USB_C_AUDIO_DEVICE,
    @IntDef({MediaDeviceType.TYPE_UNKNOWN,
            MediaDeviceType.TYPE_USB_C_AUDIO_DEVICE,
            MediaDeviceType.TYPE_3POINT5_MM_AUDIO_DEVICE,
            MediaDeviceType.TYPE_FAST_PAIR_BLUETOOTH_DEVICE,
            MediaDeviceType.TYPE_BLUETOOTH_DEVICE,
@@ -57,6 +58,7 @@ public abstract class MediaDevice implements Comparable<MediaDevice> {
            MediaDeviceType.TYPE_CAST_GROUP_DEVICE,
            MediaDeviceType.TYPE_PHONE_DEVICE})
    public @interface MediaDeviceType {
        int TYPE_UNKNOWN = 0;
        int TYPE_USB_C_AUDIO_DEVICE = 1;
        int TYPE_3POINT5_MM_AUDIO_DEVICE = 2;
        int TYPE_FAST_PAIR_BLUETOOTH_DEVICE = 3;