1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef STORAGE_MANAGER_IMPL_H 17 #define STORAGE_MANAGER_IMPL_H 18 19 #include <nocopyable.h> 20 #include <singleton.h> 21 22 #include "bundle_stats.h" 23 #include "istorage_manager.h" 24 #include "storage_manager_ffi.h" 25 26 namespace OHOS { 27 namespace CJStorageManager { 28 29 class CjStorageStatusService : public NoCopyable { 30 DECLARE_DELAYED_SINGLETON(CjStorageStatusService); 31 32 public: 33 int32_t Connect(); 34 int32_t GetCurrentBundleStats(StorageManager::BundleStats &bundleStats, uint32_t statFlag); 35 int32_t GetTotalSize(int64_t &totalSize); 36 int32_t GetFreeSize(int64_t &freeSize); 37 38 int32_t ResetProxy(); 39 40 private: 41 sptr<StorageManager::IStorageManager> storageManager_ = nullptr; 42 sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr; 43 std::mutex mutex_; 44 }; 45 46 class CjSmDeathRecipient : public IRemoteObject::DeathRecipient { 47 public: 48 CjSmDeathRecipient() = default; 49 virtual ~CjSmDeathRecipient() = default; 50 51 virtual void OnRemoteDied(const wptr<IRemoteObject> &object); 52 }; 53 54 int32_t Convert2CjErrNum(int32_t errNum); 55 } // namespace CJStorageManager 56 } // namespace OHOS 57 58 #endif