Search in sources :

Example 1 with TaskThumbnailInfo

use of android.app.ActivityManager.TaskThumbnailInfo in project android_frameworks_base by ResurrectionRemix.

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.valueOf(attrValue);
        } else if (ATTR_AUTOREMOVERECENTS.equals(attrName)) {
            autoRemoveRecents = Boolean.valueOf(attrValue);
        } else if (ATTR_ASKEDCOMPATMODE.equals(attrName)) {
            askedCompatMode = Boolean.valueOf(attrValue);
        } else if (ATTR_USERID.equals(attrName)) {
            userId = Integer.parseInt(attrValue);
        } else if (ATTR_USER_SETUP_COMPLETE.equals(attrName)) {
            userSetupComplete = Boolean.valueOf(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.valueOf(attrValue);
        } else if (ATTR_LASTACTIVETIME.equals(attrName)) {
            lastActiveTime = Long.valueOf(attrValue);
        } else if (ATTR_LASTDESCRIPTION.equals(attrName)) {
            lastDescription = attrValue;
        } else if (ATTR_LASTTIMEMOVED.equals(attrName)) {
            lastTimeOnTop = Long.valueOf(attrValue);
        } else if (ATTR_NEVERRELINQUISH.equals(attrName)) {
            neverRelinquishIdentity = Boolean.valueOf(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.valueOf(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;
}
Also used : Rect(android.graphics.Rect) ArrayList(java.util.ArrayList) ApplicationInfo(android.content.pm.ApplicationInfo) Intent(android.content.Intent) Point(android.graphics.Point) TaskDescription(android.app.ActivityManager.TaskDescription) IPackageManager(android.content.pm.IPackageManager) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException) TaskThumbnailInfo(android.app.ActivityManager.TaskThumbnailInfo)

Example 2 with TaskThumbnailInfo

use of android.app.ActivityManager.TaskThumbnailInfo in project android_frameworks_base by DirtyUnicorns.

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.valueOf(attrValue);
        } else if (ATTR_AUTOREMOVERECENTS.equals(attrName)) {
            autoRemoveRecents = Boolean.valueOf(attrValue);
        } else if (ATTR_ASKEDCOMPATMODE.equals(attrName)) {
            askedCompatMode = Boolean.valueOf(attrValue);
        } else if (ATTR_USERID.equals(attrName)) {
            userId = Integer.parseInt(attrValue);
        } else if (ATTR_USER_SETUP_COMPLETE.equals(attrName)) {
            userSetupComplete = Boolean.valueOf(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.valueOf(attrValue);
        } else if (ATTR_LASTACTIVETIME.equals(attrName)) {
            lastActiveTime = Long.valueOf(attrValue);
        } else if (ATTR_LASTDESCRIPTION.equals(attrName)) {
            lastDescription = attrValue;
        } else if (ATTR_LASTTIMEMOVED.equals(attrName)) {
            lastTimeOnTop = Long.valueOf(attrValue);
        } else if (ATTR_NEVERRELINQUISH.equals(attrName)) {
            neverRelinquishIdentity = Boolean.valueOf(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.valueOf(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;
}
Also used : Rect(android.graphics.Rect) ArrayList(java.util.ArrayList) ApplicationInfo(android.content.pm.ApplicationInfo) Intent(android.content.Intent) Point(android.graphics.Point) TaskDescription(android.app.ActivityManager.TaskDescription) IPackageManager(android.content.pm.IPackageManager) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException) TaskThumbnailInfo(android.app.ActivityManager.TaskThumbnailInfo)

Example 3 with TaskThumbnailInfo

use of android.app.ActivityManager.TaskThumbnailInfo in project android_frameworks_base by AOSPA.

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.valueOf(attrValue);
        } else if (ATTR_AUTOREMOVERECENTS.equals(attrName)) {
            autoRemoveRecents = Boolean.valueOf(attrValue);
        } else if (ATTR_ASKEDCOMPATMODE.equals(attrName)) {
            askedCompatMode = Boolean.valueOf(attrValue);
        } else if (ATTR_USERID.equals(attrName)) {
            userId = Integer.parseInt(attrValue);
        } else if (ATTR_USER_SETUP_COMPLETE.equals(attrName)) {
            userSetupComplete = Boolean.valueOf(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.valueOf(attrValue);
        } else if (ATTR_LASTACTIVETIME.equals(attrName)) {
            lastActiveTime = Long.valueOf(attrValue);
        } else if (ATTR_LASTDESCRIPTION.equals(attrName)) {
            lastDescription = attrValue;
        } else if (ATTR_LASTTIMEMOVED.equals(attrName)) {
            lastTimeOnTop = Long.valueOf(attrValue);
        } else if (ATTR_NEVERRELINQUISH.equals(attrName)) {
            neverRelinquishIdentity = Boolean.valueOf(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.valueOf(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;
}
Also used : Rect(android.graphics.Rect) ArrayList(java.util.ArrayList) ApplicationInfo(android.content.pm.ApplicationInfo) Intent(android.content.Intent) Point(android.graphics.Point) TaskDescription(android.app.ActivityManager.TaskDescription) IPackageManager(android.content.pm.IPackageManager) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException) TaskThumbnailInfo(android.app.ActivityManager.TaskThumbnailInfo)

Example 4 with TaskThumbnailInfo

use of android.app.ActivityManager.TaskThumbnailInfo in project platform_frameworks_base by android.

the class ActivityManagerService method addAppTask.

@Override
public int addAppTask(IBinder activityToken, Intent intent, ActivityManager.TaskDescription description, Bitmap thumbnail) throws RemoteException {
    final int callingUid = Binder.getCallingUid();
    final long callingIdent = Binder.clearCallingIdentity();
    try {
        synchronized (this) {
            ActivityRecord r = ActivityRecord.isInStackLocked(activityToken);
            if (r == null) {
                throw new IllegalArgumentException("Activity does not exist; token=" + activityToken);
            }
            ComponentName comp = intent.getComponent();
            if (comp == null) {
                throw new IllegalArgumentException("Intent " + intent + " must specify explicit component");
            }
            if (thumbnail.getWidth() != mThumbnailWidth || thumbnail.getHeight() != mThumbnailHeight) {
                throw new IllegalArgumentException("Bad thumbnail size: got " + thumbnail.getWidth() + "x" + thumbnail.getHeight() + ", require " + mThumbnailWidth + "x" + mThumbnailHeight);
            }
            if (intent.getSelector() != null) {
                intent.setSelector(null);
            }
            if (intent.getSourceBounds() != null) {
                intent.setSourceBounds(null);
            }
            if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) != 0) {
                if ((intent.getFlags() & Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS) == 0) {
                    // The caller has added this as an auto-remove task...  that makes no
                    // sense, so turn off auto-remove.
                    intent.addFlags(Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS);
                }
            }
            if (!comp.equals(mLastAddedTaskComponent) || callingUid != mLastAddedTaskUid) {
                mLastAddedTaskActivity = null;
            }
            ActivityInfo ainfo = mLastAddedTaskActivity;
            if (ainfo == null) {
                ainfo = mLastAddedTaskActivity = AppGlobals.getPackageManager().getActivityInfo(comp, 0, UserHandle.getUserId(callingUid));
                if (ainfo.applicationInfo.uid != callingUid) {
                    throw new SecurityException("Can't add task for another application: target uid=" + ainfo.applicationInfo.uid + ", calling uid=" + callingUid);
                }
            }
            // Use the full screen as the context for the task thumbnail
            final Point displaySize = new Point();
            final TaskThumbnailInfo thumbnailInfo = new TaskThumbnailInfo();
            r.task.stack.getDisplaySize(displaySize);
            thumbnailInfo.taskWidth = displaySize.x;
            thumbnailInfo.taskHeight = displaySize.y;
            thumbnailInfo.screenOrientation = mConfiguration.orientation;
            TaskRecord task = new TaskRecord(this, mStackSupervisor.getNextTaskIdForUserLocked(r.userId), ainfo, intent, description, thumbnailInfo);
            int trimIdx = mRecentTasks.trimForTaskLocked(task, false);
            if (trimIdx >= 0) {
                // means it would be added at the end of the list but then just removed.
                return INVALID_TASK_ID;
            }
            final int N = mRecentTasks.size();
            if (N >= (ActivityManager.getMaxRecentTasksStatic() - 1)) {
                final TaskRecord tr = mRecentTasks.remove(N - 1);
                tr.removedFromRecents();
            }
            task.inRecents = true;
            mRecentTasks.add(task);
            r.task.stack.addTask(task, false, "addAppTask");
            task.setLastThumbnailLocked(thumbnail);
            task.freeLastThumbnail();
            return task.taskId;
        }
    } finally {
        Binder.restoreCallingIdentity(callingIdent);
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) ComponentName(android.content.ComponentName) Point(android.graphics.Point) Point(android.graphics.Point) TaskThumbnailInfo(android.app.ActivityManager.TaskThumbnailInfo)

Example 5 with TaskThumbnailInfo

use of android.app.ActivityManager.TaskThumbnailInfo 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;
}
Also used : Rect(android.graphics.Rect) ArrayList(java.util.ArrayList) ApplicationInfo(android.content.pm.ApplicationInfo) Intent(android.content.Intent) Point(android.graphics.Point) TaskDescription(android.app.ActivityManager.TaskDescription) IPackageManager(android.content.pm.IPackageManager) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException) TaskThumbnailInfo(android.app.ActivityManager.TaskThumbnailInfo)

Aggregations

TaskThumbnailInfo (android.app.ActivityManager.TaskThumbnailInfo)7 ComponentName (android.content.ComponentName)7 Point (android.graphics.Point)7 TaskDescription (android.app.ActivityManager.TaskDescription)5 Intent (android.content.Intent)5 ApplicationInfo (android.content.pm.ApplicationInfo)5 IPackageManager (android.content.pm.IPackageManager)5 Rect (android.graphics.Rect)5 RemoteException (android.os.RemoteException)5 ArrayList (java.util.ArrayList)5 ActivityInfo (android.content.pm.ActivityInfo)2