FileDocCategorySizeDatePackage
MidWindowManager.javaAPI DocAndroid 1.5 API39663Wed May 06 22:42:06 BST 2009com.android.internal.policy.impl

MidWindowManager

public class MidWindowManager extends Object implements android.view.WindowManagerPolicy
WindowManagerPolicy implementation for the Android MID UI.

Fields Summary
private static final String
TAG
private static final boolean
DEBUG
private static final boolean
localLOGV
private static final boolean
SHOW_STARTING_ANIMATIONS
private static final int
APPLICATION_LAYER
private static final int
PHONE_LAYER
private static final int
SEARCH_BAR_LAYER
private static final int
STATUS_BAR_PANEL_LAYER
private static final int
TOAST_LAYER
private static final int
STATUS_BAR_LAYER
private static final int
PRIORITY_PHONE_LAYER
private static final int
SYSTEM_ALERT_LAYER
private static final int
SYSTEM_ERROR_LAYER
private static final int
KEYGUARD_LAYER
private static final int
KEYGUARD_DIALOG_LAYER
private static final int
SYSTEM_OVERLAY_LAYER
private static final int
APPLICATION_PANEL_SUBLAYER
private static final int
APPLICATION_MEDIA_SUBLAYER
private static final int
APPLICATION_SUB_PANEL_SUBLAYER
private static final boolean
SINGLE_PRESS_OFF
private static final float
SLIDE_TOUCH_EVENT_SIZE_LIMIT
public static final String
SYSTEM_DIALOG_REASON_KEY
public static final String
SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS
public static final String
SYSTEM_DIALOG_REASON_RECENT_APPS
private android.content.Context
mContext
private android.view.IWindowManager
mWindowManager
private android.os.LocalPowerManager
mPowerManager
boolean
mSafeMode
private android.view.WindowManagerPolicy.WindowState
mStatusBar
private android.view.WindowManagerPolicy.WindowState
mSearchBar
private android.view.WindowManagerPolicy.WindowState
mKeyguard
private boolean
mFirstConnect
private GlobalActions
mGlobalActions
private boolean
mShouldTurnOffOnKeyUp
private RecentApplicationsDialog
mRecentAppsDialog
private android.os.Handler
mHandler
private boolean
mLidOpen
private boolean
mScreenOn
private int
mCurrentAppOrientation
private int
mW
private int
mH
private int
mCurLeft
private int
mCurTop
private int
mCurRight
private int
mCurBottom
static final android.graphics.Rect
mTmpParentFrame
static final android.graphics.Rect
mTmpDisplayFrame
static final android.graphics.Rect
mTmpVisibleFrame
private android.view.WindowManagerPolicy.WindowState
mTopFullscreenOpaqueWindowState
private boolean
mForceStatusBar
private boolean
mHomePressed
private android.content.Intent
mHomeIntent
private boolean
mSearchKeyPressed
private boolean
mConsumeSearchKeyUp
private static final int
ENDCALL_HOME
private static final int
ENDCALL_SLEEPS
private static final int
DEFAULT_ENDCALL_BEHAVIOR
private int
mEndcallBehavior
private ShortcutManager
mShortcutManager
private PowerManager.WakeLock
mBroadcastWakeLock
private Runnable
mEndCallLongPress
private Runnable
mHomeLongPress
When a home-key longpress expires, close other system windows and launch the recent apps
private static final boolean
PRINT_ANIM
private android.content.BroadcastReceiver
mBroadcastDone
Constructors Summary
Methods Summary
public android.view.ViewaddStartingWindow(android.os.IBinder appToken, java.lang.String packageName, int theme, java.lang.CharSequence nonLocalizedLabel, int labelRes, int icon)
{@inheritDoc}

        if (!SHOW_STARTING_ANIMATIONS) {
            return null;
        }
        if (packageName == null) {
            return null;
        }
        
    	Context context = mContext;
    	boolean setTheme = false;
    	//Log.i(TAG, "addStartingWindow " + packageName + ": nonLocalizedLabel="
    	//        + nonLocalizedLabel + " theme=" + Integer.toHexString(theme));
    	if (theme != 0 || labelRes != 0) {
    	    try {
    	        context = context.createPackageContext(packageName, 0);
    	        if (theme != 0) {
    	            context.setTheme(theme);
    	            setTheme = true;
    	        }
    	    } catch (PackageManager.NameNotFoundException e) {
    	    }
    	}
    	if (!setTheme) {
    	    context.setTheme(com.android.internal.R.style.Theme);
    	}
    	
        Window win = PolicyManager.makeNewWindow(context);
        Resources r = context.getResources();
        win.setTitle(r.getText(labelRes, nonLocalizedLabel));

        win.setType(
            WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
        win.setFlags(
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE|
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE|
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);

        win.setLayout(WindowManager.LayoutParams.FILL_PARENT,
                            WindowManager.LayoutParams.FILL_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.setTitle("Starting " + packageName);

        try {
            WindowManagerImpl wm = (WindowManagerImpl)
                    context.getSystemService(Context.WINDOW_SERVICE);
            View view = win.getDecorView();

            if (win.isFloating()) {
                // Whoops, there is no way to display an animation/preview
                // of such a thing!  After all that work...  let's skip it.
                // (Note that we must do this here because it is in
                // getDecorView() where the theme is evaluated...  maybe
                // we should peek the floating attribute from the theme
                // earlier.)
                return null;
            }
            
            if (localLOGV) Log.v(
                TAG, "Adding starting window for " + packageName
                + " / " + appToken + ": "
                + (view.getParent() != null ? view : null));

            wm.addView(view, params);

            // Only return the view if it was successfully added to the
            // window manager... which we can tell by it having a parent.
            return view.getParent() != null ? view : null;
        } catch (WindowManagerImpl.BadTokenException e) {
            // ignore
            Log.w(TAG, appToken + " already running, starting window not displayed");
        }

        return null;
    
public voidadjustConfigurationLw(android.content.res.Configuration config)
{@inheritDoc}

        mPowerManager.setKeyboardVisibility(true);
        config.keyboardHidden = Configuration.KEYBOARDHIDDEN_NO;
        mPowerManager.userActivity(SystemClock.uptimeMillis(), false,
                LocalPowerManager.OTHER_EVENT);
    
public voidadjustWindowParamsLw(WindowManager.LayoutParams attrs)

        switch (attrs.type) {
            case TYPE_SYSTEM_OVERLAY:
            case TYPE_TOAST:
                // These types of windows can't receive input events.
                attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
                break;
        }
    
public voidanimatingWindowLw(android.view.WindowManagerPolicy.WindowState win, WindowManager.LayoutParams attrs)
{@inheritDoc}

        if (mTopFullscreenOpaqueWindowState == null
            && attrs.type >= FIRST_APPLICATION_WINDOW
            && attrs.type <= LAST_APPLICATION_WINDOW
            && win.fillsScreenLw(mW, mH, true, false)
            && win.isDisplayedLw()) {
            mTopFullscreenOpaqueWindowState = win;
        } else if ((attrs.flags & FLAG_FORCE_NOT_FULLSCREEN) != 0) {
            mForceStatusBar = true;
        }
    
public voidbeginAnimationLw(int displayWidth, int displayHeight)
{@inheritDoc}

        mTopFullscreenOpaqueWindowState = null;
        mForceStatusBar = false;
    
public voidbeginLayoutLw(int displayWidth, int displayHeight)
{@inheritDoc}

        mW = displayWidth;
        mH = displayHeight;
        mCurLeft = 0;
        mCurTop = 0;
        mCurRight = displayWidth;
        mCurBottom = displayHeight;

        // decide where the status bar goes ahead of time
        if (mStatusBar != null) {
            final Rect pf = mTmpParentFrame;
            final Rect df = mTmpDisplayFrame;
            final Rect vf = mTmpVisibleFrame;
            pf.left = df.left = vf.left = 0;
            pf.top = df.top = vf.top = 0;
            pf.right = df.right = vf.right = displayWidth;
            pf.bottom = df.bottom = vf.bottom = displayHeight;
            
            mStatusBar.computeFrameLw(pf, df, vf, vf);
            mCurTop = mStatusBar.getFrameLw().bottom;
        }
    
public intcheckAddPermission(WindowManager.LayoutParams attrs)
{@inheritDoc}

        int type = attrs.type;
        if (type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW
                || type > WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) {
            return WindowManagerImpl.ADD_OKAY;
        }
        String permission = null;
        switch (type) {
            case TYPE_TOAST:
                // XXX right now the app process has complete control over
                // this...  should introduce a token to let the system
                // monitor/control what they are doing.
                break;
            case TYPE_PHONE:
            case TYPE_PRIORITY_PHONE:
            case TYPE_SYSTEM_ALERT:
            case TYPE_SYSTEM_ERROR:
            case TYPE_SYSTEM_OVERLAY:
                permission = android.Manifest.permission.SYSTEM_ALERT_WINDOW;
                break;
            default:
                permission = android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;
        }
        if (permission != null) {
            if (mContext.checkCallingOrSelfPermission(permission)
                    != PackageManager.PERMISSION_GRANTED) {
                return WindowManagerImpl.ADD_PERMISSION_DENIED;
            }
        }
        return WindowManagerImpl.ADD_OKAY;
    
public booleandetectSafeMode()

        try {
            int menuState = mWindowManager.getKeycodeState(KeyEvent.KEYCODE_MENU);
            mSafeMode = menuState > 0;
            Log.i(TAG, "Menu key state: " + menuState + " safeMode=" + mSafeMode);
            return mSafeMode;
        } catch (RemoteException e) {
            // Doom! (it's also local)
            throw new RuntimeException("window manager dead");
        }
    
public voidenableKeyguard(boolean enabled)
{@inheritDoc}

    
public voidenableScreenAfterBoot()
{@inheritDoc}

        updateRotation();
    
public voidexitKeyguardSecurely(OnKeyguardExitResult callback)
{@inheritDoc}

    
public booleanfinishAnimationLw()
{@inheritDoc}

        if (mStatusBar != null) {
            if (mForceStatusBar) {
                mStatusBar.showLw(true);
            } else if (mTopFullscreenOpaqueWindowState != null) {
               WindowManager.LayoutParams lp =
                   mTopFullscreenOpaqueWindowState.getAttrs();
               boolean hideStatusBar =
                   (lp.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0;
               if (hideStatusBar) {
                   mStatusBar.hideLw(true);
               } else {
                   mStatusBar.showLw(true);
               }
           }
        }
       return false;
    
public booleanfinishLayoutLw()
{@inheritDoc}

        return false;
    
private static android.media.IAudioServicegetAudioInterface()

        return IAudioService.Stub.asInterface(ServiceManager.checkService(Context.AUDIO_SERVICE));
    
public voidgetContentInsetHintLw(WindowManager.LayoutParams attrs, android.graphics.Rect coveredInset)

        final int fl = attrs.flags;
        
        if ((fl &
                (FLAG_LAYOUT_IN_SCREEN | FLAG_FULLSCREEN | FLAG_LAYOUT_INSET_DECOR))
                == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) {
            coveredInset.set(mCurLeft, mCurTop, mW - mCurRight, mH - mCurBottom);
        } else {
            coveredInset.setEmpty();
        }
    
booleangoHome()
goes to the home screen

return
whether it did anything

        if (false) {
            // This code always brings home to the front.
            mContext.startActivity(mHomeIntent);
        } else {
            // This code brings home to the front or, if it is already
            // at the front, puts the device to sleep.
            try {
                int result = ActivityManagerNative.getDefault()
                        .startActivity(null, mHomeIntent,
                                mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
                                null, 0, null, null, 0, true /* onlyIfNeeded*/, false);
                if (result == IActivityManager.START_RETURN_INTENT_TO_CALLER) {
                    return false;
                }
            } catch (RemoteException ex) {
                // bummer, the activity manager, which is in this process, is dead
            }
        }
        sendCloseSystemWindows();
        return true;
    
public booleaninKeyguardRestrictedKeyInputMode()
{@inheritDoc}

        return false;
    
public voidinit(android.content.Context context, android.view.IWindowManager windowManager, android.os.LocalPowerManager powerManager)
{@inheritDoc}

        mContext = context;
        mWindowManager = windowManager;
        mPowerManager = powerManager;
        mHandler = new Handler();
        mShortcutManager = new ShortcutManager(context, mHandler);
        mShortcutManager.observe();
        mHomeIntent =  new Intent(Intent.ACTION_MAIN, null);
        mHomeIntent.addCategory(Intent.CATEGORY_HOME);
        mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
        mBroadcastWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
                "MidWindowManager.mBroadcastWakeLock");
    
public booleaninterceptKeyTi(android.view.WindowManagerPolicy.WindowState win, int code, int metaKeys, boolean down, int repeatCount)
{@inheritDoc}

        if (false) {
            Log.d(TAG, "interceptKeyTi code=" + code + " down=" + down + " repeatCount="
                    + repeatCount);
        }

        // Clear a pending HOME longpress if the user releases Home
        // TODO: This could probably be inside the next bit of logic, but that code
        // turned out to be a bit fragile so I'm doing it here explicitly, for now.
        if ((code == KeyEvent.KEYCODE_HOME) && !down) {
            mHandler.removeCallbacks(mHomeLongPress);
        }

        // If the HOME button is currently being held, then we do special
        // chording with it.
        if (mHomePressed) {
            
            // If we have released the home key, and didn't do anything else
            // while it was pressed, then it is time to go home!
            if (code == KeyEvent.KEYCODE_HOME) {
                if (!down) {
                    mHomePressed = false;
                    launchHomeFromHotKey();
                }
            }
            
            return true;
        }
            
        // First we always handle the home key here, so applications
        // can never break it, although if keyguard is on, we do let
        // it handle it, because that gives us the correct 5 second
        // timeout.
        if (code == KeyEvent.KEYCODE_HOME) {

            // If a system window has focus, then it doesn't make sense
            // right now to interact with applications.
            WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null;
            if (attrs != null) {
                int type = attrs.type;
                if (type >= WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW
                        && type <= WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) {
                    // Only do this once, so home-key-longpress doesn't close itself
                    if (repeatCount == 0 && down) {
                		sendCloseSystemWindows();
                    }
                    return false;
                }
            }
            
            if (down && repeatCount == 0) {
                mHandler.postDelayed(mHomeLongPress, ViewConfiguration.getGlobalActionKeyTimeout());
                mHomePressed = true;
            }
            return true;
        } else if (code == KeyEvent.KEYCODE_MENU) {
            // Hijack modified menu keys for debugging features
            final int chordBug = KeyEvent.META_SHIFT_ON;
            final int chordProcess = KeyEvent.META_ALT_ON;
           
            if (down && repeatCount == 0) {
                if ((metaKeys & chordBug) == chordBug) {
                    Intent intent = new Intent(Intent.ACTION_BUG_REPORT);
                    mContext.sendOrderedBroadcast(intent, null);
                    return true;
                } else if ((metaKeys & chordProcess) == chordProcess) {
                    Intent service = new Intent();
                    service.setClassName(mContext, "com.android.server.LoadAverageService");
                    ContentResolver res = mContext.getContentResolver();
                    boolean shown = Settings.System.getInt(
                            res, Settings.System.SHOW_PROCESSES, 0) != 0;
                    if (!shown) {
                        mContext.startService(service);
                    } else {
                        mContext.stopService(service);
                    }
                    Settings.System.putInt(
                            res, Settings.System.SHOW_PROCESSES, shown ? 0 : 1);
                    return true;
                }
            }
        } else if (code == KeyEvent.KEYCODE_NOTIFICATION) {
            if (down) {
                // this key doesn't exist on current hardware, but if a device
                // didn't have a touchscreen, it would want one of these to open
                // the status bar.
                IStatusBar sbs = IStatusBar.Stub.asInterface(ServiceManager.getService("statusbar"));
                if (sbs != null) {
                    try {
                        sbs.toggle();
                    } catch (RemoteException e) {
                        // we're screwed anyway, since it's in this process
                        throw new RuntimeException(e);
                    }
                }
            }
            return true;
        } else if (code == KeyEvent.KEYCODE_SEARCH) {
            if (down) {
                if (repeatCount == 0) {
                    mSearchKeyPressed = true;
                }
            } else {
                mSearchKeyPressed = false;
                
                if (mConsumeSearchKeyUp) {
                    // Consume the up-event
                    mConsumeSearchKeyUp = false;
                    return true;
                }
            }
        }
        
        // Shortcuts are invoked through Search+key, so intercept those here
        if (mSearchKeyPressed) {
            if (down && repeatCount == 0) {
                Intent shortcutIntent = mShortcutManager.getIntent(code, metaKeys);
                if (shortcutIntent != null) {
                    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    mContext.startActivity(shortcutIntent);
                    
                    /*
                     * We launched an app, so the up-event of the search key
                     * should be consumed
                     */
                    mConsumeSearchKeyUp = true;
                    return true;
                }
            }
        }

        return false;
    
public intinterceptKeyTq(android.view.RawInputEvent event, boolean screenIsOn)
{@inheritDoc}

        int result = ACTION_PASS_TO_USER | ACTION_POKE_USER_ACTIVITY;
        return result;
    
public booleanisAppSwitchKeyTqTiLwLi(int keycode)
{@inheritDoc}

        return keycode == KeyEvent.KEYCODE_HOME
                || keycode == KeyEvent.KEYCODE_ENDCALL;
    
public booleanisCheekPressedAgainstScreen(android.view.MotionEvent ev)

        return false;
    
private booleanisDeviceProvisioned()

        return Settings.System.getInt(
                mContext.getContentResolver(), Settings.System.DEVICE_PROVISIONED, 0) != 0;
    
public booleanisMovementKeyTi(int keycode)
{@inheritDoc}

        switch (keycode) {
            case KeyEvent.KEYCODE_DPAD_UP:
            case KeyEvent.KEYCODE_DPAD_DOWN:
            case KeyEvent.KEYCODE_DPAD_LEFT:
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                return true;
        }
        return false;
    
private booleanisMusicActive()

return
Whether music is being played right now.

        final IAudioService audio = getAudioInterface();
        if (audio == null) {
            Log.w(TAG, "isMusicActive: couldn't get IAudioService reference");
            return false;
        }
        try {
            return audio.isMusicActive();
        } catch (RemoteException e) {
            Log.w(TAG, "IAudioService.isMusicActive() threw RemoteException " + e);
            return false;
        }
    
public booleanisWakeAbsMovementTq(int device, int classes, android.view.RawInputEvent event)
{@inheritDoc}

        // if it's tagged with one of the wake bits, it wakes up the device
        return ((event.flags & (FLAG_WAKE | FLAG_WAKE_DROPPED)) != 0);
    
protected booleanisWakeKeyTq(android.view.RawInputEvent event)
Given the current state of the world, should this key wake up the device?

        // There are not key maps for trackball devices, but we'd still
        // like to have pressing it wake the device up, so force it here.
        int keycode = event.keycode;
        int flags = event.flags;
        if (keycode == RawInputEvent.BTN_MOUSE) {
            flags |= WindowManagerPolicy.FLAG_WAKE;
        }
        return (flags
                & (WindowManagerPolicy.FLAG_WAKE | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0;
    
public booleanisWakeRelMovementTq(int device, int classes, android.view.RawInputEvent event)
{@inheritDoc}

    
      
         
              
        // if it's tagged with one of the wake bits, it wakes up the device
        return ((event.flags & (FLAG_WAKE | FLAG_WAKE_DROPPED)) != 0);
    
public booleankeyguardIsShowingTq()
{@inheritDoc}

        return false;
    
private voidlaunchHomeFromHotKey()
A home key -> launch home action was detected. Take the appropriate action given the situation with the keyguard.

        // no keyguard stuff to worry about, just launch home!
        mContext.startActivity(mHomeIntent);
        sendCloseSystemWindows();
    
public voidlayoutWindowLw(android.view.WindowManagerPolicy.WindowState win, WindowManager.LayoutParams attrs, android.view.WindowManagerPolicy.WindowState attached)
{@inheritDoc}

        // we've already done the status bar
        if (win == mStatusBar) {
            return;
        }

        final int fl = attrs.flags;
        
        final Rect pf = mTmpParentFrame;
        final Rect df = mTmpDisplayFrame;
        final Rect vf = mTmpVisibleFrame;
        
        if ((fl &
                (FLAG_LAYOUT_IN_SCREEN | FLAG_FULLSCREEN | FLAG_LAYOUT_INSET_DECOR))
                == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) {
            df.left = 0;
            df.top = 0;
            df.right = mW;
            df.bottom = mH;
            vf.left = mCurLeft;
            vf.top = mCurTop;
            vf.right = mCurRight;
            vf.bottom = mCurBottom;
        } else if ((fl & FLAG_LAYOUT_IN_SCREEN) == 0) {
            // Make sure this window doesn't intrude into the status bar.
            df.left = vf.left = mCurLeft;
            df.top = vf.top = mCurTop;
            df.right = vf.right = mCurRight;
            df.bottom = vf.bottom = mCurBottom;
        } else {
            df.left = vf.left = 0;
            df.top = vf.top = 0;
            df.right = vf.right = mW;
            df.bottom = vf.bottom = mH;
        }
        
        if (attached != null && (fl & (FLAG_LAYOUT_IN_SCREEN)) == 0) {
            pf.set(attached.getFrameLw());
        } else {
            pf.set(df);
        }
        
        if ((fl & FLAG_LAYOUT_NO_LIMITS) != 0) {
            df.left = df.top = vf.left = vf.top = -10000;
            df.right = df.bottom = vf.right = vf.bottom = 10000;
        }

        win.computeFrameLw(pf, df, vf, vf);
    
public voidonKeyguardShow()
Callback from {@link KeyguardViewMediator}

        sendCloseSystemWindows();
    
public booleanperformHapticFeedbackLw(android.view.WindowManagerPolicy.WindowState win, int effectId, boolean always)

        return false;
    
public intprepareAddWindowLw(android.view.WindowManagerPolicy.WindowState win, WindowManager.LayoutParams attrs)
Preflight adding a window to the system. Currently enforces that three window types are singletons:
  • STATUS_BAR_TYPE
  • SEARCH_BAR_TYPE
  • KEYGUARD_TYPE

param
win The window to be added
param
attrs Information about the window to be added
return
If ok, WindowManagerImpl.ADD_OKAY. If too many singletons, WindowManagerImpl.ADD_MULTIPLE_SINGLETON

        switch (attrs.type) {
            case TYPE_STATUS_BAR:
                if (mStatusBar != null) {
                    return WindowManagerImpl.ADD_MULTIPLE_SINGLETON;
                }
                mStatusBar = win;
                break;
            case TYPE_SEARCH_BAR:
                if (mSearchBar != null) {
                    return WindowManagerImpl.ADD_MULTIPLE_SINGLETON;
                }
                mSearchBar = win;
                break;
            case TYPE_KEYGUARD:
                if (mKeyguard != null) {
                    return WindowManagerImpl.ADD_MULTIPLE_SINGLETON;
                }
                mKeyguard = win;
                break;
        }
        return WindowManagerImpl.ADD_OKAY;
    
public booleanpreprocessInputEventTq(android.view.RawInputEvent event)
{@inheritDoc}

        return false;
    
public voidremoveStartingWindow(android.os.IBinder appToken, android.view.View window)
{@inheritDoc}

        // RuntimeException e = new RuntimeException();
        // Log.i(TAG, "remove " + appToken + " " + window, e);

        if (localLOGV) Log.v(
            TAG, "Removing starting window for " + appToken + ": " + window);

        if (window != null) {
            WindowManagerImpl wm = (WindowManagerImpl) mContext.getSystemService(Context.WINDOW_SERVICE);
            wm.removeView(window);
        }
    
public voidremoveWindowLw(android.view.WindowManagerPolicy.WindowState win)
{@inheritDoc}

        if (mStatusBar == win) {
            mStatusBar = null;
        }
        else if (mSearchBar == win) {
            mSearchBar = null;
        }
        else if (mKeyguard == win) {
            mKeyguard = null;
        }
    
public introtationForOrientationLw(int orientation, int lastRotation, boolean displayEnabled)

        // get rid of rotation for now. Always rotation of 0
        return Surface.ROTATION_0;
    
public voidscreenOnStoppedLw()

    
public voidscreenTurnedOff(int why)
{@inheritDoc}

        EventLog.writeEvent(70000, 0);
        mScreenOn = false;
    
public voidscreenTurnedOn()
{@inheritDoc}

        EventLog.writeEvent(70000, 1);
        mScreenOn = true;
    
public intselectAnimationLw(android.view.WindowManagerPolicy.WindowState win, int transit)
{@inheritDoc}

    
      
          
        if (PRINT_ANIM) Log.i(TAG, "selectAnimation in " + win
              + ": transit=" + transit);
        if (transit == TRANSIT_PREVIEW_DONE) {
            if (win.hasAppShownWindows()) {
                if (PRINT_ANIM) Log.i(TAG, "**** STARTING EXIT");
                return com.android.internal.R.anim.app_starting_exit;
            }
        }

        return 0;
    
private voidsendCloseSystemWindows()

        sendCloseSystemWindows(null);
    
private voidsendCloseSystemWindows(java.lang.String reason)

        Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        if (reason != null) {
            intent.putExtra(SYSTEM_DIALOG_REASON_KEY, reason);
        }
        mContext.sendBroadcast(intent);
    
private voidsendVolToMusic(int keycode)
Tell the audio service to adjust the volume appropriate to the event.

param
keycode

        final IAudioService audio = getAudioInterface();
        if (audio == null) {
            Log.w(TAG, "sendVolToMusic: couldn't get IAudioService reference");
            return;
        }
        try {
            // since audio is playing, we shouldn't have to hold a wake lock
            // during the call, but we do it as a precaution for the rare possibility
            // that the music stops right before we call this
            mBroadcastWakeLock.acquire();
            audio.adjustStreamVolume(
                AudioManager.STREAM_MUSIC,
                keycode == KeyEvent.KEYCODE_VOLUME_UP
                            ? AudioManager.ADJUST_RAISE
                            : AudioManager.ADJUST_LOWER,
                    0);
        } catch (RemoteException e) {
            Log.w(TAG, "IAudioService.adjustStreamVolume() threw RemoteException " + e);
        } finally {
            mBroadcastWakeLock.release();
        }
    
public voidsetCurrentOrientationLw(int newOrientation)

        if(newOrientation != mCurrentAppOrientation) {
            mCurrentAppOrientation = newOrientation;
        }
    
private voidshowGlobalActionsDialog()


       
        if (mGlobalActions == null) {
            mGlobalActions = new GlobalActions(mContext, mPowerManager);
        }
        mGlobalActions.showDialog(false, isDeviceProvisioned());
    
private voidshowRecentAppsDialog()
Create (if necessary) and launch the recent apps dialog


                  
       
        if (mRecentAppsDialog == null) {
            mRecentAppsDialog = new RecentApplicationsDialog(mContext);
        }
        mRecentAppsDialog.show();
    
public intsubWindowTypeToLayerLw(int type)
{@inheritDoc}

        switch (type) {
        case TYPE_APPLICATION_PANEL:
            return APPLICATION_PANEL_SUBLAYER;
        case TYPE_APPLICATION_MEDIA:
            return APPLICATION_MEDIA_SUBLAYER;
        case TYPE_APPLICATION_SUB_PANEL:
            return APPLICATION_SUB_PANEL_SUBLAYER;
        }
        Log.e(TAG, "Unknown sub-window type: " + type);
        return 0;
    
public voidsystemReady()
{@inheritDoc}

        try {
            if (mSafeMode) {
                // If the user is holding the menu key code, then we are
                // going to boot into safe mode.
                ActivityManagerNative.getDefault().enterSafeMode();
            } else {
                // tell the keyguard
                android.os.SystemProperties.set("dev.bootcomplete", "1"); 
            }
        } catch (RemoteException e) {
        }
    
private voidupdateRotation()

        mPowerManager.setKeyboardVisibility(true);
        int rotation = Surface.ROTATION_0;
        try {
            //set orientation on WindowManager
            mWindowManager.setRotation(rotation, true, 0);
        } catch (RemoteException e) {
        }

        mPowerManager.userActivity(SystemClock.uptimeMillis(), false,
                LocalPowerManager.OTHER_EVENT);
    
public intwindowTypeToLayerLw(int type)
{@inheritDoc}

        if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) {
            return APPLICATION_LAYER;
        }
        switch (type) {
        case TYPE_APPLICATION_PANEL:
            return APPLICATION_LAYER;
        case TYPE_APPLICATION_SUB_PANEL:
            return APPLICATION_LAYER;
        case TYPE_STATUS_BAR:
            return STATUS_BAR_LAYER;
        case TYPE_STATUS_BAR_PANEL:
            return STATUS_BAR_PANEL_LAYER;
        case TYPE_SEARCH_BAR:
            return SEARCH_BAR_LAYER;
        case TYPE_PHONE:
            return PHONE_LAYER;
        case TYPE_KEYGUARD:
            return KEYGUARD_LAYER;
        case TYPE_KEYGUARD_DIALOG:
            return KEYGUARD_DIALOG_LAYER;
        case TYPE_SYSTEM_ALERT:
            return SYSTEM_ALERT_LAYER;
        case TYPE_SYSTEM_ERROR:
            return SYSTEM_ERROR_LAYER;
        case TYPE_SYSTEM_OVERLAY:
            return SYSTEM_OVERLAY_LAYER;
        case TYPE_PRIORITY_PHONE:
            return PRIORITY_PHONE_LAYER;
        case TYPE_TOAST:
            return TOAST_LAYER;
        }
        Log.e(TAG, "Unknown window type: " + type);
        return APPLICATION_LAYER;