From b6437245c280596d0a580b8d67189739cf793250 Mon Sep 17 00:00:00 2001 From: Costin Manolache Date: Thu, 10 Sep 2009 16:14:12 -0700 Subject: [PATCH] If disk-full, don't crash the system server. Still todo: when we have disk we should trigger the event again. --- core/java/android/accounts/AccountManager.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java index d04abe59c6805..9afeb74b02f4c 100644 --- a/core/java/android/accounts/AccountManager.java +++ b/core/java/android/accounts/AccountManager.java @@ -21,11 +21,13 @@ import android.content.Intent; import android.content.Context; import android.content.IntentFilter; import android.content.BroadcastReceiver; +import android.database.SQLException; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.RemoteException; import android.os.Parcelable; +import android.util.Log; import java.io.IOException; import java.util.concurrent.Callable; @@ -364,7 +366,13 @@ public class AccountManager { handler = (handler == null) ? mMainHandler : handler; handler.post(new Runnable() { public void run() { - listener.onAccountsUpdated(accountsCopy); + try { + listener.onAccountsUpdated(accountsCopy); + } catch (SQLException e) { + // Better luck next time. If the problem was disk-full, + // the STORAGE_OK intent will re-trigger the update. + Log.e(TAG, "Can't update accounts", e); + } } }); } @@ -824,6 +832,8 @@ public class AccountManager { // Register a broadcast receiver to monitor account changes IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constants.LOGIN_ACCOUNTS_CHANGED_ACTION); + // To recover from disk-full. + intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); mContext.registerReceiver(mAccountsChangedBroadcastReceiver, intentFilter); } }