[Audiosharing] Add audio sharing loggings (P1)
Bug: 331515891 Test: atest Change-Id: I7396f99538f36b47086e0c4f45ef775535f2f321
This commit is contained in:
@@ -17,6 +17,7 @@ package com.android.settings.connecteddevice;
|
||||
|
||||
import static com.android.settingslib.Utils.isAudioModeOngoingCall;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothLeBroadcast;
|
||||
import android.bluetooth.BluetoothLeBroadcastAssistant;
|
||||
@@ -47,6 +48,7 @@ import com.android.settings.connecteddevice.audiosharing.AudioSharingDialogHandl
|
||||
import com.android.settings.connecteddevice.audiosharing.AudioSharingUtils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.bluetooth.BluetoothCallback;
|
||||
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
@@ -279,6 +281,8 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
||||
((BluetoothDevicePreference) preference).getBluetoothDevice();
|
||||
if (AudioSharingUtils.isFeatureEnabled() && mDialogHandler != null) {
|
||||
mDialogHandler.handleDeviceConnected(cachedDevice, /* userTriggered= */ true);
|
||||
FeatureFactory.getFeatureFactory().getMetricsFeatureProvider()
|
||||
.action(mContext, SettingsEnums.ACTION_MEDIA_DEVICE_CLICK);
|
||||
} else {
|
||||
cachedDevice.setActive();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.connecteddevice.audiosharing;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -70,6 +71,7 @@ public class AudioSharingBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
mMetricsFeatureProvider.logClickedPreference(preference, mMetricsCategory);
|
||||
mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_AUDIO_SHARING_DEVICE_CLICK);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class AudioSharingCallAudioDialogFragment extends InstrumentedDialogFragm
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.DIALOG_AUDIO_SHARING_SWITCH_ACTIVE;
|
||||
return SettingsEnums.DIALOG_AUDIO_SHARING_CALL_AUDIO;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.connecteddevice.audiosharing;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.bluetooth.BluetoothLeBroadcast;
|
||||
import android.bluetooth.BluetoothLeBroadcastMetadata;
|
||||
import android.content.Context;
|
||||
@@ -32,9 +33,11 @@ import androidx.preference.TwoStatePreference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.bluetooth.Utils;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -53,6 +56,7 @@ public class AudioSharingCompatibilityPreferenceController extends TogglePrefere
|
||||
@Nullable private final LocalBluetoothLeBroadcast mBroadcast;
|
||||
@Nullable private TwoStatePreference mPreference;
|
||||
private final Executor mExecutor;
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private AtomicBoolean mCallbacksRegistered = new AtomicBoolean(false);
|
||||
|
||||
private final BluetoothLeBroadcast.Callback mBroadcastCallback =
|
||||
@@ -108,6 +112,7 @@ public class AudioSharingCompatibilityPreferenceController extends TogglePrefere
|
||||
mProfileManager = mBtManager == null ? null : mBtManager.getProfileManager();
|
||||
mBroadcast = mProfileManager == null ? null : mProfileManager.getLeAudioBroadcastProfile();
|
||||
mExecutor = Executors.newSingleThreadExecutor();
|
||||
mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,6 +183,8 @@ public class AudioSharingCompatibilityPreferenceController extends TogglePrefere
|
||||
}
|
||||
mBroadcast.setImproveCompatibility(isChecked);
|
||||
// TODO: call updateBroadcast once framework change ready.
|
||||
mMetricsFeatureProvider.action(
|
||||
mContext, SettingsEnums.ACTION_AUDIO_SHARING_IMPROVE_COMPATIBILITY, isChecked);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.connecteddevice.audiosharing;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -33,8 +34,7 @@ public class AudioSharingConfirmDialogFragment extends InstrumentedDialogFragmen
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
// TODO: add metrics category.
|
||||
return 0;
|
||||
return SettingsEnums.DIALOG_AUDIO_SHARING_CONFIRMATION;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ public class AudioSharingConfirmDialogFragment extends InstrumentedDialogFragmen
|
||||
.setTitleIcon(com.android.settingslib.R.drawable.ic_bt_le_audio_sharing)
|
||||
.setIsCustomBodyEnabled(true)
|
||||
.setCustomMessage(R.string.audio_sharing_comfirm_dialog_content)
|
||||
.setPositiveButton(com.android.settings.R.string.okay, (d, w) -> dismiss())
|
||||
.setPositiveButton(com.android.settings.R.string.okay, (d, w) -> {})
|
||||
.build();
|
||||
dialog.setCanceledOnTouchOutside(true);
|
||||
return dialog;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.connecteddevice.audiosharing;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.bluetooth.BluetoothCsipSetCoordinator;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
@@ -156,6 +157,10 @@ public class AudioSharingDeviceVolumeControlUpdater extends BluetoothDeviceUpdat
|
||||
if (mVolumeControl != null) {
|
||||
mVolumeControl.setDeviceVolume(
|
||||
cachedDevice.getDevice(), progress, /* isGroupOp= */ true);
|
||||
mMetricsFeatureProvider.action(
|
||||
mContext,
|
||||
SettingsEnums.ACTION_AUDIO_SHARING_CHANGE_MEDIA_DEVICE_VOLUME,
|
||||
/* isPrimary= */ false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,6 +175,10 @@ public class AudioSharingDeviceVolumeControlUpdater extends BluetoothDeviceUpdat
|
||||
- audioManager.getStreamMinVolume(AudioManager.STREAM_MUSIC);
|
||||
int volume = Math.round((float) progress * streamVolumeRange / seekbarRange);
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0);
|
||||
mMetricsFeatureProvider.action(
|
||||
mContext,
|
||||
SettingsEnums.ACTION_AUDIO_SHARING_CHANGE_MEDIA_DEVICE_VOLUME,
|
||||
/* isPrimary= */ true);
|
||||
} catch (RuntimeException e) {
|
||||
Log.e(TAG, "Fail to setAudioManagerStreamVolumeForFallbackDevice, error = " + e);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class AudioSharingJoinDialogFragment extends InstrumentedDialogFragment {
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return AudioSharingUtils.isBroadcasting(Utils.getLocalBtManager(getContext()))
|
||||
? SettingsEnums.DIALOG_START_AUDIO_SHARING
|
||||
? SettingsEnums.DIALOG_AUDIO_SHARING_ADD_DEVICE
|
||||
: SettingsEnums.DIALOG_START_AUDIO_SHARING;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.connecteddevice.audiosharing;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.media.AudioAttributes;
|
||||
@@ -31,6 +32,8 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
public class AudioSharingPlaySoundPreferenceController
|
||||
extends AudioSharingBasePreferenceController {
|
||||
@@ -39,6 +42,7 @@ public class AudioSharingPlaySoundPreferenceController
|
||||
|
||||
private static final String PREF_KEY = "audio_sharing_play_sound";
|
||||
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private Ringtone mRingtone;
|
||||
|
||||
public AudioSharingPlaySoundPreferenceController(Context context) {
|
||||
@@ -47,6 +51,7 @@ public class AudioSharingPlaySoundPreferenceController
|
||||
if (mRingtone != null) {
|
||||
mRingtone.setStreamType(AudioManager.STREAM_MUSIC);
|
||||
}
|
||||
mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,6 +79,9 @@ public class AudioSharingPlaySoundPreferenceController
|
||||
.build());
|
||||
if (!mRingtone.isPlaying()) {
|
||||
mRingtone.play();
|
||||
mMetricsFeatureProvider.action(
|
||||
mContext,
|
||||
SettingsEnums.ACTION_AUDIO_SHARING_PLAY_TEST_SOUND);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Log.w(TAG, "Fail to play sample, error = " + e);
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -30,8 +31,10 @@ import androidx.core.app.NotificationCompat;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.bluetooth.Utils;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
public class AudioSharingReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "AudioSharingNotification";
|
||||
@@ -54,6 +57,8 @@ public class AudioSharingReceiver extends BroadcastReceiver {
|
||||
Log.w(TAG, "Received unexpected intent with null action.");
|
||||
return;
|
||||
}
|
||||
MetricsFeatureProvider metricsFeatureProvider =
|
||||
FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
|
||||
switch (action) {
|
||||
case LocalBluetoothLeBroadcast.ACTION_LE_AUDIO_SHARING_STATE_CHANGE:
|
||||
int state =
|
||||
@@ -61,8 +66,12 @@ public class AudioSharingReceiver extends BroadcastReceiver {
|
||||
LocalBluetoothLeBroadcast.EXTRA_LE_AUDIO_SHARING_STATE, -1);
|
||||
if (state == LocalBluetoothLeBroadcast.BROADCAST_STATE_ON) {
|
||||
showSharingNotification(context);
|
||||
metricsFeatureProvider.action(
|
||||
context, SettingsEnums.ACTION_SHOW_AUDIO_SHARING_NOTIFICATION);
|
||||
} else if (state == LocalBluetoothLeBroadcast.BROADCAST_STATE_OFF) {
|
||||
cancelSharingNotification(context);
|
||||
metricsFeatureProvider.action(
|
||||
context, SettingsEnums.ACTION_CANCEL_AUDIO_SHARING_NOTIFICATION);
|
||||
} else {
|
||||
Log.w(
|
||||
TAG,
|
||||
@@ -72,6 +81,8 @@ public class AudioSharingReceiver extends BroadcastReceiver {
|
||||
case ACTION_LE_AUDIO_SHARING_STOP:
|
||||
LocalBluetoothManager manager = Utils.getLocalBtManager(context);
|
||||
AudioSharingUtils.stopBroadcasting(manager);
|
||||
metricsFeatureProvider.action(
|
||||
context, SettingsEnums.ACTION_STOP_AUDIO_SHARING_FROM_NOTIFICATION);
|
||||
break;
|
||||
default:
|
||||
Log.w(TAG, "Received unexpected intent " + intent.getAction());
|
||||
@@ -98,7 +109,11 @@ public class AudioSharingReceiver extends BroadcastReceiver {
|
||||
stopIntent,
|
||||
PendingIntent.FLAG_IMMUTABLE);
|
||||
Intent settingsIntent =
|
||||
new Intent(ACTION_LE_AUDIO_SHARING_SETTINGS).setPackage(context.getPackageName());
|
||||
new Intent(ACTION_LE_AUDIO_SHARING_SETTINGS)
|
||||
.setPackage(context.getPackageName())
|
||||
.putExtra(
|
||||
MetricsFeatureProvider.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||
SettingsEnums.NOTIFICATION_AUDIO_SHARING);
|
||||
PendingIntent settingsPendingIntent =
|
||||
PendingIntent.getActivity(
|
||||
context,
|
||||
|
||||
Reference in New Issue
Block a user