1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.ranging; 18 19 import android.annotation.FlaggedApi; 20 import android.annotation.IntDef; 21 import android.annotation.SuppressLint; 22 import android.os.Parcelable; 23 import android.ranging.oob.OobInitiatorRangingConfig; 24 import android.ranging.oob.OobResponderRangingConfig; 25 import android.ranging.raw.RawInitiatorRangingConfig; 26 import android.ranging.raw.RawResponderRangingConfig; 27 28 import com.android.ranging.flags.Flags; 29 30 import java.lang.annotation.Retention; 31 import java.lang.annotation.RetentionPolicy; 32 33 /** 34 * Abstract class to represent type of ranging configuration. 35 * 36 * <p>Subclasses include:</p> 37 * <ul> 38 * <li>{@link RawResponderRangingConfig}</li> 39 * <li>{@link RawInitiatorRangingConfig}</li> 40 * <li>{@link OobResponderRangingConfig}</li> 41 * <li>{@link OobInitiatorRangingConfig}</li> 42 * </ul> 43 */ 44 @FlaggedApi(Flags.FLAG_RANGING_STACK_ENABLED) 45 @SuppressLint({"ParcelCreator", "ParcelNotFinal"}) 46 public abstract class RangingConfig implements Parcelable { 47 /** 48 * @hide 49 */ 50 @Retention(RetentionPolicy.SOURCE) 51 @IntDef({ 52 RANGING_SESSION_RAW, 53 RANGING_SESSION_OOB, 54 }) 55 public @interface RangingSessionType { 56 } 57 RangingConfig()58 protected RangingConfig() { } 59 60 /** Ranging session with the out-of-band negotiations performed by the app. */ 61 public static final int RANGING_SESSION_RAW = 0; 62 /** Ranging session with the out-of-band negotiations performed by the ranging API. */ 63 public static final int RANGING_SESSION_OOB = 1; 64 65 @RangingSessionType 66 private int mRangingSessionType; 67 68 /** 69 * @hide 70 */ setRangingSessionType(@angingSessionType int rangingSessionType)71 protected void setRangingSessionType(@RangingSessionType int rangingSessionType) { 72 mRangingSessionType = rangingSessionType; 73 } 74 75 /** 76 * Gets the ranging session type {@link RangingSessionType} 77 * 78 * @return the type of ranging session. 79 */ getRangingSessionType()80 public int getRangingSessionType() { 81 return mRangingSessionType; 82 } 83 84 @Override toString()85 public String toString() { 86 return "RangingParams{ " 87 + "mRangingSessionType=" 88 + mRangingSessionType 89 + " }"; 90 } 91 } 92