package com.learnium.RNDeviceInfo;

import javax.annotation.Nullable;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.Callback;

import android.os.Build;
import android.provider.Settings.Secure;
import android.content.pm.PackageManager;
import android.content.pm.PackageInfo;
import android.bluetooth.BluetoothAdapter;

import java.util.HashMap;
import java.util.Map;

public class RNDeviceModule extends ReactContextBaseJavaModule {

  ReactApplicationContext reactContext;

  public RNDeviceModule(ReactApplicationContext reactContext) {
    super(reactContext);
    this.reactContext = reactContext;
  }

  @Override
  public String getName() {
    return "RNDeviceInfo";
  }

  @Override
  public @Nullable Map<String, Object> getConstants() {
    HashMap<String, Object> constants = new HashMap<String, Object>();

    PackageManager packageManager = this.reactContext.getPackageManager();
    String packageName = this.reactContext.getPackageName();

    constants.put("appVersion", "not available");
    constants.put("buildNumber", 0);

    try {
      PackageInfo info = packageManager.getPackageInfo(packageName, 0);
      constants.put("appVersion", info.versionName);
      constants.put("buildNumber", info.versionCode);
    } catch (PackageManager.NameNotFoundException e) {
      e.printStackTrace();
    }

    String deviceName = "Unknown";

    try {
      BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
      deviceName = myDevice.getName();
    } catch(Exception e) {
      e.printStackTrace();
    }

    constants.put("deviceName", deviceName);
    constants.put("systemName", "Android");
    constants.put("systemVersion", Build.VERSION.RELEASE);
    constants.put("model", Build.MODEL);
    constants.put("deviceId", Build.BOARD);
    constants.put("deviceLocale", this.reactContext.getResources().getConfiguration().locale.toString());
    constants.put("uniqueId", Secure.getString(this.reactContext.getContentResolver(), Secure.ANDROID_ID));
    constants.put("systemManufacturer", Build.MANUFACTURER);
    constants.put("bundleId", packageName);
    constants.put("userAgent", System.getProperty("http.agent"));
    return constants;
  }
}

@@ -40,246 +40,191 @@
 ort 
-javax.annotation.Nullable
+android.bluetooth.BluetoothAdapter
 ;%0A
-%0A
 import 
-com.facebook.react.bridge.ReactApplicationContext;%0Aimport com.facebook.react.bridge.ReactContextBaseJavaModule;%0Aimport com.facebook.react.bridge.ReactMethod;%0Aimport com.facebook.react.bridge.ReadableMap;
+android.content.pm.PackageInfo;%0Aimport android.content.pm.PackageManager;%0Aimport android.os.Build;%0Aimport android.provider.Settings.Secure;%0A
 %0Aimp
@@ -260,18 +260,28 @@
 .Rea
-dableArray
+ctApplicationContext
 ;%0Aim
@@ -315,210 +315,88 @@
 dge.
-Callback;%0A%0Aimport android.os.Build;%0Aimport android.provider.Settings.Secure;%0Aimport android.content.pm.PackageManager
+ReactContextBaseJavaModule
 ;%0A
+%0A
 import 
-android.content.pm.PackageInfo;%0Aimport android.bluetooth.BluetoothAdapter
+java.util.HashMap;%0Aimport java.util.Locale
 ;%0A
-%0A
 impo
@@ -404,33 +404,30 @@
 t java.util.
-Hash
 Map;%0A
+%0A
 import java.
@@ -425,25 +425,37 @@
 ort java
-.util.Map
+x.annotation.Nullable
 ;%0A%0Apubli
@@ -756,24 +756,581 @@
 Info%22;%0A  %7D%0A%0A
+  private String getCurrentLanguage() %7B%0A      Locale current = getReactApplicationContext().getResources().getConfiguration().locale;%0A      if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.LOLLIPOP) %7B%0A          return current.toLanguageTag();%0A      %7D else %7B%0A          StringBuilder builder = new StringBuilder();%0A          builder.append(current.getLanguage());%0A          if (current.getCountry() != null) %7B%0A              builder.append(%22-%22);%0A              builder.append(current.getCountry());%0A          %7D%0A          return builder.toString();%0A      %7D%0A  %7D%0A%0A
   @Override%0A
@@ -2454,70 +2454,26 @@
 his.
-reactContext.getResources().getConfiguration().locale.toString
+getCurrentLanguage
 ());

Use getLanguageTag to retrieve device locale