下面列出了怎么用android.app.KeyguardManager的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void onStart() {
runOnMainSync(() -> {
final Application app = (Application) getTargetContext().getApplicationContext();
final String simpleName = SpoonInstrumentationTestRunner.class.getSimpleName();
// Unlock the device so that the tests can input keystrokes.
((KeyguardManager) app.getSystemService(Context.KEYGUARD_SERVICE))
.newKeyguardLock(simpleName)
.disableKeyguard();
// Wake up the screen.
((PowerManager) app.getSystemService(Context.POWER_SERVICE))
.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager
.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, simpleName)
.acquire();
});
super.onStart();
}
/** Check is permissions granted for biometric things. */
public static boolean isPermissionsGranted(@NonNull final Context context) {
// before api23 no permissions for biometric, no hardware == no permissions
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return false;
}
final KeyguardManager km =
(KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
if( !km.isKeyguardSecure() ) return false;
// api28+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
return context.checkSelfPermission(Manifest.permission.USE_BIOMETRIC) == PERMISSION_GRANTED;
}
// before api28
return context.checkSelfPermission(Manifest.permission.USE_FINGERPRINT) == PERMISSION_GRANTED;
}
public ShadowsocksNotification(Service service, String profileName, boolean visible) {
this.service = service;
this.profileName = profileName;
this.visible = visible;
keyGuard = (KeyguardManager) service.getSystemService(Context.KEYGUARD_SERVICE);
nm = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE);
pm = (PowerManager) service.getSystemService(Context.POWER_SERVICE);
// init notification builder
initNotificationBuilder();
style = new NotificationCompat.BigTextStyle(builder);
// init with update action
initWithUpdateAction();
// register lock receiver
registerLockReceiver(service, visible);
}
/**
* 检查锁屏状态,如果锁屏先点亮屏幕
*
* @param content
*/
private void checkLockAndShowNotification(String content) {
//管理锁屏的一个服务
KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
if (km.inKeyguardRestrictedInputMode()) {//锁屏
//获取电源管理器对象
PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
if (!pm.isScreenOn()) {
@SuppressLint("InvalidWakeLockTag") PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP |
PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");
wl.acquire(); //点亮屏幕
wl.release(); //任务结束后释放
}
sendNotification(content);
} else {
sendNotification(content);
}
}
@Override
public boolean supportsFingerprint(StrongReference<NSError> error) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
KeyguardManager keyguardManager
= (KeyguardManager) MainActivity.current().getSystemService(KEYGUARD_SERVICE);
fingerprintManager
= (FingerprintManager) MainActivity.current().getSystemService(FINGERPRINT_SERVICE);
if (!fingerprintManager.isHardwareDetected()) {
error.set(new NSError(LAErrorDomain, LAError.TouchIDNotAvailable, getUserInfo("Device has no fingerprint sensor")));
return false;
}
if (!fingerprintManager.hasEnrolledFingerprints()) {
error.set(new NSError(LAErrorDomain, LAError.TouchIDNotEnrolled, getUserInfo("No identities are enrolled")));
return false;
}
if (!keyguardManager.isKeyguardSecure()) {
error.set(new NSError(LAErrorDomain, LAError.PasscodeNotSet, getUserInfo("A passcode isn’t set on the device.")));
// return false;
}
return true;
}
return false;
}
@Override
public void onResume() {
super.onResume();
if (!mCreated)
return;
if (isInitialized()) {
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
if (!keyguardManager.inKeyguardRestrictedInputMode()) {
startPlayer();
}
} else {
if (mCloseComplete) {
reOpen();
}
}
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
boolean locked = km.inKeyguardRestrictedInputMode();
if (locked) {
IntentFilter filter = new IntentFilter(Intent.ACTION_USER_PRESENT);
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_USER_PRESENT.equals(intent.getAction())) {
mServiceBoundContext.attachService();
}
}
};
registerReceiver(receiver, filter);
} else {
mServiceBoundContext.attachService();
}
finish();
}
private void bindSystemServices(Application application) {
bindSystemService(application, LocationManager.class, LOCATION_SERVICE);
bindSystemService(application, WindowManager.class, WINDOW_SERVICE);
bindSystemService(application, ActivityManager.class, ACTIVITY_SERVICE);
bindSystemService(application, PowerManager.class, POWER_SERVICE);
bindSystemService(application, AlarmManager.class, ALARM_SERVICE);
bindSystemService(application, NotificationManager.class, NOTIFICATION_SERVICE);
bindSystemService(application, KeyguardManager.class, KEYGUARD_SERVICE);
bindSystemService(application, Vibrator.class, VIBRATOR_SERVICE);
bindSystemService(application, ConnectivityManager.class, CONNECTIVITY_SERVICE);
bindSystemService(application, WifiManager.class, WIFI_SERVICE);
bindSystemService(application, InputMethodManager.class, INPUT_METHOD_SERVICE);
bindSystemService(application, SearchManager.class, SEARCH_SERVICE);
bindSystemService(application, SensorManager.class, SENSOR_SERVICE);
bindSystemService(application, TelephonyManager.class, TELEPHONY_SERVICE);
bindSystemService(application, AudioManager.class, AUDIO_SERVICE);
bindSystemService(application, DownloadManager.class, DOWNLOAD_SERVICE);
bindSystemService(application, ClipboardManager.class, CLIPBOARD_SERVICE);
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Test
@Config(sdk = 21)
public void shouldNotRequireAuthenticationIfAPI21AndLockScreenDisabled() {
ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", 21);
Activity activity = spy(Robolectric.buildActivity(Activity.class).create().start().resume().get());
//Set LockScreen as Disabled
KeyguardManager kService = mock(KeyguardManager.class);
when(activity.getSystemService(Context.KEYGUARD_SERVICE)).thenReturn(kService);
when(kService.isKeyguardSecure()).thenReturn(false);
when(kService.createConfirmDeviceCredentialIntent("title", "description")).thenReturn(null);
boolean willAskAuthentication = manager.requireAuthentication(activity, 123, "title", "description");
assertThat(willAskAuthentication, is(false));
}
/**
* 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 be 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;
}
public static void showAuthenticationScreen(Context context, int requestCode) {
// Create the Confirm Credentials screen. You can customize the title and description. Or
// we will provide a generic one for you if you leave it null
Log.e(TAG, "showAuthenticationScreen: ");
if (context instanceof Activity) {
Activity app = (Activity) context;
KeyguardManager mKeyguardManager = (KeyguardManager) app.getSystemService(Context.KEYGUARD_SERVICE);
if (mKeyguardManager == null) {
return;
}
Intent intent = mKeyguardManager
.createConfirmDeviceCredentialIntent(
context.getString(R.string.unlock_screen_title_android),
context.getString(R.string.unlock_screen_prompt_android));
if (intent != null) {
app.startActivityForResult(intent, requestCode);
} else {
Log.e(TAG, "showAuthenticationScreen: failed to create intent for auth");
app.finish();
}
} else {
Log.e(TAG, "showAuthenticationScreen: context is not activity!");
}
}
@Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "ButlerService starting up...");
try {
shellBinder = new ShellButlerServiceBinder(this);
butlerApi = shellBinder.bind(5, TimeUnit.SECONDS);
locks = new CommonDeviceLocks();
locks.acquire(this);
// CommonDeviceLocks doesn't enable the Keyguard Lock on Q due to compatibility issues.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
keyguardLock = keyguardManager.newKeyguardLock("ButlerKeyguardLock");
keyguardLock.disableKeyguard();
}
accessibilityServiceWaiter = new AccessibilityServiceWaiter();
Log.d(TAG, "ButlerService startup completed...");
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
@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();
}
});
}
public void wakeUpAndUnlock() {
// TODO: 24/05/2018 解锁密码
// 获取电源管理器对象
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (pm == null)
return;
boolean screenOn = pm.isScreenOn();
if (!screenOn) {
// 获取PowerManager.WakeLock对象,后面的参数|表示同时传入两个值,最后的是LogCat里用的Tag
PowerManager.WakeLock wl = pm.newWakeLock(
PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");
wl.acquire(1000); // 点亮屏幕
wl.release(); // 释放
}
// 屏幕解锁
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(KEYGUARD_SERVICE);
KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("unLock");
// 屏幕锁定
keyguardLock.reenableKeyguard();
keyguardLock.disableKeyguard(); // 解锁
}
private void inicializarSeguranca() {
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this,
getString(R.string.fingerprint_error_no_permission),
Toast.LENGTH_LONG).show();
return;
}
keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
keystoreManager = new AndroidKeystoreManager(KEY_NAME);
keystoreManager.generateKey();
if (keystoreManager.cipherInit()) {
cryptoObject = new FingerprintManager.CryptoObject(keystoreManager.getCipher());
}
}
@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);
}
});
}
public static boolean isDeviceSecure(@NonNull final Context context) {
final KeyguardManager km =
(KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
km != null &&
km.isDeviceSecure();
}
@Override
public void onKeyguardStateChanged(boolean isShowing) {
// Push down current secure keyguard status so that we ignore malicious
// USB devices while locked.
mSecureKeyguardShowing = isShowing
&& mContext.getSystemService(KeyguardManager.class).isDeviceSecure();
try {
mVold.onSecureKeyguardStateChanged(mSecureKeyguardShowing);
} catch (Exception e) {
Slog.wtf(TAG, e);
}
}
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
Activity activityContext = spy(activity);
KeyguardManager kManager = mock(KeyguardManager.class);
when(activityContext.getSystemService(Context.KEYGUARD_SERVICE)).thenReturn(kManager);
SecureCredentialsManager secureCredentialsManager = new SecureCredentialsManager(client, storage, crypto, jwtDecoder);
manager = spy(secureCredentialsManager);
doReturn(CredentialsMock.CURRENT_TIME_MS).when(manager).getCurrentTimeInMillis();
gson = GsonProvider.buildGson();
}
@Override
public void onStart() {
publishBinderService(Context.MEDIA_SESSION_SERVICE, mSessionManagerImpl);
Watchdog.getInstance().addMonitor(this);
mKeyguardManager =
(KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE);
mAudioService = getAudioService();
mAudioPlayerStateMonitor = AudioPlayerStateMonitor.getInstance();
mAudioPlayerStateMonitor.registerListener(
(config, isRemoved) -> {
if (isRemoved || !config.isActive() || config.getPlayerType()
== AudioPlaybackConfiguration.PLAYER_TYPE_JAM_SOUNDPOOL) {
return;
}
synchronized (mLock) {
FullUserRecord user = getFullUserRecordLocked(
UserHandle.getUserId(config.getClientUid()));
if (user != null) {
user.mPriorityStack.updateMediaButtonSessionIfNeeded();
}
}
}, null /* handler */);
mAudioPlayerStateMonitor.registerSelfIntoAudioServiceIfNeeded(mAudioService);
mContentResolver = getContext().getContentResolver();
mSettingsObserver = new SettingsObserver();
mSettingsObserver.observe();
mHasFeatureLeanback = getContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_LEANBACK);
updateUser();
registerPackageBroadcastReceivers();
// TODO(jaewan): Query per users (b/73597722)
buildMediaSessionService2List();
}
private boolean isDeviceLocked() {
int callingUserId = UserHandle.getCallingUserId();
final long token = Binder.clearCallingIdentity();
try {
final KeyguardManager keyguardManager = getContext().getSystemService(
KeyguardManager.class);
return keyguardManager != null && keyguardManager.isDeviceLocked(callingUserId);
} finally {
Binder.restoreCallingIdentity(token);
}
}
@VisibleForTesting
boolean isIntentUserVisible() {
// Only process Intents if the screen is on and the device is unlocked;
// i.e. the user will see what is going on.
Context appContext = ContextUtils.getApplicationContext();
if (!ApiCompatibilityUtils.isInteractive(appContext)) return false;
if (!ApiCompatibilityUtils.isDeviceProvisioned(appContext)) return true;
return !((KeyguardManager) appContext.getSystemService(Context.KEYGUARD_SERVICE))
.inKeyguardRestrictedInputMode();
}
@RequiresApi(api = Build.VERSION_CODES.M)
public static boolean checkFinger(Context ctx) {
// Keyguard Manager
KeyguardManager keyguardManager = (KeyguardManager) ctx.getSystemService(KEYGUARD_SERVICE);
// Fingerprint Manager
FingerprintManager fingerprintManager = (FingerprintManager) ctx.getSystemService(FINGERPRINT_SERVICE);
try {
// Check if the fingerprint sensor is present
if (!fingerprintManager.isHardwareDetected()) {
// Update the UI with a message
StringUtils.showToast(ctx, ctx.getString(R.string.fp_not_supported));
return false;
}
if (!fingerprintManager.hasEnrolledFingerprints()) {
StringUtils.showToast(ctx, ctx.getString(R.string.fp_not_configured));
return false;
}
if (!keyguardManager.isKeyguardSecure()) {
StringUtils.showToast(ctx, ctx.getString(R.string.fp_not_enabled_sls));
return false;
}
} catch (SecurityException se) {
se.printStackTrace();
}
return true;
}
@Override
protected void onCreate(Bundle state) {
super.onCreate(state);
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
boolean isOn = Build.VERSION.SDK_INT < 7 || pm.isScreenOn();
boolean isKG = km.inKeyguardRestrictedInputMode();
if (!isOn || isKG) {
finish();
return;
}
TextView tv = new TextView(this);
tv.setText("Protifying code...");
float d = getResources().getDisplayMetrics().density;
tv.setPadding(asDp(8, d), asDp(8, d), asDp(8, d), asDp(8, d));
setContentView(tv);
if (Build.VERSION.SDK_INT >= 11 &&
(state == null || !state.getBoolean(STATE_SAVED, false))) {
recreate();
} else {
new Handler().post(new Runnable() {
@Override
public void run() {
finish();
}
});
}
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mTextureView = new TextureView(this);
setContentView(mTextureView);
KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
KeyguardManager.KeyguardLock keyguardLock = km.newKeyguardLock("TAG");
keyguardLock.disableKeyguard();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
public void onUIForegroundStateChanged(boolean isForeground) {
if (currentState == STATE_WAITING_INCOMING) {
if (isForeground) {
stopForeground(true);
} else {
if (!((KeyguardManager) getSystemService(KEYGUARD_SERVICE)).inKeyguardRestrictedInputMode()) {
if(NotificationManagerCompat.from(this).areNotificationsEnabled())
showIncomingNotification(ContactsController.formatName(user.first_name, user.last_name), null, user, null, 0, VoIPActivity.class);
else
declineIncomingCall(DISCARD_REASON_LINE_BUSY, null);
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(VoIPService.this, VoIPActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
try {
PendingIntent.getActivity(VoIPService.this, 0, intent, 0).send();
} catch (PendingIntent.CanceledException e) {
if (BuildVars.LOGS_ENABLED) {
FileLog.e("error restarting activity", e);
}
declineIncomingCall(DISCARD_REASON_LINE_BUSY, null);
}
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){
showNotification();
}
}
}, 500);
}
}
}
}
private void handleIntent(Intent intent) {
isReply = intent != null && intent.getBooleanExtra("force", false);
popupMessages.clear();
if (isReply) {
int account = intent != null ? intent.getIntExtra("currentAccount", UserConfig.selectedAccount) : UserConfig.selectedAccount;
popupMessages.addAll(NotificationsController.getInstance(account).popupReplyMessages);
} else {
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
if (UserConfig.getInstance(a).isClientActivated()) {
popupMessages.addAll(NotificationsController.getInstance(a).popupMessages);
}
}
}
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();
}
public static Locker create(String keyName, Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
KeyguardManager keyguardManager = context.getSystemService(KeyguardManager.class);
if (keyguardManager != null && keyguardManager.isDeviceSecure()) {
return new UserAuthenticationLocker(keyName, context);
}
}
return new InternalLocker(keyName, context);
}
public static UserAuthenticationHandler defaultHandler(Continuation<Object[]> ret) {
return (context, cont) -> {
KeyguardManager keyguardManager = context.getSystemService(KeyguardManager.class);
Intent intent = keyguardManager == null ? null : keyguardManager.createConfirmDeviceCredentialIntent(null, null);
if (intent == null) {
cont.run();
return;
}
ret.cont(new Object[]{ intent, cont });
};
}
public static void noSysLocker(Context context) {
KeyguardManager keyguardManager = (KeyguardManager) context
.getApplicationContext().getSystemService(
Context.KEYGUARD_SERVICE);
KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("Zhaome");
keyguardLock.disableKeyguard();
}