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

Commit 49c5a7a3 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

release-request-8cd2a23c-f767-488e-8139-390d1636483f-for-git_oc-mr1-release-43...

release-request-8cd2a23c-f767-488e-8139-390d1636483f-for-git_oc-mr1-release-4323561 snap-temp-L80400000100600189

Change-Id: Id45eaa83c7b48512837dec24e9be5f05532c75ca
parents 6f3b3312 ed76bdc5
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -86,6 +86,12 @@ import com.android.bluetooth.btservice.BluetoothProto;
        /** Flag to signal that transport is congested */
        Boolean isCongested = false;

        /** Whether the calling app has location permission */
        boolean hasLocationPermisson;

        /** Whether the calling app has peers mac address permission */
        boolean hasPeersMacAddressPermission;

        /** Internal callback info queue, waiting to be send on congestion clear */
        private List<CallbackInfo> congestionQueue = new ArrayList<CallbackInfo>();

@@ -151,7 +157,7 @@ import com.android.bluetooth.btservice.BluetoothProto;
    /**
     * Add an entry to the application context list.
     */
    void add(UUID uuid, WorkSource workSource, C callback, T info, GattService service) {
    App add(UUID uuid, WorkSource workSource, C callback, T info, GattService service) {
        int appUid = Binder.getCallingUid();
        String appName = service.getPackageManager().getNameForUid(appUid);
        if (appName == null) {
@@ -164,8 +170,10 @@ import com.android.bluetooth.btservice.BluetoothProto;
                appScanStats = new AppScanStats(appName, workSource, this, service);
                mAppScanStats.put(appUid, appScanStats);
            }
            mApps.add(new App(uuid, callback, info, appName, appScanStats));
            App app = new App(uuid, callback, info, appName, appScanStats);
            mApps.add(app);
            appScanStats.isRegistered = true;
            return app;
        }
    }

+24 −13
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.util.NumberUtils;
import com.android.internal.annotations.VisibleForTesting;

