Loading core/java/android/hardware/hdmi/IHdmiCecService.aidl +0 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import android.os.IBinder; interface IHdmiCecService { IBinder allocateLogicalDevice(int type, IHdmiCecListener listener); void removeServiceListener(IBinder b, IHdmiCecListener listener); void setOsdName(IBinder b, String name); void sendActiveSource(IBinder b); void sendInactiveSource(IBinder b); void sendImageViewOn(IBinder b); Loading services/core/java/com/android/server/hdmi/HdmiCecDevice.java +0 −19 Original line number Diff line number Diff line Loading @@ -55,7 +55,6 @@ abstract class HdmiCecDevice { private final Binder mBinder = new Binder(); private final HdmiCecService mService; private String mName; private boolean mIsActiveSource; /** Loading Loading @@ -106,24 +105,6 @@ abstract class HdmiCecDevice { return mType; } /** * Set the name of the device. The name will be transferred via the message * <Set OSD Name> to other HDMI-CEC devices connected through HDMI * cables and shown on TV screen to identify the devicie. * * @param name name of the device */ public void setName(String name) { mName = name; } /** * Return the name of this device. */ public String getName() { return mName; } /** * Register a listener to be invoked when events occur. * Loading services/core/java/com/android/server/hdmi/HdmiCecService.java +10 −31 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.hardware.hdmi.HdmiCecMessage; import android.hardware.hdmi.IHdmiCecListener; import android.hardware.hdmi.IHdmiCecService; import android.os.Binder; import android.os.Build; import android.os.IBinder; import android.os.RemoteException; import android.text.TextUtils; Loading Loading @@ -76,6 +77,9 @@ public final class HdmiCecService extends SystemService { public void onStart() { mNativePtr = nativeInit(this); if (mNativePtr != 0) { // TODO: Consider using a dedicated, configurable identifier for OSD name, maybe from // Settings. It should be ASCII only, not a very long one (limited to 15 chars). setOsdNameLocked(Build.MODEL); publishBinderService(Context.HDMI_CEC_SERVICE, new BinderService()); } } Loading Loading @@ -138,22 +142,6 @@ public final class HdmiCecService extends SystemService { return HdmiCec.DEVICE_INACTIVE; } /** * Called by native when a request for the device OSD name was received. * The native part uses the return value to generate the message * <Set Osd Name> in response. */ private byte[] getOsdName(int type) { // TODO: Consider getting the OSD name from device name instead. synchronized (mLock) { HdmiCecDevice device = mLogicalDevices.get(type); if (device != null) { return device.getName().getBytes(Charset.forName("US-ASCII")); } } return null; } /** * Called by native when a request for the menu language of the device was * received. The native part uses the return value to generate the message Loading @@ -175,8 +163,7 @@ public final class HdmiCecService extends SystemService { synchronized (mLock) { for (int i = 0; i < mLogicalDevices.size(); ++i) { HdmiCecDevice device = mLogicalDevices.valueAt(i); pw.println("Device: name=" + device.getName() + ", type=" + device.getType() + pw.println("Device: type=" + device.getType() + ", active=" + device.isActiveSource()); } } Loading Loading @@ -211,6 +198,10 @@ public final class HdmiCecService extends SystemService { nativeSendMessage(mNativePtr, type, address, opcode, params); } private void setOsdNameLocked(String name) { nativeSetOsdName(mNativePtr, name.getBytes(Charset.forName("US-ASCII"))); } private final class ListenerRecord implements IBinder.DeathRecipient { private final IHdmiCecListener mListener; private final int mType; Loading Loading @@ -259,7 +250,6 @@ public final class HdmiCecService extends SystemService { Log.e(TAG, "Device type not supported yet."); return null; } device.setName(HdmiCec.getDefaultDeviceName(address)); device.initialize(); mLogicalDevices.put(type, device); } Loading @@ -282,18 +272,6 @@ public final class HdmiCecService extends SystemService { } } @Override public void setOsdName(IBinder b, String name) { enforceAccessPermission(); if (TextUtils.isEmpty(name)) { throw new IllegalArgumentException("name must not be null"); } synchronized (mLock) { HdmiCecDevice device = getLogicalDeviceLocked(b); device.setName(name); } } @Override public void sendActiveSource(IBinder b) { enforceAccessPermission(); Loading Loading @@ -408,4 +386,5 @@ public final class HdmiCecService extends SystemService { private static native void nativeSendMessage(long handler, int deviceType, int destination, int opcode, byte[] params); private static native int nativeGetPhysicalAddress(long handler); private static native void nativeSetOsdName(long handler, byte[] name); } services/core/jni/com_android_server_hdmi_HdmiCecService.cpp +20 −15 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ #include "ScopedPrimitiveArray.h" #include <cstring> #include <string> #include <deque> #include <map> Loading @@ -34,7 +34,6 @@ static struct { jmethodID handleMessage; jmethodID handleHotplug; jmethodID getActiveSource; jmethodID getOsdName; jmethodID getLanguage; } gHdmiCecServiceClassInfo; Loading Loading @@ -84,6 +83,7 @@ public: void sendSetMenuLanguage(cec_logical_address_t srcAddr, cec_logical_address_t dstAddr); void sendCecMessage(const cec_message_t& message); void setOsdName(const char* name, size_t len); private: enum { Loading Loading @@ -156,6 +156,7 @@ private: std::deque<MessageEntry> mMessageQueue; uint16_t mPhysicalAddress; std::string mOsdName; }; Loading Loading @@ -373,6 +374,10 @@ void HdmiCecHandler::sendCecMessage(const cec_message_t& message) { mDevice->send_message(mDevice, &message); } void HdmiCecHandler::setOsdName(const char* name, size_t len) { mOsdName.assign(name, min(len, CEC_MESSAGE_BODY_MAX_LENGTH - 1)); } // static void HdmiCecHandler::onReceived(const hdmi_event_t* event, void* arg) { HdmiCecHandler* handler = static_cast<HdmiCecHandler*>(arg); Loading Loading @@ -504,18 +509,9 @@ void HdmiCecHandler::handleRequestActiveSource() { } void HdmiCecHandler::handleGetOsdName(const cec_message_t& msg) { cec_logical_address_t addr = msg.destination; JNIEnv* env = AndroidRuntime::getJNIEnv(); jbyteArray res = (jbyteArray) env->CallObjectMethod(mCallbacksObj, gHdmiCecServiceClassInfo.getOsdName, getDeviceType(addr)); jbyte *name = env->GetByteArrayElements(res, NULL); if (name != NULL) { sendSetOsdName(addr, msg.initiator, reinterpret_cast<const char *>(name), env->GetArrayLength(res)); env->ReleaseByteArrayElements(res, name, JNI_ABORT); if (!mOsdName.empty()) { sendSetOsdName(msg.destination, msg.initiator, mOsdName.c_str(), mOsdName.length()); } checkAndClearExceptionFromCallback(env, __FUNCTION__); } void HdmiCecHandler::handleGiveDeviceVendorID(const cec_message_t& msg) { Loading Loading @@ -562,8 +558,6 @@ static jlong nativeInit(JNIEnv* env, jclass clazz, jobject callbacksObj) { "handleHotplug", "(Z)V"); GET_METHOD_ID(gHdmiCecServiceClassInfo.getActiveSource, clazz, "getActiveSource", "()I"); GET_METHOD_ID(gHdmiCecServiceClassInfo.getOsdName, clazz, "getOsdName", "(I)[B"); GET_METHOD_ID(gHdmiCecServiceClassInfo.getLanguage, clazz, "getLanguage", "(I)Ljava/lang/String;"); Loading Loading @@ -603,6 +597,15 @@ static jint nativeGetPhysicalAddress(JNIEnv* env, jclass clazz, jlong handlerPtr return handler->getPhysicalAddress(); } static void nativeSetOsdName(JNIEnv* env, jclass clazz, jlong handlerPtr, jbyteArray name) { HdmiCecHandler *handler = reinterpret_cast<HdmiCecHandler *>(handlerPtr); jsize len = env->GetArrayLength(name); if (len > 0) { ScopedByteArrayRO namePtr(env, name); handler->setOsdName(reinterpret_cast<const char *>(namePtr.get()), len); } } static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ { "nativeInit", "(Lcom/android/server/hdmi/HdmiCecService;)J", Loading @@ -615,6 +618,8 @@ static JNINativeMethod sMethods[] = { (void *)nativeRemoveLogicalAddress }, { "nativeGetPhysicalAddress", "(J)I", (void *)nativeGetPhysicalAddress }, { "nativeSetOsdName", "(J[B)V", (void *)nativeSetOsdName }, }; #define CLASS_PATH "com/android/server/hdmi/HdmiCecService" Loading Loading
core/java/android/hardware/hdmi/IHdmiCecService.aidl +0 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import android.os.IBinder; interface IHdmiCecService { IBinder allocateLogicalDevice(int type, IHdmiCecListener listener); void removeServiceListener(IBinder b, IHdmiCecListener listener); void setOsdName(IBinder b, String name); void sendActiveSource(IBinder b); void sendInactiveSource(IBinder b); void sendImageViewOn(IBinder b); Loading
services/core/java/com/android/server/hdmi/HdmiCecDevice.java +0 −19 Original line number Diff line number Diff line Loading @@ -55,7 +55,6 @@ abstract class HdmiCecDevice { private final Binder mBinder = new Binder(); private final HdmiCecService mService; private String mName; private boolean mIsActiveSource; /** Loading Loading @@ -106,24 +105,6 @@ abstract class HdmiCecDevice { return mType; } /** * Set the name of the device. The name will be transferred via the message * <Set OSD Name> to other HDMI-CEC devices connected through HDMI * cables and shown on TV screen to identify the devicie. * * @param name name of the device */ public void setName(String name) { mName = name; } /** * Return the name of this device. */ public String getName() { return mName; } /** * Register a listener to be invoked when events occur. * Loading
services/core/java/com/android/server/hdmi/HdmiCecService.java +10 −31 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.hardware.hdmi.HdmiCecMessage; import android.hardware.hdmi.IHdmiCecListener; import android.hardware.hdmi.IHdmiCecService; import android.os.Binder; import android.os.Build; import android.os.IBinder; import android.os.RemoteException; import android.text.TextUtils; Loading Loading @@ -76,6 +77,9 @@ public final class HdmiCecService extends SystemService { public void onStart() { mNativePtr = nativeInit(this); if (mNativePtr != 0) { // TODO: Consider using a dedicated, configurable identifier for OSD name, maybe from // Settings. It should be ASCII only, not a very long one (limited to 15 chars). setOsdNameLocked(Build.MODEL); publishBinderService(Context.HDMI_CEC_SERVICE, new BinderService()); } } Loading Loading @@ -138,22 +142,6 @@ public final class HdmiCecService extends SystemService { return HdmiCec.DEVICE_INACTIVE; } /** * Called by native when a request for the device OSD name was received. * The native part uses the return value to generate the message * <Set Osd Name> in response. */ private byte[] getOsdName(int type) { // TODO: Consider getting the OSD name from device name instead. synchronized (mLock) { HdmiCecDevice device = mLogicalDevices.get(type); if (device != null) { return device.getName().getBytes(Charset.forName("US-ASCII")); } } return null; } /** * Called by native when a request for the menu language of the device was * received. The native part uses the return value to generate the message Loading @@ -175,8 +163,7 @@ public final class HdmiCecService extends SystemService { synchronized (mLock) { for (int i = 0; i < mLogicalDevices.size(); ++i) { HdmiCecDevice device = mLogicalDevices.valueAt(i); pw.println("Device: name=" + device.getName() + ", type=" + device.getType() + pw.println("Device: type=" + device.getType() + ", active=" + device.isActiveSource()); } } Loading Loading @@ -211,6 +198,10 @@ public final class HdmiCecService extends SystemService { nativeSendMessage(mNativePtr, type, address, opcode, params); } private void setOsdNameLocked(String name) { nativeSetOsdName(mNativePtr, name.getBytes(Charset.forName("US-ASCII"))); } private final class ListenerRecord implements IBinder.DeathRecipient { private final IHdmiCecListener mListener; private final int mType; Loading Loading @@ -259,7 +250,6 @@ public final class HdmiCecService extends SystemService { Log.e(TAG, "Device type not supported yet."); return null; } device.setName(HdmiCec.getDefaultDeviceName(address)); device.initialize(); mLogicalDevices.put(type, device); } Loading @@ -282,18 +272,6 @@ public final class HdmiCecService extends SystemService { } } @Override public void setOsdName(IBinder b, String name) { enforceAccessPermission(); if (TextUtils.isEmpty(name)) { throw new IllegalArgumentException("name must not be null"); } synchronized (mLock) { HdmiCecDevice device = getLogicalDeviceLocked(b); device.setName(name); } } @Override public void sendActiveSource(IBinder b) { enforceAccessPermission(); Loading Loading @@ -408,4 +386,5 @@ public final class HdmiCecService extends SystemService { private static native void nativeSendMessage(long handler, int deviceType, int destination, int opcode, byte[] params); private static native int nativeGetPhysicalAddress(long handler); private static native void nativeSetOsdName(long handler, byte[] name); }
services/core/jni/com_android_server_hdmi_HdmiCecService.cpp +20 −15 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ #include "ScopedPrimitiveArray.h" #include <cstring> #include <string> #include <deque> #include <map> Loading @@ -34,7 +34,6 @@ static struct { jmethodID handleMessage; jmethodID handleHotplug; jmethodID getActiveSource; jmethodID getOsdName; jmethodID getLanguage; } gHdmiCecServiceClassInfo; Loading Loading @@ -84,6 +83,7 @@ public: void sendSetMenuLanguage(cec_logical_address_t srcAddr, cec_logical_address_t dstAddr); void sendCecMessage(const cec_message_t& message); void setOsdName(const char* name, size_t len); private: enum { Loading Loading @@ -156,6 +156,7 @@ private: std::deque<MessageEntry> mMessageQueue; uint16_t mPhysicalAddress; std::string mOsdName; }; Loading Loading @@ -373,6 +374,10 @@ void HdmiCecHandler::sendCecMessage(const cec_message_t& message) { mDevice->send_message(mDevice, &message); } void HdmiCecHandler::setOsdName(const char* name, size_t len) { mOsdName.assign(name, min(len, CEC_MESSAGE_BODY_MAX_LENGTH - 1)); } // static void HdmiCecHandler::onReceived(const hdmi_event_t* event, void* arg) { HdmiCecHandler* handler = static_cast<HdmiCecHandler*>(arg); Loading Loading @@ -504,18 +509,9 @@ void HdmiCecHandler::handleRequestActiveSource() { } void HdmiCecHandler::handleGetOsdName(const cec_message_t& msg) { cec_logical_address_t addr = msg.destination; JNIEnv* env = AndroidRuntime::getJNIEnv(); jbyteArray res = (jbyteArray) env->CallObjectMethod(mCallbacksObj, gHdmiCecServiceClassInfo.getOsdName, getDeviceType(addr)); jbyte *name = env->GetByteArrayElements(res, NULL); if (name != NULL) { sendSetOsdName(addr, msg.initiator, reinterpret_cast<const char *>(name), env->GetArrayLength(res)); env->ReleaseByteArrayElements(res, name, JNI_ABORT); if (!mOsdName.empty()) { sendSetOsdName(msg.destination, msg.initiator, mOsdName.c_str(), mOsdName.length()); } checkAndClearExceptionFromCallback(env, __FUNCTION__); } void HdmiCecHandler::handleGiveDeviceVendorID(const cec_message_t& msg) { Loading Loading @@ -562,8 +558,6 @@ static jlong nativeInit(JNIEnv* env, jclass clazz, jobject callbacksObj) { "handleHotplug", "(Z)V"); GET_METHOD_ID(gHdmiCecServiceClassInfo.getActiveSource, clazz, "getActiveSource", "()I"); GET_METHOD_ID(gHdmiCecServiceClassInfo.getOsdName, clazz, "getOsdName", "(I)[B"); GET_METHOD_ID(gHdmiCecServiceClassInfo.getLanguage, clazz, "getLanguage", "(I)Ljava/lang/String;"); Loading Loading @@ -603,6 +597,15 @@ static jint nativeGetPhysicalAddress(JNIEnv* env, jclass clazz, jlong handlerPtr return handler->getPhysicalAddress(); } static void nativeSetOsdName(JNIEnv* env, jclass clazz, jlong handlerPtr, jbyteArray name) { HdmiCecHandler *handler = reinterpret_cast<HdmiCecHandler *>(handlerPtr); jsize len = env->GetArrayLength(name); if (len > 0) { ScopedByteArrayRO namePtr(env, name); handler->setOsdName(reinterpret_cast<const char *>(namePtr.get()), len); } } static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ { "nativeInit", "(Lcom/android/server/hdmi/HdmiCecService;)J", Loading @@ -615,6 +618,8 @@ static JNINativeMethod sMethods[] = { (void *)nativeRemoveLogicalAddress }, { "nativeGetPhysicalAddress", "(J)I", (void *)nativeGetPhysicalAddress }, { "nativeSetOsdName", "(J[B)V", (void *)nativeSetOsdName }, }; #define CLASS_PATH "com/android/server/hdmi/HdmiCecService" Loading