diff options
| author | 2021-11-23 20:34:23 +0000 | |
|---|---|---|
| committer | 2021-11-23 20:34:23 +0000 | |
| commit | f66756826f0ae512ed4a244abdb9ab787e87e0fc (patch) | |
| tree | 27e3cbef909a279b6b25b9c66c8fb75eb8b86d3a | |
| parent | 12dd515b46ac9aab490e4536773030e30caa6f98 (diff) | |
| parent | 7563aa2b43e6ac7a2a3112ab2649edd291011e7d (diff) | |
Merge "Fix permission error of binding to TvInputService" am: e1215118ac am: 37c7128618 am: 7563aa2b43
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1895043
Change-Id: Ie4107b15587e65378583eec07e038b977cb2ca54
| -rwxr-xr-x | services/core/java/com/android/server/tv/TvInputManagerService.java | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java index b9ceec15c9ab..2f54f302af6c 100755 --- a/services/core/java/com/android/server/tv/TvInputManagerService.java +++ b/services/core/java/com/android/server/tv/TvInputManagerService.java @@ -2985,32 +2985,47 @@ public final class TvInputManagerService extends SystemService { public void addHardwareInput(int deviceId, TvInputInfo inputInfo) { ensureHardwarePermission(); ensureValidInput(inputInfo); - synchronized (mLock) { - mTvInputHardwareManager.addHardwareInput(deviceId, inputInfo); - addHardwareInputLocked(inputInfo); + final long identity = Binder.clearCallingIdentity(); + try { + synchronized (mLock) { + mTvInputHardwareManager.addHardwareInput(deviceId, inputInfo); + addHardwareInputLocked(inputInfo); + } + } finally { + Binder.restoreCallingIdentity(identity); } } public void addHdmiInput(int id, TvInputInfo inputInfo) { ensureHardwarePermission(); ensureValidInput(inputInfo); - synchronized (mLock) { - mTvInputHardwareManager.addHdmiInput(id, inputInfo); - addHardwareInputLocked(inputInfo); + final long identity = Binder.clearCallingIdentity(); + try { + synchronized (mLock) { + mTvInputHardwareManager.addHdmiInput(id, inputInfo); + addHardwareInputLocked(inputInfo); + } + } finally { + Binder.restoreCallingIdentity(identity); } } public void removeHardwareInput(String inputId) { ensureHardwarePermission(); - synchronized (mLock) { - ServiceState serviceState = getServiceStateLocked(mComponent, mUserId); - boolean removed = serviceState.hardwareInputMap.remove(inputId) != null; - if (removed) { - buildTvInputListLocked(mUserId, null); - mTvInputHardwareManager.removeHardwareInput(inputId); - } else { - Slog.e(TAG, "failed to remove input " + inputId); + final long identity = Binder.clearCallingIdentity(); + try { + synchronized (mLock) { + ServiceState serviceState = getServiceStateLocked(mComponent, mUserId); + boolean removed = serviceState.hardwareInputMap.remove(inputId) != null; + if (removed) { + buildTvInputListLocked(mUserId, null); + mTvInputHardwareManager.removeHardwareInput(inputId); + } else { + Slog.e(TAG, "failed to remove input " + inputId); + } } + } finally { + Binder.restoreCallingIdentity(identity); } } } |