<commit_before>package sc.shortcut.sdk.android.deeplinking;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

/**
 * Main Singleton class.
 */
public class SCDeepLinking {

    private static final String LOG_TAG = SCDeepLinking.class.getSimpleName();

    private static final String LINK_ID_KEY= "sc_link_id";

    private static SCDeepLinking sSCDeepLinking;
    private Context mContext;
    private SCActivityLifecyleObserver mActivityLifecyleObserver;
    private boolean mActivityLifecyleCallbackRegistred;
    private SCPreference mPreference;
    private boolean mAutoSessionMode;
    private boolean mTestMode;

    private Activity mCurrentActivity;
    private Uri mDeepLinkAtLaunch;
    private Uri mDeepLink;
    private SCSession mCurrentSession;
    private Map<Activity, SCSession> mSessions;
    private boolean mDeviceRotated;


    private SCDeepLinking(Context context) {
        mContext = context;
        mPreference = new SCPreference(context.getApplicationContext());
        mSessions = new HashMap<>();

        if (context instanceof SCDeepLinkingApp) {
            mAutoSessionMode = true;
            setActivityLifeCycleObserver((Application) context.getApplicationContext());
        }

        if (context instanceof Activity) {
            Intent intent = ((Activity) context).getIntent();
            mDeepLinkAtLaunch = getDeepLinkFromIntent(intent);

            // TODO do not strip Deeplink id if prevented by configuration
            mDeepLink = SCUtils.uriStripQueryParameter(mDeepLinkAtLaunch, LINK_ID_KEY);
            intent.setData(mDeepLink);
        }
    }

    public static SCDeepLinking getInstance(Context context) {
        if (sSCDeepLinking == null) {
            sSCDeepLinking = new SCDeepLinking(context);
        }
        return sSCDeepLinking;
    }

    public static SCDeepLinking getInstance() {
        return sSCDeepLinking;
    }

    public void startSession(Intent intent) {<commit_msg>fix: unobserved activity lifecyle method breaks otherwise<commit_after>package sc.shortcut.sdk.android.deeplinking;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

/**
 * Main Singleton class.
 */
public class SCDeepLinking {

    private static final String LOG_TAG = SCDeepLinking.class.getSimpleName();

    private static final String LINK_ID_KEY= "sc_link_id";

    private static SCDeepLinking sSCDeepLinking;
    private Context mContext;
    private SCActivityLifecyleObserver mActivityLifecyleObserver;
    private boolean mActivityLifecyleCallbackRegistred;
    private SCPreference mPreference;
    private boolean mAutoSessionMode;
    private boolean mTestMode;

    private Activity mCurrentActivity;
    private Uri mDeepLinkAtLaunch;
    private Uri mDeepLink;
    private SCSession mCurrentSession;
    private Map<Activity, SCSession> mSessions;
    private boolean mDeviceRotated;


    private SCDeepLinking(Context context) {
        mContext = context;
        mPreference = new SCPreference(context.getApplicationContext());
        mSessions = new HashMap<>();

        if (context instanceof SCDeepLinkingApp) {
            mAutoSessionMode = true;
            setActivityLifeCycleObserver((Application) context.getApplicationContext());
        }
    }

    public static SCDeepLinking getInstance(Context context) {
        if (sSCDeepLinking == null) {
            sSCDeepLinking = new SCDeepLinking(context);
        }
        return sSCDeepLinking;
    }

    public static SCDeepLinking getInstance() {
        return sSCDeepLinking;
    }

    public void startSession(Intent intent) {
{'fraction_non_alphanumeric': 0.07321428571428572, 'fraction_numerical': 0.0, 'mean_word_length': 3.726793248945148, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '3960323', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1259, 'n_words': 300}