/** Show the keyguard. Will handle creating and attaching to the view manager lazily. */ public synchronized void show() { if (DEBUG) Log.d(TAG, "show(); mKeyguardView==" + mKeyguardView); Resources res = mContext.getResources(); boolean enableScreenRotation = SystemProperties.getBoolean("lockscreen.rot_override", false) || res.getBoolean(R.bool.config_enableLockScreenRotation); enableScreenRotation = Settings.System.getInt( mContext.getContentResolver(), Settings.System.LOCKSCREEN_LANDSCAPE, enableScreenRotation ? 1 : 0) == 1; if (mKeyguardHost == null) { if (DEBUG) Log.d(TAG, "keyguard host is null, creating it..."); mKeyguardHost = new KeyguardViewHost(mContext, mCallback); final int stretch = ViewGroup.LayoutParams.MATCH_PARENT; int flags = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN | WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER | WindowManager.LayoutParams.FLAG_KEEP_SURFACE_WHILE_ANIMATING /*| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR*/ ; if (!mNeedsInput) { flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; } if (ActivityManager.isHighEndGfx( ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay())) { flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; } WindowManager.LayoutParams lp = new WindowManager.LayoutParams( stretch, stretch, WindowManager.LayoutParams.TYPE_KEYGUARD, flags, PixelFormat.TRANSLUCENT); lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; lp.windowAnimations = com.android.internal.R.style.Animation_LockScreen; if (ActivityManager.isHighEndGfx( ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay())) { lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; } lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY; lp.setTitle("Keyguard"); mWindowLayoutParams = lp; mViewManager.addView(mKeyguardHost, lp); } if (enableScreenRotation && Settings.System.getInt( mContext.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 1) == 1) { if (DEBUG) Log.d(TAG, "Rotation sensor for lock screen On!"); mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR; } else { if (DEBUG) Log.d(TAG, "Rotation sensor for lock screen Off!"); mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; } mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); if (mKeyguardView == null) { if (DEBUG) Log.d(TAG, "keyguard view is null, creating it..."); mKeyguardView = mKeyguardViewProperties.createKeyguardView(mContext, mUpdateMonitor, this); mKeyguardView.setId(R.id.lock_screen); mKeyguardView.setCallback(mCallback); final ViewGroup.LayoutParams lp = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mKeyguardHost.addView(mKeyguardView, lp); if (mScreenOn) { mKeyguardView.show(); } } // Disable aspects of the system/status/navigation bars that are not appropriate or // useful for the lockscreen but can be re-shown by dialogs or SHOW_WHEN_LOCKED activities. // Other disabled bits are handled by the KeyguardViewMediator talking directly to the // status bar service. int visFlags = (View.STATUS_BAR_DISABLE_BACK | View.STATUS_BAR_DISABLE_HOME); mKeyguardHost.setSystemUiVisibility(visFlags); mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); mKeyguardHost.setVisibility(View.VISIBLE); mKeyguardView.requestFocus(); }
private void maybeCreateKeyguardLocked( boolean enableScreenRotation, boolean force, Bundle options) { if (mKeyguardHost != null) { mKeyguardHost.saveHierarchyState(mStateContainer); } if (mKeyguardHost == null) { if (DEBUG) Log.d(TAG, "keyguard host is null, creating it..."); mKeyguardHost = new ViewManagerHost(mContext); int flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN | WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; if (!mNeedsInput) { flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; } final int stretch = ViewGroup.LayoutParams.MATCH_PARENT; final int type = WindowManager.LayoutParams.TYPE_KEYGUARD; WindowManager.LayoutParams lp = new WindowManager.LayoutParams(stretch, stretch, type, flags, PixelFormat.TRANSLUCENT); lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; lp.windowAnimations = R.style.Animation_LockScreen; lp.screenOrientation = enableScreenRotation ? ActivityInfo.SCREEN_ORIENTATION_USER : ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; if (ActivityManager.isHighEndGfx()) { lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; } lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY; /// M: Poke user activity when operating Keyguard // lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY; lp.setTitle("Keyguard"); mWindowLayoutParams = lp; /// M: skip add KeyguardHost into viewManager in AT case if (!KeyguardViewMediator.isKeyguardInActivity) { mViewManager.addView(mKeyguardHost, lp); } else { if (DEBUG) Log.d(TAG, "skip add mKeyguardHost into mViewManager for testing"); } KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mBackgroundChanger); } /// M: If force and keyguardView is not null, we should relase memory hold by old keyguardview if (force && mKeyguardView != null) { mKeyguardView.cleanUp(); } if (force || mKeyguardView == null) { mKeyguardHost.setCustomBackground(null); mKeyguardHost.removeAllViews(); inflateKeyguardView(options); mKeyguardView.requestFocus(); } updateUserActivityTimeoutInWindowLayoutParams(); mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); mKeyguardHost.restoreHierarchyState(mStateContainer); }