| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.app; |
| 18 |
|
| 19 |
import android.app.ActivityThread.ActivityClientRecord; |
| 20 |
import android.app.servertransaction.PendingTransactionActions; |
| 21 |
import android.compat.annotation.UnsupportedAppUsage; |
| 22 |
import android.content.Intent; |
| 23 |
import android.content.pm.ActivityInfo; |
| 24 |
import android.os.Binder; |
| 25 |
import android.os.Build; |
| 26 |
import android.os.Bundle; |
| 27 |
import android.util.Log; |
| 28 |
import android.view.Window; |
| 29 |
|
| 30 |
import com.android.internal.content.ReferrerIntent; |
| 31 |
|
| 32 |
import java.util.ArrayList; |
| 33 |
import java.util.HashMap; |
| 34 |
import java.util.Map; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
@Deprecated |
| 48 |
public class LocalActivityManager { |
| 49 |
private static final String TAG = "LocalActivityManager"; |
| 50 |
private static final boolean localLOGV = false; |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
private static class LocalActivityRecord extends Binder { |
| 55 |
LocalActivityRecord(String _id, Intent _intent) { |
| 56 |
id = _id; |
| 57 |
intent = _intent; |
| 58 |
} |
| 59 |
|
| 60 |
final String id; |
| 61 |
Intent intent; |
| 62 |
ActivityInfo activityInfo; |
| 63 |
Activity activity; |
| 64 |
Window window; |
| 65 |
Bundle instanceState; |
| 66 |
int curState = RESTORED; |
| 67 |
} |
| 68 |
|
| 69 |
static final int RESTORED = 0; |
| 70 |
static final int INITIALIZING = 1; |
| 71 |
static final int CREATED = 2; |
| 72 |
static final int STARTED = 3; |
| 73 |
static final int RESUMED = 4; |
| 74 |
static final int DESTROYED = 5; |
| 75 |
|
| 76 |
|
| 77 |
private final ActivityThread mActivityThread; |
| 78 |
|
| 79 |
@UnsupportedAppUsage(trackingBug = 137825207, maxTargetSdk = Build.VERSION_CODES.Q, |
| 80 |
publicAlternatives = "Use {@code androidx.fragment.app.Fragment} and " |
| 81 |
+ "{@code androidx.fragment.app.FragmentManager} instead") |
| 82 |
private final Activity mParent; |
| 83 |
|
| 84 |
|
| 85 |
@UnsupportedAppUsage(trackingBug = 137825207, maxTargetSdk = Build.VERSION_CODES.Q, |
| 86 |
publicAlternatives = "Use {@code androidx.fragment.app.Fragment} and " |
| 87 |
+ "{@code androidx.fragment.app.FragmentManager} instead") |
| 88 |
private LocalActivityRecord mResumed; |
| 89 |
|
| 90 |
@UnsupportedAppUsage(trackingBug = 137825207, maxTargetSdk = Build.VERSION_CODES.Q, |
| 91 |
publicAlternatives = "Use {@code androidx.fragment.app.Fragment} and " |
| 92 |
+ "{@code androidx.fragment.app.FragmentManager} instead") |
| 93 |
private final Map<String, LocalActivityRecord> mActivities |
| 94 |
= new HashMap<String, LocalActivityRecord>(); |
| 95 |
|
| 96 |
@UnsupportedAppUsage(trackingBug = 137825207, maxTargetSdk = Build.VERSION_CODES.Q, |
| 97 |
publicAlternatives = "Use {@code androidx.fragment.app.Fragment} and " |
| 98 |
+ "{@code androidx.fragment.app.FragmentManager} instead") |
| 99 |
private final ArrayList<LocalActivityRecord> mActivityArray |
| 100 |
= new ArrayList<LocalActivityRecord>(); |
| 101 |
|
| 102 |
|
| 103 |
@UnsupportedAppUsage(trackingBug = 137825207, maxTargetSdk = Build.VERSION_CODES.Q, |
| 104 |
publicAlternatives = "Use {@code androidx.fragment.app.Fragment} and " |
| 105 |
+ "{@code androidx.fragment.app.FragmentManager} instead") |
| 106 |
private boolean mSingleMode; |
| 107 |
|
| 108 |
|
| 109 |
private boolean mFinishing; |
| 110 |
|
| 111 |
|
| 112 |
private int mCurState = INITIALIZING; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
public LocalActivityManager(Activity parent, boolean singleMode) { |
| 127 |
mActivityThread = ActivityThread.currentActivityThread(); |
| 128 |
mParent = parent; |
| 129 |
mSingleMode = singleMode; |
| 130 |
} |
| 131 |
|
| 132 |
@UnsupportedAppUsage(trackingBug = 137825207, maxTargetSdk = Build.VERSION_CODES.Q, |
| 133 |
publicAlternatives = "Use {@code androidx.fragment.app.Fragment} and " |
| 134 |
+ "{@code androidx.fragment.app.FragmentManager} instead") |
| 135 |
private void moveToState(LocalActivityRecord r, int desiredState) { |
| 136 |
if (r.curState == RESTORED || r.curState == DESTROYED) { |
| 137 |
|
| 138 |
return; |
| 139 |
} |
| 140 |
|
| 141 |
if (r.curState == INITIALIZING) { |
| 142 |
|
| 143 |
HashMap<String, Object> lastNonConfigurationInstances = |
| 144 |
mParent.getLastNonConfigurationChildInstances(); |
| 145 |
Object instanceObj = null; |
| 146 |
if (lastNonConfigurationInstances != null) { |
| 147 |
instanceObj = lastNonConfigurationInstances.get(r.id); |
| 148 |
} |
| 149 |
Activity.NonConfigurationInstances instance = null; |
| 150 |
if (instanceObj != null) { |
| 151 |
instance = new Activity.NonConfigurationInstances(); |
| 152 |
instance.activity = instanceObj; |
| 153 |
} |
| 154 |
|
| 155 |
|
| 156 |
if (localLOGV) Log.v(TAG, r.id + ": starting " + r.intent); |
| 157 |
if (r.activityInfo == null) { |
| 158 |
r.activityInfo = mActivityThread.resolveActivityInfo(r.intent); |
| 159 |
} |
| 160 |
r.activity = mActivityThread.startActivityNow( |
| 161 |
mParent, r.id, r.intent, r.activityInfo, r, r.instanceState, instance, r, r); |
| 162 |
if (r.activity == null) { |
| 163 |
return; |
| 164 |
} |
| 165 |
r.window = r.activity.getWindow(); |
| 166 |
r.instanceState = null; |
| 167 |
|
| 168 |
final ActivityClientRecord clientRecord = mActivityThread.getActivityClient(r); |
| 169 |
final PendingTransactionActions pendingActions; |
| 170 |
|
| 171 |
if (!r.activity.mFinished) { |
| 172 |
|
| 173 |
pendingActions = new PendingTransactionActions(); |
| 174 |
pendingActions.setOldState(clientRecord.state); |
| 175 |
pendingActions.setRestoreInstanceState(true); |
| 176 |
pendingActions.setCallOnPostCreate(true); |
| 177 |
} else { |
| 178 |
pendingActions = null; |
| 179 |
} |
| 180 |
|
| 181 |
mActivityThread.handleStartActivity(clientRecord, pendingActions, |
| 182 |
null ); |
| 183 |
r.curState = STARTED; |
| 184 |
|
| 185 |
if (desiredState == RESUMED) { |
| 186 |
if (localLOGV) Log.v(TAG, r.id + ": resuming"); |
| 187 |
mActivityThread.performResumeActivity(clientRecord, true, |
| 188 |
"moveToState-INITIALIZING"); |
| 189 |
r.curState = RESUMED; |
| 190 |
} |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
return; |
| 199 |
} |
| 200 |
|
| 201 |
final ActivityClientRecord clientRecord = mActivityThread.getActivityClient(r); |
| 202 |
if (clientRecord == null) { |
| 203 |
Log.w(TAG, "Can't get activity record for " + r.id); |
| 204 |
return; |
| 205 |
} |
| 206 |
|
| 207 |
switch (r.curState) { |
| 208 |
case CREATED: |
| 209 |
if (desiredState == STARTED) { |
| 210 |
if (localLOGV) Log.v(TAG, r.id + ": restarting"); |
| 211 |
mActivityThread.performRestartActivity(clientRecord, true ); |
| 212 |
r.curState = STARTED; |
| 213 |
} |
| 214 |
if (desiredState == RESUMED) { |
| 215 |
if (localLOGV) Log.v(TAG, r.id + ": restarting and resuming"); |
| 216 |
mActivityThread.performRestartActivity(clientRecord, true ); |
| 217 |
mActivityThread.performResumeActivity(clientRecord, true, |
| 218 |
"moveToState-CREATED"); |
| 219 |
r.curState = RESUMED; |
| 220 |
} |
| 221 |
return; |
| 222 |
|
| 223 |
case STARTED: |
| 224 |
if (desiredState == RESUMED) { |
| 225 |
|
| 226 |
if (localLOGV) Log.v(TAG, r.id + ": resuming"); |
| 227 |
mActivityThread.performResumeActivity(clientRecord, true, |
| 228 |
"moveToState-STARTED"); |
| 229 |
r.instanceState = null; |
| 230 |
r.curState = RESUMED; |
| 231 |
} |
| 232 |
if (desiredState == CREATED) { |
| 233 |
if (localLOGV) Log.v(TAG, r.id + ": stopping"); |
| 234 |
mActivityThread.performStopActivity(r, false, "moveToState-STARTED"); |
| 235 |
r.curState = CREATED; |
| 236 |
} |
| 237 |
return; |
| 238 |
|
| 239 |
case RESUMED: |
| 240 |
if (desiredState == STARTED) { |
| 241 |
if (localLOGV) Log.v(TAG, r.id + ": pausing"); |
| 242 |
performPause(r, mFinishing); |
| 243 |
r.curState = STARTED; |
| 244 |
} |
| 245 |
if (desiredState == CREATED) { |
| 246 |
if (localLOGV) Log.v(TAG, r.id + ": pausing"); |
| 247 |
performPause(r, mFinishing); |
| 248 |
if (localLOGV) Log.v(TAG, r.id + ": stopping"); |
| 249 |
mActivityThread.performStopActivity(r, false, "moveToState-RESUMED"); |
| 250 |
r.curState = CREATED; |
| 251 |
} |
| 252 |
return; |
| 253 |
} |
| 254 |
} |
| 255 |
|
| 256 |
private void performPause(LocalActivityRecord r, boolean finishing) { |
| 257 |
final boolean needState = r.instanceState == null; |
| 258 |
final Bundle instanceState = mActivityThread.performPauseActivity(r, finishing, |
| 259 |
"performPause", null ); |
| 260 |
if (needState) { |
| 261 |
r.instanceState = instanceState; |
| 262 |
} |
| 263 |
} |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
public Window startActivity(String id, Intent intent) { |
| 311 |
if (mCurState == INITIALIZING) { |
| 312 |
throw new IllegalStateException( |
| 313 |
"Activities can't be added until the containing group has been created."); |
| 314 |
} |
| 315 |
|
| 316 |
boolean adding = false; |
| 317 |
boolean sameIntent = false; |
| 318 |
|
| 319 |
ActivityInfo aInfo = null; |
| 320 |
|
| 321 |
|
| 322 |
LocalActivityRecord r = mActivities.get(id); |
| 323 |
if (r == null) { |
| 324 |
|
| 325 |
r = new LocalActivityRecord(id, intent); |
| 326 |
adding = true; |
| 327 |
} else if (r.intent != null) { |
| 328 |
sameIntent = r.intent.filterEquals(intent); |
| 329 |
if (sameIntent) { |
| 330 |
|
| 331 |
aInfo = r.activityInfo; |
| 332 |
} |
| 333 |
} |
| 334 |
if (aInfo == null) { |
| 335 |
aInfo = mActivityThread.resolveActivityInfo(intent); |
| 336 |
} |
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
if (mSingleMode) { |
| 341 |
LocalActivityRecord old = mResumed; |
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
if (old != null && old != r && mCurState == RESUMED) { |
| 346 |
moveToState(old, STARTED); |
| 347 |
} |
| 348 |
} |
| 349 |
|
| 350 |
if (adding) { |
| 351 |
|
| 352 |
mActivities.put(id, r); |
| 353 |
mActivityArray.add(r); |
| 354 |
} else if (r.activityInfo != null) { |
| 355 |
|
| 356 |
|
| 357 |
if (aInfo == r.activityInfo || |
| 358 |
(aInfo.name.equals(r.activityInfo.name) && |
| 359 |
aInfo.packageName.equals(r.activityInfo.packageName))) { |
| 360 |
if (aInfo.launchMode != ActivityInfo.LAUNCH_MULTIPLE || |
| 361 |
(intent.getFlags()&Intent.FLAG_ACTIVITY_SINGLE_TOP) != 0) { |
| 362 |
|
| 363 |
ArrayList<ReferrerIntent> intents = new ArrayList<>(1); |
| 364 |
intents.add(new ReferrerIntent(intent, mParent.getPackageName())); |
| 365 |
if (localLOGV) Log.v(TAG, r.id + ": new intent"); |
| 366 |
final ActivityClientRecord clientRecord = mActivityThread.getActivityClient(r); |
| 367 |
mActivityThread.handleNewIntent(clientRecord, intents); |
| 368 |
r.intent = intent; |
| 369 |
moveToState(r, mCurState); |
| 370 |
if (mSingleMode) { |
| 371 |
mResumed = r; |
| 372 |
} |
| 373 |
return r.window; |
| 374 |
} |
| 375 |
if (sameIntent && |
| 376 |
(intent.getFlags()&Intent.FLAG_ACTIVITY_CLEAR_TOP) == 0) { |
| 377 |
|
| 378 |
|
| 379 |
r.intent = intent; |
| 380 |
moveToState(r, mCurState); |
| 381 |
if (mSingleMode) { |
| 382 |
mResumed = r; |
| 383 |
} |
| 384 |
return r.window; |
| 385 |
} |
| 386 |
} |
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
performDestroy(r, true); |
| 392 |
} |
| 393 |
|
| 394 |
r.intent = intent; |
| 395 |
r.curState = INITIALIZING; |
| 396 |
r.activityInfo = aInfo; |
| 397 |
|
| 398 |
moveToState(r, mCurState); |
| 399 |
|
| 400 |
|
| 401 |
if (mSingleMode) { |
| 402 |
mResumed = r; |
| 403 |
} |
| 404 |
return r.window; |
| 405 |
} |
| 406 |
|
| 407 |
private Window performDestroy(LocalActivityRecord r, boolean finish) { |
| 408 |
Window win; |
| 409 |
win = r.window; |
| 410 |
if (r.curState == RESUMED && !finish) { |
| 411 |
performPause(r, finish); |
| 412 |
} |
| 413 |
if (localLOGV) Log.v(TAG, r.id + ": destroying"); |
| 414 |
final ActivityClientRecord clientRecord = mActivityThread.getActivityClient(r); |
| 415 |
if (clientRecord != null) { |
| 416 |
mActivityThread.performDestroyActivity(clientRecord, finish, 0 , |
| 417 |
false , "LocalActivityManager::performDestroy"); |
| 418 |
} |
| 419 |
r.activity = null; |
| 420 |
r.window = null; |
| 421 |
if (finish) { |
| 422 |
r.instanceState = null; |
| 423 |
} |
| 424 |
r.curState = DESTROYED; |
| 425 |
return win; |
| 426 |
} |
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
public Window destroyActivity(String id, boolean finish) { |
| 441 |
LocalActivityRecord r = mActivities.get(id); |
| 442 |
Window win = null; |
| 443 |
if (r != null) { |
| 444 |
win = performDestroy(r, finish); |
| 445 |
if (finish) { |
| 446 |
mActivities.remove(id); |
| 447 |
mActivityArray.remove(r); |
| 448 |
} |
| 449 |
} |
| 450 |
return win; |
| 451 |
} |
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
public Activity getCurrentActivity() { |
| 463 |
return mResumed != null ? mResumed.activity : null; |
| 464 |
} |
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
public String getCurrentId() { |
| 476 |
return mResumed != null ? mResumed.id : null; |
| 477 |
} |
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
public Activity getActivity(String id) { |
| 488 |
LocalActivityRecord r = mActivities.get(id); |
| 489 |
return r != null ? r.activity : null; |
| 490 |
} |
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
public void dispatchCreate(Bundle state) { |
| 507 |
if (state != null) { |
| 508 |
for (String id : state.keySet()) { |
| 509 |
try { |
| 510 |
final Bundle astate = state.getBundle(id); |
| 511 |
LocalActivityRecord r = mActivities.get(id); |
| 512 |
if (r != null) { |
| 513 |
r.instanceState = astate; |
| 514 |
} else { |
| 515 |
r = new LocalActivityRecord(id, null); |
| 516 |
r.instanceState = astate; |
| 517 |
mActivities.put(id, r); |
| 518 |
mActivityArray.add(r); |
| 519 |
} |
| 520 |
} catch (Exception e) { |
| 521 |
|
| 522 |
Log.e(TAG, "Exception thrown when restoring LocalActivityManager state", e); |
| 523 |
} |
| 524 |
} |
| 525 |
} |
| 526 |
|
| 527 |
mCurState = CREATED; |
| 528 |
} |
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
public Bundle saveInstanceState() { |
| 541 |
Bundle state = null; |
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
final int N = mActivityArray.size(); |
| 546 |
for (int i=0; i<N; i++) { |
| 547 |
final LocalActivityRecord r = mActivityArray.get(i); |
| 548 |
if (state == null) { |
| 549 |
state = new Bundle(); |
| 550 |
} |
| 551 |
if ((r.instanceState != null || r.curState == RESUMED) |
| 552 |
&& r.activity != null) { |
| 553 |
|
| 554 |
|
| 555 |
final Bundle childState = new Bundle(); |
| 556 |
r.activity.performSaveInstanceState(childState); |
| 557 |
r.instanceState = childState; |
| 558 |
} |
| 559 |
if (r.instanceState != null) { |
| 560 |
state.putBundle(r.id, r.instanceState); |
| 561 |
} |
| 562 |
} |
| 563 |
|
| 564 |
return state; |
| 565 |
} |
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
public void dispatchResume() { |
| 575 |
mCurState = RESUMED; |
| 576 |
if (mSingleMode) { |
| 577 |
if (mResumed != null) { |
| 578 |
moveToState(mResumed, RESUMED); |
| 579 |
} |
| 580 |
} else { |
| 581 |
final int N = mActivityArray.size(); |
| 582 |
for (int i=0; i<N; i++) { |
| 583 |
moveToState(mActivityArray.get(i), RESUMED); |
| 584 |
} |
| 585 |
} |
| 586 |
} |
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
public void dispatchPause(boolean finishing) { |
| 601 |
if (finishing) { |
| 602 |
mFinishing = true; |
| 603 |
} |
| 604 |
mCurState = STARTED; |
| 605 |
if (mSingleMode) { |
| 606 |
if (mResumed != null) { |
| 607 |
moveToState(mResumed, STARTED); |
| 608 |
} |
| 609 |
} else { |
| 610 |
final int N = mActivityArray.size(); |
| 611 |
for (int i=0; i<N; i++) { |
| 612 |
LocalActivityRecord r = mActivityArray.get(i); |
| 613 |
if (r.curState == RESUMED) { |
| 614 |
moveToState(r, STARTED); |
| 615 |
} |
| 616 |
} |
| 617 |
} |
| 618 |
} |
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
public void dispatchStop() { |
| 628 |
mCurState = CREATED; |
| 629 |
final int N = mActivityArray.size(); |
| 630 |
for (int i=0; i<N; i++) { |
| 631 |
LocalActivityRecord r = mActivityArray.get(i); |
| 632 |
moveToState(r, CREATED); |
| 633 |
} |
| 634 |
} |
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
public HashMap<String,Object> dispatchRetainNonConfigurationInstance() { |
| 644 |
HashMap<String,Object> instanceMap = null; |
| 645 |
|
| 646 |
final int N = mActivityArray.size(); |
| 647 |
for (int i=0; i<N; i++) { |
| 648 |
LocalActivityRecord r = mActivityArray.get(i); |
| 649 |
if ((r != null) && (r.activity != null)) { |
| 650 |
Object instance = r.activity.onRetainNonConfigurationInstance(); |
| 651 |
if (instance != null) { |
| 652 |
if (instanceMap == null) { |
| 653 |
instanceMap = new HashMap<String,Object>(); |
| 654 |
} |
| 655 |
instanceMap.put(r.id, instance); |
| 656 |
} |
| 657 |
} |
| 658 |
} |
| 659 |
return instanceMap; |
| 660 |
} |
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
public void removeAllActivities() { |
| 667 |
dispatchDestroy(true); |
| 668 |
} |
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
public void dispatchDestroy(boolean finishing) { |
| 678 |
final int N = mActivityArray.size(); |
| 679 |
for (int i=0; i<N; i++) { |
| 680 |
LocalActivityRecord r = mActivityArray.get(i); |
| 681 |
if (localLOGV) Log.v(TAG, r.id + ": destroying"); |
| 682 |
final ActivityClientRecord clientRecord = mActivityThread.getActivityClient(r); |
| 683 |
if (clientRecord == null) { |
| 684 |
if (localLOGV) Log.v(TAG, r.id + ": no corresponding record"); |
| 685 |
continue; |
| 686 |
} |
| 687 |
mActivityThread.performDestroyActivity(clientRecord, finishing, 0 , |
| 688 |
false , "LocalActivityManager::dispatchDestroy"); |
| 689 |
} |
| 690 |
mActivities.clear(); |
| 691 |
mActivityArray.clear(); |
| 692 |
} |
| 693 |
} |