FileDocCategorySizeDatePackage
KeyguardServiceDelegate.javaAPI DocAndroid 5.1 API11929Thu Mar 12 22:22:42 GMT 2015com.android.internal.policy.impl.keyguard

KeyguardServiceDelegate

public class KeyguardServiceDelegate extends Object
A local class that keeps a cache of keyguard state that can be restored in the event keyguard crashes. It currently also allows runtime-selectable local or remote instances of keyguard.

Fields Summary
public static final String
KEYGUARD_PACKAGE
public static final String
KEYGUARD_CLASS
private static final String
TAG
private static final boolean
DEBUG
protected KeyguardServiceWrapper
mKeyguardService
private final android.content.Context
mContext
private final android.view.View
mScrim
private final KeyguardState
mKeyguardState
private ShowListener
mShowListenerWhenConnect
private final android.content.ServiceConnection
mKeyguardConnection
Constructors Summary
public KeyguardServiceDelegate(android.content.Context context)

        mContext = context;
        mScrim = createScrim(context);
    
Methods Summary
public voidbindService(android.content.Context context)

        Intent intent = new Intent();
        intent.setClassName(KEYGUARD_PACKAGE, KEYGUARD_CLASS);
        if (!context.bindServiceAsUser(intent, mKeyguardConnection,
                Context.BIND_AUTO_CREATE, UserHandle.OWNER)) {
            Log.v(TAG, "*** Keyguard: can't bind to " + KEYGUARD_CLASS);
            mKeyguardState.showing = false;
            mKeyguardState.showingAndNotOccluded = false;
            mKeyguardState.secure = false;
            mKeyguardState.deviceHasKeyguard = false;
            hideScrim();
        } else {
            if (DEBUG) Log.v(TAG, "*** Keyguard started");
        }
    
private static final android.view.ViewcreateScrim(android.content.Context context)

        View view = new View(context);

        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
                ;

        final int stretch = ViewGroup.LayoutParams.MATCH_PARENT;
        final int type = WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM;
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                stretch, stretch, type, flags, PixelFormat.TRANSLUCENT);
        lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
        lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
        lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED;
        lp.setTitle("KeyguardScrim");
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        wm.addView(view, lp);
        // Disable pretty much everything in statusbar until keyguard comes back and we know
        // the state of the world.
        view.setSystemUiVisibility(View.STATUS_BAR_DISABLE_HOME
                | View.STATUS_BAR_DISABLE_BACK
                | View.STATUS_BAR_DISABLE_RECENT
                | View.STATUS_BAR_DISABLE_EXPAND
                | View.STATUS_BAR_DISABLE_SEARCH);
        return view;
    
public voiddismiss()

        if (mKeyguardService != null) {
            mKeyguardService.dismiss();
        }
    
public voiddoKeyguardTimeout(android.os.Bundle options)

        if (mKeyguardService != null) {
            mKeyguardService.doKeyguardTimeout(options);
        }
    
public voidhideScrim()

        mScrim.post(new Runnable() {
            @Override
            public void run() {
                mScrim.setVisibility(View.GONE);
            }
        });
    
public booleanisInputRestricted()

        if (mKeyguardService != null) {
            mKeyguardState.inputRestricted = mKeyguardService.isInputRestricted();
        }
        return mKeyguardState.inputRestricted;
    
public booleanisSecure()

        if (mKeyguardService != null) {
            mKeyguardState.secure = mKeyguardService.isSecure();
        }
        return mKeyguardState.secure;
    
public booleanisShowing()


       
        if (mKeyguardService != null) {
            mKeyguardState.showing = mKeyguardService.isShowing();
        }
        return mKeyguardState.showing;
    
public voidkeyguardDone(boolean authenticated, boolean wakeup)

        if (mKeyguardService != null) {
            mKeyguardService.keyguardDone(authenticated, wakeup);
        }
    
public voidonActivityDrawn()

        if (mKeyguardService != null) {
            mKeyguardService.onActivityDrawn();
        }
    
public voidonBootCompleted()

        if (mKeyguardService != null) {
            mKeyguardService.onBootCompleted();
        }
        mKeyguardState.bootCompleted = true;
    
public voidonDreamingStarted()

        if (mKeyguardService != null) {
            mKeyguardService.onDreamingStarted();
        }
        mKeyguardState.dreaming = true;
    
public voidonDreamingStopped()

        if (mKeyguardService != null) {
            mKeyguardService.onDreamingStopped();
        }
        mKeyguardState.dreaming = false;
    
public voidonScreenTurnedOff(int why)

        if (mKeyguardService != null) {
            mKeyguardService.onScreenTurnedOff(why);
        }
        mKeyguardState.offReason = why;
        mKeyguardState.screenIsOn = false;
    
public voidonScreenTurnedOn(com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate$ShowListener showListener)

        if (mKeyguardService != null) {
            if (DEBUG) Log.v(TAG, "onScreenTurnedOn(showListener = " + showListener + ")");
            mKeyguardService.onScreenTurnedOn(new KeyguardShowDelegate(showListener));
        } else {
            // try again when we establish a connection
            Slog.w(TAG, "onScreenTurnedOn(): no keyguard service!");
            // This shouldn't happen, but if it does, show the scrim immediately and
            // invoke the listener's callback after the service actually connects.
            mShowListenerWhenConnect = showListener;
            showScrim();
        }
        mKeyguardState.screenIsOn = true;
    
public voidonSystemReady()

        if (mKeyguardService != null) {
            mKeyguardService.onSystemReady();
        } else {
            mKeyguardState.systemIsReady = true;
        }
    
public voidsetCurrentUser(int newUserId)

        if (mKeyguardService != null) {
            mKeyguardService.setCurrentUser(newUserId);
        }
        mKeyguardState.currentUser = newUserId;
    
public voidsetKeyguardEnabled(boolean enabled)

        if (mKeyguardService != null) {
            mKeyguardService.setKeyguardEnabled(enabled);
        }
        mKeyguardState.enabled = enabled;
    
public voidsetOccluded(boolean isOccluded)

        if (mKeyguardService != null) {
            mKeyguardService.setOccluded(isOccluded);
        }
        mKeyguardState.occluded = isOccluded;
    
public voidshowScrim()

        if (!mKeyguardState.deviceHasKeyguard) return;
        mScrim.post(new Runnable() {
            @Override
            public void run() {
                mScrim.setVisibility(View.VISIBLE);
            }
        });
    
public voidstartKeyguardExitAnimation(long startTime, long fadeoutDuration)

        if (mKeyguardService != null) {
            mKeyguardService.startKeyguardExitAnimation(startTime, fadeoutDuration);
        }
    
public voidverifyUnlock(android.view.WindowManagerPolicy.OnKeyguardExitResult onKeyguardExitResult)

        if (mKeyguardService != null) {
            mKeyguardService.verifyUnlock(new KeyguardExitDelegate(onKeyguardExitResult));
        }