HomePhabricator
Diffusion Comm ee24602c5622

[native] Add JSI functions for creating/setting and fetching device ID

Description

[native] Add JSI functions for creating/setting and fetching device ID

Summary:
Create JSI functions that may be called from js as well as cpp. setDeviceID calls a rust function that generates the id, and then calls a cpp function that sets 'device_id' entry in Metadata table of SQLite database to the generated
value.

Test Plan:
comment out native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp set_encryption_key function to turn off the database encryption, Add the following to onClick function of ThreadsettingsPromoteSidebar in
native/chat/settings/thread-settings-promote-sidebar.react.js:

console.log(commCoreModule.setDeviceID('WEB'));
commCoreModule.getDeviceID().then(id => console.log(id));

And see by setting breakpoints before and after these lines that in the SQLite Metadata table for the simulator there appears device_id entry with a value subject to "^(ks|mobile|web):[a-zA-Z0-9]{64}$" in the data column.
See that this value gets logged to the console twice.

Reviewers: marcin, varun, jon, tomek

Reviewed By: marcin, tomek

Subscribers: ashoat, tomek, atul, abosh

Differential Revision: https://phab.comm.dev/D5341