Give serial to the device during cert exchange so it can provide it whenever it connects

Summary:
Android devices don't always know their own serial.
But we do a certificate exchange using adb from the desktop, so we can provide it in the response.

After this the client will provide it every time it connects, so we can do things like filter plugins by device id.

For apps that have already done cert exchange, they'll continue to use 'unknown' as their id until they do it again with an up to date version of sonar.
We can think about forcefully stopping that, but I haven't done it.

Reviewed By: danielbuechele

Differential Revision: D9481460

fbshipit-source-id: f8932699711ebbec4260fabe32f87e6cdff920f2
This commit is contained in:
John Knox
2018-08-31 07:58:01 -07:00
committed by Facebook Github Bot
parent 94e22508ae
commit edff177c3f
5 changed files with 74 additions and 9 deletions

View File

@@ -181,9 +181,11 @@ export default class Server extends EventEmitter {
subscriber.onSubscribe();
this.certificateProvider
.processCertificateSigningRequest(csr, clientData.os, destination)
.then(_ => {
.then(result => {
subscriber.onComplete({
data: JSON.stringify({}),
data: JSON.stringify({
deviceId: result.deviceId,
}),
metadata: '',
});
})
@@ -241,7 +243,7 @@ export default class Server extends EventEmitter {
addConnection(conn: ReactiveSocket, query: ClientQuery): Client {
invariant(query, 'expected query');
const id = `${query.app}-${query.os}-${query.device}`;
const id = `${query.app}-${query.os}-${query.device}-${query.device_id}`;
console.debug(`Device connected: ${id}`, 'connection');
const client = new Client(id, query, conn, this.logger);