Rename AudioSharingRetryDialogFragment

Test: atest
Flag: com.android.settingslib.flags.enable_le_audio_sharing
Bug: 362858894
Change-Id: I157b036541e9a7b21205ee45437bfd4562c49118
This commit is contained in:
Yiyi Shen
2024-09-23 16:20:48 +08:00
parent 322e153350
commit 51fc7a8239
4 changed files with 23 additions and 23 deletions

View File

@@ -29,8 +29,8 @@ import androidx.fragment.app.FragmentManager;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settingslib.bluetooth.BluetoothUtils;
public class AudioSharingRetryDialogFragment extends InstrumentedDialogFragment {
private static final String TAG = "AudioSharingRetryDialog";
public class AudioSharingErrorDialogFragment extends InstrumentedDialogFragment {
private static final String TAG = "AudioSharingErrorDialog";
@Override
public int getMetricsCategory() {
@@ -39,7 +39,7 @@ public class AudioSharingRetryDialogFragment extends InstrumentedDialogFragment
}
/**
* Display the {@link AudioSharingRetryDialogFragment} dialog.
* Display the {@link AudioSharingErrorDialogFragment} dialog.
*
* @param host The Fragment this dialog will be hosted.
*/
@@ -57,8 +57,8 @@ public class AudioSharingRetryDialogFragment extends InstrumentedDialogFragment
Log.d(TAG, "Dialog is showing, return.");
return;
}
Log.d(TAG, "Show up the retry dialog.");
AudioSharingRetryDialogFragment dialogFrag = new AudioSharingRetryDialogFragment();
Log.d(TAG, "Show up the error dialog.");
AudioSharingErrorDialogFragment dialogFrag = new AudioSharingErrorDialogFragment();
dialogFrag.show(manager, TAG);
}

View File

@@ -161,7 +161,7 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
public void onBroadcastStartFailed(int reason) {
Log.d(TAG, "onBroadcastStartFailed(), reason = " + reason);
updateSwitch();
showRetryDialog();
showErrorDialog();
mMetricsFeatureProvider.action(
mContext,
SettingsEnums.ACTION_AUDIO_SHARING_START_FAILED,
@@ -190,7 +190,7 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
mStoppingSharing.compareAndSet(true, false);
updateSwitch();
AudioSharingUtils.postOnMainThread(mContext,
() -> dismissStaleDialogsOtherThanRetryDialog());
() -> dismissStaleDialogsOtherThanErrorDialog());
AudioSharingUtils.toastMessage(
mContext,
mContext.getString(R.string.audio_sharing_sharing_stopped_label));
@@ -278,7 +278,7 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
+ reason);
if (mSinksInAdding.contains(sink)) {
stopAudioSharing();
showRetryDialog();
showErrorDialog();
mMetricsFeatureProvider.action(
mContext,
SettingsEnums.ACTION_AUDIO_SHARING_JOIN_FAILED,
@@ -742,17 +742,17 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
});
}
private void showRetryDialog() {
private void showErrorDialog() {
AudioSharingUtils.postOnMainThread(mContext,
() -> {
// Remove all opening dialogs before show retry dialog
dismissStaleDialogsOtherThanRetryDialog();
AudioSharingRetryDialogFragment.show(mFragment);
// Remove all stale dialogs before showing error dialog
dismissStaleDialogsOtherThanErrorDialog();
AudioSharingErrorDialogFragment.show(mFragment);
});
}
@UiThread
private void dismissStaleDialogsOtherThanRetryDialog() {
private void dismissStaleDialogsOtherThanErrorDialog() {
List<Fragment> fragments = new ArrayList<Fragment>();
try {
if (mFragment != null) {
@@ -764,7 +764,7 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
}
for (Fragment fragment : fragments) {
if (fragment != null && fragment instanceof DialogFragment
&& !(fragment instanceof AudioSharingRetryDialogFragment)
&& !(fragment instanceof AudioSharingErrorDialogFragment)
&& ((DialogFragment) fragment).getDialog() != null) {
Log.d(TAG, "Remove stale dialog = " + fragment.getTag());
((DialogFragment) fragment).dismiss();

View File

@@ -51,14 +51,14 @@ import org.robolectric.shadows.androidx.fragment.FragmentController;
ShadowAlertDialogCompat.class,
ShadowBluetoothAdapter.class,
})
public class AudioSharingRetryDialogFragmentTest {
public class AudioSharingErrorDialogFragmentTest {
@Rule
public final MockitoRule mocks = MockitoJUnit.rule();
@Rule
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
private Fragment mParent;
private AudioSharingRetryDialogFragment mFragment;
private AudioSharingErrorDialogFragment mFragment;
@Before
public void setUp() {
@@ -70,7 +70,7 @@ public class AudioSharingRetryDialogFragmentTest {
BluetoothStatusCodes.FEATURE_SUPPORTED);
shadowBluetoothAdapter.setIsLeAudioBroadcastAssistantSupported(
BluetoothStatusCodes.FEATURE_SUPPORTED);
mFragment = new AudioSharingRetryDialogFragment();
mFragment = new AudioSharingErrorDialogFragment();
mParent = new Fragment();
FragmentController.setupFragment(
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
@@ -91,7 +91,7 @@ public class AudioSharingRetryDialogFragmentTest {
@Test
public void onCreateDialog_flagOff_dialogNotExist() {
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
AudioSharingRetryDialogFragment.show(mParent);
AudioSharingErrorDialogFragment.show(mParent);
shadowMainLooper().idle();
AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNull();
@@ -100,7 +100,7 @@ public class AudioSharingRetryDialogFragmentTest {
@Test
public void onCreateDialog_unattachedFragment_dialogNotExist() {
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
AudioSharingRetryDialogFragment.show(new Fragment());
AudioSharingErrorDialogFragment.show(new Fragment());
shadowMainLooper().idle();
AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNull();
@@ -109,7 +109,7 @@ public class AudioSharingRetryDialogFragmentTest {
@Test
public void onCreateDialog_flagOn_showDialog() {
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
AudioSharingRetryDialogFragment.show(mParent);
AudioSharingErrorDialogFragment.show(mParent);
shadowMainLooper().idle();
AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
@@ -119,7 +119,7 @@ public class AudioSharingRetryDialogFragmentTest {
@Test
public void onCreateDialog_clickOk_dialogDismiss() {
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
AudioSharingRetryDialogFragment.show(mParent);
AudioSharingErrorDialogFragment.show(mParent);
shadowMainLooper().idle();
AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();

View File

@@ -821,7 +821,7 @@ public class AudioSharingSwitchBarControllerTest {
}
@Test
public void testAssistantCallbacks_onSourceAddFailed_twoDevices_showRetryAndLogAction() {
public void testAssistantCallbacks_onSourceAddFailed_twoDevices_showErrorAndLogAction() {
FeatureFlagUtils.setEnabled(
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
when(mBtnView.isEnabled()).thenReturn(true);
@@ -857,7 +857,7 @@ public class AudioSharingSwitchBarControllerTest {
// Progress dialog shows sharing progress for the user chosen sink.
List<Fragment> childFragments = mParentFragment.getChildFragmentManager().getFragments();
assertThat(childFragments).comparingElementsUsing(CLAZZNAME_EQUALS).containsExactly(
AudioSharingRetryDialogFragment.class.getName());
AudioSharingErrorDialogFragment.class.getName());
verify(mFeatureFactory.metricsFeatureProvider)
.action(
mContext,