コード例 #1
0
 protected override void OnDestroy()
 {
     this.CancelInvoke("UpdateBatteryLevel");
     BatteryUtils.unRegisterPowerConnectionListener(this.OnConnected, this.OnDisconnected);
     BatteryUtils.unRegisterBatteryLevelListener(null, null, this.OnBatteryLevelChange);
     base.OnDestroy();
 }
コード例 #2
0
    private void Init()
    {
        BatteryUtils      = SvrNativeInterface.GetInstance().BatteryUtils;
        MaxBatteryValue   = GetMaxBatteryValue();
        BatteryPowerLevel = 5;
        BPLevelUnit       = 10 / BatteryPowerLevel;
        OldBatteryValue   = 0;
        OldBatterySts     = BatteryStatus.NoCharging;

        //InvokeRepeating("CheckDeviceStatus", 0, 1);
    }
コード例 #3
0
        /************************************************自 定 义 方 法************************************************/
        //循环检测电量
        private void UpdateBatteryLevel()
        {
#if (UNITY_ANDROID) && (!UNITY_EDITOR)
            int batteryCapacity = BatteryUtils.getBatteryCapacity(AndroidContextHolder.GetAndroidContext());
            GuLog.Debug(string.Format("----BattaryStatusListenerView.UpdateBatteryLevel----Battery: {0}, InCharging: {1}", batteryCapacity, this.inCharging));
            while (this.tips.Count > 0)
            {
                GuLog.Debug(this.tips.Dequeue());
            }
#endif
        }
コード例 #4
0
        /************************************************Unity方法与事件***********************************************/
        protected override void Start()
        {
#if (UNITY_ANDROID) && (!UNITY_EDITOR)
            int batteryCapacity = BatteryUtils.getBatteryCapacity(AndroidContextHolder.GetAndroidContext());
            this.inCharging = BatteryUtils.isCharging(AndroidContextHolder.GetAndroidContext());
#else
            int batteryCapacity = 15;
#endif
            this.InvokeRepeating("UpdateBatteryLevel", 0, 5);
            this.OnBatteryLevelChange(batteryCapacity);
            BatteryUtils.registerPowerConnectionListener(this.OnConnected, this.OnDisconnected);
            BatteryUtils.registerBatteryLevelListener(null, null, this.OnBatteryLevelChange);
            GuLog.Debug(string.Format("----BattaryStatusListenerView.Start----unSafe: {0}", true));
        }
コード例 #5
0
    public SvrNativeInterface()
    {
        InitAndroidInterface();

        AppUtils        = new AppUtils(this);
        ApkUtils        = new ApkUtils(this);
        BatteryUtils    = new BatteryUtils(this);
        WifiUtils       = new WifiUtils(this);
        VolumeUtils     = new VolumeUtils(this);
        BrightnessUtils = new BrightnessUtils(this);
        DateTimeUtils   = new DateTimeUtils(this);
        WFDUtils        = new WFDUtils(this);
        FotaUtils       = new FotaUtils(this);
        BluetoothUtils  = new BluetoothUtils(this);
        DeviceUtils     = new DeviceUtils(this);
    }
