debug item to locally simulate a SN change

...because constantly reinstalling a secondary device takes too long

You can toggle twice to switch it back, but most of the time you'll
simply pull the latest (real) key when the message view regains focus.

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent 34f59d661a
commit 54865e43ed

@ -61,112 +61,133 @@ NS_ASSUME_NONNULL_BEGIN
}],
]]];
[contents
addSection:[OWSTableSection
sectionWithTitle:@"Session State"
items:@[
[OWSTableItem itemWithTitle:@"Log All Recipient Identities"
actionBlock:^{
[OWSRecipientIdentity printAllIdentities];
}],
[OWSTableItem itemWithTitle:@"Log All Sessions"
actionBlock:^{
dispatch_async([OWSDispatch sessionStoreQueue], ^{
[[TSStorageManager sharedManager] printAllSessions];
});
}],
[OWSTableItem
itemWithTitle:@"Delete session (Contact Thread Only)"
actionBlock:^{
if (![thread isKindOfClass:[TSContactThread class]]) {
DDLogError(@"Refusing to delete session for group thread.");
OWSAssert(NO);
return;
}
TSContactThread *contactThread = (TSContactThread *)thread;
dispatch_async([OWSDispatch sessionStoreQueue], ^{
[[TSStorageManager sharedManager]
deleteAllSessionsForContact:contactThread.contactIdentifier];
});
}],
[OWSTableItem
itemWithTitle:@"Send session reset (Contact Thread Only)"
actionBlock:^{
if (![thread isKindOfClass:[TSContactThread class]]) {
DDLogError(@"Refusing to reset session for group thread.");
OWSAssert(NO);
return;
}
TSContactThread *contactThread = (TSContactThread *)thread;
[OWSSessionResetJob
runWithContactThread:contactThread
messageSender:[Environment getCurrent].messageSender
storageManager:[TSStorageManager sharedManager]];
}]
]]];
if ([thread isKindOfClass:[TSContactThread class]]) {
TSContactThread *contactThread = (TSContactThread *)thread;
[contents
addSection:[OWSTableSection
sectionWithTitle:@"Session State"
items:@[
[OWSTableItem itemWithTitle:@"Log All Recipient Identities"
actionBlock:^{
[OWSRecipientIdentity printAllIdentities];
}],
[OWSTableItem itemWithTitle:@"Log All Sessions"
actionBlock:^{
dispatch_async([OWSDispatch sessionStoreQueue], ^{
[[TSStorageManager sharedManager] printAllSessions];
});
}],
[OWSTableItem itemWithTitle:@"Toggle Key Change (Contact Thread Only)"
actionBlock:^{
DDLogError(
@"Flipping identity Key. Flip again to return.");
OWSIdentityManager *identityManager =
[OWSIdentityManager sharedManager];
NSString *recipientId = [contactThread contactIdentifier];
NSData *currentKey = [identityManager
identityKeyForRecipientId:recipientId];
NSMutableData *flippedKey = [NSMutableData new];
const char *currentKeyBytes = currentKey.bytes;
for (NSUInteger i = 0; i < currentKey.length; i++) {
const char xorByte = currentKeyBytes[i] ^ 0xff;
[flippedKey appendBytes:&xorByte length:1];
}
OWSAssert(flippedKey.length == 32);
[identityManager saveRemoteIdentity:flippedKey
recipientId:recipientId];
}],
[OWSTableItem
itemWithTitle:@"Delete session (Contact Thread Only)"
actionBlock:^{
dispatch_async([OWSDispatch sessionStoreQueue], ^{
[[TSStorageManager sharedManager]
deleteAllSessionsForContact:contactThread
.contactIdentifier];
});
}],
[OWSTableItem
itemWithTitle:@"Send session reset (Contact Thread Only)"
actionBlock:^{
[OWSSessionResetJob
runWithContactThread:contactThread
messageSender:[Environment getCurrent].messageSender
storageManager:[TSStorageManager sharedManager]];
}]
]]];
// After enqueing the notification you may want to background the app or lock the screen before it triggers, so
// we give a little delay.
uint64_t notificationDelay = 5;
[contents
addSection:
[OWSTableSection
sectionWithTitle:[NSString
stringWithFormat:@"Call Notifications (%llu second delay)", notificationDelay]
items:@[
[OWSTableItem
itemWithTitle:@"Missed Call"
actionBlock:^{
SignalCall *call =
[SignalCall incomingCallWithLocalId:[NSUUID new]
remotePhoneNumber:thread.contactIdentifier
signalingId:0];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(notificationDelay * NSEC_PER_SEC)),
dispatch_get_main_queue(),
^{
[[Environment getCurrent].callService.notificationsAdapter
presentMissedCall:call
callerName:thread.name];
});
}],
[OWSTableItem
itemWithTitle:@"Rejected Call with New Safety Number"
actionBlock:^{
SignalCall *call =
[SignalCall incomingCallWithLocalId:[NSUUID new]
remotePhoneNumber:thread.contactIdentifier
signalingId:0];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(notificationDelay * NSEC_PER_SEC)),
dispatch_get_main_queue(),
^{
[[Environment getCurrent].callService.notificationsAdapter
presentMissedCallBecauseOfNewIdentityWithCall:call
callerName:thread.name];
});
}],
[OWSTableItem
itemWithTitle:@"Rejected Call with No Longer Verified Safety Number"
actionBlock:^{
SignalCall *call =
[SignalCall incomingCallWithLocalId:[NSUUID new]
remotePhoneNumber:thread.contactIdentifier
signalingId:0];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(notificationDelay * NSEC_PER_SEC)),
dispatch_get_main_queue(),
^{
[[Environment getCurrent].callService.notificationsAdapter
presentMissedCallBecauseOfNoLongerVerifiedIdentityWithCall:call
callerName:
thread
.name];
});
}],
]]];
} // end contact thread section
[contents addSection:[DebugUIContacts section]];
// After enqueing the notification you may want to background the app or lock the screen before it triggers, so we
// give a little delay.
uint64_t notificationDelay = 5;
[contents
addSection:
[OWSTableSection
sectionWithTitle:[NSString
stringWithFormat:@"Call Notifications (%llu second delay)", notificationDelay]
items:@[
[OWSTableItem itemWithTitle:@"Missed Call"
actionBlock:^{
SignalCall *call =
[SignalCall incomingCallWithLocalId:[NSUUID new]
remotePhoneNumber:thread.contactIdentifier
signalingId:0];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(notificationDelay * NSEC_PER_SEC)),
dispatch_get_main_queue(),
^{
[[Environment getCurrent].callService.notificationsAdapter
presentMissedCall:call
callerName:thread.name];
});
}],
[OWSTableItem
itemWithTitle:@"Rejected Call with New Safety Number"
actionBlock:^{
SignalCall *call = [SignalCall incomingCallWithLocalId:[NSUUID new]
remotePhoneNumber:thread.contactIdentifier
signalingId:0];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(notificationDelay * NSEC_PER_SEC)),
dispatch_get_main_queue(),
^{
[[Environment getCurrent].callService.notificationsAdapter
presentMissedCallBecauseOfNewIdentityWithCall:call
callerName:thread.name];
});
}],
[OWSTableItem
itemWithTitle:@"Rejected Call with No Longer Verified Safety Number"
actionBlock:^{
SignalCall *call = [SignalCall incomingCallWithLocalId:[NSUUID new]
remotePhoneNumber:thread.contactIdentifier
signalingId:0];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(notificationDelay * NSEC_PER_SEC)),
dispatch_get_main_queue(),
^{
[[Environment getCurrent].callService.notificationsAdapter
presentMissedCallBecauseOfNoLongerVerifiedIdentityWithCall:call
callerName:
thread.name];
});
}],
]]];
viewController.contents = contents;
[viewController presentFromViewController:fromViewController];
}

Loading…
Cancel
Save