diff --git a/AccountKit/.gitignore b/AccountKit/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/AccountKit/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/AccountKit/AppScope/app.json5 b/AccountKit/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..03d7d87b5b9e37b6c40c4243ab91ee266c6b10bb --- /dev/null +++ b/AccountKit/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.accountkit", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/AccountKit/AppScope/resources/base/element/string.json b/AccountKit/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3f32c554f4c3626a213c7507188007677c7cb584 --- /dev/null +++ b/AccountKit/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AccountKit" + } + ] +} diff --git a/AccountKit/AppScope/resources/base/media/background.png b/AccountKit/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/AccountKit/AppScope/resources/base/media/background.png differ diff --git a/AccountKit/AppScope/resources/base/media/foreground.png b/AccountKit/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/AccountKit/AppScope/resources/base/media/foreground.png differ diff --git a/AccountKit/AppScope/resources/base/media/layered_image.json b/AccountKit/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/AccountKit/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/AccountKit/build-profile.json5 b/AccountKit/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7600bb7e2e85e29cc29ec245a6bea5c4d4845a88 --- /dev/null +++ b/AccountKit/build-profile.json5 @@ -0,0 +1,55 @@ +{ + "app": { + "signingConfigs": [ + { + "name": "default", + "type": "HarmonyOS", + "material": { + "certpath": "C:\\Users\\Administrator\\.ohos\\config\\default_AccountKit_s5w29Lv4UnmLLlIj0EXq7mWCghmY77uWxiiZoCjfApU=.cer", + "keyAlias": "debugKey", + "keyPassword": "0000001BFF68E5D1C209ACB668E1914CE5C2042CC0EB8C2F829682D3E1221F235E42CE155CF75CA7D53F78", + "profile": "C:\\Users\\Administrator\\.ohos\\config\\default_AccountKit_s5w29Lv4UnmLLlIj0EXq7mWCghmY77uWxiiZoCjfApU=.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "C:\\Users\\Administrator\\.ohos\\config\\default_AccountKit_s5w29Lv4UnmLLlIj0EXq7mWCghmY77uWxiiZoCjfApU=.p12", + "storePassword": "0000001B0EEEF99946CD87A5E9725581B2082F437E30DD7C4FF90773DDA36B0F3DD0F273CF850DA7DECF49" + } + } + ], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.4(16)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/AccountKit/code-linter.json5 b/AccountKit/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/AccountKit/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/AccountKit/entry/.gitignore b/AccountKit/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/AccountKit/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/AccountKit/entry/build-profile.json5 b/AccountKit/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/AccountKit/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/AccountKit/entry/hvigorfile.ts b/AccountKit/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/AccountKit/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/AccountKit/entry/obfuscation-rules.txt b/AccountKit/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/AccountKit/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/AccountKit/entry/oh-package.json5 b/AccountKit/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/AccountKit/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/AccountKit/entry/src/main/ets/entryability/EntryAbility.ets b/AccountKit/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..cdb78e0c45c745b39152339e2d55b1b79db4fb6a --- /dev/null +++ b/AccountKit/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant,ConfigurationConstant,UIAbility,Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want,launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN,'testTag','%{public}s','Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN,'testTag','%{public}s','Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN,'testTag','%{public}s','Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index',(err) => { + if (err.code) { + hilog.error(DOMAIN,'testTag','Failed to load the content. Cause: %{public}s',JSON.stringify(err)); + return; + } + hilog.info(DOMAIN,'testTag','Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN,'testTag','%{public}s','Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN,'testTag','%{public}s','Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN,'testTag','%{public}s','Ability onBackground'); + } +} \ No newline at end of file diff --git a/AccountKit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/AccountKit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..16518c63c152c5c8459c10ac47c6ee39377bf1d8 --- /dev/null +++ b/AccountKit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility,BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN,'testTag','onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN,'testTag','onRestore ok %{public}s',JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/AccountKit/entry/src/main/ets/pages/IdToken.ets b/AccountKit/entry/src/main/ets/pages/IdToken.ets new file mode 100644 index 0000000000000000000000000000000000000000..16e7a320e12d4bf3d12e1e602236b7adaaa20b73 --- /dev/null +++ b/AccountKit/entry/src/main/ets/pages/IdToken.ets @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:ID Token的使用场景与使用方法 + */ + +// [Start IdToken3] +import { buffer } from '@kit.ArkTS'; +import { cryptoFramework } from '@kit.CryptoArchitectureKit'; +import { http } from '@kit.NetworkKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +class IdToken { + decodeBase64(data: string): string { + return buffer.from(data,'base64').toString('utf8'); + } + + // Resolve ID Token and validate it + decodeIdToken(idToken: string): void { + const parts = idToken.split('.'); + if (parts.length !== 3) { + return; + } + const idTokenObj: Record = {}; + // ID Token header + idTokenObj['header'] = JSON.parse(this.decodeBase64(parts[0])); + // ID Token Load + idTokenObj['payload'] = JSON.parse(this.decodeBase64(parts[1])); + // ID Token Signature + idTokenObj['signature'] = parts[2]; + const header: Record = idTokenObj['header'] as Record; + // Parse nonce and other data from the load + const payLoad: Record = idTokenObj['payload'] as Record; + const nonce: string = payLoad['nonce']; + // Application Client ID, please replace before use + const CLIENT_ID: string = '<应用Client ID>'; + const ID_TOKEN_ISSUE: string = 'https://accounts.huawei.com'; + const iss: string = payLoad['iss']; + const aud: string = payLoad['aud']; + if (iss !== ID_TOKEN_ISSUE) { + // Verification failed, developers handle failure scenarios + hilog.error(0x0000,'testTag','Failed to check iss'); + return; + } + if (aud !== CLIENT_ID) { + // Verification failed, developers handle failure scenarios + hilog.error(0x0000,'testTag','Failed to check aud'); + return; + } + // verify signature + this.checkSignature(idToken,header['kid'],header['alg']); + } + + private stringToUint8Array(str: string): Uint8Array { + const arr: number[] = []; + for (let i = 0,j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + const tmpUint8Array: Uint8Array = new Uint8Array(arr); + return tmpUint8Array; + } + + // Verification method + private checkSignature(idToken: string,kid: string,alg: string) { + if (!idToken) { + return; + } + const parts = idToken.split('.'); + if (parts.length !== 3) { + return; + } + const url = 'https://oauth-login.cloud.huawei.com/oauth2/v3/certs'; + // To create an HTTP request, the application needs to apply for "ohos. permission. INTERNET" network permission + // in the module.json5 file before the request can be sent successfully + const httpRequest = http.createHttp(); + httpRequest.request(url,(err,data) => { + if (err) { + hilog.error(0x0000,'testTag',`Failed to httpRequest. Code: ${err.code}, message: ${err.message}`); + httpRequest.destroy(); + return; + } + let nStr = ''; + let eStr = ''; + const keys: object[] = JSON.parse(data.result as string)["keys"]; + for (let item of keys) { + if (kid === item['kid']) { + nStr = item['n']; + eStr = item['e']; + break; + } + } + const nBigInt = '0x' + buffer.from(nStr,"base64url").toString('hex'); + const eBigInt = '0x' + buffer.from(eStr,"base64url").toString('hex'); + const dsaCommonSpec: cryptoFramework.RSACommonParamsSpec = { + algName: "RSA", + specType: cryptoFramework.AsyKeySpecType.COMMON_PARAMS_SPEC, + n: BigInt(nBigInt), + } + const rsaKeyPairSpec: cryptoFramework.RSAPubKeySpec = { + algName: "RSA", + specType: cryptoFramework.AsyKeySpecType.PUBLIC_KEY_SPEC, + params: dsaCommonSpec, + pk: BigInt(eBigInt), + } + const asyKeyGeneratorBySpec = cryptoFramework.createAsyKeyGeneratorBySpec(rsaKeyPairSpec); + asyKeyGeneratorBySpec.generatePubKey(async (error,publicKey) => { + if (error) { + return; + } + if (publicKey === null) { + return; + } + const idTokenSign = parts[2]; + const idTokenSignArr: cryptoFramework.DataBlob = + { data: new Uint8Array(buffer.from(idTokenSign,"base64url").buffer) }; + const idToken = parts[0] + '.' + parts[1]; + const idTokenArr: cryptoFramework.DataBlob = { data: this.stringToUint8Array(idToken) }; + const verifier = alg === 'PS256' ? cryptoFramework.createVerify("RSA2048|PSS|SHA256|MGF1_SHA256") + : cryptoFramework.createVerify("RSA2048|PKCS1|SHA256"); + verifier.init(publicKey,(initErr,result) => { + verifier.verify(idTokenArr,idTokenSignArr,(verifyErr,data) => { + // Print the verification result. If the result is true, the verification is passed + hilog.info(0x0000,'testTag','verify result is: %{public}s',data); + }); + }); + }) + httpRequest.destroy(); + }); + } +} +// [End IdToken3] diff --git a/AccountKit/entry/src/main/ets/pages/IdToken1.txt b/AccountKit/entry/src/main/ets/pages/IdToken1.txt new file mode 100644 index 0000000000000000000000000000000000000000..4ce0e42151925638bb30e591256248c1dd218890 --- /dev/null +++ b/AccountKit/entry/src/main/ets/pages/IdToken1.txt @@ -0,0 +1,32 @@ +/* +* FAQ:ID Token的使用场景与使用方法 + */ +// [Start IdToken1] + + + com.alibaba.fastjson2 + fastjson2 + 2.0.51 + + + org.bouncycastle + bcprov-jdk18on + 1.74 + + + org.apache.httpcomponents + httpclient + 4.5 + + + com.auth0 + jwks-rsa + 0.8.2 + + + com.auth0 + java-jwt + 3.8.1 + + +// [End IdToken1] \ No newline at end of file diff --git a/AccountKit/entry/src/main/ets/pages/IdToken2.java b/AccountKit/entry/src/main/ets/pages/IdToken2.java new file mode 100644 index 0000000000000000000000000000000000000000..cecd590c03421a2bbdde42c7b76f4bb00faab537 --- /dev/null +++ b/AccountKit/entry/src/main/ets/pages/IdToken2.java @@ -0,0 +1,200 @@ +/* +* FAQ:ID Token的使用场景与使用方法 + */ +// [Start IdToken2] +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.auth0.jwk.InvalidPublicKeyException; +import com.auth0.jwk.Jwk; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.exceptions.JWTDecodeException; +import com.auth0.jwt.exceptions.JWTVerificationException; +import com.auth0.jwt.exceptions.TokenExpiredException; +import com.auth0.jwt.interfaces.DecodedJWT; +import org.apache.commons.codec.binary.Base64; +import org.apache.http.HttpEntity; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import java.nio.charset.StandardCharsets; +import java.security.GeneralSecurityException; +import java.security.Security; +import java.security.Signature; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +public class IDTokenParser { + // 请替换为您的Client ID + private final static String CLIENT_ID = "123456"; + private final static int MAX_PUBLIC_KEY_SIZE = 4; + // 缓存jwt公钥信息 + private final Map keyId2PublicKey = new HashMap<>(); + /** + * JWK JSON Web Key端点,开发者可以从该端点获取最近两天的JWK + * 公钥在24小时内更新。确保以下ID Token在24小时内生成 + */ + private static final String CERT_URL = "https://oauth-login.cloud.huawei.com/oauth2/v3/certs"; + // ID Token的issuer + public static final String ID_TOKEN_ISSUE = "https://accounts.huawei.com"; + public static final String ALG_RS256 = "RS256"; + public final static String ALG_PS256 = "PS256"; + public static void main(String[] args) throws Exception { + // 由上述CLIENT_ID对应值生成的ID Token + String idToken = ""; + IDTokenParser idTokenParser = new IDTokenParser(); + JSONObject idTokenInfo = idTokenParser.verifyAndParse(idToken); + // 解析获取ID Token中的数据,例:解析获取iss + String iss = idTokenInfo.getString("iss"); + } + /** + * 验证并解析ID Token + * @param idToken idToken + * @return ID Token携带的信息 + * @throws Exception 异常 + */ + public JSONObject verifyAndParse(String idToken) throws Exception { + try { + DecodedJWT decoder = JWT.decode(idToken); + if (!decoder.getIssuer().equals(ID_TOKEN_ISSUE)) { + // issuer校验不通过,抛出异常(异常类型可自行选择) + throw new RuntimeException("issuer no match"); + } + if (decoder.getAudience().size() > 0) { + if (!decoder.getAudience().get(0).equals(CLIENT_ID)) { + // audience校验不通过,抛出异常(异常类型可自行选择) + throw new RuntimeException("audience no match"); + } + } + // 获取ID Token签名使用的算法 + String alg = decoder.getAlgorithm(); + if (ALG_RS256.equals(alg)) { + Algorithm algorithm = Algorithm.RSA256(getRSAPublicKeyByKid(decoder.getKeyId()), null); + JWTVerifier verifier = JWT.require(algorithm).build(); + JSONObject jsonObject = JSONObject.parseObject(new String(Base64.decodeBase64(decoder.getPayload()))); + // 验证签名 + verifier.verify(decoder); + jsonObject.put("alg", decoder.getAlgorithm()); + jsonObject.put("typ", decoder.getType()); + jsonObject.put("kid", decoder.getKeyId()); + return jsonObject; + } else if (ALG_PS256.equals(alg)) { + PS256Algorithm algorithm = new PS256Algorithm(getRSAPublicKeyByKid(decoder.getKeyId())); + boolean verifyResult = algorithm.verify(decoder.getHeader(), decoder.getPayload(), + decoder.getSignature()); + if (verifyResult) { + JSONObject jsonObject = JSONObject.parseObject( + new String(Base64.decodeBase64(decoder.getPayload()))); + jsonObject.put("alg", decoder.getAlgorithm()); + jsonObject.put("typ", decoder.getType()); + jsonObject.put("kid", decoder.getKeyId()); + return jsonObject; + } + } + return null; + } catch (JWTDecodeException e) { + // ID Token解析失败,此场景常见于ID Token格式不正确 + throw new RuntimeException("ID Token decode failed"); + } catch (TokenExpiredException e) { + // ID Token已过期 + throw new RuntimeException("ID Token expired"); + } + } + /** + * 通过kid获取公钥信息,请缓存公钥信息,示例中采用map方式进行缓存,开发者可选择其它合适的方式进行缓存 + * @param keyId keyId + * @return 公钥信息 + * @throws InvalidPublicKeyException 异常 + */ + private RSAPublicKey getRSAPublicKeyByKid(String keyId) throws InvalidPublicKeyException { + if (keyId2PublicKey.get(keyId) != null) { + return keyId2PublicKey.get(keyId); + } + JSONArray keys = getJwks(); + if (keys == null) { + return null; + } + if (keyId2PublicKey.size() > MAX_PUBLIC_KEY_SIZE) { + keyId2PublicKey.clear(); + } + for (int i = 0; i < keys.size(); i++) { + String kid = keys.getJSONObject(i).getString("kid"); + String alg = keys.getJSONObject(i).getString("alg"); + if (ALG_RS256.equals(alg) || ALG_PS256.equals(alg)) { + keyId2PublicKey.put(kid, getRsaPublicKeyByJwk(keys.getJSONObject(i))); + } + } + return keyId2PublicKey.get(keyId); + } + /** + * 从https://oauth-login.cloud.huawei.com/oauth2/v3/certs获取jwt公钥信息jwk + * 因为jwk每天都会更新,所以需要缓存jwk + * @return JSONObject 公钥信息数组 + */ + private static JSONArray getJwks() { + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpGet httpGet = new HttpGet(CERT_URL); + RequestConfig requestConfig = RequestConfig.custom() + .setConnectTimeout(5000) + .setConnectionRequestTimeout(5000) + .setSocketTimeout(5000) + .build(); + httpGet.setConfig(requestConfig); + try { + CloseableHttpResponse response = httpClient.execute(httpGet); + HttpEntity entity = response.getEntity(); + String result = EntityUtils.toString(entity); + return JSONObject.parseObject(result).getJSONArray("keys"); + } catch (Exception e) { + return null; + } finally { + if (null != httpClient) { + try { + httpClient.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + /** + * 通过jwk获取公钥信息 + * @return RSAPublicKey 公钥信息 + */ + private static RSAPublicKey getRsaPublicKeyByJwk(JSONObject jwkObject) throws InvalidPublicKeyException { + Map additionalAttributes = new HashMap<>(); + additionalAttributes.put("n", jwkObject.getString("n")); + additionalAttributes.put("e", jwkObject.getString("e")); + List operations = new ArrayList<>(); + Jwk jwk = new Jwk(jwkObject.getString("kid"), jwkObject.getString("kty"), jwkObject.getString("alg"), + jwkObject.getString("use"), operations, null, null, null, additionalAttributes); + return (RSAPublicKey) jwk.getPublicKey(); + } + static class PS256Algorithm { + private final RSAPublicKey publicKey; + public PS256Algorithm(RSAPublicKey publicKey) { + this.publicKey = publicKey; + } + public boolean verify(String header, String payload, String signature) throws JWTVerificationException { + byte[] contentBytes = (header + '.' + payload).getBytes(StandardCharsets.UTF_8); + byte[] signatureBytes = Base64.decodeBase64(signature); + try { + Security.addProvider(new BouncyCastleProvider()); + Signature sign = Signature.getInstance("SHA256WithRSA/PSS"); + sign.initVerify(publicKey); + sign.update(contentBytes); + return sign.verify(signatureBytes); + } catch (GeneralSecurityException e) { + throw new JWTVerificationException("JWT verify failed"); + } + } + } +} +// [End IdToken2] \ No newline at end of file diff --git a/AccountKit/entry/src/main/ets/pages/Index.ets b/AccountKit/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..def634d091282e99d7528089d11e872d823425fd --- /dev/null +++ b/AccountKit/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,23 @@ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__',align: VerticalAlign.Center }, + middle: { anchor: '__container__',align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/AccountKit/entry/src/main/module.json5 b/AccountKit/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a1cea8b6a4560cee7bda7a2db52f310c035ab6c8 --- /dev/null +++ b/AccountKit/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/AccountKit/entry/src/main/resources/base/element/color.json b/AccountKit/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/AccountKit/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/AccountKit/entry/src/main/resources/base/element/float.json b/AccountKit/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/AccountKit/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/AccountKit/entry/src/main/resources/base/element/string.json b/AccountKit/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/AccountKit/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/AccountKit/entry/src/main/resources/base/media/background.png b/AccountKit/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/AccountKit/entry/src/main/resources/base/media/background.png differ diff --git a/AccountKit/entry/src/main/resources/base/media/foreground.png b/AccountKit/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/AccountKit/entry/src/main/resources/base/media/foreground.png differ diff --git a/AccountKit/entry/src/main/resources/base/media/layered_image.json b/AccountKit/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/AccountKit/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/AccountKit/entry/src/main/resources/base/media/startIcon.png b/AccountKit/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/AccountKit/entry/src/main/resources/base/media/startIcon.png differ diff --git a/AccountKit/entry/src/main/resources/base/profile/backup_config.json b/AccountKit/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/AccountKit/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/AccountKit/entry/src/main/resources/base/profile/main_pages.json b/AccountKit/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/AccountKit/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/AccountKit/entry/src/main/resources/dark/element/color.json b/AccountKit/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/AccountKit/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/AccountKit/entry/src/mock/mock-config.json5 b/AccountKit/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/AccountKit/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/AccountKit/entry/src/ohosTest/ets/test/Ability.test.ets b/AccountKit/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/AccountKit/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/AccountKit/entry/src/ohosTest/ets/test/List.test.ets b/AccountKit/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/AccountKit/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/AccountKit/entry/src/ohosTest/module.json5 b/AccountKit/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55725a929993a8a18b3808d41ef037759440488b --- /dev/null +++ b/AccountKit/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/AccountKit/entry/src/test/List.test.ets b/AccountKit/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/AccountKit/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/AccountKit/entry/src/test/LocalUnit.test.ets b/AccountKit/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/AccountKit/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/AccountKit/hvigor/hvigor-config.json5 b/AccountKit/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a63d34ae5ce5833b3874807e2b8d472687c6c5bf --- /dev/null +++ b/AccountKit/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.4", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/AccountKit/hvigorfile.ts b/AccountKit/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/AccountKit/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/AccountKit/oh-package-lock.json5 b/AccountKit/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c6f99f5c73b06c5fdef7ec6f491b74b7befebe2e --- /dev/null +++ b/AccountKit/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/AccountKit/oh-package.json5 b/AccountKit/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..75e4e229db0f608fc3d9471c8819d0e52fb403c5 --- /dev/null +++ b/AccountKit/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.4", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/Arkgraphics2D/.gitignore b/Arkgraphics2D/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/Arkgraphics2D/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/Arkgraphics2D/AppScope/app.json5 b/Arkgraphics2D/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..75e573f4adf6ae3d2165e8355e49c03c59c229e1 --- /dev/null +++ b/Arkgraphics2D/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.arkgraphics2d", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/Arkgraphics2D/AppScope/resources/base/element/string.json b/Arkgraphics2D/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a7930360cb4b584e665b5492ddf4674c3ee8ac15 --- /dev/null +++ b/Arkgraphics2D/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Arkgraphics2D" + } + ] +} diff --git a/Arkgraphics2D/AppScope/resources/base/media/background.png b/Arkgraphics2D/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/Arkgraphics2D/AppScope/resources/base/media/background.png differ diff --git a/Arkgraphics2D/AppScope/resources/base/media/foreground.png b/Arkgraphics2D/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/Arkgraphics2D/AppScope/resources/base/media/foreground.png differ diff --git a/Arkgraphics2D/AppScope/resources/base/media/layered_image.json b/Arkgraphics2D/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/Arkgraphics2D/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/Arkgraphics2D/build-profile.json5 b/Arkgraphics2D/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..03ac3a3ae9dd397844173066e5d5ee21b49455a1 --- /dev/null +++ b/Arkgraphics2D/build-profile.json5 @@ -0,0 +1,41 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.4(16)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Arkgraphics2D/code-linter.json5 b/Arkgraphics2D/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/Arkgraphics2D/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/.gitignore b/Arkgraphics2D/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/Arkgraphics2D/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/Arkgraphics2D/entry/build-profile.json5 b/Arkgraphics2D/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/Arkgraphics2D/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/hvigorfile.ts b/Arkgraphics2D/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/Arkgraphics2D/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/Arkgraphics2D/entry/obfuscation-rules.txt b/Arkgraphics2D/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/Arkgraphics2D/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/Arkgraphics2D/entry/oh-package.json5 b/Arkgraphics2D/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/Arkgraphics2D/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/Arkgraphics2D/entry/src/main/ets/entryability/EntryAbility.ets b/Arkgraphics2D/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..cdb78e0c45c745b39152339e2d55b1b79db4fb6a --- /dev/null +++ b/Arkgraphics2D/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant,ConfigurationConstant,UIAbility,Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want,launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN,'testTag','%{public}s','Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN,'testTag','%{public}s','Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN,'testTag','%{public}s','Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index',(err) => { + if (err.code) { + hilog.error(DOMAIN,'testTag','Failed to load the content. Cause: %{public}s',JSON.stringify(err)); + return; + } + hilog.info(DOMAIN,'testTag','Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN,'testTag','%{public}s','Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN,'testTag','%{public}s','Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN,'testTag','%{public}s','Ability onBackground'); + } +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/Arkgraphics2D/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..16518c63c152c5c8459c10ac47c6ee39377bf1d8 --- /dev/null +++ b/Arkgraphics2D/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility,BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN,'testTag','onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN,'testTag','onRestore ok %{public}s',JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/main/ets/pages/CreateShare.cpp b/Arkgraphics2D/entry/src/main/ets/pages/CreateShare.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ed5d023d9ec89328b6c58d7855e35105d4e5bb95 --- /dev/null +++ b/Arkgraphics2D/entry/src/main/ets/pages/CreateShare.cpp @@ -0,0 +1,21 @@ +/* +* FAQ:EGL绘制是否支持多线程?如何在多线程的场景下同时操作一块buffer进行图形绘制 + */ +// [Start CreateShareEglContext] +void CreateShareEglContext() +{ + if (renderContext == nullptr) { // renderContext是主线程context + RS_LOGE("renderContext_ is nullptr"); + return; + } + eglShareContext = renderContext->CreateShareContext(); // 创建share context + if (eglShareContext == EGL_NO_CONTEXT) { + RS_LOGE("eglShareContext is EGL_NO_CONTEXT"); + return; + } + if (!eglMakeCurrent(renderContext->GetEGLDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, eglShareContext)) { + RS_LOGE("eglMakeCurrent failed"); + return; + } +} +// [End CreateShareEglContext] \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/main/ets/pages/Index.ets b/Arkgraphics2D/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..def634d091282e99d7528089d11e872d823425fd --- /dev/null +++ b/Arkgraphics2D/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,23 @@ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__',align: VerticalAlign.Center }, + middle: { anchor: '__container__',align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/main/ets/pages/MonitorFrameRate.ets b/Arkgraphics2D/entry/src/main/ets/pages/MonitorFrameRate.ets new file mode 100644 index 0000000000000000000000000000000000000000..3cba29db71c34eb77f2a164d84b153931f4cdd13 --- /dev/null +++ b/Arkgraphics2D/entry/src/main/ets/pages/MonitorFrameRate.ets @@ -0,0 +1,58 @@ + +/* +* FAQ:应用帧率如何监控,运行时如何获取应用的帧率、渲染帧的耗时 + */ + +// [Start MonitorFrameRate] +import { displaySync } from '@kit.ArkGraphics2D'; + +@Entry +@Component +struct Index { + @State backDisplaySync: displaySync.DisplaySync = displaySync.create(); + private passframeInfo: Array = [] + @State fps: number = 0 + + aboutToAppear(): void { + let callback = (frameInfo: displaySync.IntervalInfo) => { + this.passframeInfo.push(frameInfo); + if (this.passframeInfo.length >= 2) { + let tmp = this.passframeInfo[1].timestamp - this.passframeInfo[0].timestamp; + let result = 1000000000 / Number.parseInt(tmp.toString()); + this.fps = result; + this.passframeInfo.shift(); + } + }; + // Register subscription function + this.backDisplaySync?.on("frame", callback); + } + + build() { + Column() { + Row() { + Text('Start') + .fontSize(50) + .onClick(() => [ + this.backDisplaySync?.start() + ]) + } + + Row() { + Text(this.fps.toString()) + .fontSize(50) + } + + Row() { + Text('End') + .fontSize(50) + .onClick(() => [ + this.backDisplaySync?.stop() + ]) + } + } + .justifyContent(FlexAlign.Center) + .width('100%') + .height('100%') + } +} +// [End MonitorFrameRate] \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/main/ets/pages/SurfaceCreatedCB.cpp b/Arkgraphics2D/entry/src/main/ets/pages/SurfaceCreatedCB.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cef78d8c4998493c24ea4a6636bdec9be206074d --- /dev/null +++ b/Arkgraphics2D/entry/src/main/ets/pages/SurfaceCreatedCB.cpp @@ -0,0 +1,11 @@ +/* +* FAQ:如何主动关闭CPU访问窗口缓冲区数据降低功耗 + */ +// [Start OnSurfaceCreatedCB] +void OnSurfaceCreatedCB(OH_NativeXComponent *component, void *window) { + uint64_t usage = 0; + int32_t ret = OH_NativeWindow_NativeWindowHandleOpt((OHNativeWindow*)window, GET_USAGE, &usage); + usage &= ~NATIVEBUFFER_USAGE_CPU_READ; + int32_t ret2 = OH_NativeWindow_NativeWindowHandleOpt((OHNativeWindow*)window, SET_USAGE, usage); +} +// [End OnSurfaceCreatedCB] \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/main/module.json5 b/Arkgraphics2D/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a1cea8b6a4560cee7bda7a2db52f310c035ab6c8 --- /dev/null +++ b/Arkgraphics2D/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/main/resources/base/element/color.json b/Arkgraphics2D/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/Arkgraphics2D/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/main/resources/base/element/float.json b/Arkgraphics2D/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/Arkgraphics2D/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/Arkgraphics2D/entry/src/main/resources/base/element/string.json b/Arkgraphics2D/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/Arkgraphics2D/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/main/resources/base/media/background.png b/Arkgraphics2D/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/Arkgraphics2D/entry/src/main/resources/base/media/background.png differ diff --git a/Arkgraphics2D/entry/src/main/resources/base/media/foreground.png b/Arkgraphics2D/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/Arkgraphics2D/entry/src/main/resources/base/media/foreground.png differ diff --git a/Arkgraphics2D/entry/src/main/resources/base/media/layered_image.json b/Arkgraphics2D/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/Arkgraphics2D/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/main/resources/base/media/startIcon.png b/Arkgraphics2D/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/Arkgraphics2D/entry/src/main/resources/base/media/startIcon.png differ diff --git a/Arkgraphics2D/entry/src/main/resources/base/profile/backup_config.json b/Arkgraphics2D/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/Arkgraphics2D/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/main/resources/base/profile/main_pages.json b/Arkgraphics2D/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/Arkgraphics2D/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/Arkgraphics2D/entry/src/main/resources/dark/element/color.json b/Arkgraphics2D/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/Arkgraphics2D/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/mock/mock-config.json5 b/Arkgraphics2D/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/Arkgraphics2D/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/ohosTest/ets/test/Ability.test.ets b/Arkgraphics2D/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/Arkgraphics2D/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/ohosTest/ets/test/List.test.ets b/Arkgraphics2D/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/Arkgraphics2D/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/ohosTest/module.json5 b/Arkgraphics2D/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55725a929993a8a18b3808d41ef037759440488b --- /dev/null +++ b/Arkgraphics2D/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/Arkgraphics2D/entry/src/test/List.test.ets b/Arkgraphics2D/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/Arkgraphics2D/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/Arkgraphics2D/entry/src/test/LocalUnit.test.ets b/Arkgraphics2D/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/Arkgraphics2D/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/Arkgraphics2D/hvigor/hvigor-config.json5 b/Arkgraphics2D/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a63d34ae5ce5833b3874807e2b8d472687c6c5bf --- /dev/null +++ b/Arkgraphics2D/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.4", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/Arkgraphics2D/hvigorfile.ts b/Arkgraphics2D/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/Arkgraphics2D/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/Arkgraphics2D/oh-package-lock.json5 b/Arkgraphics2D/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c6f99f5c73b06c5fdef7ec6f491b74b7befebe2e --- /dev/null +++ b/Arkgraphics2D/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/Arkgraphics2D/oh-package.json5 b/Arkgraphics2D/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..75e4e229db0f608fc3d9471c8819d0e52fb403c5 --- /dev/null +++ b/Arkgraphics2D/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.4", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/AudioKit/.gitignore b/AudioKit/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/AudioKit/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/AudioKit/AppScope/app.json5 b/AudioKit/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9e43dba5bb6c4a662876fa8d1e8f80cc835d75aa --- /dev/null +++ b/AudioKit/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.audiokit", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/AudioKit/AppScope/resources/base/element/string.json b/AudioKit/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e90eea4c93665644f2232fea7ae24752573c4ed7 --- /dev/null +++ b/AudioKit/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AudioKit" + } + ] +} diff --git a/AudioKit/AppScope/resources/base/media/background.png b/AudioKit/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/AudioKit/AppScope/resources/base/media/background.png differ diff --git a/AudioKit/AppScope/resources/base/media/foreground.png b/AudioKit/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/AudioKit/AppScope/resources/base/media/foreground.png differ diff --git a/AudioKit/AppScope/resources/base/media/layered_image.json b/AudioKit/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/AudioKit/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/AudioKit/build-profile.json5 b/AudioKit/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e07dd8e3577aabef154aaeff54b9dc8913cfe546 --- /dev/null +++ b/AudioKit/build-profile.json5 @@ -0,0 +1,55 @@ +{ + "app": { + "signingConfigs": [ + { + "name": "default", + "type": "HarmonyOS", + "material": { + "certpath": "C:\\Users\\Administrator\\.ohos\\config\\default_AudioKit_YfZdFkMDwVHEm_7p-xPzofQqw7zU6vCm8RUfGiXHrks=.cer", + "keyAlias": "debugKey", + "keyPassword": "0000001B023EFFE0CF3461A8333C583B31FD9E84C2487293DD9186BF8C2C162DFCDC583E0C8A609A8EBA2B", + "profile": "C:\\Users\\Administrator\\.ohos\\config\\default_AudioKit_YfZdFkMDwVHEm_7p-xPzofQqw7zU6vCm8RUfGiXHrks=.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "C:\\Users\\Administrator\\.ohos\\config\\default_AudioKit_YfZdFkMDwVHEm_7p-xPzofQqw7zU6vCm8RUfGiXHrks=.p12", + "storePassword": "0000001B2626C99852E7C1CEFCBA7D6A0C94F99085E592C577C1B0F42F207EF8907AA4B64574F86F1DFC3E" + } + } + ], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.4(16)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/AudioKit/code-linter.json5 b/AudioKit/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/AudioKit/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/AudioKit/entry/.gitignore b/AudioKit/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/AudioKit/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/AudioKit/entry/build-profile.json5 b/AudioKit/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/AudioKit/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/AudioKit/entry/hvigorfile.ts b/AudioKit/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/AudioKit/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/AudioKit/entry/obfuscation-rules.txt b/AudioKit/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/AudioKit/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/AudioKit/entry/oh-package.json5 b/AudioKit/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/AudioKit/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/AudioKit/entry/src/main/ets/entryability/EntryAbility.ets b/AudioKit/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..cdb78e0c45c745b39152339e2d55b1b79db4fb6a --- /dev/null +++ b/AudioKit/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant,ConfigurationConstant,UIAbility,Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want,launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN,'testTag','%{public}s','Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN,'testTag','%{public}s','Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN,'testTag','%{public}s','Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index',(err) => { + if (err.code) { + hilog.error(DOMAIN,'testTag','Failed to load the content. Cause: %{public}s',JSON.stringify(err)); + return; + } + hilog.info(DOMAIN,'testTag','Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN,'testTag','%{public}s','Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN,'testTag','%{public}s','Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN,'testTag','%{public}s','Ability onBackground'); + } +} \ No newline at end of file diff --git a/AudioKit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/AudioKit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..16518c63c152c5c8459c10ac47c6ee39377bf1d8 --- /dev/null +++ b/AudioKit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility,BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN,'testTag','onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN,'testTag','onRestore ok %{public}s',JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/AudioKit/entry/src/main/ets/pages/AvSeek.ets b/AudioKit/entry/src/main/ets/pages/AvSeek.ets new file mode 100644 index 0000000000000000000000000000000000000000..27c3294a809823788b89cf118ca445d8aa34cd67 --- /dev/null +++ b/AudioKit/entry/src/main/ets/pages/AvSeek.ets @@ -0,0 +1,24 @@ +/* +* FAQ:AudioRenderer是否有跳转到某一帧的接口 + */ +import { media } from '@kit.MediaKit' +import { BusinessError } from '@kit.BasicServicesKit'; + +let avPlayer: media.AVPlayer; +media.createAVPlayer((error: BusinessError, video: media.AVPlayer) => { + if (video != null) { + avPlayer = video; + + // [Start AvSeek] + let seekTime: number = 1000 + avPlayer.seek(seekTime,media.SeekMode.SEEK_PREV_SYNC) + // [End AvSeek] + + console.info('Succeeded in creating AVPlayer'); + } else { + console.error(`Failed to create AVPlayer, error message:${error.message}`); + } +}); + + + diff --git a/AudioKit/entry/src/main/ets/pages/GetCapability.cpp b/AudioKit/entry/src/main/ets/pages/GetCapability.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a38d31e8a0482c0cbcab685441b47c32ed4dead3 --- /dev/null +++ b/AudioKit/entry/src/main/ets/pages/GetCapability.cpp @@ -0,0 +1,12 @@ +/* +* FAQ:如何获取系统支持的编解码能力 + */ +// [Start GetCapability1] +// Obtain an example of the recommended audio AAC decoder capability from the system +OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_AUDIO_AAC, false); +// [End GetCapability1] + +// [Start GetCapability2] +// Obtain an instance of video AVC encoder capability for the specified hardware +OH_AVCapability *capability = OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true, HARDWARE); +// [End GetCapability2] \ No newline at end of file diff --git a/AudioKit/entry/src/main/ets/pages/Index.ets b/AudioKit/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..def634d091282e99d7528089d11e872d823425fd --- /dev/null +++ b/AudioKit/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,23 @@ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__',align: VerticalAlign.Center }, + middle: { anchor: '__container__',align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/AudioKit/entry/src/main/ets/pages/VideoErrorReload.ets b/AudioKit/entry/src/main/ets/pages/VideoErrorReload.ets new file mode 100644 index 0000000000000000000000000000000000000000..4903f1a6eba845d503ef732f57de60925ad2e664 --- /dev/null +++ b/AudioKit/entry/src/main/ets/pages/VideoErrorReload.ets @@ -0,0 +1,30 @@ +/* +* FAQ:使用video组件播放视频时,如何刷新重新加载视频?比如网络异常导致播放失败等情况 + */ + +// [Start VideoErrorReload] +@Component +export struct VideoErrorReload { + @State url: string = 'https://******'; + + build() { + Column({ space: 20 }) { + Video({ src: this.url }) + .height(300) + + Button('重新url') + .onClick(() => { + let temp = this.url; + this.url = ''; + setTimeout(() => { + this.url = temp; + }, 100); + }) + } + } +} +// [End VideoErrorReload] + + + + diff --git a/AudioKit/entry/src/main/module.json5 b/AudioKit/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a1cea8b6a4560cee7bda7a2db52f310c035ab6c8 --- /dev/null +++ b/AudioKit/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/AudioKit/entry/src/main/resources/base/element/color.json b/AudioKit/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/AudioKit/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/AudioKit/entry/src/main/resources/base/element/float.json b/AudioKit/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/AudioKit/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/AudioKit/entry/src/main/resources/base/element/string.json b/AudioKit/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/AudioKit/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/AudioKit/entry/src/main/resources/base/media/background.png b/AudioKit/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/AudioKit/entry/src/main/resources/base/media/background.png differ diff --git a/AudioKit/entry/src/main/resources/base/media/foreground.png b/AudioKit/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/AudioKit/entry/src/main/resources/base/media/foreground.png differ diff --git a/AudioKit/entry/src/main/resources/base/media/layered_image.json b/AudioKit/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/AudioKit/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/AudioKit/entry/src/main/resources/base/media/startIcon.png b/AudioKit/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/AudioKit/entry/src/main/resources/base/media/startIcon.png differ diff --git a/AudioKit/entry/src/main/resources/base/profile/backup_config.json b/AudioKit/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/AudioKit/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/AudioKit/entry/src/main/resources/base/profile/main_pages.json b/AudioKit/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/AudioKit/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/AudioKit/entry/src/main/resources/dark/element/color.json b/AudioKit/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/AudioKit/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/AudioKit/entry/src/mock/mock-config.json5 b/AudioKit/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/AudioKit/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/AudioKit/entry/src/ohosTest/ets/test/Ability.test.ets b/AudioKit/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/AudioKit/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/AudioKit/entry/src/ohosTest/ets/test/List.test.ets b/AudioKit/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/AudioKit/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/AudioKit/entry/src/ohosTest/module.json5 b/AudioKit/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55725a929993a8a18b3808d41ef037759440488b --- /dev/null +++ b/AudioKit/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/AudioKit/entry/src/test/List.test.ets b/AudioKit/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/AudioKit/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/AudioKit/entry/src/test/LocalUnit.test.ets b/AudioKit/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/AudioKit/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/AudioKit/hvigor/hvigor-config.json5 b/AudioKit/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a63d34ae5ce5833b3874807e2b8d472687c6c5bf --- /dev/null +++ b/AudioKit/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.4", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/AudioKit/hvigorfile.ts b/AudioKit/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/AudioKit/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/AudioKit/oh-package-lock.json5 b/AudioKit/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c6f99f5c73b06c5fdef7ec6f491b74b7befebe2e --- /dev/null +++ b/AudioKit/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/AudioKit/oh-package.json5 b/AudioKit/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..75e4e229db0f608fc3d9471c8819d0e52fb403c5 --- /dev/null +++ b/AudioKit/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.4", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/GraphicsAccelerate/.gitignore b/GraphicsAccelerate/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/GraphicsAccelerate/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/GraphicsAccelerate/AppScope/app.json5 b/GraphicsAccelerate/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..61293ddbf08bc11222a67b74f08b52bd2c0d13e4 --- /dev/null +++ b/GraphicsAccelerate/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.graphicsaccelerate", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/GraphicsAccelerate/AppScope/resources/base/element/string.json b/GraphicsAccelerate/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f154cf5190e8768d0f150d7f47a5a9f5553f8707 --- /dev/null +++ b/GraphicsAccelerate/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "GraphicsAccelerate" + } + ] +} diff --git a/GraphicsAccelerate/AppScope/resources/base/media/background.png b/GraphicsAccelerate/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/GraphicsAccelerate/AppScope/resources/base/media/background.png differ diff --git a/GraphicsAccelerate/AppScope/resources/base/media/foreground.png b/GraphicsAccelerate/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/GraphicsAccelerate/AppScope/resources/base/media/foreground.png differ diff --git a/GraphicsAccelerate/AppScope/resources/base/media/layered_image.json b/GraphicsAccelerate/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/GraphicsAccelerate/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/GraphicsAccelerate/build-profile.json5 b/GraphicsAccelerate/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..36f074152053e9d09928282371f68d3844cf6697 --- /dev/null +++ b/GraphicsAccelerate/build-profile.json5 @@ -0,0 +1,55 @@ +{ + "app": { + "signingConfigs": [ + { + "name": "default", + "type": "HarmonyOS", + "material": { + "certpath": "C:\\Users\\Administrator\\.ohos\\config\\default_GraphicsAccelerate_K7_ADvrge8C5VExbkU7pQhDM_qxu0e3bytR0FY9kaoE=.cer", + "keyAlias": "debugKey", + "keyPassword": "0000001B2B339F312E3162576FB737D74D1FB737D5FF8870E8DA0E1B71AE9C6B36BA6DAC4AD3C0D4FC82D7", + "profile": "C:\\Users\\Administrator\\.ohos\\config\\default_GraphicsAccelerate_K7_ADvrge8C5VExbkU7pQhDM_qxu0e3bytR0FY9kaoE=.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "C:\\Users\\Administrator\\.ohos\\config\\default_GraphicsAccelerate_K7_ADvrge8C5VExbkU7pQhDM_qxu0e3bytR0FY9kaoE=.p12", + "storePassword": "0000001BB27436455DB0B50DB2CCBABE958DB1FDD0D30B9C570A732556F79732B28F39B721F105D45CE59D" + } + } + ], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.4(16)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/GraphicsAccelerate/code-linter.json5 b/GraphicsAccelerate/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/GraphicsAccelerate/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/.gitignore b/GraphicsAccelerate/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/GraphicsAccelerate/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/GraphicsAccelerate/entry/build-profile.json5 b/GraphicsAccelerate/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/GraphicsAccelerate/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/hvigorfile.ts b/GraphicsAccelerate/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/GraphicsAccelerate/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/GraphicsAccelerate/entry/obfuscation-rules.txt b/GraphicsAccelerate/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/GraphicsAccelerate/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/GraphicsAccelerate/entry/oh-package.json5 b/GraphicsAccelerate/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/GraphicsAccelerate/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/GraphicsAccelerate/entry/src/main/ets/entryability/EntryAbility.ets b/GraphicsAccelerate/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..cdb78e0c45c745b39152339e2d55b1b79db4fb6a --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant,ConfigurationConstant,UIAbility,Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want,launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN,'testTag','%{public}s','Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN,'testTag','%{public}s','Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN,'testTag','%{public}s','Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index',(err) => { + if (err.code) { + hilog.error(DOMAIN,'testTag','Failed to load the content. Cause: %{public}s',JSON.stringify(err)); + return; + } + hilog.info(DOMAIN,'testTag','Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN,'testTag','%{public}s','Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN,'testTag','%{public}s','Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN,'testTag','%{public}s','Ability onBackground'); + } +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/GraphicsAccelerate/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..16518c63c152c5c8459c10ac47c6ee39377bf1d8 --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility,BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN,'testTag','onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN,'testTag','onRestore ok %{public}s',JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/main/ets/pages/EdgeDragging.txt b/GraphicsAccelerate/entry/src/main/ets/pages/EdgeDragging.txt new file mode 100644 index 0000000000000000000000000000000000000000..7fde49f44afb848ed78c8c5ccb12de5aed32e9ef --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/ets/pages/EdgeDragging.txt @@ -0,0 +1,32 @@ +/* +* FAQ:开启超帧外插模式后运动物体边缘出现严重拖影现象,可能的原因是什么? + */ +// [Start EdgeDragging] +Shader "Standard_with_stencil" +{ + Properties + { + /* ... */ + _LightingStencilRef("Lighting Stencil Reference", Float) = 128 // 将动态物体材质模板值改为1xxx xxxx,消除头身分离现象 + [Enum(UnityEngine.Rendering.CompareFunction)] _LightingStencilComp("Lighting Stencil Comparison", Float) = 8 + _StencilReadMask("Stencil Read Mask", Float) = 255 + _StencilWriteMask("Stencil Write Mask", Float) = 255 + } + SubShader + { + /* ... */ + Pass + { + /* ... */ + Stencil + { + Ref[_LightingStencilRef] + Comp[_LightingStencilComp] + ReadMask[_StencilReadMask] + WriteMask[_StencilWriteMask] + Pass Replace + } + } + } +} +// [End EdgeDragging] \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/main/ets/pages/GetScaledTexture.cpp b/GraphicsAccelerate/entry/src/main/ets/pages/GetScaledTexture.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6cb549d338f8bcb30950c506fabf3c27655de56c --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/ets/pages/GetScaledTexture.cpp @@ -0,0 +1,12 @@ +/* +* FAQ:集成ABR后,从游戏引擎获取到的Native纹理内容为空,该如何解决? + */ +// [Start GetScaledTexture] +// Called after Buffer rendering +GLuint originTexture; +GLuint scaledTexture; +errorCode = HMS_ABR_GetScaledTexture_GLES(context_, originTexture, &scaledTexture); +if (errorCode != ABR_SUCCESS) { + GOLOGE("HMS_ABR_GetScaledTexture_GLES execution failed, error code: %d.", errorCode); +} +// [End GetScaledTexture] \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/main/ets/pages/Index.ets b/GraphicsAccelerate/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..def634d091282e99d7528089d11e872d823425fd --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,23 @@ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__',align: VerticalAlign.Center }, + middle: { anchor: '__container__',align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/main/ets/pages/SetPerCameraShaderVariables.cpp b/GraphicsAccelerate/entry/src/main/ets/pages/SetPerCameraShaderVariables.cpp new file mode 100644 index 0000000000000000000000000000000000000000..853862e3e4cc930ed331d5cd3cd7b54a55a1cb60 --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/ets/pages/SetPerCameraShaderVariables.cpp @@ -0,0 +1,32 @@ +/* +* FAQ:ABR进行Buffer分辨率调整引起其他Pass渲染效果异常,该如何解决? + */ +// [Start SetPerCameraShaderVariables1] +void SetPerCameraShaderVariables(CommandBuffer cmd, ref CameraData cameraData, bool isTargetFlipped) +{ + Camera camera = cameraData.camera; + float scaledCameraWidth = (float)cameraData.cameraTargetDescriptor.width; + float scaledCameraHeight = (float)cameraData.cameraTargetDescriptor.height; + // The scale is the ABR Buffer resolution factor obtained through the HMS-ABR_SetScale interface + scaledCameraWidth *= scale; + scaledCameraHeight *= scale; + cmd.SetGlobalVector(ShaderPropertyId.scaledScreenParams, new Vector4(scaledCameraWidth, scaledCameraHeight, 1.0f + 1.0f / scaledCameraWidth, 1.0f + 1.0f / scaledCameraHeight)); +} +// [End SetPerCameraShaderVariables1] +// [Start SetPerCameraShaderVariables2] +// Called after Buffer rendering +float scale = 1.0f; +errorCode = HMS_ABR_GetNextScale(context_, &scale); +if (errorCode != ABR_SUCCESS) { + GOLOGE("HMS_ABR_GetNextScale execution failed, error code: %d.", errorCode); +} + +// Synchronize and adjust rendering data based on Buffer resolution factor +void SetViewUniformParameters() +{ + ViewUniformParameters.BufferSize.X = (int)(ViewUniformParameters.BufferSize.X * scale); + ViewUniformParameters.BufferSize.Y = (int)(ViewUniformParameters.BufferSize.Y * scale); + ViewUniformParameters.BufferInvSize.X /= scale; + ViewUniformParameters.BufferInvSize.Y /= scale; +} +// [End SetPerCameraShaderVariables2] \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/main/module.json5 b/GraphicsAccelerate/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a1cea8b6a4560cee7bda7a2db52f310c035ab6c8 --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/main/resources/base/element/color.json b/GraphicsAccelerate/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/main/resources/base/element/float.json b/GraphicsAccelerate/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/GraphicsAccelerate/entry/src/main/resources/base/element/string.json b/GraphicsAccelerate/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/main/resources/base/media/background.png b/GraphicsAccelerate/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/GraphicsAccelerate/entry/src/main/resources/base/media/background.png differ diff --git a/GraphicsAccelerate/entry/src/main/resources/base/media/foreground.png b/GraphicsAccelerate/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/GraphicsAccelerate/entry/src/main/resources/base/media/foreground.png differ diff --git a/GraphicsAccelerate/entry/src/main/resources/base/media/layered_image.json b/GraphicsAccelerate/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/main/resources/base/media/startIcon.png b/GraphicsAccelerate/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/GraphicsAccelerate/entry/src/main/resources/base/media/startIcon.png differ diff --git a/GraphicsAccelerate/entry/src/main/resources/base/profile/backup_config.json b/GraphicsAccelerate/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/main/resources/base/profile/main_pages.json b/GraphicsAccelerate/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/GraphicsAccelerate/entry/src/main/resources/dark/element/color.json b/GraphicsAccelerate/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/GraphicsAccelerate/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/mock/mock-config.json5 b/GraphicsAccelerate/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/GraphicsAccelerate/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/ohosTest/ets/test/Ability.test.ets b/GraphicsAccelerate/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/GraphicsAccelerate/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/ohosTest/ets/test/List.test.ets b/GraphicsAccelerate/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/GraphicsAccelerate/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/ohosTest/module.json5 b/GraphicsAccelerate/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55725a929993a8a18b3808d41ef037759440488b --- /dev/null +++ b/GraphicsAccelerate/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/GraphicsAccelerate/entry/src/test/List.test.ets b/GraphicsAccelerate/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/GraphicsAccelerate/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/GraphicsAccelerate/entry/src/test/LocalUnit.test.ets b/GraphicsAccelerate/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/GraphicsAccelerate/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/GraphicsAccelerate/hvigor/hvigor-config.json5 b/GraphicsAccelerate/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a63d34ae5ce5833b3874807e2b8d472687c6c5bf --- /dev/null +++ b/GraphicsAccelerate/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.4", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/GraphicsAccelerate/hvigorfile.ts b/GraphicsAccelerate/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/GraphicsAccelerate/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/GraphicsAccelerate/oh-package-lock.json5 b/GraphicsAccelerate/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c6f99f5c73b06c5fdef7ec6f491b74b7befebe2e --- /dev/null +++ b/GraphicsAccelerate/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/GraphicsAccelerate/oh-package.json5 b/GraphicsAccelerate/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..75e4e229db0f608fc3d9471c8819d0e52fb403c5 --- /dev/null +++ b/GraphicsAccelerate/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.4", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/MapKit/.gitignore b/MapKit/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/MapKit/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/MapKit/AppScope/app.json5 b/MapKit/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c07c63bce7c116cbceb5dfa22673637aeec3fb77 --- /dev/null +++ b/MapKit/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.mapkit", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/MapKit/AppScope/resources/base/element/string.json b/MapKit/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0eff1e2639764d26a5824548bc3a16e25c592c50 --- /dev/null +++ b/MapKit/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MapKit" + } + ] +} diff --git a/MapKit/AppScope/resources/base/media/background.png b/MapKit/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/MapKit/AppScope/resources/base/media/background.png differ diff --git a/MapKit/AppScope/resources/base/media/foreground.png b/MapKit/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/MapKit/AppScope/resources/base/media/foreground.png differ diff --git a/MapKit/AppScope/resources/base/media/layered_image.json b/MapKit/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/MapKit/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/MapKit/build-profile.json5 b/MapKit/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..03ac3a3ae9dd397844173066e5d5ee21b49455a1 --- /dev/null +++ b/MapKit/build-profile.json5 @@ -0,0 +1,41 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.4(16)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/MapKit/code-linter.json5 b/MapKit/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/MapKit/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/MapKit/entry/.gitignore b/MapKit/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/MapKit/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/MapKit/entry/build-profile.json5 b/MapKit/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/MapKit/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/MapKit/entry/hvigorfile.ts b/MapKit/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/MapKit/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/MapKit/entry/obfuscation-rules.txt b/MapKit/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/MapKit/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/MapKit/entry/oh-package.json5 b/MapKit/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/MapKit/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/MapKit/entry/src/main/ets/entryability/EntryAbility.ets b/MapKit/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..cdb78e0c45c745b39152339e2d55b1b79db4fb6a --- /dev/null +++ b/MapKit/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant,ConfigurationConstant,UIAbility,Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want,launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN,'testTag','%{public}s','Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN,'testTag','%{public}s','Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN,'testTag','%{public}s','Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index',(err) => { + if (err.code) { + hilog.error(DOMAIN,'testTag','Failed to load the content. Cause: %{public}s',JSON.stringify(err)); + return; + } + hilog.info(DOMAIN,'testTag','Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN,'testTag','%{public}s','Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN,'testTag','%{public}s','Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN,'testTag','%{public}s','Ability onBackground'); + } +} \ No newline at end of file diff --git a/MapKit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/MapKit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..16518c63c152c5c8459c10ac47c6ee39377bf1d8 --- /dev/null +++ b/MapKit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility,BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN,'testTag','onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN,'testTag','onRestore ok %{public}s',JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/MapKit/entry/src/main/ets/pages/GestureStuttering.ets b/MapKit/entry/src/main/ets/pages/GestureStuttering.ets new file mode 100644 index 0000000000000000000000000000000000000000..26ea102aa0ea3cfaee50e6b0e630199eace77d97 --- /dev/null +++ b/MapKit/entry/src/main/ets/pages/GestureStuttering.ets @@ -0,0 +1,197 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:手势卡顿或者不生效 + */ + +// [Start GestureStuttering] +import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit'; +import { map, mapCommon, MapComponent } from '@kit.MapKit'; + +class MyDataSource implements IDataSource { + private list: number[] = []; + + constructor(list: number[]) { + this.list = list; + } + + totalCount(): number { + return this.list.length; + } + + getData(index: number): number { + return this.list[index]; + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + } +} + +@Entry +@Component +struct SwiperExample { + private swiperController: SwiperController = new SwiperController(); + private data: MyDataSource = new MyDataSource([]); + private mapOptions?: mapCommon.MapOptions; + private callback?: AsyncCallback; + private mapController?: map.MapComponentController; + private mapEventManager?: map.MapEventManager; + @State mapPositionX: number = 0; + @State mapPositionY: number = 0; + @State mapHeight: number = 0; + @State mapWidth: number = 0; + @State index: number = 0; + + // Determine whether the coordinates are within the map rectangle + isMap(event: TouchEvent) { + if (event.changedTouches[0].displayX > this.mapPositionX + && event.changedTouches[0].displayX < this.mapPositionX + this.mapWidth + && event.changedTouches[0].displayY > this.mapPositionY + && event.changedTouches[0].displayY < this.mapPositionY + this.mapHeight) { + return true; + } + return false; + } + + aboutToAppear(): void { + let list: number[] = []; + for (let i = 1; i <= 10; i++) { + list.push(i); + } + this.data = new MyDataSource(list); + + this.mapOptions = { + position: { + target: { + latitude: 31.98441025, + longitude: 118.766253 + }, + zoom: 10, + tilt: 10, + bearing: 90 + }, + scaleControlsEnabled: true + } + + this.callback = async (err, mapController) => { + if (!err) { + this.mapController = mapController; + this.mapEventManager = this.mapController.getEventManager(); + let callback = () => { + console.info(`on-mapLoad`); + }; + this.mapEventManager.on("mapLoad", callback); + } + } + } + + build() { + Column({ space: 5 }) { + Swiper(this.swiperController) { + LazyForEach(this.data, (item: string) => { + if (item == "3") { + Column() { + Text(item.toString()) + .width('90%') + .height(160) + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + MapComponent({ mapOptions: this.mapOptions, mapCallback: this.callback }) + // 获取MapComponent的位置和长宽 + .width('100%') + .height('65%') + .onAreaChange((_oldValue: Area, newValue: Area) => { + try { + if (newValue.globalPosition.x !== undefined && newValue.globalPosition.y !== undefined) { + this.mapPositionX = Number(newValue.globalPosition.x); + this.mapPositionY = Number(newValue.globalPosition.y); + this.mapHeight = Number(newValue.height); + this.mapWidth = Number(newValue.width); + } + } catch (error) { + let e: BusinessError = error as BusinessError; + console.log("onAreaChange error code:" + e.code + "message:" + e.message); + } + }) + }.height("100%") + } else { + Text(item.toString()) + .width('90%') + .height(160) + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + } + }, (item: string) => item) + } + // Gesture judgment: When the index indicates the existence of a map page and the click is within the map rectangle, + // it is HitTestMode. None (does not respond to the Swiper gesture, responds to the sub component gesture) + .onTouchIntercept((event: TouchEvent) => { + if (this.index === 2 && this.isMap(event)) { + return HitTestMode.None; + } + return HitTestMode.Transparent; + }) + .cachedCount(2) + .index(1) + .loop(true) + .itemSpace(0) + // Set the style of circular navigation points + .indicator( + new DotIndicator() + .itemWidth(15) + .itemHeight(15) + .selectedItemWidth(15) + .selectedItemHeight(15) + .color(Color.Gray) + .selectedColor(Color.Blue)) + .displayArrow({ + // Set navigation point arrow style + showBackground: true, + isSidebarMiddle: true, + backgroundSize: 24, + backgroundColor: Color.White, + arrowSize: 18, + arrowColor: Color.Blue + }, false) + .curve(Curve.Linear) + .onChange((index: number) => { + this.index = index; + }) + .onGestureSwipe((index: number, extraInfo: SwiperAnimationEvent) => { + console.info("index: " + index); + console.info("current offset: " + extraInfo.currentOffset); + }) + + Row({ space: 12 }) { + Button('showNext') + .onClick(() => { + this.swiperController.showNext(); + }) + Button('showPrevious') + .onClick(() => { + this.swiperController.showPrevious(); + }) + }.margin(5) + }.width('100%') + .margin({ top: 5 }) + } +} +// [End GestureStuttering] \ No newline at end of file diff --git a/MapKit/entry/src/main/ets/pages/Index.ets b/MapKit/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..def634d091282e99d7528089d11e872d823425fd --- /dev/null +++ b/MapKit/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,23 @@ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__',align: VerticalAlign.Center }, + middle: { anchor: '__container__',align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/MapKit/entry/src/main/module.json5 b/MapKit/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a1cea8b6a4560cee7bda7a2db52f310c035ab6c8 --- /dev/null +++ b/MapKit/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/MapKit/entry/src/main/resources/base/element/color.json b/MapKit/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/MapKit/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/MapKit/entry/src/main/resources/base/element/float.json b/MapKit/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/MapKit/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/MapKit/entry/src/main/resources/base/element/string.json b/MapKit/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/MapKit/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/MapKit/entry/src/main/resources/base/media/background.png b/MapKit/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/MapKit/entry/src/main/resources/base/media/background.png differ diff --git a/MapKit/entry/src/main/resources/base/media/foreground.png b/MapKit/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/MapKit/entry/src/main/resources/base/media/foreground.png differ diff --git a/MapKit/entry/src/main/resources/base/media/layered_image.json b/MapKit/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/MapKit/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/MapKit/entry/src/main/resources/base/media/startIcon.png b/MapKit/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/MapKit/entry/src/main/resources/base/media/startIcon.png differ diff --git a/MapKit/entry/src/main/resources/base/profile/backup_config.json b/MapKit/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/MapKit/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/MapKit/entry/src/main/resources/base/profile/main_pages.json b/MapKit/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/MapKit/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/MapKit/entry/src/main/resources/dark/element/color.json b/MapKit/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/MapKit/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/MapKit/entry/src/mock/mock-config.json5 b/MapKit/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/MapKit/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/MapKit/entry/src/ohosTest/ets/test/Ability.test.ets b/MapKit/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/MapKit/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/MapKit/entry/src/ohosTest/ets/test/List.test.ets b/MapKit/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/MapKit/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/MapKit/entry/src/ohosTest/module.json5 b/MapKit/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55725a929993a8a18b3808d41ef037759440488b --- /dev/null +++ b/MapKit/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/MapKit/entry/src/test/List.test.ets b/MapKit/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/MapKit/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/MapKit/entry/src/test/LocalUnit.test.ets b/MapKit/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/MapKit/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/MapKit/hvigor/hvigor-config.json5 b/MapKit/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a63d34ae5ce5833b3874807e2b8d472687c6c5bf --- /dev/null +++ b/MapKit/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.4", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/MapKit/hvigorfile.ts b/MapKit/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/MapKit/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/MapKit/oh-package-lock.json5 b/MapKit/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c6f99f5c73b06c5fdef7ec6f491b74b7befebe2e --- /dev/null +++ b/MapKit/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/MapKit/oh-package.json5 b/MapKit/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..75e4e229db0f608fc3d9471c8819d0e52fb403c5 --- /dev/null +++ b/MapKit/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.4", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/Notificationkit/.gitignore b/Notificationkit/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/Notificationkit/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/Notificationkit/AppScope/app.json5 b/Notificationkit/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..62de4147cdd575d7ffdb7f8b428080b59f7de3d3 --- /dev/null +++ b/Notificationkit/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.notificationkit", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/Notificationkit/AppScope/resources/base/element/string.json b/Notificationkit/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2535e559af177bc81b5a6b312f655f51c3fb7c4c --- /dev/null +++ b/Notificationkit/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Notificationkit" + } + ] +} diff --git a/Notificationkit/AppScope/resources/base/media/background.png b/Notificationkit/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/Notificationkit/AppScope/resources/base/media/background.png differ diff --git a/Notificationkit/AppScope/resources/base/media/foreground.png b/Notificationkit/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/Notificationkit/AppScope/resources/base/media/foreground.png differ diff --git a/Notificationkit/AppScope/resources/base/media/layered_image.json b/Notificationkit/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/Notificationkit/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/Notificationkit/build-profile.json5 b/Notificationkit/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..03ac3a3ae9dd397844173066e5d5ee21b49455a1 --- /dev/null +++ b/Notificationkit/build-profile.json5 @@ -0,0 +1,41 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.4(16)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Notificationkit/code-linter.json5 b/Notificationkit/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/Notificationkit/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/Notificationkit/entry/.gitignore b/Notificationkit/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/Notificationkit/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/Notificationkit/entry/build-profile.json5 b/Notificationkit/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/Notificationkit/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/Notificationkit/entry/hvigorfile.ts b/Notificationkit/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/Notificationkit/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/Notificationkit/entry/obfuscation-rules.txt b/Notificationkit/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/Notificationkit/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/Notificationkit/entry/oh-package.json5 b/Notificationkit/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/Notificationkit/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/Notificationkit/entry/src/main/ets/entryability/EntryAbility.ets b/Notificationkit/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..cdb78e0c45c745b39152339e2d55b1b79db4fb6a --- /dev/null +++ b/Notificationkit/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant,ConfigurationConstant,UIAbility,Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want,launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN,'testTag','%{public}s','Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN,'testTag','%{public}s','Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN,'testTag','%{public}s','Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index',(err) => { + if (err.code) { + hilog.error(DOMAIN,'testTag','Failed to load the content. Cause: %{public}s',JSON.stringify(err)); + return; + } + hilog.info(DOMAIN,'testTag','Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN,'testTag','%{public}s','Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN,'testTag','%{public}s','Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN,'testTag','%{public}s','Ability onBackground'); + } +} \ No newline at end of file diff --git a/Notificationkit/entry/src/main/ets/entryability/EntryAbility2.ets b/Notificationkit/entry/src/main/ets/entryability/EntryAbility2.ets new file mode 100644 index 0000000000000000000000000000000000000000..b11da8859e81c254ef5167bb12bf1bfc58ea88a4 --- /dev/null +++ b/Notificationkit/entry/src/main/ets/entryability/EntryAbility2.ets @@ -0,0 +1,26 @@ +/* +* FAQ:如何让事件只在一个UIAbility实例中传递 + */ + +// [Start EventHubTransfer] +import { UIAbility } from '@kit.AbilityKit'; + +export default class EntryAbility extends UIAbility { + onForeground() { + this.context.eventHub.on('myEvent', this.eventFunc); + // result: + // eventFunc is called,undefined,undefined + this.context.eventHub.emit('myEvent'); + // result: + // eventFunc is called,1,undefined + this.context.eventHub.emit('myEvent', 1); + // result: + // eventFunc is called,1,2 + this.context.eventHub.emit('myEvent', 1, 2); + } + + eventFunc(argOne: number, argTwo: number) { + console.log('eventFunc is called, ${argOne}, ${argTwo}'); + } +} +// [End EventHubTransfer] \ No newline at end of file diff --git a/Notificationkit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/Notificationkit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..16518c63c152c5c8459c10ac47c6ee39377bf1d8 --- /dev/null +++ b/Notificationkit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility,BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN,'testTag','onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN,'testTag','onRestore ok %{public}s',JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/Notificationkit/entry/src/main/ets/pages/CommonEvent.ets b/Notificationkit/entry/src/main/ets/pages/CommonEvent.ets new file mode 100644 index 0000000000000000000000000000000000000000..dfb7cdda5a28d0ed2a119b69da65a25d53530889 --- /dev/null +++ b/Notificationkit/entry/src/main/ets/pages/CommonEvent.ets @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:如何监听系统公共事件,如熄屏、亮屏、开机等 + */ + +// [Start CommonEvent1] +import { commonEventManager } from '@kit.BasicServicesKit'; + +let subscriber:commonEventManager.CommonEventSubscriber; +let subscribeInfo: commonEventManager.CommonEventSubscribeInfo = { + events: ['usual.event.SCREEN_OFF'], // Subscribe to screen out public events + priority:80 +} +commonEventManager.createSubscriber(subscribeInfo, (err, data) => { + if (err) { + console.error(`Failed to create subscriber. Code is ${err.code}, message is ${err.message}`); + return; + } + console.info('Succeeded in creating subscriber1.'); + subscriber = data; + // Subscribe to public event callbacks + commonEventManager.subscribe(subscriber, (err, data) => { + if (err) { + console.error(`Failed to subscribe common event. Code is ${err.code}, message is ${err.message}`); + return; + } else { + console.info(`Succeeded in subscribe common event Succeeded1 `); + } + }) +}) +// [End CommonEvent1] \ No newline at end of file diff --git a/Notificationkit/entry/src/main/ets/pages/EmitterOff.ets b/Notificationkit/entry/src/main/ets/pages/EmitterOff.ets new file mode 100644 index 0000000000000000000000000000000000000000..fab1e028c8da6b9b72def365d135bc550ddbb14b --- /dev/null +++ b/Notificationkit/entry/src/main/ets/pages/EmitterOff.ets @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { emitter } from '@kit.BasicServicesKit'; + +/* +* FAQ:emitter.off取消订阅某个事件后,是不是所有订阅该事件的地方都不会再收到该事件的消息 + */ + +// [Start emitterOff] +emitter.off(1); +// [End emitterOff] \ No newline at end of file diff --git a/Notificationkit/entry/src/main/ets/pages/Index.ets b/Notificationkit/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..def634d091282e99d7528089d11e872d823425fd --- /dev/null +++ b/Notificationkit/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,23 @@ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__',align: VerticalAlign.Center }, + middle: { anchor: '__container__',align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/Notificationkit/entry/src/main/module.json5 b/Notificationkit/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a1cea8b6a4560cee7bda7a2db52f310c035ab6c8 --- /dev/null +++ b/Notificationkit/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/Notificationkit/entry/src/main/resources/base/element/color.json b/Notificationkit/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/Notificationkit/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/Notificationkit/entry/src/main/resources/base/element/float.json b/Notificationkit/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/Notificationkit/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/Notificationkit/entry/src/main/resources/base/element/string.json b/Notificationkit/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/Notificationkit/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/Notificationkit/entry/src/main/resources/base/media/background.png b/Notificationkit/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/Notificationkit/entry/src/main/resources/base/media/background.png differ diff --git a/Notificationkit/entry/src/main/resources/base/media/foreground.png b/Notificationkit/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/Notificationkit/entry/src/main/resources/base/media/foreground.png differ diff --git a/Notificationkit/entry/src/main/resources/base/media/layered_image.json b/Notificationkit/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/Notificationkit/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/Notificationkit/entry/src/main/resources/base/media/startIcon.png b/Notificationkit/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/Notificationkit/entry/src/main/resources/base/media/startIcon.png differ diff --git a/Notificationkit/entry/src/main/resources/base/profile/backup_config.json b/Notificationkit/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/Notificationkit/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/Notificationkit/entry/src/main/resources/base/profile/main_pages.json b/Notificationkit/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/Notificationkit/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/Notificationkit/entry/src/main/resources/dark/element/color.json b/Notificationkit/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/Notificationkit/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/Notificationkit/entry/src/mock/mock-config.json5 b/Notificationkit/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/Notificationkit/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/Notificationkit/entry/src/ohosTest/ets/test/Ability.test.ets b/Notificationkit/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/Notificationkit/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/Notificationkit/entry/src/ohosTest/ets/test/List.test.ets b/Notificationkit/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/Notificationkit/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/Notificationkit/entry/src/ohosTest/module.json5 b/Notificationkit/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55725a929993a8a18b3808d41ef037759440488b --- /dev/null +++ b/Notificationkit/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/Notificationkit/entry/src/test/List.test.ets b/Notificationkit/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/Notificationkit/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/Notificationkit/entry/src/test/LocalUnit.test.ets b/Notificationkit/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/Notificationkit/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/Notificationkit/hvigor/hvigor-config.json5 b/Notificationkit/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a63d34ae5ce5833b3874807e2b8d472687c6c5bf --- /dev/null +++ b/Notificationkit/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.4", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/Notificationkit/hvigorfile.ts b/Notificationkit/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/Notificationkit/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/Notificationkit/oh-package-lock.json5 b/Notificationkit/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c6f99f5c73b06c5fdef7ec6f491b74b7befebe2e --- /dev/null +++ b/Notificationkit/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/Notificationkit/oh-package.json5 b/Notificationkit/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..75e4e229db0f608fc3d9471c8819d0e52fb403c5 --- /dev/null +++ b/Notificationkit/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.4", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +}