Class Overview
This class provides APIs to create, update, and remove Access Point Name (APN) settings on the
device. Use the ApnSettings
class to fill up the relevant APN setting
details.
Summary
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public Methods
public
long
createApnSettings
(ApnSettings apn)
Deprecated
in API level 35
API to create APN settings.
Parameters
apn
| The APN settings to be created. |
Returns
- Unique Id if the APN setting creation is successful, else -1.
Use this Id for future reference to this APN setting.
Usage
Access Point Name (APN) is a computer protocol that
allows a user's computer to access the Internet using the mobile phone network.
An administrator can use this API to complete APN information
for accessing the data network of a carrier and, using this API,
add this item on the device APN list without user interaction.
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
ApnSettingsPolicy apnSettingsPolicy = edm.getApnSettingsPolicy();
ApnSettings apnSettings = new ApnSettings();
apnSettings.user = "ApnUser";
apnSettings.password = "1234";
apnSettings.server = "ApnServer";
apnSettings.mmsc = "http://mms.msg.eg.t-mobile.com/mms/wapenc";
apnSettings.mmsProxy = "127.0.0.0";
apnSettings.mmsPort = "80";
apnSettings.mcc = "310";
apnSettings.mnc = "260";
apnSettings.type = "default";
try {
long ret= apnSettingsPolicy.createApnSettings(apnSettings);
if (ret != -1) {
Log.w("APN", "APN created");
} else {
Log.w("APN", "APN creation failed");
}
} catch (SecurityException e) {
Log.w(TAG, "SecurityException: " + e);
}
|
Permission
The use of this API requires the caller to have the
"com.samsung.android.knox.permission.KNOX_APN" permission which has a
protection level of signature.
|
public
boolean
deleteApn
(long apnId)
Deprecated
in API level 35
API to delete particular APN settings.
Parameters
apnId
| The Id for the APN to be deleted. |
Returns
true
if deletion of APN is successful, else false
.
Usage
An administrator can use this API to delete an APN from the device without
user interaction. Use the unique Id obtained when the APN settings
were created to delete the APN settings.
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
ApnSettingsPolicy apnSettingsPolicy = edm.getApnSettingsPolicy();
try {
boolean result = apnSettingsPolicy.deleteApn(1);
if (result == true){
//APN deletion succeeded
} else {
//APN deletion failed.
}
} catch(SecurityException e) {
Log.w(TAG,"SecurityException: " + e);
} |
Permission
The use of this API requires the caller to have the
"com.samsung.android.knox.permission.KNOX_APN" permission which has a
protection level of signature.
|
Dependency
Must use an existing id value. |
Deprecated
in API level 35
API to get all APN settings from the device.
Returns
- If successful, a list of all the APN settings present on the device
or an empty list if none are found, else
null
.
Usage
An administrator can use this API to get a list of APNs already provisioned
on the device and use the ApnSettings object returned to
manipulate them. If this API is called and the device does not have a valid SIM card
inserted, the API returns all the available APNs on the device. Otherwise, the API
return APNs that are specific to the inserted SIM card.
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
ApnSettingsPolicy apnSettingsPolicy = edm.getApnSettingsPolicy();
try {
List apnList = apnSettingsPolicy.getApnList();
if (apnList != null){
Iterator iApnList = apnList.iterator();
List infoList = new ArrayList();
while(iApnList.hasNext()) {
ApnSettings apnSettings = iApnList.next();
String tmp = "Id: " + apnSettings.id + "\n" +
"Name: " + apnSettings.name + "\n" +
"Apn: " + apnSettings.apn + "\n" +
"MCC: " + apnSettings.mcc + "\n" +
"MNC: " + apnSettings.mnc + "\n" +
"User: " + apnSettings.user + "\n" +
"Server: " + apnSettings.server + "\n" +
"Password: " + apnSettings.password + "\n" +
"Proxy: " + apnSettings.proxy + "\n" +
"Port: " + apnSettings.port + "\n" +
"MmsProxy: " + apnSettings.mmsProxy + "\n" +
"MMSC: " + apnSettings.mmsc + "\n" +
"Type: " + apnSettings.type + "\n" +
"AuthType: " + apnSettings.authType;
infoList.add(tmp);
}
// Log the retrieved APN settings
}
} catch(SecurityException e) {
Log.w(TAG,"SecurityException: "+e);
}
//Sample Output
// Id: 2
// Name: KT
// Apn: lte.ktfwing.com
// MCC: 450
// MNC: 08
// User:
// Server: *
// Password:
// Proxy:
// Port: -1
// MmsProxy:
// MMSC: http://mmsc.ktwing.com:9082
// Type: *
// AuthType: 1
|
Permission
The use of this API requires the caller to have the
"com.samsung.android.knox.permission.KNOX_APN" permission which has a
protection level of signature.
|
public
ApnSettings
getApnSettings
(long apnId)
Deprecated
in API level 35
API to get particular APN settings.
Parameters
apnId
| The Id for the APN whose settings are to be retrieved. |
Returns
- APN settings present on the device if successful, else
null
.
Usage
An administrator can use this API to get the APN settings configured on the device.
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
ApnSettingsPolicy apnSettingsPolicy = edm.getApnSettingsPolicy();
long apnId = 1;
try {
ApnSettings apnSettings = apnSettingsPolicy.getApnSettings(apnId);
if(apnSettings != null){
String tmp = "Id: " + apnSettings.id + "\n" +
"Name: " + apnSettings.name + "\n" +
"Apn: " + apnSettings.apn + "\n" +
"MCC: " + apnSettings.mcc + "\n" +
"MNC: " + apnSettings.mnc + "\n" +
"User: " + apnSettings.user + "\n" +
"Server: " + apnSettings.server + "\n" +
"Password: " + apnSettings.password + "\n" +
"Proxy: " + apnSettings.proxy + "\n" +
"Port: " + apnSettings.port + "\n" +
"MmsProxy: " + apnSettings.mmsProxy + "\n" +
"MMSC: " + apnSettings.mmsc + "\n" +
"Type: " + apnSettings.type + "\n" +
"AuthType: " + apnSettings.authType;
// Log the retrieved APN settings
} catch(SecurityException e) {
Log.w(TAG,"SecurityException: "+ e);
}
//Sample Output
// Id: 2
// Name: KT
// Apn: lte.ktfwing.com
// MCC: 450
// MNC: 08
// User:
// Server: *
// Password:
// Proxy:
// Port: -1
// MmsProxy:
// MMSC: http://mmsc.ktwing.com:9082
// Type: *
// AuthType: 1
|
The administrator can use this API to get the APNs already provisioned on the
device and use the ApnSettings object returned to manipulate them.
|
Permission
The use of this API requires the caller to have the
"com.samsung.android.knox.permission.KNOX_APN" permission which has a
protection level of signature. |
public
ApnSettings
getPreferredApnSettings
()
Deprecated
in API level 35
API to get preferred APN settings.
Returns
- Preferred APN settings present on the device if successful, else
null
.
Usage
An administrator can use this API to get the preferred (active) APN on the device
and use the ApnSettings object returned to manipulate the APN.
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
ApnSettingsPolicy apnSettingsPolicy = edm.getApnSettingsPolicy();
try {
ApnSettings apnSettings = apnSettingsPolicy.getPreferredApnSettings();
if(apnSettings != null){
String tmp = "Id: " + apnSettings.id + "\n" +
"Name: " + apnSettings.name + "\n" +
"Apn: " + apnSettings.apn + "\n" +
"MCC: " + apnSettings.mcc + "\n" +
"MNC: " + apnSettings.mnc + "\n" +
"User: " + apnSettings.user + "\n" +
"Server: " + apnSettings.server + "\n" +
"Password: " + apnSettings.password + "\n" +
"Proxy: " + apnSettings.proxy + "\n" +
"Port: " + apnSettings.port + "\n" +
"MmsProxy: " + apnSettings.mmsProxy + "\n" +
"MMSC: " + apnSettings.mmsc + "\n" +
"Type: " + apnSettings.type + "\n" +
"AuthType: " + apnSettings.authType;
// Log the retrieved APN settings
} catch(SecurityException e) {
Log.w(TAG,"SecurityException: "+ e);
}
|
Permission
The use of this API requires the caller to have the
"com.samsung.android.knox.permission.KNOX_APN" permission which has a
protection level of signature. |
public
boolean
setPreferredApn
(long apnId)
Deprecated
in API level 35
API to set a preferred APN.
Parameters
apnId
| The Id of the preferred ApnSetting. |
Returns
true
if the APN is set successfully as preferred, else false
.
Usage
The specified APN is preferred when a connection to an APN
is requested. If a connection to the preferred APN is not possible,
another APN is chosen from the available list. Use the
unique Id obtained when the APN settings were created to set the
preferred APN.
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
ApnSettingsPolicy apnSettingsPolicy = edm.getApnSettingsPolicy();
long apnId = 2;
try {
boolean result = apnSettingsPolicy.setPreferredApn(apnId);
} catch (SecurityException e) {
Log.w(TAG, "SecurityException: " + e);
}
|
Permission
The use of this API requires the caller to have the
"com.samsung.android.knox.permission.KNOX_APN" permission which has a
protection level of signature.
|
Precondition
1. The APN must have the MCC and MNC set to the same values from the current SIM Card configured as default mobile data. |
2. The APN to be set as preferred must have a non-null value type different from "mms" or "dun". |
public
boolean
updateApnSettings
(ApnSettings apn)
Deprecated
in API level 35
API to update existing APN settings.
Parameters
apn
| The ApnSetting to be updated. |
Returns
true
if APN has updated successfully, else false
.
Usage
An administrator can use this API to complete APN information
for accessing the data network of a carrier and, using this API,
update this item on the device APN list without user interaction. Use
the unique Id obtained when the APN settings were created
to fill the id field when updating a
particular APN.
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
ApnSettingsPolicy apnSettingsPolicy = edm.getApnSettingsPolicy();
long apnId = 2;
ApnSettings apnSettings = apnSettingsPolicy.getApnSettings(apnId);
apnSettings.user = "ApnUser";
apnSettings.password = "1234";
apnSettings.server = "ApnServer";
apnSettings.mmsc = "http://mms.msg.eg.t-mobile.com/mms/wapenc";
apnSettings.mmsProxy = "127.0.0.0";
apnSettings.mmsPort = "80";
apnSettings.mcc = "310";
apnSettings.mnc = "260";
apnSettings.type = "default";
try {
if(apnSettings.id != -1){
if(apnSettingsPolicy.updateApnSettings(apnSettings)) {
Log.w("APN", "APN settings updated");
} else {
Log.w("APN", "FAILED: APN settings not updated");
}
}
} catch (SecurityException e) {
Log.w(TAG, "SecurityException: " + e);
}
|
Permission
The use of this API requires the caller to have the
"com.samsung.android.knox.permission.KNOX_APN" permission which has a
protection level of signature.
|
Dependency
ApnSettings object must have an existing
id value because this is an update operation. |