1212import android .os .Handler ;
1313import android .os .Process ;
1414import android .util .Log ;
15-
1615import androidx .localbroadcastmanager .content .LocalBroadcastManager ;
1716import com .google .firebase .messaging .FirebaseMessagingService ;
1817import com .google .firebase .messaging .RemoteMessage ;
19-
18+ import io .flutter .plugin .common .MethodChannel ;
19+ import io .flutter .plugin .common .PluginRegistry ;
20+ import io .flutter .view .FlutterCallbackInformation ;
21+ import io .flutter .view .FlutterMain ;
22+ import io .flutter .view .FlutterNativeView ;
23+ import io .flutter .view .FlutterRunArguments ;
2024import java .util .Collections ;
2125import java .util .HashMap ;
2226import java .util .Iterator ;
2630import java .util .concurrent .CountDownLatch ;
2731import java .util .concurrent .atomic .AtomicBoolean ;
2832
29- import io .flutter .plugin .common .MethodChannel ;
30- import io .flutter .plugin .common .PluginRegistry ;
31- import io .flutter .view .FlutterCallbackInformation ;
32- import io .flutter .view .FlutterMain ;
33- import io .flutter .view .FlutterNativeView ;
34- import io .flutter .view .FlutterRunArguments ;
35-
3633public class FlutterFirebaseMessagingService extends FirebaseMessagingService {
3734
3835 public static final String ACTION_REMOTE_MESSAGE =
@@ -44,7 +41,8 @@ public class FlutterFirebaseMessagingService extends FirebaseMessagingService {
4441
4542 private static final String SHARED_PREFERENCES_KEY = "io.flutter.android_fcm_plugin" ;
4643 private static final String BACKGROUND_SETUP_CALLBACK_HANDLE_KEY = "background_setup_callback" ;
47- private static final String BACKGROUND_MESSAGE_CALLBACK_HANDLE_KEY = "background_message_callback" ;
44+ private static final String BACKGROUND_MESSAGE_CALLBACK_HANDLE_KEY =
45+ "background_message_callback" ;
4846
4947 // TODO(kroikie): make sIsIsolateRunning per-instance, not static.
5048 private static AtomicBoolean sIsIsolateRunning = new AtomicBoolean (false );
@@ -56,7 +54,8 @@ public class FlutterFirebaseMessagingService extends FirebaseMessagingService {
5654
5755 private static Long sBackgroundMessageHandle ;
5856
59- private static List <RemoteMessage > sBackgroundMessageQueue = Collections .synchronizedList (new LinkedList <RemoteMessage >());
57+ private static List <RemoteMessage > sBackgroundMessageQueue =
58+ Collections .synchronizedList (new LinkedList <RemoteMessage >());
6059
6160 private static PluginRegistry .PluginRegistrantCallback sPluginRegistrantCallback ;
6261
@@ -105,8 +104,8 @@ public void onMessageReceived(final RemoteMessage remoteMessage) {
105104 new Runnable () {
106105 @ Override
107106 public void run () {
108- Log . d ( TAG , "executing dart callback" );
109- executeDartCallbackInBackgroundIsolate ( FlutterFirebaseMessagingService .this , remoteMessage , latch );
107+ executeDartCallbackInBackgroundIsolate (
108+ FlutterFirebaseMessagingService .this , remoteMessage , latch );
110109 }
111110 });
112111 try {
@@ -199,16 +198,15 @@ public static void setBackgroundSetupHandle(Context context, long callbackHandle
199198 }
200199
201200 public static Long getOnMessageCallbackHandle (Context context ) {
202- return context .getSharedPreferences (SHARED_PREFERENCES_KEY , 0 )
201+ return context
202+ .getSharedPreferences (SHARED_PREFERENCES_KEY , 0 )
203203 .getLong (BACKGROUND_MESSAGE_CALLBACK_HANDLE_KEY , 0 );
204204 }
205205
206- private static void executeDartCallbackInBackgroundIsolate (Context context ,
207- RemoteMessage remoteMessage , final CountDownLatch latch ) {
206+ private static void executeDartCallbackInBackgroundIsolate (
207+ Context context , RemoteMessage remoteMessage , final CountDownLatch latch ) {
208208 if (sBackgroundChannel == null ) {
209- Log .e (
210- TAG ,
211- "setBackgroundChannel was not called before messages came in, exiting." );
209+ Log .e (TAG , "setBackgroundChannel was not called before messages came in, exiting." );
212210 return ;
213211 }
214212
@@ -257,14 +255,16 @@ public void notImplemented() {
257255
258256 // TODO(kroikie): Find a better way to determine application state.
259257 public static boolean isApplicationForeground (Context context ) {
260- KeyguardManager keyguardManager = (KeyguardManager ) context .getSystemService (Context .KEYGUARD_SERVICE );
258+ KeyguardManager keyguardManager =
259+ (KeyguardManager ) context .getSystemService (Context .KEYGUARD_SERVICE );
261260
262261 if (keyguardManager .inKeyguardRestrictedInputMode ()) {
263262 return false ;
264263 }
265264 int myPid = Process .myPid ();
266265
267- ActivityManager activityManager = (ActivityManager ) context .getSystemService (Context .ACTIVITY_SERVICE );
266+ ActivityManager activityManager =
267+ (ActivityManager ) context .getSystemService (Context .ACTIVITY_SERVICE );
268268
269269 List <ActivityManager .RunningAppProcessInfo > list ;
270270
0 commit comments