|
4 | 4 | import android.content.pm.PackageManager; |
5 | 5 | import android.content.res.Configuration; |
6 | 6 | import android.os.Build; |
| 7 | +import android.provider.Settings; |
7 | 8 | import android.util.DisplayMetrics; |
8 | 9 | import android.view.Display; |
9 | 10 | import android.view.WindowManager; |
@@ -64,7 +65,7 @@ public Map<String, Object> getComplexAttributes() { |
64 | 65 | private void setDeviceInformation() { |
65 | 66 | this.attributes.put("uname.version", Build.VERSION.RELEASE); |
66 | 67 | this.attributes.put("culture", Locale.getDefault().getDisplayLanguage()); |
67 | | - this.attributes.put("build.type", BuildConfig.DEBUG ? "Debug": "Release"); |
| 68 | + this.attributes.put("build.type", BuildConfig.DEBUG ? "Debug" : "Release"); |
68 | 69 | this.attributes.put("device.model", Build.MODEL); |
69 | 70 | this.attributes.put("device.brand", Build.BRAND); |
70 | 71 | this.attributes.put("device.product", Build.PRODUCT); |
@@ -101,10 +102,9 @@ private void setScreenInformation() { |
101 | 102 | this.attributes.put("screen.height", metrics.heightPixels); |
102 | 103 | this.attributes.put("screen.dpi", metrics.densityDpi); |
103 | 104 | this.attributes.put("screen.orientation", getScreenOrientation().toString()); |
| 105 | + this.attributes.put("screen.brightness", getScreenBrightness()); |
104 | 106 | } |
105 | 107 |
|
106 | | - |
107 | | - |
108 | 108 | /** |
109 | 109 | * Set information about exception (message and classifier) |
110 | 110 | * |
@@ -138,6 +138,18 @@ private ScreenOrientation getScreenOrientation() { |
138 | 138 | return ScreenOrientation.UNDEFINED; |
139 | 139 | } |
140 | 140 |
|
| 141 | + /** |
| 142 | + * Get screen brightness value |
| 143 | + * |
| 144 | + * @return screen backlight brightness between 0 and 255 |
| 145 | + */ |
| 146 | + private int getScreenBrightness() { |
| 147 | + return Settings.System.getInt( |
| 148 | + this.context.getContentResolver(), |
| 149 | + Settings.System.SCREEN_BRIGHTNESS, |
| 150 | + 0); |
| 151 | + } |
| 152 | + |
141 | 153 | /** |
142 | 154 | * Divide custom user attributes into primitive and complex attributes and add to this object |
143 | 155 | * |
|
0 commit comments