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:
parent
fd96929f8f
commit
e568f1bd37
|
@ -37,4 +37,8 @@
|
||||||
<string name="mailbox_name_server_starred" translatable="false">Starred</string>
|
<string name="mailbox_name_server_starred" translatable="false">Starred</string>
|
||||||
<!-- Do Not Translate. This is the system name of the "all unread" folder. -->
|
<!-- Do Not Translate. This is the system name of the "all unread" folder. -->
|
||||||
<string name="mailbox_name_server_all_unread" translatable="false">Unread</string>
|
<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>
|
</resources>
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.content.ContentUris;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.OperationApplicationException;
|
import android.content.OperationApplicationException;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
@ -32,6 +33,7 @@ import android.os.RemoteException;
|
||||||
|
|
||||||
import com.android.emailcommon.utility.TextUtilities;
|
import com.android.emailcommon.utility.TextUtilities;
|
||||||
import com.android.emailcommon.utility.Utility;
|
import com.android.emailcommon.utility.Utility;
|
||||||
|
import com.android.emailcommon.R;
|
||||||
import com.android.mail.providers.UIProvider;
|
import com.android.mail.providers.UIProvider;
|
||||||
import com.android.mail.utils.LogUtils;
|
import com.android.mail.utils.LogUtils;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
@ -112,7 +114,6 @@ public abstract class EmailContent {
|
||||||
public abstract void restore (Cursor cursor);
|
public abstract void restore (Cursor cursor);
|
||||||
|
|
||||||
|
|
||||||
public static String PACKAGE_NAME;
|
|
||||||
public static String EMAIL_PACKAGE_NAME;
|
public static String EMAIL_PACKAGE_NAME;
|
||||||
public static String AUTHORITY;
|
public static String AUTHORITY;
|
||||||
// The notifier authority is used to send notifications regarding changes to messages (insert,
|
// 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) {
|
public static synchronized void init(Context context) {
|
||||||
if (AUTHORITY == null) {
|
if (AUTHORITY == null) {
|
||||||
PACKAGE_NAME = context.getPackageName();
|
final Resources res = context.getResources();
|
||||||
EMAIL_PACKAGE_NAME = PACKAGE_NAME;
|
EMAIL_PACKAGE_NAME = res.getString(R.string.email_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";
|
|
||||||
}
|
|
||||||
AUTHORITY = EMAIL_PACKAGE_NAME + ".provider";
|
AUTHORITY = EMAIL_PACKAGE_NAME + ".provider";
|
||||||
LogUtils.d("EmailContent", "init for " + AUTHORITY);
|
LogUtils.d("EmailContent", "init for " + AUTHORITY);
|
||||||
NOTIFIER_AUTHORITY = EMAIL_PACKAGE_NAME + ".notifier";
|
NOTIFIER_AUTHORITY = EMAIL_PACKAGE_NAME + ".notifier";
|
||||||
|
|
|
@ -404,10 +404,10 @@ public class Mailbox extends EmailContent implements MailboxColumns, Parcelable
|
||||||
if (c.moveToFirst()) {
|
if (c.moveToFirst()) {
|
||||||
mailbox = getContent(c, Mailbox.class);
|
mailbox = getContent(c, Mailbox.class);
|
||||||
if (c.moveToNext()) {
|
if (c.moveToNext()) {
|
||||||
LogUtils.w(Logging.LOG_TAG, "Multiple mailboxes named \"" + path + "\"");
|
LogUtils.w(Logging.LOG_TAG, "Multiple mailboxes named \"%s\"", path);
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
return mailbox;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue