Merge "Do not relaunch bg activities when application info changes" into sc-dev
This commit is contained in:
@@ -5613,7 +5613,7 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
}
|
||||
|
||||
/** Performs the activity relaunch locally vs. requesting from system-server. */
|
||||
private void handleRelaunchActivityLocally(IBinder token) {
|
||||
public void handleRelaunchActivityLocally(IBinder token) {
|
||||
final ActivityClientRecord r = mActivities.get(token);
|
||||
if (r == null) {
|
||||
Log.w(TAG, "Activity to relaunch no longer exists");
|
||||
@@ -5977,20 +5977,6 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
// Update all affected Resources objects to use new ResourcesImpl
|
||||
mResourcesManager.applyNewResourceDirsLocked(ai, oldResDirs);
|
||||
}
|
||||
|
||||
ApplicationPackageManager.configurationChanged();
|
||||
|
||||
// Trigger a regular Configuration change event, only with a different assetsSeq number
|
||||
// so that we actually call through to all components.
|
||||
// TODO(adamlesinski): Change this to make use of ActivityManager's upcoming ability to
|
||||
// store configurations per-process.
|
||||
final Configuration config = mConfigurationController.getConfiguration();
|
||||
Configuration newConfig = new Configuration();
|
||||
newConfig.assetsSeq = (config != null ? config.assetsSeq : 0) + 1;
|
||||
mConfigurationController.handleConfigurationChanged(newConfig, null /* compat */);
|
||||
|
||||
// Preserve windows to avoid black flickers when overlays change.
|
||||
relaunchAllActivities(true /* preserveWindows */, "handleApplicationInfoChanged");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -184,15 +184,6 @@ public class ActivityThreadTest {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleActivity_assetsChanged() {
|
||||
relaunchActivityAndAssertPreserveWindow(activity -> {
|
||||
// Relaunches all activities.
|
||||
activity.getActivityThread().handleApplicationInfoChanged(
|
||||
activity.getApplicationInfo());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecreateActivity() {
|
||||
relaunchActivityAndAssertPreserveWindow(Activity::recreate);
|
||||
|
||||
@@ -135,6 +135,7 @@ import com.android.server.pm.dex.DexManager;
|
||||
import com.android.server.pm.parsing.pkg.AndroidPackage;
|
||||
import com.android.server.wm.ActivityServiceConnectionsHolder;
|
||||
import com.android.server.wm.WindowManagerService;
|
||||
import com.android.server.wm.WindowProcessController;
|
||||
|
||||
import dalvik.system.VMRuntime;
|
||||
|
||||
@@ -4626,6 +4627,7 @@ public final class ProcessList {
|
||||
@GuardedBy(anyOf = {"mService", "mProcLock"})
|
||||
void updateApplicationInfoLOSP(List<String> packagesToUpdate, int userId,
|
||||
boolean updateFrameworkRes) {
|
||||
final ArrayList<WindowProcessController> targetProcesses = new ArrayList<>();
|
||||
for (int i = mLruProcesses.size() - 1; i >= 0; i--) {
|
||||
final ProcessRecord app = mLruProcesses.get(i);
|
||||
if (app.getThread() == null) {
|
||||
@@ -4646,6 +4648,7 @@ public final class ProcessList {
|
||||
if (ai.packageName.equals(app.info.packageName)) {
|
||||
app.info = ai;
|
||||
}
|
||||
targetProcesses.add(app.getWindowProcessController());
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG, String.format("Failed to update %s ApplicationInfo for %s",
|
||||
@@ -4654,6 +4657,9 @@ public final class ProcessList {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mService.mActivityTaskManager.updateAssetConfiguration(
|
||||
updateFrameworkRes ? null : targetProcesses);
|
||||
}
|
||||
|
||||
@GuardedBy("mService")
|
||||
|
||||
@@ -91,6 +91,7 @@ import static android.content.pm.ActivityInfo.SIZE_CHANGES_UNSUPPORTED_OVERRIDE;
|
||||
import static android.content.pm.ActivityInfo.isFixedOrientationLandscape;
|
||||
import static android.content.pm.ActivityInfo.isFixedOrientationPortrait;
|
||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
import static android.content.res.Configuration.ASSETS_SEQ_UNDEFINED;
|
||||
import static android.content.res.Configuration.EMPTY;
|
||||
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
|
||||
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
|
||||
@@ -6858,6 +6859,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
|
||||
@Override
|
||||
void resolveOverrideConfiguration(Configuration newParentConfiguration) {
|
||||
final Configuration requestedOverrideConfig = getRequestedOverrideConfiguration();
|
||||
if (requestedOverrideConfig.assetsSeq != ASSETS_SEQ_UNDEFINED
|
||||
&& newParentConfiguration.assetsSeq > requestedOverrideConfig.assetsSeq) {
|
||||
requestedOverrideConfig.assetsSeq = ASSETS_SEQ_UNDEFINED;
|
||||
}
|
||||
super.resolveOverrideConfiguration(newParentConfiguration);
|
||||
final Configuration resolvedConfig = getResolvedOverrideConfiguration();
|
||||
if (isFixedRotationTransforming()) {
|
||||
|
||||
@@ -472,6 +472,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
||||
|
||||
/** Current sequencing integer of the configuration, for skipping old configurations. */
|
||||
private int mConfigurationSeq;
|
||||
|
||||
/** Current sequencing integer of the asset changes, for skipping old resources overlays. */
|
||||
private int mGlobalAssetsSeq;
|
||||
|
||||
// To cache the list of supported system locales
|
||||
private String[] mSupportedSystemLocales = null;
|
||||
|
||||
@@ -4129,6 +4133,35 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
||||
return changes;
|
||||
}
|
||||
|
||||
private int increaseAssetConfigurationSeq() {
|
||||
mGlobalAssetsSeq = Math.max(++mGlobalAssetsSeq, 1);
|
||||
return mGlobalAssetsSeq;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the asset configuration and increase the assets sequence number.
|
||||
* @param processes the processes that needs to update the asset configuration, if none
|
||||
* updates the global configuration for all processes.
|
||||
*/
|
||||
public void updateAssetConfiguration(List<WindowProcessController> processes) {
|
||||
synchronized (mGlobalLock) {
|
||||
final int assetSeq = increaseAssetConfigurationSeq();
|
||||
|
||||
// Update the global configuration if the no target processes
|
||||
if (processes == null) {
|
||||
Configuration newConfig = new Configuration();
|
||||
newConfig.assetsSeq = assetSeq;
|
||||
updateConfiguration(newConfig);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = processes.size() - 1; i >= 0; i--) {
|
||||
final WindowProcessController wpc = processes.get(i);
|
||||
wpc.updateAssetConfiguration(assetSeq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void startLaunchPowerMode(@PowerModeReason int reason) {
|
||||
if (mPowerManagerInternal == null) return;
|
||||
mPowerManagerInternal.setPowerMode(Mode.LAUNCH, true);
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.server.wm;
|
||||
|
||||
import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT;
|
||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
|
||||
import static android.content.res.Configuration.ASSETS_SEQ_UNDEFINED;
|
||||
import static android.os.Build.VERSION_CODES.Q;
|
||||
import static android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS;
|
||||
|
||||
@@ -1318,6 +1319,11 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
|
||||
|
||||
@Override
|
||||
void resolveOverrideConfiguration(Configuration newParentConfig) {
|
||||
final Configuration requestedOverrideConfig = getRequestedOverrideConfiguration();
|
||||
if (requestedOverrideConfig.assetsSeq != ASSETS_SEQ_UNDEFINED
|
||||
&& newParentConfig.assetsSeq > requestedOverrideConfig.assetsSeq) {
|
||||
requestedOverrideConfig.assetsSeq = ASSETS_SEQ_UNDEFINED;
|
||||
}
|
||||
super.resolveOverrideConfiguration(newParentConfig);
|
||||
final Configuration resolvedConfig = getResolvedOverrideConfiguration();
|
||||
// Make sure that we don't accidentally override the activity type.
|
||||
@@ -1396,6 +1402,28 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
|
||||
return mHasPendingConfigurationChange;
|
||||
}
|
||||
|
||||
void updateAssetConfiguration(int assetSeq) {
|
||||
// Update the process override configuration directly if the process configuration will
|
||||
// not be override from its activities.
|
||||
if (!mHasActivities || !mIsActivityConfigOverrideAllowed) {
|
||||
Configuration overrideConfig = new Configuration(getRequestedOverrideConfiguration());
|
||||
overrideConfig.assetsSeq = assetSeq;
|
||||
onRequestedOverrideConfigurationChanged(overrideConfig);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, we can just update the activity override configuration.
|
||||
for (int i = mActivities.size() - 1; i >= 0; i--) {
|
||||
ActivityRecord r = mActivities.get(i);
|
||||
Configuration overrideConfig = new Configuration(r.getRequestedOverrideConfiguration());
|
||||
overrideConfig.assetsSeq = assetSeq;
|
||||
r.onRequestedOverrideConfigurationChanged(overrideConfig);
|
||||
if (r.mVisibleRequested) {
|
||||
r.ensureActivityConfiguration(0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called for sending {@link android.app.servertransaction.LaunchActivityItem}.
|
||||
* The caller must call {@link #setLastReportedConfiguration} if the delivered configuration
|
||||
|
||||
Reference in New Issue
Block a user