diff options
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/Activity.java | 39 | ||||
| -rw-r--r-- | core/java/android/app/ActivityManager.java | 130 | ||||
| -rw-r--r-- | core/java/android/app/ActivityManagerNative.java | 12 | ||||
| -rw-r--r-- | core/java/android/app/IActivityManager.java | 4 | ||||
| -rw-r--r-- | core/java/android/bluetooth/BluetoothSocket.java | 22 | ||||
| -rw-r--r-- | core/java/android/service/trust/TrustAgentService.java | 21 | ||||
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 35 |
7 files changed, 174 insertions, 89 deletions
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 @@ public class Activity extends ContextThemeWrapper 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 @@ public class Activity extends ContextThemeWrapper } /** - * 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.PackageManager; 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 @@ public class ActivityManager { /** * 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 @@ public class ActivityManager { @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 @@ public class ActivityManager { /** * 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 @@ public class ActivityManager { 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 @@ public class ActivityManager { 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 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM 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 @@ class ActivityManagerProxy implements IActivityManager } @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..8434c2a 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -440,7 +440,7 @@ public interface IActivityManager extends IInterface { 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 @@ public interface IActivityManager extends IInterface { 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 @@ import java.nio.ByteBuffer; */ 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 @@ public final class BluetoothSocket implements Closeable { 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 @@ public final class BluetoothSocket implements Closeable { // 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 @@ public final class BluetoothSocket implements Closeable { @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 @@ public final class BluetoothSocket implements Closeable { 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..98f70f4 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 @@ public class TrustAgentService extends Service { }; }; + @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 @@ public final class ViewRootImpl implements ViewParent, 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 @@ public final class ViewRootImpl implements ViewParent, * 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 @@ public final class ViewRootImpl implements ViewParent, 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, |
