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

Commit 9369e03c authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of [19134336, 19219300, 19126196, 19396589, 19378359] into tm-release.

Change-Id: I8638397353d0c122ef731511ef97967c195e8011
parents 036178e6 f92f6bf6
Loading
Loading
Loading
Loading
+49 −16
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.ContentObserver;
@@ -2892,9 +2893,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
     */
    private void updateOppLauncherComponentState(UserHandle userHandle,
            boolean bluetoothSharingDisallowed) {
        final ComponentName oppLauncherComponent = new ComponentName(
                mContext.getPackageManager().getPackagesForUid(Process.BLUETOOTH_UID)[0],
                "com.android.bluetooth.opp.BluetoothOppLauncherActivity");
        try {
            int newState;
            if (bluetoothSharingDisallowed) {
                newState = PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
@@ -2903,13 +2902,47 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
            } else {
                newState = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
            }

            String launcherActivity = "com.android.bluetooth.opp.BluetoothOppLauncherActivity";

            PackageManager packageManager = mContext.createContextAsUser(userHandle, 0)
                                                        .getPackageManager();
            var allPackages = packageManager.getPackagesForUid(Process.BLUETOOTH_UID);
            for (String candidatePackage : allPackages) {
                PackageInfo packageInfo;
                try {
            mContext.createContextAsUser(userHandle, 0)
                .getPackageManager()
                .setComponentEnabledSetting(oppLauncherComponent, newState,
                        PackageManager.DONT_KILL_APP);
                    // note: we need the package manager for the SYSTEM user, not our userHandle
                    packageInfo = mContext.getPackageManager().getPackageInfo(
                        candidatePackage,
                        PackageManager.PackageInfoFlags.of(PackageManager.GET_ACTIVITIES));
                } catch (PackageManager.NameNotFoundException e) {
                    // ignore, try next package
                    Log.e(TAG, "Could not find package " + candidatePackage);
                    continue;
                } catch (Exception e) {
                    Log.e(TAG, "Error while loading package" + e);
                    continue;
                }
                if (packageInfo.activities == null) {
                    continue;
                }
                for (var activity : packageInfo.activities) {
                    if (launcherActivity.equals(activity.name)) {
                        final ComponentName oppLauncherComponent = new ComponentName(
                                candidatePackage, launcherActivity
                        );
                        packageManager.setComponentEnabledSetting(
                                oppLauncherComponent, newState, PackageManager.DONT_KILL_APP
                        );
                        return;
                    }
                }
            }

            Log.e(TAG,
                    "Cannot toggle BluetoothOppLauncherActivity, could not find it in any package");
        } catch (Exception e) {
            // The component was not found, do nothing.
            Log.e(TAG, "updateOppLauncherComponentState failed: " + e);
        }
    }

