summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2009-03-18 11:33:14 -0700
committerJean-Baptiste Queru <jbq@google.com>2009-03-18 11:33:14 -0700
commit2a73de7b21a89aa2ba4c254d28658b49793425b2 (patch)
treeded5bcd581464b4174d81c373044b6d36eee58d2 /packages
parent42e48026b21a962e5bf40344d738665ecbd9d74d (diff)
parentba87e3e6c985e7175152993b5efcc7dd2f0e1c93 (diff)
downloadframeworks_base-2a73de7b21a89aa2ba4c254d28658b49793425b2.zip
frameworks_base-2a73de7b21a89aa2ba4c254d28658b49793425b2.tar.gz
frameworks_base-2a73de7b21a89aa2ba4c254d28658b49793425b2.tar.bz2
Merge commit 'remotes/korg/cupcake' into merge
Conflicts: core/java/android/view/animation/TranslateAnimation.java core/jni/Android.mk core/res/res/values-en-rGB/strings.xml libs/audioflinger/AudioFlinger.cpp libs/surfaceflinger/LayerScreenshot.cpp packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
Diffstat (limited to 'packages')
-rw-r--r--packages/SettingsProvider/Android.mk2
-rw-r--r--packages/SettingsProvider/etc/Android.mk4
-rw-r--r--packages/SettingsProvider/etc/bookmarks.xml52
-rw-r--r--packages/SettingsProvider/etc/favorites.xml3
-rw-r--r--packages/SettingsProvider/res/values/defaults.xml41
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java154
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java36
-rw-r--r--packages/SubscribedFeedsProvider/AndroidManifest.xml5
-rw-r--r--packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsBroadcastReceiver.java41
-rw-r--r--packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsIntentService.java (renamed from packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java)113
10 files changed, 334 insertions, 117 deletions
diff --git a/packages/SettingsProvider/Android.mk b/packages/SettingsProvider/Android.mk
index 330a673..724e988 100644
--- a/packages/SettingsProvider/Android.mk
+++ b/packages/SettingsProvider/Android.mk
@@ -1,7 +1,7 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := user development
+LOCAL_MODULE_TAGS := user
LOCAL_SRC_FILES := $(call all-subdir-java-files)
diff --git a/packages/SettingsProvider/etc/Android.mk b/packages/SettingsProvider/etc/Android.mk
index e3f958c..d73175f 100644
--- a/packages/SettingsProvider/etc/Android.mk
+++ b/packages/SettingsProvider/etc/Android.mk
@@ -21,7 +21,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := bookmarks.xml
-LOCAL_MODULE_TAGS := user development
+LOCAL_MODULE_TAGS := user
# This will install the file in /system/etc
#
@@ -36,7 +36,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := favorites.xml
-LOCAL_MODULE_TAGS := user development
+LOCAL_MODULE_TAGS := user
# This will install the file in /system/etc
#
diff --git a/packages/SettingsProvider/etc/bookmarks.xml b/packages/SettingsProvider/etc/bookmarks.xml
index 235e2ed..5fb6608 100644
--- a/packages/SettingsProvider/etc/bookmarks.xml
+++ b/packages/SettingsProvider/etc/bookmarks.xml
@@ -15,14 +15,44 @@
-->
<bookmarks>
- <bookmark package="com.android.browser" class="com.android.browser.BrowserActivity" shortcut="b" />
- <bookmark package="com.android.calendar" class="com.android.calendar.LaunchActivity" shortcut="l" />
- <bookmark package="com.android.contacts" class="com.android.contacts.DialtactsContactsEntryActivity" shortcut="c" />
- <bookmark package="com.google.android.gm" class="com.google.android.gm.ConversationListActivityGmail" shortcut="g" />
- <bookmark package="com.android.email" class="com.android.email.activity.Welcome" shortcut="e" />
- <bookmark package="com.android.im" class="com.android.im.app.ChooseAccountActivity" shortcut="i" />
- <bookmark package="com.google.android.apps.maps" class="com.google.android.maps.MapsActivity" shortcut="m" />
- <bookmark package="com.android.music" class="com.android.music.MusicBrowserActivity" shortcut="p" />
- <bookmark package="com.android.mms" class="com.android.mms.ui.ConversationList" shortcut="s" />
- <bookmark package="com.google.android.youtube" class="com.google.android.youtube.HomePage" shortcut="y" />
-</bookmarks>
+ <bookmark
+ package="com.android.browser"
+ class="com.android.browser.BrowserActivity"
+ shortcut="b" />
+ <bookmark
+ package="com.android.contacts"
+ class="com.android.contacts.DialtactsContactsEntryActivity"
+ shortcut="c" />
+ <bookmark
+ package="com.android.email"
+ class="com.android.email.activity.Welcome"
+ shortcut="e" />
+ <bookmark
+ package="com.google.android.gm"
+ class="com.google.android.gm.ConversationListActivityGmail"
+ shortcut="g" />
+ <bookmark
+ package="com.android.providers.im"
+ class="com.android.providers.im.LandingPage"
+ shortcut="i" />
+ <bookmark
+ package="com.android.calendar"
+ class="com.android.calendar.LaunchActivity"
+ shortcut="l" />
+ <bookmark
+ package="com.google.android.apps.maps"
+ class="com.google.android.maps.MapsActivity"
+ shortcut="m" />
+ <bookmark
+ package="com.android.music"
+ class="com.android.music.MusicBrowserActivity"
+ shortcut="p" />
+ <bookmark
+ package="com.android.mms"
+ class="com.android.mms.ui.ConversationList"
+ shortcut="s" />
+ <bookmark
+ package="com.google.android.youtube"
+ class="com.google.android.youtube.HomePage"
+ shortcut="y" />
+</bookmarks> \ No newline at end of file
diff --git a/packages/SettingsProvider/etc/favorites.xml b/packages/SettingsProvider/etc/favorites.xml
index 0ecf8a6..ae74b8e 100644
--- a/packages/SettingsProvider/etc/favorites.xml
+++ b/packages/SettingsProvider/etc/favorites.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
+<!-- Copyright (C) 2009 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -19,4 +19,5 @@
<favorite package="com.android.contacts" class="com.android.contacts.DialtactsContactsEntryActivity" screen="1" x="1" y="3" />
<favorite package="com.android.browser" class="com.android.browser.BrowserActivity" screen="1" x="2" y="3" />
<favorite package="com.google.android.apps.maps" class="com.google.android.maps.MapsActivity" screen="1" x="3" y="3" />
+ <favorite package="com.android.vending" class="com.android.vending.AssetBrowserActivity" screen="1" x="0" y="2" />
</favorites>
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
new file mode 100644
index 0000000..275ff3a
--- /dev/null
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2009, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<resources>
+ <bool name="def_dim_screen">true</bool>
+ <integer name="def_screen_off_timeout">60000</integer>
+ <bool name="def_airplane_mode_on">false</bool>
+ <!-- Comma-separated list of bluetooth, wifi, and cell. -->
+ <string name="def_airplane_mode_radios">cell,bluetooth,wifi</string>
+ <bool name="def_auto_time">true</bool>
+ <bool name="def_accelerometer_rotation">true</bool>
+ <!-- Default screen brightness, from 0 to 255. 102 is 40%. -->
+ <integer name="def_screen_brightness">102</integer>
+ <fraction name="def_window_animation_scale">100%</fraction>
+ <fraction name="def_window_transition_scale">0%</fraction>
+
+ <bool name="def_bluetooth_on">false</bool>
+ <bool name="def_install_non_market_apps">false</bool>
+ <!-- Comma-separated list of providers. -->
+ <string name="def_location_providers_allowed">network</string>
+ <!-- 0 == mobile, 1 == wifi. -->
+ <integer name="def_network_preference">1</integer>
+ <bool name="def_usb_mass_storage_enabled">true</bool>
+ <bool name="def_wifi_on">false</bool>
+ <bool name="def_networks_available_notification_on">true</bool>
+</resources>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 2182271..c6f54a3 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -22,11 +22,11 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
+import android.content.res.Resources;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement;
-import android.location.LocationManager;
import android.media.AudioManager;
import android.media.AudioService;
import android.net.ConnectivityManager;
@@ -63,7 +63,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
private static final String TAG = "SettingsProvider";
private static final String DATABASE_NAME = "settings.db";
- private static final int DATABASE_VERSION = 31;
+ private static final int DATABASE_VERSION = 34;
private Context mContext;
@@ -332,6 +332,58 @@ public class DatabaseHelper extends SQLiteOpenHelper {
upgradeVersion = 31;
}
+ if (upgradeVersion == 31) {
+ /*
+ * Animations are now managed in preferences, and may be
+ * enabled or disabled based on product resources.
+ */
+ db.beginTransaction();
+ try {
+ db.execSQL("DELETE FROM system WHERE name='"
+ + Settings.System.WINDOW_ANIMATION_SCALE + "'");
+ db.execSQL("DELETE FROM system WHERE name='"
+ + Settings.System.TRANSITION_ANIMATION_SCALE + "'");
+ SQLiteStatement stmt = db.compileStatement("INSERT INTO system(name,value)"
+ + " VALUES(?,?);");
+ loadDefaultAnimationSettings(stmt);
+ stmt.close();
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ }
+ upgradeVersion = 32;
+ }
+
+ if (upgradeVersion == 32) {
+ // The Wi-Fi watchdog SSID list is now seeded with the value of
+ // the property ro.com.android.wifi-watchlist
+ String wifiWatchList = SystemProperties.get("ro.com.android.wifi-watchlist");
+ if (!TextUtils.isEmpty(wifiWatchList)) {
+ db.beginTransaction();
+ try {
+ db.execSQL("INSERT OR IGNORE INTO secure(name,value) values('" +
+ Settings.Secure.WIFI_WATCHDOG_WATCH_LIST + "','" +
+ wifiWatchList + "');");
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ }
+ }
+ upgradeVersion = 33;
+ }
+
+ if (upgradeVersion == 33) {
+ // Set the default zoom controls to: tap-twice to bring up +/-
+ db.beginTransaction();
+ try {
+ db.execSQL("INSERT INTO system(name,value) values('zoom','2');");
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ }
+ upgradeVersion = 34;
+ }
+
if (upgradeVersion != currentVersion) {
Log.w(TAG, "Got stuck trying to upgrade from version " + upgradeVersion
+ ", must wipe the settings provider");
@@ -529,28 +581,31 @@ public class DatabaseHelper extends SQLiteOpenHelper {
SQLiteStatement stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
+ " VALUES(?,?);");
- loadSetting(stmt, Settings.System.DIM_SCREEN, 1);
+ Resources r = mContext.getResources();
+ loadBooleanSetting(stmt, Settings.System.DIM_SCREEN,
+ R.bool.def_dim_screen);
loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN,
"1".equals(SystemProperties.get("ro.kernel.qemu")) ? 1 : 0);
- loadSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, 60000);
- // Allow airplane mode to turn off cell radio
- loadSetting(stmt, Settings.System.AIRPLANE_MODE_RADIOS,
- Settings.System.RADIO_CELL + ","
- + Settings.System.RADIO_BLUETOOTH + "," + Settings.System.RADIO_WIFI);
+ loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
+ R.integer.def_screen_off_timeout);
+
+ loadBooleanSetting(stmt, Settings.System.AIRPLANE_MODE_ON,
+ R.bool.def_airplane_mode_on);
- loadSetting(stmt, Settings.System.AIRPLANE_MODE_ON, 0);
+ loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_RADIOS,
+ R.string.def_airplane_mode_radios);
- loadSetting(stmt, Settings.System.AUTO_TIME, 1); // Sync time to NITZ
+ loadBooleanSetting(stmt, Settings.System.AUTO_TIME,
+ R.bool.def_auto_time); // Sync time to NITZ
- // Set default brightness to 40%
- loadSetting(stmt, Settings.System.SCREEN_BRIGHTNESS,
- (int) (android.os.Power.BRIGHTNESS_ON * 0.4f));
+ loadIntegerSetting(stmt, Settings.System.SCREEN_BRIGHTNESS,
+ R.integer.def_screen_brightness);
- // Enable normal window animations (menus, toasts); disable
- // activity transition animations.
- loadSetting(stmt, Settings.System.WINDOW_ANIMATION_SCALE, "1");
- loadSetting(stmt, Settings.System.TRANSITION_ANIMATION_SCALE, "1");
+ loadDefaultAnimationSettings(stmt);
+ loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION,
+ R.bool.def_accelerometer_rotation);
+
// Default date format based on build
loadSetting(stmt, Settings.System.DATE_FORMAT,
SystemProperties.get("ro.com.android.dateformat",
@@ -558,12 +613,19 @@ public class DatabaseHelper extends SQLiteOpenHelper {
stmt.close();
}
+ private void loadDefaultAnimationSettings(SQLiteStatement stmt) {
+ loadFractionSetting(stmt, Settings.System.WINDOW_ANIMATION_SCALE,
+ R.fraction.def_window_animation_scale, 1);
+ loadFractionSetting(stmt, Settings.System.TRANSITION_ANIMATION_SCALE,
+ R.fraction.def_window_transition_scale, 1);
+ }
+
private void loadSecureSettings(SQLiteDatabase db) {
SQLiteStatement stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+ " VALUES(?,?);");
- // Bluetooth off
- loadSetting(stmt, Settings.Secure.BLUETOOTH_ON, 0);
+ loadBooleanSetting(stmt, Settings.Secure.BLUETOOTH_ON,
+ R.bool.def_bluetooth_on);
// Data roaming default, based on build
loadSetting(stmt, Settings.Secure.DATA_ROAMING,
@@ -571,27 +633,36 @@ public class DatabaseHelper extends SQLiteOpenHelper {
SystemProperties.get("ro.com.android.dataroaming",
"false")) ? 1 : 0);
- // Don't allow non-market apps to be installed
- loadSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS, 0);
+ loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS,
+ R.bool.def_install_non_market_apps);
- // Set the default location providers to network based (cell-id)
- loadSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
- LocationManager.NETWORK_PROVIDER);
+ loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
+ R.string.def_location_providers_allowed);
- loadSetting(stmt, Settings.Secure.NETWORK_PREFERENCE,
- ConnectivityManager.DEFAULT_NETWORK_PREFERENCE);
-
- // USB mass storage on by default
- loadSetting(stmt, Settings.Secure.USB_MASS_STORAGE_ENABLED, 1);
+ loadIntegerSetting(stmt, Settings.Secure.NETWORK_PREFERENCE,
+ R.integer.def_network_preference);
- // WIFI on, notify about available networks
- loadSetting(stmt, Settings.Secure.WIFI_ON, 0);
- loadSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1);
+ loadBooleanSetting(stmt, Settings.Secure.USB_MASS_STORAGE_ENABLED,
+ R.bool.def_usb_mass_storage_enabled);
+ loadBooleanSetting(stmt, Settings.Secure.WIFI_ON,
+ R.bool.def_wifi_on);
+ loadBooleanSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
+ R.bool.def_networks_available_notification_on);
+
+ String wifiWatchList = SystemProperties.get("ro.com.android.wifi-watchlist");
+ if (!TextUtils.isEmpty(wifiWatchList)) {
+ loadSetting(stmt, Settings.Secure.WIFI_WATCHDOG_WATCH_LIST, wifiWatchList);
+ }
+
// Don't do this. The SystemServer will initialize ADB_ENABLED from a
// persistent system property instead.
//loadSetting(stmt, Settings.Secure.ADB_ENABLED, 0);
+ // Allow mock locations default, based on build
+ loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION,
+ "1".equals(SystemProperties.get("ro.allow.mock.location")) ? 1 : 0);
+
stmt.close();
}
@@ -600,4 +671,23 @@ public class DatabaseHelper extends SQLiteOpenHelper {
stmt.bindString(2, value.toString());
stmt.execute();
}
+
+ private void loadStringSetting(SQLiteStatement stmt, String key, int resid) {
+ loadSetting(stmt, key, mContext.getResources().getString(resid));
+ }
+
+ private void loadBooleanSetting(SQLiteStatement stmt, String key, int resid) {
+ loadSetting(stmt, key,
+ mContext.getResources().getBoolean(resid) ? "1" : "0");
+ }
+
+ private void loadIntegerSetting(SQLiteStatement stmt, String key, int resid) {
+ loadSetting(stmt, key,
+ Integer.toString(mContext.getResources().getInteger(resid)));
+ }
+
+ private void loadFractionSetting(SQLiteStatement stmt, String key, int resid, int base) {
+ loadSetting(stmt, key,
+ Float.toString(mContext.getResources().getFraction(resid, base, base)));
+ }
}
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 0101ece..8d52070 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -40,6 +40,9 @@ public class SettingsProvider extends ContentProvider {
private static final String TAG = "SettingsProvider";
private static final boolean LOCAL_LOGV = false;
+ private static final String TABLE_FAVORITES = "favorites";
+ private static final String TABLE_OLD_FAVORITES = "old_favorites";
+
protected DatabaseHelper mOpenHelper;
/**
@@ -47,7 +50,7 @@ public class SettingsProvider extends ContentProvider {
* used to access the corresponding database rows.
*/
private static class SqlArguments {
- public final String table;
+ public String table;
public final String where;
public final String[] args;
@@ -175,17 +178,30 @@ public class SettingsProvider extends ContentProvider {
@Override
public Cursor query(Uri url, String[] select, String where, String[] whereArgs, String sort) {
SqlArguments args = new SqlArguments(url, where, whereArgs);
+ SQLiteDatabase db = mOpenHelper.getReadableDatabase();
+
// The favorites table was moved from this provider to a provider inside Home
// Home still need to query this table to upgrade from pre-cupcake builds
// However, a cupcake+ build with no data does not contain this table which will
// cause an exception in the SQL stack. The following line is a special case to
// let the caller of the query have a chance to recover and avoid the exception
- if ("favorites".equals(args.table)) return null;
+ if (TABLE_FAVORITES.equals(args.table)) {
+ return null;
+ } else if (TABLE_OLD_FAVORITES.equals(args.table)) {
+ args.table = TABLE_FAVORITES;
+ Cursor cursor = db.rawQuery("PRAGMA table_info(favorites);", null);
+ if (cursor != null) {
+ boolean exists = cursor.getCount() > 0;
+ cursor.close();
+ if (!exists) return null;
+ } else {
+ return null;
+ }
+ }
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(args.table);
- SQLiteDatabase db = mOpenHelper.getReadableDatabase();
Cursor ret = qb.query(db, select, args.where, args.args, null, null, sort);
ret.setNotificationUri(getContext().getContentResolver(), url);
return ret;
@@ -206,6 +222,9 @@ public class SettingsProvider extends ContentProvider {
@Override
public int bulkInsert(Uri uri, ContentValues[] values) {
SqlArguments args = new SqlArguments(uri);
+ if (TABLE_FAVORITES.equals(args.table)) {
+ return 0;
+ }
checkWritePermissions(args);
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
@@ -228,6 +247,9 @@ public class SettingsProvider extends ContentProvider {
@Override
public Uri insert(Uri url, ContentValues initialValues) {
SqlArguments args = new SqlArguments(url);
+ if (TABLE_FAVORITES.equals(args.table)) {
+ return null;
+ }
checkWritePermissions(args);
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
@@ -243,6 +265,11 @@ public class SettingsProvider extends ContentProvider {
@Override
public int delete(Uri url, String where, String[] whereArgs) {
SqlArguments args = new SqlArguments(url, where, whereArgs);
+ if (TABLE_FAVORITES.equals(args.table)) {
+ return 0;
+ } else if (TABLE_OLD_FAVORITES.equals(args.table)) {
+ args.table = TABLE_FAVORITES;
+ }
checkWritePermissions(args);
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
@@ -255,6 +282,9 @@ public class SettingsProvider extends ContentProvider {
@Override
public int update(Uri url, ContentValues initialValues, String where, String[] whereArgs) {
SqlArguments args = new SqlArguments(url, where, whereArgs);
+ if (TABLE_FAVORITES.equals(args.table)) {
+ return 0;
+ }
checkWritePermissions(args);
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
diff --git a/packages/SubscribedFeedsProvider/AndroidManifest.xml b/packages/SubscribedFeedsProvider/AndroidManifest.xml
index 94c4be5..6ecda48 100644
--- a/packages/SubscribedFeedsProvider/AndroidManifest.xml
+++ b/packages/SubscribedFeedsProvider/AndroidManifest.xml
@@ -6,7 +6,7 @@
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.SUBSCRIBED_FEEDS_READ" />
<uses-permission android:name="android.permission.SUBSCRIBED_FEEDS_WRITE" />
-
+
<application android:process="system"
android:allowClearUserData="false"
android:icon="@drawable/app_icon"
@@ -17,7 +17,7 @@
android:multiprocess="false"
android:readPermission="android.permission.SUBSCRIBED_FEEDS_READ"
android:writePermission="android.permission.SUBSCRIBED_FEEDS_WRITE" />
- <receiver android:name="SubscribedFeedsService">
+ <receiver android:name="SubscribedFeedsBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.GTALK_DATA_MESSAGE_RECEIVED" />
<category android:name="GSYNC_TICKLE"/>
@@ -29,5 +29,6 @@
<action android:name="com.android.subscribedfeeds.action.REFRESH" />
</intent-filter>
</receiver>
+ <service android:name="SubscribedFeedsIntentService"/>
</application>
</manifest>
diff --git a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsBroadcastReceiver.java b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsBroadcastReceiver.java
new file mode 100644
index 0000000..3513215
--- /dev/null
+++ b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsBroadcastReceiver.java
@@ -0,0 +1,41 @@
+/*
+** Copyright 2006, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+package com.android.providers.subscribedfeeds;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+/**
+ * Handles the XMPP_CONNECTED_ACTION intent by updating all the
+ * subscribed feeds with the new jabber id and initiating a sync
+ * for all subscriptions.
+ *
+ * Handles the TICKLE_ACTION intent by finding the matching
+ * subscribed feed and intiating a sync for it.
+ */
+public class SubscribedFeedsBroadcastReceiver extends BroadcastReceiver {
+
+ private static final String TAG = "Sync";
+
+ public void onReceive(Context context, Intent intent) {
+ if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "Received intent " + intent);
+ intent.setClass(context, SubscribedFeedsIntentService.class);
+ context.startService(intent);
+ }
+}
diff --git a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsIntentService.java
index 4a1de59..df599c7 100644
--- a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java
+++ b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsIntentService.java
@@ -1,61 +1,35 @@
-/*
-** Copyright 2006, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
package com.android.providers.subscribedfeeds;
-import android.app.AlarmManager;
-import android.app.PendingIntent;
-import android.content.BroadcastReceiver;
+import android.content.Intent;
+import android.content.Context;
import android.content.ContentResolver;
import android.content.ContentValues;
-import android.content.Context;
-import android.content.Intent;
import android.content.SharedPreferences;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Bundle;
-import android.provider.SubscribedFeeds;
+import android.util.Log;
+import android.util.Config;
+import android.util.EventLog;
+import android.app.IntentService;
import android.provider.Sync;
+import android.provider.SubscribedFeeds;
import android.provider.SyncConstValue;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteFullException;
+import android.app.AlarmManager;
+import android.app.PendingIntent;
+import android.os.Bundle;
+import android.os.Debug;
import android.text.TextUtils;
-import android.util.Config;
-import android.util.EventLog;
-import android.util.Log;
+import android.net.Uri;
import java.util.ArrayList;
import java.util.Calendar;
/**
- * Handles the XMPP_CONNECTED_ACTION intent by updating all the
- * subscribed feeds with the new jabber id and initiating a sync
- * for all subscriptions.
- *
- * Handles the TICKLE_ACTION intent by finding the matching
- * subscribed feed and intiating a sync for it.
+ * A service to handle various intents asynchronously.
*/
-public class SubscribedFeedsService extends BroadcastReceiver {
-
+public class SubscribedFeedsIntentService extends IntentService {
private static final String TAG = "Sync";
- private static final String SUBSCRIBED_FEEDS_REFRESH_ACTION =
- "com.android.subscribedfeeds.action.REFRESH";
-
- private static final Intent sSubscribedFeedsRefreshIntent =
- new Intent(SUBSCRIBED_FEEDS_REFRESH_ACTION);
-
private static final String[] sAccountProjection =
new String[] {SubscribedFeeds.Accounts._SYNC_ACCOUNT};
@@ -66,11 +40,20 @@ public class SubscribedFeedsService extends BroadcastReceiver {
private static final String sSubscribedFeedsPrefs = "subscribedFeeds";
- static final int LOG_TICKLE = 2742;
+ private static final String GTALK_DATA_MESSAGE_RECEIVED =
+ "android.intent.action.GTALK_DATA_MESSAGE_RECEIVED";
- public void onReceive(Context context, Intent intent) {
- if ("android.intent.action.GTALK_DATA_MESSAGE_RECEIVED".equals(
- intent.getAction())) {
+ private static final String SUBSCRIBED_FEEDS_REFRESH_ACTION =
+ "com.android.subscribedfeeds.action.REFRESH";
+
+ private static final int LOG_TICKLE = 2742;
+
+ public SubscribedFeedsIntentService() {
+ super("SubscribedFeedsIntentService");
+ }
+
+ protected void onHandleIntent(Intent intent) {
+ if (GTALK_DATA_MESSAGE_RECEIVED.equals(intent.getAction())) {
boolean fromTrustedServer = intent.getBooleanExtra("from_trusted_server", false);
if (fromTrustedServer) {
String account = intent.getStringExtra("account");
@@ -88,7 +71,7 @@ public class SubscribedFeedsService extends BroadcastReceiver {
+ account + " - " + token);
}
- handleTickle(context, account, token);
+ handleTickle(this, account, token);
} else {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "Ignoring tickle -- not from trusted server.");
@@ -101,25 +84,23 @@ public class SubscribedFeedsService extends BroadcastReceiver {
Log.d(TAG, "Received boot completed action");
}
// load the time from the shared preferences and schedule an alarm
- long refreshTime = context.getSharedPreferences(
+ long refreshTime = getSharedPreferences(
sSubscribedFeedsPrefs,
Context.MODE_WORLD_READABLE).getLong(sRefreshTime, 0);
- scheduleRefresh(context, refreshTime);
- } else if (sSubscribedFeedsRefreshIntent.getAction().equals(
- intent.getAction())) {
+ scheduleRefresh(this, refreshTime);
+ } else if (SUBSCRIBED_FEEDS_REFRESH_ACTION.equals(intent.getAction())) {
if (Config.LOGD) {
Log.d(TAG, "Received sSubscribedFeedsRefreshIntent");
}
- handleRefreshAlarm(context);
+ handleRefreshAlarm(this);
}
}
-
private void scheduleRefresh(Context context, long when) {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(
Context.ALARM_SERVICE);
- PendingIntent sender = PendingIntent.getBroadcast(context,
- 0, sSubscribedFeedsRefreshIntent, 0);
- alarmManager.set(AlarmManager.RTC, when, sender);
+ PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
+ 0, new Intent(SUBSCRIBED_FEEDS_REFRESH_ACTION), 0);
+ alarmManager.set(AlarmManager.RTC, when, pendingIntent);
}
private void handleTickle(Context context, String account, String feed) {
@@ -189,20 +170,22 @@ public class SubscribedFeedsService extends BroadcastReceiver {
// mark the feeds dirty, by setting the accounts to the same value,
// which will trigger a sync.
- ContentValues values = new ContentValues();
- for (String account : accounts) {
- values.put(SyncConstValue._SYNC_ACCOUNT, account);
- contentResolver.update(SubscribedFeeds.Feeds.CONTENT_URI, values,
- SubscribedFeeds.Feeds._SYNC_ACCOUNT + "=?", new String[] {account});
+ try {
+ ContentValues values = new ContentValues();
+ for (String account : accounts) {
+ values.put(SyncConstValue._SYNC_ACCOUNT, account);
+ contentResolver.update(SubscribedFeeds.Feeds.CONTENT_URI, values,
+ SubscribedFeeds.Feeds._SYNC_ACCOUNT + "=?", new String[] {account});
+ }
+ } catch (SQLiteFullException e) {
+ Log.w(TAG, "disk full while trying to mark the feeds as dirty, skipping");
}
// Schedule a refresh.
long refreshTime = Calendar.getInstance().getTimeInMillis() + SUBSCRIPTION_REFRESH_INTERVAL;
scheduleRefresh(context, refreshTime);
- SharedPreferences preferences = context
- .getSharedPreferences(sSubscribedFeedsPrefs,
- Context.MODE_WORLD_READABLE);
- SharedPreferences.Editor editor = preferences.edit();
+ SharedPreferences.Editor editor = context.getSharedPreferences(sSubscribedFeedsPrefs,
+ Context.MODE_WORLD_READABLE).edit();
editor.putLong(sRefreshTime, refreshTime);
editor.commit();
}