Merge "Fix permission error of binding to TvInputService" am: e1215118ac am: 37c7128618

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1895043

Change-Id: I140d08f04861a25868320a26f5887ad11f107bdd
This commit is contained in:
Henry Fang
2021-11-23 20:22:48 +00:00
committed by Automerger Merge Worker

View File

@@ -2985,32 +2985,47 @@ public final class TvInputManagerService extends SystemService {
public void addHardwareInput(int deviceId, TvInputInfo inputInfo) { public void addHardwareInput(int deviceId, TvInputInfo inputInfo) {
ensureHardwarePermission(); ensureHardwarePermission();
ensureValidInput(inputInfo); ensureValidInput(inputInfo);
synchronized (mLock) { final long identity = Binder.clearCallingIdentity();
mTvInputHardwareManager.addHardwareInput(deviceId, inputInfo); try {
addHardwareInputLocked(inputInfo); synchronized (mLock) {
mTvInputHardwareManager.addHardwareInput(deviceId, inputInfo);
addHardwareInputLocked(inputInfo);
}
} finally {
Binder.restoreCallingIdentity(identity);
} }
} }
public void addHdmiInput(int id, TvInputInfo inputInfo) { public void addHdmiInput(int id, TvInputInfo inputInfo) {
ensureHardwarePermission(); ensureHardwarePermission();
ensureValidInput(inputInfo); ensureValidInput(inputInfo);
synchronized (mLock) { final long identity = Binder.clearCallingIdentity();
mTvInputHardwareManager.addHdmiInput(id, inputInfo); try {
addHardwareInputLocked(inputInfo); synchronized (mLock) {
mTvInputHardwareManager.addHdmiInput(id, inputInfo);
addHardwareInputLocked(inputInfo);
}
} finally {
Binder.restoreCallingIdentity(identity);
} }
} }
public void removeHardwareInput(String inputId) { public void removeHardwareInput(String inputId) {
ensureHardwarePermission(); ensureHardwarePermission();
synchronized (mLock) { final long identity = Binder.clearCallingIdentity();
ServiceState serviceState = getServiceStateLocked(mComponent, mUserId); try {
boolean removed = serviceState.hardwareInputMap.remove(inputId) != null; synchronized (mLock) {
if (removed) { ServiceState serviceState = getServiceStateLocked(mComponent, mUserId);
buildTvInputListLocked(mUserId, null); boolean removed = serviceState.hardwareInputMap.remove(inputId) != null;
mTvInputHardwareManager.removeHardwareInput(inputId); if (removed) {
} else { buildTvInputListLocked(mUserId, null);
Slog.e(TAG, "failed to remove input " + inputId); mTvInputHardwareManager.removeHardwareInput(inputId);
} else {
Slog.e(TAG, "failed to remove input " + inputId);
}
} }
} finally {
Binder.restoreCallingIdentity(identity);
} }
} }
} }