summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2015-04-10 21:51:20 +0200
committerSteve Kondik <steve@cyngn.com>2015-10-18 15:54:18 -0700
commitb37e795442570f7eeca6c8cee1203e8410dbc5af (patch)
tree04224020f07ff565a75d1b4c269f8840598a8378
parentf021cec83e253e5ea9760d895e8d09e4525a942c (diff)
downloadandroid_packages_apps_Exchange-b37e795442570f7eeca6c8cee1203e8410dbc5af.tar.gz
android_packages_apps_Exchange-b37e795442570f7eeca6c8cee1203e8410dbc5af.tar.bz2
android_packages_apps_Exchange-b37e795442570f7eeca6c8cee1203e8410dbc5af.zip
exchange: serialize the account parcelable before using with AlarmManager
AlarmManager cannot deal with ClasspathLoaders to properly restore the parcelable, so we serialize to a byte array and restore it in the EasService Change-Id: Ib89236f9a0d3d38817322bfa28e5fc20e108f2f8 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
-rw-r--r--src/com/android/exchange/service/EasService.java13
-rw-r--r--src/com/android/exchange/service/PingSyncSynchronizer.java8
2 files changed, 19 insertions, 2 deletions
diff --git a/src/com/android/exchange/service/EasService.java b/src/com/android/exchange/service/EasService.java
index cf0a983b..b809632b 100644
--- a/src/com/android/exchange/service/EasService.java
+++ b/src/com/android/exchange/service/EasService.java
@@ -25,6 +25,7 @@ import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.IBinder;
+import android.os.Parcel;
import android.provider.CalendarContract;
import android.provider.ContactsContract;
import android.text.TextUtils;
@@ -76,6 +77,7 @@ public class EasService extends Service {
public static final String EXTRA_START_PING = "START_PING";
public static final String EXTRA_PING_ACCOUNT = "PING_ACCOUNT";
+ public static final String EXTRA_PING_ACCOUNT_AS_DATA = "PING_ACCOUNT_AS_DATA";
/**
* The content authorities that can be synced for EAS accounts. Initialization must wait until
@@ -378,7 +380,16 @@ public class EasService extends Service {
System.exit(-1);
} else if (intent.getBooleanExtra(EXTRA_START_PING, false)) {
LogUtils.d(LogUtils.TAG, "Restarting ping");
- final Account account = intent.getParcelableExtra(EXTRA_PING_ACCOUNT);
+ Account account = null;
+ if (intent.hasExtra(EXTRA_PING_ACCOUNT_AS_DATA)) {
+ byte[] byteArrayExtra = intent.getByteArrayExtra(EXTRA_PING_ACCOUNT_AS_DATA);
+ Parcel parcel = Parcel.obtain();
+ parcel.unmarshall(byteArrayExtra, 0, byteArrayExtra.length);
+ parcel.setDataPosition(0);
+ account = Account.CREATOR.createFromParcel(parcel);
+ } else {
+ account = intent.getParcelableExtra(EXTRA_PING_ACCOUNT);
+ }
final android.accounts.Account amAccount =
new android.accounts.Account(account.mEmailAddress,
Eas.EXCHANGE_ACCOUNT_MANAGER_TYPE);
diff --git a/src/com/android/exchange/service/PingSyncSynchronizer.java b/src/com/android/exchange/service/PingSyncSynchronizer.java
index f722e865..3d78dc32 100644
--- a/src/com/android/exchange/service/PingSyncSynchronizer.java
+++ b/src/com/android/exchange/service/PingSyncSynchronizer.java
@@ -23,6 +23,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.os.Parcel;
import android.os.SystemClock;
import android.support.v4.util.LongSparseArray;
import android.text.format.DateUtils;
@@ -241,7 +242,12 @@ public class PingSyncSynchronizer {
final Intent intent = new Intent(context, EasService.class);
intent.setAction(Eas.EXCHANGE_SERVICE_INTENT_ACTION);
intent.putExtra(EasService.EXTRA_START_PING, true);
- intent.putExtra(EasService.EXTRA_PING_ACCOUNT, account);
+ // AlarmManager cannot deal with ClasspathLoaders to properly restore the
+ // parcelable, so we serialize to a byte array and restore it in the EasService
+ Parcel parcel = Parcel.obtain();
+ account.writeToParcel(parcel, 0);
+ parcel.setDataPosition(0);
+ intent.putExtra(EasService.EXTRA_PING_ACCOUNT_AS_DATA, parcel.marshall());
final PendingIntent pi = PendingIntent.getService(context, 0, intent,
PendingIntent.FLAG_ONE_SHOT);