Merge "Add more downscale factors." into sc-dev
This commit is contained in:
@@ -21,10 +21,18 @@ import static android.content.Intent.ACTION_PACKAGE_CHANGED;
|
||||
import static android.content.Intent.ACTION_PACKAGE_REMOVED;
|
||||
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALED;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_30;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_35;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_40;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_45;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_50;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_55;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_60;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_65;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_70;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_75;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_80;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_85;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_90;
|
||||
|
||||
import android.Manifest;
|
||||
@@ -213,6 +221,39 @@ public final class GameManagerService extends IGameManagerService.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
// Turn the raw string to the corresponding CompatChange id.
|
||||
static long getCompatChangeId(String raw) {
|
||||
switch (raw) {
|
||||
case "0.3":
|
||||
return DOWNSCALE_30;
|
||||
case "0.35":
|
||||
return DOWNSCALE_35;
|
||||
case "0.4":
|
||||
return DOWNSCALE_40;
|
||||
case "0.45":
|
||||
return DOWNSCALE_45;
|
||||
case "0.5":
|
||||
return DOWNSCALE_50;
|
||||
case "0.55":
|
||||
return DOWNSCALE_55;
|
||||
case "0.6":
|
||||
return DOWNSCALE_60;
|
||||
case "0.65":
|
||||
return DOWNSCALE_65;
|
||||
case "0.7":
|
||||
return DOWNSCALE_70;
|
||||
case "0.75":
|
||||
return DOWNSCALE_75;
|
||||
case "0.8":
|
||||
return DOWNSCALE_80;
|
||||
case "0.85":
|
||||
return DOWNSCALE_85;
|
||||
case "0.9":
|
||||
return DOWNSCALE_90;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* GamePackageConfiguration manages all game mode config details for its associated package.
|
||||
*/
|
||||
@@ -331,19 +372,7 @@ public final class GameManagerService extends IGameManagerService.Stub {
|
||||
* Get the corresponding compat change id for the current scaling string.
|
||||
*/
|
||||
public long getCompatChangeId() {
|
||||
switch (mScaling) {
|
||||
case "0.5":
|
||||
return DOWNSCALE_50;
|
||||
case "0.6":
|
||||
return DOWNSCALE_60;
|
||||
case "0.7":
|
||||
return DOWNSCALE_70;
|
||||
case "0.8":
|
||||
return DOWNSCALE_80;
|
||||
case "0.9":
|
||||
return DOWNSCALE_90;
|
||||
}
|
||||
return 0;
|
||||
return GameManagerService.getCompatChangeId(mScaling);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -663,10 +692,18 @@ public final class GameManagerService extends IGameManagerService.Stub {
|
||||
Slog.i(TAG, "Enabling downscale: " + scaleId + " for " + packageName);
|
||||
final ArrayMap<Long, PackageOverride> overrides = new ArrayMap<>();
|
||||
overrides.put(DOWNSCALED, COMPAT_ENABLED);
|
||||
overrides.put(DOWNSCALE_30, COMPAT_DISABLED);
|
||||
overrides.put(DOWNSCALE_35, COMPAT_DISABLED);
|
||||
overrides.put(DOWNSCALE_40, COMPAT_DISABLED);
|
||||
overrides.put(DOWNSCALE_45, COMPAT_DISABLED);
|
||||
overrides.put(DOWNSCALE_50, COMPAT_DISABLED);
|
||||
overrides.put(DOWNSCALE_55, COMPAT_DISABLED);
|
||||
overrides.put(DOWNSCALE_60, COMPAT_DISABLED);
|
||||
overrides.put(DOWNSCALE_65, COMPAT_DISABLED);
|
||||
overrides.put(DOWNSCALE_70, COMPAT_DISABLED);
|
||||
overrides.put(DOWNSCALE_75, COMPAT_DISABLED);
|
||||
overrides.put(DOWNSCALE_80, COMPAT_DISABLED);
|
||||
overrides.put(DOWNSCALE_85, COMPAT_DISABLED);
|
||||
overrides.put(DOWNSCALE_90, COMPAT_DISABLED);
|
||||
overrides.put(scaleId, COMPAT_ENABLED);
|
||||
final CompatibilityOverrideConfig changeConfig = new CompatibilityOverrideConfig(
|
||||
|
||||
@@ -16,6 +16,21 @@
|
||||
|
||||
package com.android.server.app;
|
||||
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALED;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_30;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_35;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_40;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_45;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_50;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_55;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_60;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_65;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_70;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_75;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_80;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_85;
|
||||
import static com.android.server.wm.CompatModePackages.DOWNSCALE_90;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.GameManager;
|
||||
import android.app.IGameManagerService;
|
||||
@@ -27,7 +42,6 @@ import android.util.ArraySet;
|
||||
|
||||
import com.android.internal.compat.CompatibilityChangeConfig;
|
||||
import com.android.server.compat.PlatformCompat;
|
||||
import com.android.server.wm.CompatModePackages;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Set;
|
||||
@@ -43,12 +57,21 @@ public class GameManagerShellCommand extends ShellCommand {
|
||||
public GameManagerShellCommand() {}
|
||||
|
||||
private static final ArraySet<Long> DOWNSCALE_CHANGE_IDS = new ArraySet<>(new Long[]{
|
||||
CompatModePackages.DOWNSCALED,
|
||||
CompatModePackages.DOWNSCALE_90,
|
||||
CompatModePackages.DOWNSCALE_80,
|
||||
CompatModePackages.DOWNSCALE_70,
|
||||
CompatModePackages.DOWNSCALE_60,
|
||||
CompatModePackages.DOWNSCALE_50});
|
||||
DOWNSCALED,
|
||||
DOWNSCALE_90,
|
||||
DOWNSCALE_85,
|
||||
DOWNSCALE_80,
|
||||
DOWNSCALE_75,
|
||||
DOWNSCALE_70,
|
||||
DOWNSCALE_65,
|
||||
DOWNSCALE_60,
|
||||
DOWNSCALE_55,
|
||||
DOWNSCALE_50,
|
||||
DOWNSCALE_45,
|
||||
DOWNSCALE_40,
|
||||
DOWNSCALE_35,
|
||||
DOWNSCALE_30,
|
||||
});
|
||||
|
||||
@Override
|
||||
public int onCommand(String cmd) {
|
||||
@@ -62,32 +85,9 @@ public class GameManagerShellCommand extends ShellCommand {
|
||||
final String ratio = getNextArgRequired();
|
||||
final String packageName = getNextArgRequired();
|
||||
|
||||
final long changeId;
|
||||
switch (ratio) {
|
||||
case "0.5":
|
||||
changeId = CompatModePackages.DOWNSCALE_50;
|
||||
break;
|
||||
case "0.6":
|
||||
changeId = CompatModePackages.DOWNSCALE_60;
|
||||
break;
|
||||
case "0.7":
|
||||
changeId = CompatModePackages.DOWNSCALE_70;
|
||||
break;
|
||||
case "0.8":
|
||||
changeId = CompatModePackages.DOWNSCALE_80;
|
||||
break;
|
||||
case "0.9":
|
||||
changeId = CompatModePackages.DOWNSCALE_90;
|
||||
break;
|
||||
case "disable":
|
||||
changeId = 0;
|
||||
break;
|
||||
default:
|
||||
changeId = -1;
|
||||
pw.println("Invalid scaling ratio '" + ratio + "'");
|
||||
break;
|
||||
}
|
||||
if (changeId == -1) {
|
||||
final long changeId = GameManagerService.getCompatChangeId(ratio);
|
||||
if (changeId == 0 && !ratio.equals("disable")) {
|
||||
pw.println("Invalid scaling ratio '" + ratio + "'");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -96,10 +96,10 @@ public class GameManagerShellCommand extends ShellCommand {
|
||||
if (changeId == 0) {
|
||||
disabled = DOWNSCALE_CHANGE_IDS;
|
||||
} else {
|
||||
enabled.add(CompatModePackages.DOWNSCALED);
|
||||
enabled.add(DOWNSCALED);
|
||||
enabled.add(changeId);
|
||||
disabled = DOWNSCALE_CHANGE_IDS.stream()
|
||||
.filter(it -> it != CompatModePackages.DOWNSCALED && it != changeId)
|
||||
.filter(it -> it != DOWNSCALED && it != changeId)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ public class GameManagerShellCommand extends ShellCommand {
|
||||
pw.println("Game manager (game) commands:");
|
||||
pw.println(" help");
|
||||
pw.println(" Print this help text.");
|
||||
pw.println(" downscale [0.5|0.6|0.7|0.8|0.9|disable] <PACKAGE_NAME>");
|
||||
pw.println(" downscale [0.3|0.35|0.4|0.45|0.5|0.55|0.6|0.65|0.7|0.75|0.8|0.85|0.9|disable] <PACKAGE_NAME>");
|
||||
pw.println(" Force app to run at the specified scaling ratio.");
|
||||
pw.println(" mode [--user <USER_ID>] [1|2|3|standard|performance|battery] <PACKAGE_NAME>");
|
||||
pw.println(" Force app to run in the specified game mode, if supported.");
|
||||
|
||||
@@ -75,10 +75,18 @@ public final class CompatModePackages {
|
||||
* CompatModePackages#DOWNSCALED is the gatekeeper of all per-app buffer downscaling
|
||||
* changes. Disabling this change will prevent the following scaling factors from working:
|
||||
* CompatModePackages#DOWNSCALE_90
|
||||
* CompatModePackages#DOWNSCALE_85
|
||||
* CompatModePackages#DOWNSCALE_80
|
||||
* CompatModePackages#DOWNSCALE_75
|
||||
* CompatModePackages#DOWNSCALE_70
|
||||
* CompatModePackages#DOWNSCALE_65
|
||||
* CompatModePackages#DOWNSCALE_60
|
||||
* CompatModePackages#DOWNSCALE_55
|
||||
* CompatModePackages#DOWNSCALE_50
|
||||
* CompatModePackages#DOWNSCALE_45
|
||||
* CompatModePackages#DOWNSCALE_40
|
||||
* CompatModePackages#DOWNSCALE_35
|
||||
* CompatModePackages#DOWNSCALE_30
|
||||
*
|
||||
* If CompatModePackages#DOWNSCALED is enabled for an app package, then the app will be forcibly
|
||||
* resized to the highest enabled scaling factor e.g. 80% if both 80% and 70% were enabled.
|
||||
@@ -98,6 +106,16 @@ public final class CompatModePackages {
|
||||
@Overridable
|
||||
public static final long DOWNSCALE_90 = 182811243L;
|
||||
|
||||
/**
|
||||
* With CompatModePackages#DOWNSCALED enabled, subsequently enabling change-id
|
||||
* CompatModePackages#DOWNSCALE_85 for a package will force the app to assume it's
|
||||
* running on a display with 85% the vertical and horizontal resolution of the real display.
|
||||
*/
|
||||
@ChangeId
|
||||
@Disabled
|
||||
@Overridable
|
||||
public static final long DOWNSCALE_85 = 189969734L;
|
||||
|
||||
/**
|
||||
* With CompatModePackages#DOWNSCALED enabled, subsequently enabling change-id
|
||||
* CompatModePackages#DOWNSCALE_80 for a package will force the app to assume it's
|
||||
@@ -108,6 +126,16 @@ public final class CompatModePackages {
|
||||
@Overridable
|
||||
public static final long DOWNSCALE_80 = 176926753L;
|
||||
|
||||
/**
|
||||
* With CompatModePackages#DOWNSCALED enabled, subsequently enabling change-id
|
||||
* CompatModePackages#DOWNSCALE_75 for a package will force the app to assume it's
|
||||
* running on a display with 75% the vertical and horizontal resolution of the real display.
|
||||
*/
|
||||
@ChangeId
|
||||
@Disabled
|
||||
@Overridable
|
||||
public static final long DOWNSCALE_75 = 189969779L;
|
||||
|
||||
/**
|
||||
* With CompatModePackages#DOWNSCALED enabled, subsequently enabling change-id
|
||||
* CompatModePackages#DOWNSCALE_70 for a package will force the app to assume it's
|
||||
@@ -118,6 +146,16 @@ public final class CompatModePackages {
|
||||
@Overridable
|
||||
public static final long DOWNSCALE_70 = 176926829L;
|
||||
|
||||
/**
|
||||
* With CompatModePackages#DOWNSCALED enabled, subsequently enabling change-id
|
||||
* CompatModePackages#DOWNSCALE_65 for a package will force the app to assume it's
|
||||
* running on a display with 65% the vertical and horizontal resolution of the real display.
|
||||
*/
|
||||
@ChangeId
|
||||
@Disabled
|
||||
@Overridable
|
||||
public static final long DOWNSCALE_65 = 189969744L;
|
||||
|
||||
/**
|
||||
* With CompatModePackages#DOWNSCALED enabled, subsequently enabling change-id
|
||||
* CompatModePackages#DOWNSCALE_60 for a package will force the app to assume it's
|
||||
@@ -128,6 +166,16 @@ public final class CompatModePackages {
|
||||
@Overridable
|
||||
public static final long DOWNSCALE_60 = 176926771L;
|
||||
|
||||
/**
|
||||
* With CompatModePackages#DOWNSCALED enabled, subsequently enabling change-id
|
||||
* CompatModePackages#DOWNSCALE_55 for a package will force the app to assume it's
|
||||
* running on a display with 55% the vertical and horizontal resolution of the real display.
|
||||
*/
|
||||
@ChangeId
|
||||
@Disabled
|
||||
@Overridable
|
||||
public static final long DOWNSCALE_55 = 189970036L;
|
||||
|
||||
/**
|
||||
* With CompatModePackages#DOWNSCALED enabled, subsequently enabling change-id
|
||||
* CompatModePackages#DOWNSCALE_50 for a package will force the app to assume it's
|
||||
@@ -138,6 +186,46 @@ public final class CompatModePackages {
|
||||
@Overridable
|
||||
public static final long DOWNSCALE_50 = 176926741L;
|
||||
|
||||
/**
|
||||
* With CompatModePackages#DOWNSCALED enabled, subsequently enabling change-id
|
||||
* CompatModePackages#DOWNSCALE_45 for a package will force the app to assume it's
|
||||
* running on a display with 45% the vertical and horizontal resolution of the real display.
|
||||
*/
|
||||
@ChangeId
|
||||
@Disabled
|
||||
@Overridable
|
||||
public static final long DOWNSCALE_45 = 189969782L;
|
||||
|
||||
/**
|
||||
* With CompatModePackages#DOWNSCALED enabled, subsequently enabling change-id
|
||||
* CompatModePackages#DOWNSCALE_40 for a package will force the app to assume it's
|
||||
* running on a display with 40% the vertical and horizontal resolution of the real display.
|
||||
*/
|
||||
@ChangeId
|
||||
@Disabled
|
||||
@Overridable
|
||||
public static final long DOWNSCALE_40 = 189970038L;
|
||||
|
||||
/**
|
||||
* With CompatModePackages#DOWNSCALED enabled, subsequently enabling change-id
|
||||
* CompatModePackages#DOWNSCALE_35 for a package will force the app to assume it's
|
||||
* running on a display with 35% the vertical and horizontal resolution of the real display.
|
||||
*/
|
||||
@ChangeId
|
||||
@Disabled
|
||||
@Overridable
|
||||
public static final long DOWNSCALE_35 = 189969749L;
|
||||
|
||||
/**
|
||||
* With CompatModePackages#DOWNSCALED enabled, subsequently enabling change-id
|
||||
* CompatModePackages#DOWNSCALE_30 for a package will force the app to assume it's
|
||||
* running on a display with 30% the vertical and horizontal resolution of the real display.
|
||||
*/
|
||||
@ChangeId
|
||||
@Disabled
|
||||
@Overridable
|
||||
public static final long DOWNSCALE_30 = 189970040L;
|
||||
|
||||
/**
|
||||
* On Android TV applications that target pre-S are not expecting to receive a Window larger
|
||||
* than 1080p, so if needed we are downscaling their Windows to 1080p.
|
||||
@@ -291,18 +379,42 @@ public final class CompatModePackages {
|
||||
if (CompatChanges.isChangeEnabled(DOWNSCALE_90, packageName, userHandle)) {
|
||||
return 1f / 0.9f;
|
||||
}
|
||||
if (CompatChanges.isChangeEnabled(DOWNSCALE_85, packageName, userHandle)) {
|
||||
return 1f / 0.85f;
|
||||
}
|
||||
if (CompatChanges.isChangeEnabled(DOWNSCALE_80, packageName, userHandle)) {
|
||||
return 1f / 0.8f;
|
||||
}
|
||||
if (CompatChanges.isChangeEnabled(DOWNSCALE_75, packageName, userHandle)) {
|
||||
return 1f / 0.75f;
|
||||
}
|
||||
if (CompatChanges.isChangeEnabled(DOWNSCALE_70, packageName, userHandle)) {
|
||||
return 1f / 0.7f;
|
||||
}
|
||||
if (CompatChanges.isChangeEnabled(DOWNSCALE_65, packageName, userHandle)) {
|
||||
return 1f / 0.65f;
|
||||
}
|
||||
if (CompatChanges.isChangeEnabled(DOWNSCALE_60, packageName, userHandle)) {
|
||||
return 1f / 0.6f;
|
||||
}
|
||||
if (CompatChanges.isChangeEnabled(DOWNSCALE_55, packageName, userHandle)) {
|
||||
return 1f / 0.55f;
|
||||
}
|
||||
if (CompatChanges.isChangeEnabled(DOWNSCALE_50, packageName, userHandle)) {
|
||||
return 1f / 0.5f;
|
||||
}
|
||||
if (CompatChanges.isChangeEnabled(DOWNSCALE_45, packageName, userHandle)) {
|
||||
return 1f / 0.45f;
|
||||
}
|
||||
if (CompatChanges.isChangeEnabled(DOWNSCALE_40, packageName, userHandle)) {
|
||||
return 1f / 0.4f;
|
||||
}
|
||||
if (CompatChanges.isChangeEnabled(DOWNSCALE_35, packageName, userHandle)) {
|
||||
return 1f / 0.35f;
|
||||
}
|
||||
if (CompatChanges.isChangeEnabled(DOWNSCALE_30, packageName, userHandle)) {
|
||||
return 1f / 0.3f;
|
||||
}
|
||||
}
|
||||
|
||||
if (mService.mHasLeanbackFeature) {
|
||||
|
||||
Reference in New Issue
Block a user