Merge "MTP host: Add support for reading files from an MTP device via ParcelFileDescriptor"
diff --git a/api/current.xml b/api/current.xml
index 96ca9e9..52b7217 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -63391,6 +63391,17 @@
visibility="public"
>
</method>
+<method name="executeUpdateDelete"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="simpleQueryForLong"
return="long"
abstract="false"
diff --git a/core/java/android/app/ApplicationErrorReport.java b/core/java/android/app/ApplicationErrorReport.java
index 48cbd46..ddc2b1f 100644
--- a/core/java/android/app/ApplicationErrorReport.java
+++ b/core/java/android/app/ApplicationErrorReport.java
@@ -79,6 +79,11 @@
public static final int TYPE_STRICT_MODE_VIOLATION = 4;
/**
+ * An error report about a StrictMode violation.
+ */
+ public static final int TYPE_RUNNING_SERVICE = 5;
+
+ /**
* Type of this report. Can be one of {@link #TYPE_NONE},
* {@link #TYPE_CRASH}, {@link #TYPE_ANR}, or {@link #TYPE_BATTERY}.
*/
@@ -130,6 +135,12 @@
public BatteryInfo batteryInfo;
/**
+ * If this report is of type {@link #TYPE_RUNNING_SERVICE}, contains an instance
+ * of RunningServiceInfo; otherwise null.
+ */
+ public RunningServiceInfo runningServiceInfo;
+
+ /**
* Create an uninitialized instance of {@link ApplicationErrorReport}.
*/
public ApplicationErrorReport() {
@@ -223,6 +234,9 @@
case TYPE_BATTERY:
batteryInfo.writeToParcel(dest, flags);
break;
+ case TYPE_RUNNING_SERVICE:
+ runningServiceInfo.writeToParcel(dest, flags);
+ break;
}
}
@@ -239,16 +253,25 @@
crashInfo = new CrashInfo(in);
anrInfo = null;
batteryInfo = null;
+ runningServiceInfo = null;
break;
case TYPE_ANR:
anrInfo = new AnrInfo(in);
crashInfo = null;
batteryInfo = null;
+ runningServiceInfo = null;
break;
case TYPE_BATTERY:
batteryInfo = new BatteryInfo(in);
anrInfo = null;
crashInfo = null;
+ runningServiceInfo = null;
+ break;
+ case TYPE_RUNNING_SERVICE:
+ batteryInfo = null;
+ anrInfo = null;
+ crashInfo = null;
+ runningServiceInfo = new RunningServiceInfo(in);
break;
}
}
@@ -494,6 +517,51 @@
}
}
+ /**
+ * Describes a running service report.
+ */
+ public static class RunningServiceInfo {
+ /**
+ * Duration in milliseconds that the service has been running.
+ */
+ public long durationMillis;
+
+ /**
+ * Dump of debug information about the service.
+ */
+ public String serviceDetails;
+
+ /**
+ * Create an uninitialized instance of RunningServiceInfo.
+ */
+ public RunningServiceInfo() {
+ }
+
+ /**
+ * Create an instance of RunningServiceInfo initialized from a Parcel.
+ */
+ public RunningServiceInfo(Parcel in) {
+ durationMillis = in.readLong();
+ serviceDetails = in.readString();
+ }
+
+ /**
+ * Save a RunningServiceInfo instance to a parcel.
+ */
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeLong(durationMillis);
+ dest.writeString(serviceDetails);
+ }
+
+ /**
+ * Dump a BatteryInfo instance to a Printer.
+ */
+ public void dump(Printer pw, String prefix) {
+ pw.println(prefix + "durationMillis: " + durationMillis);
+ pw.println(prefix + "serviceDetails: " + serviceDetails);
+ }
+ }
+
public static final Parcelable.Creator<ApplicationErrorReport> CREATOR
= new Parcelable.Creator<ApplicationErrorReport>() {
public ApplicationErrorReport createFromParcel(Parcel source) {
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 6098617..8e93855 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2792,6 +2792,9 @@
// For use by package manager to keep track of where it has done dexopt.
public boolean mDidDexOpt;
+ // User set enabled state.
+ public int mSetEnabled = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
+
// Additional data supplied by callers.
public Object mExtras;
@@ -3018,6 +3021,12 @@
}
private static boolean copyNeeded(int flags, Package p, Bundle metaData) {
+ if (p.mSetEnabled != PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) {
+ boolean enabled = p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
+ if (p.applicationInfo.enabled != enabled) {
+ return true;
+ }
+ }
if ((flags & PackageManager.GET_META_DATA) != 0
&& (metaData != null || p.mAppMetaData != null)) {
return true;
@@ -3051,6 +3060,7 @@
if (!sCompatibilityModeEnabled) {
ai.disableCompatibilityMode();
}
+ ai.enabled = p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
return ai;
}
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java
index cf4d07f..623821b 100644
--- a/core/java/android/database/sqlite/SQLiteDatabase.java
+++ b/core/java/android/database/sqlite/SQLiteDatabase.java
@@ -67,7 +67,7 @@
* is the Unicode Collation Algorithm and not tailored to the current locale.
*/
public class SQLiteDatabase extends SQLiteClosable {
- private static final String TAG = "Database";
+ private static final String TAG = "SQLiteDatabase";
private static final int EVENT_DB_OPERATION = 52000;
private static final int EVENT_DB_CORRUPT = 75004;
@@ -1641,18 +1641,7 @@
}
// Run the program and then cleanup
- statement.execute();
-
- long insertedRowId = lastInsertRow();
- if (insertedRowId == -1) {
- Log.e(TAG, "Error inserting " + initialValues + " using " + sql);
- } else {
- if (Config.LOGD && Log.isLoggable(TAG, Log.VERBOSE)) {
- Log.v(TAG, "Inserting row " + insertedRowId + " from "
- + initialValues + " using " + sql);
- }
- }
- return insertedRowId;
+ return statement.executeInsert();
} catch (SQLiteDatabaseCorruptException e) {
onCorruption();
throw e;
@@ -1689,8 +1678,7 @@
DatabaseUtils.bindObjectToProgram(statement, i + 1, whereArgs[i]);
}
}
- statement.execute();
- return lastChangeCount();
+ return statement.executeUpdateDelete();
} catch (SQLiteDatabaseCorruptException e) {
onCorruption();
throw e;
@@ -1782,12 +1770,7 @@
}
// Run the program and then cleanup
- statement.execute();
- int numChangedRows = lastChangeCount();
- if (Config.LOGD && Log.isLoggable(TAG, Log.VERBOSE)) {
- Log.v(TAG, "Updated " + numChangedRows + " using " + values + " and " + sql);
- }
- return numChangedRows;
+ return statement.executeUpdateDelete();
} catch (SQLiteDatabaseCorruptException e) {
onCorruption();
throw e;
@@ -1834,13 +1817,18 @@
long timeStart = SystemClock.uptimeMillis();
lock();
logTimeStat(mLastSqlStatement, timeStart, GET_LOCK_LOG_PREFIX);
+ SQLiteStatement stmt = null;
try {
closePendingStatements();
- native_execSQL(sql);
+ stmt = compileStatement(sql);
+ stmt.execute();
} catch (SQLiteDatabaseCorruptException e) {
onCorruption();
throw e;
} finally {
+ if (stmt != null) {
+ stmt.close();
+ }
unlock();
}
@@ -1914,7 +1902,7 @@
DatabaseUtils.bindObjectToProgram(statement, i + 1, bindArgs[i]);
}
}
- statement.execute();
+ statement.executeUpdateDelete();
} catch (SQLiteDatabaseCorruptException e) {
onCorruption();
throw e;
@@ -2025,7 +2013,7 @@
}
if (durationMillis >= sQueryLogTimeInMillis) {
samplePercent = 100;
- } else {;
+ } else {
samplePercent = (int) (100 * durationMillis / sQueryLogTimeInMillis) + 1;
if (mRandom.nextInt(100) >= samplePercent) return;
}
@@ -2628,15 +2616,6 @@
private native void enableSqlProfiling(String path, short connectionNum);
/**
- * Native call to execute a raw SQL statement. {@link #lock} must be held
- * when calling this method.
- *
- * @param sql The raw SQL string
- * @throws SQLException
- */
- /* package */ native void native_execSQL(String sql) throws SQLException;
-
- /**
* Native call to set the locale. {@link #lock} must be held when calling
* this method.
* @throws SQLException
@@ -2644,20 +2623,6 @@
/* package */ native void native_setLocale(String loc, int flags);
/**
- * Returns the row ID of the last row inserted into the database.
- *
- * @return the row ID of the last row inserted into the database.
- */
- /* package */ native long lastInsertRow();
-
- /**
- * Returns the number of changes made in the last statement executed.
- *
- * @return the number of changes made in the last statement executed.
- */
- /* package */ native int lastChangeCount();
-
- /**
* return the SQLITE_DBSTATUS_LOOKASIDE_USED documented here
* http://www.sqlite.org/c3ref/c_dbstatus_lookaside_used.html
* @return int value of SQLITE_DBSTATUS_LOOKASIDE_USED
diff --git a/core/java/android/database/sqlite/SQLiteStatement.java b/core/java/android/database/sqlite/SQLiteStatement.java
index b902803..7a683e4 100644
--- a/core/java/android/database/sqlite/SQLiteStatement.java
+++ b/core/java/android/database/sqlite/SQLiteStatement.java
@@ -48,18 +48,31 @@
}
/**
- * Execute this SQL statement, if it is not a query. For example,
- * CREATE TABLE, DELTE, INSERT, etc.
+ * Execute this SQL statement, if it is not a SELECT / INSERT / DELETE / UPDATE, for example
+ * CREATE / DROP table, view, trigger, index etc.
*
* @throws android.database.SQLException If the SQL string is invalid for
* some reason
*/
public void execute() {
+ executeUpdateDelete();
+ }
+
+ /**
+ * Execute this SQL statement, if the the number of rows affected by exection of this SQL
+ * statement is of any importance to the caller - for example, UPDATE / DELETE SQL statements.
+ *
+ * @return the number of rows affected by this SQL statement execution.
+ * @throws android.database.SQLException If the SQL string is invalid for
+ * some reason
+ */
+ public int executeUpdateDelete() {
synchronized(this) {
long timeStart = acquireAndLock(WRITE);
try {
- native_execute();
+ int numChanges = native_execute();
mDatabase.logTimeStat(mSql, timeStart);
+ return numChanges;
} finally {
releaseAndUnlock();
}
@@ -79,9 +92,9 @@
synchronized(this) {
long timeStart = acquireAndLock(WRITE);
try {
- native_execute();
+ long lastInsertedRowId = native_executeInsert();
mDatabase.logTimeStat(mSql, timeStart);
- return (mDatabase.lastChangeCount() > 0) ? mDatabase.lastInsertRow() : -1;
+ return lastInsertedRowId;
} finally {
releaseAndUnlock();
}
@@ -182,7 +195,8 @@
nHandle = mDatabase.mNativeHandle;
}
- private final native void native_execute();
+ private final native int native_execute();
+ private final native long native_executeInsert();
private final native long native_1x1_long();
private final native String native_1x1_string();
}
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 0afd6cd..a699388 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -106,7 +106,7 @@
// NOTE: Update this list if you add/change any stats above.
// These characters are supposed to represent "total", "last", "current",
- // and "unplugged". They were shortened for effeciency sake.
+ // and "unplugged". They were shortened for efficiency sake.
private static final String[] STAT_NAMES = { "t", "l", "c", "u" };
/**
@@ -395,19 +395,23 @@
public char batteryTemperature;
public char batteryVoltage;
+ // Constants from SCREEN_BRIGHTNESS_*
public static final int STATE_BRIGHTNESS_MASK = 0x000000f;
public static final int STATE_BRIGHTNESS_SHIFT = 0;
+ // Constants from SIGNAL_STRENGTH_*
public static final int STATE_SIGNAL_STRENGTH_MASK = 0x00000f0;
public static final int STATE_SIGNAL_STRENGTH_SHIFT = 4;
+ // Constants from ServiceState.STATE_*
public static final int STATE_PHONE_STATE_MASK = 0x0000f00;
public static final int STATE_PHONE_STATE_SHIFT = 8;
+ // Constants from DATA_CONNECTION_*
public static final int STATE_DATA_CONNECTION_MASK = 0x000f000;
public static final int STATE_DATA_CONNECTION_SHIFT = 12;
public static final int STATE_BATTERY_PLUGGED_FLAG = 1<<30;
public static final int STATE_SCREEN_ON_FLAG = 1<<29;
public static final int STATE_GPS_ON_FLAG = 1<<28;
- public static final int STATE_PHONE_ON_FLAG = 1<<27;
+ public static final int STATE_PHONE_IN_CALL_FLAG = 1<<27;
public static final int STATE_PHONE_SCANNING_FLAG = 1<<26;
public static final int STATE_WIFI_ON_FLAG = 1<<25;
public static final int STATE_WIFI_RUNNING_FLAG = 1<<24;
@@ -619,7 +623,7 @@
new BitDescription(HistoryItem.STATE_BATTERY_PLUGGED_FLAG, "plugged"),
new BitDescription(HistoryItem.STATE_SCREEN_ON_FLAG, "screen"),
new BitDescription(HistoryItem.STATE_GPS_ON_FLAG, "gps"),
- new BitDescription(HistoryItem.STATE_PHONE_ON_FLAG, "phone"),
+ new BitDescription(HistoryItem.STATE_PHONE_IN_CALL_FLAG, "phone_in_call"),
new BitDescription(HistoryItem.STATE_PHONE_SCANNING_FLAG, "phone_scanning"),
new BitDescription(HistoryItem.STATE_WIFI_ON_FLAG, "wifi"),
new BitDescription(HistoryItem.STATE_WIFI_RUNNING_FLAG, "wifi_running"),
@@ -717,6 +721,18 @@
public abstract int getDischargeCurrentLevel();
/**
+ * Get the amount the battery has discharged since the stats were
+ * last reset after charging, as a lower-end approximation.
+ */
+ public abstract int getLowDischargeAmountSinceCharge();
+
+ /**
+ * Get the amount the battery has discharged since the stats were
+ * last reset after charging, as an upper-end approximation.
+ */
+ public abstract int getHighDischargeAmountSinceCharge();
+
+ /**
* Returns the total, last, or current battery uptime in microseconds.
*
* @param curTime the elapsed realtime in microseconds.
diff --git a/core/java/android/provider/Downloads.java b/core/java/android/provider/Downloads.java
index 7e1d685..1b37107 100644
--- a/core/java/android/provider/Downloads.java
+++ b/core/java/android/provider/Downloads.java
@@ -624,6 +624,13 @@
"android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS";
/**
+ * The permission to downloads files to the cache partition that won't be automatically
+ * purged when space is needed.
+ */
+ public static final String PERMISSION_CACHE_NON_PURGEABLE =
+ "android.permission.DOWNLOAD_CACHE_NON_PURGEABLE";
+
+ /**
* The content:// URI for the data table in the provider
*/
public static final Uri CONTENT_URI =
diff --git a/core/java/com/android/internal/app/IBatteryStats.aidl b/core/java/com/android/internal/app/IBatteryStats.aidl
index 88ef395..d040d3f 100644
--- a/core/java/com/android/internal/app/IBatteryStats.aidl
+++ b/core/java/com/android/internal/app/IBatteryStats.aidl
@@ -24,8 +24,15 @@
byte[] getStatistics();
void noteStartWakelock(int uid, String name, int type);
void noteStopWakelock(int uid, String name, int type);
+
+ /* DO NOT CHANGE the position of noteStartSensor without updating
+ SensorService.cpp */
void noteStartSensor(int uid, int sensor);
+
+ /* DO NOT CHANGE the position of noteStopSensor without updating
+ SensorService.cpp */
void noteStopSensor(int uid, int sensor);
+
void noteStartGps(int uid);
void noteStopGps(int uid);
void noteScreenOn();
diff --git a/core/java/com/android/internal/app/ShutdownThread.java b/core/java/com/android/internal/app/ShutdownThread.java
index a96253b..d1aff2a 100644
--- a/core/java/com/android/internal/app/ShutdownThread.java
+++ b/core/java/com/android/internal/app/ShutdownThread.java
@@ -84,7 +84,7 @@
public static void shutdown(final Context context, boolean confirm) {
// ensure that only one thread is trying to power down.
// any additional calls are just returned
- synchronized (sIsStartedGuard){
+ synchronized (sIsStartedGuard) {
if (sIsStarted) {
Log.d(TAG, "Request to shutdown already running, returning.");
return;
@@ -133,6 +133,10 @@
private static void beginShutdownSequence(Context context) {
synchronized (sIsStartedGuard) {
+ if (sIsStarted) {
+ Log.d(TAG, "Request to shutdown already running, returning.");
+ return;
+ }
sIsStarted = true;
}
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 642c313..b3323e9 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -63,7 +63,7 @@
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
// Current on-disk Parcel version
- private static final int VERSION = 48;
+ private static final int VERSION = 49;
// Maximum number of items we will record in the history.
private static final int MAX_HISTORY_ITEMS = 1000;
@@ -184,6 +184,8 @@
int mDischargeStartLevel;
int mDischargeUnplugLevel;
int mDischargeCurrentLevel;
+ int mLowDischargeAmountSinceCharge;
+ int mHighDischargeAmountSinceCharge;
long mLastWriteTime = 0; // Milliseconds
@@ -260,7 +262,7 @@
mPluggedCount = in.readInt();
mCount.set(mPluggedCount);
mLoadedCount = in.readInt();
- mLastCount = in.readInt();
+ mLastCount = 0;
mUnpluggedCount = in.readInt();
unpluggables.add(this);
}
@@ -273,7 +275,6 @@
public void writeToParcel(Parcel out) {
out.writeInt(mCount.get());
out.writeInt(mLoadedCount);
- out.writeInt(mLastCount);
out.writeInt(mUnpluggedCount);
}
@@ -348,13 +349,12 @@
void writeSummaryFromParcelLocked(Parcel out) {
int count = mCount.get();
out.writeInt(count);
- out.writeInt(count - mLoadedCount);
}
void readSummaryFromParcelLocked(Parcel in) {
mLoadedCount = in.readInt();
mCount.set(mLoadedCount);
- mLastCount = in.readInt();
+ mLastCount = 0;
mUnpluggedCount = mPluggedCount = mLoadedCount;
}
}
@@ -428,11 +428,11 @@
mCount = in.readInt();
mLoadedCount = in.readInt();
- mLastCount = in.readInt();
+ mLastCount = 0;
mUnpluggedCount = in.readInt();
mTotalTime = in.readLong();
mLoadedTime = in.readLong();
- mLastTime = in.readLong();
+ mLastTime = 0;
mUnpluggedTime = in.readLong();
unpluggables.add(this);
}
@@ -467,11 +467,9 @@
public void writeToParcel(Parcel out, long batteryRealtime) {
out.writeInt(mCount);
out.writeInt(mLoadedCount);
- out.writeInt(mLastCount);
out.writeInt(mUnpluggedCount);
out.writeLong(computeRunTimeLocked(batteryRealtime));
out.writeLong(mLoadedTime);
- out.writeLong(mLastTime);
out.writeLong(mUnpluggedTime);
}
@@ -569,18 +567,16 @@
long runTime = computeRunTimeLocked(batteryRealtime);
// Divide by 1000 for backwards compatibility
out.writeLong((runTime + 500) / 1000);
- out.writeLong(((runTime - mLoadedTime) + 500) / 1000);
out.writeInt(mCount);
- out.writeInt(mCount - mLoadedCount);
}
void readSummaryFromParcelLocked(Parcel in) {
// Multiply by 1000 for backwards compatibility
mTotalTime = mLoadedTime = in.readLong() * 1000;
- mLastTime = in.readLong() * 1000;
+ mLastTime = 0;
mUnpluggedTime = mTotalTime;
mCount = mLoadedCount = in.readInt();
- mLastCount = in.readInt();
+ mLastCount = 0;
mUnpluggedCount = mCount;
}
}
@@ -1243,7 +1239,6 @@
if (DEBUG_HISTORY) Slog.v(TAG, "Screen on to: "
+ Integer.toHexString(mHistoryCur.states));
addHistoryRecordLocked(SystemClock.elapsedRealtime());
- mGpsNesting++;
mScreenOn = true;
mScreenOnTimer.startRunningLocked(this);
if (mScreenBrightnessBin >= 0) {
@@ -1297,7 +1292,7 @@
public void notePhoneOnLocked() {
if (!mPhoneOn) {
- mHistoryCur.states |= HistoryItem.STATE_PHONE_ON_FLAG;
+ mHistoryCur.states |= HistoryItem.STATE_PHONE_IN_CALL_FLAG;
if (DEBUG_HISTORY) Slog.v(TAG, "Phone on to: "
+ Integer.toHexString(mHistoryCur.states));
addHistoryRecordLocked(SystemClock.elapsedRealtime());
@@ -1308,7 +1303,7 @@
public void notePhoneOffLocked() {
if (mPhoneOn) {
- mHistoryCur.states &= ~HistoryItem.STATE_PHONE_ON_FLAG;
+ mHistoryCur.states &= ~HistoryItem.STATE_PHONE_IN_CALL_FLAG;
if (DEBUG_HISTORY) Slog.v(TAG, "Phone off to: "
+ Integer.toHexString(mHistoryCur.states));
addHistoryRecordLocked(SystemClock.elapsedRealtime());
@@ -1317,38 +1312,43 @@
}
}
+ void stopAllSignalStrengthTimersLocked(int except) {
+ for (int i = 0; i < NUM_SIGNAL_STRENGTH_BINS; i++) {
+ if (i == except) {
+ continue;
+ }
+ while (mPhoneSignalStrengthsTimer[i].isRunningLocked()) {
+ mPhoneSignalStrengthsTimer[i].stopRunningLocked(this);
+ }
+ }
+ }
+
/**
* Telephony stack updates the phone state.
* @param state phone state from ServiceState.getState()
*/
public void notePhoneStateLocked(int state) {
+ boolean scanning = false;
+
int bin = mPhoneSignalStrengthBin;
- boolean isAirplaneMode = state == ServiceState.STATE_POWER_OFF;
- // Stop all timers
- if (isAirplaneMode || state == ServiceState.STATE_OUT_OF_SERVICE) {
- for (int i = 0; i < NUM_SIGNAL_STRENGTH_BINS; i++) {
- while (mPhoneSignalStrengthsTimer[i].isRunningLocked()) {
- mPhoneSignalStrengthsTimer[i].stopRunningLocked(this);
- }
- }
- }
- // Stop Signal Scanning timer, in case we're going into service
- if (mPhoneSignalScanningTimer.isRunningLocked()) {
- mHistoryCur.states &= ~HistoryItem.STATE_PHONE_SCANNING_FLAG;
- if (DEBUG_HISTORY) Slog.v(TAG, "Phone stopped scanning to: "
- + Integer.toHexString(mHistoryCur.states));
- addHistoryRecordLocked(SystemClock.elapsedRealtime());
- mPhoneSignalScanningTimer.stopRunningLocked(this);
- }
+
+ // If the phone is powered off, stop all timers.
+ if (state == ServiceState.STATE_POWER_OFF) {
+ stopAllSignalStrengthTimersLocked(-1);
// If we're back in service or continuing in service, restart the old timer.
- if (state == ServiceState.STATE_IN_SERVICE) {
+ } if (state == ServiceState.STATE_IN_SERVICE) {
if (bin == -1) bin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
if (!mPhoneSignalStrengthsTimer[bin].isRunningLocked()) {
mPhoneSignalStrengthsTimer[bin].startRunningLocked(this);
}
+
+ // If we're out of service, we are in the lowest signal strength
+ // bin and have the scanning bit set.
} else if (state == ServiceState.STATE_OUT_OF_SERVICE) {
+ scanning = true;
mPhoneSignalStrengthBin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
+ stopAllSignalStrengthTimersLocked(mPhoneSignalStrengthBin);
if (!mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].isRunningLocked()) {
mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].startRunningLocked(this);
}
@@ -1361,6 +1361,17 @@
}
}
+ if (!scanning) {
+ // If we are no longer scanning, then stop the scanning timer.
+ if (mPhoneSignalScanningTimer.isRunningLocked()) {
+ mHistoryCur.states &= ~HistoryItem.STATE_PHONE_SCANNING_FLAG;
+ if (DEBUG_HISTORY) Slog.v(TAG, "Phone stopped scanning to: "
+ + Integer.toHexString(mHistoryCur.states));
+ addHistoryRecordLocked(SystemClock.elapsedRealtime());
+ mPhoneSignalScanningTimer.stopRunningLocked(this);
+ }
+ }
+
if (mPhoneServiceState != state) {
mHistoryCur.states = (mHistoryCur.states&~HistoryItem.STATE_PHONE_STATE_MASK)
| (state << HistoryItem.STATE_PHONE_STATE_SHIFT);
@@ -2622,10 +2633,6 @@
out.writeLong(mLoadedSystemTime);
out.writeLong(mLoadedForegroundTime);
out.writeInt(mLoadedStarts);
- out.writeLong(mLastUserTime);
- out.writeLong(mLastSystemTime);
- out.writeLong(mLastForegroundTime);
- out.writeInt(mLastStarts);
out.writeLong(mUnpluggedUserTime);
out.writeLong(mUnpluggedSystemTime);
out.writeLong(mUnpluggedForegroundTime);
@@ -2652,10 +2659,10 @@
mLoadedSystemTime = in.readLong();
mLoadedForegroundTime = in.readLong();
mLoadedStarts = in.readInt();
- mLastUserTime = in.readLong();
- mLastSystemTime = in.readLong();
- mLastForegroundTime = in.readLong();
- mLastStarts = in.readInt();
+ mLastUserTime = 0;
+ mLastSystemTime = 0;
+ mLastForegroundTime = 0;
+ mLastStarts = 0;
mUnpluggedUserTime = in.readLong();
mUnpluggedSystemTime = in.readLong();
mUnpluggedForegroundTime = in.readLong();
@@ -2828,7 +2835,7 @@
void readFromParcelLocked(Parcel in) {
mWakeups = in.readInt();
mLoadedWakeups = in.readInt();
- mLastWakeups = in.readInt();
+ mLastWakeups = 0;
mUnpluggedWakeups = in.readInt();
int numServs = in.readInt();
@@ -2845,7 +2852,6 @@
void writeToParcelLocked(Parcel out) {
out.writeInt(mWakeups);
out.writeInt(mLoadedWakeups);
- out.writeInt(mLastWakeups);
out.writeInt(mUnpluggedWakeups);
out.writeInt(mServiceStats.size());
@@ -3002,9 +3008,9 @@
mLoadedStartTime = in.readLong();
mLoadedStarts = in.readInt();
mLoadedLaunches = in.readInt();
- mLastStartTime = in.readLong();
- mLastStarts = in.readInt();
- mLastLaunches = in.readInt();
+ mLastStartTime = 0;
+ mLastStarts = 0;
+ mLastLaunches = 0;
mUnpluggedStartTime = in.readLong();
mUnpluggedStarts = in.readInt();
mUnpluggedLaunches = in.readInt();
@@ -3022,9 +3028,6 @@
out.writeLong(mLoadedStartTime);
out.writeInt(mLoadedStarts);
out.writeInt(mLoadedLaunches);
- out.writeLong(mLastStartTime);
- out.writeInt(mLastStarts);
- out.writeInt(mLastLaunches);
out.writeLong(mUnpluggedStartTime);
out.writeInt(mUnpluggedStarts);
out.writeInt(mUnpluggedLaunches);
@@ -3336,6 +3339,8 @@
mDischargeStartLevel = 0;
mDischargeUnplugLevel = 0;
mDischargeCurrentLevel = 0;
+ mLowDischargeAmountSinceCharge = 0;
+ mHighDischargeAmountSinceCharge = 0;
}
public BatteryStatsImpl(Parcel p) {
@@ -3434,6 +3439,8 @@
doWrite = true;
resetAllStatsLocked();
mDischargeStartLevel = level;
+ mLowDischargeAmountSinceCharge = 0;
+ mHighDischargeAmountSinceCharge = 0;
}
updateKernelWakelocksLocked();
mHistoryCur.batteryLevel = (byte)level;
@@ -3457,6 +3464,10 @@
mTrackBatteryPastUptime += uptime - mTrackBatteryUptimeStart;
mTrackBatteryPastRealtime += realtime - mTrackBatteryRealtimeStart;
mDischargeCurrentLevel = level;
+ if (level < mDischargeUnplugLevel) {
+ mLowDischargeAmountSinceCharge = mDischargeUnplugLevel-level-1;
+ mHighDischargeAmountSinceCharge = mDischargeUnplugLevel-level;
+ }
doPlugLocked(getBatteryUptimeLocked(uptime), getBatteryRealtimeLocked(realtime));
}
if (doWrite || (mLastWriteTime + (60 * 1000)) < mSecRealtime) {
@@ -3723,6 +3734,20 @@
}
@Override
+ public int getLowDischargeAmountSinceCharge() {
+ synchronized(this) {
+ return mLowDischargeAmountSinceCharge;
+ }
+ }
+
+ @Override
+ public int getHighDischargeAmountSinceCharge() {
+ synchronized(this) {
+ return mHighDischargeAmountSinceCharge;
+ }
+ }
+
+ @Override
public int getCpuSpeedSteps() {
return sNumSpeedSteps;
}
@@ -3926,15 +3951,13 @@
mStartCount = in.readInt();
mBatteryUptime = in.readLong();
- mBatteryLastUptime = in.readLong();
mBatteryRealtime = in.readLong();
- mBatteryLastRealtime = in.readLong();
mUptime = in.readLong();
- mLastUptime = in.readLong();
mRealtime = in.readLong();
- mLastRealtime = in.readLong();
mDischargeUnplugLevel = in.readInt();
mDischargeCurrentLevel = in.readInt();
+ mLowDischargeAmountSinceCharge = in.readInt();
+ mHighDischargeAmountSinceCharge = in.readInt();
mStartCount++;
@@ -4058,11 +4081,8 @@
String procName = in.readString();
Uid.Proc p = u.getProcessStatsLocked(procName);
p.mUserTime = p.mLoadedUserTime = in.readLong();
- p.mLastUserTime = in.readLong();
p.mSystemTime = p.mLoadedSystemTime = in.readLong();
- p.mLastSystemTime = in.readLong();
p.mStarts = p.mLoadedStarts = in.readInt();
- p.mLastStarts = in.readInt();
}
NP = in.readInt();
@@ -4074,17 +4094,13 @@
String pkgName = in.readString();
Uid.Pkg p = u.getPackageStatsLocked(pkgName);
p.mWakeups = p.mLoadedWakeups = in.readInt();
- p.mLastWakeups = in.readInt();
final int NS = in.readInt();
for (int is = 0; is < NS; is++) {
String servName = in.readString();
Uid.Pkg.Serv s = u.getServiceStatsLocked(pkgName, servName);
s.mStartTime = s.mLoadedStartTime = in.readLong();
- s.mLastStartTime = in.readLong();
s.mStarts = s.mLoadedStarts = in.readInt();
- s.mLastStarts = in.readInt();
s.mLaunches = s.mLoadedLaunches = in.readInt();
- s.mLastLaunches = in.readInt();
}
}
@@ -4111,16 +4127,13 @@
out.writeInt(mStartCount);
out.writeLong(computeBatteryUptime(NOW_SYS, STATS_SINCE_CHARGED));
- out.writeLong(computeBatteryUptime(NOW_SYS, STATS_CURRENT));
out.writeLong(computeBatteryRealtime(NOWREAL_SYS, STATS_SINCE_CHARGED));
- out.writeLong(computeBatteryRealtime(NOWREAL_SYS, STATS_CURRENT));
out.writeLong(computeUptime(NOW_SYS, STATS_SINCE_CHARGED));
- out.writeLong(computeUptime(NOW_SYS, STATS_CURRENT));
out.writeLong(computeRealtime(NOWREAL_SYS, STATS_SINCE_CHARGED));
- out.writeLong(computeRealtime(NOWREAL_SYS, STATS_CURRENT));
out.writeInt(mDischargeUnplugLevel);
out.writeInt(mDischargeCurrentLevel);
-
+ out.writeInt(mLowDischargeAmountSinceCharge);
+ out.writeInt(mHighDischargeAmountSinceCharge);
mScreenOnTimer.writeSummaryFromParcelLocked(out, NOWREAL);
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
@@ -4256,11 +4269,8 @@
out.writeString(ent.getKey());
Uid.Proc ps = ent.getValue();
out.writeLong(ps.mUserTime);
- out.writeLong(ps.mUserTime - ps.mLoadedUserTime);
out.writeLong(ps.mSystemTime);
- out.writeLong(ps.mSystemTime - ps.mLoadedSystemTime);
out.writeInt(ps.mStarts);
- out.writeInt(ps.mStarts - ps.mLoadedStarts);
}
}
@@ -4272,7 +4282,6 @@
out.writeString(ent.getKey());
Uid.Pkg ps = ent.getValue();
out.writeInt(ps.mWakeups);
- out.writeInt(ps.mWakeups - ps.mLoadedWakeups);
final int NS = ps.mServiceStats.size();
out.writeInt(NS);
if (NS > 0) {
@@ -4282,11 +4291,8 @@
BatteryStatsImpl.Uid.Pkg.Serv ss = sent.getValue();
long time = ss.getStartTimeToNowLocked(NOW);
out.writeLong(time);
- out.writeLong(time - ss.mLoadedStartTime);
out.writeInt(ss.mStarts);
- out.writeInt(ss.mStarts - ss.mLoadedStarts);
out.writeInt(ss.mLaunches);
- out.writeInt(ss.mLaunches - ss.mLoadedLaunches);
}
}
}
@@ -4311,9 +4317,9 @@
mStartCount = in.readInt();
mBatteryUptime = in.readLong();
- mBatteryLastUptime = in.readLong();
+ mBatteryLastUptime = 0;
mBatteryRealtime = in.readLong();
- mBatteryLastRealtime = in.readLong();
+ mBatteryLastRealtime = 0;
mScreenOn = false;
mScreenOnTimer = new StopwatchTimer(-1, null, mUnpluggables, in);
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
@@ -4337,10 +4343,10 @@
mBluetoothOnTimer = new StopwatchTimer(-2, null, mUnpluggables, in);
mUptime = in.readLong();
mUptimeStart = in.readLong();
- mLastUptime = in.readLong();
+ mLastUptime = 0;
mRealtime = in.readLong();
mRealtimeStart = in.readLong();
- mLastRealtime = in.readLong();
+ mLastRealtime = 0;
mOnBattery = in.readInt() != 0;
mOnBatteryInternal = false; // we are no longer really running.
mTrackBatteryPastUptime = in.readLong();
@@ -4351,6 +4357,8 @@
mUnpluggedBatteryRealtime = in.readLong();
mDischargeUnplugLevel = in.readInt();
mDischargeCurrentLevel = in.readInt();
+ mLowDischargeAmountSinceCharge = in.readInt();
+ mHighDischargeAmountSinceCharge = in.readInt();
mLastWriteTime = in.readLong();
mMobileDataRx[STATS_LAST] = in.readLong();
@@ -4396,11 +4404,15 @@
}
public void writeToParcel(Parcel out, int flags) {
- writeToParcelLocked(out, flags);
+ writeToParcelLocked(out, true, flags);
+ }
+
+ public void writeToParcelWithoutUids(Parcel out, int flags) {
+ writeToParcelLocked(out, false, flags);
}
@SuppressWarnings("unused")
- void writeToParcelLocked(Parcel out, int flags) {
+ void writeToParcelLocked(Parcel out, boolean inclUids, int flags) {
final long uSecUptime = SystemClock.uptimeMillis() * 1000;
final long uSecRealtime = SystemClock.elapsedRealtime() * 1000;
final long batteryUptime = getBatteryUptimeLocked(uSecUptime);
@@ -4412,9 +4424,7 @@
out.writeInt(mStartCount);
out.writeLong(mBatteryUptime);
- out.writeLong(mBatteryLastUptime);
out.writeLong(mBatteryRealtime);
- out.writeLong(mBatteryLastRealtime);
mScreenOnTimer.writeToParcel(out, batteryRealtime);
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
mScreenBrightnessTimer[i].writeToParcel(out, batteryRealtime);
@@ -4433,10 +4443,8 @@
mBluetoothOnTimer.writeToParcel(out, batteryRealtime);
out.writeLong(mUptime);
out.writeLong(mUptimeStart);
- out.writeLong(mLastUptime);
out.writeLong(mRealtime);
out.writeLong(mRealtimeStart);
- out.writeLong(mLastRealtime);
out.writeInt(mOnBattery ? 1 : 0);
out.writeLong(batteryUptime);
out.writeLong(mTrackBatteryUptimeStart);
@@ -4446,6 +4454,8 @@
out.writeLong(mUnpluggedBatteryRealtime);
out.writeInt(mDischargeUnplugLevel);
out.writeInt(mDischargeCurrentLevel);
+ out.writeInt(mLowDischargeAmountSinceCharge);
+ out.writeInt(mHighDischargeAmountSinceCharge);
out.writeLong(mLastWriteTime);
out.writeLong(getMobileTcpBytesReceived(STATS_SINCE_UNPLUGGED));
@@ -4458,27 +4468,35 @@
out.writeInt(getBluetoothPingCount());
- out.writeInt(mKernelWakelockStats.size());
- for (Map.Entry<String, SamplingTimer> ent : mKernelWakelockStats.entrySet()) {
- SamplingTimer kwlt = ent.getValue();
- if (kwlt != null) {
- out.writeInt(1);
- out.writeString(ent.getKey());
- Timer.writeTimerToParcel(out, kwlt, batteryRealtime);
- } else {
- out.writeInt(0);
+ if (inclUids) {
+ out.writeInt(mKernelWakelockStats.size());
+ for (Map.Entry<String, SamplingTimer> ent : mKernelWakelockStats.entrySet()) {
+ SamplingTimer kwlt = ent.getValue();
+ if (kwlt != null) {
+ out.writeInt(1);
+ out.writeString(ent.getKey());
+ Timer.writeTimerToParcel(out, kwlt, batteryRealtime);
+ } else {
+ out.writeInt(0);
+ }
}
+ } else {
+ out.writeInt(0);
}
out.writeInt(sNumSpeedSteps);
- int size = mUidStats.size();
- out.writeInt(size);
- for (int i = 0; i < size; i++) {
- out.writeInt(mUidStats.keyAt(i));
- Uid uid = mUidStats.valueAt(i);
+ if (inclUids) {
+ int size = mUidStats.size();
+ out.writeInt(size);
+ for (int i = 0; i < size; i++) {
+ out.writeInt(mUidStats.keyAt(i));
+ Uid uid = mUidStats.valueAt(i);
- uid.writeToParcelLocked(out, batteryRealtime);
+ uid.writeToParcelLocked(out, batteryRealtime);
+ }
+ } else {
+ out.writeInt(0);
}
}
diff --git a/core/jni/android/graphics/TextLayout.cpp b/core/jni/android/graphics/TextLayout.cpp
index 3de2c95..716d960 100644
--- a/core/jni/android/graphics/TextLayout.cpp
+++ b/core/jni/android/graphics/TextLayout.cpp
@@ -151,7 +151,7 @@
}
bool TextLayout::prepareText(SkPaint *paint, const jchar* text, jsize len, jint bidiFlags,
- const jchar** outText, int32_t* outBytes) {
+ const jchar** outText, int32_t* outBytes, jchar** outBuffer) {
const jchar *workText = text;
jchar *buffer = NULL;
int dir = kDirection_LTR;
@@ -196,8 +196,8 @@
*outBytes = (workLimit - workText) << 1;
*outText = workText;
-
- free(buffer);
+ *outBuffer = buffer;
+
return true;
}
@@ -207,8 +207,9 @@
void TextLayout::handleText(SkPaint *paint, const jchar* text, jsize len,
jint bidiFlags, jfloat x, jfloat y,SkCanvas *canvas, SkPath *path) {
const jchar *workText;
+ jchar *buffer = NULL;
int32_t workBytes;
- if (prepareText(paint, text, len, bidiFlags, &workText, &workBytes)) {
+ if (prepareText(paint, text, len, bidiFlags, &workText, &workBytes, &buffer)) {
SkScalar x_ = SkFloatToScalar(x);
SkScalar y_ = SkFloatToScalar(y);
if (canvas) {
@@ -216,6 +217,7 @@
} else {
paint->getTextPath(workText, workBytes, x_, y_, path);
}
+ free(buffer);
}
}
diff --git a/core/jni/android/graphics/TextLayout.h b/core/jni/android/graphics/TextLayout.h
index dc7208a..3d05e18 100644
--- a/core/jni/android/graphics/TextLayout.h
+++ b/core/jni/android/graphics/TextLayout.h
@@ -65,7 +65,7 @@
SkPath* path, SkCanvas* canvas);
static bool prepareText(SkPaint *paint, const jchar* text, jsize len, jint bidiFlags,
- const jchar** outText, int32_t* outBytes);
+ const jchar** outText, int32_t* outBytes, jchar** outBuffer);
private:
static bool needsLayout(const jchar* text, jint len, jint bidiFlags);
diff --git a/core/jni/android_database_SQLiteDatabase.cpp b/core/jni/android_database_SQLiteDatabase.cpp
index 290b532..003bbc1 100644
--- a/core/jni/android_database_SQLiteDatabase.cpp
+++ b/core/jni/android_database_SQLiteDatabase.cpp
@@ -15,7 +15,7 @@
*/
#undef LOG_TAG
-#define LOG_TAG "Database"
+#define LOG_TAG "SqliteDatabaseCpp"
#include <utils/Log.h>
#include <utils/String8.h>
@@ -245,77 +245,6 @@
}
}
-/* public native void native_execSQL(String sql); */
-static void native_execSQL(JNIEnv* env, jobject object, jstring sqlString)
-{
- int err;
- int stepErr;
- sqlite3_stmt * statement = NULL;
- sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle);
- jchar const * sql = env->GetStringChars(sqlString, NULL);
- jsize sqlLen = env->GetStringLength(sqlString);
-
- if (sql == NULL || sqlLen == 0) {
- jniThrowException(env, "java/lang/IllegalArgumentException",
- "You must supply an SQL string");
- return;
- }
-
- err = sqlite3_prepare16_v2(handle, sql, sqlLen * 2, &statement, NULL);
-
- env->ReleaseStringChars(sqlString, sql);
-
- if (err != SQLITE_OK) {
- char const * sql8 = env->GetStringUTFChars(sqlString, NULL);
- LOGE("Failure %d (%s) on %p when preparing '%s'.\n", err, sqlite3_errmsg(handle),
- handle, sql8);
- throw_sqlite3_exception(env, handle, sql8);
- env->ReleaseStringUTFChars(sqlString, sql8);
- return;
- }
-
- stepErr = sqlite3_step(statement);
- err = sqlite3_finalize(statement);
-
- if (stepErr != SQLITE_DONE) {
- if (stepErr == SQLITE_ROW) {
- throw_sqlite3_exception(env,
- "Queries cannot be performed using execSQL(), use query() instead.");
- } else {
- char const * sql8 = env->GetStringUTFChars(sqlString, NULL);
- LOGE("Failure %d (%s) on %p when executing '%s'\n", err, sqlite3_errmsg(handle),
- handle, sql8);
- throw_sqlite3_exception(env, handle, sql8);
- env->ReleaseStringUTFChars(sqlString, sql8);
-
- }
- } else
-#ifndef DB_LOG_STATEMENTS
- IF_LOGV()
-#endif
- {
- char const * sql8 = env->GetStringUTFChars(sqlString, NULL);
- LOGV("Success on %p when executing '%s'\n", handle, sql8);
- env->ReleaseStringUTFChars(sqlString, sql8);
- }
-}
-
-/* native long lastInsertRow(); */
-static jlong lastInsertRow(JNIEnv* env, jobject object)
-{
- sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle);
-
- return sqlite3_last_insert_rowid(handle);
-}
-
-/* native int lastChangeCount(); */
-static jint lastChangeCount(JNIEnv* env, jobject object)
-{
- sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle);
-
- return sqlite3_changes(handle);
-}
-
/* native int native_getDbLookaside(); */
static jint native_getDbLookaside(JNIEnv* env, jobject object)
{
@@ -522,9 +451,6 @@
{"dbclose", "()V", (void *)dbclose},
{"enableSqlTracing", "(Ljava/lang/String;S)V", (void *)enableSqlTracing},
{"enableSqlProfiling", "(Ljava/lang/String;S)V", (void *)enableSqlProfiling},
- {"native_execSQL", "(Ljava/lang/String;)V", (void *)native_execSQL},
- {"lastInsertRow", "()J", (void *)lastInsertRow},
- {"lastChangeCount", "()I", (void *)lastChangeCount},
{"native_setLocale", "(Ljava/lang/String;I)V", (void *)native_setLocale},
{"native_getDbLookaside", "()I", (void *)native_getDbLookaside},
{"releaseMemory", "()I", (void *)native_releaseMemory},
diff --git a/core/jni/android_database_SQLiteStatement.cpp b/core/jni/android_database_SQLiteStatement.cpp
index 0341e0b..2212d9a 100644
--- a/core/jni/android_database_SQLiteStatement.cpp
+++ b/core/jni/android_database_SQLiteStatement.cpp
@@ -16,7 +16,7 @@
*/
#undef LOG_TAG
-#define LOG_TAG "Cursor"
+#define LOG_TAG "SQLiteStatementCpp"
#include <jni.h>
#include <JNIHelp.h>
@@ -48,24 +48,40 @@
(sqlite3 *)env->GetIntField(object, gHandleField)
-static void native_execute(JNIEnv* env, jobject object)
+static jint native_execute(JNIEnv* env, jobject object)
{
int err;
sqlite3 * handle = GET_HANDLE(env, object);
sqlite3_stmt * statement = GET_STATEMENT(env, object);
+ int numChanges = -1;
// Execute the statement
err = sqlite3_step(statement);
- // Throw an exception if an error occured
+ // Throw an exception if an error occurred
if (err == SQLITE_ROW) {
- LOGV("Queries cannot be performed using execute(). use SQLiteDatabase.query() instead.");
+ throw_sqlite3_exception(env,
+ "Queries can be performed using SQLiteDatabase query or rawQuery methods only.");
} else if (err != SQLITE_DONE) {
throw_sqlite3_exception_errcode(env, err, sqlite3_errmsg(handle));
+ } else {
+ numChanges = sqlite3_changes(handle);
}
- // Reset the statment so it's ready to use again
+ // Reset the statement so it's ready to use again
sqlite3_reset(statement);
+ return numChanges;
+}
+
+static jlong native_executeInsert(JNIEnv* env, jobject object)
+{
+ sqlite3 * handle = GET_HANDLE(env, object);
+ jint numChanges = native_execute(env, object);
+ if (numChanges > 0) {
+ return sqlite3_last_insert_rowid(handle);
+ } else {
+ return -1;
+ }
}
static jlong native_1x1_long(JNIEnv* env, jobject object)
@@ -117,11 +133,11 @@
return value;
}
-
static JNINativeMethod sMethods[] =
{
/* name, signature, funcPtr */
- {"native_execute", "()V", (void *)native_execute},
+ {"native_execute", "()I", (void *)native_execute},
+ {"native_executeInsert", "()J", (void *)native_executeInsert},
{"native_1x1_long", "()J", (void *)native_1x1_long},
{"native_1x1_string", "()Ljava/lang/String;", (void *)native_1x1_string},
};
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index d2e7faf..1e4a66d 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -256,9 +256,11 @@
static void renderText(OpenGLRenderer* renderer, const jchar* text, int count,
jfloat x, jfloat y, int flags, SkPaint* paint) {
const jchar *workText;
+ jchar* buffer = NULL;
int32_t workBytes;
- if (TextLayout::prepareText(paint, text, count, flags, &workText, &workBytes)) {
+ if (TextLayout::prepareText(paint, text, count, flags, &workText, &workBytes, &buffer)) {
renderer->drawText((const char*) workText, workBytes, count, x, y, paint);
+ free(buffer);
}
}
diff --git a/core/tests/coretests/src/android/database/DatabaseGeneralTest.java b/core/tests/coretests/src/android/database/DatabaseGeneralTest.java
index e33421a..cd38bf07 100644
--- a/core/tests/coretests/src/android/database/DatabaseGeneralTest.java
+++ b/core/tests/coretests/src/android/database/DatabaseGeneralTest.java
@@ -21,6 +21,7 @@
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteException;
import android.os.Handler;
import android.os.Parcel;
import android.test.AndroidTestCase;
@@ -384,54 +385,28 @@
@MediumTest
public void testSchemaChange2() throws Exception {
- SQLiteDatabase db1 = mDatabase;
- SQLiteDatabase db2 = SQLiteDatabase.openOrCreateDatabase(mDatabaseFile, null);
- Cursor cursor;
-
- db1.execSQL("CREATE TABLE db1 (_id INTEGER PRIMARY KEY, data TEXT);");
-
- cursor = db1.query("db1", null, null, null, null, null, null);
- assertNotNull("Cursor is null", cursor);
+ mDatabase.execSQL("CREATE TABLE db1 (_id INTEGER PRIMARY KEY, data TEXT);");
+ Cursor cursor = mDatabase.query("db1", null, null, null, null, null, null);
+ assertNotNull(cursor);
assertEquals(0, cursor.getCount());
- cursor.deactivate();
- // this cause exception because we're still using sqlite_prepate16 and not
- // sqlite_prepare16_v2. The v2 variant added the ability to check the
- // schema version and handle the case when the schema has changed
- // Marco Nelissen claim it was 2x slower to compile SQL statements so
- // I reverted back to the v1 variant.
- /* db2.execSQL("CREATE TABLE db2 (_id INTEGER PRIMARY KEY, data TEXT);");
-
- cursor = db1.query("db1", null, null, null, null, null, null);
- assertNotNull("Cursor is null", cursor);
- assertEquals(0, cursor.count());
- cursor.deactivate();
- */
+ cursor.close();
}
@MediumTest
public void testSchemaChange3() throws Exception {
- SQLiteDatabase db1 = mDatabase;
- SQLiteDatabase db2 = SQLiteDatabase.openOrCreateDatabase(mDatabaseFile, null);
- Cursor cursor;
-
-
- db1.execSQL("CREATE TABLE db1 (_id INTEGER PRIMARY KEY, data TEXT);");
- db1.execSQL("INSERT INTO db1 (data) VALUES ('test');");
-
- cursor = db1.query("db1", null, null, null, null, null, null);
- // this cause exception because we're still using sqlite_prepate16 and not
- // sqlite_prepare16_v2. The v2 variant added the ability to check the
- // schema version and handle the case when the schema has changed
- // Marco Nelissen claim it was 2x slower to compile SQL statements so
- // I reverted back to the v1 variant.
- /* db2.execSQL("CREATE TABLE db2 (_id INTEGER PRIMARY KEY, data TEXT);");
-
- assertNotNull("Cursor is null", cursor);
- assertEquals(1, cursor.count());
- assertTrue(cursor.first());
- assertEquals("test", cursor.getString(cursor.getColumnIndexOrThrow("data")));
- cursor.deactivate();
- */
+ mDatabase.execSQL("CREATE TABLE db1 (_id INTEGER PRIMARY KEY, data TEXT);");
+ mDatabase.execSQL("INSERT INTO db1 (data) VALUES ('test');");
+ mDatabase.execSQL("ALTER TABLE db1 ADD COLUMN blah int;");
+ Cursor c = null;
+ try {
+ c = mDatabase.rawQuery("select blah from db1", null);
+ } catch (SQLiteException e) {
+ fail("unexpected exception: " + e.getMessage());
+ } finally {
+ if (c != null) {
+ c.close();
+ }
+ }
}
private class ChangeObserver extends ContentObserver {
diff --git a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java
index fc71b77..38191b0 100644
--- a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java
+++ b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java
@@ -16,24 +16,24 @@
package android.content.pm;
+import com.android.ddmlib.AdbCommandRejectedException;
import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.IShellOutputReceiver;
+import com.android.ddmlib.InstallException;
import com.android.ddmlib.Log;
import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.SyncService;
+import com.android.ddmlib.ShellCommandUnresponsiveException;
+import com.android.ddmlib.SyncException;
+import com.android.ddmlib.TimeoutException;
import com.android.ddmlib.SyncService.ISyncProgressMonitor;
-import com.android.ddmlib.SyncService.SyncResult;
import com.android.ddmlib.testrunner.ITestRunListener;
import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.hosttest.DeviceTestCase;
-import com.android.hosttest.DeviceTestSuite;
import java.io.BufferedReader;
-import java.io.File;
-import java.io.InputStreamReader;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.StringReader;
import java.lang.Runtime;
import java.lang.Process;
@@ -42,7 +42,6 @@
import java.util.regex.Pattern;
import junit.framework.Assert;
-import com.android.hosttest.DeviceTestCase;
/**
* Set of tests that verify host side install cases
@@ -120,8 +119,14 @@
* Helper method to run tests and return the listener that collected the results.
* @param pkgName Android application package for tests
* @return the {@link CollectingTestRunListener}
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- private CollectingTestRunListener doRunTests(String pkgName) throws IOException {
+ private CollectingTestRunListener doRunTests(String pkgName) throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(
pkgName, mDevice);
CollectingTestRunListener listener = new CollectingTestRunListener();
@@ -138,8 +143,14 @@
*
* @param pkgName Android application package for tests
* @return true if every test passed, false otherwise.
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public boolean runDeviceTestsDidAllTestsPass(String pkgName) throws IOException {
+ public boolean runDeviceTestsDidAllTestsPass(String pkgName) throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
CollectingTestRunListener listener = doRunTests(pkgName);
return listener.didAllTestsPass();
}
@@ -147,22 +158,26 @@
/**
* Helper method to push a file to device
* @param apkAppPrivatePath
- * @throws IOException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
*/
public void pushFile(final String localFilePath, final String destFilePath)
- throws IOException {
- SyncResult result = mDevice.getSyncService().pushFile(
- localFilePath, destFilePath, new NullSyncProgressMonitor());
- assertEquals(SyncService.RESULT_OK, result.getCode());
+ throws IOException, SyncException, TimeoutException, AdbCommandRejectedException {
+ mDevice.getSyncService().pushFile(localFilePath,
+ destFilePath, new NullSyncProgressMonitor());
}
/**
* Helper method to install a file
* @param localFilePath the absolute file system path to file on local host to install
* @param reinstall set to <code>true</code> if re-install of app should be performed
- * @throws IOException
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed
*/
- public void installFile(final String localFilePath, final boolean replace) throws IOException {
+ public void installFile(final String localFilePath, final boolean replace) throws IOException,
+ InstallException {
String result = mDevice.installPackage(localFilePath, replace);
assertEquals(null, result);
}
@@ -172,10 +187,11 @@
* @param localFilePath the absolute file system path to file on local host to install
* @param reinstall set to <code>true</code> if re-install of app should be performed
* @return the string output of the failed install attempt
- * @throws IOException
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed
*/
public String installFileFail(final String localFilePath, final boolean replace)
- throws IOException {
+ throws IOException, InstallException {
String result = mDevice.installPackage(localFilePath, replace);
assertNotNull(result);
return result;
@@ -185,10 +201,17 @@
* Helper method to install a file to device as forward locked
* @param localFilePath the absolute file system path to file on local host to install
* @param reinstall set to <code>true</code> if re-install of app should be performed
- * @throws IOException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
public String installFileForwardLocked(final String localFilePath, final boolean replace)
- throws IOException {
+ throws IOException, SyncException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException, InstallException {
String remoteFilePath = mDevice.syncPackageToDevice(localFilePath);
InstallReceiver receiver = new InstallReceiver();
String cmd = String.format(replace ? "pm install -r -l \"%1$s\"" :
@@ -203,9 +226,14 @@
*
* @param destPath the absolute path of file on device to check
* @return <code>true</code> if file exists, <code>false</code> otherwise.
- * @throws IOException if adb shell command failed
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public boolean doesRemoteFileExist(String destPath) throws IOException {
+ public boolean doesRemoteFileExist(String destPath) throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
String lsGrep = executeShellCommand(String.format("ls %s", destPath));
return !lsGrep.contains("No such file or directory");
}
@@ -216,10 +244,15 @@
* @param destPath the absolute path of the file
* @return <code>true</code> if file exists containing given string,
* <code>false</code> otherwise.
- * @throws IOException if adb shell command failed
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
public boolean doesRemoteFileExistContainingString(String destPath, String searchString)
- throws IOException {
+ throws IOException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
String lsResult = executeShellCommand(String.format("ls %s", destPath));
return lsResult.contains(searchString);
}
@@ -229,9 +262,14 @@
*
* @param packageName the Android manifest package to check.
* @return <code>true</code> if package exists, <code>false</code> otherwise
- * @throws IOException if adb shell command failed
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public boolean doesPackageExist(String packageName) throws IOException {
+ public boolean doesPackageExist(String packageName) throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
String pkgGrep = executeShellCommand(String.format("pm path %s", packageName));
return pkgGrep.contains("package:");
}
@@ -241,9 +279,14 @@
*
* @param packageName package name to check for
* @return <code>true</code> if file exists, <code>false</code> otherwise.
- * @throws IOException if adb shell command failed
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public boolean doesAppExistOnDevice(String packageName) throws IOException {
+ public boolean doesAppExistOnDevice(String packageName) throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
return doesRemoteFileExistContainingString(DEVICE_APP_PATH, packageName);
}
@@ -252,9 +295,14 @@
*
* @param packageName package name to check for
* @return <code>true</code> if file exists, <code>false</code> otherwise.
- * @throws IOException if adb shell command failed
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public boolean doesAppExistOnSDCard(String packageName) throws IOException {
+ public boolean doesAppExistOnSDCard(String packageName) throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
return doesRemoteFileExistContainingString(SDCARD_APP_PATH, packageName);
}
@@ -263,9 +311,14 @@
*
* @param packageName package name to check for
* @return <code>true</code> if file exists, <code>false</code> otherwise.
- * @throws IOException if adb shell command failed
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public boolean doesAppExistAsForwardLocked(String packageName) throws IOException {
+ public boolean doesAppExistAsForwardLocked(String packageName) throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
return doesRemoteFileExistContainingString(APP_PRIVATE_PATH, packageName);
}
@@ -273,9 +326,14 @@
* Waits for device's package manager to respond.
*
* @throws InterruptedException
- * @throws IOException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public void waitForPackageManager() throws InterruptedException, IOException {
+ public void waitForPackageManager() throws InterruptedException, IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "waiting for device");
int currentWaitTime = 0;
// poll the package manager until it returns something for android
@@ -341,9 +399,14 @@
*
* @param packageName The name of the package to wait to load
* @throws InterruptedException
- * @throws IOException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public void waitForApp(String packageName) throws InterruptedException, IOException {
+ public void waitForApp(String packageName) throws InterruptedException, IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "waiting for app to launch");
int currentWaitTime = 0;
// poll the package manager until it returns something for the package we're looking for
@@ -360,9 +423,14 @@
/**
* Helper method which executes a adb shell command and returns output as a {@link String}
* @return the output of the command
- * @throws IOException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public String executeShellCommand(String command) throws IOException {
+ public String executeShellCommand(String command) throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, String.format("adb shell %s", command));
CollectingOutputReceiver receiver = new CollectingOutputReceiver();
mDevice.executeShellCommand(command, receiver);
@@ -374,9 +442,14 @@
/**
* Helper method ensures we are in root mode on the host side. It returns only after
* PackageManager is actually up and running.
- * @throws IOException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public void runAdbRoot() throws IOException, InterruptedException {
+ public void runAdbRoot() throws IOException, InterruptedException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "adb root");
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("adb root"); // adb should be in the path
@@ -394,10 +467,15 @@
/**
* Helper method which reboots the device and returns once the device is online again
* and package manager is up and running (note this function is synchronous to callers).
- * @throws IOException
* @throws InterruptedException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public void rebootDevice() throws IOException, InterruptedException {
+ public void rebootDevice() throws IOException, InterruptedException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
String command = "reboot"; // no need for -s since mDevice is already tied to a device
Log.i(LOG_TAG, command);
CollectingOutputReceiver receiver = new CollectingOutputReceiver();
@@ -550,17 +628,23 @@
/**
* Helper method for installing an app to wherever is specified in its manifest, and
* then verifying the app was installed onto SD Card.
+ * <p/>
+ * Assumes adb is running as root in device under test.
*
* @param the path of the apk to install
* @param the name of the package
* @param <code>true</code> if the app should be overwritten, <code>false</code> otherwise
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
- * <p/>
- * Assumes adb is running as root in device under test.
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void installAppAndVerifyExistsOnSDCard(String apkPath, String pkgName, boolean overwrite)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
// Start with a clean slate if we're not overwriting
if (!overwrite) {
// cleanup test app just in case it already exists
@@ -581,17 +665,23 @@
/**
* Helper method for installing an app to wherever is specified in its manifest, and
* then verifying the app was installed onto device.
+ * <p/>
+ * Assumes adb is running as root in device under test.
*
* @param the path of the apk to install
* @param the name of the package
* @param <code>true</code> if the app should be overwritten, <code>false</code> otherwise
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
- * <p/>
- * Assumes adb is running as root in device under test.
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void installAppAndVerifyExistsOnDevice(String apkPath, String pkgName, boolean overwrite)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
// Start with a clean slate if we're not overwriting
if (!overwrite) {
// cleanup test app just in case it already exists
@@ -612,17 +702,24 @@
/**
* Helper method for installing an app as forward-locked, and
* then verifying the app was installed in the proper forward-locked location.
+ * <p/>
+ * Assumes adb is running as root in device under test.
*
* @param the path of the apk to install
* @param the name of the package
* @param <code>true</code> if the app should be overwritten, <code>false</code> otherwise
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
- * <p/>
- * Assumes adb is running as root in device under test.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
*/
public void installFwdLockedAppAndVerifyExists(String apkPath,
- String pkgName, boolean overwrite) throws IOException, InterruptedException {
+ String pkgName, boolean overwrite) throws IOException, InterruptedException,
+ InstallException, SyncException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
// Start with a clean slate if we're not overwriting
if (!overwrite) {
// cleanup test app just in case it already exists
@@ -643,14 +740,21 @@
/**
* Helper method for uninstalling an app.
- *
- * @param pkgName package name to uninstall
- * @throws IOException if adb shell command failed
- * @throws InterruptedException if the thread was interrupted
* <p/>
* Assumes adb is running as root in device under test.
+ *
+ * @param pkgName package name to uninstall
+ * @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the uninstall failed.
*/
- public void uninstallApp(String pkgName) throws IOException, InterruptedException {
+ public void uninstallApp(String pkgName) throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
mDevice.uninstallPackage(pkgName);
// make sure its not installed anymore
assertFalse(doesPackageExist(pkgName));
@@ -660,12 +764,18 @@
* Helper method for clearing any installed non-system apps.
* Useful ensuring no non-system apps are installed, and for cleaning up stale files that
* may be lingering on the system for whatever reason.
- *
- * @throws IOException if adb shell command failed
* <p/>
* Assumes adb is running as root in device under test.
+ *
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the uninstall failed.
*/
- public void wipeNonSystemApps() throws IOException {
+ public void wipeNonSystemApps() throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException, InstallException {
String allInstalledPackages = executeShellCommand("pm list packages -f");
BufferedReader outputReader = new BufferedReader(new StringReader(allInstalledPackages));
@@ -690,8 +800,14 @@
*
* <p/>
* Assumes adb is running as root in device under test.
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public void setDevicePreferredInstallLocation(InstallLocPreference pref) throws IOException {
+ public void setDevicePreferredInstallLocation(InstallLocPreference pref) throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
String command = "pm setInstallLocation %d";
int locValue = 0;
switch (pref) {
@@ -713,8 +829,14 @@
*
* <p/>
* Assumes adb is running as root in device under test.
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public InstallLocPreference getDevicePreferredInstallLocation() throws IOException {
+ public InstallLocPreference getDevicePreferredInstallLocation() throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
String result = executeShellCommand("pm getInstallLocation");
if (result.indexOf('0') != -1) {
return InstallLocPreference.AUTO;
diff --git a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java
index 1b797d5..22a2be6 100644
--- a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java
+++ b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java
@@ -16,13 +16,12 @@
package android.content.pm;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.IShellOutputReceiver;
+import com.android.ddmlib.AdbCommandRejectedException;
+import com.android.ddmlib.InstallException;
import com.android.ddmlib.Log;
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.SyncService;
-import com.android.ddmlib.SyncService.ISyncProgressMonitor;
-import com.android.ddmlib.SyncService.SyncResult;
+import com.android.ddmlib.ShellCommandUnresponsiveException;
+import com.android.ddmlib.SyncException;
+import com.android.ddmlib.TimeoutException;
import com.android.hosttest.DeviceTestCase;
import com.android.hosttest.DeviceTestSuite;
@@ -156,10 +155,18 @@
* the app, and otherwise cause the system to blow up.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
- public void testPushAppPrivate() throws IOException, InterruptedException {
+ public void testPushAppPrivate() throws IOException, InterruptedException, InstallException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException,
+ SyncException {
Log.i(LOG_TAG, "testing pushing an apk to /data/app-private");
final String apkAppPrivatePath = appPrivatePath + SIMPLE_APK;
@@ -187,12 +194,18 @@
* @param apkName the file name of the test app apk
* @param pkgName the package name of the test app apk
* @param expectedLocation the file name of the test app apk
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
private void doStandardInstall(String apkName, String pkgName,
PackageManagerHostTestUtils.InstallLocation expectedLocation)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
if (expectedLocation == PackageManagerHostTestUtils.InstallLocation.DEVICE) {
mPMHostUtils.installAppAndVerifyExistsOnDevice(
@@ -211,12 +224,18 @@
* Assumes adb is running as root in device under test.
* @param preference the device's preferred location of where to install apps
* @param expectedLocation the expected location of where the apk was installed
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void installAppAutoLoc(PackageManagerHostTestUtils.InstallLocPreference preference,
PackageManagerHostTestUtils.InstallLocation expectedLocation)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException, InstallException {
PackageManagerHostTestUtils.InstallLocPreference savedPref =
PackageManagerHostTestUtils.InstallLocPreference.AUTO;
@@ -239,10 +258,16 @@
* will install the app to the device when device's preference is auto.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppAutoLocPrefIsAuto() throws IOException, InterruptedException {
+ public void testInstallAppAutoLocPrefIsAuto() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=auto, prefer=auto gets installed on device");
installAppAutoLoc(PackageManagerHostTestUtils.InstallLocPreference.AUTO,
PackageManagerHostTestUtils.InstallLocation.DEVICE);
@@ -253,10 +278,17 @@
* will install the app to the device when device's preference is internal.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppAutoLocPrefIsInternal() throws IOException, InterruptedException {
+ public void testInstallAppAutoLocPrefIsInternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=auto, prefer=internal gets installed on device");
installAppAutoLoc(PackageManagerHostTestUtils.InstallLocPreference.INTERNAL,
PackageManagerHostTestUtils.InstallLocation.DEVICE);
@@ -267,10 +299,17 @@
* will install the app to the SD card when device's preference is external.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppAutoLocPrefIsExternal() throws IOException, InterruptedException {
+ public void testInstallAppAutoLocPrefIsExternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=auto, prefer=external gets installed on device");
installAppAutoLoc(PackageManagerHostTestUtils.InstallLocPreference.EXTERNAL,
PackageManagerHostTestUtils.InstallLocation.DEVICE);
@@ -283,12 +322,18 @@
* Assumes adb is running as root in device under test.
* @param preference the device's preferred location of where to install apps
* @param expectedLocation the expected location of where the apk was installed
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the (un)install failed.
*/
public void installAppInternalLoc(PackageManagerHostTestUtils.InstallLocPreference preference,
PackageManagerHostTestUtils.InstallLocation expectedLocation)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException, InstallException {
PackageManagerHostTestUtils.InstallLocPreference savedPref =
PackageManagerHostTestUtils.InstallLocPreference.AUTO;
@@ -311,10 +356,17 @@
* will install the app to the device when device's preference is auto.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppInternalLocPrefIsAuto() throws IOException, InterruptedException {
+ public void testInstallAppInternalLocPrefIsAuto() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=internal, prefer=auto gets installed on device");
installAppInternalLoc(PackageManagerHostTestUtils.InstallLocPreference.AUTO,
PackageManagerHostTestUtils.InstallLocation.DEVICE);
@@ -325,10 +377,17 @@
* will install the app to the device when device's preference is internal.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppInternalLocPrefIsInternal() throws IOException, InterruptedException {
+ public void testInstallAppInternalLocPrefIsInternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=internal, prefer=internal is installed on device");
installAppInternalLoc(PackageManagerHostTestUtils.InstallLocPreference.INTERNAL,
PackageManagerHostTestUtils.InstallLocation.DEVICE);
@@ -339,10 +398,17 @@
* will install the app to the device when device's preference is external.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppInternalLocPrefIsExternal() throws IOException, InterruptedException {
+ public void testInstallAppInternalLocPrefIsExternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=internal, prefer=external is installed on device");
installAppInternalLoc(PackageManagerHostTestUtils.InstallLocPreference.EXTERNAL,
PackageManagerHostTestUtils.InstallLocation.DEVICE);
@@ -355,12 +421,18 @@
* Assumes adb is running as root in device under test.
* @param preference the device's preferred location of where to install apps
* @param expectedLocation the expected location of where the apk was installed
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void installAppExternalLoc(PackageManagerHostTestUtils.InstallLocPreference preference,
PackageManagerHostTestUtils.InstallLocation expectedLocation)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException, InstallException {
PackageManagerHostTestUtils.InstallLocPreference savedPref =
PackageManagerHostTestUtils.InstallLocPreference.AUTO;
@@ -384,10 +456,17 @@
* will install the app to the device when device's preference is auto.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppExternalLocPrefIsAuto() throws IOException, InterruptedException {
+ public void testInstallAppExternalLocPrefIsAuto() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=external, pref=auto gets installed on SD Card");
installAppExternalLoc(PackageManagerHostTestUtils.InstallLocPreference.AUTO,
PackageManagerHostTestUtils.InstallLocation.SDCARD);
@@ -398,10 +477,17 @@
* will install the app to the device when device's preference is internal.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppExternalLocPrefIsInternal() throws IOException, InterruptedException {
+ public void testInstallAppExternalLocPrefIsInternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=external, pref=internal gets installed on SD Card");
installAppExternalLoc(PackageManagerHostTestUtils.InstallLocPreference.INTERNAL,
PackageManagerHostTestUtils.InstallLocation.SDCARD);
@@ -412,10 +498,17 @@
* will install the app to the device when device's preference is external.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppExternalLocPrefIsExternal() throws IOException, InterruptedException {
+ public void testInstallAppExternalLocPrefIsExternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=external, pref=external gets installed on SD Card");
installAppExternalLoc(PackageManagerHostTestUtils.InstallLocPreference.EXTERNAL,
PackageManagerHostTestUtils.InstallLocation.SDCARD);
@@ -427,10 +520,17 @@
* system decide.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppNoLocPrefIsAuto() throws IOException, InterruptedException {
+ public void testInstallAppNoLocPrefIsAuto() throws IOException, InterruptedException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException,
+ InstallException {
Log.i(LOG_TAG, "Test an app with no installLocation gets installed on device");
PackageManagerHostTestUtils.InstallLocPreference savedPref =
@@ -456,10 +556,17 @@
* external.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppNoLocPrefIsExternal() throws IOException, InterruptedException {
+ public void testInstallAppNoLocPrefIsExternal() throws IOException, InterruptedException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException,
+ InstallException {
Log.i(LOG_TAG, "Test an app with no installLocation gets installed on SD card");
PackageManagerHostTestUtils.InstallLocPreference savedPref =
@@ -485,10 +592,17 @@
* internal.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppNoLocPrefIsInternal() throws IOException, InterruptedException {
+ public void testInstallAppNoLocPrefIsInternal() throws IOException, InterruptedException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException,
+ InstallException {
Log.i(LOG_TAG, "Test an app with no installLocation gets installed on device");
PackageManagerHostTestUtils.InstallLocPreference savedPref =
@@ -513,10 +627,18 @@
* forward-locked will get installed to the correct location.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
- public void testInstallFwdLockedAppInternal() throws IOException, InterruptedException {
+ public void testInstallFwdLockedAppInternal() throws IOException, InterruptedException,
+ InstallException, SyncException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test an app with installLoc set to Internal gets installed to app-private");
try {
@@ -534,10 +656,18 @@
* forward-locked will get installed to the correct location.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
- public void testInstallFwdLockedAppExternal() throws IOException, InterruptedException {
+ public void testInstallFwdLockedAppExternal() throws IOException, InterruptedException,
+ InstallException, SyncException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test an app with installLoc set to Internal gets installed to app-private");
try {
@@ -555,10 +685,18 @@
* forward-locked will get installed to the correct location.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
- public void testInstallFwdLockedAppAuto() throws IOException, InterruptedException {
+ public void testInstallFwdLockedAppAuto() throws IOException, InterruptedException,
+ InstallException, SyncException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test an app with installLoc set to Auto gets installed to app-private");
try {
@@ -576,10 +714,18 @@
* forward-locked installed will get installed to the correct location.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
- public void testInstallFwdLockedAppNone() throws IOException, InterruptedException {
+ public void testInstallFwdLockedAppNone() throws IOException, InterruptedException,
+ InstallException, SyncException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test an app with no installLoc set gets installed to app-private");
try {
@@ -597,14 +743,21 @@
* uninstall it, and reinstall it onto the SD card.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
// TODO: This currently relies on the app's manifest to switch from device to
// SD card install locations. We might want to make Device's installPackage()
// accept a installLocation flag so we can install a package to the
// destination of our choosing.
- public void testReinstallInternalToExternal() throws IOException, InterruptedException {
+ public void testReinstallInternalToExternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installing an app first to the device, then to the SD Card");
try {
@@ -625,14 +778,21 @@
* uninstall it, and reinstall it onto the device.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
// TODO: This currently relies on the app's manifest to switch from device to
// SD card install locations. We might want to make Device's installPackage()
// accept a installLocation flag so we can install a package to the
// destination of our choosing.
- public void testReinstallExternalToInternal() throws IOException, InterruptedException {
+ public void testReinstallExternalToInternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installing an app first to the SD Care, then to the device");
try {
@@ -655,10 +815,16 @@
* the update onto the SD card as well when location is set to external for both versions
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testUpdateBothExternal() throws IOException, InterruptedException {
+ public void testUpdateBothExternal() throws IOException, InterruptedException, InstallException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating an app on the SD card stays on the SD card");
try {
@@ -681,10 +847,16 @@
* updated apps' manifest file.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testUpdateToSDCard() throws IOException, InterruptedException {
+ public void testUpdateToSDCard() throws IOException, InterruptedException, InstallException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating an app on the SD card stays on the SD card");
try {
@@ -706,10 +878,17 @@
* the update onto the device if the manifest has changed to installLocation=internalOnly
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testUpdateSDCardToDevice() throws IOException, InterruptedException {
+ public void testUpdateSDCardToDevice() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating an app on the SD card to the Device through manifest change");
try {
@@ -731,11 +910,18 @@
* the update onto the device's forward-locked location
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndUpdateExternalLocForwardLockedApp()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, SyncException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating a forward-locked app marked preferExternal");
try {
@@ -757,11 +943,18 @@
* the update onto the device's forward-locked location
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndUpdateNoLocForwardLockedApp()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, SyncException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating a forward-locked app with no installLocation pref set");
try {
@@ -783,11 +976,18 @@
* and then launched without crashing.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchAllPermsAppOnSD()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app with all perms set, installed on SD card");
try {
@@ -808,11 +1008,17 @@
* run without permissions errors.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchFLPermsAppOnSD()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app with location perms set, installed on SD card");
try {
@@ -833,11 +1039,17 @@
* run without permissions errors.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchBTPermsAppOnSD()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app with bluetooth perms set, installed on SD card");
try {
@@ -858,11 +1070,17 @@
* SecurityException when launched if its other shared apps are not installed.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchSharedPermsAppOnSD_NoPerms()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app with no explicit perms set, installed on SD card");
try {
@@ -888,11 +1106,17 @@
* shared apps are installed.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchSharedPermsAppOnSD_GrantedPerms()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app with no explicit perms set, installed on SD card");
try {
@@ -921,11 +1145,17 @@
* run without permissions errors even after a reboot
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchFLPermsAppOnSD_Reboot()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app with location perms set, installed on SD card");
try {
@@ -951,11 +1181,17 @@
* shared apps are installed, even after a reboot.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchSharedPermsAppOnSD_Reboot()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app on SD, with no explicit perms set after reboot");
try {
diff --git a/core/tests/hosttests/src/android/content/pm/PackageManagerStressHostTests.java b/core/tests/hosttests/src/android/content/pm/PackageManagerStressHostTests.java
index 715c55b..a2a5dd3 100644
--- a/core/tests/hosttests/src/android/content/pm/PackageManagerStressHostTests.java
+++ b/core/tests/hosttests/src/android/content/pm/PackageManagerStressHostTests.java
@@ -16,8 +16,11 @@
package android.content.pm;
-import com.android.ddmlib.IDevice;
+import com.android.ddmlib.AdbCommandRejectedException;
+import com.android.ddmlib.InstallException;
import com.android.ddmlib.Log;
+import com.android.ddmlib.ShellCommandUnresponsiveException;
+import com.android.ddmlib.TimeoutException;
import com.android.hosttest.DeviceTestCase;
import com.android.hosttest.DeviceTestSuite;
@@ -138,7 +141,9 @@
* <p/>
* Assumes adb is running as root in device under test.
*/
- public void testUpdateAppManyTimesOnSD() throws IOException, InterruptedException {
+ public void testUpdateAppManyTimesOnSD() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating an app on SD numerous times");
// cleanup test app just in case it already exists
@@ -173,7 +178,9 @@
* <p/>
* Assumes adb is running as root in device under test.
*/
- public void testUninstallReinstallAppOnSDManyTimes() throws IOException, InterruptedException {
+ public void testUninstallReinstallAppOnSDManyTimes() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating an app on the SD card stays on the SD card");
// cleanup test app just in case it was already exists
@@ -207,7 +214,9 @@
* <p/>
* Assumes adb is running as root in device under test.
*/
- public void testInstallManyLargeAppsOnSD() throws IOException, InterruptedException {
+ public void testInstallManyLargeAppsOnSD() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installing 20 large apps onto the sd card");
try {
@@ -251,7 +260,9 @@
* <p/>
* Assumes adb is running as root in device under test.
*/
- public void testInstallManyAppsOnSD() throws IOException, InterruptedException {
+ public void testInstallManyAppsOnSD() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installing 500 small apps onto SD");
try {
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index 14ad7d7..5595ab0 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -80,6 +80,21 @@
nPenX, nPenY - height, 0, u1, v1);
}
+Font::CachedGlyphInfo* Font::getCachedUTFChar(SkPaint* paint, int32_t utfChar) {
+ CachedGlyphInfo* cachedGlyph = mCachedGlyphs.valueFor(utfChar);
+ if (cachedGlyph == NULL) {
+ cachedGlyph = cacheGlyph(paint, utfChar);
+ }
+
+ // Is the glyph still in texture cache?
+ if (!cachedGlyph->mIsValid) {
+ const SkGlyph& skiaGlyph = paint->getUnicharMetrics(utfChar);
+ updateGlyphCache(paint, skiaGlyph, cachedGlyph);
+ }
+
+ return cachedGlyph;
+}
+
void Font::renderUTF(SkPaint* paint, const char* text, uint32_t start, uint32_t len,
int numGlyphs, int x, int y) {
if (numGlyphs == 0 || text == NULL || len == 0) {
@@ -102,16 +117,7 @@
break;
}
- CachedGlyphInfo* cachedGlyph = mCachedGlyphs.valueFor(utfChar);
- if (cachedGlyph == NULL) {
- cachedGlyph = cacheGlyph(paint, utfChar);
- }
-
- // Is the glyph still in texture cache?
- if (!cachedGlyph->mIsValid) {
- const SkGlyph& skiaGlyph = paint->getUnicharMetrics(utfChar);
- updateGlyphCache(paint, skiaGlyph, cachedGlyph);
- }
+ CachedGlyphInfo* cachedGlyph = getCachedUTFChar(paint, utfChar);
// If it's still not valid, we couldn't cache it, so we shouldn't draw garbage
if (cachedGlyph->mIsValid) {
@@ -340,6 +346,8 @@
nextLine += mCacheLines.top()->mMaxHeight;
mCacheLines.push(new CacheTextureLine(mCacheWidth, 24, nextLine, 0));
nextLine += mCacheLines.top()->mMaxHeight;
+ mCacheLines.push(new CacheTextureLine(mCacheWidth, 24, nextLine, 0));
+ nextLine += mCacheLines.top()->mMaxHeight;
mCacheLines.push(new CacheTextureLine(mCacheWidth, 32, nextLine, 0));
nextLine += mCacheLines.top()->mMaxHeight;
mCacheLines.push(new CacheTextureLine(mCacheWidth, 32, nextLine, 0));
@@ -392,6 +400,12 @@
initTextTexture();
initVertexArrayBuffers();
+ // We store a string with letters in a rough frequency of occurrence
+ mLatinPrecache = String16("eisarntolcdugpmhbyfvkwzxjq ");
+ mLatinPrecache += String16("EISARNTOLCDUGPMHBYFVKWZXJQ");
+ mLatinPrecache += String16(",.?!()-+@;:`'");
+ mLatinPrecache += String16("0123456789");
+
mInitialized = true;
}
@@ -484,8 +498,38 @@
}
}
-void FontRenderer::setFont(uint32_t fontId, float fontSize) {
+uint32_t FontRenderer::getRemainingCacheCapacity() {
+ uint32_t remainingCapacity = 0;
+ float totalPixels = 0;
+ for(uint32_t i = 0; i < mCacheLines.size(); i ++) {
+ remainingCapacity += (mCacheLines[i]->mMaxWidth - mCacheLines[i]->mCurrentCol);
+ totalPixels += mCacheLines[i]->mMaxWidth;
+ }
+ remainingCapacity = (remainingCapacity * 100) / totalPixels;
+ return remainingCapacity;
+}
+
+void FontRenderer::precacheLatin(SkPaint* paint) {
+ // Remaining capacity is measured in %
+ uint32_t remainingCapacity = getRemainingCacheCapacity();
+ uint32_t precacheIdx = 0;
+ while(remainingCapacity > 25 && precacheIdx < mLatinPrecache.size()) {
+ mCurrentFont->getCachedUTFChar(paint, (int32_t)mLatinPrecache[precacheIdx]);
+ remainingCapacity = getRemainingCacheCapacity();
+ precacheIdx ++;
+ }
+}
+
+void FontRenderer::setFont(SkPaint* paint, uint32_t fontId, float fontSize) {
+ uint32_t currentNumFonts = mActiveFonts.size();
mCurrentFont = Font::create(this, fontId, fontSize);
+
+ const float maxPrecacheFontSize = 40.0f;
+ bool isNewFont = currentNumFonts != mActiveFonts.size();
+
+ if(isNewFont && fontSize <= maxPrecacheFontSize ){
+ precacheLatin(paint);
+ }
}
void FontRenderer::renderText(SkPaint* paint, const Rect* clip, const char *text,
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index bacd3aa..2f7a8ba 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -18,6 +18,7 @@
#define ANDROID_UI_FONT_RENDERER_H
#include <utils/String8.h>
+#include <utils/String16.h>
#include <utils/Vector.h>
#include <utils/KeyedVector.h>
@@ -82,10 +83,12 @@
void invalidateTextureCache();
- CachedGlyphInfo *cacheGlyph(SkPaint* paint, int32_t glyph);
+ CachedGlyphInfo* cacheGlyph(SkPaint* paint, int32_t glyph);
void updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, CachedGlyphInfo *glyph);
void drawCachedGlyph(CachedGlyphInfo *glyph, int x, int y);
+ CachedGlyphInfo* getCachedUTFChar(SkPaint* paint, int32_t utfChar);
+
FontRenderer* mState;
uint32_t mFontId;
float mFontSize;
@@ -99,7 +102,7 @@
void init();
void deinit();
- void setFont(uint32_t fontId, float fontSize);
+ void setFont(SkPaint* paint, uint32_t fontId, float fontSize);
void renderText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex,
uint32_t len, int numGlyphs, int x, int y);
@@ -160,6 +163,9 @@
void checkInit();
+ String16 mLatinPrecache;
+ void precacheLatin(SkPaint* paint);
+
void issueDrawCommand();
void appendMeshQuad(float x1, float y1, float z1, float u1, float v1, float x2, float y2,
float z2, float u2, float v2, float x3, float y3, float z3, float u3, float v3,
@@ -169,6 +175,7 @@
uint32_t mCacheHeight;
Vector<CacheTextureLine*> mCacheLines;
+ uint32_t getRemainingCacheCapacity();
Font* mCurrentFont;
Vector<Font*> mActiveFonts;
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index d30d718..2e44e122 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -569,7 +569,7 @@
// TODO: Implement scale properly
const Rect& clip = mSnapshot->getLocalClip();
- mFontRenderer.setFont(SkTypeface::UniqueID(paint->getTypeface()), paint->getTextSize());
+ mFontRenderer.setFont(paint, SkTypeface::UniqueID(paint->getTypeface()), paint->getTextSize());
mFontRenderer.renderText(paint, &clip, text, 0, bytesCount, count, x, y);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index e897d00..d6df581 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -468,8 +468,11 @@
timerInit();
timerSet(RS_TIMER_INTERNAL);
- LOGV("RS Launching thread(s)");
- mWorkers.mCount = 2;
+ int cpu = sysconf(_SC_NPROCESSORS_ONLN);
+ LOGV("RS Launching thread(s), reported CPU count %i", cpu);
+ if (cpu < 2) cpu = 0;
+
+ mWorkers.mCount = (uint32_t)cpu;
mWorkers.mThreadId = (pthread_t *) calloc(mWorkers.mCount, sizeof(pthread_t));
mWorkers.mNativeThreadId = (pid_t *) calloc(mWorkers.mCount, sizeof(pid_t));
mWorkers.mLaunchSignals = new Signal[mWorkers.mCount];
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c
index e66513f..8cf84b7 100755
--- a/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c
@@ -18,8 +18,8 @@
/****************************************************************************************
$Author: nxp007753 $
- $Revision: 1223 $
- $Date: 2010-07-15 14:27:01 +0200 (Thu, 15 Jul 2010) $
+ $Revision: 1315 $
+ $Date: 2010-07-23 11:52:08 +0200 (Fri, 23 Jul 2010) $
*****************************************************************************************/
@@ -124,10 +124,11 @@
/*
* Setup the high pass filter
*/
- LoadConst_16(0, /* Clear the history, value 0 */
- (LVM_INT16 *)&pInstance->pData->HPFTaps, /* Destination */
- sizeof(pInstance->pData->HPFTaps)/sizeof(LVM_INT16)); /* Number of words */
- BQ_2I_D32F32Cll_TRC_WRA_01_Init(&pInstance->pCoef->HPFInstance, /* Initialise the filter */
+ LoadConst_16(0, /* Clear the history, value 0 */
+ (void *)&pInstance->pData->HPFTaps, /* Destination Cast to void: \
+ no dereferencing in function*/
+ sizeof(pInstance->pData->HPFTaps)/sizeof(LVM_INT16)); /* Number of words */
+ BQ_2I_D32F32Cll_TRC_WRA_01_Init(&pInstance->pCoef->HPFInstance, /* Initialise the filter */
&pInstance->pData->HPFTaps,
(BQ_C32_Coefs_t *)&LVDBE_HPF_Table[Offset]);
@@ -135,10 +136,11 @@
/*
* Setup the band pass filter
*/
- LoadConst_16(0, /* Clear the history, value 0 */
- (LVM_INT16 *)&pInstance->pData->BPFTaps, /* Destination */
- sizeof(pInstance->pData->BPFTaps)/sizeof(LVM_INT16)); /* Number of words */
- BP_1I_D32F32Cll_TRC_WRA_02_Init(&pInstance->pCoef->BPFInstance, /* Initialise the filter */
+ LoadConst_16(0, /* Clear the history, value 0 */
+ (void *)&pInstance->pData->BPFTaps, /* Destination Cast to void:\
+ no dereferencing in function*/
+ sizeof(pInstance->pData->BPFTaps)/sizeof(LVM_INT16)); /* Number of words */
+ BP_1I_D32F32Cll_TRC_WRA_02_Init(&pInstance->pCoef->BPFInstance, /* Initialise the filter */
&pInstance->pData->BPFTaps,
(BP_C32_Coefs_t *)&LVDBE_BPF_Table[Offset]);
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c
index 41785a3..7273400 100755
--- a/media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c
@@ -19,8 +19,8 @@
/****************************************************************************************
$Author: nxp007753 $
- $Revision: 1082 $
- $Date: 2010-07-05 12:44:39 +0200 (Mon, 05 Jul 2010) $
+ $Revision: 1316 $
+ $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $
*****************************************************************************************/
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c
index 4667feb..922f77d 100755
--- a/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c
@@ -18,8 +18,8 @@
/****************************************************************************************
$Author: nxp007753 $
- $Revision: 1255 $
- $Date: 2010-07-16 17:07:29 +0200 (Fri, 16 Jul 2010) $
+ $Revision: 1316 $
+ $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $
*****************************************************************************************/
@@ -314,8 +314,9 @@
/*
* Clear the taps
*/
- LoadConst_16((LVM_INT16)0, /* Value */
- (LVM_INT16 *)&pInstance->pTE_Taps->TrebleBoost_Taps, /* Destination */
+ LoadConst_16((LVM_INT16)0, /* Value */
+ (void *)&pInstance->pTE_Taps->TrebleBoost_Taps, /* Destination.\
+ Cast to void: no dereferencing in function */
(LVM_UINT16)(sizeof(pInstance->pTE_Taps->TrebleBoost_Taps)/sizeof(LVM_INT16))); /* Number of words */
}
}
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c
index 7ac5685..323a2a3 100755
--- a/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c
@@ -18,8 +18,8 @@
/************************************************************************************
$Author: nxp007753 $
- $Revision: 1255 $
- $Date: 2010-07-16 17:07:29 +0200 (Fri, 16 Jul 2010) $
+ $Revision: 1316 $
+ $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $
*************************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c b/media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c
index b03f0ba..83f95ac 100755
--- a/media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c
+++ b/media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c
@@ -18,9 +18,9 @@
/************************************************************************/
/* */
/* Project:: */
-/* $Author: beq07716 $*/
-/* $Revision: 1000 $*/
-/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* $Author: nxp007753 $*/
+/* $Revision: 1316 $*/
+/* $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $*/
/* */
/************************************************************************/
@@ -51,7 +51,8 @@
if ((pInstance->Current1 != pInstance->Target1) || (pInstance->Current2 != pInstance->Target2))
{
MixSoft_1St_D32C31_WRA( (Mix_1St_Cll_t*) pInstance, src1, dst, n);
- MixInSoft_D32C31_SAT( (Mix_1St_Cll_t*) &pInstance->Alpha2, src2, dst, n);
+ MixInSoft_D32C31_SAT( (void *) &pInstance->Alpha2, /* Cast to void: no dereferencing in function*/
+ src2, dst, n);
}
/******************************************************************************
@@ -61,7 +62,8 @@
else
{
if (pInstance->Current1 == 0)
- MixSoft_1St_D32C31_WRA( (Mix_1St_Cll_t*) &pInstance->Alpha2, src2, dst, n);
+ MixSoft_1St_D32C31_WRA( (void *) &pInstance->Alpha2, /* Cast to void: no dereferencing in function*/
+ src2, dst, n);
else if (pInstance->Current2 == 0)
MixSoft_1St_D32C31_WRA( (Mix_1St_Cll_t*) pInstance, src1, dst, n);
else
diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.c
index 88f6fb0..dac2449 100755
--- a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.c
+++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.c
@@ -18,8 +18,8 @@
/**********************************************************************************
$Author: nxp007753 $
- $Revision: 1223 $
- $Date: 2010-07-15 14:27:01 +0200 (Thu, 15 Jul 2010) $
+ $Revision: 1316 $
+ $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $
***********************************************************************************/
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.c
index 2a83e89..b1d9408 100755
--- a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.c
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.c
@@ -17,9 +17,9 @@
/************************************************************************************
- $Author: nxp007753 $
- $Revision: 1246 $
- $Date: 2010-07-16 11:07:10 +0200 (Fri, 16 Jul 2010) $
+ $Author: beq06068 $
+ $Revision: 1307 $
+ $Date: 2010-07-22 17:41:25 +0200 (Thu, 22 Jul 2010) $
*************************************************************************************/
@@ -90,7 +90,7 @@
*/
if ((pParams->OperatingMode == LVCS_ON) &&
(pInstance->bTimerDone == LVM_TRUE)
- && (LVC_Mixer_GetTarget(&pInstance->MSBypassMixer.MixerStream[1]) != 0x7FFF) /* this indicates an off->on transtion */
+ && (pInstance->MSTarget1 != 0x7FFF) /* this indicates an off->on transtion */
)
{
pInstance->TransitionGain = pParams->EffectLevel;
@@ -260,17 +260,15 @@
LVM_INT16 CallbackParam)
{
LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance;
- LVM_INT32 Target1;
- Target1 = LVC_Mixer_GetTarget(&pInstance->MSBypassMixer.MixerStream[0]);
- (void)pGeneralPurpose;
+ (void)pGeneralPurpose;
/*
* Off transition has completed in Headphone mode
*/
if ((pInstance->OutputDevice == LVCS_HEADPHONE) &&
(pInstance->bInOperatingModeTransition) &&
- (Target1 == 0x0000)&& /* this indicates an on->off transition */
+ (pInstance->MSTarget0 == 0x0000)&& /* this indicates an on->off transition */
(CallbackParam == 0))
{
/* Set operating mode to OFF */
@@ -289,7 +287,7 @@
if ((pInstance->OutputDevice == LVCS_HEADPHONE) &&
- (Target1 == 1) &&
+ (pInstance->MSTarget0 == 1) &&
(pInstance->bTimerDone == LVM_TRUE)){
/* Exit transition state */
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c
index 5dfca256..fea44bf 100755
--- a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c
@@ -17,9 +17,9 @@
/************************************************************************************
- $Author: nxp007753 $
- $Revision: 1246 $
- $Date: 2010-07-16 11:07:10 +0200 (Fri, 16 Jul 2010) $
+ $Author: beq06068 $
+ $Revision: 1307 $
+ $Date: 2010-07-22 17:41:25 +0200 (Thu, 22 Jul 2010) $
*************************************************************************************/
@@ -94,9 +94,6 @@
if (pParams->SampleRate != pInstance->Params.SampleRate)
{
- LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[0],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
-
- LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[1],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
pInstance->TimerParams.SamplingRate = LVCS_SampleRateTable[pParams->SampleRate];
}
@@ -130,6 +127,29 @@
pInstance->VolCorrect = pLVCS_VolCorrectTable[Offset];
+ LVC_Mixer_Init(&pInstance->BypassMix.Mixer_Instance.MixerStream[0],0,0);
+
+
+ {
+ LVM_UINT32 Gain;
+ const Gain_t *pOutputGainTable = (Gain_t*)&LVCS_OutputGainTable[0];
+ Gain = (LVM_UINT32)(pOutputGainTable[Offset].Loss * LVM_MAXINT_16);
+ Gain = (LVM_UINT32)pOutputGainTable[Offset].UnprocLoss * (Gain >> 15);
+ Gain=Gain>>15;
+ /*
+ * Apply the gain correction and shift, note the result is in Q3.13 format
+ */
+ Gain = (Gain * pInstance->VolCorrect.GainMin) >>12;
+
+ LVC_Mixer_Init(&pInstance->BypassMix.Mixer_Instance.MixerStream[1],0,Gain);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->BypassMix.Mixer_Instance.MixerStream[0],
+ LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->BypassMix.Mixer_Instance.MixerStream[1],
+ LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
+
+ }
+
+
err=LVCS_SEnhancerInit(hInstance,
pParams);
@@ -199,44 +219,15 @@
/* Change transition bypass mixer settings if needed depending on transition type */
if(pParams->OperatingMode != LVCS_OFF){
- LVM_INT32 Current1;
- LVM_INT32 Current2;
-
- Current1 = LVC_Mixer_GetCurrent(&pInstance->MSBypassMixer.MixerStream[0]);
- Current2 = LVC_Mixer_GetCurrent(&pInstance->MSBypassMixer.MixerStream[1]);
-
- if(pInstance->bInOperatingModeTransition != LVM_TRUE)
- {
- Current1 = 0x00000000;
- Current2 = LVM_MAXINT_16;
- }
- pInstance->MSBypassMixer.MixerStream[0].CallbackSet = 1;
- pInstance->MSBypassMixer.MixerStream[1].CallbackSet = 1;
-
- LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[0],LVM_MAXINT_16,Current1);
- LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[1],0,Current2);
+ pInstance->MSTarget0=LVM_MAXINT_16;
+ pInstance->MSTarget1=0;
}
else
{
- LVM_INT32 Current1;
- LVM_INT32 Current2;
-
- Current1 = LVC_Mixer_GetCurrent(&pInstance->MSBypassMixer.MixerStream[0]);
- Current2 = LVC_Mixer_GetCurrent(&pInstance->MSBypassMixer.MixerStream[1]);
-
- if(pInstance->bInOperatingModeTransition != LVM_TRUE)
- {
- Current1 = LVM_MAXINT_16;
- Current2 = 0x00000000;
- }
- pInstance->MSBypassMixer.MixerStream[0].CallbackSet = 1;
- pInstance->MSBypassMixer.MixerStream[1].CallbackSet = 1;
pInstance->Params.OperatingMode = OperatingModeSave;
- LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[0],0x00000000,Current1);
- LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[1],LVM_MAXINT_16,Current2);
+ pInstance->MSTarget1=LVM_MAXINT_16;
+ pInstance->MSTarget0=0;
}
- LVC_Mixer_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[0],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
- LVC_Mixer_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[1],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
/* Set transition flag */
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c
index ca615b0..7ab6571 100755
--- a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c
@@ -17,9 +17,9 @@
/************************************************************************************
- $Author: beq07716 $
- $Revision: 1001 $
- $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+ $Author: nxp007753 $
+ $Revision: 1315 $
+ $Date: 2010-07-23 11:52:08 +0200 (Fri, 23 Jul 2010) $
*************************************************************************************/
@@ -94,8 +94,9 @@
Coeffs.B1 = (LVM_INT16)-pEqualiserCoefTable[Offset].B1;
Coeffs.B2 = (LVM_INT16)-pEqualiserCoefTable[Offset].B2;
- LoadConst_16((LVM_INT16)0, /* Value */
- (LVM_INT16 *)&pData->EqualiserBiquadTaps, /* Destination */
+ LoadConst_16((LVM_INT16)0, /* Value */
+ (void *)&pData->EqualiserBiquadTaps, /* Destination Cast to void:\
+ no dereferencing in function*/
(LVM_UINT16)(sizeof(pData->EqualiserBiquadTaps)/sizeof(LVM_INT16))); /* Number of words */
BQ_2I_D16F32Css_TRC_WRA_01_Init(&pCoefficients->EqualiserBiquadInstance,
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c
index 4aa95d3..f5f7cd0 100755
--- a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c
@@ -17,9 +17,9 @@
/************************************************************************************
- $Author: beq07716 $
- $Revision: 1001 $
- $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+ $Author: beq06068 $
+ $Revision: 1307 $
+ $Date: 2010-07-22 17:41:25 +0200 (Thu, 22 Jul 2010) $
*************************************************************************************/
@@ -159,7 +159,6 @@
LVCS_Capabilities_t *pCapabilities)
{
- LVM_INT16 Offset;
LVCS_Instance_t *pInstance;
LVCS_VolCorrect_t *pLVCS_VolCorrectTable;
@@ -197,30 +196,18 @@
pInstance->Params.EffectLevel = 0;
pInstance->Params.ReverbLevel = (LVM_UINT16)0x8000;
pLVCS_VolCorrectTable = (LVCS_VolCorrect_t*)&LVCS_VolCorrectTable[0];
- Offset = (LVM_INT16)(pInstance->Params.SpeakerType + (pInstance->Params.SourceFormat*(1+LVCS_EX_HEADPHONES)));
- pInstance->VolCorrect = pLVCS_VolCorrectTable[Offset];
+ pInstance->VolCorrect = pLVCS_VolCorrectTable[0];
pInstance->TransitionGain = 0;
+ /* These current and target values are intialized again in LVCS_Control.c */
LVC_Mixer_Init(&pInstance->BypassMix.Mixer_Instance.MixerStream[0],0,0);
+ /* These current and target values are intialized again in LVCS_Control.c */
LVC_Mixer_Init(&pInstance->BypassMix.Mixer_Instance.MixerStream[1],0,0);
/*
* Initialise the bypass variables
*/
- pInstance->MSBypassMixer.MixerStream[0].CallbackParam = 0;
- pInstance->MSBypassMixer.MixerStream[0].pCallbackHandle = LVM_NULL;
- pInstance->MSBypassMixer.MixerStream[0].pCallBack = LVM_NULL;
- pInstance->MSBypassMixer.MixerStream[0].CallbackSet = 0;
- LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[0],0,0);
- LVC_Mixer_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[0],0,LVM_FS_44100,2);
-
-
- pInstance->MSBypassMixer.MixerStream[1].CallbackParam = 0;
- pInstance->MSBypassMixer.MixerStream[1].pCallbackHandle = LVM_NULL;
- pInstance->MSBypassMixer.MixerStream[1].pCallBack = LVM_NULL;
- pInstance->MSBypassMixer.MixerStream[1].CallbackSet = 0;
- LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[1],0,0);
- LVC_Mixer_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[1],0,LVM_FS_44100,2);
-
+ pInstance->MSTarget0=0;
+ pInstance->MSTarget1=0;
pInstance->bInOperatingModeTransition = LVM_FALSE;
pInstance->bTimerDone = LVM_FALSE;
pInstance->TimerParams.CallBackParam = 0;
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Private.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Private.h
index be30829..a977690 100755
--- a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Private.h
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Private.h
@@ -17,9 +17,9 @@
/************************************************************************************
- $Author: beq07716 $
- $Revision: 1001 $
- $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+ $Author: beq06068 $
+ $Revision: 1307 $
+ $Date: 2010-07-22 17:41:25 +0200 (Thu, 22 Jul 2010) $
*************************************************************************************/
@@ -128,7 +128,8 @@
LVCS_BypassMix_t BypassMix; /* Bypass mixer configuration */
/* Bypass variable */
- LVMixer3_2St_st MSBypassMixer; /* Bypass mixer used in transitions in MS mode */
+ LVM_INT16 MSTarget0; /* Mixer state control variable for smooth transtion */
+ LVM_INT16 MSTarget1; /* Mixer state control variable for smooth transtion */
LVM_INT16 bInOperatingModeTransition; /* Operating mode transition flag */
LVM_INT16 bTimerDone; /* Timer completion flag */
LVM_Timer_Params_t TimerParams; /* Timer parameters */
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.c
index 2efef84..861bde6 100755
--- a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.c
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.c
@@ -17,9 +17,9 @@
/************************************************************************************
- $Author: beq07716 $
- $Revision: 1001 $
- $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+ $Author: nxp007753 $
+ $Revision: 1315 $
+ $Date: 2010-07-23 11:52:08 +0200 (Fri, 23 Jul 2010) $
*************************************************************************************/
@@ -113,7 +113,7 @@
Coeffs.B2 = (LVM_INT16)-pReverbCoefTable[Offset].B2;
LoadConst_16(0, /* Value */
- (LVM_INT16 *)&pData->ReverbBiquadTaps, /* Destination */
+ (void *)&pData->ReverbBiquadTaps, /* Destination Cast to void: no dereferencing in function*/
(LVM_UINT16)(sizeof(pData->ReverbBiquadTaps)/sizeof(LVM_INT16))); /* Number of words */
BQ_2I_D16F16Css_TRC_WRA_01_Init(&pCoefficients->ReverbBiquadInstance,
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c
index 4ff4716..b67d824 100755
--- a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c
@@ -17,9 +17,9 @@
/************************************************************************************
- $Author: beq07716 $
- $Revision: 1001 $
- $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+ $Author: nxp007753 $
+ $Revision: 1315 $
+ $Date: 2010-07-23 11:52:08 +0200 (Fri, 23 Jul 2010) $
*************************************************************************************/
@@ -90,7 +90,8 @@
/* Clear the taps */
LoadConst_16(0, /* Value */
- (LVM_INT16 *)&pData->SEBiquadTapsMid, /* Destination */
+ (void *)&pData->SEBiquadTapsMid, /* Destination Cast to void:\
+ no dereferencing in function*/
(LVM_UINT16)(sizeof(pData->SEBiquadTapsMid)/sizeof(LVM_UINT16))); /* Number of words */
FO_1I_D16F16Css_TRC_WRA_01_Init(&pCoefficient->SEBiquadInstanceMid,
@@ -116,7 +117,8 @@
/* Clear the taps */
LoadConst_16(0, /* Value */
- (LVM_INT16 *)&pData->SEBiquadTapsSide, /* Destination */
+ (void *)&pData->SEBiquadTapsSide, /* Destination Cast to void:\
+ no dereferencing in function*/
(LVM_UINT16)(sizeof(pData->SEBiquadTapsSide)/sizeof(LVM_UINT16))); /* Number of words */
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index 6043dd5..5e91974 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -2337,7 +2337,6 @@
void *pReplyData){
EffectContext * pContext = (EffectContext *) self;
int retsize;
- int status = 0;
//LOGV("\t\nEffect_command start");
@@ -2371,54 +2370,29 @@
switch (cmdCode){
case EFFECT_CMD_INIT:
+ if (pReplyData == NULL || *replySize != sizeof(int)){
+ LOGV("\tLVM_ERROR, EFFECT_CMD_INIT: ERROR for effect type %d",
+ pContext->EffectType);
+ return -EINVAL;
+ }
+ *(int *) pReplyData = 0;
//LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT start");
if(pContext->EffectType == LVM_BASS_BOOST){
//LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_BASS_BOOST");
-
- if (pReplyData == NULL || *replySize != sizeof(int)){
- LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
- "EFFECT_CMD_INIT: ERROR");
- return -EINVAL;
- }
-
android::BassSetStrength(pContext, 0);
}
if(pContext->EffectType == LVM_VIRTUALIZER){
//LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VIRTUALIZER");
-
- if (pReplyData == NULL || *replySize != sizeof(int)){
- LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
- "EFFECT_CMD_INIT: ERROR");
- return -EINVAL;
- }
-
android::VirtualizerSetStrength(pContext, 0);
}
if(pContext->EffectType == LVM_EQUALIZER){
//LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_EQUALIZER");
-
- if (pReplyData == NULL || *replySize != sizeof(int)){
- LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: "
- "EFFECT_CMD_INIT: ERROR");
- return -EINVAL;
- }
-
android::EqualizerSetPreset(pContext, 0);
}
if(pContext->EffectType == LVM_VOLUME){
//LOGV("\tEffect_command cmdCode Case: "
// "EFFECT_CMD_INIT start");
-
- if (pReplyData == NULL || *replySize != sizeof(int)){
- LOGV("\tLVM_ERROR : Volume_command cmdCode Case: "
- "EFFECT_CMD_INIT: ERROR");
- return -EINVAL;
- }
-
- status = android::VolumeSetVolumeLevel(pContext, 0);
- if(status == -EINVAL){
- return -EINVAL;
- }
+ *(int *) pReplyData = android::VolumeSetVolumeLevel(pContext, 0);
}
break;
diff --git a/packages/DefaultContainerService/res/values/strings.xml b/packages/DefaultContainerService/res/values/strings.xml
index 2897f34..37f5b61 100644
--- a/packages/DefaultContainerService/res/values/strings.xml
+++ b/packages/DefaultContainerService/res/values/strings.xml
@@ -19,5 +19,5 @@
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- service name -->
- <string name="service_name">Media Container Service</string>
+ <string name="service_name">Package Access Helper</string>
</resources>
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index af2145e..01376eb 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -1495,6 +1495,7 @@
ps.pkg.applicationInfo.publicSourceDir = ps.resourcePathString;
ps.pkg.applicationInfo.sourceDir = ps.codePathString;
ps.pkg.applicationInfo.dataDir = getDataPathForPackage(ps.pkg).getPath();
+ ps.pkg.mSetEnabled = ps.enabled;
}
return generatePackageInfo(ps.pkg, flags);
}
@@ -6875,6 +6876,7 @@
return;
}
pkgSetting.enabled = newState;
+ pkgSetting.pkg.mSetEnabled = newState;
} else {
// We're dealing with a component level state change
switch (newState) {
@@ -8261,6 +8263,7 @@
private void insertPackageSettingLP(PackageSetting p, PackageParser.Package pkg) {
p.pkg = pkg;
+ pkg.mSetEnabled = p.enabled;
String codePath = pkg.applicationInfo.sourceDir;
String resourcePath = pkg.applicationInfo.publicSourceDir;
// Update code path if needed
@@ -9486,6 +9489,9 @@
}
boolean isEnabledLP(ComponentInfo componentInfo, int flags) {
+ if ((flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
+ return true;
+ }
final PackageSetting packageSettings = mPackages.get(componentInfo.packageName);
if (Config.LOGV) {
Log.v(TAG, "isEnabledLock - packageName = " + componentInfo.packageName
@@ -9501,14 +9507,20 @@
Debug.waitForDebugger();
Log.i(TAG, "We will crash!");
}
+ return false;
}
- return ((flags&PackageManager.GET_DISABLED_COMPONENTS) != 0)
- || ((componentInfo.enabled
- && ((packageSettings.enabled == COMPONENT_ENABLED_STATE_ENABLED)
- || (componentInfo.applicationInfo.enabled
- && packageSettings.enabled != COMPONENT_ENABLED_STATE_DISABLED))
- && !packageSettings.disabledComponents.contains(componentInfo.name))
- || packageSettings.enabledComponents.contains(componentInfo.name));
+ if (packageSettings.enabled == COMPONENT_ENABLED_STATE_DISABLED
+ || (packageSettings.pkg != null && !packageSettings.pkg.applicationInfo.enabled
+ && packageSettings.enabled == COMPONENT_ENABLED_STATE_DEFAULT)) {
+ return false;
+ }
+ if (packageSettings.enabledComponents.contains(componentInfo.name)) {
+ return true;
+ }
+ if (packageSettings.disabledComponents.contains(componentInfo.name)) {
+ return false;
+ }
+ return componentInfo.enabled;
}
}
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 0c8769e..fa2ec1f 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -6755,7 +6755,7 @@
}
return;
} else if ("service".equals(cmd)) {
- dumpService(fd, pw, args, opti, true);
+ dumpService(fd, pw, args, opti, dumpAll);
return;
} else if ("services".equals(cmd) || "s".equals(cmd)) {
synchronized (this) {
@@ -7061,20 +7061,28 @@
componentNameString = args[opti];
opti++;
ComponentName componentName = ComponentName.unflattenFromString(componentNameString);
- r = componentName != null ? mServices.get(componentName) : null;
+ synchronized (this) {
+ r = componentName != null ? mServices.get(componentName) : null;
+ }
newArgs = new String[args.length - opti];
if (args.length > 2) System.arraycopy(args, opti, newArgs, 0, args.length - opti);
}
if (r != null) {
- dumpService(fd, pw, r, newArgs);
+ dumpService(fd, pw, r, newArgs, dumpAll);
} else {
- for (ServiceRecord r1 : mServices.values()) {
- if (componentNameString == null
- || r1.name.flattenToString().contains(componentNameString)) {
- dumpService(fd, pw, r1, newArgs);
+ ArrayList<ServiceRecord> services = new ArrayList<ServiceRecord>();
+ synchronized (this) {
+ for (ServiceRecord r1 : mServices.values()) {
+ if (componentNameString == null
+ || r1.name.flattenToString().contains(componentNameString)) {
+ services.add(r1);
+ }
}
}
+ for (int i=0; i<services.size(); i++) {
+ dumpService(fd, pw, services.get(i), newArgs, dumpAll);
+ }
}
}
@@ -7082,8 +7090,16 @@
* Invokes IApplicationThread.dumpService() on the thread of the specified service if
* there is a thread associated with the service.
*/
- private void dumpService(FileDescriptor fd, PrintWriter pw, ServiceRecord r, String[] args) {
+ private void dumpService(FileDescriptor fd, PrintWriter pw, ServiceRecord r, String[] args,
+ boolean dumpAll) {
pw.println(" Service " + r.name.flattenToString());
+ if (dumpAll) {
+ synchronized (this) {
+ pw.print(" * "); pw.println(r);
+ r.dump(pw, " ");
+ }
+ pw.println("");
+ }
if (r.app != null && r.app.thread != null) {
try {
// flush anything that is already in the PrintWriter since the thread is going
@@ -7091,6 +7107,7 @@
pw.flush();
r.app.thread.dumpService(fd, r, args);
pw.print("\n");
+ pw.flush();
} catch (RemoteException e) {
pw.println("got a RemoteException while dumping the service");
}
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index b79373d..3025f77 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -24,6 +24,7 @@
#include <utils/Errors.h>
#include <utils/RefBase.h>
#include <utils/Singleton.h>
+#include <utils/String16.h>
#include <binder/BinderService.h>
#include <binder/IServiceManager.h>
@@ -38,39 +39,65 @@
namespace android {
// ---------------------------------------------------------------------------
-/*
- * TODO:
- * - make sure to keep the last value of each event type so we can quickly
- * send something to application when they enable a sensor that is already
- * active (the issue here is that it can take time before a value is
- * produced by the h/w if the rate is low or if it's a one-shot sensor).
- * - send sensor info to battery service
- */
-
-// ---------------------------------------------------------------------------
-
class BatteryService : public Singleton<BatteryService> {
+ static const int TRANSACTION_noteStartSensor = IBinder::FIRST_CALL_TRANSACTION + 3;
+ static const int TRANSACTION_noteStopSensor = IBinder::FIRST_CALL_TRANSACTION + 4;
+ static const String16 DESCRIPTOR;
+
friend class Singleton<BatteryService>;
sp<IBinder> mBatteryStatService;
+
BatteryService() {
- const String16 name("batteryinfo");
- //getService(name, &mBatteryStatService);
+ const sp<IServiceManager> sm(defaultServiceManager());
+ if (sm != NULL) {
+ const String16 name("batteryinfo");
+ mBatteryStatService = sm->getService(name);
+ }
}
+
+ status_t noteStartSensor(int uid, int handle) {
+ Parcel data, reply;
+ data.writeInterfaceToken(DESCRIPTOR);
+ data.writeInt32(uid);
+ data.writeInt32(handle);
+ status_t err = mBatteryStatService->transact(
+ TRANSACTION_noteStartSensor, data, &reply, 0);
+ err = reply.readExceptionCode();
+ return err;
+ }
+
+ status_t noteStopSensor(int uid, int handle) {
+ Parcel data, reply;
+ data.writeInterfaceToken(DESCRIPTOR);
+ data.writeInt32(uid);
+ data.writeInt32(handle);
+ status_t err = mBatteryStatService->transact(
+ TRANSACTION_noteStopSensor, data, &reply, 0);
+ err = reply.readExceptionCode();
+ return err;
+ }
+
public:
void enableSensor(int handle) {
if (mBatteryStatService != 0) {
int uid = IPCThreadState::self()->getCallingUid();
- //mBatteryStatService->noteStartSensor(uid, handle);
+ int64_t identity = IPCThreadState::self()->clearCallingIdentity();
+ noteStartSensor(uid, handle);
+ IPCThreadState::self()->restoreCallingIdentity(identity);
}
}
void disableSensor(int handle) {
if (mBatteryStatService != 0) {
int uid = IPCThreadState::self()->getCallingUid();
- //mBatteryStatService->noteStopSensor(uid, handle);
+ int64_t identity = IPCThreadState::self()->clearCallingIdentity();
+ noteStopSensor(uid, handle);
+ IPCThreadState::self()->restoreCallingIdentity(identity);
}
}
};
+const String16 BatteryService::DESCRIPTOR("com.android.internal.app.IBatteryStats");
+
ANDROID_SINGLETON_STATIC_INSTANCE(BatteryService)
// ---------------------------------------------------------------------------
@@ -103,8 +130,12 @@
LOGE_IF(err, "couldn't open device for module %s (%s)",
SENSORS_HARDWARE_MODULE_ID, strerror(-err));
+ sensors_event_t event;
+ memset(&event, 0, sizeof(event));
+
struct sensor_t const* list;
int count = mSensorModule->get_sensors_list(mSensorModule, &list);
+ mLastEventSeen.setCapacity(count);
for (int i=0 ; i<count ; i++) {
Sensor sensor(list + i);
LOGI("%s", sensor.getName().string());
@@ -112,6 +143,7 @@
if (mSensorDevice) {
mSensorDevice->activate(mSensorDevice, sensor.getHandle(), 0);
}
+ mLastEventSeen.add(sensor.getHandle(), event);
}
if (mSensorDevice) {
@@ -138,6 +170,19 @@
result.append(buffer);
} else {
Mutex::Autolock _l(mLock);
+ snprintf(buffer, SIZE, "Sensor List:\n");
+ result.append(buffer);
+ for (size_t i=0 ; i<mSensorList.size() ; i++) {
+ const Sensor& s(mSensorList[i]);
+ const sensors_event_t& e(mLastEventSeen.valueFor(s.getHandle()));
+ snprintf(buffer, SIZE, "%s (vendor=%s, handle=%d, last=<%5.1f,%5.1f,%5.1f>)\n",
+ s.getName().string(),
+ s.getVendor().string(),
+ s.getHandle(),
+ e.data[0], e.data[1], e.data[2]);
+ result.append(buffer);
+ }
+
snprintf(buffer, SIZE, "%d active connections\n",
mActiveConnections.size());
result.append(buffer);
@@ -178,6 +223,19 @@
size_t numConnections = activeConnections.size();
if (numConnections) {
Mutex::Autolock _l(mLock);
+
+ // record the last event for each sensor
+ int32_t prev = buffer[0].sensor;
+ for (ssize_t i=1 ; i<count ; i++) {
+ // record the last event of each sensor type in this buffer
+ int32_t curr = buffer[i].sensor;
+ if (curr != prev) {
+ mLastEventSeen.editValueFor(prev) = buffer[i-1];
+ prev = curr;
+ }
+ }
+ mLastEventSeen.editValueFor(prev) = buffer[count-1];
+
for (size_t i=0 ; i<numConnections ; i++) {
sp<SensorEventConnection> connection(activeConnections[i].promote());
if (connection != 0) {
@@ -258,7 +316,16 @@
BatteryService::getInstance().enableSensor(handle);
}
} else {
- rec->addConnection(connection);
+ if (rec->addConnection(connection)) {
+ // this sensor is already activated, but we are adding a
+ // connection that uses it. Immediately send down the last
+ // known value of the requested sensor.
+ sensors_event_t scratch;
+ sensors_event_t& event(mLastEventSeen.editValueFor(handle));
+ if (event.version == sizeof(sensors_event_t)) {
+ connection->sendEvents(&event, 1);
+ }
+ }
}
if (err == NO_ERROR) {
// connection now active
@@ -430,18 +497,27 @@
sensors_event_t* scratch)
{
// filter out events not for this connection
- size_t count=0, i=0;
- while (i<numEvents) {
- const int32_t curr = buffer[i].sensor;
- if (mSensorInfo.indexOfKey(curr) >= 0) {
- do {
- scratch[count++] = buffer[i++];
- } while ((i<numEvents) && (buffer[i].sensor == curr));
- } else {
- i++;
+ size_t count = 0;
+ if (scratch) {
+ size_t i=0;
+ while (i<numEvents) {
+ const int32_t curr = buffer[i].sensor;
+ if (mSensorInfo.indexOfKey(curr) >= 0) {
+ do {
+ scratch[count++] = buffer[i++];
+ } while ((i<numEvents) && (buffer[i].sensor == curr));
+ } else {
+ i++;
+ }
}
+ } else {
+ scratch = const_cast<sensors_event_t *>(buffer);
+ count = numEvents;
}
+ if (count == 0)
+ return 0;
+
ssize_t size = mChannel->write(scratch, count*sizeof(sensors_event_t));
if (size == -EAGAIN) {
// the destination doesn't accept events anymore, it's probably
diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h
index f77652d..9f37799 100644
--- a/services/sensorservice/SensorService.h
+++ b/services/sensorservice/SensorService.h
@@ -87,7 +87,7 @@
SensorEventConnection(const sp<SensorService>& service);
status_t sendEvents(sensors_event_t const* buffer, size_t count,
- sensors_event_t* scratch);
+ sensors_event_t* scratch = NULL);
bool hasSensor(int32_t handle) const;
bool hasAnySensor() const;
bool addSensor(int32_t handle);
@@ -123,6 +123,9 @@
DefaultKeyedVector<int, SensorRecord*> mActiveSensors;
SortedVector< wp<SensorEventConnection> > mActiveConnections;
+ // The size of this vector is constant, only the items are mutable
+ KeyedVector<int32_t, sensors_event_t> mLastEventSeen;
+
public:
static char const* getServiceName() { return "sensorservice"; }
diff --git a/telephony/java/com/android/internal/telephony/CallManager.java b/telephony/java/com/android/internal/telephony/CallManager.java
index 9a13a5f..1381a2d 100644
--- a/telephony/java/com/android/internal/telephony/CallManager.java
+++ b/telephony/java/com/android/internal/telephony/CallManager.java
@@ -16,8 +16,6 @@
package com.android.internal.telephony;
-
-
import android.content.Context;
import android.os.AsyncResult;
import android.os.Handler;
@@ -25,7 +23,6 @@
import android.os.RegistrantList;
import android.telephony.PhoneStateListener;
-
import java.util.ArrayList;
import java.util.List;
@@ -49,8 +46,23 @@
public final class CallManager {
private static final int EVENT_DISCONNECT = 100;
- private static final int EVENT_CALL_STATE_CHANGED = 101;
-
+ private static final int EVENT_PRECISE_CALL_STATE_CHANGED = 101;
+ private static final int EVENT_NEW_RINGING_CONNECTION = 102;
+ private static final int EVENT_UNKNOWN_CONNECTION = 103;
+ private static final int EVENT_INCOMING_RING = 104;
+ private static final int EVENT_RINGBACK_TONE = 105;
+ private static final int EVENT_IN_CALL_VOICE_PRIVACY_ON = 106;
+ private static final int EVENT_IN_CALL_VOICE_PRIVACY_OFF = 107;
+ private static final int EVENT_CALL_WAITING = 108;
+ private static final int EVENT_DISPLAY_INFO = 109;
+ private static final int EVENT_SIGNAL_INFO = 110;
+ private static final int EVENT_CDMA_OTA_STATUS_CHANGE = 111;
+ private static final int EVENT_RESEND_INCALL_MUTE = 112;
+ private static final int EVENT_MMI_INITIATE = 113;
+ private static final int EVENT_MMI_COMPLETE = 114;
+ private static final int EVENT_ECM_TIMER_RESET = 115;
+ private static final int EVENT_SUBSCRIPTION_INFO_READY = 116;
+ private static final int EVENT_SUPP_SERVICE_FAILED = 117;
// Singleton instance
private static final CallManager INSTANCE = new CallManager();
@@ -89,15 +101,48 @@
protected final RegistrantList mServiceStateRegistrants
= new RegistrantList();
- protected final RegistrantList mMmiCompleteRegistrants
- = new RegistrantList();
-
protected final RegistrantList mMmiRegistrants
= new RegistrantList();
protected final RegistrantList mUnknownConnectionRegistrants
= new RegistrantList();
+ protected final RegistrantList mRingbackToneRegistrants
+ = new RegistrantList();
+
+ protected final RegistrantList mInCallVoicePrivacyOnRegistrants
+ = new RegistrantList();
+
+ protected final RegistrantList mInCallVoicePrivacyOffRegistrants
+ = new RegistrantList();
+
+ protected final RegistrantList mCallWaitingRegistrants
+ = new RegistrantList();
+
+ protected final RegistrantList mDisplayInfoRegistrants
+ = new RegistrantList();
+
+ protected final RegistrantList mSignalInfoRegistrants
+ = new RegistrantList();
+
+ protected final RegistrantList mCdmaOtaStatusChangeRegistrants
+ = new RegistrantList();
+
+ protected final RegistrantList mResendIncallMuteRegistrants
+ = new RegistrantList();
+
+ protected final RegistrantList mMmiInitiateRegistrants
+ = new RegistrantList();
+
+ protected final RegistrantList mMmiCompleteRegistrants
+ = new RegistrantList();
+
+ protected final RegistrantList mEcmTimerResetRegistrants
+ = new RegistrantList();
+
+ protected final RegistrantList mSubscriptionInfoReadyRegistrants
+ = new RegistrantList();
+
protected final RegistrantList mSuppServiceFailedRegistrants
= new RegistrantList();
@@ -118,9 +163,28 @@
}
/**
+ * Get current coarse-grained voice call state.
+ * If the Call Manager has an active call and call waiting occurs,
+ * then the phone state is RINGING not OFFHOOK
+ *
+ */
+ public Phone.State getState() {
+ Phone.State s = Phone.State.IDLE;
+
+ for(Phone phone : mPhones) {
+ if (phone.getState() == Phone.State.RINGING) {
+ return Phone.State.RINGING;
+ } else if (phone.getState() == Phone.State.OFFHOOK) {
+ s = Phone.State.OFFHOOK;
+ }
+ }
+ return s;
+ }
+
+ /**
* Register phone to CallManager
* @param phone
- * @return
+ * @return true if register successfully
*/
public boolean registerPhone(Phone phone) {
if (phone != null && !mPhones.contains(phone)) {
@@ -159,13 +223,45 @@
}
private void registerForPhoneStates(Phone phone) {
- phone.registerForPreciseCallStateChanged(mHandler, EVENT_CALL_STATE_CHANGED, null);
+ phone.registerForPreciseCallStateChanged(mHandler, EVENT_PRECISE_CALL_STATE_CHANGED, null);
phone.registerForDisconnect(mHandler, EVENT_DISCONNECT, null);
+ phone.registerForNewRingingConnection(mHandler, EVENT_NEW_RINGING_CONNECTION, null);
+ phone.registerForUnknownConnection(mHandler, EVENT_UNKNOWN_CONNECTION, null);
+ phone.registerForIncomingRing(mHandler, EVENT_INCOMING_RING, null);
+ phone.registerForRingbackTone(mHandler, EVENT_RINGBACK_TONE, null);
+ phone.registerForInCallVoicePrivacyOn(mHandler, EVENT_IN_CALL_VOICE_PRIVACY_ON, null);
+ phone.registerForInCallVoicePrivacyOff(mHandler, EVENT_IN_CALL_VOICE_PRIVACY_OFF, null);
+ phone.registerForCallWaiting(mHandler, EVENT_CALL_WAITING, null);
+ phone.registerForDisplayInfo(mHandler, EVENT_DISPLAY_INFO, null);
+ phone.registerForSignalInfo(mHandler, EVENT_SIGNAL_INFO, null);
+ phone.registerForCdmaOtaStatusChange(mHandler, EVENT_CDMA_OTA_STATUS_CHANGE, null);
+ phone.registerForResendIncallMute(mHandler, EVENT_RESEND_INCALL_MUTE, null);
+ phone.registerForMmiInitiate(mHandler, EVENT_MMI_INITIATE, null);
+ phone.registerForMmiComplete(mHandler, EVENT_MMI_COMPLETE, null);
+ phone.registerForEcmTimerReset(mHandler, EVENT_ECM_TIMER_RESET, null);
+ phone.registerForSubscriptionInfoReady(mHandler, EVENT_SUBSCRIPTION_INFO_READY, null);
+ phone.registerForSuppServiceFailed(mHandler, EVENT_SUPP_SERVICE_FAILED, null);
}
private void unregisterForPhoneStates(Phone phone) {
phone.unregisterForPreciseCallStateChanged(mHandler);
phone.unregisterForDisconnect(mHandler);
+ phone.unregisterForNewRingingConnection(mHandler);
+ phone.unregisterForUnknownConnection(mHandler);
+ phone.unregisterForIncomingRing(mHandler);
+ phone.unregisterForRingbackTone(mHandler);
+ phone.unregisterForInCallVoicePrivacyOn(mHandler);
+ phone.unregisterForInCallVoicePrivacyOff(mHandler);
+ phone.unregisterForCallWaiting(mHandler);
+ phone.unregisterForDisplayInfo(mHandler);
+ phone.unregisterForSignalInfo(mHandler);
+ phone.unregisterForCdmaOtaStatusChange(mHandler);
+ phone.unregisterForResendIncallMute(mHandler);
+ phone.unregisterForMmiInitiate(mHandler);
+ phone.unregisterForMmiComplete(mHandler);
+ phone.unregisterForEcmTimerReset(mHandler);
+ phone.unregisterForSubscriptionInfoReady(mHandler);
+ phone.unregisterForSuppServiceFailed(mHandler);
}
/**
@@ -523,12 +619,16 @@
* Notifies when a previously untracked non-ringing/waiting connection has appeared.
* This is likely due to some other entity (eg, SIM card application) initiating a call.
*/
- public void registerForUnknownConnection(Handler h, int what, Object obj){}
+ public void registerForUnknownConnection(Handler h, int what, Object obj){
+ mUnknownConnectionRegistrants.addUnique(h, what, obj);
+ }
/**
* Unregisters for unknown connection notifications.
*/
- public void unregisterForUnknownConnection(Handler h){}
+ public void unregisterForUnknownConnection(Handler h){
+ mUnknownConnectionRegistrants.remove(h);
+ }
/**
@@ -543,14 +643,18 @@
* If Connection.isRinging() is true, then
* Connection.getCall() == Phone.getRingingCall()
*/
- public void registerForNewRingingConnection(Handler h, int what, Object obj){}
+ public void registerForNewRingingConnection(Handler h, int what, Object obj){
+ mNewRingingConnectionRegistrants.addUnique(h, what, obj);
+ }
/**
* Unregisters for new ringing connection notification.
* Extraneous calls are tolerated silently
*/
- public void unregisterForNewRingingConnection(Handler h){}
+ public void unregisterForNewRingingConnection(Handler h){
+ mNewRingingConnectionRegistrants.remove(h);
+ }
/**
* Notifies when an incoming call rings.<p>
@@ -560,14 +664,18 @@
* AsyncResult.userObj = obj
* AsyncResult.result = a Connection. <p>
*/
- public void registerForIncomingRing(Handler h, int what, Object obj){}
+ public void registerForIncomingRing(Handler h, int what, Object obj){
+ mIncomingRingRegistrants.addUnique(h, what, obj);
+ }
/**
* Unregisters for ring notification.
* Extraneous calls are tolerated silently
*/
- public void unregisterForIncomingRing(Handler h){}
+ public void unregisterForIncomingRing(Handler h){
+ mIncomingRingRegistrants.remove(h);
+ }
/**
* Notifies when out-band ringback tone is needed.<p>
@@ -578,26 +686,32 @@
* AsyncResult.result = boolean, true to start play ringback tone
* and false to stop. <p>
*/
- public void registerForRingbackTone(Handler h, int what, Object obj){}
+ public void registerForRingbackTone(Handler h, int what, Object obj){
+ mRingbackToneRegistrants.addUnique(h, what, obj);
+ }
/**
* Unregisters for ringback tone notification.
*/
- public void unregisterForRingbackTone(Handler h){}
+ public void unregisterForRingbackTone(Handler h){
+ mRingbackToneRegistrants.remove(h);
+ }
/**
* Registers the handler to reset the uplink mute state to get
* uplink audio.
*/
- public void registerForResendIncallMute(Handler h, int what, Object obj){}
+ public void registerForResendIncallMute(Handler h, int what, Object obj){
+ mResendIncallMuteRegistrants.addUnique(h, what, obj);
+ }
/**
* Unregisters for resend incall mute notifications.
*/
- public void unregisterForResendIncallMute(Handler h){}
-
-
+ public void unregisterForResendIncallMute(Handler h){
+ mResendIncallMuteRegistrants.remove(h);
+ }
/**
* Register for notifications of initiation of a new MMI code request.
@@ -610,13 +724,17 @@
*
* <code>obj.result</code> will be an "MmiCode" object.
*/
- public void registerForMmiInitiate(Handler h, int what, Object obj){}
+ public void registerForMmiInitiate(Handler h, int what, Object obj){
+ mMmiInitiateRegistrants.addUnique(h, what, obj);
+ }
/**
* Unregisters for new MMI initiate notification.
* Extraneous calls are tolerated silently
*/
- public void unregisterForMmiInitiate(Handler h){}
+ public void unregisterForMmiInitiate(Handler h){
+ mMmiInitiateRegistrants.remove(h);
+ }
/**
* Register for notifications that an MMI request has completed
@@ -626,13 +744,17 @@
* <code>Message.obj</code> will contain an AsyncResult.
* <code>obj.result</code> will be an "MmiCode" object
*/
- public void registerForMmiComplete(Handler h, int what, Object obj){}
+ public void registerForMmiComplete(Handler h, int what, Object obj){
+ mMmiCompleteRegistrants.addUnique(h, what, obj);
+ }
/**
* Unregisters for MMI complete notification.
* Extraneous calls are tolerated silently
*/
- public void unregisterForMmiComplete(Handler h){}
+ public void unregisterForMmiComplete(Handler h){
+ mMmiCompleteRegistrants.remove(h);
+ }
/**
* Registration point for Ecm timer reset
@@ -640,15 +762,17 @@
* @param what user-defined message code
* @param obj placed in Message.obj
*/
- public void registerForEcmTimerReset(Handler h, int what, Object obj){}
+ public void registerForEcmTimerReset(Handler h, int what, Object obj){
+ mEcmTimerResetRegistrants.addUnique(h, what, obj);
+ }
/**
* Unregister for notification for Ecm timer reset
* @param h Handler to be removed from the registrant list.
*/
- public void unregisterForEcmTimerReset(Handler h){}
-
-
+ public void unregisterForEcmTimerReset(Handler h){
+ mEcmTimerResetRegistrants.remove(h);
+ }
/**
* Register for ServiceState changed.
@@ -664,25 +788,6 @@
public void unregisterForServiceStateChanged(Handler h){}
/**
- * Register for Supplementary Service notifications from the network.
- * Message.obj will contain an AsyncResult.
- * AsyncResult.result will be a SuppServiceNotification instance.
- *
- * @param h Handler that receives the notification message.
- * @param what User-defined message code.
- * @param obj User object.
- */
- public void registerForSuppServiceNotification(Handler h, int what, Object obj){}
-
- /**
- * Unregisters for Supplementary Service notifications.
- * Extraneous calls are tolerated silently
- *
- * @param h Handler to be removed from the registrant list.
- */
- public void unregisterForSuppServiceNotification(Handler h){}
-
- /**
* Register for notifications when a supplementary service attempt fails.
* Message.obj will contain an AsyncResult.
*
@@ -690,7 +795,9 @@
* @param what User-defined message code.
* @param obj User object.
*/
- public void registerForSuppServiceFailed(Handler h, int what, Object obj){}
+ public void registerForSuppServiceFailed(Handler h, int what, Object obj){
+ mSuppServiceFailedRegistrants.addUnique(h, what, obj);
+ }
/**
* Unregister for notifications when a supplementary service attempt fails.
@@ -698,7 +805,9 @@
*
* @param h Handler to be removed from the registrant list.
*/
- public void unregisterForSuppServiceFailed(Handler h){}
+ public void unregisterForSuppServiceFailed(Handler h){
+ mSuppServiceFailedRegistrants.remove(h);
+ }
/**
* Register for notifications when a sInCall VoicePrivacy is enabled
@@ -707,14 +816,18 @@
* @param what User-defined message code.
* @param obj User object.
*/
- public void registerForInCallVoicePrivacyOn(Handler h, int what, Object obj){}
+ public void registerForInCallVoicePrivacyOn(Handler h, int what, Object obj){
+ mInCallVoicePrivacyOnRegistrants.addUnique(h, what, obj);
+ }
/**
- * Unegister for notifications when a sInCall VoicePrivacy is enabled
+ * Unregister for notifications when a sInCall VoicePrivacy is enabled
*
* @param h Handler to be removed from the registrant list.
*/
- public void unregisterForInCallVoicePrivacyOn(Handler h){}
+ public void unregisterForInCallVoicePrivacyOn(Handler h){
+ mInCallVoicePrivacyOnRegistrants.remove(h);
+ }
/**
* Register for notifications when a sInCall VoicePrivacy is disabled
@@ -723,14 +836,85 @@
* @param what User-defined message code.
* @param obj User object.
*/
- public void registerForInCallVoicePrivacyOff(Handler h, int what, Object obj){}
+ public void registerForInCallVoicePrivacyOff(Handler h, int what, Object obj){
+ mInCallVoicePrivacyOffRegistrants.addUnique(h, what, obj);
+ }
/**
- * Unegister for notifications when a sInCall VoicePrivacy is disabled
+ * Unregister for notifications when a sInCall VoicePrivacy is disabled
*
* @param h Handler to be removed from the registrant list.
*/
- public void unregisterForInCallVoicePrivacyOff(Handler h){}
+ public void unregisterForInCallVoicePrivacyOff(Handler h){
+ mInCallVoicePrivacyOffRegistrants.remove(h);
+ }
+
+ /**
+ * Register for notifications when CDMA call waiting comes
+ *
+ * @param h Handler that receives the notification message.
+ * @param what User-defined message code.
+ * @param obj User object.
+ */
+ public void registerForCallWaiting(Handler h, int what, Object obj){
+ mCallWaitingRegistrants.addUnique(h, what, obj);
+ }
+
+ /**
+ * Unregister for notifications when CDMA Call waiting comes
+ * @param h Handler to be removed from the registrant list.
+ */
+ public void unregisterForCallWaiting(Handler h){
+ mCallWaitingRegistrants.remove(h);
+ }
+
+
+ /**
+ * Register for signal information notifications from the network.
+ * Message.obj will contain an AsyncResult.
+ * AsyncResult.result will be a SuppServiceNotification instance.
+ *
+ * @param h Handler that receives the notification message.
+ * @param what User-defined message code.
+ * @param obj User object.
+ */
+
+ public void registerForSignalInfo(Handler h, int what, Object obj){
+ mSignalInfoRegistrants.addUnique(h, what, obj);
+ }
+
+ /**
+ * Unregisters for signal information notifications.
+ * Extraneous calls are tolerated silently
+ *
+ * @param h Handler to be removed from the registrant list.
+ */
+ public void unregisterForSignalInfo(Handler h){
+ mSignalInfoRegistrants.remove(h);
+ }
+
+ /**
+ * Register for display information notifications from the network.
+ * Message.obj will contain an AsyncResult.
+ * AsyncResult.result will be a SuppServiceNotification instance.
+ *
+ * @param h Handler that receives the notification message.
+ * @param what User-defined message code.
+ * @param obj User object.
+ */
+ public void registerForDisplayInfo(Handler h, int what, Object obj){
+ mDisplayInfoRegistrants.addUnique(h, what, obj);
+ }
+
+ /**
+ * Unregisters for display information notifications.
+ * Extraneous calls are tolerated silently
+ *
+ * @param h Handler to be removed from the registrant list.
+ */
+ public void unregisterForDisplayInfo(Handler h) {
+ mDisplayInfoRegistrants.remove(h);
+ }
/**
* Register for notifications when CDMA OTA Provision status change
@@ -739,13 +923,17 @@
* @param what User-defined message code.
* @param obj User object.
*/
- public void registerForCdmaOtaStatusChange(Handler h, int what, Object obj){}
+ public void registerForCdmaOtaStatusChange(Handler h, int what, Object obj){
+ mCdmaOtaStatusChangeRegistrants.addUnique(h, what, obj);
+ }
/**
- * Unegister for notifications when CDMA OTA Provision status change
+ * Unregister for notifications when CDMA OTA Provision status change
* @param h Handler to be removed from the registrant list.
*/
- public void unregisterForCdmaOtaStatusChange(Handler h){}
+ public void unregisterForCdmaOtaStatusChange(Handler h){
+ mCdmaOtaStatusChangeRegistrants.remove(h);
+ }
/**
* Registration point for subscription info ready
@@ -753,13 +941,17 @@
* @param what what code of message when delivered
* @param obj placed in Message.obj
*/
- public void registerForSubscriptionInfoReady(Handler h, int what, Object obj){}
+ public void registerForSubscriptionInfoReady(Handler h, int what, Object obj){
+ mSubscriptionInfoReadyRegistrants.addUnique(h, what, obj);
+ }
/**
* Unregister for notifications for subscription info
* @param h Handler to be removed from the registrant list.
*/
- public void unregisterForSubscriptionInfoReady(Handler h){}
+ public void unregisterForSubscriptionInfoReady(Handler h){
+ mSubscriptionInfoReadyRegistrants.remove(h);
+ }
/* APIs to access foregroudCalls, backgroudCalls, and ringingCalls
* 1. APIs to access list of calls
@@ -974,9 +1166,57 @@
case EVENT_DISCONNECT:
mDisconnectRegistrants.notifyRegistrants((AsyncResult) msg.obj);
break;
- case EVENT_CALL_STATE_CHANGED:
+ case EVENT_PRECISE_CALL_STATE_CHANGED:
mPreciseCallStateRegistrants.notifyRegistrants((AsyncResult) msg.obj);
break;
+ case EVENT_NEW_RINGING_CONNECTION:
+ mNewRingingConnectionRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_UNKNOWN_CONNECTION:
+ mUnknownConnectionRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_INCOMING_RING:
+ mIncomingRingRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_RINGBACK_TONE:
+ mRingbackToneRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_IN_CALL_VOICE_PRIVACY_ON:
+ mInCallVoicePrivacyOnRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_IN_CALL_VOICE_PRIVACY_OFF:
+ mInCallVoicePrivacyOffRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_CALL_WAITING:
+ mCallWaitingRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_DISPLAY_INFO:
+ mDisplayInfoRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_SIGNAL_INFO:
+ mSignalInfoRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_CDMA_OTA_STATUS_CHANGE:
+ mCdmaOtaStatusChangeRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_RESEND_INCALL_MUTE:
+ mResendIncallMuteRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_MMI_INITIATE:
+ mMmiInitiateRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_MMI_COMPLETE:
+ mMmiCompleteRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_ECM_TIMER_RESET:
+ mEcmTimerResetRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_SUBSCRIPTION_INFO_READY:
+ mSubscriptionInfoReadyRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
+ case EVENT_SUPP_SERVICE_FAILED:
+ mSuppServiceFailedRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ break;
}
}
};
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaCall.java b/telephony/java/com/android/internal/telephony/cdma/CdmaCall.java
index c3bb01f..4ad61bb 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaCall.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaCall.java
@@ -75,8 +75,7 @@
public Phone
getPhone() {
- //TODO, see GsmCall
- return null;
+ return owner.phone;
}
public boolean isMultiparty() {
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmCall.java b/telephony/java/com/android/internal/telephony/gsm/GsmCall.java
index 9542d20..58124a2 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmCall.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmCall.java
@@ -70,8 +70,7 @@
public Phone
getPhone() {
- //TODO
- return null;
+ return owner.phone;
}
public boolean
diff --git a/telephony/tests/telephonytests/Android.mk b/telephony/tests/telephonytests/Android.mk
index 45e265a..98e4403 100644
--- a/telephony/tests/telephonytests/Android.mk
+++ b/telephony/tests/telephonytests/Android.mk
@@ -5,6 +5,8 @@
LOCAL_SRC_FILES := $(call all-subdir-java-files)
+LOCAL_STATIC_JAVA_LIBRARIES := librilproto-java
+
LOCAL_JAVA_LIBRARIES := android.test.runner
LOCAL_PACKAGE_NAME := FrameworksTelephonyTests
diff --git a/telephony/tests/telephonytests/AndroidManifest.xml b/telephony/tests/telephonytests/AndroidManifest.xml
index 6a97423..ba1d957 100644
--- a/telephony/tests/telephonytests/AndroidManifest.xml
+++ b/telephony/tests/telephonytests/AndroidManifest.xml
@@ -32,6 +32,13 @@
android:targetPackage="com.android.frameworks.telephonytests"
android:label="Frameworks Telephony Tests">
</instrumentation>
+
+ <instrumentation android:name=".TelephonyMockRilTestRunner"
+ android:targetPackage="com.android.frameworks.telephonytests"
+ android:label="Test Runner for Mock Ril Tests"
+ />
+
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
+ <uses-permission android:name="android.permission.INTERNET" />
</manifest>
diff --git a/telephony/tests/telephonytests/src/com/android/frameworks/telephonytests/TelephonyMockRilTestRunner.java b/telephony/tests/telephonytests/src/com/android/frameworks/telephonytests/TelephonyMockRilTestRunner.java
new file mode 100644
index 0000000..9192f57
--- /dev/null
+++ b/telephony/tests/telephonytests/src/com/android/frameworks/telephonytests/TelephonyMockRilTestRunner.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2010, 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.frameworks.telephonytests;
+
+import android.os.Bundle;
+
+import android.test.InstrumentationTestRunner;
+import android.test.InstrumentationTestSuite;
+import android.util.Log;
+
+import java.io.IOException;
+
+import com.android.internal.telephony.RilChannel;
+import com.android.internal.telephony.mockril.MockRilTest;
+
+import junit.framework.TestSuite;
+
+public class TelephonyMockRilTestRunner extends InstrumentationTestRunner {
+
+ public RilChannel mMockRilChannel;
+
+ @Override
+ public TestSuite getAllTests() {
+ log("getAllTests E");
+ TestSuite suite = new InstrumentationTestSuite(this);
+ suite.addTestSuite(MockRilTest.class);
+ log("getAllTests X");
+ return suite;
+ }
+
+ @Override
+ public ClassLoader getLoader() {
+ log("getLoader EX");
+ return TelephonyMockRilTestRunner.class.getClassLoader();
+ }
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ log("onCreate E");
+ try {
+ mMockRilChannel = RilChannel.makeRilChannel();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ log("onCreate X");
+
+ super.onCreate(icicle);
+ }
+
+ @Override
+ public void onDestroy() {
+ // I've not seen this called
+ log("onDestroy EX");
+ super.onDestroy();
+ }
+
+ @Override
+ public void onStart() {
+ // Called when the instrumentation thread is started.
+ // At the moment we don't need the thread so return
+ // which will shut down this unused thread.
+ log("onStart EX");
+ super.onStart();
+ }
+
+ @Override
+ public void finish(int resultCode, Bundle results) {
+ // Called when complete so I ask the mMockRilChannel to quit.
+ log("finish E");
+ mMockRilChannel.close();
+ log("finish X");
+ super.finish(resultCode, results);
+ }
+
+ private void log(String s) {
+ Log.e("TelephonyMockRilTestRunner", s);
+ }
+}
diff --git a/telephony/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java b/telephony/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java
new file mode 100644
index 0000000..ee03b7c
--- /dev/null
+++ b/telephony/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2010 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.internal.telephony.mockril;
+
+import android.util.Log;
+import android.test.InstrumentationTestCase;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import com.android.internal.communication.MsgHeader;
+import com.android.internal.communication.Msg;
+import com.android.internal.telephony.RilChannel;
+import com.android.internal.telephony.ril_proto.RilCtrlCmds;
+
+import com.android.frameworks.telephonytests.TelephonyMockRilTestRunner;
+import com.google.protobuf.micro.InvalidProtocolBufferMicroException;
+
+// Test suite for test ril
+public class MockRilTest extends InstrumentationTestCase {
+ private static final String TAG = "MockRilTest";
+
+ RilChannel mMockRilChannel;
+ TelephonyMockRilTestRunner mRunner;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mRunner = (TelephonyMockRilTestRunner)getInstrumentation();
+ mMockRilChannel = mRunner.mMockRilChannel;
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ static void log(String s) {
+ Log.v(TAG, s);
+ }
+
+ /**
+ * Test protobuf serialization and deserialization
+ * @throws InvalidProtocolBufferMicroException
+ */
+ public void testProtobufSerDes() throws InvalidProtocolBufferMicroException {
+ log("testProtobufSerdes E");
+
+ RilCtrlCmds.CtrlRspRadioState rs = new RilCtrlCmds.CtrlRspRadioState();
+ assertTrue(String.format("expected rs.state == 0 was %d", rs.getState()),
+ rs.getState() == 0);
+ rs.setState(1);
+ assertTrue(String.format("expected rs.state == 1 was %d", rs.getState()),
+ rs.getState() == 1);
+
+ byte[] rs_ser = rs.toByteArray();
+ RilCtrlCmds.CtrlRspRadioState rsNew = RilCtrlCmds.CtrlRspRadioState.parseFrom(rs_ser);
+ assertTrue(String.format("expected rsNew.state == 1 was %d", rs.getState()),
+ rs.getState() == 1);
+
+ log("testProtobufSerdes X");
+ }
+
+ /**
+ * Test echo command works using writeMsg & readMsg
+ */
+ public void testEchoMsg() throws IOException {
+ log("testEchoMsg E");
+
+ MsgHeader mh = new MsgHeader();
+ mh.setCmd(0);
+ mh.setToken(1);
+ mh.setStatus(2);
+ ByteBuffer data = ByteBuffer.allocate(3);
+ data.put((byte)3);
+ data.put((byte)4);
+ data.put((byte)5);
+ Msg.send(mMockRilChannel, mh, data);
+
+ Msg respMsg = Msg.recv(mMockRilChannel);
+ assertTrue(String.format("expected mhd.header.cmd == 0 was %d",respMsg.getCmd()),
+ respMsg.getCmd() == 0);
+ assertTrue(String.format("expected mhd.header.token == 1 was %d",respMsg.getToken()),
+ respMsg.getToken() == 1);
+ assertTrue(String.format("expected mhd.header.status == 2 was %d", respMsg.getStatus()),
+ respMsg.getStatus() == 2);
+ assertTrue(String.format("expected mhd.data[0] == 3 was %d", respMsg.getData(0)),
+ respMsg.getData(0) == 3);
+ assertTrue(String.format("expected mhd.data[1] == 4 was %d", respMsg.getData(1)),
+ respMsg.getData(1) == 4);
+ assertTrue(String.format("expected mhd.data[2] == 5 was %d", respMsg.getData(2)),
+ respMsg.getData(2) == 5);
+
+ log("testEchoMsg X");
+ }
+
+ /**
+ * Test get as
+ */
+ public void testGetAs() {
+ log("testGetAs E");
+
+ // Use a message header as the protobuf data content
+ MsgHeader mh = new MsgHeader();
+ mh.setCmd(12345);
+ mh.setToken(9876);
+ mh.setStatus(7654);
+ mh.setLengthData(4321);
+ byte[] data = mh.toByteArray();
+ MsgHeader mhResult = Msg.getAs(MsgHeader.class, data);
+
+ assertTrue(String.format("expected cmd == 12345 was %d", mhResult.getCmd()),
+ mhResult.getCmd() == 12345);
+ assertTrue(String.format("expected token == 9876 was %d", mhResult.getToken()),
+ mhResult.getToken() == 9876);
+ assertTrue(String.format("expected status == 7654 was %d", mhResult.getStatus()),
+ mhResult.getStatus() == 7654);
+ assertTrue(String.format("expected lengthData == 4321 was %d", mhResult.getLengthData()),
+ mhResult.getLengthData() == 4321);
+
+ Msg msg = Msg.obtain();
+ msg.setData(ByteBuffer.wrap(data));
+
+ mhResult = msg.getDataAs(MsgHeader.class);
+
+ assertTrue(String.format("expected cmd == 12345 was %d", mhResult.getCmd()),
+ mhResult.getCmd() == 12345);
+ assertTrue(String.format("expected token == 9876 was %d", mhResult.getToken()),
+ mhResult.getToken() == 9876);
+ assertTrue(String.format("expected status == 7654 was %d", mhResult.getStatus()),
+ mhResult.getStatus() == 7654);
+ assertTrue(String.format("expected lengthData == 4321 was %d", mhResult.getLengthData()),
+ mhResult.getLengthData() == 4321);
+
+ log("testGetAs X");
+ }
+
+ public void testGetRadioState() throws IOException {
+ log("testGetRadioState E");
+
+ Msg.send(mMockRilChannel, 1, 9876, 0, null);
+
+ Msg resp = Msg.recv(mMockRilChannel);
+ //resp.printHeader("testGetRadioState");
+
+ assertTrue(String.format("expected cmd == 1 was %d", resp.getCmd()),
+ resp.getCmd() == 1);
+ assertTrue(String.format("expected token == 9876 was %d", resp.getToken()),
+ resp.getToken() == 9876);
+ assertTrue(String.format("expected status == 0 was %d", resp.getStatus()),
+ resp.getStatus() == 0);
+
+ RilCtrlCmds.CtrlRspRadioState rsp = resp.getDataAs(RilCtrlCmds.CtrlRspRadioState.class);
+
+ int state = rsp.getState();
+ log("testGetRadioState state=" + state);
+ assertTrue(String.format("expected RadioState >= 0 && RadioState <= 9 was %d", state),
+ ((state >= 0) && (state <= 9)));
+
+ log("testGetRadioState X");
+ }
+}