當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyguardManager類代碼示例

本文整理匯總了Java中android.app.KeyguardManager的典型用法代碼示例。如果您正苦於以下問題:Java KeyguardManager類的具體用法?Java KeyguardManager怎麽用?Java KeyguardManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


KeyguardManager類屬於android.app包,在下文中一共展示了KeyguardManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onStart

import android.app.KeyguardManager; //導入依賴的package包/類
@SuppressLint("MissingPermission")
@Override
public void onStart() {
    Application application = (Application) getTargetContext().getApplicationContext();
    String simpleName = UnlockDeviceAndroidJUnitRunner.class.getSimpleName();
    // Unlock the device so that the tests can input keystrokes.
    ((KeyguardManager) application.getSystemService(KEYGUARD_SERVICE))
            .newKeyguardLock(simpleName)
            .disableKeyguard();
    // Wake up the screen.
    PowerManager powerManager = ((PowerManager) application.getSystemService(POWER_SERVICE));
    mWakeLock = powerManager.newWakeLock(FULL_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP |
            ON_AFTER_RELEASE, simpleName);
    mWakeLock.acquire();
    super.onStart();
}
 
開發者ID:ebridfighter,項目名稱:GongXianSheng,代碼行數:17,代碼來源:UnlockDeviceAndroidJUnitRunner.java

示例2: requireAuthentication

import android.app.KeyguardManager; //導入依賴的package包/類
/**
 * Require the user to authenticate using the configured LockScreen before accessing the credentials.
 * This feature is disabled by default and will only work if the device is running on Android version 21 or up and if the user
 * has configured a secure LockScreen (PIN, Pattern, Password or Fingerprint).
 * <p>
 * The activity passed as first argument here must override the {@link Activity#onActivityResult(int, int, Intent)} method and
 * call {@link SecureCredentialsManager#checkAuthenticationResult(int, int)} with the received parameters.
 *
 * @param activity    a valid activity context. Will be used in the authentication request to launch a LockScreen intent.
 * @param requestCode the request code to use in the authentication request. Must be a value between 1 and 255.
 * @param title       the text to use as title in the authentication screen. Passing null will result in using the OS's default value.
 * @param description the text to use as description in the authentication screen. On some Android versions it might not be shown. Passing null will result in using the OS's default value.
 * @return whether this device supports requiring authentication or not. This result can be ignored safely.
 */
public boolean requireAuthentication(@NonNull Activity activity, @IntRange(from = 1, to = 255) int requestCode, @Nullable String title, @Nullable String description) {
    if (requestCode < 1 || requestCode > 255) {
        throw new IllegalArgumentException("Request code must a value between 1 and 255.");
    }
    KeyguardManager kManager = (KeyguardManager) activity.getSystemService(Context.KEYGUARD_SERVICE);
    this.authIntent = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? kManager.createConfirmDeviceCredentialIntent(title, description) : null;
    this.authenticateBeforeDecrypt = ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && kManager.isDeviceSecure())
            || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && kManager.isKeyguardSecure()))
            && authIntent != null;
    if (authenticateBeforeDecrypt) {
        this.activity = activity;
        this.authenticationRequestCode = requestCode;
    }
    return authenticateBeforeDecrypt;
}
 
開發者ID:auth0,項目名稱:Auth0.Android,代碼行數:30,代碼來源:SecureCredentialsManager.java

示例3: setup

import android.app.KeyguardManager; //導入依賴的package包/類
@Before
public void setup() throws Throwable {
    // espresso need the screen on
    final Activity activity = mRule.getActivity();
    mRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            KeyguardManager km = (KeyguardManager) activity.getSystemService(Context.KEYGUARD_SERVICE);
            KeyguardManager.KeyguardLock lock = km.newKeyguardLock(Context.KEYGUARD_SERVICE);
            lock.disableKeyguard();

            //turn the screen on
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                    | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                    | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                    | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
                    | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
        }
    });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:PickerFragmentTest.java

示例4: wakeAndUnlock

import android.app.KeyguardManager; //導入依賴的package包/類
private void wakeAndUnlock()
{
    //獲取電源管理器對象
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);

    //獲取PowerManager.WakeLock對象,後麵的參數|表示同時傳入兩個值,最後的是調試用的Tag
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");

    //點亮屏幕
    wl.acquire(1000);

    //得到鍵盤鎖管理器對象
    KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
    kl = km.newKeyguardLock("unLock");

    //解鎖
    kl.disableKeyguard();

}
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:20,代碼來源:AppCompatDlalog.java

