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

Commit 06ce8359 authored by Joseph Pirozzo's avatar Joseph Pirozzo Committed by android-build-merger
Browse files

Merge changes I11362911,I39b524b2,I75de88e7,Ie9101e0b,Iad3806e3, ... am: fb235b67 am: 2ac5d0a0

am: 1ebe940a

Change-Id: I0b05645442edbb7917df97b902449dc50d9c7dc1
parents bb59aacd 1ebe940a
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -317,6 +317,16 @@
                <action android:name="android.media.browse.MediaBrowserService" />
                <action android:name="android.media.browse.MediaBrowserService" />
            </intent-filter>
            </intent-filter>
        </service>
        </service>

        <activity
            android:name=".BluetoothPrefs"
            android:exported="@bool/profile_supported_a2dp_sink"
            android:enabled="@bool/profile_supported_a2dp_sink">
            <intent-filter>
                <action android:name="android.intent.action.APPLICATION_PREFERENCES"/>
            </intent-filter>
        </activity>

        <service
        <service
            android:process="@string/process"
            android:process="@string/process"
            android:name = ".avrcp.AvrcpTargetService"
            android:name = ".avrcp.AvrcpTargetService"
+1 −0
Original line number Original line Diff line number Diff line
@@ -249,4 +249,5 @@
    <string name="bluetooth_disconnected">Bluetooth audio disconnected"</string>
    <string name="bluetooth_disconnected">Bluetooth audio disconnected"</string>
    <string name="a2dp_sink_mbs_label">Bluetooth Audio</string>
    <string name="a2dp_sink_mbs_label">Bluetooth Audio</string>
    <string name="bluetooth_opp_file_limit_exceeded">Files bigger than 4GB cannot be transferred</string>
    <string name="bluetooth_opp_file_limit_exceeded">Files bigger than 4GB cannot be transferred</string>
    <string name="bluetooth_connect_action">Connect to Bluetooth</string>
</resources>
</resources>
+40 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2019 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.
 */

package com.android.bluetooth;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

/**
 * Activity that routes to Bluetooth settings when launched
 */
public class BluetoothPrefs extends Activity {

