From e4f5cff1f7c48e2cd84861d27671948ce9d318dc Mon Sep 17 00:00:00 2001 From: Carlos Cabanero Date: Fri, 4 Oct 2024 13:26:15 -0400 Subject: [PATCH] ios patches --- Blink.xcodeproj/project.pbxproj | 6 ++++ ios_patches.h | 38 +++++++++++++++++++++++++ ios_patches.m | 50 +++++++++++++++++++++++++++++++++ main.m | 5 ++-- 4 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 ios_patches.h create mode 100644 ios_patches.m diff --git a/Blink.xcodeproj/project.pbxproj b/Blink.xcodeproj/project.pbxproj index f195a4286..c62fe1347 100644 --- a/Blink.xcodeproj/project.pbxproj +++ b/Blink.xcodeproj/project.pbxproj @@ -93,6 +93,7 @@ BD11E9E6270CD0FD003EA5AE /* openssl.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2F64C9425CA99AD00F2225D /* openssl.xcframework */; }; BD1758AC26EA8C5400AEC545 /* MenuController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1758AB26EA8C5400AEC545 /* MenuController.swift */; }; BD19DB412B056E9C003A4367 /* SSHCommandTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD19DB402B056E9C003A4367 /* SSHCommandTest.swift */; }; + BD23B6E12CB0585B0041C38D /* ios_patches.m in Sources */ = {isa = PBXBuildFile; fileRef = BD23B6E02CB0585B0041C38D /* ios_patches.m */; }; BD2E27B529BAA8DA003AF1DA /* ReplaySubject.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD2E27B429BAA8DA003AF1DA /* ReplaySubject.swift */; }; BD33F7822AAA426D00CD16EE /* MoshBootstrap.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD33F7802AAA426D00CD16EE /* MoshBootstrap.swift */; }; BD33F7872AAA7C4300CD16EE /* MoshBootstrapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD33F7862AAA7C4300CD16EE /* MoshBootstrapTests.swift */; }; @@ -827,6 +828,8 @@ BD028AF22A8EC509002F5F54 /* TrialSupportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrialSupportView.swift; sourceTree = ""; }; BD1758AB26EA8C5400AEC545 /* MenuController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuController.swift; sourceTree = ""; }; BD19DB402B056E9C003A4367 /* SSHCommandTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHCommandTest.swift; sourceTree = ""; }; + BD23B6DF2CB058550041C38D /* ios_patches.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ios_patches.h; sourceTree = ""; }; + BD23B6E02CB0585B0041C38D /* ios_patches.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ios_patches.m; sourceTree = ""; }; BD2E27B429BAA8DA003AF1DA /* ReplaySubject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReplaySubject.swift; sourceTree = ""; }; BD33F7802AAA426D00CD16EE /* MoshBootstrap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoshBootstrap.swift; sourceTree = ""; }; BD33F7862AAA7C4300CD16EE /* MoshBootstrapTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoshBootstrapTests.swift; sourceTree = ""; }; @@ -2332,6 +2335,8 @@ 0732F04F1D062BB300AB5438 /* Frameworks */, 0732F0481D062B9A00AB5438 /* Resources */, 074F30781D062A2800A73445 /* main.m */, + BD23B6E02CB0585B0041C38D /* ios_patches.m */, + BD23B6DF2CB058550041C38D /* ios_patches.h */, 07E4C5201C935E28000C571A /* Media.xcassets */, 07F670621D05EEE200C0A53C /* Sessions */, 0716B5231CFFAB9300268B5B /* Blink */, @@ -3257,6 +3262,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + BD23B6E12CB0585B0041C38D /* ios_patches.m in Sources */, D2AD8E7D27A2BAFA00DED28D /* CheckmarkRow.swift in Sources */, D2AD8E7527A2BAFA00DED28D /* PurchasesUserModel.swift in Sources */, BD9EA212271F824900874007 /* Publisher.swift in Sources */, diff --git a/ios_patches.h b/ios_patches.h new file mode 100644 index 000000000..822510810 --- /dev/null +++ b/ios_patches.h @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////// +// +// B L I N K +// +// Copyright (C) 2016-2024 Blink Mobile Shell Project +// +// This file is part of Blink. +// +// Blink is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Blink is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Blink. If not, see . +// +// In addition, Blink is also subject to certain additional terms under +// GNU GPL version 3 section 7. +// +// You should have received a copy of these additional terms immediately +// following the terms and conditions of the GNU General Public License +// which accompanied the Blink Source Code. If not, see +// . +// +//////////////////////////////////////////////////////////////////////////////// + + +#ifndef ios_patch_h +#define ios_patch_h + +void __blink_ios_patches(void); + +#endif /* ios_patch_h */ diff --git a/ios_patches.m b/ios_patches.m new file mode 100644 index 000000000..ac32f5b95 --- /dev/null +++ b/ios_patches.m @@ -0,0 +1,50 @@ +////////////////////////////////////////////////////////////////////////////////// +// +// B L I N K +// +// Copyright (C) 2016-2024 Blink Mobile Shell Project +// +// This file is part of Blink. +// +// Blink is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Blink is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Blink. If not, see . +// +// In addition, Blink is also subject to certain additional terms under +// GNU GPL version 3 section 7. +// +// You should have received a copy of these additional terms immediately +// following the terms and conditions of the GNU General Public License +// which accompanied the Blink Source Code. If not, see +// . +// +//////////////////////////////////////////////////////////////////////////////// + + +#import +#import +#include "ios_patches.h" + +void __blink_ios_patches(void) { + // Check to class method of UIPressAndHoldPopoverController + // Opened Radar so this can be fixed or exposed. + // We won't implement a different fix because plan is to move away from Hterm. + // Also an issue on macOS: https://apple.stackexchange.com/questions/332769/macos-disable-popup-showing-accented-characters-when-holding-down-a-key + Class cls = NSClassFromString(@"UIPressAndHoldPopoverController"); + + SEL selector = sel_getUid("canPresentPressAndHoldPopoverForEvent:"); + Method method = class_getClassMethod(cls, selector); + IMP override = imp_implementationWithBlock(^BOOL(id me, void* arg0) { + return NO; + }); + method_setImplementation(method, override); +} diff --git a/main.m b/main.m index ecec8bf64..9859fe54c 100644 --- a/main.m +++ b/main.m @@ -31,13 +31,14 @@ #import #import "AppDelegate.h" -#import #import #import +#include "ios_patches.h" int main(int argc, char * argv[]) { - @autoreleasepool { + @autoreleasepool { + __blink_ios_patches(); return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } }