From 73f8a4fcfc93da08a40b96df3537bb9b6ef1b0fa Mon Sep 17 00:00:00 2001 From: Arthur Thompson Date: Thu, 20 Aug 2015 08:52:33 -0700 Subject: [PATCH] Remove unnecessary synchronized. --- .../RegistrationIntentService.java | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/android/gcm/app/src/main/java/gcm/play/android/samples/com/gcmquickstart/RegistrationIntentService.java b/android/gcm/app/src/main/java/gcm/play/android/samples/com/gcmquickstart/RegistrationIntentService.java index 7440b3a8..1f33c847 100644 --- a/android/gcm/app/src/main/java/gcm/play/android/samples/com/gcmquickstart/RegistrationIntentService.java +++ b/android/gcm/app/src/main/java/gcm/play/android/samples/com/gcmquickstart/RegistrationIntentService.java @@ -43,31 +43,27 @@ protected void onHandleIntent(Intent intent) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); try { - // In the (unlikely) event that multiple refresh operations occur simultaneously, - // ensure that they are processed sequentially. - synchronized (TAG) { - // [START register_for_gcm] - // Initially this call goes out to the network to retrieve the token, subsequent calls - // are local. - // [START get_token] - InstanceID instanceID = InstanceID.getInstance(this); - String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId), - GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); - // [END get_token] - Log.i(TAG, "GCM Registration Token: " + token); + // [START register_for_gcm] + // Initially this call goes out to the network to retrieve the token, subsequent calls + // are local. + // [START get_token] + InstanceID instanceID = InstanceID.getInstance(this); + String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId), + GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); + // [END get_token] + Log.i(TAG, "GCM Registration Token: " + token); - // TODO: Implement this method to send any registration to your app's servers. - sendRegistrationToServer(token); + // TODO: Implement this method to send any registration to your app's servers. + sendRegistrationToServer(token); - // Subscribe to topic channels - subscribeTopics(token); + // Subscribe to topic channels + subscribeTopics(token); - // You should store a boolean that indicates whether the generated token has been - // sent to your server. If the boolean is false, send the token to your server, - // otherwise your server should have already received the token. - sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, true).apply(); - // [END register_for_gcm] - } + // You should store a boolean that indicates whether the generated token has been + // sent to your server. If the boolean is false, send the token to your server, + // otherwise your server should have already received the token. + sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, true).apply(); + // [END register_for_gcm] } catch (Exception e) { Log.d(TAG, "Failed to complete token refresh", e); // If an exception happens while fetching the new token or updating our registration data