diff --git a/features/batterycomponent/src/main/ets/default/pages/batteryPic.ets b/features/batterycomponent/src/main/ets/default/pages/batteryPic.ets index 5f78a3cac2ac0f54a854a6bc84bb516c35e1b7bb..7781c4fe27d62f1b5149cef2cf1842c10223f004 100644 --- a/features/batterycomponent/src/main/ets/default/pages/batteryPic.ets +++ b/features/batterycomponent/src/main/ets/default/pages/batteryPic.ets @@ -37,47 +37,65 @@ export default struct BatteryPic { } build() { - - Row() { + Stack({ alignContent: Alignment.Bottom }) { Row() { + Row() { + Row() { + } + .height('100%') + .width((this.batterySoc < 100 ? this.batterySoc : 100) + '%') + .backgroundColor(this.getBatteryColor(this.batterySoc, this.batteryCharging)) + } + .width(this.style.picBodyWidth) + .height(this.style.picBodyHeight) + .backgroundColor($r('app.color.battery_background')) + .border({ width: this.style.picBodyBorderWidth, + color: this.mTintContentInfo.contentColor, + radius: this.style.picBorderRadius, + style: BorderStyle.Solid }) + .padding(this.style.picBodyPadding) + .margin({ + // bottom: this.mTintContentInfo.contentColor.includes("FFFFFF") ? 0 : 8, + }) Row() { } - .height('100%') - .width((this.batterySoc < 100 ? this.batterySoc : 100) + '%') - .backgroundColor(this.getBatteryColor(this.batterySoc, this.batteryCharging)) - } - .width(this.style.picBodyWidth) - .height(this.style.picBodyHeight) - .backgroundColor($r('app.color.battery_background')) - .border({ width: this.style.picBodyBorderWidth, - color: this.mTintContentInfo.contentColor, - radius: this.style.picBorderRadius, - style: BorderStyle.Solid }) - .padding(this.style.picBodyPadding) + .width(this.style.picGap) + .height(1) - Row() { + Row() { + } + .width(this.style.picHeadWidth) + .height(this.style.picHeadHeight) + .backgroundColor(this.mTintContentInfo.contentColor) + .borderRadius(this.style.picHeadBorderRadius) + // .margin({ + // bottom: 1, + // }) - } - .width(this.style.picGap) - .height(1) - Row() { + } + .margin({ + top: $r("app.float.battery_component_margin"), + bottom: $r("app.float.battery_component_margin"), + left: $r("app.float.battery_component_margin"), + right: $r("app.float.battery_component_margin") + }) + if (this.batteryCharging) { + Row() { + Image(this.mTintContentInfo.contentColor.includes("FFFFFF") ? $r("app.media.light") : $r("app.media.deep")) + .height(this.style.picBodyHeight) + .margin({ + bottom: $r('app.float.battery_component_pic_gap'), + }) + } + .justifyContent(FlexAlign.Center) } - .width(this.style.picHeadWidth) - .height(this.style.picHeadHeight) - .backgroundColor(this.mTintContentInfo.contentColor) - .borderRadius(this.style.picHeadBorderRadius) + + } - .margin({ - top: $r("app.float.battery_component_margin"), - bottom: $r("app.float.battery_component_margin"), - left: $r("app.float.battery_component_margin"), - right: $r("app.float.battery_component_margin") - }) } - private getBatteryColor(val, charging) { Log.showInfo(TAG, `getBatteryColor, val: ${val} charging: ${charging} `); if (charging) { diff --git a/features/batterycomponent/src/main/resources/base/media/deep.png b/features/batterycomponent/src/main/resources/base/media/deep.png new file mode 100644 index 0000000000000000000000000000000000000000..16862ba8058b00656bfd92a3a2b37d5922120364 Binary files /dev/null and b/features/batterycomponent/src/main/resources/base/media/deep.png differ diff --git a/features/batterycomponent/src/main/resources/base/media/light.png b/features/batterycomponent/src/main/resources/base/media/light.png new file mode 100644 index 0000000000000000000000000000000000000000..07c46724f4ddfc25aba11780034be0e59382d37a Binary files /dev/null and b/features/batterycomponent/src/main/resources/base/media/light.png differ diff --git a/features/bluetoothcomponent/src/main/ets/com/ohos/model/BluetoothService.ts b/features/bluetoothcomponent/src/main/ets/com/ohos/model/BluetoothService.ts index a54c0610a1fe664da1b9bc4dc1d5a3584d8bd187..68c2dea6085f2f12a8cfd0a0fff64eac652f00ca 100644 --- a/features/bluetoothcomponent/src/main/ets/com/ohos/model/BluetoothService.ts +++ b/features/bluetoothcomponent/src/main/ets/com/ohos/model/BluetoothService.ts @@ -14,10 +14,12 @@ */ import bluetooth from '@ohos.bluetooth'; +import bluetoothManager from '@ohos.bluetoothManager'; import Log from '../../../../../../../../common/src/main/ets/default/Log'; import createOrGet from '../../../../../../../../common/src/main/ets/default/SingleInstanceHelper'; const TAG = 'BluetoothModel'; +const DEFAULT_DEVICENAME = '蓝牙'; export interface BlueupdateStateListener { updateState(state: boolean): void; @@ -33,8 +35,27 @@ export class BluetoothService { mIsStart = false; mListener: BlueupdateStateListener; mIsBluetoothOpen = false; + private profiles: any[] = new Array(10); + public canUse: boolean = false; constructor() { + try{ + Log.showDebug(TAG, 'bluetooth.getProfile start') + let profileId = bluetoothManager.ProfileId; + this.profiles[profileId.PROFILE_A2DP_SOURCE] = + bluetoothManager.getProfileInstance(profileId.PROFILE_A2DP_SOURCE); + this.profiles[profileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY] = + bluetoothManager.getProfileInstance(profileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY); + this.profiles[profileId.PROFILE_HID_HOST] = + bluetoothManager.getProfileInstance(profileId.PROFILE_HID_HOST); + Log.showDebug(TAG, 'bluetooth.getProfile end') + this.canUse = true; + } + catch(error){ + Log.showDebug(TAG, 'bluetooth.getProfile error') + this.canUse = false; + Log.showDebug(TAG, `BluetoothModel error: ${JSON.stringify(error)}.`); + } Log.showDebug(TAG, 'constructor'); } @@ -44,19 +65,20 @@ export class BluetoothService { } this.mIsStart = true; this.mIsBluetoothOpen = isBluetoothOpen(bluetooth.getState()); - bluetooth.on('stateChange', (state): void => { - let isOpen = isBluetoothOpen(state); - if (this.mIsBluetoothOpen != isOpen) { - Log.showInfo(TAG, `state change: ${isOpen}`); - this.mIsBluetoothOpen = isOpen; - this.mListener?.updateState(this.mIsBluetoothOpen); - } - if(state == bluetooth.BluetoothState.STATE_ON) { - bluetooth.setBluetoothScanMode(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 0); + bluetooth.on('stateChange', (state) => { + Log.showInfo(TAG, `bluetooth onStatechange state: ${state}`); + const bluetoothOpenStatus = !!(state === 4 || state === 1 || state === 5 || state === 2); + Log.showInfo(TAG, `bluetooth onStatechange bluetoothOpenStatus: ${bluetoothOpenStatus}`); + if (!bluetoothOpenStatus) { + AppStorage.SetOrCreate('deviceName', DEFAULT_DEVICENAME); } + AppStorage.setOrCreate('BluetoothOpenStatus', bluetoothOpenStatus); }); Log.showInfo(TAG, `startService, mIsBluetoothOpen: ${this.mIsBluetoothOpen}`); } + getBluetoothState(): bluetooth.BluetoothState { + return bluetooth.getState(); + } stopService(): void { if (!this.mIsStart) { @@ -66,6 +88,48 @@ export class BluetoothService { this.mIsStart = false; bluetooth.off('stateChange'); } + /** + * Subscribe device connection state Change + */ + subscribeDeviceStateChange(callback: (data: { + profileId: number; + deviceId: string; + profileConnectionState: number; + }) => void): void { + for (let i = 0;i < this.profiles.length; i++) { + if (this.profiles[i]) { + let profile = this.profiles[i]; + profile.on('connectionStateChange', (data) => { + if (callback) { + let result = { + profileId: i, + deviceId: data.deviceId, + profileConnectionState: data.state + }; + Log.showInfo(TAG, `subscribeDeviceStateChange->connectionStateChange, + return:${result.profileId} - ${result.profileConnectionState}`); + callback(result); + } + }) + } + } + } + + /** + * unsubscribe device connection state Change + */ + unsubscribeDeviceStateChange(callback?: (data: { + profileId: number; + deviceId: string; + profileConnectionState: number; + }) => void): void { + for (let i = 0; i < this.profiles.length; i++) { + if (this.profiles[i]) { + let profile = this.profiles[i]; + profile.off('connectionStateChange'); + } + } + } registerListener(listener: BlueupdateStateListener): void { Log.showInfo(TAG, `registerListener, listener: ${listener}`); @@ -90,6 +154,9 @@ export class BluetoothService { Log.showInfo(TAG, `disableBluetooth, result: ${result}`); return result; } + getBlueState(): bluetooth.BluetoothState { + return bluetooth.getState(); + } } let sBluetoothService = createOrGet(BluetoothService, TAG); diff --git a/features/bluetoothcomponent/src/main/ets/com/ohos/pages/ControlCenterComplexToggleBluetoothComponent.ets b/features/bluetoothcomponent/src/main/ets/com/ohos/pages/ControlCenterComplexToggleBluetoothComponent.ets index 151efd1ad582cc136292bf1a3aebb05fb6a4b1d0..35c0d75582733b0551336ec8c80a88c421816f65 100644 --- a/features/bluetoothcomponent/src/main/ets/com/ohos/pages/ControlCenterComplexToggleBluetoothComponent.ets +++ b/features/bluetoothcomponent/src/main/ets/com/ohos/pages/ControlCenterComplexToggleBluetoothComponent.ets @@ -18,6 +18,7 @@ import EventManager from "../../../../../../../../common/src/main/ets/default/ev import {obtainStartAbility} from "../../../../../../../../common/src/main/ets/default/event/EventUtil"; import ViewModel from '../viewmodel/BluetoothVM'; import iconTitleBase from '../../../../../../../../common/src/main/ets/template/iconTitleBase'; +import bluetooth from '@ohos.bluetooth'; const TAG = 'bluetooth-ControlCenterComplexToggleBluetoothComponent'; @@ -29,6 +30,8 @@ export default struct ControlCenterComplexToggleBluetoothComponent { ]; @State mTitle: Resource = $r("app.string.control_center_complex_toggle_bluetooth_title"); @StorageLink('BluetoothOpenStatus') BluetoothOpenStatus: boolean = false; + @StorageLink('deviceName') deviceName: Resource | string = $r("app.string.control_center_complex_toggle_bluetooth_title"); + private timeoutId: number = -1; aboutToAppear() { Log.showInfo(TAG, 'aboutToAppear'); @@ -44,7 +47,7 @@ export default struct ControlCenterComplexToggleBluetoothComponent { iconTitleBase({ iconOff: this.IconInfo[0], iconOn: this.IconInfo[1], - mTitle: $mTitle, + mTitle: $deviceName, changeSwitch: $BluetoothOpenStatus, mClickEvent: () => this.mClickEvent(), mLongClickEvent: () => this.mLongClickEvent() @@ -54,12 +57,34 @@ export default struct ControlCenterComplexToggleBluetoothComponent { } mClickEvent() { - Log.showDebug(TAG, `mClickEvent, BluetoothOpenStatus: ${this.BluetoothOpenStatus}`); - if (this.BluetoothOpenStatus) { - ViewModel.disableBluetooth(); - } else { - ViewModel.enableBluetooth(); - }; + let mBluetoothOpenStatus = !this.BluetoothOpenStatus; + Log.showInfo(TAG, `mClickEvent, BluetoothOpenStatus: ${this.BluetoothOpenStatus}; timeoutId: ${JSON.stringify(this.timeoutId)}`); + if (this.timeoutId != -1) { + Log.showInfo(TAG, `timeoutId is not -1`); + clearTimeout(this.timeoutId); + } + this.timeoutId = setTimeout(() => { + let curState: bluetooth.BluetoothState = ViewModel.getBlueState(); + Log.showInfo(TAG, `curState: ${JSON.stringify(curState)}`); + if (mBluetoothOpenStatus == ( + curState == bluetooth.BluetoothState.STATE_ON || + curState == bluetooth.BluetoothState.STATE_TURNING_ON || + curState == bluetooth.BluetoothState.STATE_BLE_TURNING_ON || + curState == bluetooth.BluetoothState.STATE_BLE_ON + )) { + Log.showInfo(TAG, `curStatte not need change`); + this.timeoutId = -1; + return; + } + if (mBluetoothOpenStatus) { + Log.showInfo(TAG, `enableBluetooth`); + ViewModel.enableBluetooth(); + } else { + Log.showInfo(TAG, `disableBluetooth`); + ViewModel.disableBluetooth(); + } + this.timeoutId = -1; + }, 500) } mLongClickEvent() { diff --git a/features/bluetoothcomponent/src/main/ets/com/ohos/pages/StatusBarIconItemBluetoothComponent.ets b/features/bluetoothcomponent/src/main/ets/com/ohos/pages/StatusBarIconItemBluetoothComponent.ets index 7f79c98477219b8f0ce94db7b356ff14806833d4..0b46e319cdf22c1792c0c2209aeeb0b964608731 100644 --- a/features/bluetoothcomponent/src/main/ets/com/ohos/pages/StatusBarIconItemBluetoothComponent.ets +++ b/features/bluetoothcomponent/src/main/ets/com/ohos/pages/StatusBarIconItemBluetoothComponent.ets @@ -26,6 +26,7 @@ const TAG = 'bluetooth-StatusBarIconItemBluetoothComponent'; @Component export default struct StatusBarIconItemBluetoothComponent { @StorageLink('BluetoothOpenStatus') BluetoothOpenStatus: boolean = false; + @StorageLink('isConnected') isConnected: boolean = false; @State mTintContentInfo: TintContentInfo = ViewModel.getTintContentInfo(); @State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle(); @State style: StatusBarBluetoothComponentStyle = StyleConfiguration.getStatusBarBluetoothComponentStyle(); @@ -43,7 +44,7 @@ export default struct StatusBarIconItemBluetoothComponent { Row() { if (this.BluetoothOpenStatus) { Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%') - Image($r("app.media.ic_status_bt")) + Image(this.getImage(this.isConnected)) .objectFit(ImageFit.Contain) .width(this.style.staticBarBluetoothWidth) .height(this.style.staticBarBluetoothHeight) @@ -52,6 +53,17 @@ export default struct StatusBarIconItemBluetoothComponent { } } .height('100%') - .opacity($r("app.float.icon_component_opacity")) + .opacity($r('app.float.icon_component_opacity')) + } + + private getImage(isConnected: boolean) { + Log.showInfo(TAG, `949494getImage:${isConnected}`); + let bluetoothImage; + if(isConnected) { + bluetoothImage = $r('app.media.ic_status_bt_connecting'); + } else { + bluetoothImage = $r('app.media.ic_status_bt'); + } + return bluetoothImage; } } \ No newline at end of file diff --git a/features/bluetoothcomponent/src/main/ets/com/ohos/viewmodel/BluetoothVM.ts b/features/bluetoothcomponent/src/main/ets/com/ohos/viewmodel/BluetoothVM.ts index 964d11956923fd877e123dd3f33591c5067fe5b3..c1a43bfc02b5856d1e07bcf963cb9ec91704970a 100644 --- a/features/bluetoothcomponent/src/main/ets/com/ohos/viewmodel/BluetoothVM.ts +++ b/features/bluetoothcomponent/src/main/ets/com/ohos/viewmodel/BluetoothVM.ts @@ -15,15 +15,20 @@ import Log from '../../../../../../../../common/src/main/ets/default/Log'; import { FASlotName } from '../../../../../../../../common/src/main/ets/default/Constants'; -import { TintContentInfo, getOrCreateTintContentInfo -} from '../../../../../../../../common/src/main/ets/default/TintStateManager'; +import { + TintContentInfo, + getOrCreateTintContentInfo } from '../../../../../../../../common/src/main/ets/default/TintStateManager'; import createOrGet from '../../../../../../../../common/src/main/ets/default/SingleInstanceHelper'; import BluetoothService from '../model/BluetoothService'; +import bluetooth from '@ohos.bluetooth'; +import constant from '@ohos.bluetooth.constant'; export const BLUETOOTH_OPEN_STATUS_KEY = 'BluetoothOpenStatus'; const TAG = 'BluetoothVM'; +const DEFAULT_DEVICENAME = '蓝牙'; + export class BluetoothVM { mIsStart = false; mBluetoothOpenStatus: SubscribedAbstractProperty; @@ -39,9 +44,35 @@ export class BluetoothVM { } Log.showDebug(TAG, 'initViewModel '); this.mIsStart = true; - this.mBluetoothOpenStatus = AppStorage.SetAndLink(BLUETOOTH_OPEN_STATUS_KEY, false); + AppStorage.setOrCreate('deviceName', DEFAULT_DEVICENAME); + AppStorage.setOrCreate('isConnected', false); + AppStorage.setOrCreate('BluetoothOpenStatus', BluetoothService.getBluetoothState() === 2); BluetoothService.startService(); - BluetoothService.registerListener(this); + this.subscribeDeviceConnectStateChange(); + } + + /** + * Subscribe device connect state change + */ + private subscribeDeviceConnectStateChange() { + BluetoothService.subscribeDeviceStateChange((data: { + profileId: number; + deviceId: string; + profileConnectionState: number; + }) => { + Log.showInfo(TAG, 'device connection state changed. profileId:' + JSON.stringify(data.profileId) + + ' profileConnectionState: ' + JSON.stringify(data.profileConnectionState)); + let deviceName = bluetooth.getRemoteDeviceName(data?.deviceId); + if (data.profileConnectionState === constant.ProfileConnectionState.STATE_CONNECTED || data.profileConnectionState === constant.ProfileConnectionState.STATE_DISCONNECTING){ + AppStorage.SetOrCreate('deviceName', deviceName); + AppStorage.SetOrCreate('isConnected', true); + Log.showInfo(TAG, `device isConnected,deviceName:${deviceName}`); + } else { + AppStorage.SetOrCreate('deviceName', DEFAULT_DEVICENAME); + AppStorage.SetOrCreate('isConnected', false); + Log.showInfo(TAG, 'device disConnected'); + } + }); } updateState(state: boolean): void { @@ -49,6 +80,10 @@ export class BluetoothVM { this.mBluetoothOpenStatus.set(state); } + getBluetoothState() { + return BluetoothService.getBluetoothState(); + } + enableBluetooth(): boolean{ return BluetoothService.enableBluetooth(); } @@ -60,6 +95,10 @@ export class BluetoothVM { getTintContentInfo(): TintContentInfo { return this.mTintContentInfo; } + + getBlueState(): bluetooth.BluetoothState { + return BluetoothService.getBlueState(); + } } let sBluetoothVM = createOrGet(BluetoothVM, TAG); diff --git a/features/bluetoothcomponent/src/main/resources/phone/media/ic_status_bt_connecting.svg b/features/bluetoothcomponent/src/main/resources/phone/media/ic_status_bt_connecting.svg new file mode 100644 index 0000000000000000000000000000000000000000..b69946abf4759c26320c45eca213f9ae3fc587db --- /dev/null +++ b/features/bluetoothcomponent/src/main/resources/phone/media/ic_status_bt_connecting.svg @@ -0,0 +1,11 @@ + + + ic_status_bt_connecting + + + + + + + + \ No newline at end of file diff --git a/features/wificomponent/src/main/ets/default/pages/wifiComponent.ets b/features/wificomponent/src/main/ets/default/pages/wifiComponent.ets index 74052e3fec4dbba7a7695707ac988885dcf3e257..df33efdffa990edc5c0224e995014b5820d96218 100644 --- a/features/wificomponent/src/main/ets/default/pages/wifiComponent.ets +++ b/features/wificomponent/src/main/ets/default/pages/wifiComponent.ets @@ -16,9 +16,10 @@ import mWifiManger from '../wifiModel' import Log from '../../../../../../../common/src/main/ets/default/Log' import EventManager from "../../../../../../../common/src/main/ets/default/event/EventManager" -import {obtainStartAbility} from "../../../../../../../common/src/main/ets/default/event/EventUtil" +import { obtainStartAbility } from "../../../../../../../common/src/main/ets/default/event/EventUtil" import iconTitleBase from '../../../../../../../common/src/main/ets/template/iconTitleBase' import Constants from '../common/constants' +import mWifiModel from '../wifiModel' const TAG = 'Control-wifiComponent' @@ -30,17 +31,33 @@ export default struct WifiComponent { ] @StorageLink('wifiName') wifiName: string = Constants.DEFAULT_WIFI_NAME @StorageLink('wifiOpenStatus') wifiOpenStatus: boolean = Constants.DEFAULT_WIFI_OPEN_STATUS + private timeoutId: number = -1; mClickEvent() { + this.wifiOpenStatus = !this.wifiOpenStatus; Log.showInfo(TAG, `mClickEvent, wifiOpenStatus: ${this.wifiOpenStatus}`); - if (this.wifiOpenStatus == false) { - Log.showInfo(TAG, `WLAN status is closing:${this.wifiOpenStatus} “no”, set WLAN status enableWifi`); - mWifiManger.enableWifi() - } else { - Log.showInfo(TAG, `WLAN status is opening:${this.wifiOpenStatus} “yes”,se WLAN status disableWifi`); - mWifiManger.disableWifi() + if (this.timeoutId != -1) { + Log.showInfo(TAG, `timeoutId is not -1`); + clearTimeout(this.timeoutId); } + let curState: boolean = mWifiModel.wifiIsActive(); + Log.showInfo(TAG, `curState: ${JSON.stringify(curState)}`); + this.timeoutId = setTimeout(() => { + if (this.wifiOpenStatus == curState) { + Log.showInfo(TAG, `curState not need change`); + this.timeoutId = -1; + return; + } + if (this.wifiOpenStatus) { + Log.showInfo(TAG, `enableWifi`); + mWifiModel.enableWifi(); + } else { + Log.showInfo(TAG, `disableWifi`); + mWifiModel.disableWifi(); + } + this.timeoutId = -1; + }, 500); } mLongClickEvent() { diff --git a/features/wificomponent/src/main/ets/default/wifiModel.ts b/features/wificomponent/src/main/ets/default/wifiModel.ts index 5fd30ed8c15e25d70e43e4f3d1512240c3ff0e37..4b266bad817fafe15ff2a11e0820869bfeff0a46 100644 --- a/features/wificomponent/src/main/ets/default/wifiModel.ts +++ b/features/wificomponent/src/main/ets/default/wifiModel.ts @@ -35,10 +35,10 @@ export class WifiModel { Log.showInfo(TAG, 'initWifiModel'); this.mIsStart = true; - mWifiInfo = AppStorage.SetAndLink('wifiInfo', Constants.DEFAULT_WIFI_INFO); - mWifiStatus = AppStorage.SetAndLink('wifiStatus', Constants.DEFAULT_WIFI_STATUS); - mWifiName = AppStorage.SetAndLink('wifiName', Constants.DEFAULT_WIFI_NAME); - mWifiOpenStatus = AppStorage.SetAndLink('wifiOpenStatus', Constants.DEFAULT_WIFI_OPEN_STATUS); + mWifiInfo = AppStorage.setAndLink('wifiInfo', Constants.DEFAULT_WIFI_INFO); + mWifiStatus = AppStorage.setAndLink('wifiStatus', Constants.DEFAULT_WIFI_STATUS); + mWifiName = AppStorage.setAndLink('wifiName', Constants.DEFAULT_WIFI_NAME); + mWifiOpenStatus = AppStorage.setAndLink('wifiOpenStatus', Constants.DEFAULT_WIFI_OPEN_STATUS); this.getWifiInfo(); @@ -74,7 +74,9 @@ export class WifiModel { if (data == WifiState.STATE_OFF || data == WifiState.STATE_ON) { let checkState = wifi.isWifiActive(); Log.showInfo(TAG, `checkState, data: ${JSON.stringify(checkState)}`); - mWifiOpenStatus.set(checkState); + if (mWifiOpenStatus.get() !== checkState) { + mWifiOpenStatus.set(checkState); + } if (checkState) { this.getWifiConnectInfo(); } else { @@ -113,7 +115,7 @@ export class WifiModel { let isConnected = wifi.isConnected(); Log.showInfo(TAG, `getWifiConnectInfo, isConnected: ${isConnected}`); if (isConnected) { - mWifiStatus.set(true); + mWifiStatus?.set(true); this.getLinkedInfo(); } else { this.setDisconnectedStatus(); @@ -124,11 +126,11 @@ export class WifiModel { Log.showInfo(TAG, 'getLinkedInfo'); wifi.getLinkedInfo((err, data) => { if (wifi.isConnected()) { - mWifiStatus.set(true); - mWifiName.set(data.ssid); + mWifiStatus?.set(true); + mWifiName?.set(data.ssid); let signalLevel = wifi.getSignalLevel(data.rssi, data.band); Log.showInfo(TAG, `getLinkedInfo, signalLevel: ${signalLevel}`); - mWifiInfo.set(signalLevel); + mWifiInfo?.set(signalLevel); } else { this.setDisconnectedStatus(); } @@ -137,9 +139,13 @@ export class WifiModel { setDisconnectedStatus(): void { Log.showInfo(TAG, 'setDisconnectedStatus'); - mWifiStatus.set(Constants.DEFAULT_WIFI_STATUS); - mWifiInfo.set(Constants.DEFAULT_WIFI_INFO); - mWifiName.set(Constants.DEFAULT_WIFI_NAME); + mWifiStatus?.set(Constants.DEFAULT_WIFI_STATUS); + mWifiInfo?.set(Constants.DEFAULT_WIFI_INFO); + mWifiName?.set(Constants.DEFAULT_WIFI_NAME); + } + + wifiIsActive(): boolean { + return wifi.isWifiActive(); } enableWifi(): void { diff --git a/product/phone/statusbar/src/main/resources/base/media/deep.png b/product/phone/statusbar/src/main/resources/base/media/deep.png new file mode 100644 index 0000000000000000000000000000000000000000..16862ba8058b00656bfd92a3a2b37d5922120364 Binary files /dev/null and b/product/phone/statusbar/src/main/resources/base/media/deep.png differ diff --git a/product/phone/statusbar/src/main/resources/base/media/ic_status_bt_connecting.svg b/product/phone/statusbar/src/main/resources/base/media/ic_status_bt_connecting.svg new file mode 100644 index 0000000000000000000000000000000000000000..b69946abf4759c26320c45eca213f9ae3fc587db --- /dev/null +++ b/product/phone/statusbar/src/main/resources/base/media/ic_status_bt_connecting.svg @@ -0,0 +1,11 @@ + + + ic_status_bt_connecting + + + + + + + + \ No newline at end of file diff --git a/product/phone/statusbar/src/main/resources/base/media/light.png b/product/phone/statusbar/src/main/resources/base/media/light.png new file mode 100644 index 0000000000000000000000000000000000000000..07c46724f4ddfc25aba11780034be0e59382d37a Binary files /dev/null and b/product/phone/statusbar/src/main/resources/base/media/light.png differ