summaryrefslogtreecommitdiffstats
path: root/src/com/android/calendar/Utils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/calendar/Utils.java')
-rw-r--r--src/com/android/calendar/Utils.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/com/android/calendar/Utils.java b/src/com/android/calendar/Utils.java
index 4018f22b..41961852 100644
--- a/src/com/android/calendar/Utils.java
+++ b/src/com/android/calendar/Utils.java
@@ -22,6 +22,7 @@ import android.accounts.Account;
import android.app.Activity;
import android.app.SearchManager;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -848,6 +849,28 @@ public class Utils {
return (0xff000000) | ((r | g | b) >> 8);
}
+ public static void trySyncAndDisableUpgradeReceiver(Context context) {
+ final PackageManager pm = context.getPackageManager();
+ ComponentName upgradeComponent = new ComponentName(context, UpgradeReceiver.class);
+ if (pm.getComponentEnabledSetting(upgradeComponent) ==
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
+ // The upgrade receiver has been disabled, which means this code has been run before,
+ // so no need to sync.
+ return;
+ }
+
+ Bundle extras = new Bundle();
+ extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
+ ContentResolver.requestSync(
+ null /* no account */,
+ Calendars.CONTENT_URI.getAuthority(),
+ extras);
+
+ // Now unregister the receiver so that we won't continue to sync every time.
+ pm.setComponentEnabledSetting(upgradeComponent,
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
+ }
+
// A single strand represents one color of events. Events are divided up by
// color to make them convenient to draw. The black strand is special in
// that it holds conflicting events as well as color settings for allday on