示例5: wakeAndUnlock

import android.app.KeyguardManager; //導入依賴的package包/類
private void wakeAndUnlock(boolean b)
   {
if (b)
{
    //獲取電源管理器對象
    mPowerManager = (PowerManager)getApplicationContext().getSystemService(Context.POWER_SERVICE);
    //獲取PowerManager.WakeLock對象,後麵的參數|表示同時傳入兩個值,最後的是調試用的Tag
    mWakeLock = mPowerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");
    //點亮屏幕
    mWakeLock.acquire();
    //得到鍵盤鎖管理器對象
    mKeyguardManager = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
    mKeyguardLock = mKeyguardManager.newKeyguardLock("unLock");
    //解鎖
    mKeyguardLock.disableKeyguard();
}
else
{
    //鎖屏
    mKeyguardLock.reenableKeyguard();
    //釋放wakeLock,關燈
    mWakeLock.release();
}}
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:24,代碼來源:dex_smali.java

示例6: wakeAndUnlock

import android.app.KeyguardManager; //導入依賴的package包/類
private void wakeAndUnlock(boolean b) {
    Log.i(TAG, "解鎖亮屏?:" + b);
    if (b) {
        //獲取電源管理器對象
        pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
        //獲取PowerManager.WakeLock對象,後麵的參數|表示同時傳入兩個值,最後的是調試用的Tag
        wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK, "bright");
        //點亮屏幕
        wl.acquire();
        //得到鍵盤鎖管理器對象
        km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
        kl = km.newKeyguardLock("unLock");
        //解鎖
        kl.disableKeyguard();
        isWaked = true;
    } else {
        //鎖屏
        kl.reenableKeyguard();
        //釋放wakeLock,關燈
        wl.release();
    }
}
 
開發者ID:mcxtzhang,項目名稱:miser-utils,代碼行數:23,代碼來源:ComeOnMoneyService.java

示例7: checkSensorState

import android.app.KeyguardManager; //導入依賴的package包/類
public static SensorState checkSensorState(Context context) {
    if (checkFingerprintCompatibility(context)) {
        KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);

        if (!keyguardManager.isKeyguardSecure()) {
            return SensorState.NOT_BLOCKED;
        }

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || !((FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE)).hasEnrolledFingerprints()) {
            return SensorState.NO_FINGERPRINTS;
        }

        return SensorState.READY;
    } else {
        return SensorState.NOT_SUPPORTED;
    }
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:18,代碼來源:FingerprintTools.java

示例8: handleIntent

