• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.telephony.satellite;
18 
19 import android.annotation.FlaggedApi;
20 import android.annotation.NonNull;
21 import android.annotation.SystemApi;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 
25 import com.android.internal.telephony.flags.Flags;
26 
27 import java.util.Objects;
28 
29 /**
30  * SatelliteModemEnableRequestAttributes is used to pack info needed by modem to allow carrier to
31  * roam to satellite.
32  * These attributes will be used by modem to decide how they should act,
33  * decide how to attach to the network and whether to enable or disable satellite mode.
34  * @hide
35  */
36 @SystemApi
37 @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS)
38 public final class SatelliteModemEnableRequestAttributes implements Parcelable {
39 
40     /** {@code true} to enable satellite and {@code false} to disable satellite */
41     private final boolean mIsEnabled;
42     /**
43      * {@code true} to enable demo mode and {@code false} to disable. When disabling satellite,
44      * {@code mIsDemoMode} is always considered as {@code false} by Telephony.
45      */
46     private final boolean mIsForDemoMode;
47     /**
48      * {@code true} means satellite is enabled for emergency mode, {@code false} otherwise. When
49      * disabling satellite, {@code isEmergencyMode} is always considered as {@code false} by
50      * Telephony.
51      */
52     private final boolean mIsForEmergencyMode;
53 
54     /** The subscription related info */
55     @NonNull private final SatelliteSubscriptionInfo mSatelliteSubscriptionInfo;
56 
57     /**
58      * Constructor for SatelliteModemEnableRequestAttributes objects.
59      * @param isEnabled {@code true} to enable satellite and {@code false} to disable satellite
60      * @param isForDemoMode {@code true} to enable demo mode and {@code false} to disable.
61      * @param isForEmergencyMode {@code true} means satellite is enabled for emergency mode,
62      *                        {@code false} otherwise.
63      * @param satelliteSubscriptionInfo satellite subscription related info.
64      */
SatelliteModemEnableRequestAttributes(boolean isEnabled, boolean isForDemoMode, boolean isForEmergencyMode, @NonNull SatelliteSubscriptionInfo satelliteSubscriptionInfo)65     public SatelliteModemEnableRequestAttributes(boolean isEnabled, boolean isForDemoMode,
66             boolean isForEmergencyMode,
67             @NonNull SatelliteSubscriptionInfo satelliteSubscriptionInfo) {
68         mIsEnabled = isEnabled;
69         mIsForDemoMode = isForDemoMode;
70         mIsForEmergencyMode = isForEmergencyMode;
71         mSatelliteSubscriptionInfo = satelliteSubscriptionInfo;
72     }
73 
SatelliteModemEnableRequestAttributes(Parcel in)74     private SatelliteModemEnableRequestAttributes(Parcel in) {
75         mIsEnabled = in.readBoolean();
76         mIsForDemoMode = in.readBoolean();
77         mIsForEmergencyMode = in.readBoolean();
78         mSatelliteSubscriptionInfo = in.readParcelable(
79                 SatelliteSubscriptionInfo.class.getClassLoader(), SatelliteSubscriptionInfo.class);
80     }
81 
82     @Override
describeContents()83     public int describeContents() {
84         return 0;
85     }
86 
87     @Override
writeToParcel(@onNull Parcel dest, int flags)88     public void writeToParcel(@NonNull Parcel dest, int flags) {
89         dest.writeBoolean(mIsEnabled);
90         dest.writeBoolean(mIsForDemoMode);
91         dest.writeBoolean(mIsForEmergencyMode);
92         mSatelliteSubscriptionInfo.writeToParcel(dest, flags);
93     }
94 
95     @NonNull
96     public static final Creator<SatelliteModemEnableRequestAttributes> CREATOR = new Creator<>() {
97         @Override
98         public SatelliteModemEnableRequestAttributes createFromParcel(Parcel in) {
99             return new SatelliteModemEnableRequestAttributes(in);
100         }
101 
102         @Override
103         public SatelliteModemEnableRequestAttributes[] newArray(int size) {
104             return new SatelliteModemEnableRequestAttributes[size];
105         }
106     };
107 
108     @Override
toString()109     public String toString() {
110         return (new StringBuilder()).append("SatelliteModemEnableRequestAttributes{")
111                 .append(", mIsEnabled=").append(mIsEnabled)
112                 .append(", mIsForDemoMode=").append(mIsForDemoMode)
113                 .append(", mIsForEmergencyMode=").append(mIsForEmergencyMode)
114                 .append("mSatelliteSubscriptionInfo=").append(mSatelliteSubscriptionInfo)
115                 .append("}")
116                 .toString();
117     }
118 
119     @Override
equals(Object o)120     public boolean equals(Object o) {
121         if (this == o) return true;
122         if (o == null || getClass() != o.getClass()) return false;
123         SatelliteModemEnableRequestAttributes that = (SatelliteModemEnableRequestAttributes) o;
124         return mIsEnabled == that.mIsEnabled && mIsForDemoMode == that.mIsForDemoMode
125                 && mIsForEmergencyMode == that.mIsForEmergencyMode
126                 && mSatelliteSubscriptionInfo.equals(that.mSatelliteSubscriptionInfo);
127     }
128 
129     @Override
hashCode()130     public int hashCode() {
131         return Objects.hash(mIsEnabled, mIsForDemoMode, mIsForEmergencyMode,
132                 mSatelliteSubscriptionInfo);
133     }
134 
135 
136     /**
137      * Get whether satellite modem needs to be enabled or disabled.
138      * @return {@code true} if the request is to enable satellite, else {@code false} to disable
139      * satellite.
140      */
isEnabled()141     public boolean isEnabled() {
142         return mIsEnabled;
143     }
144 
145     /**
146      * Get whether satellite modem is enabled for demo mode.
147      * @return {@code true} if the request is to enable demo mode, else {@code false}.
148      */
isForDemoMode()149     public boolean isForDemoMode() {
150         return mIsForDemoMode;
151     }
152 
153     /**
154      * Get whether satellite modem is enabled for emergency mode.
155      * @return {@code true} if the request is to enable satellite for emergency mode,
156      * else {@code false}.
157      */
isForEmergencyMode()158     public boolean isForEmergencyMode() {
159         return mIsForEmergencyMode;
160     }
161 
162 
163     /**
164      * Return subscription info related to satellite.
165      */
166     @NonNull
getSatelliteSubscriptionInfo()167     public SatelliteSubscriptionInfo getSatelliteSubscriptionInfo() {
168         return mSatelliteSubscriptionInfo;
169     }
170 }
171