am 35fc6a02: Merge "Implement setActivityLabelAndIcon()."

* commit '35fc6a02aeded9578375af5828e14043164028d5':
  Implement setActivityLabelAndIcon().
This commit is contained in:
Craig Mautner
2014-04-03 20:43:44 +00:00
committed by Android Git Automerger
7 changed files with 60 additions and 94 deletions

View File

@@ -4701,42 +4701,33 @@ public class Activity extends ContextThemeWrapper
}
/**
* Set a label to be used in the Recents task display. The activities of a task are traversed
* in order from the topmost activity to the bottommost. As soon as one activity returns a
* non-null Recents label the traversal is ended and that value will be used in
* {@link ActivityManager.RecentTaskInfo#activityLabel}
* Set a label and icon to be used in the Recents task display. When {@link
* ActivityManager#getRecentTasks} is called, the activities of each task are
* traversed in order from the topmost activity to the bottommost. As soon as one activity is
* found with either a non-null label or a non-null icon set by this call the traversal is
* ended. For each task those values will be returned in {@link
* ActivityManager.RecentTaskInfo#activityLabel} and {@link
* ActivityManager.RecentTaskInfo#activityIcon}. The {link Intent} for the activity that set
* activityLabel and activityIcon will be returned in {@link
* ActivityManager.RecentTaskInfo#activityIntent}
*
* @see ActivityManager#getRecentTasks
* @see ActivityManager.RecentTaskInfo
*
* @param recentsLabel The label to use in the RecentTaskInfo.
* @param activityLabel The label to use in the RecentTaskInfo.
* @param activityIcon The Bitmap to use in the RecentTaskInfo.
*/
public void setRecentsLabel(CharSequence recentsLabel) {
try {
ActivityManagerNative.getDefault().setRecentsLabel(mToken, recentsLabel);
} catch (RemoteException e) {
}
}
/**
* Set an icon to be used in the Recents task display. The activities of a task are traversed
* in order from the topmost activity to the bottommost. As soon as one activity returns a
* non-null Recents icon the traversal is ended and that value will be used in
* {@link ActivityManager.RecentTaskInfo#activityIcon}.
*
* @see ActivityManager#getRecentTasks
*
* @param recentsIcon The Bitmap to use in the RecentTaskInfo.
*/
public void setRecentsIcon(Bitmap recentsIcon) {
public void setActivityLabelAndIcon(CharSequence activityLabel, Bitmap activityIcon) {
final Bitmap scaledIcon;
if (recentsIcon != null) {
if (activityIcon != null) {
final int size = ActivityManager.getLauncherLargeIconSizeInner(this);
scaledIcon = Bitmap.createScaledBitmap(recentsIcon, size, size, true);
scaledIcon = Bitmap.createScaledBitmap(activityIcon, size, size, true);
} else {
scaledIcon = null;
}
try {
ActivityManagerNative.getDefault().setRecentsIcon(mToken, scaledIcon);
ActivityManagerNative.getDefault().setActivityLabelAndIcon(mToken, activityLabel,
scaledIcon);
} catch (RemoteException e) {
}
}

View File

@@ -516,14 +516,14 @@ public class ActivityManager {
public int userId;
/**
* The label of the highest activity in the task stack to have set a label
* {@link Activity#setRecentsLabel}.
* The label of the highest activity in the task stack to have set a label using
* {@link Activity#setActivityLabelAndIcon(CharSequence, android.graphics.Bitmap)}.
*/
public CharSequence activityLabel;
/**
* The Bitmap icon of the highest activity in the task stack to set a Bitmap using
* {@link Activity#setRecentsIcon}.
* {@link Activity#setActivityLabelAndIcon(CharSequence, android.graphics.Bitmap)}.
*/
public Bitmap activityIcon;
@@ -563,11 +563,7 @@ public class ActivityManager {
public void readFromParcel(Parcel source) {
id = source.readInt();
persistentId = source.readInt();
if (source.readInt() != 0) {
baseIntent = Intent.CREATOR.createFromParcel(source);
} else {
baseIntent = null;
}
baseIntent = source.readInt() > 0 ? Intent.CREATOR.createFromParcel(source) : null;
origActivity = ComponentName.readFromParcel(source);
description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
activityLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);

View File

@@ -2129,21 +2129,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
return true;
}
case SET_RECENTS_LABEL_TRANSACTION: {
case SET_ACTIVITY_LABEL_ICON_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
IBinder token = data.readStrongBinder();
CharSequence recentsLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
setRecentsLabel(token, recentsLabel);
reply.writeNoException();
return true;
}
case SET_RECENTS_ICON_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
IBinder token = data.readStrongBinder();
Bitmap recentsIcon = data.readInt() != 0
CharSequence activityLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
Bitmap activityIcon = data.readInt() > 0
? Bitmap.CREATOR.createFromParcel(data) : null;
setRecentsIcon(token, recentsIcon);
setActivityLabelAndIcon(token, activityLabel, activityIcon);
reply.writeNoException();
return true;
}
@@ -4918,32 +4910,22 @@ class ActivityManagerProxy implements IActivityManager
return isInLockTaskMode;
}
public void setRecentsLabel(IBinder token, CharSequence recentsLabel) throws RemoteException
@Override
public void setActivityLabelAndIcon(IBinder token, CharSequence activityLabel,
Bitmap activityIcon) throws RemoteException
{
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(token);
TextUtils.writeToParcel(recentsLabel, data, 0);
mRemote.transact(SET_RECENTS_LABEL_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
reply.readException();
data.recycle();
reply.recycle();
}
public void setRecentsIcon(IBinder token, Bitmap recentsBitmap) throws RemoteException
{
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(token);
if (recentsBitmap != null) {
TextUtils.writeToParcel(activityLabel, data, 0);
if (activityIcon != null) {
data.writeInt(1);
recentsBitmap.writeToParcel(data, 0);
activityIcon.writeToParcel(data, 0);
} else {
data.writeInt(0);
}
mRemote.transact(SET_RECENTS_ICON_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
mRemote.transact(SET_ACTIVITY_LABEL_ICON_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
reply.readException();
data.recycle();
reply.recycle();

View File

@@ -437,10 +437,8 @@ public interface IActivityManager extends IInterface {
public boolean isInLockTaskMode() throws RemoteException;
/** @hide */
public void setRecentsLabel(IBinder token, CharSequence recentsLabel) throws RemoteException;
/** @hide */
public void setRecentsIcon(IBinder token, Bitmap recentsBitmap) throws RemoteException;
public void setActivityLabelAndIcon(IBinder token, CharSequence activityLabel,
Bitmap activityBitmap) throws RemoteException;
/*
* Private non-Binder interfaces
@@ -741,6 +739,5 @@ 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_LABEL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+217;
int SET_RECENTS_ICON_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+218;
int SET_ACTIVITY_LABEL_ICON_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+217;
}