Page MenuHomePhabricator

D5993.id20687.diff
No OneTemporary

D5993.id20687.diff

diff --git a/native/cpp/CommonCpp/DatabaseManagers/DatabaseManager.h b/native/cpp/CommonCpp/DatabaseManagers/DatabaseManager.h
--- a/native/cpp/CommonCpp/DatabaseManagers/DatabaseManager.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/DatabaseManager.h
@@ -15,6 +15,7 @@
static const DatabaseQueryExecutor &getQueryExecutor();
static void clearSensitiveData();
static void initializeQueryExecutor();
+ static bool checkIfDatabaseNeedsDeletion();
};
} // namespace comm
diff --git a/native/cpp/CommonCpp/DatabaseManagers/DatabaseManager.cpp b/native/cpp/CommonCpp/DatabaseManagers/DatabaseManager.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/DatabaseManager.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/DatabaseManager.cpp
@@ -62,4 +62,12 @@
commSecureStore.set(DATABASE_MANAGER_STATUS_KEY, DB_MANAGER_WORKABLE);
}
+bool DatabaseManager::checkIfDatabaseNeedsDeletion() {
+ comm::CommSecureStore commSecureStore{};
+ folly::Optional<std::string> databaseManagerStatus =
+ commSecureStore.get(DATABASE_MANAGER_STATUS_KEY);
+ return databaseManagerStatus.hasValue() &&
+ databaseManagerStatus.value() == DB_MANAGER_SECOND_FAILURE;
+}
+
} // namespace comm
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
@@ -59,6 +59,7 @@
setDeviceID(jsi::Runtime &rt, jsi::String deviceType) override;
virtual jsi::Value getDeviceID(jsi::Runtime &rt) override;
virtual jsi::Value clearSensitiveData(jsi::Runtime &rt) override;
+ virtual bool checkIfDatabaseNeedsDeletion(jsi::Runtime &rt) override;
public:
CommCoreModule(std::shared_ptr<facebook::react::CallInvoker> jsInvoker);
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
@@ -1060,4 +1060,8 @@
});
}
+bool CommCoreModule::checkIfDatabaseNeedsDeletion(jsi::Runtime &rt) {
+ return DatabaseManager::checkIfDatabaseNeedsDeletion();
+}
+
} // namespace comm
diff --git a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
--- a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
+++ b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
@@ -83,6 +83,9 @@
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_clearSensitiveData(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->clearSensitiveData(rt);
}
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_checkIfDatabaseNeedsDeletion(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->checkIfDatabaseNeedsDeletion(rt);
+}
CommCoreModuleSchemaCxxSpecJSI::CommCoreModuleSchemaCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule("CommTurboModule", jsInvoker) {
@@ -109,6 +112,7 @@
methodMap_["setDeviceID"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_setDeviceID};
methodMap_["getDeviceID"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getDeviceID};
methodMap_["clearSensitiveData"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_clearSensitiveData};
+ methodMap_["checkIfDatabaseNeedsDeletion"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_checkIfDatabaseNeedsDeletion};
}
diff --git a/native/cpp/CommonCpp/_generated/commJSI.h b/native/cpp/CommonCpp/_generated/commJSI.h
--- a/native/cpp/CommonCpp/_generated/commJSI.h
+++ b/native/cpp/CommonCpp/_generated/commJSI.h
@@ -43,6 +43,7 @@
virtual jsi::Value setDeviceID(jsi::Runtime &rt, jsi::String deviceType) = 0;
virtual jsi::Value getDeviceID(jsi::Runtime &rt) = 0;
virtual jsi::Value clearSensitiveData(jsi::Runtime &rt) = 0;
+ virtual bool checkIfDatabaseNeedsDeletion(jsi::Runtime &rt) = 0;
};
@@ -248,6 +249,14 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::clearSensitiveData, jsInvoker_, instance_);
}
+ bool checkIfDatabaseNeedsDeletion(jsi::Runtime &rt) override {
+ static_assert(
+ bridging::getParameterCount(&T::checkIfDatabaseNeedsDeletion) == 1,
+ "Expected checkIfDatabaseNeedsDeletion(...) to have 1 parameters");
+
+ return bridging::callFromJs<bool>(
+ rt, &T::checkIfDatabaseNeedsDeletion, jsInvoker_, instance_);
+ }
private:
T *instance_;
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -63,6 +63,7 @@
+setDeviceID: (deviceType: string) => Promise<string>;
+getDeviceID: () => Promise<string>;
+clearSensitiveData: () => Promise<void>;
+ +checkIfDatabaseNeedsDeletion: () => boolean;
}
export default (TurboModuleRegistry.getEnforcing<Spec>(

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 6:42 PM (20 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678446
Default Alt Text
D5993.id20687.diff (5 KB)

Event Timeline