package com.longtu.sample;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

import com.acegameproject.burstshooter.R;
import com.longtugame.ndklibray.LTJniTest;

import java.util.Arrays;

/**
 * 崩溃测试功能。
 * 作者：liqingshuo on 2019-08-09 16:57
 *
 * @author liqingshuo
 */
public class LTBase_Demo_CrashTest extends Activity implements View.OnClickListener {

    private Button mCrashJava, mCrashAnr, mCrashSo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // 设置无标题(DEMO代码)
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        // // 设置全屏幕(DEMO代码)
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        int currentApiVersion = Build.VERSION.SDK_INT;
        if (currentApiVersion >= 14) {
            WindowManager.LayoutParams params = getWindow().getAttributes();
            params.systemUiVisibility = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
            getWindow().setAttributes(params);
        }

        // 强制使屏幕一直处于活动状态，不关闭背景光(DEMO代码)
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        setContentView(R.layout.longtu_demo_crashtest);

        mCrashJava = (Button)this.findViewById(R.id.crash_java);
        mCrashAnr = (Button)this.findViewById(R.id.crash_anr);
        mCrashSo = (Button)this.findViewById(R.id.crash_so);


        mCrashJava.setOnClickListener(this);
        mCrashAnr.setOnClickListener(this);
        mCrashSo.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        if (v == this.mCrashJava) {
            String a = null;
            String b = a.substring(111);
            Arrays abc = null;
            String abcd = abc.toString();
        } else if (v == this.mCrashAnr) {

            try {
                Thread.sleep(16000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        } else if (v == this.mCrashSo) {
            LTJniTest mLTJniTest = new LTJniTest();
            mLTJniTest.getdesKey();
        }
    }
}
