Skip to content

Commit

Permalink
fix: Strickmode Error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mansi-mParticle committed Apr 30, 2024
1 parent ca4fd0b commit 2e0e957
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
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
11 changes: 4 additions & 7 deletions android-core/src/main/java/com/mparticle/internal/MPUtility.java
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

0 comments on commit 2e0e957

Please sign in to comment.