コード例 #1
0
 private void restoreRotationStateLocked() {
   try {
     if (mInitialFrozenRotation != INITIAL_FROZEN_ROTATION_UNSPECIFIED) {
       // Calling out with a lock held is fine since if the system
       // process is gone the client calling in will be killed.
       mWindowManager.freezeRotation(mInitialFrozenRotation);
     } else {
       // Calling out with a lock held is fine since if the system
       // process is gone the client calling in will be killed.
       mWindowManager.thawRotation();
     }
   } catch (RemoteException re) {
     /* ignore */
   }
 }
コード例 #2
0
  private void handleToggleAutoRotateScreenPreferenceClick() {

    boolean enableDefaultRotation = getResources().getBoolean(R.bool.config_enableDefaultRotation);
    try {
      IWindowManager wm =
          IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE));
      if (mToggleAutoRotateScreenPreference.isChecked()) {
        wm.thawRotation();
      } else {
        if (enableDefaultRotation) {
          wm.freezeRotation(-1);
        } else {
          wm.freezeRotation(Surface.ROTATION_0);
        }
      }
    } catch (RemoteException exc) {
      Log.w(TAG, "Unable to save auto-rotate setting");
    }
  }
コード例 #3
0
 @Override
 public boolean setRotation(int rotation) {
   synchronized (mLock) {
     throwIfCalledByNotTrustedUidLocked();
     throwIfShutdownLocked();
     throwIfNotConnectedLocked();
   }
   final long identity = Binder.clearCallingIdentity();
   try {
     if (rotation == UiAutomation.ROTATION_UNFREEZE) {
       mWindowManager.thawRotation();
     } else {
       mWindowManager.freezeRotation(rotation);
     }
     return true;
   } catch (RemoteException re) {
     /* ignore */
   } finally {
     Binder.restoreCallingIdentity(identity);
   }
   return false;
 }