VancedMicroG/play-services-cast-api/src/main/java/com/google/android/gms/cast/CastDevice.java

153 lines
3.6 KiB
Java
Raw Normal View History

2015-09-28 16:27:29 +00:00
/*
2017-06-12 22:11:15 +00:00
* Copyright (C) 2013-2017 microG Project Team
2015-09-28 16:27:29 +00:00
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.gms.cast;
import android.os.Bundle;
import android.text.TextUtils;
import com.google.android.gms.common.images.WebImage;
import org.microg.gms.common.PublicApi;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
import java.net.Inet4Address;
import java.util.ArrayList;
import java.util.List;
@PublicApi
public class CastDevice extends AutoSafeParcelable {
private static final String EXTRA_CAST_DEVICE = "com.google.android.gms.cast.EXTRA_CAST_DEVICE";
2015-10-02 01:22:02 +00:00
/**
* Video-output device capability.
*/
2015-09-28 16:27:29 +00:00
public static final int CAPABILITY_VIDEO_OUT = 1;
2015-10-02 01:22:02 +00:00
/**
* Video-input device capability.
*/
2015-09-28 16:27:29 +00:00
public static final int CAPABILITY_VIDEO_IN = 2;
2015-10-02 01:22:02 +00:00
/**
* Audio-output device capability.
*/
2015-09-28 16:27:29 +00:00
public static final int CAPABILITY_AUDIO_OUT = 4;
2015-10-02 01:22:02 +00:00
/**
* Audio-input device capability.
*/
2015-09-28 16:27:29 +00:00
public static final int CAPABILITY_AUDIO_IN = 8;
@SafeParceled(1)
2015-10-02 01:22:02 +00:00
private int versionCode = 3;
@SafeParceled(2)
private String deviceId;
2015-09-28 16:27:29 +00:00
@SafeParceled(3)
private String addrString;
private Inet4Address addr;
2015-10-02 01:22:02 +00:00
@SafeParceled(4)
private String friendlyName;
2015-09-28 16:27:29 +00:00
2015-10-02 01:22:02 +00:00
@SafeParceled(5)
private String modelName;
2015-09-28 16:27:29 +00:00
2015-10-02 01:22:02 +00:00
@SafeParceled(6)
private String deviceVersion;
2015-09-28 16:27:29 +00:00
2015-10-02 01:22:02 +00:00
@SafeParceled(7)
2015-09-28 16:27:29 +00:00
private int servicePort;
@SafeParceled(value = 8, subClass = WebImage.class)
private ArrayList<WebImage> icons;
2015-10-02 01:22:02 +00:00
@SafeParceled(8)
private int capabilities;
@SafeParceled(9)
private int status;
2015-09-28 16:27:29 +00:00
public String getDeviceId() {
return deviceId;
}
public String getDeviceVersion() {
return deviceVersion;
}
public String getFriendlyName() {
return friendlyName;
}
public static CastDevice getFromBundle(Bundle extras) {
if (extras == null) {
return null;
}
extras.setClassLoader(CastDevice.class.getClassLoader());
return extras.getParcelable(EXTRA_CAST_DEVICE);
}
public WebImage getIcon(int preferredWidth, int preferredHeight) {
return null;
}
public List<WebImage> getIcons() {
return icons;
}
public Inet4Address getIpAddress() {
return addr;
}
public String getModelName() {
2015-10-02 01:22:02 +00:00
return modelName;
2015-09-28 16:27:29 +00:00
}
public int getServicePort() {
return servicePort;
}
public boolean hasCapabilities(int[] capabilities) {
return false;
}
public boolean hasCapability(int capability) {
2015-10-02 01:22:02 +00:00
return (capability & capabilities) == capability;
2015-09-28 16:27:29 +00:00
}
public boolean hasIcons() {
return !icons.isEmpty();
}
public boolean isOnLocalNetwork() {
return false;
}
public boolean isSameDevice(CastDevice castDevice) {
return TextUtils.equals(castDevice.deviceId, deviceId);
}
public void putInBundle(Bundle bundle) {
bundle.putParcelable(EXTRA_CAST_DEVICE, this);
}
public static Creator<CastDevice> CREATOR = new AutoCreator<CastDevice>(CastDevice.class);
}