resolve merge conflicts of 1faafcb488 to stage-aosp-master
Bug: None Test: I solemnly swear I tested this conflict resolution. Change-Id: I055f014081e454b1dcfb8523a0387d7bc4b4ff9a Merged-In: I981067477f6f4aa435459c0bc9a52099e6f5d445 Exempted-From-Owner-Approval: merge conflict resolution
This commit is contained in:
@@ -88,6 +88,7 @@ import android.view.Display;
|
|||||||
import com.android.internal.util.HexDump;
|
import com.android.internal.util.HexDump;
|
||||||
import com.android.internal.util.MemInfoReader;
|
import com.android.internal.util.MemInfoReader;
|
||||||
import com.android.internal.util.Preconditions;
|
import com.android.internal.util.Preconditions;
|
||||||
|
import com.android.server.compat.CompatConfig;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -288,6 +289,8 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
|||||||
return runNoHomeScreen(pw);
|
return runNoHomeScreen(pw);
|
||||||
case "wait-for-broadcast-idle":
|
case "wait-for-broadcast-idle":
|
||||||
return runWaitForBroadcastIdle(pw);
|
return runWaitForBroadcastIdle(pw);
|
||||||
|
case "compat":
|
||||||
|
return runCompat(pw);
|
||||||
default:
|
default:
|
||||||
return handleDefaultCommands(cmd);
|
return handleDefaultCommands(cmd);
|
||||||
}
|
}
|
||||||
@@ -2865,6 +2868,50 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int runCompat(PrintWriter pw) {
|
||||||
|
final CompatConfig config = CompatConfig.get();
|
||||||
|
String toggleValue = getNextArgRequired();
|
||||||
|
long changeId;
|
||||||
|
String changeIdString = getNextArgRequired();
|
||||||
|
try {
|
||||||
|
changeId = Long.parseLong(changeIdString);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
changeId = config.lookupChangeId(changeIdString);
|
||||||
|
}
|
||||||
|
if (changeId == -1) {
|
||||||
|
pw.println("Unknown or invalid change: '" + changeIdString + "'.");
|
||||||
|
}
|
||||||
|
String packageName = getNextArgRequired();
|
||||||
|
switch(toggleValue) {
|
||||||
|
case "enable":
|
||||||
|
if (!config.addOverride(changeId, packageName, true)) {
|
||||||
|
pw.println("Warning! Change " + changeId + " is not known yet. Enabling it"
|
||||||
|
+ " could have no effect.");
|
||||||
|
}
|
||||||
|
pw.println("Enabled change " + changeId + " for " + packageName + ".");
|
||||||
|
return 0;
|
||||||
|
case "disable":
|
||||||
|
if (!config.addOverride(changeId, packageName, false)) {
|
||||||
|
pw.println("Warning! Change " + changeId + " is not known yet. Disabling it"
|
||||||
|
+ " could have no effect.");
|
||||||
|
}
|
||||||
|
pw.println("Disabled change " + changeId + " for " + packageName + ".");
|
||||||
|
return 0;
|
||||||
|
case "reset":
|
||||||
|
if (config.removeOverride(changeId, packageName)) {
|
||||||
|
pw.println("Reset change " + changeId + " for " + packageName
|
||||||
|
+ " to default value.");
|
||||||
|
} else {
|
||||||
|
pw.println("No override exists for changeId " + changeId + ".");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
pw.println("Invalid toggle value: '" + toggleValue + "'.");
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private Resources getResources(PrintWriter pw) throws RemoteException {
|
private Resources getResources(PrintWriter pw) throws RemoteException {
|
||||||
// system resources does not contain all the device configuration, construct it manually.
|
// system resources does not contain all the device configuration, construct it manually.
|
||||||
Configuration config = mInterface.getConfiguration();
|
Configuration config = mInterface.getConfiguration();
|
||||||
@@ -3170,6 +3217,8 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
|||||||
pw.println(" without restarting any processes.");
|
pw.println(" without restarting any processes.");
|
||||||
pw.println(" write");
|
pw.println(" write");
|
||||||
pw.println(" Write all pending state to storage.");
|
pw.println(" Write all pending state to storage.");
|
||||||
|
pw.println(" compat enable|disable|reset <CHANGE_ID|CHANGE_NAME> <PACKAGE_NAME>");
|
||||||
|
pw.println(" Toggles a change either by id or by name for <PACKAGE_NAME>.");
|
||||||
pw.println();
|
pw.println();
|
||||||
Intent.printIntentArgsHelp(pw, "");
|
Intent.printIntentArgsHelp(pw, "");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,20 +128,24 @@ public final class CompatConfig {
|
|||||||
* <p>Note, package overrides are not persistent and will be lost on system or runtime restart.
|
* <p>Note, package overrides are not persistent and will be lost on system or runtime restart.
|
||||||
*
|
*
|
||||||
* @param changeId The ID of the change to be overridden. Note, this call will succeed even if
|
* @param changeId The ID of the change to be overridden. Note, this call will succeed even if
|
||||||
* this change is not known; it will only have any affect if any code in the
|
* this change is not known; it will only have any effect if any code in the
|
||||||
* platform is gated on the ID given.
|
* platform is gated on the ID given.
|
||||||
* @param packageName The app package name to override the change for.
|
* @param packageName The app package name to override the change for.
|
||||||
* @param enabled If the change should be enabled or disabled.
|
* @param enabled If the change should be enabled or disabled.
|
||||||
|
* @return {@code true} if the change existed before adding the override.
|
||||||
*/
|
*/
|
||||||
public void addOverride(long changeId, String packageName, boolean enabled) {
|
public boolean addOverride(long changeId, String packageName, boolean enabled) {
|
||||||
|
boolean alreadyKnown = true;
|
||||||
synchronized (mChanges) {
|
synchronized (mChanges) {
|
||||||
CompatChange c = mChanges.get(changeId);
|
CompatChange c = mChanges.get(changeId);
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
|
alreadyKnown = false;
|
||||||
c = new CompatChange(changeId);
|
c = new CompatChange(changeId);
|
||||||
addChange(c);
|
addChange(c);
|
||||||
}
|
}
|
||||||
c.addPackageOverride(packageName, enabled);
|
c.addPackageOverride(packageName, enabled);
|
||||||
}
|
}
|
||||||
|
return alreadyKnown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,14 +155,18 @@ public final class CompatConfig {
|
|||||||
*
|
*
|
||||||
* @param changeId The ID of the change that was overridden.
|
* @param changeId The ID of the change that was overridden.
|
||||||
* @param packageName The app package name that was overridden.
|
* @param packageName The app package name that was overridden.
|
||||||
|
* @return {@code true} if an override existed;
|
||||||
*/
|
*/
|
||||||
public void removeOverride(long changeId, String packageName) {
|
public boolean removeOverride(long changeId, String packageName) {
|
||||||
|
boolean overrideExists = false;
|
||||||
synchronized (mChanges) {
|
synchronized (mChanges) {
|
||||||
CompatChange c = mChanges.get(changeId);
|
CompatChange c = mChanges.get(changeId);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
|
overrideExists = true;
|
||||||
c.removePackageOverride(packageName);
|
c.removePackageOverride(packageName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return overrideExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user