mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-16 12:11:39 +08:00
update RNOH SDK dependence from local to remote (#473)
* fix harmony more than 2M issue * fix mtpush-react-native conflics * update harmony remote dependency flow * udpate * udpate * udpate * udpate * udpate * update * uddate * udpapte
This commit is contained in:
@@ -1,25 +1,11 @@
|
||||
## 运行harmony_use_pushy项目步骤
|
||||
|
||||
### 1.将项目克隆到本地后在项目根目录创建libs文件夹。
|
||||
|
||||
### 2.然后将[`rnoh`](https://github.com/bozaigao/rnoh)克隆到libs文件夹中。
|
||||
|
||||
说明:rnoh项目基于react-native 0.72.5版本适配,如果使用最新的RN版本可能会报错,项目适配RN新版本请关注[`gitee仓库`](https://gitee.com/openharmony-sig/ohos_react_native/tree/0.72.5-ohos-5.0-release/tester/harmony/react_native_openharmony/src/main)
|
||||
|
||||
### 3.进入rnoh项目执行下面命令对rnoh项目依赖的C++库进行初始化;
|
||||
```
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
### 4. 确保在react-native-update根目录已经执行过yarn submodule命令。
|
||||
说明:这个命令会在harmony/src/main/cpp目录生成HDiffPatch和lzma的C++模块依赖。
|
||||
|
||||
### 5. 在项目根目录执行下面命令安装第三方依赖。
|
||||
### 1. 在项目根目录执行下面命令安装第三方依赖。
|
||||
```
|
||||
yarn install
|
||||
```
|
||||
|
||||
### 6. 在项目根目录执行下面命令生成bundle包文件。
|
||||
### 2. 在项目根目录执行下面命令生成bundle包文件。
|
||||
```
|
||||
yarn build
|
||||
```
|
||||
@@ -27,8 +13,8 @@ yarn build
|
||||
|
||||
**注意⚠️**:在使用pushy bundle --platform harmony命令进行打包的默认bundle包名是Hbundle.harmony.js,不要随意修改包名,因为diff是匹配该包名进行生成的。
|
||||
|
||||
### 7. 使用DevEco Studio IDE打开harmony目录然后执行sync运行项目
|
||||
### 3. 使用DevEco Studio IDE打开harmony目录然后执行sync运行项目
|
||||

|
||||
|
||||
### 8 运行效果图
|
||||
### 4 运行效果图
|
||||

|
@@ -37,10 +37,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'rnoh',
|
||||
srcPath: '../libs/rnoh',
|
||||
},
|
||||
{
|
||||
name: 'pushy',
|
||||
srcPath: '../node_modules/react-native-update/harmony',
|
||||
|
@@ -41,4 +41,4 @@ export function generatePushyBuildTime(str?: string) {
|
||||
export default {
|
||||
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
||||
plugins:[generatePushyBuildTime()] /* Custom plugin to extend the functionality of Hvigor. */
|
||||
}
|
||||
}
|
@@ -5,24 +5,25 @@
|
||||
"lockfileVersion": 3,
|
||||
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
||||
"specifiers": {
|
||||
"pushy@../../node_modules/react-native-update/harmony": "pushy@../../node_modules/react-native-update/harmony",
|
||||
"rnoh@../../libs/rnoh": "rnoh@../../libs/rnoh"
|
||||
"@rnoh/react-native-openharmony@0.72.38": "@rnoh/react-native-openharmony@0.72.38",
|
||||
"pushy@../../node_modules/react-native-update/harmony": "pushy@../../node_modules/react-native-update/harmony"
|
||||
},
|
||||
"packages": {
|
||||
"@rnoh/react-native-openharmony@0.72.38": {
|
||||
"name": "@rnoh/react-native-openharmony",
|
||||
"version": "0.72.38",
|
||||
"integrity": "sha512-br5SIrbB0OarSLirenleE7eTOX1lNccMJ7nb/G7qWTyJ7kW4DalmTXVKYpoT2qaOLls1uEE7McD1OjbZZM9jug==",
|
||||
"resolved": "https://ohpm.openharmony.cn/ohpm/@rnoh/react-native-openharmony/-/react-native-openharmony-0.72.38.har",
|
||||
"registryType": "ohpm"
|
||||
},
|
||||
"pushy@../../node_modules/react-native-update/harmony": {
|
||||
"name": "pushy",
|
||||
"version": "3.1.0-0.0.7",
|
||||
"resolved": "../../node_modules/react-native-update/harmony",
|
||||
"registryType": "local",
|
||||
"dependencies": {
|
||||
"rnoh": "file:../../../libs/rnoh"
|
||||
"@rnoh/react-native-openharmony": "^0.72.38"
|
||||
}
|
||||
},
|
||||
"rnoh@../../libs/rnoh": {
|
||||
"name": "rnoh",
|
||||
"version": "0.72.12",
|
||||
"resolved": "../../libs/rnoh",
|
||||
"registryType": "local"
|
||||
}
|
||||
}
|
||||
}
|
@@ -6,7 +6,7 @@
|
||||
"author": "",
|
||||
"license": "",
|
||||
"dependencies": {
|
||||
"rnoh": "file:../../libs/rnoh",
|
||||
"@rnoh/react-native-openharmony": "0.72.38",
|
||||
"pushy": "file:../../node_modules/react-native-update/harmony"
|
||||
}
|
||||
}
|
||||
|
@@ -2,12 +2,23 @@ cmake_minimum_required(VERSION 3.16)
|
||||
project(rnapp)
|
||||
set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
|
||||
set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../libs/rnoh/src/main/cpp")
|
||||
set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
|
||||
set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp")
|
||||
set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
|
||||
add_subdirectory("${OH_MODULES}/pushy/src/main/cpp" ./pushy)
|
||||
set(LOG_VERBOSITY_LEVEL 1)
|
||||
set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
|
||||
set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
|
||||
set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
|
||||
set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
|
||||
add_compile_definitions(WITH_HITRACE_SYSTRACE)
|
||||
|
||||
add_subdirectory("${OH_MODULES}/pushy/src/main/cpp" ./pushy)
|
||||
add_subdirectory("${RNOH_CPP_DIR}" ./rn)
|
||||
|
||||
file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1
|
||||
|
||||
add_library(rnoh_app SHARED
|
||||
${GENERATED_CPP_FILES}
|
||||
"./PackageProvider.cpp"
|
||||
"${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
|
||||
)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import type {RNPackageContext, RNPackage} from 'rnoh/ts';
|
||||
import type {RNPackageContext, RNPackage} from '@rnoh/react-native-openharmony/ts';
|
||||
import {PushyPackage} from 'pushy/ts';
|
||||
|
||||
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import {RNAbility} from 'rnoh/ts';
|
||||
import {RNAbility} from '@rnoh/react-native-openharmony';
|
||||
|
||||
export default class EntryAbility extends RNAbility {
|
||||
getPagePath() {
|
||||
|
@@ -1,26 +1,32 @@
|
||||
import { FileJSBundleProvider } from 'pushy/src/main/ets/FileJSBundleProvider';
|
||||
import { ComponentBuilderContext, JSBundleProvider, RNOHLogger } from 'rnoh';
|
||||
import { ComponentBuilderContext, RNOHCoreContext,RNAbility } from '@rnoh/react-native-openharmony';
|
||||
import {
|
||||
RNApp,
|
||||
RNAbility,
|
||||
AnyJSBundleProvider,
|
||||
ResourceJSBundleProvider,
|
||||
TraceJSBundleProviderDecorator,
|
||||
} from 'rnoh'
|
||||
} from '@rnoh/react-native-openharmony'
|
||||
import { createRNPackages } from '../RNPackagesFactory'
|
||||
import preferences from '@ohos.data.preferences';
|
||||
|
||||
const arkTsComponentNames: Array<string> = [];
|
||||
|
||||
@Builder
|
||||
export function CustomComponentBuilder(ctx: ComponentBuilderContext) {
|
||||
|
||||
export function buildCustomRNComponent(ctx: ComponentBuilderContext) {
|
||||
// There seems to be a problem with the placement of ArkTS components in mixed mode. Nested Stack temporarily avoided.
|
||||
Stack() {
|
||||
}
|
||||
.position({ x: 0, y: 0 })
|
||||
}
|
||||
|
||||
|
||||
const wrappedCustomRNComponentBuilder = wrapBuilder(buildCustomRNComponent)
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
@StorageLink('RNAbility') private rnAbility: RNAbility | undefined = undefined
|
||||
@StorageLink('RNOHCoreContext') private rnohCoreContext: RNOHCoreContext | undefined = undefined
|
||||
@State shouldShow: boolean = false
|
||||
@State message: string = 'Hello World';
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.shouldShow = true
|
||||
@@ -30,28 +36,37 @@ struct Index {
|
||||
// NOTE: this is required since `Ability`'s `onBackPressed` function always
|
||||
// terminates or puts the app in the background, but we want Ark to ignore it completely
|
||||
// when handled by RN
|
||||
return this.rnAbility?.onBackPress();
|
||||
this.rnohCoreContext!.dispatchBackPress()
|
||||
|
||||
// this.preferences = preferences.getPreferencesSync(this.context, {name:'update'});
|
||||
return true
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
if (this.rnAbility && this.shouldShow) {
|
||||
if (this.rnohCoreContext && this.shouldShow) {
|
||||
RNApp({
|
||||
rnInstanceConfig: { createRNPackages },
|
||||
rnInstanceConfig: {
|
||||
createRNPackages,
|
||||
enableNDKTextMeasuring: true,
|
||||
enableBackgroundExecutor: false,
|
||||
enableCAPIArchitecture: true,
|
||||
arkTsComponentNames: arkTsComponentNames,
|
||||
},
|
||||
initialProps: { "foo": "bar" } as Record<string, string>,
|
||||
appKey: "harmony_use_pushy",
|
||||
buildCustomComponent: CustomComponentBuilder,
|
||||
wrappedCustomRNComponentBuilder: wrappedCustomRNComponentBuilder,
|
||||
onSetUp: (rnInstance) => {
|
||||
rnInstance.enableFeatureFlag("ENABLE_RN_INSTANCE_CLEAN_UP")
|
||||
},
|
||||
jsBundleProvider: new TraceJSBundleProviderDecorator(
|
||||
new AnyJSBundleProvider([
|
||||
// MetroJSBundleProvider.fromServerIp('127.0.0.1'),
|
||||
// new ResourceJSBundleProvider(this.rnAbility.context.resourceManager, 'hermes_bundle.hbc'),
|
||||
new FileJSBundleProvider(this.rnAbility.context),
|
||||
new ResourceJSBundleProvider(this.rnAbility.context.resourceManager, 'bundle.harmony.js')
|
||||
// new ResourceJSBundleProvider(rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),
|
||||
new FileJSBundleProvider(this.rnohCoreContext.uiAbilityContext),
|
||||
new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'bundle.harmony.js')
|
||||
]),
|
||||
this.rnAbility.getLogger()),
|
||||
this.rnohCoreContext.logger),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"pushy_build_time": "2025-02-14T09:43:25.648Z",
|
||||
"versionName": "1.0.0"
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"ios": {
|
||||
"appId": 24794,
|
||||
"appKey": "SqShg4Klnj2hG6LAFMW2PdcgSSuniz0T"
|
||||
},
|
||||
"android": {
|
||||
"appId": 27509,
|
||||
"appKey": "aQz3Uc2pA7gt_prDaQ4rbWRY"
|
||||
},
|
||||
"harmony": {
|
||||
"appId": 29140,
|
||||
"appKey": "JLklGflGIRbY-cMebjQwm1J1"
|
||||
}
|
||||
}
|
@@ -13,5 +13,8 @@
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"strict": false
|
||||
}
|
||||
},
|
||||
"overrides": {
|
||||
"@rnoh/react-native-openharmony": "0.72.38"
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
"appKey": "aQz3Uc2pA7gt_prDaQ4rbWRY"
|
||||
},
|
||||
"harmony": {
|
||||
"appId": 29040,
|
||||
"appKey": "gdzeAqAFE5Jew15c5Df8EKU9"
|
||||
"appId": 29140,
|
||||
"appKey": "JLklGflGIRbY-cMebjQwm1J1"
|
||||
}
|
||||
}
|
||||
|
@@ -6003,7 +6003,7 @@ react-is@^17.0.1:
|
||||
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
|
||||
|
||||
"react-native-update@file:../..":
|
||||
version "10.15.1"
|
||||
version "10.19.6"
|
||||
dependencies:
|
||||
nanoid "^3.3.3"
|
||||
react-native-url-polyfill "^2.0.0"
|
||||
|
0
harmony/README.md
Normal file
0
harmony/README.md
Normal file
@@ -5,14 +5,15 @@
|
||||
"lockfileVersion": 3,
|
||||
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
||||
"specifiers": {
|
||||
"rnoh@../../../libs/rnoh": "rnoh@../../../libs/rnoh"
|
||||
"@rnoh/react-native-openharmony@0.72.38": "@rnoh/react-native-openharmony@0.72.38"
|
||||
},
|
||||
"packages": {
|
||||
"rnoh@../../../libs/rnoh": {
|
||||
"name": "rnoh",
|
||||
"version": "0.72.12",
|
||||
"resolved": "../../../libs/rnoh",
|
||||
"registryType": "local"
|
||||
"@rnoh/react-native-openharmony@0.72.38": {
|
||||
"name": "@rnoh/react-native-openharmony",
|
||||
"version": "0.72.38",
|
||||
"integrity": "sha512-br5SIrbB0OarSLirenleE7eTOX1lNccMJ7nb/G7qWTyJ7kW4DalmTXVKYpoT2qaOLls1uEE7McD1OjbZZM9jug==",
|
||||
"resolved": "https://ohpm.openharmony.cn/ohpm/@rnoh/react-native-openharmony/-/react-native-openharmony-0.72.38.har",
|
||||
"registryType": "ohpm"
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,6 +7,6 @@
|
||||
"main": "index.ets",
|
||||
"version": "3.1.0-0.0.7",
|
||||
"dependencies": {
|
||||
"rnoh": "file:../../../libs/rnoh"
|
||||
"@rnoh/react-native-openharmony":"^0.72.38"
|
||||
}
|
||||
}
|
||||
|
1
harmony/oh_modules/@rnoh/react-native-openharmony
Symbolic link
1
harmony/oh_modules/@rnoh/react-native-openharmony
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../../harmony/oh_modules/.ohpm/@rnoh+react-native-openharmony@0.72.38/oh_modules/@rnoh/react-native-openharmony
|
@@ -491,4 +491,4 @@ export class DownloadTask {
|
||||
params.listener?.onDownloadFailed(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
import { HotReloadConfig, JSBundleProvider, JSBundleProviderError, JSPackagerClientConfig } from 'rnoh';
|
||||
import { HotReloadConfig, JSBundleProvider, JSBundleProviderError, JSPackagerClientConfig } from '@rnoh/react-native-openharmony';
|
||||
import fileIo from '@ohos.file.fs';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import { UpdateContext } from './UpdateContext';
|
||||
@@ -40,20 +40,15 @@ export class FileJSBundleProvider extends JSBundleProvider {
|
||||
}
|
||||
throw new Error('Update bundle not found');
|
||||
} catch (error) {
|
||||
throw new JSBundleProviderError(`Couldn't load JSBundle from ${this.filePath}`, error)
|
||||
throw new JSBundleProviderError({
|
||||
whatHappened: `Couldn't load JSBundle from ${this.filePath}`,
|
||||
extraData: error,
|
||||
howCanItBeFixed: [`Check if a bundle exists at "${this.filePath}" on your device.`]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
getAppKeys(): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
getHotReloadConfig(): HotReloadConfig | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
getJSPackagerClientConfig(): JSPackagerClientConfig | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
import { RNPackage, TurboModulesFactory } from 'rnoh/ts';
|
||||
import type { TurboModule, TurboModuleContext } from 'rnoh/ts';
|
||||
import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
|
||||
import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
||||
import { PushyTurboModule } from './PushyTurboModule';
|
||||
|
||||
class PushyTurboModulesFactory extends TurboModulesFactory {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { TurboModule, TurboModuleContext } from 'rnoh/ts';
|
||||
import { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import dataPreferences from '@ohos.data.preferences';
|
||||
import { bundleManager } from '@kit.AbilityKit';
|
||||
|
@@ -26,49 +26,49 @@ export class UpdateContext {
|
||||
this.initPreferences();
|
||||
}
|
||||
|
||||
private async initPreferences() {
|
||||
private initPreferences() {
|
||||
try {
|
||||
this.preferences = await preferences.getPreferences(this.context, 'update');
|
||||
const packageVersion = await this.getPackageVersion();
|
||||
const storedVersion = await this.preferences.get('packageVersion', '');
|
||||
this.preferences = preferences.getPreferencesSync(this.context, {name:'update'});
|
||||
const packageVersion = this.getPackageVersion();
|
||||
const storedVersion = this.preferences.getSync('packageVersion', '');
|
||||
if (packageVersion !== storedVersion) {
|
||||
await this.preferences.clear();
|
||||
await this.preferences.put('packageVersion', packageVersion);
|
||||
await this.preferences.flush();
|
||||
this.cleanUp();
|
||||
this.preferences.clear();
|
||||
this.preferences.putSync('packageVersion', packageVersion);
|
||||
this.preferences.flush();
|
||||
this.cleanUp();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to init preferences:', e);
|
||||
}
|
||||
}
|
||||
|
||||
public async setKv(key: string, value: string): Promise<void> {
|
||||
await this.preferences.put(key, value);
|
||||
await this.preferences.flush();
|
||||
public setKv(key: string, value: string): void {
|
||||
this.preferences.putSync(key, value);
|
||||
this.preferences.flush();
|
||||
}
|
||||
|
||||
public async getKv(key: string): Promise<string> {
|
||||
return await this.preferences.get(key, '') as string;
|
||||
public getKv(key: string): string {
|
||||
return this.preferences.getSync(key, '') as string;
|
||||
}
|
||||
|
||||
public async isFirstTime(): Promise<boolean> {
|
||||
return await this.preferences.get('firstTime', false) as boolean;
|
||||
public isFirstTime(): boolean {
|
||||
return this.preferences.getSync('firstTime', false) as boolean;
|
||||
}
|
||||
|
||||
public async rolledBackVersion(): Promise<string> {
|
||||
return await this.preferences.get('rolledBackVersion', '') as string;
|
||||
public rolledBackVersion(): string {
|
||||
return this.preferences.getSync('rolledBackVersion', '') as string;
|
||||
}
|
||||
|
||||
public async markSuccess(): Promise<void> {
|
||||
await this.preferences.put('firstTimeOk', true);
|
||||
const lastVersion = await this.preferences.get('lastVersion', '') as string;
|
||||
const curVersion = await this.preferences.get('currentVersion', '') as string;
|
||||
public markSuccess(): void {
|
||||
this.preferences.putSync('firstTimeOk', true);
|
||||
const lastVersion = this.preferences.getSync('lastVersion', '') as string;
|
||||
const curVersion = this.preferences.getSync('currentVersion', '') as string;
|
||||
|
||||
if (lastVersion && lastVersion !== curVersion) {
|
||||
await this.preferences.delete('lastVersion');
|
||||
await this.preferences.delete(`hash_${lastVersion}`);
|
||||
this.preferences.deleteSync('lastVersion');
|
||||
this.preferences.deleteSync(`hash_${lastVersion}`);
|
||||
}
|
||||
await this.preferences.flush();
|
||||
this.preferences.flush();
|
||||
this.cleanUp();
|
||||
}
|
||||
|
||||
@@ -143,23 +143,23 @@ export class UpdateContext {
|
||||
}
|
||||
}
|
||||
|
||||
public async switchVersion(hash: string): Promise<void> {
|
||||
public switchVersion(hash: string): void {
|
||||
try {
|
||||
const bundlePath = `${this.rootDir}/${hash}/bundle.harmony.js`;
|
||||
if (!fileIo.accessSync(bundlePath)) {
|
||||
throw new Error(`Bundle version ${hash} not found.`);
|
||||
}
|
||||
|
||||
const lastVersion = await this.getKv('currentVersion');
|
||||
await this.setKv('currentVersion', hash);
|
||||
const lastVersion = this.getKv('currentVersion');
|
||||
this.setKv('currentVersion', hash);
|
||||
|
||||
if (lastVersion && lastVersion !== hash) {
|
||||
await this.setKv('lastVersion', lastVersion);
|
||||
this.setKv('lastVersion', lastVersion);
|
||||
}
|
||||
|
||||
await this.setKv('firstTime', 'true');
|
||||
await this.setKv('firstTimeOk', 'false');
|
||||
await this.setKv('rolledBackVersion', null);
|
||||
this.setKv('firstTime', 'true');
|
||||
this.setKv('firstTimeOk', 'false');
|
||||
this.setKv('rolledBackVersion', null);
|
||||
} catch (e) {
|
||||
console.error('Failed to switch version:', e);
|
||||
}
|
||||
@@ -176,7 +176,7 @@ export class UpdateContext {
|
||||
return defaultAssetsUrl;
|
||||
}
|
||||
if (!this.isFirstTime()) {
|
||||
if (!this.preferences.get('firstTimeOk', true)) {
|
||||
if (!this.preferences.getSync('firstTimeOk', true)) {
|
||||
return this.rollBack();
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,5 @@
|
||||
import { TurboModuleContext } from 'rnoh/ts';
|
||||
import dataPreferences from '@ohos.data.preferences';
|
||||
import bundleManager from '@ohos.bundle.bundleManager';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import { UpdateContext } from './UpdateContext';
|
||||
import { DownloadTaskParams } from './DownloadTaskParams';
|
||||
import logger from './Logger';
|
||||
|
Reference in New Issue
Block a user