fix bug: jscrash caused by asynchrony

Signed-off-by: xuchangzhou <xuzhangzhou@huawei.com>
This commit is contained in:
xuchangzhou 2022-06-09 11:10:26 +08:00
parent 8c8398a8a2
commit 230e236aed
2 changed files with 10 additions and 6 deletions

View File

@ -34,11 +34,6 @@ var volumePanelWant = {
"abilityName": "com.ohos.systemui.volumepanel.ServiceExtAbility"
}
var dropdownPanelWant = {
"bundleName": "com.ohos.systemui",
"abilityName": "com.ohos.systemui.dropdownpanel.ServiceExtAbility"
}
class ServiceExtAbility extends ServiceExtension {
onCreate(want) {
Log.showInfo(TAG, `onCreate, want: ${JSON.stringify(want)}`)
@ -47,7 +42,6 @@ class ServiceExtAbility extends ServiceExtension {
AbilityManager.startAbility(statusBarWant)
AbilityManager.startAbility(navigationBarWant)
AbilityManager.startAbility(volumePanelWant)
AbilityManager.startAbility(dropdownPanelWant)
}
onDestroy() {

View File

@ -13,6 +13,7 @@
* limitations under the License.
*/
import deviceInfo from "@ohos.deviceInfo"
import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
import Log from '../../../../../../../common/src/main/ets/default/Log'
import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager'
@ -21,6 +22,11 @@ import NavBarConfiguration from '../common/navbarconfiguration'
const TAG = "NavigationBar_ServiceExtAbility"
var dropdownPanelWant = {
"bundleName": "com.ohos.systemui",
"abilityName": "com.ohos.systemui.dropdownpanel.ServiceExtAbility"
}
class ServiceExtAbility extends ServiceExtension {
async onCreate(want) {
Log.showInfo(TAG, `onCreate, want: ${JSON.stringify(want)}`);
@ -49,6 +55,10 @@ class ServiceExtAbility extends ServiceExtension {
}
}
AbilityManager.setAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config', configInfo)
if(deviceInfo.deviceType == "phone"){
AbilityManager.startAbility(dropdownPanelWant)
}
Log.showDebug(TAG, `onCreate, configInfo: ${JSON.stringify(configInfo)}`)
let navigationBarRect = {