/**
   * 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;
  }
예제 #2
0
 void reenableKeyguard() {
   if (!enabled) {
     try {
       if (Integer.parseInt(Build.VERSION.SDK) < 5) Thread.sleep(1000);
     } catch (InterruptedException e) {
     }
     mKeyguardLock.reenableKeyguard();
     enabled = true;
   }
 }
예제 #3
0
 @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();
   }
 }
예제 #4
0
 @Override
 public void lock() {
   if (manageKeyguard) {
     keyguardLock.reenableKeyguard();
   }
 }
예제 #5
0
 public void release() {
   if (keyguardLock != null) {
     // 禁用显示键盘锁定
     keyguardLock.reenableKeyguard();
   }
 }
예제 #6
0
 public void reenableKeyguard() {
   keyguardLock.reenableKeyguard();
 }
예제 #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();
 }