protected transient Void doInBackground(Void avoid[]) { if (mGcm == null) { mGcm = GoogleCloudMessaging.getInstance(getContext()); } try { SLog.dWithTag( "GCMRegService", (new StringBuilder()) .append("Registering with senderId=") .append(mSenderId) .toString()); avoid = mGcm.register(new String[] {mSenderId}); SLog.d("GCM: Registration complete with regId={}", avoid); setRegistrationId(avoid); mAppController.sendGcmRegId(avoid, mUserId); } // Misplaced declaration of an exception variable catch (Void avoid[]) { SLog.dWithTag("GCMRegService", "Failed to register with GCM service."); } // Misplaced declaration of an exception variable catch (Void avoid[]) { } return null; }
private String getRegistrationId() { SharedPreferences sharedpreferences = getGCMPreferences(this); String s = sharedpreferences.getString("registrationId", null); if (s == null) { SLog.dWithTag("GCMRegService", "Registration not found."); s = null; } else if (sharedpreferences.getInt("registrationVersion", 0x80000000) != getAppVersion() || isRegistrationExpired()) { SLog.dWithTag("GCMRegService", "App version changed or registration expired."); return null; } return s; }
private void stopService() { int i; for (Iterator iterator = mStartIds.iterator(); iterator.hasNext(); stopSelf(i)) { i = ((Integer) iterator.next()).intValue(); SLog.dWithTag( "GCMRegService", (new StringBuilder()).append("Stopping service for startId=").append(i).toString()); } }
protected transient Void doInBackground(Void avoid[]) { if (mGcm == null) { mGcm = GoogleCloudMessaging.getInstance(getContext()); } SLog.dWithTag("GCMRegService", "Unregistering..."); mAppController.clearGcmRegId(mRegId, mUserId, mSessionKey); GCMRegistrationService.getGCMPreferences(getContext()).edit().clear().commit(); return null; }
public int onStartCommand(Intent intent, int i, int j) { SLog.dWithTag( "GCMRegService", (new StringBuilder()) .append("onStartCommand, startId=") .append(j) .append(", startIds=") .append(mStartIds.toString()) .toString()); mStartIds.add(Integer.valueOf(j)); if (intent == null) { return 2; } String s = getRegistrationId(); SLog.dWithTag( "GCMRegService", (new StringBuilder()) .append("Starting GCM registration service with regId=") .append(s) .toString()); long l = intent.getLongExtra("user_id", 0L); String s1 = intent.getAction(); if ("co.vine.android.gcm.REGISTER".equals(s1)) { if (s == null) { (new GCMRegisterTask(l)).execute(new Void[0]); return 2; } if (!getGCMPreferences(this).getBoolean("registrationIdSent", false)) { mAppController.sendGcmRegId(s, l); return 2; } else { stopService(); return 2; } } if ("co.vine.android.gcm.UNREGISTER".equals(s1)) { (new GCMUnregisterTask(s, l, intent.getStringExtra("s_key"))).execute(new Void[0]); return 2; } else { stopService(); return 2; } }
public void onGcmRegistrationComplete(String s, int i, String s1, long l) { if (i == 200 && l > 0L) { SLog.dWithTag( "GCMRegService", "GCM registration completed successfully; saving regId and stopping service now."); s = GCMRegistrationService.getGCMPreferences(GCMRegistrationService.this).edit(); s.putBoolean("registrationIdSent", true); s.commit(); } stopService(); }