Merge "Added AntennaPosition.aidl" into udc-dev

This commit is contained in:
Aishwarya Mallampati
2023-04-11 01:21:11 +00:00
committed by Android (Google) Code Review
7 changed files with 410 additions and 3 deletions

View File

@@ -0,0 +1,19 @@
/*
* Copyright 2023, The Android Open Source Project
*
* 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 android.telephony.satellite;
parcelable AntennaDirection;

View File

@@ -0,0 +1,138 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* 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 android.telephony.satellite;
import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Objects;
/**
* Antenna direction is provided as X/Y/Z values corresponding to the direction of the antenna
* main lobe as a unit vector in CTIA coordinate system (as specified in Appendix A of Wireless
* device CTIA OTAn test plan). CTIA coordinate system is defined relative to device’s screen
* when the device is held in default portrait mode with screen facing the user:
*
* Z axis is vertical along the plane of the device with positive Z pointing up and negative z
* pointing towards bottom of the device
* Y axis is horizontal along the plane of the device with positive Y pointing towards right of
* the phone screen and negative Y pointing towards left
* X axis is orthogonal to the Y-Z plane (phone screen), pointing away from the phone screen for
* positive X and pointing away from back of the phone for negative X.
* @hide
*/
public final class AntennaDirection implements Parcelable {
/** Antenna x axis direction. */
private float mX;
/** Antenna y axis direction. */
private float mY;
/** Antenna z axis direction. */
private float mZ;
/**
* @hide
*/
@UnsupportedAppUsage
public AntennaDirection(float x, float y, float z) {
mX = x;
mY = y;
mZ = z;
}
private AntennaDirection(Parcel in) {
readFromParcel(in);
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(@NonNull Parcel out, int flags) {
out.writeFloat(mX);
out.writeFloat(mY);
out.writeFloat(mZ);
}
@NonNull
public static final Creator<AntennaDirection> CREATOR =
new Creator<>() {
@Override
public AntennaDirection createFromParcel(Parcel in) {
return new AntennaDirection(in);
}
@Override
public AntennaDirection[] newArray(int size) {
return new AntennaDirection[size];
}
};
@Override
@NonNull public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("X:");
sb.append(mX);
sb.append(",");
sb.append("Y:");
sb.append(mY);
sb.append(",");
sb.append("Z:");
sb.append(mZ);
return sb.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AntennaDirection that = (AntennaDirection) o;
return mX == that.mX
&& mY == that.mY
&& mZ == that.mZ;
}
@Override
public int hashCode() {
return Objects.hash(mX, mY, mZ);
}
public float getX() {
return mX;
}
public float getY() {
return mY;
}
public float getZ() {
return mZ;
}
private void readFromParcel(Parcel in) {
mX = in.readFloat();
mY = in.readFloat();
mZ = in.readFloat();
}
}

View File

@@ -0,0 +1,19 @@
/*
* Copyright 2023, The Android Open Source Project
*
* 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 android.telephony.satellite;
parcelable AntennaPosition;

View File

@@ -0,0 +1,117 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* 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 android.telephony.satellite;
import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Objects;
/**
* Antenna Position received from satellite modem which gives information about antenna
* direction to be used with satellite communication and suggested device hold positions.
* @hide
*/
public final class AntennaPosition implements Parcelable {
/** Antenna direction used for satellite communication. */
@NonNull AntennaDirection mAntennaDirection;
/** Enum corresponding to device hold position to be used by the end user. */
@SatelliteManager.DeviceHoldPosition int mSuggestedHoldPosition;
/**
* @hide
*/
@UnsupportedAppUsage
public AntennaPosition(@NonNull AntennaDirection antennaDirection, int suggestedHoldPosition) {
mAntennaDirection = antennaDirection;
mSuggestedHoldPosition = suggestedHoldPosition;
}
private AntennaPosition(Parcel in) {
readFromParcel(in);
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(@NonNull Parcel out, int flags) {
out.writeParcelable(mAntennaDirection, flags);
out.writeInt(mSuggestedHoldPosition);
}
@NonNull
public static final Creator<AntennaPosition> CREATOR =
new Creator<>() {
@Override
public AntennaPosition createFromParcel(Parcel in) {
return new AntennaPosition(in);
}
@Override
public AntennaPosition[] newArray(int size) {
return new AntennaPosition[size];
}
};
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AntennaPosition that = (AntennaPosition) o;
return Objects.equals(mAntennaDirection, that.mAntennaDirection)
&& mSuggestedHoldPosition == that.mSuggestedHoldPosition;
}
@Override
public int hashCode() {
return Objects.hash(mAntennaDirection, mSuggestedHoldPosition);
}
@Override
@NonNull public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("antennaDirection:");
sb.append(mAntennaDirection);
sb.append(",");
sb.append("suggestedHoldPosition:");
sb.append(mSuggestedHoldPosition);
return sb.toString();
}
@NonNull
public AntennaDirection getAntennaDirection() {
return mAntennaDirection;
}
@SatelliteManager.DeviceHoldPosition
public int getSuggestedHoldPosition() {
return mSuggestedHoldPosition;
}
private void readFromParcel(Parcel in) {
mAntennaDirection = in.readParcelable(AntennaDirection.class.getClassLoader(),
AntennaDirection.class);
mSuggestedHoldPosition = in.readInt();
}
}

