Merge "Animate clock position on Keyguard."
diff --git a/api/current.txt b/api/current.txt
index ed20009..b03c079 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -3348,12 +3348,12 @@
method public final void setProgressBarIndeterminate(boolean);
method public final void setProgressBarIndeterminateVisibility(boolean);
method public final void setProgressBarVisibility(boolean);
- method public void setRecentsActivityValues(android.app.ActivityManager.RecentsActivityValues);
method public void setRequestedOrientation(int);
method public final void setResult(int);
method public final void setResult(int, android.content.Intent);
method public final void setSecondaryProgress(int);
method public void setSharedElementListener(android.app.SharedElementListener);
+ method public void setTaskDescription(android.app.ActivityManager.TaskDescription);
method public void setTitle(java.lang.CharSequence);
method public void setTitle(int);
method public deprecated void setTitleColor(int);
@@ -3478,7 +3478,6 @@
method public void readFromParcel(android.os.Parcel);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator CREATOR;
- field public android.app.ActivityManager.RecentsActivityValues activityValues;
field public android.content.Intent baseIntent;
field public java.lang.CharSequence description;
field public int id;
@@ -3486,21 +3485,6 @@
field public int persistentId;
}
- public static class ActivityManager.RecentsActivityValues implements android.os.Parcelable {
- ctor public ActivityManager.RecentsActivityValues(android.app.ActivityManager.RecentsActivityValues);
- ctor public ActivityManager.RecentsActivityValues(java.lang.CharSequence, android.graphics.Bitmap, int);
- ctor public ActivityManager.RecentsActivityValues(java.lang.CharSequence, android.graphics.Bitmap);
- ctor public ActivityManager.RecentsActivityValues(java.lang.CharSequence);
- ctor public ActivityManager.RecentsActivityValues();
- method public int describeContents();
- method public void readFromParcel(android.os.Parcel);
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator CREATOR;
- field public int colorPrimary;
- field public android.graphics.Bitmap icon;
- field public java.lang.CharSequence label;
- }
-
public static class ActivityManager.RunningAppProcessInfo implements android.os.Parcelable {
ctor public ActivityManager.RunningAppProcessInfo();
ctor public ActivityManager.RunningAppProcessInfo(java.lang.String, int, java.lang.String[]);
@@ -3570,6 +3554,21 @@
field public android.content.ComponentName topActivity;
}
+ public static class ActivityManager.TaskDescription implements android.os.Parcelable {
+ ctor public ActivityManager.TaskDescription(android.app.ActivityManager.TaskDescription);
+ ctor public ActivityManager.TaskDescription(java.lang.CharSequence, android.graphics.Bitmap, int);
+ ctor public ActivityManager.TaskDescription(java.lang.CharSequence, android.graphics.Bitmap);
+ ctor public ActivityManager.TaskDescription(java.lang.CharSequence);
+ ctor public ActivityManager.TaskDescription();
+ method public int describeContents();
+ method public android.graphics.Bitmap getIcon();
+ method public java.lang.CharSequence getLabel();
+ method public int getPrimaryColor();
+ method public void readFromParcel(android.os.Parcel);
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator CREATOR;
+ }
+
public class ActivityOptions {
method public static android.app.ActivityOptions makeCustomAnimation(android.content.Context, int, int);
method public static android.app.ActivityOptions makeScaleUpAnimation(android.view.View, int, int, int, int);
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 87789de..e1a94d7 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -3613,15 +3613,15 @@
theme.applyStyle(resid, false);
}
- // Get the primary color and update the RecentsActivityValues for this activity
+ // Get the primary color and update the TaskDescription for this activity
if (theme != null) {
TypedArray a = theme.obtainStyledAttributes(com.android.internal.R.styleable.Theme);
int colorPrimary = a.getColor(com.android.internal.R.styleable.Theme_colorPrimary, 0);
a.recycle();
if (colorPrimary != 0) {
- ActivityManager.RecentsActivityValues v = new ActivityManager.RecentsActivityValues();
- v.colorPrimary = colorPrimary;
- setRecentsActivityValues(v);
+ ActivityManager.TaskDescription v = new ActivityManager.TaskDescription(null, null,
+ colorPrimary);
+ setTaskDescription(v);
}
}
}
@@ -4926,27 +4926,30 @@
}
/**
- * Sets information describing this Activity for presentation inside the Recents System UI. When
- * {@link ActivityManager#getRecentTasks} is called, the activities of each task are
- * traversed in order from the topmost activity to the bottommost. The traversal continues for
- * each property until a suitable value is found. For each task those values will be returned in
- * {@link android.app.ActivityManager.RecentsActivityValues}.
+ * Sets information describing the task with this activity for presentation inside the Recents
+ * System UI. When {@link ActivityManager#getRecentTasks} is called, the activities of each task
+ * are traversed in order from the topmost activity to the bottommost. The traversal continues
+ * for each property until a suitable value is found. For each task the taskDescription will be
+ * returned in {@link android.app.ActivityManager.TaskDescription}.
*
* @see ActivityManager#getRecentTasks
- * @see android.app.ActivityManager.RecentsActivityValues
+ * @see android.app.ActivityManager.TaskDescription
*
- * @param values The Recents values that describe this activity.
+ * @param taskDescription The TaskDescription properties that describe the task with this activity
*/
- public void setRecentsActivityValues(ActivityManager.RecentsActivityValues values) {
- ActivityManager.RecentsActivityValues activityValues =
- new ActivityManager.RecentsActivityValues(values);
- // Scale the icon down to something reasonable
- if (values.icon != null) {
+ public void setTaskDescription(ActivityManager.TaskDescription taskDescription) {
+ ActivityManager.TaskDescription td;
+ // Scale the icon down to something reasonable if it is provided
+ if (taskDescription.getIcon() != null) {
final int size = ActivityManager.getLauncherLargeIconSizeInner(this);
- activityValues.icon = Bitmap.createScaledBitmap(values.icon, size, size, true);
+ final Bitmap icon = Bitmap.createScaledBitmap(taskDescription.getIcon(), size, size, true);
+ td = new ActivityManager.TaskDescription(taskDescription.getLabel(), icon,
+ taskDescription.getPrimaryColor());
+ } else {
+ td = taskDescription;
}
try {
- ActivityManagerNative.getDefault().setRecentsActivityValues(mToken, activityValues);
+ ActivityManagerNative.getDefault().setTaskDescription(mToken, td);
} catch (RemoteException e) {
}
}
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 1d05320..abcb0d0 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -33,6 +33,7 @@
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.Color;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Debug;
@@ -477,65 +478,84 @@
/**
* Information you can set and retrieve about the current activity within the recent task list.
*/
- public static class RecentsActivityValues implements Parcelable {
- public CharSequence label;
- public Bitmap icon;
- public int colorPrimary;
-
- public RecentsActivityValues(RecentsActivityValues values) {
- copyFrom(values);
- }
+ public static class TaskDescription implements Parcelable {
+ private String mLabel;
+ private Bitmap mIcon;
+ private int mColorPrimary;
/**
- * Creates the RecentsActivityValues to the specified values.
+ * Creates the TaskDescription to the specified values.
*
- * @param label A label and description of the current state of this activity.
- * @param icon An icon that represents the current state of this activity.
- * @param color A color to override the theme's primary color.
+ * @param label A label and description of the current state of this task.
+ * @param icon An icon that represents the current state of this task.
+ * @param colorPrimary A color to override the theme's primary color. This color must be opaque.
*/
- public RecentsActivityValues(CharSequence label, Bitmap icon, int color) {
- this.label = label;
- this.icon = icon;
- this.colorPrimary = color;
+ public TaskDescription(String label, Bitmap icon, int colorPrimary) {
+ if ((colorPrimary != 0) && (Color.alpha(colorPrimary) != 255)) {
+ throw new RuntimeException("A TaskDescription's primary color should be opaque");
+ }
+
+ mLabel = label;
+ mIcon = icon;
+ mColorPrimary = colorPrimary;
}
/**
- * Creates the RecentsActivityValues to the specified values.
+ * Creates the TaskDescription to the specified values.
*
* @param label A label and description of the current state of this activity.
* @param icon An icon that represents the current state of this activity.
*/
- public RecentsActivityValues(CharSequence label, Bitmap icon) {
+ public TaskDescription(String label, Bitmap icon) {
this(label, icon, 0);
}
/**
- * Creates the RecentsActivityValues to the specified values.
+ * Creates the TaskDescription to the specified values.
*
* @param label A label and description of the current state of this activity.
*/
- public RecentsActivityValues(CharSequence label) {
+ public TaskDescription(String label) {
this(label, null, 0);
}
- public RecentsActivityValues() {
+ /**
+ * Creates an empty TaskDescription.
+ */
+ public TaskDescription() {
this(null, null, 0);
}
- private RecentsActivityValues(Parcel source) {
+ /**
+ * Creates a copy of another TaskDescription.
+ */
+ public TaskDescription(TaskDescription td) {
+ this(td.getLabel(), td.getIcon(), td.getPrimaryColor());
+ }
+
+ private TaskDescription(Parcel source) {
readFromParcel(source);
}
/**
- * Do a shallow copy of another set of activity values.
- * @hide
+ * @return The label and description of the current state of this task.
*/
- public void copyFrom(RecentsActivityValues v) {
- if (v != null) {
- label = v.label;
- icon = v.icon;
- colorPrimary = v.colorPrimary;
- }
+ public String getLabel() {
+ return mLabel;
+ }
+
+ /**
+ * @return The icon that represents the current state of this task.
+ */
+ public Bitmap getIcon() {
+ return mIcon;
+ }
+
+ /**
+ * @return The color override on the theme's primary color.
+ */
+ public int getPrimaryColor() {
+ return mColorPrimary;
}
@Override
@@ -545,37 +565,41 @@
@Override
public void writeToParcel(Parcel dest, int flags) {
- TextUtils.writeToParcel(label, dest,
- Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
- if (icon == null) {
+ if (mLabel == null) {
dest.writeInt(0);
} else {
dest.writeInt(1);
- icon.writeToParcel(dest, 0);
+ dest.writeString(mLabel);
}
- dest.writeInt(colorPrimary);
+ if (mIcon == null) {
+ dest.writeInt(0);
+ } else {
+ dest.writeInt(1);
+ mIcon.writeToParcel(dest, 0);
+ }
+ dest.writeInt(mColorPrimary);
}
public void readFromParcel(Parcel source) {
- label = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
- icon = source.readInt() > 0 ? Bitmap.CREATOR.createFromParcel(source) : null;
- colorPrimary = source.readInt();
+ mLabel = source.readInt() > 0 ? source.readString() : null;
+ mIcon = source.readInt() > 0 ? Bitmap.CREATOR.createFromParcel(source) : null;
+ mColorPrimary = source.readInt();
}
- public static final Creator<RecentsActivityValues> CREATOR
- = new Creator<RecentsActivityValues>() {
- public RecentsActivityValues createFromParcel(Parcel source) {
- return new RecentsActivityValues(source);
+ public static final Creator<TaskDescription> CREATOR
+ = new Creator<TaskDescription>() {
+ public TaskDescription createFromParcel(Parcel source) {
+ return new TaskDescription(source);
}
- public RecentsActivityValues[] newArray(int size) {
- return new RecentsActivityValues[size];
+ public TaskDescription[] newArray(int size) {
+ return new TaskDescription[size];
}
};
@Override
public String toString() {
- return "RecentsActivityValues Label: " + label + " Icon: " + icon +
- " colorPrimary: " + colorPrimary;
+ return "TaskDescription Label: " + mLabel + " Icon: " + mIcon +
+ " colorPrimary: " + mColorPrimary;
}
}
@@ -629,9 +653,11 @@
/**
* The recent activity values for the highest activity in the stack to have set the values.
- * {@link Activity#setRecentsActivityValues(android.app.ActivityManager.RecentsActivityValues)}.
+ * {@link Activity#setTaskDescription(android.app.ActivityManager.TaskDescription)}.
+ *
+ * @hide
*/
- public RecentsActivityValues activityValues;
+ public TaskDescription taskDescription;
public RecentTaskInfo() {
}
@@ -654,9 +680,9 @@
ComponentName.writeToParcel(origActivity, dest);
TextUtils.writeToParcel(description, dest,
Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
- if (activityValues != null) {
+ if (taskDescription != null) {
dest.writeInt(1);
- activityValues.writeToParcel(dest, 0);
+ taskDescription.writeToParcel(dest, 0);
} else {
dest.writeInt(0);
}
@@ -670,8 +696,8 @@
baseIntent = source.readInt() > 0 ? Intent.CREATOR.createFromParcel(source) : null;
origActivity = ComponentName.readFromParcel(source);
description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
- activityValues = source.readInt() > 0 ?
- RecentsActivityValues.CREATOR.createFromParcel(source) : null;
+ taskDescription = source.readInt() > 0 ?
+ TaskDescription.CREATOR.createFromParcel(source) : null;
stackId = source.readInt();
userId = source.readInt();
}
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index e704a1c..0f65454 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -2158,12 +2158,12 @@
return true;
}
- case SET_RECENTS_ACTIVITY_VALUES_TRANSACTION: {
+ case SET_TASK_DESCRIPTION_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
IBinder token = data.readStrongBinder();
- ActivityManager.RecentsActivityValues values =
- ActivityManager.RecentsActivityValues.CREATOR.createFromParcel(data);
- setRecentsActivityValues(token, values);
+ ActivityManager.TaskDescription values =
+ ActivityManager.TaskDescription.CREATOR.createFromParcel(data);
+ setTaskDescription(token, values);
reply.writeNoException();
return true;
}
@@ -4967,14 +4967,14 @@
}
@Override
- public void setRecentsActivityValues(IBinder token, ActivityManager.RecentsActivityValues values)
+ public void setTaskDescription(IBinder token, ActivityManager.TaskDescription values)
throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(token);
values.writeToParcel(data, 0);
- mRemote.transact(SET_RECENTS_ACTIVITY_VALUES_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
+ mRemote.transact(SET_TASK_DESCRIPTION_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
reply.readException();
data.recycle();
reply.recycle();
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 8753312..8434c2a0 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -440,7 +440,7 @@
public boolean isInLockTaskMode() throws RemoteException;
/** @hide */
- public void setRecentsActivityValues(IBinder token, ActivityManager.RecentsActivityValues values)
+ public void setTaskDescription(IBinder token, ActivityManager.TaskDescription values)
throws RemoteException;
/*
@@ -739,7 +739,7 @@
int START_LOCK_TASK_BY_TOKEN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+214;
int STOP_LOCK_TASK_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+215;
int IS_IN_LOCK_TASK_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+216;
- int SET_RECENTS_ACTIVITY_VALUES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+217;
+ int SET_TASK_DESCRIPTION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+217;
int START_VOICE_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+218;
int GET_ACTIVITY_OPTIONS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+219;
int GET_APP_TASKS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+220;
diff --git a/core/java/android/bluetooth/BluetoothSocket.java b/core/java/android/bluetooth/BluetoothSocket.java
index 00fd7ce..b98e5ae 100644
--- a/core/java/android/bluetooth/BluetoothSocket.java
+++ b/core/java/android/bluetooth/BluetoothSocket.java
@@ -81,8 +81,8 @@
*/
public final class BluetoothSocket implements Closeable {
private static final String TAG = "BluetoothSocket";
- private static final boolean DBG = true;
- private static final boolean VDBG = false;
+ private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);
+ private static final boolean VDBG = Log.isLoggable(TAG, Log.VERBOSE);
/** @hide */
public static final int MAX_RFCOMM_CHANNEL = 30;
@@ -185,7 +185,7 @@
BluetoothSocket as = new BluetoothSocket(this);
as.mSocketState = SocketState.CONNECTED;
FileDescriptor[] fds = mSocket.getAncillaryFileDescriptors();
- if (VDBG) Log.d(TAG, "socket fd passed by stack fds: " + fds);
+ if (DBG) Log.d(TAG, "socket fd passed by stack fds: " + fds);
if(fds == null || fds.length != 1) {
Log.e(TAG, "socket fd passed from stack failed, fds: " + fds);
as.close();
@@ -352,24 +352,24 @@
// read out port number
try {
synchronized(this) {
- if (VDBG) Log.d(TAG, "bindListen(), SocketState: " + mSocketState + ", mPfd: " +
+ if (DBG) Log.d(TAG, "bindListen(), SocketState: " + mSocketState + ", mPfd: " +
mPfd);
if(mSocketState != SocketState.INIT) return EBADFD;
if(mPfd == null) return -1;
FileDescriptor fd = mPfd.getFileDescriptor();
- if (VDBG) Log.d(TAG, "bindListen(), new LocalSocket ");
+ if (DBG) Log.d(TAG, "bindListen(), new LocalSocket ");
mSocket = new LocalSocket(fd);
- if (VDBG) Log.d(TAG, "bindListen(), new LocalSocket.getInputStream() ");
+ if (DBG) Log.d(TAG, "bindListen(), new LocalSocket.getInputStream() ");
mSocketIS = mSocket.getInputStream();
mSocketOS = mSocket.getOutputStream();
}
- if (VDBG) Log.d(TAG, "bindListen(), readInt mSocketIS: " + mSocketIS);
+ if (DBG) Log.d(TAG, "bindListen(), readInt mSocketIS: " + mSocketIS);
int channel = readInt(mSocketIS);
synchronized(this) {
if(mSocketState == SocketState.INIT)
mSocketState = SocketState.LISTENING;
}
- if (VDBG) Log.d(TAG, "channel: " + channel);
+ if (DBG) Log.d(TAG, "channel: " + channel);
if (mPort == -1) {
mPort = channel;
} // else ASSERT(mPort == channel)
@@ -439,7 +439,7 @@
@Override
public void close() throws IOException {
- if (VDBG) Log.d(TAG, "close() in, this: " + this + ", channel: " + mPort + ", state: " + mSocketState);
+ if (DBG) Log.d(TAG, "close() in, this: " + this + ", channel: " + mPort + ", state: " + mSocketState);
if(mSocketState == SocketState.CLOSED)
return;
else
@@ -449,10 +449,10 @@
if(mSocketState == SocketState.CLOSED)
return;
mSocketState = SocketState.CLOSED;
- if (VDBG) Log.d(TAG, "close() this: " + this + ", channel: " + mPort + ", mSocketIS: " + mSocketIS +
+ if (DBG) Log.d(TAG, "close() this: " + this + ", channel: " + mPort + ", mSocketIS: " + mSocketIS +
", mSocketOS: " + mSocketOS + "mSocket: " + mSocket);
if(mSocket != null) {
- if (VDBG) Log.d(TAG, "Closing mSocket: " + mSocket);
+ if (DBG) Log.d(TAG, "Closing mSocket: " + mSocket);
mSocket.shutdownInput();
mSocket.shutdownOutput();
mSocket.close();
diff --git a/core/java/android/service/trust/TrustAgentService.java b/core/java/android/service/trust/TrustAgentService.java
index bb40eec..98f70f40 100644
--- a/core/java/android/service/trust/TrustAgentService.java
+++ b/core/java/android/service/trust/TrustAgentService.java
@@ -16,12 +16,17 @@
package android.service.trust;
+import android.Manifest;
import android.annotation.SdkConstant;
import android.app.Service;
+import android.content.ComponentName;
import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ServiceInfo;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
+import android.util.Log;
import android.util.Slog;
/**
@@ -83,6 +88,22 @@
};
};
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ ComponentName component = new ComponentName(this, getClass());
+ try {
+ ServiceInfo serviceInfo = getPackageManager().getServiceInfo(component, 0 /* flags */);
+ if (!Manifest.permission.BIND_TRUST_AGENT.equals(serviceInfo.permission)) {
+ throw new IllegalStateException(component.flattenToShortString()
+ + " is not declared with the permission "
+ + "\"" + Manifest.permission.BIND_TRUST_AGENT + "\"");
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "Can't get ServiceInfo for " + component.toShortString());
+ }
+ }
+
/**
* Called when the user attempted to authenticate on the device.
*
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 35b4bc5..eed6412 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -111,6 +111,7 @@
private static final boolean DEBUG_IMF = false || LOCAL_LOGV;
private static final boolean DEBUG_CONFIGURATION = false || LOCAL_LOGV;
private static final boolean DEBUG_FPS = false;
+ private static final boolean DEBUG_INPUT_STAGES = false || LOCAL_LOGV;
/**
* Set this system property to true to force the view hierarchy to render
@@ -3486,6 +3487,9 @@
* Called when an event is being delivered to the next stage.
*/
protected void onDeliverToNext(QueuedInputEvent q) {
+ if (DEBUG_INPUT_STAGES) {
+ Log.v(TAG, "Done with " + getClass().getSimpleName() + ". " + q);
+ }
if (mNext != null) {
mNext.deliver(q);
} else {
@@ -5520,6 +5524,37 @@
return false;
}
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("QueuedInputEvent{flags=");
+ boolean hasPrevious = false;
+ hasPrevious = flagToString("DELIVER_POST_IME", FLAG_DELIVER_POST_IME, hasPrevious, sb);
+ hasPrevious = flagToString("DEFERRED", FLAG_DEFERRED, hasPrevious, sb);
+ hasPrevious = flagToString("FINISHED", FLAG_FINISHED, hasPrevious, sb);
+ hasPrevious = flagToString("FINISHED_HANDLED", FLAG_FINISHED_HANDLED, hasPrevious, sb);
+ hasPrevious = flagToString("RESYNTHESIZED", FLAG_RESYNTHESIZED, hasPrevious, sb);
+ hasPrevious = flagToString("UNHANDLED", FLAG_UNHANDLED, hasPrevious, sb);
+ if (!hasPrevious) {
+ sb.append("0");
+ }
+ sb.append(", hasNextQueuedEvent=" + (mEvent != null ? "true" : "false"));
+ sb.append(", hasInputEventReceiver=" + (mReceiver != null ? "true" : "false"));
+ sb.append(", mEvent=" + mEvent + "}");
+ return sb.toString();
+ }
+
+ private boolean flagToString(String name, int flag,
+ boolean hasPrevious, StringBuilder sb) {
+ if ((mFlags & flag) != 0) {
+ if (hasPrevious) {
+ sb.append("|");
+ }
+ sb.append(name);
+ return true;
+ }
+ return hasPrevious;
+ }
}
private QueuedInputEvent obtainQueuedInputEvent(InputEvent event,
diff --git a/packages/InputDevices/res/raw/keyboard_layout_latvian_qwerty.kcm b/packages/InputDevices/res/raw/keyboard_layout_latvian_qwerty.kcm
new file mode 100644
index 0000000..d4bc0c0
--- /dev/null
+++ b/packages/InputDevices/res/raw/keyboard_layout_latvian_qwerty.kcm
@@ -0,0 +1,362 @@
+# Copyright (C) 2014 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.
+
+#
+# Latvian (QWERTY-US-intl based) keyboard layout.
+#
+
+type OVERLAY
+
+map key 86 BACKSLASH
+map key 43 POUND
+
+### ROW 1
+
+key GRAVE {
+ label: '\u0300'
+ base: '\u0300'
+ shift: '\u0303'
+ ralt: '-'
+}
+
+key 1 {
+ label: '1'
+ base: '1'
+ shift: '!'
+ ralt: '\u00a0'
+}
+
+key 2 {
+ label: '2'
+ base: '2'
+ shift: '@'
+ ralt: '\u00ab'
+}
+
+key 3 {
+ label: '3'
+ base: '3'
+ shift: '#'
+ ralt: '\u00bb'
+}
+
+key 4 {
+ label: '4'
+ base: '4'
+ shift: '$'
+ ralt: '\u20ac'
+ ralt+shift: '\u00a7'
+}
+
+key 5 {
+ label: '5'
+ base: '5'
+ shift: '%'
+ ralt+shift: '\u00b0'
+}
+
+key 6 {
+ label: '6'
+ base: '6'
+ shift: '\u0302'
+ ralt: '\u2019'
+}
+
+key 7 {
+ label: '7'
+ base: '7'
+ shift: '&'
+ ralt+shift: '\u00b1'
+}
+
+key 8 {
+ label: '8'
+ base: '8'
+ shift: '*'
+ ralt+shift: '\u00d7'
+}
+
+key 9 {
+ label: '9'
+ base: '9'
+ shift: '('
+}
+
+key 0 {
+ label: '0'
+ base: '0'
+ shift: ')'
+}
+
+key MINUS {
+ label: '-'
+ base: '-'
+ shift: '_'
+ ralt: '\u2013'
+ ralt+shift: '\u2014'
+}
+
+key EQUALS {
+ label: '='
+ base: '='
+ shift: '+'
+}
+
+### ROW 2
+
+key Q {
+ label: 'Q'
+ base: 'q'
+ shift, capslock: 'Q'
+}
+
+key W {
+ label: 'W'
+ base: 'w'
+ shift, capslock: 'W'
+}
+
+key E {
+ label: 'E'
+ base: 'e'
+ shift, capslock: 'E'
+ ralt: '\u0113'
+ shift+ralt, ralt+capslock: '\u0112'
+}
+
+key R {
+ label: 'R'
+ base: 'r'
+ shift, capslock: 'R'
+ ralt: '\u0157'
+ shift+ralt, ralt+capslock: '\u0156'
+}
+
+key T {
+ label: 'T'
+ base: 't'
+ shift, capslock: 'T'
+}
+
+key Y {
+ label: 'Y'
+ base: 'y'
+ shift, capslock: 'Y'
+}
+
+key U {
+ label: 'U'
+ base: 'u'
+ shift, capslock: 'U'
+ ralt: '\u016b'
+ shift+ralt, ralt+capslock: '\u016a'
+}
+
+key I {
+ label: 'I'
+ base: 'i'
+ shift, capslock: 'I'
+ ralt: '\u012b'
+ shift+ralt, ralt+capslock: '\u012a'
+}
+
+key O {
+ label: 'O'
+ base: 'o'
+ shift, capslock: 'O'
+ ralt: '\u00f5'
+ shift+ralt, ralt+capslock: '\u00d5'
+}
+
+key P {
+ label: 'P'
+ base: 'p'
+ shift, capslock: 'P'
+}
+
+key LEFT_BRACKET {
+ label: '['
+ base: '['
+ shift: '{'
+}
+
+key RIGHT_BRACKET {
+ label: ']'
+ base: ']'
+ shift: '}'
+}
+
+
+### ROW 3
+
+key A {
+ label: 'A'
+ base: 'a'
+ shift, capslock: 'A'
+ ralt: '\u0101'
+ shift+ralt, ralt+capslock: '\u0100'
+}
+
+key S {
+ label: 'S'
+ base: 's'
+ shift, capslock: 'S'
+ ralt: '\u0161'
+ shift+ralt, ralt+capslock: '\u0160'
+}
+
+key D {
+ label: 'D'
+ base: 'd'
+ shift, capslock: 'D'
+}
+
+key F {
+ label: 'F'
+ base: 'f'
+ shift, capslock: 'F'
+}
+
+key G {
+ label: 'G'
+ base: 'g'
+ shift, capslock: 'G'
+ ralt: '\u0123'
+ shift+ralt, ralt+capslock: '\u0122'
+}
+
+key H {
+ label: 'H'
+ base: 'h'
+ shift, capslock: 'H'
+}
+
+key J {
+ label: 'J'
+ base: 'j'
+ shift, capslock: 'J'
+}
+
+key K {
+ label: 'K'
+ base: 'k'
+ shift, capslock: 'K'
+ ralt: '\u0137'
+ shift+ralt, ralt+capslock: '\u0136'
+}
+
+key L {
+ label: 'L'
+ base: 'l'
+ shift, capslock: 'L'
+ ralt: '\u013c'
+ shift+ralt, ralt+capslock: '\u013b'
+}
+
+key SEMICOLON {
+ label: ';'
+ base: ';'
+ shift: ':'
+}
+
+key APOSTROPHE {
+ label: '\''
+ base: '\''
+ shift: '"'
+ ralt: '\u0301'
+ shift+ralt: '\u0308'
+}
+
+key POUND {
+ label: '\u00b0'
+ base: '\u00b0'
+ shift: '|'
+}
+
+### ROW 4
+
+key BACKSLASH {
+ label: '\\'
+ base: '\\'
+ shift: '|'
+ ralt: '\u00ac'
+ shift+ralt: '\u00a6'
+}
+
+key Z {
+ label: 'Z'
+ base: 'z'
+ shift, capslock: 'Z'
+ ralt: '\u017e'
+ shift+ralt, ralt+capslock: '\u017d'
+}
+
+key X {
+ label: 'X'
+ base: 'x'
+ shift, capslock: 'X'
+}
+
+key C {
+ label: 'C'
+ base: 'c'
+ shift, capslock: 'C'
+ ralt: '\u010d'
+ shift+ralt, ralt+capslock: '\u010c'
+}
+
+key V {
+ label: 'V'
+ base: 'v'
+ shift, capslock: 'V'
+}
+
+key B {
+ label: 'B'
+ base: 'b'
+ shift, capslock: 'B'
+}
+
+key N {
+ label: 'N'
+ base: 'n'
+ shift, capslock: 'N'
+ ralt: '\u0146'
+ shift+ralt, ralt+capslock: '\u0145'
+}
+
+key M {
+ label: 'M'
+ base: 'm'
+ shift, capslock: 'M'
+}
+
+key COMMA {
+ label: ','
+ base: ','
+ shift: '<'
+}
+
+key PERIOD {
+ label: '.'
+ base: '.'
+ shift: '>'
+}
+
+key SLASH {
+ label: '/'
+ base: '/'
+ shift: '?'
+ ralt: '\u00bf'
+}
diff --git a/packages/InputDevices/res/values/strings.xml b/packages/InputDevices/res/values/strings.xml
index 6239336..968961a 100644
--- a/packages/InputDevices/res/values/strings.xml
+++ b/packages/InputDevices/res/values/strings.xml
@@ -113,4 +113,7 @@
<!-- Spanish (Latin) keyboard layout label. [CHAR LIMIT=35] -->
<string name="keyboard_layout_spanish_latin">Spanish (Latin)</string>
+
+ <!-- Latvian keyboard layout label. [CHAR LIMIT=35] -->
+ <string name="keyboard_layout_latvian">Latvian</string>
</resources>
diff --git a/packages/InputDevices/res/xml/keyboard_layouts.xml b/packages/InputDevices/res/xml/keyboard_layouts.xml
index dc1db0b..6f7253c 100644
--- a/packages/InputDevices/res/xml/keyboard_layouts.xml
+++ b/packages/InputDevices/res/xml/keyboard_layouts.xml
@@ -143,4 +143,8 @@
<keyboard-layout android:name="keyboard_layout_spanish_latin"
android:label="@string/keyboard_layout_spanish_latin"
android:keyboardLayout="@raw/keyboard_layout_spanish_latin" />
+
+ <keyboard-layout android:name="keyboard_layout_latvian"
+ android:label="@string/keyboard_layout_latvian"
+ android:keyboardLayout="@raw/keyboard_layout_latvian_qwerty" />
</keyboard-layouts>
diff --git a/packages/Keyguard/test/SampleTrustAgent/AndroidManifest.xml b/packages/Keyguard/test/SampleTrustAgent/AndroidManifest.xml
index 1511911..7904927 100644
--- a/packages/Keyguard/test/SampleTrustAgent/AndroidManifest.xml
+++ b/packages/Keyguard/test/SampleTrustAgent/AndroidManifest.xml
@@ -22,6 +22,7 @@
<service
android:name=".SampleTrustAgent"
android:label="@string/app_name"
+ android:permission="android.permission.BIND_TRUST_AGENT"
android:exported="true">
<intent-filter>
<action android:name="android.service.trust.TrustAgentService" />
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java
index 1ca0476..1c12ac2 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java
@@ -400,15 +400,14 @@
ActivityInfo info = ssp.getActivityInfo(t.baseIntent.getComponent(), t.userId);
if (info == null) continue;
- ActivityManager.RecentsActivityValues av = t.activityValues;
+ ActivityManager.TaskDescription av = t.taskDescription;
String activityLabel = null;
BitmapDrawable activityIcon = null;
int activityColor = 0;
if (av != null) {
- activityLabel = (av.label != null ? av.label.toString() :
- ssp.getActivityLabel(info));
- activityIcon = (av.icon != null) ? new BitmapDrawable(res, av.icon) : null;
- activityColor = av.colorPrimary;
+ activityLabel = (av.getLabel() != null ? av.getLabel() : ssp.getActivityLabel(info));
+ activityIcon = (av.getIcon() != null) ? new BitmapDrawable(res, av.getIcon()) : null;
+ activityColor = av.getPrimaryColor();
} else {
activityLabel = ssp.getActivityLabel(info);
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java
index 8d82883..59d0ea6 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java
@@ -96,18 +96,19 @@
int packageIndex = i % Constants.DebugFlags.App.SystemServicesProxyMockPackageCount;
ComponentName cn = new ComponentName("com.android.test" + packageIndex,
"com.android.test" + i + ".Activity");
+ String description = "" + i + " - " +
+ Long.toString(Math.abs(new Random().nextLong()), 36);
// Create the recent task info
ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo();
rti.id = rti.persistentId = i;
rti.baseIntent = new Intent();
rti.baseIntent.setComponent(cn);
- rti.activityValues = new ActivityManager.RecentsActivityValues();
- rti.description = "" + i + " - " +
- Long.toString(Math.abs(new Random().nextLong()), 36);
+ rti.description = description;
if (i % 2 == 0) {
- rti.activityValues.label = rti.description;
- rti.activityValues.icon = Bitmap.createBitmap(mDummyIcon);
- rti.activityValues.colorPrimary = new Random().nextInt();
+ rti.taskDescription = new ActivityManager.TaskDescription(description,
+ Bitmap.createBitmap(mDummyIcon), new Random().nextInt());
+ } else {
+ rti.taskDescription = new ActivityManager.TaskDescription();
}
tasks.add(rti);
}
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 1b96f1f..e204cb2 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -204,6 +204,8 @@
private int mTextColor = 0;
private int mStatusBarColor = 0;
private int mNavigationBarColor = 0;
+ private boolean mForcedStatusBarColor = false;
+ private boolean mForcedNavigationBarColor = false;
private CharSequence mTitle = null;
@@ -3084,8 +3086,12 @@
}
decor.setOnSystemUiVisibilityChangeListener(decor);
}
- mStatusBarColor = a.getColor(R.styleable.Window_statusBarColor, 0xFF000000);
- mNavigationBarColor = a.getColor(R.styleable.Window_navigationBarColor, 0xFF000000);
+ if (!mForcedStatusBarColor) {
+ mStatusBarColor = a.getColor(R.styleable.Window_statusBarColor, 0xFF000000);
+ }
+ if (!mForcedNavigationBarColor) {
+ mNavigationBarColor = a.getColor(R.styleable.Window_navigationBarColor, 0xFF000000);
+ }
if (mAlwaysReadCloseOnTouchAttr || getContext().getApplicationInfo().targetSdkVersion
>= android.os.Build.VERSION_CODES.HONEYCOMB) {
@@ -4245,19 +4251,29 @@
@Override
public int getStatusBarColor() {
- return 0;
+ return mStatusBarColor;
}
@Override
public void setStatusBarColor(int color) {
+ mStatusBarColor = color;
+ mForcedStatusBarColor = true;
+ if (mDecor != null) {
+ mDecor.updateColorViews(null);
+ }
}
@Override
public int getNavigationBarColor() {
- return 0;
+ return mNavigationBarColor;
}
@Override
public void setNavigationBarColor(int color) {
+ mNavigationBarColor = color;
+ mForcedNavigationBarColor = true;
+ if (mDecor != null) {
+ mDecor.updateColorViews(null);
+ }
}
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index bab5b9c..7abc75f 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -7087,50 +7087,7 @@
rti.description = tr.lastDescription;
rti.stackId = tr.stack.mStackId;
rti.userId = tr.userId;
-
- // Traverse upwards looking for any break between main task activities and
- // utility activities.
- final ArrayList<ActivityRecord> activities = tr.mActivities;
- int activityNdx;
- final int numActivities = activities.size();
- for (activityNdx = Math.min(numActivities, 1); activityNdx < numActivities;
- ++activityNdx) {
- final ActivityRecord r = activities.get(activityNdx);
- if (r.intent != null &&
- (r.intent.getFlags() & Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
- != 0) {
- break;
- }
- }
- if (activityNdx > 0) {
- // Traverse downwards starting below break looking for set label, icon.
- // Note that if there are activities in the task but none of them set the
- // recent activity values, then we do not fall back to the last set
- // values in the TaskRecord.
- rti.activityValues = new ActivityManager.RecentsActivityValues();
- for (--activityNdx; activityNdx >= 0; --activityNdx) {
- final ActivityRecord r = activities.get(activityNdx);
- if (r.activityValues != null) {
- if (rti.activityValues.label == null) {
- rti.activityValues.label = r.activityValues.label;
- tr.lastActivityValues.label = r.activityValues.label;
- }
- if (rti.activityValues.icon == null) {
- rti.activityValues.icon = r.activityValues.icon;
- tr.lastActivityValues.icon = r.activityValues.icon;
- }
- if (rti.activityValues.colorPrimary == 0) {
- rti.activityValues.colorPrimary = r.activityValues.colorPrimary;
- tr.lastActivityValues.colorPrimary = r.activityValues.colorPrimary;
- }
- }
- }
- } else {
- // If there are no activity records in this task, then we use the last
- // resolved values
- rti.activityValues =
- new ActivityManager.RecentsActivityValues(tr.lastActivityValues);
- }
+ rti.taskDescription = new ActivityManager.TaskDescription(tr.lastTaskDescription);
return rti;
}
@@ -7261,11 +7218,12 @@
}
@Override
- public void setRecentsActivityValues(IBinder token, ActivityManager.RecentsActivityValues rav) {
+ public void setTaskDescription(IBinder token, ActivityManager.TaskDescription td) {
synchronized (this) {
ActivityRecord r = ActivityRecord.isInStackLocked(token);
if (r != null) {
- r.activityValues = rav;
+ r.taskDescription = td;
+ r.task.updateTaskDescription();
}
}
}
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index 9582ac7..dbe2ca1 100755
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -149,7 +149,7 @@
boolean mStartingWindowShown = false;
ActivityContainer mInitialActivityContainer;
- ActivityManager.RecentsActivityValues activityValues; // the recents information for this activity
+ ActivityManager.TaskDescription taskDescription; // the recents information for this activity
void dump(PrintWriter pw, String prefix) {
final long now = SystemClock.uptimeMillis();
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index be884e7..6d66b29 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -58,8 +58,8 @@
// This represents the last resolved activity values for this task
// NOTE: This value needs to be persisted with each task
- ActivityManager.RecentsActivityValues lastActivityValues =
- new ActivityManager.RecentsActivityValues();
+ ActivityManager.TaskDescription lastTaskDescription =
+ new ActivityManager.TaskDescription();
/** List of all activities in the task arranged in history order */
final ArrayList<ActivityRecord> mActivities = new ArrayList<ActivityRecord>();
@@ -486,6 +486,48 @@
return null;
}
+ /** Updates the last task description values. */
+ void updateTaskDescription() {
+ // Traverse upwards looking for any break between main task activities and
+ // utility activities.
+ int activityNdx;
+ final int numActivities = mActivities.size();
+ for (activityNdx = Math.min(numActivities, 1); activityNdx < numActivities;
+ ++activityNdx) {
+ final ActivityRecord r = mActivities.get(activityNdx);
+ if (r.intent != null &&
+ (r.intent.getFlags() & Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
+ != 0) {
+ break;
+ }
+ }
+ if (activityNdx > 0) {
+ // Traverse downwards starting below break looking for set label, icon.
+ // Note that if there are activities in the task but none of them set the
+ // recent activity values, then we do not fall back to the last set
+ // values in the TaskRecord.
+ String label = null;
+ Bitmap icon = null;
+ int colorPrimary = 0;
+ for (--activityNdx; activityNdx >= 0; --activityNdx) {
+ final ActivityRecord r = mActivities.get(activityNdx);
+ if (r.taskDescription != null) {
+ if (label == null) {
+ label = r.taskDescription.getLabel();
+ }
+ if (icon == null) {
+ icon = r.taskDescription.getIcon();
+ }
+ if (colorPrimary == 0) {
+ colorPrimary = r.taskDescription.getPrimaryColor();
+
+ }
+ }
+ }
+ lastTaskDescription = new ActivityManager.TaskDescription(label, icon, colorPrimary);
+ }
+ }
+
void dump(PrintWriter pw, String prefix) {
if (numActivities != 0 || rootWasReset || userId != 0 || numFullscreen != 0) {
pw.print(prefix); pw.print("numActivities="); pw.print(numActivities);
diff --git a/services/core/java/com/android/server/connectivity/Nat464Xlat.java b/services/core/java/com/android/server/connectivity/Nat464Xlat.java
index 3884ab0..096ab66 100644
--- a/services/core/java/com/android/server/connectivity/Nat464Xlat.java
+++ b/services/core/java/com/android/server/connectivity/Nat464Xlat.java
@@ -74,6 +74,14 @@
mIsStarted = false;
mIsRunning = false;
mLP = new LinkProperties();
+
+ // If this is a runtime restart, it's possible that clatd is already
+ // running, but we don't know about it. If so, stop it.
+ try {
+ if (mNMService.isClatdStarted()) {
+ mNMService.stopClatd();
+ }
+ } catch(RemoteException e) {} // Well, we tried.
}
/**
@@ -198,13 +206,13 @@
NetworkUtils.resetConnections(
CLAT_INTERFACE_NAME,
NetworkUtils.RESET_IPV4_ADDRESSES);
+ mBaseLP.removeStackedLink(mLP);
+ updateConnectivityService();
}
Slog.i(TAG, "interface " + CLAT_INTERFACE_NAME +
" removed, mIsRunning = " + mIsRunning + " -> false");
mIsRunning = false;
- mBaseLP.removeStackedLink(mLP);
mLP.clear();
- updateConnectivityService();
Slog.i(TAG, "mLP = " + mLP);
}
}
diff --git a/services/core/java/com/android/server/task/controllers/IdleController.java b/services/core/java/com/android/server/task/controllers/IdleController.java
new file mode 100644
index 0000000..a319a31
--- /dev/null
+++ b/services/core/java/com/android/server/task/controllers/IdleController.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.server.task.controllers;
+
+import java.util.ArrayList;
+
+import android.app.AlarmManager;
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.SystemClock;
+import android.util.Slog;
+
+import com.android.server.task.TaskManagerService;
+
+public class IdleController extends StateController {
+ private static final String TAG = "IdleController";
+ private static final boolean DEBUG = false;
+
+ // Policy: we decide that we're "idle" if the device has been unused /
+ // screen off or dreaming for at least this long
+ private static final long INACTIVITY_IDLE_THRESHOLD = 71 * 60 * 1000; // millis; 71 min
+ private static final long IDLE_WINDOW_SLOP = 5 * 60 * 1000; // 5 minute window, to be nice
+
+ private static final String ACTION_TRIGGER_IDLE =
+ "com.android.server.task.controllers.IdleController.ACTION_TRIGGER_IDLE";
+
+ final ArrayList<TaskStatus> mTrackedTasks = new ArrayList<TaskStatus>();
+ IdlenessTracker mIdleTracker;
+
+ // Singleton factory
+ private static Object sCreationLock = new Object();
+ private static volatile IdleController sController;
+
+ public IdleController getController(TaskManagerService service) {
+ synchronized (sCreationLock) {
+ if (sController == null) {
+ sController = new IdleController(service);
+ }
+ return sController;
+ }
+ }
+
+ private IdleController(TaskManagerService service) {
+ super(service);
+ initIdleStateTracking();
+ }
+
+ /**
+ * StateController interface
+ */
+ @Override
+ public void maybeTrackTaskState(TaskStatus taskStatus) {
+ if (taskStatus.hasIdleConstraint()) {
+ synchronized (mTrackedTasks) {
+ mTrackedTasks.add(taskStatus);
+ taskStatus.idleConstraintSatisfied.set(mIdleTracker.isIdle());
+ }
+ }
+ }
+
+ @Override
+ public void removeTaskStateIfTracked(TaskStatus taskStatus) {
+ synchronized (mTrackedTasks) {
+ mTrackedTasks.remove(taskStatus);
+ }
+ }
+
+ /**
+ * Interaction with the task manager service
+ */
+ void reportNewIdleState(boolean isIdle) {
+ synchronized (mTrackedTasks) {
+ for (TaskStatus task : mTrackedTasks) {
+ task.idleConstraintSatisfied.set(isIdle);
+ mStateChangedListener.onTaskStateChanged(task);
+ }
+ }
+ }
+
+ /**
+ * Idle state tracking, and messaging with the task manager when
+ * significant state changes occur
+ */
+ private void initIdleStateTracking() {
+ mIdleTracker = new IdlenessTracker();
+ mIdleTracker.startTracking();
+ }
+
+ class IdlenessTracker extends BroadcastReceiver {
+ private AlarmManager mAlarm;
+ private PendingIntent mIdleTriggerIntent;
+ boolean mIdle;
+
+ public IdlenessTracker() {
+ mAlarm = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
+
+ Intent intent = new Intent(ACTION_TRIGGER_IDLE);
+ intent.setComponent(new ComponentName(mContext, this.getClass()));
+ mIdleTriggerIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
+
+ // at boot we presume that the user has just "interacted" with the
+ // device in some meaningful way
+ mIdle = false;
+ }
+
+ public boolean isIdle() {
+ return mIdle;
+ }
+
+ public void startTracking() {
+ IntentFilter filter = new IntentFilter();
+
+ // Screen state
+ filter.addAction(Intent.ACTION_SCREEN_ON);
+ filter.addAction(Intent.ACTION_SCREEN_OFF);
+
+ // Dreaming state
+ filter.addAction(Intent.ACTION_DREAMING_STARTED);
+ filter.addAction(Intent.ACTION_DREAMING_STOPPED);
+
+ mContext.registerReceiver(this, filter);
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ final String action = intent.getAction();
+
+ if (action.equals(Intent.ACTION_SCREEN_ON)
+ || action.equals(Intent.ACTION_DREAMING_STOPPED)) {
+ // possible transition to not-idle
+ if (mIdle) {
+ if (DEBUG) {
+ Slog.v(TAG, "exiting idle : " + action);
+ }
+ mAlarm.cancel(mIdleTriggerIntent);
+ mIdle = false;
+ reportNewIdleState(mIdle);
+ }
+ } else if (action.equals(Intent.ACTION_SCREEN_OFF)
+ || action.equals(Intent.ACTION_DREAMING_STARTED)) {
+ // when the screen goes off or dreaming starts, we schedule the
+ // alarm that will tell us when we have decided the device is
+ // truly idle.
+ long when = SystemClock.elapsedRealtime() + INACTIVITY_IDLE_THRESHOLD;
+ if (DEBUG) {
+ Slog.v(TAG, "Scheduling idle : " + action + " when=" + when);
+ }
+ mAlarm.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+ when, IDLE_WINDOW_SLOP, mIdleTriggerIntent);
+ } else if (action.equals(ACTION_TRIGGER_IDLE)) {
+ // idle time starts now
+ if (!mIdle) {
+ if (DEBUG) {
+ Slog.v(TAG, "Idle trigger fired @ " + SystemClock.elapsedRealtime());
+ }
+ mIdle = true;
+ reportNewIdleState(mIdle);
+ }
+ }
+ }
+ }
+}
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/CirclePropActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/CirclePropActivity.java
index e4ea9367..4938579 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/CirclePropActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/CirclePropActivity.java
@@ -108,6 +108,7 @@
mToggle = !mToggle;
+ /*
mRunningAnimations.add(new RenderNodeAnimator(
mX, mToggle ? 400.0f : 200.0f));
@@ -146,7 +147,7 @@
}
});
}
-
+ */
return true;
}
}