3535import org .jetbrains .annotations .TestOnly ;
3636
3737@ ApiStatus .Internal
38- public class DeviceInfoUtil {
38+ public final class DeviceInfoUtil {
3939
4040 @ SuppressLint ("StaticFieldLeak" )
4141 private static volatile DeviceInfoUtil instance ;
@@ -61,7 +61,8 @@ public DeviceInfoUtil(
6161 ContextUtils .retrieveSideLoadedInfo (context , options .getLogger (), buildInfoProvider );
6262 }
6363
64- public static @ NotNull DeviceInfoUtil getInstance (
64+ @ NotNull
65+ public static DeviceInfoUtil getInstance (
6566 final @ NotNull Context context , final @ NotNull SentryAndroidOptions options ) {
6667 if (instance == null ) {
6768 synchronized (DeviceInfoUtil .class ) {
@@ -139,7 +140,8 @@ public Device collectDeviceInformation(
139140 return device ;
140141 }
141142
142- public final @ NotNull OperatingSystem getOperatingSystem () {
143+ @ NotNull
144+ public OperatingSystem getOperatingSystem () {
143145 return os ;
144146 }
145147
@@ -164,7 +166,8 @@ protected OperatingSystem retrieveOperatingSystemInformation() {
164166 return os ;
165167 }
166168
167- public @ Nullable ContextUtils .SideLoadedInfo getSideLoadedInfo () {
169+ @ Nullable
170+ public ContextUtils .SideLoadedInfo getSideLoadedInfo () {
168171 return sideLoadedInfo ;
169172 }
170173
@@ -226,6 +229,7 @@ private void setDeviceIO(final @NotNull Device device, final boolean includeDyna
226229 }
227230
228231 @ SuppressWarnings ("NewApi" )
232+ @ NotNull
229233 private TimeZone getTimeZone () {
230234 if (buildInfoProvider .getSdkInfoVersion () >= Build .VERSION_CODES .N ) {
231235 LocaleList locales = context .getResources ().getConfiguration ().getLocales ();
@@ -238,7 +242,8 @@ private TimeZone getTimeZone() {
238242 }
239243
240244 @ SuppressWarnings ("JdkObsolete" )
241- private @ Nullable Date getBootTime () {
245+ @ Nullable
246+ private Date getBootTime () {
242247 try {
243248 // if user changes the clock, will give a wrong answer, consider ACTION_TIME_CHANGED.
244249 // currentTimeMillis returns UTC already
@@ -249,7 +254,8 @@ private TimeZone getTimeZone() {
249254 return null ;
250255 }
251256
252- private @ Nullable Intent getBatteryIntent () {
257+ @ Nullable
258+ private Intent getBatteryIntent () {
253259 return context .registerReceiver (null , new IntentFilter (Intent .ACTION_BATTERY_CHANGED ));
254260 }
255261
@@ -258,7 +264,8 @@ private TimeZone getTimeZone() {
258264 *
259265 * @return the device's current battery level (as a percentage of total), or null if unknown
260266 */
261- private @ Nullable Float getBatteryLevel (final @ NotNull Intent batteryIntent ) {
267+ @ Nullable
268+ private Float getBatteryLevel (final @ NotNull Intent batteryIntent ) {
262269 try {
263270 int level = batteryIntent .getIntExtra (BatteryManager .EXTRA_LEVEL , -1 );
264271 int scale = batteryIntent .getIntExtra (BatteryManager .EXTRA_SCALE , -1 );
@@ -281,7 +288,8 @@ private TimeZone getTimeZone() {
281288 *
282289 * @return whether or not the device is currently plugged in and charging, or null if unknown
283290 */
284- private @ Nullable Boolean isCharging (final @ NotNull Intent batteryIntent ) {
291+ @ Nullable
292+ private Boolean isCharging (final @ NotNull Intent batteryIntent ) {
285293 try {
286294 int plugged = batteryIntent .getIntExtra (BatteryManager .EXTRA_PLUGGED , -1 );
287295 return plugged == BatteryManager .BATTERY_PLUGGED_AC
@@ -292,7 +300,8 @@ private TimeZone getTimeZone() {
292300 }
293301 }
294302
295- private @ Nullable Float getBatteryTemperature (final @ NotNull Intent batteryIntent ) {
303+ @ Nullable
304+ private Float getBatteryTemperature (final @ NotNull Intent batteryIntent ) {
296305 try {
297306 int temperature = batteryIntent .getIntExtra (EXTRA_TEMPERATURE , -1 );
298307 if (temperature != -1 ) {
@@ -309,7 +318,8 @@ private TimeZone getTimeZone() {
309318 *
310319 * @return the device's current screen orientation, or null if unknown
311320 */
312- private @ Nullable Device .DeviceOrientation getOrientation () {
321+ @ Nullable
322+ private Device .DeviceOrientation getOrientation () {
313323 Device .DeviceOrientation deviceOrientation = null ;
314324 try {
315325 deviceOrientation =
@@ -329,7 +339,8 @@ private TimeZone getTimeZone() {
329339 }
330340
331341 @ SuppressWarnings ({"ObsoleteSdkInt" , "NewApi" })
332- private @ NotNull Long getMemorySize (final @ NotNull ActivityManager .MemoryInfo memInfo ) {
342+ @ NotNull
343+ private Long getMemorySize (final @ NotNull ActivityManager .MemoryInfo memInfo ) {
333344 if (buildInfoProvider .getSdkInfoVersion () >= Build .VERSION_CODES .JELLY_BEAN ) {
334345 return memInfo .totalMem ;
335346 }
@@ -342,7 +353,8 @@ private TimeZone getTimeZone() {
342353 *
343354 * @return the total amount of internal storage, in bytes
344355 */
345- private @ Nullable Long getTotalInternalStorage (final @ NotNull StatFs stat ) {
356+ @ Nullable
357+ private Long getTotalInternalStorage (final @ NotNull StatFs stat ) {
346358 try {
347359 long blockSize = getBlockSizeLong (stat );
348360 long totalBlocks = getBlockCountLong (stat );
@@ -397,7 +409,8 @@ private int getAvailableBlocksDep(final @NotNull StatFs stat) {
397409 *
398410 * @return the unused amount of internal storage, in bytes
399411 */
400- private @ Nullable Long getUnusedInternalStorage (final @ NotNull StatFs stat ) {
412+ @ Nullable
413+ private Long getUnusedInternalStorage (final @ NotNull StatFs stat ) {
401414 try {
402415 long blockSize = getBlockSizeLong (stat );
403416 long availableBlocks = getAvailableBlocksLong (stat );
@@ -410,7 +423,8 @@ private int getAvailableBlocksDep(final @NotNull StatFs stat) {
410423 }
411424 }
412425
413- private @ Nullable StatFs getExternalStorageStat (final @ Nullable File internalStorage ) {
426+ @ Nullable
427+ private StatFs getExternalStorageStat (final @ Nullable File internalStorage ) {
414428 if (!isExternalStorageMounted ()) {
415429 File path = getExternalStorageDep (internalStorage );
416430 if (path != null ) { // && path.canRead()) { canRead() will read return false
@@ -424,7 +438,8 @@ private int getAvailableBlocksDep(final @NotNull StatFs stat) {
424438 }
425439
426440 @ SuppressWarnings ({"ObsoleteSdkInt" , "NewApi" })
427- private @ Nullable File [] getExternalFilesDirs () {
441+ @ Nullable
442+ private File [] getExternalFilesDirs () {
428443 if (buildInfoProvider .getSdkInfoVersion () >= Build .VERSION_CODES .KITKAT ) {
429444 return context .getExternalFilesDirs (null );
430445 } else {
@@ -436,7 +451,8 @@ private int getAvailableBlocksDep(final @NotNull StatFs stat) {
436451 return null ;
437452 }
438453
439- private @ Nullable File getExternalStorageDep (final @ Nullable File internalStorage ) {
454+ @ Nullable
455+ private File getExternalStorageDep (final @ Nullable File internalStorage ) {
440456 final @ Nullable File [] externalFilesDirs = getExternalFilesDirs ();
441457
442458 if (externalFilesDirs != null ) {
@@ -471,7 +487,8 @@ private int getAvailableBlocksDep(final @NotNull StatFs stat) {
471487 * @return the total amount of external storage, in bytes, or null if no external storage is
472488 * mounted
473489 */
474- private @ Nullable Long getTotalExternalStorage (final @ NotNull StatFs stat ) {
490+ @ Nullable
491+ private Long getTotalExternalStorage (final @ NotNull StatFs stat ) {
475492 try {
476493 final long blockSize = getBlockSizeLong (stat );
477494 final long totalBlocks = getBlockCountLong (stat );
@@ -495,7 +512,8 @@ private boolean isExternalStorageMounted() {
495512 * @return the unused amount of external storage, in bytes, or null if no external storage is
496513 * mounted
497514 */
498- private @ Nullable Long getUnusedExternalStorage (final @ NotNull StatFs stat ) {
515+ @ Nullable
516+ private Long getUnusedExternalStorage (final @ NotNull StatFs stat ) {
499517 try {
500518 final long blockSize = getBlockSizeLong (stat );
501519 final long availableBlocks = getAvailableBlocksLong (stat );
@@ -508,7 +526,8 @@ private boolean isExternalStorageMounted() {
508526 }
509527 }
510528
511- private @ Nullable String getDeviceId () {
529+ @ Nullable
530+ private String getDeviceId () {
512531 try {
513532 return Installation .id (context );
514533 } catch (Throwable e ) {
0 commit comments