| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.app; |
| 18 |
|
| 19 |
import static android.Manifest.permission.CONTROL_KEYGUARD; |
| 20 |
import static android.Manifest.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS; |
| 21 |
import static android.Manifest.permission.START_TASKS_FROM_RECENTS; |
| 22 |
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; |
| 23 |
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; |
| 24 |
import static android.view.Display.INVALID_DISPLAY; |
| 25 |
import static android.window.DisplayAreaOrganizer.FEATURE_UNDEFINED; |
| 26 |
|
| 27 |
import android.annotation.IntDef; |
| 28 |
import android.annotation.NonNull; |
| 29 |
import android.annotation.Nullable; |
| 30 |
import android.annotation.RequiresPermission; |
| 31 |
import android.annotation.SystemApi; |
| 32 |
import android.annotation.TestApi; |
| 33 |
import android.app.ExitTransitionCoordinator.ActivityExitTransitionCallbacks; |
| 34 |
import android.app.ExitTransitionCoordinator.ExitTransitionCallbacks; |
| 35 |
import android.compat.annotation.UnsupportedAppUsage; |
| 36 |
import android.content.ComponentName; |
| 37 |
import android.content.Context; |
| 38 |
import android.content.Intent; |
| 39 |
import android.graphics.Bitmap; |
| 40 |
import android.graphics.Bitmap.Config; |
| 41 |
import android.graphics.Rect; |
| 42 |
import android.hardware.HardwareBuffer; |
| 43 |
import android.os.Bundle; |
| 44 |
import android.os.Handler; |
| 45 |
import android.os.IBinder; |
| 46 |
import android.os.IRemoteCallback; |
| 47 |
import android.os.Parcel; |
| 48 |
import android.os.Parcelable; |
| 49 |
import android.os.RemoteException; |
| 50 |
import android.os.ResultReceiver; |
| 51 |
import android.os.SystemClock; |
| 52 |
import android.os.UserHandle; |
| 53 |
import android.transition.TransitionManager; |
| 54 |
import android.util.Pair; |
| 55 |
import android.util.Slog; |
| 56 |
import android.view.AppTransitionAnimationSpec; |
| 57 |
import android.view.IAppTransitionAnimationSpecsFuture; |
| 58 |
import android.view.RemoteAnimationAdapter; |
| 59 |
import android.view.View; |
| 60 |
import android.view.ViewGroup; |
| 61 |
import android.view.Window; |
| 62 |
import android.window.RemoteTransition; |
| 63 |
import android.window.SplashScreen; |
| 64 |
import android.window.WindowContainerToken; |
| 65 |
|
| 66 |
import java.lang.annotation.Retention; |
| 67 |
import java.lang.annotation.RetentionPolicy; |
| 68 |
import java.util.ArrayList; |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
public class ActivityOptions extends ComponentOptions { |
| 76 |
private static final String TAG = "ActivityOptions"; |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
public static final String EXTRA_USAGE_TIME_REPORT = "android.activity.usage_time"; |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
public static final String EXTRA_USAGE_TIME_REPORT_PACKAGES = "android.usage_time_packages"; |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
public static final String KEY_PACKAGE_NAME = "android:activity.packageName"; |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
public static final String KEY_LAUNCH_BOUNDS = "android:activity.launchBounds"; |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
public static final String KEY_ANIM_TYPE = "android:activity.animType"; |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
public static final String KEY_ANIM_ENTER_RES_ID = "android:activity.animEnterRes"; |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
public static final String KEY_ANIM_EXIT_RES_ID = "android:activity.animExitRes"; |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
public static final String KEY_ANIM_IN_PLACE_RES_ID = "android:activity.animInPlaceRes"; |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
public static final String KEY_ANIM_BACKGROUND_COLOR = "android:activity.backgroundColor"; |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
public static final String KEY_ANIM_THUMBNAIL = "android:activity.animThumbnail"; |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
public static final String KEY_ANIM_START_X = "android:activity.animStartX"; |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
public static final String KEY_ANIM_START_Y = "android:activity.animStartY"; |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
public static final String KEY_ANIM_WIDTH = "android:activity.animWidth"; |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
public static final String KEY_ANIM_HEIGHT = "android:activity.animHeight"; |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
public static final String KEY_ANIM_START_LISTENER = "android:activity.animStartListener"; |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
public static final String KEY_SPLASH_SCREEN_THEME = "android.activity.splashScreenTheme"; |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
public static final String KEY_LEGACY_PERMISSION_PROMPT_ELIGIBLE = |
| 184 |
"android:activity.legacyPermissionPromptEligible"; |
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
private static final String KEY_ANIMATION_FINISHED_LISTENER = |
| 191 |
"android:activity.animationFinishedListener"; |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
private static final String KEY_ANIM_SPECS = "android:activity.animSpecs"; |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
private static final String KEY_LOCK_TASK_MODE = "android:activity.lockTaskMode"; |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
private static final String KEY_LAUNCH_DISPLAY_ID = "android.activity.launchDisplayId"; |
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
private static final String KEY_CALLER_DISPLAY_ID = "android.activity.callerDisplayId"; |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
private static final String KEY_LAUNCH_TASK_DISPLAY_AREA_TOKEN = |
| 224 |
"android.activity.launchTaskDisplayAreaToken"; |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
private static final String KEY_LAUNCH_TASK_DISPLAY_AREA_FEATURE_ID = |
| 232 |
"android.activity.launchTaskDisplayAreaFeatureId"; |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
public static final String KEY_LAUNCH_ROOT_TASK_TOKEN = |
| 240 |
"android.activity.launchRootTaskToken"; |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
public static final String KEY_LAUNCH_TASK_FRAGMENT_TOKEN = |
| 248 |
"android.activity.launchTaskFragmentToken"; |
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
private static final String KEY_LAUNCH_WINDOWING_MODE = "android.activity.windowingMode"; |
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
private static final String KEY_LAUNCH_ACTIVITY_TYPE = "android.activity.activityType"; |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
private static final String KEY_LAUNCH_TASK_ID = "android.activity.launchTaskId"; |
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
private static final String KEY_DISABLE_STARTING_WINDOW = "android.activity.disableStarting"; |
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
private static final String KEY_PENDING_INTENT_LAUNCH_FLAGS = |
| 279 |
"android.activity.pendingIntentLaunchFlags"; |
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
private static final String KEY_TASK_ALWAYS_ON_TOP = "android.activity.alwaysOnTop"; |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
private static final String KEY_TASK_OVERLAY = "android.activity.taskOverlay"; |
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
private static final String KEY_TASK_OVERLAY_CAN_RESUME = |
| 298 |
"android.activity.taskOverlayCanResume"; |
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
private static final String KEY_AVOID_MOVE_TO_FRONT = "android.activity.avoidMoveToFront"; |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
private static final String KEY_FREEZE_RECENT_TASKS_REORDERING = |
| 311 |
"android.activity.freezeRecentTasksReordering"; |
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
private static final String KEY_DISALLOW_ENTER_PICTURE_IN_PICTURE_WHILE_LAUNCHING = |
| 319 |
"android:activity.disallowEnterPictureInPictureWhileLaunching"; |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
private static final String KEY_APPLY_ACTIVITY_FLAGS_FOR_BUBBLES = |
| 327 |
"android:activity.applyActivityFlagsForBubbles"; |
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
private static final String KEY_TRANSITION_COMPLETE_LISTENER |
| 335 |
= "android:activity.transitionCompleteListener"; |
| 336 |
|
| 337 |
private static final String KEY_TRANSITION_IS_RETURNING |
| 338 |
= "android:activity.transitionIsReturning"; |
| 339 |
private static final String KEY_TRANSITION_SHARED_ELEMENTS |
| 340 |
= "android:activity.sharedElementNames"; |
| 341 |
private static final String KEY_RESULT_DATA = "android:activity.resultData"; |
| 342 |
private static final String KEY_RESULT_CODE = "android:activity.resultCode"; |
| 343 |
private static final String KEY_EXIT_COORDINATOR_INDEX |
| 344 |
= "android:activity.exitCoordinatorIndex"; |
| 345 |
|
| 346 |
|
| 347 |
private static final String KEY_SOURCE_INFO = "android.activity.sourceInfo"; |
| 348 |
|
| 349 |
private static final String KEY_USAGE_TIME_REPORT = "android:activity.usageTimeReport"; |
| 350 |
private static final String KEY_ROTATION_ANIMATION_HINT = "android:activity.rotationAnimationHint"; |
| 351 |
|
| 352 |
private static final String KEY_INSTANT_APP_VERIFICATION_BUNDLE |
| 353 |
= "android:instantapps.installerbundle"; |
| 354 |
private static final String KEY_SPECS_FUTURE = "android:activity.specsFuture"; |
| 355 |
private static final String KEY_REMOTE_ANIMATION_ADAPTER |
| 356 |
= "android:activity.remoteAnimationAdapter"; |
| 357 |
private static final String KEY_REMOTE_TRANSITION = |
| 358 |
"android:activity.remoteTransition"; |
| 359 |
|
| 360 |
private static final String KEY_OVERRIDE_TASK_TRANSITION = |
| 361 |
"android:activity.overrideTaskTransition"; |
| 362 |
|
| 363 |
|
| 364 |
private static final String KEY_REMOVE_WITH_TASK_ORGANIZER = |
| 365 |
"android.activity.removeWithTaskOrganizer"; |
| 366 |
|
| 367 |
private static final String KEY_LAUNCHED_FROM_BUBBLE = |
| 368 |
"android.activity.launchTypeBubble"; |
| 369 |
|
| 370 |
|
| 371 |
private static final String KEY_SPLASH_SCREEN_STYLE = |
| 372 |
"android.activity.splashScreenStyle"; |
| 373 |
|
| 374 |
|
| 375 |
private static final String KEY_TRANSIENT_LAUNCH = "android.activity.transientLaunch"; |
| 376 |
|
| 377 |
|
| 378 |
private static final String KEY_LAUNCH_INTO_PIP_PARAMS = |
| 379 |
"android.activity.launchIntoPipParams"; |
| 380 |
|
| 381 |
|
| 382 |
private static final String KEY_DISMISS_KEYGUARD = "android.activity.dismissKeyguard"; |
| 383 |
|
| 384 |
private static final String KEY_IGNORE_PENDING_INTENT_CREATOR_FOREGROUND_STATE = |
| 385 |
"android.activity.ignorePendingIntentCreatorForegroundState"; |
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
public static final String KEY_LAUNCH_COOKIE = "android.activity.launchCookie"; |
| 392 |
|
| 393 |
|
| 394 |
public static final int ANIM_UNDEFINED = -1; |
| 395 |
|
| 396 |
public static final int ANIM_NONE = 0; |
| 397 |
|
| 398 |
public static final int ANIM_CUSTOM = 1; |
| 399 |
|
| 400 |
public static final int ANIM_SCALE_UP = 2; |
| 401 |
|
| 402 |
public static final int ANIM_THUMBNAIL_SCALE_UP = 3; |
| 403 |
|
| 404 |
public static final int ANIM_THUMBNAIL_SCALE_DOWN = 4; |
| 405 |
|
| 406 |
public static final int ANIM_SCENE_TRANSITION = 5; |
| 407 |
|
| 408 |
public static final int ANIM_DEFAULT = 6; |
| 409 |
|
| 410 |
public static final int ANIM_LAUNCH_TASK_BEHIND = 7; |
| 411 |
|
| 412 |
public static final int ANIM_THUMBNAIL_ASPECT_SCALE_UP = 8; |
| 413 |
|
| 414 |
public static final int ANIM_THUMBNAIL_ASPECT_SCALE_DOWN = 9; |
| 415 |
|
| 416 |
public static final int ANIM_CUSTOM_IN_PLACE = 10; |
| 417 |
|
| 418 |
public static final int ANIM_CLIP_REVEAL = 11; |
| 419 |
|
| 420 |
public static final int ANIM_OPEN_CROSS_PROFILE_APPS = 12; |
| 421 |
|
| 422 |
public static final int ANIM_REMOTE_ANIMATION = 13; |
| 423 |
|
| 424 |
public static final int ANIM_FROM_STYLE = 14; |
| 425 |
|
| 426 |
private String mPackageName; |
| 427 |
private Rect mLaunchBounds; |
| 428 |
private int mAnimationType = ANIM_UNDEFINED; |
| 429 |
private int mCustomEnterResId; |
| 430 |
private int mCustomExitResId; |
| 431 |
private int mCustomInPlaceResId; |
| 432 |
private int mCustomBackgroundColor; |
| 433 |
private Bitmap mThumbnail; |
| 434 |
private int mStartX; |
| 435 |
private int mStartY; |
| 436 |
private int mWidth; |
| 437 |
private int mHeight; |
| 438 |
private IRemoteCallback mAnimationStartedListener; |
| 439 |
private IRemoteCallback mAnimationFinishedListener; |
| 440 |
private ResultReceiver mTransitionReceiver; |
| 441 |
private boolean mIsReturning; |
| 442 |
private ArrayList<String> mSharedElementNames; |
| 443 |
private Intent mResultData; |
| 444 |
private int mResultCode; |
| 445 |
private int mExitCoordinatorIndex; |
| 446 |
private PendingIntent mUsageTimeReport; |
| 447 |
private int mLaunchDisplayId = INVALID_DISPLAY; |
| 448 |
private int mCallerDisplayId = INVALID_DISPLAY; |
| 449 |
private WindowContainerToken mLaunchTaskDisplayArea; |
| 450 |
private int mLaunchTaskDisplayAreaFeatureId = FEATURE_UNDEFINED; |
| 451 |
private WindowContainerToken mLaunchRootTask; |
| 452 |
private IBinder mLaunchTaskFragmentToken; |
| 453 |
@WindowConfiguration.WindowingMode |
| 454 |
private int mLaunchWindowingMode = WINDOWING_MODE_UNDEFINED; |
| 455 |
@WindowConfiguration.ActivityType |
| 456 |
private int mLaunchActivityType = ACTIVITY_TYPE_UNDEFINED; |
| 457 |
private int mLaunchTaskId = -1; |
| 458 |
private int mPendingIntentLaunchFlags; |
| 459 |
private boolean mLockTaskMode = false; |
| 460 |
private boolean mDisallowEnterPictureInPictureWhileLaunching; |
| 461 |
private boolean mApplyActivityFlagsForBubbles; |
| 462 |
private boolean mTaskAlwaysOnTop; |
| 463 |
private boolean mTaskOverlay; |
| 464 |
private boolean mTaskOverlayCanResume; |
| 465 |
private boolean mAvoidMoveToFront; |
| 466 |
private boolean mFreezeRecentTasksReordering; |
| 467 |
private AppTransitionAnimationSpec mAnimSpecs[]; |
| 468 |
private SourceInfo mSourceInfo; |
| 469 |
private int mRotationAnimationHint = -1; |
| 470 |
private Bundle mAppVerificationBundle; |
| 471 |
private IAppTransitionAnimationSpecsFuture mSpecsFuture; |
| 472 |
private RemoteAnimationAdapter mRemoteAnimationAdapter; |
| 473 |
private IBinder mLaunchCookie; |
| 474 |
private RemoteTransition mRemoteTransition; |
| 475 |
private boolean mOverrideTaskTransition; |
| 476 |
private String mSplashScreenThemeResName; |
| 477 |
@SplashScreen.SplashScreenStyle |
| 478 |
private int mSplashScreenStyle = SplashScreen.SPLASH_SCREEN_STYLE_UNDEFINED; |
| 479 |
private boolean mIsEligibleForLegacyPermissionPrompt; |
| 480 |
private boolean mRemoveWithTaskOrganizer; |
| 481 |
private boolean mLaunchedFromBubble; |
| 482 |
private boolean mTransientLaunch; |
| 483 |
private PictureInPictureParams mLaunchIntoPipParams; |
| 484 |
private boolean mDismissKeyguard; |
| 485 |
private boolean mIgnorePendingIntentCreatorForegroundState; |
| 486 |
private boolean mDisableStartingWindow; |
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
public static ActivityOptions makeCustomAnimation(Context context, |
| 502 |
int enterResId, int exitResId) { |
| 503 |
return makeCustomAnimation(context, enterResId, exitResId, 0, null, null); |
| 504 |
} |
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
public static @NonNull ActivityOptions makeCustomAnimation(@NonNull Context context, |
| 522 |
int enterResId, int exitResId, int backgroundColor) { |
| 523 |
return makeCustomAnimation(context, enterResId, exitResId, backgroundColor, null, null); |
| 524 |
} |
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
@UnsupportedAppUsage |
| 546 |
public static ActivityOptions makeCustomAnimation(Context context, |
| 547 |
int enterResId, int exitResId, int backgroundColor, Handler handler, |
| 548 |
OnAnimationStartedListener listener) { |
| 549 |
ActivityOptions opts = new ActivityOptions(); |
| 550 |
opts.mPackageName = context.getPackageName(); |
| 551 |
opts.mAnimationType = ANIM_CUSTOM; |
| 552 |
opts.mCustomEnterResId = enterResId; |
| 553 |
opts.mCustomExitResId = exitResId; |
| 554 |
opts.mCustomBackgroundColor = backgroundColor; |
| 555 |
opts.setOnAnimationStartedListener(handler, listener); |
| 556 |
return opts; |
| 557 |
} |
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
@TestApi |
| 581 |
public static @NonNull ActivityOptions makeCustomAnimation(@NonNull Context context, |
| 582 |
int enterResId, int exitResId, int backgroundColor, @Nullable Handler handler, |
| 583 |
@Nullable OnAnimationStartedListener startedListener, |
| 584 |
@Nullable OnAnimationFinishedListener finishedListener) { |
| 585 |
ActivityOptions opts = makeCustomAnimation(context, enterResId, exitResId, backgroundColor, |
| 586 |
handler, startedListener); |
| 587 |
opts.setOnAnimationFinishedListener(handler, finishedListener); |
| 588 |
return opts; |
| 589 |
} |
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
@RequiresPermission(START_TASKS_FROM_RECENTS) |
| 614 |
@TestApi |
| 615 |
public static @NonNull ActivityOptions makeCustomTaskAnimation(@NonNull Context context, |
| 616 |
int enterResId, int exitResId, @Nullable Handler handler, |
| 617 |
@Nullable OnAnimationStartedListener startedListener, |
| 618 |
@Nullable OnAnimationFinishedListener finishedListener) { |
| 619 |
ActivityOptions opts = makeCustomAnimation(context, enterResId, exitResId, 0, |
| 620 |
handler, startedListener, finishedListener); |
| 621 |
opts.mOverrideTaskTransition = true; |
| 622 |
return opts; |
| 623 |
} |
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
public static ActivityOptions makeCustomInPlaceAnimation(Context context, int animId) { |
| 638 |
if (animId == 0) { |
| 639 |
throw new RuntimeException("You must specify a valid animation."); |
| 640 |
} |
| 641 |
|
| 642 |
ActivityOptions opts = new ActivityOptions(); |
| 643 |
opts.mPackageName = context.getPackageName(); |
| 644 |
opts.mAnimationType = ANIM_CUSTOM_IN_PLACE; |
| 645 |
opts.mCustomInPlaceResId = animId; |
| 646 |
return opts; |
| 647 |
} |
| 648 |
|
| 649 |
private void setOnAnimationStartedListener(final Handler handler, |
| 650 |
final OnAnimationStartedListener listener) { |
| 651 |
if (listener != null) { |
| 652 |
mAnimationStartedListener = new IRemoteCallback.Stub() { |
| 653 |
@Override |
| 654 |
public void sendResult(Bundle data) throws RemoteException { |
| 655 |
final long elapsedRealtime = SystemClock.elapsedRealtime(); |
| 656 |
handler.post(new Runnable() { |
| 657 |
@Override public void run() { |
| 658 |
listener.onAnimationStarted(elapsedRealtime); |
| 659 |
} |
| 660 |
}); |
| 661 |
} |
| 662 |
}; |
| 663 |
} |
| 664 |
} |
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
@TestApi |
| 671 |
public interface OnAnimationStartedListener { |
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
void onAnimationStarted(long elapsedRealTime); |
| 676 |
} |
| 677 |
|
| 678 |
private void setOnAnimationFinishedListener(final Handler handler, |
| 679 |
final OnAnimationFinishedListener listener) { |
| 680 |
if (listener != null) { |
| 681 |
mAnimationFinishedListener = new IRemoteCallback.Stub() { |
| 682 |
@Override |
| 683 |
public void sendResult(Bundle data) throws RemoteException { |
| 684 |
final long elapsedRealtime = SystemClock.elapsedRealtime(); |
| 685 |
handler.post(new Runnable() { |
| 686 |
@Override |
| 687 |
public void run() { |
| 688 |
listener.onAnimationFinished(elapsedRealtime); |
| 689 |
} |
| 690 |
}); |
| 691 |
} |
| 692 |
}; |
| 693 |
} |
| 694 |
} |
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
@TestApi |
| 701 |
public interface OnAnimationFinishedListener { |
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
void onAnimationFinished(long elapsedRealTime); |
| 706 |
} |
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
public static ActivityOptions makeScaleUpAnimation(View source, |
| 728 |
int startX, int startY, int width, int height) { |
| 729 |
ActivityOptions opts = new ActivityOptions(); |
| 730 |
opts.mPackageName = source.getContext().getPackageName(); |
| 731 |
opts.mAnimationType = ANIM_SCALE_UP; |
| 732 |
int[] pts = new int[2]; |
| 733 |
source.getLocationOnScreen(pts); |
| 734 |
opts.mStartX = pts[0] + startX; |
| 735 |
opts.mStartY = pts[1] + startY; |
| 736 |
opts.mWidth = width; |
| 737 |
opts.mHeight = height; |
| 738 |
return opts; |
| 739 |
} |
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
public static ActivityOptions makeClipRevealAnimation(View source, |
| 756 |
int startX, int startY, int width, int height) { |
| 757 |
ActivityOptions opts = new ActivityOptions(); |
| 758 |
opts.mAnimationType = ANIM_CLIP_REVEAL; |
| 759 |
int[] pts = new int[2]; |
| 760 |
source.getLocationOnScreen(pts); |
| 761 |
opts.mStartX = pts[0] + startX; |
| 762 |
opts.mStartY = pts[1] + startY; |
| 763 |
opts.mWidth = width; |
| 764 |
opts.mHeight = height; |
| 765 |
return opts; |
| 766 |
} |
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
public static ActivityOptions makeOpenCrossProfileAppsAnimation() { |
| 776 |
ActivityOptions options = new ActivityOptions(); |
| 777 |
options.mAnimationType = ANIM_OPEN_CROSS_PROFILE_APPS; |
| 778 |
return options; |
| 779 |
} |
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
public static ActivityOptions makeThumbnailScaleUpAnimation(View source, |
| 801 |
Bitmap thumbnail, int startX, int startY) { |
| 802 |
return makeThumbnailScaleUpAnimation(source, thumbnail, startX, startY, null); |
| 803 |
} |
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
private static ActivityOptions makeThumbnailScaleUpAnimation(View source, |
| 823 |
Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener) { |
| 824 |
return makeThumbnailAnimation(source, thumbnail, startX, startY, listener, true); |
| 825 |
} |
| 826 |
|
| 827 |
private static ActivityOptions makeThumbnailAnimation(View source, |
| 828 |
Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener, |
| 829 |
boolean scaleUp) { |
| 830 |
ActivityOptions opts = new ActivityOptions(); |
| 831 |
opts.mPackageName = source.getContext().getPackageName(); |
| 832 |
opts.mAnimationType = scaleUp ? ANIM_THUMBNAIL_SCALE_UP : ANIM_THUMBNAIL_SCALE_DOWN; |
| 833 |
opts.mThumbnail = thumbnail; |
| 834 |
int[] pts = new int[2]; |
| 835 |
source.getLocationOnScreen(pts); |
| 836 |
opts.mStartX = pts[0] + startX; |
| 837 |
opts.mStartY = pts[1] + startY; |
| 838 |
opts.setOnAnimationStartedListener(source.getHandler(), listener); |
| 839 |
return opts; |
| 840 |
} |
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
@UnsupportedAppUsage |
| 848 |
public static ActivityOptions makeMultiThumbFutureAspectScaleAnimation(Context context, |
| 849 |
Handler handler, IAppTransitionAnimationSpecsFuture specsFuture, |
| 850 |
OnAnimationStartedListener listener, boolean scaleUp) { |
| 851 |
ActivityOptions opts = new ActivityOptions(); |
| 852 |
opts.mPackageName = context.getPackageName(); |
| 853 |
opts.mAnimationType = scaleUp |
| 854 |
? ANIM_THUMBNAIL_ASPECT_SCALE_UP |
| 855 |
: ANIM_THUMBNAIL_ASPECT_SCALE_DOWN; |
| 856 |
opts.mSpecsFuture = specsFuture; |
| 857 |
opts.setOnAnimationStartedListener(handler, listener); |
| 858 |
return opts; |
| 859 |
} |
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
public static ActivityOptions makeThumbnailAspectScaleDownAnimation(View source, |
| 881 |
Bitmap thumbnail, int startX, int startY, int targetWidth, int targetHeight, |
| 882 |
Handler handler, OnAnimationStartedListener listener) { |
| 883 |
return makeAspectScaledThumbnailAnimation(source, thumbnail, startX, startY, |
| 884 |
targetWidth, targetHeight, handler, listener, false); |
| 885 |
} |
| 886 |
|
| 887 |
private static ActivityOptions makeAspectScaledThumbnailAnimation(View source, Bitmap thumbnail, |
| 888 |
int startX, int startY, int targetWidth, int targetHeight, |
| 889 |
Handler handler, OnAnimationStartedListener listener, boolean scaleUp) { |
| 890 |
ActivityOptions opts = new ActivityOptions(); |
| 891 |
opts.mPackageName = source.getContext().getPackageName(); |
| 892 |
opts.mAnimationType = scaleUp ? ANIM_THUMBNAIL_ASPECT_SCALE_UP : |
| 893 |
ANIM_THUMBNAIL_ASPECT_SCALE_DOWN; |
| 894 |
opts.mThumbnail = thumbnail; |
| 895 |
int[] pts = new int[2]; |
| 896 |
source.getLocationOnScreen(pts); |
| 897 |
opts.mStartX = pts[0] + startX; |
| 898 |
opts.mStartY = pts[1] + startY; |
| 899 |
opts.mWidth = targetWidth; |
| 900 |
opts.mHeight = targetHeight; |
| 901 |
opts.setOnAnimationStartedListener(handler, listener); |
| 902 |
return opts; |
| 903 |
} |
| 904 |
|
| 905 |
|
| 906 |
public static ActivityOptions makeThumbnailAspectScaleDownAnimation(View source, |
| 907 |
AppTransitionAnimationSpec[] specs, Handler handler, |
| 908 |
OnAnimationStartedListener onAnimationStartedListener, |
| 909 |
OnAnimationFinishedListener onAnimationFinishedListener) { |
| 910 |
ActivityOptions opts = new ActivityOptions(); |
| 911 |
opts.mPackageName = source.getContext().getPackageName(); |
| 912 |
opts.mAnimationType = ANIM_THUMBNAIL_ASPECT_SCALE_DOWN; |
| 913 |
opts.mAnimSpecs = specs; |
| 914 |
opts.setOnAnimationStartedListener(handler, onAnimationStartedListener); |
| 915 |
opts.setOnAnimationFinishedListener(handler, onAnimationFinishedListener); |
| 916 |
return opts; |
| 917 |
} |
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
public static ActivityOptions makeSceneTransitionAnimation(Activity activity, |
| 939 |
View sharedElement, String sharedElementName) { |
| 940 |
return makeSceneTransitionAnimation(activity, Pair.create(sharedElement, sharedElementName)); |
| 941 |
} |
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
@SafeVarargs |
| 963 |
public static ActivityOptions makeSceneTransitionAnimation(Activity activity, |
| 964 |
Pair<View, String>... sharedElements) { |
| 965 |
ActivityOptions opts = new ActivityOptions(); |
| 966 |
ExitTransitionCoordinator exit = makeSceneTransitionAnimation( |
| 967 |
new ActivityExitTransitionCallbacks(activity), activity.mExitTransitionListener, |
| 968 |
activity.getWindow(), opts, sharedElements); |
| 969 |
opts.mExitCoordinatorIndex = |
| 970 |
activity.mActivityTransitionState.addExitTransitionCoordinator(exit); |
| 971 |
return opts; |
| 972 |
} |
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
@SafeVarargs |
| 986 |
public static Pair<ActivityOptions, ExitTransitionCoordinator> startSharedElementAnimation( |
| 987 |
Window window, ExitTransitionCallbacks exitCallbacks, SharedElementCallback callback, |
| 988 |
Pair<View, String>... sharedElements) { |
| 989 |
ActivityOptions opts = new ActivityOptions(); |
| 990 |
ExitTransitionCoordinator exit = makeSceneTransitionAnimation( |
| 991 |
exitCallbacks, callback, window, opts, sharedElements); |
| 992 |
opts.mExitCoordinatorIndex = -1; |
| 993 |
return Pair.create(opts, exit); |
| 994 |
} |
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
public static void stopSharedElementAnimation(Window window) { |
| 1005 |
final View decorView = window.getDecorView(); |
| 1006 |
if (decorView == null) { |
| 1007 |
return; |
| 1008 |
} |
| 1009 |
final ExitTransitionCoordinator exit = (ExitTransitionCoordinator) |
| 1010 |
decorView.getTag(com.android.internal.R.id.cross_task_transition); |
| 1011 |
if (exit != null) { |
| 1012 |
exit.cancelPendingTransitions(); |
| 1013 |
decorView.setTagInternal(com.android.internal.R.id.cross_task_transition, null); |
| 1014 |
TransitionManager.endTransitions((ViewGroup) decorView); |
| 1015 |
exit.resetViews(); |
| 1016 |
exit.clearState(); |
| 1017 |
decorView.setVisibility(View.VISIBLE); |
| 1018 |
} |
| 1019 |
} |
| 1020 |
|
| 1021 |
static ExitTransitionCoordinator makeSceneTransitionAnimation( |
| 1022 |
ExitTransitionCallbacks exitCallbacks, SharedElementCallback callback, Window window, |
| 1023 |
ActivityOptions opts, Pair<View, String>[] sharedElements) { |
| 1024 |
if (!window.hasFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)) { |
| 1025 |
opts.mAnimationType = ANIM_DEFAULT; |
| 1026 |
return null; |
| 1027 |
} |
| 1028 |
opts.mAnimationType = ANIM_SCENE_TRANSITION; |
| 1029 |
|
| 1030 |
ArrayList<String> names = new ArrayList<String>(); |
| 1031 |
ArrayList<View> views = new ArrayList<View>(); |
| 1032 |
|
| 1033 |
if (sharedElements != null) { |
| 1034 |
for (int i = 0; i < sharedElements.length; i++) { |
| 1035 |
Pair<View, String> sharedElement = sharedElements[i]; |
| 1036 |
String sharedElementName = sharedElement.second; |
| 1037 |
if (sharedElementName == null) { |
| 1038 |
throw new IllegalArgumentException("Shared element name must not be null"); |
| 1039 |
} |
| 1040 |
names.add(sharedElementName); |
| 1041 |
View view = sharedElement.first; |
| 1042 |
if (view == null) { |
| 1043 |
throw new IllegalArgumentException("Shared element must not be null"); |
| 1044 |
} |
| 1045 |
views.add(sharedElement.first); |
| 1046 |
} |
| 1047 |
} |
| 1048 |
|
| 1049 |
ExitTransitionCoordinator exit = new ExitTransitionCoordinator(exitCallbacks, window, |
| 1050 |
callback, names, names, views, false); |
| 1051 |
opts.mTransitionReceiver = exit; |
| 1052 |
opts.mSharedElementNames = names; |
| 1053 |
opts.mIsReturning = false; |
| 1054 |
return exit; |
| 1055 |
} |
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
@TestApi |
| 1064 |
public static void setExitTransitionTimeout(long timeoutMillis) { |
| 1065 |
ExitTransitionCoordinator.sMaxWaitMillis = timeoutMillis; |
| 1066 |
} |
| 1067 |
|
| 1068 |
|
| 1069 |
static ActivityOptions makeSceneTransitionAnimation(Activity activity, |
| 1070 |
ExitTransitionCoordinator exitCoordinator, ArrayList<String> sharedElementNames, |
| 1071 |
int resultCode, Intent resultData) { |
| 1072 |
ActivityOptions opts = new ActivityOptions(); |
| 1073 |
opts.mAnimationType = ANIM_SCENE_TRANSITION; |
| 1074 |
opts.mSharedElementNames = sharedElementNames; |
| 1075 |
opts.mTransitionReceiver = exitCoordinator; |
| 1076 |
opts.mIsReturning = true; |
| 1077 |
opts.mResultCode = resultCode; |
| 1078 |
opts.mResultData = resultData; |
| 1079 |
if (activity == null) { |
| 1080 |
opts.mExitCoordinatorIndex = -1; |
| 1081 |
} else { |
| 1082 |
opts.mExitCoordinatorIndex = |
| 1083 |
activity.mActivityTransitionState.addExitTransitionCoordinator(exitCoordinator); |
| 1084 |
} |
| 1085 |
return opts; |
| 1086 |
} |
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
public static ActivityOptions makeTaskLaunchBehind() { |
| 1099 |
final ActivityOptions opts = new ActivityOptions(); |
| 1100 |
opts.mAnimationType = ANIM_LAUNCH_TASK_BEHIND; |
| 1101 |
return opts; |
| 1102 |
} |
| 1103 |
|
| 1104 |
|
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
public static ActivityOptions makeBasic() { |
| 1109 |
final ActivityOptions opts = new ActivityOptions(); |
| 1110 |
return opts; |
| 1111 |
} |
| 1112 |
|
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
@RequiresPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS) |
| 1119 |
@UnsupportedAppUsage |
| 1120 |
public static ActivityOptions makeRemoteAnimation( |
| 1121 |
RemoteAnimationAdapter remoteAnimationAdapter) { |
| 1122 |
final ActivityOptions opts = new ActivityOptions(); |
| 1123 |
opts.mRemoteAnimationAdapter = remoteAnimationAdapter; |
| 1124 |
opts.mAnimationType = ANIM_REMOTE_ANIMATION; |
| 1125 |
return opts; |
| 1126 |
} |
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
@RequiresPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS) |
| 1134 |
public static ActivityOptions makeRemoteAnimation(RemoteAnimationAdapter remoteAnimationAdapter, |
| 1135 |
RemoteTransition remoteTransition) { |
| 1136 |
final ActivityOptions opts = new ActivityOptions(); |
| 1137 |
opts.mRemoteAnimationAdapter = remoteAnimationAdapter; |
| 1138 |
opts.mAnimationType = ANIM_REMOTE_ANIMATION; |
| 1139 |
opts.mRemoteTransition = remoteTransition; |
| 1140 |
return opts; |
| 1141 |
} |
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
|
| 1148 |
@RequiresPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS) |
| 1149 |
public static ActivityOptions makeRemoteTransition(RemoteTransition remoteTransition) { |
| 1150 |
final ActivityOptions opts = new ActivityOptions(); |
| 1151 |
opts.mRemoteTransition = remoteTransition; |
| 1152 |
return opts; |
| 1153 |
} |
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
|
| 1162 |
@NonNull |
| 1163 |
public static ActivityOptions makeLaunchIntoPip( |
| 1164 |
@NonNull PictureInPictureParams pictureInPictureParams) { |
| 1165 |
final ActivityOptions opts = new ActivityOptions(); |
| 1166 |
opts.mLaunchIntoPipParams = new PictureInPictureParams.Builder(pictureInPictureParams) |
| 1167 |
.setIsLaunchIntoPip(true) |
| 1168 |
.build(); |
| 1169 |
return opts; |
| 1170 |
} |
| 1171 |
|
| 1172 |
|
| 1173 |
public boolean getLaunchTaskBehind() { |
| 1174 |
return mAnimationType == ANIM_LAUNCH_TASK_BEHIND; |
| 1175 |
} |
| 1176 |
|
| 1177 |
private ActivityOptions() { |
| 1178 |
super(); |
| 1179 |
} |
| 1180 |
|
| 1181 |
|
| 1182 |
public ActivityOptions(Bundle opts) { |
| 1183 |
super(opts); |
| 1184 |
|
| 1185 |
mPackageName = opts.getString(KEY_PACKAGE_NAME); |
| 1186 |
try { |
| 1187 |
mUsageTimeReport = opts.getParcelable(KEY_USAGE_TIME_REPORT, PendingIntent.class); |
| 1188 |
} catch (RuntimeException e) { |
| 1189 |
Slog.w(TAG, e); |
| 1190 |
} |
| 1191 |
mLaunchBounds = opts.getParcelable(KEY_LAUNCH_BOUNDS); |
| 1192 |
mAnimationType = opts.getInt(KEY_ANIM_TYPE, ANIM_UNDEFINED); |
| 1193 |
switch (mAnimationType) { |
| 1194 |
case ANIM_CUSTOM: |
| 1195 |
mCustomEnterResId = opts.getInt(KEY_ANIM_ENTER_RES_ID, 0); |
| 1196 |
mCustomExitResId = opts.getInt(KEY_ANIM_EXIT_RES_ID, 0); |
| 1197 |
mCustomBackgroundColor = opts.getInt(KEY_ANIM_BACKGROUND_COLOR, 0); |
| 1198 |
mAnimationStartedListener = IRemoteCallback.Stub.asInterface( |
| 1199 |
opts.getBinder(KEY_ANIM_START_LISTENER)); |
| 1200 |
break; |
| 1201 |
|
| 1202 |
case ANIM_CUSTOM_IN_PLACE: |
| 1203 |
mCustomInPlaceResId = opts.getInt(KEY_ANIM_IN_PLACE_RES_ID, 0); |
| 1204 |
break; |
| 1205 |
|
| 1206 |
case ANIM_SCALE_UP: |
| 1207 |
case ANIM_CLIP_REVEAL: |
| 1208 |
mStartX = opts.getInt(KEY_ANIM_START_X, 0); |
| 1209 |
mStartY = opts.getInt(KEY_ANIM_START_Y, 0); |
| 1210 |
mWidth = opts.getInt(KEY_ANIM_WIDTH, 0); |
| 1211 |
mHeight = opts.getInt(KEY_ANIM_HEIGHT, 0); |
| 1212 |
break; |
| 1213 |
|
| 1214 |
case ANIM_THUMBNAIL_SCALE_UP: |
| 1215 |
case ANIM_THUMBNAIL_SCALE_DOWN: |
| 1216 |
case ANIM_THUMBNAIL_ASPECT_SCALE_UP: |
| 1217 |
case ANIM_THUMBNAIL_ASPECT_SCALE_DOWN: |
| 1218 |
|
| 1219 |
final HardwareBuffer buffer = opts.getParcelable(KEY_ANIM_THUMBNAIL); |
| 1220 |
if (buffer != null) { |
| 1221 |
mThumbnail = Bitmap.wrapHardwareBuffer(buffer, null); |
| 1222 |
} |
| 1223 |
mStartX = opts.getInt(KEY_ANIM_START_X, 0); |
| 1224 |
mStartY = opts.getInt(KEY_ANIM_START_Y, 0); |
| 1225 |
mWidth = opts.getInt(KEY_ANIM_WIDTH, 0); |
| 1226 |
mHeight = opts.getInt(KEY_ANIM_HEIGHT, 0); |
| 1227 |
mAnimationStartedListener = IRemoteCallback.Stub.asInterface( |
| 1228 |
opts.getBinder(KEY_ANIM_START_LISTENER)); |
| 1229 |
break; |
| 1230 |
|
| 1231 |
case ANIM_SCENE_TRANSITION: |
| 1232 |
mTransitionReceiver = opts.getParcelable(KEY_TRANSITION_COMPLETE_LISTENER); |
| 1233 |
mIsReturning = opts.getBoolean(KEY_TRANSITION_IS_RETURNING, false); |
| 1234 |
mSharedElementNames = opts.getStringArrayList(KEY_TRANSITION_SHARED_ELEMENTS); |
| 1235 |
mResultData = opts.getParcelable(KEY_RESULT_DATA); |
| 1236 |
mResultCode = opts.getInt(KEY_RESULT_CODE); |
| 1237 |
mExitCoordinatorIndex = opts.getInt(KEY_EXIT_COORDINATOR_INDEX); |
| 1238 |
break; |
| 1239 |
} |
| 1240 |
mLockTaskMode = opts.getBoolean(KEY_LOCK_TASK_MODE, false); |
| 1241 |
mLaunchDisplayId = opts.getInt(KEY_LAUNCH_DISPLAY_ID, INVALID_DISPLAY); |
| 1242 |
mCallerDisplayId = opts.getInt(KEY_CALLER_DISPLAY_ID, INVALID_DISPLAY); |
| 1243 |
mLaunchTaskDisplayArea = opts.getParcelable(KEY_LAUNCH_TASK_DISPLAY_AREA_TOKEN); |
| 1244 |
mLaunchTaskDisplayAreaFeatureId = opts.getInt(KEY_LAUNCH_TASK_DISPLAY_AREA_FEATURE_ID, |
| 1245 |
FEATURE_UNDEFINED); |
| 1246 |
mLaunchRootTask = opts.getParcelable(KEY_LAUNCH_ROOT_TASK_TOKEN); |
| 1247 |
mLaunchTaskFragmentToken = opts.getBinder(KEY_LAUNCH_TASK_FRAGMENT_TOKEN); |
| 1248 |
mLaunchWindowingMode = opts.getInt(KEY_LAUNCH_WINDOWING_MODE, WINDOWING_MODE_UNDEFINED); |
| 1249 |
mLaunchActivityType = opts.getInt(KEY_LAUNCH_ACTIVITY_TYPE, ACTIVITY_TYPE_UNDEFINED); |
| 1250 |
mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1); |
| 1251 |
mPendingIntentLaunchFlags = opts.getInt(KEY_PENDING_INTENT_LAUNCH_FLAGS, 0); |
| 1252 |
mTaskAlwaysOnTop = opts.getBoolean(KEY_TASK_ALWAYS_ON_TOP, false); |
| 1253 |
mTaskOverlay = opts.getBoolean(KEY_TASK_OVERLAY, false); |
| 1254 |
mTaskOverlayCanResume = opts.getBoolean(KEY_TASK_OVERLAY_CAN_RESUME, false); |
| 1255 |
mAvoidMoveToFront = opts.getBoolean(KEY_AVOID_MOVE_TO_FRONT, false); |
| 1256 |
mFreezeRecentTasksReordering = opts.getBoolean(KEY_FREEZE_RECENT_TASKS_REORDERING, false); |
| 1257 |
mDisallowEnterPictureInPictureWhileLaunching = opts.getBoolean( |
| 1258 |
KEY_DISALLOW_ENTER_PICTURE_IN_PICTURE_WHILE_LAUNCHING, false); |
| 1259 |
mApplyActivityFlagsForBubbles = opts.getBoolean( |
| 1260 |
KEY_APPLY_ACTIVITY_FLAGS_FOR_BUBBLES, false); |
| 1261 |
if (opts.containsKey(KEY_ANIM_SPECS)) { |
| 1262 |
Parcelable[] specs = opts.getParcelableArray(KEY_ANIM_SPECS); |
| 1263 |
mAnimSpecs = new AppTransitionAnimationSpec[specs.length]; |
| 1264 |
for (int i = specs.length - 1; i >= 0; i--) { |
| 1265 |
mAnimSpecs[i] = (AppTransitionAnimationSpec) specs[i]; |
| 1266 |
} |
| 1267 |
} |
| 1268 |
if (opts.containsKey(KEY_ANIMATION_FINISHED_LISTENER)) { |
| 1269 |
mAnimationFinishedListener = IRemoteCallback.Stub.asInterface( |
| 1270 |
opts.getBinder(KEY_ANIMATION_FINISHED_LISTENER)); |
| 1271 |
} |
| 1272 |
mSourceInfo = opts.getParcelable(KEY_SOURCE_INFO); |
| 1273 |
mRotationAnimationHint = opts.getInt(KEY_ROTATION_ANIMATION_HINT, -1); |
| 1274 |
mAppVerificationBundle = opts.getBundle(KEY_INSTANT_APP_VERIFICATION_BUNDLE); |
| 1275 |
if (opts.containsKey(KEY_SPECS_FUTURE)) { |
| 1276 |
mSpecsFuture = IAppTransitionAnimationSpecsFuture.Stub.asInterface(opts.getBinder( |
| 1277 |
KEY_SPECS_FUTURE)); |
| 1278 |
} |
| 1279 |
mRemoteAnimationAdapter = opts.getParcelable(KEY_REMOTE_ANIMATION_ADAPTER); |
| 1280 |
mLaunchCookie = opts.getBinder(KEY_LAUNCH_COOKIE); |
| 1281 |
mRemoteTransition = opts.getParcelable(KEY_REMOTE_TRANSITION); |
| 1282 |
mOverrideTaskTransition = opts.getBoolean(KEY_OVERRIDE_TASK_TRANSITION); |
| 1283 |
mSplashScreenThemeResName = opts.getString(KEY_SPLASH_SCREEN_THEME); |
| 1284 |
mRemoveWithTaskOrganizer = opts.getBoolean(KEY_REMOVE_WITH_TASK_ORGANIZER); |
| 1285 |
mLaunchedFromBubble = opts.getBoolean(KEY_LAUNCHED_FROM_BUBBLE); |
| 1286 |
mTransientLaunch = opts.getBoolean(KEY_TRANSIENT_LAUNCH); |
| 1287 |
mSplashScreenStyle = opts.getInt(KEY_SPLASH_SCREEN_STYLE); |
| 1288 |
mLaunchIntoPipParams = opts.getParcelable(KEY_LAUNCH_INTO_PIP_PARAMS); |
| 1289 |
mIsEligibleForLegacyPermissionPrompt = |
| 1290 |
opts.getBoolean(KEY_LEGACY_PERMISSION_PROMPT_ELIGIBLE); |
| 1291 |
mDismissKeyguard = opts.getBoolean(KEY_DISMISS_KEYGUARD); |
| 1292 |
mIgnorePendingIntentCreatorForegroundState = opts.getBoolean( |
| 1293 |
KEY_IGNORE_PENDING_INTENT_CREATOR_FOREGROUND_STATE); |
| 1294 |
mDisableStartingWindow = opts.getBoolean(KEY_DISABLE_STARTING_WINDOW); |
| 1295 |
} |
| 1296 |
|
| 1297 |
|
| 1298 |
|
| 1299 |
|
| 1300 |
|
| 1301 |
|
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
public ActivityOptions setLaunchBounds(@Nullable Rect screenSpacePixelRect) { |
| 1309 |
mLaunchBounds = screenSpacePixelRect != null ? new Rect(screenSpacePixelRect) : null; |
| 1310 |
return this; |
| 1311 |
} |
| 1312 |
|
| 1313 |
|
| 1314 |
public String getPackageName() { |
| 1315 |
return mPackageName; |
| 1316 |
} |
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
@Nullable |
| 1324 |
public Rect getLaunchBounds() { |
| 1325 |
return mLaunchBounds; |
| 1326 |
} |
| 1327 |
|
| 1328 |
|
| 1329 |
public int getAnimationType() { |
| 1330 |
return mAnimationType; |
| 1331 |
} |
| 1332 |
|
| 1333 |
|
| 1334 |
public int getCustomEnterResId() { |
| 1335 |
return mCustomEnterResId; |
| 1336 |
} |
| 1337 |
|
| 1338 |
|
| 1339 |
public int getCustomExitResId() { |
| 1340 |
return mCustomExitResId; |
| 1341 |
} |
| 1342 |
|
| 1343 |
|
| 1344 |
public int getCustomInPlaceResId() { |
| 1345 |
return mCustomInPlaceResId; |
| 1346 |
} |
| 1347 |
|
| 1348 |
|
| 1349 |
public int getCustomBackgroundColor() { |
| 1350 |
return mCustomBackgroundColor; |
| 1351 |
} |
| 1352 |
|
| 1353 |
|
| 1354 |
|
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
public HardwareBuffer getThumbnail() { |
| 1360 |
return mThumbnail != null ? mThumbnail.getHardwareBuffer() : null; |
| 1361 |
} |
| 1362 |
|
| 1363 |
|
| 1364 |
public int getStartX() { |
| 1365 |
return mStartX; |
| 1366 |
} |
| 1367 |
|
| 1368 |
|
| 1369 |
public int getStartY() { |
| 1370 |
return mStartY; |
| 1371 |
} |
| 1372 |
|
| 1373 |
|
| 1374 |
public int getWidth() { |
| 1375 |
return mWidth; |
| 1376 |
} |
| 1377 |
|
| 1378 |
|
| 1379 |
public int getHeight() { |
| 1380 |
return mHeight; |
| 1381 |
} |
| 1382 |
|
| 1383 |
|
| 1384 |
public IRemoteCallback getAnimationStartedListener() { |
| 1385 |
return mAnimationStartedListener; |
| 1386 |
} |
| 1387 |
|
| 1388 |
|
| 1389 |
public IRemoteCallback getAnimationFinishedListener() { |
| 1390 |
return mAnimationFinishedListener; |
| 1391 |
} |
| 1392 |
|
| 1393 |
|
| 1394 |
public int getExitCoordinatorKey() { return mExitCoordinatorIndex; } |
| 1395 |
|
| 1396 |
|
| 1397 |
public void abort() { |
| 1398 |
if (mAnimationStartedListener != null) { |
| 1399 |
try { |
| 1400 |
mAnimationStartedListener.sendResult(null); |
| 1401 |
} catch (RemoteException e) { |
| 1402 |
} |
| 1403 |
} |
| 1404 |
} |
| 1405 |
|
| 1406 |
|
| 1407 |
public boolean isReturning() { |
| 1408 |
return mIsReturning; |
| 1409 |
} |
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
boolean isCrossTask() { |
| 1418 |
return mExitCoordinatorIndex < 0; |
| 1419 |
} |
| 1420 |
|
| 1421 |
|
| 1422 |
public ArrayList<String> getSharedElementNames() { |
| 1423 |
return mSharedElementNames; |
| 1424 |
} |
| 1425 |
|
| 1426 |
|
| 1427 |
public ResultReceiver getResultReceiver() { return mTransitionReceiver; } |
| 1428 |
|
| 1429 |
|
| 1430 |
public int getResultCode() { return mResultCode; } |
| 1431 |
|
| 1432 |
|
| 1433 |
public Intent getResultData() { return mResultData; } |
| 1434 |
|
| 1435 |
|
| 1436 |
public PendingIntent getUsageTimeReport() { |
| 1437 |
return mUsageTimeReport; |
| 1438 |
} |
| 1439 |
|
| 1440 |
|
| 1441 |
public AppTransitionAnimationSpec[] getAnimSpecs() { return mAnimSpecs; } |
| 1442 |
|
| 1443 |
|
| 1444 |
public IAppTransitionAnimationSpecsFuture getSpecsFuture() { |
| 1445 |
return mSpecsFuture; |
| 1446 |
} |
| 1447 |
|
| 1448 |
|
| 1449 |
public RemoteAnimationAdapter getRemoteAnimationAdapter() { |
| 1450 |
return mRemoteAnimationAdapter; |
| 1451 |
} |
| 1452 |
|
| 1453 |
|
| 1454 |
public void setRemoteAnimationAdapter(RemoteAnimationAdapter remoteAnimationAdapter) { |
| 1455 |
mRemoteAnimationAdapter = remoteAnimationAdapter; |
| 1456 |
} |
| 1457 |
|
| 1458 |
|
| 1459 |
public RemoteTransition getRemoteTransition() { |
| 1460 |
return mRemoteTransition; |
| 1461 |
} |
| 1462 |
|
| 1463 |
|
| 1464 |
public void setRemoteTransition(@Nullable RemoteTransition remoteTransition) { |
| 1465 |
mRemoteTransition = remoteTransition; |
| 1466 |
} |
| 1467 |
|
| 1468 |
|
| 1469 |
public static ActivityOptions fromBundle(Bundle bOptions) { |
| 1470 |
return bOptions != null ? new ActivityOptions(bOptions) : null; |
| 1471 |
} |
| 1472 |
|
| 1473 |
|
| 1474 |
public static void abort(ActivityOptions options) { |
| 1475 |
if (options != null) { |
| 1476 |
options.abort(); |
| 1477 |
} |
| 1478 |
} |
| 1479 |
|
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
|
| 1485 |
|
| 1486 |
public boolean getLockTaskMode() { |
| 1487 |
return mLockTaskMode; |
| 1488 |
} |
| 1489 |
|
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
|
| 1494 |
@Nullable |
| 1495 |
public String getSplashScreenThemeResName() { |
| 1496 |
return mSplashScreenThemeResName; |
| 1497 |
} |
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
public @SplashScreen.SplashScreenStyle int getSplashScreenStyle() { |
| 1504 |
return mSplashScreenStyle; |
| 1505 |
} |
| 1506 |
|
| 1507 |
|
| 1508 |
|
| 1509 |
|
| 1510 |
|
| 1511 |
|
| 1512 |
|
| 1513 |
@NonNull |
| 1514 |
public ActivityOptions setSplashScreenStyle(@SplashScreen.SplashScreenStyle int style) { |
| 1515 |
if (style == SplashScreen.SPLASH_SCREEN_STYLE_ICON |
| 1516 |
|| style == SplashScreen.SPLASH_SCREEN_STYLE_SOLID_COLOR) { |
| 1517 |
mSplashScreenStyle = style; |
| 1518 |
} |
| 1519 |
return this; |
| 1520 |
} |
| 1521 |
|
| 1522 |
|
| 1523 |
|
| 1524 |
|
| 1525 |
|
| 1526 |
@TestApi |
| 1527 |
public boolean isEligibleForLegacyPermissionPrompt() { |
| 1528 |
return mIsEligibleForLegacyPermissionPrompt; |
| 1529 |
} |
| 1530 |
|
| 1531 |
|
| 1532 |
|
| 1533 |
|
| 1534 |
|
| 1535 |
@TestApi |
| 1536 |
public void setEligibleForLegacyPermissionPrompt(boolean eligible) { |
| 1537 |
mIsEligibleForLegacyPermissionPrompt = eligible; |
| 1538 |
} |
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
|
| 1547 |
|
| 1548 |
e. |
| 1549 |
|
| 1550 |
|
| 1551 |
|
| 1552 |
|
| 1553 |
|
| 1554 |
|
| 1555 |
|
| 1556 |
|
| 1557 |
public ActivityOptions setLockTaskEnabled(boolean lockTaskMode) { |
| 1558 |
mLockTaskMode = lockTaskMode; |
| 1559 |
return this; |
| 1560 |
} |
| 1561 |
|
| 1562 |
|
| 1563 |
|
| 1564 |
|
| 1565 |
|
| 1566 |
|
| 1567 |
|
| 1568 |
public int getLaunchDisplayId() { |
| 1569 |
return mLaunchDisplayId; |
| 1570 |
} |
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
|
| 1578 |
|
| 1579 |
|
| 1580 |
|
| 1581 |
|
| 1582 |
|
| 1583 |
public ActivityOptions setLaunchDisplayId(int launchDisplayId) { |
| 1584 |
mLaunchDisplayId = launchDisplayId; |
| 1585 |
return this; |
| 1586 |
} |
| 1587 |
|
| 1588 |
|
| 1589 |
public int getCallerDisplayId() { |
| 1590 |
return mCallerDisplayId; |
| 1591 |
} |
| 1592 |
|
| 1593 |
|
| 1594 |
public ActivityOptions setCallerDisplayId(int callerDisplayId) { |
| 1595 |
mCallerDisplayId = callerDisplayId; |
| 1596 |
return this; |
| 1597 |
} |
| 1598 |
|
| 1599 |
|
| 1600 |
public WindowContainerToken getLaunchTaskDisplayArea() { |
| 1601 |
return mLaunchTaskDisplayArea; |
| 1602 |
} |
| 1603 |
|
| 1604 |
|
| 1605 |
public ActivityOptions setLaunchTaskDisplayArea( |
| 1606 |
WindowContainerToken windowContainerToken) { |
| 1607 |
mLaunchTaskDisplayArea = windowContainerToken; |
| 1608 |
return this; |
| 1609 |
} |
| 1610 |
|
| 1611 |
|
| 1612 |
public int getLaunchTaskDisplayAreaFeatureId() { |
| 1613 |
return mLaunchTaskDisplayAreaFeatureId; |
| 1614 |
} |
| 1615 |
|
| 1616 |
|
| 1617 |
|
| 1618 |
|
| 1619 |
|
| 1620 |
|
| 1621 |
|
| 1622 |
|
| 1623 |
@TestApi |
| 1624 |
public void setLaunchTaskDisplayAreaFeatureId(int launchTaskDisplayAreaFeatureId) { |
| 1625 |
mLaunchTaskDisplayAreaFeatureId = launchTaskDisplayAreaFeatureId; |
| 1626 |
} |
| 1627 |
|
| 1628 |
|
| 1629 |
public WindowContainerToken getLaunchRootTask() { |
| 1630 |
return mLaunchRootTask; |
| 1631 |
} |
| 1632 |
|
| 1633 |
|
| 1634 |
public ActivityOptions setLaunchRootTask(WindowContainerToken windowContainerToken) { |
| 1635 |
mLaunchRootTask = windowContainerToken; |
| 1636 |
return this; |
| 1637 |
} |
| 1638 |
|
| 1639 |
|
| 1640 |
public IBinder getLaunchTaskFragmentToken() { |
| 1641 |
return mLaunchTaskFragmentToken; |
| 1642 |
} |
| 1643 |
|
| 1644 |
|
| 1645 |
public ActivityOptions setLaunchTaskFragmentToken(IBinder taskFragmentToken) { |
| 1646 |
mLaunchTaskFragmentToken = taskFragmentToken; |
| 1647 |
return this; |
| 1648 |
} |
| 1649 |
|
| 1650 |
|
| 1651 |
public int getLaunchWindowingMode() { |
| 1652 |
return mLaunchWindowingMode; |
| 1653 |
} |
| 1654 |
|
| 1655 |
|
| 1656 |
|
| 1657 |
|
| 1658 |
|
| 1659 |
@TestApi |
| 1660 |
public void setLaunchWindowingMode(int windowingMode) { |
| 1661 |
mLaunchWindowingMode = windowingMode; |
| 1662 |
} |
| 1663 |
|
| 1664 |
|
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
public PictureInPictureParams getLaunchIntoPipParams() { |
| 1669 |
return mLaunchIntoPipParams; |
| 1670 |
} |
| 1671 |
|
| 1672 |
|
| 1673 |
|
| 1674 |
|
| 1675 |
|
| 1676 |
public boolean isLaunchIntoPip() { |
| 1677 |
return mLaunchIntoPipParams != null |
| 1678 |
&& mLaunchIntoPipParams.isLaunchIntoPip(); |
| 1679 |
} |
| 1680 |
|
| 1681 |
|
| 1682 |
public int getLaunchActivityType() { |
| 1683 |
return mLaunchActivityType; |
| 1684 |
} |
| 1685 |
|
| 1686 |
|
| 1687 |
@TestApi |
| 1688 |
public void setLaunchActivityType(int activityType) { |
| 1689 |
mLaunchActivityType = activityType; |
| 1690 |
} |
| 1691 |
|
| 1692 |
|
| 1693 |
|
| 1694 |
|
| 1695 |
|
| 1696 |
@RequiresPermission(START_TASKS_FROM_RECENTS) |
| 1697 |
@SystemApi |
| 1698 |
public void setLaunchTaskId(int taskId) { |
| 1699 |
mLaunchTaskId = taskId; |
| 1700 |
} |
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
@SystemApi |
| 1706 |
public int getLaunchTaskId() { |
| 1707 |
return mLaunchTaskId; |
| 1708 |
} |
| 1709 |
|
| 1710 |
|
| 1711 |
|
| 1712 |
|
| 1713 |
|
| 1714 |
@RequiresPermission(START_TASKS_FROM_RECENTS) |
| 1715 |
public void setDisableStartingWindow(boolean disable) { |
| 1716 |
mDisableStartingWindow = disable; |
| 1717 |
} |
| 1718 |
|
| 1719 |
|
| 1720 |
|
| 1721 |
|
| 1722 |
public boolean getDisableStartingWindow() { |
| 1723 |
return mDisableStartingWindow; |
| 1724 |
} |
| 1725 |
|
| 1726 |
|
| 1727 |
|
| 1728 |
|
| 1729 |
|
| 1730 |
|
| 1731 |
public void setPendingIntentLaunchFlags(@android.content.Intent.Flags int flags) { |
| 1732 |
mPendingIntentLaunchFlags = flags; |
| 1733 |
} |
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
public int getPendingIntentLaunchFlags() { |
| 1739 |
return mPendingIntentLaunchFlags; |
| 1740 |
} |
| 1741 |
|
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
|
| 1746 |
@TestApi |
| 1747 |
public void setTaskAlwaysOnTop(boolean alwaysOnTop) { |
| 1748 |
mTaskAlwaysOnTop = alwaysOnTop; |
| 1749 |
} |
| 1750 |
|
| 1751 |
|
| 1752 |
|
| 1753 |
|
| 1754 |
public boolean getTaskAlwaysOnTop() { |
| 1755 |
return mTaskAlwaysOnTop; |
| 1756 |
} |
| 1757 |
|
| 1758 |
|
| 1759 |
|
| 1760 |
|
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
@TestApi |
| 1765 |
public void setTaskOverlay(boolean taskOverlay, boolean canResume) { |
| 1766 |
mTaskOverlay = taskOverlay; |
| 1767 |
mTaskOverlayCanResume = canResume; |
| 1768 |
} |
| 1769 |
|
| 1770 |
|
| 1771 |
|
| 1772 |
|
| 1773 |
public boolean getTaskOverlay() { |
| 1774 |
return mTaskOverlay; |
| 1775 |
} |
| 1776 |
|
| 1777 |
|
| 1778 |
|
| 1779 |
|
| 1780 |
public boolean canTaskOverlayResume() { |
| 1781 |
return mTaskOverlayCanResume; |
| 1782 |
} |
| 1783 |
|
| 1784 |
|
| 1785 |
|
| 1786 |
|
| 1787 |
|
| 1788 |
|
| 1789 |
|
| 1790 |
public void setAvoidMoveToFront() { |
| 1791 |
mAvoidMoveToFront = true; |
| 1792 |
} |
| 1793 |
|
| 1794 |
|
| 1795 |
|
| 1796 |
|
| 1797 |
|
| 1798 |
|
| 1799 |
public boolean getAvoidMoveToFront() { |
| 1800 |
return mAvoidMoveToFront; |
| 1801 |
} |
| 1802 |
|
| 1803 |
|
| 1804 |
|
| 1805 |
|
| 1806 |
|
| 1807 |
|
| 1808 |
|
| 1809 |
public void setFreezeRecentTasksReordering() { |
| 1810 |
mFreezeRecentTasksReordering = true; |
| 1811 |
} |
| 1812 |
|
| 1813 |
|
| 1814 |
|
| 1815 |
|
| 1816 |
|
| 1817 |
public boolean freezeRecentTasksReordering() { |
| 1818 |
return mFreezeRecentTasksReordering; |
| 1819 |
} |
| 1820 |
|
| 1821 |
|
| 1822 |
@UnsupportedAppUsage |
| 1823 |
public void setSplitScreenCreateMode(int splitScreenCreateMode) { |
| 1824 |
|
| 1825 |
} |
| 1826 |
|
| 1827 |
|
| 1828 |
public void setDisallowEnterPictureInPictureWhileLaunching(boolean disallow) { |
| 1829 |
mDisallowEnterPictureInPictureWhileLaunching = disallow; |
| 1830 |
} |
| 1831 |
|
| 1832 |
|
| 1833 |
public boolean disallowEnterPictureInPictureWhileLaunching() { |
| 1834 |
return mDisallowEnterPictureInPictureWhileLaunching; |
| 1835 |
} |
| 1836 |
|
| 1837 |
|
| 1838 |
public void setApplyActivityFlagsForBubbles(boolean apply) { |
| 1839 |
mApplyActivityFlagsForBubbles = apply; |
| 1840 |
} |
| 1841 |
|
| 1842 |
|
| 1843 |
public boolean isApplyActivityFlagsForBubbles() { |
| 1844 |
return mApplyActivityFlagsForBubbles; |
| 1845 |
} |
| 1846 |
|
| 1847 |
|
| 1848 |
|
| 1849 |
|
| 1850 |
|
| 1851 |
|
| 1852 |
|
| 1853 |
|
| 1854 |
public void setLaunchCookie(IBinder launchCookie) { |
| 1855 |
mLaunchCookie = launchCookie; |
| 1856 |
} |
| 1857 |
|
| 1858 |
|
| 1859 |
|
| 1860 |
|
| 1861 |
|
| 1862 |
|
| 1863 |
public IBinder getLaunchCookie() { |
| 1864 |
return mLaunchCookie; |
| 1865 |
} |
| 1866 |
|
| 1867 |
|
| 1868 |
|
| 1869 |
public boolean getOverrideTaskTransition() { |
| 1870 |
return mOverrideTaskTransition; |
| 1871 |
} |
| 1872 |
|
| 1873 |
|
| 1874 |
|
| 1875 |
|
| 1876 |
|
| 1877 |
public void setRemoveWithTaskOrganizer(boolean remove) { |
| 1878 |
mRemoveWithTaskOrganizer = remove; |
| 1879 |
} |
| 1880 |
|
| 1881 |
|
| 1882 |
|
| 1883 |
|
| 1884 |
|
| 1885 |
public boolean getRemoveWithTaskOranizer() { |
| 1886 |
return mRemoveWithTaskOrganizer; |
| 1887 |
} |
| 1888 |
|
| 1889 |
|
| 1890 |
|
| 1891 |
|
| 1892 |
|
| 1893 |
@TestApi |
| 1894 |
public void setLaunchedFromBubble(boolean fromBubble) { |
| 1895 |
mLaunchedFromBubble = fromBubble; |
| 1896 |
} |
| 1897 |
|
| 1898 |
|
| 1899 |
|
| 1900 |
|
| 1901 |
|
| 1902 |
public boolean getLaunchedFromBubble() { |
| 1903 |
return mLaunchedFromBubble; |
| 1904 |
} |
| 1905 |
|
| 1906 |
|
| 1907 |
|
| 1908 |
|
| 1909 |
|
| 1910 |
|
| 1911 |
|
| 1912 |
|
| 1913 |
|
| 1914 |
public ActivityOptions setTransientLaunch() { |
| 1915 |
mTransientLaunch = true; |
| 1916 |
return this; |
| 1917 |
} |
| 1918 |
|
| 1919 |
|
| 1920 |
|
| 1921 |
|
| 1922 |
|
| 1923 |
|
| 1924 |
public boolean getTransientLaunch() { |
| 1925 |
return mTransientLaunch; |
| 1926 |
} |
| 1927 |
|
| 1928 |
|
| 1929 |
|
| 1930 |
|
| 1931 |
|
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
@RequiresPermission(CONTROL_KEYGUARD) |
| 1936 |
public void setDismissKeyguard() { |
| 1937 |
mDismissKeyguard = true; |
| 1938 |
} |
| 1939 |
|
| 1940 |
|
| 1941 |
|
| 1942 |
|
| 1943 |
|
| 1944 |
|
| 1945 |
public boolean getDismissKeyguard() { |
| 1946 |
return mDismissKeyguard; |
| 1947 |
} |
| 1948 |
|
| 1949 |
|
| 1950 |
|
| 1951 |
|
| 1952 |
|
| 1953 |
public void setIgnorePendingIntentCreatorForegroundState(boolean state) { |
| 1954 |
mIgnorePendingIntentCreatorForegroundState = state; |
| 1955 |
} |
| 1956 |
|
| 1957 |
|
| 1958 |
|
| 1959 |
|
| 1960 |
|
| 1961 |
|
| 1962 |
public boolean getIgnorePendingIntentCreatorForegroundState() { |
| 1963 |
return mIgnorePendingIntentCreatorForegroundState; |
| 1964 |
} |
| 1965 |
|
| 1966 |
|
| 1967 |
|
| 1968 |
|
| 1969 |
|
| 1970 |
|
| 1971 |
public void update(ActivityOptions otherOptions) { |
| 1972 |
if (otherOptions.mPackageName != null) { |
| 1973 |
mPackageName = otherOptions.mPackageName; |
| 1974 |
} |
| 1975 |
mUsageTimeReport = otherOptions.mUsageTimeReport; |
| 1976 |
mTransitionReceiver = null; |
| 1977 |
mSharedElementNames = null; |
| 1978 |
mIsReturning = false; |
| 1979 |
mResultData = null; |
| 1980 |
mResultCode = 0; |
| 1981 |
mExitCoordinatorIndex = 0; |
| 1982 |
mAnimationType = otherOptions.mAnimationType; |
| 1983 |
switch (otherOptions.mAnimationType) { |
| 1984 |
case ANIM_CUSTOM: |
| 1985 |
mCustomEnterResId = otherOptions.mCustomEnterResId; |
| 1986 |
mCustomExitResId = otherOptions.mCustomExitResId; |
| 1987 |
mCustomBackgroundColor = otherOptions.mCustomBackgroundColor; |
| 1988 |
mThumbnail = null; |
| 1989 |
if (mAnimationStartedListener != null) { |
| 1990 |
try { |
| 1991 |
mAnimationStartedListener.sendResult(null); |
| 1992 |
} catch (RemoteException e) { |
| 1993 |
} |
| 1994 |
} |
| 1995 |
mAnimationStartedListener = otherOptions.mAnimationStartedListener; |
| 1996 |
break; |
| 1997 |
case ANIM_CUSTOM_IN_PLACE: |
| 1998 |
mCustomInPlaceResId = otherOptions.mCustomInPlaceResId; |
| 1999 |
break; |
| 2000 |
case ANIM_SCALE_UP: |
| 2001 |
mStartX = otherOptions.mStartX; |
| 2002 |
mStartY = otherOptions.mStartY; |
| 2003 |
mWidth = otherOptions.mWidth; |
| 2004 |
mHeight = otherOptions.mHeight; |
| 2005 |
if (mAnimationStartedListener != null) { |
| 2006 |
try { |
| 2007 |
mAnimationStartedListener.sendResult(null); |
| 2008 |
} catch (RemoteException e) { |
| 2009 |
} |
| 2010 |
} |
| 2011 |
mAnimationStartedListener = null; |
| 2012 |
break; |
| 2013 |
case ANIM_THUMBNAIL_SCALE_UP: |
| 2014 |
case ANIM_THUMBNAIL_SCALE_DOWN: |
| 2015 |
case ANIM_THUMBNAIL_ASPECT_SCALE_UP: |
| 2016 |
case ANIM_THUMBNAIL_ASPECT_SCALE_DOWN: |
| 2017 |
mThumbnail = otherOptions.mThumbnail; |
| 2018 |
mStartX = otherOptions.mStartX; |
| 2019 |
mStartY = otherOptions.mStartY; |
| 2020 |
mWidth = otherOptions.mWidth; |
| 2021 |
mHeight = otherOptions.mHeight; |
| 2022 |
if (mAnimationStartedListener != null) { |
| 2023 |
try { |
| 2024 |
mAnimationStartedListener.sendResult(null); |
| 2025 |
} catch (RemoteException e) { |
| 2026 |
} |
| 2027 |
} |
| 2028 |
mAnimationStartedListener = otherOptions.mAnimationStartedListener; |
| 2029 |
break; |
| 2030 |
case ANIM_SCENE_TRANSITION: |
| 2031 |
mTransitionReceiver = otherOptions.mTransitionReceiver; |
| 2032 |
mSharedElementNames = otherOptions.mSharedElementNames; |
| 2033 |
mIsReturning = otherOptions.mIsReturning; |
| 2034 |
mThumbnail = null; |
| 2035 |
mAnimationStartedListener = null; |
| 2036 |
mResultData = otherOptions.mResultData; |
| 2037 |
mResultCode = otherOptions.mResultCode; |
| 2038 |
mExitCoordinatorIndex = otherOptions.mExitCoordinatorIndex; |
| 2039 |
break; |
| 2040 |
} |
| 2041 |
mLockTaskMode = otherOptions.mLockTaskMode; |
| 2042 |
mAnimSpecs = otherOptions.mAnimSpecs; |
| 2043 |
mAnimationFinishedListener = otherOptions.mAnimationFinishedListener; |
| 2044 |
mSpecsFuture = otherOptions.mSpecsFuture; |
| 2045 |
mRemoteAnimationAdapter = otherOptions.mRemoteAnimationAdapter; |
| 2046 |
mLaunchIntoPipParams = otherOptions.mLaunchIntoPipParams; |
| 2047 |
mIsEligibleForLegacyPermissionPrompt = otherOptions.mIsEligibleForLegacyPermissionPrompt; |
| 2048 |
} |
| 2049 |
|
| 2050 |
|
| 2051 |
|
| 2052 |
|
| 2053 |
|
| 2054 |
|
| 2055 |
|
| 2056 |
|
| 2057 |
|
| 2058 |
@Override |
| 2059 |
public Bundle toBundle() { |
| 2060 |
Bundle b = super.toBundle(); |
| 2061 |
if (mPackageName != null) { |
| 2062 |
b.putString(KEY_PACKAGE_NAME, mPackageName); |
| 2063 |
} |
| 2064 |
if (mLaunchBounds != null) { |
| 2065 |
b.putParcelable(KEY_LAUNCH_BOUNDS, mLaunchBounds); |
| 2066 |
} |
| 2067 |
if (mAnimationType != ANIM_UNDEFINED) { |
| 2068 |
b.putInt(KEY_ANIM_TYPE, mAnimationType); |
| 2069 |
} |
| 2070 |
if (mUsageTimeReport != null) { |
| 2071 |
b.putParcelable(KEY_USAGE_TIME_REPORT, mUsageTimeReport); |
| 2072 |
} |
| 2073 |
switch (mAnimationType) { |
| 2074 |
case ANIM_CUSTOM: |
| 2075 |
b.putInt(KEY_ANIM_ENTER_RES_ID, mCustomEnterResId); |
| 2076 |
b.putInt(KEY_ANIM_EXIT_RES_ID, mCustomExitResId); |
| 2077 |
b.putInt(KEY_ANIM_BACKGROUND_COLOR, mCustomBackgroundColor); |
| 2078 |
b.putBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener |
| 2079 |
!= null ? mAnimationStartedListener.asBinder() : null); |
| 2080 |
break; |
| 2081 |
case ANIM_CUSTOM_IN_PLACE: |
| 2082 |
b.putInt(KEY_ANIM_IN_PLACE_RES_ID, mCustomInPlaceResId); |
| 2083 |
break; |
| 2084 |
case ANIM_SCALE_UP: |
| 2085 |
case ANIM_CLIP_REVEAL: |
| 2086 |
b.putInt(KEY_ANIM_START_X, mStartX); |
| 2087 |
b.putInt(KEY_ANIM_START_Y, mStartY); |
| 2088 |
b.putInt(KEY_ANIM_WIDTH, mWidth); |
| 2089 |
b.putInt(KEY_ANIM_HEIGHT, mHeight); |
| 2090 |
break; |
| 2091 |
case ANIM_THUMBNAIL_SCALE_UP: |
| 2092 |
case ANIM_THUMBNAIL_SCALE_DOWN: |
| 2093 |
case ANIM_THUMBNAIL_ASPECT_SCALE_UP: |
| 2094 |
case ANIM_THUMBNAIL_ASPECT_SCALE_DOWN: |
| 2095 |
|
| 2096 |
|
| 2097 |
if (mThumbnail != null) { |
| 2098 |
final Bitmap hwBitmap = mThumbnail.copy(Config.HARDWARE, false ); |
| 2099 |
if (hwBitmap != null) { |
| 2100 |
b.putParcelable(KEY_ANIM_THUMBNAIL, hwBitmap.getHardwareBuffer()); |
| 2101 |
} else { |
| 2102 |
Slog.w(TAG, "Failed to copy thumbnail"); |
| 2103 |
} |
| 2104 |
} |
| 2105 |
b.putInt(KEY_ANIM_START_X, mStartX); |
| 2106 |
b.putInt(KEY_ANIM_START_Y, mStartY); |
| 2107 |
b.putInt(KEY_ANIM_WIDTH, mWidth); |
| 2108 |
b.putInt(KEY_ANIM_HEIGHT, mHeight); |
| 2109 |
b.putBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener |
| 2110 |
!= null ? mAnimationStartedListener.asBinder() : null); |
| 2111 |
break; |
| 2112 |
case ANIM_SCENE_TRANSITION: |
| 2113 |
if (mTransitionReceiver != null) { |
| 2114 |
b.putParcelable(KEY_TRANSITION_COMPLETE_LISTENER, mTransitionReceiver); |
| 2115 |
} |
| 2116 |
b.putBoolean(KEY_TRANSITION_IS_RETURNING, mIsReturning); |
| 2117 |
b.putStringArrayList(KEY_TRANSITION_SHARED_ELEMENTS, mSharedElementNames); |
| 2118 |
b.putParcelable(KEY_RESULT_DATA, mResultData); |
| 2119 |
b.putInt(KEY_RESULT_CODE, mResultCode); |
| 2120 |
b.putInt(KEY_EXIT_COORDINATOR_INDEX, mExitCoordinatorIndex); |
| 2121 |
break; |
| 2122 |
} |
| 2123 |
if (mLockTaskMode) { |
| 2124 |
b.putBoolean(KEY_LOCK_TASK_MODE, mLockTaskMode); |
| 2125 |
} |
| 2126 |
if (mLaunchDisplayId != INVALID_DISPLAY) { |
| 2127 |
b.putInt(KEY_LAUNCH_DISPLAY_ID, mLaunchDisplayId); |
| 2128 |
} |
| 2129 |
if (mCallerDisplayId != INVALID_DISPLAY) { |
| 2130 |
b.putInt(KEY_CALLER_DISPLAY_ID, mCallerDisplayId); |
| 2131 |
} |
| 2132 |
if (mLaunchTaskDisplayArea != null) { |
| 2133 |
b.putParcelable(KEY_LAUNCH_TASK_DISPLAY_AREA_TOKEN, mLaunchTaskDisplayArea); |
| 2134 |
} |
| 2135 |
if (mLaunchTaskDisplayAreaFeatureId != FEATURE_UNDEFINED) { |
| 2136 |
b.putInt(KEY_LAUNCH_TASK_DISPLAY_AREA_FEATURE_ID, mLaunchTaskDisplayAreaFeatureId); |
| 2137 |
} |
| 2138 |
if (mLaunchRootTask != null) { |
| 2139 |
b.putParcelable(KEY_LAUNCH_ROOT_TASK_TOKEN, mLaunchRootTask); |
| 2140 |
} |
| 2141 |
if (mLaunchTaskFragmentToken != null) { |
| 2142 |
b.putBinder(KEY_LAUNCH_TASK_FRAGMENT_TOKEN, mLaunchTaskFragmentToken); |
| 2143 |
} |
| 2144 |
if (mLaunchWindowingMode != WINDOWING_MODE_UNDEFINED) { |
| 2145 |
b.putInt(KEY_LAUNCH_WINDOWING_MODE, mLaunchWindowingMode); |
| 2146 |
} |
| 2147 |
if (mLaunchActivityType != ACTIVITY_TYPE_UNDEFINED) { |
| 2148 |
b.putInt(KEY_LAUNCH_ACTIVITY_TYPE, mLaunchActivityType); |
| 2149 |
} |
| 2150 |
if (mLaunchTaskId != -1) { |
| 2151 |
b.putInt(KEY_LAUNCH_TASK_ID, mLaunchTaskId); |
| 2152 |
} |
| 2153 |
if (mPendingIntentLaunchFlags != 0) { |
| 2154 |
b.putInt(KEY_PENDING_INTENT_LAUNCH_FLAGS, mPendingIntentLaunchFlags); |
| 2155 |
} |
| 2156 |
if (mTaskAlwaysOnTop) { |
| 2157 |
b.putBoolean(KEY_TASK_ALWAYS_ON_TOP, mTaskAlwaysOnTop); |
| 2158 |
} |
| 2159 |
if (mTaskOverlay) { |
| 2160 |
b.putBoolean(KEY_TASK_OVERLAY, mTaskOverlay); |
| 2161 |
} |
| 2162 |
if (mTaskOverlayCanResume) { |
| 2163 |
b.putBoolean(KEY_TASK_OVERLAY_CAN_RESUME, mTaskOverlayCanResume); |
| 2164 |
} |
| 2165 |
if (mAvoidMoveToFront) { |
| 2166 |
b.putBoolean(KEY_AVOID_MOVE_TO_FRONT, mAvoidMoveToFront); |
| 2167 |
} |
| 2168 |
if (mFreezeRecentTasksReordering) { |
| 2169 |
b.putBoolean(KEY_FREEZE_RECENT_TASKS_REORDERING, mFreezeRecentTasksReordering); |
| 2170 |
} |
| 2171 |
if (mDisallowEnterPictureInPictureWhileLaunching) { |
| 2172 |
b.putBoolean(KEY_DISALLOW_ENTER_PICTURE_IN_PICTURE_WHILE_LAUNCHING, |
| 2173 |
mDisallowEnterPictureInPictureWhileLaunching); |
| 2174 |
} |
| 2175 |
if (mApplyActivityFlagsForBubbles) { |
| 2176 |
b.putBoolean(KEY_APPLY_ACTIVITY_FLAGS_FOR_BUBBLES, mApplyActivityFlagsForBubbles); |
| 2177 |
} |
| 2178 |
if (mAnimSpecs != null) { |
| 2179 |
b.putParcelableArray(KEY_ANIM_SPECS, mAnimSpecs); |
| 2180 |
} |
| 2181 |
if (mAnimationFinishedListener != null) { |
| 2182 |
b.putBinder(KEY_ANIMATION_FINISHED_LISTENER, mAnimationFinishedListener.asBinder()); |
| 2183 |
} |
| 2184 |
if (mSpecsFuture != null) { |
| 2185 |
b.putBinder(KEY_SPECS_FUTURE, mSpecsFuture.asBinder()); |
| 2186 |
} |
| 2187 |
if (mSourceInfo != null) { |
| 2188 |
b.putParcelable(KEY_SOURCE_INFO, mSourceInfo); |
| 2189 |
} |
| 2190 |
if (mRotationAnimationHint != -1) { |
| 2191 |
b.putInt(KEY_ROTATION_ANIMATION_HINT, mRotationAnimationHint); |
| 2192 |
} |
| 2193 |
if (mAppVerificationBundle != null) { |
| 2194 |
b.putBundle(KEY_INSTANT_APP_VERIFICATION_BUNDLE, mAppVerificationBundle); |
| 2195 |
} |
| 2196 |
if (mRemoteAnimationAdapter != null) { |
| 2197 |
b.putParcelable(KEY_REMOTE_ANIMATION_ADAPTER, mRemoteAnimationAdapter); |
| 2198 |
} |
| 2199 |
if (mLaunchCookie != null) { |
| 2200 |
b.putBinder(KEY_LAUNCH_COOKIE, mLaunchCookie); |
| 2201 |
} |
| 2202 |
if (mRemoteTransition != null) { |
| 2203 |
b.putParcelable(KEY_REMOTE_TRANSITION, mRemoteTransition); |
| 2204 |
} |
| 2205 |
if (mOverrideTaskTransition) { |
| 2206 |
b.putBoolean(KEY_OVERRIDE_TASK_TRANSITION, mOverrideTaskTransition); |
| 2207 |
} |
| 2208 |
if (mSplashScreenThemeResName != null && !mSplashScreenThemeResName.isEmpty()) { |
| 2209 |
b.putString(KEY_SPLASH_SCREEN_THEME, mSplashScreenThemeResName); |
| 2210 |
} |
| 2211 |
if (mRemoveWithTaskOrganizer) { |
| 2212 |
b.putBoolean(KEY_REMOVE_WITH_TASK_ORGANIZER, mRemoveWithTaskOrganizer); |
| 2213 |
} |
| 2214 |
if (mLaunchedFromBubble) { |
| 2215 |
b.putBoolean(KEY_LAUNCHED_FROM_BUBBLE, mLaunchedFromBubble); |
| 2216 |
} |
| 2217 |
if (mTransientLaunch) { |
| 2218 |
b.putBoolean(KEY_TRANSIENT_LAUNCH, mTransientLaunch); |
| 2219 |
} |
| 2220 |
if (mSplashScreenStyle != 0) { |
| 2221 |
b.putInt(KEY_SPLASH_SCREEN_STYLE, mSplashScreenStyle); |
| 2222 |
} |
| 2223 |
if (mLaunchIntoPipParams != null) { |
| 2224 |
b.putParcelable(KEY_LAUNCH_INTO_PIP_PARAMS, mLaunchIntoPipParams); |
| 2225 |
} |
| 2226 |
if (mIsEligibleForLegacyPermissionPrompt) { |
| 2227 |
b.putBoolean(KEY_LEGACY_PERMISSION_PROMPT_ELIGIBLE, |
| 2228 |
mIsEligibleForLegacyPermissionPrompt); |
| 2229 |
} |
| 2230 |
if (mDismissKeyguard) { |
| 2231 |
b.putBoolean(KEY_DISMISS_KEYGUARD, mDismissKeyguard); |
| 2232 |
} |
| 2233 |
if (mIgnorePendingIntentCreatorForegroundState) { |
| 2234 |
b.putBoolean(KEY_IGNORE_PENDING_INTENT_CREATOR_FOREGROUND_STATE, |
| 2235 |
mIgnorePendingIntentCreatorForegroundState); |
| 2236 |
} |
| 2237 |
if (mDisableStartingWindow) { |
| 2238 |
b.putBoolean(KEY_DISABLE_STARTING_WINDOW, mDisableStartingWindow); |
| 2239 |
} |
| 2240 |
return b; |
| 2241 |
} |
| 2242 |
|
| 2243 |
|
| 2244 |
|
| 2245 |
|
| 2246 |
|
| 2247 |
|
| 2248 |
|
| 2249 |
|
| 2250 |
|
| 2251 |
|
| 2252 |
|
| 2253 |
|
| 2254 |
|
| 2255 |
|
| 2256 |
|
| 2257 |
|
| 2258 |
|
| 2259 |
|
| 2260 |
|
| 2261 |
|
| 2262 |
|
| 2263 |
|
| 2264 |
|
| 2265 |
|
| 2266 |
|
| 2267 |
public void requestUsageTimeReport(PendingIntent receiver) { |
| 2268 |
mUsageTimeReport = receiver; |
| 2269 |
} |
| 2270 |
|
| 2271 |
|
| 2272 |
|
| 2273 |
|
| 2274 |
|
| 2275 |
public @Nullable SourceInfo getSourceInfo() { |
| 2276 |
return mSourceInfo; |
| 2277 |
} |
| 2278 |
|
| 2279 |
|
| 2280 |
|
| 2281 |
|
| 2282 |
|
| 2283 |
|
| 2284 |
|
| 2285 |
|
| 2286 |
|
| 2287 |
|
| 2288 |
|
| 2289 |
public void setSourceInfo(@SourceInfo.SourceType int type, long uptimeMillis) { |
| 2290 |
mSourceInfo = new SourceInfo(type, uptimeMillis); |
| 2291 |
} |
| 2292 |
|
| 2293 |
|
| 2294 |
|
| 2295 |
|
| 2296 |
|
| 2297 |
public ActivityOptions forTargetActivity() { |
| 2298 |
if (mAnimationType == ANIM_SCENE_TRANSITION) { |
| 2299 |
final ActivityOptions result = new ActivityOptions(); |
| 2300 |
result.update(this); |
| 2301 |
return result; |
| 2302 |
} |
| 2303 |
|
| 2304 |
return null; |
| 2305 |
} |
| 2306 |
|
| 2307 |
|
| 2308 |
|
| 2309 |
|
| 2310 |
|
| 2311 |
|
| 2312 |
public int getRotationAnimationHint() { |
| 2313 |
return mRotationAnimationHint; |
| 2314 |
} |
| 2315 |
|
| 2316 |
|
| 2317 |
|
| 2318 |
|
| 2319 |
|
| 2320 |
|
| 2321 |
|
| 2322 |
|
| 2323 |
|
| 2324 |
public void setRotationAnimationHint(int hint) { |
| 2325 |
mRotationAnimationHint = hint; |
| 2326 |
} |
| 2327 |
|
| 2328 |
|
| 2329 |
|
| 2330 |
|
| 2331 |
|
| 2332 |
|
| 2333 |
|
| 2334 |
public Bundle popAppVerificationBundle() { |
| 2335 |
Bundle out = mAppVerificationBundle; |
| 2336 |
mAppVerificationBundle = null; |
| 2337 |
return out; |
| 2338 |
} |
| 2339 |
|
| 2340 |
|
| 2341 |
|
| 2342 |
|
| 2343 |
|
| 2344 |
|
| 2345 |
|
| 2346 |
public ActivityOptions setAppVerificationBundle(Bundle bundle) { |
| 2347 |
mAppVerificationBundle = bundle; |
| 2348 |
return this; |
| 2349 |
|
| 2350 |
} |
| 2351 |
|
| 2352 |
|
| 2353 |
@Override |
| 2354 |
public String toString() { |
| 2355 |
return "ActivityOptions(" + hashCode() + "), mPackageName=" + mPackageName |
| 2356 |
+ ", mAnimationType=" + mAnimationType + ", mStartX=" + mStartX + ", mStartY=" |
| 2357 |
+ mStartY + ", mWidth=" + mWidth + ", mHeight=" + mHeight; |
| 2358 |
} |
| 2359 |
|
| 2360 |
|
| 2361 |
|
| 2362 |
|
| 2363 |
|
| 2364 |
|
| 2365 |
public static class SourceInfo implements Parcelable { |
| 2366 |
|
| 2367 |
public static final int TYPE_LAUNCHER = 1; |
| 2368 |
|
| 2369 |
public static final int TYPE_NOTIFICATION = 2; |
| 2370 |
|
| 2371 |
public static final int TYPE_LOCKSCREEN = 3; |
| 2372 |
|
| 2373 |
public static final int TYPE_RECENTS_ANIMATION = 4; |
| 2374 |
|
| 2375 |
@IntDef(prefix = { "TYPE_" }, value = { |
| 2376 |
TYPE_LAUNCHER, |
| 2377 |
TYPE_NOTIFICATION, |
| 2378 |
TYPE_LOCKSCREEN, |
| 2379 |
}) |
| 2380 |
@Retention(RetentionPolicy.SOURCE) |
| 2381 |
public @interface SourceType {} |
| 2382 |
|
| 2383 |
|
| 2384 |
public final @SourceType int type; |
| 2385 |
|
| 2386 |
|
| 2387 |
public final long eventTimeMs; |
| 2388 |
|
| 2389 |
SourceInfo(@SourceType int srcType, long uptimeMillis) { |
| 2390 |
type = srcType; |
| 2391 |
eventTimeMs = uptimeMillis; |
| 2392 |
} |
| 2393 |
|
| 2394 |
@Override |
| 2395 |
public void writeToParcel(Parcel dest, int flags) { |
| 2396 |
dest.writeInt(type); |
| 2397 |
dest.writeLong(eventTimeMs); |
| 2398 |
} |
| 2399 |
|
| 2400 |
@Override |
| 2401 |
public int describeContents() { |
| 2402 |
return 0; |
| 2403 |
} |
| 2404 |
|
| 2405 |
public static final Creator<SourceInfo> CREATOR = new Creator<SourceInfo>() { |
| 2406 |
public SourceInfo createFromParcel(Parcel in) { |
| 2407 |
return new SourceInfo(in.readInt(), in.readLong()); |
| 2408 |
} |
| 2409 |
|
| 2410 |
public SourceInfo[] newArray(int size) { |
| 2411 |
return new SourceInfo[size]; |
| 2412 |
} |
| 2413 |
}; |
| 2414 |
} |
| 2415 |
} |