com.nativex.advertiser
Class DeviceManager

java.lang.Object
  extended by com.nativex.advertiser.DeviceManager

public class DeviceManager
extends Object

The DeviceManager class handles accessing underlying data from the Android device. Access to this data is provided by the static getDeviceInstance() method.

Version:
12/31/2013
Author:
matthew.macgregor

Field Summary
private  Context context
           
private static Device device
           
private static String deviceId
           
private static DeviceManager deviceManager
           
 
Constructor Summary
private DeviceManager(Context context)
           
 
Method Summary
private  String getAndroidDeviceId()
          Returns the AndroidDeviceId (IMEI) for this Android device.
private  String getAndroidId()
          Returns the device AndroidId.
private  String getDeviceId()
          This method fetches DeviceId from SharedPreferences.
static Device getDeviceInstance(Context context)
          Returns a populated instance of the device object that represents the device that we are currently running.
protected  Device getDeviceInstance(Device mockDevice)
          Provided for unit test purposes.
private  String getOsVersion()
          Retrieves the version of the Android OS installed on this device.
private  boolean isHacked()
          Is this device running as root?
static void release()
          Releases the manager.
static void updateDeviceId()
           
private  String verifyVersionString(String version)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

device

private static Device device

context

private Context context

deviceManager

private static DeviceManager deviceManager

deviceId

private static String deviceId
Constructor Detail

DeviceManager

private DeviceManager(Context context)
Method Detail

getDeviceInstance

public static Device getDeviceInstance(Context context)
Returns a populated instance of the device object that represents the device that we are currently running.


getOsVersion

private String getOsVersion()
Retrieves the version of the Android OS installed on this device.

Returns:
String. The Android OS version.

verifyVersionString

private String verifyVersionString(String version)

getDeviceInstance

protected Device getDeviceInstance(Device mockDevice)
Provided for unit test purposes.

Parameters:
mockDevice - Device. A device instance with mock data.
Returns:
Device. The mock device instance.

updateDeviceId

public static void updateDeviceId()

isHacked

private boolean isHacked()
Is this device running as root?


getAndroidDeviceId

private String getAndroidDeviceId()
Returns the AndroidDeviceId (IMEI) for this Android device. Requires the READ_PHONE_STATE permission.


getAndroidId

private String getAndroidId()
Returns the device AndroidId. There is a bug in some millions of devices that returns duplicate values for certain devices. For the purposes of this SDK, we are ignoring this and handling it on the server side.

Returns:
The AndroidId if available, null if not available.

getDeviceId

private String getDeviceId()
This method fetches DeviceId from SharedPreferences. The DeviceId is an identifier that is generated when a device first calls CreateSession from the nativeX API.

Returns:
If the Id is found it is returned, otherwise null is returned.

release

public static void release()
Releases the manager.