Permalink
Browse files

Remove whitespace [Gun.io WhitespaceBot]

  • Loading branch information...
1 parent be51170 commit f34788c983f7efea1641bae6795ed8640388ff54 Gun.io Whitespace Robot committed Oct 29, 2011
@@ -7,8 +7,8 @@
</head>
<body lang="EN-US">
<h2>About This Content</h2>
-
-<p>September 19, 2010</p>
+
+<p>September 19, 2010</p>
<h3>License</h3>
<pre>
@@ -55,23 +55,23 @@
public static final String ERR_INVALID_PARAMETERS = "INVALID_PARAMETERS";
public static final String ERR_INVALID_SENDER = "INVALID_SENDER";
public static final String ERR_PHONE_REGISTRATION_ERROR = "PHONE_REGISTRATION_ERROR";
-
+
// wakelock
private static final String WAKELOCK_KEY = "C2DM_LIB";
private static PowerManager.WakeLock mWakeLock;
private final String senderId;
/**
- * The C2DMReceiver class must create a no-arg constructor and pass the
+ * The C2DMReceiver class must create a no-arg constructor and pass the
* sender id to be used for registration.
*/
public C2DMBaseReceiver(String senderId) {
// senderId is used as base name for threads, etc.
super(senderId);
this.senderId = senderId;
}
-
+
/**
* Called when a cloud message has been received.
*/
@@ -80,7 +80,7 @@ public C2DMBaseReceiver(String senderId) {
/**
* Called on registration error. Override to provide better
* error messages.
- *
+ *
* This is called in the context of a Service - no dialog or UI.
*/
public abstract void onError(Context context, String errorId);
@@ -98,7 +98,7 @@ public void onRegistered(Context context, String registrationId) throws IOExcept
public void onUnregistered(Context context) {
}
-
+
@Override
public final void onHandleIntent(Intent intent) {
try {
@@ -112,42 +112,42 @@ public final void onHandleIntent(Intent intent) {
}
} finally {
// Release the power lock, so phone can get back to sleep.
- // The lock is reference counted by default, so multiple
+ // The lock is reference counted by default, so multiple
// messages are ok.
-
+
// If the onMessage() needs to spawn a thread or do something else,
// it should use it's own lock.
mWakeLock.release();
}
}
-
+
/**
- * Called from the broadcast receiver.
+ * Called from the broadcast receiver.
* Will process the received intent, call handleMessage(), registered(), etc.
- * in background threads, with a wake lock, while keeping the service
- * alive.
+ * in background threads, with a wake lock, while keeping the service
+ * alive.
*/
static void runIntentInService(Context context, Intent intent) {
if (mWakeLock == null) {
// This is called from BroadcastReceiver, there is no init.
- PowerManager pm =
+ PowerManager pm =
(PowerManager) context.getSystemService(Context.POWER_SERVICE);
- mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
+ mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
WAKELOCK_KEY);
}
mWakeLock.acquire();
-
- // Use a naming convention, similar with how permissions and intents are
- // used. Alternatives are introspection or an ugly use of statics.
+
+ // Use a naming convention, similar with how permissions and intents are
+ // used. Alternatives are introspection or an ugly use of statics.
String receiver = context.getPackageName() + ".C2DMReceiver";
intent.setClassName(context, receiver);
-
+
context.startService(intent);
}
-
-
+
+
private void handleRegistration(final Context context, Intent intent) {
final String registrationId = intent.getStringExtra(EXTRA_REGISTRATION_ID);
String error = intent.getStringExtra(EXTRA_ERROR);
@@ -171,20 +171,20 @@ private void handleRegistration(final Context context, Intent intent) {
onError(context, error);
if ("SERVICE_NOT_AVAILABLE".equals(error)) {
long backoffTimeMs = C2DMessaging.getBackoff(context);
-
+
Log.d(TAG, "Scheduling registration retry, backoff = " + backoffTimeMs);
Intent retryIntent = new Intent(C2DM_RETRY);
- PendingIntent retryPIntent = PendingIntent.getBroadcast(context,
+ PendingIntent retryPIntent = PendingIntent.getBroadcast(context,
0 /*requestCode*/, retryIntent, 0 /*flags*/);
-
+
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.set(AlarmManager.ELAPSED_REALTIME,
backoffTimeMs, retryPIntent);
// Next retry should wait longer.
backoffTimeMs *= 2;
C2DMessaging.setBackoff(context, backoffTimeMs);
- }
+ }
} else {
try {
onRegistered(context, registrationId);
@@ -9,17 +9,17 @@
/**
* Helper class to handle BroadcastReciver behavior.
- * - can only run for a limited amount of time - it must start a real service
+ * - can only run for a limited amount of time - it must start a real service
* for longer activity
* - must get the power lock, must make sure it's released when all done.
- *
+ *
*/
public class C2DMBroadcastReceiver extends BroadcastReceiver {
-
+
@Override
public final void onReceive(Context context, Intent intent) {
// To keep things in one place.
C2DMBaseReceiver.runIntentInService(context, intent);
- setResult(Activity.RESULT_OK, null /* data */, null /* extra */);
+ setResult(Activity.RESULT_OK, null /* data */, null /* extra */);
}
}
@@ -39,7 +39,7 @@
// package
static final String PREFERENCE = "com.google.android.c2dm";
-
+
private static final long DEFAULT_BACKOFF = 30000;
/**
@@ -88,14 +88,14 @@ public static long getLastRegistrationChange(Context context) {
Context.MODE_PRIVATE);
return prefs.getLong(LAST_REGISTRATION_CHANGE, 0);
}
-
+
static long getBackoff(Context context) {
final SharedPreferences prefs = context.getSharedPreferences(
PREFERENCE,
Context.MODE_PRIVATE);
return prefs.getLong(BACKOFF, DEFAULT_BACKOFF);
}
-
+
static void setBackoff(Context context, long backoff) {
final SharedPreferences prefs = context.getSharedPreferences(
PREFERENCE,
@@ -99,7 +99,7 @@ public void onRegistered(final Context context, String registrationId) throws IO
editor.putString(REG_ID, registrationId.trim());
editor.commit();
Log.v("pivot13", registrationId);
-
+
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {

0 comments on commit f34788c

Please sign in to comment.