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

Commit 9044be13 authored by Youngsang Cho's avatar Youngsang Cho
Browse files

Send notification messages immediatelly

Notification messages are posted through a handler with a main thread.
When a caller of TIS.notifyXXX runs also in a main thread, the notification
is delivered after the method including the caller is finished.
So we added runOnMainThread and made notification messages sent through
runOnMainThread.

Change-Id: Ieb2c5c04ff031e42a532acfc45e0174563265c6b
parent cad78a80
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -300,7 +300,7 @@ public abstract class TvInputService extends Service {
            if (eventType == null) {
                throw new IllegalArgumentException("eventType should not be null.");
            }
            mHandler.post(new Runnable() {
            runOnMainThread(new Runnable() {
                @Override
                public void run() {
                    try {
@@ -319,7 +319,7 @@ public abstract class TvInputService extends Service {
         * @param channelUri The URI of a channel.
         */
        public void notifyChannelRetuned(final Uri channelUri) {
            mHandler.post(new Runnable() {
            runOnMainThread(new Runnable() {
                @Override
                public void run() {
                    try {
@@ -351,7 +351,7 @@ public abstract class TvInputService extends Service {
            trackIdSet.clear();

            // TODO: Validate the track list.
            mHandler.post(new Runnable() {
            runOnMainThread(new Runnable() {
                @Override
                public void run() {
                    try {
@@ -375,7 +375,7 @@ public abstract class TvInputService extends Service {
         * @see #onSelectTrack
         */
        public void notifyTrackSelected(final int type, final String trackId) {
            mHandler.post(new Runnable() {
            runOnMainThread(new Runnable() {
                @Override
                public void run() {
                    try {
@@ -393,7 +393,7 @@ public abstract class TvInputService extends Service {
         * been started.
         */
        public void notifyVideoAvailable() {
            mHandler.post(new Runnable() {
            runOnMainThread(new Runnable() {
                @Override
                public void run() {
                    try {
@@ -423,7 +423,7 @@ public abstract class TvInputService extends Service {
                    || reason > TvInputManager.VIDEO_UNAVAILABLE_REASON_END) {
                throw new IllegalArgumentException("Unknown reason: " + reason);
            }
            mHandler.post(new Runnable() {
            runOnMainThread(new Runnable() {
                @Override
                public void run() {
                    try {
@@ -462,7 +462,7 @@ public abstract class TvInputService extends Service {
         * @see TvInputManager
         */
        public void notifyContentAllowed() {
            mHandler.post(new Runnable() {
            runOnMainThread(new Runnable() {
                @Override
                public void run() {
                    try {
@@ -502,7 +502,7 @@ public abstract class TvInputService extends Service {
         * @see TvInputManager
         */
        public void notifyContentBlocked(final TvContentRating rating) {
            mHandler.post(new Runnable() {
            runOnMainThread(new Runnable() {
                @Override
                public void run() {
                    try {
@@ -531,7 +531,7 @@ public abstract class TvInputService extends Service {
            if (left > right || top > bottm) {
                throw new IllegalArgumentException("Invalid parameter");
            }
            mHandler.post(new Runnable() {
            runOnMainThread(new Runnable() {
                @Override
                public void run() {
                    try {
@@ -1049,6 +1049,14 @@ public abstract class TvInputService extends Service {
        private void setSessionCallback(ITvInputSessionCallback callback) {
            mSessionCallback = callback;
        }

        private final void runOnMainThread(Runnable action) {
            if (mHandler.getLooper().isCurrentThread()) {
                action.run();
            } else {
                mHandler.post(action);
            }
        }
    }

    /**