am 549ac692: am d8b9b642: Merge "Use DisplayAdjustments when creating display in ResourceManager" into mnc-dev
* commit '549ac6925a28bf185515334a99cffb2048f0708a': Use DisplayAdjustments when creating display in ResourceManager
This commit is contained in:
@@ -34706,6 +34706,7 @@ package android.view {
|
|||||||
field public static final int FLAG_ROUND = 16; // 0x10
|
field public static final int FLAG_ROUND = 16; // 0x10
|
||||||
field public static final int FLAG_SECURE = 2; // 0x2
|
field public static final int FLAG_SECURE = 2; // 0x2
|
||||||
field public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1; // 0x1
|
field public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1; // 0x1
|
||||||
|
field public static final int INVALID_DISPLAY = -1; // 0xffffffff
|
||||||
field public static final int STATE_DOZE = 3; // 0x3
|
field public static final int STATE_DOZE = 3; // 0x3
|
||||||
field public static final int STATE_DOZE_SUSPEND = 4; // 0x4
|
field public static final int STATE_DOZE_SUSPEND = 4; // 0x4
|
||||||
field public static final int STATE_OFF = 1; // 0x1
|
field public static final int STATE_OFF = 1; // 0x1
|
||||||
|
|||||||
@@ -36971,6 +36971,7 @@ package android.view {
|
|||||||
field public static final int FLAG_ROUND = 16; // 0x10
|
field public static final int FLAG_ROUND = 16; // 0x10
|
||||||
field public static final int FLAG_SECURE = 2; // 0x2
|
field public static final int FLAG_SECURE = 2; // 0x2
|
||||||
field public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1; // 0x1
|
field public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1; // 0x1
|
||||||
|
field public static final int INVALID_DISPLAY = -1; // 0xffffffff
|
||||||
field public static final int STATE_DOZE = 3; // 0x3
|
field public static final int STATE_DOZE = 3; // 0x3
|
||||||
field public static final int STATE_DOZE_SUSPEND = 4; // 0x4
|
field public static final int STATE_DOZE_SUSPEND = 4; // 0x4
|
||||||
field public static final int STATE_OFF = 1; // 0x1
|
field public static final int STATE_OFF = 1; // 0x1
|
||||||
|
|||||||
@@ -2444,7 +2444,8 @@ public final class ActivityThread {
|
|||||||
&& r.packageInfo.mPackageName.contains(pkgName)) {
|
&& r.packageInfo.mPackageName.contains(pkgName)) {
|
||||||
for (int id : dm.getDisplayIds()) {
|
for (int id : dm.getDisplayIds()) {
|
||||||
if (id != Display.DEFAULT_DISPLAY) {
|
if (id != Display.DEFAULT_DISPLAY) {
|
||||||
Display display = dm.getRealDisplay(id, r.overrideConfig);
|
Display display =
|
||||||
|
dm.getCompatibleDisplay(id, appContext.getDisplayAdjustments(id));
|
||||||
baseContext = appContext.createDisplayContext(display);
|
baseContext = appContext.createDisplayContext(display);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1597,7 +1597,7 @@ class ContextImpl extends Context {
|
|||||||
final boolean restricted = (flags & CONTEXT_RESTRICTED) == CONTEXT_RESTRICTED;
|
final boolean restricted = (flags & CONTEXT_RESTRICTED) == CONTEXT_RESTRICTED;
|
||||||
ContextImpl c = new ContextImpl(this, mMainThread, pi, mActivityToken,
|
ContextImpl c = new ContextImpl(this, mMainThread, pi, mActivityToken,
|
||||||
new UserHandle(UserHandle.getUserId(application.uid)), restricted,
|
new UserHandle(UserHandle.getUserId(application.uid)), restricted,
|
||||||
mDisplay, null);
|
mDisplay, null, Display.INVALID_DISPLAY);
|
||||||
if (c.mResources != null) {
|
if (c.mResources != null) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@@ -1620,14 +1620,14 @@ class ContextImpl extends Context {
|
|||||||
final boolean restricted = (flags & CONTEXT_RESTRICTED) == CONTEXT_RESTRICTED;
|
final boolean restricted = (flags & CONTEXT_RESTRICTED) == CONTEXT_RESTRICTED;
|
||||||
if (packageName.equals("system") || packageName.equals("android")) {
|
if (packageName.equals("system") || packageName.equals("android")) {
|
||||||
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
|
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
|
||||||
user, restricted, mDisplay, null);
|
user, restricted, mDisplay, null, Display.INVALID_DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadedApk pi = mMainThread.getPackageInfo(packageName, mResources.getCompatibilityInfo(),
|
LoadedApk pi = mMainThread.getPackageInfo(packageName, mResources.getCompatibilityInfo(),
|
||||||
flags | CONTEXT_REGISTER_PACKAGE, user.getIdentifier());
|
flags | CONTEXT_REGISTER_PACKAGE, user.getIdentifier());
|
||||||
if (pi != null) {
|
if (pi != null) {
|
||||||
ContextImpl c = new ContextImpl(this, mMainThread, pi, mActivityToken,
|
ContextImpl c = new ContextImpl(this, mMainThread, pi, mActivityToken,
|
||||||
user, restricted, mDisplay, null);
|
user, restricted, mDisplay, null, Display.INVALID_DISPLAY);
|
||||||
if (c.mResources != null) {
|
if (c.mResources != null) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@@ -1645,7 +1645,7 @@ class ContextImpl extends Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
|
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
|
||||||
mUser, mRestricted, mDisplay, overrideConfiguration);
|
mUser, mRestricted, mDisplay, overrideConfiguration, Display.INVALID_DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1655,15 +1655,15 @@ class ContextImpl extends Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
|
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
|
||||||
mUser, mRestricted, display, null);
|
mUser, mRestricted, display, null, Display.INVALID_DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
Display getDisplay() {
|
Display getDisplay() {
|
||||||
if (mDisplay != null) {
|
if (mDisplay != null) {
|
||||||
return mDisplay;
|
return mDisplay;
|
||||||
}
|
}
|
||||||
DisplayManager dm = getSystemService(DisplayManager.class);
|
return ResourcesManager.getInstance().getAdjustedDisplay(
|
||||||
return dm.getDisplay(Display.DEFAULT_DISPLAY);
|
Display.DEFAULT_DISPLAY, mDisplayAdjustments);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getDisplayId() {
|
private int getDisplayId() {
|
||||||
@@ -1708,7 +1708,7 @@ class ContextImpl extends Context {
|
|||||||
static ContextImpl createSystemContext(ActivityThread mainThread) {
|
static ContextImpl createSystemContext(ActivityThread mainThread) {
|
||||||
LoadedApk packageInfo = new LoadedApk(mainThread);
|
LoadedApk packageInfo = new LoadedApk(mainThread);
|
||||||
ContextImpl context = new ContextImpl(null, mainThread,
|
ContextImpl context = new ContextImpl(null, mainThread,
|
||||||
packageInfo, null, null, false, null, null);
|
packageInfo, null, null, false, null, null, Display.INVALID_DISPLAY);
|
||||||
context.mResources.updateConfiguration(context.mResourcesManager.getConfiguration(),
|
context.mResources.updateConfiguration(context.mResourcesManager.getConfiguration(),
|
||||||
context.mResourcesManager.getDisplayMetricsLocked());
|
context.mResourcesManager.getDisplayMetricsLocked());
|
||||||
return context;
|
return context;
|
||||||
@@ -1717,21 +1717,19 @@ class ContextImpl extends Context {
|
|||||||
static ContextImpl createAppContext(ActivityThread mainThread, LoadedApk packageInfo) {
|
static ContextImpl createAppContext(ActivityThread mainThread, LoadedApk packageInfo) {
|
||||||
if (packageInfo == null) throw new IllegalArgumentException("packageInfo");
|
if (packageInfo == null) throw new IllegalArgumentException("packageInfo");
|
||||||
return new ContextImpl(null, mainThread,
|
return new ContextImpl(null, mainThread,
|
||||||
packageInfo, null, null, false, null, null);
|
packageInfo, null, null, false, null, null, Display.INVALID_DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ContextImpl createActivityContext(ActivityThread mainThread,
|
static ContextImpl createActivityContext(ActivityThread mainThread,
|
||||||
LoadedApk packageInfo, int displayId, Configuration overrideConfiguration) {
|
LoadedApk packageInfo, int displayId, Configuration overrideConfiguration) {
|
||||||
if (packageInfo == null) throw new IllegalArgumentException("packageInfo");
|
if (packageInfo == null) throw new IllegalArgumentException("packageInfo");
|
||||||
final Display display = ResourcesManager.getInstance().getAdjustedDisplay(
|
return new ContextImpl(null, mainThread, packageInfo, null, null, false,
|
||||||
displayId, overrideConfiguration);
|
null, overrideConfiguration, displayId);
|
||||||
return new ContextImpl(null, mainThread, packageInfo, null, null, false, display,
|
|
||||||
overrideConfiguration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContextImpl(ContextImpl container, ActivityThread mainThread,
|
private ContextImpl(ContextImpl container, ActivityThread mainThread,
|
||||||
LoadedApk packageInfo, IBinder activityToken, UserHandle user, boolean restricted,
|
LoadedApk packageInfo, IBinder activityToken, UserHandle user, boolean restricted,
|
||||||
Display display, Configuration overrideConfiguration) {
|
Display display, Configuration overrideConfiguration, int createDisplayWithId) {
|
||||||
mOuterContext = this;
|
mOuterContext = this;
|
||||||
|
|
||||||
mMainThread = mainThread;
|
mMainThread = mainThread;
|
||||||
@@ -1745,9 +1743,10 @@ class ContextImpl extends Context {
|
|||||||
|
|
||||||
mPackageInfo = packageInfo;
|
mPackageInfo = packageInfo;
|
||||||
mResourcesManager = ResourcesManager.getInstance();
|
mResourcesManager = ResourcesManager.getInstance();
|
||||||
mDisplay = display;
|
|
||||||
|
|
||||||
final int displayId = getDisplayId();
|
final int displayId = (createDisplayWithId != Display.INVALID_DISPLAY)
|
||||||
|
? createDisplayWithId : getDisplayId();
|
||||||
|
|
||||||
CompatibilityInfo compatInfo = null;
|
CompatibilityInfo compatInfo = null;
|
||||||
if (container != null) {
|
if (container != null) {
|
||||||
compatInfo = container.getDisplayAdjustments(displayId).getCompatibilityInfo();
|
compatInfo = container.getDisplayAdjustments(displayId).getCompatibilityInfo();
|
||||||
@@ -1760,6 +1759,9 @@ class ContextImpl extends Context {
|
|||||||
mDisplayAdjustments.setCompatibilityInfo(compatInfo);
|
mDisplayAdjustments.setCompatibilityInfo(compatInfo);
|
||||||
mDisplayAdjustments.setConfiguration(overrideConfiguration);
|
mDisplayAdjustments.setConfiguration(overrideConfiguration);
|
||||||
|
|
||||||
|
mDisplay = (createDisplayWithId == Display.INVALID_DISPLAY) ? display
|
||||||
|
: ResourcesManager.getInstance().getAdjustedDisplay(displayId, mDisplayAdjustments);
|
||||||
|
|
||||||
Resources resources = packageInfo.getResources(mainThread);
|
Resources resources = packageInfo.getResources(mainThread);
|
||||||
if (resources != null) {
|
if (resources != null) {
|
||||||
if (displayId != Display.DEFAULT_DISPLAY
|
if (displayId != Display.DEFAULT_DISPLAY
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import android.util.Log;
|
|||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
|
import android.view.DisplayAdjustments;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@@ -42,7 +44,7 @@ public class ResourcesManager {
|
|||||||
private static ResourcesManager sResourcesManager;
|
private static ResourcesManager sResourcesManager;
|
||||||
private final ArrayMap<ResourcesKey, WeakReference<Resources> > mActiveResources =
|
private final ArrayMap<ResourcesKey, WeakReference<Resources> > mActiveResources =
|
||||||
new ArrayMap<>();
|
new ArrayMap<>();
|
||||||
private final ArrayMap<Pair<Integer, Configuration>, WeakReference<Display>> mDisplays =
|
private final ArrayMap<Pair<Integer, DisplayAdjustments>, WeakReference<Display>> mDisplays =
|
||||||
new ArrayMap<>();
|
new ArrayMap<>();
|
||||||
|
|
||||||
CompatibilityInfo mResCompatibilityInfo;
|
CompatibilityInfo mResCompatibilityInfo;
|
||||||
@@ -68,7 +70,8 @@ public class ResourcesManager {
|
|||||||
|
|
||||||
DisplayMetrics getDisplayMetricsLocked(int displayId) {
|
DisplayMetrics getDisplayMetricsLocked(int displayId) {
|
||||||
DisplayMetrics dm = new DisplayMetrics();
|
DisplayMetrics dm = new DisplayMetrics();
|
||||||
final Display display = getAdjustedDisplay(displayId, Configuration.EMPTY);
|
final Display display =
|
||||||
|
getAdjustedDisplay(displayId, DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS);
|
||||||
if (display != null) {
|
if (display != null) {
|
||||||
display.getMetrics(dm);
|
display.getMetrics(dm);
|
||||||
} else {
|
} else {
|
||||||
@@ -113,12 +116,13 @@ public class ResourcesManager {
|
|||||||
* available.
|
* available.
|
||||||
*
|
*
|
||||||
* @param displayId display Id.
|
* @param displayId display Id.
|
||||||
* @param overrideConfiguration override configurations.
|
* @param displayAdjustments display adjustments.
|
||||||
*/
|
*/
|
||||||
public Display getAdjustedDisplay(final int displayId, Configuration overrideConfiguration) {
|
public Display getAdjustedDisplay(final int displayId, DisplayAdjustments displayAdjustments) {
|
||||||
final Configuration configCopy = (overrideConfiguration != null)
|
final DisplayAdjustments displayAdjustmentsCopy = (displayAdjustments != null)
|
||||||
? new Configuration(overrideConfiguration) : new Configuration();
|
? new DisplayAdjustments(displayAdjustments) : new DisplayAdjustments();
|
||||||
final Pair<Integer, Configuration> key = Pair.create(displayId, configCopy);
|
final Pair<Integer, DisplayAdjustments> key =
|
||||||
|
Pair.create(displayId, displayAdjustmentsCopy);
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
WeakReference<Display> wd = mDisplays.get(key);
|
WeakReference<Display> wd = mDisplays.get(key);
|
||||||
if (wd != null) {
|
if (wd != null) {
|
||||||
@@ -132,7 +136,7 @@ public class ResourcesManager {
|
|||||||
// may be null early in system startup
|
// may be null early in system startup
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final Display display = dm.getRealDisplay(displayId, key.second);
|
final Display display = dm.getCompatibleDisplay(displayId, key.second);
|
||||||
if (display != null) {
|
if (display != null) {
|
||||||
mDisplays.put(key, new WeakReference<>(display));
|
mDisplays.put(key, new WeakReference<>(display));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,17 +192,6 @@ public final class DisplayManagerGlobal {
|
|||||||
return getCompatibleDisplay(displayId, DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS);
|
return getCompatibleDisplay(displayId, DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets information about a logical display without applying any compatibility metrics.
|
|
||||||
*
|
|
||||||
* @param displayId The logical display id.
|
|
||||||
* @param configuration the configuration.
|
|
||||||
* @return The display object, or null if there is no display with the given id.
|
|
||||||
*/
|
|
||||||
public Display getRealDisplay(int displayId, Configuration configuration) {
|
|
||||||
return getCompatibleDisplay(displayId, new DisplayAdjustments(configuration));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerDisplayListener(DisplayListener listener, Handler handler) {
|
public void registerDisplayListener(DisplayListener listener, Handler handler) {
|
||||||
if (listener == null) {
|
if (listener == null) {
|
||||||
throw new IllegalArgumentException("listener must not be null");
|
throw new IllegalArgumentException("listener must not be null");
|
||||||
|
|||||||
@@ -88,6 +88,11 @@ public final class Display {
|
|||||||
*/
|
*/
|
||||||
public static final int DEFAULT_DISPLAY = 0;
|
public static final int DEFAULT_DISPLAY = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalid display id.
|
||||||
|
*/
|
||||||
|
public static final int INVALID_DISPLAY = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display flag: Indicates that the display supports compositing content
|
* Display flag: Indicates that the display supports compositing content
|
||||||
* that is stored in protected graphics buffers.
|
* that is stored in protected graphics buffers.
|
||||||
|
|||||||
Reference in New Issue
Block a user