import java.security.Security;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -846,7 +847,7 @@ public class GattService extends ProfileService {
                if (cbApp.callback != null) {
                    cbApp.linkToDeath(new ScannerDeathRecipient(scannerId));
                } else {
                    continuePiStartScan(scannerId, cbApp.info);
                    continuePiStartScan(scannerId, cbApp);
                }
            } else {
                mScannerMap.remove(scannerId);
@@ -1629,26 +1630,36 @@ public class GattService extends ProfileService {
        piInfo.settings = settings;
        piInfo.filters = filters;
        piInfo.callingPackage = callingPackage;
        mScannerMap.add(uuid, null, null, piInfo, this);
        ScannerMap.App app = mScannerMap.add(uuid, null, null, piInfo, this);
        try {
            app.hasLocationPermisson =
                    Utils.checkCallerHasLocationPermission(this, mAppOps, callingPackage);
        } catch (SecurityException se) {
            // No need to throw here. Just mark as not granted.
            app.hasLocationPermisson = false;
        }
        try {
            app.hasPeersMacAddressPermission = Utils.checkCallerHasPeersMacAddressPermission(this);
        } catch (SecurityException se) {
            // No need to throw here. Just mark as not granted.
            app.hasPeersMacAddressPermission = false;
        }
        mScanManager.registerScanner(uuid);
    }

    void continuePiStartScan(int scannerId, PendingIntentInfo piInfo) {
    void continuePiStartScan(int scannerId, ScannerMap.App app) {
        final PendingIntentInfo piInfo = app.info;
        final ScanClient scanClient =
                new ScanClient(scannerId, piInfo.settings, piInfo.filters, null);
        scanClient.hasLocationPermission =
                true; // Utils.checkCallerHasLocationPermission(this, mAppOps,
        // piInfo.callingPackage);
        scanClient.hasPeersMacAddressPermission =
                true; // Utils.checkCallerHasPeersMacAddressPermission(
        // this);
        scanClient.hasLocationPermission = app.hasLocationPermisson;
        scanClient.hasPeersMacAddressPermission = app.hasPeersMacAddressPermission;
        scanClient.legacyForegroundApp = Utils.isLegacyForegroundApp(this, piInfo.callingPackage);

        AppScanStats app = mScannerMap.getAppScanStatsById(scannerId);
        if (app != null) {
            scanClient.stats = app;
        AppScanStats scanStats = mScannerMap.getAppScanStatsById(scannerId);
        if (scanStats != null) {
            scanClient.stats = scanStats;
            boolean isFilteredScan = (piInfo.filters != null) && !piInfo.filters.isEmpty();
            app.recordScanStart(piInfo.settings, isFilteredScan, scannerId);
            scanStats.recordScanStart(piInfo.settings, isFilteredScan, scannerId);
        }

        mScanManager.startScan(scanClient);
+59 −4
Original line number Diff line number Diff line
@@ -435,6 +435,9 @@ final class HeadsetStateMachine extends StateMachine {
                                        + device.getBondState() + ", device=" + device);
                        // reject the connection and stay in Disconnected state itself
                        disconnectHfpNative(getByteAddress(device));
                        // the other profile connection should be initiated
                        broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTED,
                                BluetoothProfile.STATE_DISCONNECTED);
                    }
                    break;
                case HeadsetHalConstants.CONNECTION_STATE_DISCONNECTING:
@@ -518,6 +521,60 @@ final class HeadsetStateMachine extends StateMachine {
                        case EVENT_TYPE_BIND:
                            processAtBind(event.valueString, event.device);
                            break;
                        // Unexpected AT commands, we only handle them for comparability reasons
                        case EVENT_TYPE_VR_STATE_CHANGED:
                            Log.w(TAG,
                                    "Pending: Unexpected VR event, device=" + event.device
                                            + ", state=" + event.valueInt);
                            processVrEvent(event.valueInt, event.device);
                            break;
                        case EVENT_TYPE_DIAL_CALL:
                            Log.w(TAG, "Pending: Unexpected dial event, device=" + event.device);
                            processDialCall(event.valueString, event.device);
                            break;
                        case EVENT_TYPE_SUBSCRIBER_NUMBER_REQUEST:
                            Log.w(TAG,
                                    "Pending: Unexpected subscriber number event for" + event.device
                                            + ", state=" + event.valueInt);
                            processSubscriberNumberRequest(event.device);
                            break;
                        case EVENT_TYPE_AT_COPS:
                            Log.w(TAG, "Pending: Unexpected COPS event for " + event.device);
                            processAtCops(event.device);
                            break;
                        case EVENT_TYPE_AT_CLCC:
                            Log.w(TAG, "Pending: Unexpected CLCC event for" + event.device);
                            processAtClcc(event.device);
                            break;
                        case EVENT_TYPE_UNKNOWN_AT:
                            Log.w(TAG,
                                    "Pending: Unexpected unknown AT event for" + event.device
                                            + ", cmd=" + event.valueString);
                            processUnknownAt(event.valueString, event.device);
                            break;
                        case EVENT_TYPE_KEY_PRESSED:
                            Log.w(TAG, "Pending: Unexpected key-press event for " + event.device);
                            processKeyPressed(event.device);
                            break;
                        case EVENT_TYPE_BIEV:
                            Log.w(TAG,
                                    "Pending: Unexpected BIEV event for " + event.device
                                            + ", indId=" + event.valueInt
                                            + ", indVal=" + event.valueInt2);
                            processAtBiev(event.valueInt, event.valueInt2, event.device);
                            break;
                        case EVENT_TYPE_VOLUME_CHANGED:
                            Log.w(TAG, "Pending: Unexpected volume event for " + event.device);
                            processVolumeEvent(event.valueInt, event.valueInt2, event.device);
                            break;
                        case EVENT_TYPE_ANSWER_CALL:
                            Log.w(TAG, "Pending: Unexpected answer event for " + event.device);
                            processAnswerCall(event.device);
                            break;
                        case EVENT_TYPE_HANGUP_CALL:
                            Log.w(TAG, "Pending: Unexpected hangup event for " + event.device);
                            processHangupCall(event.device);
                            break;
                        default:
                            Log.e(TAG, "Pending: Unexpected event: " + event.type);
                            break;
@@ -924,11 +981,9 @@ final class HeadsetStateMachine extends StateMachine {
                            processVrEvent(event.valueInt, event.device);
                            break;
                        case EVENT_TYPE_ANSWER_CALL:
                            // TODO(BT) could answer call happen on Connected state?
                            processAnswerCall(event.device);
                            break;
                        case EVENT_TYPE_HANGUP_CALL:
                            // TODO(BT) could hangup call happen on Connected state?
                            processHangupCall(event.device);
                            break;
                        case EVENT_TYPE_VOLUME_CHANGED:
@@ -1072,9 +1127,9 @@ final class HeadsetStateMachine extends StateMachine {
                    mAudioState = BluetoothHeadset.STATE_AUDIO_CONNECTED;
                    setAudioParameters(device); /*Set proper Audio Paramters.*/
                    mAudioManager.setBluetoothScoOn(true);
                    mActiveScoDevice = device;
                    broadcastAudioState(device, BluetoothHeadset.STATE_AUDIO_CONNECTED,
                            BluetoothHeadset.STATE_AUDIO_CONNECTING);
                    mActiveScoDevice = device;
                    transitionTo(mAudioOn);
                    break;
                case HeadsetHalConstants.AUDIO_STATE_CONNECTING:
@@ -2049,7 +2104,7 @@ final class HeadsetStateMachine extends StateMachine {
            sco disconnect issued in AudioOn state. This was causing a mismatch in the
            Incall screen UI. */

            if (getCurrentState() == mAudioOn && mCurrentDevice.equals(device)
            if (mActiveScoDevice != null && mActiveScoDevice.equals(device)
                    && mAudioState != BluetoothHeadset.STATE_AUDIO_DISCONNECTED) {
                return true;
            }
+15 −5
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
@@ -118,11 +119,12 @@ public class BluetoothOppTransferHistory extends Activity implements

        final String sortOrder = BluetoothShare.TIMESTAMP + " DESC";

        mTransferCursor = managedQuery(BluetoothShare.CONTENT_URI, new String[] {
                "_id", BluetoothShare.FILENAME_HINT, BluetoothShare.STATUS,
        mTransferCursor = getContentResolver().query(BluetoothShare.CONTENT_URI,
                new String[] {"_id", BluetoothShare.FILENAME_HINT, BluetoothShare.STATUS,
                        BluetoothShare.TOTAL_BYTES, BluetoothShare._DATA, BluetoothShare.TIMESTAMP,
                BluetoothShare.VISIBILITY, BluetoothShare.DESTINATION, BluetoothShare.DIRECTION
        }, selection, sortOrder);
                        BluetoothShare.VISIBILITY, BluetoothShare.DESTINATION,
                        BluetoothShare.DIRECTION},
                selection, null, sortOrder);

        // only attach everything to the listbox if we can access
        // the transfer database. Otherwise, just show it empty
@@ -192,6 +194,14 @@ public class BluetoothOppTransferHistory extends Activity implements
        return false;
    }

    @Override
    protected void onDestroy() {
        if (mTransferCursor != null) {
            mTransferCursor.close();
        }
        super.onDestroy();
    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
        if (mTransferCursor != null) {