keymanapp / keyman

Keyman cross platform input methods system running on Android, iOS, Linux, macOS, Windows and mobile and desktop web
https://keyman.com/
Other
372 stars 102 forks source link

fix(mac): Prompt for required permissions at start time #7354

Closed sgschantz closed 1 year ago

sgschantz commented 1 year ago

Fixes #6110 Fixes #1725

Mac TCC (Transparency, Consent and Control) has increasingly restricted the services/data that applications have access to without explicit consent being granted by the user. In macOS Catalina (10.15), new restrictions were added that sometimes limit Keyman functionality, including breaking the shift layer and sometimes the OSK.

With this change, Keyman will check to see if it has the required permissions, and, if not, prompt the user with dialog No. 1:

To function properly, Keyman requires

After the user dismisses the dialog, the System Preferences window will appear and open to the Privacy tab with Accessibility selected. Also, the system will prompt the user with dialog No. 2 with its display blocked by the System Preferences window.

Pasted Graphic

If Accessibility is not enabled for Keyman, the first prompt from Keyman will be displayed each time that Keyman is run after restarting. Whenever dialog No. 1 is dismissed, the System Preferences window should appear. Dialog No. 2 will usually display only once but may display again when running Keyman after a system restart if the required access has not been granted.

User Testing

GROUP_CATALINA_AND_LATER: Using a version of macOS 10.15 or later GROUP_PRE_CATALINA: Using a version of macOS before 10.15

  1. Remove old version of Keyman after first removing its permissions from Security & Privacy > Privacy > Accessibility
  2. Install the Keyman build for this PR
  3. Restart the system
  4. Select Keyman from the System Input Source menu
  5. Confirm that dialog No. 1 is displayed.
  6. Click the OK button and confirm that the System Preferences window is displayed with dialog No. 2 in the background
  7. Enable Accessibility access for Keyman
  8. Restart the system.
  9. Use Keyman and confirm that the OSK and shift layer work correctly
  1. Remove old version of Keyman after first removing its permissions from Security & Privacy > Privacy > Accessibility
  2. Install the Keyman build for this PR
  3. Restart the system
  4. Select Keyman from the System Input Source menu
  5. Confirm that dialog No. 1 is displayed.
  6. Click the OK button and confirm that the System Preferences window is displayed with dialog No. 2 in the background
  7. Do not enable accessibility access for Keyman
  8. Restart the system.
  9. Select Keyman from the System Input Source menu
  10. Confirm that dialog No. 1 is displayed again.
  11. Click the OK button and confirm that the System Preferences window is now displayed with Keyman unchecked for Accessibility (Dialog No. 2 may or may not be displayed in the background.)
keymanapp-test-bot[bot] commented 1 year ago

User Test Results

Test specification and instructions

Test Artifacts

bharanidharanj commented 1 year ago
sgschantz commented 1 year ago

It looks like you used the same version of macOS with all three tests. Catalina is 10.15. Can you test with a version of macOS prior to 10.15 for the second test?

What is macOS version 12.06? I don't see any reference to that version. Did you mean 12.6?

Are you doing the tests with a completely new install -- no remnants of Keyman existing on the system? If there are entries in System Preferences, Privacy & Security to Keyman, then the tests will be invalid. Let me know if you need help with ensuring that everything from previous versions is removed.

bharanidharanj commented 1 year ago

Hi @sgschantz , I am using macOS Monterey 12.6 version. Here, what I did is: Completely uninstalled the existing Keyman 16.0 from System Preferences / Keyboard / Input Sources. Then, I installed the attached PR build in the Mac OS. After installing it, I just clicked the keyman from the system tray and noticed that no dialog has been displayed on the screen.

