Do not require package visibility when obtaining SessionTokens
The only reason this is required at the moment is to set the process UID field in the token, that is supposed to make it easier for controller apps to identify the session. However, if this visibility is not provided, it shouldn't stop us from creating the controller for this session. Also docuement more clearly what UID means in this context. PiperOrigin-RevId: 490184508
This commit is contained in:
parent
45b8fb0ae1
commit
c41a5c8420
@ -36,6 +36,7 @@ import androidx.annotation.IntDef;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media.MediaBrowserServiceCompat;
|
import androidx.media.MediaBrowserServiceCompat;
|
||||||
import androidx.media3.common.Bundleable;
|
import androidx.media3.common.Bundleable;
|
||||||
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.MediaLibraryInfo;
|
import androidx.media3.common.MediaLibraryInfo;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
@ -179,7 +180,11 @@ public final class SessionToken implements Bundleable {
|
|||||||
return impl.toString();
|
return impl.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the uid of the session */
|
/**
|
||||||
|
* Returns the UID of the session process, or {@link C#INDEX_UNSET} if the UID can't be determined
|
||||||
|
* due to missing <a href="https://developer.android.com/training/package-visibility">package
|
||||||
|
* visibility</a>.
|
||||||
|
*/
|
||||||
public int getUid() {
|
public int getUid() {
|
||||||
return impl.getUid();
|
return impl.getUid();
|
||||||
}
|
}
|
||||||
@ -393,8 +398,7 @@ public final class SessionToken implements Bundleable {
|
|||||||
try {
|
try {
|
||||||
return manager.getApplicationInfo(packageName, 0).uid;
|
return manager.getApplicationInfo(packageName, 0).uid;
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
throw new IllegalArgumentException(
|
return C.INDEX_UNSET;
|
||||||
"Cannot find package " + packageName + " or package is not visible", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user