From 52f578fb8559703be4ea93595fa49841016d7db8 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Thu, 28 Sep 2023 21:48:14 -0700 Subject: [PATCH] Apply the second half of https://github.com/google/EarlGrey/pull/1977 PiperOrigin-RevId: 569379325 --- .../AutomationSetup/GREYAutomationSetup.m | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/AppFramework/AutomationSetup/GREYAutomationSetup.m b/AppFramework/AutomationSetup/GREYAutomationSetup.m index c7ae2b121..db3cb8245 100644 --- a/AppFramework/AutomationSetup/GREYAutomationSetup.m +++ b/AppFramework/AutomationSetup/GREYAutomationSetup.m @@ -15,6 +15,7 @@ // #import "GREYAutomationSetup.h" +#import #import "GREYAppleInternals.h" @@ -24,7 +25,26 @@ @implementation GREYAutomationSetup + (void)load { // Force software keyboard. - [[UIKeyboardImpl sharedInstance] setAutomaticMinimizationEnabled:NO]; + static NSArray *legacyTargets; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + legacyTargets = @[ + ]; + }); + BOOL deferKeyboardChange = YES; + NSString *packagePath = NSProcessInfo.processInfo.environment[@"TEST_UNDECLARED_OUTPUTS_DIR"]; + for (NSString *legacyTarget in legacyTargets) { + if ([packagePath containsString:legacyTarget]) { + deferKeyboardChange = NO; + } + } + if (deferKeyboardChange) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[UIKeyboardImpl sharedInstance] setAutomaticMinimizationEnabled:NO]; + }); + } else { + [[UIKeyboardImpl sharedInstance] setAutomaticMinimizationEnabled:NO]; + } } @end