android.device
Class DeviceManager

java.lang.Object
  extended by android.device.DeviceManager

public class DeviceManager
extends java.lang.Object

The DeviceManager class provides support to get and set the device configurations.

Use this class to control the basic functions of the equipment system, according to the following steps,

  1. You should import the class first.

    import android.device.DeviceManager;

  2. You can obtain an instance of this class.

    DeviceManager manager = new DeviceManager();

  3. Use the interface in the class, for example, get SN number.

    String sn = manager.getTIDSN();

    For more information about the device configurations, read DeviceManager sample.


Constructor Summary
DeviceManager()
The DeviceManager class provides support to get and set the device configurations.
 
Method Summary
 java.lang.String getDeviceId()
Get the device SN.
 java.lang.String getTIDSN()
Get the TUSN number of the device.
 boolean setCurrentTime(long when)
Set the current wall time, in milliseconds.
 void enableHomeKey(boolean enable)
Enable/Disable device Home key.
 void enableStatusBar(boolean enable)
Enable/Disable the device status bar.
 boolean setAPN(java.lang.String name, java.lang.String apn, java.lang.String proxy, int port, java.lang.String user, java.lang.String server, java.lang.String password, java.lang.String mmsc, java.lang.String mcc, java.lang.String mnc, java.lang.String mmsproxy, int mmsport, int authType, java.lang.String type, java.lang.String protocol, int bearer, java.lang.String roamingProtocol, boolean current)
Set the access point name(APN) configurations for mobile data network.
 boolean installApplication(java.lang.String apkFilePath)
Install a android package.
 boolean uninstallApplication(java.lang.String packageName)
Attempt to remove an android package.
 boolean getDockerState()
Only supports i9000S(Android 4.3/Android5.1). The function is to test the docking station connection status of the current device.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeviceManager

public DeviceManager()
Method Detail

getDeviceId

public java.lang.String getDeviceId()
Get the device SN.

Parameters:
none
Returns:
In the form of 14 alphanumeric characters, all alphanumeric numbers represent ID numbers.

getTIDSN

public java.lang.String getTIDSN()
Get the TUSN number of the device.

Parameters:
none
Returns:
In the form of 8 alphanumeric characters, all representing TUSN number.
Note: Interface unique to POS project.

setCurrentTime

public boolean setCurrentTime(long when)
Set the current wall time, in milliseconds.

Parameters:
when - in milliseconds. The expression of time is the number of milliseconds between the current time and GMT (Greenwich mean time) at 0:00:00 on January 1, 1970.
Returns:
True if successful, false if failed.
Example:
DeviceManager deviceManager = new DeviceManager();
deviceManager.setCurrentTime(1562226000);

enableHomeKey

public void enableHomeKey(boolean enable)
Enable/Disable device Home key.

Parameters:
enable - Set to false to disable the Home key function and set to true to enable the Home key function.
Returns:
none.
Note:This status is not persistent. The Home key will be back to normal after reboot.
Example:
//Call enableHomeKey to disable the Home key
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    new DeviceManager().enableHomeKey(false);
}

//Enable the Home key when exit your application
protected void onDestroy() {
    new DeviceManager().enableHomeKey(true);
}

enableStatusBar

public void enableStatusBar(boolean enable)
Enable/Disable the device status bar.

Parameters:
enable - Set to true to enable the status bar. Set to false to disable the status bar expand.
Returns:
none.
Note:This status is not persistent. The status bar will be back to normal after reboot.
Example:
DeviceManager deviceManager = new DeviceManager();
deviceManager.enableStatusBar(false);

setAPN

public boolean setAPN(java.lang.String name,
                      java.lang.String apn,
                      java.lang.String proxy,
                      int port,
                      java.lang.String user,
                      java.lang.String server,
                      java.lang.String password,
                      java.lang.String mmsc,
                      java.lang.String mcc,
                      java.lang.String mnc,
                      java.lang.String mmsproxy,
                      int mmsport,
                      int authType,
                      java.lang.String type,
                      java.lang.String protocol,
                      int bearer,
                      java.lang.String roamingProtocol,
                      boolean current)
Set the access point name(APN) configurations for mobile data network.

Parameters:
name - Entry name. Cannot be null.
apn - APN name. Cannot be null.
proxy - Proxy address.
port - Proxy port.
user - APN username.
server - Server address.
password - APN password.
mmsc - MMSC URL.
mcc - Mobile Country Code (MCC).
mnc - MNC Mobile Network Code (MNC). Cannot be null.
mmsproxy - MMS proxy address.
mmsport - MMS proxy port.
authType - Authentication type. Value:
                    0 : none
                    1 : PAP
                    2 : CHAP
                    3 : PAP or CHAP
type - Comma-delimited list of APN types.
protocol - The protocol to use to connect to this APN. Value: IPv6 or IPv4.
bearer - BEARER Radio Access Technology info. Value:
                    0 : none
                    13 : eHRPD
                    14 :LTE
roamingProtocol - The protocol to use to connect to this APN when roaming.
current - Enable current APN.
Returns:
True if successful, false if failed.

installApplication

public boolean installApplication(java.lang.String apkFilePath)
Install a android package. Since this may take a little while, the result will be posted back to the given observer. An installation will fail if the package named in the package file's manifest is already installed INSTALL_REPLACE_EXISTING, or if there's no space available on the device.

Parameters:
apkFilePath - The location of the package file to install. This can be a 'file:' or a 'content:' URI.
Returns:
True if successful, false if failed.
Example:
DeviceManager deviceManager = new DeviceManager();
boolean ret = deviceManager.installApplication("/sdcard/test.apk");
if(ret)
    //install success
else
    //install failed

uninstallApplication

public boolean uninstallApplication(java.lang.String packageName)
Attempt to remove an android package. A deletion will fail if the named package cannot be found, or if the named package is a "system package".

Parameters:
packageName - The name of the package to delete.
Returns:
True if successful, false if failed.
Example:
DeviceManager deviceManager = new DeviceManager();
boolean ret = deviceManager.uninstallApplication("com.device.uhome");
if(ret)
    //uninstall success
else
    //uninstall failed

getDockerState

public boolean getDockerState()
Only supports i9000S(Android 4.3/Android5.1). The function is to test the docking station connection status of the current device.

Parameters:
none.
Returns:
True if the device is in Ethernet mode or USB host mode, or false if the device is in normal mode.
Note: only equipment with base can be used!