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

Commit 9710469f authored by Hangyu Kuang's avatar Hangyu Kuang Committed by Android (Google) Code Review
Browse files

Merge "transcoding: Add a new API for client to add UID for a session." into sc-dev

parents 56a9d29c 42eb1711
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -25,7 +25,9 @@ package android.media {
  }

  public static final class MediaTranscodeManager.TranscodingSession {
    method public void addClientUid(int);
    method public void cancel();
    method @NonNull public java.util.List<java.lang.Integer> getClientUids();
    method public int getErrorCode();
    method @IntRange(from=0, to=100) public int getProgress();
    method public int getResult();
+33 −0
Original line number Diff line number Diff line
@@ -1352,6 +1352,8 @@ public final class MediaTranscodeManager {
        private @TranscodingSessionErrorCode int mErrorCode = ERROR_NONE;
        @GuardedBy("mLock")
        private boolean mHasRetried = false;
        @GuardedBy("mLock")
        private @NonNull List<Integer> mClientUidList = new ArrayList<>();
        // The original request that associated with this session.
        private final TranscodingRequest mRequest;

@@ -1370,6 +1372,7 @@ public final class MediaTranscodeManager {
            mListenerExecutor = executor;
            mListener = listener;
            mRequest = request;
            mClientUidList.add(request.getClientUid());
        }

        /**
@@ -1514,6 +1517,36 @@ public final class MediaTranscodeManager {
            }
        }

        /**
         * Adds a client uid that is also waiting for this transcoding session.
         * <p>
         * Only privilege caller with android.permission.WRITE_MEDIA_STORAGE could add the
         * uid. Note that the permission check happens on the service side upon starting the
         * transcoding. If the client does not have the permission, the transcoding will fail.
         */
        public void addClientUid(int uid) {
            if (uid < 0) {
                throw new IllegalArgumentException("Invalid Uid");
            }
            synchronized (mLock) {
                if (!mClientUidList.contains(uid)) {
                    // see ag/14023202 for implementation
                    mClientUidList.add(uid);
                }
            }
        }

        /**
         * Query all the client that waiting for this transcoding session
         * @return a list containing all the client uids.
         */
        @NonNull
        public List<Integer> getClientUids() {
            synchronized (mLock) {
                return mClientUidList;
            }
        }

        /**
         * Gets sessionId of the transcoding session.
         * @return session id.