1
1
package com .mparticle .internal ;
2
2
3
+ import android .app .Application ;
3
4
import android .content .Context ;
4
5
import android .content .SharedPreferences ;
5
6
import android .content .pm .ApplicationInfo ;
8
9
import android .os .Build ;
9
10
import android .telephony .TelephonyManager ;
10
11
import android .util .DisplayMetrics ;
11
- import android .view .WindowManager ;
12
12
13
13
import com .mparticle .MParticle ;
14
14
import com .mparticle .internal .Constants .MessageKey ;
@@ -196,9 +196,9 @@ JSONObject getStaticDeviceInfo(Context appContext) {
196
196
attributes .put (MessageKey .OS_VERSION_INT , Build .VERSION .SDK_INT );
197
197
attributes .put (MessageKey .MODEL , android .os .Build .MODEL );
198
198
attributes .put (MessageKey .RELEASE_VERSION , Build .VERSION .RELEASE );
199
-
199
+ Application application = ( Application ) appContext ;
200
200
// device ID
201
- addAndroidId (attributes , appContext );
201
+ addAndroidId (attributes , application );
202
202
203
203
attributes .put (MessageKey .DEVICE_BLUETOOTH_ENABLED , MPUtility .isBluetoothEnabled (appContext ));
204
204
attributes .put (MessageKey .DEVICE_BLUETOOTH_VERSION , MPUtility .getBluetoothVersion (appContext ));
@@ -210,12 +210,11 @@ JSONObject getStaticDeviceInfo(Context appContext) {
210
210
attributes .put (MessageKey .DEVICE_ROOTED , rootedObject );
211
211
212
212
// screen height/width
213
- WindowManager windowManager = (WindowManager ) appContext .getSystemService (Context .WINDOW_SERVICE );
214
- DisplayMetrics metrics = new DisplayMetrics ();
215
- windowManager .getDefaultDisplay ().getMetrics (metrics );
216
- attributes .put (MessageKey .SCREEN_HEIGHT , metrics .heightPixels );
217
- attributes .put (MessageKey .SCREEN_WIDTH , metrics .widthPixels );
218
- attributes .put (MessageKey .SCREEN_DPI , metrics .densityDpi );
213
+ DisplayMetrics displayMetrics = appContext .getResources ().getDisplayMetrics ();
214
+
215
+ attributes .put (MessageKey .SCREEN_HEIGHT , displayMetrics .heightPixels );
216
+ attributes .put (MessageKey .SCREEN_WIDTH , displayMetrics .widthPixels );
217
+ attributes .put (MessageKey .SCREEN_DPI , displayMetrics .densityDpi );
219
218
220
219
// locales
221
220
Locale locale = Locale .getDefault ();
0 commit comments