diff options
author | Steve Kondik <steve@cyngn.com> | 2016-11-08 21:19:32 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-11-08 21:19:32 -0800 |
commit | 699645f59f1c9f2242c57dbaa3cedc36fa50002e (patch) | |
tree | a4a125f0de02d2db16836f46225f78f7eaeb4edb | |
parent | d8e9445752ced8c73cb59ede67b62e8120c617e1 (diff) | |
parent | 2d03e3e3c4568e09a7e30b2bc99def0cd34b8f97 (diff) | |
download | android_packages_apps_Bluetooth-699645f59f1c9f2242c57dbaa3cedc36fa50002e.tar.gz android_packages_apps_Bluetooth-699645f59f1c9f2242c57dbaa3cedc36fa50002e.tar.bz2 android_packages_apps_Bluetooth-699645f59f1c9f2242c57dbaa3cedc36fa50002e.zip |
Merge tag 'android-7.1.0_r7' of https://android.googlesource.com/platform/packages/apps/Bluetooth into HEAD
Android 7.1.0 release 7
# gpg: Signature made Fri 04 Nov 2016 11:14:09 AM PDT
# gpg: using DSA key E8AD3F819AB10E78
# gpg: Can't check signature: No public key
-rw-r--r-- | src/com/android/bluetooth/btservice/AdapterService.java | 4 | ||||
-rwxr-xr-x | src/com/android/bluetooth/map/BluetoothMapContentObserver.java | 59 |
2 files changed, 61 insertions, 2 deletions
diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java index 6f0d47fba..7299fbe00 100644 --- a/src/com/android/bluetooth/btservice/AdapterService.java +++ b/src/com/android/bluetooth/btservice/AdapterService.java @@ -2260,8 +2260,8 @@ public class AdapterService extends Service { } boolean setPairingConfirmation(BluetoothDevice device, boolean accept) { - enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, - "Need BLUETOOTH ADMIN permission"); + enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, + "Need BLUETOOTH PRIVILEGED permission"); DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device); if (deviceProp == null || deviceProp.getBondState() != BluetoothDevice.BOND_BONDING) { return false; diff --git a/src/com/android/bluetooth/map/BluetoothMapContentObserver.java b/src/com/android/bluetooth/map/BluetoothMapContentObserver.java index 6edc5563a..8465274a8 100755 --- a/src/com/android/bluetooth/map/BluetoothMapContentObserver.java +++ b/src/com/android/bluetooth/map/BluetoothMapContentObserver.java @@ -173,7 +173,9 @@ public class BluetoothMapContentObserver { public static final String EXTRA_MESSAGE_SENT_TIMESTAMP = "timestamp"; private SmsBroadcastReceiver mSmsBroadcastReceiver = new SmsBroadcastReceiver(); + private CeBroadcastReceiver mCeBroadcastReceiver = new CeBroadcastReceiver(); + private boolean mStorageUnlocked = false; private boolean mInitialized = false; @@ -481,6 +483,12 @@ public class BluetoothMapContentObserver { Log.w(TAG, "onChange() with URI == null - not handled."); return; } + + if (!mStorageUnlocked) { + Log.v(TAG, "Ignore events until storage is completely unlocked"); + return; + } + if (V) Log.d(TAG, "onChange on thread: " + Thread.currentThread().getId() + " Uri: " + uri.toString() + " selfchange: " + selfChange); @@ -3198,6 +3206,52 @@ public class BluetoothMapContentObserver { } } + private class CeBroadcastReceiver extends BroadcastReceiver { + public void register() { + UserManager manager = UserManager.get(mContext); + if (manager == null || manager.isUserUnlocked()) { + mStorageUnlocked = true; + return; + } + + Handler handler = new Handler(Looper.getMainLooper()); + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(Intent.ACTION_BOOT_COMPLETED); + mContext.registerReceiver(this, intentFilter, null, handler); + } + + public void unregister() { + try { + mContext.unregisterReceiver(this); + } catch (IllegalArgumentException e) { + /* do nothing */ + } + } + + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + Log.d(TAG, "onReceive: action" + action); + + if (action.equals(Intent.ACTION_BOOT_COMPLETED)) { + try { + initMsgList(); + } catch (RemoteException e) { + Log.e(TAG, "Error initializing SMS/MMS message lists."); + } + + for (String folder : FOLDER_SMS_MAP.values()) { + Event evt = new Event(EVENT_TYPE_NEW, -1, folder, mSmsType); + sendEvent(evt); + } + mStorageUnlocked = true; + /* After unlock this BroadcastReceiver is never needed */ + unregister(); + } else { + Log.d(TAG, "onReceive: Unknown action " + action); + } + } + } + /** * Handle MMS sent intents in disconnected(MNS) state, where we do not need to send any * notifications. @@ -3408,6 +3462,11 @@ public class BluetoothMapContentObserver { if (mSmsBroadcastReceiver != null) { mSmsBroadcastReceiver.register(); } + + if (mCeBroadcastReceiver != null) { + mCeBroadcastReceiver.register(); + } + registerPhoneServiceStateListener(); mInitialized = true; } |