Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee9cd185 authored by Aishwarya Mallampati's avatar Aishwarya Mallampati Committed by Android (Google) Code Review
Browse files

Merge "Added AntennaPosition.aidl"

parents dc26c77f 1427eb3d
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
/*
 * 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;
+138 −0
Original line number Diff line number Diff line
/*
 * 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();
    }
}
+19 −0
Original line number Diff line number Diff line
/*
 * 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;
+117 −0
Original line number Diff line number Diff line
/*
 * 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();
    }
}
+66 −2
Original line number Diff line number Diff line
@@ -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);
        }
    }
}
Loading