Merge "Add Context.getDisplayId() to avoid possible IPC"
This commit is contained in:
committed by
Android (Google) Code Review
commit
02f2a315d7
@@ -5054,7 +5054,7 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
private void performConfigurationChangedForActivity(ActivityClientRecord r,
|
||||
Configuration newBaseConfig) {
|
||||
performConfigurationChangedForActivity(r, newBaseConfig,
|
||||
r.activity.getDisplay().getDisplayId(), false /* movedToDifferentDisplay */);
|
||||
r.activity.getDisplayId(), false /* movedToDifferentDisplay */);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5406,7 +5406,7 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
return;
|
||||
}
|
||||
final boolean movedToDifferentDisplay = displayId != INVALID_DISPLAY
|
||||
&& displayId != r.activity.getDisplay().getDisplayId();
|
||||
&& displayId != r.activity.getDisplayId();
|
||||
|
||||
// Perform updates.
|
||||
r.overrideConfig = overrideConfig;
|
||||
|
||||
@@ -2088,8 +2088,7 @@ class ContextImpl extends Context {
|
||||
ContextImpl c = new ContextImpl(this, mMainThread, pi, null, mActivityToken,
|
||||
new UserHandle(UserHandle.getUserId(application.uid)), flags, null);
|
||||
|
||||
final int displayId = mDisplay != null
|
||||
? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
|
||||
final int displayId = getDisplayId();
|
||||
|
||||
c.setResources(createResources(mActivityToken, pi, null, displayId, null,
|
||||
getDisplayAdjustments(displayId).getCompatibilityInfo()));
|
||||
@@ -2124,8 +2123,7 @@ class ContextImpl extends Context {
|
||||
ContextImpl c = new ContextImpl(this, mMainThread, pi, null, mActivityToken, user,
|
||||
flags, null);
|
||||
|
||||
final int displayId = mDisplay != null
|
||||
? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
|
||||
final int displayId = getDisplayId();
|
||||
|
||||
c.setResources(createResources(mActivityToken, pi, null, displayId, null,
|
||||
getDisplayAdjustments(displayId).getCompatibilityInfo()));
|
||||
@@ -2152,8 +2150,7 @@ class ContextImpl extends Context {
|
||||
final ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, splitName,
|
||||
mActivityToken, mUser, mFlags, classLoader);
|
||||
|
||||
final int displayId = mDisplay != null
|
||||
? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
|
||||
final int displayId = getDisplayId();
|
||||
|
||||
context.setResources(ResourcesManager.getInstance().getResources(
|
||||
mActivityToken,
|
||||
@@ -2177,7 +2174,7 @@ class ContextImpl extends Context {
|
||||
ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, mSplitName,
|
||||
mActivityToken, mUser, mFlags, mClassLoader);
|
||||
|
||||
final int displayId = mDisplay != null ? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
|
||||
final int displayId = getDisplayId();
|
||||
context.setResources(createResources(mActivityToken, mPackageInfo, mSplitName, displayId,
|
||||
overrideConfiguration, getDisplayAdjustments(displayId).getCompatibilityInfo()));
|
||||
return context;
|
||||
@@ -2249,6 +2246,11 @@ class ContextImpl extends Context {
|
||||
return mDisplay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayId() {
|
||||
return mDisplay != null ? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDisplay(int displayId) {
|
||||
mDisplay = mResourcesManager.getAdjustedDisplay(displayId, mResources);
|
||||
|
||||
@@ -4981,6 +4981,14 @@ public abstract class Context {
|
||||
@UnsupportedAppUsage
|
||||
public abstract Display getDisplay();
|
||||
|
||||
/**
|
||||
* Gets the display ID.
|
||||
*
|
||||
* @return display ID associated with this {@link Context}.
|
||||
* @hide
|
||||
*/
|
||||
public abstract int getDisplayId();
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
|
||||
@@ -917,6 +917,14 @@ public class ContextWrapper extends Context {
|
||||
return mBase.getDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public int getDisplayId() {
|
||||
return mBase.getDisplayId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
|
||||
@@ -397,7 +397,7 @@ public final class DisplayManager {
|
||||
if (display == null) {
|
||||
// TODO: We cannot currently provide any override configurations for metrics on displays
|
||||
// other than the display the context is associated with.
|
||||
final Context context = mContext.getDisplay().getDisplayId() == displayId
|
||||
final Context context = mContext.getDisplayId() == displayId
|
||||
? mContext : mContext.getApplicationContext();
|
||||
|
||||
display = mGlobal.getCompatibleDisplay(displayId, context.getResources());
|
||||
|
||||
@@ -137,7 +137,7 @@ public class Toast {
|
||||
String pkg = mContext.getOpPackageName();
|
||||
TN tn = mTN;
|
||||
tn.mNextView = mNextView;
|
||||
final int displayId = mContext.getDisplay().getDisplayId();
|
||||
final int displayId = mContext.getDisplayId();
|
||||
|
||||
try {
|
||||
service.enqueueToast(pkg, tn, mDuration, displayId);
|
||||
|
||||
Reference in New Issue
Block a user