Use resources for authority/package name

This will better handle the case where the Email package name
changes from the "orignal package name"

Bug: 9763397

Change-Id: I8e01620551ce473e389e6a13963caaf685aea221
This commit is contained in:
Paul Westbrook 2013-08-20 17:25:59 -07:00
parent fd96929f8f
commit e568f1bd37
3 changed files with 10 additions and 10 deletions

View File

@ -37,4 +37,8 @@
<string name="mailbox_name_server_starred" translatable="false">Starred</string>
<!-- Do Not Translate. This is the system name of the "all unread" folder. -->
<string name="mailbox_name_server_all_unread" translatable="false">Unread</string>
<!-- Do Not Translate. This is the authority for the email package name -->
<string name="email_package_name" translatable="false">com.android.email</string>
</resources>

View File

@ -23,6 +23,7 @@ import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.OperationApplicationException;
import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
import android.os.Environment;
@ -32,6 +33,7 @@ import android.os.RemoteException;
import com.android.emailcommon.utility.TextUtilities;
import com.android.emailcommon.utility.Utility;
import com.android.emailcommon.R;
import com.android.mail.providers.UIProvider;
import com.android.mail.utils.LogUtils;
import com.google.common.annotations.VisibleForTesting;
@ -112,7 +114,6 @@ public abstract class EmailContent {
public abstract void restore (Cursor cursor);
public static String PACKAGE_NAME;
public static String EMAIL_PACKAGE_NAME;
public static String AUTHORITY;
// The notifier authority is used to send notifications regarding changes to messages (insert,
@ -131,13 +132,8 @@ public abstract class EmailContent {
public static synchronized void init(Context context) {
if (AUTHORITY == null) {
PACKAGE_NAME = context.getPackageName();
EMAIL_PACKAGE_NAME = PACKAGE_NAME;
// If our package is com...exchange, the provider is com...email.provider
if (PACKAGE_NAME.endsWith("exchange")) {
int lastDot = EMAIL_PACKAGE_NAME.lastIndexOf('.');
EMAIL_PACKAGE_NAME = PACKAGE_NAME.substring(0, lastDot + 1) + "email";
}
final Resources res = context.getResources();
EMAIL_PACKAGE_NAME = res.getString(R.string.email_package_name);
AUTHORITY = EMAIL_PACKAGE_NAME + ".provider";
LogUtils.d("EmailContent", "init for " + AUTHORITY);
NOTIFIER_AUTHORITY = EMAIL_PACKAGE_NAME + ".notifier";

View File

@ -404,10 +404,10 @@ public class Mailbox extends EmailContent implements MailboxColumns, Parcelable
if (c.moveToFirst()) {
mailbox = getContent(c, Mailbox.class);
if (c.moveToNext()) {
LogUtils.w(Logging.LOG_TAG, "Multiple mailboxes named \"" + path + "\"");
LogUtils.w(Logging.LOG_TAG, "Multiple mailboxes named \"%s\"", path);
}
} else {
LogUtils.i(Logging.LOG_TAG, "Could not find mailbox at \"" + path + "\"");
LogUtils.i(Logging.LOG_TAG, "Could not find mailbox at \"%s\"", path);
}
return mailbox;
} finally {