Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(656)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java

Issue 2129763002: bluetooth: Only unregister the receiver if dialog hasn't been closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Use a boolean to keep track of the receiver Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/BluetoothChooserDialogTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
index 83fa3b72047a2a21562f4328744244f8eda9adfe..7992cf9234cd21a7dea63d82fffca957e51dee4d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
@@ -66,6 +66,9 @@ public class BluetoothChooserDialog
// A pointer back to the native part of the implementation for this dialog.
long mNativeBluetoothChooserDialogPtr;
+ // Used to keep track of when the Mode Changed Receiver is registered.
+ boolean mIsLocationModeChangedReceiverRegistered = false;
gone 2016/07/06 22:07:10 Default value for booleans in Java is false, so ad
ortuno 2016/07/06 22:20:03 In C++ the value is undefined so I developed the h
+
@VisibleForTesting
final BroadcastReceiver mLocationModeBroadcastReceiver = new BroadcastReceiver() {
@Override
@@ -152,11 +155,16 @@ public class BluetoothChooserDialog
mActivity.registerReceiver(mLocationModeBroadcastReceiver,
new IntentFilter(LocationManager.MODE_CHANGED_ACTION));
+ mIsLocationModeChangedReceiverRegistered = true;
}
// Called to report the dialog's results back to native code.
private void finishDialog(int resultCode, String id) {
- mActivity.unregisterReceiver(mLocationModeBroadcastReceiver);
+ if (mIsLocationModeChangedReceiverRegistered) {
+ mActivity.unregisterReceiver(mLocationModeBroadcastReceiver);
+ mIsLocationModeChangedReceiverRegistered = false;
+ }
+
if (mNativeBluetoothChooserDialogPtr != 0) {
nativeOnDialogFinished(mNativeBluetoothChooserDialogPtr, resultCode, id);
}
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/BluetoothChooserDialogTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698