Hence, the first test failed, I failed the other 2 tests. (since, I don't have the old version of macOS)

Could you please, guide me how to test this PR with macOS 12.6? Or how to move back to the Older version (like 10.10 and 10.15) of macOS from the current version? Thanks.

sgschantz commented 1 year ago

Does @MakaraSok know a way to test with older versions of macOS? I haven't done that myself, but I thought he had a way...I hope.

To test this as if it is a new installation of Keyman, you must first remove all mention of Keyman from System Preferences, Security & Privacy, before removing the actual Keyman app:

image

It is shown above in Accessibility, but it may also be listed under Input Monitoring and Full Disk Access or Files and Folders. Even though it is unchecked as shown, it must be deleted from the list. If Keyman is listed here and the app is then deleted from disk, then it will also disappear from all Security & Privacy lists. However, this does not mean that all settings are gone; they may automatically reappear when you install Keyman again.

Therefore, you must manually remove all Keyman references from Security & Privacy before trashing the Keyman app itself.

Let me know if you want to meet and go over any of this. It's a little tricky, and I'm still not sure how the system handles permissions for different versions of the same app.

bharanidharanj commented 1 year ago

Hi @sgschantz , I am using macOS Monterey 12.6 version. Here, what I did is: Completely uninstalled the existing Keyman 16.0 from System Preferences / Keyboard / Input Sources. Then, I installed the attached PR build in the Mac OS. After installing it, I just clicked the keyman from the system tray and noticed that no dialog has been displayed on the screen.

Hence, the first test failed, I failed the other 2 tests. (since, I don't have the old version of macOS)

Could you please, guide me how to test this PR with macOS 12.6? Or how to move back to the Older version (like 10.10 and 10.15) of macOS from the current version? Thanks.

Hi @sgschantz , Thank you so much for your guidance. Now, I am able to see the 2 dialogs after installing the Keyman 16.0.70-alpah-test-7354 in macOS. I will do my further testing on it.

sgschantz commented 1 year ago

@keymanapp-test-bot retest TEST_ADD_ACCESS_WITH_CATALINA TEST_ADD_ACCESS_PRE_CATALINA TEST_DENY_ACCESS_AND_RESTART

bharanidharanj commented 1 year ago

After restarting MacOS, I am able to use the Shift layer. (ie., typing with the shift layer produces the corresponding output) Seems to be working as expected.

bharanidharanj commented 1 year ago
bharanidharanj commented 1 year ago
MakaraSok commented 1 year ago

@keymanapp-test-bot retest TEST_ADD_ACCESS_WITH_CATALINA TEST_ADD_ACCESS_PRE_CATALINA TEST_DENY_ACCESS_AND_RESTART

MakaraSok commented 1 year ago

Test Results

mcdurdin commented 1 year ago
  • TEST_DENY_ACCESS_AND_RESTART

@sgschantz, I think we should reorganise these tests using groups for the test bot.

GROUP_CATALINA: Using a version of macOS 10.15 or later GROUP_PRE_CATALINA: Using a version of macOS between 10.10 and 10.15

@MakaraSok, you marked the test as passing for TEST_ADD_ACCESS_WITH_CATALINA, but it seems like it wasn't working correctly?

after restarting:

  • press k, output ក​ (✅)
  • press K, output គ (✅)
  • press right alt+k, output ˚ (❌) - expected ឝ
  • press right alt+K, output  (❌) - expected ᧳
MakaraSok commented 1 year ago

The behaviors observes when testing with the current stable version (15.0.270).

Press k on the default, shift, right alt and right alt + shift output the following:

MakaraSok commented 1 year ago

@MakaraSok, you marked the test as passing for TEST_ADD_ACCESS_WITH_CATALINA, but it seems like it wasn't working correctly?

@mcdurdin It works as indicated in the instructions. Shift is not expected to be working before restarting, but is afterwards. In an essence, it's only fair to say it's PASSED, isn't it?

  1. Switch to a keyboard in Keyman and confirm that the default layer types correctly but shift has no effect on what is being typed.
  2. Try to use the OSK and confirm that clicking on the keys does work (but not the shift layer)
  3. Restart the Mac.
  4. Test Keyman again and confirm that the shift layer now works as expected.

The behaviors on the right alt and right alt+shift are extra observation while testing with Khmer Angkor with those layers utilized.

mcdurdin commented 1 year ago

The behaviors on the right alt and right alt+shift are extra observation while testing with Khmer Angkor with those layers utilized.

I see. Can you call those out as a separate issue then?

bharanidharanj commented 1 year ago

GROUP_CATALINA_AND_LATER: Using a version of macOS 10.15 or later

.. 2 dialogues..

..Shift Layer is working before I restarted the machine.

bharanidharanj commented 1 year ago

GROUP_CATALINA_AND_LATER: Using a version of macOS 10.15 or later

bharanidharanj commented 1 year ago

GROUP_CATALINA_AND_LATER: Using a version of macOS 10.15 or later

bharanidharanj commented 1 year ago

GROUP_PRE_CATALINA: Using a version of macOS before 10.15

bharanidharanj commented 1 year ago

GROUP_CATALINA_AND_LATER: Using a version of macOS 10.15 or later

MakaraSok commented 1 year ago

@keymanapp-test-bot retest all

I'd like to retest this as the behaviors experienced previously were not consistent.

MakaraSok commented 1 year ago

Test Results

GROUP_CATALINA_AND_LATER: Using a version of macOS 10.15 or later

Tested on a fresh macOS Big Sur 11.0.1 (20B29)

GROUP_PRE_CATALINA: Using a version of macOS before 10.15

Tested on a fresh macOS Mojave 10.14 (18A391)

keyman-server commented 1 year ago

Changes in this pull request will be available for download in Keyman version 16.0.86-alpha