Merge branch 'android15-release' into merge-aosp15
This commit is contained in:
@@ -29,7 +29,6 @@ import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.window.OnBackInvokedDispatcher;
|
||||
|
||||
import androidx.activity.ComponentActivity;
|
||||
@@ -39,6 +38,7 @@ import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
import com.android.launcher3.util.RunnableList;
|
||||
import com.android.launcher3.util.SystemUiController;
|
||||
import com.android.launcher3.util.ViewCache;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
@@ -154,6 +154,18 @@ public abstract class BaseActivity extends ComponentActivity implements Activity
|
||||
|
||||
private final ViewCache mViewCache = new ViewCache();
|
||||
|
||||
@Retention(SOURCE)
|
||||
@IntDef({EVENT_STARTED, EVENT_RESUMED, EVENT_STOPPED, EVENT_DESTROYED})
|
||||
public @interface ActivityEvent { }
|
||||
public static final int EVENT_STARTED = 0;
|
||||
public static final int EVENT_RESUMED = 1;
|
||||
public static final int EVENT_STOPPED = 2;
|
||||
public static final int EVENT_DESTROYED = 3;
|
||||
|
||||
// Callback array that corresponds to events defined in @ActivityEvent
|
||||
private final RunnableList[] mEventCallbacks =
|
||||
{new RunnableList(), new RunnableList(), new RunnableList(), new RunnableList()};
|
||||
|
||||
@Override
|
||||
public ViewCache getViewCache() {
|
||||
return mViewCache;
|
||||
@@ -206,12 +218,14 @@ public abstract class BaseActivity extends ComponentActivity implements Activity
|
||||
protected void onStart() {
|
||||
addActivityFlags(ACTIVITY_STATE_STARTED);
|
||||
super.onStart();
|
||||
mEventCallbacks[EVENT_STARTED].executeAllAndClear();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
setResumed();
|
||||
super.onResume();
|
||||
mEventCallbacks[EVENT_RESUMED].executeAllAndClear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -233,12 +247,20 @@ public abstract class BaseActivity extends ComponentActivity implements Activity
|
||||
removeActivityFlags(ACTIVITY_STATE_STARTED | ACTIVITY_STATE_USER_ACTIVE);
|
||||
mForceInvisible = 0;
|
||||
super.onStop();
|
||||
mEventCallbacks[EVENT_STOPPED].executeAllAndClear();
|
||||
|
||||
|
||||
// Reset the overridden sysui flags used for the task-swipe launch animation, this is a
|
||||
// catch all for if we do not get resumed (and therefore not paused below)
|
||||
getSystemUiController().updateUiState(UI_STATE_FULLSCREEN_TASK, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mEventCallbacks[EVENT_DESTROYED].executeAllAndClear();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
setPaused();
|
||||
@@ -259,7 +281,6 @@ public abstract class BaseActivity extends ComponentActivity implements Activity
|
||||
} else {
|
||||
removeActivityFlags(ACTIVITY_STATE_WINDOW_FOCUSED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void registerBackDispatcher() {
|
||||
@@ -365,9 +386,15 @@ public abstract class BaseActivity extends ComponentActivity implements Activity
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to clear accessibility focus on {@param view}.
|
||||
* Adds a callback for the provided activity event
|
||||
*/
|
||||
public void tryClearAccessibilityFocus(View view) {
|
||||
public void addEventCallback(@ActivityEvent int event, Runnable callback) {
|
||||
mEventCallbacks[event].add(callback);
|
||||
}
|
||||
|
||||
/** Removes a previously added callback */
|
||||
public void removeEventCallback(@ActivityEvent int event, Runnable callback) {
|
||||
mEventCallbacks[event].remove(callback);
|
||||
}
|
||||
|
||||
public interface MultiWindowModeChangedListener {
|
||||
@@ -386,6 +413,8 @@ public abstract class BaseActivity extends ComponentActivity implements Activity
|
||||
public static <T extends BaseActivity> T fromContext(Context context) {
|
||||
if (context instanceof BaseActivity) {
|
||||
return (T) context;
|
||||
} else if (context instanceof ActivityContextDelegate) {
|
||||
return (T) ((ActivityContextDelegate) context).mDelegate;
|
||||
} else if (context instanceof ContextWrapper) {
|
||||
return fromContext(((ContextWrapper) context).getBaseContext());
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user