use of android.app.ActivityManager.TaskDescription in project android_frameworks_base by ResurrectionRemix.
the class TaskRecord method updateTaskDescription.
/** 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();
final boolean relinquish = numActivities == 0 ? false : (mActivities.get(0).info.flags & ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY) != 0;
for (activityNdx = Math.min(numActivities, 1); activityNdx < numActivities; ++activityNdx) {
final ActivityRecord r = mActivities.get(activityNdx);
if (relinquish && (r.info.flags & ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY) == 0) {
// This will be the top activity for determining taskDescription. Pre-inc to
// overcome initial decrement below.
++activityNdx;
break;
}
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;
String iconFilename = null;
int colorPrimary = 0;
int colorBackground = 0;
for (--activityNdx; activityNdx >= 0; --activityNdx) {
final ActivityRecord r = mActivities.get(activityNdx);
if (r.taskDescription != null) {
if (label == null) {
label = r.taskDescription.getLabel();
}
if (iconFilename == null) {
iconFilename = r.taskDescription.getIconFilename();
}
if (colorPrimary == 0) {
colorPrimary = r.taskDescription.getPrimaryColor();
}
if (colorBackground == 0) {
colorBackground = r.taskDescription.getBackgroundColor();
}
}
}
lastTaskDescription = new TaskDescription(label, null, iconFilename, colorPrimary, colorBackground);
// Update the task affiliation color if we are the parent of the group
if (taskId == mAffiliatedTaskId) {
mAffiliatedTaskColor = lastTaskDescription.getPrimaryColor();
}
}
}
use of android.app.ActivityManager.TaskDescription in project android_frameworks_base by crdroidandroid.
the class TaskRecord method updateTaskDescription.
/** 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();
final boolean relinquish = numActivities == 0 ? false : (mActivities.get(0).info.flags & ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY) != 0;
for (activityNdx = Math.min(numActivities, 1); activityNdx < numActivities; ++activityNdx) {
final ActivityRecord r = mActivities.get(activityNdx);
if (relinquish && (r.info.flags & ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY) == 0) {
// This will be the top activity for determining taskDescription. Pre-inc to
// overcome initial decrement below.
++activityNdx;
break;
}
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;
String iconFilename = null;
int colorPrimary = 0;
int colorBackground = 0;
for (--activityNdx; activityNdx >= 0; --activityNdx) {
final ActivityRecord r = mActivities.get(activityNdx);
if (r.taskDescription != null) {
if (label == null) {
label = r.taskDescription.getLabel();
}
if (iconFilename == null) {
iconFilename = r.taskDescription.getIconFilename();
}
if (colorPrimary == 0) {
colorPrimary = r.taskDescription.getPrimaryColor();
}
if (colorBackground == 0) {
colorBackground = r.taskDescription.getBackgroundColor();
}
}
}
lastTaskDescription = new TaskDescription(label, null, iconFilename, colorPrimary, colorBackground);
// Update the task affiliation color if we are the parent of the group
if (taskId == mAffiliatedTaskId) {
mAffiliatedTaskColor = lastTaskDescription.getPrimaryColor();
}
}
}
use of android.app.ActivityManager.TaskDescription in project android_frameworks_base by crdroidandroid.
the class ActivityRecord method restoreFromXml.
static ActivityRecord restoreFromXml(XmlPullParser in, ActivityStackSupervisor stackSupervisor) throws IOException, XmlPullParserException {
Intent intent = null;
PersistableBundle persistentState = null;
int launchedFromUid = 0;
String launchedFromPackage = null;
String resolvedType = null;
boolean componentSpecified = false;
int userId = 0;
long createTime = -1;
final int outerDepth = in.getDepth();
TaskDescription taskDescription = new TaskDescription();
for (int attrNdx = in.getAttributeCount() - 1; attrNdx >= 0; --attrNdx) {
final String attrName = in.getAttributeName(attrNdx);
final String attrValue = in.getAttributeValue(attrNdx);
if (TaskPersister.DEBUG)
Slog.d(TaskPersister.TAG, "ActivityRecord: attribute name=" + attrName + " value=" + attrValue);
if (ATTR_ID.equals(attrName)) {
createTime = Long.valueOf(attrValue);
} else if (ATTR_LAUNCHEDFROMUID.equals(attrName)) {
launchedFromUid = Integer.parseInt(attrValue);
} else if (ATTR_LAUNCHEDFROMPACKAGE.equals(attrName)) {
launchedFromPackage = attrValue;
} else if (ATTR_RESOLVEDTYPE.equals(attrName)) {
resolvedType = attrValue;
} else if (ATTR_COMPONENTSPECIFIED.equals(attrName)) {
componentSpecified = Boolean.valueOf(attrValue);
} else if (ATTR_USERID.equals(attrName)) {
userId = Integer.parseInt(attrValue);
} else if (attrName.startsWith(TaskDescription.ATTR_TASKDESCRIPTION_PREFIX)) {
taskDescription.restoreFromXml(attrName, attrValue);
} else {
Log.d(TAG, "Unknown ActivityRecord attribute=" + attrName);
}
}
int event;
while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && (event != XmlPullParser.END_TAG || in.getDepth() >= outerDepth)) {
if (event == XmlPullParser.START_TAG) {
final String name = in.getName();
if (TaskPersister.DEBUG)
Slog.d(TaskPersister.TAG, "ActivityRecord: START_TAG name=" + name);
if (TAG_INTENT.equals(name)) {
intent = Intent.restoreFromXml(in);
if (TaskPersister.DEBUG)
Slog.d(TaskPersister.TAG, "ActivityRecord: intent=" + intent);
} else if (TAG_PERSISTABLEBUNDLE.equals(name)) {
persistentState = PersistableBundle.restoreFromXml(in);
if (TaskPersister.DEBUG)
Slog.d(TaskPersister.TAG, "ActivityRecord: persistentState=" + persistentState);
} else {
Slog.w(TAG, "restoreActivity: unexpected name=" + name);
XmlUtils.skipCurrentTag(in);
}
}
}
if (intent == null) {
throw new XmlPullParserException("restoreActivity error intent=" + intent);
}
final ActivityManagerService service = stackSupervisor.mService;
final ActivityInfo aInfo = stackSupervisor.resolveActivity(intent, resolvedType, 0, null, userId);
if (aInfo == null) {
throw new XmlPullParserException("restoreActivity resolver error. Intent=" + intent + " resolvedType=" + resolvedType);
}
final ActivityRecord r = new ActivityRecord(service, /*caller*/
null, launchedFromUid, launchedFromPackage, intent, resolvedType, aInfo, service.getConfiguration(), null, null, 0, componentSpecified, false, stackSupervisor, null, null, null);
r.persistentState = persistentState;
r.taskDescription = taskDescription;
r.createTime = createTime;
return r;
}
use of android.app.ActivityManager.TaskDescription in project platform_frameworks_base by android.
the class ActivityRecord method restoreFromXml.
static ActivityRecord restoreFromXml(XmlPullParser in, ActivityStackSupervisor stackSupervisor) throws IOException, XmlPullParserException {
Intent intent = null;
PersistableBundle persistentState = null;
int launchedFromUid = 0;
String launchedFromPackage = null;
String resolvedType = null;
boolean componentSpecified = false;
int userId = 0;
long createTime = -1;
final int outerDepth = in.getDepth();
TaskDescription taskDescription = new TaskDescription();
for (int attrNdx = in.getAttributeCount() - 1; attrNdx >= 0; --attrNdx) {
final String attrName = in.getAttributeName(attrNdx);
final String attrValue = in.getAttributeValue(attrNdx);
if (TaskPersister.DEBUG)
Slog.d(TaskPersister.TAG, "ActivityRecord: attribute name=" + attrName + " value=" + attrValue);
if (ATTR_ID.equals(attrName)) {
createTime = Long.parseLong(attrValue);
} else if (ATTR_LAUNCHEDFROMUID.equals(attrName)) {
launchedFromUid = Integer.parseInt(attrValue);
} else if (ATTR_LAUNCHEDFROMPACKAGE.equals(attrName)) {
launchedFromPackage = attrValue;
} else if (ATTR_RESOLVEDTYPE.equals(attrName)) {
resolvedType = attrValue;
} else if (ATTR_COMPONENTSPECIFIED.equals(attrName)) {
componentSpecified = Boolean.parseBoolean(attrValue);
} else if (ATTR_USERID.equals(attrName)) {
userId = Integer.parseInt(attrValue);
} else if (attrName.startsWith(TaskDescription.ATTR_TASKDESCRIPTION_PREFIX)) {
taskDescription.restoreFromXml(attrName, attrValue);
} else {
Log.d(TAG, "Unknown ActivityRecord attribute=" + attrName);
}
}
int event;
while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && (event != XmlPullParser.END_TAG || in.getDepth() >= outerDepth)) {
if (event == XmlPullParser.START_TAG) {
final String name = in.getName();
if (TaskPersister.DEBUG)
Slog.d(TaskPersister.TAG, "ActivityRecord: START_TAG name=" + name);
if (TAG_INTENT.equals(name)) {
intent = Intent.restoreFromXml(in);
if (TaskPersister.DEBUG)
Slog.d(TaskPersister.TAG, "ActivityRecord: intent=" + intent);
} else if (TAG_PERSISTABLEBUNDLE.equals(name)) {
persistentState = PersistableBundle.restoreFromXml(in);
if (TaskPersister.DEBUG)
Slog.d(TaskPersister.TAG, "ActivityRecord: persistentState=" + persistentState);
} else {
Slog.w(TAG, "restoreActivity: unexpected name=" + name);
XmlUtils.skipCurrentTag(in);
}
}
}
if (intent == null) {
throw new XmlPullParserException("restoreActivity error intent=" + intent);
}
final ActivityManagerService service = stackSupervisor.mService;
final ActivityInfo aInfo = stackSupervisor.resolveActivity(intent, resolvedType, 0, null, userId);
if (aInfo == null) {
throw new XmlPullParserException("restoreActivity resolver error. Intent=" + intent + " resolvedType=" + resolvedType);
}
final ActivityRecord r = new ActivityRecord(service, /*caller*/
null, launchedFromUid, launchedFromPackage, intent, resolvedType, aInfo, service.getConfiguration(), null, null, 0, componentSpecified, false, stackSupervisor, null, null, null);
r.persistentState = persistentState;
r.taskDescription = taskDescription;
r.createTime = createTime;
return r;
}
use of android.app.ActivityManager.TaskDescription in project platform_frameworks_base by android.
the class TaskRecord method restoreFromXml.
static TaskRecord restoreFromXml(XmlPullParser in, ActivityStackSupervisor stackSupervisor) throws IOException, XmlPullParserException {
Intent intent = null;
Intent affinityIntent = null;
ArrayList<ActivityRecord> activities = new ArrayList<>();
ComponentName realActivity = null;
boolean realActivitySuspended = false;
ComponentName origActivity = null;
String affinity = null;
String rootAffinity = null;
boolean hasRootAffinity = false;
boolean rootHasReset = false;
boolean autoRemoveRecents = false;
boolean askedCompatMode = false;
int taskType = ActivityRecord.APPLICATION_ACTIVITY_TYPE;
int userId = 0;
boolean userSetupComplete = true;
int effectiveUid = -1;
String lastDescription = null;
long firstActiveTime = -1;
long lastActiveTime = -1;
long lastTimeOnTop = 0;
boolean neverRelinquishIdentity = true;
int taskId = INVALID_TASK_ID;
final int outerDepth = in.getDepth();
TaskDescription taskDescription = new TaskDescription();
TaskThumbnailInfo thumbnailInfo = new TaskThumbnailInfo();
int taskAffiliation = INVALID_TASK_ID;
int taskAffiliationColor = 0;
int prevTaskId = INVALID_TASK_ID;
int nextTaskId = INVALID_TASK_ID;
int callingUid = -1;
String callingPackage = "";
int resizeMode = RESIZE_MODE_FORCE_RESIZEABLE;
boolean privileged = false;
Rect bounds = null;
int minWidth = INVALID_MIN_SIZE;
int minHeight = INVALID_MIN_SIZE;
for (int attrNdx = in.getAttributeCount() - 1; attrNdx >= 0; --attrNdx) {
final String attrName = in.getAttributeName(attrNdx);
final String attrValue = in.getAttributeValue(attrNdx);
if (TaskPersister.DEBUG)
Slog.d(TaskPersister.TAG, "TaskRecord: attribute name=" + attrName + " value=" + attrValue);
if (ATTR_TASKID.equals(attrName)) {
if (taskId == INVALID_TASK_ID)
taskId = Integer.parseInt(attrValue);
} else if (ATTR_REALACTIVITY.equals(attrName)) {
realActivity = ComponentName.unflattenFromString(attrValue);
} else if (ATTR_REALACTIVITY_SUSPENDED.equals(attrName)) {
realActivitySuspended = Boolean.valueOf(attrValue);
} else if (ATTR_ORIGACTIVITY.equals(attrName)) {
origActivity = ComponentName.unflattenFromString(attrValue);
} else if (ATTR_AFFINITY.equals(attrName)) {
affinity = attrValue;
} else if (ATTR_ROOT_AFFINITY.equals(attrName)) {
rootAffinity = attrValue;
hasRootAffinity = true;
} else if (ATTR_ROOTHASRESET.equals(attrName)) {
rootHasReset = Boolean.parseBoolean(attrValue);
} else if (ATTR_AUTOREMOVERECENTS.equals(attrName)) {
autoRemoveRecents = Boolean.parseBoolean(attrValue);
} else if (ATTR_ASKEDCOMPATMODE.equals(attrName)) {
askedCompatMode = Boolean.parseBoolean(attrValue);
} else if (ATTR_USERID.equals(attrName)) {
userId = Integer.parseInt(attrValue);
} else if (ATTR_USER_SETUP_COMPLETE.equals(attrName)) {
userSetupComplete = Boolean.parseBoolean(attrValue);
} else if (ATTR_EFFECTIVE_UID.equals(attrName)) {
effectiveUid = Integer.parseInt(attrValue);
} else if (ATTR_TASKTYPE.equals(attrName)) {
taskType = Integer.parseInt(attrValue);
} else if (ATTR_FIRSTACTIVETIME.equals(attrName)) {
firstActiveTime = Long.parseLong(attrValue);
} else if (ATTR_LASTACTIVETIME.equals(attrName)) {
lastActiveTime = Long.parseLong(attrValue);
} else if (ATTR_LASTDESCRIPTION.equals(attrName)) {
lastDescription = attrValue;
} else if (ATTR_LASTTIMEMOVED.equals(attrName)) {
lastTimeOnTop = Long.parseLong(attrValue);
} else if (ATTR_NEVERRELINQUISH.equals(attrName)) {
neverRelinquishIdentity = Boolean.parseBoolean(attrValue);
} else if (attrName.startsWith(TaskThumbnailInfo.ATTR_TASK_THUMBNAILINFO_PREFIX)) {
thumbnailInfo.restoreFromXml(attrName, attrValue);
} else if (attrName.startsWith(TaskDescription.ATTR_TASKDESCRIPTION_PREFIX)) {
taskDescription.restoreFromXml(attrName, attrValue);
} else if (ATTR_TASK_AFFILIATION.equals(attrName)) {
taskAffiliation = Integer.parseInt(attrValue);
} else if (ATTR_PREV_AFFILIATION.equals(attrName)) {
prevTaskId = Integer.parseInt(attrValue);
} else if (ATTR_NEXT_AFFILIATION.equals(attrName)) {
nextTaskId = Integer.parseInt(attrValue);
} else if (ATTR_TASK_AFFILIATION_COLOR.equals(attrName)) {
taskAffiliationColor = Integer.parseInt(attrValue);
} else if (ATTR_CALLING_UID.equals(attrName)) {
callingUid = Integer.parseInt(attrValue);
} else if (ATTR_CALLING_PACKAGE.equals(attrName)) {
callingPackage = attrValue;
} else if (ATTR_RESIZE_MODE.equals(attrName)) {
resizeMode = Integer.parseInt(attrValue);
resizeMode = (resizeMode == RESIZE_MODE_CROP_WINDOWS) ? RESIZE_MODE_FORCE_RESIZEABLE : resizeMode;
} else if (ATTR_PRIVILEGED.equals(attrName)) {
privileged = Boolean.parseBoolean(attrValue);
} else if (ATTR_NON_FULLSCREEN_BOUNDS.equals(attrName)) {
bounds = Rect.unflattenFromString(attrValue);
} else if (ATTR_MIN_WIDTH.equals(attrName)) {
minWidth = Integer.parseInt(attrValue);
} else if (ATTR_MIN_HEIGHT.equals(attrName)) {
minHeight = Integer.parseInt(attrValue);
} else {
Slog.w(TAG, "TaskRecord: Unknown attribute=" + attrName);
}
}
int event;
while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && (event != XmlPullParser.END_TAG || in.getDepth() >= outerDepth)) {
if (event == XmlPullParser.START_TAG) {
final String name = in.getName();
if (TaskPersister.DEBUG)
Slog.d(TaskPersister.TAG, "TaskRecord: START_TAG name=" + name);
if (TAG_AFFINITYINTENT.equals(name)) {
affinityIntent = Intent.restoreFromXml(in);
} else if (TAG_INTENT.equals(name)) {
intent = Intent.restoreFromXml(in);
} else if (TAG_ACTIVITY.equals(name)) {
ActivityRecord activity = ActivityRecord.restoreFromXml(in, stackSupervisor);
if (TaskPersister.DEBUG)
Slog.d(TaskPersister.TAG, "TaskRecord: activity=" + activity);
if (activity != null) {
activities.add(activity);
}
} else {
Slog.e(TAG, "restoreTask: Unexpected name=" + name);
XmlUtils.skipCurrentTag(in);
}
}
}
if (!hasRootAffinity) {
rootAffinity = affinity;
} else if ("@".equals(rootAffinity)) {
rootAffinity = null;
}
if (effectiveUid <= 0) {
Intent checkIntent = intent != null ? intent : affinityIntent;
effectiveUid = 0;
if (checkIntent != null) {
IPackageManager pm = AppGlobals.getPackageManager();
try {
ApplicationInfo ai = pm.getApplicationInfo(checkIntent.getComponent().getPackageName(), PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS, userId);
if (ai != null) {
effectiveUid = ai.uid;
}
} catch (RemoteException e) {
}
}
Slog.w(TAG, "Updating task #" + taskId + " for " + checkIntent + ": effectiveUid=" + effectiveUid);
}
final TaskRecord task = new TaskRecord(stackSupervisor.mService, taskId, intent, affinityIntent, affinity, rootAffinity, realActivity, origActivity, rootHasReset, autoRemoveRecents, askedCompatMode, taskType, userId, effectiveUid, lastDescription, activities, firstActiveTime, lastActiveTime, lastTimeOnTop, neverRelinquishIdentity, taskDescription, thumbnailInfo, taskAffiliation, prevTaskId, nextTaskId, taskAffiliationColor, callingUid, callingPackage, resizeMode, privileged, realActivitySuspended, userSetupComplete, minWidth, minHeight);
task.updateOverrideConfiguration(bounds);
for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
activities.get(activityNdx).task = task;
}
if (DEBUG_RECENTS)
Slog.d(TAG_RECENTS, "Restored task=" + task);
return task;
}
Aggregations