summaryrefslogtreecommitdiffstats
path: root/quickstep/src
diff options
context:
space:
mode:
authorRiddle Hsu <riddlehsu@google.com>2019-06-27 00:37:38 -0600
committerRiddle Hsu <riddlehsu@google.com>2019-07-01 13:29:34 +0800
commit70697e48a8e0c16a9d7c4231767a213cbaa9df47 (patch)
tree726a3b9bfb4894696ca181db3ecab5c48882f2ed /quickstep/src
parentbd0003da9931fba40216172941d265df6ea83f3f (diff)
downloadandroid_packages_apps_Trebuchet-70697e48a8e0c16a9d7c4231767a213cbaa9df47.tar.gz
android_packages_apps_Trebuchet-70697e48a8e0c16a9d7c4231767a213cbaa9df47.tar.bz2
android_packages_apps_Trebuchet-70697e48a8e0c16a9d7c4231767a213cbaa9df47.zip
Preload overview activity in background
To reduce the jank when swiping-up the overview which is not ready yet, we restart the overview activity if the process was died and update its configuration if there is change. Bug: 127350205 Test: manual - Enable 2-button or gesture navigation. Swipe-up overview after: Case 1: Other app is in foreground and kill the process of launcher. Case 2: Change configuration, e.g. font size, language. Change-Id: Ia6e365cc0faf3765781484d040bdddd4e10a2650
Diffstat (limited to 'quickstep/src')
-rw-r--r--quickstep/src/com/android/quickstep/OverviewComponentObserver.java91
1 files changed, 63 insertions, 28 deletions
diff --git a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java
index 0738affa9..4a2ed3a3d 100644
--- a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java
+++ b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java
@@ -29,11 +29,15 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.util.SparseIntArray;
import com.android.systemui.shared.system.PackageManagerWrapper;
import java.util.ArrayList;
+import java.util.Objects;
/**
* Class to keep track of the current overview component based off user preferences and app updates
@@ -53,22 +57,41 @@ public final class OverviewComponentObserver {
}
};
private final Context mContext;
- private final ComponentName mMyHomeComponent;
+ private final Intent mCurrentHomeIntent;
+ private final Intent mMyHomeIntent;
+ private final Intent mFallbackIntent;
+ private final SparseIntArray mConfigChangesMap = new SparseIntArray();
private String mUpdateRegisteredPackage;
private ActivityControlHelper mActivityControlHelper;
private Intent mOverviewIntent;
- private Intent mHomeIntent;
private int mSystemUiStateFlags;
private boolean mIsHomeAndOverviewSame;
+ private boolean mIsDefaultHome;
public OverviewComponentObserver(Context context) {
mContext = context;
- Intent myHomeIntent = new Intent(Intent.ACTION_MAIN)
+ mCurrentHomeIntent = new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_HOME)
- .setPackage(mContext.getPackageName());
- ResolveInfo info = context.getPackageManager().resolveActivity(myHomeIntent, 0);
- mMyHomeComponent = new ComponentName(context.getPackageName(), info.activityInfo.name);
+ .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mMyHomeIntent = new Intent(mCurrentHomeIntent).setPackage(mContext.getPackageName());
+ ResolveInfo info = context.getPackageManager().resolveActivity(mMyHomeIntent, 0);
+ ComponentName myHomeComponent =
+ new ComponentName(context.getPackageName(), info.activityInfo.name);
+ mMyHomeIntent.setComponent(myHomeComponent);
+ mConfigChangesMap.append(myHomeComponent.hashCode(), info.activityInfo.configChanges);
+
+ ComponentName fallbackComponent = new ComponentName(mContext, RecentsActivity.class);
+ mFallbackIntent = new Intent(Intent.ACTION_MAIN)
+ .addCategory(Intent.CATEGORY_DEFAULT)
+ .setComponent(fallbackComponent)
+ .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ try {
+ ActivityInfo fallbackInfo = context.getPackageManager().getActivityInfo(
+ mFallbackIntent.getComponent(), 0 /* flags */);
+ mConfigChangesMap.append(fallbackComponent.hashCode(), fallbackInfo.configChanges);
+ } catch (PackageManager.NameNotFoundException ignored) { /* Impossible */ }
mContext.registerReceiver(mUserPreferenceChangeReceiver,
new IntentFilter(ACTION_PREFERRED_ACTIVITY_CHANGED));
@@ -92,17 +115,14 @@ public final class OverviewComponentObserver {
ComponentName defaultHome = PackageManagerWrapper.getInstance()
.getHomeActivities(new ArrayList<>());
- final String overviewIntentCategory;
- ComponentName overviewComponent;
- mHomeIntent = null;
-
- if ((mSystemUiStateFlags & SYSUI_STATE_HOME_DISABLED) == 0 &&
- (defaultHome == null || mMyHomeComponent.equals(defaultHome))) {
+ mIsDefaultHome = Objects.equals(mMyHomeIntent.getComponent(), defaultHome);
+ if ((mSystemUiStateFlags & SYSUI_STATE_HOME_DISABLED) == 0
+ && (defaultHome == null || mIsDefaultHome)) {
// User default home is same as out home app. Use Overview integrated in Launcher.
- overviewComponent = mMyHomeComponent;
mActivityControlHelper = new LauncherActivityControllerHelper();
mIsHomeAndOverviewSame = true;
- overviewIntentCategory = Intent.CATEGORY_HOME;
+ mOverviewIntent = mMyHomeIntent;
+ mCurrentHomeIntent.setComponent(mMyHomeIntent.getComponent());
if (mUpdateRegisteredPackage != null) {
// Remove any update listener as we don't care about other packages.
@@ -111,14 +131,11 @@ public final class OverviewComponentObserver {
}
} else {
// The default home app is a different launcher. Use the fallback Overview instead.
- overviewComponent = new ComponentName(mContext, RecentsActivity.class);
mActivityControlHelper = new FallbackActivityControllerHelper();
mIsHomeAndOverviewSame = false;
- overviewIntentCategory = Intent.CATEGORY_DEFAULT;
+ mOverviewIntent = mFallbackIntent;
+ mCurrentHomeIntent.setComponent(defaultHome);
- mHomeIntent = new Intent(Intent.ACTION_MAIN)
- .addCategory(Intent.CATEGORY_HOME)
- .setComponent(defaultHome);
// User's default home app can change as a result of package updates of this app (such
// as uninstalling the app or removing the "Launcher" feature in an update).
// Listen for package updates of this app (and remove any previously attached
@@ -138,14 +155,6 @@ public final class OverviewComponentObserver {
ACTION_PACKAGE_REMOVED));
}
}
-
- mOverviewIntent = new Intent(Intent.ACTION_MAIN)
- .addCategory(overviewIntentCategory)
- .setComponent(overviewComponent)
- .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- if (mHomeIntent == null) {
- mHomeIntent = mOverviewIntent;
- }
}
/**
@@ -161,6 +170,32 @@ public final class OverviewComponentObserver {
}
/**
+ * @return {@code true} if the overview component is able to handle the configuration changes.
+ */
+ boolean canHandleConfigChanges(ComponentName component, int changes) {
+ final int orientationChange =
+ ActivityInfo.CONFIG_ORIENTATION | ActivityInfo.CONFIG_SCREEN_SIZE;
+ if ((changes & orientationChange) == orientationChange) {
+ // This is just an approximate guess for simple orientation change because the changes
+ // may contain non-public bits (e.g. window configuration).
+ return true;
+ }
+
+ int configMask = mConfigChangesMap.get(component.hashCode());
+ return configMask != 0 && (~configMask & changes) == 0;
+ }
+
+ /**
+ * Get the intent for overview activity. It is used when lockscreen is shown and home was died
+ * in background, we still want to restart the one that will be used after unlock.
+ *
+ * @return the overview intent
+ */
+ Intent getOverviewIntentIgnoreSysUiState() {
+ return mIsDefaultHome ? mMyHomeIntent : mOverviewIntent;
+ }
+
+ /**
* Get the current intent for going to the overview activity.
*
* @return the overview intent
@@ -173,7 +208,7 @@ public final class OverviewComponentObserver {
* Get the current intent for going to the home activity.
*/
public Intent getHomeIntent() {
- return mHomeIntent;
+ return mCurrentHomeIntent;
}
/**