Normalize constructors of SessionTokenImplBase/SessionTokenImplLegacy

#minor-release

PiperOrigin-RevId: 463328436
This commit is contained in:
bachinger 2022-07-26 14:12:19 +00:00 committed by tonihei
parent 9c33b47f15
commit 428fc89635
2 changed files with 34 additions and 30 deletions

View File

@ -46,21 +46,22 @@ import java.lang.annotation.Target;
private final String serviceName; private final String serviceName;
@Nullable private final IBinder iSession;
@Nullable private final ComponentName componentName; @Nullable private final ComponentName componentName;
@Nullable private final IBinder iSession;
private final Bundle extras; private final Bundle extras;
public SessionTokenImplBase(ComponentName serviceComponent, int uid, int type) { public SessionTokenImplBase(ComponentName serviceComponent, int uid, int type) {
componentName = checkNotNull(serviceComponent); this(
packageName = serviceComponent.getPackageName(); uid,
serviceName = serviceComponent.getClassName(); type,
this.uid = uid; /* version= */ 0,
this.type = type; checkNotNull(serviceComponent).getPackageName(),
version = 0; /* serviceName= */ serviceComponent.getClassName(),
iSession = null; /* componentName= */ serviceComponent,
extras = Bundle.EMPTY; /* iSession= */ null,
/* extras= */ Bundle.EMPTY);
} }
public SessionTokenImplBase( public SessionTokenImplBase(
@ -70,14 +71,15 @@ import java.lang.annotation.Target;
String packageName, String packageName,
IMediaSession iSession, IMediaSession iSession,
Bundle tokenExtras) { Bundle tokenExtras) {
this.uid = uid; this(
this.type = type; uid,
this.version = version; type,
this.packageName = packageName; version,
serviceName = ""; checkNotNull(packageName),
componentName = null; /* serviceName= */ "",
this.iSession = iSession.asBinder(); /* componentName= */ null,
extras = checkNotNull(tokenExtras); iSession.asBinder(),
checkNotNull(tokenExtras));
} }
private SessionTokenImplBase( private SessionTokenImplBase(

View File

@ -53,21 +53,23 @@ import java.lang.annotation.Target;
public SessionTokenImplLegacy( public SessionTokenImplLegacy(
MediaSessionCompat.Token token, String packageName, int uid, Bundle extras) { MediaSessionCompat.Token token, String packageName, int uid, Bundle extras) {
legacyToken = checkNotNull(token); this(
this.uid = uid; checkNotNull(token),
this.packageName = checkNotEmpty(packageName); uid,
componentName = null; TYPE_SESSION_LEGACY,
type = TYPE_SESSION_LEGACY; /* componentName= */ null,
this.extras = checkNotNull(extras); checkNotEmpty(packageName),
checkNotNull(extras));
} }
public SessionTokenImplLegacy(ComponentName serviceComponent, int uid) { public SessionTokenImplLegacy(ComponentName serviceComponent, int uid) {
legacyToken = null; this(
this.uid = uid; /* legacyToken= */ null,
type = TYPE_BROWSER_SERVICE_LEGACY; uid,
packageName = checkNotNull(serviceComponent).getPackageName(); TYPE_BROWSER_SERVICE_LEGACY,
componentName = serviceComponent; /* componentName= */ checkNotNull(serviceComponent),
extras = Bundle.EMPTY; /* packageName= */ serviceComponent.getPackageName(),
/* extras= */ Bundle.EMPTY);
} }
private SessionTokenImplLegacy( private SessionTokenImplLegacy(