Merge "Refactor out PackageConfigurationUpdaterImpl" into sc-v2-dev am: c82c4b8dcb
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15828029 Change-Id: Icd50c0b90b84c3c6e20269fd4760c74d1c30af6a
This commit is contained in:
@@ -6554,7 +6554,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PackageConfigurationUpdater createPackageConfigurationUpdater() {
|
public PackageConfigurationUpdater createPackageConfigurationUpdater() {
|
||||||
return new PackageConfigurationUpdaterImpl(Binder.getCallingPid());
|
return new PackageConfigurationUpdaterImpl(Binder.getCallingPid(),
|
||||||
|
ActivityTaskManagerService.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -6571,57 +6572,4 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
null /* trigger */, mRootWindowContainer.getDefaultDisplay());
|
null /* trigger */, mRootWindowContainer.getDefaultDisplay());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class PackageConfigurationUpdaterImpl implements
|
|
||||||
ActivityTaskManagerInternal.PackageConfigurationUpdater {
|
|
||||||
private final int mPid;
|
|
||||||
private Integer mNightMode;
|
|
||||||
private LocaleList mLocales;
|
|
||||||
|
|
||||||
PackageConfigurationUpdaterImpl(int pid) {
|
|
||||||
mPid = pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActivityTaskManagerInternal.PackageConfigurationUpdater setNightMode(int nightMode) {
|
|
||||||
mNightMode = nightMode;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActivityTaskManagerInternal.PackageConfigurationUpdater
|
|
||||||
setLocales(LocaleList locales) {
|
|
||||||
mLocales = locales;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void commit() {
|
|
||||||
synchronized (mGlobalLock) {
|
|
||||||
final long ident = Binder.clearCallingIdentity();
|
|
||||||
try {
|
|
||||||
final WindowProcessController wpc = mProcessMap.getProcess(mPid);
|
|
||||||
if (wpc == null) {
|
|
||||||
Slog.w(TAG, "Override application configuration: cannot find pid " + mPid);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LocaleList localesOverride = LocaleOverlayHelper.combineLocalesIfOverlayExists(
|
|
||||||
mLocales, getGlobalConfiguration().getLocales());
|
|
||||||
wpc.applyAppSpecificConfig(mNightMode, localesOverride);
|
|
||||||
wpc.updateAppSpecificSettingsForAllActivities(mNightMode, localesOverride);
|
|
||||||
mPackageConfigPersister.updateFromImpl(wpc.mName, wpc.mUserId, this);
|
|
||||||
} finally {
|
|
||||||
Binder.restoreCallingIdentity(ident);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer getNightMode() {
|
|
||||||
return mNightMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
LocaleList getLocales() {
|
|
||||||
return mLocales;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ public class PackageConfigPersister {
|
|||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
void updateFromImpl(String packageName, int userId,
|
void updateFromImpl(String packageName, int userId,
|
||||||
ActivityTaskManagerService.PackageConfigurationUpdaterImpl impl) {
|
PackageConfigurationUpdaterImpl impl) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
PackageConfigRecord record = findRecordOrCreate(mModified, packageName, userId);
|
PackageConfigRecord record = findRecordOrCreate(mModified, packageName, userId);
|
||||||
if (impl.getNightMode() != null) {
|
if (impl.getNightMode() != null) {
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.server.wm;
|
||||||
|
|
||||||
|
import android.os.Binder;
|
||||||
|
import android.os.LocaleList;
|
||||||
|
import android.util.Slog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An implementation of {@link ActivityTaskManagerInternal.PackageConfigurationUpdater}.
|
||||||
|
*/
|
||||||
|
final class PackageConfigurationUpdaterImpl implements
|
||||||
|
ActivityTaskManagerInternal.PackageConfigurationUpdater {
|
||||||
|
private static final String TAG = "PackageConfigurationUpdaterImpl";
|
||||||
|
private final int mPid;
|
||||||
|
private Integer mNightMode;
|
||||||
|
private LocaleList mLocales;
|
||||||
|
private ActivityTaskManagerService mAtm;
|
||||||
|
|
||||||
|
PackageConfigurationUpdaterImpl(int pid, ActivityTaskManagerService atm) {
|
||||||
|
mPid = pid;
|
||||||
|
mAtm = atm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityTaskManagerInternal.PackageConfigurationUpdater setNightMode(int nightMode) {
|
||||||
|
synchronized (this) {
|
||||||
|
mNightMode = nightMode;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityTaskManagerInternal.PackageConfigurationUpdater
|
||||||
|
setLocales(LocaleList locales) {
|
||||||
|
synchronized (this) {
|
||||||
|
mLocales = locales;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void commit() {
|
||||||
|
synchronized (this) {
|
||||||
|
synchronized (mAtm.mGlobalLock) {
|
||||||
|
final long ident = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
final WindowProcessController wpc = mAtm.mProcessMap.getProcess(mPid);
|
||||||
|
if (wpc == null) {
|
||||||
|
Slog.w(TAG, "Override application configuration: cannot find pid " + mPid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LocaleList localesOverride = LocaleOverlayHelper.combineLocalesIfOverlayExists(
|
||||||
|
mLocales, mAtm.getGlobalConfiguration().getLocales());
|
||||||
|
wpc.applyAppSpecificConfig(mNightMode, localesOverride);
|
||||||
|
wpc.updateAppSpecificSettingsForAllActivities(mNightMode, localesOverride);
|
||||||
|
mAtm.mPackageConfigPersister.updateFromImpl(wpc.mName, wpc.mUserId, this);
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer getNightMode() {
|
||||||
|
return mNightMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
LocaleList getLocales() {
|
||||||
|
return mLocales;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user