Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7bbd083d authored by Tyler Gunn's avatar Tyler Gunn Committed by android-build-merger
Browse files

Merge "Add new ConnectionEvent API (hide) to send a notification to Telecom" into nyc-dev

am: e40cc284

* commit 'e40cc284':
  Add new ConnectionEvent API (hide) to send a notification to Telecom
parents 5dc17725 e40cc284
Loading
Loading
Loading
Loading
+32 −0
Original line number Original line Diff line number Diff line
@@ -297,6 +297,24 @@ public abstract class Connection extends Conferenceable {
     */
     */
    public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT";
    public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT";


    /**
     * Connection event used to inform Telecom that it should play the on hold tone.  This is used
     * to play a tone when the peer puts the current call on hold.  Sent to Telecom via
     * {@link #sendConnectionEvent(String)}.
     * @hide
     */
    public static final String EVENT_ON_HOLD_TONE_START =
            "android.telecom.event.ON_HOLD_TONE_START";

    /**
     * Connection event used to inform Telecom that it should stop the on hold tone.  This is used
     * to stop a tone when the peer puts the current call on hold.  Sent to Telecom via
     * {@link #sendConnectionEvent(String)}.
     * @hide
     */
    public static final String EVENT_ON_HOLD_TONE_END =
            "android.telecom.event.ON_HOLD_TONE_END";

    // Flag controlling whether PII is emitted into the logs
    // Flag controlling whether PII is emitted into the logs
    private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
    private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);


@@ -447,6 +465,8 @@ public abstract class Connection extends Conferenceable {
        public void onConferenceStarted() {}
        public void onConferenceStarted() {}
        public void onConferenceMergeFailed(Connection c) {}
        public void onConferenceMergeFailed(Connection c) {}
        public void onExtrasChanged(Connection c, Bundle extras) {}
        public void onExtrasChanged(Connection c, Bundle extras) {}
        /** @hide */
        public void onConnectionEvent(Connection c, String event) {}
    }
    }


    /**
    /**
@@ -1986,4 +2006,16 @@ public abstract class Connection extends Conferenceable {
            l.onConferenceStarted();
            l.onConferenceStarted();
        }
        }
    }
    }

    /**
     * Sends a connection event to Telecom.
     *
     * @param event The connection event.
     * @hide
     */
    protected void sendConnectionEvent(String event) {
        for (Listener l : mListeners) {
            l.onConnectionEvent(this, event);
        }
    }
}
}
+8 −0
Original line number Original line Diff line number Diff line
@@ -613,6 +613,14 @@ public abstract class ConnectionService extends Service {
                mAdapter.setExtras(id, extras);
                mAdapter.setExtras(id, extras);
            }
            }
        }
        }

        @Override
        public void onConnectionEvent(Connection connection, String event) {
            String id = mIdByConnection.get(connection);
            if (id != null) {
                mAdapter.onConnectionEvent(id, event);
            }
        }
    };
    };


    /** {@inheritDoc} */
    /** {@inheritDoc} */
+16 −0
Original line number Original line Diff line number Diff line
@@ -412,4 +412,20 @@ final class ConnectionServiceAdapter implements DeathRecipient {
            }
            }
        }
        }
    }
    }

    /**
     * Informs Telecom of a connection level event.
     *
     * @param callId The unique ID of the call.
     * @param event The event.
     */
    void onConnectionEvent(String callId, String event) {
        Log.v(this, "onConnectionEvent: %s", event);
        for (IConnectionServiceAdapter adapter : mAdapters) {
            try {
                adapter.onConnectionEvent(callId, event);
            } catch (RemoteException ignored) {
            }
        }
    }
}
}
+18 −0
Original line number Original line Diff line number Diff line
@@ -62,6 +62,7 @@ final class ConnectionServiceAdapterServant {
    private static final int MSG_ON_POST_DIAL_CHAR = 22;
    private static final int MSG_ON_POST_DIAL_CHAR = 22;
    private static final int MSG_SET_CONFERENCE_MERGE_FAILED = 23;
    private static final int MSG_SET_CONFERENCE_MERGE_FAILED = 23;
    private static final int MSG_SET_EXTRAS = 24;
    private static final int MSG_SET_EXTRAS = 24;
    private static final int MSG_ON_CONNECTION_EVENT = 25;


    private final IConnectionServiceAdapter mDelegate;
    private final IConnectionServiceAdapter mDelegate;


@@ -240,6 +241,15 @@ final class ConnectionServiceAdapterServant {
                        args.recycle();
                        args.recycle();
                    }
                    }
                }
                }

                case MSG_ON_CONNECTION_EVENT: {
                    SomeArgs args = (SomeArgs) msg.obj;
                    try {
                        mDelegate.onConnectionEvent((String) args.arg1, (String) args.arg2);
                    } finally {
                        args.recycle();
                    }
                }
            }
            }
        }
        }
    };
    };
@@ -419,6 +429,14 @@ final class ConnectionServiceAdapterServant {
            args.arg2 = extras;
            args.arg2 = extras;
            mHandler.obtainMessage(MSG_SET_EXTRAS, args).sendToTarget();
            mHandler.obtainMessage(MSG_SET_EXTRAS, args).sendToTarget();
        }
        }

        @Override
        public final void onConnectionEvent(String connectionId, String event) {
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = connectionId;
            args.arg2 = event;
            mHandler.obtainMessage(MSG_ON_CONNECTION_EVENT, args).sendToTarget();
        }
    };
    };


    public ConnectionServiceAdapterServant(IConnectionServiceAdapter delegate) {
    public ConnectionServiceAdapterServant(IConnectionServiceAdapter delegate) {
+23 −0
Original line number Original line Diff line number Diff line
@@ -209,6 +209,15 @@ public final class RemoteConnection {
         * @param extras The extras containing other information associated with the connection.
         * @param extras The extras containing other information associated with the connection.
         */
         */
        public void onExtrasChanged(RemoteConnection connection, @Nullable Bundle extras) {}
        public void onExtrasChanged(RemoteConnection connection, @Nullable Bundle extras) {}

        /**
         * Handles a connection event propagated to this {@link RemoteConnection}.
         *
         * @param connection The {@code RemoteConnection} invoking this method.
         * @param event The connection event.
         * @hide
         */
        public void onConnectionEvent(RemoteConnection connection, String event) {}
    }
    }


    /**
    /**
@@ -1291,6 +1300,20 @@ public final class RemoteConnection {
        }
        }
    }
    }


    /** @hide */
    void onConnectionEvent(final String event) {
        for (CallbackRecord record : mCallbackRecords) {
            final RemoteConnection connection = this;
            final Callback callback = record.getCallback();
            record.getHandler().post(new Runnable() {
                @Override
                public void run() {
                    callback.onConnectionEvent(connection, event);
                }
            });
        }
    }

    /**
    /**
     * Create a RemoteConnection represents a failure, and which will be in
     * Create a RemoteConnection represents a failure, and which will be in
     * {@link Connection#STATE_DISCONNECTED}. Attempting to use it for anything will almost
     * {@link Connection#STATE_DISCONNECTED}. Attempting to use it for anything will almost
Loading