in sdk/appcenter/src/main/java/com/microsoft/appcenter/utils/DeviceInfoHelper.java [55:132]
public static synchronized Device getDeviceInfo(Context context) throws DeviceInfoException {
Device device = new Device();
/* Application version. */
PackageInfo packageInfo;
try {
PackageManager packageManager = context.getPackageManager();
packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
device.setAppVersion(packageInfo.versionName);
device.setAppBuild(String.valueOf(getVersionCode(packageInfo)));
} catch (Exception e) {
AppCenterLog.error(AppCenter.LOG_TAG, "Cannot retrieve package info", e);
throw new DeviceInfoException("Cannot retrieve package info", e);
}
/* Application namespace. */
device.setAppNamespace(context.getPackageName());
/* Carrier info. */
try {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String networkCountryIso = telephonyManager.getNetworkCountryIso();
if (!TextUtils.isEmpty(networkCountryIso)) {
device.setCarrierCountry(networkCountryIso);
}
String networkOperatorName = telephonyManager.getNetworkOperatorName();
if (!TextUtils.isEmpty(networkOperatorName)) {
device.setCarrierName(networkOperatorName);
}
} catch (Exception e) {
AppCenterLog.error(AppCenter.LOG_TAG, "Cannot retrieve carrier info", e);
}
/* Set country code. */
if (mCountryCode != null) {
device.setCarrierCountry(mCountryCode);
}
/* Locale. */
device.setLocale(Locale.getDefault().toString());
/* Hardware info. */
device.setModel(Build.MODEL);
device.setOemName(Build.MANUFACTURER);
/* OS version. */
device.setOsApiLevel(Build.VERSION.SDK_INT);
device.setOsName(OS_NAME);
device.setOsVersion(Build.VERSION.RELEASE);
device.setOsBuild(Build.ID);
/* Screen size. */
try {
device.setScreenSize(getScreenSize(context));
} catch (Exception e) {
AppCenterLog.error(AppCenter.LOG_TAG, "Cannot retrieve screen size", e);
}
/* Set SDK name and version. Don't add the BuildConfig import or it will trigger a Javadoc warning... */
device.setSdkName(com.microsoft.appcenter.BuildConfig.SDK_NAME);
device.setSdkVersion(com.microsoft.appcenter.BuildConfig.VERSION_NAME);
/* Timezone offset in minutes (including DST). */
device.setTimeZoneOffset(TimeZone.getDefault().getOffset(System.currentTimeMillis()) / 60 / 1000);
/* Add wrapper SDK information if any. */
if (sWrapperSdk != null) {
device.setWrapperSdkVersion(sWrapperSdk.getWrapperSdkVersion());
device.setWrapperSdkName(sWrapperSdk.getWrapperSdkName());
device.setWrapperRuntimeVersion(sWrapperSdk.getWrapperRuntimeVersion());
device.setLiveUpdateReleaseLabel(sWrapperSdk.getLiveUpdateReleaseLabel());
device.setLiveUpdateDeploymentKey(sWrapperSdk.getLiveUpdateDeploymentKey());
device.setLiveUpdatePackageHash(sWrapperSdk.getLiveUpdatePackageHash());
}
/* Return device properties. */
return device;
}