Skip to content

Commit 8f8d9c3

Browse files
author
My Name
committed
fix formatting
1 parent 0b970a4 commit 8f8d9c3

File tree

1 file changed

+12
-14
lines changed
  • firebase-messaging/src/main/java/com/google/firebase/messaging

1 file changed

+12
-14
lines changed

firebase-messaging/src/main/java/com/google/firebase/messaging/SyncTask.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
import java.util.concurrent.ThreadPoolExecutor;
3636
import java.util.concurrent.TimeUnit;
3737

38-
/**
39-
* Background task to perform sync operations with the Firebase backend using a bg thread
40-
*/
38+
/** Background task to perform sync operations with the Firebase backend using a bg thread */
4139
class SyncTask implements Runnable {
4240

4341
private final long nextDelaySeconds;
@@ -115,9 +113,9 @@ public void run() {
115113
* Refreshes the token if needed
116114
*
117115
* @return {@code true} if successful, {@code false} if needs to be rescheduled.
118-
* @throws IOException on a hard failure that should not be retried. Hard failures are
119-
* failures except {@link GmsRpc#ERROR_SERVICE_NOT_AVAILABLE} and
120-
* {@link GmsRpc#ERROR_INTERNAL_SERVER_ERROR}
116+
* @throws IOException on a hard failure that should not be retried. Hard failures are failures
117+
* except {@link GmsRpc#ERROR_SERVICE_NOT_AVAILABLE} and {@link
118+
* GmsRpc#ERROR_INTERNAL_SERVER_ERROR}
121119
*/
122120
@VisibleForTesting
123121
boolean maybeRefreshToken() throws IOException {
@@ -162,10 +160,8 @@ boolean isDeviceConnected() {
162160
@VisibleForTesting
163161
static class ConnectivityChangeReceiver extends BroadcastReceiver {
164162

165-
@Nullable
166-
private SyncTask task; // task is set to null after it has been fired.
167-
@Nullable
168-
private Context context;
163+
@Nullable private SyncTask task; // task is set to null after it has been fired.
164+
@Nullable private Context context;
169165

170166
public ConnectivityChangeReceiver(SyncTask task) {
171167
this.task = task;
@@ -176,8 +172,10 @@ public void registerReceiver() {
176172
Log.d(TAG, "Connectivity change received registered");
177173
}
178174
IntentFilter intentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
179-
context = task.getContext();
180-
context.registerReceiver(this, intentFilter);
175+
if (task != null) {
176+
context = task.getContext();
177+
context.registerReceiver(this, intentFilter);
178+
}
181179
}
182180

183181
@Override
@@ -197,8 +195,8 @@ public void onReceive(Context context, Intent intent) {
197195
Log.d(TAG, "Connectivity changed. Starting background sync.");
198196
}
199197
task.firebaseMessaging.enqueueTaskWithDelaySeconds(task, 0);
200-
if (context != null) {
201-
context.unregisterReceiver(this);
198+
if (this.context != null) {
199+
this.context.unregisterReceiver(this);
202200
task = null;
203201
}
204202
}

0 commit comments

Comments
 (0)