Search in sources :

Example 66 with ActivityOptions

use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.

the class ActivityStack method resetTaskIfNeededLocked.

final ActivityRecord resetTaskIfNeededLocked(ActivityRecord taskTop, ActivityRecord newActivity) {
    boolean forceReset = (newActivity.info.flags & ActivityInfo.FLAG_CLEAR_TASK_ON_LAUNCH) != 0;
    if (ACTIVITY_INACTIVE_RESET_TIME > 0 && taskTop.task.getInactiveDuration() > ACTIVITY_INACTIVE_RESET_TIME) {
        if ((newActivity.info.flags & ActivityInfo.FLAG_ALWAYS_RETAIN_TASK_STATE) == 0) {
            forceReset = true;
        }
    }
    final TaskRecord task = taskTop.task;
    /** False until we evaluate the TaskRecord associated with taskTop. Switches to true
         * for remaining tasks. Used for later tasks to reparent to task. */
    boolean taskFound = false;
    /** If ActivityOptions are moved out and need to be aborted or moved to taskTop. */
    ActivityOptions topOptions = null;
    // Preserve the location for reparenting in the new task.
    int reparentInsertionPoint = -1;
    for (int i = mTaskHistory.size() - 1; i >= 0; --i) {
        final TaskRecord targetTask = mTaskHistory.get(i);
        if (targetTask == task) {
            topOptions = resetTargetTaskIfNeededLocked(task, forceReset);
            taskFound = true;
        } else {
            reparentInsertionPoint = resetAffinityTaskIfNeededLocked(targetTask, task, taskFound, forceReset, reparentInsertionPoint);
        }
    }
    int taskNdx = mTaskHistory.indexOf(task);
    if (taskNdx >= 0) {
        do {
            taskTop = mTaskHistory.get(taskNdx--).getTopActivity();
        } while (taskTop == null && taskNdx >= 0);
    }
    if (topOptions != null) {
        // was removed from the task, propagate them to the new real top.
        if (taskTop != null) {
            taskTop.updateOptionsLocked(topOptions);
        } else {
            topOptions.abort();
        }
    }
    return taskTop;
}
Also used : Point(android.graphics.Point) ActivityOptions(android.app.ActivityOptions)

Example 67 with ActivityOptions

use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.

the class ActivityStarter method startConfirmCredentialIntent.

void startConfirmCredentialIntent(Intent intent) {
    intent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | FLAG_ACTIVITY_TASK_ON_HOME);
    final ActivityOptions options = ActivityOptions.makeBasic();
    options.setLaunchTaskId(mSupervisor.getHomeActivity().task.taskId);
    mService.mContext.startActivityAsUser(intent, options.toBundle(), UserHandle.CURRENT);
}
Also used : ActivityOptions(android.app.ActivityOptions)

Example 68 with ActivityOptions

use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.

the class KeyguardBottomAreaView method launchCamera.

