Merge "Fix setApplicationNightMode crash due to permission denial." into sc-dev am: d42b8e2c73
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14702762 Change-Id: Iade12e39ebdeebafef68714f1cb67e767122947c
This commit is contained in:
@@ -67,7 +67,6 @@ interface IUiModeManager {
|
|||||||
* 1 - notnight mode
|
* 1 - notnight mode
|
||||||
* 2 - night mode
|
* 2 - night mode
|
||||||
* 3 - automatic mode switching
|
* 3 - automatic mode switching
|
||||||
* @throws RemoteException
|
|
||||||
*/
|
*/
|
||||||
void setApplicationNightMode(in int mode);
|
void setApplicationNightMode(in int mode);
|
||||||
|
|
||||||
|
|||||||
@@ -754,8 +754,7 @@ final class UiModeManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setApplicationNightMode(@UiModeManager.NightMode int mode)
|
public void setApplicationNightMode(@UiModeManager.NightMode int mode) {
|
||||||
throws RemoteException {
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case UiModeManager.MODE_NIGHT_NO:
|
case UiModeManager.MODE_NIGHT_NO:
|
||||||
case UiModeManager.MODE_NIGHT_YES:
|
case UiModeManager.MODE_NIGHT_YES:
|
||||||
@@ -776,14 +775,10 @@ final class UiModeManagerService extends SystemService {
|
|||||||
default:
|
default:
|
||||||
configNightMode = Configuration.UI_MODE_NIGHT_UNDEFINED;
|
configNightMode = Configuration.UI_MODE_NIGHT_UNDEFINED;
|
||||||
}
|
}
|
||||||
try {
|
final ActivityTaskManagerInternal.PackageConfigurationUpdater updater =
|
||||||
final ActivityTaskManagerInternal.PackageConfigurationUpdater updater =
|
mActivityTaskManager.createPackageConfigurationUpdater();
|
||||||
mActivityTaskManager.createPackageConfigurationUpdater();
|
updater.setNightMode(configNightMode);
|
||||||
updater.setNightMode(configNightMode);
|
updater.commit();
|
||||||
updater.commit();
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -618,7 +618,7 @@ public abstract class ActivityTaskManagerInternal {
|
|||||||
/**
|
/**
|
||||||
* Commit changes.
|
* Commit changes.
|
||||||
*/
|
*/
|
||||||
void commit() throws RemoteException;
|
void commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6390,9 +6390,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PackageConfigurationUpdater createPackageConfigurationUpdater() {
|
public PackageConfigurationUpdater createPackageConfigurationUpdater() {
|
||||||
synchronized (mGlobalLock) {
|
return new PackageConfigurationUpdaterImpl(Binder.getCallingPid());
|
||||||
return new PackageConfigurationUpdaterImpl(Binder.getCallingPid());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -6405,7 +6403,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
|
|
||||||
final class PackageConfigurationUpdaterImpl implements
|
final class PackageConfigurationUpdaterImpl implements
|
||||||
ActivityTaskManagerInternal.PackageConfigurationUpdater {
|
ActivityTaskManagerInternal.PackageConfigurationUpdater {
|
||||||
private int mPid;
|
private final int mPid;
|
||||||
private int mNightMode;
|
private int mNightMode;
|
||||||
|
|
||||||
PackageConfigurationUpdaterImpl(int pid) {
|
PackageConfigurationUpdaterImpl(int pid) {
|
||||||
@@ -6419,24 +6417,26 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void commit() throws RemoteException {
|
public void commit() {
|
||||||
if (mPid == 0) {
|
|
||||||
throw new RemoteException("Invalid process");
|
|
||||||
}
|
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
final WindowProcessController wpc = mProcessMap.getProcess(mPid);
|
final long ident = Binder.clearCallingIdentity();
|
||||||
if (wpc == null) {
|
try {
|
||||||
Slog.w(TAG, "Override application configuration: cannot find application");
|
final WindowProcessController wpc = mProcessMap.getProcess(mPid);
|
||||||
return;
|
if (wpc == null) {
|
||||||
|
Slog.w(TAG, "Override application configuration: cannot find pid " + mPid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (wpc.getNightMode() == mNightMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!wpc.setOverrideNightMode(mNightMode)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wpc.updateNightModeForAllActivities(mNightMode);
|
||||||
|
mPackageConfigPersister.updateFromImpl(wpc.mName, wpc.mUserId, this);
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(ident);
|
||||||
}
|
}
|
||||||
if (wpc.getNightMode() == mNightMode) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!wpc.setOverrideNightMode(mNightMode)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
wpc.updateNightModeForAllActivities(mNightMode);
|
|
||||||
mPackageConfigPersister.updateFromImpl(wpc.mName, wpc.mUserId, this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user