Merge "keystore: add AID_ROOT into the user table."
diff --git a/api/current.xml b/api/current.xml
index 4146859..ba28d14 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -114301,6 +114301,23 @@
<exception name="IOException" type="java.io.IOException">
</exception>
</method>
+<method name="dumpService"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="name" type="java.lang.String">
+</parameter>
+<parameter name="fd" type="java.io.FileDescriptor">
+</parameter>
+<parameter name="args" type="java.lang.String[]">
+</parameter>
+</method>
<method name="enableEmulatorTraceOutput"
return="void"
abstract="false"
@@ -135531,6 +135548,39 @@
visibility="public"
>
</field>
+<field name="LOCK_PATTERN_ENABLED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""lock_pattern_autolock""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""lock_pattern_tactile_feedback_enabled""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="LOCK_PATTERN_VISIBLE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""lock_pattern_visible_pattern""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="LOGGING_ID"
type="java.lang.String"
transient="false"
@@ -136508,7 +136558,7 @@
value=""lock_pattern_autolock""
static="true"
final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
</field>
@@ -136519,7 +136569,7 @@
value=""lock_pattern_tactile_feedback_enabled""
static="true"
final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
</field>
@@ -136530,7 +136580,7 @@
value=""lock_pattern_visible_pattern""
static="true"
final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
</field>
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c
index adec5a4..eaa34c8 100644
--- a/cmds/dumpstate/dumpstate.c
+++ b/cmds/dumpstate/dumpstate.c
@@ -110,6 +110,9 @@
dump_file("KERNEL WAKELOCKS", "/proc/wakelocks");
dump_file("KERNEL CPUFREQ", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
+ run_command("SECURE CONTAINERS", 10, "vdc", "asec", "list", NULL);
+ run_command("MOUNTED FILESYSTEMS", 10, "df", NULL);
+
run_command("PROCESSES", 10, "ps", "-P", NULL);
run_command("PROCESSES AND THREADS", 10, "ps", "-t", "-p", "-P", NULL);
run_command("LIBRANK", 10, "librank", NULL);
@@ -208,7 +211,7 @@
}
/* switch to non-root user and group */
- gid_t groups[] = { AID_LOG, AID_SDCARD_RW };
+ gid_t groups[] = { AID_LOG, AID_SDCARD_RW, AID_MOUNT };
setgroups(sizeof(groups)/sizeof(groups[0]), groups);
setuid(AID_SHELL);
diff --git a/cmds/keystore/keystore_get.h b/cmds/keystore/keystore_get.h
index 0e7e1ae..8330f8e 100644
--- a/cmds/keystore/keystore_get.h
+++ b/cmds/keystore/keystore_get.h
@@ -19,7 +19,6 @@
#include <stdio.h>
#include <stdint.h>
-#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -28,18 +27,21 @@
#define KEYSTORE_MESSAGE_SIZE 65535
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* This function is provided for native components to get values from keystore.
* Users are required to link against libcutils. The lengths of keys and values
* are limited to KEYSTORE_MESSAGE_SIZE. This function returns the length of
* the requested value or -1 if something goes wrong. */
-static int keystore_get(const char *key, char *value)
+static int keystore_get(const char *key, int length, char *value)
{
- int length = strlen(key);
uint8_t bytes[2] = {length >> 8, length};
uint8_t code = 'g';
int sock;
- if (length > KEYSTORE_MESSAGE_SIZE) {
+ if (length < 0 || length > KEYSTORE_MESSAGE_SIZE) {
return -1;
}
sock = socket_local_client("keystore", ANDROID_SOCKET_NAMESPACE_RESERVED,
@@ -66,4 +68,8 @@
return length;
}
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index c951ce9..3e426f5 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -668,7 +668,7 @@
// The user changed the query, remember it.
mUserQuery = s == null ? "" : s.toString();
}
- updateVoiceButton(TextUtils.isEmpty(s));
+ updateVoiceButton(mSearchAutoComplete.isEmpty());
}
public void afterTextChanged(Editable s) {
@@ -691,13 +691,30 @@
};
/**
- * Enable/Disable the cancel button based on edit text state (any text?)
+ * Enable/Disable the go button based on edit text state (any text?)
*/
private void updateWidgetState() {
// enable the button if we have one or more non-space characters
boolean enabled = !mSearchAutoComplete.isEmpty();
- mGoButton.setEnabled(enabled);
- mGoButton.setFocusable(enabled);
+ if (isBrowserSearch()) {
+ // In the browser, we hide the search button when there is no text
+ if (enabled) {
+ mSearchAutoComplete.setBackgroundResource(
+ com.android.internal.R.drawable.textfield_search);
+ mGoButton.setVisibility(View.VISIBLE);
+ // Just to be sure
+ mGoButton.setEnabled(true);
+ mGoButton.setFocusable(true);
+ } else {
+ mSearchAutoComplete.setBackgroundResource(
+ com.android.internal.R.drawable.textfield_search_empty);
+ mGoButton.setVisibility(View.GONE);
+ }
+ } else {
+ // Elsewhere we just disable the button
+ mGoButton.setEnabled(enabled);
+ mGoButton.setFocusable(enabled);
+ }
}
/**
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java
index 2974981..dfd4024 100644
--- a/core/java/android/database/sqlite/SQLiteDatabase.java
+++ b/core/java/android/database/sqlite/SQLiteDatabase.java
@@ -261,7 +261,7 @@
public static final int MAX_SQL_CACHE_SIZE = 250;
private int mMaxSqlCacheSize = MAX_SQL_CACHE_SIZE; // max cache size per Database instance
private int mCacheFullWarnings;
- private static final int MAX_WARNINGS_ON_CACHESIZE_CONDITION = 5;
+ private static final int MAX_WARNINGS_ON_CACHESIZE_CONDITION = 1;
/** maintain stats about number of cache hits and misses */
private int mNumCacheHits;
@@ -1909,43 +1909,28 @@
}
// add this <sql, compiledStatement> to the cache
if (mCompiledQueries.size() == mMaxSqlCacheSize) {
- /* reached max cachesize. before adding new entry, remove an entry from the
- * cache. we don't want to wipe out the entire cache because of this:
- * GCing {@link SQLiteCompiledSql} requires call to sqlite3_finalize
- * JNI method. If entire cache is wiped out, it could cause a big GC activity
- * just because a (rogue) process is using the cache incorrectly.
+ /*
+ * cache size of {@link #mMaxSqlCacheSize} is not enough for this app.
+ * log a warning MAX_WARNINGS_ON_CACHESIZE_CONDITION times
+ * chances are it is NOT using ? for bindargs - so caching is useless.
+ * TODO: either let the callers set max cchesize for their app, or intelligently
+ * figure out what should be cached for a given app.
*/
- Log.w(TAG, "Reached MAX size for compiled-sql statement cache for database " +
- getPath() + "; i.e., NO space for this sql statement in cache: " +
- sql + ". Please change your sql statements to use '?' for " +
- "bindargs, instead of using actual values");
-
- /* increment the number of times this warnings has been printed.
- * if this warning is printed too many times, clear the whole cache - the app
- * is doing something weird or incorrect and printing more warnings will only
- * flood the logfile.
- */
- if (++mCacheFullWarnings > MAX_WARNINGS_ON_CACHESIZE_CONDITION) {
- mCacheFullWarnings = 0;
- // clear the cache
- mCompiledQueries.clear();
- Log.w(TAG, "Compiled-sql statement cache for database: " +
- getPath() + " hit MAX size-limit too many times. " +
- "Removing all compiled-sql statements from the cache.");
- } else {
- // clear just a single entry from cache
- Set<String> keySet = mCompiledQueries.keySet();
- for (String s : keySet) {
- mCompiledQueries.remove(s);
- break;
- }
+ if (++mCacheFullWarnings == MAX_WARNINGS_ON_CACHESIZE_CONDITION) {
+ Log.w(TAG, "Reached MAX size for compiled-sql statement cache for database " +
+ getPath() + "; i.e., NO space for this sql statement in cache: " +
+ sql + ". Please change your sql statements to use '?' for " +
+ "bindargs, instead of using actual values");
+ }
+ // don't add this entry to cache
+ } else {
+ // cache is NOT full. add this to cache.
+ mCompiledQueries.put(sql, compiledStatement);
+ if (SQLiteDebug.DEBUG_SQL_CACHE) {
+ Log.v(TAG, "|adding_sql_to_cache|" + getPath() + "|" +
+ mCompiledQueries.size() + "|" + sql);
}
}
- mCompiledQueries.put(sql, compiledStatement);
- }
- if (SQLiteDebug.DEBUG_SQL_CACHE) {
- Log.v(TAG, "|adding_sql_to_cache|" + getPath() + "|" + mCompiledQueries.size() + "|" +
- sql);
}
return;
}
diff --git a/core/java/android/database/sqlite/SQLiteProgram.java b/core/java/android/database/sqlite/SQLiteProgram.java
index 389e15e..6636473 100644
--- a/core/java/android/database/sqlite/SQLiteProgram.java
+++ b/core/java/android/database/sqlite/SQLiteProgram.java
@@ -58,11 +58,10 @@
db.addSQLiteClosable(this);
this.nHandle = db.mNativeHandle;
- // shouldn't reuse compiled-plans of PRAGMA sql statements
- // because sqlite returns OLD values if compiled-pragma-statements are reused
- //TODO: remove this code when sqlite fixes it (and add tests too)
+ // only cache CRUD statements
String prefixSql = mSql.substring(0, 6);
- if (prefixSql.toLowerCase().startsWith("pragma")) {
+ if (!prefixSql.equalsIgnoreCase("INSERT") && !prefixSql.equalsIgnoreCase("UPDATE") &&
+ !prefixSql.equalsIgnoreCase("DELETE") && !prefixSql.equalsIgnoreCase("SELECT")) {
mCompiledSql = new SQLiteCompiledSql(db, sql);
nStatement = mCompiledSql.nStatement;
// since it is not in the cache, no need to acquire() it.
diff --git a/core/java/android/net/WebAddress.java b/core/java/android/net/WebAddress.java
index a572f60..e5bc6e3 100644
--- a/core/java/android/net/WebAddress.java
+++ b/core/java/android/net/WebAddress.java
@@ -57,7 +57,7 @@
/* scheme */ "(?:(http|HTTP|https|HTTPS|file|FILE)\\:\\/\\/)?" +
/* authority */ "(?:([-A-Za-z0-9$_.+!*'(),;?&=]+(?:\\:[-A-Za-z0-9$_.+!*'(),;?&=]+)?)@)?" +
/* host */ "([-" + GOOD_IRI_CHAR + "%_]+(?:\\.[-" + GOOD_IRI_CHAR + "%_]+)*|\\[[0-9a-fA-F:\\.]+\\])?" +
- /* port */ "(?:\\:([0-9]+))?" +
+ /* port */ "(?:\\:([0-9]*))?" +
/* path */ "(\\/?[^#]*)?" +
/* anchor */ ".*");
@@ -85,7 +85,8 @@
t = m.group(MATCH_GROUP_HOST);
if (t != null) mHost = t;
t = m.group(MATCH_GROUP_PORT);
- if (t != null) {
+ if (t != null && t.length() > 0) {
+ // The ':' character is not returned by the regex.
try {
mPort = Integer.parseInt(t);
} catch (NumberFormatException ex) {
diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java
index a4c595d..2e14667 100644
--- a/core/java/android/os/Debug.java
+++ b/core/java/android/os/Debug.java
@@ -57,6 +57,8 @@
*/
public final class Debug
{
+ private static final String TAG = "Debug";
+
/**
* Flags for startMethodTracing(). These can be ORed together.
*
@@ -1111,7 +1113,7 @@
}
}
} else {
- Log.w("android.os.Debug",
+ Log.wtf(TAG,
"setFieldsOn(" + (cl == null ? "null" : cl.getName()) +
") called in non-DEBUG build");
}
@@ -1127,4 +1129,31 @@
@Retention(RetentionPolicy.RUNTIME)
public @interface DebugProperty {
}
+
+ /**
+ * Get a debugging dump of a system service by name.
+ *
+ * <p>Most services require the caller to hold android.permission.DUMP.
+ *
+ * @param name of the service to dump
+ * @param fd to write dump output to (usually an output log file)
+ * @param args to pass to the service's dump method, may be null
+ * @return true if the service was dumped successfully, false if
+ * the service could not be found or had an error while dumping
+ */
+ public static boolean dumpService(String name, FileDescriptor fd, String[] args) {
+ IBinder service = ServiceManager.getService(name);
+ if (service == null) {
+ Log.e(TAG, "Can't find service to dump: " + name);
+ return false;
+ }
+
+ try {
+ service.dump(fd, args);
+ return true;
+ } catch (RemoteException e) {
+ Log.e(TAG, "Can't dump service: " + name, e);
+ return false;
+ }
+ }
}
diff --git a/core/java/android/pim/vcard/VCardEntry.java b/core/java/android/pim/vcard/VCardEntry.java
index f6135fc..61012c9 100644
--- a/core/java/android/pim/vcard/VCardEntry.java
+++ b/core/java/android/pim/vcard/VCardEntry.java
@@ -17,6 +17,7 @@
import android.accounts.Account;
import android.content.ContentProviderOperation;
+import android.content.ContentProviderResult;
import android.content.ContentResolver;
import android.content.OperationApplicationException;
import android.database.Cursor;
@@ -90,7 +91,7 @@
this.label = label;
this.isPrimary = isPrimary;
}
-
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof PhoneData)) {
@@ -100,7 +101,7 @@
return (type == phoneData.type && data.equals(phoneData.data) &&
label.equals(phoneData.label) && isPrimary == phoneData.isPrimary);
}
-
+
@Override
public String toString() {
return String.format("type: %d, data: %s, label: %s, isPrimary: %s",
@@ -122,7 +123,7 @@
this.label = label;
this.isPrimary = isPrimary;
}
-
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof EmailData)) {
@@ -132,7 +133,7 @@
return (type == emailData.type && data.equals(emailData.data) &&
label.equals(emailData.label) && isPrimary == emailData.isPrimary);
}
-
+
@Override
public String toString() {
return String.format("type: %d, data: %s, label: %s, isPrimary: %s",
@@ -193,14 +194,14 @@
this.label = label;
this.isPrimary = isPrimary;
}
-
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof PostalData)) {
return false;
}
final PostalData postalData = (PostalData)obj;
- return (Arrays.equals(dataArray, postalData.dataArray) &&
+ return (Arrays.equals(dataArray, postalData.dataArray) &&
(type == postalData.type &&
(type == StructuredPostal.TYPE_CUSTOM ?
(label == postalData.label) : true)) &&
@@ -239,7 +240,7 @@
return builder.toString().trim();
}
-
+
@Override
public String toString() {
return String.format("type: %d, label: %s, isPrimary: %s",
@@ -267,7 +268,7 @@
this.titleName = titleName;
this.isPrimary = isPrimary;
}
-
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof OrganizationData)) {
@@ -311,7 +312,7 @@
type, companyName, departmentName, titleName, isPrimary);
}
}
-
+
static public class ImData {
public final int protocol;
public final String customProtocol;
@@ -348,7 +349,7 @@
type, protocol, customProtocol, data, isPrimary);
}
}
-
+
public static class PhotoData {
public static final String FORMAT_FLASH = "SWF";
public final int type;
@@ -382,7 +383,7 @@
type, formatName, photoBytes.length, isPrimary);
}
}
-
+
/* package */ static class Property {
private String mPropertyName;
private Map<String, Collection<String>> mParameterMap =
@@ -393,7 +394,7 @@
public void setPropertyName(final String propertyName) {
mPropertyName = propertyName;
}
-
+
public void addParameter(final String paramName, final String paramValue) {
Collection<String> values;
if (!mParameterMap.containsKey(paramName)) {
@@ -408,11 +409,11 @@
}
values.add(paramValue);
}
-
+
public void addToPropertyValueList(final String propertyValue) {
mPropertyValueList.add(propertyValue);
}
-
+
public void setPropertyBytes(final byte[] propertyBytes) {
mPropertyBytes = propertyBytes;
}
@@ -420,11 +421,11 @@
public final Collection<String> getParameters(String type) {
return mParameterMap.get(type);
}
-
+
public final List<String> getPropertyValueList() {
return mPropertyValueList;
}
-
+
public void clear() {
mPropertyName = null;
mParameterMap.clear();
@@ -432,7 +433,7 @@
mPropertyBytes = null;
}
}
-
+
private String mFamilyName;
private String mGivenName;
private String mMiddleName;
@@ -441,19 +442,19 @@
// Used only when no family nor given name is found.
private String mFullName;
-
+
private String mPhoneticFamilyName;
private String mPhoneticGivenName;
private String mPhoneticMiddleName;
-
+
private String mPhoneticFullName;
private List<String> mNickNameList;
- private String mDisplayName;
+ private String mDisplayName;
private String mBirthday;
-
+
private List<String> mNoteList;
private List<PhoneData> mPhoneList;
private List<EmailData> mEmailList;
@@ -513,21 +514,21 @@
}
mNickNameList.add(nickName);
}
-
+
private void addEmail(int type, String data, String label, boolean isPrimary){
if (mEmailList == null) {
mEmailList = new ArrayList<EmailData>();
}
mEmailList.add(new EmailData(type, data, label, isPrimary));
}
-
+
private void addPostal(int type, List<String> propValueList, String label, boolean isPrimary){
if (mPostalList == null) {
mPostalList = new ArrayList<PostalData>(0);
}
mPostalList.add(new PostalData(type, propValueList, label, isPrimary));
}
-
+
/**
* Should be called via {@link #handleOrgValue(int, List, boolean)} or
* {@link #handleTitleValue(String)}.
@@ -640,14 +641,14 @@
}
mImList.add(new ImData(protocol, customProtocol, type, propValue, isPrimary));
}
-
+
private void addNote(final String note) {
if (mNoteList == null) {
mNoteList = new ArrayList<String>(1);
}
mNoteList.add(note);
}
-
+
private void addPhotoBytes(String formatName, byte[] photoBytes, boolean isPrimary) {
if (mPhotoList == null) {
mPhotoList = new ArrayList<PhotoData>(1);
@@ -745,12 +746,12 @@
final Map<String, Collection<String>> paramMap = property.mParameterMap;
final List<String> propValueList = property.mPropertyValueList;
byte[] propBytes = property.mPropertyBytes;
-
+
if (propValueList.size() == 0) {
return;
}
final String propValue = listToString(propValueList).trim();
-
+
if (propName.equals(VCardConstants.PROPERTY_VERSION)) {
// vCard version. Ignore this.
} else if (propName.equals(VCardConstants.PROPERTY_FN)) {
@@ -805,7 +806,7 @@
} else if (typeString.equals(VCardConstants.PARAM_TYPE_HOME)) {
type = StructuredPostal.TYPE_HOME;
label = "";
- } else if (typeString.equals(VCardConstants.PARAM_TYPE_WORK) ||
+ } else if (typeString.equals(VCardConstants.PARAM_TYPE_WORK) ||
typeString.equalsIgnoreCase(VCardConstants.PARAM_EXTRA_TYPE_COMPANY)) {
// "COMPANY" seems emitted by Windows Mobile, which is not
// specifically supported by vCard 2.1. We assume this is same
@@ -916,7 +917,7 @@
type = Phone.TYPE_CUSTOM;
label = typeObject.toString();
}
-
+
final boolean isPrimary;
if (typeCollection != null && typeCollection.contains(VCardConstants.PARAM_TYPE_PREF)) {
isPrimary = true;
@@ -977,7 +978,7 @@
VCardUtils.constructListFromValue(propValue,
VCardConfig.isV30(mVCardType));
handleAndroidCustomProperty(customPropertyList);
- /*} else if (propName.equals("REV")) {
+ /*} else if (propName.equals("REV")) {
// Revision of this VCard entry. I think we can ignore this.
} else if (propName.equals("UID")) {
} else if (propName.equals("KEY")) {
@@ -1041,7 +1042,7 @@
}
/**
- * Consolidate several fielsds (like mName) using name candidates,
+ * Consolidate several fielsds (like mName) using name candidates,
*/
public void consolidateFields() {
constructDisplayName();
@@ -1051,9 +1052,9 @@
}
}
- public void pushIntoContentResolver(ContentResolver resolver) {
+ public Uri pushIntoContentResolver(ContentResolver resolver) {
ArrayList<ContentProviderOperation> operationList =
- new ArrayList<ContentProviderOperation>();
+ new ArrayList<ContentProviderOperation>();
ContentProviderOperation.Builder builder =
ContentProviderOperation.newInsert(RawContacts.CONTENT_URI);
String myGroupsId = null;
@@ -1176,7 +1177,7 @@
operationList.add(builder.build());
}
}
-
+
if (mPostalList != null) {
for (PostalData postalData : mPostalList) {
builder = ContentProviderOperation.newInsert(Data.CONTENT_URI);
@@ -1185,7 +1186,7 @@
operationList.add(builder.build());
}
}
-
+
if (mImList != null) {
for (ImData imData : mImList) {
builder = ContentProviderOperation.newInsert(Data.CONTENT_URI);
@@ -1201,7 +1202,7 @@
}
}
}
-
+
if (mNoteList != null) {
for (String note : mNoteList) {
builder = ContentProviderOperation.newInsert(Data.CONTENT_URI);
@@ -1232,7 +1233,7 @@
builder.withValue(Data.MIMETYPE, Website.CONTENT_ITEM_TYPE);
builder.withValue(Website.URL, website);
// There's no information about the type of URL in vCard.
- // We use TYPE_HOMEPAGE for safety.
+ // We use TYPE_HOMEPAGE for safety.
builder.withValue(Website.TYPE, Website.TYPE_HOMEPAGE);
operationList.add(builder.build());
}
@@ -1265,7 +1266,7 @@
builder = ContentProviderOperation.newInsert(Data.CONTENT_URI);
builder.withValueBackReference(GroupMembership.RAW_CONTACT_ID, 0);
builder.withValue(Data.MIMETYPE, mimeType);
- } else { // 1 <= i && i <= MAX_DATA_COLUMNS
+ } else { // 1 <= i && i <= MAX_DATA_COLUMNS
if (!TextUtils.isEmpty(customPropertyValue)) {
builder.withValue("data" + i, customPropertyValue);
}
@@ -1286,11 +1287,17 @@
}
try {
- resolver.applyBatch(ContactsContract.AUTHORITY, operationList);
+ ContentProviderResult[] results = resolver.applyBatch(
+ ContactsContract.AUTHORITY, operationList);
+ // the first result is always the raw_contact. return it's uri so
+ // that it can be found later
+ return results[0].uri;
} catch (RemoteException e) {
Log.e(LOG_TAG, String.format("%s: %s", e.toString(), e.getMessage()));
+ return null;
} catch (OperationApplicationException e) {
Log.e(LOG_TAG, String.format("%s: %s", e.toString(), e.getMessage()));
+ return null;
}
}
@@ -1319,7 +1326,7 @@
public boolean isIgnorable() {
return getDisplayName().length() == 0;
}
-
+
private String listToString(List<String> list){
final int size = list.size();
if (size > 1) {
diff --git a/core/java/android/pim/vcard/VCardEntryCommitter.java b/core/java/android/pim/vcard/VCardEntryCommitter.java
index ebbbab6..3cd64b0 100644
--- a/core/java/android/pim/vcard/VCardEntryCommitter.java
+++ b/core/java/android/pim/vcard/VCardEntryCommitter.java
@@ -16,6 +16,7 @@
package android.pim.vcard;
import android.content.ContentResolver;
+import android.net.Uri;
import android.util.Log;
/**
@@ -34,6 +35,7 @@
private final ContentResolver mContentResolver;
private long mTimeToCommit;
+ private Uri mLastCreatedUri;
public VCardEntryCommitter(ContentResolver resolver) {
mContentResolver = resolver;
@@ -50,7 +52,11 @@
public void onEntryCreated(final VCardEntry contactStruct) {
long start = System.currentTimeMillis();
- contactStruct.pushIntoContentResolver(mContentResolver);
+ mLastCreatedUri = contactStruct.pushIntoContentResolver(mContentResolver);
mTimeToCommit += System.currentTimeMillis() - start;
}
+
+ public Uri getLastCreatedUri() {
+ return mLastCreatedUri;
+ }
}
\ No newline at end of file
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 726f98a..fdde591 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -679,6 +679,9 @@
MOVED_TO_SECURE.add(Secure.HTTP_PROXY);
MOVED_TO_SECURE.add(Secure.INSTALL_NON_MARKET_APPS);
MOVED_TO_SECURE.add(Secure.LOCATION_PROVIDERS_ALLOWED);
+ MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_ENABLED);
+ MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_VISIBLE);
+ MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
MOVED_TO_SECURE.add(Secure.LOGGING_ID);
MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_ENABLED);
MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_LAST_UPDATE);
@@ -1160,18 +1163,25 @@
"bluetooth_discoverability_timeout";
/**
- * Whether autolock is enabled (0 = false, 1 = true)
+ * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_ENABLED}
+ * instead
*/
- public static final String LOCK_PATTERN_ENABLED = "lock_pattern_autolock";
+ @Deprecated
+ public static final String LOCK_PATTERN_ENABLED = Secure.LOCK_PATTERN_ENABLED;
/**
- * Whether lock pattern is visible as user enters (0 = false, 1 = true)
+ * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_VISIBLE}
+ * instead
*/
+ @Deprecated
public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
/**
- * Whether lock pattern will vibrate as user enters (0 = false, 1 = true)
+ * @deprecated Use
+ * {@link android.provider.Settings.Secure#LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED}
+ * instead
*/
+ @Deprecated
public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED =
"lock_pattern_tactile_feedback_enabled";
@@ -2297,6 +2307,22 @@
public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
/**
+ * Whether autolock is enabled (0 = false, 1 = true)
+ */
+ public static final String LOCK_PATTERN_ENABLED = "lock_pattern_autolock";
+
+ /**
+ * Whether lock pattern is visible as user enters (0 = false, 1 = true)
+ */
+ public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
+
+ /**
+ * Whether lock pattern will vibrate as user enters (0 = false, 1 = true)
+ */
+ public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED =
+ "lock_pattern_tactile_feedback_enabled";
+
+ /**
* Whether assisted GPS should be enabled or not.
* @hide
*/
diff --git a/core/java/android/speech/RecognizerResultsIntent.java b/core/java/android/speech/RecognizerResultsIntent.java
index 228258e..b45e4b1 100644
--- a/core/java/android/speech/RecognizerResultsIntent.java
+++ b/core/java/android/speech/RecognizerResultsIntent.java
@@ -16,6 +16,8 @@
package android.speech;
+import android.os.Bundle;
+
import java.util.ArrayList;
/**
@@ -119,7 +121,23 @@
*/
public static final String EXTRA_VOICE_SEARCH_RESULT_HTML_BASE_URLS =
"android.speech.extras.VOICE_SEARCH_RESULT_HTML_BASE_URLS";
-
+
+ /**
+ * The key to an extra {@link ArrayList} of {@link Bundle}s that contains key/value pairs.
+ * All the values and the keys are {@link String}s. Each key/value pair represents an extra HTTP
+ * header. The keys can't be the standard HTTP headers as they are set by the WebView.
+ *
+ * A list of size 1 may be provided to apply the same HTTP headers to all web results. A
+ * list of the same size as {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS} may be provided to
+ * apply different HTTP headers to each different web result in the list. These headers will
+ * only be used in the case that the url for a particular web result (from
+ * {@link #EXTRA_VOICE_SEARCH_RESULT_URLS}) is loaded.
+ *
+ * @hide not to be exposed immediately as the implementation details may change
+ */
+ public static final String EXTRA_VOICE_SEARCH_RESULT_HTTP_HEADERS =
+ "android.speech.extras.EXTRA_VOICE_SEARCH_RESULT_HTTP_HEADERS";
+
/**
* The scheme used currently for html content in {@link #EXTRA_VOICE_SEARCH_RESULT_HTML}.
*
diff --git a/core/java/android/view/inputmethod/BaseInputConnection.java b/core/java/android/view/inputmethod/BaseInputConnection.java
index 7393737..6ac1633 100644
--- a/core/java/android/view/inputmethod/BaseInputConnection.java
+++ b/core/java/android/view/inputmethod/BaseInputConnection.java
@@ -328,6 +328,11 @@
b = tmp;
}
+ // Guard against the case where the cursor has not been positioned yet.
+ if (b < 0) {
+ b = 0;
+ }
+
if (b + length > content.length()) {
length = content.length() - b;
}
diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java
index 1d28731..427ce76 100644
--- a/core/java/android/webkit/CookieManager.java
+++ b/core/java/android/webkit/CookieManager.java
@@ -216,19 +216,23 @@
diff = cookie2.domain.length() - cookie1.domain.length();
if (diff != 0) return diff;
- diff = cookie2.name.hashCode() - cookie1.name.hashCode();
- if (diff != 0) return diff;
-
// If cookie2 has a null value, it should come later in
// the list.
if (cookie2.value == null) {
- return -1;
+ // If both cookies have null values, fall back to using the name
+ // difference.
+ if (cookie1.value != null) {
+ return -1;
+ }
} else if (cookie1.value == null) {
// Now we know that cookie2 does not have a null value, if
// cookie1 has a null value, place it later in the list.
return 1;
}
+ diff = cookie2.name.hashCode() - cookie1.name.hashCode();
+ if (diff != 0) return diff;
+
// cookie1 and cookie2 both have non-null values so we emit a
// warning and treat them as the same.
Log.w(LOGTAG, "Found two cookies with the same value."
@@ -804,9 +808,13 @@
cookie = new Cookie(host, path);
// Cookies like "testcookie; path=/;" are valid and used
- // (lovefilm.se). Check for equal as in the string "testcookie"
- // Check for equalIndex == -1 as in the string "testcookie;"
- if (semicolonIndex <= equalIndex || equalIndex == -1) {
+ // (lovefilm.se).
+ // Look for 2 cases:
+ // 1. "foo" or "foo;" where equalIndex is -1
+ // 2. "foo; path=..." where the first semicolon is before an equal
+ // and a semicolon exists.
+ if ((semicolonIndex != -1 && (semicolonIndex < equalIndex)) ||
+ equalIndex == -1) {
// Fix up the index in case we have a string like "testcookie"
if (semicolonIndex == -1) {
semicolonIndex = length;
@@ -815,7 +823,10 @@
cookie.value = null;
} else {
cookie.name = cookieString.substring(index, equalIndex);
- if (cookieString.charAt(equalIndex + 1) == QUOTATION) {
+ // Make sure we do not throw an exception if the cookie is like
+ // "foo="
+ if ((equalIndex < length - 1) &&
+ (cookieString.charAt(equalIndex + 1) == QUOTATION)) {
index = cookieString.indexOf(QUOTATION, equalIndex + 2);
if (index == -1) {
// bad format, force return
@@ -834,7 +845,7 @@
equalIndex + 1 + MAX_COOKIE_LENGTH);
} else if (equalIndex + 1 == semicolonIndex
|| semicolonIndex < equalIndex) {
- // this is an unusual case like foo=;
+ // this is an unusual case like "foo=;" or "foo="
cookie.value = "";
} else {
cookie.value = cookieString.substring(equalIndex + 1,
diff --git a/core/java/android/webkit/FrameLoader.java b/core/java/android/webkit/FrameLoader.java
index dacb33f..303e417 100644
--- a/core/java/android/webkit/FrameLoader.java
+++ b/core/java/android/webkit/FrameLoader.java
@@ -111,11 +111,10 @@
}
mNetwork = Network.getInstance(mListener.getContext());
if (mListener.isSynchronous()) {
- handleHTTPLoad();
- } else {
- WebViewWorker.getHandler().obtainMessage(
- WebViewWorker.MSG_ADD_HTTPLOADER, this).sendToTarget();
+ return handleHTTPLoad();
}
+ WebViewWorker.getHandler().obtainMessage(
+ WebViewWorker.MSG_ADD_HTTPLOADER, this).sendToTarget();
return true;
} else if (handleLocalFile(url, mListener, mSettings)) {
return true;
@@ -147,34 +146,53 @@
return true;
}
if (URLUtil.isAssetUrl(url)) {
- // load asset in a separate thread as it involves IO
- WebViewWorker.getHandler().obtainMessage(
- WebViewWorker.MSG_ADD_STREAMLOADER,
- new FileLoader(url, loadListener, FileLoader.TYPE_ASSET,
- true)).sendToTarget();
+ if (loadListener.isSynchronous()) {
+ new FileLoader(url, loadListener, FileLoader.TYPE_ASSET,
+ true).load();
+ } else {
+ // load asset in a separate thread as it involves IO
+ WebViewWorker.getHandler().obtainMessage(
+ WebViewWorker.MSG_ADD_STREAMLOADER,
+ new FileLoader(url, loadListener, FileLoader.TYPE_ASSET,
+ true)).sendToTarget();
+ }
return true;
} else if (URLUtil.isResourceUrl(url)) {
- // load resource in a separate thread as it involves IO
- WebViewWorker.getHandler().obtainMessage(
- WebViewWorker.MSG_ADD_STREAMLOADER,
- new FileLoader(url, loadListener, FileLoader.TYPE_RES,
- true)).sendToTarget();
+ if (loadListener.isSynchronous()) {
+ new FileLoader(url, loadListener, FileLoader.TYPE_RES,
+ true).load();
+ } else {
+ // load resource in a separate thread as it involves IO
+ WebViewWorker.getHandler().obtainMessage(
+ WebViewWorker.MSG_ADD_STREAMLOADER,
+ new FileLoader(url, loadListener, FileLoader.TYPE_RES,
+ true)).sendToTarget();
+ }
return true;
} else if (URLUtil.isFileUrl(url)) {
- // load file in a separate thread as it involves IO
- WebViewWorker.getHandler().obtainMessage(
- WebViewWorker.MSG_ADD_STREAMLOADER,
- new FileLoader(url, loadListener, FileLoader.TYPE_FILE,
- settings.getAllowFileAccess())).sendToTarget();
+ if (loadListener.isSynchronous()) {
+ new FileLoader(url, loadListener, FileLoader.TYPE_FILE,
+ settings.getAllowFileAccess()).load();
+ } else {
+ // load file in a separate thread as it involves IO
+ WebViewWorker.getHandler().obtainMessage(
+ WebViewWorker.MSG_ADD_STREAMLOADER,
+ new FileLoader(url, loadListener, FileLoader.TYPE_FILE,
+ settings.getAllowFileAccess())).sendToTarget();
+ }
return true;
} else if (URLUtil.isContentUrl(url)) {
// Send the raw url to the ContentLoader because it will do a
// permission check and the url has to match.
- // load content in a separate thread as it involves IO
- WebViewWorker.getHandler().obtainMessage(
- WebViewWorker.MSG_ADD_STREAMLOADER,
- new ContentLoader(loadListener.url(), loadListener))
- .sendToTarget();
+ if (loadListener.isSynchronous()) {
+ new ContentLoader(loadListener.url(), loadListener).load();
+ } else {
+ // load content in a separate thread as it involves IO
+ WebViewWorker.getHandler().obtainMessage(
+ WebViewWorker.MSG_ADD_STREAMLOADER,
+ new ContentLoader(loadListener.url(), loadListener))
+ .sendToTarget();
+ }
return true;
} else if (URLUtil.isDataUrl(url)) {
// load data in the current thread to reduce the latency
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 65ae059..a889476 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -3213,27 +3213,6 @@
}
}
- private static class Metrics {
- int mScrollX;
- int mScrollY;
- int mWidth;
- int mHeight;
- float mInvScale;
- }
-
- private Metrics getViewMetrics() {
- Metrics metrics = new Metrics();
- metrics.mScrollX = mScrollX;
- metrics.mScrollY = computeVerticalScrollOffset();
- metrics.mWidth = getWidth();
- metrics.mHeight = getHeight() - getVisibleTitleHeight();
- if (mFindIsUp) {
- metrics.mHeight -= mFindHeight;
- }
- metrics.mInvScale = mInvActualScale;
- return metrics;
- }
-
private void drawExtras(Canvas canvas, int extras) {
// If mNativeClass is 0, we should not reach here, so we do not
// need to check it again.
@@ -3340,7 +3319,7 @@
if (!animateScroll) {
extras = DRAW_EXTRAS_FIND;
}
- } else if (mShiftIsPressed) {
+ } else if (mShiftIsPressed && !nativeFocusIsPlugin()) {
if (!animateZoom && !mPreviewZoomOnly) {
extras = DRAW_EXTRAS_SELECTION;
nativeSetSelectionRegion(mTouchSelection || mExtendSelection);
@@ -3695,6 +3674,7 @@
}
if (mShiftIsPressed == false && nativeCursorWantsKeyEvents() == false
+ && !nativeFocusIsPlugin()
&& (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT
|| keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT)) {
setUpSelectXY();
@@ -3702,8 +3682,11 @@
if (keyCode >= KeyEvent.KEYCODE_DPAD_UP
&& keyCode <= KeyEvent.KEYCODE_DPAD_RIGHT) {
- // always handle the navigation keys in the UI thread
switchOutDrawHistory();
+ if (nativeFocusIsPlugin()) {
+ letPluginHandleNavKey(keyCode, event.getEventTime(), true);
+ return true;
+ }
if (mShiftIsPressed) {
int xRate = keyCode == KeyEvent.KEYCODE_DPAD_LEFT
? -1 : keyCode == KeyEvent.KEYCODE_DPAD_RIGHT ? 1 : 0;
@@ -3713,7 +3696,7 @@
moveSelection(xRate * multiplier, yRate * multiplier);
return true;
}
- if (navHandledKey(keyCode, 1, false, event.getEventTime(), false)) {
+ if (navHandledKey(keyCode, 1, false, event.getEventTime())) {
playSoundEffect(keyCodeToSoundsEffect(keyCode));
return true;
}
@@ -3724,7 +3707,7 @@
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
switchOutDrawHistory();
if (event.getRepeatCount() == 0) {
- if (mShiftIsPressed) {
+ if (mShiftIsPressed && !nativeFocusIsPlugin()) {
return true; // discard press if copy in progress
}
mGotCenterDown = true;
@@ -3840,6 +3823,10 @@
if (keyCode >= KeyEvent.KEYCODE_DPAD_UP
&& keyCode <= KeyEvent.KEYCODE_DPAD_RIGHT) {
+ if (nativeFocusIsPlugin()) {
+ letPluginHandleNavKey(keyCode, event.getEventTime(), false);
+ return true;
+ }
// always handle the navigation keys in the UI thread
// Bubble up the key event as WebView doesn't handle it
return false;
@@ -3850,7 +3837,7 @@
mPrivateHandler.removeMessages(LONG_PRESS_CENTER);
mGotCenterDown = false;
- if (mShiftIsPressed) {
+ if (mShiftIsPressed && !nativeFocusIsPlugin()) {
if (mExtendSelection) {
commitCopy();
} else {
@@ -5035,7 +5022,7 @@
return true;
}
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
- if (mShiftIsPressed) {
+ if (mShiftIsPressed && !nativeFocusIsPlugin()) {
return true; // discard press if copy in progress
}
mTrackballDown = true;
@@ -5060,7 +5047,7 @@
mPrivateHandler.removeMessages(LONG_PRESS_CENTER);
mTrackballDown = false;
mTrackballUpTime = time;
- if (mShiftIsPressed) {
+ if (mShiftIsPressed && !nativeFocusIsPlugin()) {
if (mExtendSelection) {
commitCopy();
} else {
@@ -5198,7 +5185,7 @@
float yRate = mTrackballRemainsY * 1000 / elapsed;
int viewWidth = getViewWidth();
int viewHeight = getViewHeight();
- if (mShiftIsPressed) {
+ if (mShiftIsPressed && !nativeFocusIsPlugin()) {
moveSelection(scaleTrackballX(xRate, viewWidth),
scaleTrackballY(yRate, viewHeight));
mTrackballRemainsX = mTrackballRemainsY = 0;
@@ -5236,7 +5223,12 @@
+ " mTrackballRemainsX=" + mTrackballRemainsX
+ " mTrackballRemainsY=" + mTrackballRemainsY);
}
- if (navHandledKey(selectKeyCode, count, false, time, false)) {
+ if (nativeFocusIsPlugin()) {
+ for (int i = 0; i < count; i++) {
+ letPluginHandleNavKey(selectKeyCode, time, true);
+ letPluginHandleNavKey(selectKeyCode, time, false);
+ }
+ } else if (navHandledKey(selectKeyCode, count, false, time)) {
playSoundEffect(keyCodeToSoundsEffect(selectKeyCode));
}
mTrackballRemainsX = mTrackballRemainsY = 0;
@@ -5713,7 +5705,7 @@
return result;
}
if (mNativeClass != 0 && !nativeHasCursorNode()) {
- navHandledKey(fakeKeyDirection, 1, true, 0, true);
+ navHandledKey(fakeKeyDirection, 1, true, 0);
}
}
}
@@ -6139,7 +6131,7 @@
}
break;
case MOVE_OUT_OF_PLUGIN:
- navHandledKey(msg.arg1, 1, false, 0, true);
+ navHandledKey(msg.arg1, 1, false, 0);
break;
case UPDATE_TEXT_ENTRY_MSG_ID:
// this is sent after finishing resize in WebViewCore. Make
@@ -6806,21 +6798,34 @@
invalidate();
}
- // return true if the key was handled
- private boolean navHandledKey(int keyCode, int count, boolean noScroll,
- long time, boolean ignorePlugin) {
- if (mNativeClass == 0) {
- return false;
+ /**
+ * Pass the key to the plugin. This assumes that nativeFocusIsPlugin()
+ * returned true.
+ */
+ private void letPluginHandleNavKey(int keyCode, long time, boolean down) {
+ int keyEventAction;
+ int eventHubAction;
+ if (down) {
+ keyEventAction = KeyEvent.ACTION_DOWN;
+ eventHubAction = EventHub.KEY_DOWN;
+ playSoundEffect(keyCodeToSoundsEffect(keyCode));
+ } else {
+ keyEventAction = KeyEvent.ACTION_UP;
+ eventHubAction = EventHub.KEY_UP;
}
- if (ignorePlugin == false && nativeFocusIsPlugin()) {
- KeyEvent event = new KeyEvent(time, time, KeyEvent.ACTION_DOWN
- , keyCode, count, (mShiftIsPressed ? KeyEvent.META_SHIFT_ON : 0)
+ KeyEvent event = new KeyEvent(time, time, keyEventAction, keyCode,
+ 1, (mShiftIsPressed ? KeyEvent.META_SHIFT_ON : 0)
| (false ? KeyEvent.META_ALT_ON : 0) // FIXME
| (false ? KeyEvent.META_SYM_ON : 0) // FIXME
, 0, 0, 0);
- mWebViewCore.sendMessage(EventHub.KEY_DOWN, event);
- mWebViewCore.sendMessage(EventHub.KEY_UP, event);
- return true;
+ mWebViewCore.sendMessage(eventHubAction, event);
+ }
+
+ // return true if the key was handled
+ private boolean navHandledKey(int keyCode, int count, boolean noScroll,
+ long time) {
+ if (mNativeClass == 0) {
+ return false;
}
mLastCursorTime = time;
mLastCursorBounds = nativeGetCursorRingBounds();
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java
index 0f47b96..ed63787 100644
--- a/core/java/android/widget/AutoCompleteTextView.java
+++ b/core/java/android/widget/AutoCompleteTextView.java
@@ -1081,11 +1081,11 @@
}
@Override
- protected boolean setFrame(int l, int t, int r, int b) {
+ protected boolean setFrame(final int l, int t, final int r, int b) {
boolean result = super.setFrame(l, t, r, b);
if (mPopup.isShowing()) {
- mPopup.update(this, r - l, -1);
+ showDropDown();
}
return result;
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 9ef5e0b..b3d5f1a 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -94,9 +94,7 @@
mDayPicker.setOnChangeListener(new OnChangedListener() {
public void onChanged(NumberPicker picker, int oldVal, int newVal) {
mDay = newVal;
- if (mOnDateChangedListener != null) {
- mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay);
- }
+ notifyDateChanged();
}
});
mMonthPicker = (NumberPicker) findViewById(R.id.month);
@@ -126,9 +124,7 @@
mMonth = newVal - 1;
// Adjust max day of the month
adjustMaxDay();
- if (mOnDateChangedListener != null) {
- mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay);
- }
+ notifyDateChanged();
updateDaySpinner();
}
});
@@ -139,9 +135,7 @@
mYear = newVal;
// Adjust max day for leap years if needed
adjustMaxDay();
- if (mOnDateChangedListener != null) {
- mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay);
- }
+ notifyDateChanged();
updateDaySpinner();
}
});
@@ -242,11 +236,14 @@
}
public void updateDate(int year, int monthOfYear, int dayOfMonth) {
- mYear = year;
- mMonth = monthOfYear;
- mDay = dayOfMonth;
- updateSpinners();
- reorderPickers(new DateFormatSymbols().getShortMonths());
+ if (mYear != year || mMonth != monthOfYear || mDay != dayOfMonth) {
+ mYear = year;
+ mMonth = monthOfYear;
+ mDay = dayOfMonth;
+ updateSpinners();
+ reorderPickers(new DateFormatSymbols().getShortMonths());
+ notifyDateChanged();
+ }
}
private static class SavedState extends BaseSavedState {
@@ -388,4 +385,10 @@
mDay = max;
}
}
+
+ private void notifyDateChanged() {
+ if (mOnDateChangedListener != null) {
+ mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay);
+ }
+ }
}
diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java
index acb7e02..d80a5e3 100644
--- a/core/java/android/widget/HorizontalScrollView.java
+++ b/core/java/android/widget/HorizontalScrollView.java
@@ -318,11 +318,7 @@
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// Let the focused view and/or our descendants get the key first
- boolean handled = super.dispatchKeyEvent(event);
- if (handled) {
- return true;
- }
- return executeKeyEvent(event);
+ return super.dispatchKeyEvent(event) || executeKeyEvent(event);
}
/**
@@ -509,8 +505,11 @@
final int deltaX = (int) (mLastMotionX - x);
mLastMotionX = x;
+ final int oldX = mScrollX;
+ final int oldY = mScrollY;
overscrollBy(deltaX, 0, mScrollX, 0, getScrollRange(), 0,
getOverscrollMax(), 0);
+ onScrollChanged(mScrollX, mScrollY, oldX, oldY);
}
break;
case MotionEvent.ACTION_UP:
@@ -524,7 +523,7 @@
fling(-initialVelocity);
} else {
final int right = getScrollRange();
- if (mScroller.springback(mScrollX, mScrollY, 0, 0, right, 0)) {
+ if (mScroller.springback(mScrollX, mScrollY, 0, right, 0, 0)) {
invalidate();
}
}
diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java
index d20ab3b..cf2ed86 100644
--- a/core/java/android/widget/PopupWindow.java
+++ b/core/java/android/widget/PopupWindow.java
@@ -126,7 +126,7 @@
WindowManager.LayoutParams p = (WindowManager.LayoutParams)
mPopupView.getLayoutParams();
- mAboveAnchor = findDropDownPosition(anchor, p, mAnchorXoff, mAnchorYoff);
+ updateAboveAnchor(findDropDownPosition(anchor, p, mAnchorXoff, mAnchorYoff));
update(p.x, p.y, -1, -1, true);
}
}
@@ -729,22 +729,8 @@
WindowManager.LayoutParams p = createPopupLayout(anchor.getWindowToken());
preparePopup(p);
- mAboveAnchor = findDropDownPosition(anchor, p, xoff, yoff);
- if (mBackground != null) {
- // If the background drawable provided was a StateListDrawable with above-anchor
- // and below-anchor states, use those. Otherwise rely on refreshDrawableState to
- // do the job.
- if (mAboveAnchorBackgroundDrawable != null) {
- if (mAboveAnchor) {
- mPopupView.setBackgroundDrawable(mAboveAnchorBackgroundDrawable);
- } else {
- mPopupView.setBackgroundDrawable(mBelowAnchorBackgroundDrawable);
- }
- } else {
- mPopupView.refreshDrawableState();
- }
- }
+ updateAboveAnchor(findDropDownPosition(anchor, p, xoff, yoff));
if (mHeightMode < 0) p.height = mLastHeight = mHeightMode;
if (mWidthMode < 0) p.width = mLastWidth = mWidthMode;
@@ -754,6 +740,27 @@
invokePopup(p);
}
+ private void updateAboveAnchor(boolean aboveAnchor) {
+ if (aboveAnchor != mAboveAnchor) {
+ mAboveAnchor = aboveAnchor;
+
+ if (mBackground != null) {
+ // If the background drawable provided was a StateListDrawable with above-anchor
+ // and below-anchor states, use those. Otherwise rely on refreshDrawableState to
+ // do the job.
+ if (mAboveAnchorBackgroundDrawable != null) {
+ if (mAboveAnchor) {
+ mPopupView.setBackgroundDrawable(mAboveAnchorBackgroundDrawable);
+ } else {
+ mPopupView.setBackgroundDrawable(mBelowAnchorBackgroundDrawable);
+ }
+ } else {
+ mPopupView.refreshDrawableState();
+ }
+ }
+ }
+ }
+
/**
* Indicates whether the popup is showing above (the y coordinate of the popup's bottom
* is less than the y coordinate of the anchor) or below the anchor view (the y coordinate
@@ -915,7 +922,7 @@
anchor.getLocationInWindow(mDrawingLocation);
p.x = mDrawingLocation[0] + xoff;
- p.y = mDrawingLocation[1] + anchor.getMeasuredHeight() + yoff;
+ p.y = mDrawingLocation[1] + anchor.getHeight() + yoff;
boolean onTop = false;
@@ -932,26 +939,26 @@
// the edit box
int scrollX = anchor.getScrollX();
int scrollY = anchor.getScrollY();
- Rect r = new Rect(scrollX, scrollY, scrollX + mPopupWidth,
- scrollY + mPopupHeight + anchor.getMeasuredHeight());
+ Rect r = new Rect(scrollX, scrollY, scrollX + mPopupWidth + xoff,
+ scrollY + mPopupHeight + anchor.getHeight() + yoff);
anchor.requestRectangleOnScreen(r, true);
-
+
// now we re-evaluate the space available, and decide from that
// whether the pop-up will go above or below the anchor.
anchor.getLocationInWindow(mDrawingLocation);
p.x = mDrawingLocation[0] + xoff;
- p.y = mDrawingLocation[1] + anchor.getMeasuredHeight() + yoff;
+ p.y = mDrawingLocation[1] + anchor.getHeight() + yoff;
// determine whether there is more space above or below the anchor
anchor.getLocationOnScreen(mScreenLocation);
- onTop = (displayFrame.bottom - mScreenLocation[1] - anchor.getMeasuredHeight() - yoff) <
+ onTop = (displayFrame.bottom - mScreenLocation[1] - anchor.getHeight() - yoff) <
(mScreenLocation[1] - yoff - displayFrame.top);
if (onTop) {
p.gravity = Gravity.LEFT | Gravity.BOTTOM;
p.y = root.getHeight() - mDrawingLocation[1] + yoff;
} else {
- p.y = mDrawingLocation[1] + anchor.getMeasuredHeight() + yoff;
+ p.y = mDrawingLocation[1] + anchor.getHeight() + yoff;
}
}
@@ -1257,13 +1264,16 @@
}
}
- if (updateLocation) {
- mAboveAnchor = findDropDownPosition(anchor, p, xoff, yoff);
- } else {
- mAboveAnchor = findDropDownPosition(anchor, p, mAnchorXoff, mAnchorYoff);
- }
+ int x = p.x;
+ int y = p.y;
- update(p.x, p.y, width, height);
+ if (updateLocation) {
+ updateAboveAnchor(findDropDownPosition(anchor, p, xoff, yoff));
+ } else {
+ updateAboveAnchor(findDropDownPosition(anchor, p, mAnchorXoff, mAnchorYoff));
+ }
+
+ update(p.x, p.y, width, height, x != p.x || y != p.y);
}
/**
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index 489c44d..d7dfa86 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -22,7 +22,6 @@
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.FocusFinder;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -52,8 +51,6 @@
* <p>ScrollView only supports vertical scrolling.
*/
public class ScrollView extends FrameLayout {
- private static final String TAG = "ScrollView";
-
static final int ANIMATED_SCROLL_GAP = 250;
static final float MAX_SCROLL_FACTOR = 0.5f;
@@ -318,11 +315,7 @@
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// Let the focused view and/or our descendants get the key first
- boolean handled = super.dispatchKeyEvent(event);
- if (handled) {
- return true;
- }
- return executeKeyEvent(event);
+ return super.dispatchKeyEvent(event) || executeKeyEvent(event);
}
/**
@@ -510,8 +503,11 @@
final int deltaY = (int) (mLastMotionY - y);
mLastMotionY = y;
+ final int oldX = mScrollX;
+ final int oldY = mScrollY;
overscrollBy(0, deltaY, 0, mScrollY, 0, getScrollRange(),
0, getOverscrollMax());
+ onScrollChanged(mScrollX, mScrollY, oldX, oldY);
}
break;
case MotionEvent.ACTION_UP:
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 51e1c57..7b21be5 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -1376,15 +1376,18 @@
dr.mDrawableLeft.setCallback(null);
}
dr.mDrawableLeft = left;
- if (dr.mDrawableTop != left && dr.mDrawableTop != null) {
+
+ if (dr.mDrawableTop != top && dr.mDrawableTop != null) {
dr.mDrawableTop.setCallback(null);
}
dr.mDrawableTop = top;
- if (dr.mDrawableRight != left && dr.mDrawableRight != null) {
+
+ if (dr.mDrawableRight != right && dr.mDrawableRight != null) {
dr.mDrawableRight.setCallback(null);
}
dr.mDrawableRight = right;
- if (dr.mDrawableBottom != left && dr.mDrawableBottom != null) {
+
+ if (dr.mDrawableBottom != bottom && dr.mDrawableBottom != null) {
dr.mDrawableBottom.setCallback(null);
}
dr.mDrawableBottom = bottom;
diff --git a/core/java/com/android/internal/app/ShutdownThread.java b/core/java/com/android/internal/app/ShutdownThread.java
index 2f48499..37898a1 100644
--- a/core/java/com/android/internal/app/ShutdownThread.java
+++ b/core/java/com/android/internal/app/ShutdownThread.java
@@ -28,6 +28,7 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Handler;
+import android.os.PowerManager;
import android.os.RemoteException;
import android.os.Power;
import android.os.ServiceManager;
@@ -56,6 +57,8 @@
private final Object mBroadcastDoneSync = new Object();
private boolean mBroadcastDone;
private Context mContext;
+ private PowerManager mPowerManager;
+ private PowerManager.WakeLock mWakeLock;
private Handler mHandler;
private ShutdownThread() {
@@ -125,6 +128,18 @@
// start the thread that initiates shutdown
sInstance.mContext = context;
+ sInstance.mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
+ sInstance.mWakeLock = null;
+ if (sInstance.mPowerManager.isScreenOn()) {
+ try {
+ sInstance.mWakeLock = sInstance.mPowerManager.newWakeLock(
+ PowerManager.FULL_WAKE_LOCK, "Shutdown");
+ sInstance.mWakeLock.acquire();
+ } catch (SecurityException e) {
+ Log.w(TAG, "No permission to acquire wake lock", e);
+ sInstance.mWakeLock = null;
+ }
+ }
sInstance.mHandler = new Handler() {
};
sInstance.start();
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index d6b0808..efd025a 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -173,22 +173,6 @@
getDevicePolicyManager().reportSuccessfulPasswordAttempt();
}
- public void setActivePasswordState(int mode, int length) {
- int policyMode = DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
- switch (mode) {
- case MODE_PATTERN:
- policyMode = DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
- break;
- case MODE_PIN:
- policyMode = DevicePolicyManager.PASSWORD_QUALITY_NUMERIC;
- break;
- case MODE_PASSWORD:
- policyMode = DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC;
- break;
- }
- getDevicePolicyManager().setActivePasswordState(policyMode, length);
- }
-
/**
* Check to see if a pattern matches the saved pattern. If no pattern exists,
* always returns true.
@@ -312,13 +296,15 @@
raf.write(hash, 0, hash.length);
}
raf.close();
+ DevicePolicyManager dpm = getDevicePolicyManager();
if (pattern != null) {
setBoolean(PATTERN_EVER_CHOSEN_KEY, true);
setLong(PASSWORD_TYPE_KEY, MODE_PATTERN);
- DevicePolicyManager dpm = (DevicePolicyManager)mContext.getSystemService(
- Context.DEVICE_POLICY_SERVICE);
dpm.setActivePasswordState(
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, pattern.size());
+ } else {
+ dpm.setActivePasswordState(
+ DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED, 0);
}
} catch (FileNotFoundException fnfe) {
// Cant do much, unless we want to fail over to using the settings provider
@@ -404,15 +390,17 @@
raf.write(hash, 0, hash.length);
}
raf.close();
+ DevicePolicyManager dpm = getDevicePolicyManager();
if (password != null) {
int finalMode = adjustPasswordMode(password, mode);
if (mode < finalMode) {
mode = finalMode;
}
setLong(PASSWORD_TYPE_KEY, mode);
- DevicePolicyManager dpm = (DevicePolicyManager)mContext.getSystemService(
- Context.DEVICE_POLICY_SERVICE);
dpm.setActivePasswordState(mode, password.length());
+ } else {
+ dpm.setActivePasswordState(
+ DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED, 0);
}
} catch (FileNotFoundException fnfe) {
// Cant do much, unless we want to fail over to using the settings provider
@@ -550,7 +538,7 @@
* @return Whether the lock pattern is enabled.
*/
public boolean isLockPatternEnabled() {
- return getBoolean(Settings.System.LOCK_PATTERN_ENABLED)
+ return getBoolean(Settings.Secure.LOCK_PATTERN_ENABLED)
&& getLong(PASSWORD_TYPE_KEY, MODE_PATTERN) == MODE_PATTERN;
}
@@ -558,35 +546,35 @@
* Set whether the lock pattern is enabled.
*/
public void setLockPatternEnabled(boolean enabled) {
- setBoolean(Settings.System.LOCK_PATTERN_ENABLED, enabled);
+ setBoolean(Settings.Secure.LOCK_PATTERN_ENABLED, enabled);
}
/**
* @return Whether the visible pattern is enabled.
*/
public boolean isVisiblePatternEnabled() {
- return getBoolean(Settings.System.LOCK_PATTERN_VISIBLE);
+ return getBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE);
}
/**
* Set whether the visible pattern is enabled.
*/
public void setVisiblePatternEnabled(boolean enabled) {
- setBoolean(Settings.System.LOCK_PATTERN_VISIBLE, enabled);
+ setBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, enabled);
}
/**
* @return Whether tactile feedback for the pattern is enabled.
*/
public boolean isTactileFeedbackEnabled() {
- return getBoolean(Settings.System.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
+ return getBoolean(Settings.Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
}
/**
* Set whether tactile feedback for the pattern is enabled.
*/
public void setTactileFeedbackEnabled(boolean enabled) {
- setBoolean(Settings.System.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED, enabled);
+ setBoolean(Settings.Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED, enabled);
}
/**
@@ -648,30 +636,22 @@
return nextAlarm;
}
- private boolean getBoolean(String systemSettingKey) {
- // STOPSHIP: these need to be moved to secure settings!
+ private boolean getBoolean(String secureSettingKey) {
return 1 ==
- android.provider.Settings.System.getInt(
- mContentResolver,
- systemSettingKey, 0);
+ android.provider.Settings.Secure.getInt(mContentResolver, secureSettingKey, 0);
}
- private void setBoolean(String systemSettingKey, boolean enabled) {
- // STOPSHIP: these need to be moved to secure settings!
- android.provider.Settings.System.putInt(
- mContentResolver,
- systemSettingKey,
- enabled ? 1 : 0);
+ private void setBoolean(String secureSettingKey, boolean enabled) {
+ android.provider.Settings.Secure.putInt(mContentResolver, secureSettingKey,
+ enabled ? 1 : 0);
}
- private long getLong(String systemSettingKey, long def) {
- // STOPSHIP: these need to be moved to secure settings!
- return android.provider.Settings.System.getLong(mContentResolver, systemSettingKey, def);
+ private long getLong(String secureSettingKey, long def) {
+ return android.provider.Settings.Secure.getLong(mContentResolver, secureSettingKey, def);
}
- private void setLong(String systemSettingKey, long value) {
- // STOPSHIP: these need to be moved to secure settings!
- android.provider.Settings.System.putLong(mContentResolver, systemSettingKey, value);
+ private void setLong(String secureSettingKey, long value) {
+ android.provider.Settings.Secure.putLong(mContentResolver, secureSettingKey, value);
}
public boolean isSecure() {
diff --git a/mms-common/java/com/android/mmscommon/mms/ContentType.java b/core/java/com/google/android/mms/ContentType.java
similarity index 98%
rename from mms-common/java/com/android/mmscommon/mms/ContentType.java
rename to core/java/com/google/android/mms/ContentType.java
index f21eba8..94bc9fd 100644
--- a/mms-common/java/com/android/mmscommon/mms/ContentType.java
+++ b/core/java/com/google/android/mms/ContentType.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms;
+package com.google.android.mms;
import java.util.ArrayList;
@@ -26,7 +26,6 @@
public static final String MMS_GENERIC = "application/vnd.wap.mms-generic";
public static final String MULTIPART_MIXED = "application/vnd.wap.multipart.mixed";
public static final String MULTIPART_RELATED = "application/vnd.wap.multipart.related";
- public static final String MULTIPART_ALTERNATIVE = "application/vnd.wap.multipart.alternative";
public static final String TEXT_PLAIN = "text/plain";
public static final String TEXT_HTML = "text/html";
diff --git a/mms-common/java/com/android/mmscommon/InvalidHeaderValueException.java b/core/java/com/google/android/mms/InvalidHeaderValueException.java
similarity index 97%
rename from mms-common/java/com/android/mmscommon/InvalidHeaderValueException.java
rename to core/java/com/google/android/mms/InvalidHeaderValueException.java
index 34d5871..73d7832 100644
--- a/mms-common/java/com/android/mmscommon/InvalidHeaderValueException.java
+++ b/core/java/com/google/android/mms/InvalidHeaderValueException.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.mmscommon;
+package com.google.android.mms;
/**
* Thrown when an invalid header value was set.
diff --git a/mms-common/java/com/android/mmscommon/MmsException.java b/core/java/com/google/android/mms/MmsException.java
similarity index 97%
rename from mms-common/java/com/android/mmscommon/MmsException.java
rename to core/java/com/google/android/mms/MmsException.java
index 296a2c3..6ca0c7e 100644
--- a/mms-common/java/com/android/mmscommon/MmsException.java
+++ b/core/java/com/google/android/mms/MmsException.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.mmscommon;
+package com.google.android.mms;
/**
* A generic exception that is thrown by the Mms client.
diff --git a/core/java/com/google/android/mms/package.html b/core/java/com/google/android/mms/package.html
new file mode 100755
index 0000000..c9f96a6
--- /dev/null
+++ b/core/java/com/google/android/mms/package.html
@@ -0,0 +1,5 @@
+<body>
+
+{@hide}
+
+</body>
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/AcknowledgeInd.java b/core/java/com/google/android/mms/pdu/AcknowledgeInd.java
similarity index 94%
rename from mms-common/java/com/android/mmscommon/mms/pdu/AcknowledgeInd.java
rename to core/java/com/google/android/mms/pdu/AcknowledgeInd.java
index d1243b2..0e96c60 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/AcknowledgeInd.java
+++ b/core/java/com/google/android/mms/pdu/AcknowledgeInd.java
@@ -15,10 +15,9 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
-import com.android.mmscommon.InvalidHeaderValueException;
-import com.android.mmscommon.PduHeaders;
+import com.google.android.mms.InvalidHeaderValueException;
/**
* M-Acknowledge.ind PDU.
diff --git a/core/java/com/google/android/mms/pdu/Base64.java b/core/java/com/google/android/mms/pdu/Base64.java
new file mode 100644
index 0000000..604bee0
--- /dev/null
+++ b/core/java/com/google/android/mms/pdu/Base64.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2007 Esmertec AG.
+ * Copyright (C) 2007 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.google.android.mms.pdu;
+
+public class Base64 {
+ /**
+ * Used to get the number of Quadruples.
+ */
+ static final int FOURBYTE = 4;
+
+ /**
+ * Byte used to pad output.
+ */
+ static final byte PAD = (byte) '=';
+
+ /**
+ * The base length.
+ */
+ static final int BASELENGTH = 255;
+
+ // Create arrays to hold the base64 characters
+ private static byte[] base64Alphabet = new byte[BASELENGTH];
+
+ // Populating the character arrays
+ static {
+ for (int i = 0; i < BASELENGTH; i++) {
+ base64Alphabet[i] = (byte) -1;
+ }
+ for (int i = 'Z'; i >= 'A'; i--) {
+ base64Alphabet[i] = (byte) (i - 'A');
+ }
+ for (int i = 'z'; i >= 'a'; i--) {
+ base64Alphabet[i] = (byte) (i - 'a' + 26);
+ }
+ for (int i = '9'; i >= '0'; i--) {
+ base64Alphabet[i] = (byte) (i - '0' + 52);
+ }
+
+ base64Alphabet['+'] = 62;
+ base64Alphabet['/'] = 63;
+ }
+
+ /**
+ * Decodes Base64 data into octects
+ *
+ * @param base64Data Byte array containing Base64 data
+ * @return Array containing decoded data.
+ */
+ public static byte[] decodeBase64(byte[] base64Data) {
+ // RFC 2045 requires that we discard ALL non-Base64 characters
+ base64Data = discardNonBase64(base64Data);
+
+ // handle the edge case, so we don't have to worry about it later
+ if (base64Data.length == 0) {
+ return new byte[0];
+ }
+
+ int numberQuadruple = base64Data.length / FOURBYTE;
+ byte decodedData[] = null;
+ byte b1 = 0, b2 = 0, b3 = 0, b4 = 0, marker0 = 0, marker1 = 0;
+
+ // Throw away anything not in base64Data
+
+ int encodedIndex = 0;
+ int dataIndex = 0;
+ {
+ // this sizes the output array properly - rlw
+ int lastData = base64Data.length;
+ // ignore the '=' padding
+ while (base64Data[lastData - 1] == PAD) {
+ if (--lastData == 0) {
+ return new byte[0];
+ }
+ }
+ decodedData = new byte[lastData - numberQuadruple];
+ }
+
+ for (int i = 0; i < numberQuadruple; i++) {
+ dataIndex = i * 4;
+ marker0 = base64Data[dataIndex + 2];
+ marker1 = base64Data[dataIndex + 3];
+
+ b1 = base64Alphabet[base64Data[dataIndex]];
+ b2 = base64Alphabet[base64Data[dataIndex + 1]];
+
+ if (marker0 != PAD && marker1 != PAD) {
+ //No PAD e.g 3cQl
+ b3 = base64Alphabet[marker0];
+ b4 = base64Alphabet[marker1];
+
+ decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
+ decodedData[encodedIndex + 1] =
+ (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
+ decodedData[encodedIndex + 2] = (byte) (b3 << 6 | b4);
+ } else if (marker0 == PAD) {
+ //Two PAD e.g. 3c[Pad][Pad]
+ decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
+ } else if (marker1 == PAD) {
+ //One PAD e.g. 3cQ[Pad]
+ b3 = base64Alphabet[marker0];
+
+ decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
+ decodedData[encodedIndex + 1] =
+ (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
+ }
+ encodedIndex += 3;
+ }
+ return decodedData;
+ }
+
+ /**
+ * Check octect wheter it is a base64 encoding.
+ *
+ * @param octect to be checked byte
+ * @return ture if it is base64 encoding, false otherwise.
+ */
+ private static boolean isBase64(byte octect) {
+ if (octect == PAD) {
+ return true;
+ } else if (base64Alphabet[octect] == -1) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Discards any characters outside of the base64 alphabet, per
+ * the requirements on page 25 of RFC 2045 - "Any characters
+ * outside of the base64 alphabet are to be ignored in base64
+ * encoded data."
+ *
+ * @param data The base-64 encoded data to groom
+ * @return The data, less non-base64 characters (see RFC 2045).
+ */
+ static byte[] discardNonBase64(byte[] data) {
+ byte groomedData[] = new byte[data.length];
+ int bytesCopied = 0;
+
+ for (int i = 0; i < data.length; i++) {
+ if (isBase64(data[i])) {
+ groomedData[bytesCopied++] = data[i];
+ }
+ }
+
+ byte packedData[] = new byte[bytesCopied];
+
+ System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
+
+ return packedData;
+ }
+}
diff --git a/mms-common/java/com/android/mmscommon/CharacterSets.java b/core/java/com/google/android/mms/pdu/CharacterSets.java
similarity index 98%
rename from mms-common/java/com/android/mmscommon/CharacterSets.java
rename to core/java/com/google/android/mms/pdu/CharacterSets.java
index f19b078..4e22ca5 100644
--- a/mms-common/java/com/android/mmscommon/CharacterSets.java
+++ b/core/java/com/google/android/mms/pdu/CharacterSets.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.mmscommon;
+package com.google.android.mms.pdu;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/DeliveryInd.java b/core/java/com/google/android/mms/pdu/DeliveryInd.java
similarity index 94%
rename from mms-common/java/com/android/mmscommon/mms/pdu/DeliveryInd.java
rename to core/java/com/google/android/mms/pdu/DeliveryInd.java
index e83729b..dafa8d1 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/DeliveryInd.java
+++ b/core/java/com/google/android/mms/pdu/DeliveryInd.java
@@ -15,11 +15,9 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
-import com.android.mmscommon.EncodedStringValue;
-import com.android.mmscommon.InvalidHeaderValueException;
-import com.android.mmscommon.PduHeaders;
+import com.google.android.mms.InvalidHeaderValueException;
/**
* M-Delivery.Ind Pdu.
diff --git a/mms-common/java/com/android/mmscommon/EncodedStringValue.java b/core/java/com/google/android/mms/pdu/EncodedStringValue.java
similarity index 99%
rename from mms-common/java/com/android/mmscommon/EncodedStringValue.java
rename to core/java/com/google/android/mms/pdu/EncodedStringValue.java
index 0a4424e..a27962d 100644
--- a/mms-common/java/com/android/mmscommon/EncodedStringValue.java
+++ b/core/java/com/google/android/mms/pdu/EncodedStringValue.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.mmscommon;
+package com.google.android.mms.pdu;
import android.util.Config;
import android.util.Log;
@@ -269,7 +269,7 @@
return new EncodedStringValue(value.mCharacterSet, value.mData);
}
-
+
public static EncodedStringValue[] encodeStrings(String[] array) {
int count = array.length;
if (count > 0) {
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/GenericPdu.java b/core/java/com/google/android/mms/pdu/GenericPdu.java
similarity index 93%
rename from mms-common/java/com/android/mmscommon/mms/pdu/GenericPdu.java
rename to core/java/com/google/android/mms/pdu/GenericPdu.java
index c38e502..705de6a 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/GenericPdu.java
+++ b/core/java/com/google/android/mms/pdu/GenericPdu.java
@@ -15,11 +15,9 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
-import com.android.mmscommon.EncodedStringValue;
-import com.android.mmscommon.InvalidHeaderValueException;
-import com.android.mmscommon.PduHeaders;
+import com.google.android.mms.InvalidHeaderValueException;
public class GenericPdu {
/**
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/MultimediaMessagePdu.java b/core/java/com/google/android/mms/pdu/MultimediaMessagePdu.java
similarity index 94%
rename from mms-common/java/com/android/mmscommon/mms/pdu/MultimediaMessagePdu.java
rename to core/java/com/google/android/mms/pdu/MultimediaMessagePdu.java
index 04fde2d..5a85e0e 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/MultimediaMessagePdu.java
+++ b/core/java/com/google/android/mms/pdu/MultimediaMessagePdu.java
@@ -15,11 +15,9 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
-import com.android.mmscommon.EncodedStringValue;
-import com.android.mmscommon.InvalidHeaderValueException;
-import com.android.mmscommon.PduHeaders;
+import com.google.android.mms.InvalidHeaderValueException;
/**
* Multimedia message PDU.
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/NotificationInd.java b/core/java/com/google/android/mms/pdu/NotificationInd.java
similarity index 97%
rename from mms-common/java/com/android/mmscommon/mms/pdu/NotificationInd.java
rename to core/java/com/google/android/mms/pdu/NotificationInd.java
index 24f17b09..c56cba6 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/NotificationInd.java
+++ b/core/java/com/google/android/mms/pdu/NotificationInd.java
@@ -15,11 +15,9 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
-import com.android.mmscommon.EncodedStringValue;
-import com.android.mmscommon.InvalidHeaderValueException;
-import com.android.mmscommon.PduHeaders;
+import com.google.android.mms.InvalidHeaderValueException;
/**
* M-Notification.ind PDU.
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/NotifyRespInd.java b/core/java/com/google/android/mms/pdu/NotifyRespInd.java
similarity index 95%
rename from mms-common/java/com/android/mmscommon/mms/pdu/NotifyRespInd.java
rename to core/java/com/google/android/mms/pdu/NotifyRespInd.java
index c2e2b26..2cc2fce 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/NotifyRespInd.java
+++ b/core/java/com/google/android/mms/pdu/NotifyRespInd.java
@@ -15,10 +15,9 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
-import com.android.mmscommon.InvalidHeaderValueException;
-import com.android.mmscommon.PduHeaders;
+import com.google.android.mms.InvalidHeaderValueException;
/**
* M-NofifyResp.ind PDU.
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/PduBody.java b/core/java/com/google/android/mms/pdu/PduBody.java
similarity index 98%
rename from mms-common/java/com/android/mmscommon/mms/pdu/PduBody.java
rename to core/java/com/google/android/mms/pdu/PduBody.java
index cc28d80..fa0416c 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/PduBody.java
+++ b/core/java/com/google/android/mms/pdu/PduBody.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
import java.util.HashMap;
import java.util.Map;
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/PduComposer.java b/core/java/com/google/android/mms/pdu/PduComposer.java
similarity index 99%
rename from mms-common/java/com/android/mmscommon/mms/pdu/PduComposer.java
rename to core/java/com/google/android/mms/pdu/PduComposer.java
index bb3116d..8940945 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/PduComposer.java
+++ b/core/java/com/google/android/mms/pdu/PduComposer.java
@@ -15,10 +15,7 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
-
-import com.android.mmscommon.EncodedStringValue;
-import com.android.mmscommon.PduHeaders;
+package com.google.android.mms.pdu;
import android.content.ContentResolver;
import android.content.Context;
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/PduContentTypes.java b/core/java/com/google/android/mms/pdu/PduContentTypes.java
similarity index 98%
rename from mms-common/java/com/android/mmscommon/mms/pdu/PduContentTypes.java
rename to core/java/com/google/android/mms/pdu/PduContentTypes.java
index 3f971fd..7799e0e 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/PduContentTypes.java
+++ b/core/java/com/google/android/mms/pdu/PduContentTypes.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
public class PduContentTypes {
/**
diff --git a/mms-common/java/com/android/mmscommon/PduHeaders.java b/core/java/com/google/android/mms/pdu/PduHeaders.java
similarity index 97%
rename from mms-common/java/com/android/mmscommon/PduHeaders.java
rename to core/java/com/google/android/mms/pdu/PduHeaders.java
index d8f1211..4313815 100644
--- a/mms-common/java/com/android/mmscommon/PduHeaders.java
+++ b/core/java/com/google/android/mms/pdu/PduHeaders.java
@@ -15,7 +15,9 @@
* limitations under the License.
*/
-package com.android.mmscommon;
+package com.google.android.mms.pdu;
+
+import com.google.android.mms.InvalidHeaderValueException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -337,7 +339,7 @@
* with specified header field. Return 0 if
* the value is not set.
*/
- public int getOctet(int field) {
+ protected int getOctet(int field) {
Integer octet = (Integer) mHeaderMap.get(field);
if (null == octet) {
return 0;
@@ -353,7 +355,7 @@
* @param field the field
* @throws InvalidHeaderValueException if the value is invalid.
*/
- public void setOctet(int value, int field)
+ protected void setOctet(int value, int field)
throws InvalidHeaderValueException{
/**
* Check whether this field can be set for specific
@@ -497,7 +499,7 @@
* @return the TextString value of the pdu header
* with specified header field
*/
- public byte[] getTextString(int field) {
+ protected byte[] getTextString(int field) {
return (byte[]) mHeaderMap.get(field);
}
@@ -510,7 +512,7 @@
* with specified header field
* @throws NullPointerException if the value is null.
*/
- public void setTextString(byte[] value, int field) {
+ protected void setTextString(byte[] value, int field) {
/**
* Check whether this field can be set for specific
* header and check validity of the field.
@@ -546,7 +548,7 @@
* @return the EncodedStringValue value of the pdu header
* with specified header field
*/
- public EncodedStringValue getEncodedStringValue(int field) {
+ protected EncodedStringValue getEncodedStringValue(int field) {
return (EncodedStringValue) mHeaderMap.get(field);
}
@@ -557,7 +559,7 @@
* @return the EncodeStringValue array of the pdu header
* with specified header field
*/
- public EncodedStringValue[] getEncodedStringValues(int field) {
+ protected EncodedStringValue[] getEncodedStringValues(int field) {
ArrayList<EncodedStringValue> list =
(ArrayList<EncodedStringValue>) mHeaderMap.get(field);
if (null == list) {
@@ -576,7 +578,7 @@
* with specified header field
* @throws NullPointerException if the value is null.
*/
- public void setEncodedStringValue(EncodedStringValue value, int field) {
+ protected void setEncodedStringValue(EncodedStringValue value, int field) {
/**
* Check whether this field can be set for specific
* header and check validity of the field.
@@ -613,7 +615,7 @@
* with specified header field
* @throws NullPointerException if the value is null.
*/
- public void setEncodedStringValues(EncodedStringValue[] value, int field) {
+ protected void setEncodedStringValues(EncodedStringValue[] value, int field) {
/**
* Check whether this field can be set for specific
* header and check validity of the field.
@@ -646,7 +648,7 @@
* @param field the field
* @throws NullPointerException if the value is null.
*/
- public void appendEncodedStringValue(EncodedStringValue value,
+ protected void appendEncodedStringValue(EncodedStringValue value,
int field) {
if (null == value) {
throw new NullPointerException();
@@ -678,7 +680,7 @@
* with specified header field. if return -1, the
* field is not existed in pdu header.
*/
- public long getLongInteger(int field) {
+ protected long getLongInteger(int field) {
Long longInteger = (Long) mHeaderMap.get(field);
if (null == longInteger) {
return -1;
@@ -693,7 +695,7 @@
* @param value the value
* @param field the field
*/
- public void setLongInteger(long value, int field) {
+ protected void setLongInteger(long value, int field) {
/**
* Check whether this field can be set for specific
* header and check validity of the field.
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/PduParser.java b/core/java/com/google/android/mms/pdu/PduParser.java
similarity index 98%
rename from mms-common/java/com/android/mmscommon/mms/pdu/PduParser.java
rename to core/java/com/google/android/mms/pdu/PduParser.java
index 6a58ba6..d465c5a 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/PduParser.java
+++ b/core/java/com/google/android/mms/pdu/PduParser.java
@@ -15,17 +15,13 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
-import com.android.mmscommon.CharacterSets;
-import com.android.mmscommon.ContentType;
-import com.android.mmscommon.EncodedStringValue;
-import com.android.mmscommon.InvalidHeaderValueException;
-import com.android.mmscommon.PduHeaders;
+import com.google.android.mms.ContentType;
+import com.google.android.mms.InvalidHeaderValueException;
import android.util.Config;
import android.util.Log;
-import android.util.base64.Base64;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -161,11 +157,9 @@
}
String ctTypeStr = new String(contentType);
if (ctTypeStr.equals(ContentType.MULTIPART_MIXED)
- || ctTypeStr.equals(ContentType.MULTIPART_RELATED)
- || ctTypeStr.equals(ContentType.MULTIPART_ALTERNATIVE)) {
+ || ctTypeStr.equals(ContentType.MULTIPART_RELATED)) {
// The MMS content type must be "application/vnd.wap.multipart.mixed"
// or "application/vnd.wap.multipart.related"
- // or "application/vnd.wap.multipart.alternative"
return retrieveConf;
}
return null;
@@ -791,7 +785,7 @@
String encoding = new String(partDataEncoding);
if (encoding.equalsIgnoreCase(PduPart.P_BASE64)) {
// Decode "base64" into "binary".
- partData = Base64.decode(partData, Base64.DEFAULT);
+ partData = Base64.decodeBase64(partData);
} else if (encoding.equalsIgnoreCase(PduPart.P_QUOTED_PRINTABLE)) {
// Decode "quoted-printable" into "binary".
partData = QuotedPrintable.decodeQuotedPrintable(partData);
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/PduPart.java b/core/java/com/google/android/mms/pdu/PduPart.java
similarity index 99%
rename from mms-common/java/com/android/mmscommon/mms/pdu/PduPart.java
rename to core/java/com/google/android/mms/pdu/PduPart.java
index 7d51b86..b43e388 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/PduPart.java
+++ b/core/java/com/google/android/mms/pdu/PduPart.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
import android.net.Uri;
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/PduPersister.java b/core/java/com/google/android/mms/pdu/PduPersister.java
similarity index 96%
rename from mms-common/java/com/android/mmscommon/mms/pdu/PduPersister.java
rename to core/java/com/google/android/mms/pdu/PduPersister.java
index d92f0e1..2a1f23a 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/PduPersister.java
+++ b/core/java/com/google/android/mms/pdu/PduPersister.java
@@ -15,19 +15,14 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
-import com.android.mmscommon.mms.pdu.PduPersister;
-
-import com.android.mmscommon.ContentType;
-import com.android.mmscommon.CharacterSets;
-import com.android.mmscommon.EncodedStringValue;
-import com.android.mmscommon.InvalidHeaderValueException;
-import com.android.mmscommon.MmsException;
-import com.android.mmscommon.PduHeaders;
-import com.android.mmscommon.mms.util.PduCache;
-import com.android.mmscommon.mms.util.PduCacheEntry;
-import android.database.sqlite.SqliteWrapper;
+import com.google.android.mms.ContentType;
+import com.google.android.mms.InvalidHeaderValueException;
+import com.google.android.mms.MmsException;
+import com.google.android.mms.util.PduCache;
+import com.google.android.mms.util.PduCacheEntry;
+import com.google.android.mms.util.SqliteWrapper;
import android.content.ContentResolver;
import android.content.ContentUris;
@@ -36,13 +31,13 @@
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.net.Uri;
-import com.android.mmscommon.telephony.TelephonyProvider;
-import com.android.mmscommon.telephony.TelephonyProvider.Mms;
-import com.android.mmscommon.telephony.TelephonyProvider.MmsSms;
-import com.android.mmscommon.telephony.TelephonyProvider.Threads;
-import com.android.mmscommon.telephony.TelephonyProvider.Mms.Addr;
-import com.android.mmscommon.telephony.TelephonyProvider.Mms.Part;
-import com.android.mmscommon.telephony.TelephonyProvider.MmsSms.PendingMessages;
+import android.provider.Telephony;
+import android.provider.Telephony.Mms;
+import android.provider.Telephony.MmsSms;
+import android.provider.Telephony.Threads;
+import android.provider.Telephony.Mms.Addr;
+import android.provider.Telephony.Mms.Part;
+import android.provider.Telephony.MmsSms.PendingMessages;
import android.text.TextUtils;
import android.util.Config;
import android.util.Log;
@@ -60,6 +55,7 @@
import java.util.Set;
import java.util.Map.Entry;
+import com.google.android.mms.pdu.EncodedStringValue;
/**
* This class is the high-level manager of PDU storage.
@@ -426,12 +422,8 @@
// Store simple string values directly in the database instead of an
// external file. This makes the text searchable and retrieval slightly
// faster.
- if (ContentType.TEXT_PLAIN.equals(type) || ContentType.APP_SMIL.equals(type)
- || ContentType.TEXT_HTML.equals(type)) {
+ if ("text/plain".equals(type) || "application/smil".equals(type)) {
String text = c.getString(PART_COLUMN_TEXT);
- if (text == null) {
- text = "";
- }
byte [] blob = new EncodedStringValue(text).getTextString();
baos.write(blob, 0, blob.length);
} else {
@@ -743,11 +735,9 @@
try {
byte[] data = part.getData();
- if (ContentType.TEXT_PLAIN.equals(contentType)
- || ContentType.APP_SMIL.equals(contentType)
- || ContentType.TEXT_HTML.equals(contentType)) {
+ if ("text/plain".equals(contentType) || "application/smil".equals(contentType)) {
ContentValues cv = new ContentValues();
- cv.put(TelephonyProvider.Mms.Part.TEXT, new EncodedStringValue(data).getString());
+ cv.put(Telephony.Mms.Part.TEXT, new EncodedStringValue(data).getString());
if (mContentResolver.update(uri, cv, null, null) != 1) {
throw new MmsException("unable to update " + uri.toString());
}
@@ -868,7 +858,7 @@
} else {
values.put(Mms.SUBJECT, "");
}
-
+
long messageSize = sendReq.getMessageSize();
if (messageSize > 0) {
values.put(Mms.MESSAGE_SIZE, messageSize);
@@ -1145,10 +1135,6 @@
}
}
- // mark "read" and "seen"
- values.put(Mms.READ, 0);
- values.put(Mms.SEEN, 0);
-
Uri res = SqliteWrapper.insert(mContext, mContentResolver, uri, values);
if (res == null) {
throw new MmsException("persist() failed: return null.");
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/QuotedPrintable.java b/core/java/com/google/android/mms/pdu/QuotedPrintable.java
similarity index 97%
rename from mms-common/java/com/android/mmscommon/mms/pdu/QuotedPrintable.java
rename to core/java/com/google/android/mms/pdu/QuotedPrintable.java
index e9da7df..a34ed12 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/QuotedPrintable.java
+++ b/core/java/com/google/android/mms/pdu/QuotedPrintable.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
import java.io.ByteArrayOutputStream;
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/ReadOrigInd.java b/core/java/com/google/android/mms/pdu/ReadOrigInd.java
similarity index 95%
rename from mms-common/java/com/android/mmscommon/mms/pdu/ReadOrigInd.java
rename to core/java/com/google/android/mms/pdu/ReadOrigInd.java
index 9678784..1bfc0bb 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/ReadOrigInd.java
+++ b/core/java/com/google/android/mms/pdu/ReadOrigInd.java
@@ -15,11 +15,9 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
-import com.android.mmscommon.EncodedStringValue;
-import com.android.mmscommon.InvalidHeaderValueException;
-import com.android.mmscommon.PduHeaders;
+import com.google.android.mms.InvalidHeaderValueException;
public class ReadOrigInd extends GenericPdu {
/**
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/ReadRecInd.java b/core/java/com/google/android/mms/pdu/ReadRecInd.java
similarity index 95%
rename from mms-common/java/com/android/mmscommon/mms/pdu/ReadRecInd.java
rename to core/java/com/google/android/mms/pdu/ReadRecInd.java
index c1efbbc..880e3ac 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/ReadRecInd.java
+++ b/core/java/com/google/android/mms/pdu/ReadRecInd.java
@@ -15,11 +15,9 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
-import com.android.mmscommon.EncodedStringValue;
-import com.android.mmscommon.InvalidHeaderValueException;
-import com.android.mmscommon.PduHeaders;
+import com.google.android.mms.InvalidHeaderValueException;
public class ReadRecInd extends GenericPdu {
/**
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/RetrieveConf.java b/core/java/com/google/android/mms/pdu/RetrieveConf.java
similarity index 97%
rename from mms-common/java/com/android/mmscommon/mms/pdu/RetrieveConf.java
rename to core/java/com/google/android/mms/pdu/RetrieveConf.java
index 442949e..98e67c0 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/RetrieveConf.java
+++ b/core/java/com/google/android/mms/pdu/RetrieveConf.java
@@ -15,11 +15,9 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
-import com.android.mmscommon.EncodedStringValue;
-import com.android.mmscommon.InvalidHeaderValueException;
-import com.android.mmscommon.PduHeaders;
+import com.google.android.mms.InvalidHeaderValueException;
/**
* M-Retrive.conf Pdu.
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/SendConf.java b/core/java/com/google/android/mms/pdu/SendConf.java
similarity index 94%
rename from mms-common/java/com/android/mmscommon/mms/pdu/SendConf.java
rename to core/java/com/google/android/mms/pdu/SendConf.java
index 0a57b6b..0568fe79 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/SendConf.java
+++ b/core/java/com/google/android/mms/pdu/SendConf.java
@@ -15,11 +15,9 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
-import com.android.mmscommon.EncodedStringValue;
-import com.android.mmscommon.InvalidHeaderValueException;
-import com.android.mmscommon.PduHeaders;
+import com.google.android.mms.InvalidHeaderValueException;
public class SendConf extends GenericPdu {
/**
diff --git a/mms-common/java/com/android/mmscommon/mms/pdu/SendReq.java b/core/java/com/google/android/mms/pdu/SendReq.java
similarity index 97%
rename from mms-common/java/com/android/mmscommon/mms/pdu/SendReq.java
rename to core/java/com/google/android/mms/pdu/SendReq.java
index 5da4719..597cd00 100644
--- a/mms-common/java/com/android/mmscommon/mms/pdu/SendReq.java
+++ b/core/java/com/google/android/mms/pdu/SendReq.java
@@ -15,13 +15,11 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.pdu;
+package com.google.android.mms.pdu;
import android.util.Log;
-import com.android.mmscommon.EncodedStringValue;
-import com.android.mmscommon.InvalidHeaderValueException;
-import com.android.mmscommon.PduHeaders;
+import com.google.android.mms.InvalidHeaderValueException;
public class SendReq extends MultimediaMessagePdu {
private static final String TAG = "SendReq";
diff --git a/core/java/com/google/android/mms/pdu/package.html b/core/java/com/google/android/mms/pdu/package.html
new file mode 100755
index 0000000..c9f96a6
--- /dev/null
+++ b/core/java/com/google/android/mms/pdu/package.html
@@ -0,0 +1,5 @@
+<body>
+
+{@hide}
+
+</body>
diff --git a/mms-common/java/com/android/mmscommon/mms/util/AbstractCache.java b/core/java/com/google/android/mms/util/AbstractCache.java
similarity index 98%
rename from mms-common/java/com/android/mmscommon/mms/util/AbstractCache.java
rename to core/java/com/google/android/mms/util/AbstractCache.java
index 10a6fce..670439c 100644
--- a/mms-common/java/com/android/mmscommon/mms/util/AbstractCache.java
+++ b/core/java/com/google/android/mms/util/AbstractCache.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.util;
+package com.google.android.mms.util;
import android.util.Config;
import android.util.Log;
diff --git a/mms-common/java/com/android/mmscommon/mms/util/PduCache.java b/core/java/com/google/android/mms/util/PduCache.java
similarity index 98%
rename from mms-common/java/com/android/mmscommon/mms/util/PduCache.java
rename to core/java/com/google/android/mms/util/PduCache.java
index ca5432f..7c3fad7 100644
--- a/mms-common/java/com/android/mmscommon/mms/util/PduCache.java
+++ b/core/java/com/google/android/mms/util/PduCache.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.util;
+package com.google.android.mms.util;
import android.content.ContentUris;
import android.content.UriMatcher;
import android.net.Uri;
-import com.android.mmscommon.telephony.TelephonyProvider.Mms;
+import android.provider.Telephony.Mms;
import android.util.Config;
import android.util.Log;
diff --git a/mms-common/java/com/android/mmscommon/mms/util/PduCacheEntry.java b/core/java/com/google/android/mms/util/PduCacheEntry.java
similarity index 92%
rename from mms-common/java/com/android/mmscommon/mms/util/PduCacheEntry.java
rename to core/java/com/google/android/mms/util/PduCacheEntry.java
index aed741d..8b41386 100644
--- a/mms-common/java/com/android/mmscommon/mms/util/PduCacheEntry.java
+++ b/core/java/com/google/android/mms/util/PduCacheEntry.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package com.android.mmscommon.mms.util;
+package com.google.android.mms.util;
-import com.android.mmscommon.mms.pdu.GenericPdu;
+import com.google.android.mms.pdu.GenericPdu;
public final class PduCacheEntry {
private final GenericPdu mPdu;
diff --git a/core/java/com/google/android/mms/util/SqliteWrapper.java b/core/java/com/google/android/mms/util/SqliteWrapper.java
new file mode 100644
index 0000000..bcdac22
--- /dev/null
+++ b/core/java/com/google/android/mms/util/SqliteWrapper.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2008 Esmertec AG.
+ * Copyright (C) 2008 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.google.android.mms.util;
+
+import android.app.ActivityManager;
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteException;
+import android.net.Uri;
+import android.util.Log;
+import android.widget.Toast;
+
+public final class SqliteWrapper {
+ private static final String TAG = "SqliteWrapper";
+ private static final String SQLITE_EXCEPTION_DETAIL_MESSAGE
+ = "unable to open database file";
+
+ private SqliteWrapper() {
+ // Forbidden being instantiated.
+ }
+
+ // FIXME: It looks like outInfo.lowMemory does not work well as we expected.
+ // after run command: adb shell fillup -p 100, outInfo.lowMemory is still false.
+ private static boolean isLowMemory(Context context) {
+ if (null == context) {
+ return false;
+ }
+
+ ActivityManager am = (ActivityManager)
+ context.getSystemService(Context.ACTIVITY_SERVICE);
+ ActivityManager.MemoryInfo outInfo = new ActivityManager.MemoryInfo();
+ am.getMemoryInfo(outInfo);
+
+ return outInfo.lowMemory;
+ }
+
+ // FIXME: need to optimize this method.
+ private static boolean isLowMemory(SQLiteException e) {
+ return e.getMessage().equals(SQLITE_EXCEPTION_DETAIL_MESSAGE);
+ }
+
+ public static void checkSQLiteException(Context context, SQLiteException e) {
+ if (isLowMemory(e)) {
+ Toast.makeText(context, com.android.internal.R.string.low_memory,
+ Toast.LENGTH_SHORT).show();
+ } else {
+ throw e;
+ }
+ }
+
+ public static Cursor query(Context context, ContentResolver resolver, Uri uri,
+ String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+ try {
+ return resolver.query(uri, projection, selection, selectionArgs, sortOrder);
+ } catch (SQLiteException e) {
+ Log.e(TAG, "Catch a SQLiteException when query: ", e);
+ checkSQLiteException(context, e);
+ return null;
+ }
+ }
+
+ public static boolean requery(Context context, Cursor cursor) {
+ try {
+ return cursor.requery();
+ } catch (SQLiteException e) {
+ Log.e(TAG, "Catch a SQLiteException when requery: ", e);
+ checkSQLiteException(context, e);
+ return false;
+ }
+ }
+ public static int update(Context context, ContentResolver resolver, Uri uri,
+ ContentValues values, String where, String[] selectionArgs) {
+ try {
+ return resolver.update(uri, values, where, selectionArgs);
+ } catch (SQLiteException e) {
+ Log.e(TAG, "Catch a SQLiteException when update: ", e);
+ checkSQLiteException(context, e);
+ return -1;
+ }
+ }
+
+ public static int delete(Context context, ContentResolver resolver, Uri uri,
+ String where, String[] selectionArgs) {
+ try {
+ return resolver.delete(uri, where, selectionArgs);
+ } catch (SQLiteException e) {
+ Log.e(TAG, "Catch a SQLiteException when delete: ", e);
+ checkSQLiteException(context, e);
+ return -1;
+ }
+ }
+
+ public static Uri insert(Context context, ContentResolver resolver,
+ Uri uri, ContentValues values) {
+ try {
+ return resolver.insert(uri, values);
+ } catch (SQLiteException e) {
+ Log.e(TAG, "Catch a SQLiteException when insert: ", e);
+ checkSQLiteException(context, e);
+ return null;
+ }
+ }
+}
diff --git a/core/java/com/google/android/mms/util/package.html b/core/java/com/google/android/mms/util/package.html
new file mode 100755
index 0000000..c9f96a6
--- /dev/null
+++ b/core/java/com/google/android/mms/util/package.html
@@ -0,0 +1,5 @@
+<body>
+
+{@hide}
+
+</body>
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index 0f1b845..88bbafd 100644
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -527,6 +527,53 @@
}
}
+static bool Bitmap_sameAs(JNIEnv* env, jobject, const SkBitmap* bm0,
+ const SkBitmap* bm1) {
+ if (bm0->width() != bm1->width() ||
+ bm0->height() != bm1->height() ||
+ bm0->config() != bm1->config()) {
+ return false;
+ }
+
+ SkAutoLockPixels alp0(*bm0);
+ SkAutoLockPixels alp1(*bm1);
+
+ // if we can't load the pixels, return false
+ if (NULL == bm0->getPixels() || NULL == bm1->getPixels()) {
+ return false;
+ }
+
+ if (bm0->config() == SkBitmap::kIndex8_Config) {
+ SkColorTable* ct0 = bm0->getColorTable();
+ SkColorTable* ct1 = bm1->getColorTable();
+ if (NULL == ct0 || NULL == ct1) {
+ return false;
+ }
+ if (ct0->count() != ct1->count()) {
+ return false;
+ }
+
+ SkAutoLockColors alc0(ct0);
+ SkAutoLockColors alc1(ct1);
+ const size_t size = ct0->count() * sizeof(SkPMColor);
+ if (memcmp(alc0.colors(), alc1.colors(), size) != 0) {
+ return false;
+ }
+ }
+
+ // now compare each scanline. We can't do the entire buffer at once,
+ // since we don't care about the pixel values that might extend beyond
+ // the width (since the scanline might be larger than the logical width)
+ const int h = bm0->height();
+ const size_t size = bm0->width() * bm0->bytesPerPixel();
+ for (int y = 0; y < h; y++) {
+ if (memcmp(bm0->getAddr(0, y), bm1->getAddr(0, y), size) != 0) {
+ return false;
+ }
+ }
+ return true;
+}
+
static void Bitmap_prepareToDraw(JNIEnv* env, jobject, SkBitmap* bitmap) {
bitmap->lockPixels();
bitmap->unlockPixels();
@@ -567,7 +614,8 @@
(void*)Bitmap_copyPixelsToBuffer },
{ "nativeCopyPixelsFromBuffer", "(ILjava/nio/Buffer;)V",
(void*)Bitmap_copyPixelsFromBuffer },
- { "nativePrepareToDraw", "(I)V", (void*)Bitmap_prepareToDraw }
+ { "nativeSameAs", "(II)Z", (void*)Bitmap_sameAs },
+ { "nativePrepareToDraw", "(I)V", (void*)Bitmap_prepareToDraw },
};
#define kClassPathName "android/graphics/Bitmap"
diff --git a/core/jni/android_database_SQLiteDatabase.cpp b/core/jni/android_database_SQLiteDatabase.cpp
index bd55e83..44e091d 100644
--- a/core/jni/android_database_SQLiteDatabase.cpp
+++ b/core/jni/android_database_SQLiteDatabase.cpp
@@ -367,7 +367,7 @@
if (err != SQLITE_OK) {
LOGE("register_localized_collators() failed setting locale\n");
throw_sqlite3_exception(env, handle);
- goto done;
+ goto rollback;
}
err = sqlite3_exec(handle, "DELETE FROM " ANDROID_TABLE, NULL, NULL, NULL);
@@ -415,7 +415,9 @@
}
rollback:
- sqlite3_exec(handle, "ROLLBACK TRANSACTION", NULL, NULL, NULL);
+ if (err != SQLITE_OK) {
+ sqlite3_exec(handle, "ROLLBACK TRANSACTION", NULL, NULL, NULL);
+ }
done:
if (locale8 != NULL) env->ReleaseStringUTFChars(localeString, locale8);
diff --git a/core/jni/android_location_GpsLocationProvider.cpp b/core/jni/android_location_GpsLocationProvider.cpp
index f845878..a3be309 100755
--- a/core/jni/android_location_GpsLocationProvider.cpp
+++ b/core/jni/android_location_GpsLocationProvider.cpp
@@ -42,6 +42,7 @@
static const GpsXtraInterface* sGpsXtraInterface = NULL;
static const AGpsInterface* sAGpsInterface = NULL;
static const GpsNiInterface* sGpsNiInterface = NULL;
+static const GpsDebugInterface* sGpsDebugInterface = NULL;
// data written to by GPS callbacks
static GpsLocation sGpsLocation;
@@ -57,7 +58,7 @@
GpsUtcTime timestamp;
char nmea[NMEA_SENTENCE_LENGTH];
};
-static NmeaSentence sNmeaBuffer[NMEA_SENTENCE_LENGTH];
+static NmeaSentence sNmeaBuffer[NMEA_SENTENCE_COUNT];
static int mNmeaSentenceCount = 0;
// a copy of the data shared by android_location_GpsLocationProvider_wait_for_event
@@ -66,7 +67,7 @@
static GpsStatus sGpsStatusCopy;
static GpsSvStatus sGpsSvStatusCopy;
static AGpsStatus sAGpsStatusCopy;
-static NmeaSentence sNmeaBufferCopy[NMEA_SENTENCE_LENGTH];
+static NmeaSentence sNmeaBufferCopy[NMEA_SENTENCE_COUNT];
static GpsNiNotification sGpsNiNotificationCopy;
enum CallbackType {
@@ -226,6 +227,9 @@
if (sGpsNiInterface)
sGpsNiInterface->init(&sGpsNiCallbacks);
+ if (!sGpsDebugInterface)
+ sGpsDebugInterface = (const GpsDebugInterface*)sGpsInterface->get_extension(GPS_DEBUG_INTERFACE);
+
return true;
}
@@ -472,11 +476,26 @@
static void android_location_GpsLocationProvider_send_ni_response(JNIEnv* env, jobject obj,
jint notifId, jint response)
{
- if (!sGpsNiInterface)
- sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE);
- if (sGpsNiInterface) {
- sGpsNiInterface->respond(notifId, response);
- }
+ if (!sGpsNiInterface) {
+ sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE);
+ }
+ if (sGpsNiInterface) {
+ sGpsNiInterface->respond(notifId, response);
+ }
+}
+
+static jstring android_location_GpsLocationProvider_get_internal_state(JNIEnv* env, jobject obj)
+{
+ jstring result = NULL;
+ if (sGpsDebugInterface) {
+ const size_t maxLength = 2047;
+ char buffer[maxLength+1];
+ size_t length = sGpsDebugInterface->get_internal_state(buffer, maxLength);
+ if (length > maxLength) length = maxLength;
+ buffer[length] = 0;
+ result = env->NewStringUTF(buffer);
+ }
+ return result;
}
static JNINativeMethod sMethods[] = {
@@ -501,6 +520,7 @@
{"native_agps_data_conn_failed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_failed},
{"native_set_agps_server", "(ILjava/lang/String;I)V", (void*)android_location_GpsLocationProvider_set_agps_server},
{"native_send_ni_response", "(II)V", (void*)android_location_GpsLocationProvider_send_ni_response},
+ {"native_get_internal_state", "()Ljava/lang/String;", (void*)android_location_GpsLocationProvider_get_internal_state},
};
int register_android_location_GpsLocationProvider(JNIEnv* env)
diff --git a/core/res/res/drawable-hdpi/btn_search_dialog_voice_default.9.png b/core/res/res/drawable-hdpi/btn_search_dialog_voice_default.9.png
index 44668b3..eda6e16 100644
--- a/core/res/res/drawable-hdpi/btn_search_dialog_voice_default.9.png
+++ b/core/res/res/drawable-hdpi/btn_search_dialog_voice_default.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_search_dialog_voice_pressed.9.png b/core/res/res/drawable-hdpi/btn_search_dialog_voice_pressed.9.png
index 3a4571e..4158ac4 100644
--- a/core/res/res/drawable-hdpi/btn_search_dialog_voice_pressed.9.png
+++ b/core/res/res/drawable-hdpi/btn_search_dialog_voice_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_search_dialog_voice_selected.9.png b/core/res/res/drawable-hdpi/btn_search_dialog_voice_selected.9.png
index 60dc632..6f68f25 100644
--- a/core/res/res/drawable-hdpi/btn_search_dialog_voice_selected.9.png
+++ b/core/res/res/drawable-hdpi/btn_search_dialog_voice_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_search_empty_default.9.png b/core/res/res/drawable-hdpi/textfield_search_empty_default.9.png
new file mode 100644
index 0000000..c0b84da
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_search_empty_default.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_search_empty_pressed.9.png b/core/res/res/drawable-hdpi/textfield_search_empty_pressed.9.png
new file mode 100644
index 0000000..0a0fc6b
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_search_empty_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_search_empty_selected.9.png b/core/res/res/drawable-hdpi/textfield_search_empty_selected.9.png
new file mode 100644
index 0000000..04813c2
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_search_empty_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_search_empty_default.9.png b/core/res/res/drawable-mdpi/textfield_search_empty_default.9.png
new file mode 100644
index 0000000..515117f
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_search_empty_default.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_search_empty_pressed.9.png b/core/res/res/drawable-mdpi/textfield_search_empty_pressed.9.png
new file mode 100644
index 0000000..a01f763
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_search_empty_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_search_empty_selected.9.png b/core/res/res/drawable-mdpi/textfield_search_empty_selected.9.png
new file mode 100644
index 0000000..611276f
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_search_empty_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable/textfield_search_empty.xml b/core/res/res/drawable/textfield_search_empty.xml
new file mode 100644
index 0000000..55eec83
--- /dev/null
+++ b/core/res/res/drawable/textfield_search_empty.xml
@@ -0,0 +1,31 @@
+<?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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:state_window_focused="false" android:state_enabled="true"
+ android:drawable="@drawable/textfield_search_empty_default" />
+
+ <item android:state_pressed="true"
+ android:drawable="@drawable/textfield_search_empty_pressed" />
+
+ <item android:state_enabled="true" android:state_focused="true"
+ android:drawable="@drawable/textfield_search_empty_selected" />
+
+ <item android:state_enabled="true"
+ android:drawable="@drawable/textfield_search_empty_default" />
+
+</selector>
diff --git a/core/tests/coretests/src/android/provider/SettingsProviderTest.java b/core/tests/coretests/src/android/provider/SettingsProviderTest.java
index f82d79a..370ae78 100644
--- a/core/tests/coretests/src/android/provider/SettingsProviderTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsProviderTest.java
@@ -59,7 +59,7 @@
assertEquals("content://settings/system/test_setting",
Settings.System.getUriFor("test_setting").toString());
- assertEquals("content://settings/gservices/test_service",
+ assertEquals("content://settings/secure/test_service",
Settings.Secure.getUriFor("test_service").toString());
// These tables use the row name (not ID) as their content URI.
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 5aa88b0..7ca3741 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -972,6 +972,19 @@
}
/**
+ * Given another bitmap, return true if it has the same dimensions, config,
+ * and pixel data as this bitmap. If any of those differ, return false.
+ * If other is null, return false.
+ *
+ * @hide (just needed internally right now)
+ */
+ public boolean sameAs(Bitmap other) {
+ return this == other ||
+ (other != null &&
+ nativeSameAs(mNativeBitmap, other.mNativeBitmap));
+ }
+
+ /**
* Rebuilds any caches associated with the bitmap that are used for
* drawing it. In the case of purgeable bitmaps, this call will attempt to
* ensure that the pixels have been decoded.
@@ -1042,6 +1055,7 @@
private static native void nativePrepareToDraw(int nativeBitmap);
private static native void nativeSetHasAlpha(int nBitmap, boolean hasAlpha);
+ private static native boolean nativeSameAs(int nb0, int nb1);
/* package */ final int ni() {
return mNativeBitmap;
diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index 6c6d0bc..a7568d7 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -228,6 +228,9 @@
// Example value: "true". Read only.
static const char KEY_SMOOTH_ZOOM_SUPPORTED[];
+ // Value for KEY_ZOOM_SUPPORTED or KEY_SMOOTH_ZOOM_SUPPORTED.
+ static const char TRUE[];
+
// Values for white balance settings.
static const char WHITE_BALANCE_AUTO[];
static const char WHITE_BALANCE_INCANDESCENT[];
diff --git a/include/media/stagefright/AudioPlayer.h b/include/media/stagefright/AudioPlayer.h
index ea15a5c..9af5871 100644
--- a/include/media/stagefright/AudioPlayer.h
+++ b/include/media/stagefright/AudioPlayer.h
@@ -44,7 +44,7 @@
// Return time in us.
virtual int64_t getRealTimeUs();
- status_t start();
+ status_t start(bool sourceAlreadyStarted = false);
void pause();
void resume();
diff --git a/libs/audioflinger/AudioPolicyManagerBase.cpp b/libs/audioflinger/AudioPolicyManagerBase.cpp
index 7b866c7..cfcc3ea 100644
--- a/libs/audioflinger/AudioPolicyManagerBase.cpp
+++ b/libs/audioflinger/AudioPolicyManagerBase.cpp
@@ -1290,7 +1290,7 @@
a2dpOutputDesc->changeRefCount((AudioSystem::stream_type)i,-refCount);
}
}
- // do not change newDevice is it was already set before this call by a previous call to
+ // do not change newDevice if it was already set before this call by a previous call to
// getNewDevice() or checkOutputForStrategy() for a strategy with higher priority
if (newDevice == 0 && hwOutputDesc->isUsedByStrategy(strategy)) {
newDevice = getDeviceForStrategy(strategy, false);
@@ -1466,6 +1466,12 @@
case STRATEGY_MEDIA: {
uint32_t device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_AUX_DIGITAL;
+ if (device2 == 0) {
+ device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADPHONE;
+ }
+ if (device2 == 0) {
+ device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADSET;
+ }
#ifdef WITH_A2DP
if (mA2dpOutput != 0) {
if (strategy == STRATEGY_SONIFICATION && !a2dpUsedForSonification()) {
@@ -1483,12 +1489,6 @@
}
#endif
if (device2 == 0) {
- device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADPHONE;
- }
- if (device2 == 0) {
- device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADSET;
- }
- if (device2 == 0) {
device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_SPEAKER;
}
diff --git a/libs/camera/CameraParameters.cpp b/libs/camera/CameraParameters.cpp
index 65785c7..76a9715 100644
--- a/libs/camera/CameraParameters.cpp
+++ b/libs/camera/CameraParameters.cpp
@@ -70,6 +70,8 @@
const char CameraParameters::KEY_ZOOM_SUPPORTED[] = "zoom-supported";
const char CameraParameters::KEY_SMOOTH_ZOOM_SUPPORTED[] = "smooth-zoom-supported";
+const char CameraParameters::TRUE[] = "true";
+
// Values for white balance settings.
const char CameraParameters::WHITE_BALANCE_AUTO[] = "auto";
const char CameraParameters::WHITE_BALANCE_INCANDESCENT[] = "incandescent";
diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp
index c080513..7ca7875 100644
--- a/libs/surfaceflinger/Layer.cpp
+++ b/libs/surfaceflinger/Layer.cpp
@@ -156,7 +156,11 @@
if (mFlags & DisplayHardware::DIRECT_TEXTURE) {
if (buffer->usage & GraphicBuffer::USAGE_HW_TEXTURE) {
if (mTextures[index].dirty) {
- initializeEglImage(buffer, &mTextures[index]);
+ if (initializeEglImage(buffer, &mTextures[index]) != NO_ERROR) {
+ // not sure what we can do here...
+ mFlags &= ~DisplayHardware::DIRECT_TEXTURE;
+ goto slowpath;
+ }
}
} else {
if (mHybridBuffer==0 || (mHybridBuffer->width != buffer->width ||
@@ -166,8 +170,13 @@
buffer->width, buffer->height, buffer->format,
GraphicBuffer::USAGE_SW_WRITE_OFTEN |
GraphicBuffer::USAGE_HW_TEXTURE);
- initializeEglImage(
- mHybridBuffer, &mTextures[0]);
+ if (initializeEglImage(
+ mHybridBuffer, &mTextures[0]) != NO_ERROR) {
+ // not sure what we can do here...
+ mFlags &= ~DisplayHardware::DIRECT_TEXTURE;
+ mHybridBuffer.clear();
+ goto slowpath;
+ }
}
GGLSurface t;
@@ -236,6 +245,7 @@
} else
#endif
{
+slowpath:
for (size_t i=0 ; i<NUM_BUFFERS ; i++) {
mTextures[i].image = EGL_NO_IMAGE_KHR;
}
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index b0109ca..63b5720 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -666,22 +666,15 @@
dpy, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID,
(EGLClientBuffer)clientBuf, attrs);
- LOGE_IF(texture->image == EGL_NO_IMAGE_KHR,
- "eglCreateImageKHR() failed. err=0x%4x",
- eglGetError());
-
if (texture->image != EGL_NO_IMAGE_KHR) {
glBindTexture(GL_TEXTURE_2D, texture->name);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D,
(GLeglImageOES)texture->image);
GLint error = glGetError();
if (UNLIKELY(error != GL_NO_ERROR)) {
- // this failed, for instance, because we don't support NPOT.
- // FIXME: do something!
LOGE("layer=%p, glEGLImageTargetTexture2DOES(%p) "
"failed err=0x%04x",
this, texture->image, error);
- mFlags &= ~DisplayHardware::DIRECT_TEXTURE;
err = INVALID_OPERATION;
} else {
// Everything went okay!
@@ -691,6 +684,8 @@
texture->height = clientBuf->height;
}
} else {
+ LOGE("layer=%p, eglCreateImageKHR() failed. err=0x%4x",
+ this, eglGetError());
err = INVALID_OPERATION;
}
return err;
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp
index 6d1685b..5c21593 100644
--- a/libs/surfaceflinger/LayerBuffer.cpp
+++ b/libs/surfaceflinger/LayerBuffer.cpp
@@ -261,7 +261,8 @@
// LayerBuffer::Buffer
// ============================================================================
-LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers, ssize_t offset)
+LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers,
+ ssize_t offset, size_t bufferSize)
: mBufferHeap(buffers), mSupportsCopybit(false)
{
NativeBuffer& src(mNativeBuffer);
@@ -280,7 +281,7 @@
if (module && module->perform) {
int err = module->perform(module,
GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER,
- buffers.heap->heapID(), buffers.heap->getSize(),
+ buffers.heap->heapID(), bufferSize,
offset, buffers.heap->base(),
&src.img.handle);
@@ -415,7 +416,7 @@
sp<Buffer> buffer;
if (buffers.heap != 0) {
- buffer = new LayerBuffer::Buffer(buffers, offset);
+ buffer = new LayerBuffer::Buffer(buffers, offset, mBufferSize);
if (buffer->getStatus() != NO_ERROR)
buffer.clear();
setBuffer(buffer);
@@ -469,6 +470,11 @@
if (mLayer.mFlags & DisplayHardware::DIRECT_TEXTURE) {
err = INVALID_OPERATION;
if (ourBuffer->supportsCopybit()) {
+
+ // there are constraints on buffers used by the GPU and these may not
+ // be honored here. We need to change the API so the buffers
+ // are allocated with gralloc. For now disable this code-path
+#if 0
// First, try to use the buffer as an EGLImage directly
if (mUseEGLImageDirectly) {
// NOTE: Assume the buffer is allocated with the proper USAGE flags
@@ -483,6 +489,8 @@
mUseEGLImageDirectly = false;
}
}
+#endif
+
copybit_device_t* copybit = mLayer.mBlitEngine;
if (copybit && err != NO_ERROR) {
// create our EGLImageKHR the first time
diff --git a/libs/surfaceflinger/LayerBuffer.h b/libs/surfaceflinger/LayerBuffer.h
index eb5b8eb..b176623 100644
--- a/libs/surfaceflinger/LayerBuffer.h
+++ b/libs/surfaceflinger/LayerBuffer.h
@@ -99,7 +99,8 @@
class Buffer : public LightRefBase<Buffer> {
public:
- Buffer(const ISurface::BufferHeap& buffers, ssize_t offset);
+ Buffer(const ISurface::BufferHeap& buffers,
+ ssize_t offset, size_t bufferSize);
inline bool supportsCopybit() const {
return mSupportsCopybit;
}
diff --git a/location/java/android/location/ILocationProvider.aidl b/location/java/android/location/ILocationProvider.aidl
index 5529b11..97b283c 100644
--- a/location/java/android/location/ILocationProvider.aidl
+++ b/location/java/android/location/ILocationProvider.aidl
@@ -39,6 +39,7 @@
void disable();
int getStatus(out Bundle extras);
long getStatusUpdateTime();
+ String getInternalState();
void enableLocationTracking(boolean enable);
void setMinTime(long minTime);
void updateNetworkState(int state, in NetworkInfo info);
diff --git a/location/java/android/location/LocationProviderInterface.java b/location/java/android/location/LocationProviderInterface.java
index 98beffe..5ffe15c 100644
--- a/location/java/android/location/LocationProviderInterface.java
+++ b/location/java/android/location/LocationProviderInterface.java
@@ -42,6 +42,7 @@
int getStatus(Bundle extras);
long getStatusUpdateTime();
void enableLocationTracking(boolean enable);
+ String getInternalState();
void setMinTime(long minTime);
void updateNetworkState(int state, NetworkInfo info);
void updateLocation(Location location);
diff --git a/location/java/android/location/provider/LocationProvider.java b/location/java/android/location/provider/LocationProvider.java
index 4163def..56cfb33 100644
--- a/location/java/android/location/provider/LocationProvider.java
+++ b/location/java/android/location/provider/LocationProvider.java
@@ -95,6 +95,10 @@
return LocationProvider.this.onGetStatusUpdateTime();
}
+ public String getInternalState() {
+ return LocationProvider.this.onGetInternalState();
+ }
+
public void enableLocationTracking(boolean enable) {
LocationProvider.this.onEnableLocationTracking(enable);
}
@@ -267,6 +271,13 @@
public abstract long onGetStatusUpdateTime();
/**
+ * Returns debugging information about the location provider.
+ *
+ * @return string describing the internal state of the location provider, or null.
+ */
+ public abstract String onGetInternalState();
+
+ /**
* Notifies the location provider that clients are listening for locations.
* Called with enable set to true when the first client is added and
* called with enable set to false when the last client is removed.
diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java
index 90b50cc..44a5a6b 100755
--- a/location/java/com/android/internal/location/GpsLocationProvider.java
+++ b/location/java/com/android/internal/location/GpsLocationProvider.java
@@ -633,6 +633,10 @@
}
}
+ public String getInternalState() {
+ return native_get_internal_state();
+ }
+
private final class Listener implements IBinder.DeathRecipient {
final IGpsStatusListener mListener;
@@ -1391,12 +1395,15 @@
private native int native_read_nmea(int index, byte[] buffer, int bufferSize);
private native void native_inject_location(double latitude, double longitude, float accuracy);
- // XTRA Support
+ // XTRA Support
private native void native_inject_time(long time, long timeReference, int uncertainty);
private native boolean native_supports_xtra();
private native void native_inject_xtra_data(byte[] data, int length);
- // AGPS Support
+ // DEBUG Support
+ private native String native_get_internal_state();
+
+ // AGPS Support
private native void native_agps_data_conn_open(String apn);
private native void native_agps_data_conn_closed();
private native void native_agps_data_conn_failed();
diff --git a/location/java/com/android/internal/location/LocationProviderProxy.java b/location/java/com/android/internal/location/LocationProviderProxy.java
index abb90b7..31ec09a 100644
--- a/location/java/com/android/internal/location/LocationProviderProxy.java
+++ b/location/java/com/android/internal/location/LocationProviderProxy.java
@@ -266,6 +266,15 @@
return 0;
}
+ public String getInternalState() {
+ try {
+ return mProvider.getInternalState();
+ } catch (RemoteException e) {
+ Log.e(TAG, "getInternalState failed", e);
+ return null;
+ }
+ }
+
public boolean isLocationTracking() {
return mLocationTracking;
}
diff --git a/location/java/com/android/internal/location/MockProvider.java b/location/java/com/android/internal/location/MockProvider.java
index bc1893e..d912740 100644
--- a/location/java/com/android/internal/location/MockProvider.java
+++ b/location/java/com/android/internal/location/MockProvider.java
@@ -168,6 +168,10 @@
mStatusUpdateTime = 0;
}
+ public String getInternalState() {
+ return null;
+ }
+
public void enableLocationTracking(boolean enable) {
}
diff --git a/location/java/com/android/internal/location/PassiveProvider.java b/location/java/com/android/internal/location/PassiveProvider.java
index 7eb711d..ab90937 100644
--- a/location/java/com/android/internal/location/PassiveProvider.java
+++ b/location/java/com/android/internal/location/PassiveProvider.java
@@ -106,6 +106,10 @@
return -1;
}
+ public String getInternalState() {
+ return null;
+ }
+
public void enableLocationTracking(boolean enable) {
mTracking = enable;
}
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp
index 5e6e0da..005c64a 100644
--- a/media/libstagefright/AudioPlayer.cpp
+++ b/media/libstagefright/AudioPlayer.cpp
@@ -55,14 +55,17 @@
mSource = source;
}
-status_t AudioPlayer::start() {
+status_t AudioPlayer::start(bool sourceAlreadyStarted) {
CHECK(!mStarted);
CHECK(mSource != NULL);
- status_t err = mSource->start();
+ status_t err;
+ if (!sourceAlreadyStarted) {
+ err = mSource->start();
- if (err != OK) {
- return err;
+ if (err != OK) {
+ return err;
+ }
}
sp<MetaData> format = mSource->getFormat();
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 5090c39..e00ba470 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -410,6 +410,9 @@
if (mDurationUs >= 0) {
int64_t cachedDurationUs = mPrefetcher->getCachedDurationUs();
+
+ LOGV("cache holds %.2f secs worth of data.", cachedDurationUs / 1E6);
+
int64_t positionUs = 0;
if (mVideoSource != NULL) {
positionUs = mVideoTimeUs;
@@ -486,7 +489,11 @@
if (mAudioSink != NULL) {
mAudioPlayer = new AudioPlayer(mAudioSink);
mAudioPlayer->setSource(mAudioSource);
- status_t err = mAudioPlayer->start();
+
+ // We've already started the MediaSource in order to enable
+ // the prefetcher to read its data.
+ status_t err = mAudioPlayer->start(
+ true /* sourceAlreadyStarted */);
if (err != OK) {
delete mAudioPlayer;
@@ -734,6 +741,8 @@
}
}
+ mAudioSource->start();
+
return mAudioSource != NULL ? OK : UNKNOWN_ERROR;
}
@@ -1064,6 +1073,8 @@
}
void AwesomePlayer::onPrepareAsyncEvent() {
+ sp<Prefetcher> prefetcher;
+
{
Mutex::Autolock autoLock(mLock);
@@ -1075,12 +1086,25 @@
return;
}
}
- }
- sp<Prefetcher> prefetcher;
+ if (mVideoTrack != NULL && mVideoSource == NULL) {
+ status_t err = initVideoDecoder();
- {
- Mutex::Autolock autoLock(mLock);
+ if (err != OK) {
+ abortPrepare(err);
+ return;
+ }
+ }
+
+ if (mAudioTrack != NULL && mAudioSource == NULL) {
+ status_t err = initAudioDecoder();
+
+ if (err != OK) {
+ abortPrepare(err);
+ return;
+ }
+ }
+
prefetcher = mPrefetcher;
}
@@ -1091,24 +1115,6 @@
Mutex::Autolock autoLock(mLock);
- if (mVideoTrack != NULL && mVideoSource == NULL) {
- status_t err = initVideoDecoder();
-
- if (err != OK) {
- abortPrepare(err);
- return;
- }
- }
-
- if (mAudioTrack != NULL && mAudioSource == NULL) {
- status_t err = initAudioDecoder();
-
- if (err != OK) {
- abortPrepare(err);
- return;
- }
- }
-
if (mIsAsyncPrepare) {
if (mVideoWidth < 0 || mVideoHeight < 0) {
notifyListener_l(MEDIA_SET_VIDEO_SIZE, 0, 0);
diff --git a/media/libstagefright/Prefetcher.cpp b/media/libstagefright/Prefetcher.cpp
index 9c73f4a..debb60d 100644
--- a/media/libstagefright/Prefetcher.cpp
+++ b/media/libstagefright/Prefetcher.cpp
@@ -59,6 +59,7 @@
int64_t mSeekTimeUs;
int64_t mCacheDurationUs;
bool mPrefetcherStopped;
+ bool mCurrentlyPrefetching;
List<MediaBuffer *> mCachedBuffers;
@@ -194,6 +195,7 @@
int64_t minCacheDurationUs = -1;
ssize_t minIndex = -1;
+ bool anySourceActive = false;
for (size_t i = 0; i < mSources.size(); ++i) {
int64_t cacheDurationUs;
sp<PrefetchedSource> source = mSources[i].promote();
@@ -201,12 +203,8 @@
continue;
}
- if (!source->getCacheDurationUs(&cacheDurationUs)) {
- continue;
- }
-
- if (cacheDurationUs >= kMaxCacheDurationUs) {
- continue;
+ if (source->getCacheDurationUs(&cacheDurationUs)) {
+ anySourceActive = true;
}
if (minIndex < 0 || cacheDurationUs < minCacheDurationUs) {
@@ -216,20 +214,20 @@
}
if (noMoreData) {
- *noMoreData = minCacheDurationUs < 0;
+ *noMoreData = !anySourceActive;
}
return minCacheDurationUs < 0 ? 0 : minCacheDurationUs;
}
status_t Prefetcher::prepare() {
- // Buffer about 2 secs worth of data on prepare.
+ // Fill the cache.
int64_t duration;
bool noMoreData;
do {
duration = getCachedDurationUs(&noMoreData);
- } while (!noMoreData && duration < 2000000);
+ } while (!noMoreData && duration < 2000000ll);
return OK;
}
@@ -245,7 +243,8 @@
mReachedEOS(false),
mSeekTimeUs(0),
mCacheDurationUs(0),
- mPrefetcherStopped(false) {
+ mPrefetcherStopped(false),
+ mCurrentlyPrefetching(false) {
}
PrefetchedSource::~PrefetchedSource() {
@@ -275,6 +274,10 @@
Mutex::Autolock autoLock(mLock);
+ while (mCurrentlyPrefetching) {
+ mCondition.wait(mLock);
+ }
+
clearCache_l();
status_t err = mSource->stop();
@@ -324,14 +327,12 @@
bool PrefetchedSource::getCacheDurationUs(int64_t *durationUs) {
Mutex::Autolock autoLock(mLock);
- if (!mStarted || mReachedEOS) {
- *durationUs = 0;
+ *durationUs = mCacheDurationUs;
+ if (!mStarted || mReachedEOS) {
return false;
}
- *durationUs = mCacheDurationUs;
-
return true;
}
@@ -344,15 +345,24 @@
return;
}
+ mCurrentlyPrefetching = true;
+
if (mSeekTimeUs >= 0) {
options.setSeekTo(mSeekTimeUs);
mSeekTimeUs = -1;
}
+ // Ensure our object does not go away while we're not holding
+ // the lock.
+ sp<PrefetchedSource> me = this;
+
+ mLock.unlock();
MediaBuffer *buffer;
status_t err = mSource->read(&buffer, &options);
+ mLock.lock();
if (err != OK) {
+ mCurrentlyPrefetching = false;
mReachedEOS = true;
mFinalStatus = err;
mCondition.signal();
@@ -380,6 +390,8 @@
mCachedBuffers.push_back(copy);
updateCacheDuration_l();
+
+ mCurrentlyPrefetching = false;
mCondition.signal();
}
diff --git a/media/libstagefright/colorconversion/SoftwareRenderer.cpp b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
index 4c11c36..a6dbf69 100644
--- a/media/libstagefright/colorconversion/SoftwareRenderer.cpp
+++ b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
@@ -45,7 +45,9 @@
LOGI("Creating physical memory heap failed, reverting to regular heap.");
mMemoryHeap = new MemoryHeapBase(2 * mFrameSize);
} else {
- mMemoryHeap = new MemoryHeapPmem(mMemoryHeap);
+ sp<MemoryHeapPmem> pmemHeap = new MemoryHeapPmem(mMemoryHeap);
+ pmemHeap->slap();
+ mMemoryHeap = pmemHeap;
}
CHECK(mISurface.get() != NULL);
diff --git a/mms-common/Android.mk b/mms-common/Android.mk
deleted file mode 100644
index 57f1ccc..0000000
--- a/mms-common/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-# Note: the source code is in java/, not src/, because this code is also part of
-# the framework library, and build/core/pathmap.mk expects a java/ subdirectory.
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := mms-common
-LOCAL_SRC_FILES := $(call all-java-files-under, java)
-LOCAL_STATIC_JAVA_LIBRARIES += android-common
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# Include this library in the build server's output directory
-$(call dist-for-goals, droid, $(LOCAL_BUILT_MODULE):mms-common.jar)
-
-# Build the test package
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/mms-common/java/com/android/mmscommon/ContentType.java b/mms-common/java/com/android/mmscommon/ContentType.java
deleted file mode 100644
index ca449fe..0000000
--- a/mms-common/java/com/android/mmscommon/ContentType.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Esmertec AG.
- * Copyright (C) 2007-2008 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.mmscommon;
-
-import java.util.ArrayList;
-
-public class ContentType {
- public static final String MMS_MESSAGE = "application/vnd.wap.mms-message";
- // The phony content type for generic PDUs (e.g. ReadOrig.ind,
- // Notification.ind, Delivery.ind).
- public static final String MMS_GENERIC = "application/vnd.wap.mms-generic";
- public static final String MULTIPART_MIXED = "application/vnd.wap.multipart.mixed";
- public static final String MULTIPART_RELATED = "application/vnd.wap.multipart.related";
- public static final String MULTIPART_ALTERNATIVE = "application/vnd.wap.multipart.alternative";
-
- public static final String TEXT_PLAIN = "text/plain";
- public static final String TEXT_HTML = "text/html";
- public static final String TEXT_VCALENDAR = "text/x-vCalendar";
- public static final String TEXT_VCARD = "text/x-vCard";
-
- public static final String IMAGE_UNSPECIFIED = "image/*";
- public static final String IMAGE_JPEG = "image/jpeg";
- public static final String IMAGE_JPG = "image/jpg";
- public static final String IMAGE_GIF = "image/gif";
- public static final String IMAGE_WBMP = "image/vnd.wap.wbmp";
- public static final String IMAGE_PNG = "image/png";
-
- public static final String AUDIO_UNSPECIFIED = "audio/*";
- public static final String AUDIO_AAC = "audio/aac";
- public static final String AUDIO_AMR = "audio/amr";
- public static final String AUDIO_IMELODY = "audio/imelody";
- public static final String AUDIO_MID = "audio/mid";
- public static final String AUDIO_MIDI = "audio/midi";
- public static final String AUDIO_MP3 = "audio/mp3";
- public static final String AUDIO_MPEG3 = "audio/mpeg3";
- public static final String AUDIO_MPEG = "audio/mpeg";
- public static final String AUDIO_MPG = "audio/mpg";
- public static final String AUDIO_MP4 = "audio/mp4";
- public static final String AUDIO_X_MID = "audio/x-mid";
- public static final String AUDIO_X_MIDI = "audio/x-midi";
- public static final String AUDIO_X_MP3 = "audio/x-mp3";
- public static final String AUDIO_X_MPEG3 = "audio/x-mpeg3";
- public static final String AUDIO_X_MPEG = "audio/x-mpeg";
- public static final String AUDIO_X_MPG = "audio/x-mpg";
- public static final String AUDIO_3GPP = "audio/3gpp";
- public static final String AUDIO_OGG = "application/ogg";
-
- public static final String VIDEO_UNSPECIFIED = "video/*";
- public static final String VIDEO_3GPP = "video/3gpp";
- public static final String VIDEO_3G2 = "video/3gpp2";
- public static final String VIDEO_H263 = "video/h263";
- public static final String VIDEO_MP4 = "video/mp4";
-
- public static final String APP_SMIL = "application/smil";
- public static final String APP_WAP_XHTML = "application/vnd.wap.xhtml+xml";
- public static final String APP_XHTML = "application/xhtml+xml";
-
- public static final String APP_DRM_CONTENT = "application/vnd.oma.drm.content";
- public static final String APP_DRM_MESSAGE = "application/vnd.oma.drm.message";
-
- private static final ArrayList<String> sSupportedContentTypes = new ArrayList<String>();
- private static final ArrayList<String> sSupportedImageTypes = new ArrayList<String>();
- private static final ArrayList<String> sSupportedAudioTypes = new ArrayList<String>();
- private static final ArrayList<String> sSupportedVideoTypes = new ArrayList<String>();
-
- static {
- sSupportedContentTypes.add(TEXT_PLAIN);
- sSupportedContentTypes.add(TEXT_HTML);
- sSupportedContentTypes.add(TEXT_VCALENDAR);
- sSupportedContentTypes.add(TEXT_VCARD);
-
- sSupportedContentTypes.add(IMAGE_JPEG);
- sSupportedContentTypes.add(IMAGE_GIF);
- sSupportedContentTypes.add(IMAGE_WBMP);
- sSupportedContentTypes.add(IMAGE_PNG);
- sSupportedContentTypes.add(IMAGE_JPG);
- //supportedContentTypes.add(IMAGE_SVG); not yet supported.
-
- sSupportedContentTypes.add(AUDIO_AAC);
- sSupportedContentTypes.add(AUDIO_AMR);
- sSupportedContentTypes.add(AUDIO_IMELODY);
- sSupportedContentTypes.add(AUDIO_MID);
- sSupportedContentTypes.add(AUDIO_MIDI);
- sSupportedContentTypes.add(AUDIO_MP3);
- sSupportedContentTypes.add(AUDIO_MPEG3);
- sSupportedContentTypes.add(AUDIO_MPEG);
- sSupportedContentTypes.add(AUDIO_MPG);
- sSupportedContentTypes.add(AUDIO_X_MID);
- sSupportedContentTypes.add(AUDIO_X_MIDI);
- sSupportedContentTypes.add(AUDIO_X_MP3);
- sSupportedContentTypes.add(AUDIO_X_MPEG3);
- sSupportedContentTypes.add(AUDIO_X_MPEG);
- sSupportedContentTypes.add(AUDIO_X_MPG);
- sSupportedContentTypes.add(AUDIO_3GPP);
- sSupportedContentTypes.add(AUDIO_OGG);
-
- sSupportedContentTypes.add(VIDEO_3GPP);
- sSupportedContentTypes.add(VIDEO_3G2);
- sSupportedContentTypes.add(VIDEO_H263);
- sSupportedContentTypes.add(VIDEO_MP4);
-
- sSupportedContentTypes.add(APP_SMIL);
- sSupportedContentTypes.add(APP_WAP_XHTML);
- sSupportedContentTypes.add(APP_XHTML);
-
- sSupportedContentTypes.add(APP_DRM_CONTENT);
- sSupportedContentTypes.add(APP_DRM_MESSAGE);
-
- // add supported image types
- sSupportedImageTypes.add(IMAGE_JPEG);
- sSupportedImageTypes.add(IMAGE_GIF);
- sSupportedImageTypes.add(IMAGE_WBMP);
- sSupportedImageTypes.add(IMAGE_PNG);
- sSupportedImageTypes.add(IMAGE_JPG);
-
- // add supported audio types
- sSupportedAudioTypes.add(AUDIO_AAC);
- sSupportedAudioTypes.add(AUDIO_AMR);
- sSupportedAudioTypes.add(AUDIO_IMELODY);
- sSupportedAudioTypes.add(AUDIO_MID);
- sSupportedAudioTypes.add(AUDIO_MIDI);
- sSupportedAudioTypes.add(AUDIO_MP3);
- sSupportedAudioTypes.add(AUDIO_MPEG3);
- sSupportedAudioTypes.add(AUDIO_MPEG);
- sSupportedAudioTypes.add(AUDIO_MPG);
- sSupportedAudioTypes.add(AUDIO_MP4);
- sSupportedAudioTypes.add(AUDIO_X_MID);
- sSupportedAudioTypes.add(AUDIO_X_MIDI);
- sSupportedAudioTypes.add(AUDIO_X_MP3);
- sSupportedAudioTypes.add(AUDIO_X_MPEG3);
- sSupportedAudioTypes.add(AUDIO_X_MPEG);
- sSupportedAudioTypes.add(AUDIO_X_MPG);
- sSupportedAudioTypes.add(AUDIO_3GPP);
- sSupportedAudioTypes.add(AUDIO_OGG);
-
- // add supported video types
- sSupportedVideoTypes.add(VIDEO_3GPP);
- sSupportedVideoTypes.add(VIDEO_3G2);
- sSupportedVideoTypes.add(VIDEO_H263);
- sSupportedVideoTypes.add(VIDEO_MP4);
- }
-
- // This class should never be instantiated.
- private ContentType() {
- }
-
- public static boolean isSupportedType(String contentType) {
- return (null != contentType) && sSupportedContentTypes.contains(contentType);
- }
-
- public static boolean isSupportedImageType(String contentType) {
- return isImageType(contentType) && isSupportedType(contentType);
- }
-
- public static boolean isSupportedAudioType(String contentType) {
- return isAudioType(contentType) && isSupportedType(contentType);
- }
-
- public static boolean isSupportedVideoType(String contentType) {
- return isVideoType(contentType) && isSupportedType(contentType);
- }
-
- public static boolean isTextType(String contentType) {
- return (null != contentType) && contentType.startsWith("text/");
- }
-
- public static boolean isImageType(String contentType) {
- return (null != contentType) && contentType.startsWith("image/");
- }
-
- public static boolean isAudioType(String contentType) {
- return (null != contentType) && contentType.startsWith("audio/");
- }
-
- public static boolean isVideoType(String contentType) {
- return (null != contentType) && contentType.startsWith("video/");
- }
-
- public static boolean isDrmType(String contentType) {
- return (null != contentType)
- && (contentType.equals(APP_DRM_CONTENT)
- || contentType.equals(APP_DRM_MESSAGE));
- }
-
- public static boolean isUnspecified(String contentType) {
- return (null != contentType) && contentType.endsWith("*");
- }
-
- @SuppressWarnings("unchecked")
- public static ArrayList<String> getImageTypes() {
- return (ArrayList<String>) sSupportedImageTypes.clone();
- }
-
- @SuppressWarnings("unchecked")
- public static ArrayList<String> getAudioTypes() {
- return (ArrayList<String>) sSupportedAudioTypes.clone();
- }
-
- @SuppressWarnings("unchecked")
- public static ArrayList<String> getVideoTypes() {
- return (ArrayList<String>) sSupportedVideoTypes.clone();
- }
-
- @SuppressWarnings("unchecked")
- public static ArrayList<String> getSupportedTypes() {
- return (ArrayList<String>) sSupportedContentTypes.clone();
- }
-}
diff --git a/mms-common/java/com/android/mmscommon/telephony/TelephonyProvider.java b/mms-common/java/com/android/mmscommon/telephony/TelephonyProvider.java
deleted file mode 100644
index cfc9231..0000000
--- a/mms-common/java/com/android/mmscommon/telephony/TelephonyProvider.java
+++ /dev/null
@@ -1,1779 +0,0 @@
-/*
- * Copyright (C) 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.mmscommon.telephony;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.net.Uri;
-import android.provider.BaseColumns;
-import android.telephony.SmsMessage;
-import android.text.TextUtils;
-import android.util.Config;
-import android.util.Log;
-import android.util.Patterns;
-
-import android.database.sqlite.SqliteWrapper;
-
-/**
- * The Telephony provider contains data related to phone operation.
- *
- * @hide
- */
-
-// This is a copy of the private TelephoneProvider.java file found in:
-// com.android.providers.telephony
-// TODO: keep these files in sync.
-
-public final class TelephonyProvider {
- private static final String TAG = "Telephony";
- private static final boolean DEBUG = true;
- private static final boolean LOCAL_LOGV = DEBUG ? Config.LOGD : Config.LOGV;
-
- // Constructor
- public TelephonyProvider() {
- }
-
- /**
- * Base columns for tables that contain text based SMSs.
- */
- public interface TextBasedSmsColumns {
- /**
- * The type of the message
- * <P>Type: INTEGER</P>
- */
- public static final String TYPE = "type";
-
- public static final int MESSAGE_TYPE_ALL = 0;
- public static final int MESSAGE_TYPE_INBOX = 1;
- public static final int MESSAGE_TYPE_SENT = 2;
- public static final int MESSAGE_TYPE_DRAFT = 3;
- public static final int MESSAGE_TYPE_OUTBOX = 4;
- public static final int MESSAGE_TYPE_FAILED = 5; // for failed outgoing messages
- public static final int MESSAGE_TYPE_QUEUED = 6; // for messages to send later
-
-
- /**
- * The thread ID of the message
- * <P>Type: INTEGER</P>
- */
- public static final String THREAD_ID = "thread_id";
-
- /**
- * The address of the other party
- * <P>Type: TEXT</P>
- */
- public static final String ADDRESS = "address";
-
- /**
- * The person ID of the sender
- * <P>Type: INTEGER (long)</P>
- */
- public static final String PERSON_ID = "person";
-
- /**
- * The date the message was sent
- * <P>Type: INTEGER (long)</P>
- */
- public static final String DATE = "date";
-
- /**
- * Has the message been read
- * <P>Type: INTEGER (boolean)</P>
- */
- public static final String READ = "read";
-
- /**
- * Indicates whether this message has been seen by the user. The "seen" flag will be
- * used to figure out whether we need to throw up a statusbar notification or not.
- */
- public static final String SEEN = "seen";
-
- /**
- * The TP-Status value for the message, or -1 if no status has
- * been received
- */
- public static final String STATUS = "status";
-
- public static final int STATUS_NONE = -1;
- public static final int STATUS_COMPLETE = 0;
- public static final int STATUS_PENDING = 64;
- public static final int STATUS_FAILED = 128;
-
- /**
- * The subject of the message, if present
- * <P>Type: TEXT</P>
- */
- public static final String SUBJECT = "subject";
-
- /**
- * The body of the message
- * <P>Type: TEXT</P>
- */
- public static final String BODY = "body";
-
- /**
- * The id of the sender of the conversation, if present
- * <P>Type: INTEGER (reference to item in content://contacts/people)</P>
- */
- public static final String PERSON = "person";
-
- /**
- * The protocol identifier code
- * <P>Type: INTEGER</P>
- */
- public static final String PROTOCOL = "protocol";
-
- /**
- * Whether the <code>TP-Reply-Path</code> bit was set on this message
- * <P>Type: BOOLEAN</P>
- */
- public static final String REPLY_PATH_PRESENT = "reply_path_present";
-
- /**
- * The service center (SC) through which to send the message, if present
- * <P>Type: TEXT</P>
- */
- public static final String SERVICE_CENTER = "service_center";
-
- /**
- * Has the message been locked?
- * <P>Type: INTEGER (boolean)</P>
- */
- public static final String LOCKED = "locked";
-
- /**
- * Error code associated with sending or receiving this message
- * <P>Type: INTEGER</P>
- */
- public static final String ERROR_CODE = "error_code";
-}
-
- /**
- * Contains all text based SMS messages.
- */
- public static final class Sms implements BaseColumns, TextBasedSmsColumns {
- public static final Cursor query(ContentResolver cr, String[] projection) {
- return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
- }
-
- public static final Cursor query(ContentResolver cr, String[] projection,
- String where, String orderBy) {
- return cr.query(CONTENT_URI, projection, where,
- null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
- }
-
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://sms");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * Add an SMS to the given URI.
- *
- * @param resolver the content resolver to use
- * @param uri the URI to add the message to
- * @param address the address of the sender
- * @param body the body of the message
- * @param subject the psuedo-subject of the message
- * @param date the timestamp for the message
- * @param read true if the message has been read, false if not
- * @param deliveryReport true if a delivery report was requested, false if not
- * @return the URI for the new message
- */
- public static Uri addMessageToUri(ContentResolver resolver,
- Uri uri, String address, String body, String subject,
- Long date, boolean read, boolean deliveryReport) {
- return addMessageToUri(resolver, uri, address, body, subject,
- date, read, deliveryReport, -1L);
- }
-
- /**
- * Add an SMS to the given URI with thread_id specified.
- *
- * @param resolver the content resolver to use
- * @param uri the URI to add the message to
- * @param address the address of the sender
- * @param body the body of the message
- * @param subject the psuedo-subject of the message
- * @param date the timestamp for the message
- * @param read true if the message has been read, false if not
- * @param deliveryReport true if a delivery report was requested, false if not
- * @param threadId the thread_id of the message
- * @return the URI for the new message
- */
- public static Uri addMessageToUri(ContentResolver resolver,
- Uri uri, String address, String body, String subject,
- Long date, boolean read, boolean deliveryReport, long threadId) {
- ContentValues values = new ContentValues(7);
-
- values.put(ADDRESS, address);
- if (date != null) {
- values.put(DATE, date);
- }
- values.put(READ, read ? Integer.valueOf(1) : Integer.valueOf(0));
- values.put(SUBJECT, subject);
- values.put(BODY, body);
- if (deliveryReport) {
- values.put(STATUS, STATUS_PENDING);
- }
- if (threadId != -1L) {
- values.put(THREAD_ID, threadId);
- }
- return resolver.insert(uri, values);
- }
-
- /**
- * Move a message to the given folder.
- *
- * @param context the context to use
- * @param uri the message to move
- * @param folder the folder to move to
- * @return true if the operation succeeded
- */
- public static boolean moveMessageToFolder(Context context,
- Uri uri, int folder, int error) {
- if (uri == null) {
- return false;
- }
-
- boolean markAsUnread = false;
- boolean markAsRead = false;
- switch(folder) {
- case MESSAGE_TYPE_INBOX:
- case MESSAGE_TYPE_DRAFT:
- break;
- case MESSAGE_TYPE_OUTBOX:
- case MESSAGE_TYPE_SENT:
- markAsRead = true;
- break;
- case MESSAGE_TYPE_FAILED:
- case MESSAGE_TYPE_QUEUED:
- markAsUnread = true;
- break;
- default:
- return false;
- }
-
- ContentValues values = new ContentValues(3);
-
- values.put(TYPE, folder);
- if (markAsUnread) {
- values.put(READ, Integer.valueOf(0));
- } else if (markAsRead) {
- values.put(READ, Integer.valueOf(1));
- }
- values.put(ERROR_CODE, error);
-
- return 1 == SqliteWrapper.update(context, context.getContentResolver(),
- uri, values, null, null);
- }
-
- /**
- * Returns true iff the folder (message type) identifies an
- * outgoing message.
- */
- public static boolean isOutgoingFolder(int messageType) {
- return (messageType == MESSAGE_TYPE_FAILED)
- || (messageType == MESSAGE_TYPE_OUTBOX)
- || (messageType == MESSAGE_TYPE_SENT)
- || (messageType == MESSAGE_TYPE_QUEUED);
- }
-
- /**
- * Contains all text based SMS messages in the SMS app's inbox.
- */
- public static final class Inbox implements BaseColumns, TextBasedSmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://sms/inbox");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * Add an SMS to the Draft box.
- *
- * @param resolver the content resolver to use
- * @param address the address of the sender
- * @param body the body of the message
- * @param subject the psuedo-subject of the message
- * @param date the timestamp for the message
- * @param read true if the message has been read, false if not
- * @return the URI for the new message
- */
- public static Uri addMessage(ContentResolver resolver,
- String address, String body, String subject, Long date,
- boolean read) {
- return addMessageToUri(resolver, CONTENT_URI, address, body,
- subject, date, read, false);
- }
- }
-
- /**
- * Contains all sent text based SMS messages in the SMS app's.
- */
- public static final class Sent implements BaseColumns, TextBasedSmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://sms/sent");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * Add an SMS to the Draft box.
- *
- * @param resolver the content resolver to use
- * @param address the address of the sender
- * @param body the body of the message
- * @param subject the psuedo-subject of the message
- * @param date the timestamp for the message
- * @return the URI for the new message
- */
- public static Uri addMessage(ContentResolver resolver,
- String address, String body, String subject, Long date) {
- return addMessageToUri(resolver, CONTENT_URI, address, body,
- subject, date, true, false);
- }
- }
-
- /**
- * Contains all sent text based SMS messages in the SMS app's.
- */
- public static final class Draft implements BaseColumns, TextBasedSmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://sms/draft");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * Add an SMS to the Draft box.
- *
- * @param resolver the content resolver to use
- * @param address the address of the sender
- * @param body the body of the message
- * @param subject the psuedo-subject of the message
- * @param date the timestamp for the message
- * @return the URI for the new message
- */
- public static Uri addMessage(ContentResolver resolver,
- String address, String body, String subject, Long date) {
- return addMessageToUri(resolver, CONTENT_URI, address, body,
- subject, date, true, false);
- }
-
- /**
- * Save over an existing draft message.
- *
- * @param resolver the content resolver to use
- * @param uri of existing message
- * @param body the new body for the draft message
- * @return true is successful, false otherwise
- */
- public static boolean saveMessage(ContentResolver resolver,
- Uri uri, String body) {
- ContentValues values = new ContentValues(2);
- values.put(BODY, body);
- values.put(DATE, System.currentTimeMillis());
- return resolver.update(uri, values, null, null) == 1;
- }
- }
-
- /**
- * Contains all pending outgoing text based SMS messages.
- */
- public static final class Outbox implements BaseColumns, TextBasedSmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://sms/outbox");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * Add an SMS to the Out box.
- *
- * @param resolver the content resolver to use
- * @param address the address of the sender
- * @param body the body of the message
- * @param subject the psuedo-subject of the message
- * @param date the timestamp for the message
- * @param deliveryReport whether a delivery report was requested for the message
- * @return the URI for the new message
- */
- public static Uri addMessage(ContentResolver resolver,
- String address, String body, String subject, Long date,
- boolean deliveryReport, long threadId) {
- return addMessageToUri(resolver, CONTENT_URI, address, body,
- subject, date, true, deliveryReport, threadId);
- }
- }
-
- /**
- * Contains all sent text-based SMS messages in the SMS app's.
- */
- public static final class Conversations
- implements BaseColumns, TextBasedSmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://sms/conversations");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * The first 45 characters of the body of the message
- * <P>Type: TEXT</P>
- */
- public static final String SNIPPET = "snippet";
-
- /**
- * The number of messages in the conversation
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_COUNT = "msg_count";
- }
-
- /**
- * Contains info about SMS related Intents that are broadcast.
- */
- public static final class Intents {
- /**
- * Set by BroadcastReceiver. Indicates the message was handled
- * successfully.
- */
- public static final int RESULT_SMS_HANDLED = 1;
-
- /**
- * Set by BroadcastReceiver. Indicates a generic error while
- * processing the message.
- */
- public static final int RESULT_SMS_GENERIC_ERROR = 2;
-
- /**
- * Set by BroadcastReceiver. Indicates insufficient memory to store
- * the message.
- */
- public static final int RESULT_SMS_OUT_OF_MEMORY = 3;
-
- /**
- * Set by BroadcastReceiver. Indicates the message, while
- * possibly valid, is of a format or encoding that is not
- * supported.
- */
- public static final int RESULT_SMS_UNSUPPORTED = 4;
-
- /**
- * Broadcast Action: A new text based SMS message has been received
- * by the device. The intent will have the following extra
- * values:</p>
- *
- * <ul>
- * <li><em>pdus</em> - An Object[] od byte[]s containing the PDUs
- * that make up the message.</li>
- * </ul>
- *
- * <p>The extra values can be extracted using
- * {@link #getMessagesFromIntent(Intent)}.</p>
- *
- * <p>If a BroadcastReceiver encounters an error while processing
- * this intent it should set the result code appropriately.</p>
- */
- public static final String SMS_RECEIVED_ACTION =
- "android.provider.Telephony.SMS_RECEIVED";
-
- /**
- * Broadcast Action: A new data based SMS message has been received
- * by the device. The intent will have the following extra
- * values:</p>
- *
- * <ul>
- * <li><em>pdus</em> - An Object[] od byte[]s containing the PDUs
- * that make up the message.</li>
- * </ul>
- *
- * <p>The extra values can be extracted using
- * {@link #getMessagesFromIntent(Intent)}.</p>
- *
- * <p>If a BroadcastReceiver encounters an error while processing
- * this intent it should set the result code appropriately.</p>
- */
- public static final String DATA_SMS_RECEIVED_ACTION =
- "android.intent.action.DATA_SMS_RECEIVED";
-
- /**
- * Broadcast Action: A new WAP PUSH message has been received by the
- * device. The intent will have the following extra
- * values:</p>
- *
- * <ul>
- * <li><em>transactionId (Integer)</em> - The WAP transaction
- * ID</li>
- * <li><em>pduType (Integer)</em> - The WAP PDU type</li>
- * <li><em>header (byte[])</em> - The header of the message</li>
- * <li><em>data (byte[])</em> - The data payload of the message</li>
- * </ul>
- *
- * <p>If a BroadcastReceiver encounters an error while processing
- * this intent it should set the result code appropriately.</p>
- */
- public static final String WAP_PUSH_RECEIVED_ACTION =
- "android.provider.Telephony.WAP_PUSH_RECEIVED";
-
- /**
- * Broadcast Action: The SIM storage for SMS messages is full. If
- * space is not freed, messages targeted for the SIM (class 2) may
- * not be saved.
- */
- public static final String SIM_FULL_ACTION =
- "android.provider.Telephony.SIM_FULL";
-
- /**
- * Broadcast Action: An incoming SMS has been rejected by the
- * telephony framework. This intent is sent in lieu of any
- * of the RECEIVED_ACTION intents. The intent will have the
- * following extra value:</p>
- *
- * <ul>
- * <li><em>result</em> - An int result code, eg,
- * <code>{@link #RESULT_SMS_OUT_OF_MEMORY}</code>,
- * indicating the error returned to the network.</li>
- * </ul>
-
- */
- public static final String SMS_REJECTED_ACTION =
- "android.provider.Telephony.SMS_REJECTED";
-
- /**
- * Broadcast Action: The phone service state has changed. The intent will have the following
- * extra values:</p>
- * <ul>
- * <li><em>state</em> - An int with one of the following values:
- * {@link android.telephony.ServiceState#STATE_IN_SERVICE},
- * {@link android.telephony.ServiceState#STATE_OUT_OF_SERVICE},
- * {@link android.telephony.ServiceState#STATE_EMERGENCY_ONLY}
- * or {@link android.telephony.ServiceState#STATE_POWER_OFF}
- * <li><em>roaming</em> - A boolean value indicating whether the phone is roaming.</li>
- * <li><em>operator-alpha-long</em> - The carrier name as a string.</li>
- * <li><em>operator-alpha-short</em> - A potentially shortened version of the carrier name,
- * as a string.</li>
- * <li><em>operator-numeric</em> - A number representing the carrier, as a string. This is
- * a five or six digit number consisting of the MCC (Mobile Country Code, 3 digits)
- * and MNC (Mobile Network code, 2-3 digits).</li>
- * <li><em>manual</em> - A boolean, where true indicates that the user has chosen to select
- * the network manually, and false indicates that network selection is handled by the
- * phone.</li>
- * </ul>
- *
- * <p class="note">
- * Requires the READ_PHONE_STATE permission.
- *
- * <p class="note">This is a protected intent that can only be sent
- * by the system.
- */
- public static final String ACTION_SERVICE_STATE_CHANGED =
- "android.intent.action.SERVICE_STATE";
-
- /**
- * Read the PDUs out of an {@link #SMS_RECEIVED_ACTION} or a
- * {@link #DATA_SMS_RECEIVED_ACTION} intent.
- *
- * @param intent the intent to read from
- * @return an array of SmsMessages for the PDUs
- */
- public static final SmsMessage[] getMessagesFromIntent(
- Intent intent) {
- Object[] messages = (Object[]) intent.getSerializableExtra("pdus");
- byte[][] pduObjs = new byte[messages.length][];
-
- for (int i = 0; i < messages.length; i++) {
- pduObjs[i] = (byte[]) messages[i];
- }
- byte[][] pdus = new byte[pduObjs.length][];
- int pduCount = pdus.length;
- SmsMessage[] msgs = new SmsMessage[pduCount];
- for (int i = 0; i < pduCount; i++) {
- pdus[i] = pduObjs[i];
- msgs[i] = SmsMessage.createFromPdu(pdus[i]);
- }
- return msgs;
- }
- }
- }
-
- /**
- * Base columns for tables that contain MMSs.
- */
- public interface BaseMmsColumns extends BaseColumns {
-
- public static final int MESSAGE_BOX_ALL = 0;
- public static final int MESSAGE_BOX_INBOX = 1;
- public static final int MESSAGE_BOX_SENT = 2;
- public static final int MESSAGE_BOX_DRAFTS = 3;
- public static final int MESSAGE_BOX_OUTBOX = 4;
-
- /**
- * The date the message was sent.
- * <P>Type: INTEGER (long)</P>
- */
- public static final String DATE = "date";
-
- /**
- * The box which the message belong to, for example, MESSAGE_BOX_INBOX.
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_BOX = "msg_box";
-
- /**
- * Has the message been read.
- * <P>Type: INTEGER (boolean)</P>
- */
- public static final String READ = "read";
-
- /**
- * Indicates whether this message has been seen by the user. The "seen" flag will be
- * used to figure out whether we need to throw up a statusbar notification or not.
- */
- public static final String SEEN = "seen";
-
- /**
- * The Message-ID of the message.
- * <P>Type: TEXT</P>
- */
- public static final String MESSAGE_ID = "m_id";
-
- /**
- * The subject of the message, if present.
- * <P>Type: TEXT</P>
- */
- public static final String SUBJECT = "sub";
-
- /**
- * The character set of the subject, if present.
- * <P>Type: INTEGER</P>
- */
- public static final String SUBJECT_CHARSET = "sub_cs";
-
- /**
- * The Content-Type of the message.
- * <P>Type: TEXT</P>
- */
- public static final String CONTENT_TYPE = "ct_t";
-
- /**
- * The Content-Location of the message.
- * <P>Type: TEXT</P>
- */
- public static final String CONTENT_LOCATION = "ct_l";
-
- /**
- * The address of the sender.
- * <P>Type: TEXT</P>
- */
- public static final String FROM = "from";
-
- /**
- * The address of the recipients.
- * <P>Type: TEXT</P>
- */
- public static final String TO = "to";
-
- /**
- * The address of the cc. recipients.
- * <P>Type: TEXT</P>
- */
- public static final String CC = "cc";
-
- /**
- * The address of the bcc. recipients.
- * <P>Type: TEXT</P>
- */
- public static final String BCC = "bcc";
-
- /**
- * The expiry time of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String EXPIRY = "exp";
-
- /**
- * The class of the message.
- * <P>Type: TEXT</P>
- */
- public static final String MESSAGE_CLASS = "m_cls";
-
- /**
- * The type of the message defined by MMS spec.
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_TYPE = "m_type";
-
- /**
- * The version of specification that this message conform.
- * <P>Type: INTEGER</P>
- */
- public static final String MMS_VERSION = "v";
-
- /**
- * The size of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_SIZE = "m_size";
-
- /**
- * The priority of the message.
- * <P>Type: TEXT</P>
- */
- public static final String PRIORITY = "pri";
-
- /**
- * The read-report of the message.
- * <P>Type: TEXT</P>
- */
- public static final String READ_REPORT = "rr";
-
- /**
- * Whether the report is allowed.
- * <P>Type: TEXT</P>
- */
- public static final String REPORT_ALLOWED = "rpt_a";
-
- /**
- * The response-status of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String RESPONSE_STATUS = "resp_st";
-
- /**
- * The status of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String STATUS = "st";
-
- /**
- * The transaction-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String TRANSACTION_ID = "tr_id";
-
- /**
- * The retrieve-status of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String RETRIEVE_STATUS = "retr_st";
-
- /**
- * The retrieve-text of the message.
- * <P>Type: TEXT</P>
- */
- public static final String RETRIEVE_TEXT = "retr_txt";
-
- /**
- * The character set of the retrieve-text.
- * <P>Type: TEXT</P>
- */
- public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs";
-
- /**
- * The read-status of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String READ_STATUS = "read_status";
-
- /**
- * The content-class of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String CONTENT_CLASS = "ct_cls";
-
- /**
- * The delivery-report of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String DELIVERY_REPORT = "d_rpt";
-
- /**
- * The delivery-time-token of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String DELIVERY_TIME_TOKEN = "d_tm_tok";
-
- /**
- * The delivery-time of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String DELIVERY_TIME = "d_tm";
-
- /**
- * The response-text of the message.
- * <P>Type: TEXT</P>
- */
- public static final String RESPONSE_TEXT = "resp_txt";
-
- /**
- * The sender-visibility of the message.
- * <P>Type: TEXT</P>
- */
- public static final String SENDER_VISIBILITY = "s_vis";
-
- /**
- * The reply-charging of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String REPLY_CHARGING = "r_chg";
-
- /**
- * The reply-charging-deadline-token of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String REPLY_CHARGING_DEADLINE_TOKEN = "r_chg_dl_tok";
-
- /**
- * The reply-charging-deadline of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl";
-
- /**
- * The reply-charging-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String REPLY_CHARGING_ID = "r_chg_id";
-
- /**
- * The reply-charging-size of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String REPLY_CHARGING_SIZE = "r_chg_sz";
-
- /**
- * The previously-sent-by of the message.
- * <P>Type: TEXT</P>
- */
- public static final String PREVIOUSLY_SENT_BY = "p_s_by";
-
- /**
- * The previously-sent-date of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String PREVIOUSLY_SENT_DATE = "p_s_d";
-
- /**
- * The store of the message.
- * <P>Type: TEXT</P>
- */
- public static final String STORE = "store";
-
- /**
- * The mm-state of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String MM_STATE = "mm_st";
-
- /**
- * The mm-flags-token of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String MM_FLAGS_TOKEN = "mm_flg_tok";
-
- /**
- * The mm-flags of the message.
- * <P>Type: TEXT</P>
- */
- public static final String MM_FLAGS = "mm_flg";
-
- /**
- * The store-status of the message.
- * <P>Type: TEXT</P>
- */
- public static final String STORE_STATUS = "store_st";
-
- /**
- * The store-status-text of the message.
- * <P>Type: TEXT</P>
- */
- public static final String STORE_STATUS_TEXT = "store_st_txt";
-
- /**
- * The stored of the message.
- * <P>Type: TEXT</P>
- */
- public static final String STORED = "stored";
-
- /**
- * The totals of the message.
- * <P>Type: TEXT</P>
- */
- public static final String TOTALS = "totals";
-
- /**
- * The mbox-totals of the message.
- * <P>Type: TEXT</P>
- */
- public static final String MBOX_TOTALS = "mb_t";
-
- /**
- * The mbox-totals-token of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String MBOX_TOTALS_TOKEN = "mb_t_tok";
-
- /**
- * The quotas of the message.
- * <P>Type: TEXT</P>
- */
- public static final String QUOTAS = "qt";
-
- /**
- * The mbox-quotas of the message.
- * <P>Type: TEXT</P>
- */
- public static final String MBOX_QUOTAS = "mb_qt";
-
- /**
- * The mbox-quotas-token of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok";
-
- /**
- * The message-count of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_COUNT = "m_cnt";
-
- /**
- * The start of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String START = "start";
-
- /**
- * The distribution-indicator of the message.
- * <P>Type: TEXT</P>
- */
- public static final String DISTRIBUTION_INDICATOR = "d_ind";
-
- /**
- * The element-descriptor of the message.
- * <P>Type: TEXT</P>
- */
- public static final String ELEMENT_DESCRIPTOR = "e_des";
-
- /**
- * The limit of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String LIMIT = "limit";
-
- /**
- * The recommended-retrieval-mode of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod";
-
- /**
- * The recommended-retrieval-mode-text of the message.
- * <P>Type: TEXT</P>
- */
- public static final String RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt";
-
- /**
- * The status-text of the message.
- * <P>Type: TEXT</P>
- */
- public static final String STATUS_TEXT = "st_txt";
-
- /**
- * The applic-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String APPLIC_ID = "apl_id";
-
- /**
- * The reply-applic-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String REPLY_APPLIC_ID = "r_apl_id";
-
- /**
- * The aux-applic-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String AUX_APPLIC_ID = "aux_apl_id";
-
- /**
- * The drm-content of the message.
- * <P>Type: TEXT</P>
- */
- public static final String DRM_CONTENT = "drm_c";
-
- /**
- * The adaptation-allowed of the message.
- * <P>Type: TEXT</P>
- */
- public static final String ADAPTATION_ALLOWED = "adp_a";
-
- /**
- * The replace-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String REPLACE_ID = "repl_id";
-
- /**
- * The cancel-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String CANCEL_ID = "cl_id";
-
- /**
- * The cancel-status of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String CANCEL_STATUS = "cl_st";
-
- /**
- * The thread ID of the message
- * <P>Type: INTEGER</P>
- */
- public static final String THREAD_ID = "thread_id";
-
- /**
- * Has the message been locked?
- * <P>Type: INTEGER (boolean)</P>
- */
- public static final String LOCKED = "locked";
- }
-
- /**
- * Columns for the "canonical_addresses" table used by MMS and
- * SMS."
- */
- public interface CanonicalAddressesColumns extends BaseColumns {
- /**
- * An address used in MMS or SMS. Email addresses are
- * converted to lower case and are compared by string
- * equality. Other addresses are compared using
- * PHONE_NUMBERS_EQUAL.
- * <P>Type: TEXT</P>
- */
- public static final String ADDRESS = "address";
- }
-
- /**
- * Columns for the "threads" table used by MMS and SMS.
- */
- public interface ThreadsColumns extends BaseColumns {
- /**
- * The date at which the thread was created.
- *
- * <P>Type: INTEGER (long)</P>
- */
- public static final String DATE = "date";
-
- /**
- * A string encoding of the recipient IDs of the recipients of
- * the message, in numerical order and separated by spaces.
- * <P>Type: TEXT</P>
- */
- public static final String RECIPIENT_IDS = "recipient_ids";
-
- /**
- * The message count of the thread.
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_COUNT = "message_count";
- /**
- * Indicates whether all messages of the thread have been read.
- * <P>Type: INTEGER</P>
- */
- public static final String READ = "read";
-
- /**
- * The snippet of the latest message in the thread.
- * <P>Type: TEXT</P>
- */
- public static final String SNIPPET = "snippet";
- /**
- * The charset of the snippet.
- * <P>Type: INTEGER</P>
- */
- public static final String SNIPPET_CHARSET = "snippet_cs";
- /**
- * Type of the thread, either Threads.COMMON_THREAD or
- * Threads.BROADCAST_THREAD.
- * <P>Type: INTEGER</P>
- */
- public static final String TYPE = "type";
- /**
- * Indicates whether there is a transmission error in the thread.
- * <P>Type: INTEGER</P>
- */
- public static final String ERROR = "error";
- /**
- * Indicates whether this thread contains any attachments.
- * <P>Type: INTEGER</P>
- */
- public static final String HAS_ATTACHMENT = "has_attachment";
- }
-
- /**
- * Helper functions for the "threads" table used by MMS and SMS.
- */
- public static final class Threads implements ThreadsColumns {
- private static final String[] ID_PROJECTION = { BaseColumns._ID };
- private static final String STANDARD_ENCODING = "UTF-8";
- private static final Uri THREAD_ID_CONTENT_URI = Uri.parse(
- "content://mms-sms/threadID");
- public static final Uri CONTENT_URI = Uri.withAppendedPath(
- MmsSms.CONTENT_URI, "conversations");
- public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath(
- CONTENT_URI, "obsolete");
-
- public static final int COMMON_THREAD = 0;
- public static final int BROADCAST_THREAD = 1;
-
- // No one should construct an instance of this class.
- private Threads() {
- }
-
- /**
- * This is a single-recipient version of
- * getOrCreateThreadId. It's convenient for use with SMS
- * messages.
- */
- public static long getOrCreateThreadId(Context context, String recipient) {
- Set<String> recipients = new HashSet<String>();
-
- recipients.add(recipient);
- return getOrCreateThreadId(context, recipients);
- }
-
- /**
- * Given the recipients list and subject of an unsaved message,
- * return its thread ID. If the message starts a new thread,
- * allocate a new thread ID. Otherwise, use the appropriate
- * existing thread ID.
- *
- * Find the thread ID of the same set of recipients (in
- * any order, without any additions). If one
- * is found, return it. Otherwise, return a unique thread ID.
- */
- public static long getOrCreateThreadId(
- Context context, Set<String> recipients) {
- Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
-
- for (String recipient : recipients) {
- if (Mms.isEmailAddress(recipient)) {
- recipient = Mms.extractAddrSpec(recipient);
- }
-
- uriBuilder.appendQueryParameter("recipient", recipient);
- }
-
- Uri uri = uriBuilder.build();
- if (DEBUG) {
- Log.v(TAG, "getOrCreateThreadId uri: " + uri);
- }
- Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
- uri, ID_PROJECTION, null, null, null);
- if (DEBUG) {
- Log.v(TAG, "getOrCreateThreadId cursor cnt: " + cursor.getCount());
- }
- if (cursor != null) {
- try {
- if (cursor.moveToFirst()) {
- return cursor.getLong(0);
- } else {
- Log.e(TAG, "getOrCreateThreadId returned no rows!");
- }
- } finally {
- cursor.close();
- }
- }
-
- Log.e(TAG, "getOrCreateThreadId failed with uri " + uri.toString());
- throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
- }
- }
-
- /**
- * Contains all MMS messages.
- */
- public static final class Mms implements BaseMmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI = Uri.parse("content://mms");
-
- public static final Uri REPORT_REQUEST_URI = Uri.withAppendedPath(
- CONTENT_URI, "report-request");
-
- public static final Uri REPORT_STATUS_URI = Uri.withAppendedPath(
- CONTENT_URI, "report-status");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * mailbox = name-addr
- * name-addr = [display-name] angle-addr
- * angle-addr = [CFWS] "<" addr-spec ">" [CFWS]
- */
- public static final Pattern NAME_ADDR_EMAIL_PATTERN =
- Pattern.compile("\\s*(\"[^\"]*\"|[^<>\"]+)\\s*<([^<>]+)>\\s*");
-
- /**
- * quoted-string = [CFWS]
- * DQUOTE *([FWS] qcontent) [FWS] DQUOTE
- * [CFWS]
- */
- public static final Pattern QUOTED_STRING_PATTERN =
- Pattern.compile("\\s*\"([^\"]*)\"\\s*");
-
- public static final Cursor query(
- ContentResolver cr, String[] projection) {
- return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
- }
-
- public static final Cursor query(
- ContentResolver cr, String[] projection,
- String where, String orderBy) {
- return cr.query(CONTENT_URI, projection,
- where, null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
- }
-
- public static final String getMessageBoxName(int msgBox) {
- switch (msgBox) {
- case MESSAGE_BOX_ALL:
- return "all";
- case MESSAGE_BOX_INBOX:
- return "inbox";
- case MESSAGE_BOX_SENT:
- return "sent";
- case MESSAGE_BOX_DRAFTS:
- return "drafts";
- case MESSAGE_BOX_OUTBOX:
- return "outbox";
- default:
- throw new IllegalArgumentException("Invalid message box: " + msgBox);
- }
- }
-
- public static String extractAddrSpec(String address) {
- Matcher match = NAME_ADDR_EMAIL_PATTERN.matcher(address);
-
- if (match.matches()) {
- return match.group(2);
- }
- return address;
- }
-
- /**
- * Returns true if the address is an email address
- *
- * @param address the input address to be tested
- * @return true if address is an email address
- */
- public static boolean isEmailAddress(String address) {
- if (TextUtils.isEmpty(address)) {
- return false;
- }
-
- String s = extractAddrSpec(address);
- Matcher match = Patterns.EMAIL_ADDRESS.matcher(s);
- return match.matches();
- }
-
- /**
- * Returns true if the number is a Phone number
- *
- * @param number the input number to be tested
- * @return true if number is a Phone number
- */
- public static boolean isPhoneNumber(String number) {
- if (TextUtils.isEmpty(number)) {
- return false;
- }
-
- Matcher match = Patterns.PHONE.matcher(number);
- return match.matches();
- }
-
- /**
- * Contains all MMS messages in the MMS app's inbox.
- */
- public static final class Inbox implements BaseMmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri
- CONTENT_URI = Uri.parse("content://mms/inbox");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
- }
-
- /**
- * Contains all MMS messages in the MMS app's sent box.
- */
- public static final class Sent implements BaseMmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri
- CONTENT_URI = Uri.parse("content://mms/sent");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
- }
-
- /**
- * Contains all MMS messages in the MMS app's drafts box.
- */
- public static final class Draft implements BaseMmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri
- CONTENT_URI = Uri.parse("content://mms/drafts");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
- }
-
- /**
- * Contains all MMS messages in the MMS app's outbox.
- */
- public static final class Outbox implements BaseMmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri
- CONTENT_URI = Uri.parse("content://mms/outbox");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
- }
-
- public static final class Addr implements BaseColumns {
- /**
- * The ID of MM which this address entry belongs to.
- */
- public static final String MSG_ID = "msg_id";
-
- /**
- * The ID of contact entry in Phone Book.
- */
- public static final String CONTACT_ID = "contact_id";
-
- /**
- * The address text.
- */
- public static final String ADDRESS = "address";
-
- /**
- * Type of address, must be one of PduHeaders.BCC,
- * PduHeaders.CC, PduHeaders.FROM, PduHeaders.TO.
- */
- public static final String TYPE = "type";
-
- /**
- * Character set of this entry.
- */
- public static final String CHARSET = "charset";
- }
-
- public static final class Part implements BaseColumns {
- /**
- * The identifier of the message which this part belongs to.
- * <P>Type: INTEGER</P>
- */
- public static final String MSG_ID = "mid";
-
- /**
- * The order of the part.
- * <P>Type: INTEGER</P>
- */
- public static final String SEQ = "seq";
-
- /**
- * The content type of the part.
- * <P>Type: TEXT</P>
- */
- public static final String CONTENT_TYPE = "ct";
-
- /**
- * The name of the part.
- * <P>Type: TEXT</P>
- */
- public static final String NAME = "name";
-
- /**
- * The charset of the part.
- * <P>Type: TEXT</P>
- */
- public static final String CHARSET = "chset";
-
- /**
- * The file name of the part.
- * <P>Type: TEXT</P>
- */
- public static final String FILENAME = "fn";
-
- /**
- * The content disposition of the part.
- * <P>Type: TEXT</P>
- */
- public static final String CONTENT_DISPOSITION = "cd";
-
- /**
- * The content ID of the part.
- * <P>Type: INTEGER</P>
- */
- public static final String CONTENT_ID = "cid";
-
- /**
- * The content location of the part.
- * <P>Type: INTEGER</P>
- */
- public static final String CONTENT_LOCATION = "cl";
-
- /**
- * The start of content-type of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String CT_START = "ctt_s";
-
- /**
- * The type of content-type of the message.
- * <P>Type: TEXT</P>
- */
- public static final String CT_TYPE = "ctt_t";
-
- /**
- * The location(on filesystem) of the binary data of the part.
- * <P>Type: INTEGER</P>
- */
- public static final String _DATA = "_data";
-
- public static final String TEXT = "text";
-
- }
-
- public static final class Rate {
- public static final Uri CONTENT_URI = Uri.withAppendedPath(
- Mms.CONTENT_URI, "rate");
- /**
- * When a message was successfully sent.
- * <P>Type: INTEGER</P>
- */
- public static final String SENT_TIME = "sent_time";
- }
-
- public static final class ScrapSpace {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI = Uri.parse("content://mms/scrapSpace");
-
- /**
- * This is the scrap file we use to store the media attachment when the user
- * chooses to capture a photo to be attached . We pass {#link@Uri} to the Camera app,
- * which streams the captured image to the uri. Internally we write the media content
- * to this file. It's named '.temp.jpg' so Gallery won't pick it up.
- */
- public static final String SCRAP_FILE_PATH = "/sdcard/mms/scrapSpace/.temp.jpg";
- }
-
- public static final class Intents {
- private Intents() {
- // Non-instantiatable.
- }
-
- /**
- * The extra field to store the contents of the Intent,
- * which should be an array of Uri.
- */
- public static final String EXTRA_CONTENTS = "contents";
- /**
- * The extra field to store the type of the contents,
- * which should be an array of String.
- */
- public static final String EXTRA_TYPES = "types";
- /**
- * The extra field to store the 'Cc' addresses.
- */
- public static final String EXTRA_CC = "cc";
- /**
- * The extra field to store the 'Bcc' addresses;
- */
- public static final String EXTRA_BCC = "bcc";
- /**
- * The extra field to store the 'Subject'.
- */
- public static final String EXTRA_SUBJECT = "subject";
- /**
- * Indicates that the contents of specified URIs were changed.
- * The application which is showing or caching these contents
- * should be updated.
- */
- public static final String
- CONTENT_CHANGED_ACTION = "android.intent.action.CONTENT_CHANGED";
- /**
- * An extra field which stores the URI of deleted contents.
- */
- public static final String DELETED_CONTENTS = "deleted_contents";
- }
- }
-
- /**
- * Contains all MMS and SMS messages.
- */
- public static final class MmsSms implements BaseColumns {
- /**
- * The column to distinguish SMS & MMS messages in query results.
- */
- public static final String TYPE_DISCRIMINATOR_COLUMN =
- "transport_type";
-
- public static final Uri CONTENT_URI = Uri.parse("content://mms-sms/");
-
- public static final Uri CONTENT_CONVERSATIONS_URI = Uri.parse(
- "content://mms-sms/conversations");
-
- public static final Uri CONTENT_FILTER_BYPHONE_URI = Uri.parse(
- "content://mms-sms/messages/byphone");
-
- public static final Uri CONTENT_UNDELIVERED_URI = Uri.parse(
- "content://mms-sms/undelivered");
-
- public static final Uri CONTENT_DRAFT_URI = Uri.parse(
- "content://mms-sms/draft");
-
- public static final Uri CONTENT_LOCKED_URI = Uri.parse(
- "content://mms-sms/locked");
-
- /***
- * Pass in a query parameter called "pattern" which is the text
- * to search for.
- * The sort order is fixed to be thread_id ASC,date DESC.
- */
- public static final Uri SEARCH_URI = Uri.parse(
- "content://mms-sms/search");
-
- // Constants for message protocol types.
- public static final int SMS_PROTO = 0;
- public static final int MMS_PROTO = 1;
-
- // Constants for error types of pending messages.
- public static final int NO_ERROR = 0;
- public static final int ERR_TYPE_GENERIC = 1;
- public static final int ERR_TYPE_SMS_PROTO_TRANSIENT = 2;
- public static final int ERR_TYPE_MMS_PROTO_TRANSIENT = 3;
- public static final int ERR_TYPE_TRANSPORT_FAILURE = 4;
- public static final int ERR_TYPE_GENERIC_PERMANENT = 10;
- public static final int ERR_TYPE_SMS_PROTO_PERMANENT = 11;
- public static final int ERR_TYPE_MMS_PROTO_PERMANENT = 12;
-
- public static final class PendingMessages implements BaseColumns {
- public static final Uri CONTENT_URI = Uri.withAppendedPath(
- MmsSms.CONTENT_URI, "pending");
- /**
- * The type of transport protocol(MMS or SMS).
- * <P>Type: INTEGER</P>
- */
- public static final String PROTO_TYPE = "proto_type";
- /**
- * The ID of the message to be sent or downloaded.
- * <P>Type: INTEGER</P>
- */
- public static final String MSG_ID = "msg_id";
- /**
- * The type of the message to be sent or downloaded.
- * This field is only valid for MM. For SM, its value is always
- * set to 0.
- */
- public static final String MSG_TYPE = "msg_type";
- /**
- * The type of the error code.
- * <P>Type: INTEGER</P>
- */
- public static final String ERROR_TYPE = "err_type";
- /**
- * The error code of sending/retrieving process.
- * <P>Type: INTEGER</P>
- */
- public static final String ERROR_CODE = "err_code";
- /**
- * How many times we tried to send or download the message.
- * <P>Type: INTEGER</P>
- */
- public static final String RETRY_INDEX = "retry_index";
- /**
- * The time to do next retry.
- */
- public static final String DUE_TIME = "due_time";
- /**
- * The time we last tried to send or download the message.
- */
- public static final String LAST_TRY = "last_try";
- }
-
- public static final class WordsTable {
- public static final String ID = "_id";
- public static final String SOURCE_ROW_ID = "source_id";
- public static final String TABLE_ID = "table_to_use";
- public static final String INDEXED_TEXT = "index_text";
- }
- }
-
- public static final class Carriers implements BaseColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://telephony/carriers");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "name ASC";
-
- public static final String NAME = "name";
-
- public static final String APN = "apn";
-
- public static final String PROXY = "proxy";
-
- public static final String PORT = "port";
-
- public static final String MMSPROXY = "mmsproxy";
-
- public static final String MMSPORT = "mmsport";
-
- public static final String SERVER = "server";
-
- public static final String USER = "user";
-
- public static final String PASSWORD = "password";
-
- public static final String MMSC = "mmsc";
-
- public static final String MCC = "mcc";
-
- public static final String MNC = "mnc";
-
- public static final String NUMERIC = "numeric";
-
- public static final String AUTH_TYPE = "authtype";
-
- public static final String TYPE = "type";
-
- public static final String CURRENT = "current";
- }
-
- public static final class Intents {
- private Intents() {
- // Not instantiable
- }
-
- /**
- * Broadcast Action: A "secret code" has been entered in the dialer. Secret codes are
- * of the form *#*#<code>#*#*. The intent will have the data URI:</p>
- *
- * <p><code>android_secret_code://<code></code></p>
- */
- public static final String SECRET_CODE_ACTION =
- "android.provider.Telephony.SECRET_CODE";
-
- /**
- * Broadcast Action: The Service Provider string(s) have been updated. Activities or
- * services that use these strings should update their display.
- * The intent will have the following extra values:</p>
- * <ul>
- * <li><em>showPlmn</em> - Boolean that indicates whether the PLMN should be shown.</li>
- * <li><em>plmn</em> - The operator name of the registered network, as a string.</li>
- * <li><em>showSpn</em> - Boolean that indicates whether the SPN should be shown.</li>
- * <li><em>spn</em> - The service provider name, as a string.</li>
- * </ul>
- * Note that <em>showPlmn</em> may indicate that <em>plmn</em> should be displayed, even
- * though the value for <em>plmn</em> is null. This can happen, for example, if the phone
- * has not registered to a network yet. In this case the receiver may substitute an
- * appropriate placeholder string (eg, "No service").
- *
- * It is recommended to display <em>plmn</em> before / above <em>spn</em> if
- * both are displayed.
- *
- * <p>Note this is a protected intent that can only be sent
- * by the system.
- */
- public static final String SPN_STRINGS_UPDATED_ACTION =
- "android.provider.Telephony.SPN_STRINGS_UPDATED";
-
- public static final String EXTRA_SHOW_PLMN = "showPlmn";
- public static final String EXTRA_PLMN = "plmn";
- public static final String EXTRA_SHOW_SPN = "showSpn";
- public static final String EXTRA_SPN = "spn";
- }
-}
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index 1e9c312..bd131e0 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -60,7 +60,7 @@
<!-- user interface sound effects -->
<integer name="def_power_sounds_enabled">1</integer>
- <string name="def_low_battery_sound" translatable="false">/system/media/ui/LowBattery.ogg</string>
+ <string name="def_low_battery_sound" translatable="false">/system/media/audio/ui/LowBattery.ogg</string>
<integer name="def_dock_sounds_enabled">0</integer>
<string name="def_desk_dock_sound" translatable="false">/system/media/audio/ui/Dock.ogg</string>
<string name="def_desk_undock_sound" translatable="false">/system/media/audio/ui/Undock.ogg</string>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 18e247e..bccf7d2 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -38,6 +38,7 @@
import android.os.Environment;
import android.os.SystemProperties;
import android.provider.Settings;
+import android.provider.Settings.Secure;
import android.speech.RecognitionService;
import android.speech.RecognizerIntent;
import android.text.TextUtils;
@@ -76,7 +77,7 @@
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
// is properly propagated through your change. Not doing so will result in a loss of user
// settings.
- private static final int DATABASE_VERSION = 51;
+ private static final int DATABASE_VERSION = 52;
private Context mContext;
@@ -232,18 +233,7 @@
}
if (upgradeVersion == 27) {
- // Copy settings values from 'system' to 'secure' and delete them from 'system'
- SQLiteStatement insertStmt = null;
- SQLiteStatement deleteStmt = null;
-
- db.beginTransaction();
- try {
- insertStmt =
- db.compileStatement("INSERT INTO secure (name,value) SELECT name,value FROM "
- + "system WHERE name=?");
- deleteStmt = db.compileStatement("DELETE FROM system WHERE name=?");
-
- String[] settingsToMove = {
+ String[] settingsToMove = {
Settings.Secure.ADB_ENABLED,
Settings.Secure.ANDROID_ID,
Settings.Secure.BLUETOOTH_ON,
@@ -276,24 +266,7 @@
Settings.Secure.WIFI_WATCHDOG_PING_DELAY_MS,
Settings.Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS,
};
-
- for (String setting : settingsToMove) {
- insertStmt.bindString(1, setting);
- insertStmt.execute();
-
- deleteStmt.bindString(1, setting);
- deleteStmt.execute();
- }
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- if (insertStmt != null) {
- insertStmt.close();
- }
- if (deleteStmt != null) {
- deleteStmt.close();
- }
- }
+ moveFromSystemToSecure(db, settingsToMove);
upgradeVersion = 28;
}
@@ -661,6 +634,23 @@
upgradeVersion = 51;
}
+ if (upgradeVersion == 51) {
+ /* Move the lockscreen related settings to Secure, including some private ones. */
+ String[] settingsToMove = {
+ Secure.LOCK_PATTERN_ENABLED,
+ Secure.LOCK_PATTERN_VISIBLE,
+ Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED,
+ "lockscreen.password_type",
+ "lockscreen.lockoutattemptdeadline",
+ "lockscreen.patterneverchosen",
+ "lock_pattern_autolock",
+ "lockscreen.lockedoutpermanently",
+ "lockscreen.password_salt"
+ };
+ moveFromSystemToSecure(db, settingsToMove);
+ upgradeVersion = 52;
+ }
+
if (upgradeVersion != currentVersion) {
Log.w(TAG, "Got stuck trying to upgrade from version " + upgradeVersion
+ ", must wipe the settings provider");
@@ -684,6 +674,38 @@
}
}
+ private void moveFromSystemToSecure(SQLiteDatabase db, String [] settingsToMove) {
+ // Copy settings values from 'system' to 'secure' and delete them from 'system'
+ SQLiteStatement insertStmt = null;
+ SQLiteStatement deleteStmt = null;
+
+ db.beginTransaction();
+ try {
+ insertStmt =
+ db.compileStatement("INSERT INTO secure (name,value) SELECT name,value FROM "
+ + "system WHERE name=?");
+ deleteStmt = db.compileStatement("DELETE FROM system WHERE name=?");
+
+
+ for (String setting : settingsToMove) {
+ insertStmt.bindString(1, setting);
+ insertStmt.execute();
+
+ deleteStmt.bindString(1, setting);
+ deleteStmt.execute();
+ }
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ if (insertStmt != null) {
+ insertStmt.close();
+ }
+ if (deleteStmt != null) {
+ deleteStmt.close();
+ }
+ }
+ }
+
private void upgradeLockPatternLocation(SQLiteDatabase db) {
Cursor c = db.query("system", new String[] {"_id", "value"}, "name='lock_pattern'",
null, null, null, null);
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index 8d00deb..7aa092a 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -765,7 +765,9 @@
pw.println(prefix + "mMinTime=" + mMinTime + " mMinDistance=" + mMinDistance);
pw.println(prefix + "mUid=" + mUid);
pw.println(prefix + "mLastFixBroadcast:");
- mLastFixBroadcast.dump(new PrintWriterPrinter(pw), prefix + " ");
+ if (mLastFixBroadcast != null) {
+ mLastFixBroadcast.dump(new PrintWriterPrinter(pw), prefix + " ");
+ }
pw.println(prefix + "mLastStatusBroadcast=" + mLastStatusBroadcast);
}
}
@@ -1954,6 +1956,13 @@
i.getValue().dump(pw, " ");
}
}
+ for (LocationProviderInterface provider: mProviders) {
+ String state = provider.getInternalState();
+ if (state != null) {
+ pw.println(provider.getName() + " Internal State:");
+ pw.write(state);
+ }
+ }
}
}
}
diff --git a/services/java/com/android/server/UiModeManagerService.java b/services/java/com/android/server/UiModeManagerService.java
index 71826ff..5f23a90 100644
--- a/services/java/com/android/server/UiModeManagerService.java
+++ b/services/java/com/android/server/UiModeManagerService.java
@@ -347,11 +347,13 @@
}
}
if (mKeyguardLock != null) {
+ long ident = Binder.clearCallingIdentity();
if (enabled) {
mKeyguardLock.disableKeyguard();
} else {
mKeyguardLock.reenableKeyguard();
}
+ Binder.restoreCallingIdentity(ident);
}
}
}
diff --git a/telephony/java/com/android/internal/telephony/MccTable.java b/telephony/java/com/android/internal/telephony/MccTable.java
index 7f62169..b73c2f7 100644
--- a/telephony/java/com/android/internal/telephony/MccTable.java
+++ b/telephony/java/com/android/internal/telephony/MccTable.java
@@ -107,7 +107,7 @@
(294, 'mk', 2, 'The Former Yugoslav Republic of Macedonia'),
(295, 'li', 2, 'Liechtenstein (Principality of)'),
(297, 'me', 2, 'Montenegro (Republic of)'),
- (302, 'ca', 2, '', '', 11, 'Canada'),
+ (302, 'ca', 3, '', '', 11, 'Canada'),
(308, 'pm', 2, 'Saint Pierre and Miquelon (Collectivit territoriale de la Rpublique franaise)'),
(310, 'us', 3, '', 'en', 11, 'United States of America'),
(311, 'us', 3, '', 'en', 11, 'United States of America'),
@@ -454,7 +454,7 @@
0x6d640400, 0x706c04f0, 0x64656c72, 0x67690400, 0x70740400, 0x6c750400,
0x69650483, 0x69730400, 0x616c0400, 0x6d740400, 0x63790400, 0x67650400,
0x616d0400, 0x62670400, 0x74720400, 0x666f0400, 0x67650400, 0x676c0400,
- 0x736d0400, 0x736c0400, 0x6d6b0400, 0x6c690400, 0x6d650400, 0x63615c00,
+ 0x736d0400, 0x736c0400, 0x6d6b0400, 0x6c690400, 0x6d650400, 0x63615e00,
0x706d0400, 0x75735e03, 0x75735e03, 0x75735e03, 0x75735e03, 0x75735e03,
0x75735e03, 0x75735e03, 0x70720400, 0x76690400, 0x6d780600, 0x6a6d0600,
0x67700400, 0x62620600, 0x61670600, 0x6b790600, 0x76670600, 0x626d0400,