transcoding: Add a new API for client to add UID for a session.
This is needed for MediaProvider to append a UID to an existing transcoding session when there are multiple client waiting for the file to be transcoded. Bug: 171398942 Test: atest CtsMediaTranscodingTestCases:MediaTranscodeManagerTest Change-Id: I58e561f7afed16314349764195a65386d1d0b909
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user