Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
6541aa34
Commit
6541aa34
authored
1 year ago
by
Arun Voddu
Committed by
Android (Google) Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "Add support to fetch more parameters of carrier restriction" into main
parents
10b14e22
714b158c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
telephony/java/android/telephony/CarrierInfo.java
+236
-0
236 additions, 0 deletions
telephony/java/android/telephony/CarrierInfo.java
telephony/java/android/telephony/CarrierRestrictionRules.java
+137
-4
137 additions, 4 deletions
...phony/java/android/telephony/CarrierRestrictionRules.java
with
373 additions
and
4 deletions
telephony/java/android/telephony/CarrierInfo.java
0 → 100644
+
236
−
0
View file @
6541aa34
/*
* Copyright (C) 2024 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
;
import
android.annotation.Nullable
;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
android.util.Log
;
import
androidx.annotation.NonNull
;
import
com.android.telephony.Rlog
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* CarrierInfo that is used to represent the carrier lock information details.
*
* @hide
*/
public
final
class
CarrierInfo
implements
Parcelable
{
/**
* Used to create a {@link CarrierInfo} from a {@link Parcel}.
*
* @hide
*/
public
static
final
@android
.
annotation
.
NonNull
Creator
<
CarrierInfo
>
CREATOR
=
new
Creator
<
CarrierInfo
>()
{
/**
* Create a new instance of the Parcelable class, instantiating it
* from the given Parcel whose data had previously been written by
* {@link Parcelable#writeToParcel Parcelable.writeToParcel()}.
*
* @param source The Parcel to read the object's data from.
* @return Returns a new instance of the Parcelable class.
*/
@Override
public
CarrierInfo
createFromParcel
(
Parcel
source
)
{
return
new
CarrierInfo
(
source
);
}
/**
* Create a new array of the Parcelable class.
*
* @param size Size of the array.
* @return Returns an array of the Parcelable class, with every entry
* initialized to null.
*/
@Override
public
CarrierInfo
[]
newArray
(
int
size
)
{
return
new
CarrierInfo
[
size
];
}
};
@NonNull
private
String
mMcc
;
@NonNull
private
String
mMnc
;
@Nullable
private
String
mSpn
;
@Nullable
private
String
mGid1
;
@Nullable
private
String
mGid2
;
@Nullable
private
String
mImsiPrefix
;
/** Ehplmn is String combination of MCC,MNC */
@Nullable
private
List
<
String
>
mEhplmn
;
@Nullable
private
String
mIccid
;
@Nullable
private
String
mImpi
;
/** @hide */
@NonNull
public
String
getMcc
()
{
return
mMcc
;
}
/** @hide */
@NonNull
public
String
getMnc
()
{
return
mMnc
;
}
/** @hide */
@Nullable
public
String
getSpn
()
{
return
mSpn
;
}
/** @hide */
@Nullable
public
String
getGid1
()
{
return
mGid1
;
}
/** @hide */
@Nullable
public
String
getGid2
()
{
return
mGid2
;
}
/** @hide */
@Nullable
public
String
getImsiPrefix
()
{
return
mImsiPrefix
;
}
/** @hide */
@Nullable
public
String
getIccid
()
{
return
mIccid
;
}
/** @hide */
@Nullable
public
String
getImpi
()
{
return
mImpi
;
}
/**
* Returns the list of EHPLMN.
*
* @return List of String that represent Ehplmn.
* @hide
*/
@NonNull
public
List
<
String
>
getEhplmn
()
{
return
mEhplmn
;
}
/** @hide */
public
CarrierInfo
(
@NonNull
String
mcc
,
@NonNull
String
mnc
,
@Nullable
String
spn
,
@Nullable
String
gid1
,
@Nullable
String
gid2
,
@Nullable
String
imsi
,
@Nullable
String
iccid
,
@Nullable
String
impi
,
@Nullable
List
<
String
>
plmnArrayList
)
{
mMcc
=
mcc
;
mMnc
=
mnc
;
mSpn
=
spn
;
mGid1
=
gid1
;
mGid2
=
gid2
;
mImsiPrefix
=
imsi
;
mIccid
=
iccid
;
mImpi
=
impi
;
mEhplmn
=
plmnArrayList
;
}
/**
* Describe the kinds of special objects contained in this Parcelable
* instance's marshaled representation. For example, if the object will
* include a file descriptor in the output of {@link #writeToParcel(Parcel, int)},
* the return value of this method must include the
* {@link #CONTENTS_FILE_DESCRIPTOR} bit.
*
* @return a bitmask indicating the set of special object types marshaled
* by this Parcelable object instance.
* @hide
*/
@Override
public
int
describeContents
()
{
return
0
;
}
/**
* Flatten this object in to a Parcel.
*
* @param dest The Parcel in which the object should be written.
* @param flags Additional flags about how the object should be written.
* May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}.
* @hide
*/
@Override
public
void
writeToParcel
(
@NonNull
Parcel
dest
,
int
flags
)
{
dest
.
writeString8
(
mMcc
);
dest
.
writeString8
(
mMnc
);
dest
.
writeString8
(
mSpn
);
dest
.
writeString8
(
mGid1
);
dest
.
writeString8
(
mGid2
);
dest
.
writeString8
(
mImsiPrefix
);
dest
.
writeString8
(
mIccid
);
dest
.
writeString8
(
mImpi
);
dest
.
writeStringList
(
mEhplmn
);
}
/** @hide */
public
CarrierInfo
(
Parcel
in
)
{
mEhplmn
=
new
ArrayList
<
String
>();
mMcc
=
in
.
readString8
();
mMnc
=
in
.
readString8
();
mSpn
=
in
.
readString8
();
mGid1
=
in
.
readString8
();
mGid2
=
in
.
readString8
();
mImsiPrefix
=
in
.
readString8
();
mIccid
=
in
.
readString8
();
mImpi
=
in
.
readString8
();
in
.
readStringList
(
mEhplmn
);
}
/** @hide */
@android
.
annotation
.
NonNull
@Override
public
String
toString
()
{
return
"CarrierInfo MCC = "
+
mMcc
+
" MNC = "
+
mMnc
+
" SPN = "
+
mSpn
+
" GID1 = "
+
mGid1
+
" GID2 = "
+
mGid2
+
" IMSI = "
+
getPrintableImsi
()
+
" ICCID = "
+
SubscriptionInfo
.
getPrintableId
(
mIccid
)
+
" IMPI = "
+
mImpi
+
" EHPLMN = [ "
+
getEhplmn_toString
()
+
" ]"
;
}
private
String
getEhplmn_toString
()
{
return
String
.
join
(
" "
,
mEhplmn
);
}
private
String
getPrintableImsi
()
{
boolean
enablePiiLog
=
Rlog
.
isLoggable
(
"CarrierInfo"
,
Log
.
VERBOSE
);
return
((
mImsiPrefix
!=
null
&&
mImsiPrefix
.
length
()
>
6
)
?
mImsiPrefix
.
substring
(
0
,
6
)
+
Rlog
.
pii
(
enablePiiLog
,
mImsiPrefix
.
substring
(
6
))
:
mImsiPrefix
);
}
}
This diff is collapsed.
Click to expand it.
telephony/java/android/telephony/CarrierRestrictionRules.java
+
137
−
4
View file @
6541aa34
...
...
@@ -84,13 +84,75 @@ public final class CarrierRestrictionRules implements Parcelable {
/** The same configuration is applied to all SIM slots independently. */
public
static
final
int
MULTISIM_POLICY_NONE
=
0
;
/** Any SIM card can be used as far as one SIM card matching the configuration is present. */
/**
* Indicates that any SIM card can be used as far as one valid card is present in the device.
* For the modem, a SIM card is valid when its content (i.e. MCC, MNC, GID, SPN) matches the
* carrier restriction configuration.
*/
public
static
final
int
MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT
=
1
;
/**
* Indicates that the SIM lock policy applies uniformly to all sim slots.
* @hide
*/
public
static
final
int
MULTISIM_POLICY_APPLY_TO_ALL_SLOTS
=
2
;
/**
* The SIM lock configuration applies exclusively to sim slot 1, leaving
* all other sim slots unlocked irrespective of the SIM card in slot 1
* @hide
*/
public
static
final
int
MULTISIM_POLICY_APPLY_TO_ONLY_SLOT_1
=
3
;
/**
* Valid sim cards must be present on sim slot1 in order
* to use other sim slots.
* @hide
*/
public
static
final
int
MULTISIM_POLICY_VALID_SIM_MUST_PRESENT_ON_SLOT_1
=
4
;
/**
* Valid sim card must be present on slot1 and it must be in full service
* in order to use other sim slots.
* @hide
*/
public
static
final
int
MULTISIM_POLICY_ACTIVE_SERVICE_ON_SLOT_1_TO_UNBLOCK_OTHER_SLOTS
=
5
;
/**
* Valid sim card be present on any slot and it must be in full service
* in order to use other sim slots.
* @hide
*/
public
static
final
int
MULTISIM_POLICY_ACTIVE_SERVICE_ON_ANY_SLOT_TO_UNBLOCK_OTHER_SLOTS
=
6
;
/**
* Valid sim cards must be present on all slots. If any SIM cards become
* invalid then device would set other SIM cards as invalid as well.
* @hide
*/
public
static
final
int
MULTISIM_POLICY_ALL_SIMS_MUST_BE_VALID
=
7
;
/**
* In case there is no match policy listed above.
* @hide
*/
public
static
final
int
MULTISIM_POLICY_SLOT_POLICY_OTHER
=
8
;
/** @hide */
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
(
prefix
=
"MULTISIM_POLICY_"
,
value
=
{
MULTISIM_POLICY_NONE
,
MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT
})
value
=
{
MULTISIM_POLICY_NONE
,
MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT
,
MULTISIM_POLICY_APPLY_TO_ALL_SLOTS
,
MULTISIM_POLICY_APPLY_TO_ONLY_SLOT_1
,
MULTISIM_POLICY_VALID_SIM_MUST_PRESENT_ON_SLOT_1
,
MULTISIM_POLICY_ACTIVE_SERVICE_ON_SLOT_1_TO_UNBLOCK_OTHER_SLOTS
,
MULTISIM_POLICY_ACTIVE_SERVICE_ON_ANY_SLOT_TO_UNBLOCK_OTHER_SLOTS
,
MULTISIM_POLICY_ALL_SIMS_MUST_BE_VALID
,
MULTISIM_POLICY_SLOT_POLICY_OTHER
})
public
@interface
MultiSimPolicy
{}
/** @hide */
...
...
@@ -104,6 +166,8 @@ public final class CarrierRestrictionRules implements Parcelable {
private
List
<
CarrierIdentifier
>
mAllowedCarriers
;
private
List
<
CarrierIdentifier
>
mExcludedCarriers
;
private
List
<
CarrierInfo
>
mAllowedCarrierInfo
;
private
List
<
CarrierInfo
>
mExcludedCarrierInfo
;
@CarrierRestrictionDefault
private
int
mCarrierRestrictionDefault
;
@MultiSimPolicy
...
...
@@ -114,6 +178,8 @@ public final class CarrierRestrictionRules implements Parcelable {
private
CarrierRestrictionRules
()
{
mAllowedCarriers
=
new
ArrayList
<
CarrierIdentifier
>();
mExcludedCarriers
=
new
ArrayList
<
CarrierIdentifier
>();
mAllowedCarrierInfo
=
new
ArrayList
<
CarrierInfo
>();
mExcludedCarrierInfo
=
new
ArrayList
<
CarrierInfo
>();
mCarrierRestrictionDefault
=
CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED
;
mMultiSimPolicy
=
MULTISIM_POLICY_NONE
;
mCarrierRestrictionStatus
=
TelephonyManager
.
CARRIER_RESTRICTION_STATUS_UNKNOWN
;
...
...
@@ -122,12 +188,17 @@ public final class CarrierRestrictionRules implements Parcelable {
private
CarrierRestrictionRules
(
Parcel
in
)
{
mAllowedCarriers
=
new
ArrayList
<
CarrierIdentifier
>();
mExcludedCarriers
=
new
ArrayList
<
CarrierIdentifier
>();
mAllowedCarrierInfo
=
new
ArrayList
<
CarrierInfo
>();
mExcludedCarrierInfo
=
new
ArrayList
<
CarrierInfo
>();
in
.
readTypedList
(
mAllowedCarriers
,
CarrierIdentifier
.
CREATOR
);
in
.
readTypedList
(
mExcludedCarriers
,
CarrierIdentifier
.
CREATOR
);
mCarrierRestrictionDefault
=
in
.
readInt
();
mMultiSimPolicy
=
in
.
readInt
();
mCarrierRestrictionStatus
=
in
.
readInt
();
if
(
Flags
.
carrierRestrictionRulesEnhancement
())
{
in
.
readTypedList
(
mAllowedCarrierInfo
,
CarrierInfo
.
CREATOR
);
in
.
readTypedList
(
mExcludedCarrierInfo
,
CarrierInfo
.
CREATOR
);
}
}
/**
...
...
@@ -164,6 +235,25 @@ public final class CarrierRestrictionRules implements Parcelable {
return
mExcludedCarriers
;
}
/**
* Retrieves list of excluded carrierInfos
*
* @return the list of excluded carrierInfos
* @hide
*/
public
@NonNull
List
<
CarrierInfo
>
getExcludedCarriersInfoList
()
{
return
mExcludedCarrierInfo
;
}
/**
* Retrieves list of excluded carrierInfos
*
* @return the list of excluded carrierInfos
* @hide
*/
public
@NonNull
List
<
CarrierInfo
>
getAllowedCarriersInfoList
()
{
return
mAllowedCarrierInfo
;
}
/**
* Retrieves the default behavior of carrier restrictions
*/
...
...
@@ -326,6 +416,10 @@ public final class CarrierRestrictionRules implements Parcelable {
out
.
writeInt
(
mCarrierRestrictionDefault
);
out
.
writeInt
(
mMultiSimPolicy
);
out
.
writeInt
(
mCarrierRestrictionStatus
);
if
(
Flags
.
carrierRestrictionRulesEnhancement
())
{
out
.
writeTypedList
(
mAllowedCarrierInfo
);
out
.
writeTypedList
(
mExcludedCarrierInfo
);
}
}
/**
...
...
@@ -357,7 +451,16 @@ public final class CarrierRestrictionRules implements Parcelable {
public
String
toString
()
{
return
"CarrierRestrictionRules(allowed:"
+
mAllowedCarriers
+
", excluded:"
+
mExcludedCarriers
+
", default:"
+
mCarrierRestrictionDefault
+
", multisim policy:"
+
mMultiSimPolicy
+
")"
;
+
", multisim policy:"
+
mMultiSimPolicy
+
getCarrierInfoList
()
+
")"
;
}
private
String
getCarrierInfoList
()
{
if
(
Flags
.
carrierRestrictionRulesEnhancement
())
{
return
", allowedCarrierInfoList:"
+
mAllowedCarrierInfo
+
", excludedCarrierInfoList:"
+
mExcludedCarrierInfo
;
}
else
{
return
""
;
}
}
/**
...
...
@@ -382,6 +485,12 @@ public final class CarrierRestrictionRules implements Parcelable {
mRules
.
mAllowedCarriers
.
clear
();
mRules
.
mExcludedCarriers
.
clear
();
mRules
.
mCarrierRestrictionDefault
=
CARRIER_RESTRICTION_DEFAULT_ALLOWED
;
if
(
Flags
.
carrierRestrictionRulesEnhancement
())
{
mRules
.
mCarrierRestrictionStatus
=
TelephonyManager
.
CARRIER_RESTRICTION_STATUS_NOT_RESTRICTED
;
mRules
.
mAllowedCarrierInfo
.
clear
();
mRules
.
mExcludedCarrierInfo
.
clear
();
}
return
this
;
}
...
...
@@ -439,5 +548,29 @@ public final class CarrierRestrictionRules implements Parcelable {
mRules
.
mCarrierRestrictionStatus
=
carrierRestrictionStatus
;
return
this
;
}
/**
* Set list of allowed carrierInfo
*
* @param allowedCarrierInfo list of allowed CarrierInfo
* @hide
*/
public
@NonNull
Builder
setAllowedCarrierInfo
(
@NonNull
List
<
CarrierInfo
>
allowedCarrierInfo
)
{
mRules
.
mAllowedCarrierInfo
=
new
ArrayList
<
CarrierInfo
>(
allowedCarrierInfo
);
return
this
;
}
/**
* Set list of allowed carrierInfo
*
* @param excludedCarrierInfo list of allowed CarrierInfo
* @hide
*/
public
@NonNull
Builder
setExcludedCarrierInfo
(
@NonNull
List
<
CarrierInfo
>
excludedCarrierInfo
)
{
mRules
.
mExcludedCarrierInfo
=
new
ArrayList
<
CarrierInfo
>(
excludedCarrierInfo
);
return
this
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment