|
65 | 65 | import android.os.ServiceManager; |
66 | 66 | import android.os.StrictMode; |
67 | 67 | import android.os.SystemClock; |
| 68 | +import android.os.SystemProperties; |
68 | 69 | import android.os.Trace; |
69 | 70 | import android.os.UserHandle; |
70 | 71 | import android.util.AndroidRuntimeException; |
@@ -2114,9 +2115,7 @@ private Activity performLaunchActivity(ActivityClientRecord r, Intent customInte |
2114 | 2115 | + ", dir=" + r.packageInfo.getAppDir()); |
2115 | 2116 |
|
2116 | 2117 | 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); |
2120 | 2119 | CharSequence title = r.activityInfo.loadLabel(appContext.getPackageManager()); |
2121 | 2120 | Configuration config = new Configuration(mCompatConfiguration); |
2122 | 2121 | if (DEBUG_CONFIGURATION) Slog.v(TAG, "Launching activity " |
@@ -2181,6 +2180,31 @@ private Activity performLaunchActivity(ActivityClientRecord r, Intent customInte |
2181 | 2180 | return activity; |
2182 | 2181 | } |
2183 | 2182 |
|
| 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 | + |
2184 | 2208 | private void handleLaunchActivity(ActivityClientRecord r, Intent customIntent) { |
2185 | 2209 | // If we are getting ready to gc after going to the background, well |
2186 | 2210 | // we are back active so skip it. |
|
0 commit comments