diff options
7 files changed, 50 insertions, 60 deletions
diff --git a/android/app/res/values/strings.xml b/android/app/res/values/strings.xml index e6409cbe42..4760e8abb1 100644 --- a/android/app/res/values/strings.xml +++ b/android/app/res/values/strings.xml @@ -211,12 +211,8 @@ <string name="transfer_clear_dlg_msg">All items will be cleared from the list.</string> <string name="outbound_noti_title">Bluetooth share: Sent files</string> <string name="inbound_noti_title">Bluetooth share: Received files</string> - <string name="noti_caption_unsuccessful"> {count, plural, - other {# unsuccessful.} - }</string> - <string name="noti_caption_success"> {count, plural, - other {# successful, %1$s} - }</string> + <string name="noti_caption_unsuccessful"> <xliff:g id="count">%d</xliff:g> unsuccessful.</string> + <string name="noti_caption_success"><xliff:g id="count">%d</xliff:g> successful,</string> <string name="transfer_menu_clear_all">Clear list</string> <string name="transfer_menu_open">Open</string> diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java index 44a9c1864b..e4bae7f487 100644 --- a/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java +++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java @@ -437,8 +437,8 @@ class BluetoothOppNotification { outboundNum = outboundSuccNumber + outboundFailNumber; // create the outbound notification if (outboundNum > 0) { - String caption = BluetoothOppUtility.formatResultText(outboundSuccNumber, - outboundFailNumber, mContext); + String caption = mContext.getString(R.string.noti_caption_success, outboundSuccNumber) + + mContext.getString(R.string.noti_caption_unsuccessful, outboundFailNumber); Intent contentIntent = new Intent(Constants.ACTION_OPEN_OUTBOUND_TRANSFER).setClassName( mContext, BluetoothOppReceiver.class.getName()); Intent deleteIntent = new Intent(Constants.ACTION_COMPLETE_HIDE).setClassName( @@ -501,8 +501,8 @@ class BluetoothOppNotification { inboundNum = inboundSuccNumber + inboundFailNumber; // create the inbound notification if (inboundNum > 0) { - String caption = BluetoothOppUtility.formatResultText(inboundSuccNumber, - inboundFailNumber, mContext); + String caption = mContext.getString(R.string.noti_caption_success, inboundSuccNumber) + + mContext.getString(R.string.noti_caption_unsuccessful, inboundFailNumber); Intent contentIntent = new Intent(Constants.ACTION_OPEN_INBOUND_TRANSFER).setClassName( mContext, BluetoothOppReceiver.class.getName()); Intent deleteIntent = new Intent(Constants.ACTION_COMPLETE_HIDE).setClassName( diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppService.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppService.java index 6fab0ca50c..3bbd85d8ea 100644 --- a/android/app/src/com/android/bluetooth/opp/BluetoothOppService.java +++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppService.java @@ -37,7 +37,6 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevicePicker; import android.bluetooth.BluetoothSocket; import android.content.BroadcastReceiver; -import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; @@ -53,6 +52,8 @@ import android.os.Binder; import android.os.Handler; import android.os.Message; import android.os.Process; +import android.os.UserHandle; +import android.os.UserManager; import android.sysprop.BluetoothProperties; import android.util.Log; @@ -251,9 +252,15 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti Log.v(TAG, "start()"); } + //Check for user restrictions before enabling component + UserManager mUserManager = getSystemService(UserManager.class); + if (!mUserManager.hasUserRestrictionForUser( + UserManager.DISALLOW_BLUETOOTH_SHARING, UserHandle.CURRENT)) { + setComponentAvailable(LAUNCHER_ACTIVITY, true); + } + setComponentAvailable(OPP_PROVIDER, true); setComponentAvailable(OPP_FILE_PROVIDER, true); - setComponentAvailable(LAUNCHER_ACTIVITY, true); setComponentAvailable(BT_ENABLE_ACTIVITY, true); setComponentAvailable(BT_ERROR_ACTIVITY, true); setComponentAvailable(BT_ENABLING_ACTIVITY, true); diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppUtility.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppUtility.java index 90f151413f..a0a7878442 100644 --- a/android/app/src/com/android/bluetooth/opp/BluetoothOppUtility.java +++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppUtility.java @@ -43,7 +43,6 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.database.Cursor; -import android.icu.text.MessageFormat; import android.net.Uri; import android.os.Environment; import android.os.ParcelFileDescriptor; @@ -58,10 +57,7 @@ import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Locale; -import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** @@ -319,26 +315,6 @@ public class BluetoothOppUtility { } /** - * Helper function to build the result notification text content. - */ - static String formatResultText(int countSuccess, int countUnsuccessful, Context context) { - if (context == null) { - return null; - } - Map<String, Object> mapUnsuccessful = new HashMap<>(); - mapUnsuccessful.put("count", countUnsuccessful); - - Map<String, Object> mapSuccess = new HashMap<>(); - mapSuccess.put("count", countSuccess); - - return new MessageFormat(context.getResources().getString(R.string.noti_caption_success, - new MessageFormat(context.getResources().getString( - R.string.noti_caption_unsuccessful), - Locale.getDefault()).format(mapUnsuccessful)), - Locale.getDefault()).format(mapSuccess); - } - - /** * Whether the device has the "nosdcard" characteristic or not. */ public static boolean deviceHasNoSdCard() { diff --git a/service/java/com/android/server/bluetooth/BluetoothManagerService.java b/service/java/com/android/server/bluetooth/BluetoothManagerService.java index 5e2fb8949d..303074574e 100644 --- a/service/java/com/android/server/bluetooth/BluetoothManagerService.java +++ b/service/java/com/android/server/bluetooth/BluetoothManagerService.java @@ -2891,9 +2891,14 @@ public class BluetoothManagerService extends IBluetoothManager.Stub { final ComponentName oppLauncherComponent = new ComponentName( mContext.getPackageManager().getPackagesForUid(Process.BLUETOOTH_UID)[0], "com.android.bluetooth.opp.BluetoothOppLauncherActivity"); - final int newState = - bluetoothSharingDisallowed ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED - : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; + int newState; + if (bluetoothSharingDisallowed) { + newState = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; + } else if (BluetoothProperties.isProfileOppEnabled().orElse(false)) { + newState = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; + } else { + newState = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; + } try { mContext.createContextAsUser(userHandle, 0) .getPackageManager() diff --git a/system/btif/src/btif_dm.cc b/system/btif/src/btif_dm.cc index 5e8a5140c8..1c8fb227a2 100644 --- a/system/btif/src/btif_dm.cc +++ b/system/btif/src/btif_dm.cc @@ -164,6 +164,8 @@ typedef struct { bool is_le_nc; /* LE Numeric comparison */ btif_dm_ble_cb_t ble; uint8_t fail_reason; + Uuid::UUID128Bit eir_uuids[32]; + uint8_t num_eir_uuids; } btif_dm_pairing_cb_t; // TODO(jpawlowski): unify ? @@ -1296,19 +1298,17 @@ static void btif_dm_search_devices_evt(tBTA_DM_SEARCH_EVT event, &(p_search_data->inq_res.include_rsi)); num_properties++; - /* EIR queried services */ - std::vector<Uuid> uuid128_list; + /* Cache EIR queried services */ if (num_uuids > 0) { uint16_t* p_uuid16 = (uint16_t*)uuid_list; + pairing_cb.num_eir_uuids = 0; + LOG_INFO("EIR UUIDS:"); for (int i = 0; i < num_uuids; ++i) { Uuid uuid = Uuid::From16Bit(p_uuid16[i]); - uuid128_list.push_back(uuid); + LOG_INFO(" %s", uuid.ToString().c_str()); + pairing_cb.eir_uuids[i] = uuid.To128BitBE(); + pairing_cb.num_eir_uuids++; } - - BTIF_STORAGE_FILL_PROPERTY( - &properties[num_properties], BT_PROPERTY_UUIDS, - num_uuids * Uuid::kNumBytes128, uuid128_list.data()); - num_properties++; } status = @@ -1408,28 +1408,34 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event, LOG_INFO("SDP search done for %s", bd_addr.ToString().c_str()); pairing_cb.sdp_attempts = 0; - // Both SDP and bonding are done, clear pairing control block in case - // it is not already cleared - pairing_cb = {}; - - // Send one empty UUID to Java to unblock pairing intent when SDP failed - // or no UUID is discovered + // Send UUIDs discovered through EIR to Java to unblock pairing intent + // when SDP failed or no UUID is discovered if (p_data->disc_res.result != BTA_SUCCESS || p_data->disc_res.num_uuids == 0) { - LOG_INFO("SDP failed, send empty UUID to unblock bonding %s", - bd_addr.ToString().c_str()); + LOG_INFO("SDP failed, send %d EIR UUIDs to unblock bonding %s", + pairing_cb.num_eir_uuids, bd_addr.ToString().c_str()); bt_property_t prop_uuids; Uuid uuid = {}; - prop_uuids.type = BT_PROPERTY_UUIDS; - prop_uuids.val = &uuid; - prop_uuids.len = Uuid::kNumBytes128; + if (pairing_cb.num_eir_uuids > 0) { + prop_uuids.val = pairing_cb.eir_uuids; + prop_uuids.len = pairing_cb.num_eir_uuids * Uuid::kNumBytes128; + } else { + prop_uuids.val = &uuid; + prop_uuids.len = Uuid::kNumBytes128; + } - /* Send the event to the BTIF */ + /* Send the event to the BTIF + * prop_uuids will be deep copied by this call + */ invoke_remote_device_properties_cb(BT_STATUS_SUCCESS, bd_addr, 1, &prop_uuids); + pairing_cb = {}; break; } + // Both SDP and bonding are done, clear pairing control block in case + // it is not already cleared + pairing_cb = {}; } if (p_data->disc_res.num_uuids != 0) { diff --git a/system/gd/hal/snoop_logger.cc b/system/gd/hal/snoop_logger.cc index a416d2c2b9..72e20e9228 100644 --- a/system/gd/hal/snoop_logger.cc +++ b/system/gd/hal/snoop_logger.cc @@ -435,7 +435,7 @@ size_t SnoopLogger::GetMaxPacketsPerBuffer() { // and 512 KB memory for userdebug/eng builds auto is_debuggable = os::GetSystemProperty(kIsDebuggableProperty); size_t btsnooz_max_memory_usage_bytes = - ((is_debuggable.has_value() && common::StringTrim(is_debuggable.value()) == "1") ? 512 : 256) * 1024; + ((is_debuggable.has_value() && common::StringTrim(is_debuggable.value()) == "1") ? 1024 : 256) * 1024; // Calculate max number of packets based on max memory usage and max packet size return btsnooz_max_memory_usage_bytes / kDefaultBtSnoozMaxBytesPerPacket; } |