use of android.media.tv.TvInputInfo in project android_frameworks_base by DirtyUnicorns.
the class TvInputHardwareManager method dump.
public void dump(FileDescriptor fd, final PrintWriter writer, String[] args) {
final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
pw.println("Permission Denial: can't dump TvInputHardwareManager from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
return;
}
synchronized (mLock) {
pw.println("TvInputHardwareManager Info:");
pw.increaseIndent();
pw.println("mConnections: deviceId -> Connection");
pw.increaseIndent();
for (int i = 0; i < mConnections.size(); i++) {
int deviceId = mConnections.keyAt(i);
Connection mConnection = mConnections.valueAt(i);
pw.println(deviceId + ": " + mConnection);
}
pw.decreaseIndent();
pw.println("mHardwareList:");
pw.increaseIndent();
for (TvInputHardwareInfo tvInputHardwareInfo : mHardwareList) {
pw.println(tvInputHardwareInfo);
}
pw.decreaseIndent();
pw.println("mHdmiDeviceList:");
pw.increaseIndent();
for (HdmiDeviceInfo hdmiDeviceInfo : mHdmiDeviceList) {
pw.println(hdmiDeviceInfo);
}
pw.decreaseIndent();
pw.println("mHardwareInputIdMap: deviceId -> inputId");
pw.increaseIndent();
for (int i = 0; i < mHardwareInputIdMap.size(); i++) {
int deviceId = mHardwareInputIdMap.keyAt(i);
String inputId = mHardwareInputIdMap.valueAt(i);
pw.println(deviceId + ": " + inputId);
}
pw.decreaseIndent();
pw.println("mHdmiInputIdMap: id -> inputId");
pw.increaseIndent();
for (int i = 0; i < mHdmiInputIdMap.size(); i++) {
int id = mHdmiInputIdMap.keyAt(i);
String inputId = mHdmiInputIdMap.valueAt(i);
pw.println(id + ": " + inputId);
}
pw.decreaseIndent();
pw.println("mInputMap: inputId -> inputInfo");
pw.increaseIndent();
for (Map.Entry<String, TvInputInfo> entry : mInputMap.entrySet()) {
pw.println(entry.getKey() + ": " + entry.getValue());
}
pw.decreaseIndent();
pw.decreaseIndent();
}
}
use of android.media.tv.TvInputInfo in project android_frameworks_base by ResurrectionRemix.
the class TvInputManagerService method buildTvInputListLocked.
private void buildTvInputListLocked(int userId, String[] updatedPackages) {
UserState userState = getOrCreateUserStateLocked(userId);
userState.packageSet.clear();
if (DEBUG)
Slog.d(TAG, "buildTvInputList");
PackageManager pm = mContext.getPackageManager();
List<ResolveInfo> services = pm.queryIntentServicesAsUser(new Intent(TvInputService.SERVICE_INTERFACE), PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, userId);
List<TvInputInfo> inputList = new ArrayList<>();
for (ResolveInfo ri : services) {
ServiceInfo si = ri.serviceInfo;
if (!android.Manifest.permission.BIND_TV_INPUT.equals(si.permission)) {
Slog.w(TAG, "Skipping TV input " + si.name + ": it does not require the permission " + android.Manifest.permission.BIND_TV_INPUT);
continue;
}
ComponentName component = new ComponentName(si.packageName, si.name);
if (hasHardwarePermission(pm, component)) {
ServiceState serviceState = userState.serviceStateMap.get(component);
if (serviceState == null) {
// New hardware input found. Create a new ServiceState and connect to the
// service to populate the hardware list.
serviceState = new ServiceState(component, userId);
userState.serviceStateMap.put(component, serviceState);
updateServiceConnectionLocked(component, userId);
} else {
inputList.addAll(serviceState.hardwareInputList);
}
} else {
try {
TvInputInfo info = new TvInputInfo.Builder(mContext, ri).build();
inputList.add(info);
} catch (Exception e) {
Slog.e(TAG, "failed to load TV input " + si.name, e);
continue;
}
}
userState.packageSet.add(si.packageName);
}
Map<String, TvInputState> inputMap = new HashMap<>();
for (TvInputInfo info : inputList) {
if (DEBUG) {
Slog.d(TAG, "add " + info.getId());
}
TvInputState inputState = userState.inputMap.get(info.getId());
if (inputState == null) {
inputState = new TvInputState();
}
inputState.info = info;
inputMap.put(info.getId(), inputState);
}
for (String inputId : inputMap.keySet()) {
if (!userState.inputMap.containsKey(inputId)) {
notifyInputAddedLocked(userState, inputId);
} else if (updatedPackages != null) {
// Notify the package updates
ComponentName component = inputMap.get(inputId).info.getComponent();
for (String updatedPackage : updatedPackages) {
if (component.getPackageName().equals(updatedPackage)) {
updateServiceConnectionLocked(component, userId);
notifyInputUpdatedLocked(userState, inputId);
break;
}
}
}
}
for (String inputId : userState.inputMap.keySet()) {
if (!inputMap.containsKey(inputId)) {
TvInputInfo info = userState.inputMap.get(inputId).info;
ServiceState serviceState = userState.serviceStateMap.get(info.getComponent());
if (serviceState != null) {
abortPendingCreateSessionRequestsLocked(serviceState, inputId, userId);
}
notifyInputRemovedLocked(userState, inputId);
}
}
userState.inputMap.clear();
userState.inputMap = inputMap;
}
use of android.media.tv.TvInputInfo in project android_frameworks_base by crdroidandroid.
the class TvInputManagerService method buildTvInputListLocked.
private void buildTvInputListLocked(int userId, String[] updatedPackages) {
UserState userState = getOrCreateUserStateLocked(userId);
userState.packageSet.clear();
if (DEBUG)
Slog.d(TAG, "buildTvInputList");
PackageManager pm = mContext.getPackageManager();
List<ResolveInfo> services = pm.queryIntentServicesAsUser(new Intent(TvInputService.SERVICE_INTERFACE), PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, userId);
List<TvInputInfo> inputList = new ArrayList<>();
for (ResolveInfo ri : services) {
ServiceInfo si = ri.serviceInfo;
if (!android.Manifest.permission.BIND_TV_INPUT.equals(si.permission)) {
Slog.w(TAG, "Skipping TV input " + si.name + ": it does not require the permission " + android.Manifest.permission.BIND_TV_INPUT);
continue;
}
ComponentName component = new ComponentName(si.packageName, si.name);
if (hasHardwarePermission(pm, component)) {
ServiceState serviceState = userState.serviceStateMap.get(component);
if (serviceState == null) {
// New hardware input found. Create a new ServiceState and connect to the
// service to populate the hardware list.
serviceState = new ServiceState(component, userId);
userState.serviceStateMap.put(component, serviceState);
updateServiceConnectionLocked(component, userId);
} else {
inputList.addAll(serviceState.hardwareInputList);
}
} else {
try {
TvInputInfo info = new TvInputInfo.Builder(mContext, ri).build();
inputList.add(info);
} catch (Exception e) {
Slog.e(TAG, "failed to load TV input " + si.name, e);
continue;
}
}
userState.packageSet.add(si.packageName);
}
Map<String, TvInputState> inputMap = new HashMap<>();
for (TvInputInfo info : inputList) {
if (DEBUG) {
Slog.d(TAG, "add " + info.getId());
}
TvInputState inputState = userState.inputMap.get(info.getId());
if (inputState == null) {
inputState = new TvInputState();
}
inputState.info = info;
inputMap.put(info.getId(), inputState);
}
for (String inputId : inputMap.keySet()) {
if (!userState.inputMap.containsKey(inputId)) {
notifyInputAddedLocked(userState, inputId);
} else if (updatedPackages != null) {
// Notify the package updates
ComponentName component = inputMap.get(inputId).info.getComponent();
for (String updatedPackage : updatedPackages) {
if (component.getPackageName().equals(updatedPackage)) {
updateServiceConnectionLocked(component, userId);
notifyInputUpdatedLocked(userState, inputId);
break;
}
}
}
}
for (String inputId : userState.inputMap.keySet()) {
if (!inputMap.containsKey(inputId)) {
TvInputInfo info = userState.inputMap.get(inputId).info;
ServiceState serviceState = userState.serviceStateMap.get(info.getComponent());
if (serviceState != null) {
abortPendingCreateSessionRequestsLocked(serviceState, inputId, userId);
}
notifyInputRemovedLocked(userState, inputId);
}
}
userState.inputMap.clear();
userState.inputMap = inputMap;
}
use of android.media.tv.TvInputInfo in project android_frameworks_base by crdroidandroid.
the class TvInputHardwareManager method dump.
public void dump(FileDescriptor fd, final PrintWriter writer, String[] args) {
final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
pw.println("Permission Denial: can't dump TvInputHardwareManager from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
return;
}
synchronized (mLock) {
pw.println("TvInputHardwareManager Info:");
pw.increaseIndent();
pw.println("mConnections: deviceId -> Connection");
pw.increaseIndent();
for (int i = 0; i < mConnections.size(); i++) {
int deviceId = mConnections.keyAt(i);
Connection mConnection = mConnections.valueAt(i);
pw.println(deviceId + ": " + mConnection);
}
pw.decreaseIndent();
pw.println("mHardwareList:");
pw.increaseIndent();
for (TvInputHardwareInfo tvInputHardwareInfo : mHardwareList) {
pw.println(tvInputHardwareInfo);
}
pw.decreaseIndent();
pw.println("mHdmiDeviceList:");
pw.increaseIndent();
for (HdmiDeviceInfo hdmiDeviceInfo : mHdmiDeviceList) {
pw.println(hdmiDeviceInfo);
}
pw.decreaseIndent();
pw.println("mHardwareInputIdMap: deviceId -> inputId");
pw.increaseIndent();
for (int i = 0; i < mHardwareInputIdMap.size(); i++) {
int deviceId = mHardwareInputIdMap.keyAt(i);
String inputId = mHardwareInputIdMap.valueAt(i);
pw.println(deviceId + ": " + inputId);
}
pw.decreaseIndent();
pw.println("mHdmiInputIdMap: id -> inputId");
pw.increaseIndent();
for (int i = 0; i < mHdmiInputIdMap.size(); i++) {
int id = mHdmiInputIdMap.keyAt(i);
String inputId = mHdmiInputIdMap.valueAt(i);
pw.println(id + ": " + inputId);
}
pw.decreaseIndent();
pw.println("mInputMap: inputId -> inputInfo");
pw.increaseIndent();
for (Map.Entry<String, TvInputInfo> entry : mInputMap.entrySet()) {
pw.println(entry.getKey() + ": " + entry.getValue());
}
pw.decreaseIndent();
pw.decreaseIndent();
}
}
use of android.media.tv.TvInputInfo in project platform_frameworks_base by android.
the class TvInputHardwareManager method dump.
public void dump(FileDescriptor fd, final PrintWriter writer, String[] args) {
final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
pw.println("Permission Denial: can't dump TvInputHardwareManager from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
return;
}
synchronized (mLock) {
pw.println("TvInputHardwareManager Info:");
pw.increaseIndent();
pw.println("mConnections: deviceId -> Connection");
pw.increaseIndent();
for (int i = 0; i < mConnections.size(); i++) {
int deviceId = mConnections.keyAt(i);
Connection mConnection = mConnections.valueAt(i);
pw.println(deviceId + ": " + mConnection);
}
pw.decreaseIndent();
pw.println("mHardwareList:");
pw.increaseIndent();
for (TvInputHardwareInfo tvInputHardwareInfo : mHardwareList) {
pw.println(tvInputHardwareInfo);
}
pw.decreaseIndent();
pw.println("mHdmiDeviceList:");
pw.increaseIndent();
for (HdmiDeviceInfo hdmiDeviceInfo : mHdmiDeviceList) {
pw.println(hdmiDeviceInfo);
}
pw.decreaseIndent();
pw.println("mHardwareInputIdMap: deviceId -> inputId");
pw.increaseIndent();
for (int i = 0; i < mHardwareInputIdMap.size(); i++) {
int deviceId = mHardwareInputIdMap.keyAt(i);
String inputId = mHardwareInputIdMap.valueAt(i);
pw.println(deviceId + ": " + inputId);
}
pw.decreaseIndent();
pw.println("mHdmiInputIdMap: id -> inputId");
pw.increaseIndent();
for (int i = 0; i < mHdmiInputIdMap.size(); i++) {
int id = mHdmiInputIdMap.keyAt(i);
String inputId = mHdmiInputIdMap.valueAt(i);
pw.println(id + ": " + inputId);
}
pw.decreaseIndent();
pw.println("mInputMap: inputId -> inputInfo");
pw.increaseIndent();
for (Map.Entry<String, TvInputInfo> entry : mInputMap.entrySet()) {
pw.println(entry.getKey() + ": " + entry.getValue());
}
pw.decreaseIndent();
pw.decreaseIndent();
}
}
Aggregations