Merge "Make intents unique to AOSP"

main
Kurt Partridge 2013-06-12 18:11:16 +00:00 committed by Android (Google) Code Review
commit 3d9ebf213c
3 changed files with 14 additions and 12 deletions

View File

@ -109,7 +109,7 @@
<receiver android:name=".DictionaryPackInstallBroadcastReceiver"> <receiver android:name=".DictionaryPackInstallBroadcastReceiver">
<intent-filter> <intent-filter>
<action android:name="com.android.inputmethod.dictionarypack.UNKNOWN_CLIENT" /> <action android:name="com.android.inputmethod.dictionarypack.aosp.UNKNOWN_CLIENT" />
</intent-filter> </intent-filter>
</receiver> </receiver>
@ -129,7 +129,7 @@
<intent-filter> <intent-filter>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE" /> <action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
<action android:name="android.intent.action.DATE_CHANGED" /> <action android:name="android.intent.action.DATE_CHANGED" />
<action android:name="com.android.inputmethod.latin.dictionarypack.UPDATE_NOW" /> <action android:name="com.android.inputmethod.dictionarypack.aosp.UPDATE_NOW" />
</intent-filter> </intent-filter>
</receiver> </receiver>

View File

@ -28,13 +28,13 @@ public class DictionaryPackConstants {
* The root domain for the dictionary pack, upon which authorities and actions will append * The root domain for the dictionary pack, upon which authorities and actions will append
* their own distinctive strings. * their own distinctive strings.
*/ */
private static final String DICTIONARY_DOMAIN = "com.android.inputmethod.dictionarypack"; private static final String DICTIONARY_DOMAIN = "com.android.inputmethod.dictionarypack.aosp";
/** /**
* Authority for the ContentProvider protocol. * Authority for the ContentProvider protocol.
*/ */
// TODO: find some way to factorize this string with the one in the resources // TODO: find some way to factorize this string with the one in the resources
public static final String AUTHORITY = DICTIONARY_DOMAIN + ".aosp"; public static final String AUTHORITY = DICTIONARY_DOMAIN;
/** /**
* The action of the intent for publishing that new dictionary data is available. * The action of the intent for publishing that new dictionary data is available.
@ -52,7 +52,14 @@ public class DictionaryPackConstants {
*/ */
public static final String UNKNOWN_DICTIONARY_PROVIDER_CLIENT = DICTIONARY_DOMAIN public static final String UNKNOWN_DICTIONARY_PROVIDER_CLIENT = DICTIONARY_DOMAIN
+ ".UNKNOWN_CLIENT"; + ".UNKNOWN_CLIENT";
// In the above intents, the name of the string extra that contains the name of the client // In the above intents, the name of the string extra that contains the name of the client
// we want information about. // we want information about.
public static final String DICTIONARY_PROVIDER_CLIENT_EXTRA = "client"; public static final String DICTIONARY_PROVIDER_CLIENT_EXTRA = "client";
/**
* The action of the intent to tell the dictionary provider to update now.
*/
public static final String UPDATE_NOW_INTENT_ACTION = DICTIONARY_DOMAIN
+ ".UPDATE_NOW";
} }

View File

@ -54,12 +54,7 @@ public final class DictionaryService extends Service {
/** /**
* The package name, to use in the intent actions. * The package name, to use in the intent actions.
*/ */
private static final String PACKAGE_NAME = "com.android.android.inputmethod.latin"; private static final String PACKAGE_NAME = "com.android.inputmethod.latin";
/**
* The action of the intent to tell the dictionary provider to update now.
*/
private static final String UPDATE_NOW_INTENT_ACTION = PACKAGE_NAME + ".UPDATE_NOW";
/** /**
* The action of the date changing, used to schedule a periodic freshness check * The action of the date changing, used to schedule a periodic freshness check
@ -173,7 +168,7 @@ public final class DictionaryService extends Service {
// at midnight local time, but it may happen if the user changes the date // at midnight local time, but it may happen if the user changes the date
// by hand or something similar happens. // by hand or something similar happens.
checkTimeAndMaybeSetupUpdateAlarm(context); checkTimeAndMaybeSetupUpdateAlarm(context);
} else if (UPDATE_NOW_INTENT_ACTION.equals(intent.getAction())) { } else if (DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION.equals(intent.getAction())) {
// Intent to trigger an update now. // Intent to trigger an update now.
UpdateHandler.update(context, false); UpdateHandler.update(context, false);
} else { } else {
@ -196,7 +191,7 @@ public final class DictionaryService extends Service {
// It doesn't matter too much if this is very inexact. // It doesn't matter too much if this is very inexact.
final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis();
final long alarmTime = now + new Random().nextInt(MAX_ALARM_DELAY); final long alarmTime = now + new Random().nextInt(MAX_ALARM_DELAY);
final Intent updateIntent = new Intent(DictionaryService.UPDATE_NOW_INTENT_ACTION); final Intent updateIntent = new Intent(DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION);
final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0,
updateIntent, PendingIntent.FLAG_CANCEL_CURRENT); updateIntent, PendingIntent.FLAG_CANCEL_CURRENT);