summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.xml11
-rw-r--r--core/java/android/app/Activity.java2
-rw-r--r--core/java/android/app/ApplicationErrorReport.java68
-rw-r--r--core/java/android/content/pm/PackageParser.java10
-rw-r--r--core/java/android/database/sqlite/SQLiteDatabase.java59
-rw-r--r--core/java/android/database/sqlite/SQLiteStatement.java26
-rw-r--r--core/java/android/os/BatteryStats.java22
-rw-r--r--core/java/android/provider/Downloads.java7
-rw-r--r--core/java/com/android/internal/app/IBatteryStats.aidl7
-rw-r--r--core/java/com/android/internal/app/ShutdownThread.java6
-rw-r--r--core/java/com/android/internal/os/BatteryStatsImpl.java214
-rw-r--r--core/jni/android/graphics/TextLayout.cpp10
-rw-r--r--core/jni/android/graphics/TextLayout.h2
-rw-r--r--core/jni/android_database_SQLiteDatabase.cpp76
-rw-r--r--core/jni/android_database_SQLiteStatement.cpp30
-rw-r--r--core/jni/android_view_GLES20Canvas.cpp4
-rw-r--r--core/tests/coretests/src/android/database/DatabaseGeneralTest.java61
-rw-r--r--core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java280
-rw-r--r--core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java388
-rw-r--r--core/tests/hosttests/src/android/content/pm/PackageManagerStressHostTests.java21
-rw-r--r--libs/hwui/FontRenderer.cpp66
-rw-r--r--libs/hwui/FontRenderer.h11
-rw-r--r--libs/hwui/OpenGLRenderer.cpp2
-rwxr-xr-xmedia/libeffects/lvm/lib/Bass/src/LVDBE_Control.c22
-rwxr-xr-xmedia/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c4
-rwxr-xr-xmedia/libeffects/lvm/lib/Bundle/src/LVM_Control.c9
-rwxr-xr-xmedia/libeffects/lvm/lib/Bundle/src/LVM_Init.c4
-rwxr-xr-xmedia/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c12
-rwxr-xr-xmedia/libeffects/lvm/lib/Eq/src/LVEQNB_Control.c4
-rwxr-xr-xmedia/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.c16
-rwxr-xr-xmedia/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c69
-rwxr-xr-xmedia/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c11
-rwxr-xr-xmedia/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c29
-rwxr-xr-xmedia/libeffects/lvm/lib/StereoWidening/src/LVCS_Private.h9
-rwxr-xr-xmedia/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.c8
-rwxr-xr-xmedia/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c12
-rw-r--r--media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp40
-rw-r--r--packages/DefaultContainerService/res/values/strings.xml2
-rw-r--r--services/java/com/android/server/PackageManagerService.java26
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java33
-rw-r--r--services/sensorservice/SensorService.cpp126
-rw-r--r--services/sensorservice/SensorService.h5
-rw-r--r--telephony/java/com/android/internal/telephony/CallManager.java348
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CdmaCall.java3
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmCall.java3
45 files changed, 1472 insertions, 706 deletions
diff --git a/api/current.xml b/api/current.xml
index 96ca9e919086..52b72175ca51 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/Activity.java b/core/java/android/app/Activity.java
index 48d0d81f5c6d..431f66de1dda 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -775,7 +775,7 @@ public class Activity extends ContextThemeWrapper
if (mLoaderManager != null) {
return mLoaderManager;
}
- mLoaderManager = getLoaderManager(-1, false);
+ mLoaderManager = getLoaderManager(-1, mStarted);
return mLoaderManager;
}
diff --git a/core/java/android/app/ApplicationErrorReport.java b/core/java/android/app/ApplicationErrorReport.java
index 48cbd46d19bf..ddc2b1f5222b 100644
--- a/core/java/android/app/ApplicationErrorReport.java
+++ b/core/java/android/app/ApplicationErrorReport.java
@@ -79,6 +79,11 @@ public class ApplicationErrorReport implements Parcelable {
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 class ApplicationErrorReport implements Parcelable {
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 @@ public class ApplicationErrorReport implements Parcelable {
case TYPE_BATTERY:
batteryInfo.writeToParcel(dest, flags);
break;
+ case TYPE_RUNNING_SERVICE:
+ runningServiceInfo.writeToParcel(dest, flags);
+ break;
}
}
@@ -239,16 +253,25 @@ public class ApplicationErrorReport implements Parcelable {
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 @@ public class ApplicationErrorReport implements Parcelable {
}
}
+ /**
+ * 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 6098617eba20..8e9385590447 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2792,6 +2792,9 @@ public class PackageParser {
// 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 @@ public class PackageParser {
}
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 @@ public class PackageParser {
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 cf4d07ffcb4e..623821b6f0dd 100644
--- a/core/java/android/database/sqlite/SQLiteDatabase.java
+++ b/core/java/android/database/sqlite/SQLiteDatabase.java
@@ -67,7 +67,7 @@ import java.util.regex.Pattern;
* 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 @@ public class SQLiteDatabase extends SQLiteClosable {
}
// 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 @@ public class SQLiteDatabase extends SQLiteClosable {
DatabaseUtils.bindObjectToProgram(statement, i + 1, whereArgs[i]);
}
}
- statement.execute();
- return lastChangeCount();
+ return statement.executeUpdateDelete();
} catch (SQLiteDatabaseCorruptException e) {
onCorruption();
throw e;
@@ -1782,12 +1770,7 @@ public class SQLiteDatabase extends SQLiteClosable {
}
// 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 @@ public class SQLiteDatabase extends SQLiteClosable {
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 @@ public class SQLiteDatabase extends SQLiteClosable {
DatabaseUtils.bindObjectToProgram(statement, i + 1, bindArgs[i]);
}
}
- statement.execute();
+ statement.executeUpdateDelete();
} catch (SQLiteDatabaseCorruptException e) {
onCorruption();
throw e;
@@ -2025,7 +2013,7 @@ public class SQLiteDatabase extends SQLiteClosable {
}
if (durationMillis >= sQueryLogTimeInMillis) {
samplePercent = 100;
- } else {;
+ } else {
samplePercent = (int) (100 * durationMillis / sQueryLogTimeInMillis) + 1;
if (mRandom.nextInt(100) >= samplePercent) return;
}
@@ -2628,15 +2616,6 @@ public class SQLiteDatabase extends SQLiteClosable {
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 @@ public class SQLiteDatabase extends SQLiteClosable {
/* 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 b90280307ad6..7a683e41bca5 100644
--- a/core/java/android/database/sqlite/SQLiteStatement.java
+++ b/core/java/android/database/sqlite/SQLiteStatement.java
@@ -48,18 +48,31 @@ public class SQLiteStatement extends SQLiteProgram
}
/**
- * 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 @@ public class SQLiteStatement extends SQLiteProgram
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 @@ public class SQLiteStatement extends SQLiteProgram
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 0afd6cd22bea..a69938889f12 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -106,7 +106,7 @@ public abstract class BatteryStats implements Parcelable {
// 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 abstract class BatteryStats implements Parcelable {
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 @@ public abstract class BatteryStats implements Parcelable {
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 class BatteryStats implements Parcelable {
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 7e1d68590f76..1b37107e1d60 100644
--- a/core/java/android/provider/Downloads.java
+++ b/core/java/android/provider/Downloads.java
@@ -624,6 +624,13 @@ public final class Downloads {
"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 88ef3955e049..d040d3f47ce3 100644
--- a/core/java/com/android/internal/app/IBatteryStats.aidl
+++ b/core/java/com/android/internal/app/IBatteryStats.aidl
@@ -24,8 +24,15 @@ interface IBatteryStats {
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 a96253bb4bc4..d1aff2a0bfb8 100644
--- a/core/java/com/android/internal/app/ShutdownThread.java
+++ b/core/java/com/android/internal/app/ShutdownThread.java
@@ -84,7 +84,7 @@ public final class ShutdownThread extends Thread {
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 @@ public final class ShutdownThread extends Thread {
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 642c313eec11..b3323e9aca8d 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -63,7 +63,7 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
int mDischargeStartLevel;
int mDischargeUnplugLevel;
int mDischargeCurrentLevel;
+ int mLowDischargeAmountSinceCharge;
+ int mHighDischargeAmountSinceCharge;
long mLastWriteTime = 0; // Milliseconds
@@ -260,7 +262,7 @@ public final class BatteryStatsImpl extends BatteryStats {
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 final class BatteryStatsImpl extends BatteryStats {
public void writeToParcel(Parcel out) {
out.writeInt(mCount.get());
out.writeInt(mLoadedCount);
- out.writeInt(mLastCount);
out.writeInt(mUnpluggedCount);
}
@@ -348,13 +349,12 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 final class BatteryStatsImpl extends BatteryStats {
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 final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
}
}
+ 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 @@ public final class BatteryStatsImpl extends BatteryStats {
}
}
+ 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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
void writeToParcelLocked(Parcel out) {
out.writeInt(mWakeups);
out.writeInt(mLoadedWakeups);
- out.writeInt(mLastWakeups);
out.writeInt(mUnpluggedWakeups);
out.writeInt(mServiceStats.size());
@@ -3002,9 +3008,9 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
mDischargeStartLevel = 0;
mDischargeUnplugLevel = 0;
mDischargeCurrentLevel = 0;
+ mLowDischargeAmountSinceCharge = 0;
+ mHighDischargeAmountSinceCharge = 0;
}
public BatteryStatsImpl(Parcel p) {
@@ -3434,6 +3439,8 @@ public final class BatteryStatsImpl extends BatteryStats {
doWrite = true;
resetAllStatsLocked();
mDischargeStartLevel = level;
+ mLowDischargeAmountSinceCharge = 0;
+ mHighDischargeAmountSinceCharge = 0;
}
updateKernelWakelocksLocked();
mHistoryCur.batteryLevel = (byte)level;
@@ -3457,6 +3464,10 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
}
@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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 final class BatteryStatsImpl extends BatteryStats {
}
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 @@ public final class BatteryStatsImpl extends BatteryStats {
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 3de2c9509ab7..716d96044e3e 100644
--- a/core/jni/android/graphics/TextLayout.cpp
+++ b/core/jni/android/graphics/TextLayout.cpp
@@ -151,7 +151,7 @@ jint TextLayout::layoutLine(const jchar* text, jint len, jint flags, int &dir, j
}
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 @@ bool TextLayout::prepareText(SkPaint *paint, const jchar* text, jsize len, jint
*outBytes = (workLimit - workText) << 1;
*outText = workText;
-
- free(buffer);
+ *outBuffer = buffer;
+
return true;
}
@@ -207,8 +207,9 @@ bool TextLayout::prepareText(SkPaint *paint, const jchar* text, jsize len, jint
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 @@ void TextLayout::handleText(SkPaint *paint, const jchar* text, jsize len,
} 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 dc7208af0a82..3d05e18f5e1c 100644
--- a/core/jni/android/graphics/TextLayout.h
+++ b/core/jni/android/graphics/TextLayout.h
@@ -65,7 +65,7 @@ public:
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 290b5321f96d..003bbc1cb940 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 @@ static void dbclose(JNIEnv* env, jobject object)
}
}
-/* 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 @@ static JNINativeMethod sMethods[] =
{"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 0341e0bd4b17..2212d9a684c9 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 @@ static jfieldID gStatementField;
(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 @@ static jstring native_1x1_string(JNIEnv* env, jobject object)
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 d2e7faf6f606..1e4a66d74a92 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -256,9 +256,11 @@ static void android_view_GLES20Canvas_setupLinearShader(JNIEnv* env, jobject can
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 e33421acb222..cd38bf0788ea 100644
--- a/core/tests/coretests/src/android/database/DatabaseGeneralTest.java
+++ b/core/tests/coretests/src/android/database/DatabaseGeneralTest.java
@@ -21,6 +21,7 @@ import static android.database.DatabaseUtils.InsertHelper.TABLE_INFO_PRAGMA_DEFA
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 @@ public class DatabaseGeneralTest extends AndroidTestCase implements PerformanceT
@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 fc71b77eecc7..38191b008183 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.Matcher;
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 @@ public class PackageManagerHostTestUtils extends Assert {
* Helper method to run tests and return the listener that collected the results.
* @param pkgName Android application package for tests
* @return the {@link CollectingTestRunListener}
- */
- private CollectingTestRunListener doRunTests(String pkgName) 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.
+ */
+ private CollectingTestRunListener doRunTests(String pkgName) throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(
pkgName, mDevice);
CollectingTestRunListener listener = new CollectingTestRunListener();
@@ -138,8 +143,14 @@ public class PackageManagerHostTestUtils extends Assert {
*
* @param pkgName Android application package for tests
* @return true if every test passed, false otherwise.
- */
- public boolean runDeviceTestsDidAllTestsPass(String pkgName) 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 boolean runDeviceTestsDidAllTestsPass(String pkgName) throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
CollectingTestRunListener listener = doRunTests(pkgName);
return listener.didAllTestsPass();
}
@@ -147,22 +158,26 @@ public class PackageManagerHostTestUtils extends Assert {
/**
* 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 @@ public class PackageManagerHostTestUtils extends Assert {
* @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 @@ public class PackageManagerHostTestUtils extends Assert {
* 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 @@ public class PackageManagerHostTestUtils extends Assert {
*
* @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
- */
- public boolean doesRemoteFileExist(String destPath) 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 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 @@ public class PackageManagerHostTestUtils extends Assert {
* @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 @@ public class PackageManagerHostTestUtils extends Assert {
*
* @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
- */
- public boolean doesPackageExist(String packageName) 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 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 @@ public class PackageManagerHostTestUtils extends Assert {
*
* @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
- */
- public boolean doesAppExistOnDevice(String packageName) 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 boolean doesAppExistOnDevice(String packageName) throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
return doesRemoteFileExistContainingString(DEVICE_APP_PATH, packageName);
}
@@ -252,9 +295,14 @@ public class PackageManagerHostTestUtils extends Assert {
*
* @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
- */
- public boolean doesAppExistOnSDCard(String packageName) 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 boolean doesAppExistOnSDCard(String packageName) throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
return doesRemoteFileExistContainingString(SDCARD_APP_PATH, packageName);
}
@@ -263,9 +311,14 @@ public class PackageManagerHostTestUtils extends Assert {
*
* @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
- */
- public boolean doesAppExistAsForwardLocked(String packageName) 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 boolean doesAppExistAsForwardLocked(String packageName) throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
return doesRemoteFileExistContainingString(APP_PRIVATE_PATH, packageName);
}
@@ -273,9 +326,14 @@ public class PackageManagerHostTestUtils extends Assert {
* Waits for device's package manager to respond.
*
* @throws InterruptedException
- * @throws IOException
- */
- public void waitForPackageManager() throws InterruptedException, 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, 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 @@ public class PackageManagerHostTestUtils extends Assert {
*
* @param packageName The name of the package to wait to load
* @throws InterruptedException
- * @throws IOException
- */
- public void waitForApp(String packageName) throws InterruptedException, 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,
+ 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 @@ public class PackageManagerHostTestUtils extends Assert {
/**
* Helper method which executes a adb shell command and returns output as a {@link String}
* @return the output of the command
- * @throws IOException
- */
- public String executeShellCommand(String 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, 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 @@ public class PackageManagerHostTestUtils extends Assert {
/**
* Helper method ensures we are in root mode on the host side. It returns only after
* PackageManager is actually up and running.
- * @throws IOException
- */
- public void runAdbRoot() throws IOException, 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 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 @@ public class PackageManagerHostTestUtils extends Assert {
/**
* 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
- */
- public void rebootDevice() throws IOException, 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, 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 @@ public class PackageManagerHostTestUtils extends Assert {
/**
* 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 @@ public class PackageManagerHostTestUtils extends Assert {
/**
* 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 @@ public class PackageManagerHostTestUtils extends Assert {
/**
* 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 @@ public class PackageManagerHostTestUtils extends Assert {
/**
* Helper method for uninstalling an app.
+ * <p/>
+ * Assumes adb is running as root in device under test.
*
* @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.
- */
- public void uninstallApp(String pkgName) throws IOException, 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.
+ * @throws InstallException if the uninstall failed.
+ */
+ 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 @@ public class PackageManagerHostTestUtils extends Assert {
* 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.
- */
- public void wipeNonSystemApps() 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 InstallException if the uninstall failed.
+ */
+ 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 @@ public class PackageManagerHostTestUtils extends Assert {
*
* <p/>
* Assumes adb is running as root in device under test.
- */
- public void setDevicePreferredInstallLocation(InstallLocPreference pref) 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 setDevicePreferredInstallLocation(InstallLocPreference pref) throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
String command = "pm setInstallLocation %d";
int locValue = 0;
switch (pref) {
@@ -713,8 +829,14 @@ public class PackageManagerHostTestUtils extends Assert {
*
* <p/>
* Assumes adb is running as root in device under test.
- */
- public InstallLocPreference getDevicePreferredInstallLocation() 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 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 1b797d5a40ab..22a2be6c939b 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* @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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 @@ public class PackageManagerHostTests extends DeviceTestCase {
* 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 715c55b9bbf4..a2a5dd3afe70 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 @@ public class PackageManagerStressHostTests extends DeviceTestCase {
* <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 @@ public class PackageManagerStressHostTests extends DeviceTestCase {
* <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 @@ public class PackageManagerStressHostTests extends DeviceTestCase {
* <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 @@ public class PackageManagerStressHostTests extends DeviceTestCase {
* <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 14ad7d7227f9..5595ab0220d6 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -80,6 +80,21 @@ void Font::drawCachedGlyph(CachedGlyphInfo* glyph, int x, int y) {
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 @@ void Font::renderUTF(SkPaint* paint, const char* text, uint32_t start, uint32_t
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 @@ void FontRenderer::initTextTexture() {
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 @@ void FontRenderer::checkInit() {
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::appendMeshQuad(float x1, float y1, float z1, float u1, float
}
}
-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 bacd3aadba4f..2f7a8bac305a 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 @@ protected:
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 @@ public:
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 @@ protected:
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 @@ protected:
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 d30d7180028e..2e44e122ea39 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -569,7 +569,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
// 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/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c
index e66513f03ac9..8cf84b7e3c81 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 @@ void LVDBE_SetFilters(LVDBE_Instance_t *pInstance,
/*
* 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 @@ void LVDBE_SetFilters(LVDBE_Instance_t *pInstance,
/*
* 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 41785a32d35c..727340013d89 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 4667feb63ab7..922f77d2bae1 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 @@ void LVM_SetTrebleBoost(LVM_Instance_t *pInstance,
/*
* 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 7ac5685ea574..323a2a3a6dce 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 b03f0ba0ff4d..83f95ac6cd14 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 @@ void MixSoft_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance,
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 @@ void MixSoft_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance,
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 88f6fb052f52..dac244911d47 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 2a83e89fa105..b1d9408c1a05 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 @@ LVCS_ReturnStatus_en LVCS_BypassMixInit(LVCS_Handle_t hInstance,
*/
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_INT32 LVCS_MixerCallback(LVCS_Handle_t hInstance,
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 @@ LVM_INT32 LVCS_MixerCallback(LVCS_Handle_t hInstance,
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 5dfca2568bd4..fea44bfca4fb 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 @@ LVCS_ReturnStatus_en LVCS_Control(LVCS_Handle_t hInstance,
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 @@ LVCS_ReturnStatus_en LVCS_Control(LVCS_Handle_t hInstance,
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 @@ LVCS_ReturnStatus_en LVCS_Control(LVCS_Handle_t hInstance,
/* 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 ca615b07c8a4..7ab6571774a1 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 @@ LVCS_ReturnStatus_en LVCS_EqualiserInit(LVCS_Handle_t hInstance,
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 4aa95d3cb83b..f5f7cd0d5741 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_ReturnStatus_en LVCS_Init(LVCS_Handle_t *phInstance,
LVCS_Capabilities_t *pCapabilities)
{
- LVM_INT16 Offset;
LVCS_Instance_t *pInstance;
LVCS_VolCorrect_t *pLVCS_VolCorrectTable;
@@ -197,30 +196,18 @@ LVCS_ReturnStatus_en LVCS_Init(LVCS_Handle_t *phInstance,
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 be30829d8331..a97769032580 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 @@ typedef struct
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 2efef84b5ebb..861bde69b8f9 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 @@ LVCS_ReturnStatus_en LVCS_ReverbGeneratorInit(LVCS_Handle_t hInstance,
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 4ff471658d1e..b67d824f2a55 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 @@ LVCS_ReturnStatus_en LVCS_SEnhancerInit(LVCS_Handle_t hInstance,
/* 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 @@ LVCS_ReturnStatus_en LVCS_SEnhancerInit(LVCS_Handle_t hInstance,
/* 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 6043dd5ae7f5..5e919741a4ad 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -2337,7 +2337,6 @@ extern "C" int Effect_command(effect_interface_t self,
void *pReplyData){
EffectContext * pContext = (EffectContext *) self;
int retsize;
- int status = 0;
//LOGV("\t\nEffect_command start");
@@ -2371,54 +2370,29 @@ extern "C" int Effect_command(effect_interface_t self,
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 2897f34d5845..37f5b61fd59a 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 af2145e94c57..01376eb0ed85 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -1495,6 +1495,7 @@ class PackageManagerService extends IPackageManager.Stub {
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 @@ class PackageManagerService extends IPackageManager.Stub {
return;
}
pkgSetting.enabled = newState;
+ pkgSetting.pkg.mSetEnabled = newState;
} else {
// We're dealing with a component level state change
switch (newState) {
@@ -8261,6 +8263,7 @@ class PackageManagerService extends IPackageManager.Stub {
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 @@ class PackageManagerService extends IPackageManager.Stub {
}
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 @@ class PackageManagerService extends IPackageManager.Stub {
Debug.waitForDebugger();
Log.i(TAG, "We will crash!");
}
+ return false;
+ }
+ 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 ((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));
+ return componentInfo.enabled;
}
}
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 0c8769ee86f5..fa2ec1fd1327 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -6755,7 +6755,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
}
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 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
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 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
* 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 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
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 b79373d8025f..3025f7732219 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 @@ void SensorService::onFirstRef()
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 @@ void SensorService::onFirstRef()
if (mSensorDevice) {
mSensorDevice->activate(mSensorDevice, sensor.getHandle(), 0);
}
+ mLastEventSeen.add(sensor.getHandle(), event);
}
if (mSensorDevice) {
@@ -138,6 +170,19 @@ status_t SensorService::dump(int fd, const Vector<String16>& args)
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 @@ bool SensorService::threadLoop()
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 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection,
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 @@ status_t SensorService::SensorEventConnection::sendEvents(
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 f77652da0ed2..9f37799fe7d9 100644
--- a/services/sensorservice/SensorService.h
+++ b/services/sensorservice/SensorService.h
@@ -87,7 +87,7 @@ class SensorService :
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 @@ class SensorService :
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 9a13a5f8cf19..1381a2da18b0 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.Message;
import android.os.RegistrantList;
import android.telephony.PhoneStateListener;
-
import java.util.ArrayList;
import java.util.List;
@@ -49,8 +46,23 @@ import java.util.List;
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,13 +101,46 @@ public final class CallManager {
protected final RegistrantList mServiceStateRegistrants
= 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 mMmiRegistrants
+ protected final RegistrantList mEcmTimerResetRegistrants
= new RegistrantList();
- protected final RegistrantList mUnknownConnectionRegistrants
+ protected final RegistrantList mSubscriptionInfoReadyRegistrants
= new RegistrantList();
protected final RegistrantList mSuppServiceFailedRegistrants
@@ -118,9 +163,28 @@ public final class CallManager {
}
/**
+ * 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 @@ public final class CallManager {
}
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 @@ public final class CallManager {
* 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 @@ public final class CallManager {
* 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 @@ public final class CallManager {
* 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 @@ public final class CallManager {
* 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 @@ public final class CallManager {
*
* <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 @@ public final class CallManager {
* <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 @@ public final class CallManager {
* @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,73 +788,133 @@ public final class CallManager {
public void unregisterForServiceStateChanged(Handler h){}
/**
- * Register for Supplementary Service notifications from the network.
+ * Register for notifications when a supplementary service attempt fails.
* 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){}
+ public void registerForSuppServiceFailed(Handler h, int what, Object obj){
+ mSuppServiceFailedRegistrants.addUnique(h, what, obj);
+ }
/**
- * Unregisters for Supplementary Service notifications.
+ * Unregister for notifications when a supplementary service attempt fails.
* Extraneous calls are tolerated silently
*
* @param h Handler to be removed from the registrant list.
*/
- public void unregisterForSuppServiceNotification(Handler h){}
+ public void unregisterForSuppServiceFailed(Handler h){
+ mSuppServiceFailedRegistrants.remove(h);
+ }
/**
- * Register for notifications when a supplementary service attempt fails.
- * Message.obj will contain an AsyncResult.
+ * Register for notifications when a sInCall VoicePrivacy is enabled
*
* @param h Handler that receives the notification message.
* @param what User-defined message code.
* @param obj User object.
*/
- public void registerForSuppServiceFailed(Handler h, int what, Object obj){}
+ public void registerForInCallVoicePrivacyOn(Handler h, int what, Object obj){
+ mInCallVoicePrivacyOnRegistrants.addUnique(h, what, obj);
+ }
/**
- * Unregister for notifications when a supplementary service attempt fails.
- * Extraneous calls are tolerated silently
+ * Unregister for notifications when a sInCall VoicePrivacy is enabled
*
* @param h Handler to be removed from the registrant list.
*/
- public void unregisterForSuppServiceFailed(Handler h){}
+ public void unregisterForInCallVoicePrivacyOn(Handler h){
+ mInCallVoicePrivacyOnRegistrants.remove(h);
+ }
/**
- * Register for notifications when a sInCall VoicePrivacy is enabled
+ * Register for notifications when a sInCall VoicePrivacy is disabled
*
* @param h Handler that receives the notification message.
* @param what User-defined message code.
* @param obj User object.
*/
- public void registerForInCallVoicePrivacyOn(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 enabled
+ * Unregister for notifications when a sInCall VoicePrivacy is disabled
*
* @param h Handler to be removed from the registrant list.
*/
- public void unregisterForInCallVoicePrivacyOn(Handler h){}
+ public void unregisterForInCallVoicePrivacyOff(Handler h){
+ mInCallVoicePrivacyOffRegistrants.remove(h);
+ }
/**
- * Register for notifications when a sInCall VoicePrivacy is disabled
+ * 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 registerForInCallVoicePrivacyOff(Handler h, int what, Object obj){}
+ public void registerForDisplayInfo(Handler h, int what, Object obj){
+ mDisplayInfoRegistrants.addUnique(h, what, obj);
+ }
/**
- * Unegister for notifications when a sInCall VoicePrivacy is disabled
+ * Unregisters for display information notifications.
+ * Extraneous calls are tolerated silently
*
* @param h Handler to be removed from the registrant list.
*/
- public void unregisterForInCallVoicePrivacyOff(Handler h){}
+ public void unregisterForDisplayInfo(Handler h) {
+ mDisplayInfoRegistrants.remove(h);
+ }
/**
* Register for notifications when CDMA OTA Provision status change
@@ -739,13 +923,17 @@ public final class CallManager {
* @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 @@ public final class CallManager {
* @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 @@ public final class CallManager {
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 c3bb01f6db59..4ad61bb083b6 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 final class CdmaCall extends Call {
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 9542d20e1e4c..58124a25beea 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 @@ class GsmCall extends Call {
public Phone
getPhone() {
- //TODO
- return null;
+ return owner.phone;
}
public boolean