Class POBDeviceInfo
-
- All Implemented Interfaces:
public class POBDeviceInfoA class representing the Device details, derived internally using framework APIs.
Values such as disk free space, battery, audio routes, DND, and brightness are read from the system on each
get*call so bid requests reflect the latest state. Keyboard input languages are captured once when this object is constructed. System reads are implemented in the package-privatePOBDeviceInfoReaderhelper.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumPOBDeviceInfo.DEVICE_ID_TYPEEnum to denote the device type.
-
Field Summary
Fields Modifier and Type Field Description public final static intDEVICE_EXT_UNKNOWN_INTpublic final static doubleDEVICE_EXT_UNKNOWN_DOUBLEpublic final static longDEVICE_EXT_UNKNOWN_LONGpublic final static StringDEVICE_EXT_UNDETERMINEDpublic intscreenWidthpublic intscreenHeightpublic inttimeZoneOffsetInMinutespublic final longbootTimeMspublic final doubletotalDiskSpaceMbpublic final longtotalMemBytespublic final Array<String>inputLanguagespublic StringandroidIdpublic StringcarrierNamepublic StringacceptLanguagepublic Stringmakepublic Stringmodelpublic StringhardwareVersionpublic StringosNamepublic StringosVersionpublic StringscreenResolutionpublic StringcurrentTimeZonepublic floatpxratiopublic intppipublic Stringmccmnc
-
Constructor Summary
Constructors Constructor Description POBDeviceInfo(Context context)Constructor.
-
Method Summary
Modifier and Type Method Description intgetTimeZoneOffsetInMinutes()Return local time as the number +/- of minutes from UTC. longgetBootTimeMs()Kernel boot wall-clock timestamp in milliseconds since Unix epoch (best-effort). doublegetTotalDiskSpaceMb()Total primary storage capacity of the device (the total typically shown in system storage settings, e.g. longgetTotalMemBytes()Total device RAM in bytes. Array<String>getInputLanguages()Languages configured on enabled keyboard input methods (IME subtype language tags / locales). StringgetAndroidId()StringgetCarrierName()StringgetAcceptLanguage()StringgetMake()StringgetModel()StringgetHardwareVersion()StringgetOsName()StringgetOsVersion()StringgetScreenResolution()StringgetCurrentTimeZone()floatgetPxratio()intgetPpi()Approximate device PPI index from display metrics (rounded average of xdpi and ydpi). StringgetMccmnc()voidrefreshAdvertisingIdInfo()Method is used to update advertising Id from AdvertisingIdClient class POBDeviceInfo.DEVICE_ID_TYPEgetAndroidIdType(boolean aidEnabled)StringgetAdvertisingID()StringgetISOAlpha2CountryCode()Returns the ISO-3166-1 alpha-2 country code if available StringgetISOAlpha3CountryCode()Returns the ISO-3166-1 alpha-3 country code if available. StringgetUserAgent()This method fetch the user agent from WebSettings and save it for future reference. StringgetCurrentTime()Method is used to get current datetime in formated String yyyy-MM-dd HH:mm:ss BooleangetLmtEnabled()intgetOrientation()intgetScreenWidth()intgetScreenHeight()doublegetDiskSpaceMb()Available disk space on the internal data partition, in binary megabytes (MiB). intgetCharging()Whether external power (charger / USB / wireless) appears connected. doublegetBatteryLevel()Remaining battery charge as a fraction of full capacity. intgetRingMute()Whether ring / alert sounds are effectively muted. intgetDarkMode()Whether dark / night mode is enabled for the current device Configuration. intgetBluetooth()Whether a Bluetooth audio connection is active (best-effort). intgetAirplane()Whether airplane mode is enabled. intgetDnd()Whether Do Not Disturb (non-INTERRUPTION_FILTER_ALL) is active. intgetHeadset()Whether wired analog headset/headphones or USB audio output (e.g. doublegetScreenBrightness()System screen brightness setting normalized to a fraction of the configured maximum (255), rounded to two decimal places (HALF_UP) in [0.0, 1.0]for alignment withdevice.ext.screenbright.StringgetDeviceIp()voidregisterIpUpdateService(@NonNull() POBDeviceIpUpdaterService deviceIpUpdaterService)Registers a network callback that persists throughout the application lifecycle to receive network state updates, ensuring profile configuration requests are triggered and the latest IP addresses are always available as deviceIp. -
-
Constructor Detail
-
POBDeviceInfo
POBDeviceInfo(Context context)
Constructor.- Parameters:
context- context
-
-
Method Detail
-
getTimeZoneOffsetInMinutes
int getTimeZoneOffsetInMinutes()
Return local time as the number +/- of minutes from UTC. To be sent as 'utcoffset' in oRTB. Example: +330 for IST i.e. UTC+5:30
- Returns:
Local time offset
-
getBootTimeMs
long getBootTimeMs()
Kernel boot wall-clock timestamp in milliseconds since Unix epoch (best-effort). Derived from
System.currentTimeMillis() - SystemClock.elapsedRealtime().- Returns:
estimated boot instant in UTC ms, or DEVICE_EXT_UNKNOWN_LONG if not usable
-
getTotalDiskSpaceMb
double getTotalDiskSpaceMb()
Total primary storage capacity of the device (the total typically shown in system storage settings, e.g. 128 GB), expressed in decimal megabytes (1 MB = 1_000_000 bytes). Extension-style:
device.ext.totaldisk. Rounded to two decimal places (HALF_UP) at construction time.- Returns:
non-negative MB (two fractional digits), or DEVICE_EXT_UNKNOWN_DOUBLE if unavailable
-
getTotalMemBytes
long getTotalMemBytes()
Total device RAM in bytes.
- Returns:
total RAM from totalMem, or DEVICE_EXT_UNKNOWN_LONG if unavailable
-
getInputLanguages
@NonNull() Array<String> getInputLanguages()
Languages configured on enabled keyboard input methods (IME subtype language tags / locales). Order is stable; duplicates removed. Collected once at construction.
- Returns:
input language array
-
getAndroidId
@Nullable() String getAndroidId()
-
getCarrierName
@Nullable() String getCarrierName()
-
getAcceptLanguage
@Nullable() String getAcceptLanguage()
-
getHardwareVersion
@Nullable() String getHardwareVersion()
-
getOsVersion
@Nullable() String getOsVersion()
-
getScreenResolution
@Nullable() String getScreenResolution()
-
getCurrentTimeZone
@Nullable() String getCurrentTimeZone()
-
getPxratio
float getPxratio()
-
getPpi
int getPpi()
Approximate device PPI index from display metrics (rounded average of xdpi and ydpi).
- Returns:
non-negative PPI estimate, or 0 if unavailable
-
refreshAdvertisingIdInfo
void refreshAdvertisingIdInfo()
Method is used to update advertising Id from AdvertisingIdClient class
-
getAndroidIdType
POBDeviceInfo.DEVICE_ID_TYPE getAndroidIdType(boolean aidEnabled)
-
getAdvertisingID
@Nullable() String getAdvertisingID()
-
getISOAlpha2CountryCode
@Nullable() String getISOAlpha2CountryCode()
Returns the ISO-3166-1 alpha-2 country code if available
- Returns:
The lowercase 2 character ISO-3166-1 alpha-2 country code, object if not available
-
getISOAlpha3CountryCode
@Nullable() String getISOAlpha3CountryCode()
Returns the ISO-3166-1 alpha-3 country code if available. Priority is from TelephonyManager followed by GPS system.
- Returns:
The lowercase 3 character ISO-3166-1 alpha-3 country code, object if not available
-
getUserAgent
@WorkerThread() String getUserAgent()
This method fetch the user agent from WebSettings and save it for future reference. And return the same. If not found then just return user-agent using System.getProperty("http.agent"). It will return empty string in case unable to fetch the user-agent at all.
- Returns:
user agent
-
getCurrentTime
String getCurrentTime()
Method is used to get current datetime in formated String yyyy-MM-dd HH:mm:ss
- Returns:
return date of type String
-
getLmtEnabled
@Nullable() Boolean getLmtEnabled()
-
getOrientation
int getOrientation()
-
getScreenWidth
int getScreenWidth()
-
getScreenHeight
int getScreenHeight()
-
getDiskSpaceMb
double getDiskSpaceMb()
Available disk space on the internal data partition, in binary megabytes (MiB). Read from the system on each call (free space changes over time). Values are rounded to two decimal places (HALF_UP) for alignment with
device.ext.diskspace.- Returns:
non-negative MiB (two fractional digits), or DEVICE_EXT_UNKNOWN_DOUBLE if unavailable
-
getCharging
int getCharging()
Whether external power (charger / USB / wireless) appears connected. Read from the system on each call.
- Returns:
1if EXTRA_PLUGGED is non-zero,0if not charging, or DEVICE_EXT_UNKNOWN_INT if the state could not be read
-
getBatteryLevel
double getBatteryLevel()
Remaining battery charge as a fraction of full capacity. Read from the system on each call; when known, rounded to two decimal places (HALF_UP) in
[0.0, 1.0]for alignment withdevice.ext.batterylevel. Returned asdouble(notfloat) so JSON encoding avoids float round-trip noise.- Returns:
value in
[0.0, 1.0]when known, or DEVICE_EXT_UNKNOWN_DOUBLE if unknown
-
getRingMute
int getRingMute()
Whether ring / alert sounds are effectively muted. Read from the system on each call.
- Returns:
1if silent/vibrate profile or ring stream muted (API 23+),0otherwise, or DEVICE_EXT_UNKNOWN_INT if unavailable
-
getDarkMode
int getDarkMode()
Whether dark / night mode is enabled for the current device Configuration. Read from the system on each call.
- Returns:
1if UI_MODE_NIGHT_YES,0otherwise, or DEVICE_EXT_UNKNOWN_INT if unavailable
-
getBluetooth
int getBluetooth()
Whether a Bluetooth audio connection is active (best-effort). Read from the system on each call.
- Returns:
1if Bluetooth A2DP, SCO, or (API 31+) BLE headset is an active output device,0if not, or DEVICE_EXT_UNKNOWN_INT if unavailable
-
getAirplane
int getAirplane()
Whether airplane mode is enabled. Read from the system on each call.
- Returns:
1if AIRPLANE_MODE_ON is non-zero,0otherwise, or DEVICE_EXT_UNKNOWN_INT if unavailable
-
getDnd
int getDnd()
Whether Do Not Disturb (non-INTERRUPTION_FILTER_ALL) is active. Read from the system on each call.
- Returns:
1if interruption filter restricts interruptions (API 23+),0otherwise, or DEVICE_EXT_UNKNOWN_INT if unavailable (including API levels below M)
-
getHeadset
int getHeadset()
Whether wired analog headset/headphones or USB audio output (e.g. USB-C headphones) is active. Read from the system on each call.
- Returns:
1if a matching output device is present,0otherwise, or DEVICE_EXT_UNKNOWN_INT if unavailable
-
getScreenBrightness
double getScreenBrightness()
System screen brightness setting normalized to a fraction of the configured maximum (255), rounded to two decimal places (HALF_UP) in
[0.0, 1.0]for alignment withdevice.ext.screenbright. Read from the system on each call.- Returns:
value in
[0.0, 1.0]when known (two fractional digits, half-up), or DEVICE_EXT_UNKNOWN_DOUBLE if unknown / inaccessible.
-
getDeviceIp
@Nullable() String getDeviceIp()
-
registerIpUpdateService
void registerIpUpdateService(@NonNull() POBDeviceIpUpdaterService deviceIpUpdaterService)
Registers a network callback that persists throughout the application lifecycle to receive network state updates, ensuring profile configuration requests are triggered and the latest IP addresses are always available as deviceIp.
Note: This method should be called only once during the first initialize call.
- Parameters:
deviceIpUpdaterService- The POBDeviceIpUpdaterService instance responsible for registering callback mechanisms to obtain the most recent device IP address from profile configuration response headers.
-
-
-
-