package com.app.baselibrary.commonUtil;

import android.content.Context;
import android.content.Intent;

import com.app.baselibrary.base.app.BaseApplication;

/**
 * Created by zhaopenglei on 16/9/23.
 */

public class NibiruUtils {

    public static boolean isOpenVR = false;

    public static boolean isOpenVR() {
        return isOpenVR;
    }

    public static void setIsOpenVR(boolean isOpenVR) {
        NibiruUtils.isOpenVR = isOpenVR;
    }

    /**
     * 切换当双眼模式的方法;
     *
     * @param isOpenVR 是否开启VR模式;
     */
    public static void switchVR(boolean isOpenVR) {
        setIsOpenVR(isOpenVR);
        Intent intent = new Intent("com.nibiru.vr.sdk.action.switchvr");
        intent.putExtra("vr_mode", !isOpenVR);
        ContextUtil.getAppContext().sendBroadcast(intent);
    }

    public static void switchLocalEnterStatus(boolean show) {
        Intent intent = new Intent("com.oo.seex.sys.command.app_list");
        intent.putExtra("show", show);
        BaseApplication.getAppContext().sendBroadcast(intent);
        PreferencesUtils.putBoolean( BaseApplication.getAppContext(), "switchLocal", show);
    }

    public static void startNibiruSetting(Context context) {
        Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage("com.android.nibiru.settings.vr");
        if (null != launchIntent) {
            context.startActivity(launchIntent);
        } else {
            ToastUtil.showMessage("找不到该package对应的应用！");
        }
    }

//    public static String getNibiruVersionCode(Activity activity) {
//
//        ServiceConnection mScon = new ServiceConnection() {
//
//            @Override
//            public void onServiceDisconnected(ComponentName arg0) {
//                Log.d("wayne", "nps onServiceDisconnected");
//                mNps = null;
//            }
//
//            @Override
//            public void onServiceConnected(ComponentName arg0, IBinder ibinder) {
//                Log.d("wayne", "nps onServiceConnected");
//                mNps = INibiruVRPublicService.Stub.asInterface(ibinder);
//            }
//        };
//
//        Intent intent = new Intent("com.nibiru.public.service");
//        intent.setPackage("com.nibiru.vrconfig");
//        activity.bindService(intent, mScon, BIND_AUTO_CREATE);
//
//        try {
//            if (null == mNps) {
//                return "unfind_version";
//            }
//            return mNps.getNibiruOSVersion();
//        } catch (RemoteException e) {
//            e.printStackTrace();
//        }
//
//        return "unfind_version";
//    }
}
