Skip to content

Commit

Permalink
Future proof ShadowCompanionDeviceManager for AssociationInfo change.
Browse files Browse the repository at this point in the history
Use AssociationInfoBuilder in ShadowCompanionDeviceManager to prepare
for future AssociationInfo constructor signature change.

PiperOrigin-RevId: 516992437
  • Loading branch information
brettchabot authored and Copybara-Service committed Mar 16, 2023
1 parent 2ff5f86 commit a67b090
Showing 1 changed file with 12 additions and 12 deletions.
Expand Up @@ -7,7 +7,6 @@
import android.companion.AssociationRequest;
import android.companion.CompanionDeviceManager;
import android.content.ComponentName;
import android.net.MacAddress;
import android.os.Build.VERSION_CODES;
import android.os.Handler;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -129,17 +128,18 @@ protected List<AssociationInfo> getMyAssociations() {

/** Convert {@link RoboAssociationInfo} to actual {@link AssociationInfo}. */
private AssociationInfo createAssociationInfo(RoboAssociationInfo info) {
return new AssociationInfo(
info.id(),
info.userId(),
info.packageName(),
MacAddress.fromString(info.deviceMacAddress()),
info.displayName(),
info.deviceProfile(),
info.selfManaged(),
info.notifyOnDeviceNearby(),
info.timeApprovedMs(),
info.lastTimeConnectedMs());
return AssociationInfoBuilder.newBuilder()
.setId(info.id())
.setUserId(info.userId())
.setPackageName(info.packageName())
.setDeviceMacAddress(info.deviceMacAddress())
.setDisplayName(info.displayName())
.setDeviceProfile(info.deviceProfile())
.setSelfManaged(info.selfManaged())
.setNotifyOnDeviceNearby(info.notifyOnDeviceNearby())
.setApprovedMs(info.timeApprovedMs())
.setLastTimeConnectedMs(info.lastTimeConnectedMs())
.build();
}

private RoboAssociationInfo createShadowAssociationInfo(AssociationInfo info) {
Expand Down

0 comments on commit a67b090

Please sign in to comment.