Move HostAuth to top level class.
No other changes made. Change-Id: I1c6497c98abc0f99443ea42d8aed6295b263c123
This commit is contained in:
parent
182caacd47
commit
12b82d9374
|
@ -32,11 +32,8 @@ import android.os.Environment;
|
|||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.RemoteException;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -1434,7 +1431,7 @@ public abstract class EmailContent {
|
|||
if (mHostAuthKeySend != 0) {
|
||||
mHostAuthSend = HostAuth.restoreHostAuthWithId(context, mHostAuthKeySend);
|
||||
} else {
|
||||
mHostAuthSend = new EmailContent.HostAuth();
|
||||
mHostAuthSend = new HostAuth();
|
||||
}
|
||||
}
|
||||
return mHostAuthSend;
|
||||
|
@ -1445,7 +1442,7 @@ public abstract class EmailContent {
|
|||
if (mHostAuthKeyRecv != 0) {
|
||||
mHostAuthRecv = HostAuth.restoreHostAuthWithId(context, mHostAuthKeyRecv);
|
||||
} else {
|
||||
mHostAuthRecv = new EmailContent.HostAuth();
|
||||
mHostAuthRecv = new HostAuth();
|
||||
}
|
||||
}
|
||||
return mHostAuthRecv;
|
||||
|
@ -1935,12 +1932,12 @@ public abstract class EmailContent {
|
|||
|
||||
mHostAuthRecv = null;
|
||||
if (in.readByte() == 1) {
|
||||
mHostAuthRecv = new EmailContent.HostAuth(in);
|
||||
mHostAuthRecv = new HostAuth(in);
|
||||
}
|
||||
|
||||
mHostAuthSend = null;
|
||||
if (in.readByte() == 1) {
|
||||
mHostAuthSend = new EmailContent.HostAuth(in);
|
||||
mHostAuthSend = new HostAuth(in);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2312,333 +2309,6 @@ public abstract class EmailContent {
|
|||
static final String ACCOUNT_KEY = "accountKey";
|
||||
}
|
||||
|
||||
public static final class HostAuth extends EmailContent implements HostAuthColumns, Parcelable {
|
||||
public static final String TABLE_NAME = "HostAuth";
|
||||
@SuppressWarnings("hiding")
|
||||
public static final Uri CONTENT_URI = Uri.parse(EmailContent.CONTENT_URI + "/hostauth");
|
||||
|
||||
public static final int PORT_UNKNOWN = -1;
|
||||
|
||||
public static final int FLAG_NONE = 0x00; // No flags
|
||||
public static final int FLAG_SSL = 0x01; // Use SSL
|
||||
public static final int FLAG_TLS = 0x02; // Use TLS
|
||||
public static final int FLAG_AUTHENTICATE = 0x04; // Use name/password for authentication
|
||||
public static final int FLAG_TRUST_ALL = 0x08; // Trust all certificates
|
||||
// Mask of settings directly configurable by the user
|
||||
public static final int USER_CONFIG_MASK = 0x0b;
|
||||
|
||||
public String mProtocol;
|
||||
public String mAddress;
|
||||
public int mPort;
|
||||
public int mFlags;
|
||||
public String mLogin;
|
||||
public String mPassword;
|
||||
public String mDomain;
|
||||
|
||||
public static final int CONTENT_ID_COLUMN = 0;
|
||||
public static final int CONTENT_PROTOCOL_COLUMN = 1;
|
||||
public static final int CONTENT_ADDRESS_COLUMN = 2;
|
||||
public static final int CONTENT_PORT_COLUMN = 3;
|
||||
public static final int CONTENT_FLAGS_COLUMN = 4;
|
||||
public static final int CONTENT_LOGIN_COLUMN = 5;
|
||||
public static final int CONTENT_PASSWORD_COLUMN = 6;
|
||||
public static final int CONTENT_DOMAIN_COLUMN = 7;
|
||||
|
||||
public static final String[] CONTENT_PROJECTION = new String[] {
|
||||
RECORD_ID, HostAuthColumns.PROTOCOL, HostAuthColumns.ADDRESS, HostAuthColumns.PORT,
|
||||
HostAuthColumns.FLAGS, HostAuthColumns.LOGIN,
|
||||
HostAuthColumns.PASSWORD, HostAuthColumns.DOMAIN
|
||||
};
|
||||
|
||||
/**
|
||||
* no public constructor since this is a utility class
|
||||
*/
|
||||
public HostAuth() {
|
||||
mBaseUri = CONTENT_URI;
|
||||
|
||||
// other defaults policy)
|
||||
mPort = PORT_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore a HostAuth from the database, given its unique id
|
||||
* @param context
|
||||
* @param id
|
||||
* @return the instantiated HostAuth
|
||||
*/
|
||||
public static HostAuth restoreHostAuthWithId(Context context, long id) {
|
||||
return EmailContent.restoreContentWithId(context, HostAuth.class,
|
||||
HostAuth.CONTENT_URI, HostAuth.CONTENT_PROJECTION, id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the scheme for the specified flags.
|
||||
*/
|
||||
public static String getSchemeString(String protocol, int flags) {
|
||||
String security = "";
|
||||
switch (flags & USER_CONFIG_MASK) {
|
||||
case FLAG_SSL:
|
||||
security = "+ssl+";
|
||||
break;
|
||||
case FLAG_SSL | FLAG_TRUST_ALL:
|
||||
security = "+ssl+trustallcerts";
|
||||
break;
|
||||
case FLAG_TLS:
|
||||
security = "+tls+";
|
||||
break;
|
||||
case FLAG_TLS | FLAG_TRUST_ALL:
|
||||
security = "+tls+trustallcerts";
|
||||
break;
|
||||
}
|
||||
return protocol + security;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the flags for the specified scheme.
|
||||
*/
|
||||
public static int getSchemeFlags(String scheme) {
|
||||
String[] schemeParts = scheme.split("\\+");
|
||||
int flags = HostAuth.FLAG_NONE;
|
||||
if (schemeParts.length >= 2) {
|
||||
String part1 = schemeParts[1];
|
||||
if ("ssl".equals(part1)) {
|
||||
flags |= HostAuth.FLAG_SSL;
|
||||
} else if ("tls".equals(part1)) {
|
||||
flags |= HostAuth.FLAG_TLS;
|
||||
}
|
||||
if (schemeParts.length >= 3) {
|
||||
String part2 = schemeParts[2];
|
||||
if ("trustallcerts".equals(part2)) {
|
||||
flags |= HostAuth.FLAG_TRUST_ALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restore(Cursor cursor) {
|
||||
mBaseUri = CONTENT_URI;
|
||||
mId = cursor.getLong(CONTENT_ID_COLUMN);
|
||||
mProtocol = cursor.getString(CONTENT_PROTOCOL_COLUMN);
|
||||
mAddress = cursor.getString(CONTENT_ADDRESS_COLUMN);
|
||||
mPort = cursor.getInt(CONTENT_PORT_COLUMN);
|
||||
mFlags = cursor.getInt(CONTENT_FLAGS_COLUMN);
|
||||
mLogin = cursor.getString(CONTENT_LOGIN_COLUMN);
|
||||
mPassword = cursor.getString(CONTENT_PASSWORD_COLUMN);
|
||||
mDomain = cursor.getString(CONTENT_DOMAIN_COLUMN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentValues toContentValues() {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(HostAuthColumns.PROTOCOL, mProtocol);
|
||||
values.put(HostAuthColumns.ADDRESS, mAddress);
|
||||
values.put(HostAuthColumns.PORT, mPort);
|
||||
values.put(HostAuthColumns.FLAGS, mFlags);
|
||||
values.put(HostAuthColumns.LOGIN, mLogin);
|
||||
values.put(HostAuthColumns.PASSWORD, mPassword);
|
||||
values.put(HostAuthColumns.DOMAIN, mDomain);
|
||||
values.put(HostAuthColumns.ACCOUNT_KEY, 0); // Need something to satisfy the DB
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* For compatibility while converting to provider model, generate a "store URI"
|
||||
* TODO cache this so we don't rebuild every time
|
||||
*
|
||||
* @return a string in the form of a Uri, as used by the other parts of the email app
|
||||
*/
|
||||
public String getStoreUri() {
|
||||
String userInfo = null;
|
||||
if ((mFlags & FLAG_AUTHENTICATE) != 0) {
|
||||
String trimUser = (mLogin != null) ? mLogin.trim() : "";
|
||||
String password = (mPassword != null) ? mPassword : "";
|
||||
userInfo = trimUser + ":" + password;
|
||||
}
|
||||
String scheme = getSchemeString(mProtocol, mFlags);
|
||||
String address = (mAddress != null) ? mAddress.trim() : null;
|
||||
String path = (mDomain != null) ? "/" + mDomain : null;
|
||||
|
||||
URI uri;
|
||||
try {
|
||||
uri = new URI(
|
||||
scheme,
|
||||
userInfo,
|
||||
address,
|
||||
mPort,
|
||||
path,
|
||||
null,
|
||||
null);
|
||||
return uri.toString();
|
||||
} catch (URISyntaxException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user name and password from URI user info string
|
||||
*/
|
||||
public void setLogin(String userInfo) {
|
||||
String userName = null;
|
||||
String userPassword = null;
|
||||
if (!TextUtils.isEmpty(userInfo)) {
|
||||
String[] userInfoParts = userInfo.split(":", 2);
|
||||
userName = userInfoParts[0];
|
||||
if (userInfoParts.length > 1) {
|
||||
userPassword = userInfoParts[1];
|
||||
}
|
||||
}
|
||||
setLogin(userName, userPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user name and password
|
||||
*/
|
||||
public void setLogin(String userName, String userPassword) {
|
||||
mLogin = userName;
|
||||
mPassword = userPassword;
|
||||
|
||||
if (mLogin == null) {
|
||||
mFlags &= ~FLAG_AUTHENTICATE;
|
||||
} else {
|
||||
mFlags |= FLAG_AUTHENTICATE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the login information. [0] is the username and [1] is the password. If
|
||||
* {@link #FLAG_AUTHENTICATE} is not set, {@code null} is returned.
|
||||
*/
|
||||
public String[] getLogin() {
|
||||
if ((mFlags & FLAG_AUTHENTICATE) != 0) {
|
||||
String trimUser = (mLogin != null) ? mLogin.trim() : "";
|
||||
String password = (mPassword != null) ? mPassword : "";
|
||||
return new String[] { trimUser, password };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the connection values of the auth structure per the given scheme, host and port.
|
||||
*/
|
||||
public void setConnection(String scheme, String host, int port) {
|
||||
String[] schemeParts = scheme.split("\\+");
|
||||
String protocol = schemeParts[0];
|
||||
int flags = getSchemeFlags(scheme);
|
||||
|
||||
setConnection(protocol, host, port, flags);
|
||||
}
|
||||
|
||||
public void setConnection(String protocol, String address, int port, int flags) {
|
||||
// Set protocol, security, and additional flags based on uri scheme
|
||||
mProtocol = protocol;
|
||||
|
||||
mFlags &= ~(FLAG_SSL | FLAG_TLS | FLAG_TRUST_ALL);
|
||||
mFlags |= (flags & USER_CONFIG_MASK);
|
||||
|
||||
mAddress = address;
|
||||
mPort = port;
|
||||
if (mPort == PORT_UNKNOWN) {
|
||||
boolean useSSL = ((mFlags & FLAG_SSL) != 0);
|
||||
// infer port# from protocol + security
|
||||
// SSL implies a different port - TLS runs in the "regular" port
|
||||
// NOTE: Although the port should be setup in the various setup screens, this
|
||||
// block cannot easily be moved because we get process URIs from other sources
|
||||
// (e.g. for tests, provider templates and account restore) that may or may not
|
||||
// have a port specified.
|
||||
if ("pop3".equals(mProtocol)) {
|
||||
mPort = useSSL ? 995 : 110;
|
||||
} else if ("imap".equals(mProtocol)) {
|
||||
mPort = useSSL ? 993 : 143;
|
||||
} else if ("eas".equals(mProtocol)) {
|
||||
mPort = useSSL ? 443 : 80;
|
||||
} else if ("smtp".equals(mProtocol)) {
|
||||
mPort = useSSL ? 465 : 587;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Supports Parcelable
|
||||
*/
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supports Parcelable
|
||||
*/
|
||||
public static final Parcelable.Creator<EmailContent.HostAuth> CREATOR
|
||||
= new Parcelable.Creator<EmailContent.HostAuth>() {
|
||||
@Override
|
||||
public EmailContent.HostAuth createFromParcel(Parcel in) {
|
||||
return new EmailContent.HostAuth(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmailContent.HostAuth[] newArray(int size) {
|
||||
return new EmailContent.HostAuth[size];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Supports Parcelable
|
||||
*/
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
// mBaseUri is not parceled
|
||||
dest.writeLong(mId);
|
||||
dest.writeString(mProtocol);
|
||||
dest.writeString(mAddress);
|
||||
dest.writeInt(mPort);
|
||||
dest.writeInt(mFlags);
|
||||
dest.writeString(mLogin);
|
||||
dest.writeString(mPassword);
|
||||
dest.writeString(mDomain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supports Parcelable
|
||||
*/
|
||||
public HostAuth(Parcel in) {
|
||||
mBaseUri = CONTENT_URI;
|
||||
mId = in.readLong();
|
||||
mProtocol = in.readString();
|
||||
mAddress = in.readString();
|
||||
mPort = in.readInt();
|
||||
mFlags = in.readInt();
|
||||
mLogin = in.readString();
|
||||
mPassword = in.readString();
|
||||
mDomain = in.readString();
|
||||
}
|
||||
|
||||
/**
|
||||
* For debugger support only - DO NOT use for code.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getStoreUri();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof HostAuth)) {
|
||||
return false;
|
||||
}
|
||||
HostAuth that = (HostAuth)o;
|
||||
return mPort == that.mPort
|
||||
&& mFlags == that.mFlags
|
||||
&& Utility.areStringsEqual(mProtocol, that.mProtocol)
|
||||
&& Utility.areStringsEqual(mAddress, that.mAddress)
|
||||
&& Utility.areStringsEqual(mLogin, that.mLogin)
|
||||
&& Utility.areStringsEqual(mPassword, that.mPassword)
|
||||
&& Utility.areStringsEqual(mDomain, that.mDomain);
|
||||
}
|
||||
}
|
||||
|
||||
public interface PolicyColumns {
|
||||
public static final String ID = "_id";
|
||||
public static final String PASSWORD_MODE = "passwordMode";
|
||||
|
|
|
@ -0,0 +1,359 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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.emailcommon.provider;
|
||||
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuthColumns;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public final class HostAuth extends EmailContent implements HostAuthColumns, Parcelable {
|
||||
public static final String TABLE_NAME = "HostAuth";
|
||||
@SuppressWarnings("hiding")
|
||||
public static final Uri CONTENT_URI = Uri.parse(EmailContent.CONTENT_URI + "/hostauth");
|
||||
|
||||
public static final int PORT_UNKNOWN = -1;
|
||||
|
||||
public static final int FLAG_NONE = 0x00; // No flags
|
||||
public static final int FLAG_SSL = 0x01; // Use SSL
|
||||
public static final int FLAG_TLS = 0x02; // Use TLS
|
||||
public static final int FLAG_AUTHENTICATE = 0x04; // Use name/password for authentication
|
||||
public static final int FLAG_TRUST_ALL = 0x08; // Trust all certificates
|
||||
// Mask of settings directly configurable by the user
|
||||
public static final int USER_CONFIG_MASK = 0x0b;
|
||||
|
||||
public String mProtocol;
|
||||
public String mAddress;
|
||||
public int mPort;
|
||||
public int mFlags;
|
||||
public String mLogin;
|
||||
public String mPassword;
|
||||
public String mDomain;
|
||||
|
||||
public static final int CONTENT_ID_COLUMN = 0;
|
||||
public static final int CONTENT_PROTOCOL_COLUMN = 1;
|
||||
public static final int CONTENT_ADDRESS_COLUMN = 2;
|
||||
public static final int CONTENT_PORT_COLUMN = 3;
|
||||
public static final int CONTENT_FLAGS_COLUMN = 4;
|
||||
public static final int CONTENT_LOGIN_COLUMN = 5;
|
||||
public static final int CONTENT_PASSWORD_COLUMN = 6;
|
||||
public static final int CONTENT_DOMAIN_COLUMN = 7;
|
||||
|
||||
public static final String[] CONTENT_PROJECTION = new String[] {
|
||||
RECORD_ID, HostAuthColumns.PROTOCOL, HostAuthColumns.ADDRESS, HostAuthColumns.PORT,
|
||||
HostAuthColumns.FLAGS, HostAuthColumns.LOGIN,
|
||||
HostAuthColumns.PASSWORD, HostAuthColumns.DOMAIN
|
||||
};
|
||||
|
||||
/**
|
||||
* no public constructor since this is a utility class
|
||||
*/
|
||||
public HostAuth() {
|
||||
mBaseUri = CONTENT_URI;
|
||||
|
||||
// other defaults policy)
|
||||
mPort = PORT_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore a HostAuth from the database, given its unique id
|
||||
* @param context
|
||||
* @param id
|
||||
* @return the instantiated HostAuth
|
||||
*/
|
||||
public static HostAuth restoreHostAuthWithId(Context context, long id) {
|
||||
return EmailContent.restoreContentWithId(context, HostAuth.class,
|
||||
HostAuth.CONTENT_URI, HostAuth.CONTENT_PROJECTION, id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the scheme for the specified flags.
|
||||
*/
|
||||
public static String getSchemeString(String protocol, int flags) {
|
||||
String security = "";
|
||||
switch (flags & USER_CONFIG_MASK) {
|
||||
case FLAG_SSL:
|
||||
security = "+ssl+";
|
||||
break;
|
||||
case FLAG_SSL | FLAG_TRUST_ALL:
|
||||
security = "+ssl+trustallcerts";
|
||||
break;
|
||||
case FLAG_TLS:
|
||||
security = "+tls+";
|
||||
break;
|
||||
case FLAG_TLS | FLAG_TRUST_ALL:
|
||||
security = "+tls+trustallcerts";
|
||||
break;
|
||||
}
|
||||
return protocol + security;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the flags for the specified scheme.
|
||||
*/
|
||||
public static int getSchemeFlags(String scheme) {
|
||||
String[] schemeParts = scheme.split("\\+");
|
||||
int flags = HostAuth.FLAG_NONE;
|
||||
if (schemeParts.length >= 2) {
|
||||
String part1 = schemeParts[1];
|
||||
if ("ssl".equals(part1)) {
|
||||
flags |= HostAuth.FLAG_SSL;
|
||||
} else if ("tls".equals(part1)) {
|
||||
flags |= HostAuth.FLAG_TLS;
|
||||
}
|
||||
if (schemeParts.length >= 3) {
|
||||
String part2 = schemeParts[2];
|
||||
if ("trustallcerts".equals(part2)) {
|
||||
flags |= HostAuth.FLAG_TRUST_ALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restore(Cursor cursor) {
|
||||
mBaseUri = CONTENT_URI;
|
||||
mId = cursor.getLong(CONTENT_ID_COLUMN);
|
||||
mProtocol = cursor.getString(CONTENT_PROTOCOL_COLUMN);
|
||||
mAddress = cursor.getString(CONTENT_ADDRESS_COLUMN);
|
||||
mPort = cursor.getInt(CONTENT_PORT_COLUMN);
|
||||
mFlags = cursor.getInt(CONTENT_FLAGS_COLUMN);
|
||||
mLogin = cursor.getString(CONTENT_LOGIN_COLUMN);
|
||||
mPassword = cursor.getString(CONTENT_PASSWORD_COLUMN);
|
||||
mDomain = cursor.getString(CONTENT_DOMAIN_COLUMN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentValues toContentValues() {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(HostAuthColumns.PROTOCOL, mProtocol);
|
||||
values.put(HostAuthColumns.ADDRESS, mAddress);
|
||||
values.put(HostAuthColumns.PORT, mPort);
|
||||
values.put(HostAuthColumns.FLAGS, mFlags);
|
||||
values.put(HostAuthColumns.LOGIN, mLogin);
|
||||
values.put(HostAuthColumns.PASSWORD, mPassword);
|
||||
values.put(HostAuthColumns.DOMAIN, mDomain);
|
||||
values.put(HostAuthColumns.ACCOUNT_KEY, 0); // Need something to satisfy the DB
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* For compatibility while converting to provider model, generate a "store URI"
|
||||
* TODO cache this so we don't rebuild every time
|
||||
*
|
||||
* @return a string in the form of a Uri, as used by the other parts of the email app
|
||||
*/
|
||||
public String getStoreUri() {
|
||||
String userInfo = null;
|
||||
if ((mFlags & FLAG_AUTHENTICATE) != 0) {
|
||||
String trimUser = (mLogin != null) ? mLogin.trim() : "";
|
||||
String password = (mPassword != null) ? mPassword : "";
|
||||
userInfo = trimUser + ":" + password;
|
||||
}
|
||||
String scheme = getSchemeString(mProtocol, mFlags);
|
||||
String address = (mAddress != null) ? mAddress.trim() : null;
|
||||
String path = (mDomain != null) ? "/" + mDomain : null;
|
||||
|
||||
URI uri;
|
||||
try {
|
||||
uri = new URI(
|
||||
scheme,
|
||||
userInfo,
|
||||
address,
|
||||
mPort,
|
||||
path,
|
||||
null,
|
||||
null);
|
||||
return uri.toString();
|
||||
} catch (URISyntaxException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user name and password from URI user info string
|
||||
*/
|
||||
public void setLogin(String userInfo) {
|
||||
String userName = null;
|
||||
String userPassword = null;
|
||||
if (!TextUtils.isEmpty(userInfo)) {
|
||||
String[] userInfoParts = userInfo.split(":", 2);
|
||||
userName = userInfoParts[0];
|
||||
if (userInfoParts.length > 1) {
|
||||
userPassword = userInfoParts[1];
|
||||
}
|
||||
}
|
||||
setLogin(userName, userPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user name and password
|
||||
*/
|
||||
public void setLogin(String userName, String userPassword) {
|
||||
mLogin = userName;
|
||||
mPassword = userPassword;
|
||||
|
||||
if (mLogin == null) {
|
||||
mFlags &= ~FLAG_AUTHENTICATE;
|
||||
} else {
|
||||
mFlags |= FLAG_AUTHENTICATE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the login information. [0] is the username and [1] is the password. If
|
||||
* {@link #FLAG_AUTHENTICATE} is not set, {@code null} is returned.
|
||||
*/
|
||||
public String[] getLogin() {
|
||||
if ((mFlags & FLAG_AUTHENTICATE) != 0) {
|
||||
String trimUser = (mLogin != null) ? mLogin.trim() : "";
|
||||
String password = (mPassword != null) ? mPassword : "";
|
||||
return new String[] { trimUser, password };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the connection values of the auth structure per the given scheme, host and port.
|
||||
*/
|
||||
public void setConnection(String scheme, String host, int port) {
|
||||
String[] schemeParts = scheme.split("\\+");
|
||||
String protocol = schemeParts[0];
|
||||
int flags = getSchemeFlags(scheme);
|
||||
|
||||
setConnection(protocol, host, port, flags);
|
||||
}
|
||||
|
||||
public void setConnection(String protocol, String address, int port, int flags) {
|
||||
// Set protocol, security, and additional flags based on uri scheme
|
||||
mProtocol = protocol;
|
||||
|
||||
mFlags &= ~(FLAG_SSL | FLAG_TLS | FLAG_TRUST_ALL);
|
||||
mFlags |= (flags & USER_CONFIG_MASK);
|
||||
|
||||
mAddress = address;
|
||||
mPort = port;
|
||||
if (mPort == PORT_UNKNOWN) {
|
||||
boolean useSSL = ((mFlags & FLAG_SSL) != 0);
|
||||
// infer port# from protocol + security
|
||||
// SSL implies a different port - TLS runs in the "regular" port
|
||||
// NOTE: Although the port should be setup in the various setup screens, this
|
||||
// block cannot easily be moved because we get process URIs from other sources
|
||||
// (e.g. for tests, provider templates and account restore) that may or may not
|
||||
// have a port specified.
|
||||
if ("pop3".equals(mProtocol)) {
|
||||
mPort = useSSL ? 995 : 110;
|
||||
} else if ("imap".equals(mProtocol)) {
|
||||
mPort = useSSL ? 993 : 143;
|
||||
} else if ("eas".equals(mProtocol)) {
|
||||
mPort = useSSL ? 443 : 80;
|
||||
} else if ("smtp".equals(mProtocol)) {
|
||||
mPort = useSSL ? 465 : 587;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Supports Parcelable
|
||||
*/
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supports Parcelable
|
||||
*/
|
||||
public static final Parcelable.Creator<HostAuth> CREATOR
|
||||
= new Parcelable.Creator<HostAuth>() {
|
||||
@Override
|
||||
public HostAuth createFromParcel(Parcel in) {
|
||||
return new HostAuth(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostAuth[] newArray(int size) {
|
||||
return new HostAuth[size];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Supports Parcelable
|
||||
*/
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
// mBaseUri is not parceled
|
||||
dest.writeLong(mId);
|
||||
dest.writeString(mProtocol);
|
||||
dest.writeString(mAddress);
|
||||
dest.writeInt(mPort);
|
||||
dest.writeInt(mFlags);
|
||||
dest.writeString(mLogin);
|
||||
dest.writeString(mPassword);
|
||||
dest.writeString(mDomain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supports Parcelable
|
||||
*/
|
||||
public HostAuth(Parcel in) {
|
||||
mBaseUri = CONTENT_URI;
|
||||
mId = in.readLong();
|
||||
mProtocol = in.readString();
|
||||
mAddress = in.readString();
|
||||
mPort = in.readInt();
|
||||
mFlags = in.readInt();
|
||||
mLogin = in.readString();
|
||||
mPassword = in.readString();
|
||||
mDomain = in.readString();
|
||||
}
|
||||
|
||||
/**
|
||||
* For debugger support only - DO NOT use for code.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getStoreUri();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof HostAuth)) {
|
||||
return false;
|
||||
}
|
||||
HostAuth that = (HostAuth)o;
|
||||
return mPort == that.mPort
|
||||
&& mFlags == that.mFlags
|
||||
&& Utility.areStringsEqual(mProtocol, that.mProtocol)
|
||||
&& Utility.areStringsEqual(mAddress, that.mAddress)
|
||||
&& Utility.areStringsEqual(mLogin, that.mLogin)
|
||||
&& Utility.areStringsEqual(mPassword, that.mPassword)
|
||||
&& Utility.areStringsEqual(mDomain, that.mDomain);
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ package com.android.emailcommon.service;
|
|||
import com.android.emailcommon.Api;
|
||||
import com.android.emailcommon.Device;
|
||||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Policy;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
|
@ -22,11 +22,11 @@ import com.android.emailcommon.provider.EmailContent.Account;
|
|||
import com.android.emailcommon.provider.EmailContent.AccountColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.Attachment;
|
||||
import com.android.emailcommon.provider.EmailContent.AttachmentColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuthColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.Message;
|
||||
import com.android.emailcommon.provider.EmailContent.MessageColumns;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
import com.android.emailcommon.provider.ProviderUnavailableException;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import com.android.email.data.ThrottlingCursorLoader;
|
|||
import com.android.email.mail.Store;
|
||||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.android.email.mail.Store;
|
|||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Policy;
|
||||
import com.android.emailcommon.service.EmailServiceProxy;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.android.email.R;
|
|||
import com.android.email.SecurityPolicy;
|
||||
import com.android.email.activity.ActivityHelper;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.app.Activity;
|
||||
|
|
|
@ -20,7 +20,7 @@ import com.android.email.R;
|
|||
import com.android.email.activity.UiUtilities;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.app.Activity;
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.android.emailcommon.Logging;
|
|||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.app.Activity;
|
||||
|
|
|
@ -24,7 +24,7 @@ import com.android.email.activity.UiUtilities;
|
|||
import com.android.email.mail.Store;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
|
|
@ -27,7 +27,7 @@ import com.android.email.mail.Store;
|
|||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.accounts.AccountAuthenticatorResponse;
|
||||
|
|
|
@ -20,7 +20,7 @@ import com.android.email.R;
|
|||
import com.android.email.activity.ActivityHelper;
|
||||
import com.android.email.activity.UiUtilities;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentTransaction;
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.android.emailcommon.Device;
|
|||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.app.Activity;
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.android.email.mail.Store;
|
|||
import com.android.email.provider.AccountBackupRestore;
|
||||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.app.Activity;
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.android.email.provider.AccountBackupRestore;
|
|||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.app.Activity;
|
||||
|
|
|
@ -20,7 +20,7 @@ import com.android.email.R;
|
|||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.android.emailcommon.Logging;
|
|||
import com.android.emailcommon.mail.Folder;
|
||||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.android.email.mail.Store;
|
|||
import com.android.emailcommon.mail.Folder;
|
||||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.service.EmailServiceProxy;
|
||||
import com.android.emailcommon.service.IEmailService;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import com.android.emailcommon.mail.Folder;
|
|||
import com.android.emailcommon.mail.Message;
|
||||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
import com.android.emailcommon.service.EmailServiceProxy;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.android.emailcommon.mail.Message;
|
|||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.mail.Folder.OpenMode;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
import com.android.emailcommon.service.EmailServiceProxy;
|
||||
import com.android.emailcommon.utility.LoggingInputStream;
|
||||
|
|
|
@ -26,8 +26,8 @@ import com.android.emailcommon.mail.AuthenticationFailedException;
|
|||
import com.android.emailcommon.mail.CertificateValidationException;
|
||||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.EmailContent.Message;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
|
|
@ -28,13 +28,13 @@ import com.android.emailcommon.provider.EmailContent.Attachment;
|
|||
import com.android.emailcommon.provider.EmailContent.AttachmentColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.Body;
|
||||
import com.android.emailcommon.provider.EmailContent.BodyColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuthColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.Message;
|
||||
import com.android.emailcommon.provider.EmailContent.MessageColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.PolicyColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.SyncColumns;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
import com.android.emailcommon.provider.Policy;
|
||||
import com.android.emailcommon.service.LegacyPolicySet;
|
||||
|
@ -202,7 +202,7 @@ public class EmailProvider extends ContentProvider {
|
|||
Mailbox.TABLE_NAME,
|
||||
EmailContent.Message.TABLE_NAME,
|
||||
EmailContent.Attachment.TABLE_NAME,
|
||||
EmailContent.HostAuth.TABLE_NAME,
|
||||
HostAuth.TABLE_NAME,
|
||||
EmailContent.Message.UPDATED_TABLE_NAME,
|
||||
EmailContent.Message.DELETED_TABLE_NAME,
|
||||
Policy.TABLE_NAME,
|
||||
|
|
|
@ -27,7 +27,7 @@ import com.android.email.widget.WidgetManager;
|
|||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.AccountColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
|
||||
import android.accounts.AccountManager;
|
||||
import android.app.IntentService;
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.android.emailcommon.AccountManagerTypes;
|
|||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
import com.android.emailcommon.utility.AccountReconciler;
|
||||
import com.android.emailcommon.utility.EmailAsyncTask;
|
||||
|
|
|
@ -22,8 +22,8 @@ import com.android.email.provider.ProviderTestUtils;
|
|||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.Body;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.EmailContent.Message;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
|
@ -19,7 +19,7 @@ package com.android.email.activity.setup;
|
|||
import com.android.email.R;
|
||||
import com.android.email.mail.Store;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.content.ContentUris;
|
||||
|
|
|
@ -20,7 +20,7 @@ import com.android.email.R;
|
|||
import com.android.email.provider.ProviderTestUtils;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
|
@ -18,7 +18,7 @@ package com.android.email.activity.setup;
|
|||
|
||||
import com.android.email.R;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
|
@ -28,7 +28,6 @@ is not properly constructed. (empty address)
|
|||
//
|
||||
//import com.android.email.R;
|
||||
//import com.android.email.provider.EmailContent;
|
||||
//import com.android.email.provider.EmailContent.HostAuth;
|
||||
//
|
||||
//import android.content.ContentUris;
|
||||
//import android.content.Context;
|
||||
|
|
|
@ -19,7 +19,7 @@ package com.android.email.activity.setup;
|
|||
import com.android.email.R;
|
||||
import com.android.email.mail.Store;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
|
@ -18,7 +18,7 @@ package com.android.email.activity.setup;
|
|||
|
||||
import com.android.email.R;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
|
@ -20,7 +20,7 @@ import com.android.email.Email;
|
|||
import com.android.email.mail.Store.StoreInfo;
|
||||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
|
|
|
@ -43,7 +43,7 @@ import com.android.emailcommon.mail.Message.RecipientType;
|
|||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.mail.Part;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.android.emailcommon.mail.Message;
|
|||
import com.android.emailcommon.mail.Message.RecipientType;
|
||||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
|
||||
import android.test.InstrumentationTestCase;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
|
|
@ -24,8 +24,8 @@ import com.android.emailcommon.mail.MessagingException;
|
|||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.Attachment;
|
||||
import com.android.emailcommon.provider.EmailContent.Body;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.EmailContent.Message;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ package com.android.email.provider;
|
|||
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
|
|
|
@ -21,8 +21,8 @@ import com.android.emailcommon.provider.EmailContent;
|
|||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.Attachment;
|
||||
import com.android.emailcommon.provider.EmailContent.Body;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.EmailContent.Message;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ import com.android.emailcommon.provider.EmailContent.Attachment;
|
|||
import com.android.emailcommon.provider.EmailContent.AttachmentColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.Body;
|
||||
import com.android.emailcommon.provider.EmailContent.BodyColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.Message;
|
||||
import com.android.emailcommon.provider.EmailContent.MessageColumns;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
import com.android.emailcommon.utility.TextUtilities;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
@ -153,11 +153,11 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
|||
ProviderTestUtils.assertAccountEqual("testAccountSave", account1, account1get);
|
||||
|
||||
// Confirm hostauth fields can be accessed & read back correctly
|
||||
HostAuth hostAuth1get = EmailContent.HostAuth.restoreHostAuthWithId(mMockContext,
|
||||
HostAuth hostAuth1get = HostAuth.restoreHostAuthWithId(mMockContext,
|
||||
account1get.mHostAuthKeyRecv);
|
||||
ProviderTestUtils.assertHostAuthEqual("testAccountSaveHostAuth-recv",
|
||||
account1.mHostAuthRecv, hostAuth1get);
|
||||
HostAuth hostAuth2get = EmailContent.HostAuth.restoreHostAuthWithId(mMockContext,
|
||||
HostAuth hostAuth2get = HostAuth.restoreHostAuthWithId(mMockContext,
|
||||
account1get.mHostAuthKeySend);
|
||||
ProviderTestUtils.assertHostAuthEqual("testAccountSaveHostAuth-send",
|
||||
account1.mHostAuthSend, hostAuth2get);
|
||||
|
@ -180,7 +180,7 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
|||
assertTrue(authGet == authTest); // return the same object
|
||||
|
||||
// New HostAuth; based upon mHostAuthKeyRecv
|
||||
authTest = EmailContent.HostAuth.restoreHostAuthWithId(mMockContext,
|
||||
authTest = HostAuth.restoreHostAuthWithId(mMockContext,
|
||||
account.mHostAuthKeySend);
|
||||
account.mHostAuthSend = null;
|
||||
authGet = account.getOrCreateHostAuthSend(mMockContext);
|
||||
|
@ -189,7 +189,7 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
|||
ProviderTestUtils.assertHostAuthEqual("testAccountGetHostAuthSend-1", authTest, authGet);
|
||||
|
||||
// New HostAuth; completely empty
|
||||
authTest = new EmailContent.HostAuth();
|
||||
authTest = new HostAuth();
|
||||
account.mHostAuthSend = null;
|
||||
account.mHostAuthKeySend = 0;
|
||||
authGet = account.getOrCreateHostAuthSend(mMockContext);
|
||||
|
@ -215,7 +215,7 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
|||
assertTrue(authGet == authTest); // return the same object
|
||||
|
||||
// New HostAuth; based upon mHostAuthKeyRecv
|
||||
authTest = EmailContent.HostAuth.restoreHostAuthWithId(mMockContext,
|
||||
authTest = HostAuth.restoreHostAuthWithId(mMockContext,
|
||||
account.mHostAuthKeyRecv);
|
||||
account.mHostAuthRecv = null;
|
||||
authGet = account.getOrCreateHostAuthRecv(mMockContext);
|
||||
|
@ -224,7 +224,7 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
|||
ProviderTestUtils.assertHostAuthEqual("testAccountGetHostAuthRecv-1", authTest, authGet);
|
||||
|
||||
// New HostAuth; completely empty
|
||||
authTest = new EmailContent.HostAuth();
|
||||
authTest = new HostAuth();
|
||||
account.mHostAuthRecv = null;
|
||||
account.mHostAuthKeyRecv = 0;
|
||||
authGet = account.getOrCreateHostAuthRecv(mMockContext);
|
||||
|
|
|
@ -20,7 +20,7 @@ import com.android.email.AccountTestCase;
|
|||
import com.android.email.provider.ProviderTestUtils;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.AccountColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.content.ContentUris;
|
||||
|
|
|
@ -24,7 +24,7 @@ import com.android.email.service.MailService.AccountSyncReport;
|
|||
import com.android.emailcommon.AccountManagerTypes;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.accounts.AccountManager;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package com.android.emailcommon.provider;
|
||||
|
||||
import com.android.email.provider.ProviderTestUtils;
|
||||
import com.android.emailcommon.provider.EmailContent.HostAuth;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
|
|
Loading…
Reference in New Issue