public void binderDied() {
      if (DEBUG) Log.d(TAG, "GPS status listener died");

      synchronized (mListeners) {
        mListeners.remove(this);
      }
      if (mListener != null) {
        mListener.asBinder().unlinkToDeath(this, 0);
      }
    }
        public void addGpsStatusListener(IGpsStatusListener listener) throws RemoteException {
          if (listener == null) {
            throw new NullPointerException("listener is null in addGpsStatusListener");
          }

          synchronized (mListeners) {
            IBinder binder = listener.asBinder();
            int size = mListeners.size();
            for (int i = 0; i < size; i++) {
              Listener test = mListeners.get(i);
              if (binder.equals(test.mListener.asBinder())) {
                // listener already added
                return;
              }
            }

            Listener l = new Listener(listener);
            binder.linkToDeath(l, 0);
            mListeners.add(l);
          }
        }
        public void removeGpsStatusListener(IGpsStatusListener listener) {
          if (listener == null) {
            throw new NullPointerException("listener is null in addGpsStatusListener");
          }

          synchronized (mListeners) {
            IBinder binder = listener.asBinder();
            Listener l = null;
            int size = mListeners.size();
            for (int i = 0; i < size && l == null; i++) {
              Listener test = mListeners.get(i);
              if (binder.equals(test.mListener.asBinder())) {
                l = test;
              }
            }

            if (l != null) {
              mListeners.remove(l);
              binder.unlinkToDeath(l, 0);
            }
          }
        }