Merge "Enabling ActivityTaskManagerService to retrieve PackageConfigUpdater for arbitrary packages." into sc-v2-dev
This commit is contained in:
@@ -596,10 +596,17 @@ public abstract class ActivityTaskManagerInternal {
|
|||||||
public abstract boolean isBaseOfLockedTask(String packageName);
|
public abstract boolean isBaseOfLockedTask(String packageName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an interface to update configuration for an application.
|
* Creates an interface to update configuration for the calling application.
|
||||||
*/
|
*/
|
||||||
public abstract PackageConfigurationUpdater createPackageConfigurationUpdater();
|
public abstract PackageConfigurationUpdater createPackageConfigurationUpdater();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an interface to update configuration for an arbitrary application specified by it's
|
||||||
|
* packageName and userId.
|
||||||
|
*/
|
||||||
|
public abstract PackageConfigurationUpdater createPackageConfigurationUpdater(
|
||||||
|
String packageName, int userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface to update configuration for an application, and will persist override
|
* An interface to update configuration for an application, and will persist override
|
||||||
* configuration for this package.
|
* configuration for this package.
|
||||||
|
|||||||
@@ -6556,6 +6556,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
ActivityTaskManagerService.this);
|
ActivityTaskManagerService.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PackageConfigurationUpdater createPackageConfigurationUpdater(
|
||||||
|
String packageName , int userId) {
|
||||||
|
return new PackageConfigurationUpdaterImpl(packageName, userId,
|
||||||
|
ActivityTaskManagerService.this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSystemAlertWindowPermission(int callingUid, int callingPid,
|
public boolean hasSystemAlertWindowPermission(int callingUid, int callingPid,
|
||||||
String callingPackage) {
|
String callingPackage) {
|
||||||
|
|||||||
@@ -16,26 +16,40 @@
|
|||||||
|
|
||||||
package com.android.server.wm;
|
package com.android.server.wm;
|
||||||
|
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.LocaleList;
|
import android.os.LocaleList;
|
||||||
|
import android.util.ArraySet;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of {@link ActivityTaskManagerInternal.PackageConfigurationUpdater}.
|
* An implementation of {@link ActivityTaskManagerInternal.PackageConfigurationUpdater}.
|
||||||
*/
|
*/
|
||||||
final class PackageConfigurationUpdaterImpl implements
|
final class PackageConfigurationUpdaterImpl implements
|
||||||
ActivityTaskManagerInternal.PackageConfigurationUpdater {
|
ActivityTaskManagerInternal.PackageConfigurationUpdater {
|
||||||
private static final String TAG = "PackageConfigurationUpdaterImpl";
|
private static final String TAG = "PackageConfigurationUpdaterImpl";
|
||||||
private final int mPid;
|
private final Optional<Integer> mPid;
|
||||||
private Integer mNightMode;
|
private Integer mNightMode;
|
||||||
private LocaleList mLocales;
|
private LocaleList mLocales;
|
||||||
|
private String mPackageName;
|
||||||
|
private int mUserId;
|
||||||
private ActivityTaskManagerService mAtm;
|
private ActivityTaskManagerService mAtm;
|
||||||
|
|
||||||
PackageConfigurationUpdaterImpl(int pid, ActivityTaskManagerService atm) {
|
PackageConfigurationUpdaterImpl(int pid, ActivityTaskManagerService atm) {
|
||||||
mPid = pid;
|
mPid = Optional.of(pid);
|
||||||
mAtm = atm;
|
mAtm = atm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PackageConfigurationUpdaterImpl(String packageName, int userId,
|
||||||
|
ActivityTaskManagerService atm) {
|
||||||
|
mPackageName = packageName;
|
||||||
|
mUserId = userId;
|
||||||
|
mAtm = atm;
|
||||||
|
mPid = Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActivityTaskManagerInternal.PackageConfigurationUpdater setNightMode(int nightMode) {
|
public ActivityTaskManagerInternal.PackageConfigurationUpdater setNightMode(int nightMode) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
@@ -59,16 +73,29 @@ final class PackageConfigurationUpdaterImpl implements
|
|||||||
synchronized (mAtm.mGlobalLock) {
|
synchronized (mAtm.mGlobalLock) {
|
||||||
final long ident = Binder.clearCallingIdentity();
|
final long ident = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
final WindowProcessController wpc = mAtm.mProcessMap.getProcess(mPid);
|
final int uid;
|
||||||
|
if (mPid.isPresent()) {
|
||||||
|
WindowProcessController wpc = mAtm.mProcessMap.getProcess(mPid.get());
|
||||||
if (wpc == null) {
|
if (wpc == null) {
|
||||||
Slog.w(TAG, "Override application configuration: cannot find pid " + mPid);
|
Slog.w(TAG, "commit: Override application configuration failed: "
|
||||||
|
+ "cannot find pid " + mPid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LocaleList localesOverride = LocaleOverlayHelper.combineLocalesIfOverlayExists(
|
uid = wpc.mUid;
|
||||||
mLocales, mAtm.getGlobalConfiguration().getLocales());
|
mUserId = wpc.mUserId;
|
||||||
wpc.applyAppSpecificConfig(mNightMode, localesOverride);
|
mPackageName = wpc.mInfo.packageName;
|
||||||
wpc.updateAppSpecificSettingsForAllActivities(mNightMode, localesOverride);
|
} else {
|
||||||
mAtm.mPackageConfigPersister.updateFromImpl(wpc.mName, wpc.mUserId, this);
|
uid = mAtm.getPackageManagerInternalLocked().getPackageUid(mPackageName,
|
||||||
|
/* flags = */ PackageManager.MATCH_ALL, mUserId);
|
||||||
|
if (uid < 0) {
|
||||||
|
Slog.w(TAG, "commit: update of application configuration failed: "
|
||||||
|
+ "userId or packageName not valid " + mUserId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateConfig(uid, mPackageName);
|
||||||
|
mAtm.mPackageConfigPersister.updateFromImpl(mPackageName, mUserId, this);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(ident);
|
Binder.restoreCallingIdentity(ident);
|
||||||
}
|
}
|
||||||
@@ -76,6 +103,19 @@ final class PackageConfigurationUpdaterImpl implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateConfig(int uid, String packageName) {
|
||||||
|
final ArraySet<WindowProcessController> processes = mAtm.mProcessMap.getProcesses(uid);
|
||||||
|
if (processes == null) return;
|
||||||
|
for (int i = processes.size() - 1; i >= 0; i--) {
|
||||||
|
final WindowProcessController wpc = processes.valueAt(i);
|
||||||
|
if (!wpc.mInfo.packageName.equals(packageName)) continue;
|
||||||
|
LocaleList localesOverride = LocaleOverlayHelper.combineLocalesIfOverlayExists(
|
||||||
|
mLocales, mAtm.getGlobalConfiguration().getLocales());
|
||||||
|
wpc.applyAppSpecificConfig(mNightMode, localesOverride);
|
||||||
|
wpc.updateAppSpecificSettingsForAllActivities(mNightMode, localesOverride);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Integer getNightMode() {
|
Integer getNightMode() {
|
||||||
return mNightMode;
|
return mNightMode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
|
|||||||
}
|
}
|
||||||
|
|
||||||
onConfigurationChanged(atm.getGlobalConfiguration());
|
onConfigurationChanged(atm.getGlobalConfiguration());
|
||||||
mAtm.mPackageConfigPersister.updateConfigIfNeeded(this, mUserId, mName);
|
mAtm.mPackageConfigPersister.updateConfigIfNeeded(this, mUserId, mInfo.packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPid(int pid) {
|
public void setPid(int pid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user