import android.app.KeyguardManager; //導入依賴的package包/類
private void handleIntent(Intent intent) {
    KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
    if (km.inKeyguardRestrictedInputMode() || !ApplicationLoader.isScreenOn) {
        getWindow().addFlags(
                        WindowManager.LayoutParams.FLAG_DIM_BEHIND |
                        WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
                        WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    } else {
        getWindow().addFlags(
                        WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
                        WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    }

    if (currentMessageObject == null) {
        currentMessageNum = 0;
    }
    getNewMessage();
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:22,代碼來源:PopupNotificationActivity.java

示例9: initFingerPrint

import android.app.KeyguardManager; //導入依賴的package包/類
private void initFingerPrint(Context context) {
    KeyguardManager keyguardManager =
            (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    FingerprintManager fingerprintManager =
            (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);

    if (!fingerprintManager.isHardwareDetected()) {
        Toast.makeText(context, "Your device doesn't support fingerprint authentication", Toast.LENGTH_LONG).show();
    } else if (context.checkSelfPermission(Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
        Toast.makeText(context, "Please enable the fingerprint permission", Toast.LENGTH_LONG).show();
    } else if (!fingerprintManager.hasEnrolledFingerprints()) {
        Toast.makeText(
                context,
                "No fingerprint configured. Please register at least one fingerprint in your device's Settings",
                Toast.LENGTH_LONG).show();
    } else if (!keyguardManager.isKeyguardSecure()) {
        Toast.makeText(
                context,
                "Please enable lock screen security in your device's Settings",
                Toast.LENGTH_LONG).show();
    } else {
        fHandler = new FingerprintHandler(context);
    }
}
 
開發者ID:aboutZZ,項目名稱:WeChatFingerprintPay,代碼行數:25,代碼來源:PayHook.java

示例10: onStart

import android.app.KeyguardManager; //導入依賴的package包/類
@SuppressWarnings("MissingPermission")
@Override
public void onStart() {
    Application application = (Application) getTargetContext().getApplicationContext();
    String simpleName = UnlockDeviceAndroidJUnitRunner.class.getSimpleName();
    // Unlock the device so that the tests can input keystrokes.
    ((KeyguardManager) application.getSystemService(KEYGUARD_SERVICE))
            .newKeyguardLock(simpleName)
            .disableKeyguard();
    // Wake up the screen.
    PowerManager powerManager = ((PowerManager) application.getSystemService(POWER_SERVICE));
    mWakeLock = powerManager.newWakeLock(FULL_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP |
            ON_AFTER_RELEASE, simpleName);
    mWakeLock.acquire();
    super.onStart();
}
 
開發者ID:OHoussein,項目名稱:Android-Show-Reader,代碼行數:17,代碼來源:UnlockDeviceAndroidJUnitRunner.java

示例11: wakeAndUnlock

import android.app.KeyguardManager; //導入依賴的package包/類
private void wakeAndUnlock(boolean b) {
    if (b) {
        //獲取電源管理器對象
        powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
        //獲取PowerManager.WakeLock對象,後麵的參數|表示同時傳入兩個值,最後的是調試用的Tag
        wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, TAG);

        // 屏幕解鎖
        KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
        KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("unLock");

        keyguardLock.reenableKeyguard();
        keyguardLock.disableKeyguard(); // 解鎖

        //點亮屏幕
        wakeLock.acquire();
    } else {
        //釋放wakeLock,關燈
        wakeLock.release();
    }
}
 
開發者ID:qoli,項目名稱:MiHomePlus,代碼行數:22,代碼來源:MyAccessibility.java

示例12: onCreate

import android.app.KeyguardManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
    Button purchaseButton = (Button) findViewById(R.id.purchase_button);
    if (!mKeyguardManager.isKeyguardSecure()) {
        // Show a message that the user hasn't set up a lock screen.
        Toast.makeText(this,
                "Secure lock screen hasn't set up.\n"
                        + "Go to 'Settings -> Security -> Screenlock' to set up a lock screen",
                Toast.LENGTH_LONG).show();
        purchaseButton.setEnabled(false);
        return;
    }
    createKey();
    findViewById(R.id.purchase_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Test to encrypt something. It might fail if the timeout expired (30s).
            tryEncrypt();
        }
    });
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:25,代碼來源:MainActivity.java

示例13: wakeAndUnlock

import android.app.KeyguardManager; //導入依賴的package包/類
public static void wakeAndUnlock() {
    //獲取電源管理器對象
    PowerManager pm = getPowerManager();

    //獲取PowerManager.WakeLock對象,後麵的參數|表示同時傳入兩個值,最後的是調試用的Tag
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");

    //點亮屏幕
    wl.acquire(1000);

    //得到鍵盤鎖管理器對象
    KeyguardManager km = getKeyguardManager();
    KeyguardManager.KeyguardLock kl = km.newKeyguardLock("unLock");

    //解鎖
    kl.disableKeyguard();
}
 
開發者ID:A-Miracle,項目名稱:QiangHongBao,代碼行數:18,代碼來源:NotifyUtils.java

示例14: wakeAndUnlock

import android.app.KeyguardManager; //導入依賴的package包/類
private void wakeAndUnlock() {
    //獲取電源管理器對象
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);

    //獲取PowerManager.WakeLock對象,後麵的參數|表示同時傳入兩個值,最後的是調試用的Tag
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");

    //點亮屏幕
    wl.acquire(1000);

    //得到鍵盤鎖管理器對象
    KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
    kl = km.newKeyguardLock("unLock");

    //解鎖
    kl.disableKeyguard();

}
 
開發者ID:xmlxin,項目名稱:ReplyMessage,代碼行數:19,代碼來源:AutoReplyService.java

示例15: showAuthScreen

import android.app.KeyguardManager; //導入依賴的package包/類
void showAuthScreen() {
  KeyguardManager keyguardManager = (KeyguardManager) getSystemService(
      Context.KEYGUARD_SERVICE);

  if (!keyguardManager.isKeyguardSecure()) {
    basicConfigFragment.unlockAppIDandSecret();
    return;
  }

  Intent intent = keyguardManager
      .createConfirmDeviceCredentialIntent(getString(R.string.unlock_auth_title),
          getString(R.string.unlock_auth_explain));

  if (intent != null) {
    startActivityForResult(intent, 1);
  }
}
 
開發者ID:tkrworks,項目名稱:JinsMemeBRIDGE-Android,代碼行數:18,代碼來源:MainActivity.java


注:本文中的android.app.KeyguardManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。