@Override // Binder call
  public void registerCallback(IDisplayManagerCallback callback) {
    if (callback == null) {
      throw new IllegalArgumentException("listener must not be null");
    }

    synchronized (mSyncRoot) {
      int callingPid = Binder.getCallingPid();
      if (mCallbacks.get(callingPid) != null) {
        throw new SecurityException(
            "The calling process has already " + "registered an IDisplayManagerCallback.");
      }

      CallbackRecord record = new CallbackRecord(callingPid, callback);
      try {
        IBinder binder = callback.asBinder();
        binder.linkToDeath(record, 0);
      } catch (RemoteException ex) {
        // give up
        throw new RuntimeException(ex);
      }

      mCallbacks.put(callingPid, record);
    }
  }
  private void registerCallbackInternal(IDisplayManagerCallback callback, int callingPid) {
    synchronized (mSyncRoot) {
      if (mCallbacks.get(callingPid) != null) {
        throw new SecurityException(
            "The calling process has already " + "registered an IDisplayManagerCallback.");
      }

      CallbackRecord record = new CallbackRecord(callingPid, callback);
      try {
        IBinder binder = callback.asBinder();
        binder.linkToDeath(record, 0);
      } catch (RemoteException ex) {
        // give up
        throw new RuntimeException(ex);
      }

      mCallbacks.put(callingPid, record);
    }
  }