Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mparticle.internal;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
Expand All @@ -8,7 +9,6 @@
import android.os.Build;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.view.WindowManager;

import com.mparticle.MParticle;
import com.mparticle.internal.Constants.MessageKey;
Expand Down Expand Up @@ -196,9 +196,9 @@ JSONObject getStaticDeviceInfo(Context appContext) {
attributes.put(MessageKey.OS_VERSION_INT, Build.VERSION.SDK_INT);
attributes.put(MessageKey.MODEL, android.os.Build.MODEL);
attributes.put(MessageKey.RELEASE_VERSION, Build.VERSION.RELEASE);

Application application = (Application) appContext;
// device ID
addAndroidId(attributes, appContext);
addAndroidId(attributes, application);

attributes.put(MessageKey.DEVICE_BLUETOOTH_ENABLED, MPUtility.isBluetoothEnabled(appContext));
attributes.put(MessageKey.DEVICE_BLUETOOTH_VERSION, MPUtility.getBluetoothVersion(appContext));
Expand All @@ -210,12 +210,11 @@ JSONObject getStaticDeviceInfo(Context appContext) {
attributes.put(MessageKey.DEVICE_ROOTED, rootedObject);

// screen height/width
WindowManager windowManager = (WindowManager) appContext.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics metrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(metrics);
attributes.put(MessageKey.SCREEN_HEIGHT, metrics.heightPixels);
attributes.put(MessageKey.SCREEN_WIDTH, metrics.widthPixels);
attributes.put(MessageKey.SCREEN_DPI, metrics.densityDpi);
DisplayMetrics displayMetrics = appContext.getResources().getDisplayMetrics();

attributes.put(MessageKey.SCREEN_HEIGHT, displayMetrics.heightPixels);
attributes.put(MessageKey.SCREEN_WIDTH, displayMetrics.widthPixels);
attributes.put(MessageKey.SCREEN_DPI, displayMetrics.densityDpi);

// locales
Locale locale = Locale.getDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import android.os.StatFs;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.view.Display;
import android.view.WindowManager;
import android.util.DisplayMetrics;

import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
Expand Down Expand Up @@ -369,14 +368,12 @@ public static String getTimeZone() {
}

public static int getOrientation(Context context) {
WindowManager windowManager = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
Display getOrient = windowManager.getDefaultDisplay();
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
int orientation = Configuration.ORIENTATION_UNDEFINED;
if (getOrient.getWidth() == getOrient.getHeight()) {
if (displayMetrics.widthPixels == displayMetrics.heightPixels) {
orientation = Configuration.ORIENTATION_SQUARE;
} else {
if (getOrient.getWidth() < getOrient.getHeight()) {
if (displayMetrics.widthPixels < displayMetrics.heightPixels) {
orientation = Configuration.ORIENTATION_PORTRAIT;
} else {
orientation = Configuration.ORIENTATION_LANDSCAPE;
Expand Down