Validate the user is allowed to set UiMode

UiMode is basically managed for the current user, and there were code
locations in UiModeManagerService that make assumptions of the
requesting user being the current user.
If non-current user attempts to set UiMode, the current user's UiMode
may be changed.
For example, in 'multi-user on multiple displays' mode in Automotive,
the passenger access may be mistaken as the driver access, and it leads
to interferes with the driver experience.
To fix this, verify the calling user to ensure that only valid user can
set the mode.

Bug: 319554832
Test: atest CtsAppTestCases:UiModeManagerTest
(cherry picked from
https://partner-android-review.git.corp.google.com/q/commit:41f6fb5cc5aac722c342b4d71b73415f78fc3f71)

Change-Id: I9c9defd7966f453962f4190d2778777ec27bf110
1 file changed