summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hangyu Kuang <hkuang@google.com> 2021-04-08 16:48:23 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-04-08 16:48:23 +0000
commit44772ed462d394489afca07d56fef272b7df3b8c (patch)
treebc95fd8fb5cc8e892812b0df82053f7797dbeded
parentbd888709ffcd1b34a84dde90852ca431f844b668 (diff)
parenta737118adea9827c1a422379e3bcf1745cbe75db (diff)
Merge "transcoding: Connect the new addClientUid with service." into sc-dev
-rw-r--r--apex/media/framework/api/system-current.txt2
-rw-r--r--apex/media/framework/java/android/media/MediaTranscodeManager.java47
2 files changed, 38 insertions, 11 deletions
diff --git a/apex/media/framework/api/system-current.txt b/apex/media/framework/api/system-current.txt
index 7df0b4be95c0..ce68447df051 100644
--- a/apex/media/framework/api/system-current.txt
+++ b/apex/media/framework/api/system-current.txt
@@ -25,7 +25,7 @@ package android.media {
}
public static final class MediaTranscodeManager.TranscodingSession {
- method public void addClientUid(int);
+ method public boolean addClientUid(int);
method public void cancel();
method @NonNull public java.util.List<java.lang.Integer> getClientUids();
method public int getErrorCode();
diff --git a/apex/media/framework/java/android/media/MediaTranscodeManager.java b/apex/media/framework/java/android/media/MediaTranscodeManager.java
index a7de602abc1e..d7e960942eae 100644
--- a/apex/media/framework/java/android/media/MediaTranscodeManager.java
+++ b/apex/media/framework/java/android/media/MediaTranscodeManager.java
@@ -1361,8 +1361,6 @@ 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;
@@ -1381,7 +1379,6 @@ public final class MediaTranscodeManager {
mListenerExecutor = executor;
mListener = listener;
mRequest = request;
- mClientUidList.add(request.getClientUid());
}
/**
@@ -1532,17 +1529,31 @@ public final class MediaTranscodeManager {
* 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.
+ * @param uid the additional client uid to be added.
+ * @return true if successfully added, false otherwise.
*/
- public void addClientUid(int uid) {
+ public boolean 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);
+
+ // Get the client interface.
+ ITranscodingClient client = mManager.getTranscodingClient();
+ if (client == null) {
+ Log.e(TAG, "Service is dead...");
+ return false;
+ }
+
+ try {
+ if (!client.addClientUid(mSessionId, uid)) {
+ Log.e(TAG, "Failed to add client uid");
+ return false;
}
+ } catch (Exception ex) {
+ Log.e(TAG, "Failed to get client uids due to " + ex);
+ return false;
}
+ return true;
}
/**
@@ -1551,9 +1562,25 @@ public final class MediaTranscodeManager {
*/
@NonNull
public List<Integer> getClientUids() {
- synchronized (mLock) {
- return mClientUidList;
+ List<Integer> uidList = new ArrayList<Integer>();
+
+ // Get the client interface.
+ ITranscodingClient client = mManager.getTranscodingClient();
+ if (client == null) {
+ Log.e(TAG, "Service is dead...");
+ return uidList;
}
+
+ try {
+ int[] clientUids = client.getClientUids(mSessionId);
+ for (int i : clientUids) {
+ uidList.add(i);
+ }
+ } catch (Exception ex) {
+ Log.e(TAG, "Failed to get client uids due to " + ex);
+ }
+
+ return uidList;
}
/**