Merge "A/V synchronization at the beginning of a recording session"
diff --git a/api/current.xml b/api/current.xml
index 9a38459..553676c 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -25064,6 +25064,17 @@
<parameter name="packageName" type="java.lang.String">
</parameter>
</method>
+<field name="MOVE_TASK_NO_USER_ACTION"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="MOVE_TASK_WITH_HOME"
type="int"
transient="false"
@@ -25495,6 +25506,16 @@
visibility="public"
>
</field>
+<field name="persistentId"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
</class>
<class name="ActivityManager.RunningAppProcessInfo"
extends="java.lang.Object"
@@ -30692,6 +30713,19 @@
<parameter name="visibleCrumbs" type="int">
</parameter>
</method>
+<method name="setOnBreadCrumbClickListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="listener" type="android.app.FragmentBreadCrumbs.OnBreadCrumbClickListener">
+</parameter>
+</method>
<method name="setParentTitle"
return="void"
abstract="false"
@@ -30725,6 +30759,29 @@
</parameter>
</method>
</class>
+<interface name="FragmentBreadCrumbs.OnBreadCrumbClickListener"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="onBreadCrumbClick"
+ return="boolean"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="backStack" type="android.app.FragmentManager.BackStackEntry">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+</interface>
<class name="FragmentManager"
extends="java.lang.Object"
abstract="true"
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index d76b67d..a660076 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -112,6 +112,11 @@
public int id;
/**
+ * The true identifier of this task, valid even if it is not running.
+ */
+ public int persistentId;
+
+ /**
* The original Intent used to launch the task. You can use this
* Intent to re-launch the task (if it is no longer running) or bring
* the current task to the front.
@@ -127,14 +132,6 @@
public ComponentName origActivity;
/**
- * Thumbnail representation of the task's last state. Must
- * use {@link ActivityManager#TASKS_GET_THUMBNAILS} to have this set.
- * @hide -- this is not scalable, need to have a separate API to get
- * the bitmap.
- */
- public Bitmap thumbnail;
-
- /**
* Description of the task's last state.
*/
public CharSequence description;
@@ -148,6 +145,7 @@
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
+ dest.writeInt(persistentId);
if (baseIntent != null) {
dest.writeInt(1);
baseIntent.writeToParcel(dest, 0);
@@ -155,29 +153,19 @@
dest.writeInt(0);
}
ComponentName.writeToParcel(origActivity, dest);
- if (thumbnail != null) {
- dest.writeInt(1);
- thumbnail.writeToParcel(dest, 0);
- } else {
- dest.writeInt(0);
- }
TextUtils.writeToParcel(description, dest,
Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
}
public void readFromParcel(Parcel source) {
id = source.readInt();
+ persistentId = source.readInt();
if (source.readInt() != 0) {
baseIntent = Intent.CREATOR.createFromParcel(source);
} else {
baseIntent = null;
}
origActivity = ComponentName.readFromParcel(source);
- if (source.readInt() != 0) {
- thumbnail = Bitmap.CREATOR.createFromParcel(source);
- } else {
- thumbnail = null;
- }
description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
}
@@ -401,6 +389,16 @@
return getRunningTasks(maxNum, 0, null);
}
+ /** @hide */
+ public Bitmap getTaskThumbnail(int id) throws SecurityException {
+ try {
+ return ActivityManagerNative.getDefault().getTaskThumbnail(id);
+ } catch (RemoteException e) {
+ // System dead, we will be dead too soon!
+ return null;
+ }
+ }
+
/**
* Flag for {@link #moveTaskToFront(int, int)}: also move the "home"
* activity along with the task, so it is positioned immediately behind
@@ -409,6 +407,13 @@
public static final int MOVE_TASK_WITH_HOME = 0x00000001;
/**
+ * Flag for {@link #moveTaskToFront(int, int)}: don't count this as a
+ * user-instigated action, so the current activity will not receive a
+ * hint that the user is leaving.
+ */
+ public static final int MOVE_TASK_NO_USER_ACTION = 0x00000002;
+
+ /**
* Ask that the task associated with a given task ID be moved to the
* front of the stack, so it is now visible to the user. Requires that
* the caller hold permission {@link android.Manifest.permission#REORDER_TASKS}
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index c095c06..d3d3792 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -442,6 +442,20 @@
return true;
}
+ case GET_TASK_THUMBNAIL_TRANSACTION: {
+ data.enforceInterface(IActivityManager.descriptor);
+ int id = data.readInt();
+ Bitmap bm = getTaskThumbnail(id);
+ reply.writeNoException();
+ if (bm != null) {
+ reply.writeInt(1);
+ bm.writeToParcel(reply, 0);
+ } else {
+ reply.writeInt(0);
+ }
+ return true;
+ }
+
case GET_SERVICES_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
int maxNum = data.readInt();
@@ -1816,6 +1830,21 @@
reply.recycle();
return list;
}
+ public Bitmap getTaskThumbnail(int id) throws RemoteException {
+ Parcel data = Parcel.obtain();
+ Parcel reply = Parcel.obtain();
+ data.writeInterfaceToken(IActivityManager.descriptor);
+ data.writeInt(id);
+ mRemote.transact(GET_TASK_THUMBNAIL_TRANSACTION, data, reply, 0);
+ reply.readException();
+ Bitmap bm = null;
+ if (reply.readInt() != 0) {
+ bm = Bitmap.CREATOR.createFromParcel(reply);
+ }
+ data.recycle();
+ reply.recycle();
+ return bm;
+ }
public List getServices(int maxNum, int flags) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
diff --git a/core/java/android/app/FragmentBreadCrumbs.java b/core/java/android/app/FragmentBreadCrumbs.java
index 3f045ac..df64035 100644
--- a/core/java/android/app/FragmentBreadCrumbs.java
+++ b/core/java/android/app/FragmentBreadCrumbs.java
@@ -50,6 +50,26 @@
/** Listener to inform when a parent entry is clicked */
private OnClickListener mParentClickListener;
+ private OnBreadCrumbClickListener mOnBreadCrumbClickListener;
+
+ /**
+ * Interface to intercept clicks on the bread crumbs.
+ */
+ public interface OnBreadCrumbClickListener {
+ /**
+ * Called when a bread crumb is clicked.
+ *
+ * @param backStack The BackStackEntry whose bread crumb was clicked.
+ * May be null, if this bread crumb is for the root of the back stack.
+ * @param flags Additional information about the entry. Currently
+ * always 0.
+ *
+ * @return Return true to consume this click. Return to false to allow
+ * the default action (popping back stack to this entry) to occur.
+ */
+ public boolean onBreadCrumbClick(BackStackEntry backStack, int flags);
+ }
+
public FragmentBreadCrumbs(Context context) {
this(context, null);
}
@@ -107,6 +127,16 @@
updateCrumbs();
}
+ /**
+ * Sets a listener for clicks on the bread crumbs. This will be called before
+ * the default click action is performed.
+ *
+ * @param listener The new listener to set. Replaces any existing listener.
+ */
+ public void setOnBreadCrumbClickListener(OnBreadCrumbClickListener listener) {
+ mOnBreadCrumbClickListener = listener;
+ }
+
private BackStackRecord createBackStackEntry(CharSequence title, CharSequence shortTitle) {
if (title == null) return null;
@@ -266,8 +296,18 @@
mParentClickListener.onClick(v);
}
} else {
- mActivity.getFragmentManager().popBackStack(bse.getId(),
- bse == mTopEntry? FragmentManager.POP_BACK_STACK_INCLUSIVE : 0);
+ if (mOnBreadCrumbClickListener != null) {
+ if (mOnBreadCrumbClickListener.onBreadCrumbClick(
+ bse == mTopEntry ? null : bse, 0)) {
+ return;
+ }
+ }
+ if (bse == mTopEntry) {
+ // Pop everything off the back stack.
+ mActivity.getFragmentManager().popBackStack();
+ } else {
+ mActivity.getFragmentManager().popBackStack(bse.getId(), 0);
+ }
}
}
}
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 5d4380b..f42e8fb 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -133,6 +133,7 @@
IThumbnailReceiver receiver) throws RemoteException;
public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
int flags) throws RemoteException;
+ public Bitmap getTaskThumbnail(int taskId) throws RemoteException;
public List getServices(int maxNum, int flags) throws RemoteException;
public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
throws RemoteException;
@@ -514,7 +515,7 @@
int FORCE_STOP_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+78;
int KILL_PIDS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+79;
int GET_SERVICES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+80;
-
+ int GET_TASK_THUMBNAIL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+81;
int GET_RUNNING_APP_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+82;
int GET_DEVICE_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+83;
int PEEK_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+84;
diff --git a/core/java/android/app/backup/WallpaperBackupHelper.java b/core/java/android/app/backup/WallpaperBackupHelper.java
index 9808200..d70b3d3 100644
--- a/core/java/android/app/backup/WallpaperBackupHelper.java
+++ b/core/java/android/app/backup/WallpaperBackupHelper.java
@@ -32,7 +32,7 @@
*/
public class WallpaperBackupHelper extends FileBackupHelperBase implements BackupHelper {
private static final String TAG = "WallpaperBackupHelper";
- private static final boolean DEBUG = false;
+ private static final boolean DEBUG = true;
// This path must match what the WallpaperManagerService uses
private static final String WALLPAPER_IMAGE = "/data/data/com.android.settings/files/wallpaper";
@@ -64,6 +64,10 @@
wpm = (WallpaperManager) context.getSystemService(Context.WALLPAPER_SERVICE);
mDesiredMinWidth = (double) wpm.getDesiredMinimumWidth();
mDesiredMinHeight = (double) wpm.getDesiredMinimumHeight();
+
+ if (DEBUG) {
+ Slog.d(TAG, "dmW=" + mDesiredMinWidth + " dmH=" + mDesiredMinHeight);
+ }
}
/**
@@ -94,7 +98,7 @@
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(STAGE_FILE, options);
- if (DEBUG) Slog.v(TAG, "Restoring wallpaper image w=" + options.outWidth
+ if (DEBUG) Slog.d(TAG, "Restoring wallpaper image w=" + options.outWidth
+ " h=" + options.outHeight);
// how much does the image differ from our preference?
@@ -103,13 +107,13 @@
if (widthRatio > 0.8 && widthRatio < 1.25
&& heightRatio > 0.8 && heightRatio < 1.25) {
// sufficiently close to our resolution; go ahead and use it
- if (DEBUG) Slog.v(TAG, "wallpaper dimension match; using");
+ if (DEBUG) Slog.d(TAG, "wallpaper dimension match; using");
f.renameTo(new File(WALLPAPER_IMAGE));
// TODO: spin a service to copy the restored image to sd/usb storage,
// since it does not exist anywhere other than the private wallpaper
// file.
} else {
- if (DEBUG) Slog.v(TAG, "dimensions too far off: wr=" + widthRatio
+ if (DEBUG) Slog.d(TAG, "dimensions too far off: wr=" + widthRatio
+ " hr=" + heightRatio);
f.delete();
}
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java
index 891a5d9..2e43eef 100644
--- a/core/java/android/database/sqlite/SQLiteDatabase.java
+++ b/core/java/android/database/sqlite/SQLiteDatabase.java
@@ -2354,39 +2354,37 @@
* @return true if write-ahead-logging is set. false otherwise
*/
public boolean enableWriteAheadLogging() {
- // turn off WAL until lockingprotocolerror bug and diskIO bug are fixed
- return false;
-// // make sure the database is not READONLY. WAL doesn't make sense for readonly-databases.
-// if (isReadOnly()) {
-// return false;
-// }
-// // acquire lock - no that no other thread is enabling WAL at the same time
-// lock();
-// try {
-// if (mConnectionPool != null) {
-// // already enabled
-// return true;
-// }
-// if (mPath.equalsIgnoreCase(MEMORY_DB_PATH)) {
-// Log.i(TAG, "can't enable WAL for memory databases.");
-// return false;
-// }
-//
-// // make sure this database has NO attached databases because sqlite's write-ahead-logging
-// // doesn't work for databases with attached databases
-// if (mHasAttachedDbs) {
-// if (Log.isLoggable(TAG, Log.DEBUG)) {
-// Log.d(TAG,
-// "this database: " + mPath + " has attached databases. can't enable WAL.");
-// }
-// return false;
-// }
-// mConnectionPool = new DatabaseConnectionPool(this);
-// setJournalMode(mPath, "WAL");
-// return true;
-// } finally {
-// unlock();
-// }
+ // make sure the database is not READONLY. WAL doesn't make sense for readonly-databases.
+ if (isReadOnly()) {
+ return false;
+ }
+ // acquire lock - no that no other thread is enabling WAL at the same time
+ lock();
+ try {
+ if (mConnectionPool != null) {
+ // already enabled
+ return true;
+ }
+ if (mPath.equalsIgnoreCase(MEMORY_DB_PATH)) {
+ Log.i(TAG, "can't enable WAL for memory databases.");
+ return false;
+ }
+
+ // make sure this database has NO attached databases because sqlite's write-ahead-logging
+ // doesn't work for databases with attached databases
+ if (mHasAttachedDbs) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG,
+ "this database: " + mPath + " has attached databases. can't enable WAL.");
+ }
+ return false;
+ }
+ mConnectionPool = new DatabaseConnectionPool(this);
+ setJournalMode(mPath, "WAL");
+ return true;
+ } finally {
+ unlock();
+ }
}
/**
@@ -2394,20 +2392,19 @@
* @hide
*/
public void disableWriteAheadLogging() {
- return;
-// // grab database lock so that writeAheadLogging is not disabled from 2 different threads
-// // at the same time
-// lock();
-// try {
-// if (mConnectionPool == null) {
-// return; // already disabled
-// }
-// mConnectionPool.close();
-// setJournalMode(mPath, "TRUNCATE");
-// mConnectionPool = null;
-// } finally {
-// unlock();
-// }
+ // grab database lock so that writeAheadLogging is not disabled from 2 different threads
+ // at the same time
+ lock();
+ try {
+ if (mConnectionPool == null) {
+ return; // already disabled
+ }
+ mConnectionPool.close();
+ setJournalMode(mPath, "TRUNCATE");
+ mConnectionPool = null;
+ } finally {
+ unlock();
+ }
}
/* package */ SQLiteDatabase getDatabaseHandle(String sql) {
diff --git a/core/java/android/net/TrafficStats.java b/core/java/android/net/TrafficStats.java
index d143243..eca06c5 100644
--- a/core/java/android/net/TrafficStats.java
+++ b/core/java/android/net/TrafficStats.java
@@ -69,6 +69,43 @@
public static native long getMobileRxBytes();
/**
+ * Get the total number of packets transmitted through the specified interface.
+ *
+ * @return number of packets. If the statistics are not supported by this interface,
+ * {@link #UNSUPPORTED} will be returned.
+ * @hide
+ */
+ public static native long getTxPackets(String iface);
+
+ /**
+ * Get the total number of packets received through the specified interface.
+ *
+ * @return number of packets. If the statistics are not supported by this interface,
+ * {@link #UNSUPPORTED} will be returned.
+ * @hide
+ */
+ public static native long getRxPackets(String iface);
+
+ /**
+ * Get the total number of bytes transmitted through the specified interface.
+ *
+ * @return number of bytes. If the statistics are not supported by this interface,
+ * {@link #UNSUPPORTED} will be returned.
+ * @hide
+ */
+ public static native long getTxBytes(String iface);
+
+ /**
+ * Get the total number of bytes received through the specified interface.
+ *
+ * @return number of bytes. If the statistics are not supported by this interface,
+ * {@link #UNSUPPORTED} will be returned.
+ * @hide
+ */
+ public static native long getRxBytes(String iface);
+
+
+ /**
* Get the total number of packets sent through all network interfaces.
*
* @return the number of packets. If the statistics are not supported by this device,
diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java
index 53932af..4b858d0 100644
--- a/core/java/android/widget/PopupWindow.java
+++ b/core/java/android/widget/PopupWindow.java
@@ -1056,16 +1056,17 @@
anchor.getWindowVisibleDisplayFrame(displayFrame);
final View root = anchor.getRootView();
- if (mAllowScrollingAnchorParent && (p.y + mPopupHeight > displayFrame.bottom ||
- p.x + mPopupWidth - root.getWidth() > 0)) {
+ if (p.y + mPopupHeight > displayFrame.bottom || p.x + mPopupWidth - root.getWidth() > 0) {
// if the drop down disappears at the bottom of the screen. we try to
// scroll a parent scrollview or move the drop down back up on top of
// the edit box
- int scrollX = anchor.getScrollX();
- int scrollY = anchor.getScrollY();
- Rect r = new Rect(scrollX, scrollY, scrollX + mPopupWidth + xoff,
- scrollY + mPopupHeight + anchor.getHeight() + yoff);
- anchor.requestRectangleOnScreen(r, true);
+ if (mAllowScrollingAnchorParent) {
+ int scrollX = anchor.getScrollX();
+ int scrollY = anchor.getScrollY();
+ Rect r = new Rect(scrollX, scrollY, scrollX + mPopupWidth + xoff,
+ scrollY + mPopupHeight + anchor.getHeight() + yoff);
+ anchor.requestRectangleOnScreen(r, true);
+ }
// now we re-evaluate the space available, and decide from that
// whether the pop-up will go above or below the anchor.
diff --git a/core/jni/android_net_TrafficStats.cpp b/core/jni/android_net_TrafficStats.cpp
index dfa36ce..0c84f11 100644
--- a/core/jni/android_net_TrafficStats.cpp
+++ b/core/jni/android_net_TrafficStats.cpp
@@ -130,6 +130,33 @@
"/sys/class/net/ppp0/statistics/rx_bytes");
}
+static jlong getData(JNIEnv* env, char *what, jstring interface) {
+ char filename[80];
+ jboolean isCopy;
+
+ const char *interfaceStr = env->GetStringUTFChars(interface, &isCopy);
+ snprintf(filename, sizeof(filename), "/sys/class/net/%s/statistics/%s", interfaceStr, what);
+
+ return readNumber(filename);
+}
+
+static jlong getTxPackets(JNIEnv* env, jobject clazz, jstring interface) {
+ return getData(env, "tx_packets", interface);
+}
+
+static jlong getRxPackets(JNIEnv* env, jobject clazz, jstring interface) {
+ return getData(env, "rx_packets", interface);
+}
+
+static jlong getTxBytes(JNIEnv* env, jobject clazz, jstring interface) {
+ return getData(env, "tx_bytes", interface);
+}
+
+static jlong getRxBytes(JNIEnv* env, jobject clazz, jstring interface) {
+ return getData(env, "rx_bytes", interface);
+}
+
+
// Total stats are read less often, so we're willing to put up
// with listing the directory and concatenating filenames.
@@ -288,6 +315,10 @@
{"getMobileRxPackets", "()J", (void*) getMobileRxPackets},
{"getMobileTxBytes", "()J", (void*) getMobileTxBytes},
{"getMobileRxBytes", "()J", (void*) getMobileRxBytes},
+ {"getTxPackets", "(Ljava/lang/String;)J", (void*) getTxPackets},
+ {"getRxPackets", "(Ljava/lang/String;)J", (void*) getRxPackets},
+ {"getTxBytes", "(Ljava/lang/String;)J", (void*) getTxBytes},
+ {"getRxBytes", "(Ljava/lang/String;)J", (void*) getRxBytes},
{"getTotalTxPackets", "()J", (void*) getTotalTxPackets},
{"getTotalRxPackets", "()J", (void*) getTotalRxPackets},
{"getTotalTxBytes", "()J", (void*) getTotalTxBytes},
diff --git a/core/jni/android_view_MotionEvent.cpp b/core/jni/android_view_MotionEvent.cpp
index 99fbbe9..069e40b 100644
--- a/core/jni/android_view_MotionEvent.cpp
+++ b/core/jni/android_view_MotionEvent.cpp
@@ -188,23 +188,23 @@
static void pointerCoordsToNative(JNIEnv* env, jobject pointerCoordsObj,
float xOffset, float yOffset, PointerCoords* outRawPointerCoords) {
outRawPointerCoords->clear();
- outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_X,
+ outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_X,
env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.x) - xOffset);
- outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_Y,
+ outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_Y,
env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.y) - yOffset);
- outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_PRESSURE,
+ outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_PRESSURE,
env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.pressure));
- outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_SIZE,
+ outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_SIZE,
env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.size));
- outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR,
+ outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR,
env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.touchMajor));
- outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR,
+ outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR,
env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.touchMinor));
- outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR,
+ outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR,
env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.toolMajor));
- outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR,
+ outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR,
env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.toolMinor));
- outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_ORIENTATION,
+ outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION,
env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.orientation));
uint32_t bits = env->GetIntField(pointerCoordsObj,
@@ -254,34 +254,34 @@
static void pointerCoordsFromNative(JNIEnv* env, const PointerCoords* rawPointerCoords,
float xOffset, float yOffset, jobject outPointerCoordsObj) {
env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.x,
- rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_X) + xOffset);
+ rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_X) + xOffset);
env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.y,
- rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_Y) + yOffset);
+ rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_Y) + yOffset);
env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.pressure,
- rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_PRESSURE));
+ rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_PRESSURE));
env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.size,
- rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_SIZE));
+ rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_SIZE));
env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.touchMajor,
- rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR));
+ rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR));
env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.touchMinor,
- rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR));
+ rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR));
env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.toolMajor,
- rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR));
+ rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR));
env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.toolMinor,
- rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR));
+ rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR));
env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.orientation,
- rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION));
+ rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION));
const uint32_t unpackedAxisBits = 0
- | (1 << AINPUT_MOTION_AXIS_X)
- | (1 << AINPUT_MOTION_AXIS_Y)
- | (1 << AINPUT_MOTION_AXIS_PRESSURE)
- | (1 << AINPUT_MOTION_AXIS_SIZE)
- | (1 << AINPUT_MOTION_AXIS_TOUCH_MAJOR)
- | (1 << AINPUT_MOTION_AXIS_TOUCH_MINOR)
- | (1 << AINPUT_MOTION_AXIS_TOOL_MAJOR)
- | (1 << AINPUT_MOTION_AXIS_TOOL_MINOR)
- | (1 << AINPUT_MOTION_AXIS_ORIENTATION);
+ | (1 << AMOTION_EVENT_AXIS_X)
+ | (1 << AMOTION_EVENT_AXIS_Y)
+ | (1 << AMOTION_EVENT_AXIS_PRESSURE)
+ | (1 << AMOTION_EVENT_AXIS_SIZE)
+ | (1 << AMOTION_EVENT_AXIS_TOUCH_MAJOR)
+ | (1 << AMOTION_EVENT_AXIS_TOUCH_MINOR)
+ | (1 << AMOTION_EVENT_AXIS_TOOL_MAJOR)
+ | (1 << AMOTION_EVENT_AXIS_TOOL_MINOR)
+ | (1 << AMOTION_EVENT_AXIS_ORIENTATION);
uint32_t outBits = 0;
uint32_t remainingBits = rawPointerCoords->bits & ~unpackedAxisBits;
@@ -610,7 +610,7 @@
Parcel* parcel = parcelForJavaObject(env, parcelObj);
status_t status = event->readFromParcel(parcel);
- if (!status) {
+ if (status) {
if (!nativePtr) {
delete event;
}
@@ -626,7 +626,7 @@
Parcel* parcel = parcelForJavaObject(env, parcelObj);
status_t status = event->writeToParcel(parcel);
- if (!status) {
+ if (status) {
jniThrowRuntimeException(env, "Failed to write MotionEvent parcel.");
}
}
diff --git a/docs/html/guide/topics/manifest/uses-library-element.jd b/docs/html/guide/topics/manifest/uses-library-element.jd
index f1b5e70..1d38c1a 100644
--- a/docs/html/guide/topics/manifest/uses-library-element.jd
+++ b/docs/html/guide/topics/manifest/uses-library-element.jd
@@ -3,34 +3,101 @@
<dl class="xml">
<dt>syntax:</dt>
-<dd><pre><uses-library android:<a href="#nm">name</a>="<i>string</i>" /></pre></dd>
-
+<dd>
+<pre class="stx">
+<uses-library android:<a href="#nm">name</a>="<var>string</var>"
+ android:<a href="#rq">required</a>=["true" | "false"] />
+</pre>
+</dd>
<dt>contained in:</dt>
-<dd><code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code></dd>
-
+<dd>
+ <code>
+ <a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a>
+ </code>
+</dd>
<dt>description:</dt>
-<dd>Specifies a shared library that the application must be linked against.
-This element tells the system to include the library's code in the class
-loader for the package.
-
-<p>
-All of the {@code android} packages (such as {@link android.app},
-{@link android.content}, {@link android.view}, and {@link android.widget})
-are in the default library that all applications are automatically linked
-against. However, some packages (such as {@code maps} and {@code awt} are
-in separate libraries that are not automatically linked. Consult the
-documentation for the packages you're using to determine which library
-contains the package code.
-</p></dd>
-
+<dd>
+ Specifies a shared library that the application must be linked against.
+ This element tells the system to include the library's code in the class
+ loader for the package.
+ <p>
+ All of the {@code android} packages (such as {@link android.app},
+ {@link android.content}, {@link android.view}, and {@link android.widget})
+ are in the default library that all applications are automatically linked
+ against. However, some packages (such as {@code maps}) are
+ in separate libraries that are not automatically linked. Consult the
+ documentation for the packages you're using to determine which library
+ contains the package code.
+ </p>
+ <p>
+ This element also affects the installation of the application on a particular device and
+ the availability of the application in Android Market:
+ </p>
+ <dl>
+ <dt><em>Installation</em></dt>
+ <dd>
+ If this element is present and its {@code android:required} attribute is set to
+ {@code true}, the {@link android.content.pm.PackageManager} framework won't let the user
+ install the application unless the library is present on the user's device.
+ </dd>
+ <dt><em>Market</em></dt>
+ <dd>
+ Android Market filters applications based on the libraries installed on the
+ user's device. For more information about filtering, see the topic
+ <a href="{@docRoot}/guide/appendix/market-filters.html">Market Filters</a>.
+ </dd>
+ </dl>
+ <p>
+ The {@code android:required} attribute is described in detail in the following section.
+ </p>
+</dd>
<dt>attributes:</dt>
-<dd><dl class="attr">
-<dt><a name="nm"></a>{@code android:name}</dt>
-<dd>The name of the library.</dd>
-</dl></dd>
-
+<dd>
+ <dl class="attr">
+ <dt><a name="nm"></a>{@code android:name}</dt>
+ <dd>
+ The name of the library. The name is provided by the
+ documentation for the package you are using. An example of this is
+ "<code>android.test.runner</code>", a package that contains Android test
+ classes.
+ </dd>
+ <dt><a name="rq"></a>{@code android:required}</dt>
+ <dd>
+ Boolean value that indicates whether the application requires the
+ library specified by {@code android:name}:
+ <ul>
+ <li>
+ <code>"true"</code>: The application does not function without this
+ library. The system will not allow the application on a device that does not
+ have the library.
+ </li>
+ <li>
+ <code>"false"</code>: The application can use the
+ library if present, but is designed to function without it if necessary.
+ The system will allow the application to be installed, even if the library is
+ not present. If you use <code>"false"</code>, you are responsible for
+ checking at runtime that the library is available.
+ <p>
+ To check for a library, you can use reflection to determine
+ if a particular class is available.
+ </p>
+ </li>
+ </ul>
+ <p>
+ The default is <code>"true"</code>.
+ </p>
+ <p>Introduced in: API Level 7.</p>
+ </dd>
+ </dl>
+</dd>
<!-- ##api level indication## -->
<dt>introduced in:</dt>
<dd>API Level 1</dd>
-</dl>
+<dt>see also:</dt>
+<dd>
+ <ul>
+ <li>{@link android.content.pm.PackageManager}</li>
+ </ul>
+</dd>
+</dl>
\ No newline at end of file
diff --git a/include/ui/Input.h b/include/ui/Input.h
index b7b5a8d..cb9327e 100644
--- a/include/ui/Input.h
+++ b/include/ui/Input.h
@@ -170,7 +170,7 @@
* Pointer coordinate data.
*/
struct PointerCoords {
- static const size_t MAX_AXES = 15; // 15 so that sizeof(PointerCoords) == 16 * 4 == 64
+ enum { MAX_AXES = 15 }; // 15 so that sizeof(PointerCoords) == 16 * 4 == 64
// Bitfield of axes that are present in this structure.
uint32_t bits; // 32bits are enough for now, can raise to 64bit when needed
@@ -192,14 +192,14 @@
return values[index];
}
- inline void setAxisValue(int32_t axis, float value) {
+ inline status_t setAxisValue(int32_t axis, float value) {
uint32_t axisBit = 1 << axis;
uint32_t index = __builtin_popcount(bits & (axisBit - 1));
if (!(bits & axisBit)) {
uint32_t count = __builtin_popcount(bits);
if (count >= MAX_AXES) {
tooManyAxes(axis);
- return;
+ return NO_MEMORY;
}
bits |= axisBit;
for (uint32_t i = count; i > index; i--) {
@@ -207,6 +207,7 @@
}
}
values[index] = value;
+ return OK;
}
inline float* editAxisValue(int32_t axis) {
@@ -351,49 +352,49 @@
float getRawAxisValue(int32_t axis, size_t pointerIndex) const;
inline float getRawX(size_t pointerIndex) const {
- return getRawAxisValue(AINPUT_MOTION_AXIS_X, pointerIndex);
+ return getRawAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex);
}
inline float getRawY(size_t pointerIndex) const {
- return getRawAxisValue(AINPUT_MOTION_AXIS_Y, pointerIndex);
+ return getRawAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex);
}
float getAxisValue(int32_t axis, size_t pointerIndex) const;
inline float getX(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_X, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex);
}
inline float getY(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_Y, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex);
}
inline float getPressure(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_PRESSURE, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pointerIndex);
}
inline float getSize(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_SIZE, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_SIZE, pointerIndex);
}
inline float getTouchMajor(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex);
}
inline float getTouchMinor(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex);
}
inline float getToolMajor(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex);
}
inline float getToolMinor(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex);
}
inline float getOrientation(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex);
}
inline size_t getHistorySize() const { return mSampleEventTimes.size() - 1; }
@@ -410,59 +411,59 @@
inline float getHistoricalRawX(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalRawAxisValue(
- AINPUT_MOTION_AXIS_X, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex);
}
inline float getHistoricalRawY(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalRawAxisValue(
- AINPUT_MOTION_AXIS_Y, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex);
}
float getHistoricalAxisValue(int32_t axis, size_t pointerIndex, size_t historicalIndex) const;
inline float getHistoricalX(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_X, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex);
}
inline float getHistoricalY(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_Y, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex);
}
inline float getHistoricalPressure(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_PRESSURE, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_PRESSURE, pointerIndex, historicalIndex);
}
inline float getHistoricalSize(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_SIZE, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_SIZE, pointerIndex, historicalIndex);
}
inline float getHistoricalTouchMajor(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_TOUCH_MAJOR, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex, historicalIndex);
}
inline float getHistoricalTouchMinor(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_TOUCH_MINOR, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex, historicalIndex);
}
inline float getHistoricalToolMajor(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_TOOL_MAJOR, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex, historicalIndex);
}
inline float getHistoricalToolMinor(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_TOOL_MINOR, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex, historicalIndex);
}
inline float getHistoricalOrientation(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_ORIENTATION, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex, historicalIndex);
}
void initialize(
diff --git a/libs/ui/Input.cpp b/libs/ui/Input.cpp
index 90b954e..e3107d5 100644
--- a/libs/ui/Input.cpp
+++ b/libs/ui/Input.cpp
@@ -362,10 +362,10 @@
float MotionEvent::getAxisValue(int32_t axis, size_t pointerIndex) const {
float value = getRawPointerCoords(pointerIndex)->getAxisValue(axis);
switch (axis) {
- case AINPUT_MOTION_AXIS_X:
+ case AMOTION_EVENT_AXIS_X:
value += mXOffset;
break;
- case AINPUT_MOTION_AXIS_Y:
+ case AMOTION_EVENT_AXIS_Y:
value += mYOffset;
break;
}
@@ -386,10 +386,10 @@
size_t historicalIndex) const {
float value = getHistoricalRawPointerCoords(pointerIndex, historicalIndex)->getAxisValue(axis);
switch (axis) {
- case AINPUT_MOTION_AXIS_X:
+ case AMOTION_EVENT_AXIS_X:
value += mXOffset;
break;
- case AINPUT_MOTION_AXIS_Y:
+ case AMOTION_EVENT_AXIS_Y:
value += mYOffset;
break;
}
@@ -419,12 +419,12 @@
PointerCoords& c = mSamplePointerCoords.editItemAt(i);
// No need to scale pressure or size since they are normalized.
// No need to scale orientation since it is meaningless to do so.
- scaleAxisValue(c, AINPUT_MOTION_AXIS_X, scaleFactor);
- scaleAxisValue(c, AINPUT_MOTION_AXIS_Y, scaleFactor);
- scaleAxisValue(c, AINPUT_MOTION_AXIS_TOUCH_MAJOR, scaleFactor);
- scaleAxisValue(c, AINPUT_MOTION_AXIS_TOUCH_MINOR, scaleFactor);
- scaleAxisValue(c, AINPUT_MOTION_AXIS_TOOL_MAJOR, scaleFactor);
- scaleAxisValue(c, AINPUT_MOTION_AXIS_TOOL_MINOR, scaleFactor);
+ scaleAxisValue(c, AMOTION_EVENT_AXIS_X, scaleFactor);
+ scaleAxisValue(c, AMOTION_EVENT_AXIS_Y, scaleFactor);
+ scaleAxisValue(c, AMOTION_EVENT_AXIS_TOUCH_MAJOR, scaleFactor);
+ scaleAxisValue(c, AMOTION_EVENT_AXIS_TOUCH_MINOR, scaleFactor);
+ scaleAxisValue(c, AMOTION_EVENT_AXIS_TOOL_MAJOR, scaleFactor);
+ scaleAxisValue(c, AMOTION_EVENT_AXIS_TOOL_MINOR, scaleFactor);
}
}
@@ -471,8 +471,8 @@
size_t numSamples = mSamplePointerCoords.size();
for (size_t i = 0; i < numSamples; i++) {
PointerCoords& c = mSamplePointerCoords.editItemAt(i);
- float* xPtr = c.editAxisValue(AINPUT_MOTION_AXIS_X);
- float* yPtr = c.editAxisValue(AINPUT_MOTION_AXIS_Y);
+ float* xPtr = c.editAxisValue(AMOTION_EVENT_AXIS_X);
+ float* yPtr = c.editAxisValue(AMOTION_EVENT_AXIS_Y);
if (xPtr && yPtr) {
float x = *xPtr + oldXOffset;
float y = *yPtr + oldYOffset;
@@ -481,7 +481,7 @@
*yPtr = SkScalarToFloat(point.fY) - newYOffset;
}
- float* orientationPtr = c.editAxisValue(AINPUT_MOTION_AXIS_ORIENTATION);
+ float* orientationPtr = c.editAxisValue(AMOTION_EVENT_AXIS_ORIENTATION);
if (orientationPtr) {
*orientationPtr = transformAngle(matrix, *orientationPtr);
}
@@ -523,7 +523,7 @@
for (size_t i = 0; i < pointerCount; i++) {
mSamplePointerCoords.push();
status_t status = mSamplePointerCoords.editTop().readFromParcel(parcel);
- if (!status) {
+ if (status) {
return status;
}
}
@@ -559,7 +559,7 @@
parcel->writeInt64(mSampleEventTimes.itemAt(h));
for (size_t i = 0; i < pointerCount; i++) {
status_t status = (pc++)->writeToParcel(parcel);
- if (!status) {
+ if (status) {
return status;
}
}
diff --git a/libs/ui/tests/Android.mk b/libs/ui/tests/Android.mk
index 580d73c..e231971 100644
--- a/libs/ui/tests/Android.mk
+++ b/libs/ui/tests/Android.mk
@@ -7,6 +7,7 @@
# Build the unit tests.
test_src_files := \
InputChannel_test.cpp \
+ InputEvent_test.cpp \
InputPublisherAndConsumer_test.cpp
shared_libraries := \
@@ -18,7 +19,8 @@
libhardware \
libhardware_legacy \
libui \
- libstlport
+ libstlport \
+ libskia
static_libraries := \
libgtest \
@@ -28,7 +30,8 @@
bionic \
bionic/libstdc++/include \
external/gtest/include \
- external/stlport/stlport
+ external/stlport/stlport \
+ external/skia/include/core
module_tags := eng tests
diff --git a/libs/ui/tests/InputChannel_test.cpp b/libs/ui/tests/InputChannel_test.cpp
index 6cec1c0..eff22ee 100644
--- a/libs/ui/tests/InputChannel_test.cpp
+++ b/libs/ui/tests/InputChannel_test.cpp
@@ -1,6 +1,18 @@
-//
-// Copyright 2010 The Android Open Source Project
-//
+/*
+ * 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.
+ */
#include <ui/InputTransport.h>
#include <utils/Timers.h>
diff --git a/libs/ui/tests/InputEvent_test.cpp b/libs/ui/tests/InputEvent_test.cpp
new file mode 100644
index 0000000..7b15c38
--- /dev/null
+++ b/libs/ui/tests/InputEvent_test.cpp
@@ -0,0 +1,417 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ui/Input.h>
+#include <gtest/gtest.h>
+#include <binder/Parcel.h>
+
+namespace android {
+
+class BaseTest : public testing::Test {
+protected:
+ virtual void SetUp() { }
+ virtual void TearDown() { }
+};
+
+// --- PointerCoordsTest ---
+
+class PointerCoordsTest : public BaseTest {
+};
+
+TEST_F(PointerCoordsTest, ClearSetsBitsToZero) {
+ PointerCoords coords;
+ coords.clear();
+
+ ASSERT_EQ(0U, coords.bits);
+}
+
+TEST_F(PointerCoordsTest, AxisValues) {
+ float* valuePtr;
+ PointerCoords coords;
+ coords.clear();
+
+ // Check invariants when no axes are present.
+ ASSERT_EQ(0, coords.getAxisValue(0))
+ << "getAxisValue should return zero because axis is not present";
+ ASSERT_EQ(0, coords.getAxisValue(1))
+ << "getAxisValue should return zero because axis is not present";
+
+ ASSERT_EQ(NULL, coords.editAxisValue(0))
+ << "editAxisValue should return null because axis is not present";
+
+ // Set first axis.
+ ASSERT_EQ(OK, coords.setAxisValue(1, 5));
+ ASSERT_EQ(0x00000002U, coords.bits);
+ ASSERT_EQ(5, coords.values[0]);
+
+ ASSERT_EQ(0, coords.getAxisValue(0))
+ << "getAxisValue should return zero because axis is not present";
+ ASSERT_EQ(5, coords.getAxisValue(1))
+ << "getAxisValue should return value of axis";
+
+ // Set an axis with a higher id than all others. (appending value at the end)
+ ASSERT_EQ(OK, coords.setAxisValue(3, 2));
+ ASSERT_EQ(0x0000000aU, coords.bits);
+ ASSERT_EQ(5, coords.values[0]);
+ ASSERT_EQ(2, coords.values[1]);
+
+ ASSERT_EQ(0, coords.getAxisValue(0))
+ << "getAxisValue should return zero because axis is not present";
+ ASSERT_EQ(5, coords.getAxisValue(1))
+ << "getAxisValue should return value of axis";
+ ASSERT_EQ(0, coords.getAxisValue(2))
+ << "getAxisValue should return zero because axis is not present";
+ ASSERT_EQ(2, coords.getAxisValue(3))
+ << "getAxisValue should return value of axis";
+
+ // Set an axis with an id lower than all others. (prepending value at beginning)
+ ASSERT_EQ(OK, coords.setAxisValue(0, 4));
+ ASSERT_EQ(0x0000000bU, coords.bits);
+ ASSERT_EQ(4, coords.values[0]);
+ ASSERT_EQ(5, coords.values[1]);
+ ASSERT_EQ(2, coords.values[2]);
+
+ ASSERT_EQ(4, coords.getAxisValue(0))
+ << "getAxisValue should return value of axis";
+ ASSERT_EQ(5, coords.getAxisValue(1))
+ << "getAxisValue should return value of axis";
+ ASSERT_EQ(0, coords.getAxisValue(2))
+ << "getAxisValue should return zero because axis is not present";
+ ASSERT_EQ(2, coords.getAxisValue(3))
+ << "getAxisValue should return value of axis";
+
+ // Edit an existing axis value in place.
+ valuePtr = coords.editAxisValue(1);
+ ASSERT_EQ(5, *valuePtr)
+ << "editAxisValue should return pointer to axis value";
+
+ *valuePtr = 7;
+ ASSERT_EQ(7, coords.getAxisValue(1))
+ << "getAxisValue should return value of axis";
+
+ // Set an axis with an id between the others. (inserting value in the middle)
+ ASSERT_EQ(OK, coords.setAxisValue(2, 1));
+ ASSERT_EQ(0x0000000fU, coords.bits);
+ ASSERT_EQ(4, coords.values[0]);
+ ASSERT_EQ(7, coords.values[1]);
+ ASSERT_EQ(1, coords.values[2]);
+ ASSERT_EQ(2, coords.values[3]);
+
+ ASSERT_EQ(4, coords.getAxisValue(0))
+ << "getAxisValue should return value of axis";
+ ASSERT_EQ(7, coords.getAxisValue(1))
+ << "getAxisValue should return value of axis";
+ ASSERT_EQ(1, coords.getAxisValue(2))
+ << "getAxisValue should return value of axis";
+ ASSERT_EQ(2, coords.getAxisValue(3))
+ << "getAxisValue should return value of axis";
+
+ // Set an existing axis value in place.
+ ASSERT_EQ(OK, coords.setAxisValue(1, 6));
+ ASSERT_EQ(0x0000000fU, coords.bits);
+ ASSERT_EQ(4, coords.values[0]);
+ ASSERT_EQ(6, coords.values[1]);
+ ASSERT_EQ(1, coords.values[2]);
+ ASSERT_EQ(2, coords.values[3]);
+
+ ASSERT_EQ(4, coords.getAxisValue(0))
+ << "getAxisValue should return value of axis";
+ ASSERT_EQ(6, coords.getAxisValue(1))
+ << "getAxisValue should return value of axis";
+ ASSERT_EQ(1, coords.getAxisValue(2))
+ << "getAxisValue should return value of axis";
+ ASSERT_EQ(2, coords.getAxisValue(3))
+ << "getAxisValue should return value of axis";
+
+ // Set maximum number of axes.
+ for (size_t axis = 4; axis < PointerCoords::MAX_AXES; axis++) {
+ ASSERT_EQ(OK, coords.setAxisValue(axis, axis));
+ }
+ ASSERT_EQ(PointerCoords::MAX_AXES, __builtin_popcount(coords.bits));
+
+ // Try to set one more axis beyond maximum number.
+ // Ensure bits are unchanged.
+ ASSERT_EQ(NO_MEMORY, coords.setAxisValue(PointerCoords::MAX_AXES, 100));
+ ASSERT_EQ(PointerCoords::MAX_AXES, __builtin_popcount(coords.bits));
+}
+
+TEST_F(PointerCoordsTest, ReadAndWriteParcel) {
+ Parcel parcel;
+
+ PointerCoords inCoords;
+ inCoords.clear();
+ PointerCoords outCoords;
+
+ // Round trip with empty coords.
+ inCoords.writeToParcel(&parcel);
+ parcel.setDataPosition(0);
+ outCoords.readFromParcel(&parcel);
+
+ ASSERT_EQ(0U, outCoords.bits);
+
+ // Round trip with some values.
+ parcel.freeData();
+ inCoords.setAxisValue(2, 5);
+ inCoords.setAxisValue(5, 8);
+
+ inCoords.writeToParcel(&parcel);
+ parcel.setDataPosition(0);
+ outCoords.readFromParcel(&parcel);
+
+ ASSERT_EQ(outCoords.bits, inCoords.bits);
+ ASSERT_EQ(outCoords.values[0], inCoords.values[0]);
+ ASSERT_EQ(outCoords.values[1], inCoords.values[1]);
+}
+
+
+// --- KeyEventTest ---
+
+class KeyEventTest : public BaseTest {
+};
+
+TEST_F(KeyEventTest, Properties) {
+ KeyEvent event;
+
+ // Initialize and get properties.
+ const nsecs_t ARBITRARY_DOWN_TIME = 1;
+ const nsecs_t ARBITRARY_EVENT_TIME = 2;
+ event.initialize(2, AINPUT_SOURCE_GAMEPAD, AKEY_EVENT_ACTION_DOWN,
+ AKEY_EVENT_FLAG_FROM_SYSTEM, AKEYCODE_BUTTON_X, 121,
+ AMETA_ALT_ON, 1, ARBITRARY_DOWN_TIME, ARBITRARY_EVENT_TIME);
+
+ ASSERT_EQ(AINPUT_EVENT_TYPE_KEY, event.getType());
+ ASSERT_EQ(2, event.getDeviceId());
+ ASSERT_EQ(AINPUT_SOURCE_GAMEPAD, event.getSource());
+ ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, event.getAction());
+ ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM, event.getFlags());
+ ASSERT_EQ(AKEYCODE_BUTTON_X, event.getKeyCode());
+ ASSERT_EQ(121, event.getScanCode());
+ ASSERT_EQ(AMETA_ALT_ON, event.getMetaState());
+ ASSERT_EQ(1, event.getRepeatCount());
+ ASSERT_EQ(ARBITRARY_DOWN_TIME, event.getDownTime());
+ ASSERT_EQ(ARBITRARY_EVENT_TIME, event.getEventTime());
+
+ // Set source.
+ event.setSource(AINPUT_SOURCE_JOYSTICK);
+ ASSERT_EQ(AINPUT_SOURCE_JOYSTICK, event.getSource());
+}
+
+
+// --- MotionEventTest ---
+
+class MotionEventTest : public BaseTest {
+};
+
+TEST_F(MotionEventTest, Properties) {
+ MotionEvent event;
+
+ // Initialize, add samples and get properties.
+ const nsecs_t ARBITRARY_DOWN_TIME = 1;
+ const nsecs_t ARBITRARY_EVENT_TIME = 2;
+ const float X_OFFSET = 1.0f;
+ const float Y_OFFSET = 1.1f;
+ int32_t pointerIds[] = { 1, 2 };
+ PointerCoords pointerCoords[2];
+ pointerCoords[0].clear();
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 10);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, 11);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 12);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_SIZE, 13);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, 14);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, 15);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, 16);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, 17);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 18);
+ pointerCoords[1].clear();
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_X, 20);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_Y, 21);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 22);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_SIZE, 23);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, 24);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, 25);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, 26);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, 27);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 28);
+ event.initialize(2, AINPUT_SOURCE_TOUCHSCREEN, AMOTION_EVENT_ACTION_MOVE,
+ AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED,
+ AMOTION_EVENT_EDGE_FLAG_TOP, AMETA_ALT_ON,
+ X_OFFSET, Y_OFFSET, 2.0f, 2.1f,
+ ARBITRARY_DOWN_TIME, ARBITRARY_EVENT_TIME,
+ 2, pointerIds, pointerCoords);
+
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 110);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, 111);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 112);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_SIZE, 113);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, 114);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, 115);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, 116);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, 117);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 118);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_X, 120);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_Y, 121);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 122);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_SIZE, 123);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, 124);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, 125);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, 126);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, 127);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 128);
+ event.addSample(ARBITRARY_EVENT_TIME + 1, pointerCoords);
+
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 210);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, 211);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 212);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_SIZE, 213);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, 214);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, 215);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, 216);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, 217);
+ pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 218);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_X, 220);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_Y, 221);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 222);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_SIZE, 223);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, 224);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, 225);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, 226);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, 227);
+ pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 228);
+ event.addSample(ARBITRARY_EVENT_TIME + 2, pointerCoords);
+
+ ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, event.getType());
+ ASSERT_EQ(2, event.getDeviceId());
+ ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, event.getSource());
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, event.getAction());
+ ASSERT_EQ(AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED, event.getFlags());
+ ASSERT_EQ(AMOTION_EVENT_EDGE_FLAG_TOP, event.getEdgeFlags());
+ ASSERT_EQ(AMETA_ALT_ON, event.getMetaState());
+ ASSERT_EQ(X_OFFSET, event.getXOffset());
+ ASSERT_EQ(Y_OFFSET, event.getYOffset());
+ ASSERT_EQ(2.0f, event.getXPrecision());
+ ASSERT_EQ(2.1f, event.getYPrecision());
+ ASSERT_EQ(ARBITRARY_DOWN_TIME, event.getDownTime());
+
+ ASSERT_EQ(2U, event.getPointerCount());
+ ASSERT_EQ(1, event.getPointerId(0));
+ ASSERT_EQ(2, event.getPointerId(1));
+
+ ASSERT_EQ(2U, event.getHistorySize());
+
+ // Get data.
+ ASSERT_EQ(ARBITRARY_EVENT_TIME, event.getHistoricalEventTime(0));
+ ASSERT_EQ(ARBITRARY_EVENT_TIME + 1, event.getHistoricalEventTime(1));
+ ASSERT_EQ(ARBITRARY_EVENT_TIME + 2, event.getEventTime());
+
+ ASSERT_EQ(11, event.getHistoricalRawPointerCoords(0, 0)->
+ getAxisValue(AMOTION_EVENT_AXIS_Y));
+ ASSERT_EQ(21, event.getHistoricalRawPointerCoords(1, 0)->
+ getAxisValue(AMOTION_EVENT_AXIS_Y));
+ ASSERT_EQ(111, event.getHistoricalRawPointerCoords(0, 1)->
+ getAxisValue(AMOTION_EVENT_AXIS_Y));
+ ASSERT_EQ(121, event.getHistoricalRawPointerCoords(1, 1)->
+ getAxisValue(AMOTION_EVENT_AXIS_Y));
+ ASSERT_EQ(211, event.getRawPointerCoords(0)->
+ getAxisValue(AMOTION_EVENT_AXIS_Y));
+ ASSERT_EQ(221, event.getRawPointerCoords(1)->
+ getAxisValue(AMOTION_EVENT_AXIS_Y));
+
+ ASSERT_EQ(11, event.getHistoricalRawAxisValue(AMOTION_EVENT_AXIS_Y, 0, 0));
+ ASSERT_EQ(21, event.getHistoricalRawAxisValue(AMOTION_EVENT_AXIS_Y, 1, 0));
+ ASSERT_EQ(111, event.getHistoricalRawAxisValue(AMOTION_EVENT_AXIS_Y, 0, 1));
+ ASSERT_EQ(121, event.getHistoricalRawAxisValue(AMOTION_EVENT_AXIS_Y, 1, 1));
+ ASSERT_EQ(211, event.getRawAxisValue(AMOTION_EVENT_AXIS_Y, 0));
+ ASSERT_EQ(221, event.getRawAxisValue(AMOTION_EVENT_AXIS_Y, 1));
+
+ ASSERT_EQ(10, event.getHistoricalRawX(0, 0));
+ ASSERT_EQ(20, event.getHistoricalRawX(1, 0));
+ ASSERT_EQ(110, event.getHistoricalRawX(0, 1));
+ ASSERT_EQ(120, event.getHistoricalRawX(1, 1));
+ ASSERT_EQ(210, event.getRawX(0));
+ ASSERT_EQ(220, event.getRawX(1));
+
+ ASSERT_EQ(11, event.getHistoricalRawY(0, 0));
+ ASSERT_EQ(21, event.getHistoricalRawY(1, 0));
+ ASSERT_EQ(111, event.getHistoricalRawY(0, 1));
+ ASSERT_EQ(121, event.getHistoricalRawY(1, 1));
+ ASSERT_EQ(211, event.getRawY(0));
+ ASSERT_EQ(221, event.getRawY(1));
+
+ ASSERT_EQ(X_OFFSET + 10, event.getHistoricalX(0, 0));
+ ASSERT_EQ(X_OFFSET + 20, event.getHistoricalX(1, 0));
+ ASSERT_EQ(X_OFFSET + 110, event.getHistoricalX(0, 1));
+ ASSERT_EQ(X_OFFSET + 120, event.getHistoricalX(1, 1));
+ ASSERT_EQ(X_OFFSET + 210, event.getX(0));
+ ASSERT_EQ(X_OFFSET + 220, event.getX(1));
+
+ ASSERT_EQ(Y_OFFSET + 11, event.getHistoricalY(0, 0));
+ ASSERT_EQ(Y_OFFSET + 21, event.getHistoricalY(1, 0));
+ ASSERT_EQ(Y_OFFSET + 111, event.getHistoricalY(0, 1));
+ ASSERT_EQ(Y_OFFSET + 121, event.getHistoricalY(1, 1));
+ ASSERT_EQ(Y_OFFSET + 211, event.getY(0));
+ ASSERT_EQ(Y_OFFSET + 221, event.getY(1));
+
+ ASSERT_EQ(12, event.getHistoricalPressure(0, 0));
+ ASSERT_EQ(22, event.getHistoricalPressure(1, 0));
+ ASSERT_EQ(112, event.getHistoricalPressure(0, 1));
+ ASSERT_EQ(122, event.getHistoricalPressure(1, 1));
+ ASSERT_EQ(212, event.getPressure(0));
+ ASSERT_EQ(222, event.getPressure(1));
+
+ ASSERT_EQ(13, event.getHistoricalSize(0, 0));
+ ASSERT_EQ(23, event.getHistoricalSize(1, 0));
+ ASSERT_EQ(113, event.getHistoricalSize(0, 1));
+ ASSERT_EQ(123, event.getHistoricalSize(1, 1));
+ ASSERT_EQ(213, event.getSize(0));
+ ASSERT_EQ(223, event.getSize(1));
+
+ ASSERT_EQ(14, event.getHistoricalTouchMajor(0, 0));
+ ASSERT_EQ(24, event.getHistoricalTouchMajor(1, 0));
+ ASSERT_EQ(114, event.getHistoricalTouchMajor(0, 1));
+ ASSERT_EQ(124, event.getHistoricalTouchMajor(1, 1));
+ ASSERT_EQ(214, event.getTouchMajor(0));
+ ASSERT_EQ(224, event.getTouchMajor(1));
+
+ ASSERT_EQ(15, event.getHistoricalTouchMinor(0, 0));
+ ASSERT_EQ(25, event.getHistoricalTouchMinor(1, 0));
+ ASSERT_EQ(115, event.getHistoricalTouchMinor(0, 1));
+ ASSERT_EQ(125, event.getHistoricalTouchMinor(1, 1));
+ ASSERT_EQ(215, event.getTouchMinor(0));
+ ASSERT_EQ(225, event.getTouchMinor(1));
+
+ ASSERT_EQ(16, event.getHistoricalToolMajor(0, 0));
+ ASSERT_EQ(26, event.getHistoricalToolMajor(1, 0));
+ ASSERT_EQ(116, event.getHistoricalToolMajor(0, 1));
+ ASSERT_EQ(126, event.getHistoricalToolMajor(1, 1));
+ ASSERT_EQ(216, event.getToolMajor(0));
+ ASSERT_EQ(226, event.getToolMajor(1));
+
+ ASSERT_EQ(17, event.getHistoricalToolMinor(0, 0));
+ ASSERT_EQ(27, event.getHistoricalToolMinor(1, 0));
+ ASSERT_EQ(117, event.getHistoricalToolMinor(0, 1));
+ ASSERT_EQ(127, event.getHistoricalToolMinor(1, 1));
+ ASSERT_EQ(217, event.getToolMinor(0));
+ ASSERT_EQ(227, event.getToolMinor(1));
+
+ ASSERT_EQ(18, event.getHistoricalOrientation(0, 0));
+ ASSERT_EQ(28, event.getHistoricalOrientation(1, 0));
+ ASSERT_EQ(118, event.getHistoricalOrientation(0, 1));
+ ASSERT_EQ(128, event.getHistoricalOrientation(1, 1));
+ ASSERT_EQ(218, event.getOrientation(0));
+ ASSERT_EQ(228, event.getOrientation(1));
+}
+
+} // namespace android
diff --git a/libs/ui/tests/InputPublisherAndConsumer_test.cpp b/libs/ui/tests/InputPublisherAndConsumer_test.cpp
index 1819a8b..6e18a4f 100644
--- a/libs/ui/tests/InputPublisherAndConsumer_test.cpp
+++ b/libs/ui/tests/InputPublisherAndConsumer_test.cpp
@@ -1,6 +1,18 @@
-//
-// Copyright 2010 The Android Open Source Project
-//
+/*
+ * 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.
+ */
#include <ui/InputTransport.h>
#include <utils/Timers.h>
@@ -161,15 +173,15 @@
samplePointerCoords.push();
PointerCoords& pc = samplePointerCoords.editTop();
pc.clear();
- pc.setAxisValue(AINPUT_MOTION_AXIS_X, 100 * i + j);
- pc.setAxisValue(AINPUT_MOTION_AXIS_Y, 200 * i + j);
- pc.setAxisValue(AINPUT_MOTION_AXIS_PRESSURE, 0.5 * i + j);
- pc.setAxisValue(AINPUT_MOTION_AXIS_SIZE, 0.7 * i + j);
- pc.setAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR, 1.5 * i + j);
- pc.setAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR, 1.7 * i + j);
- pc.setAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR, 2.5 * i + j);
- pc.setAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR, 2.7 * i + j);
- pc.setAxisValue(AINPUT_MOTION_AXIS_ORIENTATION, 3.5 * i + j);
+ pc.setAxisValue(AMOTION_EVENT_AXIS_X, 100 * i + j);
+ pc.setAxisValue(AMOTION_EVENT_AXIS_Y, 200 * i + j);
+ pc.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 0.5 * i + j);
+ pc.setAxisValue(AMOTION_EVENT_AXIS_SIZE, 0.7 * i + j);
+ pc.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, 1.5 * i + j);
+ pc.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, 1.7 * i + j);
+ pc.setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, 2.5 * i + j);
+ pc.setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, 2.7 * i + j);
+ pc.setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 3.5 * i + j);
}
}
@@ -241,27 +253,27 @@
for (size_t i = 0; i < pointerCount; i++) {
SCOPED_TRACE(i);
size_t offset = sampleIndex * pointerCount + i;
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_X),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_X),
motionEvent->getHistoricalRawX(i, sampleIndex));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_Y),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_Y),
motionEvent->getHistoricalRawY(i, sampleIndex));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_X) + xOffset,
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_X) + xOffset,
motionEvent->getHistoricalX(i, sampleIndex));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_Y) + yOffset,
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_Y) + yOffset,
motionEvent->getHistoricalY(i, sampleIndex));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_PRESSURE),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
motionEvent->getHistoricalPressure(i, sampleIndex));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_SIZE),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_SIZE),
motionEvent->getHistoricalSize(i, sampleIndex));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR),
motionEvent->getHistoricalTouchMajor(i, sampleIndex));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR),
motionEvent->getHistoricalTouchMinor(i, sampleIndex));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
motionEvent->getHistoricalToolMajor(i, sampleIndex));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
motionEvent->getHistoricalToolMinor(i, sampleIndex));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION),
motionEvent->getHistoricalOrientation(i, sampleIndex));
}
}
@@ -271,27 +283,27 @@
for (size_t i = 0; i < pointerCount; i++) {
SCOPED_TRACE(i);
size_t offset = lastSampleIndex * pointerCount + i;
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_X),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_X),
motionEvent->getRawX(i));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_Y),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_Y),
motionEvent->getRawY(i));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_X) + xOffset,
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_X) + xOffset,
motionEvent->getX(i));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_Y) + yOffset,
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_Y) + yOffset,
motionEvent->getY(i));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_PRESSURE),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
motionEvent->getPressure(i));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_SIZE),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_SIZE),
motionEvent->getSize(i));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR),
motionEvent->getTouchMajor(i));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR),
motionEvent->getTouchMinor(i));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
motionEvent->getToolMajor(i));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
motionEvent->getToolMinor(i));
- EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION),
+ EXPECT_EQ(samplePointerCoords[offset].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION),
motionEvent->getOrientation(i));
}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java
index 44707401..e84f762 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java
@@ -811,6 +811,7 @@
try {
mMediaPlayer.setOnCompletionListener(mCompletionListener);
mMediaPlayer.setOnErrorListener(mOnErrorListener);
+ mMediaPlayer.setOnInfoListener(mInfoListener);
Log.v(TAG, "playMediaSamples: sample file name " + filePath);
mMediaPlayer.setDataSource(filePath);
mMediaPlayer.setDisplay(MediaFrameworkTest.mSurfaceView.getHolder());
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStressTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStressTest.java
index 20e2936..e6b1866 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStressTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStressTest.java
@@ -75,13 +75,13 @@
private void writeTestSummary(Writer output) throws Exception{
output.write("Total Result:\n");
- output.write(" Complete: " + mTotalComplete);
- output.write(" Error: " + mTotalPlaybackError);
- output.write(" Unknown Info: " + mTotalInfoUnknown);
- output.write(" Track Lagging: " + mTotalVideoTrackLagging );
- output.write(" BadInterleaving: " + mTotalBadInterleaving);
- output.write(" Not Seekable: " + mTotalNotSeekable);
- output.write(" Info Meta data update: " + mTotalMetaDataUpdate);
+ output.write("Total Complete: " + mTotalComplete + "\n");
+ output.write("Total Error: " + mTotalPlaybackError + "\n");
+ output.write("Total Unknown Info: " + mTotalInfoUnknown);
+ output.write("Total Track Lagging: " + mTotalVideoTrackLagging + "\n" );
+ output.write("Total BadInterleaving: " + mTotalBadInterleaving + "\n");
+ output.write("Total Not Seekable: " + mTotalNotSeekable + "\n");
+ output.write("Total Info Meta data update: " + mTotalMetaDataUpdate + "\n");
output.write("\n");
}
diff --git a/native/include/android/input.h b/native/include/android/input.h
index 0ffb8b5..ee05020 100644
--- a/native/include/android/input.h
+++ b/native/include/android/input.h
@@ -321,6 +321,21 @@
};
/*
+ * Constants that identify each individual axis of a motion event.
+ */
+enum {
+ AMOTION_EVENT_AXIS_X = 0,
+ AMOTION_EVENT_AXIS_Y = 1,
+ AMOTION_EVENT_AXIS_PRESSURE = 2,
+ AMOTION_EVENT_AXIS_SIZE = 3,
+ AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
+ AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
+ AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
+ AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
+ AMOTION_EVENT_AXIS_ORIENTATION = 8,
+};
+
+/*
* Input sources.
*
* Refer to the documentation on android.view.InputDevice for more details about input sources
@@ -363,39 +378,24 @@
};
/*
- * Constants that identify each individual axis of a motion event.
- */
-enum {
- AINPUT_MOTION_AXIS_X = 0,
- AINPUT_MOTION_AXIS_Y = 1,
- AINPUT_MOTION_AXIS_PRESSURE = 2,
- AINPUT_MOTION_AXIS_SIZE = 3,
- AINPUT_MOTION_AXIS_TOUCH_MAJOR = 4,
- AINPUT_MOTION_AXIS_TOUCH_MINOR = 5,
- AINPUT_MOTION_AXIS_TOOL_MAJOR = 6,
- AINPUT_MOTION_AXIS_TOOL_MINOR = 7,
- AINPUT_MOTION_AXIS_ORIENTATION = 8,
-};
-
-/*
* Constants used to retrieve information about the range of motion for a particular
* coordinate of a motion event.
*
* Refer to the documentation on android.view.InputDevice for more details about input sources
* and their correct interpretation.
*
- * DEPRECATION NOTICE: These constants are deprecated. Use AINPUT_MOTION_AXIS_* constants instead.
+ * DEPRECATION NOTICE: These constants are deprecated. Use AMOTION_EVENT_AXIS_* constants instead.
*/
enum {
- AINPUT_MOTION_RANGE_X = AINPUT_MOTION_AXIS_X,
- AINPUT_MOTION_RANGE_Y = AINPUT_MOTION_AXIS_Y,
- AINPUT_MOTION_RANGE_PRESSURE = AINPUT_MOTION_AXIS_PRESSURE,
- AINPUT_MOTION_RANGE_SIZE = AINPUT_MOTION_AXIS_SIZE,
- AINPUT_MOTION_RANGE_TOUCH_MAJOR = AINPUT_MOTION_AXIS_TOUCH_MAJOR,
- AINPUT_MOTION_RANGE_TOUCH_MINOR = AINPUT_MOTION_AXIS_TOUCH_MINOR,
- AINPUT_MOTION_RANGE_TOOL_MAJOR = AINPUT_MOTION_AXIS_TOOL_MAJOR,
- AINPUT_MOTION_RANGE_TOOL_MINOR = AINPUT_MOTION_AXIS_TOOL_MINOR,
- AINPUT_MOTION_RANGE_ORIENTATION = AINPUT_MOTION_AXIS_ORIENTATION,
+ AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
+ AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
+ AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
+ AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
+ AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
+ AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
+ AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
+ AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
+ AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
} __attribute__ ((deprecated));
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 42868db..ef37b4e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -33,6 +33,11 @@
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Binder;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.os.Message;
+import android.os.Messenger;
import android.os.RemoteException;
import android.provider.Settings;
import android.provider.Telephony;
@@ -50,6 +55,7 @@
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.cdma.EriInfo;
import com.android.server.am.BatteryStatsService;
+import com.android.internal.util.AsyncChannel;
import com.android.systemui.R;
@@ -82,6 +88,7 @@
// wifi
final WifiManager mWifiManager;
+ AsyncChannel mWifiChannel;
boolean mWifiEnabled, mWifiConnected;
int mWifiLevel;
String mWifiSsid;
@@ -140,6 +147,14 @@
// wifi
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ HandlerThread handlerThread = new HandlerThread("WifiServiceThread");
+ handlerThread.start();
+ Handler handler = new WifiHandler(handlerThread.getLooper());
+ mWifiChannel = new AsyncChannel();
+ Messenger wifiMessenger = mWifiManager.getMessenger();
+ if (wifiMessenger != null) {
+ mWifiChannel.connect(mContext, handler, wifiMessenger);
+ }
// broadcasts
IntentFilter filter = new IntentFilter();
@@ -584,6 +599,44 @@
// ===== Wifi ===================================================================
+ class WifiHandler extends Handler {
+
+ WifiHandler(Looper looper) {
+ super(looper);
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED:
+ if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
+ mWifiChannel.sendMessage(Message.obtain(this,
+ AsyncChannel.CMD_CHANNEL_FULL_CONNECTION));
+ } else {
+ Slog.e(TAG, "Failed to connect to wifi");
+ }
+ break;
+ case WifiManager.DATA_ACTIVITY_NOTIFICATION:
+ int dataActivity = msg.arg1;
+ /* TODO: update icons based on data activity */
+ switch (dataActivity) {
+ case WifiManager.DATA_ACTIVITY_IN:
+ break;
+ case WifiManager.DATA_ACTIVITY_OUT:
+ break;
+ case WifiManager.DATA_ACTIVITY_INOUT:
+ break;
+ case WifiManager.DATA_ACTIVITY_NONE:
+ break;
+ }
+ break;
+ default:
+ //Ignore
+ break;
+ }
+ }
+ }
+
private void updateWifiState(Intent intent) {
final String action = intent.getAction();
if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java
index 86c3e75..e0d558f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java
@@ -374,8 +374,9 @@
if (title != null && title.length() > 0 && icon != null) {
if (DEBUG) Log.v(TAG, "creating activity desc for id=" + id + ", label=" + title);
ActivityDescription item = new ActivityDescription(
- recentInfo.thumbnail, icon, title,
- recentInfo.description, intent, id, index, info.packageName);
+ am.getTaskThumbnail(recentInfo.persistentId),
+ icon, title, recentInfo.description, intent, id,
+ index, info.packageName);
activityDescriptions.add(item);
++index;
} else {
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
index 7809961..b32a729 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
@@ -89,7 +89,7 @@
* This class is created by the initialization routine of the {@link WindowManagerPolicy},
* and runs on its thread. The keyguard UI is created from that thread in the
* constructor of this class. The apis may be called from other threads, including the
- * {@link com.android.server.InputManager}'s and {@link android.view.WindowManager}'s.
+ * {@link com.android.server.wm.InputManager}'s and {@link android.view.WindowManager}'s.
* Therefore, methods on this class are synchronized, and any action that is pointed
* directly to the keyguard UI is posted to a {@link Handler} to ensure it is taken on the UI
* thread of the keyguard.
diff --git a/services/input/InputDispatcher.cpp b/services/input/InputDispatcher.cpp
index 466a9b3..ae11fb1 100644
--- a/services/input/InputDispatcher.cpp
+++ b/services/input/InputDispatcher.cpp
@@ -483,9 +483,9 @@
&& mInputTargetWaitCause == INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY
&& mInputTargetWaitApplication != NULL) {
int32_t x = int32_t(motionEntry->firstSample.pointerCoords[0].
- getAxisValue(AINPUT_MOTION_AXIS_X));
+ getAxisValue(AMOTION_EVENT_AXIS_X));
int32_t y = int32_t(motionEntry->firstSample.pointerCoords[0].
- getAxisValue(AINPUT_MOTION_AXIS_Y));
+ getAxisValue(AMOTION_EVENT_AXIS_Y));
const InputWindow* touchedWindow = findTouchedWindowAtLocked(x, y);
if (touchedWindow
&& touchedWindow->inputWindowHandle != NULL
@@ -890,15 +890,15 @@
"touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, "
"orientation=%f",
i, entry->pointerIds[i],
- sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_X),
- sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_Y),
- sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_PRESSURE),
- sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_SIZE),
- sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR),
- sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR),
- sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR),
- sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR),
- sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION));
+ sample->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X),
+ sample->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y),
+ sample->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
+ sample->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_SIZE),
+ sample->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR),
+ sample->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR),
+ sample->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
+ sample->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
+ sample->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION));
}
// Keep in mind that due to batching, it is possible for the number of samples actually
@@ -1195,9 +1195,9 @@
int32_t pointerIndex = getMotionEventActionPointerIndex(action);
int32_t x = int32_t(entry->firstSample.pointerCoords[pointerIndex].
- getAxisValue(AINPUT_MOTION_AXIS_X));
+ getAxisValue(AMOTION_EVENT_AXIS_X));
int32_t y = int32_t(entry->firstSample.pointerCoords[pointerIndex].
- getAxisValue(AINPUT_MOTION_AXIS_Y));
+ getAxisValue(AMOTION_EVENT_AXIS_Y));
const InputWindow* newTouchedWindow = NULL;
const InputWindow* topErrorWindow = NULL;
@@ -2284,15 +2284,15 @@
"touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, "
"orientation=%f",
i, pointerIds[i],
- pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_X),
- pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_Y),
- pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_PRESSURE),
- pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_SIZE),
- pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR),
- pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR),
- pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR),
- pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR),
- pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION));
+ pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X),
+ pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y),
+ pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
+ pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_SIZE),
+ pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR),
+ pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR),
+ pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
+ pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
+ pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION));
}
#endif
if (! validateMotionEvent(action, pointerCount, pointerIds)) {
diff --git a/services/input/InputReader.cpp b/services/input/InputReader.cpp
index 577da01..8f38cb2 100644
--- a/services/input/InputReader.cpp
+++ b/services/input/InputReader.cpp
@@ -1294,14 +1294,14 @@
}
float x, y;
mPointerController->getPosition(&x, &y);
- pointerCoords.setAxisValue(AINPUT_MOTION_AXIS_X, x);
- pointerCoords.setAxisValue(AINPUT_MOTION_AXIS_Y, y);
+ pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x);
+ pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
} else {
- pointerCoords.setAxisValue(AINPUT_MOTION_AXIS_X, deltaX);
- pointerCoords.setAxisValue(AINPUT_MOTION_AXIS_Y, deltaY);
+ pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, deltaX);
+ pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, deltaY);
}
- pointerCoords.setAxisValue(AINPUT_MOTION_AXIS_PRESSURE, mLocked.down ? 1.0f : 0.0f);
+ pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, mLocked.down ? 1.0f : 0.0f);
} // release lock
int32_t metaState = mContext->getGlobalMetaState();
@@ -2686,15 +2686,15 @@
// Write output coords.
PointerCoords& out = pointerCoords[outIndex];
out.clear();
- out.setAxisValue(AINPUT_MOTION_AXIS_X, x);
- out.setAxisValue(AINPUT_MOTION_AXIS_Y, y);
- out.setAxisValue(AINPUT_MOTION_AXIS_PRESSURE, pressure);
- out.setAxisValue(AINPUT_MOTION_AXIS_SIZE, size);
- out.setAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR, touchMajor);
- out.setAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR, touchMinor);
- out.setAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR, toolMajor);
- out.setAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR, toolMinor);
- out.setAxisValue(AINPUT_MOTION_AXIS_ORIENTATION, orientation);
+ out.setAxisValue(AMOTION_EVENT_AXIS_X, x);
+ out.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
+ out.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pressure);
+ out.setAxisValue(AMOTION_EVENT_AXIS_SIZE, size);
+ out.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, touchMajor);
+ out.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, touchMinor);
+ out.setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, toolMajor);
+ out.setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, toolMinor);
+ out.setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, orientation);
pointerIds[outIndex] = int32_t(id);
@@ -2706,8 +2706,8 @@
// Check edge flags by looking only at the first pointer since the flags are
// global to the event.
if (motionEventAction == AMOTION_EVENT_ACTION_DOWN) {
- float x = pointerCoords[0].getAxisValue(AINPUT_MOTION_AXIS_X);
- float y = pointerCoords[0].getAxisValue(AINPUT_MOTION_AXIS_Y);
+ float x = pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X);
+ float y = pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y);
if (x <= 0) {
motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_LEFT;
@@ -3857,8 +3857,8 @@
if (motionAxisChanged) {
PointerCoords pointerCoords;
pointerCoords.clear();
- pointerCoords.setAxisValue(AINPUT_MOTION_AXIS_X, mAxes.x.value);
- pointerCoords.setAxisValue(AINPUT_MOTION_AXIS_Y, mAxes.y.value);
+ pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, mAxes.x.value);
+ pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, mAxes.y.value);
int32_t pointerId = 0;
getDispatcher()->notifyMotion(when, getDeviceId(), AINPUT_SOURCE_JOYSTICK, 0,
diff --git a/services/input/tests/InputReader_test.cpp b/services/input/tests/InputReader_test.cpp
index 34d613a..41d67ed 100644
--- a/services/input/tests/InputReader_test.cpp
+++ b/services/input/tests/InputReader_test.cpp
@@ -1473,15 +1473,15 @@
float x, float y, float pressure, float size,
float touchMajor, float touchMinor, float toolMajor, float toolMinor,
float orientation) {
- ASSERT_NEAR(x, coords.getAxisValue(AINPUT_MOTION_AXIS_X), 1);
- ASSERT_NEAR(y, coords.getAxisValue(AINPUT_MOTION_AXIS_Y), 1);
- ASSERT_NEAR(pressure, coords.getAxisValue(AINPUT_MOTION_AXIS_PRESSURE), EPSILON);
- ASSERT_NEAR(size, coords.getAxisValue(AINPUT_MOTION_AXIS_SIZE), EPSILON);
- ASSERT_NEAR(touchMajor, coords.getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR), 1);
- ASSERT_NEAR(touchMinor, coords.getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR), 1);
- ASSERT_NEAR(toolMajor, coords.getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR), 1);
- ASSERT_NEAR(toolMinor, coords.getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR), 1);
- ASSERT_NEAR(orientation, coords.getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION), EPSILON);
+ ASSERT_NEAR(x, coords.getAxisValue(AMOTION_EVENT_AXIS_X), 1);
+ ASSERT_NEAR(y, coords.getAxisValue(AMOTION_EVENT_AXIS_Y), 1);
+ ASSERT_NEAR(pressure, coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE), EPSILON);
+ ASSERT_NEAR(size, coords.getAxisValue(AMOTION_EVENT_AXIS_SIZE), EPSILON);
+ ASSERT_NEAR(touchMajor, coords.getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR), 1);
+ ASSERT_NEAR(touchMinor, coords.getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR), 1);
+ ASSERT_NEAR(toolMajor, coords.getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR), 1);
+ ASSERT_NEAR(toolMinor, coords.getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR), 1);
+ ASSERT_NEAR(orientation, coords.getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION), EPSILON);
}
};
@@ -2892,8 +2892,8 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
- ASSERT_NEAR(50, args.pointerCoords[0].getAxisValue(AINPUT_MOTION_AXIS_X), 1);
- ASSERT_NEAR(75, args.pointerCoords[0].getAxisValue(AINPUT_MOTION_AXIS_Y), 1);
+ ASSERT_NEAR(50, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X), 1);
+ ASSERT_NEAR(75, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y), 1);
processUp(mapper);
processSync(mapper);
@@ -2914,8 +2914,8 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
- ASSERT_NEAR(50, args.pointerCoords[0].getAxisValue(AINPUT_MOTION_AXIS_X), 1);
- ASSERT_NEAR(75, args.pointerCoords[0].getAxisValue(AINPUT_MOTION_AXIS_Y), 1);
+ ASSERT_NEAR(50, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X), 1);
+ ASSERT_NEAR(75, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y), 1);
processUp(mapper);
processSync(mapper);
@@ -2927,8 +2927,8 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
- ASSERT_NEAR(75, args.pointerCoords[0].getAxisValue(AINPUT_MOTION_AXIS_X), 1);
- ASSERT_NEAR(DISPLAY_WIDTH - 50, args.pointerCoords[0].getAxisValue(AINPUT_MOTION_AXIS_Y), 1);
+ ASSERT_NEAR(75, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X), 1);
+ ASSERT_NEAR(DISPLAY_WIDTH - 50, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y), 1);
processUp(mapper);
processSync(mapper);
@@ -2940,8 +2940,8 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
- ASSERT_NEAR(DISPLAY_WIDTH - 50, args.pointerCoords[0].getAxisValue(AINPUT_MOTION_AXIS_X), 1);
- ASSERT_NEAR(DISPLAY_HEIGHT - 75, args.pointerCoords[0].getAxisValue(AINPUT_MOTION_AXIS_Y), 1);
+ ASSERT_NEAR(DISPLAY_WIDTH - 50, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X), 1);
+ ASSERT_NEAR(DISPLAY_HEIGHT - 75, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y), 1);
processUp(mapper);
processSync(mapper);
@@ -2953,8 +2953,8 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
- ASSERT_NEAR(DISPLAY_HEIGHT - 75, args.pointerCoords[0].getAxisValue(AINPUT_MOTION_AXIS_X), 1);
- ASSERT_NEAR(50, args.pointerCoords[0].getAxisValue(AINPUT_MOTION_AXIS_Y), 1);
+ ASSERT_NEAR(DISPLAY_HEIGHT - 75, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X), 1);
+ ASSERT_NEAR(50, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y), 1);
processUp(mapper);
processSync(mapper);
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 51e9b00..44b8590 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -26,7 +26,7 @@
import com.android.internal.view.IInputMethodSession;
import com.android.internal.view.InputBindResult;
-import com.android.server.StatusBarManagerService;
+import com.android.server.EventLogTags;
import org.xmlpull.v1.XmlPullParserException;
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index ef3e89a..eaf68b0 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -610,11 +610,10 @@
* argv7 - Preamble
* argv8 - Max SCB
*/
- String str = String.format("softap set " + wlanIface + " " + softapIface +
- " %s %s %s", convertQuotedString(wifiConfig.SSID),
- wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ?
- "wpa2-psk" : "open",
- convertQuotedString(wifiConfig.preSharedKey));
+ String str = String.format("softap set " + wlanIface + " " + softapIface +
+ " %s %s %s", convertQuotedString(wifiConfig.SSID),
+ getSecurityType(wifiConfig),
+ convertQuotedString(wifiConfig.preSharedKey));
mConnector.doCommand(str);
}
mConnector.doCommand(String.format("softap startap"));
@@ -631,6 +630,17 @@
return '"' + s.replaceAll("\\\\","\\\\\\\\").replaceAll("\"","\\\\\"") + '"';
}
+ private String getSecurityType(WifiConfiguration wifiConfig) {
+ switch (wifiConfig.getAuthType()) {
+ case KeyMgmt.WPA_PSK:
+ return "wpa-psk";
+ case KeyMgmt.WPA2_PSK:
+ return "wpa2-psk";
+ default:
+ return "open";
+ }
+ }
+
public void stopAccessPoint() throws IllegalStateException {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
@@ -656,7 +666,7 @@
} else {
String str = String.format("softap set " + wlanIface + " " + softapIface
+ " %s %s %s", convertQuotedString(wifiConfig.SSID),
- wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? "wpa2-psk" : "open",
+ getSecurityType(wifiConfig),
convertQuotedString(wifiConfig.preSharedKey));
mConnector.doCommand(str);
}
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index caf6376..d80a2cd 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -40,7 +40,6 @@
import android.os.BatteryManager;
import android.os.BatteryStats;
import android.os.Binder;
-import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
@@ -50,7 +49,6 @@
import android.os.PowerManager;
import android.os.Process;
import android.os.RemoteException;
-import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.WorkSource;
import android.provider.Settings.SettingNotFoundException;
@@ -69,14 +67,13 @@
import static android.provider.Settings.System.TRANSITION_ANIMATION_SCALE;
import java.io.FileDescriptor;
-import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Observable;
import java.util.Observer;
-class PowerManagerService extends IPowerManager.Stub
+public class PowerManagerService extends IPowerManager.Stub
implements LocalPowerManager, Watchdog.Monitor {
private static final String TAG = "PowerManagerService";
@@ -2689,7 +2686,7 @@
}
}
- void setPolicy(WindowManagerPolicy p) {
+ public void setPolicy(WindowManagerPolicy p) {
synchronized (mLocks) {
mPolicy = p;
mLocks.notifyAll();
diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java
index 5ada77b..8df8177 100644
--- a/services/java/com/android/server/StatusBarManagerService.java
+++ b/services/java/com/android/server/StatusBarManagerService.java
@@ -39,6 +39,7 @@
import com.android.internal.statusbar.StatusBarIcon;
import com.android.internal.statusbar.StatusBarIconList;
import com.android.internal.statusbar.StatusBarNotification;
+import com.android.server.wm.WindowManagerService;
import java.io.FileDescriptor;
import java.io.PrintWriter;
diff --git a/services/java/com/android/server/SystemBackupAgent.java b/services/java/com/android/server/SystemBackupAgent.java
index a1f43b4..80b0174 100644
--- a/services/java/com/android/server/SystemBackupAgent.java
+++ b/services/java/com/android/server/SystemBackupAgent.java
@@ -16,6 +16,7 @@
package com.android.server;
+
import android.app.backup.BackupDataInput;
import android.app.backup.BackupDataOutput;
import android.app.backup.BackupAgentHelper;
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 6a6cc2a..52c47e1 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -17,6 +17,7 @@
package com.android.server;
import com.android.server.am.ActivityManagerService;
+import com.android.server.wm.WindowManagerService;
import com.android.internal.app.ShutdownThread;
import com.android.internal.os.BinderInternal;
import com.android.internal.os.SamplingProfilerIntegration;
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java
index 997e750..b1a6a9a 100644
--- a/services/java/com/android/server/WallpaperManagerService.java
+++ b/services/java/com/android/server/WallpaperManagerService.java
@@ -70,8 +70,6 @@
import com.android.internal.service.wallpaper.ImageWallpaper;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.JournaledFile;
-import com.android.server.DevicePolicyManagerService.ActiveAdmin;
-import com.android.server.DevicePolicyManagerService.MyPackageMonitor;
class WallpaperManagerService extends IWallpaperManager.Stub {
static final String TAG = "WallpaperService";
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index 5e78353..cc25e8d 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -42,14 +42,18 @@
import android.net.DhcpInfo;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
+import android.net.NetworkInfo.DetailedState;
+import android.net.TrafficStats;
import android.os.Binder;
import android.os.Handler;
+import android.os.Messenger;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.INetworkManagementService;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.SystemProperties;
import android.os.WorkSource;
import android.provider.Settings;
import android.text.TextUtils;
@@ -111,6 +115,20 @@
private final IBatteryStats mBatteryStats;
+ private boolean mEnableTrafficStatsPoll = false;
+ private int mTrafficStatsPollToken = 0;
+ private long mTxPkts;
+ private long mRxPkts;
+ /* Tracks last reported data activity */
+ private int mDataActivity;
+ private String mInterfaceName;
+
+ /**
+ * Interval in milliseconds between polling for traffic
+ * statistics
+ */
+ private static final int POLL_TRAFFIC_STATS_INTERVAL_MSECS = 1000;
+
/**
* See {@link Settings.Secure#WIFI_IDLE_MS}. This is the default value if a
* Settings.Secure value is not present. This timeout value is chosen as
@@ -123,6 +141,9 @@
private static final String ACTION_DEVICE_IDLE =
"com.android.server.WifiManager.action.DEVICE_IDLE";
+ private static final int CMD_ENABLE_TRAFFIC_STATS_POLL = 1;
+ private static final int CMD_TRAFFIC_STATS_POLL = 2;
+
private boolean mIsReceiverRegistered = false;
@@ -180,18 +201,20 @@
/**
* Asynchronous channel to WifiStateMachine
*/
- private AsyncChannel mChannel;
+ private AsyncChannel mWifiStateMachineChannel;
/**
- * TODO: Possibly change WifiService into an AsyncService.
+ * Clients receiving asynchronous messages
*/
- private class WifiServiceHandler extends Handler {
- private AsyncChannel mWshChannel;
+ private List<AsyncChannel> mClients = new ArrayList<AsyncChannel>();
- WifiServiceHandler(android.os.Looper looper, Context context) {
+ /**
+ * Handles client connections
+ */
+ private class AsyncServiceHandler extends Handler {
+
+ AsyncServiceHandler(android.os.Looper looper) {
super(looper);
- mWshChannel = new AsyncChannel();
- mWshChannel.connect(context, this, mWifiStateMachine.getHandler());
}
@Override
@@ -199,11 +222,33 @@
switch (msg.what) {
case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED: {
if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
- mChannel = mWshChannel;
+ Slog.d(TAG, "New client listening to asynchronous messages");
+ mClients.add((AsyncChannel) msg.obj);
} else {
- Slog.d(TAG, "WifiServicehandler.handleMessage could not connect error=" +
- msg.arg1);
- mChannel = null;
+ Slog.e(TAG, "Client connection failure, error=" + msg.arg1);
+ }
+ break;
+ }
+ case AsyncChannel.CMD_CHANNEL_FULL_CONNECTION: {
+ AsyncChannel ac = new AsyncChannel();
+ ac.connect(mContext, this, msg.replyTo);
+ break;
+ }
+ case CMD_ENABLE_TRAFFIC_STATS_POLL: {
+ mEnableTrafficStatsPoll = (msg.arg1 == 1);
+ mTrafficStatsPollToken++;
+ if (mEnableTrafficStatsPoll) {
+ notifyOnDataActivity();
+ sendMessageDelayed(Message.obtain(this, CMD_TRAFFIC_STATS_POLL,
+ mTrafficStatsPollToken, 0), POLL_TRAFFIC_STATS_INTERVAL_MSECS);
+ }
+ break;
+ }
+ case CMD_TRAFFIC_STATS_POLL: {
+ if (msg.arg1 == mTrafficStatsPollToken) {
+ notifyOnDataActivity();
+ sendMessageDelayed(Message.obtain(this, CMD_TRAFFIC_STATS_POLL,
+ mTrafficStatsPollToken, 0), POLL_TRAFFIC_STATS_INTERVAL_MSECS);
}
break;
}
@@ -214,7 +259,40 @@
}
}
}
- WifiServiceHandler mHandler;
+ private AsyncServiceHandler mAsyncServiceHandler;
+
+ /**
+ * Handles interaction with WifiStateMachine
+ */
+ private class WifiStateMachineHandler extends Handler {
+ private AsyncChannel mWsmChannel;
+
+ WifiStateMachineHandler(android.os.Looper looper) {
+ super(looper);
+ mWsmChannel = new AsyncChannel();
+ mWsmChannel.connect(mContext, this, mWifiStateMachine.getHandler());
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED: {
+ if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
+ mWifiStateMachineChannel = mWsmChannel;
+ } else {
+ Slog.e(TAG, "WifiStateMachine connection failure, error=" + msg.arg1);
+ mWifiStateMachineChannel = null;
+ }
+ break;
+ }
+ default: {
+ Slog.d(TAG, "WifiStateMachineHandler.handleMessage ignoring msg=" + msg);
+ break;
+ }
+ }
+ }
+ }
+ WifiStateMachineHandler mWifiStateMachineHandler;
/**
* Temporary for computing UIDS that are responsible for starting WIFI.
@@ -224,7 +302,10 @@
WifiService(Context context) {
mContext = context;
- mWifiStateMachine = new WifiStateMachine(mContext);
+
+ mInterfaceName = SystemProperties.get("wifi.interface", "wlan0");
+
+ mWifiStateMachine = new WifiStateMachine(mContext, mInterfaceName);
mWifiStateMachine.enableRssiPolling(true);
mBatteryStats = BatteryStatsService.getService();
@@ -232,10 +313,6 @@
Intent idleIntent = new Intent(ACTION_DEVICE_IDLE, null);
mIdleIntent = PendingIntent.getBroadcast(mContext, IDLE_REQUEST, idleIntent, 0);
- HandlerThread wifiThread = new HandlerThread("WifiService");
- wifiThread.start();
- mHandler = new WifiServiceHandler(wifiThread.getLooper(), context);
-
mContext.registerReceiver(
new BroadcastReceiver() {
@Override
@@ -271,6 +348,7 @@
switch(mNetworkInfo.getDetailedState()) {
case CONNECTED:
case DISCONNECTED:
+ evaluateTrafficStatsPolling();
resetNotification();
break;
}
@@ -281,6 +359,11 @@
}
}, filter);
+ HandlerThread wifiThread = new HandlerThread("WifiService");
+ wifiThread.start();
+ mAsyncServiceHandler = new AsyncServiceHandler(wifiThread.getLooper());
+ mWifiStateMachineHandler = new WifiStateMachineHandler(wifiThread.getLooper());
+
// Setting is in seconds
NOTIFICATION_REPEAT_DELAY_MS = Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, 900) * 1000l;
@@ -337,10 +420,10 @@
*/
public boolean pingSupplicant() {
enforceAccessPermission();
- if (mChannel != null) {
- return mWifiStateMachine.syncPingSupplicant(mChannel);
+ if (mWifiStateMachineChannel != null) {
+ return mWifiStateMachine.syncPingSupplicant(mWifiStateMachineChannel);
} else {
- Slog.e(TAG, "mChannel is not initialized");
+ Slog.e(TAG, "mWifiStateMachineChannel is not initialized");
return false;
}
}
@@ -501,15 +584,12 @@
public synchronized void setWifiApConfiguration(WifiConfiguration wifiConfig) {
enforceChangePermission();
final ContentResolver cr = mContext.getContentResolver();
- boolean isWpa;
if (wifiConfig == null)
return;
+ int authType = wifiConfig.getAuthType();
Settings.Secure.putString(cr, Settings.Secure.WIFI_AP_SSID, wifiConfig.SSID);
- isWpa = wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK);
- Settings.Secure.putInt(cr,
- Settings.Secure.WIFI_AP_SECURITY,
- isWpa ? KeyMgmt.WPA_PSK : KeyMgmt.NONE);
- if (isWpa)
+ Settings.Secure.putInt(cr, Settings.Secure.WIFI_AP_SECURITY, authType);
+ if (authType != KeyMgmt.NONE)
Settings.Secure.putString(cr, Settings.Secure.WIFI_AP_PASSWD, wifiConfig.preSharedKey);
}
@@ -553,10 +633,10 @@
*/
public int addOrUpdateNetwork(WifiConfiguration config) {
enforceChangePermission();
- if (mChannel != null) {
- return mWifiStateMachine.syncAddOrUpdateNetwork(mChannel, config);
+ if (mWifiStateMachineChannel != null) {
+ return mWifiStateMachine.syncAddOrUpdateNetwork(mWifiStateMachineChannel, config);
} else {
- Slog.e(TAG, "mChannel is not initialized");
+ Slog.e(TAG, "mWifiStateMachineChannel is not initialized");
return -1;
}
}
@@ -569,10 +649,10 @@
*/
public boolean removeNetwork(int netId) {
enforceChangePermission();
- if (mChannel != null) {
- return mWifiStateMachine.syncRemoveNetwork(mChannel, netId);
+ if (mWifiStateMachineChannel != null) {
+ return mWifiStateMachine.syncRemoveNetwork(mWifiStateMachineChannel, netId);
} else {
- Slog.e(TAG, "mChannel is not initialized");
+ Slog.e(TAG, "mWifiStateMachineChannel is not initialized");
return false;
}
}
@@ -586,10 +666,11 @@
*/
public boolean enableNetwork(int netId, boolean disableOthers) {
enforceChangePermission();
- if (mChannel != null) {
- return mWifiStateMachine.syncEnableNetwork(mChannel, netId, disableOthers);
+ if (mWifiStateMachineChannel != null) {
+ return mWifiStateMachine.syncEnableNetwork(mWifiStateMachineChannel, netId,
+ disableOthers);
} else {
- Slog.e(TAG, "mChannel is not initialized");
+ Slog.e(TAG, "mWifiStateMachineChannel is not initialized");
return false;
}
}
@@ -602,10 +683,10 @@
*/
public boolean disableNetwork(int netId) {
enforceChangePermission();
- if (mChannel != null) {
- return mWifiStateMachine.syncDisableNetwork(mChannel, netId);
+ if (mWifiStateMachineChannel != null) {
+ return mWifiStateMachine.syncDisableNetwork(mWifiStateMachineChannel, netId);
} else {
- Slog.e(TAG, "mChannel is not initialized");
+ Slog.e(TAG, "mWifiStateMachineChannel is not initialized");
return false;
}
}
@@ -642,10 +723,10 @@
public boolean saveConfiguration() {
boolean result = true;
enforceChangePermission();
- if (mChannel != null) {
- return mWifiStateMachine.syncSaveConfig(mChannel);
+ if (mWifiStateMachineChannel != null) {
+ return mWifiStateMachine.syncSaveConfig(mWifiStateMachineChannel);
} else {
- Slog.e(TAG, "mChannel is not initialized");
+ Slog.e(TAG, "mWifiStateMachineChannel is not initialized");
return false;
}
}
@@ -779,14 +860,23 @@
public WpsResult startWps(WpsConfiguration config) {
enforceChangePermission();
- if (mChannel != null) {
- return mWifiStateMachine.startWps(mChannel, config);
+ if (mWifiStateMachineChannel != null) {
+ return mWifiStateMachine.startWps(mWifiStateMachineChannel, config);
} else {
- Slog.e(TAG, "mChannel is not initialized");
+ Slog.e(TAG, "mWifiStateMachineChannel is not initialized");
return new WpsResult(WpsResult.Status.FAILURE);
}
}
+ /**
+ * Get a reference to handler. This is used by a client to establish
+ * an AsyncChannel communication with WifiService
+ */
+ public Messenger getMessenger() {
+ enforceAccessPermission();
+ return new Messenger(mAsyncServiceHandler);
+ }
+
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -808,6 +898,7 @@
// Once the screen is on, we are not keeping WIFI running
// because of any locks so clear that tracking immediately.
reportStartWorkSource();
+ evaluateTrafficStatsPolling();
mWifiStateMachine.enableRssiPolling(true);
mWifiStateMachine.enableAllNetworks();
updateWifiState();
@@ -816,6 +907,7 @@
Slog.d(TAG, "ACTION_SCREEN_OFF");
}
mScreenOff = true;
+ evaluateTrafficStatsPolling();
mWifiStateMachine.enableRssiPolling(false);
/*
* Set a timer to put Wi-Fi to sleep, but only if the screen is off
@@ -1419,6 +1511,48 @@
}
}
+ /**
+ * Evaluate if traffic stats polling is needed based on
+ * connection and screen on status
+ */
+ private void evaluateTrafficStatsPolling() {
+ Message msg;
+ if (mNetworkInfo.getDetailedState() == DetailedState.CONNECTED && !mScreenOff) {
+ msg = Message.obtain(mAsyncServiceHandler, CMD_ENABLE_TRAFFIC_STATS_POLL, 1, 0);
+ } else {
+ msg = Message.obtain(mAsyncServiceHandler, CMD_ENABLE_TRAFFIC_STATS_POLL, 0, 0);
+ }
+ msg.sendToTarget();
+ }
+
+ private void notifyOnDataActivity() {
+ long sent, received;
+ long preTxPkts = mTxPkts, preRxPkts = mRxPkts;
+ int dataActivity = WifiManager.DATA_ACTIVITY_NONE;
+
+ mTxPkts = TrafficStats.getTxPackets(mInterfaceName);
+ mRxPkts = TrafficStats.getRxPackets(mInterfaceName);
+
+ if (preTxPkts > 0 || preRxPkts > 0) {
+ sent = mTxPkts - preTxPkts;
+ received = mRxPkts - preRxPkts;
+ if (sent > 0) {
+ dataActivity |= WifiManager.DATA_ACTIVITY_OUT;
+ }
+ if (received > 0) {
+ dataActivity |= WifiManager.DATA_ACTIVITY_IN;
+ }
+
+ if (dataActivity != mDataActivity && !mScreenOff) {
+ mDataActivity = dataActivity;
+ for (AsyncChannel client : mClients) {
+ client.sendMessage(WifiManager.DATA_ACTIVITY_NOTIFICATION, mDataActivity);
+ }
+ }
+ }
+ }
+
+
private void checkAndSetNotification() {
// If we shouldn't place a notification on available networks, then
// don't bother doing any of the following
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 9e3b9c6..399c19a 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -24,8 +24,8 @@
import com.android.server.ProcessStats;
import com.android.server.SystemServer;
import com.android.server.Watchdog;
-import com.android.server.WindowManagerService;
import com.android.server.am.ActivityStack.ActivityState;
+import com.android.server.wm.WindowManagerService;
import dalvik.system.Zygote;
@@ -4969,11 +4969,6 @@
enforceCallingPermission(android.Manifest.permission.GET_TASKS,
"getRecentTasks()");
- final boolean canReadFb = (flags&ActivityManager.TASKS_GET_THUMBNAILS) != 0
- && checkCallingPermission(
- android.Manifest.permission.READ_FRAME_BUFFER)
- == PackageManager.PERMISSION_GRANTED;
-
IPackageManager pm = AppGlobals.getPackageManager();
ActivityRecord resumed = mMainStack.mResumedActivity;
@@ -4991,17 +4986,10 @@
ActivityManager.RecentTaskInfo rti
= new ActivityManager.RecentTaskInfo();
rti.id = tr.numActivities > 0 ? tr.taskId : -1;
+ rti.persistentId = tr.taskId;
rti.baseIntent = new Intent(
tr.intent != null ? tr.intent : tr.affinityIntent);
rti.origActivity = tr.origActivity;
-
- if (canReadFb) {
- if (resumed != null && resumed.task == tr) {
- rti.thumbnail = resumed.stack.screenshotActivities(resumed);
- } else {
- rti.thumbnail = tr.lastThumbnail;
- }
- }
rti.description = tr.lastDescription;
if ((flags&ActivityManager.RECENT_IGNORE_UNAVAILABLE) != 0) {
@@ -5030,6 +5018,26 @@
}
}
+ public Bitmap getTaskThumbnail(int id) {
+ synchronized (this) {
+ enforceCallingPermission(android.Manifest.permission.READ_FRAME_BUFFER,
+ "getTaskThumbnail()");
+ ActivityRecord resumed = mMainStack.mResumedActivity;
+ final int N = mRecentTasks.size();
+ for (int i=0; i<N; i++) {
+ TaskRecord tr = mRecentTasks.get(i);
+ if (tr.taskId == id) {
+ if (resumed != null && resumed.task == tr) {
+ return resumed.stack.screenshotActivities(resumed);
+ } else {
+ return tr.lastThumbnail;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
private final int findAffinityTaskTopLocked(int startIndex, String affinity) {
int j;
TaskRecord startTask = ((ActivityRecord)mMainStack.mHistory.get(startIndex)).task;
@@ -5085,6 +5093,9 @@
for (int i=0; i<N; i++) {
TaskRecord tr = mRecentTasks.get(i);
if (tr.taskId == task) {
+ if ((flags&ActivityManager.MOVE_TASK_NO_USER_ACTION) == 0) {
+ mMainStack.mUserLeaving = true;
+ }
if ((flags&ActivityManager.MOVE_TASK_WITH_HOME) != 0) {
// Caller wants the home activity moved with it. To accomplish this,
// we'll just move the home task to the top first.
@@ -5097,6 +5108,9 @@
for (int i=mMainStack.mHistory.size()-1; i>=0; i--) {
ActivityRecord hr = (ActivityRecord)mMainStack.mHistory.get(i);
if (hr.task.taskId == task) {
+ if ((flags&ActivityManager.MOVE_TASK_NO_USER_ACTION) == 0) {
+ mMainStack.mUserLeaving = true;
+ }
if ((flags&ActivityManager.MOVE_TASK_WITH_HOME) != 0) {
// Caller wants the home activity moved with it. To accomplish this,
// we'll just move the home task to the top first.
diff --git a/services/java/com/android/server/InputApplication.java b/services/java/com/android/server/wm/InputApplication.java
similarity index 96%
rename from services/java/com/android/server/InputApplication.java
rename to services/java/com/android/server/wm/InputApplication.java
index ae09484..e04fd31 100644
--- a/services/java/com/android/server/InputApplication.java
+++ b/services/java/com/android/server/wm/InputApplication.java
@@ -14,7 +14,8 @@
* limitations under the License.
*/
-package com.android.server;
+package com.android.server.wm;
+
/**
* Describes input-related application properties for use by the input dispatcher.
diff --git a/services/java/com/android/server/InputApplicationHandle.java b/services/java/com/android/server/wm/InputApplicationHandle.java
similarity index 97%
rename from services/java/com/android/server/InputApplicationHandle.java
rename to services/java/com/android/server/wm/InputApplicationHandle.java
index d396d11..c95e525 100644
--- a/services/java/com/android/server/InputApplicationHandle.java
+++ b/services/java/com/android/server/wm/InputApplicationHandle.java
@@ -14,7 +14,8 @@
* limitations under the License.
*/
-package com.android.server;
+package com.android.server.wm;
+
/**
* Functions as a handle for an application that can receive input.
diff --git a/services/java/com/android/server/InputManager.java b/services/java/com/android/server/wm/InputManager.java
similarity index 99%
rename from services/java/com/android/server/InputManager.java
rename to services/java/com/android/server/wm/InputManager.java
index 8d249ff..80a2a96 100644
--- a/services/java/com/android/server/InputManager.java
+++ b/services/java/com/android/server/wm/InputManager.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server;
+package com.android.server.wm;
import com.android.internal.util.XmlUtils;
diff --git a/services/java/com/android/server/InputWindow.java b/services/java/com/android/server/wm/InputWindow.java
similarity index 98%
rename from services/java/com/android/server/InputWindow.java
rename to services/java/com/android/server/wm/InputWindow.java
index 2c2cdfe..e3eb473 100644
--- a/services/java/com/android/server/InputWindow.java
+++ b/services/java/com/android/server/wm/InputWindow.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server;
+package com.android.server.wm;
import android.graphics.Region;
import android.view.InputChannel;
diff --git a/services/java/com/android/server/InputWindowHandle.java b/services/java/com/android/server/wm/InputWindowHandle.java
similarity index 97%
rename from services/java/com/android/server/InputWindowHandle.java
rename to services/java/com/android/server/wm/InputWindowHandle.java
index 4b92939..cc508c6 100644
--- a/services/java/com/android/server/InputWindowHandle.java
+++ b/services/java/com/android/server/wm/InputWindowHandle.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server;
+package com.android.server.wm;
import android.view.WindowManagerPolicy;
diff --git a/services/java/com/android/server/InputWindowList.java b/services/java/com/android/server/wm/InputWindowList.java
similarity index 98%
rename from services/java/com/android/server/InputWindowList.java
rename to services/java/com/android/server/wm/InputWindowList.java
index 1cbb2cc..6077337 100644
--- a/services/java/com/android/server/InputWindowList.java
+++ b/services/java/com/android/server/wm/InputWindowList.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server;
+package com.android.server.wm;
/**
diff --git a/services/java/com/android/server/ScreenRotationAnimation.java b/services/java/com/android/server/wm/ScreenRotationAnimation.java
similarity index 99%
rename from services/java/com/android/server/ScreenRotationAnimation.java
rename to services/java/com/android/server/wm/ScreenRotationAnimation.java
index ef00b08f..fc9f10e 100644
--- a/services/java/com/android/server/ScreenRotationAnimation.java
+++ b/services/java/com/android/server/wm/ScreenRotationAnimation.java
@@ -14,7 +14,8 @@
* limitations under the License.
*/
-package com.android.server; // TODO: use com.android.server.wm, once things move there
+package com.android.server.wm; // TODO: use com.android.server.wm, once things move there
+
import android.content.Context;
import android.graphics.Bitmap;
diff --git a/services/java/com/android/server/StrictModeFlash.java b/services/java/com/android/server/wm/StrictModeFlash.java
similarity index 97%
rename from services/java/com/android/server/StrictModeFlash.java
rename to services/java/com/android/server/wm/StrictModeFlash.java
index 0a6c625..2aa45ac 100644
--- a/services/java/com/android/server/StrictModeFlash.java
+++ b/services/java/com/android/server/wm/StrictModeFlash.java
@@ -14,7 +14,8 @@
* limitations under the License.
*/
-package com.android.server; // TODO: use com.android.server.wm, once things move there
+package com.android.server.wm; // TODO: use com.android.server.wm, once things move there
+
import android.graphics.Canvas;
import android.graphics.Color;
diff --git a/services/java/com/android/server/ViewServer.java b/services/java/com/android/server/wm/ViewServer.java
similarity index 98%
rename from services/java/com/android/server/ViewServer.java
rename to services/java/com/android/server/wm/ViewServer.java
index 7b5d18a..cebd5e7 100644
--- a/services/java/com/android/server/ViewServer.java
+++ b/services/java/com/android/server/wm/ViewServer.java
@@ -14,7 +14,8 @@
* limitations under the License.
*/
-package com.android.server;
+package com.android.server.wm;
+
import android.util.Slog;
@@ -33,7 +34,7 @@
/**
* The ViewServer is local socket server that can be used to communicate with the
* views of the opened windows. Communication with the views is ensured by the
- * {@link com.android.server.WindowManagerService} and is a cross-process operation.
+ * {@link com.android.server.wm.WindowManagerService} and is a cross-process operation.
*
* {@hide}
*/
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
similarity index 99%
rename from services/java/com/android/server/WindowManagerService.java
rename to services/java/com/android/server/wm/WindowManagerService.java
index b662c55..3183643 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server;
+package com.android.server.wm;
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
@@ -42,6 +42,12 @@
import com.android.internal.view.IInputMethodClient;
import com.android.internal.view.IInputMethodManager;
import com.android.internal.view.WindowManagerPolicyThread;
+import com.android.server.AttributeCache;
+import com.android.server.EventLogTags;
+import com.android.server.PowerManagerService;
+import com.android.server.Watchdog;
+import com.android.server.AttributeCache.Entry;
+import com.android.server.Watchdog.Monitor;
import com.android.server.am.BatteryStatsService;
import android.Manifest;
@@ -5347,8 +5353,8 @@
*
* @return True if the server was successfully started, false otherwise.
*
- * @see com.android.server.ViewServer
- * @see com.android.server.ViewServer#VIEW_SERVER_DEFAULT_PORT
+ * @see com.android.server.wm.ViewServer
+ * @see com.android.server.wm.ViewServer#VIEW_SERVER_DEFAULT_PORT
*/
public boolean startViewServer(int port) {
if (isSystemSecure()) {
@@ -5394,7 +5400,7 @@
* @return True if the server stopped, false if it wasn't started or
* couldn't be stopped.
*
- * @see com.android.server.ViewServer
+ * @see com.android.server.wm.ViewServer
*/
public boolean stopViewServer() {
if (isSystemSecure()) {
@@ -5416,7 +5422,7 @@
*
* @return True if the server is running, false otherwise.
*
- * @see com.android.server.ViewServer
+ * @see com.android.server.wm.ViewServer
*/
public boolean isViewServerRunning() {
if (isSystemSecure()) {
diff --git a/services/jni/com_android_server_InputApplication.cpp b/services/jni/com_android_server_InputApplication.cpp
index a46a162..e64ec4e 100644
--- a/services/jni/com_android_server_InputApplication.cpp
+++ b/services/jni/com_android_server_InputApplication.cpp
@@ -77,11 +77,11 @@
LOG_FATAL_IF(! var, "Unable to find field " fieldName);
int register_android_server_InputApplication(JNIEnv* env) {
- FIND_CLASS(gInputApplicationClassInfo.clazz, "com/android/server/InputApplication");
+ FIND_CLASS(gInputApplicationClassInfo.clazz, "com/android/server/wm/InputApplication");
GET_FIELD_ID(gInputApplicationClassInfo.inputApplicationHandle,
gInputApplicationClassInfo.clazz,
- "inputApplicationHandle", "Lcom/android/server/InputApplicationHandle;");
+ "inputApplicationHandle", "Lcom/android/server/wm/InputApplicationHandle;");
GET_FIELD_ID(gInputApplicationClassInfo.name, gInputApplicationClassInfo.clazz,
"name", "Ljava/lang/String;");
diff --git a/services/jni/com_android_server_InputApplicationHandle.cpp b/services/jni/com_android_server_InputApplicationHandle.cpp
index ab82635..3a1214f 100644
--- a/services/jni/com_android_server_InputApplicationHandle.cpp
+++ b/services/jni/com_android_server_InputApplicationHandle.cpp
@@ -106,11 +106,11 @@
LOG_FATAL_IF(! var, "Unable to find field " fieldName);
int register_android_server_InputApplicationHandle(JNIEnv* env) {
- int res = jniRegisterNativeMethods(env, "com/android/server/InputApplicationHandle",
+ int res = jniRegisterNativeMethods(env, "com/android/server/wm/InputApplicationHandle",
gInputApplicationHandleMethods, NELEM(gInputApplicationHandleMethods));
LOG_FATAL_IF(res < 0, "Unable to register native methods.");
- FIND_CLASS(gInputApplicationHandleClassInfo.clazz, "com/android/server/InputApplicationHandle");
+ FIND_CLASS(gInputApplicationHandleClassInfo.clazz, "com/android/server/wm/InputApplicationHandle");
GET_FIELD_ID(gInputApplicationHandleClassInfo.ptr, gInputApplicationHandleClassInfo.clazz,
"ptr", "I");
diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp
index 427af23..0a50ff8 100644
--- a/services/jni/com_android_server_InputManager.cpp
+++ b/services/jni/com_android_server_InputManager.cpp
@@ -1079,7 +1079,7 @@
static JNINativeMethod gInputManagerMethods[] = {
/* name, signature, funcPtr */
- { "nativeInit", "(Lcom/android/server/InputManager$Callbacks;)V",
+ { "nativeInit", "(Lcom/android/server/wm/InputManager$Callbacks;)V",
(void*) android_server_InputManager_nativeInit },
{ "nativeStart", "()V",
(void*) android_server_InputManager_nativeStart },
@@ -1096,15 +1096,15 @@
{ "nativeHasKeys", "(II[I[Z)Z",
(void*) android_server_InputManager_nativeHasKeys },
{ "nativeRegisterInputChannel",
- "(Landroid/view/InputChannel;Lcom/android/server/InputWindowHandle;Z)V",
+ "(Landroid/view/InputChannel;Lcom/android/server/wm/InputWindowHandle;Z)V",
(void*) android_server_InputManager_nativeRegisterInputChannel },
{ "nativeUnregisterInputChannel", "(Landroid/view/InputChannel;)V",
(void*) android_server_InputManager_nativeUnregisterInputChannel },
{ "nativeInjectInputEvent", "(Landroid/view/InputEvent;IIII)I",
(void*) android_server_InputManager_nativeInjectInputEvent },
- { "nativeSetInputWindows", "([Lcom/android/server/InputWindow;)V",
+ { "nativeSetInputWindows", "([Lcom/android/server/wm/InputWindow;)V",
(void*) android_server_InputManager_nativeSetInputWindows },
- { "nativeSetFocusedApplication", "(Lcom/android/server/InputApplication;)V",
+ { "nativeSetFocusedApplication", "(Lcom/android/server/wm/InputApplication;)V",
(void*) android_server_InputManager_nativeSetFocusedApplication },
{ "nativeSetInputDispatchMode", "(ZZ)V",
(void*) android_server_InputManager_nativeSetInputDispatchMode },
@@ -1134,13 +1134,13 @@
LOG_FATAL_IF(! var, "Unable to find field " fieldName);
int register_android_server_InputManager(JNIEnv* env) {
- int res = jniRegisterNativeMethods(env, "com/android/server/InputManager",
+ int res = jniRegisterNativeMethods(env, "com/android/server/wm/InputManager",
gInputManagerMethods, NELEM(gInputManagerMethods));
LOG_FATAL_IF(res < 0, "Unable to register native methods.");
// Callbacks
- FIND_CLASS(gCallbacksClassInfo.clazz, "com/android/server/InputManager$Callbacks");
+ FIND_CLASS(gCallbacksClassInfo.clazz, "com/android/server/wm/InputManager$Callbacks");
GET_METHOD_ID(gCallbacksClassInfo.notifyConfigurationChanged, gCallbacksClassInfo.clazz,
"notifyConfigurationChanged", "(J)V");
@@ -1149,22 +1149,22 @@
"notifyLidSwitchChanged", "(JZ)V");
GET_METHOD_ID(gCallbacksClassInfo.notifyInputChannelBroken, gCallbacksClassInfo.clazz,
- "notifyInputChannelBroken", "(Lcom/android/server/InputWindowHandle;)V");
+ "notifyInputChannelBroken", "(Lcom/android/server/wm/InputWindowHandle;)V");
GET_METHOD_ID(gCallbacksClassInfo.notifyANR, gCallbacksClassInfo.clazz,
"notifyANR",
- "(Lcom/android/server/InputApplicationHandle;Lcom/android/server/InputWindowHandle;)J");
+ "(Lcom/android/server/wm/InputApplicationHandle;Lcom/android/server/wm/InputWindowHandle;)J");
GET_METHOD_ID(gCallbacksClassInfo.interceptKeyBeforeQueueing, gCallbacksClassInfo.clazz,
"interceptKeyBeforeQueueing", "(Landroid/view/KeyEvent;IZ)I");
GET_METHOD_ID(gCallbacksClassInfo.interceptKeyBeforeDispatching, gCallbacksClassInfo.clazz,
"interceptKeyBeforeDispatching",
- "(Lcom/android/server/InputWindowHandle;Landroid/view/KeyEvent;I)Z");
+ "(Lcom/android/server/wm/InputWindowHandle;Landroid/view/KeyEvent;I)Z");
GET_METHOD_ID(gCallbacksClassInfo.dispatchUnhandledKey, gCallbacksClassInfo.clazz,
"dispatchUnhandledKey",
- "(Lcom/android/server/InputWindowHandle;Landroid/view/KeyEvent;I)Landroid/view/KeyEvent;");
+ "(Lcom/android/server/wm/InputWindowHandle;Landroid/view/KeyEvent;I)Landroid/view/KeyEvent;");
GET_METHOD_ID(gCallbacksClassInfo.checkInjectEventsPermission, gCallbacksClassInfo.clazz,
"checkInjectEventsPermission", "(II)Z");
@@ -1188,7 +1188,7 @@
"getPointerLayer", "()I");
GET_METHOD_ID(gCallbacksClassInfo.getPointerIcon, gCallbacksClassInfo.clazz,
- "getPointerIcon", "()Lcom/android/server/InputManager$PointerIcon;");
+ "getPointerIcon", "()Lcom/android/server/wm/InputManager$PointerIcon;");
// KeyEvent
@@ -1235,7 +1235,7 @@
// PointerIcon
- FIND_CLASS(gPointerIconClassInfo.clazz, "com/android/server/InputManager$PointerIcon");
+ FIND_CLASS(gPointerIconClassInfo.clazz, "com/android/server/wm/InputManager$PointerIcon");
GET_FIELD_ID(gPointerIconClassInfo.bitmap, gPointerIconClassInfo.clazz,
"bitmap", "Landroid/graphics/Bitmap;");
diff --git a/services/jni/com_android_server_InputWindow.cpp b/services/jni/com_android_server_InputWindow.cpp
index 75154567c..8548b47 100644
--- a/services/jni/com_android_server_InputWindow.cpp
+++ b/services/jni/com_android_server_InputWindow.cpp
@@ -144,10 +144,10 @@
LOG_FATAL_IF(! var, "Unable to find field " fieldName);
int register_android_server_InputWindow(JNIEnv* env) {
- FIND_CLASS(gInputWindowClassInfo.clazz, "com/android/server/InputWindow");
+ FIND_CLASS(gInputWindowClassInfo.clazz, "com/android/server/wm/InputWindow");
GET_FIELD_ID(gInputWindowClassInfo.inputWindowHandle, gInputWindowClassInfo.clazz,
- "inputWindowHandle", "Lcom/android/server/InputWindowHandle;");
+ "inputWindowHandle", "Lcom/android/server/wm/InputWindowHandle;");
GET_FIELD_ID(gInputWindowClassInfo.inputChannel, gInputWindowClassInfo.clazz,
"inputChannel", "Landroid/view/InputChannel;");
diff --git a/services/jni/com_android_server_InputWindowHandle.cpp b/services/jni/com_android_server_InputWindowHandle.cpp
index 4d66212..5b74e43 100644
--- a/services/jni/com_android_server_InputWindowHandle.cpp
+++ b/services/jni/com_android_server_InputWindowHandle.cpp
@@ -116,18 +116,18 @@
LOG_FATAL_IF(! var, "Unable to find field " fieldName);
int register_android_server_InputWindowHandle(JNIEnv* env) {
- int res = jniRegisterNativeMethods(env, "com/android/server/InputWindowHandle",
+ int res = jniRegisterNativeMethods(env, "com/android/server/wm/InputWindowHandle",
gInputWindowHandleMethods, NELEM(gInputWindowHandleMethods));
LOG_FATAL_IF(res < 0, "Unable to register native methods.");
- FIND_CLASS(gInputWindowHandleClassInfo.clazz, "com/android/server/InputWindowHandle");
+ FIND_CLASS(gInputWindowHandleClassInfo.clazz, "com/android/server/wm/InputWindowHandle");
GET_FIELD_ID(gInputWindowHandleClassInfo.ptr, gInputWindowHandleClassInfo.clazz,
"ptr", "I");
GET_FIELD_ID(gInputWindowHandleClassInfo.inputApplicationHandle,
gInputWindowHandleClassInfo.clazz,
- "inputApplicationHandle", "Lcom/android/server/InputApplicationHandle;");
+ "inputApplicationHandle", "Lcom/android/server/wm/InputApplicationHandle;");
return 0;
}
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index 847577f..7a9276d 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -1,16 +1,16 @@
/**
* Copyright (c) 2008, The Android Open Source Project
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
+ * 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
+ * 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.
*/
@@ -23,6 +23,7 @@
import android.net.wifi.ScanResult;
import android.net.DhcpInfo;
+import android.os.Messenger;
import android.os.WorkSource;
/**
@@ -111,5 +112,7 @@
void forgetNetwork(int networkId);
WpsResult startWps(in WpsConfiguration config);
+
+ Messenger getMessenger();
}
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java
index d5fb63e..28a5bc6 100644
--- a/wifi/java/android/net/wifi/WifiConfiguration.java
+++ b/wifi/java/android/net/wifi/WifiConfiguration.java
@@ -107,9 +107,16 @@
* generated WEP keys. */
public static final int IEEE8021X = 3;
+ /** WPA2 pre-shared key for use with soft access point
+ * (requires {@code preSharedKey} to be specified).
+ * @hide
+ */
+ public static final int WPA2_PSK = 4;
+
public static final String varName = "key_mgmt";
- public static final String[] strings = { "NONE", "WPA_PSK", "WPA_EAP", "IEEE8021X" };
+ public static final String[] strings = { "NONE", "WPA_PSK", "WPA_EAP", "IEEE8021X",
+ "WPA2_PSK" };
}
/**
@@ -480,6 +487,20 @@
dest.writeInt(nextSetBit);
}
+ /** @hide */
+ public int getAuthType() {
+ if (allowedKeyManagement.get(KeyMgmt.WPA_PSK)) {
+ return KeyMgmt.WPA_PSK;
+ } else if (allowedKeyManagement.get(KeyMgmt.WPA2_PSK)) {
+ return KeyMgmt.WPA2_PSK;
+ } else if (allowedKeyManagement.get(KeyMgmt.WPA_EAP)) {
+ return KeyMgmt.WPA_EAP;
+ } else if (allowedKeyManagement.get(KeyMgmt.IEEE8021X)) {
+ return KeyMgmt.IEEE8021X;
+ }
+ return KeyMgmt.NONE;
+ }
+
/** Implement the Parcelable interface {@hide} */
public int describeContents() {
return 0;
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 4ac03a8..0807a24 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -24,6 +24,7 @@
import android.os.Handler;
import android.os.RemoteException;
import android.os.WorkSource;
+import android.os.Messenger;
import java.util.List;
@@ -60,7 +61,7 @@
* Broadcast intent action indicating that Wi-Fi has been enabled, disabled,
* enabling, disabling, or unknown. One extra provides this state as an int.
* Another extra provides the previous state, if available.
- *
+ *
* @see #EXTRA_WIFI_STATE
* @see #EXTRA_PREVIOUS_WIFI_STATE
*/
@@ -71,7 +72,7 @@
* The lookup key for an int that indicates whether Wi-Fi is enabled,
* disabled, enabling, disabling, or unknown. Retrieve it with
* {@link android.content.Intent#getIntExtra(String,int)}.
- *
+ *
* @see #WIFI_STATE_DISABLED
* @see #WIFI_STATE_DISABLING
* @see #WIFI_STATE_ENABLED
@@ -81,22 +82,22 @@
public static final String EXTRA_WIFI_STATE = "wifi_state";
/**
* The previous Wi-Fi state.
- *
+ *
* @see #EXTRA_WIFI_STATE
*/
public static final String EXTRA_PREVIOUS_WIFI_STATE = "previous_wifi_state";
-
+
/**
* Wi-Fi is currently being disabled. The state will change to {@link #WIFI_STATE_DISABLED} if
* it finishes successfully.
- *
+ *
* @see #WIFI_STATE_CHANGED_ACTION
* @see #getWifiState()
*/
public static final int WIFI_STATE_DISABLING = 0;
/**
* Wi-Fi is disabled.
- *
+ *
* @see #WIFI_STATE_CHANGED_ACTION
* @see #getWifiState()
*/
@@ -104,14 +105,14 @@
/**
* Wi-Fi is currently being enabled. The state will change to {@link #WIFI_STATE_ENABLED} if
* it finishes successfully.
- *
+ *
* @see #WIFI_STATE_CHANGED_ACTION
* @see #getWifiState()
*/
public static final int WIFI_STATE_ENABLING = 2;
/**
* Wi-Fi is enabled.
- *
+ *
* @see #WIFI_STATE_CHANGED_ACTION
* @see #getWifiState()
*/
@@ -119,7 +120,7 @@
/**
* Wi-Fi is in an unknown state. This state will occur when an error happens while enabling
* or disabling.
- *
+ *
* @see #WIFI_STATE_CHANGED_ACTION
* @see #getWifiState()
*/
@@ -418,6 +419,22 @@
*/
public static final int WIFI_FREQUENCY_BAND_2GHZ = 2;
+ /** List of asyncronous notifications
+ * @hide
+ */
+ public static final int DATA_ACTIVITY_NOTIFICATION = 1;
+
+ //Lowest bit indicates data reception and the second lowest
+ //bit indicates data transmitted
+ /** @hide */
+ public static final int DATA_ACTIVITY_NONE = 0x00;
+ /** @hide */
+ public static final int DATA_ACTIVITY_IN = 0x01;
+ /** @hide */
+ public static final int DATA_ACTIVITY_OUT = 0x02;
+ /** @hide */
+ public static final int DATA_ACTIVITY_INOUT = 0x03;
+
IWifiManager mService;
Handler mHandler;
@@ -478,7 +495,7 @@
* <p/>
* The new network will be marked DISABLED by default. To enable it,
* called {@link #enableNetwork}.
- *
+ *
* @param config the set of variables that describe the configuration,
* contained in a {@link WifiConfiguration} object.
* @return the ID of the newly created network description. This is used in
@@ -518,7 +535,7 @@
/**
* Internal method for doing the RPC that creates a new network description
* or updates an existing one.
- *
+ *
* @param config The possibly sparse object containing the variables that
* are to set or updated in the network description.
* @return the ID of the network on success, {@code -1} on failure.
@@ -705,7 +722,7 @@
* Note: It is possible for this method to change the network IDs of
* existing networks. You should assume the network IDs can be different
* after calling this method.
- *
+ *
* @return {@code true} if the operation succeeded
*/
public boolean saveConfiguration() {
@@ -816,20 +833,20 @@
return WIFI_STATE_UNKNOWN;
}
}
-
+
/**
- * Return whether Wi-Fi is enabled or disabled.
+ * Return whether Wi-Fi is enabled or disabled.
* @return {@code true} if Wi-Fi is enabled
* @see #getWifiState()
*/
public boolean isWifiEnabled() {
return getWifiState() == WIFI_STATE_ENABLED;
}
-
+
/**
* Calculates the level of the signal. This should be used any time a signal
* is being shown.
- *
+ *
* @param rssi The power of the signal measured in RSSI.
* @param numLevels The number of levels to consider in the calculated
* level.
@@ -847,10 +864,10 @@
return (int)((float)(rssi - MIN_RSSI) * outputRange / inputRange);
}
}
-
+
/**
* Compares two signal strengths.
- *
+ *
* @param rssiA The power of the first signal measured in RSSI.
* @param rssiB The power of the second signal measured in RSSI.
* @return Returns <0 if the first signal is weaker than the second signal,
@@ -1115,9 +1132,24 @@
}
/**
+ * Get a reference to WifiService handler. This is used by a client to establish
+ * an AsyncChannel communication with WifiService
+ *
+ * @return Messenger pointing to the WifiService handler
+ * @hide
+ */
+ public Messenger getMessenger() {
+ try {
+ return mService.getMessenger();
+ } catch (RemoteException e) {
+ return null;
+ }
+ }
+
+ /**
* Allows an application to keep the Wi-Fi radio awake.
* Normally the Wi-Fi radio may turn off when the user has not used the device in a while.
- * Acquiring a WifiLock will keep the radio on until the lock is released. Multiple
+ * Acquiring a WifiLock will keep the radio on until the lock is released. Multiple
* applications may hold WifiLocks, and the radio will only be allowed to turn off when no
* WifiLocks are held in any application.
*
@@ -1153,7 +1185,7 @@
* Locks the Wi-Fi radio on until {@link #release} is called.
*
* If this WifiLock is reference-counted, each call to {@code acquire} will increment the
- * reference count, and the radio will remain locked as long as the reference count is
+ * reference count, and the radio will remain locked as long as the reference count is
* above zero.
*
* If this WifiLock is not reference-counted, the first call to {@code acquire} will lock
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 26fae7f..fc42ab8 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -435,10 +435,11 @@
private final IBatteryStats mBatteryStats;
- public WifiStateMachine(Context context) {
+ public WifiStateMachine(Context context, String wlanInterface) {
super(TAG);
mContext = context;
+ mInterfaceName = wlanInterface;
mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0, NETWORKTYPE, "");
mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService("batteryinfo"));
@@ -449,7 +450,6 @@
mWifiMonitor = new WifiMonitor(this);
mDhcpInfoInternal = new DhcpInfoInternal();
mWifiInfo = new WifiInfo();
- mInterfaceName = SystemProperties.get("wifi.interface", "tiwlan0");
mSupplicantStateTracker = new SupplicantStateTracker(context, this, getHandler());
mWpsStateMachine = new WpsStateMachine(context, this, getHandler());
mLinkProperties = new LinkProperties();