View File

@@ -21,7 +21,10 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
/**
@@ -43,16 +46,26 @@ public final class SatelliteCapabilities implements Parcelable {
*/
private int mMaxBytesPerOutgoingDatagram;
/**
* Antenna Position received from satellite modem which gives information about antenna
* direction to be used with satellite communication and suggested device hold positions.
* Map key: {@link SatelliteManager.DeviceHoldPosition} value: AntennaPosition
*/
@NonNull
private Map<Integer, AntennaPosition> mAntennaPositionMap;
/**
* @hide
*/
@UnsupportedAppUsage
public SatelliteCapabilities(Set<Integer> supportedRadioTechnologies,
boolean isPointingRequired, int maxBytesPerOutgoingDatagram) {
boolean isPointingRequired, int maxBytesPerOutgoingDatagram,
@NonNull Map<Integer, AntennaPosition> antennaPositionMap) {
mSupportedRadioTechnologies = supportedRadioTechnologies == null
? new HashSet<>() : supportedRadioTechnologies;
mIsPointingRequired = isPointingRequired;
mMaxBytesPerOutgoingDatagram = maxBytesPerOutgoingDatagram;
mAntennaPositionMap = antennaPositionMap;
}
private SatelliteCapabilities(Parcel in) {
@@ -77,6 +90,17 @@ public final class SatelliteCapabilities implements Parcelable {
out.writeBoolean(mIsPointingRequired);
out.writeInt(mMaxBytesPerOutgoingDatagram);
if (mAntennaPositionMap != null && !mAntennaPositionMap.isEmpty()) {
int size = mAntennaPositionMap.size();
out.writeInt(size);
for (Map.Entry<Integer, AntennaPosition> entry : mAntennaPositionMap.entrySet()) {
out.writeInt(entry.getKey());
out.writeParcelable(entry.getValue(), flags);
}
} else {
out.writeInt(0);
}
}
@NonNull public static final Creator<SatelliteCapabilities> CREATOR = new Creator<>() {
@@ -109,11 +133,32 @@ public final class SatelliteCapabilities implements Parcelable {
sb.append(mIsPointingRequired);
sb.append(",");
sb.append("maxBytesPerOutgoingDatagram");
sb.append("maxBytesPerOutgoingDatagram:");
sb.append(mMaxBytesPerOutgoingDatagram);
sb.append(",");
sb.append("antennaPositionMap:");
sb.append(mAntennaPositionMap);
return sb.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SatelliteCapabilities that = (SatelliteCapabilities) o;
return Objects.equals(mSupportedRadioTechnologies, that.mSupportedRadioTechnologies)
&& mIsPointingRequired == that.mIsPointingRequired
&& mMaxBytesPerOutgoingDatagram == that.mMaxBytesPerOutgoingDatagram
&& Objects.equals(mAntennaPositionMap, that.mAntennaPositionMap);
}
@Override
public int hashCode() {
return Objects.hash(mSupportedRadioTechnologies, mIsPointingRequired,
mMaxBytesPerOutgoingDatagram, mAntennaPositionMap);
}
/**
* @return The list of technologies supported by the satellite modem.
*/
@@ -141,6 +186,16 @@ public final class SatelliteCapabilities implements Parcelable {
return mMaxBytesPerOutgoingDatagram;
}
/**
* Antenna Position received from satellite modem which gives information about antenna
* direction to be used with satellite communication and suggested device hold positions.
* @return Map key: {@link SatelliteManager.DeviceHoldPosition} value: AntennaPosition
*/
@NonNull
public Map<Integer, AntennaPosition> getAntennaPositionMap() {
return mAntennaPositionMap;
}
private void readFromParcel(Parcel in) {
mSupportedRadioTechnologies = new HashSet<>();
int numSupportedRadioTechnologies = in.readInt();
@@ -152,5 +207,14 @@ public final class SatelliteCapabilities implements Parcelable {
mIsPointingRequired = in.readBoolean();
mMaxBytesPerOutgoingDatagram = in.readInt();
mAntennaPositionMap = new HashMap<>();
int antennaPositionMapSize = in.readInt();
for (int i = 0; i < antennaPositionMapSize; i++) {
int key = in.readInt();
AntennaPosition antennaPosition = in.readParcelable(
AntennaPosition.class.getClassLoader(), AntennaPosition.class);
mAntennaPositionMap.put(key, antennaPosition);
}
}
}

View File

@@ -334,6 +334,46 @@ public class SatelliteManager {
@Retention(RetentionPolicy.SOURCE)
public @interface NTRadioTechnology {}
/** Suggested device hold position is unknown. */
public static final int DEVICE_HOLD_POSITION_UNKNOWN = 0;
/** User is suggested to hold the device in portrait mode. */
public static final int DEVICE_HOLD_POSITION_PORTRAIT = 1;
/** User is suggested to hold the device in landscape mode with left hand. */
public static final int DEVICE_HOLD_POSITION_LANDSCAPE_LEFT = 2;
/** User is suggested to hold the device in landscape mode with right hand. */
public static final int DEVICE_HOLD_POSITION_LANDSCAPE_RIGHT = 3;
/** @hide */
@IntDef(prefix = {"DEVICE_HOLD_POSITION_"}, value = {
DEVICE_HOLD_POSITION_UNKNOWN,
DEVICE_HOLD_POSITION_PORTRAIT,
DEVICE_HOLD_POSITION_LANDSCAPE_LEFT,
DEVICE_HOLD_POSITION_LANDSCAPE_RIGHT
})
@Retention(RetentionPolicy.SOURCE)
public @interface DeviceHoldPosition {}
/** Display mode is unknown. */
public static final int DISPLAY_MODE_UNKNOWN = 0;
/** Display mode of the device used for satellite communication for non-foldable phones. */
public static final int DISPLAY_MODE_FIXED = 1;
/** Display mode of the device used for satellite communication for foldabale phones when the
* device is opened. */
public static final int DISPLAY_MODE_OPENED = 2;
/** Display mode of the device used for satellite communication for foldabable phones when the
* device is closed. */
public static final int DISPLAY_MODE_CLOSED = 3;
/** @hide */
@IntDef(prefix = {"ANTENNA_POSITION_"}, value = {
DISPLAY_MODE_UNKNOWN,
DISPLAY_MODE_FIXED,
DISPLAY_MODE_OPENED,
DISPLAY_MODE_CLOSED
})
@Retention(RetentionPolicy.SOURCE)
public @interface DisplayMode {}
/**
* Request to enable or disable the satellite modem and demo mode. If the satellite modem is
* enabled, this may also disable the cellular modem, and if the satellite modem is disabled,

View File

@@ -17,7 +17,7 @@
package android.telephony.satellite.stub;
import android.telephony.satellite.stub.NTRadioTechnology;
import android.telephony.satellite.AntennaPosition;
/**
* {@hide}
*/
@@ -36,4 +36,14 @@ parcelable SatelliteCapabilities {
* The maximum number of bytes per datagram that can be sent over satellite.
*/
int maxBytesPerOutgoingDatagram;
/**
* Keys which are used to fill mAntennaPositionMap.
*/
int[] antennaPositionKeys;
/**
* Antenna Position for different display modes received from satellite modem.
*/
AntennaPosition[] antennaPositionValues;
}