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

View File

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