diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-05-07 15:53:46 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-05-08 12:59:21 -0700 |
commit | 55280a91884b9256e8db6af6a09f28b3feeaa9d8 (patch) | |
tree | ac29de79b8ecec41f2fde6014a1834418a82d2fd /core/java/android/content/SyncManager.java | |
parent | 672f1e2b07d985526bfd5606e6a888005fdcb70c (diff) | |
download | frameworks_base-55280a91884b9256e8db6af6a09f28b3feeaa9d8.zip frameworks_base-55280a91884b9256e8db6af6a09f28b3feeaa9d8.tar.gz frameworks_base-55280a91884b9256e8db6af6a09f28b3feeaa9d8.tar.bz2 |
Improve shutdown process to send broadcast for applications.
This introduces a new class in the base platform for performing a clean
shutdown (which was copied from the classes in the policies). It
includes new features to send a shutdown broadcast for applications
to do cleanup, and ot have the activity manager pause the current
activity before proceeding with the shutdown. These facilities are
also use to write at the most recent stat files for sync, battery
and user activity.
Diffstat (limited to 'core/java/android/content/SyncManager.java')
-rw-r--r-- | core/java/android/content/SyncManager.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java index ade5f3d..4d2cce8 100644 --- a/core/java/android/content/SyncManager.java +++ b/core/java/android/content/SyncManager.java @@ -212,6 +212,14 @@ class SyncManager { } }; + private BroadcastReceiver mShutdownIntentReceiver = + new BroadcastReceiver() { + public void onReceive(Context context, Intent intent) { + Log.w(TAG, "Writing sync state before shutdown..."); + getSyncStorageEngine().writeAllState(); + } + }; + private static final String ACTION_SYNC_ALARM = "android.content.syncmanager.SYNC_ALARM"; private static final String SYNC_POLL_ALARM = "android.content.syncmanager.SYNC_POLL_ALARM"; private final SyncHandler mSyncHandler; @@ -249,6 +257,10 @@ class SyncManager { intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); context.registerReceiver(mStorageIntentReceiver, intentFilter); + intentFilter = new IntentFilter(Intent.ACTION_SHUTDOWN); + intentFilter.setPriority(100); + context.registerReceiver(mShutdownIntentReceiver, intentFilter); + if (!factoryTest) { mNotificationMgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); |