Merge "[Audiosharing] Rename CallsAndAlarms components" into main
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
android:key="calls_and_alarms"
|
android:key="calls_and_alarms"
|
||||||
android:summary=""
|
android:summary=""
|
||||||
android:title="@string/audio_sharing_call_audio_title"
|
android:title="@string/audio_sharing_call_audio_title"
|
||||||
settings:controller="com.android.settings.connecteddevice.audiosharing.CallsAndAlarmsPreferenceController" />
|
settings:controller="com.android.settings.connecteddevice.audiosharing.AudioSharingCallAudioPreferenceController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:icon="@drawable/ic_audio_play_sample"
|
android:icon="@drawable/ic_audio_play_sample"
|
||||||
|
@@ -32,7 +32,7 @@ import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** Provides a dialog to choose the active device for calls and alarms. */
|
/** Provides a dialog to choose the active device for calls and alarms. */
|
||||||
public class CallsAndAlarmsDialogFragment extends InstrumentedDialogFragment {
|
public class AudioSharingCallAudioDialogFragment extends InstrumentedDialogFragment {
|
||||||
private static final String TAG = "CallsAndAlarmsDialog";
|
private static final String TAG = "CallsAndAlarmsDialog";
|
||||||
private static final String BUNDLE_KEY_DEVICE_ITEMS = "bundle_key_device_items";
|
private static final String BUNDLE_KEY_DEVICE_ITEMS = "bundle_key_device_items";
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public class CallsAndAlarmsDialogFragment extends InstrumentedDialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the {@link CallsAndAlarmsDialogFragment} dialog.
|
* Display the {@link AudioSharingCallAudioDialogFragment} dialog.
|
||||||
*
|
*
|
||||||
* @param host The Fragment this dialog will be hosted.
|
* @param host The Fragment this dialog will be hosted.
|
||||||
* @param deviceItems The connected device items in audio sharing session.
|
* @param deviceItems The connected device items in audio sharing session.
|
||||||
@@ -71,7 +71,8 @@ public class CallsAndAlarmsDialogFragment extends InstrumentedDialogFragment {
|
|||||||
if (manager.findFragmentByTag(TAG) == null) {
|
if (manager.findFragmentByTag(TAG) == null) {
|
||||||
final Bundle bundle = new Bundle();
|
final Bundle bundle = new Bundle();
|
||||||
bundle.putParcelableList(BUNDLE_KEY_DEVICE_ITEMS, deviceItems);
|
bundle.putParcelableList(BUNDLE_KEY_DEVICE_ITEMS, deviceItems);
|
||||||
final CallsAndAlarmsDialogFragment dialog = new CallsAndAlarmsDialogFragment();
|
final AudioSharingCallAudioDialogFragment dialog =
|
||||||
|
new AudioSharingCallAudioDialogFragment();
|
||||||
dialog.setArguments(bundle);
|
dialog.setArguments(bundle);
|
||||||
dialog.show(manager, TAG);
|
dialog.show(manager, TAG);
|
||||||
}
|
}
|
@@ -51,6 +51,8 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
|||||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||||
import com.android.settingslib.utils.ThreadUtils;
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -60,7 +62,7 @@ import java.util.concurrent.Executors;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
/** PreferenceController to control the dialog to choose the active device for calls and alarms */
|
/** PreferenceController to control the dialog to choose the active device for calls and alarms */
|
||||||
public class CallsAndAlarmsPreferenceController extends AudioSharingBasePreferenceController
|
public class AudioSharingCallAudioPreferenceController extends AudioSharingBasePreferenceController
|
||||||
implements BluetoothCallback {
|
implements BluetoothCallback {
|
||||||
private static final String TAG = "CallsAndAlarmsPreferenceController";
|
private static final String TAG = "CallsAndAlarmsPreferenceController";
|
||||||
private static final String PREF_KEY = "calls_and_alarms";
|
private static final String PREF_KEY = "calls_and_alarms";
|
||||||
@@ -131,7 +133,7 @@ public class CallsAndAlarmsPreferenceController extends AudioSharingBasePreferen
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public CallsAndAlarmsPreferenceController(Context context) {
|
public AudioSharingCallAudioPreferenceController(Context context) {
|
||||||
super(context, PREF_KEY);
|
super(context, PREF_KEY);
|
||||||
mBtManager = Utils.getLocalBtManager(mContext);
|
mBtManager = Utils.getLocalBtManager(mContext);
|
||||||
mProfileManager = mBtManager == null ? null : mBtManager.getProfileManager();
|
mProfileManager = mBtManager == null ? null : mBtManager.getProfileManager();
|
||||||
@@ -176,16 +178,13 @@ public class CallsAndAlarmsPreferenceController extends AudioSharingBasePreferen
|
|||||||
}
|
}
|
||||||
updateDeviceItemsInSharingSession();
|
updateDeviceItemsInSharingSession();
|
||||||
if (mDeviceItemsInSharingSession.size() >= 1) {
|
if (mDeviceItemsInSharingSession.size() >= 1) {
|
||||||
CallsAndAlarmsDialogFragment.show(
|
AudioSharingCallAudioDialogFragment.show(
|
||||||
mFragment,
|
mFragment,
|
||||||
mDeviceItemsInSharingSession,
|
mDeviceItemsInSharingSession,
|
||||||
(AudioSharingDeviceItem item) -> {
|
(AudioSharingDeviceItem item) -> {
|
||||||
if (!mGroupedConnectedDevices.containsKey(
|
|
||||||
item.getGroupId())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<CachedBluetoothDevice> devices =
|
List<CachedBluetoothDevice> devices =
|
||||||
mGroupedConnectedDevices.get(item.getGroupId());
|
mGroupedConnectedDevices.getOrDefault(
|
||||||
|
item.getGroupId(), ImmutableList.of());
|
||||||
@Nullable
|
@Nullable
|
||||||
CachedBluetoothDevice lead =
|
CachedBluetoothDevice lead =
|
||||||
AudioSharingUtils.getLeadDevice(devices);
|
AudioSharingUtils.getLeadDevice(devices);
|
@@ -33,7 +33,7 @@ public class AudioSharingDashboardFragment extends DashboardFragment
|
|||||||
SettingsMainSwitchBar mMainSwitchBar;
|
SettingsMainSwitchBar mMainSwitchBar;
|
||||||
private AudioSharingSwitchBarController mSwitchBarController;
|
private AudioSharingSwitchBarController mSwitchBarController;
|
||||||
private AudioSharingDeviceVolumeGroupController mAudioSharingDeviceVolumeGroupController;
|
private AudioSharingDeviceVolumeGroupController mAudioSharingDeviceVolumeGroupController;
|
||||||
private CallsAndAlarmsPreferenceController mCallsAndAlarmsPreferenceController;
|
private AudioSharingCallAudioPreferenceController mAudioSharingCallAudioPreferenceController;
|
||||||
private AudioSharingPlaySoundPreferenceController mAudioSharingPlaySoundPreferenceController;
|
private AudioSharingPlaySoundPreferenceController mAudioSharingPlaySoundPreferenceController;
|
||||||
private AudioStreamsCategoryController mAudioStreamsCategoryController;
|
private AudioStreamsCategoryController mAudioStreamsCategoryController;
|
||||||
|
|
||||||
@@ -67,8 +67,9 @@ public class AudioSharingDashboardFragment extends DashboardFragment
|
|||||||
mAudioSharingDeviceVolumeGroupController =
|
mAudioSharingDeviceVolumeGroupController =
|
||||||
use(AudioSharingDeviceVolumeGroupController.class);
|
use(AudioSharingDeviceVolumeGroupController.class);
|
||||||
mAudioSharingDeviceVolumeGroupController.init(this);
|
mAudioSharingDeviceVolumeGroupController.init(this);
|
||||||
mCallsAndAlarmsPreferenceController = use(CallsAndAlarmsPreferenceController.class);
|
mAudioSharingCallAudioPreferenceController =
|
||||||
mCallsAndAlarmsPreferenceController.init(this);
|
use(AudioSharingCallAudioPreferenceController.class);
|
||||||
|
mAudioSharingCallAudioPreferenceController.init(this);
|
||||||
mAudioSharingPlaySoundPreferenceController =
|
mAudioSharingPlaySoundPreferenceController =
|
||||||
use(AudioSharingPlaySoundPreferenceController.class);
|
use(AudioSharingPlaySoundPreferenceController.class);
|
||||||
mAudioStreamsCategoryController = use(AudioStreamsCategoryController.class);
|
mAudioStreamsCategoryController = use(AudioStreamsCategoryController.class);
|
||||||
@@ -100,7 +101,7 @@ public class AudioSharingDashboardFragment extends DashboardFragment
|
|||||||
|
|
||||||
private void updateVisibilityForAttachedPreferences() {
|
private void updateVisibilityForAttachedPreferences() {
|
||||||
mAudioSharingDeviceVolumeGroupController.updateVisibility();
|
mAudioSharingDeviceVolumeGroupController.updateVisibility();
|
||||||
mCallsAndAlarmsPreferenceController.updateVisibility();
|
mAudioSharingCallAudioPreferenceController.updateVisibility();
|
||||||
mAudioSharingPlaySoundPreferenceController.updateVisibility();
|
mAudioSharingPlaySoundPreferenceController.updateVisibility();
|
||||||
mAudioStreamsCategoryController.updateVisibility();
|
mAudioStreamsCategoryController.updateVisibility();
|
||||||
}
|
}
|
||||||
|
@@ -51,7 +51,7 @@ import java.util.ArrayList;
|
|||||||
ShadowAlertDialogCompat.class,
|
ShadowAlertDialogCompat.class,
|
||||||
ShadowBluetoothAdapter.class,
|
ShadowBluetoothAdapter.class,
|
||||||
})
|
})
|
||||||
public class CallsAndAlarmsDialogFragmentTest {
|
public class AudioSharingCallAudioDialogFragmentTest {
|
||||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||||
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ public class CallsAndAlarmsDialogFragmentTest {
|
|||||||
new AudioSharingDeviceItem(TEST_DEVICE_NAME2, /* groupId= */ 1, /* isActive= */ true);
|
new AudioSharingDeviceItem(TEST_DEVICE_NAME2, /* groupId= */ 1, /* isActive= */ true);
|
||||||
|
|
||||||
private Fragment mParent;
|
private Fragment mParent;
|
||||||
private CallsAndAlarmsDialogFragment mFragment;
|
private AudioSharingCallAudioDialogFragment mFragment;
|
||||||
private ShadowBluetoothAdapter mShadowBluetoothAdapter;
|
private ShadowBluetoothAdapter mShadowBluetoothAdapter;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -76,7 +76,7 @@ public class CallsAndAlarmsDialogFragmentTest {
|
|||||||
BluetoothStatusCodes.FEATURE_SUPPORTED);
|
BluetoothStatusCodes.FEATURE_SUPPORTED);
|
||||||
mShadowBluetoothAdapter.setIsLeAudioBroadcastAssistantSupported(
|
mShadowBluetoothAdapter.setIsLeAudioBroadcastAssistantSupported(
|
||||||
BluetoothStatusCodes.FEATURE_SUPPORTED);
|
BluetoothStatusCodes.FEATURE_SUPPORTED);
|
||||||
mFragment = new CallsAndAlarmsDialogFragment();
|
mFragment = new AudioSharingCallAudioDialogFragment();
|
||||||
mParent = new Fragment();
|
mParent = new Fragment();
|
||||||
FragmentController.setupFragment(
|
FragmentController.setupFragment(
|
||||||
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
@@ -88,7 +88,7 @@ import java.util.List;
|
|||||||
ShadowBluetoothUtils.class,
|
ShadowBluetoothUtils.class,
|
||||||
ShadowThreadUtils.class,
|
ShadowThreadUtils.class,
|
||||||
})
|
})
|
||||||
public class CallsAndAlarmsPreferenceControllerTest {
|
public class AudioSharingCallAudioPreferenceControllerTest {
|
||||||
private static final String PREF_KEY = "calls_and_alarms";
|
private static final String PREF_KEY = "calls_and_alarms";
|
||||||
private static final String TEST_DEVICE_NAME1 = "test1";
|
private static final String TEST_DEVICE_NAME1 = "test1";
|
||||||
private static final String TEST_DEVICE_NAME2 = "test2";
|
private static final String TEST_DEVICE_NAME2 = "test2";
|
||||||
@@ -118,7 +118,7 @@ public class CallsAndAlarmsPreferenceControllerTest {
|
|||||||
@Mock private CachedBluetoothDevice mCachedDevice3;
|
@Mock private CachedBluetoothDevice mCachedDevice3;
|
||||||
@Mock private BluetoothLeBroadcastReceiveState mState;
|
@Mock private BluetoothLeBroadcastReceiveState mState;
|
||||||
@Mock private ContentResolver mContentResolver;
|
@Mock private ContentResolver mContentResolver;
|
||||||
private CallsAndAlarmsPreferenceController mController;
|
private AudioSharingCallAudioPreferenceController mController;
|
||||||
@Spy private ContentObserver mContentObserver;
|
@Spy private ContentObserver mContentObserver;
|
||||||
private ShadowBluetoothAdapter mShadowBluetoothAdapter;
|
private ShadowBluetoothAdapter mShadowBluetoothAdapter;
|
||||||
private LocalBluetoothManager mBtManager;
|
private LocalBluetoothManager mBtManager;
|
||||||
@@ -151,7 +151,7 @@ public class CallsAndAlarmsPreferenceControllerTest {
|
|||||||
bisSyncState.add(1L);
|
bisSyncState.add(1L);
|
||||||
when(mState.getBisSyncState()).thenReturn(bisSyncState);
|
when(mState.getBisSyncState()).thenReturn(bisSyncState);
|
||||||
when(mContext.getContentResolver()).thenReturn(mContentResolver);
|
when(mContext.getContentResolver()).thenReturn(mContentResolver);
|
||||||
mController = new CallsAndAlarmsPreferenceController(mContext);
|
mController = new AudioSharingCallAudioPreferenceController(mContext);
|
||||||
mController.init(null);
|
mController.init(null);
|
||||||
mContentObserver = mController.getSettingsObserver();
|
mContentObserver = mController.getSettingsObserver();
|
||||||
mPreference = new Preference(mContext);
|
mPreference = new Preference(mContext);
|
Reference in New Issue
Block a user