Search in sources :

Example 6 with RoutingSessionInfo

use of android.media.RoutingSessionInfo in project android_packages_apps_Settings by omnirom.

the class RemoteMediaSlice method onNotifyChange.

@Override
public void onNotifyChange(Intent intent) {
    final int newPosition = intent.getIntExtra(EXTRA_RANGE_VALUE, -1);
    final String id = intent.getStringExtra(MEDIA_ID);
    if (!TextUtils.isEmpty(id)) {
        getWorker().adjustSessionVolume(id, newPosition);
        return;
    }
    if (TextUtils.equals(ACTION_LAUNCH_DIALOG, intent.getStringExtra(CUSTOMIZED_ACTION))) {
        // Launch Media Output Dialog
        final RoutingSessionInfo info = intent.getParcelableExtra(SESSION_INFO);
        mContext.sendBroadcast(new Intent().setPackage(MediaOutputConstants.SYSTEMUI_PACKAGE_NAME).setAction(MediaOutputConstants.ACTION_LAUNCH_MEDIA_OUTPUT_DIALOG).putExtra(MediaOutputConstants.EXTRA_PACKAGE_NAME, info.getClientPackageName()));
        // Dismiss volume panel
        mContext.sendBroadcast(new Intent().setPackage(MediaOutputConstants.SETTINGS_PACKAGE_NAME).setAction(MediaOutputConstants.ACTION_CLOSE_PANEL));
    }
}
Also used : RoutingSessionInfo(android.media.RoutingSessionInfo) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) SpannableString(android.text.SpannableString)

Example 7 with RoutingSessionInfo

use of android.media.RoutingSessionInfo in project android_packages_apps_Settings by omnirom.

the class RemoteVolumeGroupControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    doReturn(mMediaSessionManager).when(mContext).getSystemService(Context.MEDIA_SESSION_SERVICE);
    mController = new RemoteVolumeGroupController(mContext, KEY_REMOTE_VOLUME_GROUP);
    mController.mLocalMediaManager = mLocalMediaManager;
    mController.mRouterManager = mock(MediaRouter2Manager.class);
    mPreferenceCategory = spy(new PreferenceCategory(mContext));
    mPreferenceCategory.setKey(mController.getPreferenceKey());
    when(mPreferenceCategory.getPreferenceManager()).thenReturn(mPreferenceManager);
    when(mPreferenceManager.getSharedPreferences()).thenReturn(mSharedPreferences);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreferenceCategory);
    final RoutingSessionInfo remoteSessionInfo = mock(RoutingSessionInfo.class);
    when(remoteSessionInfo.getId()).thenReturn(TEST_SESSION_1_ID);
    when(remoteSessionInfo.getName()).thenReturn(TEST_SESSION_1_NAME);
    when(remoteSessionInfo.getVolumeMax()).thenReturn(MAX_VOLUME);
    when(remoteSessionInfo.getVolume()).thenReturn(CURRENT_VOLUME);
    when(remoteSessionInfo.getClientPackageName()).thenReturn(TEST_PACKAGE_NAME);
    when(remoteSessionInfo.isSystemSession()).thenReturn(false);
    mRoutingSessionInfos.add(remoteSessionInfo);
    when(mLocalMediaManager.getActiveMediaSession()).thenReturn(mRoutingSessionInfos);
}
Also used : MediaRouter2Manager(android.media.MediaRouter2Manager) PreferenceCategory(androidx.preference.PreferenceCategory) RoutingSessionInfo(android.media.RoutingSessionInfo) Before(org.junit.Before)

Aggregations

RoutingSessionInfo (android.media.RoutingSessionInfo)7 Intent (android.content.Intent)2 MediaRouter2Manager (android.media.MediaRouter2Manager)2 SpannableString (android.text.SpannableString)2 Before (org.junit.Before)2 PendingIntent (android.app.PendingIntent)1 ForegroundColorSpan (android.text.style.ForegroundColorSpan)1 IconCompat (androidx.core.graphics.drawable.IconCompat)1 Preference (androidx.preference.Preference)1 PreferenceCategory (androidx.preference.PreferenceCategory)1 ListBuilder (androidx.slice.builders.ListBuilder)1 InputRangeBuilder (androidx.slice.builders.ListBuilder.InputRangeBuilder)1 LocalMediaManager (com.android.settingslib.media.LocalMediaManager)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1