public class Subscriber
extends java.lang.Object
This class exposes the slot number where the subscriber resides as a subscriber identifier. It could be either physical slot or virtual slot. Slot numbers should be user recognizable and slot number 1 must always denote primary subscriber on the device. Slot numbers must be greater than or equal to 1 and must be less than 10. The number of slots is implementation and device specific.
The source of Subscriber information can be added or removed.
The Subscriber instances are snapshots of information from the SIM, R-UIM, CSIM
and are immutable. If a Subscriber instance reflects a SIM present in
the device, the getSlotNumber()
will reflect
the location of the SIM, otherwise the slot number will be -1.
The information in the Subscriber and related Properties is the last known
snapshot of information from the physical SIM if the SIM is no longer present.
A SubscriberListener
can be added
or
removed
to monitor changes to the SIM Slot information.
Typically, to be aware of current information about Subscribers,
an application will not retain references to Subscriber instances
and should use SubscriberListener
or getSubscribers()
to get current information.
Properties available via getProperties()
:
Property | Description | Value | Network type |
---|---|---|---|
uuid | UUID (Universally Unique Identifier) number of the Subscriber | UUID number | 3GPP, CDMA |
imsi | IMSI (International Mobile Subscriber Identity) number of the Subscriber | IMSI number | 3GPP, CDMA |
iccid | ICCID (Integrated Circuit Card ID) number of the Subscriber | ICCID number | 3GPP, CDMA |
euimid | EUIMID (Expanded User Identity Module Identifier) number of the Subscriber | EUIMID number | CDMA |
mcc | MCC (Mobile Country Code) number of the Subscriber | MCC number | 3GPP, CDMA |
mnc | MNC (Mobile Network Code) number of the Subscriber | MNC number | 3GPP, CDMA |
sid | SID (System Identifier) number of the Subscriber | SID number | CDMA |
nid | NID (Network Identifier) number of the Subscriber | NID number | CDMA |
Modifier and Type | Field and Description |
---|---|
static int |
SIM_BLOCKED
The BLOCKED state of the SIM authentication of the user.
|
static int |
SIM_MISSING
The MISSING state of the SIM; the SIM is no longer in the device.
|
static int |
SIM_PIN1
The PIN1 state of the SIM authentication of the user.
|
static int |
SIM_PIN2
The PIN2 state of the SIM authentication of the user.
|
static int |
SIM_READY
The READY state of the SIM authentication of the user.
|
Modifier and Type | Method and Description |
---|---|
static void |
addListener(SubscriberListener listener)
Adds a listener to receive subscribers related events.
|
int |
getAuthenticationState()
Returns the current state of the SIM authentication of the user.
|
static Subscriber |
getByPhoneNumber(java.lang.String phoneNumber)
Returns the Subscriber for the phone number.
|
static Subscriber |
getBySlotNumber(int slotNumber)
Returns subscriber by the slot number it occupies.
|
CellularNetwork |
getNetwork()
Returns a cellular network the device is registered into
using this Subscriber.
|
java.lang.String |
getOperator()
Returns the operator name.
|
java.lang.String |
getPhoneNumber()
Returns the phone number of the subscriber.
|
java.util.Map<java.lang.String,java.lang.String> |
getProperties()
Returns a map containing Subscriber properties.
|
int |
getSlotNumber()
Returns the number of the slot for this Subscriber.
|
static Subscriber[] |
getSubscribers()
Returns an array containing all available subscribers.
|
java.lang.String |
getSubscriberType()
Returns the type of this Subscriber.
|
static void |
removeListener(SubscriberListener listener)
Removes a previously added listener.
|
void |
setAuthenticationCode(java.lang.String code)
Sets the code to be used by the SIM to verify the identity
of the user.
|
boolean |
setAutoRegistrationMode(boolean autoRegistrationMode)
Enable/disable auto registration mode for this Subscriber.
|
public static final int SIM_MISSING
public static final int SIM_READY
public static final int SIM_PIN1
public static final int SIM_PIN2
public static final int SIM_BLOCKED
public static Subscriber[] getSubscribers()
public static Subscriber getByPhoneNumber(java.lang.String phoneNumber)
getPhoneNumber()
.phoneNumber
- subscriber phone number, not nulljava.lang.SecurityException
- if the Security policy does not permit
CellularPermission with name "subscriber"public static Subscriber getBySlotNumber(int slotNumber)
Slot number 1 always denotes primary Subscriber. Slot numbers are greater than or equal to 1 and less than 10. The number of slots is device and implementation specific.
slotNumber
- slot number to get subscriber forjava.lang.IllegalArgumentException
- if the slot number is less than 1
or greater than or equal to 10java.util.NoSuchElementException
- if the slot is
greater than supported by the device.public static void addListener(SubscriberListener listener)
As soon as a listener is added it will be notified about all subscribers
available on the device at this moment, i.e. notifySubscriberEvent with
SUBSCRIBER_ADDED
event
will be called for each available subscriber.
This prevents race condition that could exist between registering listener
and adding new subscriber.
Does nothing if the listener is already registered as a subscriber listener.
listener
- the listener to addjava.lang.NullPointerException
- if the listener is nullpublic static void removeListener(SubscriberListener listener)
Does nothing if the listener is not registered as a subscriber listener.
listener
- the listener to removejava.lang.NullPointerException
- if the listener is nullpublic int getSlotNumber()
public java.lang.String getPhoneNumber()
The returned number follows the numbering plan defined in the ITU-T recommendation E.164.
java.lang.SecurityException
- if the Security policy does not permit
CellularPermission with name "subscriber"public java.lang.String getOperator()
If no other value is available for the operator name, the concatenation
of the MCC
and MNC
components of the IMSI,
as strings separated by " " (0x20), must be returned.
java.lang.SecurityException
- if the Security policy does not permit
CellularPermission with name "subscriber"public java.lang.String getSubscriberType()
getProperties()
.
This information is always valid for the Subscriber and does not change."3GPP"
or "CDMA"
public java.util.Map<java.lang.String,java.lang.String> getProperties()
getSubscriberType()
is listed for the key.
The value null
is returned from Map.get(key)
if the key is not defined for the network type.
String values that represent numbers are decimal unless otherwise noted.
This information is always valid for the Subscriber and does not change.java.lang.SecurityException
- if the Security policy does not permit
CellularPermission with name "subscriber"public CellularNetwork getNetwork()
getNetwork
returns null.
The value of getNetwork()
may change
based on the current connection or lack of connection to the network.
null
if the Subscriber is not currently
registered with any network.public void setAuthenticationCode(java.lang.String code)
code
- the string code, non-nulljava.lang.SecurityException
- if the Security policy does not permit
CellularPermission with name "subscriber"public int getAuthenticationState()
SIM_READY
, SIM_PIN1
, SIM_PIN2
,
SIM_BLOCKED
, or SIM_MISSING
.java.lang.SecurityException
- if the Security policy does not permit
CellularPermission with name "subscriber"public boolean setAutoRegistrationMode(boolean autoRegistrationMode)
autoRegistrationMode
does
not have any effect on the behavior of
CellularNetwork.register
.
If the autoRegistrationMode
is enabled for a subscriber,
the subscriber can be used to auto-register to a cellular network.
Setting the autoRegistrationMode
to false
disables the
subscriber from being used to register to a cellular network.
autoRegistrationMode
- true
to enable auto-registration
mode for this Subscriber,
false
to disable auto-registration mode for this Subscribertrue
if auto-registration is supported using the Subscriber;
otherwise false
java.lang.SecurityException
- if the Security policy does not permit
CellularPermission with name "subscriber"Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. Use of this specification is subject to license terms.