/**
   * Called by the Android runtime to clean up the {@code Instrumentation}. This implementation
   * releases the locks obtained in {@code onStart} and stops the Jetty server.
   */
  @Override
  public void onDestroy() {
    if (wakeLock != null) {
      wakeLock.release();
      wakeLock = null;
    }

    if (keyguardLock != null) {
      keyguardLock.reenableKeyguard();
      keyguardLock = null;
    }

    if (server != null) {
      try {
        callServerStop();
      } catch (Exception exception) {
        Log.e(LOG_TAG, "Exception when stopping Jetty.", exception);
      }

      Log.i(LOG_TAG, "Jetty stopped");

      server = null;
    } else {
      Log.i(LOG_TAG, "In onDestroy(), but Jetty is not running");
    }

    instance = null;
  }
Exemple #2
0
 void reenableKeyguard() {
   if (!enabled) {
     try {
       if (Integer.parseInt(Build.VERSION.SDK) < 5) Thread.sleep(1000);
     } catch (InterruptedException e) {
     }
     mKeyguardLock.reenableKeyguard();
     enabled = true;
   }
 }
 @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();
   }
 }
 @Override
 public void lock() {
   if (manageKeyguard) {
     keyguardLock.reenableKeyguard();
   }
 }
Exemple #5
0
 public void release() {
   if (keyguardLock != null) {
     // 禁用显示键盘锁定
     keyguardLock.reenableKeyguard();
   }
 }
Exemple #6
0
 public void reenableKeyguard() {
   keyguardLock.reenableKeyguard();
 }
Exemple #7
0
 /**
  * Re-enables the keyguard after a previous disableKeyguard() call.
  *
  * <p>Any call to this method MUST correspond to (i.e. be balanced with) a previous
  * disableKeyguard() call.
  */
 /* package */ void reenableKeyguard() {
   if (DBG) Log.d(LOG_TAG, "re-enable keyguard");
   // if (DBG) Log.d(LOG_TAG, "reenableKeyguard()...", new Throwable("stack dump"));
   mKeyguardLock.reenableKeyguard();
 }