@Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    super.onStartCommand(intent, flags, startId);

    if (!initiated) {
      IntentFilter filter = new IntentFilter();
      filter.addAction(Intent.ACTION_SCREEN_OFF);
      filter.addAction(Intent.ACTION_SCREEN_ON);
      filter.setPriority(1000);
      registerReceiver(new LockscreenManager(), filter);

      IntentFilter filter2 = new IntentFilter();
      filter2.addAction(Intent.ACTION_SCREEN_OFF);
      filter2.setPriority(1000);
      registerReceiver(new UnlocktimeReceiver(), filter2);

      IntentFilter filter3 = new IntentFilter();
      filter3.addAction(Intent.ACTION_SCREEN_ON);
      filter3.setPriority(1000);
      registerReceiver(new ExpositionUnlockReceiver(), filter3);

      // todo refactor this method is depricated
      KeyguardManager keyguardManager =
          (KeyguardManager) getSystemService(Activity.KEYGUARD_SERVICE);
      KeyguardManager.KeyguardLock lock = keyguardManager.newKeyguardLock(Context.KEYGUARD_SERVICE);
      lock.disableKeyguard();

      initiated = true;
    }

    //        stopSelf();

    return Service.START_STICKY;
  }
 @SuppressWarnings("deprecation")
 private void enableKeyguard(boolean enabled) {
   if (mKeyguardLock == null) {
     KeyguardManager km = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
     mKeyguardLock = km.newKeyguardLock(LOG_TAG);
   }
   if (enabled) {
     mKeyguardLock.reenableKeyguard();
   } else {
     mKeyguardLock.disableKeyguard();
   }
 }
  @SuppressWarnings({"deprecation", "unused"})
  @Override
  public void onReceive(Context context, Intent intent) {

    if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)
        || intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {

      Intent lockIntent = new Intent(context, LockScreenActivity.class);

      keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
      keyguardLock = keyguardManager.newKeyguardLock("");
      keyguardLock.disableKeyguard(); //
      //
      //			context.startActivity(lockIntent); //
    }
  }
Exemple #4
0
 void disableKeyguard() {
   if (mKeyguardManager == null) {
     mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
     mKeyguardLock = mKeyguardManager.newKeyguardLock("Sipdroid");
     enabled = true;
   }
   if (enabled) {
     mKeyguardLock.disableKeyguard();
     if (Integer.parseInt(Build.VERSION.SDK) == 16 && Build.MODEL.contains("HTC One"))
       mKeyguardManager.exitKeyguardSecurely(
           new OnKeyguardExitResult() {
             public void onKeyguardExitResult(boolean success) {}
           });
     enabled = false;
     enabletime = SystemClock.elapsedRealtime();
   }
 }
  /**
   * Attempts to acquire the keyguard lock.
   *
   * @return a reference to the keyguard lock, or {@code null} if the keyguard lock could not be
   *     obtained
   * @see #onStart
   */
  @Nullable
  protected KeyguardManager.KeyguardLock tryToAcquireKeyguardLock() {
    KeyguardManager keyguardManager =
        (KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE);
    KeyguardManager.KeyguardLock acquiredLock = keyguardManager.newKeyguardLock(LOG_TAG);

    try {
      acquiredLock.disableKeyguard();
    } catch (SecurityException exception) {
      Log.w(
          LOG_TAG,
          "Could not disable the keyguard for testing; it must be " + "disabled manually.",
          exception);
      acquiredLock = null;
    }

    return acquiredLock;
  }
  @Override
  @SuppressWarnings("deprecation")
  public void onCreate() {
    KeyguardManager.KeyguardLock key;
    KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);

    // This is deprecated, but it is a simple way to disable the lockscreen in code
    key = km.newKeyguardLock("IN");

    key.disableKeyguard();

    // Start listening for the Screen On, Screen Off, and Boot completed actions
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_BOOT_COMPLETED);

    // Set up a receiver to listen for the Intents in this Service
    receiver = new LockScreenReceiver();
    registerReceiver(receiver, filter);

    super.onCreate();
  }
 @Override
 public void unlock() {
   manageKeyguard = true;
   keyguardLock.disableKeyguard();
 }
Exemple #8
0
 public void disableKeyguard() {
   keyguardLock.disableKeyguard();
 }
Exemple #9
0
 /**
  * Disables the keyguard. This is used by the phone app to allow interaction with the Phone UI
  * when the keyguard would otherwise be active (like receiving an incoming call while the device
  * is locked.)
  *
  * <p>Any call to this method MUST be followed (eventually) by a corresponding reenableKeyguard()
  * call.
  */
 /* package */ void disableKeyguard() {
   if (DBG) Log.d(LOG_TAG, "disable keyguard");
   // if (DBG) Log.d(LOG_TAG, "disableKeyguard()...", new Throwable("stack dump"));
   mKeyguardLock.disableKeyguard();
 }