+0 −8
Original line number Diff line number Diff line
@@ -1469,11 +1469,6 @@ void bta_dm_queue_disc(tBTA_DM_MSG* p_data) {
 ******************************************************************************/
void bta_dm_execute_queued_request() {
  if (bta_dm_search_cb.p_pending_search) {
    // Updated queued event to search event to trigger start search
    if (bta_dm_search_cb.p_pending_search->hdr.event ==
        BTA_DM_API_QUEUE_SEARCH_EVT) {
      bta_dm_search_cb.p_pending_search->hdr.event = BTA_DM_API_SEARCH_EVT;
    }
    LOG_INFO("%s Start pending search", __func__);
    bta_sys_sendmsg(bta_dm_search_cb.p_pending_search);
    bta_dm_search_cb.p_pending_search = NULL;
@@ -1481,9 +1476,6 @@ void bta_dm_execute_queued_request() {
    tBTA_DM_MSG* p_pending_discovery = (tBTA_DM_MSG*)fixed_queue_try_dequeue(
        bta_dm_search_cb.pending_discovery_queue);
    if (p_pending_discovery) {
      if (p_pending_discovery->hdr.event == BTA_DM_API_QUEUE_DISCOVER_EVT) {
        p_pending_discovery->hdr.event = BTA_DM_API_DISCOVER_EVT;
      }
      LOG_INFO("%s Start pending discovery", __func__);
      bta_sys_sendmsg(p_pending_discovery);
    }
+4 −13
Original line number Diff line number Diff line
@@ -80,16 +80,11 @@ void BTA_DmSetDeviceName(const char* p_name) {
 * Returns          void
 *
 ******************************************************************************/
void BTA_DmSearch(tBTA_DM_SEARCH_CBACK* p_cback, bool is_bonding_or_sdp) {
void BTA_DmSearch(tBTA_DM_SEARCH_CBACK* p_cback) {
  tBTA_DM_API_SEARCH* p_msg =
      (tBTA_DM_API_SEARCH*)osi_calloc(sizeof(tBTA_DM_API_SEARCH));

  /* Queue request if a device is bonding or performing service discovery */
  if (is_bonding_or_sdp) {
    p_msg->hdr.event = BTA_DM_API_QUEUE_SEARCH_EVT;
  } else {
  p_msg->hdr.event = BTA_DM_API_SEARCH_EVT;
  }
  p_msg->p_cback = p_cback;

  bta_sys_sendmsg(p_msg);
@@ -138,15 +133,11 @@ void BTA_DmSearchCancel(void) {
 *
 ******************************************************************************/
void BTA_DmDiscover(const RawAddress& bd_addr, tBTA_DM_SEARCH_CBACK* p_cback,
                    tBT_TRANSPORT transport, bool is_bonding_or_sdp) {
                    tBT_TRANSPORT transport) {
  tBTA_DM_API_DISCOVER* p_msg =
      (tBTA_DM_API_DISCOVER*)osi_calloc(sizeof(tBTA_DM_API_DISCOVER));

  if (is_bonding_or_sdp) {
    p_msg->hdr.event = BTA_DM_API_QUEUE_DISCOVER_EVT;
  } else {
  p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT;
  }
  p_msg->bd_addr = bd_addr;
  p_msg->transport = transport;
  p_msg->p_cback = p_cback;
+2 −4
Original line number Diff line number Diff line
@@ -71,18 +71,16 @@ enum {
  BTA_DM_SEARCH_CMPL_EVT,
  BTA_DM_DISCOVERY_RESULT_EVT,
  BTA_DM_DISC_CLOSE_TOUT_EVT,
  BTA_DM_API_QUEUE_SEARCH_EVT,
  BTA_DM_API_QUEUE_DISCOVER_EVT
};

/* data type for BTA_DM_API_SEARCH_EVT and BTA_DM_API_QUEUE_SEARCH_EVT */
/* data type for BTA_DM_API_SEARCH_EVT */
typedef struct {
  BT_HDR_RIGID hdr;
  tBTA_SERVICE_MASK services;
  tBTA_DM_SEARCH_CBACK* p_cback;
} tBTA_DM_API_SEARCH;

/* data type for BTA_DM_API_DISCOVER_EVT and BTA_DM_API_QUEUE_DISCOVER_EVT */
/* data type for BTA_DM_API_DISCOVER_EVT */
typedef struct {
  BT_HDR_RIGID hdr;
  RawAddress bd_addr;
+0 −11
Original line number Diff line number Diff line
@@ -82,12 +82,6 @@ bool bta_dm_search_sm_execute(BT_HDR_RIGID* p_msg) {
        case BTA_DM_DISC_CLOSE_TOUT_EVT:
          bta_dm_close_gatt_conn(message);
          break;
        case BTA_DM_API_QUEUE_SEARCH_EVT:
          bta_dm_queue_search(message);
          break;
        case BTA_DM_API_QUEUE_DISCOVER_EVT:
          bta_dm_queue_disc(message);
          break;
      }
      break;
    case BTA_DM_SEARCH_ACTIVE:
@@ -108,7 +102,6 @@ bool bta_dm_search_sm_execute(BT_HDR_RIGID* p_msg) {
          bta_dm_close_gatt_conn(message);
          break;
        case BTA_DM_API_DISCOVER_EVT:
        case BTA_DM_API_QUEUE_DISCOVER_EVT:
          bta_dm_queue_disc(message);
          break;
      }
@@ -116,11 +109,9 @@ bool bta_dm_search_sm_execute(BT_HDR_RIGID* p_msg) {
    case BTA_DM_SEARCH_CANCELLING:
      switch (p_msg->event) {
        case BTA_DM_API_SEARCH_EVT:
        case BTA_DM_API_QUEUE_SEARCH_EVT:
          bta_dm_queue_search(message);
          break;
        case BTA_DM_API_DISCOVER_EVT:
        case BTA_DM_API_QUEUE_DISCOVER_EVT:
          bta_dm_queue_disc(message);
          break;
        case BTA_DM_SDP_RESULT_EVT:
@@ -149,11 +140,9 @@ bool bta_dm_search_sm_execute(BT_HDR_RIGID* p_msg) {
          bta_dm_disc_result(message);
          break;
        case BTA_DM_API_SEARCH_EVT:
        case BTA_DM_API_QUEUE_SEARCH_EVT:
          bta_dm_queue_search(message);
          break;
        case BTA_DM_API_DISCOVER_EVT:
        case BTA_DM_API_QUEUE_DISCOVER_EVT:
          bta_dm_queue_disc(message);
          break;
      }
Loading