コード例 #6
0
        //         [Inject]
        //         public HeartBeatBody body { set; get; }

        public override void Execute()
        {
            GuLog.Info("<><HeartBeatCommand> Execute!");
            if (mLocalChildInfoAgent.getChildSN() == null || mLocalChildInfoAgent.getChildSN() == string.Empty)
            {
                GuLog.Info("<><HeartBeatCommand> child sn null!");
                FinishAndDispatchResult(ResponseErroInfo.GetErrorInfo(100, "child sn null!"));
                return;
            }
            getHeartBeatService.serviceHeartBeatBackSignal.AddListener(HeartBeatResult);
            getHeartBeatService.serviceHeartBeatErrBackSignal.AddListener(HeartBeatResultErr);

            SChild child = SChild.getBuilder().setFriend_count(10)
                           .setX_child_sn(mLocalChildInfoAgent.getChildSN()).setLanguage(languageUtils.getLanguageToAgentKey()).build();

            CupBuild.getCupHwMac((mac) => {
                Debug.Log("HeartBeatCommand mac:" + mac);
                SCup cup = SCup.getBuilder().setCup_hw_mac(mac)
#if UNITY_EDITOR
                           .setBattery(50)
                           .setCharge(false)
                           .setCapability(0)
                           .build();
#else
                           .setBattery(BatteryUtils.getBatteryCapacity(AndroidContextHolder.GetAndroidContext()))
                           .setCharge(BatteryUtils.isCharging(AndroidContextHolder.GetAndroidContext()))
                           .setCapability(0)
                           .build();
#endif
                SGame game = SGame.getBuilder()
                             .setGame_name(AppData.GetAppName())
#if UNITY_EDITOR
                             .setGame_version("1.0.31")
#else
                             .setGame_version(CupBuild.getAppVersionName())
#endif
                             .setPet_model(mLocalPetInfoAgent.getCurrentPet()).build();

                SExtra extra = SExtra.getBuilder().setTimestamp(DateUtil.GetTimeStamp()).setTimezone(8).build();

                HeartBeatBody body = HeartBeatBody.getBuilder().setChild(child).setCup(cup).setGame(game).setExtra(extra).build();


                getHeartBeatService.HeartBeat(body);
            });
コード例 #7
0
        private void BatteryInitial()
        {
            BatteryUtils.registerBatteryLevelListener(onBatteryLow, onBatteryOkay, onBatteryLevelChange);

            BatteryUtils.registerPowerConnectionListener(onConnected, onDisconnected);

            if (BatteryUtils.isCharging(AndroidContextHolder.GetAndroidContext()))
            {
                RepeatBatteryUppdate();
            }
            else
            {
                onDisconnected();
            }
            bool batteryStatus = BatteryUtils.isCharging(AndroidContextHolder.GetAndroidContext());

            GuLog.Info("<><InCharging>BatteryUtils.isCharging<><>" + batteryStatus.ToString());
        }
コード例 #8
0
        void BatteryUpdate()
        {
            if (gameObject.activeInHierarchy)
            {
                textTemperatureLabel.gameObject.SetActive(false);
#if SHOW_VERSION
                textTemperatureLabel.gameObject.SetActive(true);
                int temperature = BatteryUtils.getBatteryTemperature(AndroidContextHolder.GetAndroidContext());
                textTemperature.text = temperature.ToString();
#endif
                int    batteryCapacity = BatteryUtils.getBatteryCapacity(AndroidContextHolder.GetAndroidContext());
                string aniPlay         = "power100";

                if (batteryCapacity >= 100)
                {
                    aniPlay = "power100end";
                }
                else if (batteryCapacity > 60)
                {
                    aniPlay = "power100";
                }
                else if (batteryCapacity > 40)
                {
                    aniPlay = "power80";
                }
                else if (batteryCapacity > 20)
                {
                    aniPlay = "power60";
                }
                else
                {
                    aniPlay = "power40";
                }
                //batteryAni.AnimationState.ClearTracks();
                batteryAni.AnimationState.SetAnimation(0, aniPlay, true);
                Debug.LogFormat("<><InCharging.BatteryUpdate>battery capaticy: {0}, aniPlay: {1}", batteryCapacity, aniPlay);
            }
        }
コード例 #9
0
        void Awake()
        {
            BatteryUtils.init();
            FlurryUtil.Init();
            AsyncActionHelper.Instance.init();
            FlurryUtil.SetUserId(CupBuild.getCupSn());
            FlurryUtil.LogEvent("Hank_Splashscreen_View");
            Screen.sleepTimeout = SleepTimeout.NeverSleep;
            GameObject objGlobalContextView = null; /*= GameObject.Find("GlobalContextView");
                                                     * if (objGlobalContextView == null)*/

            {
                objGlobalContextView      = new GameObject();
                objGlobalContextView.name = "GlobalContextView";
                GlobalContextView globalContextView = objGlobalContextView.AddComponent <GlobalContextView>();
                GameObject.DontDestroyOnLoad(globalContextView);
            }
#if (UNITY_IOS || UNITY_ANDROID) && (!UNITY_EDITOR)
#if WETEST_SDK
            objGlobalContextView.AddComponent <WeTest.U3DAutomation.U3DAutomationBehaviour>();
            BuglyAgent.RegisterLogCallback(WeTest.U3DAutomation.CrashMonitor._OnLogCallbackHandler);
#endif
#endif
        }
コード例 #10
0
        private void LowBatteryUpdate()
        {
#if (UNITY_ANDROID) && (!UNITY_EDITOR)
            int batteryCapacity = BatteryUtils.getBatteryCapacity(AndroidContextHolder.GetAndroidContext());
#else
            int batteryCapacity = 15;
#endif
            //GuLog.Info("<lowbattery><>batteryCapacity<><>" + batteryCapacity.ToString());

            switch (myStatus)
            {
            case BatteryStatus.Normal:
            {
                if (batteryCapacity >= 10 && batteryCapacity < 20)
                {
                    ShowLowBattery(BatteryStatus.LowBattery_20);
                }
                else if (batteryCapacity < 10)
                {
                    ShowLowBattery(BatteryStatus.LowBattery_10);
                }
            }
            break;

            case BatteryStatus.LowBattery_20:
            {
                if (batteryCapacity >= 20)
                {
                    FlurryUtil.LogEvent("LowBattery_20_Event");

                    lowBatteryGp.AnimationState.ClearTracks();
                    HideAll();
                    myStatus = BatteryStatus.Normal;
                }
                else if (batteryCapacity < 10)
                {
                    ShowLowBattery(BatteryStatus.LowBattery_10);
                }
            }
            break;

            case BatteryStatus.LowBattery_10:
            {
                if (batteryCapacity >= 20)
                {
                    FlurryUtil.LogEvent("LowBattery_20_Event");
                    FlurryUtil.LogEvent("LowBattery_10_Event");

                    lowBatteryGp.AnimationState.ClearTracks();
                    HideAll();
                    myStatus = BatteryStatus.Normal;
                }
                if (batteryCapacity >= 10 && batteryCapacity < 20)
                {
                    FlurryUtil.LogEvent("LowBattery_10_Event");

                    ShowLowBattery(BatteryStatus.LowBattery_20);
                }
            }
            break;
            }
        }