Merge "Permission fix: don't require BACKUP perm for self-restores"
diff --git a/api/current.xml b/api/current.xml
index 19c1384..ebfa842 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -19596,6 +19596,17 @@
synchronized="false"
static="false"
final="false"
+ deprecated="deprecated"
+ visibility="public"
+>
+</method>
+<method name="getCustomView"
+ return="android.view.View"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
deprecated="not deprecated"
visibility="public"
>
@@ -21087,6 +21098,32 @@
<parameter name="nonRoot" type="boolean">
</parameter>
</method>
+<method name="onActionModeFinished"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="mode" type="android.view.ActionMode">
+</parameter>
+</method>
+<method name="onActionModeStarted"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="mode" type="android.view.ActionMode">
+</parameter>
+</method>
<method name="onActivityResult"
return="void"
abstract="false"
@@ -21722,19 +21759,6 @@
visibility="protected"
>
</method>
-<method name="onStartActionMode"
- return="android.view.ActionMode"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="callback" type="android.view.ActionMode.Callback">
-</parameter>
-</method>
<method name="onStop"
return="void"
abstract="false"
@@ -21835,6 +21859,19 @@
<parameter name="hasFocus" type="boolean">
</parameter>
</method>
+<method name="onWindowStartingActionMode"
+ return="android.view.ActionMode"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="callback" type="android.view.ActionMode.Callback">
+</parameter>
+</method>
<method name="openContextMenu"
return="void"
abstract="false"
@@ -21885,47 +21922,6 @@
<parameter name="exitAnim" type="int">
</parameter>
</method>
-<method name="popBackStack"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="deprecated"
- visibility="public"
->
-</method>
-<method name="popBackStack"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="deprecated"
- visibility="public"
->
-<parameter name="name" type="java.lang.String">
-</parameter>
-<parameter name="flags" type="int">
-</parameter>
-</method>
-<method name="popBackStack"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="deprecated"
- visibility="public"
->
-<parameter name="id" type="int">
-</parameter>
-<parameter name="flags" type="int">
-</parameter>
-</method>
<method name="registerForContextMenu"
return="void"
abstract="false"
@@ -22611,17 +22607,6 @@
visibility="protected"
>
</field>
-<field name="POP_BACK_STACK_INCLUSIVE"
- type="int"
- transient="false"
- volatile="false"
- value="1"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
<field name="RESULT_CANCELED"
type="int"
transient="false"
@@ -25434,6 +25419,32 @@
visibility="public"
>
</method>
+<method name="onActionModeFinished"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="mode" type="android.view.ActionMode">
+</parameter>
+</method>
+<method name="onActionModeStarted"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="mode" type="android.view.ActionMode">
+</parameter>
+</method>
<method name="onAttachedToWindow"
return="void"
abstract="false"
@@ -25784,19 +25795,6 @@
visibility="protected"
>
</method>
-<method name="onStartActionMode"
- return="android.view.ActionMode"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="callback" type="android.view.ActionMode.Callback">
-</parameter>
-</method>
<method name="onStop"
return="void"
abstract="false"
@@ -25860,6 +25858,19 @@
<parameter name="hasFocus" type="boolean">
</parameter>
</method>
+<method name="onWindowStartingActionMode"
+ return="android.view.ActionMode"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="callback" type="android.view.ActionMode.Callback">
+</parameter>
+</method>
<method name="openContextMenu"
return="void"
abstract="false"
@@ -26471,6 +26482,19 @@
<parameter name="request" type="android.app.DownloadManager.Request">
</parameter>
</method>
+<method name="getMimeTypeForDownloadedFile"
+ return="java.lang.String"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="id" type="long">
+</parameter>
+</method>
<method name="getUriForDownloadedFile"
return="android.net.Uri"
abstract="false"
@@ -28308,6 +28332,17 @@
<parameter name="args" type="java.lang.String[]">
</parameter>
</method>
+<method name="executePendingTransactions"
+ return="boolean"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="findFragmentById"
return="android.app.Fragment"
abstract="true"
@@ -28374,7 +28409,7 @@
>
</method>
<method name="popBackStack"
- return="boolean"
+ return="void"
abstract="true"
native="false"
synchronized="false"
@@ -28385,7 +28420,7 @@
>
</method>
<method name="popBackStack"
- return="boolean"
+ return="void"
abstract="true"
native="false"
synchronized="false"
@@ -28400,6 +28435,47 @@
</parameter>
</method>
<method name="popBackStack"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="id" type="int">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+<method name="popBackStackImmediate"
+ return="boolean"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="popBackStackImmediate"
+ return="boolean"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="name" type="java.lang.String">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+<method name="popBackStackImmediate"
return="boolean"
abstract="true"
native="false"
@@ -212083,6 +212159,32 @@
<parameter name="event" type="android.view.MotionEvent">
</parameter>
</method>
+<method name="onActionModeFinished"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="mode" type="android.view.ActionMode">
+</parameter>
+</method>
+<method name="onActionModeStarted"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="mode" type="android.view.ActionMode">
+</parameter>
+</method>
<method name="onAttachedToWindow"
return="void"
abstract="true"
@@ -212217,19 +212319,6 @@
visibility="public"
>
</method>
-<method name="onStartActionMode"
- return="android.view.ActionMode"
- abstract="true"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="callback" type="android.view.ActionMode.Callback">
-</parameter>
-</method>
<method name="onWindowAttributesChanged"
return="void"
abstract="true"
@@ -212256,6 +212345,19 @@
<parameter name="hasFocus" type="boolean">
</parameter>
</method>
+<method name="onWindowStartingActionMode"
+ return="android.view.ActionMode"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="callback" type="android.view.ActionMode.Callback">
+</parameter>
+</method>
</interface>
<interface name="WindowManager"
abstract="true"
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java
index e6b1c08..8471df9 100644
--- a/core/java/android/accounts/AccountManagerService.java
+++ b/core/java/android/accounts/AccountManagerService.java
@@ -520,6 +520,18 @@
if (account == null) throw new IllegalArgumentException("account is null");
checkManageAccountsPermission();
long identityToken = clearCallingIdentity();
+
+ cancelNotification(getSigninRequiredNotificationId(account));
+ synchronized(mCredentialsPermissionNotificationIds) {
+ for (Pair<Pair<Account, String>, Integer> pair:
+ mCredentialsPermissionNotificationIds.keySet()) {
+ if (account.equals(pair.first.first)) {
+ int id = mCredentialsPermissionNotificationIds.get(pair);
+ cancelNotification(id);
+ }
+ }
+ }
+
try {
new RemoveAccountSession(response, account).bind();
} finally {
diff --git a/core/java/android/app/ActionBar.java b/core/java/android/app/ActionBar.java
index a57b54a..246d661 100644
--- a/core/java/android/app/ActionBar.java
+++ b/core/java/android/app/ActionBar.java
@@ -138,14 +138,19 @@
* Set the action bar into custom navigation mode, supplying a view
* for custom navigation.
*
- * Custom navigation views appear between the application icon and
+ * <p>Custom navigation views appear between the application icon and
* any action buttons and may use any space available there. Common
* use cases for custom navigation views might include an auto-suggesting
* address bar for a browser or other navigation mechanisms that do not
- * translate well to provided navigation modes.
+ * translate well to provided navigation modes.</p>
+ *
+ * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
+ * the custom view to be displayed.</p>
*
* @param view Custom navigation view to place in the ActionBar.
* @param layoutParams How this custom view should layout in the bar.
+ *
+ * @see #setDisplayOptions(int, int)
*/
public abstract void setCustomView(View view, LayoutParams layoutParams);
@@ -248,39 +253,47 @@
public abstract void setStandardNavigationMode();
/**
- * Set the action bar's title. This will only be displayed in standard navigation mode.
+ * Set the action bar's title. This will only be displayed if
+ * {@link #DISPLAY_SHOW_TITLE} is set.
*
* @param title Title to set
*
* @see #setTitle(int)
+ * @see #setDisplayOptions(int, int)
*/
public abstract void setTitle(CharSequence title);
/**
- * Set the action bar's title. This will only be displayed in standard navigation mode.
+ * Set the action bar's title. This will only be displayed if
+ * {@link #DISPLAY_SHOW_TITLE} is set.
*
* @param resId Resource ID of title string to set
*
* @see #setTitle(CharSequence)
+ * @see #setDisplayOptions(int, int)
*/
public abstract void setTitle(int resId);
/**
- * Set the action bar's subtitle. This will only be displayed in standard navigation mode.
- * Set to null to disable the subtitle entirely.
+ * Set the action bar's subtitle. This will only be displayed if
+ * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the
+ * subtitle entirely.
*
* @param subtitle Subtitle to set
*
* @see #setSubtitle(int)
+ * @see #setDisplayOptions(int, int)
*/
public abstract void setSubtitle(CharSequence subtitle);
/**
- * Set the action bar's subtitle. This will only be displayed in standard navigation mode.
+ * Set the action bar's subtitle. This will only be displayed if
+ * {@link #DISPLAY_SHOW_TITLE} is set.
*
* @param resId Resource ID of subtitle string to set
*
* @see #setSubtitle(CharSequence)
+ * @see #setDisplayOptions(int, int)
*/
public abstract void setSubtitle(int resId);
@@ -317,9 +330,16 @@
/**
* @return The current custom navigation view.
+ * @deprecated Method has been renamed. Use {@link #getCustomView()}.
*/
+ @Deprecated
public abstract View getCustomNavigationView();
-
+
+ /**
+ * @return The current custom view.
+ */
+ public abstract View getCustomView();
+
/**
* Returns the current ActionBar title in standard mode.
* Returns null if {@link #getNavigationMode()} would not return
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 33f88d8..5174f19 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -2086,63 +2086,12 @@
}
/**
- * Flag for {@link #popBackStack(String, int)}
- * and {@link #popBackStack(int, int)}: If set, and the name or ID of
- * a back stack entry has been supplied, then all matching entries will
- * be consumed until one that doesn't match is found or the bottom of
- * the stack is reached. Otherwise, all entries up to but not including that entry
- * will be removed.
- */
- public static final int POP_BACK_STACK_INCLUSIVE = 1<<0;
-
- /**
- * Pop the top state off the back stack. Returns true if there was one
- * to pop, else false.
- * @deprecated use {@link #getFragmentManager}.
- */
- @Deprecated
- public boolean popBackStack() {
- return mFragments.popBackStack();
- }
-
- /**
- * Pop the last fragment transition from the local activity's fragment
- * back stack. If there is nothing to pop, false is returned.
- * @param name If non-null, this is the name of a previous back state
- * to look for; if found, all states up to that state will be popped. The
- * {@link #POP_BACK_STACK_INCLUSIVE} flag can be used to control whether
- * the named state itself is popped. If null, only the top state is popped.
- * @param flags Either 0 or {@link #POP_BACK_STACK_INCLUSIVE}.
- * @deprecated use {@link #getFragmentManager}.
- */
- @Deprecated
- public boolean popBackStack(String name, int flags) {
- return mFragments.popBackStack(name, flags);
- }
-
- /**
- * Pop all back stack states up to the one with the given identifier.
- * @param id Identifier of the stated to be popped. If no identifier exists,
- * false is returned.
- * The identifier is the number returned by
- * {@link FragmentTransaction#commit() FragmentTransaction.commit()}. The
- * {@link #POP_BACK_STACK_INCLUSIVE} flag can be used to control whether
- * the named state itself is popped.
- * @param flags Either 0 or {@link #POP_BACK_STACK_INCLUSIVE}.
- * @deprecated use {@link #getFragmentManager}.
- */
- @Deprecated
- public boolean popBackStack(int id, int flags) {
- return mFragments.popBackStack(id, flags);
- }
-
- /**
* Called when the activity has detected the user's press of the back
* key. The default implementation simply finishes the current activity,
* but you can override this to do whatever you want.
*/
public void onBackPressed() {
- if (!mFragments.popBackStack()) {
+ if (!mFragments.popBackStackImmediate()) {
finish();
}
}
@@ -4174,7 +4123,7 @@
}
/**
- * Start a context mode.
+ * Start an action mode.
*
* @param callback Callback that will manage lifecycle events for this context mode
* @return The ContextMode that was started, or null if it was canceled
@@ -4185,7 +4134,18 @@
return mWindow.getDecorView().startActionMode(callback);
}
- public ActionMode onStartActionMode(ActionMode.Callback callback) {
+ /**
+ * Give the Activity a chance to control the UI for an action mode requested
+ * by the system.
+ *
+ * <p>Note: If you are looking for a notification callback that an action mode
+ * has been started for this activity, see {@link #onActionModeStarted(ActionMode)}.</p>
+ *
+ * @param callback The callback that should control the new action mode
+ * @return The new action mode, or <code>null</code> if the activity does not want to
+ * provide special handling for this action mode. (It will be handled by the system.)
+ */
+ public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
initActionBar();
if (mActionBar != null) {
return mActionBar.startActionMode(callback);
@@ -4193,6 +4153,24 @@
return null;
}
+ /**
+ * Notifies the Activity that an action mode has been started.
+ * Activity subclasses overriding this method should call the superclass implementation.
+ *
+ * @param mode The new action mode.
+ */
+ public void onActionModeStarted(ActionMode mode) {
+ }
+
+ /**
+ * Notifies the activity that an action mode has finished.
+ * Activity subclasses overriding this method should call the superclass implementation.
+ *
+ * @param mode The action mode that just finished.
+ */
+ public void onActionModeFinished(ActionMode mode) {
+ }
+
// ------------------ Internal API ------------------
final void setParent(Activity parent) {
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java
index 526129a..64a4d7a 100644
--- a/core/java/android/app/Dialog.java
+++ b/core/java/android/app/Dialog.java
@@ -867,13 +867,19 @@
}
}
- public ActionMode onStartActionMode(ActionMode.Callback callback) {
+ public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
if (mActionBar != null) {
return mActionBar.startActionMode(callback);
}
return null;
}
+ public void onActionModeStarted(ActionMode mode) {
+ }
+
+ public void onActionModeFinished(ActionMode mode) {
+ }
+
/**
* @return The activity associated with this dialog, or null if there is no associated activity.
*/
diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java
index 3a6fd23..09a21f8 100644
--- a/core/java/android/app/DownloadManager.java
+++ b/core/java/android/app/DownloadManager.java
@@ -284,7 +284,7 @@
*/
public static final String[] UNDERLYING_COLUMNS = new String[] {
Downloads.Impl._ID,
- Downloads.Impl._DATA,
+ Downloads.Impl._DATA + " AS " + COLUMN_LOCAL_FILENAME,
Downloads.Impl.COLUMN_MEDIAPROVIDER_URI,
Downloads.Impl.COLUMN_DESTINATION,
Downloads.Impl.COLUMN_TITLE,
@@ -886,8 +886,8 @@
* downloaded successfully. otherwise, null is returned.
*<p>
* If the specified downloaded file is in external storage (for example, /sdcard dir),
- * then it is assumed to be safe for anyone to read and the returned {@link Uri} can be used
- * by any app to access the downloaded file.
+ * then it is assumed to be safe for anyone to read and the returned {@link Uri} corresponds
+ * to the filepath on sdcard.
*
* @param id the id of the downloaded file.
* @return the {@link Uri} for the given downloaded file id, if download was successful. null
@@ -903,8 +903,7 @@
return null;
}
while (cursor.moveToFirst()) {
- int status = cursor.getInt(cursor.getColumnIndexOrThrow(
- DownloadManager.COLUMN_STATUS));
+ int status = cursor.getInt(cursor.getColumnIndexOrThrow(COLUMN_STATUS));
if (DownloadManager.STATUS_SUCCESSFUL == status) {
int indx = cursor.getColumnIndexOrThrow(
Downloads.Impl.COLUMN_DESTINATION);
@@ -919,8 +918,9 @@
return ContentUris.withAppendedId(Downloads.Impl.CONTENT_URI, id);
} else {
// return public uri
- return ContentUris.withAppendedId(
- Downloads.Impl.PUBLICLY_ACCESSIBLE_DOWNLOADS_URI, id);
+ String path = cursor.getString(
+ cursor.getColumnIndexOrThrow(COLUMN_LOCAL_FILENAME));
+ return Uri.fromFile(new File(path));
}
}
}
@@ -934,6 +934,38 @@
}
/**
+ * Returns {@link Uri} for the given downloaded file id, if the file is
+ * downloaded successfully. otherwise, null is returned.
+ *<p>
+ * If the specified downloaded file is in external storage (for example, /sdcard dir),
+ * then it is assumed to be safe for anyone to read and the returned {@link Uri} corresponds
+ * to the filepath on sdcard.
+ *
+ * @param id the id of the downloaded file.
+ * @return the {@link Uri} for the given downloaded file id, if download was successful. null
+ * otherwise.
+ */
+ public String getMimeTypeForDownloadedFile(long id) {
+ Query query = new Query().setFilterById(id);
+ Cursor cursor = null;
+ try {
+ cursor = query(query);
+ if (cursor == null) {
+ return null;
+ }
+ while (cursor.moveToFirst()) {
+ return cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_MEDIA_TYPE));
+ }
+ } finally {
+ if (cursor != null) {
+ cursor.close();
+ }
+ }
+ // downloaded file not found or its status is not 'successfully completed'
+ return null;
+ }
+
+ /**
* Restart the given downloads, which must have already completed (successfully or not). This
* method will only work when called from within the download manager's process.
* @param ids the IDs of the downloads
@@ -1036,7 +1068,7 @@
long destinationType = getLong(getColumnIndex(Downloads.Impl.COLUMN_DESTINATION));
if (destinationType == Downloads.Impl.DESTINATION_FILE_URI ||
destinationType == Downloads.Impl.DESTINATION_EXTERNAL) {
- String localPath = getString(getColumnIndex(Downloads.Impl._DATA));
+ String localPath = getString(getColumnIndex(COLUMN_LOCAL_FILENAME));
if (localPath == null) {
return null;
}
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index 9970418..d3a4f33 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -22,6 +22,7 @@
import android.content.res.TypedArray;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
@@ -99,6 +100,20 @@
public abstract FragmentTransaction openTransaction();
/**
+ * After a {@link FragmentTransaction} is committed with
+ * {@link FragmentTransaction#commit FragmentTransaction.commit()}, it
+ * is scheduled to be executed asynchronously on the process's main thread.
+ * If you want to immediately executing any such pending operations, you
+ * can call this function (only from the main thread) to do so. Note that
+ * all callbacks and other related behavior will be done from within this
+ * call, so be careful about where this is called from.
+ *
+ * @return Returns true if there were any pending transactions to be
+ * executed.
+ */
+ public abstract boolean executePendingTransactions();
+
+ /**
* Finds a fragment that was identified by the given id either when inflated
* from XML or as the container ID when added in a transaction. This first
* searches through fragments that are currently added to the manager's
@@ -132,7 +147,15 @@
* Pop the top state off the back stack. Returns true if there was one
* to pop, else false.
*/
- public abstract boolean popBackStack();
+ public abstract void popBackStack();
+
+ /**
+ * Like {@link #popBackStack()}, but performs the operation immediately
+ * inside of the call. This is like calling {@link #executePendingTransactions()}
+ * afterwards.
+ * @return Returns true if there was something popped, else false.
+ */
+ public abstract boolean popBackStackImmediate();
/**
* Pop the last fragment transition from the manager's fragment
@@ -143,7 +166,15 @@
* the named state itself is popped. If null, only the top state is popped.
* @param flags Either 0 or {@link #POP_BACK_STACK_INCLUSIVE}.
*/
- public abstract boolean popBackStack(String name, int flags);
+ public abstract void popBackStack(String name, int flags);
+
+ /**
+ * Like {@link #popBackStack(String, int)}, but performs the operation immediately
+ * inside of the call. This is like calling {@link #executePendingTransactions()}
+ * afterwards.
+ * @return Returns true if there was something popped, else false.
+ */
+ public abstract boolean popBackStackImmediate(String name, int flags);
/**
* Pop all back stack states up to the one with the given identifier.
@@ -155,7 +186,15 @@
* the named state itself is popped.
* @param flags Either 0 or {@link #POP_BACK_STACK_INCLUSIVE}.
*/
- public abstract boolean popBackStack(int id, int flags);
+ public abstract void popBackStack(int id, int flags);
+
+ /**
+ * Like {@link #popBackStack(int, int)}, but performs the operation immediately
+ * inside of the call. This is like calling {@link #executePendingTransactions()}
+ * afterwards.
+ * @return Returns true if there was something popped, else false.
+ */
+ public abstract boolean popBackStackImmediate(int id, int flags);
/**
* Return the number of entries currently in the back stack.
@@ -300,17 +339,58 @@
}
@Override
- public boolean popBackStack() {
+ public boolean executePendingTransactions() {
+ return execPendingActions();
+ }
+
+ @Override
+ public void popBackStack() {
+ enqueueAction(new Runnable() {
+ @Override public void run() {
+ popBackStackState(mActivity.mHandler, null, -1, 0);
+ }
+ }, false);
+ }
+
+ @Override
+ public boolean popBackStackImmediate() {
+ checkStateLoss();
+ executePendingTransactions();
return popBackStackState(mActivity.mHandler, null, -1, 0);
}
@Override
- public boolean popBackStack(String name, int flags) {
+ public void popBackStack(final String name, final int flags) {
+ enqueueAction(new Runnable() {
+ @Override public void run() {
+ popBackStackState(mActivity.mHandler, name, -1, flags);
+ }
+ }, false);
+ }
+
+ @Override
+ public boolean popBackStackImmediate(String name, int flags) {
+ checkStateLoss();
+ executePendingTransactions();
return popBackStackState(mActivity.mHandler, name, -1, flags);
}
@Override
- public boolean popBackStack(int id, int flags) {
+ public void popBackStack(final int id, final int flags) {
+ if (id < 0) {
+ throw new IllegalArgumentException("Bad id: " + id);
+ }
+ enqueueAction(new Runnable() {
+ @Override public void run() {
+ popBackStackState(mActivity.mHandler, null, id, flags);
+ }
+ }, false);
+ }
+
+ @Override
+ public boolean popBackStackImmediate(int id, int flags) {
+ checkStateLoss();
+ executePendingTransactions();
if (id < 0) {
throw new IllegalArgumentException("Bad id: " + id);
}
@@ -849,16 +929,20 @@
return null;
}
+ private void checkStateLoss() {
+ if (mStateSaved) {
+ throw new IllegalStateException(
+ "Can not perform this action after onSaveInstanceState");
+ }
+ if (mNoTransactionsBecause != null) {
+ throw new IllegalStateException(
+ "Can not perform this action inside of " + mNoTransactionsBecause);
+ }
+ }
+
public void enqueueAction(Runnable action, boolean allowStateLoss) {
if (!allowStateLoss) {
- if (mStateSaved) {
- throw new IllegalStateException(
- "Can not perform this action after onSaveInstanceState");
- }
- if (mNoTransactionsBecause != null) {
- throw new IllegalStateException(
- "Can not perform this action inside of " + mNoTransactionsBecause);
- }
+ checkStateLoss();
}
synchronized (this) {
if (mActivity == null) {
@@ -934,17 +1018,23 @@
/**
* Only call from main thread!
*/
- public void execPendingActions() {
+ public boolean execPendingActions() {
if (mExecutingActions) {
- throw new IllegalStateException("Recursive entry to execPendingActions");
+ throw new IllegalStateException("Recursive entry to executePendingTransactions");
}
+ if (Looper.myLooper() != Looper.getMainLooper()) {
+ throw new IllegalStateException("Must be called from main thread of process");
+ }
+
+ boolean didSomething = false;
+
while (true) {
int numActions;
synchronized (this) {
if (mPendingActions == null || mPendingActions.size() == 0) {
- return;
+ return didSomething;
}
numActions = mPendingActions.size();
@@ -961,6 +1051,7 @@
mTmpActions[i].run();
}
mExecutingActions = false;
+ didSomething = true;
}
}
@@ -984,19 +1075,14 @@
if (mBackStack == null) {
return false;
}
- if (name == null && id < 0 && (flags&Activity.POP_BACK_STACK_INCLUSIVE) == 0) {
+ if (name == null && id < 0 && (flags&POP_BACK_STACK_INCLUSIVE) == 0) {
int last = mBackStack.size()-1;
if (last < 0) {
return false;
}
final BackStackRecord bss = mBackStack.remove(last);
- enqueueAction(new Runnable() {
- public void run() {
- if (DEBUG) Log.v(TAG, "Popping back stack state: " + bss);
- bss.popFromBackStack(true);
- reportBackStackChanged();
- }
- }, false);
+ bss.popFromBackStack(true);
+ reportBackStackChanged();
} else {
int index = -1;
if (name != null || id >= 0) {
@@ -1016,7 +1102,7 @@
if (index < 0) {
return false;
}
- if ((flags&Activity.POP_BACK_STACK_INCLUSIVE) != 0) {
+ if ((flags&POP_BACK_STACK_INCLUSIVE) != 0) {
index--;
// Consume all following entries that match.
while (index >= 0) {
@@ -1038,16 +1124,12 @@
for (int i=mBackStack.size()-1; i>index; i--) {
states.add(mBackStack.remove(i));
}
- enqueueAction(new Runnable() {
- public void run() {
- final int LAST = states.size()-1;
- for (int i=0; i<=LAST; i++) {
- if (DEBUG) Log.v(TAG, "Popping back stack state: " + states.get(i));
- states.get(i).popFromBackStack(i == LAST);
- }
- reportBackStackChanged();
- }
- }, false);
+ final int LAST = states.size()-1;
+ for (int i=0; i<=LAST; i++) {
+ if (DEBUG) Log.v(TAG, "Popping back stack state: " + states.get(i));
+ states.get(i).popFromBackStack(i == LAST);
+ }
+ reportBackStackChanged();
}
return true;
}
@@ -1084,6 +1166,10 @@
}
Parcelable saveAllState() {
+ // Make sure all pending operations have now been executed to get
+ // our state update-to-date.
+ execPendingActions();
+
mStateSaved = true;
if (mActive == null || mActive.size() <= 0) {
diff --git a/core/java/android/content/ContentQueryMap.java b/core/java/android/content/ContentQueryMap.java
index c955094..8aeaa8f 100644
--- a/core/java/android/content/ContentQueryMap.java
+++ b/core/java/android/content/ContentQueryMap.java
@@ -33,7 +33,7 @@
* The cursor data is accessed by row key and column name via getValue().
*/
public class ContentQueryMap extends Observable {
- private Cursor mCursor;
+ private volatile Cursor mCursor;
private String[] mColumnNames;
private int mKeyColumn;
@@ -71,7 +71,7 @@
// ContentProvider then read it once into the cache. Otherwise the cache will be filled
// automatically.
if (!keepUpdated) {
- readCursorIntoCache();
+ readCursorIntoCache(cursor);
}
}
@@ -128,27 +128,35 @@
/** Requeries the cursor and reads the contents into the cache */
public void requery() {
- mDirty = false;
- if (!mCursor.requery()) {
- throw new IllegalStateException("trying to requery an already closed cursor");
+ final Cursor cursor = mCursor;
+ if (cursor == null) {
+ // If mCursor is null then it means there was a requery() in flight
+ // while another thread called close(), which nulls out mCursor.
+ // If this happens ignore the requery() since we are closed anyways.
+ return;
}
- readCursorIntoCache();
+ mDirty = false;
+ if (!cursor.requery()) {
+ // again, don't do anything if the cursor is already closed
+ return;
+ }
+ readCursorIntoCache(cursor);
setChanged();
notifyObservers();
}
- private synchronized void readCursorIntoCache() {
+ private synchronized void readCursorIntoCache(Cursor cursor) {
// Make a new map so old values returned by getRows() are undisturbed.
int capacity = mValues != null ? mValues.size() : 0;
mValues = new HashMap<String, ContentValues>(capacity);
- while (mCursor.moveToNext()) {
+ while (cursor.moveToNext()) {
ContentValues values = new ContentValues();
for (int i = 0; i < mColumnNames.length; i++) {
if (i != mKeyColumn) {
- values.put(mColumnNames[i], mCursor.getString(i));
+ values.put(mColumnNames[i], cursor.getString(i));
}
}
- mValues.put(mCursor.getString(mKeyColumn), values);
+ mValues.put(cursor.getString(mKeyColumn), values);
}
}
diff --git a/core/java/android/os/DropBoxManager.java b/core/java/android/os/DropBoxManager.java
index a47c66a..47a7696 100644
--- a/core/java/android/os/DropBoxManager.java
+++ b/core/java/android/os/DropBoxManager.java
@@ -169,7 +169,12 @@
is = getInputStream();
if (is == null) return null;
byte[] buf = new byte[maxBytes];
- return new String(buf, 0, Math.max(0, is.read(buf)));
+ int readBytes = 0;
+ int n = 0;
+ while (n >= 0 && (readBytes += n) < maxBytes) {
+ n = is.read(buf, readBytes, maxBytes - readBytes);
+ }
+ return new String(buf, 0, readBytes);
} catch (IOException e) {
return null;
} finally {
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index 8762512..1fa5af2 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -106,6 +106,8 @@
private static final String TAG = "StrictMode";
private static final boolean LOG_V = false;
+ private static final boolean IS_USER_BUILD = "user".equals(Build.TYPE);
+
// Only log a duplicate stack trace to the logs every second.
private static final long MIN_LOG_INTERVAL_MS = 1000;
@@ -693,7 +695,7 @@
public static boolean conditionallyEnableDebugLogging() {
// For debug builds, log event loop stalls to dropbox for analysis.
// Similar logic also appears in ActivityThread.java for system apps.
- if ("user".equals(Build.TYPE)) {
+ if (IS_USER_BUILD) {
setCloseGuardEnabled(false);
return false;
}
@@ -1240,6 +1242,11 @@
mContainerState = threadState;
}
+ // Empty constructor for the NO_OP_SPAN
+ protected Span() {
+ mContainerState = null;
+ }
+
/**
* To be called when the critical span is complete (i.e. the
* animation is done animating). This can be called on any
@@ -1269,11 +1276,14 @@
state.mActiveHead = mNext;
}
+ state.mActiveSize--;
+
+ if (LOG_V) Log.d(TAG, "Span finished=" + mName + "; size=" + state.mActiveSize);
+
this.mCreateMillis = -1;
this.mName = null;
this.mPrev = null;
this.mNext = null;
- state.mActiveSize--;
// Add ourselves to the freeList, if it's not already
// too big.
@@ -1286,6 +1296,13 @@
}
}
+ // The no-op span that's used in user builds.
+ private static final Span NO_OP_SPAN = new Span() {
+ public void finish() {
+ // Do nothing.
+ }
+ };
+
/**
* Linked lists of active spans and a freelist.
*
@@ -1327,6 +1344,9 @@
* @hide
*/
public static Span enterCriticalSpan(String name) {
+ if (IS_USER_BUILD) {
+ return NO_OP_SPAN;
+ }
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("name must be non-null and non-empty");
}
@@ -1350,6 +1370,7 @@
if (span.mNext != null) {
span.mNext.mPrev = span;
}
+ if (LOG_V) Log.d(TAG, "Span enter=" + name + "; size=" + state.mActiveSize);
}
return span;
}
diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java
index 0ce69ad..39f3cee 100644
--- a/core/java/android/preference/PreferenceActivity.java
+++ b/core/java/android/preference/PreferenceActivity.java
@@ -23,6 +23,7 @@
import android.app.Fragment;
import android.app.FragmentBreadCrumbs;
+import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.app.ListActivity;
import android.content.Context;
@@ -902,7 +903,8 @@
}
private void switchToHeaderInner(String fragmentName, Bundle args, int direction) {
- getFragmentManager().popBackStack(BACK_STACK_PREFS, POP_BACK_STACK_INCLUSIVE);
+ getFragmentManager().popBackStack(BACK_STACK_PREFS,
+ FragmentManager.POP_BACK_STACK_INCLUSIVE);
Fragment f = Fragment.instantiate(this, fragmentName, args);
FragmentTransaction transaction = getFragmentManager().openTransaction();
transaction.setTransition(direction == 0 ? FragmentTransaction.TRANSIT_NONE
@@ -934,7 +936,8 @@
if (mCurHeader == header) {
// This is the header we are currently displaying. Just make sure
// to pop the stack up to its root state.
- getFragmentManager().popBackStack(BACK_STACK_PREFS, POP_BACK_STACK_INCLUSIVE);
+ getFragmentManager().popBackStack(BACK_STACK_PREFS,
+ FragmentManager.POP_BACK_STACK_INCLUSIVE);
} else {
int direction = mHeaders.indexOf(header) - mHeaders.indexOf(mCurHeader);
switchToHeaderInner(header.fragment, header.fragmentArguments, direction);
@@ -1061,14 +1064,14 @@
setResult(resultCode, resultData);
finish();
} else {
+ // XXX be smarter about popping the stack.
+ onBackPressed();
if (caller != null) {
if (caller.getTargetFragment() != null) {
caller.getTargetFragment().onActivityResult(caller.getTargetRequestCode(),
resultCode, resultData);
}
}
- // XXX be smarter about popping the stack.
- onBackPressed();
}
}
diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java
index dd25eaa..3fe4f4c 100644
--- a/core/java/android/text/Layout.java
+++ b/core/java/android/text/Layout.java
@@ -26,12 +26,11 @@
import android.text.method.TextKeyListener;
import android.text.style.AlignmentSpan;
import android.text.style.LeadingMarginSpan;
+import android.text.style.LeadingMarginSpan.LeadingMarginSpan2;
import android.text.style.LineBackgroundSpan;
import android.text.style.ParagraphStyle;
import android.text.style.ReplacementSpan;
import android.text.style.TabStopSpan;
-import android.text.style.LeadingMarginSpan.LeadingMarginSpan2;
-import android.view.KeyEvent;
import java.util.Arrays;
@@ -1056,23 +1055,30 @@
int lineEnd = getLineEnd(line);
int lineDir = getParagraphDirection(line);
+ boolean lineChanged = false;
boolean advance = toLeft == (lineDir == DIR_RIGHT_TO_LEFT);
- if (caret == (advance ? lineEnd : lineStart)) {
- // walking off line, so look at the line we're headed to
- if (caret == lineStart) {
- if (line > 0) {
- --line;
- } else {
- return caret; // at very start, don't move
- }
- } else {
+ // if walking off line, look at the line we're headed to
+ if (advance) {
+ if (caret == lineEnd) {
if (line < getLineCount() - 1) {
+ lineChanged = true;
++line;
} else {
return caret; // at very end, don't move
}
}
+ } else {
+ if (caret == lineStart) {
+ if (line > 0) {
+ lineChanged = true;
+ --line;
+ } else {
+ return caret; // at very start, don't move
+ }
+ }
+ }
+ if (lineChanged) {
lineStart = getLineStart(line);
lineEnd = getLineEnd(line);
int newDir = getParagraphDirection(line);
@@ -1672,6 +1678,7 @@
return new String(s);
}
+ @Override
public String toString() {
char[] s = new char[length()];
getChars(0, length(), s, 0);
@@ -1709,6 +1716,7 @@
return mSpanned.nextSpanTransition(start, limit, type);
}
+ @Override
public CharSequence subSequence(int start, int end) {
char[] s = new char[end - start];
getChars(start, end, s, 0);
diff --git a/core/java/android/view/MenuItem.java b/core/java/android/view/MenuItem.java
index 99da43b..602c765 100644
--- a/core/java/android/view/MenuItem.java
+++ b/core/java/android/view/MenuItem.java
@@ -405,6 +405,11 @@
/**
* Sets how this item should display in the presence of an Action Bar.
+ * The parameter actionEnum is a flag set. One of {@link #SHOW_AS_ACTION_ALWAYS},
+ * {@link #SHOW_AS_ACTION_IF_ROOM}, or {@link #SHOW_AS_ACTION_NEVER} should
+ * be used, and you may optionally OR the value with {@link #SHOW_AS_ACTION_WITH_TEXT}.
+ * SHOW_AS_ACTION_WITH_TEXT requests that when the item is shown as an action,
+ * it should be shown with a text label.
*
* @param actionEnum How the item should display. One of
* {@link #SHOW_AS_ACTION_ALWAYS}, {@link #SHOW_AS_ACTION_IF_ROOM}, or
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index be49255..e6eb46e 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6304,12 +6304,7 @@
}
final AttachInfo ai = mAttachInfo;
final ViewParent p = mParent;
- if (p != null && ai != null && ai.mHardwareAccelerated) {
- // fast-track for GL-enabled applications; just invalidate the whole hierarchy
- // with a null dirty rect, which tells the ViewRoot to redraw everything
- p.invalidateChild(this, null);
- return;
- }
+
if (p != null && ai != null) {
final Rect r = ai.mTmpInvalRect;
r.set(0, 0, mRight - mLeft, mBottom - mTop);
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index d5d9a2e..5385cd9 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -313,12 +313,31 @@
public boolean onSearchRequested();
/**
- * Called when an action mode is being started.
+ * Called when an action mode is being started for this window. Gives the
+ * callback an opportunity to handle the action mode in its own unique and
+ * beautiful way. If this method returns null the system can choose a way
+ * to present the mode or choose not to start the mode at all.
*
* @param callback Callback to control the lifecycle of this action mode
- * @return The ActionMode that was started, or null if it was canceled
+ * @return The ActionMode that was started, or null if the system should present it
*/
- public ActionMode onStartActionMode(ActionMode.Callback callback);
+ public ActionMode onWindowStartingActionMode(ActionMode.Callback callback);
+
+ /**
+ * Called when an action mode has been started. The appropriate mode callback
+ * method will have already been invoked.
+ *
+ * @param mode The new mode that has just been started.
+ */
+ public void onActionModeStarted(ActionMode mode);
+
+ /**
+ * Called when an action mode has been finished. The appropriate mode callback
+ * method will have already been invoked.
+ *
+ * @param mode The mode that was just finished.
+ */
+ public void onActionModeFinished(ActionMode mode);
}
public Window(Context context) {
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 14dbfe2..f987a49 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -2384,7 +2384,6 @@
Rect sendOurVisibleRect() {
if (mZoomManager.isPreventingWebkitUpdates()) return mLastVisibleRectSent;
-
Rect rect = new Rect();
calcOurContentVisibleRect(rect);
// Rect.equals() checks for null input.
@@ -2937,7 +2936,8 @@
postInvalidate(); // So we draw again
if (oldX != mScrollX || oldY != mScrollY) {
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
- } else {
+ } else if (mScroller.getStartX() != mScrollX
+ || mScroller.getStartY() != mScrollY) {
abortAnimation();
mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY);
WebViewCore.resumePriority();
@@ -2970,6 +2970,7 @@
if ((dx | dy) == 0) {
return false;
}
+ abortAnimation();
if (animate) {
// Log.d(LOGTAG, "startScroll: " + dx + " " + dy);
mScroller.startScroll(mScrollX, mScrollY, dx, dy,
@@ -2977,7 +2978,6 @@
awakenScrollBars(mScroller.getDuration());
invalidate();
} else {
- abortAnimation(); // just in case
scrollTo(x, y);
}
return true;
@@ -4185,9 +4185,8 @@
if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT
|| keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
- if (pageShouldHandleShiftAndArrows()) {
- mShiftIsPressed = true;
- } else if (!nativeCursorWantsKeyEvents() && !mSelectingText) {
+ if (!pageShouldHandleShiftAndArrows() && !nativeCursorWantsKeyEvents()
+ && !mSelectingText) {
setUpSelect();
}
}
@@ -4206,7 +4205,7 @@
&& keyCode <= KeyEvent.KEYCODE_DPAD_RIGHT) {
switchOutDrawHistory();
if (pageShouldHandleShiftAndArrows()) {
- letPageHandleNavKey(keyCode, event.getEventTime(), true);
+ letPageHandleNavKey(keyCode, event.getEventTime(), true, event.getMetaState());
return true;
}
if (mSelectingText) {
@@ -4248,7 +4247,6 @@
&& keyCode != KeyEvent.KEYCODE_SHIFT_RIGHT) {
// turn off copy select if a shift-key combo is pressed
selectionDone();
- mShiftIsPressed = false;
}
if (getSettings().getNavDump()) {
@@ -4339,9 +4337,7 @@
if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT
|| keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
- if (pageShouldHandleShiftAndArrows()) {
- mShiftIsPressed = false;
- } else if (copySelection()) {
+ if (!pageShouldHandleShiftAndArrows() && copySelection()) {
selectionDone();
return true;
}
@@ -4350,7 +4346,7 @@
if (keyCode >= KeyEvent.KEYCODE_DPAD_UP
&& keyCode <= KeyEvent.KEYCODE_DPAD_RIGHT) {
if (pageShouldHandleShiftAndArrows()) {
- letPageHandleNavKey(keyCode, event.getEventTime(), false);
+ letPageHandleNavKey(keyCode, event.getEventTime(), false, event.getMetaState());
return true;
}
// always handle the navigation keys in the UI thread
@@ -4592,7 +4588,6 @@
mDrawCursorRing = false;
}
mGotKeyDown = false;
- mShiftIsPressed = false;
mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
mTouchMode = TOUCH_DONE_MODE;
if (mNativeClass != 0) {
@@ -5529,7 +5524,6 @@
private int mSelectX = 0;
private int mSelectY = 0;
private boolean mFocusSizeChanged = false;
- private boolean mShiftIsPressed = false;
private boolean mTrackballDown = false;
private long mTrackballUpTime = 0;
private long mLastCursorTime = 0;
@@ -5600,7 +5594,7 @@
}
return false; // let common code in onKeyUp at it
}
- if ((mMapTrackballToArrowKeys && mShiftIsPressed == false) ||
+ if ((mMapTrackballToArrowKeys && (ev.getMetaState() & KeyEvent.META_SHIFT_ON) == 0) ||
(mAccessibilityInjector != null || mAccessibilityScriptInjected)) {
if (DebugFlags.WEB_VIEW) Log.v(LOGTAG, "onTrackballEvent gmail quit");
return false;
@@ -5629,7 +5623,7 @@
}
mTrackballRemainsX += ev.getX();
mTrackballRemainsY += ev.getY();
- doTrackball(time);
+ doTrackball(time, ev.getMetaState());
return true;
}
@@ -5713,7 +5707,7 @@
"KEYCODE_DPAD_LEFT}.");
}
- private void doTrackball(long time) {
+ private void doTrackball(long time, int metaState) {
int elapsed = (int) (mTrackballLastTime - mTrackballFirstTime);
if (elapsed == 0) {
elapsed = TRACKBALL_TIMEOUT;
@@ -5771,9 +5765,9 @@
}
if (mNativeClass != 0 && nativePageShouldHandleShiftAndArrows()) {
for (int i = 0; i < count; i++) {
- letPageHandleNavKey(selectKeyCode, time, true);
+ letPageHandleNavKey(selectKeyCode, time, true, metaState);
}
- letPageHandleNavKey(selectKeyCode, time, false);
+ letPageHandleNavKey(selectKeyCode, time, false, metaState);
} else if (navHandledKey(selectKeyCode, count, false, time)) {
playSoundEffect(keyCodeToSoundsEffect(selectKeyCode));
}
@@ -7282,7 +7276,7 @@
* Pass the key directly to the page. This assumes that
* nativePageShouldHandleShiftAndArrows() returned true.
*/
- private void letPageHandleNavKey(int keyCode, long time, boolean down) {
+ private void letPageHandleNavKey(int keyCode, long time, boolean down, int metaState) {
int keyEventAction;
int eventHubAction;
if (down) {
@@ -7293,10 +7287,11 @@
keyEventAction = KeyEvent.ACTION_UP;
eventHubAction = EventHub.KEY_UP;
}
+
KeyEvent event = new KeyEvent(time, time, keyEventAction, keyCode,
- 1, (mShiftIsPressed ? KeyEvent.META_SHIFT_ON : 0)
- | (false ? KeyEvent.META_ALT_ON : 0) // FIXME
- | (false ? KeyEvent.META_SYM_ON : 0) // FIXME
+ 1, (metaState & KeyEvent.META_SHIFT_ON)
+ | (metaState & KeyEvent.META_ALT_ON)
+ | (metaState & KeyEvent.META_SYM_ON)
, 0, 0, 0);
mWebViewCore.sendMessage(eventHubAction, event);
}
diff --git a/core/java/android/webkit/ZoomControlEmbedded.java b/core/java/android/webkit/ZoomControlEmbedded.java
index c29e72b..e505614 100644
--- a/core/java/android/webkit/ZoomControlEmbedded.java
+++ b/core/java/android/webkit/ZoomControlEmbedded.java
@@ -40,13 +40,15 @@
mZoomButtonsController.setVisible(true);
- WebSettings settings = mWebView.getSettings();
- int count = settings.getDoubleTapToastCount();
- if (mZoomManager.isInZoomOverview() && count > 0) {
- settings.setDoubleTapToastCount(--count);
- Toast.makeText(mWebView.getContext(),
- com.android.internal.R.string.double_tap_toast,
- Toast.LENGTH_LONG).show();
+ if (mZoomManager.isDoubleTapEnabled()) {
+ WebSettings settings = mWebView.getSettings();
+ int count = settings.getDoubleTapToastCount();
+ if (mZoomManager.isInZoomOverview() && count > 0) {
+ settings.setDoubleTapToastCount(--count);
+ Toast.makeText(mWebView.getContext(),
+ com.android.internal.R.string.double_tap_toast,
+ Toast.LENGTH_LONG).show();
+ }
}
}
}
diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java
index c788a53..69db6b2 100644
--- a/core/java/android/webkit/ZoomManager.java
+++ b/core/java/android/webkit/ZoomManager.java
@@ -510,6 +510,11 @@
}
}
+ public boolean isDoubleTapEnabled() {
+ WebSettings settings = mWebView.getSettings();
+ return settings != null && settings.getUseWideViewPort();
+ }
+
/**
* The double tap gesture can result in different behaviors depending on the
* content that is tapped.
@@ -528,7 +533,7 @@
*/
public void handleDoubleTap(float lastTouchX, float lastTouchY) {
WebSettings settings = mWebView.getSettings();
- if (settings == null || settings.getUseWideViewPort() == false) {
+ if (!isDoubleTapEnabled()) {
return;
}
@@ -808,7 +813,9 @@
setZoomOverviewWidth(Math.min(WebView.sMaxViewportWidth,
Math.max((int) (viewWidth * mInvDefaultScale),
Math.max(drawData.mMinPrefWidth, drawData.mViewSize.x))));
- } else {
+ } else if (drawData.mContentSize.x > 0) {
+ // The webkitDraw for layers will not populate contentSize, and it'll be
+ // ignored for zoom overview width update.
final int contentWidth = Math.max(drawData.mContentSize.x, drawData.mMinPrefWidth);
final int newZoomOverviewWidth = Math.min(WebView.sMaxViewportWidth, contentWidth);
if (newZoomOverviewWidth != mZoomOverviewWidth) {
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index ab5ff3d..466e541 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -29,6 +29,7 @@
import android.os.Handler;
import android.os.Parcel;
import android.os.Parcelable;
+import android.os.StrictMode;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@@ -460,6 +461,15 @@
private boolean mFlingProfilingStarted = false;
/**
+ * The StrictMode "critical time span" objects to catch animation
+ * stutters. Non-null when a time-sensitive animation is
+ * in-flight. Must call finish() on them when done animating.
+ * These are no-ops on user builds.
+ */
+ private StrictMode.Span mScrollStrictSpan = null;
+ private StrictMode.Span mFlingStrictSpan = null;
+
+ /**
* The last CheckForLongPress runnable we posted, if any
*/
private CheckForLongPress mPendingCheckForLongPress;
@@ -2089,6 +2099,16 @@
mAdapter.unregisterDataSetObserver(mDataSetObserver);
mDataSetObserver = null;
}
+
+ if (mScrollStrictSpan != null) {
+ mScrollStrictSpan.finish();
+ mScrollStrictSpan = null;
+ }
+
+ if (mFlingStrictSpan != null) {
+ mFlingStrictSpan.finish();
+ mFlingStrictSpan = null;
+ }
}
@Override
@@ -2559,6 +2579,11 @@
}
}
+ if (mScrollStrictSpan == null) {
+ // If it's non-null, we're already in a scroll.
+ mScrollStrictSpan = StrictMode.enterCriticalSpan("AbsListView-scroll");
+ }
+
if (y != mLastY) {
// We may be here after stopping a fling and continuing to scroll.
// If so, we haven't disallowed intercepting touch events yet.
@@ -2722,6 +2747,11 @@
mScrollProfilingStarted = false;
}
}
+
+ if (mScrollStrictSpan != null) {
+ mScrollStrictSpan.finish();
+ mScrollStrictSpan = null;
+ }
break;
}
@@ -2893,8 +2923,8 @@
void reportScrollStateChange(int newState) {
if (newState != mLastScrollState) {
if (mOnScrollListener != null) {
- mOnScrollListener.onScrollStateChanged(this, newState);
mLastScrollState = newState;
+ mOnScrollListener.onScrollStateChanged(this, newState);
}
}
}
@@ -2934,6 +2964,10 @@
mFlingProfilingStarted = true;
}
}
+
+ if (mFlingStrictSpan == null) {
+ mFlingStrictSpan = StrictMode.enterCriticalSpan("AbsListView-fling");
+ }
}
void startScroll(int distance, int duration) {
@@ -3012,6 +3046,11 @@
mFlingProfilingStarted = false;
}
}
+
+ if (mFlingStrictSpan != null) {
+ mFlingStrictSpan.finish();
+ mFlingStrictSpan = null;
+ }
}
break;
}
@@ -3431,12 +3470,13 @@
public void smoothScrollBy(int distance, int duration) {
if (mFlingRunnable == null) {
mFlingRunnable = new FlingRunnable();
- } else {
- mFlingRunnable.endFling();
}
// No sense starting to scroll if we're not going anywhere
if (distance != 0) {
+ reportScrollStateChange(OnScrollListener.SCROLL_STATE_FLING);
mFlingRunnable.startScroll(distance, duration);
+ } else {
+ mFlingRunnable.endFling();
}
}
diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java
index 432dd4a..e2d78c0 100644
--- a/core/java/android/widget/StackView.java
+++ b/core/java/android/widget/StackView.java
@@ -100,6 +100,8 @@
private static final int FRAME_PADDING = 4;
+ private final Rect mTouchRect = new Rect();
+
/**
* These variables are all related to the current state of touch interaction
* with the stack
@@ -531,7 +533,6 @@
return true;
}
- private final Rect touchRect = new Rect();
private void onSecondaryPointerUp(MotionEvent ev) {
final int activePointerIndex = ev.getActionIndex();
final int pointerId = ev.getPointerId(activePointerIndex);
@@ -552,8 +553,8 @@
float x = ev.getX(index);
float y = ev.getY(index);
- touchRect.set(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
- if (touchRect.contains(Math.round(x), Math.round(y))) {
+ mTouchRect.set(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
+ if (mTouchRect.contains(Math.round(x), Math.round(y))) {
float oldX = ev.getX(activePointerIndex);
float oldY = ev.getY(activePointerIndex);
@@ -1049,18 +1050,23 @@
private static final int RES_OUT = 0;
private static final int CLICK_FEEDBACK = 1;
private float mDensity;
+ private BlurMaskFilter mSmallBlurMaskFilter;
+ private BlurMaskFilter mLargeBlurMaskFilter;
+ private final Canvas mCanvas = new Canvas();
+ private final Canvas mMaskCanvas = new Canvas();
+ private final int[] mTmpXY = new int[2];
+ private final Matrix mIdentityMatrix = new Matrix();
HolographicHelper(Context context) {
- initializePaints(context);
- }
-
- void initializePaints(Context context) {
mDensity = context.getResources().getDisplayMetrics().density;
mHolographicPaint.setFilterBitmap(true);
mHolographicPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30));
mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
mErasePaint.setFilterBitmap(true);
+
+ mSmallBlurMaskFilter = new BlurMaskFilter(2 * mDensity, BlurMaskFilter.Blur.NORMAL);
+ mLargeBlurMaskFilter = new BlurMaskFilter(4 * mDensity, BlurMaskFilter.Blur.NORMAL);
}
Bitmap createOutline(View v) {
@@ -1070,10 +1076,10 @@
Bitmap createOutline(View v, int type) {
if (type == RES_OUT) {
mHolographicPaint.setColor(0xff6699ff);
- mBlurPaint.setMaskFilter(new BlurMaskFilter(2*mDensity, BlurMaskFilter.Blur.NORMAL));
+ mBlurPaint.setMaskFilter(mSmallBlurMaskFilter);
} else if (type == CLICK_FEEDBACK) {
mHolographicPaint.setColor(0x886699ff);
- mBlurPaint.setMaskFilter(new BlurMaskFilter(4*mDensity, BlurMaskFilter.Blur.NORMAL));
+ mBlurPaint.setMaskFilter(mLargeBlurMaskFilter);
}
if (v.getMeasuredWidth() == 0 || v.getMeasuredHeight() == 0) {
@@ -1082,7 +1088,7 @@
Bitmap bitmap = Bitmap.createBitmap(v.getMeasuredWidth(), v.getMeasuredHeight(),
Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(bitmap);
+ mCanvas.setBitmap(bitmap);
float rotationX = v.getRotationX();
float rotation = v.getRotation();
@@ -1090,23 +1096,22 @@
v.setRotationX(0);
v.setRotation(0);
v.setTranslationY(0);
- v.draw(canvas);
+ v.draw(mCanvas);
v.setRotationX(rotationX);
v.setRotation(rotation);
v.setTranslationY(translationY);
- drawOutline(canvas, bitmap);
+ drawOutline(mCanvas, bitmap);
return bitmap;
}
- final Matrix id = new Matrix();
void drawOutline(Canvas dest, Bitmap src) {
- int[] xy = new int[2];
+ final int[] xy = mTmpXY;
Bitmap mask = src.extractAlpha(mBlurPaint, xy);
- Canvas maskCanvas = new Canvas(mask);
- maskCanvas.drawBitmap(src, -xy[0], -xy[1], mErasePaint);
+ mMaskCanvas.setBitmap(mask);
+ mMaskCanvas.drawBitmap(src, -xy[0], -xy[1], mErasePaint);
dest.drawColor(0, PorterDuff.Mode.CLEAR);
- dest.setMatrix(id);
+ dest.setMatrix(mIdentityMatrix);
dest.drawBitmap(mask, xy[0], xy[1], mHolographicPaint);
mask.recycle();
}
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 5320b10..f32ae92 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -305,6 +305,8 @@
int mTextSelectHandleRes;
int mTextEditPasteWindowLayout;
int mTextEditNoPasteWindowLayout;
+ Drawable mEditTextMultilineBackground;
+ Drawable mEditTextSingleLineBackground;
Drawable mSelectHandleLeft;
Drawable mSelectHandleRight;
@@ -751,6 +753,10 @@
mTextEditNoPasteWindowLayout = a.getResourceId(attr, 0);
break;
+ case com.android.internal.R.styleable.TextView_multilineBackground:
+ mEditTextMultilineBackground = a.getDrawable(attr);
+ break;
+
case com.android.internal.R.styleable.TextView_textLineHeight:
int lineHeight = a.getDimensionPixelSize(attr, 0);
if (lineHeight != 0) {
@@ -765,6 +771,7 @@
}
a.recycle();
+ mEditTextSingleLineBackground = getBackground();
BufferType bufferType = BufferType.EDITABLE;
final int variation =
@@ -3869,7 +3876,7 @@
// - ExtractEditText does not call onFocus when it is displayed. Fixing this issue would
// allow to test for hasSelection in onFocusChanged, which would trigger a
// startTextSelectionMode here. TODO
- if (selectionController != null && hasSelection()) {
+ if (this instanceof ExtractEditText && selectionController != null && hasSelection()) {
startSelectionActionMode();
}
@@ -5042,6 +5049,7 @@
}
public void beginBatchEdit() {
+ mInBatchEditControllers = true;
final InputMethodState ims = mInputMethodState;
if (ims != null) {
int nesting = ++ims.mBatchEditNesting;
@@ -5064,6 +5072,7 @@
}
public void endBatchEdit() {
+ mInBatchEditControllers = false;
final InputMethodState ims = mInputMethodState;
if (ims != null) {
int nesting = --ims.mBatchEditNesting;
@@ -6190,12 +6199,17 @@
if (applyTransformation) {
setTransformationMethod(SingleLineTransformationMethod.getInstance());
}
+ setBackgroundDrawable(mEditTextSingleLineBackground);
} else {
setMaxLines(Integer.MAX_VALUE);
setHorizontallyScrolling(false);
if (applyTransformation) {
setTransformationMethod(null);
}
+ // mEditTextMultilineBackground is defined and used only in EditText
+ if (mEditTextMultilineBackground != null) {
+ setBackgroundDrawable(mEditTextMultilineBackground);
+ }
}
}
@@ -6709,7 +6723,8 @@
+ " before=" + before + " after=" + after + ": " + buffer);
if (AccessibilityManager.getInstance(mContext).isEnabled()
- && !isPasswordInputType(mInputType)) {
+ && !isPasswordInputType(mInputType)
+ && !hasPasswordTransformationMethod()) {
mBeforeText = buffer.toString();
}
@@ -6991,26 +7006,21 @@
// Restore previous selection
Selection.setSelection((Spannable)mText, prevStart, prevEnd);
- if (mSelectionModifierCursorController != null &&
- !mSelectionModifierCursorController.isShowing()) {
+ if (hasSelectionController() && !getSelectionController().isShowing()) {
// If the anchors aren't showing, revive them.
- mSelectionModifierCursorController.show();
- } else {
- // Tapping inside the selection displays the cut/copy/paste context menu
- // as long as the anchors are already showing.
- showContextMenu();
+ getSelectionController().show();
}
return;
} else {
// Tapping outside stops selection mode, if any
stopSelectionActionMode();
- if (mInsertionPointCursorController != null) {
- mInsertionPointCursorController.show();
+ if (hasInsertionController()) {
+ getInsertionController().show();
}
}
- } else if (hasSelection() && mSelectionModifierCursorController != null) {
- mSelectionModifierCursorController.show();
+ } else if (hasSelection() && hasSelectionController()) {
+ getSelectionController().show();
}
}
@@ -7043,11 +7053,12 @@
@Override
public boolean onTouchEvent(MotionEvent event) {
final int action = event.getActionMasked();
- if (mInsertionPointCursorController != null) {
- mInsertionPointCursorController.onTouchEvent(event);
+
+ if (hasInsertionController()) {
+ getInsertionController().onTouchEvent(event);
}
- if (mSelectionModifierCursorController != null) {
- mSelectionModifierCursorController.onTouchEvent(event);
+ if (hasSelectionController()) {
+ getSelectionController().onTouchEvent(event);
}
if (action == MotionEvent.ACTION_DOWN) {
@@ -7129,21 +7140,17 @@
|| windowParams.type > WindowManager.LayoutParams.LAST_SUB_WINDOW;
}
- if (windowSupportsHandles && isTextEditable() && mCursorVisible && mLayout != null &&
- !mTextIsSelectable) {
- if (mInsertionPointCursorController == null) {
- mInsertionPointCursorController = new InsertionPointCursorController();
- }
- } else {
- hideInsertionPointCursorController();
+ // TODO Add an extra android:cursorController flag to disable the controller?
+ mInsertionControllerEnabled = windowSupportsHandles && isTextEditable() && mCursorVisible &&
+ mLayout != null && !mTextIsSelectable;
+ mSelectionControllerEnabled = windowSupportsHandles && textCanBeSelected() &&
+ mLayout != null;
+
+ if (!mInsertionControllerEnabled) {
mInsertionPointCursorController = null;
}
- if (windowSupportsHandles && textCanBeSelected() && mLayout != null) {
- if (mSelectionModifierCursorController == null) {
- mSelectionModifierCursorController = new SelectionModifierCursorController();
- }
- } else {
+ if (!mSelectionControllerEnabled) {
// Stop selection mode if the controller becomes unavailable.
if (mSelectionModifierCursorController != null) {
stopSelectionActionMode();
@@ -7596,7 +7603,7 @@
return false;
}
- final boolean isPassword = isPasswordInputType(mInputType);
+ final boolean isPassword = hasPasswordTransformationMethod();
if (!isPassword) {
CharSequence text = getText();
@@ -8348,6 +8355,10 @@
return true;
}
+ if (isInBatchEditMode()) {
+ return false;
+ }
+
final int extendedPaddingTop = getExtendedPaddingTop();
final int extendedPaddingBottom = getExtendedPaddingBottom();
final int compoundPaddingLeft = getCompoundPaddingLeft();
@@ -8387,7 +8398,7 @@
mPositionY = y - TextView.this.mScrollY;
if (isPositionVisible()) {
int[] coords = null;
- if (mContainer.isShowing()){
+ if (mContainer.isShowing()) {
coords = mTempCoords;
TextView.this.getLocationInWindow(coords);
final int containerPositionX = coords[0] + mPositionX;
@@ -8626,6 +8637,10 @@
}
public void show() {
+ if (isInBatchEditMode()) {
+ return;
+ }
+
mIsShowing = true;
updatePosition();
mStartHandle.show();
@@ -8689,6 +8704,10 @@
}
public void updatePosition() {
+ if (!isShowing()) {
+ return;
+ }
+
final int selectionStart = getSelectionStart();
final int selectionEnd = getSelectionEnd();
@@ -8913,8 +8932,62 @@
}
}
+ /**
+ * @return True if this view supports insertion handles.
+ */
+ boolean hasInsertionController() {
+ return mInsertionControllerEnabled;
+ }
- @ViewDebug.ExportedProperty(category = "text")
+ /**
+ * @return True if this view supports selection handles.
+ */
+ boolean hasSelectionController() {
+ return mSelectionControllerEnabled;
+ }
+
+ CursorController getInsertionController() {
+ if (!mInsertionControllerEnabled) {
+ return null;
+ }
+
+ if (mInsertionPointCursorController == null) {
+ mInsertionPointCursorController = new InsertionPointCursorController();
+
+ final ViewTreeObserver observer = getViewTreeObserver();
+ if (observer != null) {
+ observer.addOnTouchModeChangeListener(mInsertionPointCursorController);
+ }
+ }
+
+ return mInsertionPointCursorController;
+ }
+
+ CursorController getSelectionController() {
+ if (!mSelectionControllerEnabled) {
+ return null;
+ }
+
+ if (mSelectionModifierCursorController == null) {
+ mSelectionModifierCursorController = new SelectionModifierCursorController();
+
+ final ViewTreeObserver observer = getViewTreeObserver();
+ if (observer != null) {
+ observer.addOnTouchModeChangeListener(mSelectionModifierCursorController);
+ }
+ }
+
+ return mSelectionModifierCursorController;
+ }
+
+ boolean isInBatchEditMode() {
+ final InputMethodState ims = mInputMethodState;
+ if (ims != null) {
+ return ims.mBatchEditNesting > 0;
+ }
+ return mInBatchEditControllers;
+ }
+
private CharSequence mText;
private CharSequence mTransformed;
private BufferType mBufferType = BufferType.NORMAL;
@@ -8942,10 +9015,14 @@
private Blink mBlink;
private boolean mCursorVisible = true;
- // Cursor Controllers. Null when disabled.
+ // Cursor Controllers.
private CursorController mInsertionPointCursorController;
private CursorController mSelectionModifierCursorController;
private ActionMode mSelectionActionMode;
+ private boolean mInsertionControllerEnabled;
+ private boolean mSelectionControllerEnabled;
+ private boolean mInBatchEditControllers;
+
// These are needed to desambiguate a long click. If the long click comes from ones of these, we
// select from the current cursor position. Otherwise, select from long pressed position.
private boolean mDPadCenterIsDown = false;
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index cd1cae6..86523ac 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -212,6 +212,10 @@
}
public View getCustomNavigationView() {
+ return getCustomView();
+ }
+
+ public View getCustomView() {
return mActionView.getCustomNavigationView();
}
diff --git a/core/java/com/android/internal/view/menu/MenuPopupHelper.java b/core/java/com/android/internal/view/menu/MenuPopupHelper.java
index 1d103ed..1406e4e 100644
--- a/core/java/com/android/internal/view/menu/MenuPopupHelper.java
+++ b/core/java/com/android/internal/view/menu/MenuPopupHelper.java
@@ -110,8 +110,10 @@
if (isShowing()) {
mPopup.dismiss();
}
- mTreeObserver.removeGlobalOnLayoutListener(this);
- mTreeObserver = null;
+ if (mTreeObserver != null) {
+ mTreeObserver.removeGlobalOnLayoutListener(this);
+ mTreeObserver = null;
+ }
}
public boolean isShowing() {
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 0a4f543..e18f58f 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -40,6 +40,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
+import android.view.Window;
import android.widget.AdapterView;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
@@ -219,7 +220,7 @@
Context context = getContext();
if (context instanceof Activity) {
Activity activity = (Activity) context;
- activity.onOptionsItemSelected(mLogoNavItem);
+ activity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem);
}
}
});
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 1018ddb..e50233e 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -1194,6 +1194,7 @@
REG_JNI(register_android_text_AndroidBidi),
REG_JNI(register_android_text_KeyCharacterMap),
REG_JNI(register_android_os_Process),
+ REG_JNI(register_android_os_SystemProperties),
REG_JNI(register_android_os_Binder),
REG_JNI(register_android_view_Display),
REG_JNI(register_android_nio_utils),
@@ -1251,7 +1252,6 @@
REG_JNI(register_android_os_ParcelFileDescriptor),
REG_JNI(register_android_os_Power),
REG_JNI(register_android_os_StatFs),
- REG_JNI(register_android_os_SystemProperties),
REG_JNI(register_android_os_UEventObserver),
REG_JNI(register_android_net_LocalSocketImpl),
REG_JNI(register_android_net_NetworkUtils),
diff --git a/core/res/res/drawable-hdpi/textfield_active_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_active_holo_dark.9.png
new file mode 100644
index 0000000..a38c03a
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_active_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_active_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_active_holo_light.9.png
new file mode 100644
index 0000000..6a88a69
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_active_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_default_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_default_holo_dark.9.png
index 7ec2192..87d9c21 100644
--- a/core/res/res/drawable-hdpi/textfield_default_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/textfield_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_default_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_default_holo_light.9.png
index c03e4f6..720ee78 100644
--- a/core/res/res/drawable-hdpi/textfield_default_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/textfield_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_dark.9.png
new file mode 100644
index 0000000..4275da07
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_light.9.png
new file mode 100644
index 0000000..3ec9c1f
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_disabled_holo_dark.9.png
index 6642717..227bde2 100644
--- a/core/res/res/drawable-hdpi/textfield_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/textfield_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_disabled_holo_light.9.png
index 9572752..6ddfab0 100644
--- a/core/res/res/drawable-hdpi/textfield_disabled_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/textfield_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_disabled_selected_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_disabled_selected_holo_dark.9.png
deleted file mode 100644
index 0ad248c..0000000
--- a/core/res/res/drawable-hdpi/textfield_disabled_selected_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_disabled_selected_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_disabled_selected_holo_light.9.png
deleted file mode 100644
index b7a07c4..0000000
--- a/core/res/res/drawable-hdpi/textfield_disabled_selected_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_active_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_multiline_active_holo_dark.9.png
new file mode 100644
index 0000000..7528479
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_multiline_active_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_active_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_multiline_active_holo_light.9.png
new file mode 100644
index 0000000..4c7d9e7
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_multiline_active_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_default_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_multiline_default_holo_dark.9.png
new file mode 100644
index 0000000..09ca253
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_multiline_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_default_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_multiline_default_holo_light.9.png
new file mode 100644
index 0000000..0a7d3a1
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_multiline_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_dark.9.png
new file mode 100644
index 0000000..54a1519
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_light.9.png
new file mode 100644
index 0000000..06ca0d4
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_dark.9.png
new file mode 100644
index 0000000..9015299
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_light.9.png
new file mode 100644
index 0000000..b355cb3
--- /dev/null
+++ b/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_pressed.9.png b/core/res/res/drawable-hdpi/textfield_pressed.9.png
deleted file mode 100644
index a42d87f..0000000
--- a/core/res/res/drawable-hdpi/textfield_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_pressed_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_pressed_holo_dark.9.png
deleted file mode 100644
index a271ac9b..0000000
--- a/core/res/res/drawable-hdpi/textfield_pressed_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_pressed_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_pressed_holo_light.9.png
deleted file mode 100644
index 521722d..0000000
--- a/core/res/res/drawable-hdpi/textfield_pressed_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_selected_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_selected_holo_dark.9.png
deleted file mode 100644
index a271ac9b..0000000
--- a/core/res/res/drawable-hdpi/textfield_selected_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_selected_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_selected_holo_light.9.png
deleted file mode 100644
index 521722d..0000000
--- a/core/res/res/drawable-hdpi/textfield_selected_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-ldpi/textfield_pressed.9.png b/core/res/res/drawable-ldpi/textfield_pressed.9.png
deleted file mode 100644
index 1433365..0000000
--- a/core/res/res/drawable-ldpi/textfield_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_active_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_active_holo_dark.9.png
new file mode 100644
index 0000000..d37c8b2
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_active_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_active_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_active_holo_light.9.png
new file mode 100644
index 0000000..16f2197
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_active_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_default_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_default_holo_dark.9.png
index 3a5f36d..c98c951 100644
--- a/core/res/res/drawable-mdpi/textfield_default_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/textfield_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_default_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_default_holo_light.9.png
index b8cc76f..7691f81 100644
--- a/core/res/res/drawable-mdpi/textfield_default_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/textfield_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_dark.9.png
new file mode 100644
index 0000000..500ede3
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_light.9.png
new file mode 100644
index 0000000..99f7f38
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_disabled_holo_dark.9.png
index a1f0c71..fab86ac 100644
--- a/core/res/res/drawable-mdpi/textfield_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/textfield_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_disabled_holo_light.9.png
index 71e3103..876eb794 100644
--- a/core/res/res/drawable-mdpi/textfield_disabled_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/textfield_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_disabled_selected_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_disabled_selected_holo_dark.9.png
deleted file mode 100644
index ac6d406..0000000
--- a/core/res/res/drawable-mdpi/textfield_disabled_selected_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_disabled_selected_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_disabled_selected_holo_light.9.png
deleted file mode 100644
index bb6e953..0000000
--- a/core/res/res/drawable-mdpi/textfield_disabled_selected_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_active_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_multiline_active_holo_dark.9.png
new file mode 100644
index 0000000..2646899
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_multiline_active_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_active_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_multiline_active_holo_light.9.png
new file mode 100644
index 0000000..374d457
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_multiline_active_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_default_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_multiline_default_holo_dark.9.png
new file mode 100644
index 0000000..65c87ba
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_multiline_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_default_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_multiline_default_holo_light.9.png
new file mode 100644
index 0000000..724b3fd
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_multiline_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_dark.9.png
new file mode 100644
index 0000000..5f0ad56
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_light.9.png
new file mode 100644
index 0000000..df03a15
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_dark.9.png
new file mode 100644
index 0000000..2cc7f62
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_light.9.png
new file mode 100644
index 0000000..a2d9d8a
--- /dev/null
+++ b/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_pressed.9.png b/core/res/res/drawable-mdpi/textfield_pressed.9.png
deleted file mode 100644
index c909ad2..0000000
--- a/core/res/res/drawable-mdpi/textfield_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_pressed_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_pressed_holo_dark.9.png
deleted file mode 100644
index 7667d95..0000000
--- a/core/res/res/drawable-mdpi/textfield_pressed_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_pressed_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_pressed_holo_light.9.png
deleted file mode 100644
index 269affd..0000000
--- a/core/res/res/drawable-mdpi/textfield_pressed_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_selected_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_selected_holo_dark.9.png
deleted file mode 100644
index 7667d95..0000000
--- a/core/res/res/drawable-mdpi/textfield_selected_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_selected_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_selected_holo_light.9.png
deleted file mode 100644
index 269affd..0000000
--- a/core/res/res/drawable-mdpi/textfield_selected_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable/edit_text.xml b/core/res/res/drawable/edit_text.xml
index 315278d..e9ba84b 100644
--- a/core/res/res/drawable/edit_text.xml
+++ b/core/res/res/drawable/edit_text.xml
@@ -15,11 +15,8 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_window_focused="false" android:state_enabled="true"
- android:drawable="@drawable/textfield_default" />
- <item android:state_window_focused="false" android:state_enabled="false"
- android:drawable="@drawable/textfield_disabled" />
- <item android:state_pressed="true" android:drawable="@drawable/textfield_pressed" />
+ <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/textfield_default" />
+ <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_disabled" />
<item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_selected" />
<item android:state_enabled="true" android:drawable="@drawable/textfield_default" />
<item android:state_focused="true" android:drawable="@drawable/textfield_disabled_selected" />
diff --git a/core/res/res/drawable/edit_text_holo_dark.xml b/core/res/res/drawable/edit_text_holo_dark.xml
index b7d24ff..63ccd1d 100644
--- a/core/res/res/drawable/edit_text_holo_dark.xml
+++ b/core/res/res/drawable/edit_text_holo_dark.xml
@@ -15,14 +15,11 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_window_focused="false" android:state_enabled="true"
- android:drawable="@drawable/textfield_default_holo_dark" />
- <item android:state_window_focused="false" android:state_enabled="false"
- android:drawable="@drawable/textfield_disabled_holo_dark" />
- <item android:state_pressed="true" android:drawable="@drawable/textfield_pressed_holo_dark" />
- <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_selected_holo_dark" />
+ <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/textfield_default_holo_dark" />
+ <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_disabled_holo_dark" />
+ <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_active_holo_dark" />
<item android:state_enabled="true" android:drawable="@drawable/textfield_default_holo_dark" />
- <item android:state_focused="true" android:drawable="@drawable/textfield_disabled_selected_holo_dark" />
+ <item android:state_focused="true" android:drawable="@drawable/textfield_disabled_focused_holo_dark" />
<item android:drawable="@drawable/textfield_disabled_holo_dark" />
</selector>
diff --git a/core/res/res/drawable/edit_text_holo_light.xml b/core/res/res/drawable/edit_text_holo_light.xml
index dae39e3..324acda 100644
--- a/core/res/res/drawable/edit_text_holo_light.xml
+++ b/core/res/res/drawable/edit_text_holo_light.xml
@@ -15,14 +15,11 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_window_focused="false" android:state_enabled="true"
- android:drawable="@drawable/textfield_default_holo_light" />
- <item android:state_window_focused="false" android:state_enabled="false"
- android:drawable="@drawable/textfield_disabled_holo_light" />
- <item android:state_pressed="true" android:drawable="@drawable/textfield_pressed_holo_light" />
- <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_selected_holo_light" />
+ <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/textfield_default_holo_light" />
+ <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_disabled_holo_light" />
+ <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_active_holo_light" />
<item android:state_enabled="true" android:drawable="@drawable/textfield_default_holo_light" />
- <item android:state_focused="true" android:drawable="@drawable/textfield_disabled_selected_holo_light" />
+ <item android:state_focused="true" android:drawable="@drawable/textfield_disabled_focused_holo_light" />
<item android:drawable="@drawable/textfield_disabled_holo_light" />
</selector>
diff --git a/core/res/res/drawable/edit_text_multiline_holo_dark.xml b/core/res/res/drawable/edit_text_multiline_holo_dark.xml
new file mode 100644
index 0000000..67d2748
--- /dev/null
+++ b/core/res/res/drawable/edit_text_multiline_holo_dark.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/textfield_multiline_default_holo_dark" />
+ <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_multiline_disabled_holo_dark" />
+ <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_multiline_active_holo_dark" />
+ <item android:state_enabled="true" android:drawable="@drawable/textfield_multiline_default_holo_dark" />
+ <item android:state_focused="true" android:drawable="@drawable/textfield_multiline_disabled_focused_holo_dark" />
+ <item android:drawable="@drawable/textfield_multiline_disabled_holo_dark" />
+</selector>
diff --git a/core/res/res/drawable/edit_text_multiline_holo_light.xml b/core/res/res/drawable/edit_text_multiline_holo_light.xml
new file mode 100644
index 0000000..08b3ec6
--- /dev/null
+++ b/core/res/res/drawable/edit_text_multiline_holo_light.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/textfield_multiline_default_holo_light" />
+ <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_multiline_disabled_holo_light" />
+ <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_multiline_active_holo_light" />
+ <item android:state_enabled="true" android:drawable="@drawable/textfield_multiline_default_holo_light" />
+ <item android:state_focused="true" android:drawable="@drawable/textfield_multiline_disabled_focused_holo_light" />
+ <item android:drawable="@drawable/textfield_multiline_disabled_holo_light" />
+</selector>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 0b61202..55b3258 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -142,6 +142,8 @@
<attr name="editTextColor" format="reference|color" />
<!-- EditText background drawable. -->
<attr name="editTextBackground" format="reference" />
+ <!-- EditText background drawable for multiline EditText. -->
+ <attr name="editTextMultilineBackground" format="reference" />
<!-- A styled string, specifying the style to be used for showing
inline candidate text when composing with an input method. The
@@ -2508,7 +2510,8 @@
<attr name="textLineHeight" />
<!-- Indicates that a non-editable text can be selected. -->
<attr name="textIsSelectable" />
-
+ <!-- A specific background drawable used by multi-line EditText only. -->
+ <attr name="multilineBackground" format="reference"/>
</declare-styleable>
<!-- An <code>input-extras</code> is a container for extra data to supply to
an input method. Contains
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index b2db9b4..dc67f45 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -422,6 +422,7 @@
<item name="android:focusableInTouchMode">true</item>
<item name="android:clickable">true</item>
<item name="android:background">?android:attr/editTextBackground</item>
+ <item name="android:multilineBackground">?android:attr/editTextMultilineBackground</item>
<item name="android:textAppearance">?android:attr/textAppearanceMediumInverse</item>
<item name="android:textColor">?android:attr/editTextColor</item>
<item name="android:gravity">center_vertical</item>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 88e755f..dd7c8e48 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -72,6 +72,7 @@
<item name="editTextColor">?android:attr/textColorPrimaryInverse</item>
<item name="editTextBackground">@android:drawable/edit_text</item>
+ <item name="editTextMultilineBackground">@android:drawable/edit_text</item>
<item name="candidatesTextStyleSpans">@android:string/candidates_style</item>
@@ -685,6 +686,7 @@
<item name="editTextColor">?android:attr/textColorPrimary</item>
<item name="editTextBackground">@android:drawable/edit_text_holo_dark</item>
+ <item name="editTextMultilineBackground">@android:drawable/edit_text_multiline_holo_dark</item>
<item name="candidatesTextStyleSpans">@android:string/candidates_style</item>
@@ -917,10 +919,11 @@
<item name="textAppearanceSearchResultSubtitle">@android:style/TextAppearance.Holo.Light.SearchResult.Subtitle</item>
<item name="textAppearanceButton">@android:style/TextAppearance.Holo.Light.Widget.Button</item>
-
+
<item name="editTextColor">?android:attr/textColorPrimary</item>
<item name="editTextBackground">@android:drawable/edit_text_holo_light</item>
-
+ <item name="editTextMultilineBackground">@android:drawable/edit_text_multiline_holo_light</item>
+
<item name="candidatesTextStyleSpans">@android:string/candidates_style</item>
<item name="textCheckMark">@android:drawable/indicator_check_mark_light</item>
diff --git a/core/tests/ConnectivityManagerTest/assets/accesspoints.xml b/core/tests/ConnectivityManagerTest/assets/accesspoints.xml
new file mode 100755
index 0000000..2b0e4af
--- /dev/null
+++ b/core/tests/ConnectivityManagerTest/assets/accesspoints.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <accesspoint>
+ <ssid>opennet</ssid>
+ <security>NONE</security>
+ </accesspoint>
+ <accesspoint>
+ <ssid>GoogleGuest</ssid>
+ <security>NONE</security>
+ </accesspoint>
+ <accesspoint>
+ <ssid>securenetdhcp</ssid>
+ <security>PSK</security>
+ <password>androidwifi</password>
+ </accesspoint>
+ <accesspoint>
+ <ssid>botnet</ssid>
+ <security>EAP</security>
+ <eap>PEAP</eap>
+ <phase2>MSCHAPV2</phase2>
+ <identity>donut</identity>
+ <password>android</password>
+ </accesspoint>
+</resources>
+
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/AccessPointParserHelper.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/AccessPointParserHelper.java
new file mode 100644
index 0000000..863fbe6
--- /dev/null
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/AccessPointParserHelper.java
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2010, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.connectivitymanagertest;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiConfiguration.AuthAlgorithm;
+import android.net.wifi.WifiConfiguration.KeyMgmt;
+
+import android.util.Log;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Help class to process configurations of access points saved in an XML file.
+ * The configurations of an access point is included in tag
+ * <accesspoint></accesspoint>. The supported configuration includes: ssid,
+ * security, eap, phase2, identity, password, anonymousidentity, cacert, usercert,
+ * in which each is included in the corresponding tags. All access points have to be
+ * enclosed in tags of <resources></resources>.
+ *
+ * The following is a sample configuration file for an access point using EAP-PEAP with MSCHAP2.
+ * <resources>
+ * <accesspoint>
+ * <ssid>testnet</ssid>
+ * <security>EAP</security>
+ * <eap>PEAP</eap>
+ * <phase2>MSCHAP2</phase2>
+ * <identity>donut</identity</identity>
+ * <password>abcdefgh</password>
+ * </accesspoint>
+ * </resources>
+ */
+public class AccessPointParserHelper {
+ private static final String KEYSTORE_SPACE = "keystore://";
+ private static final String TAG = "AccessPointParserHelper";
+ static final int NONE = 0;
+ static final int WEP = 1;
+ static final int PSK = 2;
+ static final int EAP = 3;
+
+ List<WifiConfiguration> networks = new ArrayList<WifiConfiguration>();
+
+ private int getSecurityType (String security) {
+ if (security.equalsIgnoreCase("NONE")) {
+ return NONE;
+ } else if (security.equalsIgnoreCase("WEP")) {
+ return WEP;
+ } else if (security.equalsIgnoreCase("PSK")) {
+ return PSK;
+ } else if (security.equalsIgnoreCase("EAP")) {
+ return EAP;
+ } else {
+ return -1;
+ }
+ }
+
+ private boolean validateEapValue(String value) {
+ if (value.equalsIgnoreCase("PEAP") ||
+ value.equalsIgnoreCase("TLS") ||
+ value.equalsIgnoreCase("TTLS")) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ DefaultHandler mHandler = new DefaultHandler() {
+
+ boolean ssid = false;
+ boolean security = false;
+ boolean password = false;
+ boolean ip = false;
+ boolean subnetmask = false;
+ boolean gateway = false;
+ boolean dns = false;
+ boolean eap = false;
+ boolean phase2 = false;
+ boolean identity = false;
+ boolean anonymousidentity = false;
+ boolean cacert = false;
+ boolean usercert = false;
+ WifiConfiguration config = null;
+ int securityType = NONE;
+
+ @Override
+ public void startElement(String uri, String localName, String tagName,
+ Attributes attributes) throws SAXException {
+ if (tagName.equalsIgnoreCase("accesspoint")) {
+ config = new WifiConfiguration();
+ }
+ if (tagName.equalsIgnoreCase("ssid")) {
+ ssid = true;
+ }
+ if (tagName.equalsIgnoreCase("security")) {
+ security = true;
+ }
+ if (tagName.equalsIgnoreCase("password")) {
+ password = true;
+ }
+ if (tagName.equalsIgnoreCase("eap")) {
+ eap = true;
+ }
+ if (tagName.equalsIgnoreCase("phase2")) {
+ phase2 = true;
+ }
+ if (tagName.equalsIgnoreCase("identity")) {
+ identity = true;
+ }
+ if (tagName.equalsIgnoreCase("anonymousidentity")) {
+ anonymousidentity = true;
+ }
+ if (tagName.equalsIgnoreCase("cacert")) {
+ cacert = true;
+ }
+ if (tagName.equalsIgnoreCase("usercert")) {
+ usercert = true;
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String tagName) throws SAXException {
+ Log.v(TAG, "endElement: " + tagName);
+ if (tagName.equalsIgnoreCase("accesspoint")) {
+ networks.add(config);
+ }
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) throws SAXException {
+ if (ssid) {
+ config.SSID = new String(ch, start, length);
+ Log.v(TAG, "ssid: " + config.SSID);
+ ssid = false;
+ }
+ if (security) {
+ String securityStr = (new String(ch, start, length)).toUpperCase();
+ Log.v(TAG, "security: " + securityStr);
+ securityType = getSecurityType(securityStr);
+ Log.v(TAG, "securityType = " + securityType);
+ switch (securityType) {
+ case NONE:
+ config.allowedKeyManagement.set(KeyMgmt.NONE);
+ break;
+ case WEP:
+ config.allowedKeyManagement.set(KeyMgmt.NONE);
+ config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
+ config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
+ break;
+ case PSK:
+ config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
+ break;
+ case EAP:
+ config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
+ config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
+ break;
+ default:
+ throw new SAXException();
+ }
+ security = false;
+ }
+ if (password) {
+ String passwordStr = new String(ch, start, length);
+ int len = passwordStr.length();
+ if (len == 0) {
+ throw new SAXException();
+ }
+ Log.v(TAG, "passwordStr:" + passwordStr);
+ if (securityType == WEP) {
+ if ((len == 10 || len == 26 || len == 58) &&
+ passwordStr.matches("[0-9A-Fa-f]*")) {
+ config.wepKeys[0] = passwordStr;
+ } else {
+ config.wepKeys[0] = '"' + passwordStr + '"';
+ }
+ } else if (securityType == PSK) {
+ if (passwordStr.matches("[0-9A-Fa-f]{64}")) {
+ config.preSharedKey = passwordStr;
+ } else {
+ config.preSharedKey = '"' + passwordStr + '"';
+ }
+ } else if (securityType == EAP) {
+ config.password.setValue(passwordStr);
+ } else {
+ throw new SAXException();
+ }
+ password = false;
+ }
+ if (eap) {
+ String eapValue = new String(ch, start, length);
+ if (!validateEapValue(eapValue)) {
+ throw new SAXException();
+ }
+ config.eap.setValue(eapValue);
+ eap = false;
+ }
+ if (phase2) {
+ String phase2Value = new String(ch, start, length);
+ config.phase2.setValue("auth=" + phase2Value);
+ phase2 = false;
+ }
+ if (identity) {
+ String identityValue = new String(ch, start, length);
+ config.identity.setValue(identityValue);
+ identity = false;
+ }
+ if (anonymousidentity) {
+ String anonyId = new String(ch, start, length);
+ config.anonymous_identity.setValue(anonyId);
+ anonymousidentity = false;
+ }
+ if (cacert) {
+ String cacertValue = new String(ch, start, length);
+ // need to install the credentail to "keystore://"
+ config.ca_cert.setValue(KEYSTORE_SPACE);
+ cacert = false;
+ }
+ if (usercert) {
+ String usercertValue = new String(ch, start, length);
+ config.client_cert.setValue(KEYSTORE_SPACE);
+ usercert = false;
+ }
+ }
+ };
+
+ public AccessPointParserHelper() {
+ }
+
+ /**
+ * Process the accesspoint.xml file
+ * @return List of WifiConfiguration
+ * @throws Exception when parsing the XML file
+ */
+ public List<WifiConfiguration> processAccessPoint(InputStream in) throws Exception {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ SAXParser saxParser = factory.newSAXParser();
+ saxParser.parse(in, mHandler);
+ return networks;
+ }
+}
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
index e42b657..7c46e7a 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
@@ -16,8 +16,10 @@
package com.android.connectivitymanagertest;
+import com.android.connectivitymanagertest.R;
import android.app.Activity;
import android.content.Context;
+import android.content.res.Resources;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
@@ -25,19 +27,22 @@
import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;
+
+import java.io.InputStream;
+import java.util.ArrayList;
import java.util.List;
import android.widget.LinearLayout;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
+import android.net.wifi.SupplicantState;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiInfo;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration.KeyMgmt;
-
/**
* An activity registered with connectivity manager broadcast
* provides network connectivity information and
@@ -46,8 +51,11 @@
public class ConnectivityManagerTestActivity extends Activity {
public static final String LOG_TAG = "ConnectivityManagerTestActivity";
- public static final int WAIT_FOR_SCAN_RESULT = 5 * 1000; //5 seconds
+ public static final int WAIT_FOR_SCAN_RESULT = 10 * 1000; //10 seconds
public static final int WIFI_SCAN_TIMEOUT = 20 * 1000;
+ public static final int SHORT_TIMEOUT = 5 * 1000;
+ public static final long LONG_TIMEOUT = 50 * 1000;
+ private static final String ACCESS_POINT_FILE = "accesspoints.xml";
public ConnectivityReceiver mConnectivityReceiver = null;
public WifiReceiver mWifiReceiver = null;
/*
@@ -175,6 +183,7 @@
mIntentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
mIntentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
mIntentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
+ mIntentFilter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
registerReceiver(mWifiReceiver, mIntentFilter);
// Get an instance of ConnectivityManager
@@ -185,10 +194,26 @@
if (mWifiManager.isWifiEnabled()) {
Log.v(LOG_TAG, "Clear Wifi before we start the test.");
- clearWifi();
+ removeConfiguredNetworksAndDisableWifi();
}
}
+ public List<WifiConfiguration> loadNetworkConfigurations() throws Exception {
+ InputStream in = getAssets().open(ACCESS_POINT_FILE);
+ AccessPointParserHelper parseHelper = new AccessPointParserHelper();
+ return parseHelper.processAccessPoint(in);
+ }
+
+ private void printNetConfig(String[] configuration) {
+ for (int i = 0; i < configuration.length; i++) {
+ if (i == 0) {
+ Log.v(LOG_TAG, "SSID: " + configuration[0]);
+ } else {
+ Log.v(LOG_TAG, " " + configuration[i]);
+ }
+ }
+ }
+
// for each network type, initialize network states to UNKNOWN, and no verification flag is set
public void initializeNetworkStates() {
for (int networkType = NUM_NETWORK_TYPES - 1; networkType >=0; networkType--) {
@@ -245,6 +270,68 @@
}
}
+ // Wait for network connectivity state: CONNECTING, CONNECTED, SUSPENDED,
+ // DISCONNECTING, DISCONNECTED, UNKNOWN
+ public boolean waitForNetworkState(int networkType, State expectedState, long timeout) {
+ long startTime = System.currentTimeMillis();
+ while (true) {
+ if ((System.currentTimeMillis() - startTime) > timeout) {
+ if (mCM.getNetworkInfo(networkType).getState() != expectedState) {
+ return false;
+ } else {
+ // the broadcast has been sent out. the state has been changed.
+ Log.v(LOG_TAG, "networktype: " + networkType + " state: " +
+ mCM.getNetworkInfo(networkType));
+ return true;
+ }
+ }
+ Log.v(LOG_TAG, "Wait for the connectivity state for network: " + networkType +
+ " to be " + expectedState.toString());
+ synchronized (connectivityObject) {
+ try {
+ connectivityObject.wait(SHORT_TIMEOUT);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ if ((mNetworkInfo.getType() != networkType) ||
+ (mNetworkInfo.getState() != expectedState)) {
+ Log.v(LOG_TAG, "network state for " + mNetworkInfo.getType() +
+ "is: " + mNetworkInfo.getState());
+ continue;
+ }
+ return true;
+ }
+ }
+ }
+
+ // Wait for Wifi state: WIFI_STATE_DISABLED, WIFI_STATE_DISABLING, WIFI_STATE_ENABLED,
+ // WIFI_STATE_ENALBING, WIFI_STATE_UNKNOWN
+ public boolean waitForWifiState(int expectedState, long timeout) {
+ long startTime = System.currentTimeMillis();
+ while (true) {
+ if ((System.currentTimeMillis() - startTime) > timeout) {
+ if (mWifiState != expectedState) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ Log.v(LOG_TAG, "Wait for wifi state to be: " + expectedState);
+ synchronized (wifiObject) {
+ try {
+ wifiObject.wait(SHORT_TIMEOUT);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ if (mWifiState != expectedState) {
+ Log.v(LOG_TAG, "Wifi state is: " + mWifiNetworkInfo.getState());
+ continue;
+ }
+ return true;
+ }
+ }
+ }
+
// Return true if device is currently connected to mobile network
public boolean isConnectedToMobile() {
return (mNetworkInfo.getType() == ConnectivityManager.TYPE_MOBILE);
@@ -265,6 +352,22 @@
* We don't verify whether the connection is successful or not, leave this to the test
*/
public boolean connectToWifi(String knownSSID) {
+ WifiConfiguration config = new WifiConfiguration();
+ config.SSID = knownSSID;
+ config.allowedKeyManagement.set(KeyMgmt.NONE);
+ return connectToWifiWithConfiguration(config);
+ }
+
+ /**
+ * Connect to Wi-Fi with the given configuration. Note the SSID in the configuration
+ * is pure string, we need to convert it to quoted string.
+ * @param config
+ * @return
+ */
+ public boolean connectToWifiWithConfiguration(WifiConfiguration config) {
+ String ssid = config.SSID;
+ config.SSID = convertToQuotedString(ssid);
+
//If Wifi is not enabled, enable it
if (!mWifiManager.isWifiEnabled()) {
Log.v(LOG_TAG, "Wifi is not enabled, enable it");
@@ -273,6 +376,7 @@
List<ScanResult> netList = mWifiManager.getScanResults();
if (netList == null) {
+ Log.v(LOG_TAG, "scan results are null");
// if no scan results are available, start active scan
mWifiManager.startScanActive();
mScanResultIsAvailable = false;
@@ -299,17 +403,20 @@
}
netList = mWifiManager.getScanResults();
+
for (int i = 0; i < netList.size(); i++) {
ScanResult sr= netList.get(i);
- if (sr.SSID.equals(knownSSID)) {
- Log.v(LOG_TAG, "found " + knownSSID + " in the scan result list");
- WifiConfiguration config = new WifiConfiguration();
- config.SSID = convertToQuotedString(sr.SSID);
- config.allowedKeyManagement.set(KeyMgmt.NONE);
+ if (sr.SSID.equals(ssid)) {
+ Log.v(LOG_TAG, "found " + ssid + " in the scan result list");
int networkId = mWifiManager.addNetwork(config);
// Connect to network by disabling others.
mWifiManager.enableNetwork(networkId, true);
mWifiManager.saveConfiguration();
+ List<WifiConfiguration> wifiNetworks = mWifiManager.getConfiguredNetworks();
+ for (WifiConfiguration netConfig : wifiNetworks) {
+ Log.v(LOG_TAG, netConfig.toString());
+ }
+
mWifiManager.reconnect();
break;
}
@@ -317,14 +424,14 @@
List<WifiConfiguration> netConfList = mWifiManager.getConfiguredNetworks();
if (netConfList.size() <= 0) {
- Log.v(LOG_TAG, knownSSID + " is not available");
+ Log.v(LOG_TAG, ssid + " is not available");
return false;
}
return true;
}
/*
- * Disconnect from the current AP
+ * Disconnect from the current AP and remove configured networks.
*/
public boolean disconnectAP() {
if (mWifiManager.isWifiEnabled()) {
@@ -360,9 +467,9 @@
}
/**
- * Disconnect from the current Wifi and clear the configuration list
+ * Remove configured networks and disable wifi
*/
- public boolean clearWifi() {
+ public boolean removeConfiguredNetworksAndDisableWifi() {
if (!disconnectAP()) {
return false;
}
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestRunner.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestRunner.java
index 592be92..3d4dc3d 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestRunner.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestRunner.java
@@ -21,6 +21,7 @@
import android.test.InstrumentationTestSuite;
import android.util.Log;
import com.android.connectivitymanagertest.functional.ConnectivityManagerMobileTest;
+import com.android.connectivitymanagertest.functional.WifiConnectionTest;
import junit.framework.TestSuite;
@@ -38,6 +39,7 @@
public TestSuite getAllTests() {
TestSuite suite = new InstrumentationTestSuite(this);
suite.addTestSuite(ConnectivityManagerMobileTest.class);
+ suite.addTestSuite(WifiConnectionTest.class);
return suite;
}
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java
index ad8d444..5959cf3 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java
@@ -41,8 +41,6 @@
extends ActivityInstrumentationTestCase2<ConnectivityManagerTestActivity> {
private static final String LOG_TAG = "ConnectivityManagerMobileTest";
private static final String PKG_NAME = "com.android.connectivitymanagertest";
- private static final long STATE_TRANSITION_SHORT_TIMEOUT = 5 * 1000;
- private static final long STATE_TRANSITION_LONG_TIMEOUT = 30 * 1000;
private String TEST_ACCESS_POINT;
private ConnectivityManagerTestActivity cmActivity;
@@ -64,9 +62,14 @@
wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "CMWakeLock");
wl.acquire();
// Each test case will start with cellular connection
- waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.CONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
- verifyCellularConnection();
+ if (!cmActivity.waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.CONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT)) {
+ // Note: When the test fails in setUp(), tearDown is not called. In that case,
+ // the activity is destroyed which blocks the next test at "getActivity()".
+ // tearDown() is called hear to avoid that situation.
+ tearDown();
+ fail("Device is not connected to Mobile, setUp failed");
+ }
}
@Override
@@ -74,86 +77,26 @@
cmActivity.finish();
Log.v(LOG_TAG, "tear down ConnectivityManagerTestActivity");
wl.release();
- cmActivity.clearWifi();
+ cmActivity.removeConfiguredNetworksAndDisableWifi();
super.tearDown();
}
// help function to verify 3G connection
public void verifyCellularConnection() {
- NetworkInfo extraNetInfo = cmActivity.mNetworkInfo;
+ NetworkInfo extraNetInfo = cmActivity.mCM.getActiveNetworkInfo();
assertEquals("network type is not MOBILE", ConnectivityManager.TYPE_MOBILE,
- extraNetInfo.getType());
+ extraNetInfo.getType());
assertTrue("not connected to cellular network", extraNetInfo.isConnected());
assertTrue("no data connection", cmActivity.mState.equals(State.CONNECTED));
}
- // Wait for network connectivity state: CONNECTING, CONNECTED, SUSPENDED,
- // DISCONNECTING, DISCONNECTED, UNKNOWN
- private void waitForNetworkState(int networkType, State expectedState, long timeout) {
- long startTime = System.currentTimeMillis();
- while (true) {
- if ((System.currentTimeMillis() - startTime) > timeout) {
- if (cmActivity.mCM.getNetworkInfo(networkType).getState() != expectedState) {
- assertFalse("Wait for network state timeout", true);
- } else {
- // the broadcast has been sent out. the state has been changed.
- return;
- }
- }
- Log.v(LOG_TAG, "Wait for the connectivity state for network: " + networkType +
- " to be " + expectedState.toString());
- synchronized (cmActivity.connectivityObject) {
- try {
- cmActivity.connectivityObject.wait(STATE_TRANSITION_SHORT_TIMEOUT);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- if ((cmActivity.mNetworkInfo.getType() != networkType) ||
- (cmActivity.mNetworkInfo.getState() != expectedState)) {
- Log.v(LOG_TAG, "network state for " + cmActivity.mNetworkInfo.getType() +
- "is: " + cmActivity.mNetworkInfo.getState());
- continue;
- }
- break;
- }
- }
- }
-
- // Wait for Wifi state: WIFI_STATE_DISABLED, WIFI_STATE_DISABLING, WIFI_STATE_ENABLED,
- // WIFI_STATE_ENALBING, WIFI_STATE_UNKNOWN
- private void waitForWifiState(int expectedState, long timeout) {
- long startTime = System.currentTimeMillis();
- while (true) {
- if ((System.currentTimeMillis() - startTime) > timeout) {
- if (cmActivity.mWifiState != expectedState) {
- assertFalse("Wait for Wifi state timeout", true);
- } else {
- return;
- }
- }
- Log.v(LOG_TAG, "Wait for wifi state to be: " + expectedState);
- synchronized (cmActivity.wifiObject) {
- try {
- cmActivity.wifiObject.wait(5*1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- if (cmActivity.mWifiState != expectedState) {
- Log.v(LOG_TAG, "Wifi state is: " + cmActivity.mWifiNetworkInfo.getState());
- continue;
- }
- break;
- }
- }
- }
-
// Test case 1: Test enabling Wifi without associating with any AP
@LargeTest
public void test3GToWifiNotification() {
// To avoid UNKNOWN state when device boots up
cmActivity.enableWifi();
try {
- Thread.sleep(2 * STATE_TRANSITION_SHORT_TIMEOUT);
+ Thread.sleep(2 * ConnectivityManagerTestActivity.SHORT_TIMEOUT);
} catch (Exception e) {
Log.v(LOG_TAG, "exception: " + e.toString());
}
@@ -170,7 +113,7 @@
// Eanble Wifi
cmActivity.enableWifi();
try {
- Thread.sleep(2 * STATE_TRANSITION_SHORT_TIMEOUT);
+ Thread.sleep(2 * ConnectivityManagerTestActivity.SHORT_TIMEOUT);
} catch (Exception e) {
Log.v(LOG_TAG, "exception: " + e.toString());
}
@@ -208,12 +151,13 @@
assertTrue("failed to connect to " + TEST_ACCESS_POINT,
cmActivity.connectToWifi(TEST_ACCESS_POINT));
- waitForWifiState(WifiManager.WIFI_STATE_ENABLED, STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForWifiState(WifiManager.WIFI_STATE_ENABLED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
Log.v(LOG_TAG, "wifi state is enabled");
- waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
- waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.DISCONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.DISCONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
// validate states
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_WIFI)) {
@@ -237,12 +181,13 @@
// Connect to TEST_ACCESS_POINT
assertTrue("failed to connect to " + TEST_ACCESS_POINT,
cmActivity.connectToWifi(TEST_ACCESS_POINT));
- waitForWifiState(WifiManager.WIFI_STATE_ENABLED, STATE_TRANSITION_LONG_TIMEOUT);
- waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForWifiState(WifiManager.WIFI_STATE_ENABLED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
try {
- Thread.sleep(STATE_TRANSITION_SHORT_TIMEOUT);
+ Thread.sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
} catch (Exception e) {
Log.v(LOG_TAG, "exception: " + e.toString());
}
@@ -255,11 +200,12 @@
}
// Wait for the Wifi state to be DISABLED
- waitForWifiState(WifiManager.WIFI_STATE_DISABLED, STATE_TRANSITION_LONG_TIMEOUT);
- waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.DISCONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
- waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.CONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForWifiState(WifiManager.WIFI_STATE_DISABLED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.DISCONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.CONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
//Prepare for connectivity state verification
NetworkInfo networkInfo = cmActivity.mCM.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
@@ -275,10 +221,10 @@
cmActivity.enableWifi();
// Wait for Wifi to be connected and mobile to be disconnected
- waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
- waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.DISCONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.DISCONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
// validate wifi states
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_WIFI)) {
@@ -298,12 +244,12 @@
assertTrue("failed to connect to " + TEST_ACCESS_POINT,
cmActivity.connectToWifi(TEST_ACCESS_POINT));
- waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
// Wait for a few seconds to avoid the state that both Mobile and Wifi is connected
try {
- Thread.sleep(STATE_TRANSITION_SHORT_TIMEOUT);
+ Thread.sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
} catch (Exception e) {
Log.v(LOG_TAG, "exception: " + e.toString());
}
@@ -318,12 +264,12 @@
NetworkState.TO_DISCONNECTION, State.DISCONNECTED);
// clear Wifi
- cmActivity.clearWifi();
+ cmActivity.removeConfiguredNetworksAndDisableWifi();
- waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.DISCONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
- waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.CONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.DISCONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.CONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
// validate states
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_WIFI)) {
@@ -357,7 +303,7 @@
// Enable airplane mode
cmActivity.setAirplaneMode(getInstrumentation().getContext(), true);
try {
- Thread.sleep(STATE_TRANSITION_SHORT_TIMEOUT);
+ Thread.sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
} catch (Exception e) {
Log.v(LOG_TAG, "exception: " + e.toString());
}
@@ -389,8 +335,8 @@
// disable airplane mode
cmActivity.setAirplaneMode(getInstrumentation().getContext(), false);
- waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.CONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.CONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
// Validate the state transition
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_MOBILE)) {
@@ -414,8 +360,8 @@
// Eanble airplane mode
cmActivity.setAirplaneMode(getInstrumentation().getContext(), true);
- waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.DISCONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.DISCONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
NetworkInfo networkInfo = cmActivity.mCM.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
cmActivity.setStateTransitionCriteria(ConnectivityManager.TYPE_MOBILE,
@@ -429,8 +375,8 @@
// Connect to Wifi
assertTrue("failed to connect to " + TEST_ACCESS_POINT,
cmActivity.connectToWifi(TEST_ACCESS_POINT));
- waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
// validate state and broadcast
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_WIFI)) {
@@ -457,11 +403,11 @@
assertTrue("failed to connect to " + TEST_ACCESS_POINT,
cmActivity.connectToWifi(TEST_ACCESS_POINT));
- waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
try {
- Thread.sleep(STATE_TRANSITION_SHORT_TIMEOUT);
+ Thread.sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
} catch (Exception e) {
Log.v(LOG_TAG, "exception: " + e.toString());
}
@@ -469,11 +415,11 @@
// Enable airplane mode without clearing Wifi
cmActivity.setAirplaneMode(getInstrumentation().getContext(), true);
- waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.DISCONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.DISCONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
try {
- Thread.sleep(STATE_TRANSITION_SHORT_TIMEOUT);
+ Thread.sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
} catch (Exception e) {
Log.v(LOG_TAG, "exception: " + e.toString());
}
@@ -487,10 +433,10 @@
// Disable airplane mode
cmActivity.setAirplaneMode(getInstrumentation().getContext(), false);
- waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
- waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.DISCONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.DISCONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
// validate the state transition
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_WIFI)) {
@@ -508,14 +454,15 @@
//Connect to TEST_ACCESS_POINT
assertTrue("failed to connect to " + TEST_ACCESS_POINT,
cmActivity.connectToWifi(TEST_ACCESS_POINT));
- waitForWifiState(WifiManager.WIFI_STATE_ENABLED, STATE_TRANSITION_LONG_TIMEOUT);
- waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForWifiState(WifiManager.WIFI_STATE_ENABLED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
assertNotNull("Not associated with any AP",
cmActivity.mWifiManager.getConnectionInfo().getBSSID());
try {
- Thread.sleep(STATE_TRANSITION_SHORT_TIMEOUT);
+ Thread.sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
} catch (Exception e) {
Log.v(LOG_TAG, "exception: " + e.toString());
}
@@ -527,13 +474,14 @@
}
// Verify the connectivity state for Wifi is DISCONNECTED
- waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.DISCONNECTED,
- STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.DISCONNECTED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
if (!cmActivity.disableWifi()) {
Log.v(LOG_TAG, "disable Wifi failed");
return;
}
- waitForWifiState(WifiManager.WIFI_STATE_DISABLED, STATE_TRANSITION_LONG_TIMEOUT);
+ assertTrue(cmActivity.waitForWifiState(WifiManager.WIFI_STATE_DISABLED,
+ ConnectivityManagerTestActivity.LONG_TIMEOUT));
}
}
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java
new file mode 100644
index 0000000..69eb5db
--- /dev/null
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2010, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.connectivitymanagertest.functional;
+
+import com.android.connectivitymanagertest.ConnectivityManagerTestActivity;
+import com.android.connectivitymanagertest.NetworkState;
+
+import android.R;
+import android.app.Activity;
+import android.content.Intent;
+import android.content.Context;
+import android.content.res.Resources;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.NetworkInfo.State;
+
+import android.test.suitebuilder.annotation.LargeTest;
+import android.test.ActivityInstrumentationTestCase2;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Test Wi-Fi connection with different configuration
+ * To run this tests:
+ * adb shell am instrument -e class
+ * com.android.connectivitymanagertest.functional.WifiConnectionTest
+ * -w com.android.connectivitymanagertest/.ConnectivityManagerTestRunner
+ */
+public class WifiConnectionTest
+ extends ActivityInstrumentationTestCase2<ConnectivityManagerTestActivity> {
+ private static final String TAG = "WifiConnectionTest";
+ private static final boolean DEBUG = true;
+ private static final String PKG_NAME = "com.android.connectivitymanagertests";
+ private List<WifiConfiguration> networks = new ArrayList<WifiConfiguration>();
+ private ConnectivityManagerTestActivity mAct;
+
+ public WifiConnectionTest() {
+ super(PKG_NAME, ConnectivityManagerTestActivity.class);
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ mAct = getActivity();
+ networks = mAct.loadNetworkConfigurations();
+ if (DEBUG) {
+ printNetworkConfigurations();
+ }
+
+ // enable Wifi and verify wpa_supplicant is started
+ assertTrue("enable Wifi failed", mAct.enableWifi());
+ try {
+ Thread.sleep( 2 * ConnectivityManagerTestActivity.SHORT_TIMEOUT);
+ } catch (Exception e) {
+ fail("interrupted while waiting for WPA_SUPPLICANT to start");
+ }
+ WifiInfo mConnection = mAct.mWifiManager.getConnectionInfo();
+ assertNotNull(mConnection);
+ assertTrue("wpa_supplicant is not started ", mAct.mWifiManager.pingSupplicant());
+ }
+
+ private void printNetworkConfigurations() {
+ Log.v(TAG, "==== print network configurations parsed from XML file ====");
+ Log.v(TAG, "number of access points: " + networks.size());
+ for (WifiConfiguration config : networks) {
+ Log.v(TAG, config.toString());
+ }
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ mAct.removeConfiguredNetworksAndDisableWifi();
+ super.tearDown();
+ }
+
+ /**
+ * Connect to the provided Wi-Fi network
+ * @param config is the network configuration
+ * @return true if the connection is successful.
+ */
+ private void connectToWifi(WifiConfiguration config) {
+ // step 1: connect to the test access point
+ assertTrue("failed to connect to " + config.SSID,
+ mAct.connectToWifiWithConfiguration(config));
+
+ // step 2: verify Wifi state and network state;
+ assertTrue(mAct.waitForWifiState(WifiManager.WIFI_STATE_ENABLED,
+ ConnectivityManagerTestActivity.SHORT_TIMEOUT));
+ assertTrue(mAct.waitForNetworkState(ConnectivityManager.TYPE_WIFI,
+ State.CONNECTED, ConnectivityManagerTestActivity.LONG_TIMEOUT));
+
+ // step 3: verify the current connected network is the given SSID
+ if (DEBUG) {
+ Log.v(TAG, "config.SSID = " + config.SSID);
+ Log.v(TAG, "mAct.mWifiManager.getConnectionInfo.getSSID()" +
+ mAct.mWifiManager.getConnectionInfo().getSSID());
+ }
+ assertTrue(config.SSID.contains(mAct.mWifiManager.getConnectionInfo().getSSID()));
+
+ // Maintain the connection for 50 seconds before switching
+ try {
+ Thread.sleep(50*1000);
+ } catch (Exception e) {
+ fail("interrupted while waiting for WPA_SUPPLICANT to start");
+ }
+ }
+
+ @LargeTest
+ public void testWifiConnections() {
+ for (int i = 0; i < networks.size(); i++) {
+ connectToWifi(networks.get(i));
+ mAct.removeConfiguredNetworksAndDisableWifi();
+ }
+ }
+}
diff --git a/core/tests/coretests/src/android/bluetooth/BluetoothStressTest.java b/core/tests/coretests/src/android/bluetooth/BluetoothStressTest.java
index f019599..43cf06a 100644
--- a/core/tests/coretests/src/android/bluetooth/BluetoothStressTest.java
+++ b/core/tests/coretests/src/android/bluetooth/BluetoothStressTest.java
@@ -110,6 +110,21 @@
mTestUtils.disable(adapter);
}
+ public void testAcceptPair() {
+ int iterations = BluetoothTestRunner.sPairIterations;
+ BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
+ BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sPairAddress);
+ mTestUtils.enable(adapter);
+
+ for (int i = 0; i < iterations; i++) {
+ mTestUtils.writeOutput("acceptPair iteration " + (i + 1) + " of " + iterations);
+ mTestUtils.acceptPair(adapter, device, BluetoothTestRunner.sPairPasskey,
+ BluetoothTestRunner.sPairPin);
+ mTestUtils.unpair(adapter, device);
+ }
+ mTestUtils.disable(adapter);
+ }
+
public void testConnectA2dp() {
int iterations = BluetoothTestRunner.sConnectA2dpIterations;
if (iterations == 0) {
diff --git a/core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java b/core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java
index 328891c..29dee34 100644
--- a/core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java
+++ b/core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java
@@ -137,7 +137,6 @@
@Override
public void onReceive(Context context, Intent intent) {
- Log.i("BT", intent.toString());
if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(intent.getAction())) {
setFiredFlag(DISCOVERY_STARTED_FLAG);
} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(intent.getAction())) {
@@ -203,7 +202,7 @@
if (BluetoothDevice.ACTION_PAIRING_REQUEST.equals(intent.getAction())) {
int varient = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, -1);
assertNotSame(-1, varient);
- switch(varient) {
+ switch (varient) {
case BluetoothDevice.PAIRING_VARIANT_PIN:
mDevice.setPin(mPin);
break;
@@ -252,7 +251,7 @@
mDevice = device;
mProfile = profile;
- switch(mProfile) {
+ switch (mProfile) {
case BluetoothProfile.A2DP:
mConnectionAction = BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED;
break;
@@ -384,11 +383,14 @@
mask = 0; // Don't check for received intents since we might have missed them.
break;
case BluetoothAdapter.STATE_OFF:
- case BluetoothAdapter.STATE_TURNING_OFF:
assertFalse(adapter.isEnabled());
start = System.currentTimeMillis();
assertTrue(adapter.enable());
break;
+ case BluetoothAdapter.STATE_TURNING_OFF:
+ start = System.currentTimeMillis();
+ assertTrue(adapter.enable());
+ break;
default:
removeReceiver(receiver);
fail(String.format("enable() invalid state: state=%d", state));
@@ -410,7 +412,6 @@
return;
}
} else {
- assertFalse(adapter.isEnabled());
assertEquals(BluetoothAdapter.STATE_TURNING_ON, state);
}
sleep(POLL_TIME);
@@ -437,7 +438,6 @@
case BluetoothAdapter.STATE_TURNING_ON:
assertFalse(adapter.isEnabled());
start = System.currentTimeMillis();
- assertTrue(adapter.disable());
break;
case BluetoothAdapter.STATE_ON:
assertTrue(adapter.isEnabled());
@@ -470,7 +470,6 @@
return;
}
} else {
- assertFalse(adapter.isEnabled());
assertEquals(BluetoothAdapter.STATE_TURNING_OFF, state);
}
sleep(POLL_TIME);
@@ -629,11 +628,22 @@
}
public void pair(BluetoothAdapter adapter, BluetoothDevice device, int passkey, byte[] pin) {
+ pairOrAcceptPair(adapter, device, passkey, pin, true);
+ }
+
+ public void acceptPair(BluetoothAdapter adapter, BluetoothDevice device, int passkey,
+ byte[] pin) {
+ pairOrAcceptPair(adapter, device, passkey, pin, false);
+ }
+
+ private void pairOrAcceptPair(BluetoothAdapter adapter, BluetoothDevice device, int passkey,
+ byte[] pin, boolean pair) {
int mask = PairReceiver.STATE_BONDING_FLAG | PairReceiver.STATE_BONDED_FLAG;
long start = -1;
+ String methodName = pair ? "pair()" : "acceptPair()";
if (!adapter.isEnabled()) {
- fail("pair() bluetooth not enabled");
+ fail(methodName + " bluetooth not enabled");
}
PairReceiver receiver = getPairReceiver(device, passkey, pin, mask);
@@ -643,7 +653,9 @@
case BluetoothDevice.BOND_NONE:
assertFalse(adapter.getBondedDevices().contains(device));
start = System.currentTimeMillis();
- assertTrue(device.createBond());
+ if (pair) {
+ assertTrue(device.createBond());
+ }
break;
case BluetoothDevice.BOND_BONDING:
mask = 0; // Don't check for received intents since we might have missed them.
@@ -653,7 +665,8 @@
return;
default:
removeReceiver(receiver);
- fail(String.format("pair() invalid state: device=%s, state=%d", device, state));
+ fail(String.format("%s invalid state: device=%s, state=%d", methodName, device,
+ state));
}
long s = System.currentTimeMillis();
@@ -664,10 +677,10 @@
if ((receiver.getFiredFlags() & mask) == mask) {
long finish = receiver.getCompletedTime();
if (start != -1 && finish != -1) {
- writeOutput(String.format("pair() completed in %d ms: device=%s",
+ writeOutput(String.format("%s completed in %d ms: device=%s", methodName,
(finish - start), device));
} else {
- writeOutput(String.format("pair() completed: device=%s", device));
+ writeOutput(String.format("%s completed: device=%s", methodName, device));
}
removeReceiver(receiver);
return;
@@ -678,9 +691,9 @@
int firedFlags = receiver.getFiredFlags();
removeReceiver(receiver);
- fail(String.format("pair() timeout: device=%s, state=%d (expected %d), "
- + "flags=0x%x (expected 0x%x)", device, state, BluetoothDevice.BOND_BONDED,
- firedFlags, mask));
+ fail(String.format("%s timeout: device=%s, state=%d (expected %d), "
+ + "flags=0x%x (expected 0x%x)", methodName, device, state,
+ BluetoothDevice.BOND_BONDED, firedFlags, mask));
}
public void unpair(BluetoothAdapter adapter, BluetoothDevice device) {
@@ -788,7 +801,7 @@
long finish = receiver.getCompletedTime();
if (start != -1 && finish != -1) {
writeOutput(String.format("connectProfile() completed in %d ms: "
- +"device=%s, profile=%d", (finish - start), device, profile));
+ + "device=%s, profile=%d", (finish - start), device, profile));
} else {
writeOutput(String.format("connectProfile() completed: device=%s, "
+ "profile=%d", device, profile));
@@ -857,7 +870,7 @@
long finish = receiver.getCompletedTime();
if (start != -1 && finish != -1) {
writeOutput(String.format("disconnectProfile() completed in %d ms: "
- +"device=%s, profile=%d", (finish - start), device, profile));
+ + "device=%s, profile=%d", (finish - start), device, profile));
} else {
writeOutput(String.format("disconnectProfile() completed: device=%s, "
+ "profile=%d", device, profile));
@@ -934,14 +947,12 @@
long s = System.currentTimeMillis();
switch (profile) {
case BluetoothProfile.A2DP:
- while (mA2dp != null
- && System.currentTimeMillis() - s < CONNECT_PROXY_TIMEOUT) {
+ while (mA2dp != null && System.currentTimeMillis() - s < CONNECT_PROXY_TIMEOUT) {
sleep(POLL_TIME);
}
return mA2dp;
case BluetoothProfile.HEADSET:
- while (mHeadset != null
- && System.currentTimeMillis() - s < CONNECT_PROXY_TIMEOUT) {
+ while (mHeadset != null && System.currentTimeMillis() - s < CONNECT_PROXY_TIMEOUT) {
sleep(POLL_TIME);
}
return mHeadset;
diff --git a/core/tests/coretests/src/android/os/AsyncChannelTest.java b/core/tests/coretests/src/com/android/internal/util/AsyncChannelTest.java
similarity index 83%
rename from core/tests/coretests/src/android/os/AsyncChannelTest.java
rename to core/tests/coretests/src/com/android/internal/util/AsyncChannelTest.java
index 43c8290..7088650 100644
--- a/core/tests/coretests/src/android/os/AsyncChannelTest.java
+++ b/core/tests/coretests/src/com/android/internal/util/AsyncChannelTest.java
@@ -14,8 +14,9 @@
* limitations under the License.
*/
-package android.os;
+package com.android.internal.util;
+import android.os.Debug;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
@@ -26,13 +27,17 @@
*/
public class AsyncChannelTest extends TestCase {
private static final boolean DBG = true;
- private static final boolean WAIT_FOR_DEBUGGER = true;
+ private static final boolean WAIT_FOR_DEBUGGER = false;
private static final String TAG = "AsyncChannelTest";
@SmallTest
public void test1() throws Exception {
+ if (DBG) log("test1");
if (WAIT_FOR_DEBUGGER) Debug.waitForDebugger();
- Log.d(TAG, "test1");
assertTrue(1 == 1);
}
+
+ protected void log(String s) {
+ Log.d(TAG, s);
+ }
}
diff --git a/core/tests/coretests/src/android/os/HierarchicalStateMachineTest.java b/core/tests/coretests/src/com/android/internal/util/HierarchicalStateMachineTest.java
similarity index 99%
rename from core/tests/coretests/src/android/os/HierarchicalStateMachineTest.java
rename to core/tests/coretests/src/com/android/internal/util/HierarchicalStateMachineTest.java
index 6820987..36666c4 100644
--- a/core/tests/coretests/src/android/os/HierarchicalStateMachineTest.java
+++ b/core/tests/coretests/src/com/android/internal/util/HierarchicalStateMachineTest.java
@@ -14,7 +14,13 @@
* limitations under the License.
*/
-package android.os;
+package com.android.internal.util;
+
+import android.os.Debug;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.os.Message;
+import android.os.SystemClock;
import com.android.internal.util.HierarchicalState;
import com.android.internal.util.HierarchicalStateMachine;
@@ -28,8 +34,6 @@
/**
* Test for HierarchicalStateMachine.
- *
- * @author wink@google.com (Wink Saville)
*/
public class HierarchicalStateMachineTest extends TestCase {
private static final int TEST_CMD_1 = 1;
@@ -40,7 +44,7 @@
private static final int TEST_CMD_6 = 6;
private static final boolean DBG = true;
- private static final boolean WAIT_FOR_DEBUGGER = true;
+ private static final boolean WAIT_FOR_DEBUGGER = false;
private static final String TAG = "HierarchicalStateMachineTest";
/**
@@ -92,7 +96,7 @@
@SmallTest
public void testStateMachineQuitTest() throws Exception {
- //if (WAIT_FOR_DEBUGGER) Debug.waitForDebugger();
+ if (WAIT_FOR_DEBUGGER) Debug.waitForDebugger();
StateMachineQuitTest smQuitTest = new StateMachineQuitTest("smQuitTest");
smQuitTest.start();
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index 9dc291b..0de53f2 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -352,7 +352,7 @@
if (bc == Bitmap.Config.RGB_565) {
return Element.RGB_565(rs);
}
- throw new RSInvalidStateException("Bad bitmap type.");
+ throw new RSInvalidStateException("Bad bitmap type: " + bc);
}
static private Type typeFromBitmap(RenderScript rs, Bitmap b) {
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index df03e13..20949a4 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -389,6 +389,10 @@
synchronized void nScriptSetVarV(int id, int slot, byte[] val) {
rsnScriptSetVarV(mContext, id, slot, val);
}
+ native void rsnScriptSetVarObj(int con, int id, int slot, int val);
+ synchronized void nScriptSetVarObj(int id, int slot, int val) {
+ rsnScriptSetVarObj(mContext, id, slot, val);
+ }
native void rsnScriptCBegin(int con);
synchronized void nScriptCBegin() {
diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java
index 7d7dd6d..ea616c6 100644
--- a/graphics/java/android/renderscript/Script.java
+++ b/graphics/java/android/renderscript/Script.java
@@ -88,6 +88,10 @@
mRS.nScriptSetVarI(getID(), index, v ? 1 : 0);
}
+ public void setVar(int index, BaseObj o) {
+ mRS.nScriptSetVarObj(getID(), index, (o == null) ? 0 : o.getID());
+ }
+
public void setVar(int index, FieldPacker v) {
mRS.nScriptSetVarV(getID(), index, v.getData());
}
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index dd84848..8888459 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -829,6 +829,13 @@
}
static void
+nScriptSetVarObj(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jint val)
+{
+ LOG_API("nScriptSetVarObj, con(%p), s(%p), slot(%i), val(%i)", con, (void *)script, slot, val);
+ rsScriptSetVarObj(con, (RsScript)script, slot, (RsObjectBase)val);
+}
+
+static void
nScriptSetVarJ(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jlong val)
{
LOG_API("nScriptSetVarJ, con(%p), s(%p), slot(%i), val(%lli)", con, (void *)script, slot, val);
@@ -1335,6 +1342,7 @@
{"rsnScriptSetVarF", "(IIIF)V", (void*)nScriptSetVarF },
{"rsnScriptSetVarD", "(IIID)V", (void*)nScriptSetVarD },
{"rsnScriptSetVarV", "(III[B)V", (void*)nScriptSetVarV },
+{"rsnScriptSetVarObj", "(IIII)V", (void*)nScriptSetVarObj },
{"rsnScriptCBegin", "(I)V", (void*)nScriptCBegin },
{"rsnScriptCSetScript", "(I[BII)V", (void*)nScriptCSetScript },
diff --git a/include/media/IMediaPlayer.h b/include/media/IMediaPlayer.h
index 3d77278..bba7ed7 100644
--- a/include/media/IMediaPlayer.h
+++ b/include/media/IMediaPlayer.h
@@ -34,7 +34,6 @@
virtual void disconnect() = 0;
- virtual status_t setVideoISurface(const sp<ISurface>& surface) = 0;
virtual status_t setVideoSurface(const sp<Surface>& surface) = 0;
virtual status_t prepareAsync() = 0;
virtual status_t start() = 0;
diff --git a/include/media/IOMX.h b/include/media/IOMX.h
index fa775e7..cb36bbb 100644
--- a/include/media/IOMX.h
+++ b/include/media/IOMX.h
@@ -120,30 +120,6 @@
node_id node,
const char *parameter_name,
OMX_INDEXTYPE *index) = 0;
-
- virtual sp<IOMXRenderer> createRenderer(
- const sp<ISurface> &surface,
- const char *componentName,
- OMX_COLOR_FORMATTYPE colorFormat,
- size_t encodedWidth, size_t encodedHeight,
- size_t displayWidth, size_t displayHeight) = 0;
-
- // Note: These methods are _not_ virtual, it exists as a wrapper around
- // the virtual "createRenderer" method above facilitating extraction
- // of the ISurface from a regular Surface or a java Surface object.
- sp<IOMXRenderer> createRenderer(
- const sp<Surface> &surface,
- const char *componentName,
- OMX_COLOR_FORMATTYPE colorFormat,
- size_t encodedWidth, size_t encodedHeight,
- size_t displayWidth, size_t displayHeight);
-
- sp<IOMXRenderer> createRendererFromJavaSurface(
- JNIEnv *env, jobject javaSurface,
- const char *componentName,
- OMX_COLOR_FORMATTYPE colorFormat,
- size_t encodedWidth, size_t encodedHeight,
- size_t displayWidth, size_t displayHeight);
};
struct omx_message {
@@ -190,13 +166,6 @@
virtual void onMessage(const omx_message &msg) = 0;
};
-class IOMXRenderer : public IInterface {
-public:
- DECLARE_META_INTERFACE(OMXRenderer);
-
- virtual void render(IOMX::buffer_id buffer) = 0;
-};
-
////////////////////////////////////////////////////////////////////////////////
class BnOMX : public BnInterface<IOMX> {
@@ -213,13 +182,6 @@
uint32_t flags = 0);
};
-class BnOMXRenderer : public BnInterface<IOMXRenderer> {
-public:
- virtual status_t onTransact(
- uint32_t code, const Parcel &data, Parcel *reply,
- uint32_t flags = 0);
-};
-
} // namespace android
#endif // ANDROID_IOMX_H_
diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
index 2d55a55..672931e 100644
--- a/include/media/MediaPlayerInterface.h
+++ b/include/media/MediaPlayerInterface.h
@@ -106,7 +106,6 @@
const KeyedVector<String8, String8> *headers = NULL) = 0;
virtual status_t setDataSource(int fd, int64_t offset, int64_t length) = 0;
- virtual status_t setVideoISurface(const sp<ISurface>& surface) = 0;
virtual status_t setVideoSurface(const sp<Surface>& surface) = 0;
virtual status_t prepare() = 0;
virtual status_t prepareAsync() = 0;
diff --git a/include/media/stagefright/HardwareAPI.h b/include/media/stagefright/HardwareAPI.h
index 4fd281b..17908b4 100644
--- a/include/media/stagefright/HardwareAPI.h
+++ b/include/media/stagefright/HardwareAPI.h
@@ -19,8 +19,6 @@
#define HARDWARE_API_H_
#include <media/stagefright/OMXPluginBase.h>
-#include <media/stagefright/VideoRenderer.h>
-#include <surfaceflinger/ISurface.h>
#include <ui/android_native_buffer.h>
#include <utils/RefBase.h>
@@ -91,13 +89,6 @@
} // namespace android
-extern android::VideoRenderer *createRenderer(
- const android::sp<android::ISurface> &surface,
- const char *componentName,
- OMX_COLOR_FORMATTYPE colorFormat,
- size_t displayWidth, size_t displayHeight,
- size_t decodedWidth, size_t decodedHeight);
-
extern android::OMXPluginBase *createOMXPlugin();
#endif // HARDWARE_API_H_
diff --git a/include/media/stagefright/VideoRenderer.h b/include/media/stagefright/VideoRenderer.h
deleted file mode 100644
index f80b277..0000000
--- a/include/media/stagefright/VideoRenderer.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef VIDEO_RENDERER_H_
-
-#define VIDEO_RENDERER_H_
-
-#include <sys/types.h>
-
-namespace android {
-
-class VideoRenderer {
-public:
- virtual ~VideoRenderer() {}
-
- virtual void render(
- const void *data, size_t size, void *platformPrivate) = 0;
-
-protected:
- VideoRenderer() {}
-
- VideoRenderer(const VideoRenderer &);
- VideoRenderer &operator=(const VideoRenderer &);
-};
-
-} // namespace android
-
-#endif // VIDEO_RENDERER_H_
diff --git a/libs/camera/Camera.cpp b/libs/camera/Camera.cpp
index 148e864..450971d 100644
--- a/libs/camera/Camera.cpp
+++ b/libs/camera/Camera.cpp
@@ -372,6 +372,9 @@
}
if (listener != NULL) {
listener->postDataTimestamp(timestamp, msgType, dataPtr);
+ } else {
+ LOGW("No listener was set. Drop a recording frame.");
+ releaseRecordingFrame(dataPtr);
}
}
diff --git a/libs/rs/java/ImageProcessing/src/com/android/rs/image/threshold.rs b/libs/rs/java/ImageProcessing/src/com/android/rs/image/threshold.rs
index 698540b..3e81115 100644
--- a/libs/rs/java/ImageProcessing/src/com/android/rs/image/threshold.rs
+++ b/libs/rs/java/ImageProcessing/src/com/android/rs/image/threshold.rs
@@ -64,7 +64,7 @@
static void copyInput() {
- rs_allocation ain = {0};
+ rs_allocation ain;
rsSetObject(&ain,rsGetAllocation(InPixel));
uint32_t dimx = rsAllocationGetDimX(ain);
uint32_t dimy = rsAllocationGetDimY(ain);
@@ -73,7 +73,6 @@
ScratchPixel1[x + y * dimx] = convert_float4(InPixel[x + y * dimx]);
}
}
- rsClearObject(&ain);
}
void filter() {
diff --git a/libs/rs/java/Samples/src/com/android/samples/rslist.rs b/libs/rs/java/Samples/src/com/android/samples/rslist.rs
index f29276a..0baccb8 100644
--- a/libs/rs/java/Samples/src/com/android/samples/rslist.rs
+++ b/libs/rs/java/Samples/src/com/android/samples/rslist.rs
@@ -46,7 +46,7 @@
rsgBindFont(gItalic);
color(0.2, 0.2, 0.2, 0);
- rs_allocation listAlloc = {0};
+ rs_allocation listAlloc;
rsSetObject(&listAlloc, rsGetAllocation(gList));
int allocSize = rsAllocationGetDimX(listAlloc);
@@ -67,7 +67,6 @@
}
currentYPos += itemHeight;
}
- rsClearObject(&listAlloc);
return 10;
}
diff --git a/libs/rs/java/tests/src/com/android/rs/test/rslist.rs b/libs/rs/java/tests/src/com/android/rs/test/rslist.rs
index d1fde57..f354a72 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/rslist.rs
+++ b/libs/rs/java/tests/src/com/android/rs/test/rslist.rs
@@ -47,7 +47,7 @@
rsgBindFont(gFont);
color(0.2, 0.2, 0.2, 0);
- rs_allocation listAlloc = {0};
+ rs_allocation listAlloc;
rsSetObject(&listAlloc, rsGetAllocation(gList));
int allocSize = rsAllocationGetDimX(listAlloc);
@@ -103,7 +103,6 @@
}
currentYPos += itemHeight;
}
- rsClearObject(&listAlloc);
return 10;
}
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index ac9abe0..76db14f 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -280,6 +280,12 @@
param int value
}
+ScriptSetVarObj {
+ param RsScript s
+ param uint32_t slot
+ param RsObjectBase value
+ }
+
ScriptSetVarJ {
param RsScript s
param uint32_t slot
diff --git a/libs/rs/rsScript.cpp b/libs/rs/rsScript.cpp
index 4ffdbfd..efdc626 100644
--- a/libs/rs/rsScript.cpp
+++ b/libs/rs/rsScript.cpp
@@ -67,6 +67,22 @@
}
}
+void Script::setVarObj(uint32_t slot, ObjectBase *val) {
+ ObjectBase **destPtr = ((ObjectBase ***)mEnviroment.mFieldAddress)[slot];
+
+ if (destPtr) {
+ if (val != NULL) {
+ val->incSysRef();
+ }
+ if (*destPtr) {
+ (*destPtr)->decSysRef();
+ }
+ *destPtr = val;
+ } else {
+ LOGV("Calling setVarObj on slot = %i which is null. This is dangerous because the script will not hold a ref count on the object.", slot);
+ }
+}
+
namespace android {
namespace renderscript {
@@ -103,6 +119,12 @@
s->setVar(slot, &value, sizeof(value));
}
+void rsi_ScriptSetVarObj(Context *rsc, RsScript vs, uint32_t slot, RsObjectBase value) {
+ Script *s = static_cast<Script *>(vs);
+ ObjectBase *o = static_cast<ObjectBase *>(value);
+ s->setVarObj(slot, o);
+}
+
void rsi_ScriptSetVarJ(Context *rsc, RsScript vs, uint32_t slot, long long value) {
Script *s = static_cast<Script *>(vs);
s->setVar(slot, &value, sizeof(value));
diff --git a/libs/rs/rsScript.h b/libs/rs/rsScript.h
index 9b6d8a9..bad095b 100644
--- a/libs/rs/rsScript.h
+++ b/libs/rs/rsScript.h
@@ -61,6 +61,7 @@
void initSlots();
void setSlot(uint32_t slot, Allocation *a);
void setVar(uint32_t slot, const void *val, uint32_t len);
+ void setVarObj(uint32_t slot, ObjectBase *val);
virtual void runForEach(Context *rsc,
const Allocation * ain,
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index 033f316..072cc168 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -65,12 +65,11 @@
void **dest = ((void ***)mEnviroment.mFieldAddress)[ct];
if (rsc->props.mLogScripts) {
- LOGV("%p ScriptC::setupScript slot=%i dst=%p src=%p type=%p", rsc, ct, dest, ptr, mSlots[ct]->getType());
-
- //const uint32_t *p32 = (const uint32_t *)ptr;
- //for (uint32_t ct2=0; ct2 < mSlots[ct]->getType()->getDimX(); ct2++) {
- //LOGE(" %i = 0x%08x ", ct2, p32[ct2]);
- //}
+ if (mSlots[ct].get() != NULL) {
+ LOGV("%p ScriptC::setupScript slot=%i dst=%p src=%p type=%p", rsc, ct, dest, ptr, mSlots[ct]->getType());
+ } else {
+ LOGV("%p ScriptC::setupScript slot=%i dst=%p src=%p type=null", rsc, ct, dest, ptr);
+ }
}
if (dest) {
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index 7f4960f..69b872b 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -434,24 +434,23 @@
}
}
- mMimeType = null;
+ mMimeType = mimeType;
mFileType = 0;
mFileSize = fileSize;
// try mimeType first, if it is specified
if (mimeType != null) {
mFileType = MediaFile.getFileTypeForMimeType(mimeType);
- if (mFileType != 0) {
- mMimeType = mimeType;
- }
}
// if mimeType was not specified, compute file type based on file extension.
- if (mMimeType == null) {
+ if (mFileType == 0) {
MediaFile.MediaFileType mediaFileType = MediaFile.getFileType(path);
if (mediaFileType != null) {
mFileType = mediaFileType.fileType;
- mMimeType = mediaFileType.mimeType;
+ if (mMimeType == null) {
+ mMimeType = mediaFileType.mimeType;
+ }
}
}
diff --git a/media/java/android/media/videoeditor/Effect.java b/media/java/android/media/videoeditor/Effect.java
index ef0aeb1..8fd0d27 100755
--- a/media/java/android/media/videoeditor/Effect.java
+++ b/media/java/android/media/videoeditor/Effect.java
@@ -76,7 +76,7 @@
/**
* Set the duration of the effect. If a preview or export is in progress,
- * then this change is effective for next preview or export session. s
+ * then this change is effective for next preview or export session.
*
* @param durationMs of the effect in milliseconds
*/
@@ -85,9 +85,10 @@
throw new IllegalArgumentException("Duration is too large");
}
+ final long oldDurationMs = mDurationMs;
mDurationMs = durationMs;
- mMediaItem.invalidateTransitions(mStartTimeMs, mDurationMs);
+ mMediaItem.invalidateTransitions(mStartTimeMs, oldDurationMs, mStartTimeMs, mDurationMs);
}
/**
@@ -111,9 +112,10 @@
throw new IllegalArgumentException("Start time is too large");
}
+ final long oldStartTimeMs = mStartTimeMs;
mStartTimeMs = startTimeMs;
- mMediaItem.invalidateTransitions(mStartTimeMs, mDurationMs);
+ mMediaItem.invalidateTransitions(oldStartTimeMs, mDurationMs, mStartTimeMs, mDurationMs);
}
/**
@@ -134,10 +136,13 @@
throw new IllegalArgumentException("Invalid start time or duration");
}
+ final long oldStartTimeMs = mStartTimeMs;
+ final long oldDurationMs = mDurationMs;
+
mStartTimeMs = startTimeMs;
mDurationMs = durationMs;
- mMediaItem.invalidateTransitions(mStartTimeMs, mDurationMs);
+ mMediaItem.invalidateTransitions(oldStartTimeMs, oldDurationMs, mStartTimeMs, mDurationMs);
}
/**
diff --git a/media/java/android/media/videoeditor/MediaImageItem.java b/media/java/android/media/videoeditor/MediaImageItem.java
index a4b0770..fa8d61b 100755
--- a/media/java/android/media/videoeditor/MediaImageItem.java
+++ b/media/java/android/media/videoeditor/MediaImageItem.java
@@ -242,15 +242,49 @@
*/
@Override
void invalidateTransitions(long startTimeMs, long durationMs) {
- // Check if the effect overlaps with the beginning and end transitions
+ // Check if the item overlaps with the beginning and end transitions
if (mBeginTransition != null) {
- if (startTimeMs < mBeginTransition.getDuration()) {
+ if (isOverlapping(startTimeMs, durationMs, 0, mBeginTransition.getDuration())) {
mBeginTransition.invalidate();
}
}
if (mEndTransition != null) {
- if (startTimeMs + durationMs > mDurationMs - mEndTransition.getDuration()) {
+ final long transitionDurationMs = mEndTransition.getDuration();
+ if (isOverlapping(startTimeMs, durationMs,
+ getDuration() - transitionDurationMs, transitionDurationMs)) {
+ mEndTransition.invalidate();
+ }
+ }
+ }
+
+ /*
+ * {@inheritDoc}
+ */
+ @Override
+ void invalidateTransitions(long oldStartTimeMs, long oldDurationMs, long newStartTimeMs,
+ long newDurationMs) {
+ // Check if the item overlaps with the beginning and end transitions
+ if (mBeginTransition != null) {
+ final long transitionDurationMs = mBeginTransition.getDuration();
+ // If the start time has changed and if the old or the new item
+ // overlaps with the begin transition, invalidate the transition.
+ if (oldStartTimeMs != newStartTimeMs &&
+ (isOverlapping(oldStartTimeMs, oldDurationMs, 0, transitionDurationMs) ||
+ isOverlapping(newStartTimeMs, newDurationMs, 0, transitionDurationMs))) {
+ mBeginTransition.invalidate();
+ }
+ }
+
+ if (mEndTransition != null) {
+ final long transitionDurationMs = mEndTransition.getDuration();
+ // If the start time + duration has changed and if the old or the new
+ // item overlaps the end transition, invalidate the transition/
+ if (oldStartTimeMs + oldDurationMs != newStartTimeMs + newDurationMs &&
+ (isOverlapping(oldStartTimeMs, oldDurationMs,
+ mDurationMs - transitionDurationMs, transitionDurationMs) ||
+ isOverlapping(newStartTimeMs, newDurationMs,
+ mDurationMs - transitionDurationMs, transitionDurationMs))) {
mEndTransition.invalidate();
}
}
diff --git a/media/java/android/media/videoeditor/MediaItem.java b/media/java/android/media/videoeditor/MediaItem.java
index 12f6084..20fd6c9 100755
--- a/media/java/android/media/videoeditor/MediaItem.java
+++ b/media/java/android/media/videoeditor/MediaItem.java
@@ -455,6 +455,40 @@
abstract void invalidateTransitions(long startTimeMs, long durationMs);
/**
+ * Invalidate the start and end transitions if necessary. This method is
+ * typically called when the start time and/or duration of an overlay or
+ * effect is changing.
+ *
+ * @param oldStartTimeMs The old start time of the effect or overlay
+ * @param oldDurationMs The old duration of the effect or overlay
+ * @param newStartTimeMs The new start time of the effect or overlay
+ * @param newDurationMs The new duration of the effect or overlay
+ */
+ abstract void invalidateTransitions(long oldStartTimeMs, long oldDurationMs,
+ long newStartTimeMs, long newDurationMs);
+
+ /**
+ * Check if two items overlap in time
+ *
+ * @param startTimeMs1 Item 1 start time
+ * @param durationMs1 Item 1 duration
+ * @param startTimeMs2 Item 2 start time
+ * @param durationMs2 Item 2 end time
+ *
+ * @return true if the two items overlap
+ */
+ protected boolean isOverlapping(long startTimeMs1, long durationMs1,
+ long startTimeMs2, long durationMs2) {
+ if (startTimeMs1 + durationMs1 <= startTimeMs2) {
+ return false;
+ } else if (startTimeMs1 >= startTimeMs2 + durationMs2) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
* Adjust the duration transitions.
*/
protected void adjustTransitions() {
diff --git a/media/java/android/media/videoeditor/MediaVideoItem.java b/media/java/android/media/videoeditor/MediaVideoItem.java
index 745b00a..cb835b5 100755
--- a/media/java/android/media/videoeditor/MediaVideoItem.java
+++ b/media/java/android/media/videoeditor/MediaVideoItem.java
@@ -218,15 +218,52 @@
*/
@Override
void invalidateTransitions(long startTimeMs, long durationMs) {
- // Check if the effect overlaps with the beginning and end transitions
+ // Check if the item overlaps with the beginning and end transitions
if (mBeginTransition != null) {
- if (startTimeMs < mBeginTransition.getDuration()) {
+ if (isOverlapping(startTimeMs, durationMs,
+ mBeginBoundaryTimeMs, mBeginTransition.getDuration())) {
mBeginTransition.invalidate();
}
}
if (mEndTransition != null) {
- if (startTimeMs + durationMs > mEndBoundaryTimeMs - mEndTransition.getDuration()) {
+ final long transitionDurationMs = mEndTransition.getDuration();
+ if (isOverlapping(startTimeMs, durationMs,
+ mEndBoundaryTimeMs - transitionDurationMs, transitionDurationMs)) {
+ mEndTransition.invalidate();
+ }
+ }
+ }
+
+ /*
+ * {@inheritDoc}
+ */
+ @Override
+ void invalidateTransitions(long oldStartTimeMs, long oldDurationMs, long newStartTimeMs,
+ long newDurationMs) {
+ // Check if the item overlaps with the beginning and end transitions
+ if (mBeginTransition != null) {
+ final long transitionDurationMs = mBeginTransition.getDuration();
+ // If the start time has changed and if the old or the new item
+ // overlaps with the begin transition, invalidate the transition.
+ if (oldStartTimeMs != newStartTimeMs &&
+ (isOverlapping(oldStartTimeMs, oldDurationMs,
+ mBeginBoundaryTimeMs, transitionDurationMs) ||
+ isOverlapping(newStartTimeMs, newDurationMs,
+ mBeginBoundaryTimeMs, transitionDurationMs))) {
+ mBeginTransition.invalidate();
+ }
+ }
+
+ if (mEndTransition != null) {
+ final long transitionDurationMs = mEndTransition.getDuration();
+ // If the start time + duration has changed and if the old or the new
+ // item overlaps the end transition, invalidate the transition/
+ if (oldStartTimeMs + oldDurationMs != newStartTimeMs + newDurationMs &&
+ (isOverlapping(oldStartTimeMs, oldDurationMs,
+ mEndBoundaryTimeMs - transitionDurationMs, transitionDurationMs) ||
+ isOverlapping(newStartTimeMs, newDurationMs,
+ mEndBoundaryTimeMs - transitionDurationMs, transitionDurationMs))) {
mEndTransition.invalidate();
}
}
diff --git a/media/java/android/media/videoeditor/Overlay.java b/media/java/android/media/videoeditor/Overlay.java
index e43f229..0174ba8 100755
--- a/media/java/android/media/videoeditor/Overlay.java
+++ b/media/java/android/media/videoeditor/Overlay.java
@@ -96,9 +96,10 @@
throw new IllegalArgumentException("Duration is too large");
}
+ final long oldDurationMs = mDurationMs;
mDurationMs = durationMs;
- mMediaItem.invalidateTransitions(mStartTimeMs, mDurationMs);
+ mMediaItem.invalidateTransitions(mStartTimeMs, oldDurationMs, mStartTimeMs, mDurationMs);
}
/**
@@ -120,9 +121,10 @@
throw new IllegalArgumentException("Start time is too large");
}
+ final long oldStartTimeMs = mStartTimeMs;
mStartTimeMs = startTimeMs;
- mMediaItem.invalidateTransitions(mStartTimeMs, mDurationMs);
+ mMediaItem.invalidateTransitions(oldStartTimeMs, mDurationMs, mStartTimeMs, mDurationMs);
}
/**
@@ -136,10 +138,13 @@
throw new IllegalArgumentException("Invalid start time or duration");
}
+ final long oldStartTimeMs = mStartTimeMs;
+ final long oldDurationMs = mDurationMs;
+
mStartTimeMs = startTimeMs;
mDurationMs = durationMs;
- mMediaItem.invalidateTransitions(mStartTimeMs, mDurationMs);
+ mMediaItem.invalidateTransitions(oldStartTimeMs, oldDurationMs, mStartTimeMs, mDurationMs);
}
/**
diff --git a/media/java/android/media/videoeditor/WaveformData.java b/media/java/android/media/videoeditor/WaveformData.java
index b53bd7d..5791046 100644
--- a/media/java/android/media/videoeditor/WaveformData.java
+++ b/media/java/android/media/videoeditor/WaveformData.java
@@ -16,6 +16,8 @@
package android.media.videoeditor;
+import java.io.IOException;
+
/**
* Class which describes the waveform data of an audio track. The gain values
* represent the average gain for an audio frame. For audio codecs which do
@@ -33,7 +35,7 @@
* This constructor shall not be used
*/
@SuppressWarnings("unused")
- private WaveformData() {
+ private WaveformData() throws IOException {
mFrameDurationMs = 0;
mFramesCount = 0;
mGains = null;
diff --git a/media/libmedia/IMediaPlayer.cpp b/media/libmedia/IMediaPlayer.cpp
index 1a46715..c287c0a 100644
--- a/media/libmedia/IMediaPlayer.cpp
+++ b/media/libmedia/IMediaPlayer.cpp
@@ -29,7 +29,6 @@
enum {
DISCONNECT = IBinder::FIRST_CALL_TRANSACTION,
SET_VIDEO_SURFACE,
- SET_VIDEO_ISURFACE,
PREPARE_ASYNC,
START,
STOP,
@@ -65,15 +64,6 @@
remote()->transact(DISCONNECT, data, &reply);
}
- status_t setVideoISurface(const sp<ISurface>& surface)
- {
- Parcel data, reply;
- data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor());
- data.writeStrongBinder(surface->asBinder());
- remote()->transact(SET_VIDEO_ISURFACE, data, &reply);
- return reply.readInt32();
- }
-
status_t setVideoSurface(const sp<Surface>& surface)
{
Parcel data, reply;
@@ -245,12 +235,6 @@
disconnect();
return NO_ERROR;
} break;
- case SET_VIDEO_ISURFACE: {
- CHECK_INTERFACE(IMediaPlayer, data, reply);
- sp<ISurface> surface = interface_cast<ISurface>(data.readStrongBinder());
- reply->writeInt32(setVideoISurface(surface));
- return NO_ERROR;
- } break;
case SET_VIDEO_SURFACE: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
sp<Surface> surface = Surface::readFromParcel(data);
diff --git a/media/libmedia/IOMX.cpp b/media/libmedia/IOMX.cpp
index f975217..9ce6738 100644
--- a/media/libmedia/IOMX.cpp
+++ b/media/libmedia/IOMX.cpp
@@ -31,48 +31,9 @@
FILL_BUFFER,
EMPTY_BUFFER,
GET_EXTENSION_INDEX,
- CREATE_RENDERER,
OBSERVER_ON_MSG,
- RENDERER_RENDER,
};
-sp<IOMXRenderer> IOMX::createRenderer(
- const sp<Surface> &surface,
- const char *componentName,
- OMX_COLOR_FORMATTYPE colorFormat,
- size_t encodedWidth, size_t encodedHeight,
- size_t displayWidth, size_t displayHeight) {
- return createRenderer(
- surface->getISurface(),
- componentName, colorFormat, encodedWidth, encodedHeight,
- displayWidth, displayHeight);
-}
-
-sp<IOMXRenderer> IOMX::createRendererFromJavaSurface(
- JNIEnv *env, jobject javaSurface,
- const char *componentName,
- OMX_COLOR_FORMATTYPE colorFormat,
- size_t encodedWidth, size_t encodedHeight,
- size_t displayWidth, size_t displayHeight) {
- jclass surfaceClass = env->FindClass("android/view/Surface");
- if (surfaceClass == NULL) {
- LOGE("Can't find android/view/Surface");
- return NULL;
- }
-
- jfieldID surfaceID = env->GetFieldID(surfaceClass, ANDROID_VIEW_SURFACE_JNI_ID, "I");
- if (surfaceID == NULL) {
- LOGE("Can't find Surface.mSurface");
- return NULL;
- }
-
- sp<Surface> surface = (Surface *)env->GetIntField(javaSurface, surfaceID);
-
- return createRenderer(
- surface, componentName, colorFormat, encodedWidth,
- encodedHeight, displayWidth, displayHeight);
-}
-
class BpOMX : public BpInterface<IOMX> {
public:
BpOMX(const sp<IBinder> &impl)
@@ -395,28 +356,6 @@
return err;
}
-
- virtual sp<IOMXRenderer> createRenderer(
- const sp<ISurface> &surface,
- const char *componentName,
- OMX_COLOR_FORMATTYPE colorFormat,
- size_t encodedWidth, size_t encodedHeight,
- size_t displayWidth, size_t displayHeight) {
- Parcel data, reply;
- data.writeInterfaceToken(IOMX::getInterfaceDescriptor());
-
- data.writeStrongBinder(surface->asBinder());
- data.writeCString(componentName);
- data.writeInt32(colorFormat);
- data.writeInt32(encodedWidth);
- data.writeInt32(encodedHeight);
- data.writeInt32(displayWidth);
- data.writeInt32(displayHeight);
-
- remote()->transact(CREATE_RENDERER, data, &reply);
-
- return interface_cast<IOMXRenderer>(reply.readStrongBinder());
- }
};
IMPLEMENT_META_INTERFACE(OMX, "android.hardware.IOMX");
@@ -767,33 +706,6 @@
return OK;
}
- case CREATE_RENDERER:
- {
- CHECK_INTERFACE(IOMX, data, reply);
-
- sp<ISurface> isurface =
- interface_cast<ISurface>(data.readStrongBinder());
-
- const char *componentName = data.readCString();
-
- OMX_COLOR_FORMATTYPE colorFormat =
- static_cast<OMX_COLOR_FORMATTYPE>(data.readInt32());
-
- size_t encodedWidth = (size_t)data.readInt32();
- size_t encodedHeight = (size_t)data.readInt32();
- size_t displayWidth = (size_t)data.readInt32();
- size_t displayHeight = (size_t)data.readInt32();
-
- sp<IOMXRenderer> renderer =
- createRenderer(isurface, componentName, colorFormat,
- encodedWidth, encodedHeight,
- displayWidth, displayHeight);
-
- reply->writeStrongBinder(renderer->asBinder());
-
- return OK;
- }
-
default:
return BBinder::onTransact(code, data, reply, flags);
}
@@ -839,44 +751,4 @@
}
}
-////////////////////////////////////////////////////////////////////////////////
-
-class BpOMXRenderer : public BpInterface<IOMXRenderer> {
-public:
- BpOMXRenderer(const sp<IBinder> &impl)
- : BpInterface<IOMXRenderer>(impl) {
- }
-
- virtual void render(IOMX::buffer_id buffer) {
- Parcel data, reply;
- data.writeInterfaceToken(IOMXRenderer::getInterfaceDescriptor());
- data.writeIntPtr((intptr_t)buffer);
-
- // NOTE: Do NOT make this a ONE_WAY call, it must be synchronous
- // so that the caller knows when to recycle the buffer.
- remote()->transact(RENDERER_RENDER, data, &reply);
- }
-};
-
-IMPLEMENT_META_INTERFACE(OMXRenderer, "android.hardware.IOMXRenderer");
-
-status_t BnOMXRenderer::onTransact(
- uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) {
- switch (code) {
- case RENDERER_RENDER:
- {
- CHECK_INTERFACE(IOMXRenderer, data, reply);
-
- IOMX::buffer_id buffer = (void*)data.readIntPtr();
-
- render(buffer);
-
- return NO_ERROR;
- }
-
- default:
- return BBinder::onTransact(code, data, reply, flags);
- }
-}
-
} // namespace android
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index 34e41a1..54b292c 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -198,13 +198,6 @@
Mutex::Autolock _l(mLock);
if (mPlayer == 0) return NO_INIT;
- status_t err = mPlayer->setVideoISurface(
- surface == NULL ? NULL : surface->getISurface());
-
- if (err != OK) {
- return err;
- }
-
return mPlayer->setVideoSurface(surface);
}
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index e84c2dc..00e510b 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -864,14 +864,6 @@
return mStatus;
}
-status_t MediaPlayerService::Client::setVideoISurface(const sp<ISurface>& surface)
-{
- LOGV("[%d] setVideoISurface(%p)", mConnId, surface.get());
- sp<MediaPlayerBase> p = getPlayer();
- if (p == 0) return UNKNOWN_ERROR;
- return p->setVideoISurface(surface);
-}
-
status_t MediaPlayerService::Client::setVideoSurface(const sp<Surface>& surface)
{
LOGV("[%d] setVideoSurface(%p)", mConnId, surface.get());
diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h
index e197cde..184324c 100644
--- a/media/libmediaplayerservice/MediaPlayerService.h
+++ b/media/libmediaplayerservice/MediaPlayerService.h
@@ -206,7 +206,6 @@
// IMediaPlayer interface
virtual void disconnect();
- virtual status_t setVideoISurface(const sp<ISurface>& surface);
virtual status_t setVideoSurface(const sp<Surface>& surface);
virtual status_t prepareAsync();
virtual status_t start();
diff --git a/media/libmediaplayerservice/MidiFile.h b/media/libmediaplayerservice/MidiFile.h
index 06e4b70..aa8f3f0e 100644
--- a/media/libmediaplayerservice/MidiFile.h
+++ b/media/libmediaplayerservice/MidiFile.h
@@ -35,7 +35,6 @@
const char* path, const KeyedVector<String8, String8> *headers);
virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
- virtual status_t setVideoISurface(const sp<ISurface>& surface) { return UNKNOWN_ERROR; }
virtual status_t setVideoSurface(const sp<Surface>& surface) { return UNKNOWN_ERROR; }
virtual status_t prepare();
virtual status_t prepareAsync();
diff --git a/media/libmediaplayerservice/StagefrightPlayer.cpp b/media/libmediaplayerservice/StagefrightPlayer.cpp
index e0957f6..58ef99b 100644
--- a/media/libmediaplayerservice/StagefrightPlayer.cpp
+++ b/media/libmediaplayerservice/StagefrightPlayer.cpp
@@ -44,13 +44,6 @@
return mPlayer->setDataSource(dup(fd), offset, length);
}
-status_t StagefrightPlayer::setVideoISurface(const sp<ISurface> &surface) {
- LOGV("setVideoISurface");
-
- mPlayer->setISurface(surface);
- return OK;
-}
-
status_t StagefrightPlayer::setVideoSurface(const sp<Surface> &surface) {
LOGV("setVideoSurface");
diff --git a/media/libmediaplayerservice/StagefrightPlayer.h b/media/libmediaplayerservice/StagefrightPlayer.h
index 3899447..c4a2588 100644
--- a/media/libmediaplayerservice/StagefrightPlayer.h
+++ b/media/libmediaplayerservice/StagefrightPlayer.h
@@ -35,7 +35,6 @@
const char *url, const KeyedVector<String8, String8> *headers);
virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
- virtual status_t setVideoISurface(const sp<ISurface> &surface);
virtual status_t setVideoSurface(const sp<Surface> &surface);
virtual status_t prepare();
virtual status_t prepareAsync();
diff --git a/media/libmediaplayerservice/TestPlayerStub.h b/media/libmediaplayerservice/TestPlayerStub.h
index 5eaf592..6abd8e3 100644
--- a/media/libmediaplayerservice/TestPlayerStub.h
+++ b/media/libmediaplayerservice/TestPlayerStub.h
@@ -75,9 +75,6 @@
// All the methods below wrap the mPlayer instance.
- virtual status_t setVideoISurface(const android::sp<android::ISurface>& s) {
- return mPlayer->setVideoISurface(s);
- }
virtual status_t setVideoSurface(const android::sp<android::Surface>& s) {
return mPlayer->setVideoSurface(s);
}
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 41f5f30..538e7bf 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -79,39 +79,18 @@
AwesomeEvent &operator=(const AwesomeEvent &);
};
-struct AwesomeRemoteRenderer : public AwesomeRenderer {
- AwesomeRemoteRenderer(const sp<IOMXRenderer> &target)
- : mTarget(target) {
- }
-
- virtual void render(MediaBuffer *buffer) {
- void *id;
- if (buffer->meta_data()->findPointer(kKeyBufferID, &id)) {
- mTarget->render((IOMX::buffer_id)id);
- }
- }
-
-private:
- sp<IOMXRenderer> mTarget;
-
- AwesomeRemoteRenderer(const AwesomeRemoteRenderer &);
- AwesomeRemoteRenderer &operator=(const AwesomeRemoteRenderer &);
-};
-
struct AwesomeLocalRenderer : public AwesomeRenderer {
AwesomeLocalRenderer(
- bool previewOnly,
- const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat,
- const sp<ISurface> &isurface,
const sp<Surface> &surface,
size_t displayWidth, size_t displayHeight,
- size_t decodedWidth, size_t decodedHeight)
- : mTarget(NULL),
- mLibHandle(NULL) {
- init(previewOnly, componentName,
- colorFormat, isurface, surface, displayWidth,
- displayHeight, decodedWidth, decodedHeight);
+ size_t decodedWidth, size_t decodedHeight,
+ int32_t rotationDegrees)
+ : mTarget(NULL) {
+ init(colorFormat, surface,
+ displayWidth, displayHeight,
+ decodedWidth, decodedHeight,
+ rotationDegrees);
}
virtual void render(MediaBuffer *buffer) {
@@ -127,78 +106,39 @@
virtual ~AwesomeLocalRenderer() {
delete mTarget;
mTarget = NULL;
-
- if (mLibHandle) {
- dlclose(mLibHandle);
- mLibHandle = NULL;
- }
}
private:
- VideoRenderer *mTarget;
- void *mLibHandle;
+ SoftwareRenderer *mTarget;
void init(
- bool previewOnly,
- const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat,
- const sp<ISurface> &isurface,
const sp<Surface> &surface,
size_t displayWidth, size_t displayHeight,
- size_t decodedWidth, size_t decodedHeight);
+ size_t decodedWidth, size_t decodedHeight,
+ int32_t rotationDegrees);
AwesomeLocalRenderer(const AwesomeLocalRenderer &);
AwesomeLocalRenderer &operator=(const AwesomeLocalRenderer &);;
};
void AwesomeLocalRenderer::init(
- bool previewOnly,
- const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat,
- const sp<ISurface> &isurface,
const sp<Surface> &surface,
size_t displayWidth, size_t displayHeight,
- size_t decodedWidth, size_t decodedHeight) {
- if (!previewOnly) {
- // We will stick to the vanilla software-color-converting renderer
- // for "previewOnly" mode, to avoid unneccessarily switching overlays
- // more often than necessary.
-
- mLibHandle = dlopen("libstagefrighthw.so", RTLD_NOW);
-
- if (mLibHandle) {
- typedef VideoRenderer *(*CreateRendererFunc)(
- const sp<ISurface> &surface,
- const char *componentName,
- OMX_COLOR_FORMATTYPE colorFormat,
- size_t displayWidth, size_t displayHeight,
- size_t decodedWidth, size_t decodedHeight);
-
- CreateRendererFunc func =
- (CreateRendererFunc)dlsym(
- mLibHandle,
- "_Z14createRendererRKN7android2spINS_8ISurfaceEEEPKc20"
- "OMX_COLOR_FORMATTYPEjjjj");
-
- if (func) {
- mTarget =
- (*func)(isurface, componentName, colorFormat,
- displayWidth, displayHeight,
- decodedWidth, decodedHeight);
- }
- }
- }
-
- if (mTarget == NULL) {
- mTarget = new SoftwareRenderer(
- colorFormat, surface, displayWidth, displayHeight,
- decodedWidth, decodedHeight);
- }
+ size_t decodedWidth, size_t decodedHeight,
+ int32_t rotationDegrees) {
+ mTarget = new SoftwareRenderer(
+ colorFormat, surface, displayWidth, displayHeight,
+ decodedWidth, decodedHeight, rotationDegrees);
}
struct AwesomeNativeWindowRenderer : public AwesomeRenderer {
- AwesomeNativeWindowRenderer(const sp<ANativeWindow> &nativeWindow)
+ AwesomeNativeWindowRenderer(
+ const sp<ANativeWindow> &nativeWindow,
+ int32_t rotationDegrees)
: mNativeWindow(nativeWindow) {
+ applyRotation(rotationDegrees);
}
virtual void render(MediaBuffer *buffer) {
@@ -220,6 +160,22 @@
private:
sp<ANativeWindow> mNativeWindow;
+ void applyRotation(int32_t rotationDegrees) {
+ uint32_t transform;
+ switch (rotationDegrees) {
+ case 0: transform = 0; break;
+ case 90: transform = HAL_TRANSFORM_ROT_90; break;
+ case 180: transform = HAL_TRANSFORM_ROT_180; break;
+ case 270: transform = HAL_TRANSFORM_ROT_270; break;
+ default: transform = 0; break;
+ }
+
+ if (transform) {
+ CHECK_EQ(0, native_window_set_buffers_transform(
+ mNativeWindow.get(), transform));
+ }
+ }
+
AwesomeNativeWindowRenderer(const AwesomeNativeWindowRenderer &);
AwesomeNativeWindowRenderer &operator=(
const AwesomeNativeWindowRenderer &);
@@ -863,58 +819,65 @@
CHECK(meta->findInt32(kKeyWidth, &decodedWidth));
CHECK(meta->findInt32(kKeyHeight, &decodedHeight));
- notifyListener_l(MEDIA_SET_VIDEO_SIZE, decodedWidth, decodedHeight);
+ int32_t rotationDegrees;
+ if (!mVideoTrack->getFormat()->findInt32(
+ kKeyRotation, &rotationDegrees)) {
+ rotationDegrees = 0;
+ }
+
+ if (rotationDegrees == 90 || rotationDegrees == 270) {
+ notifyListener_l(
+ MEDIA_SET_VIDEO_SIZE, decodedHeight, decodedWidth);
+ } else {
+ notifyListener_l(
+ MEDIA_SET_VIDEO_SIZE, decodedWidth, decodedHeight);
+ }
}
void AwesomePlayer::initRenderer_l() {
- if (mSurface != NULL || mISurface != NULL) {
- sp<MetaData> meta = mVideoSource->getFormat();
+ if (mSurface == NULL) {
+ return;
+ }
- int32_t format;
- const char *component;
- int32_t decodedWidth, decodedHeight;
- CHECK(meta->findInt32(kKeyColorFormat, &format));
- CHECK(meta->findCString(kKeyDecoderComponent, &component));
- CHECK(meta->findInt32(kKeyWidth, &decodedWidth));
- CHECK(meta->findInt32(kKeyHeight, &decodedHeight));
+ sp<MetaData> meta = mVideoSource->getFormat();
- mVideoRenderer.clear();
+ int32_t format;
+ const char *component;
+ int32_t decodedWidth, decodedHeight;
+ CHECK(meta->findInt32(kKeyColorFormat, &format));
+ CHECK(meta->findCString(kKeyDecoderComponent, &component));
+ CHECK(meta->findInt32(kKeyWidth, &decodedWidth));
+ CHECK(meta->findInt32(kKeyHeight, &decodedHeight));
- // Must ensure that mVideoRenderer's destructor is actually executed
- // before creating a new one.
- IPCThreadState::self()->flushCommands();
+ int32_t rotationDegrees;
+ if (!mVideoTrack->getFormat()->findInt32(
+ kKeyRotation, &rotationDegrees)) {
+ rotationDegrees = 0;
+ }
- if (mSurface != NULL) {
- if (USE_SURFACE_ALLOC && strncmp(component, "OMX.", 4) == 0) {
- // Hardware decoders avoid the CPU color conversion by decoding
- // directly to ANativeBuffers, so we must use a renderer that
- // just pushes those buffers to the ANativeWindow.
- mVideoRenderer = new AwesomeNativeWindowRenderer(mSurface);
- } else {
- // Other decoders are instantiated locally and as a consequence
- // allocate their buffers in local address space. This renderer
- // then performs a color conversion and copy to get the data
- // into the ANativeBuffer.
- mVideoRenderer = new AwesomeLocalRenderer(
- false, // previewOnly
- component,
- (OMX_COLOR_FORMATTYPE)format,
- mISurface,
- mSurface,
- mVideoWidth, mVideoHeight,
- decodedWidth, decodedHeight);
- }
- } else {
- // Our OMX codecs allocate buffers on the media_server side
- // therefore they require a remote IOMXRenderer that knows how
- // to display them.
- mVideoRenderer = new AwesomeRemoteRenderer(
- mClient.interface()->createRenderer(
- mISurface, component,
- (OMX_COLOR_FORMATTYPE)format,
- decodedWidth, decodedHeight,
- mVideoWidth, mVideoHeight));
- }
+ mVideoRenderer.clear();
+
+ // Must ensure that mVideoRenderer's destructor is actually executed
+ // before creating a new one.
+ IPCThreadState::self()->flushCommands();
+
+ if (USE_SURFACE_ALLOC && strncmp(component, "OMX.", 4) == 0) {
+ // Hardware decoders avoid the CPU color conversion by decoding
+ // directly to ANativeBuffers, so we must use a renderer that
+ // just pushes those buffers to the ANativeWindow.
+ mVideoRenderer =
+ new AwesomeNativeWindowRenderer(mSurface, rotationDegrees);
+ } else {
+ // Other decoders are instantiated locally and as a consequence
+ // allocate their buffers in local address space. This renderer
+ // then performs a color conversion and copy to get the data
+ // into the ANativeBuffer.
+ mVideoRenderer = new AwesomeLocalRenderer(
+ (OMX_COLOR_FORMATTYPE)format,
+ mSurface,
+ mVideoWidth, mVideoHeight,
+ decodedWidth, decodedHeight,
+ rotationDegrees);
}
}
@@ -958,12 +921,6 @@
return (mFlags & PLAYING) || (mFlags & CACHE_UNDERRUN);
}
-void AwesomePlayer::setISurface(const sp<ISurface> &isurface) {
- Mutex::Autolock autoLock(mLock);
-
- mISurface = isurface;
-}
-
void AwesomePlayer::setSurface(const sp<Surface> &surface) {
Mutex::Autolock autoLock(mLock);
@@ -1897,18 +1854,16 @@
mFlags = state->mFlags & (AUTO_LOOPING | LOOPING | AT_EOS);
- if (state->mLastVideoFrame && (mSurface != NULL || mISurface != NULL)) {
+ if (state->mLastVideoFrame && mSurface != NULL) {
mVideoRenderer =
new AwesomeLocalRenderer(
- true, // previewOnly
- "",
(OMX_COLOR_FORMATTYPE)state->mColorFormat,
- mISurface,
mSurface,
state->mVideoWidth,
state->mVideoHeight,
state->mDecodedWidth,
- state->mDecodedHeight);
+ state->mDecodedHeight,
+ 0);
mVideoRendererIsPreview = true;
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index b8450fb..d9ff723 100644
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -495,26 +495,6 @@
mIsMetaDataStoredInVideoBuffers = true;
}
- /*
- * mCamera->startRecording() signals camera hal to make
- * available the video buffers (for instance, allocation
- * of the video buffers may be triggered when camera hal's
- * startRecording() method is called). Making available these
- * video buffers earlier (before calling start()) is critical,
- * if one wants to configure omx video encoders to use these
- * buffers for passing video frame data during video recording
- * without the need to memcpy the video frame data stored
- * in these buffers. Eliminating memcpy for video frame data
- * is crucial in performance for HD quality video recording
- * applications.
- *
- * Based on OMX IL spec, configuring the omx video encoders
- * must occur in loaded state. When start() is called, omx
- * video encoders are already in idle state, which is too
- * late. Thus, we must call mCamera->startRecording() earlier.
- */
- startCameraRecording();
-
IPCThreadState::self()->restoreCallingIdentity(token);
int64_t glitchDurationUs = (1000000LL / mVideoFrameRate);
@@ -565,8 +545,11 @@
mStartTimeUs = startTimeUs;
}
+ // Call setListener first before calling startCameraRecording()
+ // to avoid recording frames being dropped.
int64_t token = IPCThreadState::self()->clearCallingIdentity();
mCamera->setListener(new CameraSourceListener(this));
+ startCameraRecording();
IPCThreadState::self()->restoreCallingIdentity(token);
mStarted = true;
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index 2e94a12..bb929fd 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -27,11 +27,11 @@
#include <stdlib.h>
#include <string.h>
+#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/DataSource.h>
#include "include/ESDS.h"
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MetaData.h>
@@ -766,55 +766,11 @@
case FOURCC('t', 'k', 'h', 'd'):
{
- if (chunk_data_size < 4) {
- return ERROR_MALFORMED;
+ status_t err;
+ if ((err = parseTrackHeader(data_offset, chunk_data_size)) != OK) {
+ return err;
}
- uint8_t version;
- if (mDataSource->readAt(data_offset, &version, 1) < 1) {
- return ERROR_IO;
- }
-
- uint64_t ctime, mtime, duration;
- int32_t id;
- uint32_t width, height;
-
- if (version == 1) {
- if (chunk_data_size != 36 + 60) {
- return ERROR_MALFORMED;
- }
-
- uint8_t buffer[36 + 60];
- if (mDataSource->readAt(
- data_offset, buffer, sizeof(buffer)) < (ssize_t)sizeof(buffer)) {
- return ERROR_IO;
- }
-
- ctime = U64_AT(&buffer[4]);
- mtime = U64_AT(&buffer[12]);
- id = U32_AT(&buffer[20]);
- duration = U64_AT(&buffer[28]);
- width = U32_AT(&buffer[88]);
- height = U32_AT(&buffer[92]);
- } else if (version == 0) {
- if (chunk_data_size != 24 + 60) {
- return ERROR_MALFORMED;
- }
-
- uint8_t buffer[24 + 60];
- if (mDataSource->readAt(
- data_offset, buffer, sizeof(buffer)) < (ssize_t)sizeof(buffer)) {
- return ERROR_IO;
- }
- ctime = U32_AT(&buffer[4]);
- mtime = U32_AT(&buffer[8]);
- id = U32_AT(&buffer[12]);
- duration = U32_AT(&buffer[20]);
- width = U32_AT(&buffer[76]);
- height = U32_AT(&buffer[80]);
- }
-
- mLastTrack->meta->setInt32(kKeyTrackID, id);
*offset += chunk_size;
break;
}
@@ -1275,6 +1231,93 @@
return OK;
}
+status_t MPEG4Extractor::parseTrackHeader(
+ off_t data_offset, off_t data_size) {
+ if (data_size < 4) {
+ return ERROR_MALFORMED;
+ }
+
+ uint8_t version;
+ if (mDataSource->readAt(data_offset, &version, 1) < 1) {
+ return ERROR_IO;
+ }
+
+ size_t dynSize = (version == 1) ? 36 : 24;
+
+ uint8_t buffer[36 + 60];
+
+ if (data_size != (off_t)dynSize + 60) {
+ return ERROR_MALFORMED;
+ }
+
+ if (mDataSource->readAt(
+ data_offset, buffer, data_size) < (ssize_t)data_size) {
+ return ERROR_IO;
+ }
+
+ uint64_t ctime, mtime, duration;
+ int32_t id;
+
+ if (version == 1) {
+ ctime = U64_AT(&buffer[4]);
+ mtime = U64_AT(&buffer[12]);
+ id = U32_AT(&buffer[20]);
+ duration = U64_AT(&buffer[28]);
+ } else {
+ CHECK_EQ((unsigned)version, 0u);
+
+ ctime = U32_AT(&buffer[4]);
+ mtime = U32_AT(&buffer[8]);
+ id = U32_AT(&buffer[12]);
+ duration = U32_AT(&buffer[20]);
+ }
+
+ mLastTrack->meta->setInt32(kKeyTrackID, id);
+
+ size_t matrixOffset = dynSize + 16;
+ int32_t a00 = U32_AT(&buffer[matrixOffset]);
+ int32_t a01 = U32_AT(&buffer[matrixOffset + 4]);
+ int32_t dx = U32_AT(&buffer[matrixOffset + 8]);
+ int32_t a10 = U32_AT(&buffer[matrixOffset + 12]);
+ int32_t a11 = U32_AT(&buffer[matrixOffset + 16]);
+ int32_t dy = U32_AT(&buffer[matrixOffset + 20]);
+
+#if 0
+ LOGI("x' = %.2f * x + %.2f * y + %.2f",
+ a00 / 65536.0f, a01 / 65536.0f, dx / 65536.0f);
+ LOGI("y' = %.2f * x + %.2f * y + %.2f",
+ a10 / 65536.0f, a11 / 65536.0f, dy / 65536.0f);
+#endif
+
+ uint32_t rotationDegrees;
+
+ static const int32_t kFixedOne = 0x10000;
+ if (a00 == kFixedOne && a01 == 0 && a10 == 0 && a11 == kFixedOne) {
+ // Identity, no rotation
+ rotationDegrees = 0;
+ } else if (a00 == 0 && a01 == kFixedOne && a10 == -kFixedOne && a11 == 0) {
+ rotationDegrees = 90;
+ } else if (a00 == 0 && a01 == -kFixedOne && a10 == kFixedOne && a11 == 0) {
+ rotationDegrees = 270;
+ } else if (a00 == -kFixedOne && a01 == 0 && a10 == 0 && a11 == -kFixedOne) {
+ rotationDegrees = 180;
+ } else {
+ LOGW("We only support 0,90,180,270 degree rotation matrices");
+ rotationDegrees = 0;
+ }
+
+ if (rotationDegrees != 0) {
+ mLastTrack->meta->setInt32(kKeyRotation, rotationDegrees);
+ }
+
+#if 0
+ uint32_t width = U32_AT(&buffer[dynSize + 52]);
+ uint32_t height = U32_AT(&buffer[dynSize + 56]);
+#endif
+
+ return OK;
+}
+
status_t MPEG4Extractor::parseMetaData(off_t offset, size_t size) {
if (size < 4) {
return ERROR_MALFORMED;
@@ -1588,7 +1631,7 @@
const uint8_t *ptr = (const uint8_t *)data;
CHECK(size >= 7);
- CHECK_EQ(ptr[0], 1); // configurationVersion == 1
+ CHECK_EQ((unsigned)ptr[0], 1u); // configurationVersion == 1
// The number of bytes used to encode the length of a NAL unit.
mNALLengthSize = 1 + (ptr[4] & 3);
@@ -1736,7 +1779,7 @@
}
uint32_t sampleTime;
- CHECK_EQ(OK, mSampleTable->getMetaDataForSample(
+ CHECK_EQ((status_t)OK, mSampleTable->getMetaDataForSample(
sampleIndex, NULL, NULL, &sampleTime));
if (mode == ReadOptions::SEEK_CLOSEST) {
@@ -1783,7 +1826,7 @@
err = mGroup->acquire_buffer(&mBuffer);
if (err != OK) {
- CHECK_EQ(mBuffer, NULL);
+ CHECK(mBuffer == NULL);
return err;
}
}
diff --git a/media/libstagefright/codecs/aacenc/AACEncoder.cpp b/media/libstagefright/codecs/aacenc/AACEncoder.cpp
index df9f107..9524884 100644
--- a/media/libstagefright/codecs/aacenc/AACEncoder.cpp
+++ b/media/libstagefright/codecs/aacenc/AACEncoder.cpp
@@ -36,6 +36,7 @@
mStarted(false),
mBufferGroup(NULL),
mInputBuffer(NULL),
+ mInputFrame(NULL),
mEncoderHandle(NULL),
mApiHandle(NULL),
mMemOperator(NULL) {
@@ -45,6 +46,7 @@
CHECK(mApiHandle == NULL && mEncoderHandle == NULL);
CHECK(mMeta->findInt32(kKeySampleRate, &mSampleRate));
CHECK(mMeta->findInt32(kKeyChannelCount, &mChannels));
+ CHECK(mChannels <= 2 && mChannels >= 1);
CHECK(mMeta->findInt32(kKeyBitRate, &mBitRate));
mApiHandle = new VO_AUDIO_CODECAPI;
@@ -145,6 +147,10 @@
mNumInputSamples = 0;
mAnchorTimeUs = 0;
mFrameCount = 0;
+
+ mInputFrame = new int16_t[mChannels * kNumSamplesPerFrame];
+ CHECK(mInputFrame != NULL);
+
mSource->start(params);
mStarted = true;
@@ -176,6 +182,10 @@
mApiHandle = NULL;
mStarted = false;
+ if (mInputFrame) {
+ delete[] mInputFrame;
+ mInputFrame = NULL;
+ }
return OK;
}
@@ -222,7 +232,8 @@
buffer->meta_data()->setInt32(kKeyIsCodecConfig, false);
}
- while (mNumInputSamples < kNumSamplesPerFrame) {
+ const int32_t nSamples = mChannels * kNumSamplesPerFrame;
+ while (mNumInputSamples < nSamples) {
if (mInputBuffer == NULL) {
if (mSource->read(&mInputBuffer, options) != OK) {
if (mNumInputSamples == 0) {
@@ -231,7 +242,7 @@
}
memset(&mInputFrame[mNumInputSamples],
0,
- sizeof(int16_t) * (kNumSamplesPerFrame - mNumInputSamples));
+ sizeof(int16_t) * (nSamples - mNumInputSamples));
mNumInputSamples = 0;
break;
}
@@ -250,8 +261,7 @@
} else {
readFromSource = false;
}
- size_t copy =
- (kNumSamplesPerFrame - mNumInputSamples) * sizeof(int16_t);
+ size_t copy = (nSamples - mNumInputSamples) * sizeof(int16_t);
if (copy > mInputBuffer->range_length()) {
copy = mInputBuffer->range_length();
@@ -271,8 +281,8 @@
mInputBuffer = NULL;
}
mNumInputSamples += copy / sizeof(int16_t);
- if (mNumInputSamples >= kNumSamplesPerFrame) {
- mNumInputSamples %= kNumSamplesPerFrame;
+ if (mNumInputSamples >= nSamples) {
+ mNumInputSamples %= nSamples;
break;
}
}
@@ -280,7 +290,7 @@
VO_CODECBUFFER inputData;
memset(&inputData, 0, sizeof(inputData));
inputData.Buffer = (unsigned char*) mInputFrame;
- inputData.Length = kNumSamplesPerFrame * sizeof(int16_t);
+ inputData.Length = nSamples * sizeof(int16_t);
CHECK(VO_ERR_NONE == mApiHandle->SetInputData(mEncoderHandle,&inputData));
VO_CODECBUFFER outputData;
@@ -289,15 +299,21 @@
memset(&outputInfo, 0, sizeof(outputInfo));
VO_U32 ret = VO_ERR_NONE;
- outputData.Buffer = outPtr;
- outputData.Length = buffer->size();
- ret = mApiHandle->GetOutputData(mEncoderHandle, &outputData, &outputInfo);
- CHECK(ret == VO_ERR_NONE || ret == VO_ERR_INPUT_BUFFER_SMALL);
- CHECK(outputData.Length != 0);
- buffer->set_range(0, outputData.Length);
+ size_t nOutputBytes = 0;
+ do {
+ outputData.Buffer = outPtr;
+ outputData.Length = buffer->size() - nOutputBytes;
+ ret = mApiHandle->GetOutputData(mEncoderHandle, &outputData, &outputInfo);
+ if (ret == VO_ERR_NONE) {
+ outPtr += outputData.Length;
+ nOutputBytes += outputData.Length;
+ }
+ } while (ret != VO_ERR_INPUT_BUFFER_SMALL);
+ buffer->set_range(0, nOutputBytes);
int64_t mediaTimeUs =
((mFrameCount - 1) * 1000000LL * kNumSamplesPerFrame) / mSampleRate;
+
buffer->meta_data()->setInt64(kKeyTime, mAnchorTimeUs + mediaTimeUs);
if (readFromSource && wallClockTimeUs != -1) {
buffer->meta_data()->setInt64(kKeyDriftTime, mediaTimeUs - wallClockTimeUs);
diff --git a/media/libstagefright/colorconversion/SoftwareRenderer.cpp b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
index 662a84a..3d507ca 100644
--- a/media/libstagefright/colorconversion/SoftwareRenderer.cpp
+++ b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
@@ -35,7 +35,8 @@
OMX_COLOR_FORMATTYPE colorFormat,
const sp<Surface> &surface,
size_t displayWidth, size_t displayHeight,
- size_t decodedWidth, size_t decodedHeight)
+ size_t decodedWidth, size_t decodedHeight,
+ int32_t rotationDegrees)
: mColorFormat(colorFormat),
mConverter(NULL),
mYUVMode(None),
@@ -95,6 +96,20 @@
CHECK_EQ(0, native_window_set_buffers_geometry(
mSurface.get(), mDecodedWidth, mDecodedHeight,
halFormat));
+
+ uint32_t transform;
+ switch (rotationDegrees) {
+ case 0: transform = 0; break;
+ case 90: transform = HAL_TRANSFORM_ROT_90; break;
+ case 180: transform = HAL_TRANSFORM_ROT_180; break;
+ case 270: transform = HAL_TRANSFORM_ROT_270; break;
+ default: transform = 0; break;
+ }
+
+ if (transform) {
+ CHECK_EQ(0, native_window_set_buffers_transform(
+ mSurface.get(), transform));
+ }
}
SoftwareRenderer::~SoftwareRenderer() {
diff --git a/media/libstagefright/httplive/LiveSource.cpp b/media/libstagefright/httplive/LiveSource.cpp
index 39e3e75..f9d27eb 100644
--- a/media/libstagefright/httplive/LiveSource.cpp
+++ b/media/libstagefright/httplive/LiveSource.cpp
@@ -278,7 +278,19 @@
}
if (mLastFetchTimeUs < 0) {
- mPlaylistIndex = 0;
+ if (isSeekable()) {
+ mPlaylistIndex = 0;
+ } else {
+ // This is live streamed content, the first seqnum in the
+ // various bandwidth' streams may be slightly off, so don't
+ // start at the very first entry.
+ // With a segment duration of 6-10secs, this really only
+ // delays playback up to 30secs compared to real time.
+ mPlaylistIndex = 3;
+ if (mPlaylistIndex >= mPlaylist->size()) {
+ mPlaylistIndex = mPlaylist->size() - 1;
+ }
+ }
} else {
if (nextSequenceNumber < mFirstItemSequenceNumber
|| nextSequenceNumber
diff --git a/media/libstagefright/include/AACEncoder.h b/media/libstagefright/include/AACEncoder.h
index ecc533f..3d5fc60 100644
--- a/media/libstagefright/include/AACEncoder.h
+++ b/media/libstagefright/include/AACEncoder.h
@@ -60,7 +60,7 @@
kNumSamplesPerFrame = 1024,
};
- int16_t mInputFrame[kNumSamplesPerFrame];
+ int16_t *mInputFrame;
uint8_t mAudioSpecificConfigData[2]; // auido specific data
void *mEncoderHandle;
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 302a1ba..4e63b7a 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -79,7 +79,6 @@
bool isPlaying() const;
- void setISurface(const sp<ISurface> &isurface);
void setSurface(const sp<Surface> &surface);
void setAudioSink(const sp<MediaPlayerBase::AudioSink> &audioSink);
status_t setLooping(bool shouldLoop);
@@ -130,7 +129,6 @@
bool mQueueStarted;
wp<MediaPlayerBase> mListener;
- sp<ISurface> mISurface;
sp<Surface> mSurface;
sp<MediaPlayerBase::AudioSink> mAudioSink;
diff --git a/media/libstagefright/include/MPEG4Extractor.h b/media/libstagefright/include/MPEG4Extractor.h
index 4e31059..bc2e4dc 100644
--- a/media/libstagefright/include/MPEG4Extractor.h
+++ b/media/libstagefright/include/MPEG4Extractor.h
@@ -88,6 +88,8 @@
bool mIsDrm;
status_t parseDrmSINF(off_t *offset, off_t data_offset);
+ status_t parseTrackHeader(off_t data_offset, off_t data_size);
+
MPEG4Extractor(const MPEG4Extractor &);
MPEG4Extractor &operator=(const MPEG4Extractor &);
};
diff --git a/media/libstagefright/include/OMX.h b/media/libstagefright/include/OMX.h
index 5a6c96f9..5fed98a 100644
--- a/media/libstagefright/include/OMX.h
+++ b/media/libstagefright/include/OMX.h
@@ -97,13 +97,6 @@
const char *parameter_name,
OMX_INDEXTYPE *index);
- virtual sp<IOMXRenderer> createRenderer(
- const sp<ISurface> &surface,
- const char *componentName,
- OMX_COLOR_FORMATTYPE colorFormat,
- size_t encodedWidth, size_t encodedHeight,
- size_t displayWidth, size_t displayHeight);
-
virtual void binderDied(const wp<IBinder> &the_late_who);
OMX_ERRORTYPE OnEvent(
diff --git a/media/libstagefright/include/SoftwareRenderer.h b/media/libstagefright/include/SoftwareRenderer.h
index 8d58056..9cafc68 100644
--- a/media/libstagefright/include/SoftwareRenderer.h
+++ b/media/libstagefright/include/SoftwareRenderer.h
@@ -19,25 +19,24 @@
#define SOFTWARE_RENDERER_H_
#include <media/stagefright/ColorConverter.h>
-#include <media/stagefright/VideoRenderer.h>
#include <utils/RefBase.h>
namespace android {
class Surface;
-class MemoryHeapBase;
-class SoftwareRenderer : public VideoRenderer {
+class SoftwareRenderer {
public:
SoftwareRenderer(
OMX_COLOR_FORMATTYPE colorFormat,
const sp<Surface> &surface,
size_t displayWidth, size_t displayHeight,
- size_t decodedWidth, size_t decodedHeight);
+ size_t decodedWidth, size_t decodedHeight,
+ int32_t rotationDegrees);
- virtual ~SoftwareRenderer();
+ ~SoftwareRenderer();
- virtual void render(
+ void render(
const void *data, size_t size, void *platformPrivate);
private:
diff --git a/media/libstagefright/matroska/MatroskaExtractor.cpp b/media/libstagefright/matroska/MatroskaExtractor.cpp
index d16476d..a40c0a3 100644
--- a/media/libstagefright/matroska/MatroskaExtractor.cpp
+++ b/media/libstagefright/matroska/MatroskaExtractor.cpp
@@ -22,13 +22,15 @@
#include "mkvparser.hpp"
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/hexdump.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/MediaBuffer.h>
-#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MetaData.h>
+#include <media/stagefright/Utils.h>
#include <utils/String8.h>
namespace android {
@@ -81,46 +83,6 @@
////////////////////////////////////////////////////////////////////////////////
-#include <ctype.h>
-static void hexdump(const void *_data, size_t size) {
- const uint8_t *data = (const uint8_t *)_data;
- size_t offset = 0;
- while (offset < size) {
- printf("0x%04x ", offset);
-
- size_t n = size - offset;
- if (n > 16) {
- n = 16;
- }
-
- for (size_t i = 0; i < 16; ++i) {
- if (i == 8) {
- printf(" ");
- }
-
- if (offset + i < size) {
- printf("%02x ", data[offset + i]);
- } else {
- printf(" ");
- }
- }
-
- printf(" ");
-
- for (size_t i = 0; i < n; ++i) {
- if (isprint(data[offset + i])) {
- printf("%c", data[offset + i]);
- } else {
- printf(".");
- }
- }
-
- printf("\n");
-
- offset += 16;
- }
-}
-
struct BlockIterator {
BlockIterator(mkvparser::Segment *segment, unsigned long trackNum);
@@ -167,6 +129,7 @@
size_t mTrackIndex;
Type mType;
BlockIterator mBlockIter;
+ size_t mNALSizeLen; // for type AVC
status_t advance();
@@ -180,13 +143,26 @@
mTrackIndex(index),
mType(OTHER),
mBlockIter(mExtractor->mSegment,
- mExtractor->mTracks.itemAt(index).mTrackNum) {
+ mExtractor->mTracks.itemAt(index).mTrackNum),
+ mNALSizeLen(0) {
+ sp<MetaData> meta = mExtractor->mTracks.itemAt(index).mMeta;
+
const char *mime;
- CHECK(mExtractor->mTracks.itemAt(index).mMeta->
- findCString(kKeyMIMEType, &mime));
+ CHECK(meta->findCString(kKeyMIMEType, &mime));
if (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)) {
mType = AVC;
+
+ uint32_t dummy;
+ const uint8_t *avcc;
+ size_t avccSize;
+ CHECK(meta->findData(
+ kKeyAVCC, &dummy, (const void **)&avcc, &avccSize));
+
+ CHECK_GE(avccSize, 5u);
+
+ mNALSizeLen = 1 + (avcc[4] & 3);
+ LOGV("mNALSizeLen = %d", mNALSizeLen);
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) {
mType = AAC;
}
@@ -276,6 +252,10 @@
////////////////////////////////////////////////////////////////////////////////
+static unsigned U24_AT(const uint8_t *ptr) {
+ return ptr[0] << 16 | ptr[1] << 8 | ptr[2];
+}
+
status_t MatroskaSource::read(
MediaBuffer **out, const ReadOptions *options) {
*out = NULL;
@@ -286,6 +266,7 @@
mBlockIter.seek(seekTimeUs);
}
+again:
if (mBlockIter.eos()) {
return ERROR_END_OF_STREAM;
}
@@ -294,38 +275,70 @@
size_t size = block->GetSize();
int64_t timeUs = mBlockIter.blockTimeUs();
- MediaBuffer *buffer = new MediaBuffer(size + 2);
+ // In the case of AVC content, each NAL unit is prefixed by
+ // mNALSizeLen bytes of length. We want to prefix the data with
+ // a four-byte 0x00000001 startcode instead of the length prefix.
+ // mNALSizeLen ranges from 1 through 4 bytes, so add an extra
+ // 3 bytes of padding to the buffer start.
+ static const size_t kPadding = 3;
+
+ MediaBuffer *buffer = new MediaBuffer(size + kPadding);
buffer->meta_data()->setInt64(kKeyTime, timeUs);
buffer->meta_data()->setInt32(kKeyIsSyncFrame, block->IsKey());
long res = block->Read(
- mExtractor->mReader, (unsigned char *)buffer->data() + 2);
+ mExtractor->mReader, (unsigned char *)buffer->data() + kPadding);
if (res != 0) {
return ERROR_END_OF_STREAM;
}
- buffer->set_range(2, size);
+ buffer->set_range(kPadding, size);
if (mType == AVC) {
- CHECK(size >= 2);
+ CHECK_GE(size, mNALSizeLen);
uint8_t *data = (uint8_t *)buffer->data();
- unsigned NALsize = data[2] << 8 | data[3];
- CHECK_EQ(size, NALsize + 2);
+ size_t NALsize;
+ switch (mNALSizeLen) {
+ case 1: NALsize = data[kPadding]; break;
+ case 2: NALsize = U16_AT(&data[kPadding]); break;
+ case 3: NALsize = U24_AT(&data[kPadding]); break;
+ case 4: NALsize = U32_AT(&data[kPadding]); break;
+ default:
+ TRESPASS();
+ }
- memcpy(data, "\x00\x00\x00\x01", 4);
- buffer->set_range(0, size + 2);
+ CHECK_GE(size, NALsize + mNALSizeLen);
+ if (size > NALsize + mNALSizeLen) {
+ LOGW("discarding %d bytes of data.", size - NALsize - mNALSizeLen);
+ }
+
+ // actual data starts at &data[kPadding + mNALSizeLen]
+
+ memcpy(&data[mNALSizeLen - 1], "\x00\x00\x00\x01", 4);
+ buffer->set_range(mNALSizeLen - 1, NALsize + 4);
} else if (mType == AAC) {
// There's strange junk at the beginning...
- const uint8_t *data = (const uint8_t *)buffer->data() + 2;
+ const uint8_t *data = (const uint8_t *)buffer->data() + kPadding;
+
+ // hexdump(data, size);
+
size_t offset = 0;
while (offset < size && data[offset] != 0x21) {
++offset;
}
- buffer->set_range(2 + offset, size - offset);
+
+ if (size == offset) {
+ buffer->release();
+
+ mBlockIter.advance();
+ goto again;
+ }
+
+ buffer->set_range(kPadding + offset, size - offset);
}
*out = buffer;
diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp
index f9f638f..4e9920b 100644
--- a/media/libstagefright/omx/OMX.cpp
+++ b/media/libstagefright/omx/OMX.cpp
@@ -24,14 +24,11 @@
#include <sys/resource.h>
#include "../include/OMX.h"
-#include "OMXRenderer.h"
#include "../include/OMXNodeInstance.h"
-#include "../include/SoftwareRenderer.h"
#include <binder/IMemory.h>
#include <media/stagefright/MediaDebug.h>
-#include <media/stagefright/VideoRenderer.h>
#include <utils/threads.h>
#include "OMXMaster.h"
@@ -442,110 +439,4 @@
mNodeIDToInstance.removeItem(node);
}
-////////////////////////////////////////////////////////////////////////////////
-
-struct SharedVideoRenderer : public VideoRenderer {
- SharedVideoRenderer(void *libHandle, VideoRenderer *obj)
- : mLibHandle(libHandle),
- mObj(obj) {
- }
-
- virtual ~SharedVideoRenderer() {
- delete mObj;
- mObj = NULL;
-
- dlclose(mLibHandle);
- mLibHandle = NULL;
- }
-
- virtual void render(
- const void *data, size_t size, void *platformPrivate) {
- return mObj->render(data, size, platformPrivate);
- }
-
-private:
- void *mLibHandle;
- VideoRenderer *mObj;
-
- SharedVideoRenderer(const SharedVideoRenderer &);
- SharedVideoRenderer &operator=(const SharedVideoRenderer &);
-};
-
-sp<IOMXRenderer> OMX::createRenderer(
- const sp<ISurface> &surface,
- const char *componentName,
- OMX_COLOR_FORMATTYPE colorFormat,
- size_t encodedWidth, size_t encodedHeight,
- size_t displayWidth, size_t displayHeight) {
- Mutex::Autolock autoLock(mLock);
-
- VideoRenderer *impl = NULL;
-
- void *libHandle = dlopen("libstagefrighthw.so", RTLD_NOW);
-
- if (libHandle) {
- typedef VideoRenderer *(*CreateRendererFunc)(
- const sp<ISurface> &surface,
- const char *componentName,
- OMX_COLOR_FORMATTYPE colorFormat,
- size_t displayWidth, size_t displayHeight,
- size_t decodedWidth, size_t decodedHeight);
-
- CreateRendererFunc func =
- (CreateRendererFunc)dlsym(
- libHandle,
- "_Z14createRendererRKN7android2spINS_8ISurfaceEEEPKc20"
- "OMX_COLOR_FORMATTYPEjjjj");
-
- if (func) {
- impl = (*func)(surface, componentName, colorFormat,
- displayWidth, displayHeight, encodedWidth, encodedHeight);
-
- if (impl) {
- impl = new SharedVideoRenderer(libHandle, impl);
- libHandle = NULL;
- }
- }
-
- if (libHandle) {
- dlclose(libHandle);
- libHandle = NULL;
- }
- }
-
- if (!impl) {
-#if 0
- LOGW("Using software renderer.");
- impl = new SoftwareRenderer(
- colorFormat,
- surface,
- displayWidth, displayHeight,
- encodedWidth, encodedHeight);
-#else
- CHECK(!"Should not be here.");
- return NULL;
-#endif
- }
-
- return new OMXRenderer(impl);
-}
-
-OMXRenderer::OMXRenderer(VideoRenderer *impl)
- : mImpl(impl) {
-}
-
-OMXRenderer::~OMXRenderer() {
- delete mImpl;
- mImpl = NULL;
-}
-
-void OMXRenderer::render(IOMX::buffer_id buffer) {
- OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *)buffer;
-
- mImpl->render(
- header->pBuffer + header->nOffset,
- header->nFilledLen,
- header->pPlatformPrivate);
-}
-
} // namespace android
diff --git a/media/libstagefright/omx/OMXRenderer.h b/media/libstagefright/omx/OMXRenderer.h
deleted file mode 100644
index 4d194ce..0000000
--- a/media/libstagefright/omx/OMXRenderer.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef OMX_RENDERER_H_
-
-#define OMX_RENDERER_H_
-
-#include <media/IOMX.h>
-
-namespace android {
-
-class VideoRenderer;
-
-class OMXRenderer : public BnOMXRenderer {
-public:
- // Assumes ownership of "impl".
- OMXRenderer(VideoRenderer *impl);
- virtual ~OMXRenderer();
-
- virtual void render(IOMX::buffer_id buffer);
-
-private:
- VideoRenderer *mImpl;
-
- OMXRenderer(const OMXRenderer &);
- OMXRenderer &operator=(const OMXRenderer &);
-};
-
-} // namespace android
-
-#endif // OMX_RENDERER_H_
diff --git a/media/tests/players/invoke_mock_media_player.cpp b/media/tests/players/invoke_mock_media_player.cpp
index 53308be..1e3731e 100644
--- a/media/tests/players/invoke_mock_media_player.cpp
+++ b/media/tests/players/invoke_mock_media_player.cpp
@@ -68,7 +68,6 @@
}
virtual status_t setDataSource(int fd, int64_t offset, int64_t length) {return OK;}
- virtual status_t setVideoISurface(const sp<ISurface>& surface) {return OK;}
virtual status_t setVideoSurface(const sp<Surface>& surface) {return OK;}
virtual status_t prepare() {return OK;}
virtual status_t prepareAsync() {return OK;}
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_quicksettings.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_quicksettings.png
new file mode 100644
index 0000000..4434b5c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_quicksettings.png
Binary files differ
diff --git a/packages/SystemUI/res/layout-xlarge/sysbar_panel_notification_peek.xml b/packages/SystemUI/res/layout-xlarge/sysbar_panel_notification_peek.xml
index a7c91f5..02f9a90 100644
--- a/packages/SystemUI/res/layout-xlarge/sysbar_panel_notification_peek.xml
+++ b/packages/SystemUI/res/layout-xlarge/sysbar_panel_notification_peek.xml
@@ -19,7 +19,7 @@
-->
<!-- android:background="@drawable/status_bar_closed_default_background" -->
-<com.android.systemui.statusbar.tablet.NotificationPanel
+<com.android.systemui.statusbar.tablet.NotificationPeekPanel
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
@@ -40,4 +40,4 @@
android:descendantFocusability="afterDescendants"
>
</FrameLayout>
-</com.android.systemui.statusbar.tablet.NotificationPanel>
+</com.android.systemui.statusbar.tablet.NotificationPeekPanel>
diff --git a/packages/SystemUI/res/layout-xlarge/sysbar_panel_notifications.xml b/packages/SystemUI/res/layout-xlarge/sysbar_panel_notifications.xml
index 6a8ae40..884a473 100644
--- a/packages/SystemUI/res/layout-xlarge/sysbar_panel_notifications.xml
+++ b/packages/SystemUI/res/layout-xlarge/sysbar_panel_notifications.xml
@@ -44,13 +44,27 @@
android:gravity="right"
/>
- <Button
+ <ImageView
android:id="@+id/settings_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/date"
android:layout_alignParentRight="true"
- android:text="@string/system_panel_settings_button"
+ android:paddingRight="10dp"
+ android:src="@drawable/ic_sysbar_quicksettings"
+ android:baseline="17dp"
+ />
+
+ <ImageView
+ android:id="@+id/notification_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBaseline="@id/settings_button"
+ android:layout_alignParentRight="true"
+ android:paddingRight="10dp"
+ android:visibility="invisible"
+ android:src="@drawable/status_bar_veto"
+ android:baseline="17dp"
/>
<ImageView
@@ -93,6 +107,13 @@
android:text="@string/system_panel_settings_button"
/>
+ <FrameLayout
+ android:id="@+id/settings_frame"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_below="@id/settings_button"
+ />
+
<ScrollView
android:id="@+id/notificationScroller"
android:layout_height="wrap_content"
diff --git a/packages/SystemUI/res/layout-xlarge/sysbar_panel_settings.xml b/packages/SystemUI/res/layout-xlarge/sysbar_panel_settings.xml
new file mode 100644
index 0000000..c6ddfed
--- /dev/null
+++ b/packages/SystemUI/res/layout-xlarge/sysbar_panel_settings.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<com.android.systemui.statusbar.tablet.SettingsPanel
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="200dip"
+ >
+</com.android.systemui.statusbar.tablet.SettingsPanel>
+
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
index 127d1b1..aed3dc7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
@@ -100,18 +100,20 @@
if (mSending) {
x = (int)ev.getX();
y = (int)ev.getY();
- if (x < 0 || x >= getWidth() || y < 0 || y >= getHeight()) {
- mSending = false;
- sendEvent(KeyEvent.ACTION_UP,
- KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY
- | KeyEvent.FLAG_CANCELED);
- setPressed(false);
- removeCallbacks(mCheckLongPress);
- }
+ setPressed(x >= 0 && x < getWidth() && y >= 0 && y < getHeight());
+ }
+ break;
+ case MotionEvent.ACTION_CANCEL:
+ setPressed(false);
+ if (mSending && !mLongPressed) {
+ mSending = false;
+ sendEvent(KeyEvent.ACTION_UP,
+ KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY
+ | KeyEvent.FLAG_CANCELED);
+ removeCallbacks(mCheckLongPress);
}
break;
case MotionEvent.ACTION_UP:
- case MotionEvent.ACTION_CANCEL:
setPressed(false);
if (mSending && !mLongPressed) {
mSending = false;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index f1b76f6..4ff2429 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -321,7 +321,9 @@
mPhoneSignalIconId = R.drawable.stat_sys_signal_null;
}
} else {
- if (isCdma()) {
+ if (mSignalStrength == null) {
+ mPhoneSignalIconId = R.drawable.stat_sys_signal_null;
+ } else if (isCdma()) {
// If 3G(EV) and 1x network are available than 3G should be
// displayed, displayed RSSI should be from the EV side.
// If a voice call is made then RSSI should switch to 1x.
@@ -497,7 +499,8 @@
if (mWifiConnected && !wasConnected) {
WifiInfo info = mWifiManager.getConnectionInfo();
if (info != null) {
- mWifiLevel = WifiManager.calculateSignalLevel(info.getRssi(), 101);
+ mWifiLevel = WifiManager.calculateSignalLevel(info.getRssi(),
+ WifiIcons.WIFI_LEVEL_COUNT);
mWifiSsid = huntForSsid(info);
} else {
mWifiLevel = 0;
@@ -511,7 +514,7 @@
} else if (action.equals(WifiManager.RSSI_CHANGED_ACTION)) {
if (mWifiConnected) {
final int newRssi = intent.getIntExtra(WifiManager.EXTRA_NEW_RSSI, -200);
- mWifiLevel = WifiManager.calculateSignalLevel(newRssi, 101);
+ mWifiLevel = WifiManager.calculateSignalLevel(newRssi, WifiIcons.WIFI_LEVEL_COUNT);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiIcons.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiIcons.java
index d218ebf..0787289 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiIcons.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiIcons.java
@@ -29,4 +29,6 @@
R.drawable.stat_sys_wifi_signal_3_fully,
R.drawable.stat_sys_wifi_signal_4_fully }
};
+
+ static final int WIFI_LEVEL_COUNT = WIFI_SIGNAL_STRENGTH[0].length;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
index 1a08f22..ce81fdc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
@@ -18,13 +18,25 @@
import android.content.Context;
import android.util.AttributeSet;
+import android.util.Slog;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
+import android.view.View;
+import android.widget.FrameLayout;
import com.android.systemui.R;
-public class NotificationPanel extends RelativeLayout implements StatusBarPanel {
+public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
+ View.OnClickListener {
+ static final String TAG = "NotificationPanel";
+
+ View mSettingsButton;
+ View mNotificationButton;
+ View mNotificationScroller;
+ FrameLayout mSettingsFrame;
+ View mSettingsPanel;
+
public NotificationPanel(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@@ -33,6 +45,51 @@
super(context, attrs, defStyle);
}
+ @Override
+ public void onFinishInflate() {
+ super.onFinishInflate();
+
+ mSettingsButton = (ImageView)findViewById(R.id.settings_button);
+ mSettingsButton.setOnClickListener(this);
+ mNotificationButton = (ImageView)findViewById(R.id.notification_button);
+ mNotificationButton.setOnClickListener(this);
+
+ mNotificationScroller = findViewById(R.id.notificationScroller);
+ mSettingsFrame = (FrameLayout)findViewById(R.id.settings_frame);
+ }
+
+ @Override
+ public void onVisibilityChanged(View v, int vis) {
+ super.onVisibilityChanged(v, vis);
+ // when we hide, put back the notifications
+ if (!isShown()) {
+ switchToNotificationMode();
+ }
+ }
+
+ public void onClick(View v) {
+ if (v == mSettingsButton) {
+ switchToSettingsMode();
+ } else if (v == mNotificationButton) {
+ switchToNotificationMode();
+ }
+ }
+
+ public void switchToSettingsMode() {
+ removeSettingsPanel();
+ addSettingsPanel();
+ mSettingsButton.setVisibility(View.INVISIBLE);
+ mNotificationScroller.setVisibility(View.GONE);
+ mNotificationButton.setVisibility(View.VISIBLE);
+ }
+
+ public void switchToNotificationMode() {
+ removeSettingsPanel();
+ mSettingsButton.setVisibility(View.VISIBLE);
+ mNotificationScroller.setVisibility(View.VISIBLE);
+ mNotificationButton.setVisibility(View.INVISIBLE);
+ }
+
public boolean isInContentArea(int x, int y) {
final int l = getPaddingLeft();
final int r = getWidth() - getPaddingRight();
@@ -40,5 +97,16 @@
final int b = getHeight() - getPaddingBottom();
return x >= l && x < r && y >= t && y < b;
}
+
+ void removeSettingsPanel() {
+ if (mSettingsPanel != null) {
+ mSettingsFrame.removeViewAt(0);
+ mSettingsPanel = null;
+ }
+ }
+
+ void addSettingsPanel() {
+ mSettingsPanel = View.inflate(getContext(), R.layout.sysbar_panel_settings, mSettingsFrame);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPeekPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPeekPanel.java
new file mode 100644
index 0000000..744f667
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPeekPanel.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.tablet;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.RelativeLayout;
+
+import com.android.systemui.R;
+
+public class NotificationPeekPanel extends RelativeLayout implements StatusBarPanel {
+ public NotificationPeekPanel(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public NotificationPeekPanel(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ public boolean isInContentArea(int x, int y) {
+ final int l = getPaddingLeft();
+ final int r = getWidth() - getPaddingRight();
+ final int t = getPaddingTop();
+ final int b = getHeight() - getPaddingBottom();
+ return x >= l && x < r && y >= t && y < b;
+ }
+
+}
+
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsPanel.java
new file mode 100644
index 0000000..9013f5c
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsPanel.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.tablet;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.util.Slog;
+import android.widget.LinearLayout;
+import android.view.View;
+
+import com.android.systemui.R;
+
+public class SettingsPanel extends LinearLayout {
+ static final String TAG = "SettingsPanel";
+
+ public SettingsPanel(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public SettingsPanel(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+}
+
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index 2efdf96..983215e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -99,7 +99,7 @@
InputMethodButton mInputMethodButton;
NotificationPanel mNotificationPanel;
- NotificationPanel mNotificationPeekWindow;
+ NotificationPeekPanel mNotificationPeekWindow;
ViewGroup mNotificationPeekRow;
int mNotificationPeekIndex;
LayoutTransition mNotificationPeekScrubLeft, mNotificationPeekScrubRight;
@@ -166,7 +166,7 @@
WindowManagerImpl.getDefault().addView(mNotificationPanel, lp);
// Notification preview window
- mNotificationPeekWindow = (NotificationPanel) View.inflate(context,
+ mNotificationPeekWindow = (NotificationPeekPanel) View.inflate(context,
R.layout.sysbar_panel_notification_peek, null);
mNotificationPeekRow = (ViewGroup) mNotificationPeekWindow.findViewById(R.id.content);
mNotificationPeekWindow.setVisibility(View.GONE);
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index e99b74f..18815f5 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -411,6 +411,8 @@
public final void openPanel(int featureId, KeyEvent event) {
if (featureId == FEATURE_OPTIONS_PANEL && mActionBar != null &&
mActionBar.isOverflowReserved()) {
+ // Invalidate the options menu, we want a prepare event that the app can respond to.
+ invalidatePanelMenu(FEATURE_OPTIONS_PANEL);
mActionBar.showOverflowMenu();
} else {
openPanel(getPanelState(featureId, true), event);
@@ -1830,7 +1832,12 @@
}
final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback);
- ActionMode mode = getCallback().onStartActionMode(wrappedCallback);
+ ActionMode mode = null;
+ try {
+ mode = getCallback().onWindowStartingActionMode(wrappedCallback);
+ } catch (AbstractMethodError ame) {
+ // Older apps might not implement this callback method.
+ }
if (mode != null) {
mActionMode = mode;
} else {
@@ -1874,6 +1881,13 @@
}
}
}
+ if (mActionMode != null) {
+ try {
+ getCallback().onActionModeStarted(mActionMode);
+ } catch (AbstractMethodError ame) {
+ // Older apps might not implement this callback method.
+ }
+ }
return mActionMode;
}
@@ -2089,6 +2103,11 @@
if (mActionModeView != null) {
mActionModeView.removeAllViews();
}
+ try {
+ getCallback().onActionModeFinished(mActionMode);
+ } catch (AbstractMethodError ame) {
+ // Older apps might not implement this callback method.
+ }
mActionMode = null;
}
}
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 7d58e41..8c857da 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -117,7 +117,6 @@
import android.media.IAudioService;
import android.media.AudioManager;
-import java.io.File;
import java.util.ArrayList;
/**
@@ -2306,12 +2305,8 @@
return getCurrentPortraitRotation(lastRotation);
}
- if (new File("/system/etc/allow_all_orientations").exists()) {
- mOrientationListener.setAllow180Rotation(true);
- } else {
- mOrientationListener.setAllow180Rotation(
- orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
- }
+ mOrientationListener.setAllow180Rotation(
+ orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
// case for nosensor meaning ignore sensor and consider only lid
// or orientation sensor disabled
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index cd58284..a0a1974 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -7327,16 +7327,22 @@
pw.println(" ");
pw.println("Package warning messages:");
File fname = getSettingsProblemFile();
- FileInputStream in;
+ FileInputStream in = null;
try {
in = new FileInputStream(fname);
int avail = in.available();
byte[] data = new byte[avail];
in.read(data);
pw.print(new String(data));
- in.close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ }
+ }
}
}
}
diff --git a/services/java/com/android/server/ProcessStats.java b/services/java/com/android/server/ProcessStats.java
index 43dbcc0..1a12a84 100644
--- a/services/java/com/android/server/ProcessStats.java
+++ b/services/java/com/android/server/ProcessStats.java
@@ -799,8 +799,9 @@
}
private String readFile(String file, char endChar) {
+ FileInputStream is = null;
try {
- FileInputStream is = new FileInputStream(file);
+ is = new FileInputStream(file);
int len = is.read(mBuffer);
is.close();
@@ -815,6 +816,13 @@
}
} catch (java.io.FileNotFoundException e) {
} catch (java.io.IOException e) {
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (java.io.IOException e) {
+ }
+ }
}
return null;
}
@@ -841,4 +849,3 @@
}
}
}
-
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index b5e73ac..22a45df 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -464,6 +464,7 @@
}
bool SensorService::SensorEventConnection::addSensor(int32_t handle) {
+ Mutex::Autolock _l(mConnectionLock);
if (mSensorInfo.indexOfKey(handle) <= 0) {
SensorInfo info;
mSensorInfo.add(handle, info);
@@ -473,6 +474,7 @@
}
bool SensorService::SensorEventConnection::removeSensor(int32_t handle) {
+ Mutex::Autolock _l(mConnectionLock);
if (mSensorInfo.removeItem(handle) >= 0) {
return true;
}
@@ -480,16 +482,19 @@
}
bool SensorService::SensorEventConnection::hasSensor(int32_t handle) const {
+ Mutex::Autolock _l(mConnectionLock);
return mSensorInfo.indexOfKey(handle) >= 0;
}
bool SensorService::SensorEventConnection::hasAnySensor() const {
+ Mutex::Autolock _l(mConnectionLock);
return mSensorInfo.size() ? true : false;
}
status_t SensorService::SensorEventConnection::setEventRateLocked(
int handle, nsecs_t ns)
{
+ Mutex::Autolock _l(mConnectionLock);
ssize_t index = mSensorInfo.indexOfKey(handle);
if (index >= 0) {
SensorInfo& info = mSensorInfo.editValueFor(handle);
@@ -506,6 +511,7 @@
// filter out events not for this connection
size_t count = 0;
if (scratch) {
+ Mutex::Autolock _l(mConnectionLock);
size_t i=0;
while (i<numEvents) {
const int32_t curr = buffer[i].sensor;
diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h
index b442779..c0922f5 100644
--- a/services/sensorservice/SensorService.h
+++ b/services/sensorservice/SensorService.h
@@ -75,8 +75,9 @@
sp<SensorService> const mService;
sp<SensorChannel> const mChannel;
+ mutable Mutex mConnectionLock;
- // protected by SensorService::mLock
+ // protected mConnectionLock
struct SensorInfo {
SensorInfo() : ns(DEFAULT_EVENTS_PERIOD) { }
nsecs_t ns;
diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java
index 35a2c19..290f2c1 100644
--- a/telephony/java/android/telephony/ServiceState.java
+++ b/telephony/java/android/telephony/ServiceState.java
@@ -438,9 +438,9 @@
+ " " + (mCssIndicator ? "CSS supported" : "CSS not supported")
+ " " + mNetworkId
+ " " + mSystemId
- + "RoamInd: " + mCdmaRoamingIndicator
- + "DefRoamInd: " + mCdmaDefaultRoamingIndicator
- + "EmergOnly: " + mIsEmergencyOnly);
+ + " RoamInd=" + mCdmaRoamingIndicator
+ + " DefRoamInd=" + mCdmaDefaultRoamingIndicator
+ + " EmergOnly=" + mIsEmergencyOnly);
}
public void setStateOutOfService() {
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
index 7c652c5..d7ff0c5 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
@@ -240,8 +240,8 @@
mCdmaPhone.mRuimRecords.getRecordsLoaded())) {
reason += " - radioState= " + mPhone.mCM.getRadioState() + " - RUIM not loaded";
}
- if (mPhone.getState() != Phone.State.IDLE &&
- mCdmaPhone.mSST.isConcurrentVoiceAndData()) {
+ if (!(mCdmaPhone.mSST.isConcurrentVoiceAndData() ||
+ mPhone.getState() == Phone.State.IDLE)) {
reason += " - concurrentVoiceAndData not allowed and state= " + mPhone.getState();
}
if (roaming) reason += " - Roaming";
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
index 2aca9ad..effb743 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
@@ -328,8 +328,8 @@
reason += " - PhoneState= " + mPhone.getState();
}
if (!mMasterDataEnabled) reason += " - mMasterDataEnabled= false";
- if (mPhone.getServiceState().getRoaming() && getDataOnRoamingEnabled()) {
- reason += " - Roaming";
+ if (mPhone.getServiceState().getRoaming() && !getDataOnRoamingEnabled()) {
+ reason += " - Roaming and data roaming not enabled";
}
if (mIsPsRestricted) reason += " - mIsPsRestricted= true";
if (!desiredPowerState) reason += " - desiredPowerState= false";
@@ -1037,8 +1037,15 @@
} else {
GsmDataConnection.FailCause cause;
cause = (GsmDataConnection.FailCause) (ar.result);
- if(DBG) log("PDP setup failed " + cause);
- // Log this failure to the Event Logs.
+ if (DBG) {
+ String apnString;
+ try {
+ apnString = mWaitingApns.get(0).apn;
+ } catch (Exception e) {
+ apnString = "<unknown>";
+ }
+ log(String.format("onDataSetupComplete: error apn=%s cause=%s", apnString, cause));
+ }
if (cause.isEventLoggable()) {
GsmCellLocation loc = ((GsmCellLocation)mPhone.getCellLocation());
EventLog.writeEvent(EventLogTags.PDP_SETUP_FAIL,