1 /* 2 * Copyright (c) 2022 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 #ifndef NFC_PREFERENCES_H 16 #define NFC_PREFERENCES_H 17 #include "preferences.h" 18 #include "preferences_helper.h" 19 20 namespace OHOS { 21 namespace NFC { 22 const std::string PREF_KEY_STATE = "pref_key_nfc_state"; 23 class NfcPreferences { 24 public: 25 NfcPreferences(); 26 ~NfcPreferences(); 27 static NfcPreferences& GetInstance(); 28 29 void SetString(const std::string& key, const std::string& value); 30 std::string GetString(const std::string& key); 31 void SetInt(const std::string& key, const int value); 32 int GetInt(const std::string& key); 33 void Clear(); 34 void Delete(const std::string& key); 35 36 void UpdateNfcState(int newState); 37 int GetNfcState(); 38 39 private: 40 std::shared_ptr<NativePreferences::Preferences> GetPreference(const std::string& fileName); 41 int errCode_; 42 std::string fileName_; 43 }; 44 } // NFC 45 } // OHOS 46 #endif // NFC_PREFERENCES_H