Loading android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java +60 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -1182,7 +1190,7 @@ public class BluetoothMapContentObserver { private void initMsgList() throws RemoteException { if (V) Log.d(TAG, "initMsgList"); UserManager manager = UserManager.get(mContext); if (manager == null || manager.isUserUnlocked()) return; if (manager == null || !manager.isUserUnlocked()) return; if (mEnableSmsMms) { HashMap<Long, Msg> msgListSms = new HashMap<Long, Msg>(); Loading Loading @@ -3193,6 +3201,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. Loading Loading @@ -3403,6 +3457,11 @@ public class BluetoothMapContentObserver { if (mSmsBroadcastReceiver != null) { mSmsBroadcastReceiver.register(); } if (mCeBroadcastReceiver != null) { mCeBroadcastReceiver.register(); } registerPhoneServiceStateListener(); mInitialized = true; } Loading Loading
android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java +60 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -1182,7 +1190,7 @@ public class BluetoothMapContentObserver { private void initMsgList() throws RemoteException { if (V) Log.d(TAG, "initMsgList"); UserManager manager = UserManager.get(mContext); if (manager == null || manager.isUserUnlocked()) return; if (manager == null || !manager.isUserUnlocked()) return; if (mEnableSmsMms) { HashMap<Long, Msg> msgListSms = new HashMap<Long, Msg>(); Loading Loading @@ -3193,6 +3201,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. Loading Loading @@ -3403,6 +3457,11 @@ public class BluetoothMapContentObserver { if (mSmsBroadcastReceiver != null) { mSmsBroadcastReceiver.register(); } if (mCeBroadcastReceiver != null) { mCeBroadcastReceiver.register(); } registerPhoneServiceStateListener(); mInitialized = true; } Loading