Methods Summary |
---|
public void | adjustDisplayVolume(int delta)
if (mConnectionReady && mSelectedDisplayId != null) {
mActiveConnection.adjustVolume(mSelectedDisplayId, delta);
}
|
private void | bind()
if (!mBound) {
if (DEBUG) {
Slog.d(TAG, this + ": Binding");
}
Intent service = new Intent(RemoteDisplayState.SERVICE_INTERFACE);
service.setComponent(mComponentName);
try {
mBound = mContext.bindServiceAsUser(service, this, Context.BIND_AUTO_CREATE,
new UserHandle(mUserId));
if (!mBound && DEBUG) {
Slog.d(TAG, this + ": Bind failed");
}
} catch (SecurityException ex) {
if (DEBUG) {
Slog.d(TAG, this + ": Bind failed", ex);
}
}
}
|
private void | disconnect()
if (mActiveConnection != null) {
if (mSelectedDisplayId != null) {
mActiveConnection.disconnect(mSelectedDisplayId);
}
mConnectionReady = false;
mActiveConnection.dispose();
mActiveConnection = null;
setDisplayState(null);
}
|
public void | dump(java.io.PrintWriter pw, java.lang.String prefix)
pw.println(prefix + "Proxy");
pw.println(prefix + " mUserId=" + mUserId);
pw.println(prefix + " mRunning=" + mRunning);
pw.println(prefix + " mBound=" + mBound);
pw.println(prefix + " mActiveConnection=" + mActiveConnection);
pw.println(prefix + " mConnectionReady=" + mConnectionReady);
pw.println(prefix + " mDiscoveryMode=" + mDiscoveryMode);
pw.println(prefix + " mSelectedDisplayId=" + mSelectedDisplayId);
pw.println(prefix + " mDisplayState=" + mDisplayState);
|
public android.media.RemoteDisplayState | getDisplayState()
return mDisplayState;
|
public java.lang.String | getFlattenedComponentName()
return mComponentName.flattenToShortString();
|
public boolean | hasComponentName(java.lang.String packageName, java.lang.String className)
return mComponentName.getPackageName().equals(packageName)
&& mComponentName.getClassName().equals(className);
|
private void | onConnectionDied(com.android.server.media.RemoteDisplayProviderProxy$Connection connection)
if (mActiveConnection == connection) {
if (DEBUG) {
Slog.d(TAG, this + ": Service connection died");
}
disconnect();
}
|
private void | onConnectionReady(com.android.server.media.RemoteDisplayProviderProxy$Connection connection)
if (mActiveConnection == connection) {
mConnectionReady = true;
if (mDiscoveryMode != RemoteDisplayState.DISCOVERY_MODE_NONE) {
mActiveConnection.setDiscoveryMode(mDiscoveryMode);
}
if (mSelectedDisplayId != null) {
mActiveConnection.connect(mSelectedDisplayId);
}
}
|
private void | onDisplayStateChanged(com.android.server.media.RemoteDisplayProviderProxy$Connection connection, android.media.RemoteDisplayState state)
if (mActiveConnection == connection) {
if (DEBUG) {
Slog.d(TAG, this + ": State changed, state=" + state);
}
setDisplayState(state);
}
|
public void | onServiceConnected(android.content.ComponentName name, android.os.IBinder service)
if (DEBUG) {
Slog.d(TAG, this + ": Connected");
}
if (mBound) {
disconnect();
IRemoteDisplayProvider provider = IRemoteDisplayProvider.Stub.asInterface(service);
if (provider != null) {
Connection connection = new Connection(provider);
if (connection.register()) {
mActiveConnection = connection;
} else {
if (DEBUG) {
Slog.d(TAG, this + ": Registration failed");
}
}
} else {
Slog.e(TAG, this + ": Service returned invalid remote display provider binder");
}
}
|
public void | onServiceDisconnected(android.content.ComponentName name)
if (DEBUG) {
Slog.d(TAG, this + ": Service disconnected");
}
disconnect();
|
public void | rebindIfDisconnected()
if (mActiveConnection == null && shouldBind()) {
unbind();
bind();
}
|
public void | setCallback(com.android.server.media.RemoteDisplayProviderProxy$Callback callback)
mDisplayStateCallback = callback;
|
public void | setDiscoveryMode(int mode)
if (mDiscoveryMode != mode) {
mDiscoveryMode = mode;
if (mConnectionReady) {
mActiveConnection.setDiscoveryMode(mode);
}
updateBinding();
}
|
private void | setDisplayState(android.media.RemoteDisplayState state)
if (!Objects.equals(mDisplayState, state)) {
mDisplayState = state;
if (!mScheduledDisplayStateChangedCallback) {
mScheduledDisplayStateChangedCallback = true;
mHandler.post(mDisplayStateChanged);
}
}
|
public void | setDisplayVolume(int volume)
if (mConnectionReady && mSelectedDisplayId != null) {
mActiveConnection.setVolume(mSelectedDisplayId, volume);
}
|
public void | setSelectedDisplay(java.lang.String id)
if (!Objects.equals(mSelectedDisplayId, id)) {
if (mConnectionReady && mSelectedDisplayId != null) {
mActiveConnection.disconnect(mSelectedDisplayId);
}
mSelectedDisplayId = id;
if (mConnectionReady && id != null) {
mActiveConnection.connect(id);
}
updateBinding();
}
|
private boolean | shouldBind()
if (mRunning) {
// Bind whenever there is a discovery request or selected display.
if (mDiscoveryMode != RemoteDisplayState.DISCOVERY_MODE_NONE
|| mSelectedDisplayId != null) {
return true;
}
}
return false;
|
public void | start()
if (!mRunning) {
if (DEBUG) {
Slog.d(TAG, this + ": Starting");
}
mRunning = true;
updateBinding();
}
|
public void | stop()
if (mRunning) {
if (DEBUG) {
Slog.d(TAG, this + ": Stopping");
}
mRunning = false;
updateBinding();
}
|
public java.lang.String | toString()
return "Service connection " + mComponentName.flattenToShortString();
|
private void | unbind()
if (mBound) {
if (DEBUG) {
Slog.d(TAG, this + ": Unbinding");
}
mBound = false;
disconnect();
mContext.unbindService(this);
}
|
private void | updateBinding()
if (shouldBind()) {
bind();
} else {
unbind();
}
|