Search in sources :

Example 1 with PhoneWindow

use of com.android.internal.policy.PhoneWindow in project platform_frameworks_base by android.

the class Activity method attach.

final void attach(Context context, ActivityThread aThread, Instrumentation instr, IBinder token, int ident, Application application, Intent intent, ActivityInfo info, CharSequence title, Activity parent, String id, NonConfigurationInstances lastNonConfigurationInstances, Configuration config, String referrer, IVoiceInteractor voiceInteractor, Window window) {
    attachBaseContext(context);
    mFragments.attachHost(null);
    mWindow = new PhoneWindow(this, window);
    mWindow.setWindowControllerCallback(this);
    mWindow.setCallback(this);
    mWindow.setOnWindowDismissedCallback(this);
    mWindow.getLayoutInflater().setPrivateFactory(this);
    if (info.softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
        mWindow.setSoftInputMode(info.softInputMode);
    }
    if (info.uiOptions != 0) {
        mWindow.setUiOptions(info.uiOptions);
    }
    mUiThread = Thread.currentThread();
    mMainThread = aThread;
    mInstrumentation = instr;
    mToken = token;
    mIdent = ident;
    mApplication = application;
    mIntent = intent;
    mReferrer = referrer;
    mComponent = intent.getComponent();
    mActivityInfo = info;
    mTitle = title;
    mParent = parent;
    mEmbeddedID = id;
    mLastNonConfigurationInstances = lastNonConfigurationInstances;
    if (voiceInteractor != null) {
        if (lastNonConfigurationInstances != null) {
            mVoiceInteractor = lastNonConfigurationInstances.voiceInteractor;
        } else {
            mVoiceInteractor = new VoiceInteractor(voiceInteractor, this, this, Looper.myLooper());
        }
    }
    mWindow.setWindowManager((WindowManager) context.getSystemService(Context.WINDOW_SERVICE), mToken, mComponent.flattenToString(), (info.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0);
    if (mParent != null) {
        mWindow.setContainer(mParent.getWindow());
    }
    mWindowManager = mWindow.getWindowManager();
    mCurrentConfig = config;
}
Also used : IVoiceInteractor(com.android.internal.app.IVoiceInteractor) PhoneWindow(com.android.internal.policy.PhoneWindow)

Example 2 with PhoneWindow

use of com.android.internal.policy.PhoneWindow in project android_frameworks_base by DirtyUnicorns.

the class PhoneWindowManager method addStartingWindow.

/** {@inheritDoc} */
@Override
public View addStartingWindow(IBinder appToken, String packageName, int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags, Configuration overrideConfig) {
    if (!SHOW_STARTING_ANIMATIONS) {
        return null;
    }
    if (packageName == null) {
        return null;
    }
    WindowManager wm = null;
    View view = null;
    try {
        Context context = mContext;
        if (DEBUG_STARTING_WINDOW)
            Slog.d(TAG, "addStartingWindow " + packageName + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" + Integer.toHexString(theme));
        if (theme != context.getThemeResId() || labelRes != 0) {
            try {
                context = context.createPackageContext(packageName, 0);
                context.setTheme(theme);
            } catch (PackageManager.NameNotFoundException e) {
            // Ignore
            }
        }
        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) {
                // 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);
        CharSequence label = context.getResources().getText(labelRes, null);
        // Only change the accessibility title if the label is localized
        if (label != null) {
            win.setTitle(label, true);
        } else {
            win.setTitle(nonLocalizedLabel, false);
        }
        win.setType(WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
        synchronized (mWindowManagerFuncs.getWindowManagerLock()) {
            // secret information.
            if (mKeyguardHidden) {
                windowFlags |= FLAG_SHOW_WHEN_LOCKED;
            }
        }
        // Force the window flags: this is a fake window, so it is not really
        // touchable or focusable by the user.  We also add in the ALT_FOCUSABLE_IM
        // flag because we do know that the next window will take input
        // focus, so we want to get the IME window up on top of us right away.
        win.setFlags(windowFlags | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, windowFlags | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        win.setDefaultIcon(icon);
        win.setDefaultLogo(logo);
        win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
        final WindowManager.LayoutParams params = win.getAttributes();
        params.token = appToken;
        params.packageName = packageName;
        params.windowAnimations = win.getWindowStyle().getResourceId(com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
        params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED;
        params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
        if (!compatInfo.supportsScreen()) {
            params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
        }
        params.setTitle("Starting " + packageName);
        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));
        wm.addView(view, params);
        // window manager... which we can tell by it having a parent.
        return view.getParent() != null ? view : null;
    } catch (WindowManager.BadTokenException e) {
        // ignore
        Log.w(TAG, appToken + " already running, starting window not displayed. " + e.getMessage());
    } catch (RuntimeException e) {
        // don't crash if something else bad happens, for example a
        // failure loading resources because we are loading from an app
        // on external storage that has been unmounted.
        Log.w(TAG, appToken + " failed creating starting window", e);
    } finally {
        if (view != null && view.getParent() == null) {
            Log.w(TAG, "view not successfully added to wm, removing view");
            wm.removeViewImmediate(view);
        }
    }
    return null;
}
Also used : Context(android.content.Context) PackageManager(android.content.pm.PackageManager) TypedArray(android.content.res.TypedArray) LayoutParams(android.view.WindowManager.LayoutParams) PointerLocationView(com.android.internal.widget.PointerLocationView) View(android.view.View) IWindowManager(android.view.IWindowManager) WindowManager(android.view.WindowManager) PhoneWindow(com.android.internal.policy.PhoneWindow)

Example 3 with PhoneWindow

use of com.android.internal.policy.PhoneWindow in project android_frameworks_base by AOSPA.

the class DreamService method attach.

/**
     * Called when the Dream is ready to be shown.
     *
     * Must run on mHandler.
     *
     * @param windowToken A window token that will allow a window to be created in the correct layer.
     * @param started A callback that will be invoked once onDreamingStarted has completed.
     */
private final void attach(IBinder windowToken, boolean canDoze, IRemoteCallback started) {
    if (mWindowToken != null) {
        Slog.e(TAG, "attach() called when already attached with token=" + mWindowToken);
        return;
    }
    if (mFinished || mWaking) {
        Slog.w(TAG, "attach() called after dream already finished");
        try {
            mSandman.finishSelf(windowToken, true);
        } catch (RemoteException ex) {
        // system server died
        }
        return;
    }
    mWindowToken = windowToken;
    mCanDoze = canDoze;
    if (mWindowless && !mCanDoze) {
        throw new IllegalStateException("Only doze dreams can be windowless");
    }
    if (!mWindowless) {
        mWindow = new PhoneWindow(this);
        mWindow.setCallback(this);
        mWindow.requestFeature(Window.FEATURE_NO_TITLE);
        mWindow.setBackgroundDrawable(new ColorDrawable(0xFF000000));
        mWindow.setFormat(PixelFormat.OPAQUE);
        if (mDebug)
            Slog.v(TAG, String.format("Attaching window token: %s to window of type %s", windowToken, WindowManager.LayoutParams.TYPE_DREAM));
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        lp.type = WindowManager.LayoutParams.TYPE_DREAM;
        lp.token = windowToken;
        lp.windowAnimations = com.android.internal.R.style.Animation_Dream;
        lp.flags |= (WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON | (mFullscreen ? WindowManager.LayoutParams.FLAG_FULLSCREEN : 0) | (mScreenBright ? WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON : 0));
        mWindow.setAttributes(lp);
        // Workaround: Currently low-profile and in-window system bar backgrounds don't go
        // along well. Dreams usually don't need such bars anyways, so disable them by default.
        mWindow.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        mWindow.setWindowManager(null, windowToken, "dream", true);
        applySystemUiVisibilityFlags((mLowProfile ? View.SYSTEM_UI_FLAG_LOW_PROFILE : 0), View.SYSTEM_UI_FLAG_LOW_PROFILE);
        try {
            getWindowManager().addView(mWindow.getDecorView(), mWindow.getAttributes());
        } catch (WindowManager.BadTokenException ex) {
            // This can happen because the dream manager service will remove the token
            // immediately without necessarily waiting for the dream to start.
            // We should receive a finish message soon.
            Slog.i(TAG, "attach() called after window token already removed, dream will " + "finish soon");
            mWindow = null;
            return;
        }
    }
    // We need to defer calling onDreamingStarted until after onWindowAttached,
    // which is posted to the handler by addView, so we post onDreamingStarted
    // to the handler also.  Need to watch out here in case detach occurs before
    // this callback is invoked.
    mHandler.post(new Runnable() {

        @Override
        public void run() {
            if (mWindow != null || mWindowless) {
                if (mDebug)
                    Slog.v(TAG, "Calling onDreamingStarted()");
                mStarted = true;
                try {
                    onDreamingStarted();
                } finally {
                    try {
                        started.sendResult(null);
                    } catch (RemoteException e) {
                        throw e.rethrowFromSystemServer();
                    }
                }
            }
        }
    });
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) LayoutParams(android.view.WindowManager.LayoutParams) RemoteException(android.os.RemoteException) PhoneWindow(com.android.internal.policy.PhoneWindow) WindowManager(android.view.WindowManager)

Example 4 with PhoneWindow

use of com.android.internal.policy.PhoneWindow in project android_frameworks_base by ResurrectionRemix.

the class PhoneWindowManager method addStartingWindow.

/** {@inheritDoc} */
@Override
public View addStartingWindow(IBinder appToken, String packageName, int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags, Configuration overrideConfig) {
    if (!SHOW_STARTING_ANIMATIONS) {
        return null;
    }
    if (packageName == null) {
        return null;
    }
    WindowManager wm = null;
    View view = null;
    try {
        Context context = mContext;
        if (DEBUG_STARTING_WINDOW)
            Slog.d(TAG, "addStartingWindow " + packageName + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" + Integer.toHexString(theme));
        if (theme != context.getThemeResId() || labelRes != 0) {
            try {
                context = context.createPackageContext(packageName, 0);
                context.setTheme(theme);
            } catch (PackageManager.NameNotFoundException e) {
            // Ignore
            }
        }
        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) {
                // 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);
        CharSequence label = context.getResources().getText(labelRes, null);
        // Only change the accessibility title if the label is localized
        if (label != null) {
            win.setTitle(label, true);
        } else {
            win.setTitle(nonLocalizedLabel, false);
        }
        win.setType(WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
        synchronized (mWindowManagerFuncs.getWindowManagerLock()) {
            // secret information.
            if (mKeyguardHidden) {
                windowFlags |= FLAG_SHOW_WHEN_LOCKED;
            }
        }
        // Force the window flags: this is a fake window, so it is not really
        // touchable or focusable by the user.  We also add in the ALT_FOCUSABLE_IM
        // flag because we do know that the next window will take input
        // focus, so we want to get the IME window up on top of us right away.
        win.setFlags(windowFlags | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, windowFlags | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        win.setDefaultIcon(icon);
        win.setDefaultLogo(logo);
        win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
        final WindowManager.LayoutParams params = win.getAttributes();
        params.token = appToken;
        params.packageName = packageName;
        params.windowAnimations = win.getWindowStyle().getResourceId(com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
        params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED;
        params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
        if (!compatInfo.supportsScreen()) {
            params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
        }
        params.setTitle("Starting " + packageName);
        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));
        wm.addView(view, params);
        // window manager... which we can tell by it having a parent.
        return view.getParent() != null ? view : null;
    } catch (WindowManager.BadTokenException e) {
        // ignore
        Log.w(TAG, appToken + " already running, starting window not displayed. " + e.getMessage());
    } catch (RuntimeException e) {
        // don't crash if something else bad happens, for example a
        // failure loading resources because we are loading from an app
        // on external storage that has been unmounted.
        Log.w(TAG, appToken + " failed creating starting window", e);
    } finally {
        if (view != null && view.getParent() == null) {
            Log.w(TAG, "view not successfully added to wm, removing view");
            wm.removeViewImmediate(view);
        }
    }
    return null;
}
Also used : Context(android.content.Context) PackageManager(android.content.pm.PackageManager) TypedArray(android.content.res.TypedArray) LayoutParams(android.view.WindowManager.LayoutParams) PointerLocationView(com.android.internal.widget.PointerLocationView) View(android.view.View) IWindowManager(android.view.IWindowManager) WindowManager(android.view.WindowManager) PhoneWindow(com.android.internal.policy.PhoneWindow)

Example 5 with PhoneWindow

use of com.android.internal.policy.PhoneWindow in project android_frameworks_base by ResurrectionRemix.

the class Activity method attach.

final void attach(Context context, ActivityThread aThread, Instrumentation instr, IBinder token, int ident, Application application, Intent intent, ActivityInfo info, CharSequence title, Activity parent, String id, NonConfigurationInstances lastNonConfigurationInstances, Configuration config, String referrer, IVoiceInteractor voiceInteractor, Window window) {
    attachBaseContext(context);
    mFragments.attachHost(null);
    mWindow = new PhoneWindow(this, window);
    mWindow.setWindowControllerCallback(this);
    mWindow.setCallback(this);
    mWindow.setOnWindowDismissedCallback(this);
    mWindow.getLayoutInflater().setPrivateFactory(this);
    if (info.softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
        mWindow.setSoftInputMode(info.softInputMode);
    }
    if (info.uiOptions != 0) {
        mWindow.setUiOptions(info.uiOptions);
    }
    mUiThread = Thread.currentThread();
    mMainThread = aThread;
    mInstrumentation = instr;
    mToken = token;
    mIdent = ident;
    mApplication = application;
    mIntent = intent;
    mReferrer = referrer;
    mComponent = intent.getComponent();
    mActivityInfo = info;
    mTitle = title;
    mParent = parent;
    mEmbeddedID = id;
    mLastNonConfigurationInstances = lastNonConfigurationInstances;
    if (voiceInteractor != null) {
        if (lastNonConfigurationInstances != null) {
            mVoiceInteractor = lastNonConfigurationInstances.voiceInteractor;
        } else {
            mVoiceInteractor = new VoiceInteractor(voiceInteractor, this, this, Looper.myLooper());
        }
    }
    mWindow.setWindowManager((WindowManager) context.getSystemService(Context.WINDOW_SERVICE), mToken, mComponent.flattenToString(), (info.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0);
    if (mParent != null) {
        mWindow.setContainer(mParent.getWindow());
    }
    mWindowManager = mWindow.getWindowManager();
    mCurrentConfig = config;
}
Also used : IVoiceInteractor(com.android.internal.app.IVoiceInteractor) PhoneWindow(com.android.internal.policy.PhoneWindow)

Aggregations

PhoneWindow (com.android.internal.policy.PhoneWindow)18 WindowManager (android.view.WindowManager)8 LayoutParams (android.view.WindowManager.LayoutParams)8 ColorDrawable (android.graphics.drawable.ColorDrawable)5 RemoteException (android.os.RemoteException)5 IVoiceInteractor (com.android.internal.app.IVoiceInteractor)5 Context (android.content.Context)3 PackageManager (android.content.pm.PackageManager)3 TypedArray (android.content.res.TypedArray)3 IWindowManager (android.view.IWindowManager)3 View (android.view.View)3 PointerLocationView (com.android.internal.widget.PointerLocationView)3