public void launchCamera(String source) {
    final Intent intent;
    if (source.equals(CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) || source.equals(CAMERA_LAUNCH_SOURCE_SCREEN_GESTURE) || !mShortcutHelper.isTargetCustom(LockscreenShortcutsHelper.Shortcuts.RIGHT_SHORTCUT)) {
        intent = getCameraIntent();
    } else {
        intent = mShortcutHelper.getIntent(LockscreenShortcutsHelper.Shortcuts.RIGHT_SHORTCUT);
        intent.putExtra(EXTRA_CAMERA_LAUNCH_SOURCE, source);
    }
    boolean wouldLaunchResolverActivity = PreviewInflater.wouldLaunchResolverActivity(mContext, intent, KeyguardUpdateMonitor.getCurrentUser());
    if (intent == SECURE_CAMERA_INTENT && !wouldLaunchResolverActivity) {
        AsyncTask.execute(new Runnable() {

            @Override
            public void run() {
                int result = ActivityManager.START_CANCELED;
                // Normally an activity will set it's requested rotation
                // animation on its window. However when launching an activity
                // causes the orientation to change this is too late. In these cases
                // the default animation is used. This doesn't look good for
                // the camera (as it rotates the camera contents out of sync
                // with physical reality). So, we ask the WindowManager to
                // force the crossfade animation if an orientation change
                // happens to occur during the launch.
                ActivityOptions o = ActivityOptions.makeBasic();
                o.setRotationAnimationHint(WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS);
                try {
                    result = ActivityManagerNative.getDefault().startActivityAsUser(null, getContext().getBasePackageName(), intent, intent.resolveTypeIfNeeded(getContext().getContentResolver()), null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, o.toBundle(), UserHandle.CURRENT.getIdentifier());
                } catch (RemoteException e) {
                    Log.w(TAG, "Unable to start camera activity", e);
                }
                mActivityStarter.preventNextAnimation();
                final boolean launched = isSuccessfulLaunch(result);
                post(new Runnable() {

                    @Override
                    public void run() {
                        unbindCameraPrewarmService(launched);
                    }
                });
            }
        });
    } else {
        // We need to delay starting the activity because ResolverActivity finishes itself if
        // launched behind lockscreen.
        mActivityStarter.startActivity(intent, false, /* dismissShade */
        new ActivityStarter.Callback() {

            @Override
            public void onActivityStarted(int resultCode) {
                unbindCameraPrewarmService(isSuccessfulLaunch(resultCode));
            }
        });
        updateCameraIconColor();
        updatePhoneIconColor();
        updateLockIconColor();
        updateIndicationTextColor();
    }
}
Also used : Intent(android.content.Intent) RemoteException(android.os.RemoteException) ActivityOptions(android.app.ActivityOptions)

Example 69 with ActivityOptions

use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.

the class ActivityRecord method takeOptionsLocked.

ActivityOptions takeOptionsLocked() {
    ActivityOptions opts = pendingOptions;
    pendingOptions = null;
    return opts;
}
Also used : ActivityOptions(android.app.ActivityOptions)

Example 70 with ActivityOptions

use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.

the class RecentsTvTransitionHelper method launchTaskFromRecents.

public void launchTaskFromRecents(final TaskStack stack, @Nullable final Task task, final TaskStackHorizontalGridView stackView, final TaskCardView taskView, final Rect bounds, int destinationStack) {
    final ActivityOptions opts = ActivityOptions.makeBasic();
    if (bounds != null) {
        opts.setLaunchBounds(bounds.isEmpty() ? null : bounds);
    }
    final ActivityOptions.OnAnimationStartedListener animStartedListener;
    if (task.thumbnail != null && task.thumbnail.getWidth() > 0 && task.thumbnail.getHeight() > 0) {
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                // If we are launching into another task, cancel the previous task's
                // window transition
                EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
            }
        };
    } else {
        // This is only the case if the task is not on screen (scrolled offscreen for example)
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
            }
        };
    }
    if (taskView == null) {
        // If there is no task view, then we do not need to worry about animating out occluding
        // task views, and we can launch immediately
        startTaskActivity(stack, task, taskView, opts, animStartedListener);
    } else {
        LaunchTvTaskStartedEvent launchStartedEvent = new LaunchTvTaskStartedEvent(taskView);
        EventBus.getDefault().send(launchStartedEvent);
        startTaskActivity(stack, task, taskView, opts, animStartedListener);
    }
}
Also used : ActivityOptions(android.app.ActivityOptions)

Aggregations

ActivityOptions (android.app.ActivityOptions)178 Intent (android.content.Intent)88 RemoteException (android.os.RemoteException)33 Point (android.graphics.Point)30 RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)20 TaskStack (com.android.systemui.recents.model.TaskStack)20 PendingIntent (android.app.PendingIntent)18 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)15 ActivityManager (android.app.ActivityManager)14 ComponentName (android.content.ComponentName)13 ActivityInfo (android.content.pm.ActivityInfo)13 ResolveInfo (android.content.pm.ResolveInfo)12 UserHandle (android.os.UserHandle)12 Configuration (android.content.res.Configuration)10 ReferrerIntent (com.android.internal.content.ReferrerIntent)10 RecentsTaskLoadPlan (com.android.systemui.recents.model.RecentsTaskLoadPlan)10 Task (com.android.systemui.recents.model.Task)10 Bundle (android.os.Bundle)9 ActivityNotFoundException (android.content.ActivityNotFoundException)8 RecyclerView (android.support.v7.widget.RecyclerView)8