Skip to content

Commit 7a7c6aa

Browse files
author
Jean-Baptiste Queru
committed
Merge into jb-mr1-dev
Change-Id: I821410e9ffcc7148139465c04ef335f0becc18c2
2 parents 641c36f + efd43bd commit 7a7c6aa

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

core/java/android/app/ActivityThread.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import android.os.ServiceManager;
6666
import android.os.StrictMode;
6767
import android.os.SystemClock;
68+
import android.os.SystemProperties;
6869
import android.os.Trace;
6970
import android.os.UserHandle;
7071
import android.util.AndroidRuntimeException;
@@ -2114,9 +2115,7 @@ private Activity performLaunchActivity(ActivityClientRecord r, Intent customInte
21142115
+ ", dir=" + r.packageInfo.getAppDir());
21152116

21162117
if (activity != null) {
2117-
ContextImpl appContext = new ContextImpl();
2118-
appContext.init(r.packageInfo, r.token, this);
2119-
appContext.setOuterContext(activity);
2118+
Context appContext = createBaseContextForActivity(r, activity);
21202119
CharSequence title = r.activityInfo.loadLabel(appContext.getPackageManager());
21212120
Configuration config = new Configuration(mCompatConfiguration);
21222121
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Launching activity "
@@ -2181,6 +2180,31 @@ private Activity performLaunchActivity(ActivityClientRecord r, Intent customInte
21812180
return activity;
21822181
}
21832182

2183+
private Context createBaseContextForActivity(ActivityClientRecord r,
2184+
final Activity activity) {
2185+
ContextImpl appContext = new ContextImpl();
2186+
appContext.init(r.packageInfo, r.token, this);
2187+
appContext.setOuterContext(activity);
2188+
2189+
// For debugging purposes, if the activity's package name contains the value of
2190+
// the "debug.use-second-display" system property as a substring, then show
2191+
// its content on a secondary display if there is one.
2192+
Context baseContext = appContext;
2193+
String pkgName = SystemProperties.get("debug.second-display.pkg");
2194+
if (pkgName != null && !pkgName.isEmpty()
2195+
&& r.packageInfo.mPackageName.contains(pkgName)) {
2196+
DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance();
2197+
for (int displayId : dm.getDisplayIds()) {
2198+
if (displayId != Display.DEFAULT_DISPLAY) {
2199+
Display display = dm.getRealDisplay(displayId);
2200+
baseContext = appContext.createDisplayContext(display);
2201+
break;
2202+
}
2203+
}
2204+
}
2205+
return baseContext;
2206+
}
2207+
21842208
private void handleLaunchActivity(ActivityClientRecord r, Intent customIntent) {
21852209
// If we are getting ready to gc after going to the background, well
21862210
// we are back active so skip it.

0 commit comments

Comments
 (0)