    public static final String BLUETOOTH_SETTING_ACTION = "android.settings.BLUETOOTH_SETTINGS";
    public static final String BLUETOOTH_SETTING_CATEGORY = "android.intent.category.DEFAULT";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent launchIntent = new Intent();
        launchIntent.setAction(BLUETOOTH_SETTING_ACTION);
        launchIntent.addCategory(BLUETOOTH_SETTING_CATEGORY);
        startActivity(launchIntent);
        finish();
    }
}
+1 −5
Original line number Original line Diff line number Diff line
@@ -233,11 +233,7 @@ class AvrcpControllerStateMachine extends StateMachine {
        mAddressedPlayer.updateCurrentTrack(null);
        mAddressedPlayer.updateCurrentTrack(null);
        mBrowseTree.mNowPlayingNode.setCached(false);
        mBrowseTree.mNowPlayingNode.setCached(false);
        BluetoothMediaBrowserService.notifyChanged(mBrowseTree.mNowPlayingNode);
        BluetoothMediaBrowserService.notifyChanged(mBrowseTree.mNowPlayingNode);
        PlaybackStateCompat.Builder pbb = new PlaybackStateCompat.Builder();
        BluetoothMediaBrowserService.addressedPlayerChanged(null);
        pbb.setState(PlaybackStateCompat.STATE_ERROR, PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN,
                1.0f).setActions(0);
        pbb.setErrorMessage(mService.getString(R.string.bluetooth_disconnected));
        BluetoothMediaBrowserService.notifyChanged(pbb.build());
        mService.sBrowseTree.mRootNode.removeChild(
        mService.sBrowseTree.mRootNode.removeChild(
                mBrowseTree.mRootNode);
                mBrowseTree.mRootNode);
        BluetoothMediaBrowserService.notifyChanged(mService
        BluetoothMediaBrowserService.notifyChanged(mService
+31 −5
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.bluetooth.avrcpcontroller;
package com.android.bluetooth.avrcpcontroller;


import android.app.PendingIntent;
import android.content.Intent;
import android.media.MediaMetadata;
import android.media.MediaMetadata;
import android.media.browse.MediaBrowser.MediaItem;
import android.media.browse.MediaBrowser.MediaItem;
import android.os.Bundle;
import android.os.Bundle;
@@ -29,6 +31,7 @@ import android.util.Log;


import androidx.media.MediaBrowserServiceCompat;
import androidx.media.MediaBrowserServiceCompat;


import com.android.bluetooth.BluetoothPrefs;
import com.android.bluetooth.R;
import com.android.bluetooth.R;


import java.util.ArrayList;
import java.util.ArrayList;
@@ -60,6 +63,12 @@ public class BluetoothMediaBrowserService extends MediaBrowserServiceCompat {
    // Browsing related structures.
    // Browsing related structures.
    private List<MediaSessionCompat.QueueItem> mMediaQueue = new ArrayList<>();
    private List<MediaSessionCompat.QueueItem> mMediaQueue = new ArrayList<>();


    // Error messaging extras
    public static final String ERROR_RESOLUTION_ACTION_INTENT =
            "android.media.extras.ERROR_RESOLUTION_ACTION_INTENT";
    public static final String ERROR_RESOLUTION_ACTION_LABEL =
            "android.media.extras.ERROR_RESOLUTION_ACTION_LABEL";

    /**
    /**
     * Initialize this BluetoothMediaBrowserService, creating our MediaSessionCompat, MediaPlayer
     * Initialize this BluetoothMediaBrowserService, creating our MediaSessionCompat, MediaPlayer
     * and MediaMetaData, and setting up mechanisms to talk with the AvrcpControllerService.
     * and MediaMetaData, and setting up mechanisms to talk with the AvrcpControllerService.
@@ -76,11 +85,7 @@ public class BluetoothMediaBrowserService extends MediaBrowserServiceCompat {
                | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
                | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
        mSession.setQueueTitle(getString(R.string.bluetooth_a2dp_sink_queue_name));
        mSession.setQueueTitle(getString(R.string.bluetooth_a2dp_sink_queue_name));
        mSession.setQueue(mMediaQueue);
        mSession.setQueue(mMediaQueue);
        PlaybackStateCompat.Builder playbackStateBuilder = new PlaybackStateCompat.Builder();
        setErrorPlaybackState();
        playbackStateBuilder.setState(PlaybackStateCompat.STATE_ERROR,
                PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f).setActions(0);
        playbackStateBuilder.setErrorMessage(getString(R.string.bluetooth_disconnected));
        mSession.setPlaybackState(playbackStateBuilder.build());
        sBluetoothMediaBrowserService = this;
        sBluetoothMediaBrowserService = this;
    }
    }


@@ -94,6 +99,24 @@ public class BluetoothMediaBrowserService extends MediaBrowserServiceCompat {
        }
        }
    }
    }


    private void setErrorPlaybackState() {
        Bundle extras = new Bundle();
        extras.putString(ERROR_RESOLUTION_ACTION_LABEL,
                getString(R.string.bluetooth_connect_action));
        Intent launchIntent = new Intent();
        launchIntent.setAction(BluetoothPrefs.BLUETOOTH_SETTING_ACTION);
        launchIntent.addCategory(BluetoothPrefs.BLUETOOTH_SETTING_CATEGORY);
        PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0,
                launchIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        extras.putParcelable(ERROR_RESOLUTION_ACTION_INTENT, pendingIntent);
        PlaybackStateCompat errorState = new PlaybackStateCompat.Builder()
                .setErrorMessage(getString(R.string.bluetooth_disconnected))
                .setExtras(extras)
                .setState(PlaybackStateCompat.STATE_ERROR, 0, 0)
                .build();
        mSession.setPlaybackState(errorState);
    }

    @Override
    @Override
    public synchronized void onLoadChildren(final String parentMediaId,
    public synchronized void onLoadChildren(final String parentMediaId,
            final Result<List<MediaBrowserCompat.MediaItem>> result) {
            final Result<List<MediaBrowserCompat.MediaItem>> result) {
@@ -138,6 +161,9 @@ public class BluetoothMediaBrowserService extends MediaBrowserServiceCompat {


    static synchronized void addressedPlayerChanged(MediaSessionCompat.Callback callback) {
    static synchronized void addressedPlayerChanged(MediaSessionCompat.Callback callback) {
        if (sBluetoothMediaBrowserService != null) {
        if (sBluetoothMediaBrowserService != null) {
            if (callback == null) {
                sBluetoothMediaBrowserService.setErrorPlaybackState();
            }
            sBluetoothMediaBrowserService.mSession.setCallback(callback);
            sBluetoothMediaBrowserService.mSession.setCallback(callback);
        } else {
        } else {
            Log.w(TAG, "addressedPlayerChanged Unavailable");
            Log.w(TAG, "addressedPlayerChanged Unavailable");
Loading