* @param labelRes The resource ID the application would like to use as its name.
* @param icon The resource ID the application would like to use as its icon.
* @param windowFlags Window layout flags.
+ * @param overrideConfig override configuration to consider when generating
+ * context to for resources.
*
* @return Optionally you can return the View that was used to create the
* window, for easy removal in removeStartingWindow.
*/
public View addStartingWindow(IBinder appToken, String packageName,
int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel,
- int labelRes, int icon, int logo, int windowFlags);
+ int labelRes, int icon, int logo, int windowFlags, Configuration overrideConfig);
/**
* Called when the first window of an application has been displayed, while
import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE;
import static android.content.pm.PackageManager.FEATURE_TELEVISION;
import static android.content.pm.PackageManager.FEATURE_WATCH;
+import static android.content.res.Configuration.EMPTY;
import static android.content.res.Configuration.UI_MODE_TYPE_CAR;
import static android.content.res.Configuration.UI_MODE_TYPE_MASK;
import static android.view.WindowManager.DOCKED_TOP;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.database.ContentObserver;
import android.graphics.PixelFormat;
import android.graphics.Rect;
@Override
public View addStartingWindow(IBinder appToken, String packageName, int theme,
CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes,
- int icon, int logo, int windowFlags) {
+ int icon, int logo, int windowFlags, Configuration overrideConfig) {
if (!SHOW_STARTING_ANIMATIONS) {
return null;
}
}
}
- PhoneWindow win = new PhoneWindow(context);
+ if (overrideConfig != null && overrideConfig != EMPTY) {
+ if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "addStartingWindow: creating context based"
+ + " on overrideConfig" + overrideConfig + " for starting window");
+ final Context overrideContext = context.createConfigurationContext(overrideConfig);
+ overrideContext.setTheme(theme);
+ final TypedArray typedArray = overrideContext.obtainStyledAttributes(
+ com.android.internal.R.styleable.Window);
+ final int resId = typedArray.getResourceId(R.styleable.Window_windowBackground, 0);
+ if (resId != 0 && overrideContext.getDrawable(resId) != null) {
+ // We want to use the windowBackground for the override context if it is
+ // available, otherwise we use the default one to make sure a themed starting
+ // window is displayed for the app.
+ if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "addStartingWindow: apply overrideConfig"
+ + overrideConfig + " to starting window resId=" + resId);
+ context = overrideContext;
+ }
+ }
+
+ final PhoneWindow win = new PhoneWindow(context);
win.setIsStartingWindow(true);
- Resources r = context.getResources();
+ final Resources r = context.getResources();
win.setTitle(r.getText(labelRes, nonLocalizedLabel));
win.setType(
wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
view = win.getDecorView();
- if (DEBUG_STARTING_WINDOW) Slog.d(
- TAG, "Adding starting window for " + packageName
- + " / " + appToken + ": "
- + (view.getParent() != null ? view : null));
+ if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "Adding starting window for "
+ + packageName + " / " + appToken + ": " + (view.getParent() != null ? view : null));
wm.addView(view, params);
View view = null;
try {
- view = mPolicy.addStartingWindow(
- wtoken.token, sd.pkg, sd.theme, sd.compatInfo,
- sd.nonLocalizedLabel, sd.labelRes, sd.icon, sd.logo, sd.windowFlags);
+ final Configuration overrideConfig = wtoken != null && wtoken.mTask != null
+ ? wtoken.mTask.mOverrideConfig : null;
+ view = mPolicy.addStartingWindow(wtoken.token, sd.pkg, sd.theme,
+ sd.compatInfo, sd.nonLocalizedLabel, sd.labelRes, sd.icon, sd.logo,
+ sd.windowFlags, overrideConfig);
} catch (Exception e) {
Slog.w(TAG_WM, "Exception when adding starting window", e);
}