<commit_before>
package io.xogus.reactnative.versioncheck;

import android.os.Build;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

public class RNVersionCheckModule extends ReactContextBaseJavaModule {

    private final ReactApplicationContext reactContext;

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

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

        constants.put("currentVersion", Build.VERSION.RELEASE);

        try {
            constants.put("latestVersion", getMarketVersion(this.reactContext.getPackageName()));
        } catch (Exception e) {
            constants.put("latestVersion", null);
        }

        return constants;
    }

    private String getMarketVersion(String packageName) throws Exception {
        String mData = "", mVer = null;

        URL mUrl = new URL("https://play.google.com/store/apps/details?id="
                + packageName);
        HttpURLConnection mConnection = (HttpURLConnection) mUrl
                .openConnection();<commit_msg>get current app version<commit_after>
package io.xogus.reactnative.versioncheck;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

public class RNVersionCheckModule extends ReactContextBaseJavaModule {

    private final ReactApplicationContext reactContext;

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

    @Override
    public Map<String, Object> getConstants() {
        Map<String, Object> constants = new HashMap<>();
        final String packageName = this.reactContext.getPackageName();

        try {
            PackageManager packageManager = this.reactContext.getPackageManager();
            PackageInfo info = packageManager.getPackageInfo(packageName, 0);
            constants.put("currentVersion", info.versionName);
            constants.put("currentBuildNumber", info.versionCode);
        } catch (PackageManager.NameNotFoundException e) {
            constants.put("currentVersion", null);
            constants.put("currentBuildNumber", null);
        }


        try {
            constants.put("latestVersion", getMarketVersion(packageName));
        } catch (Exception e) {
            constants.put("latestVersion", null);
        }

        return constants;
    }

    private String getMarketVersion(String packageName) throws Exception {
        String mData = "", mVer = null;

        URL mUrl = new URL("https://play.google.com/store/apps/details?id="
                + packageName);
        HttpURLConnection mConnection = (HttpURLConnection) mUrl
                .openConnection();
{'fraction_non_alphanumeric': 0.09520993494973388, 'fraction_numerical': 0.00029568302779420464, 'mean_word_length': 3.3040712468193383, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5566688', 'n_tokens_mistral': 873, 'n_tokens_neox': 858, 'n_words': 183}