From 3d2bfdb307e37fb5fa09c6f744de6e8ce420a0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rulong=20Chen=EF=BC=88=E9=99=88=E6=B1=9D=E9=BE=99=EF=BC=89?= Date: Thu, 8 Aug 2024 16:22:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=95=E6=93=8E=E6=8E=A5=E5=8F=A3=E9=87=8D?= =?UTF-8?q?=E6=9E=84=EF=BC=8C=E4=BF=AE=E6=94=B9=E7=9B=B8=E5=85=B3=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E5=92=8C=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://gitee.com/openharmony-sig/flutter_engine/pulls/374 --- .../src/main/ets/entryability/BatteryPlugin.ets | 1 - ...44\275\277\347\224\250 FlutterEngineGroup.md" | 10 +++------- ...\225\344\275\277\347\224\250 FlutterEntry.md" | 10 +++------- .../src/main/ets/entryability/BatteryPlugin.ets | 1 - .../src/main/ets/entryability/EntryAbility.ets | 16 +++++----------- .../ohos/entry/src/main/ets/pages/Index1.ets | 4 ++-- .../ohos/entry/src/main/ets/pages/Index2.ets | 4 ++-- 7 files changed, 15 insertions(+), 31 deletions(-) diff --git a/ohos/channel_demo/ohos/entry/src/main/ets/entryability/BatteryPlugin.ets b/ohos/channel_demo/ohos/entry/src/main/ets/entryability/BatteryPlugin.ets index c2e73ca7..9686fc0f 100644 --- a/ohos/channel_demo/ohos/entry/src/main/ets/entryability/BatteryPlugin.ets +++ b/ohos/channel_demo/ohos/entry/src/main/ets/entryability/BatteryPlugin.ets @@ -17,7 +17,6 @@ import { Any, BasicMessageChannel, EventChannel, - FlutterManager, FlutterPlugin, Log, MethodCall, diff --git "a/ohos/docs/04_development/\345\246\202\344\275\225\344\275\277\347\224\250 FlutterEngineGroup.md" "b/ohos/docs/04_development/\345\246\202\344\275\225\344\275\277\347\224\250 FlutterEngineGroup.md" index f0b65093..b512e4d8 100644 --- "a/ohos/docs/04_development/\345\246\202\344\275\225\344\275\277\347\224\250 FlutterEngineGroup.md" +++ "b/ohos/docs/04_development/\345\246\202\344\275\225\344\275\277\347\224\250 FlutterEngineGroup.md" @@ -3,34 +3,30 @@ ## 1. EntryAbility 修改为继承自 UIAbility ```ts -export default class EntryAbility extends UIAbility implements ExclusiveAppComponent{ +export default class EntryAbility extends UIAbility implements ExclusiveAppComponent{ detachFromFlutterEngine(): void { // throw new Error('Method not implemented.'); } - getAppComponent(): UIAbility { - return this; + getAppComponent(): common.UIAbilityContext { + return this.context; } static app?: EntryAbility; onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - FlutterManager.getInstance().pushUIAbility(this); EntryAbility.app = this; } onDestroy(): void | Promise { - FlutterManager.getInstance().popUIAbility(this); EntryAbility.app = undefined; } onWindowStageCreate(windowStage: window.WindowStage): void { - FlutterManager.getInstance().pushWindowStage(this, windowStage); windowStage.loadContent('pages/MainPage'); } onWindowStageDestroy() { - FlutterManager.getInstance().popWindowStage(this); } } ``` diff --git "a/ohos/docs/04_development/\345\246\202\344\275\225\344\275\277\347\224\250 FlutterEntry.md" "b/ohos/docs/04_development/\345\246\202\344\275\225\344\275\277\347\224\250 FlutterEntry.md" index d1dcaf04..c9e89e06 100644 --- "a/ohos/docs/04_development/\345\246\202\344\275\225\344\275\277\347\224\250 FlutterEntry.md" +++ "b/ohos/docs/04_development/\345\246\202\344\275\225\344\275\277\347\224\250 FlutterEntry.md" @@ -3,32 +3,28 @@ ## 1. EntryAbility 可以继承 UIAbility ```ts -export default class EntryAbility extends UIAbility implements ExclusiveAppComponent { +export default class EntryAbility extends UIAbility implements ExclusiveAppComponent { detachFromFlutterEngine(): void { // throw new Error('Method not implemented.'); } - getAppComponent(): UIAbility { - return this; + getAppComponent(): common.UIAbilityContext { + return this.context; } onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - FlutterManager.getInstance().pushUIAbility(this); } onDestroy(): void | Promise { - FlutterManager.getInstance().popUIAbility(this); } onWindowStageCreate(windowStage: window.WindowStage): void { windowStage.getMainWindowSync().setWindowLayoutFullScreen(true); - FlutterManager.getInstance().pushWindowStage(this, windowStage); windowStage.loadContent('pages/Index'); } onWindowStageDestroy() { - FlutterManager.getInstance().popWindowStage(this); } } ``` diff --git a/ohos/flutter_page_sample2/ohos/entry/src/main/ets/entryability/BatteryPlugin.ets b/ohos/flutter_page_sample2/ohos/entry/src/main/ets/entryability/BatteryPlugin.ets index adb31605..3fcda5f2 100644 --- a/ohos/flutter_page_sample2/ohos/entry/src/main/ets/entryability/BatteryPlugin.ets +++ b/ohos/flutter_page_sample2/ohos/entry/src/main/ets/entryability/BatteryPlugin.ets @@ -17,7 +17,6 @@ import { Any, BasicMessageChannel, EventChannel, - FlutterManager, FlutterPlugin, Log, MethodCall, diff --git a/ohos/flutter_page_sample2/ohos/entry/src/main/ets/entryability/EntryAbility.ets b/ohos/flutter_page_sample2/ohos/entry/src/main/ets/entryability/EntryAbility.ets index b63531a3..e8d95c1b 100644 --- a/ohos/flutter_page_sample2/ohos/entry/src/main/ets/entryability/EntryAbility.ets +++ b/ohos/flutter_page_sample2/ohos/entry/src/main/ets/entryability/EntryAbility.ets @@ -12,38 +12,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import { ExclusiveAppComponent, FlutterManager } from '@ohos/flutter_ohos'; +import { AbilityConstant, Want, common } from '@kit.AbilityKit'; +import { ExclusiveAppComponent } from '@ohos/flutter_ohos'; import UIAbility from '@ohos.app.ability.UIAbility'; -import AbilityConstant from '@ohos.app.ability.AbilityConstant'; -import Want from '@ohos.app.ability.Want'; import window from '@ohos.window'; -export default class EntryAbility extends UIAbility implements ExclusiveAppComponent { +export default class EntryAbility extends UIAbility implements ExclusiveAppComponent { detachFromFlutterEngine(): void { // throw new Error('Method not implemented.'); } - getAppComponent(): UIAbility { - return this; + getAppComponent(): common.UIAbilityContext { + return this.context; } onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - FlutterManager.getInstance().pushUIAbility(this); } onDestroy(): void | Promise { - FlutterManager.getInstance().popUIAbility(this); } onWindowStageCreate(windowStage: window.WindowStage): void { windowStage.getMainWindowSync().setWindowLayoutFullScreen(true); - FlutterManager.getInstance().pushWindowStage(this, windowStage); windowStage.loadContent('pages/Index'); } onWindowStageDestroy() { - FlutterManager.getInstance().popWindowStage(this); } } diff --git a/ohos/flutter_page_sample2/ohos/entry/src/main/ets/pages/Index1.ets b/ohos/flutter_page_sample2/ohos/entry/src/main/ets/pages/Index1.ets index 6de01f48..0bc6c3ea 100644 --- a/ohos/flutter_page_sample2/ohos/entry/src/main/ets/pages/Index1.ets +++ b/ohos/flutter_page_sample2/ohos/entry/src/main/ets/pages/Index1.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +import { common } from '@kit.AbilityKit'; import { FlutterEntry, FlutterPage, FlutterView, Log } from '@ohos/flutter_ohos'; import router from '@ohos.router'; import MyFlutterEntry from '../entryability/MyFlutterEntry'; @@ -27,7 +27,7 @@ struct Index1 { aboutToAppear() { Log.d("Flutter", "Index aboutToAppear==="); - this.flutterEntry = new MyFlutterEntry(getContext(this)) + this.flutterEntry = new MyFlutterEntry(getContext(this) as common.UIAbilityContext) this.flutterEntry.aboutToAppear() this.flutterView = this.flutterEntry.getFlutterView() } diff --git a/ohos/flutter_page_sample2/ohos/entry/src/main/ets/pages/Index2.ets b/ohos/flutter_page_sample2/ohos/entry/src/main/ets/pages/Index2.ets index dcf82cb6..90897945 100644 --- a/ohos/flutter_page_sample2/ohos/entry/src/main/ets/pages/Index2.ets +++ b/ohos/flutter_page_sample2/ohos/entry/src/main/ets/pages/Index2.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +import { common } from '@kit.AbilityKit'; import { FlutterEntry, FlutterPage, FlutterPlugin, FlutterView, Log } from '@ohos/flutter_ohos'; import router from '@ohos.router'; import BatteryPlugin from '../entryability/BatteryPlugin'; @@ -29,7 +29,7 @@ struct Index2 { aboutToAppear() { Log.d("Flutter", "Index aboutToAppear==="); - this.flutterEntry = new MyFlutterEntry(getContext(this), router.getParams() as Record) + this.flutterEntry = new MyFlutterEntry(getContext(this) as common.UIAbilityContext, router.getParams() as Record) this.flutterEntry.aboutToAppear() this.flutterView = this.flutterEntry.getFlutterView() this.flutterView.addFirstFrameListener(this) -- Gitee