Loading services/core/java/com/android/server/hdmi/HdmiControlService.java +8 −14 Original line number Diff line number Diff line Loading @@ -207,10 +207,10 @@ public final class HdmiControlService extends SystemService { private List<HdmiPortInfo> mPortInfo; // Map from path(physical address) to port ID. private final SparseIntArray mPortIdMap = new SparseIntArray(); private UnmodifiableSparseIntArray mPortIdMap; // Map from port ID to HdmiPortInfo. private final SparseArray<HdmiPortInfo> mPortInfoMap = new SparseArray<>(); private UnmodifiableSparseArray<HdmiPortInfo> mPortInfoMap; private HdmiCecMessageValidator mMessageValidator; Loading Loading @@ -360,10 +360,14 @@ public final class HdmiControlService extends SystemService { return; } SparseArray<HdmiPortInfo> portInfoMap = new SparseArray<>(); SparseIntArray portIdMap = new SparseIntArray(); for (HdmiPortInfo info : cecPortInfo) { mPortIdMap.put(info.getAddress(), info.getId()); mPortInfoMap.put(info.getId(), info); portIdMap.put(info.getAddress(), info.getId()); portInfoMap.put(info.getId(), info); } mPortIdMap = new UnmodifiableSparseIntArray(portIdMap); mPortInfoMap = new UnmodifiableSparseArray<>(portInfoMap); if (mMhlController == null) { mPortInfo = Collections.unmodifiableList(Arrays.asList(cecPortInfo)); Loading Loading @@ -397,9 +401,7 @@ public final class HdmiControlService extends SystemService { * @param portId HDMI port id * @return {@link HdmiPortInfo} for the given port */ @ServiceThreadOnly HdmiPortInfo getPortInfo(int portId) { assertRunOnServiceThread(); return mPortInfoMap.get(portId, null); } Loading @@ -407,9 +409,7 @@ public final class HdmiControlService extends SystemService { * Returns the routing path (physical address) of the HDMI port for the given * port id. */ @ServiceThreadOnly int portIdToPath(int portId) { assertRunOnServiceThread(); HdmiPortInfo portInfo = getPortInfo(portId); if (portInfo == null) { Slog.e(TAG, "Cannot find the port info: " + portId); Loading @@ -424,16 +424,12 @@ public final class HdmiControlService extends SystemService { * the port id to be returned is the ID associated with the port address * 0x1000 (1.0.0.0) which is the topmost path of the given routing path. */ @ServiceThreadOnly int pathToPortId(int path) { assertRunOnServiceThread(); int portAddress = path & Constants.ROUTING_PATH_TOP_MASK; return mPortIdMap.get(portAddress, Constants.INVALID_PORT_ID); } @ServiceThreadOnly boolean isValidPortId(int portId) { assertRunOnServiceThread(); return getPortInfo(portId) != null; } Loading Loading @@ -490,9 +486,7 @@ public final class HdmiControlService extends SystemService { /** * Whether a device of the specified physical address is connected to ARC enabled port. */ @ServiceThreadOnly boolean isConnectedToArcPort(int physicalAddress) { assertRunOnServiceThread(); int portId = mPortIdMap.get(physicalAddress); if (portId != Constants.INVALID_PORT_ID) { return mPortInfoMap.get(portId).isArcSupported(); Loading services/core/java/com/android/server/hdmi/UnmodifiableSparseArray.java 0 → 100644 +62 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.hdmi; import android.util.SparseArray; /** * Unmodifiable version of {@link SparseArray}. */ final class UnmodifiableSparseArray<E> { private static final String TAG = "ImmutableSparseArray"; private final SparseArray<E> mArray; public UnmodifiableSparseArray(SparseArray<E> array) { mArray = array; } public int size() { return mArray.size(); } public E get(int key) { return mArray.get(key); } public E get(int key, E valueIfKeyNotFound) { return mArray.get(key, valueIfKeyNotFound); } public int keyAt(int index) { return mArray.keyAt(index); } public E valueAt(int index) { return mArray.valueAt(index); } public int indexOfValue(E value) { return mArray.indexOfValue(value); } @Override public String toString() { return mArray.toString(); } } services/core/java/com/android/server/hdmi/UnmodifiableSparseIntArray.java 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.hdmi; import android.util.SparseIntArray; /** * Unmodifiable version of {@link SparseIntArray}. */ final class UnmodifiableSparseIntArray { private static final String TAG = "ImmutableSparseIntArray"; private final SparseIntArray mArray; public UnmodifiableSparseIntArray(SparseIntArray array) { mArray = array; } public int size() { return mArray.size(); } public int get(int key) { return mArray.get(key); } public int get(int key, int valueIfKeyNotFound) { return mArray.get(key, valueIfKeyNotFound); } public int keyAt(int index) { return mArray.keyAt(index); } public int valueAt(int index) { return mArray.valueAt(index); } public int indexOfValue(int value) { return mArray.indexOfValue(value); } @Override public String toString() { return mArray.toString(); } } Loading
services/core/java/com/android/server/hdmi/HdmiControlService.java +8 −14 Original line number Diff line number Diff line Loading @@ -207,10 +207,10 @@ public final class HdmiControlService extends SystemService { private List<HdmiPortInfo> mPortInfo; // Map from path(physical address) to port ID. private final SparseIntArray mPortIdMap = new SparseIntArray(); private UnmodifiableSparseIntArray mPortIdMap; // Map from port ID to HdmiPortInfo. private final SparseArray<HdmiPortInfo> mPortInfoMap = new SparseArray<>(); private UnmodifiableSparseArray<HdmiPortInfo> mPortInfoMap; private HdmiCecMessageValidator mMessageValidator; Loading Loading @@ -360,10 +360,14 @@ public final class HdmiControlService extends SystemService { return; } SparseArray<HdmiPortInfo> portInfoMap = new SparseArray<>(); SparseIntArray portIdMap = new SparseIntArray(); for (HdmiPortInfo info : cecPortInfo) { mPortIdMap.put(info.getAddress(), info.getId()); mPortInfoMap.put(info.getId(), info); portIdMap.put(info.getAddress(), info.getId()); portInfoMap.put(info.getId(), info); } mPortIdMap = new UnmodifiableSparseIntArray(portIdMap); mPortInfoMap = new UnmodifiableSparseArray<>(portInfoMap); if (mMhlController == null) { mPortInfo = Collections.unmodifiableList(Arrays.asList(cecPortInfo)); Loading Loading @@ -397,9 +401,7 @@ public final class HdmiControlService extends SystemService { * @param portId HDMI port id * @return {@link HdmiPortInfo} for the given port */ @ServiceThreadOnly HdmiPortInfo getPortInfo(int portId) { assertRunOnServiceThread(); return mPortInfoMap.get(portId, null); } Loading @@ -407,9 +409,7 @@ public final class HdmiControlService extends SystemService { * Returns the routing path (physical address) of the HDMI port for the given * port id. */ @ServiceThreadOnly int portIdToPath(int portId) { assertRunOnServiceThread(); HdmiPortInfo portInfo = getPortInfo(portId); if (portInfo == null) { Slog.e(TAG, "Cannot find the port info: " + portId); Loading @@ -424,16 +424,12 @@ public final class HdmiControlService extends SystemService { * the port id to be returned is the ID associated with the port address * 0x1000 (1.0.0.0) which is the topmost path of the given routing path. */ @ServiceThreadOnly int pathToPortId(int path) { assertRunOnServiceThread(); int portAddress = path & Constants.ROUTING_PATH_TOP_MASK; return mPortIdMap.get(portAddress, Constants.INVALID_PORT_ID); } @ServiceThreadOnly boolean isValidPortId(int portId) { assertRunOnServiceThread(); return getPortInfo(portId) != null; } Loading Loading @@ -490,9 +486,7 @@ public final class HdmiControlService extends SystemService { /** * Whether a device of the specified physical address is connected to ARC enabled port. */ @ServiceThreadOnly boolean isConnectedToArcPort(int physicalAddress) { assertRunOnServiceThread(); int portId = mPortIdMap.get(physicalAddress); if (portId != Constants.INVALID_PORT_ID) { return mPortInfoMap.get(portId).isArcSupported(); Loading
services/core/java/com/android/server/hdmi/UnmodifiableSparseArray.java 0 → 100644 +62 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.hdmi; import android.util.SparseArray; /** * Unmodifiable version of {@link SparseArray}. */ final class UnmodifiableSparseArray<E> { private static final String TAG = "ImmutableSparseArray"; private final SparseArray<E> mArray; public UnmodifiableSparseArray(SparseArray<E> array) { mArray = array; } public int size() { return mArray.size(); } public E get(int key) { return mArray.get(key); } public E get(int key, E valueIfKeyNotFound) { return mArray.get(key, valueIfKeyNotFound); } public int keyAt(int index) { return mArray.keyAt(index); } public E valueAt(int index) { return mArray.valueAt(index); } public int indexOfValue(E value) { return mArray.indexOfValue(value); } @Override public String toString() { return mArray.toString(); } }
services/core/java/com/android/server/hdmi/UnmodifiableSparseIntArray.java 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.hdmi; import android.util.SparseIntArray; /** * Unmodifiable version of {@link SparseIntArray}. */ final class UnmodifiableSparseIntArray { private static final String TAG = "ImmutableSparseIntArray"; private final SparseIntArray mArray; public UnmodifiableSparseIntArray(SparseIntArray array) { mArray = array; } public int size() { return mArray.size(); } public int get(int key) { return mArray.get(key); } public int get(int key, int valueIfKeyNotFound) { return mArray.get(key, valueIfKeyNotFound); } public int keyAt(int index) { return mArray.keyAt(index); } public int valueAt(int index) { return mArray.valueAt(index); } public int indexOfValue(int value) { return mArray.indexOfValue(value); } @Override public String toString() { return mArray.toString(); } }