| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.window; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.annotation.TestApi; |
| 22 |
import android.app.PendingIntent; |
| 23 |
import android.app.WindowConfiguration; |
| 24 |
import android.content.Intent; |
| 25 |
import android.content.pm.ActivityInfo; |
| 26 |
import android.content.pm.ShortcutInfo; |
| 27 |
import android.content.res.Configuration; |
| 28 |
import android.graphics.Rect; |
| 29 |
import android.os.Bundle; |
| 30 |
import android.os.IBinder; |
| 31 |
import android.os.Parcel; |
| 32 |
import android.os.Parcelable; |
| 33 |
import android.util.ArrayMap; |
| 34 |
import android.view.InsetsState; |
| 35 |
import android.view.SurfaceControl; |
| 36 |
|
| 37 |
import java.util.ArrayList; |
| 38 |
import java.util.Arrays; |
| 39 |
import java.util.List; |
| 40 |
import java.util.Map; |
| 41 |
import java.util.Objects; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
@TestApi |
| 50 |
public final class WindowContainerTransaction implements Parcelable { |
| 51 |
private final ArrayMap<IBinder, Change> mChanges = new ArrayMap<>(); |
| 52 |
|
| 53 |
|
| 54 |
private final ArrayList<HierarchyOp> mHierarchyOps = new ArrayList<>(); |
| 55 |
|
| 56 |
@Nullable |
| 57 |
private IBinder mErrorCallbackToken; |
| 58 |
|
| 59 |
@Nullable |
| 60 |
private ITaskFragmentOrganizer mTaskFragmentOrganizer; |
| 61 |
|
| 62 |
public WindowContainerTransaction() {} |
| 63 |
|
| 64 |
private WindowContainerTransaction(Parcel in) { |
| 65 |
in.readMap(mChanges, null ); |
| 66 |
in.readTypedList(mHierarchyOps, HierarchyOp.CREATOR); |
| 67 |
mErrorCallbackToken = in.readStrongBinder(); |
| 68 |
mTaskFragmentOrganizer = ITaskFragmentOrganizer.Stub.asInterface(in.readStrongBinder()); |
| 69 |
} |
| 70 |
|
| 71 |
private Change getOrCreateChange(IBinder token) { |
| 72 |
Change out = mChanges.get(token); |
| 73 |
if (out == null) { |
| 74 |
out = new Change(); |
| 75 |
mChanges.put(token, out); |
| 76 |
} |
| 77 |
return out; |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
@NonNull |
| 84 |
public WindowContainerTransaction setBounds( |
| 85 |
@NonNull WindowContainerToken container,@NonNull Rect bounds) { |
| 86 |
Change chg = getOrCreateChange(container.asBinder()); |
| 87 |
chg.mConfiguration.windowConfiguration.setBounds(bounds); |
| 88 |
chg.mConfigSetMask |= ActivityInfo.CONFIG_WINDOW_CONFIGURATION; |
| 89 |
chg.mWindowSetMask |= WindowConfiguration.WINDOW_CONFIG_BOUNDS; |
| 90 |
return this; |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
@NonNull |
| 99 |
public WindowContainerTransaction setAppBounds( |
| 100 |
@NonNull WindowContainerToken container,@NonNull Rect appBounds) { |
| 101 |
Change chg = getOrCreateChange(container.asBinder()); |
| 102 |
chg.mConfiguration.windowConfiguration.setAppBounds(appBounds); |
| 103 |
chg.mConfigSetMask |= ActivityInfo.CONFIG_WINDOW_CONFIGURATION; |
| 104 |
chg.mWindowSetMask |= WindowConfiguration.WINDOW_CONFIG_APP_BOUNDS; |
| 105 |
return this; |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
@NonNull |
| 115 |
public WindowContainerTransaction setScreenSizeDp( |
| 116 |
@NonNull WindowContainerToken container, int w, int h) { |
| 117 |
Change chg = getOrCreateChange(container.asBinder()); |
| 118 |
chg.mConfiguration.screenWidthDp = w; |
| 119 |
chg.mConfiguration.screenHeightDp = h; |
| 120 |
chg.mConfigSetMask |= ActivityInfo.CONFIG_SCREEN_SIZE; |
| 121 |
return this; |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
@NonNull |
| 129 |
public WindowContainerTransaction scheduleFinishEnterPip( |
| 130 |
@NonNull WindowContainerToken container,@NonNull Rect bounds) { |
| 131 |
Change chg = getOrCreateChange(container.asBinder()); |
| 132 |
chg.mPinnedBounds = new Rect(bounds); |
| 133 |
chg.mChangeMask |= Change.CHANGE_PIP_CALLBACK; |
| 134 |
|
| 135 |
return this; |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
@NonNull |
| 150 |
public WindowContainerTransaction setBoundsChangeTransaction( |
| 151 |
@NonNull WindowContainerToken container,@NonNull SurfaceControl.Transaction t) { |
| 152 |
Change chg = getOrCreateChange(container.asBinder()); |
| 153 |
chg.mBoundsChangeTransaction = t; |
| 154 |
chg.mChangeMask |= Change.CHANGE_BOUNDS_TRANSACTION; |
| 155 |
return this; |
| 156 |
} |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
@NonNull |
| 177 |
public WindowContainerTransaction setBoundsChangeTransaction( |
| 178 |
@NonNull WindowContainerToken task, @NonNull Rect surfaceBounds) { |
| 179 |
Change chg = getOrCreateChange(task.asBinder()); |
| 180 |
if (chg.mBoundsChangeSurfaceBounds == null) { |
| 181 |
chg.mBoundsChangeSurfaceBounds = new Rect(); |
| 182 |
} |
| 183 |
chg.mBoundsChangeSurfaceBounds.set(surfaceBounds); |
| 184 |
chg.mChangeMask |= Change.CHANGE_BOUNDS_TRANSACTION_RECT; |
| 185 |
return this; |
| 186 |
} |
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
@NonNull |
| 197 |
public WindowContainerTransaction setActivityWindowingMode( |
| 198 |
@NonNull WindowContainerToken container, int windowingMode) { |
| 199 |
Change chg = getOrCreateChange(container.asBinder()); |
| 200 |
chg.mActivityWindowingMode = windowingMode; |
| 201 |
return this; |
| 202 |
} |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
@NonNull |
| 208 |
public WindowContainerTransaction setWindowingMode( |
| 209 |
@NonNull WindowContainerToken container, int windowingMode) { |
| 210 |
Change chg = getOrCreateChange(container.asBinder()); |
| 211 |
chg.mWindowingMode = windowingMode; |
| 212 |
return this; |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
@NonNull |
| 221 |
public WindowContainerTransaction setFocusable( |
| 222 |
@NonNull WindowContainerToken container, boolean focusable) { |
| 223 |
Change chg = getOrCreateChange(container.asBinder()); |
| 224 |
chg.mFocusable = focusable; |
| 225 |
chg.mChangeMask |= Change.CHANGE_FOCUSABLE; |
| 226 |
return this; |
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
@NonNull |
| 235 |
public WindowContainerTransaction setHidden( |
| 236 |
@NonNull WindowContainerToken container, boolean hidden) { |
| 237 |
Change chg = getOrCreateChange(container.asBinder()); |
| 238 |
chg.mHidden = hidden; |
| 239 |
chg.mChangeMask |= Change.CHANGE_HIDDEN; |
| 240 |
return this; |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
@NonNull |
| 247 |
public WindowContainerTransaction setSmallestScreenWidthDp( |
| 248 |
@NonNull WindowContainerToken container, int widthDp) { |
| 249 |
Change cfg = getOrCreateChange(container.asBinder()); |
| 250 |
cfg.mConfiguration.smallestScreenWidthDp = widthDp; |
| 251 |
cfg.mConfigSetMask |= ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE; |
| 252 |
return this; |
| 253 |
} |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
@NonNull |
| 263 |
public WindowContainerTransaction setIgnoreOrientationRequest( |
| 264 |
@NonNull WindowContainerToken container, boolean ignoreOrientationRequest) { |
| 265 |
Change chg = getOrCreateChange(container.asBinder()); |
| 266 |
chg.mIgnoreOrientationRequest = ignoreOrientationRequest; |
| 267 |
chg.mChangeMask |= Change.CHANGE_IGNORE_ORIENTATION_REQUEST; |
| 268 |
return this; |
| 269 |
} |
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
@NonNull |
| 277 |
public WindowContainerTransaction setForceTranslucent( |
| 278 |
@NonNull WindowContainerToken container, boolean forceTranslucent) { |
| 279 |
Change chg = getOrCreateChange(container.asBinder()); |
| 280 |
chg.mForceTranslucent = forceTranslucent; |
| 281 |
chg.mChangeMask |= Change.CHANGE_FORCE_TRANSLUCENT; |
| 282 |
return this; |
| 283 |
} |
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
@NonNull |
| 293 |
public WindowContainerTransaction setDoNotPip(@NonNull WindowContainerToken container) { |
| 294 |
Change chg = getOrCreateChange(container.asBinder()); |
| 295 |
chg.mChangeMask |= Change.CHANGE_FORCE_NO_PIP; |
| 296 |
return this; |
| 297 |
} |
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
@NonNull |
| 307 |
public WindowContainerTransaction reparent(@NonNull WindowContainerToken child, |
| 308 |
@Nullable WindowContainerToken parent, boolean onTop) { |
| 309 |
mHierarchyOps.add(HierarchyOp.createForReparent(child.asBinder(), |
| 310 |
parent == null ? null : parent.asBinder(), |
| 311 |
onTop)); |
| 312 |
return this; |
| 313 |
} |
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
@NonNull |
| 322 |
public WindowContainerTransaction reorder(@NonNull WindowContainerToken child, boolean onTop) { |
| 323 |
mHierarchyOps.add(HierarchyOp.createForReorder(child.asBinder(), onTop)); |
| 324 |
return this; |
| 325 |
} |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
@NonNull |
| 344 |
public WindowContainerTransaction reparentTasks(@Nullable WindowContainerToken currentParent, |
| 345 |
@Nullable WindowContainerToken newParent, @Nullable int[] windowingModes, |
| 346 |
@Nullable int[] activityTypes, boolean onTop, boolean reparentTopOnly) { |
| 347 |
mHierarchyOps.add(HierarchyOp.createForChildrenTasksReparent( |
| 348 |
currentParent != null ? currentParent.asBinder() : null, |
| 349 |
newParent != null ? newParent.asBinder() : null, |
| 350 |
windowingModes, |
| 351 |
activityTypes, |
| 352 |
onTop, |
| 353 |
reparentTopOnly)); |
| 354 |
return this; |
| 355 |
} |
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
@NonNull |
| 373 |
public WindowContainerTransaction reparentTasks(@Nullable WindowContainerToken currentParent, |
| 374 |
@Nullable WindowContainerToken newParent, @Nullable int[] windowingModes, |
| 375 |
@Nullable int[] activityTypes, boolean onTop) { |
| 376 |
return reparentTasks(currentParent, newParent, windowingModes, activityTypes, onTop, |
| 377 |
false ); |
| 378 |
} |
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
@NonNull |
| 385 |
public WindowContainerTransaction setLaunchRoot(@NonNull WindowContainerToken container, |
| 386 |
@Nullable int[] windowingModes, @Nullable int[] activityTypes) { |
| 387 |
mHierarchyOps.add(HierarchyOp.createForSetLaunchRoot( |
| 388 |
container.asBinder(), |
| 389 |
windowingModes, |
| 390 |
activityTypes)); |
| 391 |
return this; |
| 392 |
} |
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
@NonNull |
| 402 |
public WindowContainerTransaction setAdjacentRoots( |
| 403 |
@NonNull WindowContainerToken root1, @NonNull WindowContainerToken root2) { |
| 404 |
mHierarchyOps.add(HierarchyOp.createForAdjacentRoots( |
| 405 |
root1.asBinder(), |
| 406 |
root2.asBinder())); |
| 407 |
return this; |
| 408 |
} |
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
@Deprecated |
| 416 |
@NonNull |
| 417 |
public WindowContainerTransaction setAdjacentRoots( |
| 418 |
@NonNull WindowContainerToken root1, @NonNull WindowContainerToken root2, |
| 419 |
boolean moveTogether) { |
| 420 |
return setAdjacentRoots(root1, root2); |
| 421 |
} |
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
@NonNull |
| 428 |
public WindowContainerTransaction setLaunchAdjacentFlagRoot( |
| 429 |
@NonNull WindowContainerToken container) { |
| 430 |
mHierarchyOps.add(HierarchyOp.createForSetLaunchAdjacentFlagRoot(container.asBinder(), |
| 431 |
false )); |
| 432 |
return this; |
| 433 |
} |
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
@NonNull |
| 439 |
public WindowContainerTransaction clearLaunchAdjacentFlagRoot( |
| 440 |
@NonNull WindowContainerToken container) { |
| 441 |
mHierarchyOps.add(HierarchyOp.createForSetLaunchAdjacentFlagRoot(container.asBinder(), |
| 442 |
true )); |
| 443 |
return this; |
| 444 |
} |
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
@NonNull |
| 453 |
public WindowContainerTransaction startTask(int taskId, @Nullable Bundle options) { |
| 454 |
mHierarchyOps.add(HierarchyOp.createForTaskLaunch(taskId, options)); |
| 455 |
return this; |
| 456 |
} |
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
@NonNull |
| 464 |
public WindowContainerTransaction removeTask(@NonNull WindowContainerToken containerToken) { |
| 465 |
mHierarchyOps.add(HierarchyOp.createForRemoveTask(containerToken.asBinder())); |
| 466 |
return this; |
| 467 |
} |
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
@NonNull |
| 478 |
public WindowContainerTransaction setDragResizing(@NonNull WindowContainerToken container, |
| 479 |
boolean dragResizing) { |
| 480 |
final Change change = getOrCreateChange(container.asBinder()); |
| 481 |
change.mChangeMask |= Change.CHANGE_DRAG_RESIZING; |
| 482 |
change.mDragResizing = dragResizing; |
| 483 |
return this; |
| 484 |
} |
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
@NonNull |
| 494 |
public WindowContainerTransaction sendPendingIntent(PendingIntent sender, Intent intent, |
| 495 |
@Nullable Bundle options) { |
| 496 |
mHierarchyOps.add(new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_PENDING_INTENT) |
| 497 |
.setLaunchOptions(options) |
| 498 |
.setPendingIntent(sender) |
| 499 |
.setActivityIntent(intent) |
| 500 |
.build()); |
| 501 |
return this; |
| 502 |
} |
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
@NonNull |
| 512 |
public WindowContainerTransaction startShortcut(@NonNull String callingPackage, |
| 513 |
@NonNull ShortcutInfo shortcutInfo, @Nullable Bundle options) { |
| 514 |
mHierarchyOps.add(HierarchyOp.createForStartShortcut( |
| 515 |
callingPackage, shortcutInfo, options)); |
| 516 |
return this; |
| 517 |
} |
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
@NonNull |
| 524 |
public WindowContainerTransaction createTaskFragment( |
| 525 |
@NonNull TaskFragmentCreationParams taskFragmentOptions) { |
| 526 |
final HierarchyOp hierarchyOp = |
| 527 |
new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_CREATE_TASK_FRAGMENT) |
| 528 |
.setTaskFragmentCreationOptions(taskFragmentOptions) |
| 529 |
.build(); |
| 530 |
mHierarchyOps.add(hierarchyOp); |
| 531 |
return this; |
| 532 |
} |
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
@NonNull |
| 539 |
public WindowContainerTransaction deleteTaskFragment( |
| 540 |
@NonNull WindowContainerToken taskFragment) { |
| 541 |
final HierarchyOp hierarchyOp = |
| 542 |
new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_DELETE_TASK_FRAGMENT) |
| 543 |
.setContainer(taskFragment.asBinder()) |
| 544 |
.build(); |
| 545 |
mHierarchyOps.add(hierarchyOp); |
| 546 |
return this; |
| 547 |
} |
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
@NonNull |
| 559 |
public WindowContainerTransaction startActivityInTaskFragment( |
| 560 |
@NonNull IBinder fragmentToken, @NonNull IBinder callerToken, |
| 561 |
@NonNull Intent activityIntent, @Nullable Bundle activityOptions) { |
| 562 |
final HierarchyOp hierarchyOp = |
| 563 |
new HierarchyOp.Builder( |
| 564 |
HierarchyOp.HIERARCHY_OP_TYPE_START_ACTIVITY_IN_TASK_FRAGMENT) |
| 565 |
.setContainer(fragmentToken) |
| 566 |
.setReparentContainer(callerToken) |
| 567 |
.setActivityIntent(activityIntent) |
| 568 |
.setLaunchOptions(activityOptions) |
| 569 |
.build(); |
| 570 |
mHierarchyOps.add(hierarchyOp); |
| 571 |
return this; |
| 572 |
} |
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
@NonNull |
| 581 |
public WindowContainerTransaction reparentActivityToTaskFragment( |
| 582 |
@NonNull IBinder fragmentToken, @NonNull IBinder activityToken) { |
| 583 |
final HierarchyOp hierarchyOp = |
| 584 |
new HierarchyOp.Builder( |
| 585 |
HierarchyOp.HIERARCHY_OP_TYPE_REPARENT_ACTIVITY_TO_TASK_FRAGMENT) |
| 586 |
.setReparentContainer(fragmentToken) |
| 587 |
.setContainer(activityToken) |
| 588 |
.build(); |
| 589 |
mHierarchyOps.add(hierarchyOp); |
| 590 |
return this; |
| 591 |
} |
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
@NonNull |
| 600 |
public WindowContainerTransaction reparentChildren( |
| 601 |
@NonNull WindowContainerToken oldParent, |
| 602 |
@Nullable WindowContainerToken newParent) { |
| 603 |
final HierarchyOp hierarchyOp = |
| 604 |
new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_REPARENT_CHILDREN) |
| 605 |
.setContainer(oldParent.asBinder()) |
| 606 |
.setReparentContainer(newParent != null ? newParent.asBinder() : null) |
| 607 |
.build(); |
| 608 |
mHierarchyOps.add(hierarchyOp); |
| 609 |
return this; |
| 610 |
} |
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
@NonNull |
| 626 |
public WindowContainerTransaction setAdjacentTaskFragments( |
| 627 |
@NonNull IBinder fragmentToken1, @Nullable IBinder fragmentToken2, |
| 628 |
@Nullable TaskFragmentAdjacentParams params) { |
| 629 |
final HierarchyOp hierarchyOp = |
| 630 |
new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_SET_ADJACENT_TASK_FRAGMENTS) |
| 631 |
.setContainer(fragmentToken1) |
| 632 |
.setReparentContainer(fragmentToken2) |
| 633 |
.setLaunchOptions(params != null ? params.toBundle() : null) |
| 634 |
.build(); |
| 635 |
mHierarchyOps.add(hierarchyOp); |
| 636 |
return this; |
| 637 |
} |
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
@NonNull |
| 647 |
public WindowContainerTransaction restoreTransientOrder( |
| 648 |
@NonNull WindowContainerToken container) { |
| 649 |
final HierarchyOp hierarchyOp = |
| 650 |
new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_RESTORE_TRANSIENT_ORDER) |
| 651 |
.setContainer(container.asBinder()) |
| 652 |
.build(); |
| 653 |
mHierarchyOps.add(hierarchyOp); |
| 654 |
return this; |
| 655 |
} |
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
@NonNull |
| 669 |
public WindowContainerTransaction addRectInsetsProvider( |
| 670 |
@NonNull WindowContainerToken receiverWindowContainer, |
| 671 |
@NonNull Rect insetsProviderFrame, |
| 672 |
@InsetsState.InternalInsetsType int[] insetsTypes) { |
| 673 |
final HierarchyOp hierarchyOp = |
| 674 |
new HierarchyOp.Builder( |
| 675 |
HierarchyOp.HIERARCHY_OP_TYPE_ADD_RECT_INSETS_PROVIDER) |
| 676 |
.setContainer(receiverWindowContainer.asBinder()) |
| 677 |
.setInsetsProviderFrame(insetsProviderFrame) |
| 678 |
.setInsetsTypes(insetsTypes) |
| 679 |
.build(); |
| 680 |
mHierarchyOps.add(hierarchyOp); |
| 681 |
return this; |
| 682 |
} |
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
@NonNull |
| 695 |
public WindowContainerTransaction removeInsetsProvider( |
| 696 |
@NonNull WindowContainerToken receiverWindowContainer, |
| 697 |
@InsetsState.InternalInsetsType int[] insetsTypes) { |
| 698 |
final HierarchyOp hierarchyOp = |
| 699 |
new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_REMOVE_INSETS_PROVIDER) |
| 700 |
.setContainer(receiverWindowContainer.asBinder()) |
| 701 |
.setInsetsTypes(insetsTypes) |
| 702 |
.build(); |
| 703 |
mHierarchyOps.add(hierarchyOp); |
| 704 |
return this; |
| 705 |
} |
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
@NonNull |
| 715 |
public WindowContainerTransaction requestFocusOnTaskFragment(@NonNull IBinder fragmentToken) { |
| 716 |
final HierarchyOp hierarchyOp = |
| 717 |
new HierarchyOp.Builder( |
| 718 |
HierarchyOp.HIERARCHY_OP_TYPE_REQUEST_FOCUS_ON_TASK_FRAGMENT) |
| 719 |
.setContainer(fragmentToken) |
| 720 |
.build(); |
| 721 |
mHierarchyOps.add(hierarchyOp); |
| 722 |
return this; |
| 723 |
} |
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
@NonNull |
| 732 |
public WindowContainerTransaction finishActivity(@NonNull IBinder activityToken) { |
| 733 |
final HierarchyOp hierarchyOp = |
| 734 |
new HierarchyOp.Builder( |
| 735 |
HierarchyOp.HIERARCHY_OP_TYPE_FINISH_ACTIVITY) |
| 736 |
.setContainer(activityToken) |
| 737 |
.build(); |
| 738 |
mHierarchyOps.add(hierarchyOp); |
| 739 |
return this; |
| 740 |
} |
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
@NonNull |
| 753 |
public WindowContainerTransaction setCompanionTaskFragment(@NonNull IBinder container, |
| 754 |
@Nullable IBinder companion) { |
| 755 |
final HierarchyOp hierarchyOp = |
| 756 |
new HierarchyOp.Builder( |
| 757 |
HierarchyOp.HIERARCHY_OP_TYPE_SET_COMPANION_TASK_FRAGMENT) |
| 758 |
.setContainer(container) |
| 759 |
.setReparentContainer(companion) |
| 760 |
.build(); |
| 761 |
mHierarchyOps.add(hierarchyOp); |
| 762 |
return this; |
| 763 |
} |
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
@NonNull |
| 775 |
public WindowContainerTransaction setTaskFragmentOperation(@NonNull IBinder fragmentToken, |
| 776 |
@NonNull TaskFragmentOperation taskFragmentOperation) { |
| 777 |
Objects.requireNonNull(fragmentToken); |
| 778 |
Objects.requireNonNull(taskFragmentOperation); |
| 779 |
final HierarchyOp hierarchyOp = |
| 780 |
new HierarchyOp.Builder( |
| 781 |
HierarchyOp.HIERARCHY_OP_TYPE_SET_TASK_FRAGMENT_OPERATION) |
| 782 |
.setContainer(fragmentToken) |
| 783 |
.setTaskFragmentOperation(taskFragmentOperation) |
| 784 |
.build(); |
| 785 |
mHierarchyOps.add(hierarchyOp); |
| 786 |
return this; |
| 787 |
} |
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
@NonNull |
| 809 |
public WindowContainerTransaction setAlwaysOnTop( |
| 810 |
@NonNull WindowContainerToken windowContainer, |
| 811 |
boolean alwaysOnTop) { |
| 812 |
final HierarchyOp hierarchyOp = |
| 813 |
new HierarchyOp.Builder( |
| 814 |
HierarchyOp.HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP) |
| 815 |
.setContainer(windowContainer.asBinder()) |
| 816 |
.setAlwaysOnTop(alwaysOnTop) |
| 817 |
.build(); |
| 818 |
mHierarchyOps.add(hierarchyOp); |
| 819 |
return this; |
| 820 |
} |
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
@NonNull |
| 830 |
public WindowContainerTransaction setErrorCallbackToken(@NonNull IBinder errorCallbackToken) { |
| 831 |
if (mErrorCallbackToken != null) { |
| 832 |
throw new IllegalStateException("Can't set multiple error token for one transaction."); |
| 833 |
} |
| 834 |
mErrorCallbackToken = errorCallbackToken; |
| 835 |
return this; |
| 836 |
} |
| 837 |
|
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
@NonNull |
| 847 |
public WindowContainerTransaction setTaskFragmentOrganizer( |
| 848 |
@NonNull ITaskFragmentOrganizer organizer) { |
| 849 |
mTaskFragmentOrganizer = organizer; |
| 850 |
return this; |
| 851 |
} |
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
@NonNull |
| 861 |
public WindowContainerTransaction setReparentLeafTaskIfRelaunch( |
| 862 |
@NonNull WindowContainerToken windowContainer, boolean reparentLeafTaskIfRelaunch) { |
| 863 |
final HierarchyOp hierarchyOp = |
| 864 |
new HierarchyOp.Builder( |
| 865 |
HierarchyOp.HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH) |
| 866 |
.setContainer(windowContainer.asBinder()) |
| 867 |
.setReparentLeafTaskIfRelaunch(reparentLeafTaskIfRelaunch) |
| 868 |
.build(); |
| 869 |
mHierarchyOps.add(hierarchyOp); |
| 870 |
return this; |
| 871 |
} |
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
public void merge(WindowContainerTransaction other, boolean transfer) { |
| 881 |
for (int i = 0, n = other.mChanges.size(); i < n; ++i) { |
| 882 |
final IBinder key = other.mChanges.keyAt(i); |
| 883 |
Change existing = mChanges.get(key); |
| 884 |
if (existing == null) { |
| 885 |
existing = new Change(); |
| 886 |
mChanges.put(key, existing); |
| 887 |
} |
| 888 |
existing.merge(other.mChanges.valueAt(i), transfer); |
| 889 |
} |
| 890 |
for (int i = 0, n = other.mHierarchyOps.size(); i < n; ++i) { |
| 891 |
mHierarchyOps.add(transfer ? other.mHierarchyOps.get(i) |
| 892 |
: new HierarchyOp(other.mHierarchyOps.get(i))); |
| 893 |
} |
| 894 |
if (mErrorCallbackToken != null && other.mErrorCallbackToken != null && mErrorCallbackToken |
| 895 |
!= other.mErrorCallbackToken) { |
| 896 |
throw new IllegalArgumentException("Can't merge two WCTs with different error token"); |
| 897 |
} |
| 898 |
final IBinder taskFragmentOrganizerAsBinder = mTaskFragmentOrganizer != null |
| 899 |
? mTaskFragmentOrganizer.asBinder() |
| 900 |
: null; |
| 901 |
final IBinder otherTaskFragmentOrganizerAsBinder = other.mTaskFragmentOrganizer != null |
| 902 |
? other.mTaskFragmentOrganizer.asBinder() |
| 903 |
: null; |
| 904 |
if (!Objects.equals(taskFragmentOrganizerAsBinder, otherTaskFragmentOrganizerAsBinder)) { |
| 905 |
throw new IllegalArgumentException( |
| 906 |
"Can't merge two WCTs from different TaskFragmentOrganizers"); |
| 907 |
} |
| 908 |
mErrorCallbackToken = mErrorCallbackToken != null |
| 909 |
? mErrorCallbackToken |
| 910 |
: other.mErrorCallbackToken; |
| 911 |
} |
| 912 |
|
| 913 |
|
| 914 |
public boolean isEmpty() { |
| 915 |
return mChanges.isEmpty() && mHierarchyOps.isEmpty(); |
| 916 |
} |
| 917 |
|
| 918 |
|
| 919 |
public Map<IBinder, Change> getChanges() { |
| 920 |
return mChanges; |
| 921 |
} |
| 922 |
|
| 923 |
|
| 924 |
public List<HierarchyOp> getHierarchyOps() { |
| 925 |
return mHierarchyOps; |
| 926 |
} |
| 927 |
|
| 928 |
|
| 929 |
@Nullable |
| 930 |
public IBinder getErrorCallbackToken() { |
| 931 |
return mErrorCallbackToken; |
| 932 |
} |
| 933 |
|
| 934 |
|
| 935 |
@Nullable |
| 936 |
public ITaskFragmentOrganizer getTaskFragmentOrganizer() { |
| 937 |
return mTaskFragmentOrganizer; |
| 938 |
} |
| 939 |
|
| 940 |
@Override |
| 941 |
@NonNull |
| 942 |
public String toString() { |
| 943 |
return "WindowContainerTransaction {" |
| 944 |
+ " changes = " + mChanges |
| 945 |
+ " hops = " + mHierarchyOps |
| 946 |
+ " errorCallbackToken=" + mErrorCallbackToken |
| 947 |
+ " taskFragmentOrganizer=" + mTaskFragmentOrganizer |
| 948 |
+ " }"; |
| 949 |
} |
| 950 |
|
| 951 |
@Override |
| 952 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 953 |
dest.writeMap(mChanges); |
| 954 |
dest.writeTypedList(mHierarchyOps); |
| 955 |
dest.writeStrongBinder(mErrorCallbackToken); |
| 956 |
dest.writeStrongInterface(mTaskFragmentOrganizer); |
| 957 |
} |
| 958 |
|
| 959 |
@Override |
| 960 |
public int describeContents() { |
| 961 |
return 0; |
| 962 |
} |
| 963 |
|
| 964 |
@NonNull |
| 965 |
public static final Creator<WindowContainerTransaction> CREATOR = |
| 966 |
new Creator<WindowContainerTransaction>() { |
| 967 |
@Override |
| 968 |
public WindowContainerTransaction createFromParcel(Parcel in) { |
| 969 |
return new WindowContainerTransaction(in); |
| 970 |
} |
| 971 |
|
| 972 |
@Override |
| 973 |
public WindowContainerTransaction[] newArray(int size) { |
| 974 |
return new WindowContainerTransaction[size]; |
| 975 |
} |
| 976 |
}; |
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
public static class Change implements Parcelable { |
| 983 |
public static final int CHANGE_FOCUSABLE = 1; |
| 984 |
public static final int CHANGE_BOUNDS_TRANSACTION = 1 << 1; |
| 985 |
public static final int CHANGE_PIP_CALLBACK = 1 << 2; |
| 986 |
public static final int CHANGE_HIDDEN = 1 << 3; |
| 987 |
public static final int CHANGE_BOUNDS_TRANSACTION_RECT = 1 << 4; |
| 988 |
public static final int CHANGE_IGNORE_ORIENTATION_REQUEST = 1 << 5; |
| 989 |
public static final int CHANGE_FORCE_NO_PIP = 1 << 6; |
| 990 |
public static final int CHANGE_FORCE_TRANSLUCENT = 1 << 7; |
| 991 |
public static final int CHANGE_DRAG_RESIZING = 1 << 8; |
| 992 |
|
| 993 |
private final Configuration mConfiguration = new Configuration(); |
| 994 |
private boolean mFocusable = true; |
| 995 |
private boolean mHidden = false; |
| 996 |
private boolean mIgnoreOrientationRequest = false; |
| 997 |
private boolean mForceTranslucent = false; |
| 998 |
private boolean mDragResizing = false; |
| 999 |
|
| 1000 |
private int mChangeMask = 0; |
| 1001 |
private @ActivityInfo.Config int mConfigSetMask = 0; |
| 1002 |
private @WindowConfiguration.WindowConfig int mWindowSetMask = 0; |
| 1003 |
|
| 1004 |
private Rect mPinnedBounds = null; |
| 1005 |
private SurfaceControl.Transaction mBoundsChangeTransaction = null; |
| 1006 |
private Rect mBoundsChangeSurfaceBounds = null; |
| 1007 |
|
| 1008 |
private int mActivityWindowingMode = -1; |
| 1009 |
private int mWindowingMode = -1; |
| 1010 |
|
| 1011 |
public Change() {} |
| 1012 |
|
| 1013 |
protected Change(Parcel in) { |
| 1014 |
mConfiguration.readFromParcel(in); |
| 1015 |
mFocusable = in.readBoolean(); |
| 1016 |
mHidden = in.readBoolean(); |
| 1017 |
mIgnoreOrientationRequest = in.readBoolean(); |
| 1018 |
mForceTranslucent = in.readBoolean(); |
| 1019 |
mDragResizing = in.readBoolean(); |
| 1020 |
mChangeMask = in.readInt(); |
| 1021 |
mConfigSetMask = in.readInt(); |
| 1022 |
mWindowSetMask = in.readInt(); |
| 1023 |
if ((mChangeMask & Change.CHANGE_PIP_CALLBACK) != 0) { |
| 1024 |
mPinnedBounds = new Rect(); |
| 1025 |
mPinnedBounds.readFromParcel(in); |
| 1026 |
} |
| 1027 |
if ((mChangeMask & Change.CHANGE_BOUNDS_TRANSACTION) != 0) { |
| 1028 |
mBoundsChangeTransaction = |
| 1029 |
SurfaceControl.Transaction.CREATOR.createFromParcel(in); |
| 1030 |
} |
| 1031 |
if ((mChangeMask & Change.CHANGE_BOUNDS_TRANSACTION_RECT) != 0) { |
| 1032 |
mBoundsChangeSurfaceBounds = new Rect(); |
| 1033 |
mBoundsChangeSurfaceBounds.readFromParcel(in); |
| 1034 |
} |
| 1035 |
|
| 1036 |
mWindowingMode = in.readInt(); |
| 1037 |
mActivityWindowingMode = in.readInt(); |
| 1038 |
} |
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
public void merge(Change other, boolean transfer) { |
| 1046 |
mConfiguration.setTo(other.mConfiguration, other.mConfigSetMask, other.mWindowSetMask); |
| 1047 |
mConfigSetMask |= other.mConfigSetMask; |
| 1048 |
mWindowSetMask |= other.mWindowSetMask; |
| 1049 |
if ((other.mChangeMask & CHANGE_FOCUSABLE) != 0) { |
| 1050 |
mFocusable = other.mFocusable; |
| 1051 |
} |
| 1052 |
if (transfer && (other.mChangeMask & CHANGE_BOUNDS_TRANSACTION) != 0) { |
| 1053 |
mBoundsChangeTransaction = other.mBoundsChangeTransaction; |
| 1054 |
other.mBoundsChangeTransaction = null; |
| 1055 |
} |
| 1056 |
if ((other.mChangeMask & CHANGE_PIP_CALLBACK) != 0) { |
| 1057 |
mPinnedBounds = transfer ? other.mPinnedBounds : new Rect(other.mPinnedBounds); |
| 1058 |
} |
| 1059 |
if ((other.mChangeMask & CHANGE_HIDDEN) != 0) { |
| 1060 |
mHidden = other.mHidden; |
| 1061 |
} |
| 1062 |
if ((other.mChangeMask & CHANGE_IGNORE_ORIENTATION_REQUEST) != 0) { |
| 1063 |
mIgnoreOrientationRequest = other.mIgnoreOrientationRequest; |
| 1064 |
} |
| 1065 |
if ((other.mChangeMask & CHANGE_FORCE_TRANSLUCENT) != 0) { |
| 1066 |
mForceTranslucent = other.mForceTranslucent; |
| 1067 |
} |
| 1068 |
if ((other.mChangeMask & CHANGE_DRAG_RESIZING) != 0) { |
| 1069 |
mDragResizing = other.mDragResizing; |
| 1070 |
} |
| 1071 |
mChangeMask |= other.mChangeMask; |
| 1072 |
if (other.mActivityWindowingMode >= 0) { |
| 1073 |
mActivityWindowingMode = other.mActivityWindowingMode; |
| 1074 |
} |
| 1075 |
if (other.mWindowingMode >= 0) { |
| 1076 |
mWindowingMode = other.mWindowingMode; |
| 1077 |
} |
| 1078 |
if (other.mBoundsChangeSurfaceBounds != null) { |
| 1079 |
mBoundsChangeSurfaceBounds = transfer ? other.mBoundsChangeSurfaceBounds |
| 1080 |
: new Rect(other.mBoundsChangeSurfaceBounds); |
| 1081 |
} |
| 1082 |
} |
| 1083 |
|
| 1084 |
public int getWindowingMode() { |
| 1085 |
return mWindowingMode; |
| 1086 |
} |
| 1087 |
|
| 1088 |
public int getActivityWindowingMode() { |
| 1089 |
return mActivityWindowingMode; |
| 1090 |
} |
| 1091 |
|
| 1092 |
public Configuration getConfiguration() { |
| 1093 |
return mConfiguration; |
| 1094 |
} |
| 1095 |
|
| 1096 |
|
| 1097 |
public boolean getFocusable() { |
| 1098 |
if ((mChangeMask & CHANGE_FOCUSABLE) == 0) { |
| 1099 |
throw new RuntimeException("Focusable not set. check CHANGE_FOCUSABLE first"); |
| 1100 |
} |
| 1101 |
return mFocusable; |
| 1102 |
} |
| 1103 |
|
| 1104 |
|
| 1105 |
public boolean getHidden() { |
| 1106 |
if ((mChangeMask & CHANGE_HIDDEN) == 0) { |
| 1107 |
throw new RuntimeException("Hidden not set. check CHANGE_HIDDEN first"); |
| 1108 |
} |
| 1109 |
return mHidden; |
| 1110 |
} |
| 1111 |
|
| 1112 |
|
| 1113 |
public boolean getIgnoreOrientationRequest() { |
| 1114 |
if ((mChangeMask & CHANGE_IGNORE_ORIENTATION_REQUEST) == 0) { |
| 1115 |
throw new RuntimeException("IgnoreOrientationRequest not set. " |
| 1116 |
+ "Check CHANGE_IGNORE_ORIENTATION_REQUEST first"); |
| 1117 |
} |
| 1118 |
return mIgnoreOrientationRequest; |
| 1119 |
} |
| 1120 |
|
| 1121 |
|
| 1122 |
public boolean getForceTranslucent() { |
| 1123 |
if ((mChangeMask & CHANGE_FORCE_TRANSLUCENT) == 0) { |
| 1124 |
throw new RuntimeException("Force translucent not set. " |
| 1125 |
+ "Check CHANGE_FORCE_TRANSLUCENT first"); |
| 1126 |
} |
| 1127 |
return mForceTranslucent; |
| 1128 |
} |
| 1129 |
|
| 1130 |
|
| 1131 |
public boolean getDragResizing() { |
| 1132 |
if ((mChangeMask & CHANGE_DRAG_RESIZING) == 0) { |
| 1133 |
throw new RuntimeException("Drag resizing not set. " |
| 1134 |
+ "Check CHANGE_DRAG_RESIZING first"); |
| 1135 |
} |
| 1136 |
return mDragResizing; |
| 1137 |
} |
| 1138 |
|
| 1139 |
public int getChangeMask() { |
| 1140 |
return mChangeMask; |
| 1141 |
} |
| 1142 |
|
| 1143 |
@ActivityInfo.Config |
| 1144 |
public int getConfigSetMask() { |
| 1145 |
return mConfigSetMask; |
| 1146 |
} |
| 1147 |
|
| 1148 |
@WindowConfiguration.WindowConfig |
| 1149 |
public int getWindowSetMask() { |
| 1150 |
return mWindowSetMask; |
| 1151 |
} |
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
public Rect getEnterPipBounds() { |
| 1158 |
return mPinnedBounds; |
| 1159 |
} |
| 1160 |
|
| 1161 |
public SurfaceControl.Transaction getBoundsChangeTransaction() { |
| 1162 |
return mBoundsChangeTransaction; |
| 1163 |
} |
| 1164 |
|
| 1165 |
public Rect getBoundsChangeSurfaceBounds() { |
| 1166 |
return mBoundsChangeSurfaceBounds; |
| 1167 |
} |
| 1168 |
|
| 1169 |
@Override |
| 1170 |
public String toString() { |
| 1171 |
final boolean changesBounds = |
| 1172 |
(mConfigSetMask & ActivityInfo.CONFIG_WINDOW_CONFIGURATION) != 0 |
| 1173 |
&& ((mWindowSetMask & WindowConfiguration.WINDOW_CONFIG_BOUNDS) |
| 1174 |
!= 0); |
| 1175 |
final boolean changesAppBounds = |
| 1176 |
(mConfigSetMask & ActivityInfo.CONFIG_WINDOW_CONFIGURATION) != 0 |
| 1177 |
&& ((mWindowSetMask & WindowConfiguration.WINDOW_CONFIG_APP_BOUNDS) |
| 1178 |
!= 0); |
| 1179 |
final boolean changesSs = (mConfigSetMask & ActivityInfo.CONFIG_SCREEN_SIZE) != 0; |
| 1180 |
final boolean changesSss = |
| 1181 |
(mConfigSetMask & ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE) != 0; |
| 1182 |
StringBuilder sb = new StringBuilder(); |
| 1183 |
sb.append('{'); |
| 1184 |
if (changesBounds) { |
| 1185 |
sb.append("bounds:" + mConfiguration.windowConfiguration.getBounds() + ","); |
| 1186 |
} |
| 1187 |
if (changesAppBounds) { |
| 1188 |
sb.append("appbounds:" + mConfiguration.windowConfiguration.getAppBounds() + ","); |
| 1189 |
} |
| 1190 |
if (changesSss) { |
| 1191 |
sb.append("ssw:" + mConfiguration.smallestScreenWidthDp + ","); |
| 1192 |
} |
| 1193 |
if (changesSs) { |
| 1194 |
sb.append("sw/h:" + mConfiguration.screenWidthDp + "x" |
| 1195 |
+ mConfiguration.screenHeightDp + ","); |
| 1196 |
} |
| 1197 |
if ((mChangeMask & CHANGE_FOCUSABLE) != 0) { |
| 1198 |
sb.append("focusable:" + mFocusable + ","); |
| 1199 |
} |
| 1200 |
if ((mChangeMask & CHANGE_DRAG_RESIZING) != 0) { |
| 1201 |
sb.append("dragResizing:" + mDragResizing + ","); |
| 1202 |
} |
| 1203 |
if (mBoundsChangeTransaction != null) { |
| 1204 |
sb.append("hasBoundsTransaction,"); |
| 1205 |
} |
| 1206 |
if ((mChangeMask & CHANGE_IGNORE_ORIENTATION_REQUEST) != 0) { |
| 1207 |
sb.append("ignoreOrientationRequest:" + mIgnoreOrientationRequest + ","); |
| 1208 |
} |
| 1209 |
sb.append("}"); |
| 1210 |
return sb.toString(); |
| 1211 |
} |
| 1212 |
|
| 1213 |
@Override |
| 1214 |
public void writeToParcel(Parcel dest, int flags) { |
| 1215 |
mConfiguration.writeToParcel(dest, flags); |
| 1216 |
dest.writeBoolean(mFocusable); |
| 1217 |
dest.writeBoolean(mHidden); |
| 1218 |
dest.writeBoolean(mIgnoreOrientationRequest); |
| 1219 |
dest.writeBoolean(mForceTranslucent); |
| 1220 |
dest.writeBoolean(mDragResizing); |
| 1221 |
dest.writeInt(mChangeMask); |
| 1222 |
dest.writeInt(mConfigSetMask); |
| 1223 |
dest.writeInt(mWindowSetMask); |
| 1224 |
|
| 1225 |
if (mPinnedBounds != null) { |
| 1226 |
mPinnedBounds.writeToParcel(dest, flags); |
| 1227 |
} |
| 1228 |
if (mBoundsChangeTransaction != null) { |
| 1229 |
mBoundsChangeTransaction.writeToParcel(dest, flags); |
| 1230 |
} |
| 1231 |
if (mBoundsChangeSurfaceBounds != null) { |
| 1232 |
mBoundsChangeSurfaceBounds.writeToParcel(dest, flags); |
| 1233 |
} |
| 1234 |
|
| 1235 |
dest.writeInt(mWindowingMode); |
| 1236 |
dest.writeInt(mActivityWindowingMode); |
| 1237 |
} |
| 1238 |
|
| 1239 |
@Override |
| 1240 |
public int describeContents() { |
| 1241 |
return 0; |
| 1242 |
} |
| 1243 |
|
| 1244 |
public static final Creator<Change> CREATOR = new Creator<Change>() { |
| 1245 |
@Override |
| 1246 |
public Change createFromParcel(Parcel in) { |
| 1247 |
return new Change(in); |
| 1248 |
} |
| 1249 |
|
| 1250 |
@Override |
| 1251 |
public Change[] newArray(int size) { |
| 1252 |
return new Change[size]; |
| 1253 |
} |
| 1254 |
}; |
| 1255 |
} |
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
|
| 1260 |
|
| 1261 |
|
| 1262 |
public static final class HierarchyOp implements Parcelable { |
| 1263 |
public static final int HIERARCHY_OP_TYPE_REPARENT = 0; |
| 1264 |
public static final int HIERARCHY_OP_TYPE_REORDER = 1; |
| 1265 |
public static final int HIERARCHY_OP_TYPE_CHILDREN_TASKS_REPARENT = 2; |
| 1266 |
public static final int HIERARCHY_OP_TYPE_SET_LAUNCH_ROOT = 3; |
| 1267 |
public static final int HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS = 4; |
| 1268 |
public static final int HIERARCHY_OP_TYPE_LAUNCH_TASK = 5; |
| 1269 |
public static final int HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT = 6; |
| 1270 |
public static final int HIERARCHY_OP_TYPE_CREATE_TASK_FRAGMENT = 7; |
| 1271 |
public static final int HIERARCHY_OP_TYPE_DELETE_TASK_FRAGMENT = 8; |
| 1272 |
public static final int HIERARCHY_OP_TYPE_START_ACTIVITY_IN_TASK_FRAGMENT = 9; |
| 1273 |
public static final int HIERARCHY_OP_TYPE_REPARENT_ACTIVITY_TO_TASK_FRAGMENT = 10; |
| 1274 |
public static final int HIERARCHY_OP_TYPE_REPARENT_CHILDREN = 11; |
| 1275 |
public static final int HIERARCHY_OP_TYPE_PENDING_INTENT = 12; |
| 1276 |
public static final int HIERARCHY_OP_TYPE_SET_ADJACENT_TASK_FRAGMENTS = 13; |
| 1277 |
public static final int HIERARCHY_OP_TYPE_START_SHORTCUT = 14; |
| 1278 |
public static final int HIERARCHY_OP_TYPE_RESTORE_TRANSIENT_ORDER = 15; |
| 1279 |
public static final int HIERARCHY_OP_TYPE_ADD_RECT_INSETS_PROVIDER = 16; |
| 1280 |
public static final int HIERARCHY_OP_TYPE_REMOVE_INSETS_PROVIDER = 17; |
| 1281 |
public static final int HIERARCHY_OP_TYPE_REQUEST_FOCUS_ON_TASK_FRAGMENT = 18; |
| 1282 |
public static final int HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP = 19; |
| 1283 |
public static final int HIERARCHY_OP_TYPE_REMOVE_TASK = 20; |
| 1284 |
public static final int HIERARCHY_OP_TYPE_FINISH_ACTIVITY = 21; |
| 1285 |
public static final int HIERARCHY_OP_TYPE_SET_COMPANION_TASK_FRAGMENT = 22; |
| 1286 |
public static final int HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH = 23; |
| 1287 |
public static final int HIERARCHY_OP_TYPE_SET_TASK_FRAGMENT_OPERATION = 24; |
| 1288 |
|
| 1289 |
|
| 1290 |
|
| 1291 |
public static final String LAUNCH_KEY_TASK_ID = "android:transaction.hop.taskId"; |
| 1292 |
|
| 1293 |
|
| 1294 |
public static final String LAUNCH_KEY_SHORTCUT_CALLING_PACKAGE = |
| 1295 |
"android:transaction.hop.shortcut_calling_package"; |
| 1296 |
|
| 1297 |
private final int mType; |
| 1298 |
|
| 1299 |
|
| 1300 |
@Nullable |
| 1301 |
private IBinder mContainer; |
| 1302 |
|
| 1303 |
|
| 1304 |
@Nullable |
| 1305 |
private IBinder mReparent; |
| 1306 |
|
| 1307 |
private @InsetsState.InternalInsetsType int[] mInsetsTypes; |
| 1308 |
|
| 1309 |
private Rect mInsetsProviderFrame; |
| 1310 |
|
| 1311 |
|
| 1312 |
private boolean mToTop; |
| 1313 |
|
| 1314 |
private boolean mReparentTopOnly; |
| 1315 |
|
| 1316 |
@Nullable |
| 1317 |
private int[] mWindowingModes; |
| 1318 |
|
| 1319 |
@Nullable |
| 1320 |
private int[] mActivityTypes; |
| 1321 |
|
| 1322 |
@Nullable |
| 1323 |
private Bundle mLaunchOptions; |
| 1324 |
|
| 1325 |
@Nullable |
| 1326 |
private Intent mActivityIntent; |
| 1327 |
|
| 1328 |
|
| 1329 |
@Nullable |
| 1330 |
private TaskFragmentCreationParams mTaskFragmentCreationOptions; |
| 1331 |
|
| 1332 |
|
| 1333 |
@Nullable |
| 1334 |
private TaskFragmentOperation mTaskFragmentOperation; |
| 1335 |
|
| 1336 |
@Nullable |
| 1337 |
private PendingIntent mPendingIntent; |
| 1338 |
|
| 1339 |
@Nullable |
| 1340 |
private ShortcutInfo mShortcutInfo; |
| 1341 |
|
| 1342 |
private boolean mAlwaysOnTop; |
| 1343 |
|
| 1344 |
private boolean mReparentLeafTaskIfRelaunch; |
| 1345 |
|
| 1346 |
public static HierarchyOp createForReparent( |
| 1347 |
@NonNull IBinder container, @Nullable IBinder reparent, boolean toTop) { |
| 1348 |
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_REPARENT) |
| 1349 |
.setContainer(container) |
| 1350 |
.setReparentContainer(reparent) |
| 1351 |
.setToTop(toTop) |
| 1352 |
.build(); |
| 1353 |
} |
| 1354 |
|
| 1355 |
public static HierarchyOp createForReorder(@NonNull IBinder container, boolean toTop) { |
| 1356 |
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_REORDER) |
| 1357 |
.setContainer(container) |
| 1358 |
.setReparentContainer(container) |
| 1359 |
.setToTop(toTop) |
| 1360 |
.build(); |
| 1361 |
} |
| 1362 |
|
| 1363 |
public static HierarchyOp createForChildrenTasksReparent(IBinder currentParent, |
| 1364 |
IBinder newParent, int[] windowingModes, int[] activityTypes, boolean onTop, |
| 1365 |
boolean reparentTopOnly) { |
| 1366 |
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_CHILDREN_TASKS_REPARENT) |
| 1367 |
.setContainer(currentParent) |
| 1368 |
.setReparentContainer(newParent) |
| 1369 |
.setWindowingModes(windowingModes) |
| 1370 |
.setActivityTypes(activityTypes) |
| 1371 |
.setToTop(onTop) |
| 1372 |
.setReparentTopOnly(reparentTopOnly) |
| 1373 |
.build(); |
| 1374 |
} |
| 1375 |
|
| 1376 |
public static HierarchyOp createForSetLaunchRoot(IBinder container, |
| 1377 |
int[] windowingModes, int[] activityTypes) { |
| 1378 |
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_SET_LAUNCH_ROOT) |
| 1379 |
.setContainer(container) |
| 1380 |
.setWindowingModes(windowingModes) |
| 1381 |
.setActivityTypes(activityTypes) |
| 1382 |
.build(); |
| 1383 |
} |
| 1384 |
|
| 1385 |
|
| 1386 |
public static HierarchyOp createForAdjacentRoots(IBinder root1, IBinder root2) { |
| 1387 |
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS) |
| 1388 |
.setContainer(root1) |
| 1389 |
.setReparentContainer(root2) |
| 1390 |
.build(); |
| 1391 |
} |
| 1392 |
|
| 1393 |
|
| 1394 |
public static HierarchyOp createForTaskLaunch(int taskId, @Nullable Bundle options) { |
| 1395 |
final Bundle fullOptions = options == null ? new Bundle() : options; |
| 1396 |
fullOptions.putInt(LAUNCH_KEY_TASK_ID, taskId); |
| 1397 |
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_LAUNCH_TASK) |
| 1398 |
.setToTop(true) |
| 1399 |
.setLaunchOptions(fullOptions) |
| 1400 |
.build(); |
| 1401 |
} |
| 1402 |
|
| 1403 |
|
| 1404 |
public static HierarchyOp createForStartShortcut(@NonNull String callingPackage, |
| 1405 |
@NonNull ShortcutInfo shortcutInfo, @Nullable Bundle options) { |
| 1406 |
final Bundle fullOptions = options == null ? new Bundle() : options; |
| 1407 |
fullOptions.putString(LAUNCH_KEY_SHORTCUT_CALLING_PACKAGE, callingPackage); |
| 1408 |
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_START_SHORTCUT) |
| 1409 |
.setShortcutInfo(shortcutInfo) |
| 1410 |
.setLaunchOptions(fullOptions) |
| 1411 |
.build(); |
| 1412 |
} |
| 1413 |
|
| 1414 |
|
| 1415 |
public static HierarchyOp createForSetLaunchAdjacentFlagRoot(IBinder container, |
| 1416 |
boolean clearRoot) { |
| 1417 |
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT) |
| 1418 |
.setContainer(container) |
| 1419 |
.setToTop(clearRoot) |
| 1420 |
.build(); |
| 1421 |
} |
| 1422 |
|
| 1423 |
|
| 1424 |
public static HierarchyOp createForRemoveTask(@NonNull IBinder container) { |
| 1425 |
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_REMOVE_TASK) |
| 1426 |
.setContainer(container) |
| 1427 |
.build(); |
| 1428 |
} |
| 1429 |
|
| 1430 |
|
| 1431 |
private HierarchyOp(int type) { |
| 1432 |
mType = type; |
| 1433 |
} |
| 1434 |
|
| 1435 |
public HierarchyOp(@NonNull HierarchyOp copy) { |
| 1436 |
mType = copy.mType; |
| 1437 |
mContainer = copy.mContainer; |
| 1438 |
mReparent = copy.mReparent; |
| 1439 |
mInsetsTypes = copy.mInsetsTypes; |
| 1440 |
mInsetsProviderFrame = copy.mInsetsProviderFrame; |
| 1441 |
mToTop = copy.mToTop; |
| 1442 |
mReparentTopOnly = copy.mReparentTopOnly; |
| 1443 |
mWindowingModes = copy.mWindowingModes; |
| 1444 |
mActivityTypes = copy.mActivityTypes; |
| 1445 |
mLaunchOptions = copy.mLaunchOptions; |
| 1446 |
mActivityIntent = copy.mActivityIntent; |
| 1447 |
mTaskFragmentCreationOptions = copy.mTaskFragmentCreationOptions; |
| 1448 |
mTaskFragmentOperation = copy.mTaskFragmentOperation; |
| 1449 |
mPendingIntent = copy.mPendingIntent; |
| 1450 |
mShortcutInfo = copy.mShortcutInfo; |
| 1451 |
mAlwaysOnTop = copy.mAlwaysOnTop; |
| 1452 |
mReparentLeafTaskIfRelaunch = copy.mReparentLeafTaskIfRelaunch; |
| 1453 |
} |
| 1454 |
|
| 1455 |
protected HierarchyOp(Parcel in) { |
| 1456 |
mType = in.readInt(); |
| 1457 |
mContainer = in.readStrongBinder(); |
| 1458 |
mReparent = in.readStrongBinder(); |
| 1459 |
mInsetsTypes = in.createIntArray(); |
| 1460 |
if (in.readInt() != 0) { |
| 1461 |
mInsetsProviderFrame = Rect.CREATOR.createFromParcel(in); |
| 1462 |
} else { |
| 1463 |
mInsetsProviderFrame = null; |
| 1464 |
} |
| 1465 |
mToTop = in.readBoolean(); |
| 1466 |
mReparentTopOnly = in.readBoolean(); |
| 1467 |
mWindowingModes = in.createIntArray(); |
| 1468 |
mActivityTypes = in.createIntArray(); |
| 1469 |
mLaunchOptions = in.readBundle(); |
| 1470 |
mActivityIntent = in.readTypedObject(Intent.CREATOR); |
| 1471 |
mTaskFragmentCreationOptions = in.readTypedObject(TaskFragmentCreationParams.CREATOR); |
| 1472 |
mTaskFragmentOperation = in.readTypedObject(TaskFragmentOperation.CREATOR); |
| 1473 |
mPendingIntent = in.readTypedObject(PendingIntent.CREATOR); |
| 1474 |
mShortcutInfo = in.readTypedObject(ShortcutInfo.CREATOR); |
| 1475 |
mAlwaysOnTop = in.readBoolean(); |
| 1476 |
mReparentLeafTaskIfRelaunch = in.readBoolean(); |
| 1477 |
} |
| 1478 |
|
| 1479 |
public int getType() { |
| 1480 |
return mType; |
| 1481 |
} |
| 1482 |
|
| 1483 |
public boolean isReparent() { |
| 1484 |
return mType == HIERARCHY_OP_TYPE_REPARENT; |
| 1485 |
} |
| 1486 |
|
| 1487 |
@Nullable |
| 1488 |
public IBinder getNewParent() { |
| 1489 |
return mReparent; |
| 1490 |
} |
| 1491 |
|
| 1492 |
@Nullable |
| 1493 |
public @InsetsState.InternalInsetsType int[] getInsetsTypes() { |
| 1494 |
return mInsetsTypes; |
| 1495 |
} |
| 1496 |
|
| 1497 |
public Rect getInsetsProviderFrame() { |
| 1498 |
return mInsetsProviderFrame; |
| 1499 |
} |
| 1500 |
|
| 1501 |
@NonNull |
| 1502 |
public IBinder getContainer() { |
| 1503 |
return mContainer; |
| 1504 |
} |
| 1505 |
|
| 1506 |
@NonNull |
| 1507 |
public IBinder getAdjacentRoot() { |
| 1508 |
return mReparent; |
| 1509 |
} |
| 1510 |
|
| 1511 |
@NonNull |
| 1512 |
public IBinder getCompanionContainer() { |
| 1513 |
return mReparent; |
| 1514 |
} |
| 1515 |
|
| 1516 |
@NonNull |
| 1517 |
public IBinder getCallingActivity() { |
| 1518 |
return mReparent; |
| 1519 |
} |
| 1520 |
|
| 1521 |
public boolean getToTop() { |
| 1522 |
return mToTop; |
| 1523 |
} |
| 1524 |
|
| 1525 |
public boolean getReparentTopOnly() { |
| 1526 |
return mReparentTopOnly; |
| 1527 |
} |
| 1528 |
|
| 1529 |
public int[] getWindowingModes() { |
| 1530 |
return mWindowingModes; |
| 1531 |
} |
| 1532 |
|
| 1533 |
public int[] getActivityTypes() { |
| 1534 |
return mActivityTypes; |
| 1535 |
} |
| 1536 |
|
| 1537 |
@Nullable |
| 1538 |
public Bundle getLaunchOptions() { |
| 1539 |
return mLaunchOptions; |
| 1540 |
} |
| 1541 |
|
| 1542 |
@Nullable |
| 1543 |
public Intent getActivityIntent() { |
| 1544 |
return mActivityIntent; |
| 1545 |
} |
| 1546 |
|
| 1547 |
public boolean isAlwaysOnTop() { |
| 1548 |
return mAlwaysOnTop; |
| 1549 |
} |
| 1550 |
|
| 1551 |
public boolean isReparentLeafTaskIfRelaunch() { |
| 1552 |
return mReparentLeafTaskIfRelaunch; |
| 1553 |
} |
| 1554 |
|
| 1555 |
@Nullable |
| 1556 |
public TaskFragmentCreationParams getTaskFragmentCreationOptions() { |
| 1557 |
return mTaskFragmentCreationOptions; |
| 1558 |
} |
| 1559 |
|
| 1560 |
@Nullable |
| 1561 |
public TaskFragmentOperation getTaskFragmentOperation() { |
| 1562 |
return mTaskFragmentOperation; |
| 1563 |
} |
| 1564 |
|
| 1565 |
@Nullable |
| 1566 |
public PendingIntent getPendingIntent() { |
| 1567 |
return mPendingIntent; |
| 1568 |
} |
| 1569 |
|
| 1570 |
@Nullable |
| 1571 |
public ShortcutInfo getShortcutInfo() { |
| 1572 |
return mShortcutInfo; |
| 1573 |
} |
| 1574 |
|
| 1575 |
@Override |
| 1576 |
public String toString() { |
| 1577 |
switch (mType) { |
| 1578 |
case HIERARCHY_OP_TYPE_CHILDREN_TASKS_REPARENT: |
| 1579 |
return "{ChildrenTasksReparent: from=" + mContainer + " to=" + mReparent |
| 1580 |
+ " mToTop=" + mToTop + " mReparentTopOnly=" + mReparentTopOnly |
| 1581 |
+ " mWindowingMode=" + Arrays.toString(mWindowingModes) |
| 1582 |
+ " mActivityType=" + Arrays.toString(mActivityTypes) + "}"; |
| 1583 |
case HIERARCHY_OP_TYPE_SET_LAUNCH_ROOT: |
| 1584 |
return "{SetLaunchRoot: container=" + mContainer |
| 1585 |
+ " mWindowingMode=" + Arrays.toString(mWindowingModes) |
| 1586 |
+ " mActivityType=" + Arrays.toString(mActivityTypes) + "}"; |
| 1587 |
case HIERARCHY_OP_TYPE_REPARENT: |
| 1588 |
return "{reparent: " + mContainer + " to " + (mToTop ? "top of " : "bottom of ") |
| 1589 |
+ mReparent + "}"; |
| 1590 |
case HIERARCHY_OP_TYPE_REORDER: |
| 1591 |
return "{reorder: " + mContainer + " to " + (mToTop ? "top" : "bottom") + "}"; |
| 1592 |
case HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS: |
| 1593 |
return "{SetAdjacentRoot: container=" + mContainer |
| 1594 |
+ " adjacentRoot=" + mReparent + "}"; |
| 1595 |
case HIERARCHY_OP_TYPE_LAUNCH_TASK: |
| 1596 |
return "{LaunchTask: " + mLaunchOptions + "}"; |
| 1597 |
case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT: |
| 1598 |
return "{SetAdjacentFlagRoot: container=" + mContainer + " clearRoot=" + mToTop |
| 1599 |
+ "}"; |
| 1600 |
case HIERARCHY_OP_TYPE_CREATE_TASK_FRAGMENT: |
| 1601 |
return "{CreateTaskFragment: options=" + mTaskFragmentCreationOptions + "}"; |
| 1602 |
case HIERARCHY_OP_TYPE_DELETE_TASK_FRAGMENT: |
| 1603 |
return "{DeleteTaskFragment: taskFragment=" + mContainer + "}"; |
| 1604 |
case HIERARCHY_OP_TYPE_START_ACTIVITY_IN_TASK_FRAGMENT: |
| 1605 |
return "{StartActivityInTaskFragment: fragmentToken=" + mContainer + " intent=" |
| 1606 |
+ mActivityIntent + " options=" + mLaunchOptions + "}"; |
| 1607 |
case HIERARCHY_OP_TYPE_REPARENT_ACTIVITY_TO_TASK_FRAGMENT: |
| 1608 |
return "{ReparentActivityToTaskFragment: fragmentToken=" + mReparent |
| 1609 |
+ " activity=" + mContainer + "}"; |
| 1610 |
case HIERARCHY_OP_TYPE_REPARENT_CHILDREN: |
| 1611 |
return "{ReparentChildren: oldParent=" + mContainer + " newParent=" + mReparent |
| 1612 |
+ "}"; |
| 1613 |
case HIERARCHY_OP_TYPE_SET_ADJACENT_TASK_FRAGMENTS: |
| 1614 |
return "{SetAdjacentTaskFragments: container=" + mContainer |
| 1615 |
+ " adjacentContainer=" + mReparent + "}"; |
| 1616 |
case HIERARCHY_OP_TYPE_START_SHORTCUT: |
| 1617 |
return "{StartShortcut: options=" + mLaunchOptions + " info=" + mShortcutInfo |
| 1618 |
+ "}"; |
| 1619 |
case HIERARCHY_OP_TYPE_ADD_RECT_INSETS_PROVIDER: |
| 1620 |
return "{addRectInsetsProvider: container=" + mContainer |
| 1621 |
+ " insetsProvidingFrame=" + mInsetsProviderFrame |
| 1622 |
+ " insetsType=" + Arrays.toString(mInsetsTypes) + "}"; |
| 1623 |
case HIERARCHY_OP_TYPE_REMOVE_INSETS_PROVIDER: |
| 1624 |
return "{removeLocalInsetsProvider: container=" + mContainer |
| 1625 |
+ " insetsType=" + Arrays.toString(mInsetsTypes) + "}"; |
| 1626 |
case HIERARCHY_OP_TYPE_REQUEST_FOCUS_ON_TASK_FRAGMENT: |
| 1627 |
return "{requestFocusOnTaskFragment: container=" + mContainer + "}"; |
| 1628 |
case HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP: |
| 1629 |
return "{setAlwaysOnTop: container=" + mContainer |
| 1630 |
+ " alwaysOnTop=" + mAlwaysOnTop + "}"; |
| 1631 |
case HIERARCHY_OP_TYPE_REMOVE_TASK: |
| 1632 |
return "{RemoveTask: task=" + mContainer + "}"; |
| 1633 |
case HIERARCHY_OP_TYPE_FINISH_ACTIVITY: |
| 1634 |
return "{finishActivity: activity=" + mContainer + "}"; |
| 1635 |
case HIERARCHY_OP_TYPE_SET_COMPANION_TASK_FRAGMENT: |
| 1636 |
return "{setCompanionTaskFragment: container = " + mContainer + " companion = " |
| 1637 |
+ mReparent + "}"; |
| 1638 |
case HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH: |
| 1639 |
return "{setReparentLeafTaskIfRelaunch: container= " + mContainer |
| 1640 |
+ " reparentLeafTaskIfRelaunch= " + mReparentLeafTaskIfRelaunch + "}"; |
| 1641 |
case HIERARCHY_OP_TYPE_SET_TASK_FRAGMENT_OPERATION: |
| 1642 |
return "{setTaskFragmentOperation: fragmentToken= " + mContainer |
| 1643 |
+ " operation= " + mTaskFragmentOperation + "}"; |
| 1644 |
default: |
| 1645 |
return "{mType=" + mType + " container=" + mContainer + " reparent=" + mReparent |
| 1646 |
+ " mToTop=" + mToTop |
| 1647 |
+ " mWindowingMode=" + Arrays.toString(mWindowingModes) |
| 1648 |
+ " mActivityType=" + Arrays.toString(mActivityTypes) + "}"; |
| 1649 |
} |
| 1650 |
} |
| 1651 |
|
| 1652 |
@Override |
| 1653 |
public void writeToParcel(Parcel dest, int flags) { |
| 1654 |
dest.writeInt(mType); |
| 1655 |
dest.writeStrongBinder(mContainer); |
| 1656 |
dest.writeStrongBinder(mReparent); |
| 1657 |
dest.writeIntArray(mInsetsTypes); |
| 1658 |
if (mInsetsProviderFrame != null) { |
| 1659 |
dest.writeInt(1); |
| 1660 |
mInsetsProviderFrame.writeToParcel(dest, 0); |
| 1661 |
} else { |
| 1662 |
dest.writeInt(0); |
| 1663 |
} |
| 1664 |
dest.writeBoolean(mToTop); |
| 1665 |
dest.writeBoolean(mReparentTopOnly); |
| 1666 |
dest.writeIntArray(mWindowingModes); |
| 1667 |
dest.writeIntArray(mActivityTypes); |
| 1668 |
dest.writeBundle(mLaunchOptions); |
| 1669 |
dest.writeTypedObject(mActivityIntent, flags); |
| 1670 |
dest.writeTypedObject(mTaskFragmentCreationOptions, flags); |
| 1671 |
dest.writeTypedObject(mTaskFragmentOperation, flags); |
| 1672 |
dest.writeTypedObject(mPendingIntent, flags); |
| 1673 |
dest.writeTypedObject(mShortcutInfo, flags); |
| 1674 |
dest.writeBoolean(mAlwaysOnTop); |
| 1675 |
dest.writeBoolean(mReparentLeafTaskIfRelaunch); |
| 1676 |
} |
| 1677 |
|
| 1678 |
@Override |
| 1679 |
public int describeContents() { |
| 1680 |
return 0; |
| 1681 |
} |
| 1682 |
|
| 1683 |
public static final Creator<HierarchyOp> CREATOR = new Creator<HierarchyOp>() { |
| 1684 |
@Override |
| 1685 |
public HierarchyOp createFromParcel(Parcel in) { |
| 1686 |
return new HierarchyOp(in); |
| 1687 |
} |
| 1688 |
|
| 1689 |
@Override |
| 1690 |
public HierarchyOp[] newArray(int size) { |
| 1691 |
return new HierarchyOp[size]; |
| 1692 |
} |
| 1693 |
}; |
| 1694 |
|
| 1695 |
private static class Builder { |
| 1696 |
|
| 1697 |
private final int mType; |
| 1698 |
|
| 1699 |
@Nullable |
| 1700 |
private IBinder mContainer; |
| 1701 |
|
| 1702 |
@Nullable |
| 1703 |
private IBinder mReparent; |
| 1704 |
|
| 1705 |
private int[] mInsetsTypes; |
| 1706 |
|
| 1707 |
private Rect mInsetsProviderFrame; |
| 1708 |
|
| 1709 |
private boolean mToTop; |
| 1710 |
|
| 1711 |
private boolean mReparentTopOnly; |
| 1712 |
|
| 1713 |
@Nullable |
| 1714 |
private int[] mWindowingModes; |
| 1715 |
|
| 1716 |
@Nullable |
| 1717 |
private int[] mActivityTypes; |
| 1718 |
|
| 1719 |
@Nullable |
| 1720 |
private Bundle mLaunchOptions; |
| 1721 |
|
| 1722 |
@Nullable |
| 1723 |
private Intent mActivityIntent; |
| 1724 |
|
| 1725 |
@Nullable |
| 1726 |
private TaskFragmentCreationParams mTaskFragmentCreationOptions; |
| 1727 |
|
| 1728 |
@Nullable |
| 1729 |
private TaskFragmentOperation mTaskFragmentOperation; |
| 1730 |
|
| 1731 |
@Nullable |
| 1732 |
private PendingIntent mPendingIntent; |
| 1733 |
|
| 1734 |
@Nullable |
| 1735 |
private ShortcutInfo mShortcutInfo; |
| 1736 |
|
| 1737 |
private boolean mAlwaysOnTop; |
| 1738 |
|
| 1739 |
private boolean mReparentLeafTaskIfRelaunch; |
| 1740 |
|
| 1741 |
Builder(int type) { |
| 1742 |
mType = type; |
| 1743 |
} |
| 1744 |
|
| 1745 |
Builder setContainer(@Nullable IBinder container) { |
| 1746 |
mContainer = container; |
| 1747 |
return this; |
| 1748 |
} |
| 1749 |
|
| 1750 |
Builder setReparentContainer(@Nullable IBinder reparentContainer) { |
| 1751 |
mReparent = reparentContainer; |
| 1752 |
return this; |
| 1753 |
} |
| 1754 |
|
| 1755 |
Builder setInsetsTypes(int[] insetsTypes) { |
| 1756 |
mInsetsTypes = insetsTypes; |
| 1757 |
return this; |
| 1758 |
} |
| 1759 |
|
| 1760 |
Builder setInsetsProviderFrame(Rect insetsProviderFrame) { |
| 1761 |
mInsetsProviderFrame = insetsProviderFrame; |
| 1762 |
return this; |
| 1763 |
} |
| 1764 |
|
| 1765 |
Builder setToTop(boolean toTop) { |
| 1766 |
mToTop = toTop; |
| 1767 |
return this; |
| 1768 |
} |
| 1769 |
|
| 1770 |
Builder setReparentTopOnly(boolean reparentTopOnly) { |
| 1771 |
mReparentTopOnly = reparentTopOnly; |
| 1772 |
return this; |
| 1773 |
} |
| 1774 |
|
| 1775 |
Builder setWindowingModes(@Nullable int[] windowingModes) { |
| 1776 |
mWindowingModes = windowingModes; |
| 1777 |
return this; |
| 1778 |
} |
| 1779 |
|
| 1780 |
Builder setActivityTypes(@Nullable int[] activityTypes) { |
| 1781 |
mActivityTypes = activityTypes; |
| 1782 |
return this; |
| 1783 |
} |
| 1784 |
|
| 1785 |
Builder setLaunchOptions(@Nullable Bundle launchOptions) { |
| 1786 |
mLaunchOptions = launchOptions; |
| 1787 |
return this; |
| 1788 |
} |
| 1789 |
|
| 1790 |
Builder setActivityIntent(@Nullable Intent activityIntent) { |
| 1791 |
mActivityIntent = activityIntent; |
| 1792 |
return this; |
| 1793 |
} |
| 1794 |
|
| 1795 |
Builder setPendingIntent(@Nullable PendingIntent sender) { |
| 1796 |
mPendingIntent = sender; |
| 1797 |
return this; |
| 1798 |
} |
| 1799 |
|
| 1800 |
Builder setAlwaysOnTop(boolean alwaysOnTop) { |
| 1801 |
mAlwaysOnTop = alwaysOnTop; |
| 1802 |
return this; |
| 1803 |
} |
| 1804 |
|
| 1805 |
Builder setTaskFragmentCreationOptions( |
| 1806 |
@Nullable TaskFragmentCreationParams taskFragmentCreationOptions) { |
| 1807 |
mTaskFragmentCreationOptions = taskFragmentCreationOptions; |
| 1808 |
return this; |
| 1809 |
} |
| 1810 |
|
| 1811 |
Builder setTaskFragmentOperation( |
| 1812 |
@Nullable TaskFragmentOperation taskFragmentOperation) { |
| 1813 |
mTaskFragmentOperation = taskFragmentOperation; |
| 1814 |
return this; |
| 1815 |
} |
| 1816 |
|
| 1817 |
Builder setReparentLeafTaskIfRelaunch(boolean reparentLeafTaskIfRelaunch) { |
| 1818 |
mReparentLeafTaskIfRelaunch = reparentLeafTaskIfRelaunch; |
| 1819 |
return this; |
| 1820 |
} |
| 1821 |
|
| 1822 |
Builder setShortcutInfo(@Nullable ShortcutInfo shortcutInfo) { |
| 1823 |
mShortcutInfo = shortcutInfo; |
| 1824 |
return this; |
| 1825 |
} |
| 1826 |
|
| 1827 |
HierarchyOp build() { |
| 1828 |
final HierarchyOp hierarchyOp = new HierarchyOp(mType); |
| 1829 |
hierarchyOp.mContainer = mContainer; |
| 1830 |
hierarchyOp.mReparent = mReparent; |
| 1831 |
hierarchyOp.mWindowingModes = mWindowingModes != null |
| 1832 |
? Arrays.copyOf(mWindowingModes, mWindowingModes.length) |
| 1833 |
: null; |
| 1834 |
hierarchyOp.mActivityTypes = mActivityTypes != null |
| 1835 |
? Arrays.copyOf(mActivityTypes, mActivityTypes.length) |
| 1836 |
: null; |
| 1837 |
hierarchyOp.mInsetsTypes = mInsetsTypes; |
| 1838 |
hierarchyOp.mInsetsProviderFrame = mInsetsProviderFrame; |
| 1839 |
hierarchyOp.mToTop = mToTop; |
| 1840 |
hierarchyOp.mReparentTopOnly = mReparentTopOnly; |
| 1841 |
hierarchyOp.mLaunchOptions = mLaunchOptions; |
| 1842 |
hierarchyOp.mActivityIntent = mActivityIntent; |
| 1843 |
hierarchyOp.mPendingIntent = mPendingIntent; |
| 1844 |
hierarchyOp.mAlwaysOnTop = mAlwaysOnTop; |
| 1845 |
hierarchyOp.mTaskFragmentCreationOptions = mTaskFragmentCreationOptions; |
| 1846 |
hierarchyOp.mTaskFragmentOperation = mTaskFragmentOperation; |
| 1847 |
hierarchyOp.mShortcutInfo = mShortcutInfo; |
| 1848 |
hierarchyOp.mReparentLeafTaskIfRelaunch = mReparentLeafTaskIfRelaunch; |
| 1849 |
|
| 1850 |
return hierarchyOp; |
| 1851 |
} |
| 1852 |
} |
| 1853 |
} |
| 1854 |
|
| 1855 |
|
| 1856 |
|
| 1857 |
|
| 1858 |
|
| 1859 |
public static class TaskFragmentAdjacentParams { |
| 1860 |
private static final String DELAY_PRIMARY_LAST_ACTIVITY_REMOVAL = |
| 1861 |
"android:transaction.adjacent.option.delay_primary_removal"; |
| 1862 |
private static final String DELAY_SECONDARY_LAST_ACTIVITY_REMOVAL = |
| 1863 |
"android:transaction.adjacent.option.delay_secondary_removal"; |
| 1864 |
|
| 1865 |
private boolean mDelayPrimaryLastActivityRemoval; |
| 1866 |
private boolean mDelaySecondaryLastActivityRemoval; |
| 1867 |
|
| 1868 |
public TaskFragmentAdjacentParams() { |
| 1869 |
} |
| 1870 |
|
| 1871 |
public TaskFragmentAdjacentParams(@NonNull Bundle bundle) { |
| 1872 |
mDelayPrimaryLastActivityRemoval = bundle.getBoolean( |
| 1873 |
DELAY_PRIMARY_LAST_ACTIVITY_REMOVAL); |
| 1874 |
mDelaySecondaryLastActivityRemoval = bundle.getBoolean( |
| 1875 |
DELAY_SECONDARY_LAST_ACTIVITY_REMOVAL); |
| 1876 |
} |
| 1877 |
|
| 1878 |
|
| 1879 |
public void setShouldDelayPrimaryLastActivityRemoval(boolean delay) { |
| 1880 |
mDelayPrimaryLastActivityRemoval = delay; |
| 1881 |
} |
| 1882 |
|
| 1883 |
|
| 1884 |
public void setShouldDelaySecondaryLastActivityRemoval(boolean delay) { |
| 1885 |
mDelaySecondaryLastActivityRemoval = delay; |
| 1886 |
} |
| 1887 |
|
| 1888 |
|
| 1889 |
|
| 1890 |
|
| 1891 |
|
| 1892 |
|
| 1893 |
|
| 1894 |
|
| 1895 |
|
| 1896 |
public boolean shouldDelayPrimaryLastActivityRemoval() { |
| 1897 |
return mDelayPrimaryLastActivityRemoval; |
| 1898 |
} |
| 1899 |
|
| 1900 |
|
| 1901 |
|
| 1902 |
|
| 1903 |
|
| 1904 |
public boolean shouldDelaySecondaryLastActivityRemoval() { |
| 1905 |
return mDelaySecondaryLastActivityRemoval; |
| 1906 |
} |
| 1907 |
|
| 1908 |
Bundle toBundle() { |
| 1909 |
final Bundle b = new Bundle(); |
| 1910 |
b.putBoolean(DELAY_PRIMARY_LAST_ACTIVITY_REMOVAL, mDelayPrimaryLastActivityRemoval); |
| 1911 |
b.putBoolean(DELAY_SECONDARY_LAST_ACTIVITY_REMOVAL, mDelaySecondaryLastActivityRemoval); |
| 1912 |
return b; |
| 1913 |
} |
| 1914 |
} |
| 1915 |
} |