| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.base; | 5 package org.chromium.base; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.app.Activity; | 8 import android.app.Activity; |
| 9 import android.app.Application; | 9 import android.app.Application; |
| 10 import android.app.Application.ActivityLifecycleCallbacks; | 10 import android.app.Application.ActivityLifecycleCallbacks; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 public ObserverList<ActivityStateListener> getListeners() { | 54 public ObserverList<ActivityStateListener> getListeners() { |
| 55 return mListeners; | 55 return mListeners; |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 private static Object sCachedApplicationStateLock = new Object(); | 59 private static Object sCachedApplicationStateLock = new Object(); |
| 60 @ApplicationState | 60 @ApplicationState |
| 61 private static Integer sCachedApplicationState; | 61 private static Integer sCachedApplicationState; |
| 62 | 62 |
| 63 /** Last activity that was shown (or null if none or it was destroyed). */ | 63 /** Last activity that was shown (or null if none or it was destroyed). */ |
| 64 @SuppressLint("StaticFieldLeak") |
| 64 private static Activity sActivity; | 65 private static Activity sActivity; |
| 65 | 66 |
| 66 /** A lazily initialized listener that forwards application state changes to
native. */ | 67 /** A lazily initialized listener that forwards application state changes to
native. */ |
| 67 private static ApplicationStateListener sNativeApplicationStateListener; | 68 private static ApplicationStateListener sNativeApplicationStateListener; |
| 68 | 69 |
| 69 /** | 70 /** |
| 70 * A map of which observers listen to state changes from which {@link Activi
ty}. | 71 * A map of which observers listen to state changes from which {@link Activi
ty}. |
| 71 */ | 72 */ |
| 72 private static final Map<Activity, ActivityInfo> sActivityInfo = | 73 private static final Map<Activity, ActivityInfo> sActivityInfo = |
| 73 new ConcurrentHashMap<Activity, ActivityInfo>(); | 74 new ConcurrentHashMap<Activity, ActivityInfo>(); |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 473 |
| 473 if (hasPausedActivity) return ApplicationState.HAS_PAUSED_ACTIVITIES; | 474 if (hasPausedActivity) return ApplicationState.HAS_PAUSED_ACTIVITIES; |
| 474 if (hasStoppedActivity) return ApplicationState.HAS_STOPPED_ACTIVITIES; | 475 if (hasStoppedActivity) return ApplicationState.HAS_STOPPED_ACTIVITIES; |
| 475 return ApplicationState.HAS_DESTROYED_ACTIVITIES; | 476 return ApplicationState.HAS_DESTROYED_ACTIVITIES; |
| 476 } | 477 } |
| 477 | 478 |
| 478 // Called to notify the native side of state changes. | 479 // Called to notify the native side of state changes. |
| 479 // IMPORTANT: This is always called on the main thread! | 480 // IMPORTANT: This is always called on the main thread! |
| 480 private static native void nativeOnApplicationStateChange(@ApplicationState
int newState); | 481 private static native void nativeOnApplicationStateChange(@ApplicationState
int newState); |
| 481 } | 482 } |
| OLD | NEW |