From fac9b6d5973332f5348dd0ab3a61b63b71430018 Mon Sep 17 00:00:00 2001 From: zkx Date: Tue, 28 Mar 2023 11:19:47 +0800 Subject: [PATCH] remove warn Signed-off-by: zkx --- .../native/file_share/include/file_share.h | 4 +-- .../native/file_share/src/file_share.cpp | 26 +++++++------- interfaces/kits/js/@ohos.remotefileshare.d.ts | 35 ------------------- .../kits/js/file_uri/get_uri_from_path.cpp | 2 +- .../src/remote_file_share.cpp | 2 +- .../file_share_native/file_share_test.cpp | 14 ++++---- 6 files changed, 24 insertions(+), 59 deletions(-) delete mode 100644 interfaces/kits/js/@ohos.remotefileshare.d.ts diff --git a/interfaces/innerkits/native/file_share/include/file_share.h b/interfaces/innerkits/native/file_share/include/file_share.h index 58b386869..61117c606 100644 --- a/interfaces/innerkits/native/file_share/include/file_share.h +++ b/interfaces/innerkits/native/file_share/include/file_share.h @@ -65,8 +65,8 @@ const vector LOWER_PATH = { class FileShare { public: FileShare() {} - static int32_t CreateShareFile(const string &uri, int32_t tokenId, int32_t flag); - static int32_t DeleteShareFile(int32_t tokenId, vector sharePathList); + static int32_t CreateShareFile(const string &uri, uint32_t tokenId, uint32_t flag); + static int32_t DeleteShareFile(uint32_t tokenId, vector sharePathList); ~FileShare() {} }; } // namespace AppFileService diff --git a/interfaces/innerkits/native/file_share/src/file_share.cpp b/interfaces/innerkits/native/file_share/src/file_share.cpp index 15f74aa32..52109e700 100644 --- a/interfaces/innerkits/native/file_share/src/file_share.cpp +++ b/interfaces/innerkits/native/file_share/src/file_share.cpp @@ -41,7 +41,7 @@ struct FileShareInfo { SHARE_FILE_TYPE type_; }; -static int32_t GetTargetInfo(int32_t tokenId, string &bundleName, string ¤tUid) +static int32_t GetTargetInfo(uint32_t tokenId, string &bundleName, string ¤tUid) { Security::AccessToken::HapTokenInfo hapInfo; int32_t result = Security::AccessToken::AccessTokenKit::GetHapTokenInfo(tokenId, hapInfo); @@ -99,7 +99,7 @@ static int32_t GetLowerPath(string &lowerPathHead, const string &lowerPathTail, return 0; } -static int32_t GetProviderPath(const string &uriStr, int32_t tokenId, FileShareInfo &info) +static int32_t GetProviderPath(const string &uriStr, FileShareInfo &info) { Uri uri(uriStr); string pathInProvider = uri.GetPath(); @@ -107,7 +107,7 @@ static int32_t GetProviderPath(const string &uriStr, int32_t tokenId, FileShareI if (pos == string::npos) { return -EINVAL; } - + size_t num = SANDBOX_PATH.size(); string lowerPathTail = "", lowerPathHead = ""; for (size_t i = 0; i < num; i++) { @@ -120,18 +120,18 @@ static int32_t GetProviderPath(const string &uriStr, int32_t tokenId, FileShareI } } } - + int32_t ret = GetLowerPath(lowerPathHead, lowerPathTail, info); if (ret != 0) { LOGE("Get lower path failed with %{public}d", ret); return ret; } - + info.providerSandboxPath_ = pathInProvider; return 0; } -static void GetSharePath(FileShareInfo &info, int32_t flag) +static void GetSharePath(FileShareInfo &info, uint32_t flag) { string shareRPath = DATA_APP_EL2_PATH + info.currentUid_ + SHARE_PATH +info.targetBundleName_ + SHARE_R_PATH + info.providerBundleName_ + info.providerSandboxPath_; @@ -160,7 +160,7 @@ static int32_t GetShareFileType(FileShareInfo &info) return -ENOENT; } -static int32_t GetFileShareInfo(const string &uri, int32_t tokenId, int32_t flag, FileShareInfo &info) +static int32_t GetFileShareInfo(const string &uri, uint32_t tokenId, uint32_t flag, FileShareInfo &info) { int32_t ret = 0; ret = GetTargetInfo(tokenId, info.targetBundleName_, info.currentUid_); @@ -168,9 +168,9 @@ static int32_t GetFileShareInfo(const string &uri, int32_t tokenId, int32_t flag LOGE("Failed to get target info %{public}d", ret); return ret; } - + GetProviderBundleName(uri, info.providerBundleName_); - ret = GetProviderPath(uri, tokenId, info); + ret = GetProviderPath(uri, info); if (ret != 0) { LOGE("Failed to get lower path %{public}d", ret); return ret; @@ -240,7 +240,7 @@ static bool RemoveDir(const string& path) } delDirs.pop(); } - + return true; } @@ -271,7 +271,7 @@ static int32_t PreparePreShareDir(FileShareInfo &info) return 0; } -int32_t FileShare::CreateShareFile(const string &uri, int32_t tokenId, int32_t flag) +int32_t FileShare::CreateShareFile(const string &uri, uint32_t tokenId, uint32_t flag) { FileShareInfo info; int32_t ret = GetFileShareInfo(uri, tokenId, flag, info); @@ -334,7 +334,7 @@ static void UmountDelUris(vector sharePathList, string currentUid, strin } } -int32_t FileShare::DeleteShareFile(int32_t tokenId, vector sharePathList) +int32_t FileShare::DeleteShareFile(uint32_t tokenId, vector sharePathList) { string bundleName, currentUid; int32_t ret = GetTargetInfo(tokenId, bundleName, currentUid); @@ -349,7 +349,7 @@ int32_t FileShare::DeleteShareFile(int32_t tokenId, vector sharePathList LOGE("Delete dir failed with %{public}d", errno); return -errno; } - + LOGI("Delete Share File Successfully!"); return 0; } diff --git a/interfaces/kits/js/@ohos.remotefileshare.d.ts b/interfaces/kits/js/@ohos.remotefileshare.d.ts deleted file mode 100644 index 40d946ae0..000000000 --- a/interfaces/kits/js/@ohos.remotefileshare.d.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* Copyright (C) 2021-2022 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 {AsyncCallback, Callback} from "./basic"; - -/** - * Provides remote file share APIs - * - * @since 8 - * @sysCap N/A - * @devices phone, tablet - */ -declare namespace Remotefileshare { - /** - * Create the remote share path of src share file. - * - * @since 8 - */ - function createSharePath(fd: number, cid: string, callback: AsyncCallback): void; - function createSharePath(fd: number, cid: string): Promise; -} - -export default Remotefileshare; diff --git a/interfaces/kits/js/file_uri/get_uri_from_path.cpp b/interfaces/kits/js/file_uri/get_uri_from_path.cpp index b2e930955..56c1ee38a 100644 --- a/interfaces/kits/js/file_uri/get_uri_from_path.cpp +++ b/interfaces/kits/js/file_uri/get_uri_from_path.cpp @@ -50,7 +50,7 @@ static string GetBundleName() { int uid = -1; uid = IPCSkeleton::GetCallingUid(); - + sptr bundleMgrProxy = GetBundleMgrProxy(); if (!bundleMgrProxy) { LOGE("GetBundleName: bundle mgr proxy is nullptr."); diff --git a/services/remote_file_share/src/remote_file_share.cpp b/services/remote_file_share/src/remote_file_share.cpp index 0252549bf..862191e9f 100644 --- a/services/remote_file_share/src/remote_file_share.cpp +++ b/services/remote_file_share/src/remote_file_share.cpp @@ -173,7 +173,7 @@ int RemoteFileShare::CreateSharePath(const int &fd, std::string &sharePath, LOGE("RemoteFileShare::CreateSharePath, invalid argument with %{public}d", EINVAL); return EINVAL; } - + const std::string processName = GetProcessName(); if (processName == "") { LOGE("RemoteFileShare::CreateSharePath, GetProcessName failed with %{public}d", errno); diff --git a/test/unittest/file_share_native/file_share_test.cpp b/test/unittest/file_share_native/file_share_test.cpp index 59fac0e79..d876fbd8f 100644 --- a/test/unittest/file_share_native/file_share_test.cpp +++ b/test/unittest/file_share_native/file_share_test.cpp @@ -63,7 +63,7 @@ namespace { string uri = "file://" + bundleNameA + "/data/storage/el2/base/files/test.txt"; string bundleNameB = "com.ohos.systemui"; - int32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); + uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); int32_t flag = 3; int32_t ret = FileShare::CreateShareFile(uri, tokenId, flag); @@ -93,7 +93,7 @@ namespace { string uri = "file://" + bundleNameA + "/data/test/el2/base/files/test.txt"; string bundleNameB = "com.ohos.systemui"; - int32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); + uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); int32_t flag = 3; int32_t ret = FileShare::CreateShareFile(uri, tokenId, flag); @@ -120,7 +120,7 @@ namespace { int32_t fd = open(fileStr.c_str(), O_RDWR | O_CREAT); ASSERT_TRUE(fd != -1) << "FileShareTest Create File Failed!"; string uri = "file://" + bundleNameA + "/data/storage/el2/base/files/test.txt"; - int32_t tokenId = 100; + uint32_t tokenId = 100; int32_t flag = 3; int32_t ret = FileShare::CreateShareFile(uri, tokenId, flag); @@ -149,7 +149,7 @@ namespace { string uri = ""; string bundleNameB = "com.ohos.systemui"; - int32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); + uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); int32_t flag = 3; int32_t ret = FileShare::CreateShareFile(uri, tokenId, flag); @@ -178,7 +178,7 @@ namespace { string uri = ""; string bundleNameB = "com.ohos.systemui"; - int32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); + uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); int32_t flag = 4; int32_t ret = FileShare::CreateShareFile(uri, tokenId, flag); @@ -201,7 +201,7 @@ namespace { uid = OHOS::IPCSkeleton::GetCallingUid(); string bundleNameB = "com.ohos.systemui"; - int32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); + uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); vector sharePathList; string bundleNameA = "com.ohos.settingsdata"; string uri = "file://" + bundleNameA + "/data/storage/el2/base/files/test.txt"; @@ -222,7 +222,7 @@ namespace { HWTEST_F(FileShareTest, File_share_DeleteShareFile_0006, testing::ext::TestSize.Level1) { GTEST_LOG_(INFO) << "FileShareTest-begin File_share_DeleteShareFile_0006"; - int32_t tokenId = 104; + uint32_t tokenId = 104; vector sharePathList; string bundleNameA = "com.ohos.settingsdata"; string uri = "file://" + bundleNameA + "/data/storage/el2/base/files/test.txt"; -- Gitee