summaryrefslogtreecommitdiff
authorTellen Yu <tellen.yu@amlogic.com>2017-09-25 10:56:57 (GMT)
committer Baocheng Sun <baocheng.sun@amlogic.com>2017-10-31 08:12:07 (GMT)
commit435ff173bd08cfe9939b4b044ad646d6d075855e (patch)
tree2b893634390899c062d717d16def4f1f49b5d83f
parent9619e7c53e6837decea8002caf01c59710709dad (diff)
downloadframeworks-435ff173bd08cfe9939b4b044ad646d6d075855e.zip
frameworks-435ff173bd08cfe9939b4b044ad646d6d075855e.tar.gz
frameworks-435ff173bd08cfe9939b4b044ad646d6d075855e.tar.bz2
treble: enable full treble mode [2/9]
PD# 151674 hdmicec daemon use hwbinder instead of binder Change-Id: I8d1dfacc703ba670d3f33dc0cfc2f117bc6c0e5f
Diffstat
-rw-r--r--core/java/Android.mk7
-rw-r--r--core/java/com/droidlogic/app/SystemControlEvent.java18
-rw-r--r--core/java/com/droidlogic/app/SystemControlManager.java1281
-rw-r--r--core/jni/hdmi_cec/Android.mk1
-rw-r--r--core/jni/hdmi_cec/HdmiCecExtend.cpp44
-rw-r--r--core/res/AndroidManifest.xml3
-rw-r--r--core/res/src/com/droidlogic/HdmiCecExtend.java8
-rw-r--r--services/hdmicec/binder/Android.mk12
-rw-r--r--services/hdmicec/binder/HdmiCecHidlClient.cpp313
-rw-r--r--services/hdmicec/binder/HdmiCecHidlClient.h108
-rw-r--r--services/hdmicec/libhdmi_cec/HdmiCecControl.cpp266
-rw-r--r--services/hdmicec/libhdmi_cec/HdmiCecControl.h2
-rw-r--r--services/hdmicec/server/Android.mk21
-rw-r--r--services/hdmicec/server/DroidHdmiCec.cpp257
-rw-r--r--services/hdmicec/server/DroidHdmiCec.h88
-rw-r--r--services/hdmicec/server/hdmicecd.rc6
-rw-r--r--services/hdmicec/server/main.cpp22
-rw-r--r--services/hdmicec/server/main_hdmicec.cpp69
-rw-r--r--services/systemcontrol/Android.mk13
-rw-r--r--services/systemcontrol/DisplayMode.cpp2
-rw-r--r--services/systemcontrol/DisplayMode.h6
-rw-r--r--services/systemcontrol/SystemControl.cpp5
-rw-r--r--services/systemcontrol/SystemControlClient.cpp435
-rw-r--r--services/systemcontrol/SystemControlClient.h120
-rw-r--r--services/systemcontrol/SystemControlHal.cpp330
-rw-r--r--services/systemcontrol/SystemControlHal.h62
-rw-r--r--services/systemcontrol/SystemControlNotify.h39
-rw-r--r--services/systemcontrol/SystemControlService.cpp656
-rw-r--r--services/systemcontrol/SystemControlService.h132
-rw-r--r--services/systemcontrol/main_systemcontrol.cpp19
-rw-r--r--services/systemcontrol/systemcontrol.rc2
-rw-r--r--services/systemcontrol/ubootenv/Ubootenv.cpp2
32 files changed, 3358 insertions, 991 deletions
diff --git a/core/java/Android.mk b/core/java/Android.mk
index fc88d34..ddf945f 100644
--- a/core/java/Android.mk
+++ b/core/java/Android.mk
@@ -15,6 +15,13 @@ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26 && echo OK),OK)
LOCAL_PROPRIETARY_MODULE := true
endif
+LOCAL_JAVA_LIBRARIES := \
+ android.hidl.base-V1.0-java \
+ android.hidl.manager-V1.0-java
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ vendor.amlogic.hardware.systemcontrol-V1.0-java
+
include $(BUILD_JAVA_LIBRARY)
#copy xml to permissions directory
diff --git a/core/java/com/droidlogic/app/SystemControlEvent.java b/core/java/com/droidlogic/app/SystemControlEvent.java
index bb87e05..f0d83ac 100644
--- a/core/java/com/droidlogic/app/SystemControlEvent.java
+++ b/core/java/com/droidlogic/app/SystemControlEvent.java
@@ -5,22 +5,24 @@ import android.content.Intent;
import android.util.Log;
import android.media.AudioManager;
+import vendor.amlogic.hardware.systemcontrol.V1_0.ISystemControlCallback;
+
//this event from native system control service
-public class SystemControlEvent extends ISystemControlNotify.Stub {
+public class SystemControlEvent extends ISystemControlCallback.Stub {
private static final String TAG = "SystemControlEvent";
public static final String ACTION_SYSTEM_CONTROL_EVENT = "android.intent.action.SYSTEM_CONTROL_EVENT";
- public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED";
- public final static String EXTRA_HDMI_PLUGGED_STATE = "state";
+ public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED";
+ public final static String EXTRA_HDMI_PLUGGED_STATE = "state";
public static final String EVENT_TYPE = "event";
//must sync with DisplayMode.h
public static final int EVENT_OUTPUT_MODE_CHANGE = 0;
public static final int EVENT_DIGITAL_MODE_CHANGE = 1;
- public static final int EVENT_HDMI_PLUG_OUT = 2;
- public static final int EVENT_HDMI_PLUG_IN = 3;
- public static final int EVENT_HDMI_AUDIO_OUT = 4;
- public static final int EVENT_HDMI_AUDIO_IN = 5;
+ public static final int EVENT_HDMI_PLUG_OUT = 2;
+ public static final int EVENT_HDMI_PLUG_IN = 3;
+ public static final int EVENT_HDMI_AUDIO_OUT = 4;
+ public static final int EVENT_HDMI_AUDIO_IN = 5;
private Context mContext = null;
@@ -32,7 +34,7 @@ public class SystemControlEvent extends ISystemControlNotify.Stub {
}
@Override
- public void onEvent(int event) {
+ public void notifyCallback(int event) {
Log.i(TAG, "system control callback event: " + event);
Intent intent;
if (event == EVENT_HDMI_PLUG_OUT || event == EVENT_HDMI_PLUG_IN) {
diff --git a/core/java/com/droidlogic/app/SystemControlManager.java b/core/java/com/droidlogic/app/SystemControlManager.java
index dafc540..d1face1 100644
--- a/core/java/com/droidlogic/app/SystemControlManager.java
+++ b/core/java/com/droidlogic/app/SystemControlManager.java
@@ -2,10 +2,20 @@ package com.droidlogic.app;
import android.content.Context;
import android.os.IBinder;
+import android.os.HwBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;
+import java.util.NoSuchElementException;
+
+import android.hidl.manager.V1_0.IServiceManager;
+import android.hidl.manager.V1_0.IServiceNotification;
+import vendor.amlogic.hardware.systemcontrol.V1_0.ISystemControl;
+import vendor.amlogic.hardware.systemcontrol.V1_0.ISystemControlCallback;
+import vendor.amlogic.hardware.systemcontrol.V1_0.Result;
+import vendor.amlogic.hardware.systemcontrol.V1_0.DroidDisplayInfo;
+
public class SystemControlManager {
private static final String TAG = "SysControlManager";
@@ -16,537 +26,551 @@ public class SystemControlManager {
public static final int DISPLAY_TYPE_MBOX = 2;
public static final int DISPLAY_TYPE_TV = 3;
- //must sync with SystemControl.h
- public static final int FORMAT_3D_OFF = 0;
- public static final int FORMAT_3D_AUTO = 1;
- public static final int FORMAT_3D_SIDE_BY_SIDE = 2;
- public static final int FORMAT_3D_TOP_AND_BOTTOM = 3;
- public static final int FORMAT_3D_LINE_ALTERNATIVE = 4;
- public static final int FORMAT_3D_FRAME_ALTERNATIVE = 5;
- public static final int FORMAT_3D_TO_2D_LEFT_EYE = 6;
- public static final int FORMAT_3D_TO_2D_RIGHT_EYE = 7;
- public static final int FORMAT_3D_SIDE_BY_SIDE_FORCE = 8;
- public static final int FORMAT_3D_TOP_AND_BOTTOM_FORCE = 9;
-
- private static final String SYS_TOKEN = "droidlogic.ISystemControlService";
- private static final int REMOTE_EXCEPTION = -0xffff;
-
- private static final int GET_PROPERTY = IBinder.FIRST_CALL_TRANSACTION;
- private static final int GET_PROPERTY_STRING = IBinder.FIRST_CALL_TRANSACTION + 1;
- private static final int GET_PROPERTY_INT = IBinder.FIRST_CALL_TRANSACTION + 2;
- private static final int GET_PROPERTY_LONG = IBinder.FIRST_CALL_TRANSACTION + 3;
- private static final int GET_PROPERTY_BOOL = IBinder.FIRST_CALL_TRANSACTION + 4;
- private static final int SET_PROPERTY = IBinder.FIRST_CALL_TRANSACTION + 5;
- private static final int READ_SYSFS = IBinder.FIRST_CALL_TRANSACTION + 6;
- private static final int WRITE_SYSFS = IBinder.FIRST_CALL_TRANSACTION + 7;
-
- private static final int GET_BOOT_ENV = IBinder.FIRST_CALL_TRANSACTION + 8;
- private static final int SET_BOOT_ENV = IBinder.FIRST_CALL_TRANSACTION + 9;
- private static final int GET_DISPLAY_INFO = IBinder.FIRST_CALL_TRANSACTION + 10;
- private static final int LOOP_MOUNT_UNMOUNT = IBinder.FIRST_CALL_TRANSACTION + 11;
-
- private static final int MBOX_OUTPUT_MODE = IBinder.FIRST_CALL_TRANSACTION + 12;
- private static final int OSD_MOUSE_MODE = IBinder.FIRST_CALL_TRANSACTION + 13;
- private static final int OSD_MOUSE_PARA = IBinder.FIRST_CALL_TRANSACTION + 14;
- private static final int SET_POSITION = IBinder.FIRST_CALL_TRANSACTION + 15;
- private static final int GET_POSITION = IBinder.FIRST_CALL_TRANSACTION + 16;
-
- private static final int REINIT = IBinder.FIRST_CALL_TRANSACTION + 17;
- private static final int SET_NATIVE_WIN_RECT = IBinder.FIRST_CALL_TRANSACTION + 18;
- private static final int SET_VIDEO_PLAYING = IBinder.FIRST_CALL_TRANSACTION + 19;
- private static final int SET_POWER_MODE = IBinder.FIRST_CALL_TRANSACTION + 20;
- private static final int INSTABOOT_RESET_DISPLAY = IBinder.FIRST_CALL_TRANSACTION + 21;
- private static final int SET_DIGITAL_MODE = IBinder.FIRST_CALL_TRANSACTION + 22;
- private static final int SET_3D_MODE = IBinder.FIRST_CALL_TRANSACTION + 23;
- private static final int SET_LISTENER = IBinder.FIRST_CALL_TRANSACTION + 24;
- private static final int INIT_3D_SETTING = IBinder.FIRST_CALL_TRANSACTION + 25;
- private static final int GET_VIDEO_3D_FORMAT = IBinder.FIRST_CALL_TRANSACTION + 26;
- private static final int GET_VIDEO_3DTO2D_FORMAT = IBinder.FIRST_CALL_TRANSACTION + 27;
- private static final int SET_VIDEO_3DTO2D_FORMAT = IBinder.FIRST_CALL_TRANSACTION + 28;
- private static final int SET_DISPLAY_3D_FORMAT = IBinder.FIRST_CALL_TRANSACTION + 29;
- private static final int GET_DISPLAY_3D_FORMAT = IBinder.FIRST_CALL_TRANSACTION + 30;
- private static final int SET_OSD_3D_FORMAT_HOLDER = IBinder.FIRST_CALL_TRANSACTION + 31;
- private static final int SET_OSD_3D_FORMAT = IBinder.FIRST_CALL_TRANSACTION + 32;
- private static final int SWITCH_3DTO2D = IBinder.FIRST_CALL_TRANSACTION + 33;
- private static final int SWITCH_2DTO3D = IBinder.FIRST_CALL_TRANSACTION + 34;
-
- private static final int WRITE_SYSFS_BIN = IBinder.FIRST_CALL_TRANSACTION + 36;
- private static final int READ_HDCPRX22_KEY = IBinder.FIRST_CALL_TRANSACTION + 37;
- private static final int WRITE_HDCPRX22_KEY = IBinder.FIRST_CALL_TRANSACTION + 38;
- private static final int READ_HDCPRX14_KEY = IBinder.FIRST_CALL_TRANSACTION + 39;
- private static final int WRITE_HDCPRX14_KEY = IBinder.FIRST_CALL_TRANSACTION + 40;
- private static final int WRITE_HDCPRX_IMG = IBinder.FIRST_CALL_TRANSACTION + 41;
- private static final int GET_SUPPORTED_DISPLAYMODE_LIST = IBinder.FIRST_CALL_TRANSACTION + 42;
- private static final int GET_ACTIVE_DISPLAYMODE = IBinder.FIRST_CALL_TRANSACTION + 43;
- private static final int SET_ACTIVE_DISPLAYMODE = IBinder.FIRST_CALL_TRANSACTION + 44;
- private static final int IS_AUTHSUCCESS = IBinder.FIRST_CALL_TRANSACTION + 45;
-
- //add get/save deep color
- private static final int SAVE_DEEP_COLOR_ATTR = IBinder.FIRST_CALL_TRANSACTION + 46;
- private static final int GET_DEEP_COLOR_ATTR = IBinder.FIRST_CALL_TRANSACTION + 47;
- private static final int SINK_OUTPUT_MODE = IBinder.FIRST_CALL_TRANSACTION + 48;
-
- private static final int WRITE_UNIFY_KEY = IBinder.FIRST_CALL_TRANSACTION + 49;
- private static final int READ_UNIFY_KEY = IBinder.FIRST_CALL_TRANSACTION + 50;
-
- //set deep color
- private static final int SET_DOLBY_VISION = IBinder.FIRST_CALL_TRANSACTION + 51;
- private static final int TV_SUPPORT_DOLBY_VISION = IBinder.FIRST_CALL_TRANSACTION + 52;
-
- private static final int RESOLVE_RESOLUTION_VALUE = IBinder.FIRST_CALL_TRANSACTION + 53;
-
- //set HDR mode and SDR mode
- private static final int SET_HDR_MODE = IBinder.FIRST_CALL_TRANSACTION + 54;
- private static final int SET_SDR_MODE = IBinder.FIRST_CALL_TRANSACTION + 55;
+ private ISystemControl mProxy = null;
+
+ // Notification object used to listen to the start of the system control daemon.
+ private final ServiceNotification mServiceNotification = new ServiceNotification();
+
+ private static final int SYSTEM_CONTROL_DEATH_COOKIE = 1000;
private Context mContext;
private IBinder mIBinder = null;
- public SystemControlManager(Context context){
+
+ // Mutex for all mutable shared state.
+ private final Object mLock = new Object();
+
+ public SystemControlManager(Context context) {
mContext = context;
try {
- Object object = Class.forName("android.os.ServiceManager")
- .getMethod("getService", new Class[] { String.class })
- .invoke(null, new Object[] { "system_control" });
- mIBinder = (IBinder)object;
+ boolean ret = IServiceManager.getService()
+ .registerForNotifications("vendor.amlogic.hardware.systemcontrol@1.0::ISystemControl", "", mServiceNotification);
+ if (!ret) {
+ Log.e(TAG, "Failed to register service start notification");
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to register service start notification", e);
+ return;
}
- catch (Exception ex) {
- Log.e(TAG, "system control manager init fail:" + ex);
+ connectToProxy();
+ }
+
+ private void connectToProxy() {
+ synchronized (mLock) {
+ if (mProxy != null) {
+ return;
+ }
+
+ try {
+ mProxy = ISystemControl.getService();
+ mProxy.linkToDeath(new DeathRecipient(), SYSTEM_CONTROL_DEATH_COOKIE);
+ } catch (NoSuchElementException e) {
+ Log.e(TAG, "connectToProxy: system control service not found."
+ + " Did the service fail to start?", e);
+ } catch (RemoteException e) {
+ Log.e(TAG, "connectToProxy: system control service not responding", e);
+ }
}
}
public String getProperty(String prop) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(prop);
- mIBinder.transact(GET_PROPERTY, data, reply, 0);
- int result = reply.readInt();
- String value = reply.readString();
- reply.recycle();
- data.recycle();
- return value;
+ synchronized (mLock) {
+ Mutable<String> resultVal = new Mutable<>();
+ try {
+ mProxy.getProperty(prop, (int ret, String v) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ }
+ });
+ return resultVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "getProperty:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "getProperty:" + ex);
}
-
- return null;
+ return "";
}
public String getPropertyString(String prop, String def) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(prop);
- data.writeString(def);
- mIBinder.transact(GET_PROPERTY_STRING, data, reply, 0);
- int result = reply.readInt();
- String value = reply.readString();
- reply.recycle();
- data.recycle();
- return value;
+ synchronized (mLock) {
+ Mutable<String> resultVal = new Mutable<>();
+ try {
+ mProxy.getPropertyString(prop, def, (int ret, String v) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ }
+ });
+ return resultVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "getPropertyString:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "getPropertyString:" + ex);
}
- return null;
+ return "";
}
public int getPropertyInt(String prop, int def) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(prop);
- data.writeInt(def);
- mIBinder.transact(GET_PROPERTY_INT, data, reply, 0);
- int result = reply.readInt();
- reply.recycle();
- data.recycle();
- return result;
+ synchronized (mLock) {
+ Mutable<Integer> resultVal = new Mutable<>();
+ try {
+ mProxy.getPropertyInt(prop, def, (int ret, int v) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ }
+ });
+ return resultVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "getPropertyInt:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "getPropertyInt:" + ex);
}
return 0;
}
public long getPropertyLong(String prop, long def) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(prop);
- data.writeLong(def);
- mIBinder.transact(GET_PROPERTY_LONG, data, reply, 0);
- long result = reply.readLong();
- reply.recycle();
- data.recycle();
- return result;
+ synchronized (mLock) {
+ Mutable<Long> resultVal = new Mutable<>();
+ try {
+ mProxy.getPropertyLong(prop, def, (int ret, long v) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ }
+ });
+ return resultVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "getPropertyLong:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "getPropertyLong:" + ex);
}
return 0;
}
public boolean getPropertyBoolean(String prop, boolean def) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(prop);
- data.writeInt(def?1:0);
- mIBinder.transact(GET_PROPERTY_BOOL, data, reply, 0);
- int result = reply.readInt();
- reply.recycle();
- data.recycle();
- return result!=0;
+ synchronized (mLock) {
+ Mutable<Boolean> resultVal = new Mutable<>();
+ try {
+ mProxy.getPropertyBoolean(prop, def, (int ret, boolean v) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ }
+ });
+ return resultVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "getPropertyBoolean:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "getPropertyBoolean:" + ex);
}
return false;
}
public void setProperty(String prop, String val) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(prop);
- data.writeString(val);
- mIBinder.transact(SET_PROPERTY, data, reply, 0);
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ try {
+ mProxy.setProperty(prop, val);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setProperty:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "setProperty:" + ex);
}
}
public String readSysFs(String path) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(path);
- mIBinder.transact(READ_SYSFS, data, reply, 0);
- String value = reply.readString();
- reply.recycle();
- data.recycle();
- return value;
+ synchronized (mLock) {
+ Mutable<String> resultVal = new Mutable<>();
+ try {
+ mProxy.readSysfs(path, (int ret, String v) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ }
+ });
+ return resultVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "readSysFs:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "readSysFs:" + ex);
}
- return null;
+ return "";
}
public boolean writeSysFs(String path, String val) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(path);
- data.writeString(val);
- mIBinder.transact(WRITE_SYSFS, data, reply, 0);
- int result = reply.readInt();
- reply.recycle();
- data.recycle();
- return result!=0;
+ synchronized (mLock) {
+ try {
+ mProxy.writeSysfs(path, val);
+ } catch (RemoteException e) {
+ Log.e(TAG, "writeSysFs:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "writeSysFs:" + ex);
}
- return false;
+ return true;
}
public boolean writeSysFs(String path, String val, int def) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(path);
- data.writeString(val);
- data.writeInt(def);
- mIBinder.transact(WRITE_SYSFS_BIN, data, reply, 0);
- int result = reply.readInt();
- reply.recycle();
- data.recycle();
- return result!=0;
+ synchronized (mLock) {
+ try {
+ mProxy.writeSysfs(path, val);
+ } catch (RemoteException e) {
+ Log.e(TAG, "writeSysFs:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "writeSysFs:" + ex);
}
- return false;
+ return true;
}
- public int readHdcpRX22Key(String val, int def) {
- /*try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeInt(def);
- mIBinder.transact(READ_HDCPRX22_KEY, data, reply, 0);
- int result = reply.readInt();
- val = reply.readString();
- reply.recycle();
- data.recycle();
- return result;
+ public int readHdcpRX22Key(String val, int size) {
+ /*
+ synchronized (mLock) {
+ Mutable<Integer> lenVal = new Mutable<>();
+ Mutable<String> resultVal = new Mutable<>();
+ try {
+ mProxy.readHdcpRX22Key(size, (int ret, String val, int len) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ lenVal.value = len;
+ }
+ });
+ val = resultVal.value;
+ return lenVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "readHdcpRX22Key:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "readHdcp22Key:" + ex);
- }*/
+ }
+ */
return 0;
}
public boolean writeHdcpRX22Key(String val, int def) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(val);
- data.writeInt(def);
- mIBinder.transact(WRITE_HDCPRX22_KEY, data, reply, 0);
- int result = reply.readInt();
- val = reply.readString();
- reply.recycle();
- data.recycle();
- return result!=0;
+ synchronized (mLock) {
+ try {
+ mProxy.writeHdcpRX22Key(val);
+ } catch (RemoteException e) {
+ Log.e(TAG, "writeHdcpRX22Key:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "writeHdcp22Key:" + ex);
}
- return false;
+ return true;
}
- public int readHdcpRX14Key(String val, int def) {
- /*try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeInt(def);
- mIBinder.transact(READ_HDCPRX14_KEY, data, reply, 0);
- int result = reply.readInt();
- reply.recycle();
- data.recycle();
- return result;
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "readHdcp14Key:" + ex);
- }*/
-
+ public int readHdcpRX14Key(String val, int size) {
+ /*
+ synchronized (mLock) {
+ Mutable<Integer> lenVal = new Mutable<>();
+ Mutable<String> resultVal = new Mutable<>();
+ try {
+ mProxy.readHdcpRX14Key(size, (int ret, String val, int len) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ lenVal.value = len;
+ }
+ });
+ val = resultVal.value;
+ return lenVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "readHdcpRX14Key:" + e);
+ }
+ }
+ */
return 0;
}
public boolean writeHdcpRX14Key(String val, int def) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(val);
- data.writeInt(def);
- mIBinder.transact(WRITE_HDCPRX14_KEY, data, reply, 0);
- int result = reply.readInt();
- reply.recycle();
- data.recycle();
- return result!=0;
+ synchronized (mLock) {
+ try {
+ mProxy.writeHdcpRX14Key(val);
+ } catch (RemoteException e) {
+ Log.e(TAG, "writeHdcpRX14Key:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "writeHdcp14Key:" + ex);
}
- return false;
+ return true;
}
public boolean writeHdcpRXImg(String path) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(path);
- mIBinder.transact(WRITE_HDCPRX_IMG, data, reply, 0);
- int result = reply.readInt();
- reply.recycle();
- data.recycle();
- return result!=0;
+ synchronized (mLock) {
+ try {
+ mProxy.writeHdcpRXImg(path);
+ } catch (RemoteException e) {
+ Log.e(TAG, "writeHdcpRXImg:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "writeHdcpImg:" + ex);
}
- return false;
+ return true;
}
public String getBootenv(String prop, String def) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(prop);
- mIBinder.transact(GET_BOOT_ENV, data, reply, 0);
- int result = reply.readInt();
- String value = reply.readString();
- reply.recycle();
- data.recycle();
- if (0 == result)
- return def;//have some error
- else
- return value;
+ synchronized (mLock) {
+ Mutable<String> resultVal = new Mutable<>();
+ try {
+ mProxy.getBootEnv(prop, (int ret, String v) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ }
+ });
+ return resultVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "getBootenv:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "get boot env:" + ex);
}
- return null;
+ return "";
}
public void setBootenv(String prop, String val) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(prop);
- data.writeString(val);
- mIBinder.transact(SET_BOOT_ENV, data, reply, 0);
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ try {
+ mProxy.setBootEnv(prop, val);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setBootenv:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "set boot env:" + ex);
}
}
public DisplayInfo getDisplayInfo() {
- DisplayInfo info = null;
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- mIBinder.transact(GET_DISPLAY_INFO, data, reply, 0);
- info = new DisplayInfo();
- info.type = reply.readInt();
- info.socType = reply.readString();
- info.defaultUI = reply.readString();
- info.fb0Width = reply.readInt();
- info.fb0Height = reply.readInt();
- info.fb0FbBits = reply.readInt();
- info.fb0TripleEnable = (reply.readInt()==0)?false:true;
- info.fb1Width = reply.readInt();
- info.fb1Height = reply.readInt();
- info.fb1FbBits = reply.readInt();
- info.fb1TripleEnable = (reply.readInt()==0)?false:true;
-
- reply.recycle();
- data.recycle();
+ DisplayInfo info = new DisplayInfo();
+ synchronized (mLock) {
+ Mutable<DroidDisplayInfo> resultInfo = new Mutable<>();
+ try {
+ mProxy.getDroidDisplayInfo((int ret, DroidDisplayInfo v) -> {
+ if (Result.OK == ret) {
+ resultInfo.value = v;
+ }
+ });
+ info.type = resultInfo.value.type;
+ info.socType = resultInfo.value.socType;
+ info.defaultUI = resultInfo.value.defaultUI;
+ info.fb0Width = resultInfo.value.fb0w;
+ info.fb0Height = resultInfo.value.fb0h;
+ info.fb0FbBits = resultInfo.value.fb0bits;
+ info.fb0TripleEnable = (1==resultInfo.value.fb0trip)?true:false;
+
+ info.fb1Width = resultInfo.value.fb1w;
+ info.fb1Height = resultInfo.value.fb1h;
+ info.fb1FbBits = resultInfo.value.fb1bits;
+ info.fb1TripleEnable = (1==resultInfo.value.fb1trip)?true:false;
+ } catch (RemoteException e) {
+ Log.e(TAG, "getDisplayInfo:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "get display info:" + ex);
}
return info;
}
public void loopMountUnmount(boolean isMount, String path){
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeInt(isMount?1:0);
- data.writeString(path);
- mIBinder.transact(LOOP_MOUNT_UNMOUNT, data, reply, 0);
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ try {
+ mProxy.loopMountUnmount(isMount?1:0, path);
+ } catch (RemoteException e) {
+ Log.e(TAG, "loopMountUnmount:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "loop mount unmount:" + ex);
}
}
public void setMboxOutputMode(String mode) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(mode);
- mIBinder.transact(MBOX_OUTPUT_MODE, data, reply, 0);
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ try {
+ mProxy.setSourceOutputMode(mode);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setMboxOutputMode:" + e);
+ }
+ }
+ }
+
+ public void setDigitalMode(String mode) {
+ synchronized (mLock) {
+ try {
+ mProxy.setDigitalMode(mode);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setDigitalMode:" + e);
+ }
+ }
+ }
+
+ public void setOsdMouseMode(String mode) {
+ synchronized (mLock) {
+ try {
+ mProxy.setOsdMouseMode(mode);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setOsdMouseMode:" + e);
+ }
+ }
+ }
+
+ public void setOsdMousePara(int x, int y, int w, int h) {
+ synchronized (mLock) {
+ try {
+ mProxy.setOsdMousePara(x, y, w, h);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setOsdMousePara:" + e);
+ }
+ }
+ }
+
+ public void setPosition(int x, int y, int w, int h) {
+ synchronized (mLock) {
+ try {
+ mProxy.setPosition(x, y, w, h);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setPosition:" + e);
+ }
+ }
+ }
+
+ public int[] getPosition(String mode) {
+ int[] curPosition = { 0, 0, 1280, 720 };
+ synchronized (mLock) {
+ Mutable<Integer> left = new Mutable<>();
+ Mutable<Integer> top = new Mutable<>();
+ Mutable<Integer> width = new Mutable<>();
+ Mutable<Integer> height = new Mutable<>();
+ try {
+ mProxy.getPosition(mode, (int ret, int x, int y, int w, int h) -> {
+ if (Result.OK == ret) {
+ left.value = x;
+ top.value = y;
+ width.value = w;
+ height.value = h;
+ }
+ });
+ curPosition[0] = left.value;
+ curPosition[1] = top.value;
+ curPosition[2] = width.value;
+ curPosition[3] = height.value;
+ return curPosition;
+ } catch (RemoteException e) {
+ Log.e(TAG, "getPosition:" + e);
+ }
+ }
+ return curPosition;
+ }
+
+ public String getDeepColorAttr(String mode) {
+ synchronized (mLock) {
+ Mutable<String> resultVal = new Mutable<>();
+ try {
+ mProxy.getDeepColorAttr(mode, (int ret, String v) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ }
+ });
+ return resultVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "getDeepColorAttr:" + e);
+ }
+ }
+ return "";
+ }
+
+ public long resolveResolutionValue(String mode) {
+ synchronized (mLock) {
+ Mutable<Long> resultVal = new Mutable<>();
+ try {
+ mProxy.resolveResolutionValue(mode, (int ret, long v) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ }
+ });
+ return resultVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "resolveResolutionValue:" + e);
+ }
+ }
+ return -1;
+ }
+
+ public String isTvSupportDolbyVision() {
+ synchronized (mLock) {
+ Mutable<String> resultVal = new Mutable<>();
+ try {
+ mProxy.sinkSupportDolbyVision((int ret, String v, boolean support) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ }
+ });
+ return resultVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "isTvSupportDolbyVision:" + e);
+ }
+ }
+ return "";
+ }
+
+ public void setDolbyVisionEnable(int state) {
+ synchronized (mLock) {
+ try {
+ mProxy.setDolbyVisionState(state);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setDolbyVisionEnable:" + e);
+ }
+ }
+ }
+
+ public void saveDeepColorAttr(String mode, String dcValue) {
+ synchronized (mLock) {
+ try {
+ mProxy.saveDeepColorAttr(mode, dcValue);
+ } catch (RemoteException e) {
+ Log.e(TAG, "saveDeepColorAttr:" + e);
+ }
+ }
+ }
+
+ public void setHdrMode(String mode) {
+ synchronized (mLock) {
+ try {
+ mProxy.setHdrMode(mode);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setHdrMode:" + e);
+ }
+ }
+ }
+
+ public void setSdrMode(String mode) {
+ synchronized (mLock) {
+ try {
+ mProxy.setSdrMode(mode);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setSdrMode:" + e);
+ }
+ }
+ }
+
+ /**
+ * that use by droidlogic-res.apk only, because need have one callback only
+ *
+ * @hide
+ */
+ public void setListener(ISystemControlCallback listener) {
+ //Log.i(TAG, "setListener");
+ synchronized (mLock) {
+ try {
+ mProxy.setCallback(listener);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setCallback:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "set mbox output mode:" + ex);
}
}
public int set3DMode(String mode3d) {
- int ret = -1;
Log.i(TAG, "[set3DMode]mode3d:" + mode3d);
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(mode3d);
- mIBinder.transact(SET_3D_MODE, data, reply, 0);
- ret = reply.readInt();
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ try {
+ mProxy.set3DMode(mode3d);
+ } catch (RemoteException e) {
+ Log.e(TAG, "set3DMode:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "set 3d mode:" + ex);
}
- return ret;
+ return 0;
}
/**
* Close 3D mode, include 3D setting and OSD display setting.
*/
public void init3DSettings() {
- //Log.i(TAG, "[init3DSettings]");
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- mIBinder.transact(INIT_3D_SETTING, data, reply, 0);
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ try {
+ mProxy.init3DSetting();
+ } catch (RemoteException e) {
+ Log.e(TAG, "init3DSettings:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "[init3DSettings]ex:" + ex);
}
}
@@ -561,23 +585,20 @@ public class SystemControlManager {
* FORMAT_3D_TOP_AND_BOTTOM
*/
public int getVideo3DFormat() {
- int ret = -1;
- //Log.i(TAG, "[getVideo3DFormat]");
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- mIBinder.transact(GET_VIDEO_3D_FORMAT, data, reply, 0);
- ret = reply.readInt();
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ Mutable<Integer> resultVal = new Mutable<>();
+ try {
+ mProxy.getVideo3DFormat((int ret, int v) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ }
+ });
+ return resultVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "getVideo3DFormat:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "[getVideo3DFormat]ex:" + ex);
}
-
- return ret;
+ return -1;
}
/**
@@ -590,23 +611,20 @@ public class SystemControlManager {
* FORMAT_3D_TOP_AND_BOTTOM
*/
public int getDisplay3DTo2DFormat() {
- int ret = -1;
- //Log.i(TAG, "[getDisplay3DTo2DFormat]");
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- mIBinder.transact(GET_VIDEO_3DTO2D_FORMAT, data, reply, 0);
- ret = reply.readInt();
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ Mutable<Integer> resultVal = new Mutable<>();
+ try {
+ mProxy.getDisplay3DTo2DFormat((int ret, int v) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ }
+ });
+ return resultVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "getDisplay3DTo2DFormat:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "[getDisplay3DTo2DFormat]ex:" + ex);
}
-
- return ret;
+ return -1;
}
/**
@@ -623,29 +641,16 @@ public class SystemControlManager {
* @return set status
*/
public boolean setDisplay3DTo2DFormat(int format) {
- boolean ret = false;
- int rettmp = -1;
- //Log.i(TAG, "[setDisplay3DTo2DFormat]format:" + format);
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeInt(format);
- mIBinder.transact(SET_VIDEO_3DTO2D_FORMAT, data, reply, 0);
- rettmp = reply.readInt();
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ Mutable<Integer> resultVal = new Mutable<>();
+ try {
+ mProxy.setDisplay3DTo2DFormat(format);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setDisplay3DTo2DFormat:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "[setDisplay3DTo2DFormat]ex:" + ex);
- }
-
- if (rettmp == 1) {
- ret = true;
}
- return ret;
+ return true;
}
/**
@@ -661,29 +666,16 @@ public class SystemControlManager {
* @return set status
*/
public boolean setDisplay3DFormat(int format) {
- boolean ret = false;
- int rettmp = -1;
- //Log.i(TAG, "[setDisplay3DFormat]format:" + format);
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeInt(format);
- mIBinder.transact(SET_DISPLAY_3D_FORMAT, data, reply, 0);
- rettmp = reply.readInt();
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ Mutable<Integer> resultVal = new Mutable<>();
+ try {
+ mProxy.setDisplay3DFormat(format);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setDisplay3DFormat:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "[setDisplay3DFormat]ex:" + ex);
- }
-
- if (rettmp == 1) {
- ret = true;
}
- return ret;
+ return true;
}
/**
@@ -696,59 +688,36 @@ public class SystemControlManager {
* FORMAT_3D_TOP_AND_BOTTOM
*/
public int getDisplay3DFormat() {
- int ret = -1;
- //Log.i(TAG, "[getDisplay3DFormat]");
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- mIBinder.transact(GET_DISPLAY_3D_FORMAT, data, reply, 0);
- ret = reply.readInt();
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ Mutable<Integer> resultVal = new Mutable<>();
+ try {
+ mProxy.getDisplay3DFormat((int ret, int v) -> {
+ if (Result.OK == ret) {
+ resultVal.value = v;
+ }
+ });
+ return resultVal.value;
+ } catch (RemoteException e) {
+ Log.e(TAG, "getDisplay3DFormat:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "[getDisplay3DFormat]ex:" + ex);
}
-
- return ret;
- }
-
- /**
- * for subtitle // TODO:
- */
- public boolean setOsd3DFormat(android.view.SurfaceHolder holder) {
- return true;
+ return -1;
}
/**
* for subtitle, maybe unnecessary
*/
public boolean setOsd3DFormat(int format) {
- boolean ret = false;
- int rettmp = -1;
- //Log.i(TAG, "[setOsd3DFormat]format:" + format);
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeInt(format);
- mIBinder.transact(SET_OSD_3D_FORMAT, data, reply, 0);
- rettmp = reply.readInt();
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ Mutable<Integer> resultVal = new Mutable<>();
+ try {
+ mProxy.setOsd3DFormat(format);
+ } catch (RemoteException e) {
+ Log.e(TAG, "setOsd3DFormat:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "[setOsd3DFormat]ex:" + ex);
}
- if (rettmp == 1) {
- ret = true;
- }
-
- return ret;
+ return true;
}
/**
@@ -762,286 +731,66 @@ public class SystemControlManager {
* @return set status
*/
public boolean switch3DTo2D(int format) {
- boolean ret = false;
- int rettmp = -1;
- //Log.i(TAG, "[switch3DTo2D]format:" + format);
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeInt(format);
- mIBinder.transact(SWITCH_3DTO2D, data, reply, 0);
- rettmp = reply.readInt();
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ Mutable<Integer> resultVal = new Mutable<>();
+ try {
+ mProxy.switch3DTo2D(format);
+ } catch (RemoteException e) {
+ Log.e(TAG, "switch3DTo2D:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "[switch3DTo2D]ex:" + ex);
- }
-
- if (rettmp == 1) {
- ret = true;
}
- return ret;
+ return true;
}
/**
* // TODO: haven't implemented yet
*/
public boolean switch2DTo3D(int format) {
- boolean ret = false;
- int rettmp = -1;
- //Log.i(TAG, "[switch2DTo3D]format:" + format);
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeInt(format);
- mIBinder.transact(SWITCH_2DTO3D, data, reply, 0);
- rettmp = reply.readInt();
- reply.recycle();
- data.recycle();
+ synchronized (mLock) {
+ Mutable<Integer> resultVal = new Mutable<>();
+ try {
+ mProxy.switch2DTo3D(format);
+ } catch (RemoteException e) {
+ Log.e(TAG, "switch2DTo3D:" + e);
}
- } catch (RemoteException ex) {
- Log.e(TAG, "[switch2DTo3D]ex:" + ex);
- }
-
- if (rettmp == 1) {
- ret = true;
}
- return ret;
- }
-
- public void setDigitalMode(String mode) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(mode);
- mIBinder.transact(SET_DIGITAL_MODE, data, reply, 0);
- reply.recycle();
- data.recycle();
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "set digital mode:" + ex);
- }
- }
-
- public void setOsdMouseMode(String mode) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(mode);
- mIBinder.transact(OSD_MOUSE_MODE, data, reply, 0);
- reply.recycle();
- data.recycle();
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "set osd mouse mode:" + ex);
- }
- }
-
- public void setOsdMousePara(int x, int y, int w, int h) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeInt(x);
- data.writeInt(y);
- data.writeInt(w);
- data.writeInt(h);
- mIBinder.transact(OSD_MOUSE_PARA, data, reply, 0);
- reply.recycle();
- data.recycle();
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "set osd mouse parameter:" + ex);
- }
- }
-
- public void setPosition(int x, int y, int w, int h) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeInt(x);
- data.writeInt(y);
- data.writeInt(w);
- data.writeInt(h);
- mIBinder.transact(SET_POSITION, data, reply, 0);
- reply.recycle();
- data.recycle();
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "set position:" + ex);
- }
- }
-
- public int[] getPosition(String mode) {
- int[] curPosition = { 0, 0, 1280, 720 };
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(mode);
- mIBinder.transact(GET_POSITION, data, reply, 0);
- curPosition[0] = reply.readInt();
- curPosition[1] = reply.readInt();
- curPosition[2] = reply.readInt();
- curPosition[3] = reply.readInt();
- reply.recycle();
- data.recycle();
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "get position:" + ex);
- }
- return curPosition;
- }
-
- public String getDeepColorAttr(String mode) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(mode);
- mIBinder.transact(GET_DEEP_COLOR_ATTR, data, reply, 0);
- String dcValue = reply.readString();
- reply.recycle();
- data.recycle();
- return dcValue;
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "get deep color attr:" + ex);
- }
- return null;
- }
-
- public long resolveResolutionValue(String mode) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(mode);
- mIBinder.transact(RESOLVE_RESOLUTION_VALUE, data, reply, 0);
- long value = reply.readLong();
- reply.recycle();
- data.recycle();
- return value;
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "get resolve Resolution value error:" + ex);
- }
- return -1;
+ return true;
}
- public String isTvSupportDolbyVision() {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- mIBinder.transact(TV_SUPPORT_DOLBY_VISION, data, reply, 0);
- String mode = reply.readString();
- reply.recycle();
- data.recycle();
- return mode;
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "set dolby vision:" + ex);
- }
- return null;
- }
+ private static class Mutable<E> {
+ public E value;
- public void setDolbyVisionEnable(int state) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeInt(state);
- mIBinder.transact(SET_DOLBY_VISION, data, reply, 0);
- reply.recycle();
- data.recycle();
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "set dolby vision:" + ex);
+ Mutable() {
+ value = null;
}
- }
- public void saveDeepColorAttr(String mode, String dcValue) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(mode);
- data.writeString(dcValue);
- mIBinder.transact(SAVE_DEEP_COLOR_ATTR, data, reply, 0);
- reply.recycle();
- data.recycle();
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "set deep color attr:" + ex);
+ Mutable(E value) {
+ this.value = value;
}
}
- public void setHdrMode(String mode) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(mode);
- mIBinder.transact(SET_HDR_MODE, data, reply, 0);
- reply.recycle();
- data.recycle();
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "set hdr mode:" + ex);
+ final class DeathRecipient implements HwBinder.DeathRecipient {
+ DeathRecipient() {
}
- }
- public void setSdrMode(String mode) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeString(mode);
- mIBinder.transact(SET_SDR_MODE, data, reply, 0);
- reply.recycle();
- data.recycle();
+ @Override
+ public void serviceDied(long cookie) {
+ if (SYSTEM_CONTROL_DEATH_COOKIE == cookie) {
+ Log.e(TAG, "system control service died cookie: " + cookie);
+ synchronized (mLock) {
+ mProxy = null;
+ }
}
- } catch (RemoteException ex) {
- Log.e(TAG, "set sdr mode:" + ex);
}
}
- public void setListener(ISystemControlNotify listener) {
- try {
- if (null != mIBinder) {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(SYS_TOKEN);
- data.writeStrongInterface(listener);
- mIBinder.transact(SET_LISTENER, data, reply, 0);
- reply.recycle();
- data.recycle();
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "set callback:" + ex);
+ final class ServiceNotification extends IServiceNotification.Stub {
+ @Override
+ public void onRegistration(String fqName, String name, boolean preexisting) {
+ Log.i(TAG, "system control service started " + fqName + " " + name);
+ connectToProxy();
}
}
diff --git a/core/jni/hdmi_cec/Android.mk b/core/jni/hdmi_cec/Android.mk
index b7c3625..51cd69f 100644
--- a/core/jni/hdmi_cec/Android.mk
+++ b/core/jni/hdmi_cec/Android.mk
@@ -15,6 +15,7 @@ LOCAL_C_INCLUDES += \
$(HDMI_CEC_NATIVE_PATH)/binder
LOCAL_SHARED_LIBRARIES := \
+ vendor.amlogic.hardware.hdmicec@1.0_vendor \
libandroid_runtime \
libcutils \
libutils \
diff --git a/core/jni/hdmi_cec/HdmiCecExtend.cpp b/core/jni/hdmi_cec/HdmiCecExtend.cpp
index a3b5ff1..fcf69d4 100644
--- a/core/jni/hdmi_cec/HdmiCecExtend.cpp
+++ b/core/jni/hdmi_cec/HdmiCecExtend.cpp
@@ -9,6 +9,7 @@
#include <HdmiCecBase.h>
#include <HdmiCecClient.h>
+#include <HdmiCecHidlClient.h>
#include <android/log.h>
namespace android {
@@ -55,45 +56,60 @@ public:
private:
sp<HdmiCecClient> mHdmiCecClient;
+ HdmiCecHidlClient *mHdmiCecHidlClient;
jobject mCallbacksObj;
};
JHdmiCecExtend::JHdmiCecExtend(jobject callbacksObj) :
mCallbacksObj(callbacksObj) {
- mHdmiCecClient = HdmiCecClient::connect();
- mHdmiCecClient->setEventObserver(this);
+ //mHdmiCecClient = HdmiCecClient::connect();
+ //mHdmiCecClient->setEventObserver(this);
+
+ mHdmiCecHidlClient = HdmiCecHidlClient::connect();
+ mHdmiCecHidlClient->setEventObserver(this);
+
}
JHdmiCecExtend::~JHdmiCecExtend() {
mHdmiCecClient.clear();
+
+ delete mHdmiCecHidlClient;
}
void JHdmiCecExtend::init() {
}
int JHdmiCecExtend::getPhysicalAddress(uint16_t* addr) {
- if (mHdmiCecClient != NULL)
- return mHdmiCecClient->getPhysicalAddress(addr);
- return 0;
+ //if (mHdmiCecClient != NULL)
+ // return mHdmiCecClient->getPhysicalAddress(addr);
+ //return 0;
+
+ return mHdmiCecHidlClient->getPhysicalAddress(addr);
}
int JHdmiCecExtend::getVendorId(uint32_t* vendorId) {
- if (mHdmiCecClient != NULL)
- return mHdmiCecClient->getVendorId(vendorId);
- return 0;
+ //if (mHdmiCecClient != NULL)
+ // return mHdmiCecClient->getVendorId(vendorId);
+ //return 0;
+
+ return mHdmiCecHidlClient->getVendorId(vendorId);
}
int JHdmiCecExtend::getVersion(int* version) {
- if (mHdmiCecClient != NULL)
- return mHdmiCecClient->getVersion(version);
- return 0;
+ //if (mHdmiCecClient != NULL)
+ // return mHdmiCecClient->getVersion(version);
+ //return 0;
+
+ return mHdmiCecHidlClient->getVersion(version);
}
int JHdmiCecExtend::sendMessage(const cec_message_t* message, bool isExtend) {
- if (mHdmiCecClient != NULL)
- return mHdmiCecClient->sendMessage(message, isExtend);
- return 0;
+ //if (mHdmiCecClient != NULL)
+ // return mHdmiCecClient->sendMessage(message, isExtend);
+ //return 0;
+
+ return mHdmiCecHidlClient->sendMessage(message, isExtend);
}
void JHdmiCecExtend::onEventUpdate(const hdmi_cec_event_t* event)
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 8570bdb..a5edf6c 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -34,8 +34,7 @@
<uses-permission android:name="android.permission.HDMI_CEC" />
<uses-permission android:name="android.permission.GET_TASKS" />
- <application android:process="system"
- android:persistent="true"
+ <application android:persistent="true"
android:hasCode="true"
android:label="@string/droidlogic_system_label"
android:allowClearUserData="false"
diff --git a/core/res/src/com/droidlogic/HdmiCecExtend.java b/core/res/src/com/droidlogic/HdmiCecExtend.java
index f72d7bb..a5755a4 100644
--- a/core/res/src/com/droidlogic/HdmiCecExtend.java
+++ b/core/res/src/com/droidlogic/HdmiCecExtend.java
@@ -665,9 +665,9 @@ public class HdmiCecExtend implements VendorCommandListener, HotplugEventListene
}
/* for native */
- public native int nativeSendCecMessage(long ptr, int dest, byte[] body);
+ public native int nativeSendCecMessage(long ptr, int dest, byte[] body);
public native long nativeInit(HdmiCecExtend ext);
- public native int nativeGetPhysicalAddr(long ptr);
- public native int nativeGetVendorId(long ptr);
- public native int nativeGetCecVersion(long ptr);
+ public native int nativeGetPhysicalAddr(long ptr);
+ public native int nativeGetVendorId(long ptr);
+ public native int nativeGetCecVersion(long ptr);
}
diff --git a/services/hdmicec/binder/Android.mk b/services/hdmicec/binder/Android.mk
index 9cc6c8b..da42fd7 100644
--- a/services/hdmicec/binder/Android.mk
+++ b/services/hdmicec/binder/Android.mk
@@ -6,9 +6,19 @@ LOCAL_SRC_FILES:= \
IHdmiCecService.cpp \
IHdmiCecCallback.cpp \
HdmiCecClient.cpp \
+ HdmiCecHidlClient.cpp \
HdmiCecBase.cpp
+LOCAL_C_INCLUDES += \
+ external/libcxx/include
+
+LOCAL_CPPFLAGS += -std=c++14
+
LOCAL_SHARED_LIBRARIES := \
+ vendor.amlogic.hardware.hdmicec@1.0_vendor \
+ libbase \
+ libhidlbase \
+ libhidltransport \
libcutils \
libutils \
libbinder \
@@ -20,4 +30,4 @@ LOCAL_MODULE:= libhdmicec
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26 && echo OK),OK)
LOCAL_PROPRIETARY_MODULE := true
endif
-include $(BUILD_SHARED_LIBRARY) \ No newline at end of file
+include $(BUILD_SHARED_LIBRARY)
diff --git a/services/hdmicec/binder/HdmiCecHidlClient.cpp b/services/hdmicec/binder/HdmiCecHidlClient.cpp
new file mode 100644
index 0000000..cb488b4
--- a/dev/null
+++ b/services/hdmicec/binder/HdmiCecHidlClient.cpp
@@ -0,0 +1,313 @@
+/*
+ * Copyright (C) 2016 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.
+ * @author Tellen Yu
+ * @version 1.0
+ * @date 2017/9/25
+ * @par function description:
+ * - 1 droidlogic hdmi cec hwbinder client
+ */
+
+#define LOG_TAG "hdmicecd-client"
+
+#include <utils/RefBase.h>
+#include <binder/IServiceManager.h>
+#include <utils/Log.h>
+
+#include "HdmiCecHidlClient.h"
+
+namespace android {
+
+Mutex HdmiCecHidlClient::mLock;
+
+HdmiCecHidlClient::HdmiCecHidlClient()
+{
+ mHdmiCecService = getHdmiCecService();
+ mHdmiCecHidlCallback = new HdmiCecHidlCallback(this);
+ Return<void> ret = mHdmiCecService->setCallback(mHdmiCecHidlCallback);
+}
+
+HdmiCecHidlClient::~HdmiCecHidlClient()
+{
+ if (nullptr != mpPortInfo)
+ delete mpPortInfo;
+}
+
+HdmiCecHidlClient* HdmiCecHidlClient::connect()
+{
+ //sp<HdmiCecHidlClient> client = new HdmiCecHidlClient();
+ //return client;
+ return new HdmiCecHidlClient();
+}
+
+int HdmiCecHidlClient::openCecDevice()
+{
+ int fd = -1;
+ Return<void> ret = mHdmiCecService->openCecDevice([&fd](Result result, int32_t addr) {
+ if (Result::SUCCESS == result) {
+ fd = addr;
+ }
+ });
+
+ ALOGI("open cec device fd:%d", fd);
+ return fd;
+}
+
+int HdmiCecHidlClient::closeCecDevice()
+{
+ Return<void> ret = mHdmiCecService->closeCecDevice();
+ if (!ret.isOk()) {
+ ALOGE("Failed to closeCecDevice.");
+ return -1;
+ }
+
+ return 0;
+}
+
+void HdmiCecHidlClient::getPortInfos(hdmi_port_info_t* list[], int* total)
+{
+ hidl_vec<HdmiPortInfo> ports;
+ Return<void> ret = mHdmiCecService->getPortInfo([&ports](hidl_vec<HdmiPortInfo> hidlList) {
+ ports = hidlList;
+ });
+
+ if (ports.size() <= 0) {
+ *total = 0;
+ ALOGE("getPortInfos fail");
+ return;
+ }
+
+ if (nullptr != mpPortInfo)
+ delete mpPortInfo;
+
+ mpPortInfo = new hdmi_port_info_t[ports.size()];
+ if (!mpPortInfo) {
+ ALOGE("alloc port_data failed");
+ *total = 0;
+ return;
+ }
+
+ for (size_t i = 0; i < ports.size(); ++i) {
+ /*
+ ALOGD("droidhdmicec client port %d, type:%s, id:%d, cec support:%d, arc support:%d, physical address:%x",
+ i, (HDMI_OUTPUT==static_cast<hdmi_port_type_t>(ports[i].type)) ? "output" : "input",
+ ports[i].portId,
+ ports[i].cecSupported?1:0,
+ ports[i].arcSupported?1:0,
+ ports[i].physicalAddress);*/
+
+ mpPortInfo[i].type = static_cast<hdmi_port_type_t>(ports[i].type);
+ mpPortInfo[i].port_id = ports[i].portId;
+ mpPortInfo[i].cec_supported = ports[i].cecSupported;
+ mpPortInfo[i].arc_supported = ports[i].arcSupported;
+ mpPortInfo[i].physical_address = ports[i].physicalAddress;
+ }
+
+ *list = mpPortInfo;
+ *total = ports.size();
+}
+
+int HdmiCecHidlClient::addLogicalAddress(cec_logical_address_t address)
+{
+ Return<Result> ret = mHdmiCecService->addLogicalAddress(static_cast<CecLogicalAddress>(address));
+ if (!ret.isOk()) {
+ ALOGE("Failed to add a logical address.");
+ return -1;
+ }
+ return 0;
+}
+
+void HdmiCecHidlClient::clearLogicaladdress()
+{
+ Return<void> ret = mHdmiCecService->clearLogicalAddress();
+ if (!ret.isOk()) {
+ ALOGE("Failed to clearLogicaladdress.");
+ }
+}
+
+void HdmiCecHidlClient::setOption(int flag, int value)
+{
+ Return<void> ret = mHdmiCecService->setOption(static_cast<OptionKey>(flag), value);
+ if (!ret.isOk()) {
+ ALOGE("Failed to set option.");
+ }
+}
+
+void HdmiCecHidlClient::setAudioReturnChannel(int port, bool flag)
+{
+ Return<void> ret = mHdmiCecService->enableAudioReturnChannel(port, flag);
+ if (!ret.isOk()) {
+ ALOGE("Failed to enable/disable ARC.");
+ }
+}
+
+bool HdmiCecHidlClient::isConnected(int port)
+{
+ Return<bool> ret = mHdmiCecService->isConnected(port);
+ if (!ret.isOk()) {
+ ALOGE("Failed to get connection info.");
+ }
+ return ret;
+}
+
+int HdmiCecHidlClient::getVersion(int* version)
+{
+ Return<int32_t> ret = mHdmiCecService->getCecVersion();
+ if (!ret.isOk()) {
+ ALOGE("Failed to get cec version.");
+ return -1;
+ }
+ *version= ret;
+ return 0;
+}
+
+int HdmiCecHidlClient::getVendorId(uint32_t* vendorId)
+{
+ Return<uint32_t> ret = mHdmiCecService->getVendorId();
+ if (!ret.isOk()) {
+ ALOGE("Failed to get vendor id.");
+ return -1;
+ }
+
+ *vendorId= ret;
+ return 0;
+}
+
+int HdmiCecHidlClient::getPhysicalAddress(uint16_t* addr)
+{
+ Result result;
+ uint16_t hidlAddr;
+ Return<void> ret = mHdmiCecService->getPhysicalAddress([&result, &hidlAddr](Result res, uint16_t paddr) {
+ result = res;
+ hidlAddr = paddr;
+ });
+ if (!ret.isOk()) {
+ ALOGE("Failed to get physical address.");
+ return -1;
+ }
+ *addr = hidlAddr;
+ return 0;
+
+}
+
+int HdmiCecHidlClient::sendMessage(const cec_message_t* message, bool isExtend)
+{
+ CecMessage hidlMsg;
+ //change message from hwbinder data structure to needed data structure
+ hidlMsg.initiator = static_cast<CecLogicalAddress>(message->initiator);
+ hidlMsg.destination = static_cast<CecLogicalAddress>(message->destination);
+
+ for (size_t i = 0; i < message->length; ++i) {
+ hidlMsg.body[i] = message->body[i];
+ }
+ Return<SendMessageResult> ret = mHdmiCecService->sendMessage(hidlMsg, isExtend);
+ if (!ret.isOk()) {
+ ALOGE("Failed to send CEC message.");
+ return -1;
+ }
+
+ return (SendMessageResult::SUCCESS == ret)?0:-1;
+}
+
+sp<IDroidHdmiCEC> HdmiCecHidlClient::getHdmiCecService()
+{
+ Mutex::Autolock _l(mLock);
+
+#if 1//PLATFORM_SDK_VERSION >= 26
+ sp<IDroidHdmiCEC> hdmicec = IDroidHdmiCEC::getService();
+
+ mDeathRecipient = new HdmiCecDaemonDeathRecipient(this);
+ Return<bool> linked = hdmicec->linkToDeath(mDeathRecipient, /*cookie*/ 0);
+ if (!linked.isOk()) {
+ ALOGE("Transaction error in linking to hdmi cec daemon service death: %s", linked.description().c_str());
+ } else if (!linked) {
+ ALOGE("Unable to link to hdmi cec daemon service death notifications");
+ } else {
+ ALOGI("Link to hdmi cec daemon service death notification successful");
+ }
+
+#else
+ if (mHdmiCecService.get() == 0) {
+ sp<IServiceManager> sm = defaultServiceManager();
+ sp<IBinder> binder;
+ do {
+ binder = sm->getService(String16("hdmi_cec"));
+ if (binder != 0)
+ break;
+
+ ALOGW("Hdmi cec not published, waiting...");
+ usleep(500000); // 0.5 s
+ } while (true);
+
+ if (mDeathNotifier == NULL) {
+ mDeathNotifier = new DeathNotifier();
+ }
+
+ binder->linkToDeath(mDeathNotifier);
+ mHdmiCecService = interface_cast<IHdmiCecService> (binder);
+ }
+
+ if (mHdmiCecService == NULL)
+ ALOGW("wrong... can't get hdmi cec service");
+ return mHdmiCecService;
+#endif
+
+ return hdmicec;
+}
+
+void HdmiCecHidlClient::setEventObserver(const sp<HdmiCecEventListener> &eventListener)
+{
+ mEventListener = eventListener;
+}
+
+Return<void> HdmiCecHidlClient::HdmiCecHidlCallback::notifyCallback(const CecEvent& hidlEvent)
+{
+ ALOGI("notifyCallback event type:%d", hidlEvent.eventType);
+ if (cecClient->mEventListener != NULL) {
+ hdmi_cec_event_t event;
+ event.eventType = hidlEvent.eventType;
+ if (HDMI_EVENT_ADD_LOGICAL_ADDRESS == hidlEvent.eventType) {
+ event.logicalAddress = hidlEvent.logicalAddress;
+ }
+ else if (HDMI_EVENT_HOT_PLUG == hidlEvent.eventType) {
+ event.hotplug.connected = hidlEvent.hotplug.connected?1:0;
+ event.hotplug.port_id = hidlEvent.hotplug.portId;
+ }
+ //HDMI_EVENT_CEC_MESSAGE or HDMI_EVENT_RECEIVE_MESSAGE
+ else if (0 != hidlEvent.eventType) {
+ event.cec.initiator = static_cast<cec_logical_address_t>(hidlEvent.cec.initiator);
+ event.cec.destination = static_cast<cec_logical_address_t>(hidlEvent.cec.destination);
+
+ event.cec.length = hidlEvent.cec.body.size();
+ for (size_t i = 0; i < event.cec.length; i++) {
+ event.cec.body[i] = hidlEvent.cec.body[i];
+ }
+ }
+
+ cecClient->mEventListener->onEventUpdate(&event);
+ }
+ return Void();
+}
+
+void HdmiCecHidlClient::HdmiCecDaemonDeathRecipient::serviceDied(uint64_t cookie __unused,
+ const ::android::wp<::android::hidl::base::V1_0::IBase>& who __unused)
+{
+ ALOGE("hdmi cec died.");
+ Mutex::Autolock _l(mLock);
+ cecClient->mHdmiCecService.clear();
+ ALOGE("kill myself");
+ kill(getpid(), SIGKILL);
+}
+
+};//namespace android
diff --git a/services/hdmicec/binder/HdmiCecHidlClient.h b/services/hdmicec/binder/HdmiCecHidlClient.h
new file mode 100644
index 0000000..f4908a1
--- a/dev/null
+++ b/services/hdmicec/binder/HdmiCecHidlClient.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2016 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.
+ * @author Tellen Yu
+ * @version 1.0
+ * @date 2017/9/25
+ * @par function description:
+ * - 1 droidlogic hdmi cec hwbinder client
+ */
+
+#ifndef DROIDLOGIC_HDMICEC_HIDL_CLIENT_H_
+#define DROIDLOGIC_HDMICEC_HIDL_CLIENT_H_
+
+#include <binder/IBinder.h>
+#include <utils/threads.h>
+
+#include "HdmiCecBase.h"
+#include "IHdmiCecCallback.h"
+#include "IHdmiCecService.h"
+
+#include <vendor/amlogic/hardware/hdmicec/1.0/IDroidHdmiCEC.h>
+
+namespace android {
+
+using ::vendor::amlogic::hardware::hdmicec::V1_0::IDroidHdmiCEC;
+using ::vendor::amlogic::hardware::hdmicec::V1_0::IDroidHdmiCecCallback;
+using ::vendor::amlogic::hardware::hdmicec::V1_0::Result;
+using ::vendor::amlogic::hardware::hdmicec::V1_0::CecEvent;
+using ::vendor::amlogic::hardware::hdmicec::V1_0::HdmiPortInfo;
+using ::vendor::amlogic::hardware::hdmicec::V1_0::CecLogicalAddress;
+using ::vendor::amlogic::hardware::hdmicec::V1_0::CecMessage;
+using ::vendor::amlogic::hardware::hdmicec::V1_0::SendMessageResult;
+using ::vendor::amlogic::hardware::hdmicec::V1_0::OptionKey;
+
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+
+class HdmiCecHidlClient {
+public:
+ HdmiCecHidlClient();
+ virtual ~HdmiCecHidlClient();
+
+ static HdmiCecHidlClient* connect();
+
+ virtual int openCecDevice();
+ virtual int closeCecDevice();
+ virtual int getVersion(int* version);
+ virtual int getVendorId(uint32_t* vendorId);
+ virtual int getPhysicalAddress(uint16_t* addr);
+ virtual int sendMessage(const cec_message_t* message, bool isExtend = false);
+
+ virtual void getPortInfos(hdmi_port_info_t* list[], int* total);
+ virtual int addLogicalAddress(cec_logical_address_t address);
+ virtual void clearLogicaladdress();
+ virtual void setOption(int flag, int value);
+ virtual void setAudioReturnChannel(int port, bool flag);
+ virtual bool isConnected(int port);
+
+ void setEventObserver(const sp<HdmiCecEventListener> &eventListener);
+
+private:
+
+ static Mutex mLock;
+ sp<IDroidHdmiCEC> mHdmiCecService;
+ sp<HdmiCecEventListener> mEventListener;
+
+ sp<IDroidHdmiCEC> getHdmiCecService();
+ class HdmiCecHidlCallback : public IDroidHdmiCecCallback {
+ public:
+ HdmiCecHidlCallback(HdmiCecHidlClient *client): cecClient(client) {};
+
+ Return<void> notifyCallback(const CecEvent& hidlEvent) override;
+
+ private:
+ HdmiCecHidlClient *cecClient;
+ };
+
+ struct HdmiCecDaemonDeathRecipient : public android::hardware::hidl_death_recipient {
+ HdmiCecDaemonDeathRecipient(HdmiCecHidlClient *client): cecClient(client) {};
+
+ // hidl_death_recipient interface
+ virtual void serviceDied(uint64_t cookie,
+ const ::android::wp<::android::hidl::base::V1_0::IBase>& who) override;
+ private:
+ HdmiCecHidlClient *cecClient;
+ };
+ sp<HdmiCecDaemonDeathRecipient> mDeathRecipient = nullptr;
+
+ sp<HdmiCecHidlCallback> mHdmiCecHidlCallback = nullptr;
+ hdmi_port_info_t *mpPortInfo = nullptr;
+};
+
+}//namespace android
+
+#endif /* DROIDLOGIC_HDMICEC_HIDL_CLIENT_H_ */
diff --git a/services/hdmicec/libhdmi_cec/HdmiCecControl.cpp b/services/hdmicec/libhdmi_cec/HdmiCecControl.cpp
index 83d3808..9a6229e 100644
--- a/services/hdmicec/libhdmi_cec/HdmiCecControl.cpp
+++ b/services/hdmicec/libhdmi_cec/HdmiCecControl.cpp
@@ -1,5 +1,25 @@
-#define LOG_NDEBUG 0
-#define LOG_CEE_TAG "HdmiCecControl"
+/*
+ * Copyright (C) 2016 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.
+ * @author Tellen Yu
+ * @version 1.0
+ * @date 2017/9/25
+ * @par function description:
+ * - 1 droidlogic hdmi cec real implementation
+ */
+
+#define LOG_TAG "hdmicecd"
#include <stdlib.h>
#include <errno.h>
@@ -11,11 +31,10 @@
#include <sys/types.h>
#include "HdmiCecControl.h"
-
namespace android {
HdmiCecControl::HdmiCecControl() {
- LOGD("HdmiCecControl");
+ ALOGD("HdmiCecControl");
init();
}
@@ -26,22 +45,16 @@ HdmiCecControl::~HdmiCecControl(){}
*/
void HdmiCecControl::init()
{
- if (mCecDevice != NULL)
- return;
-
- mCecDevice = new hdmi_device();
-
- char value[PROPERTY_VALUE_MAX];
- memset(value, 0, PROPERTY_VALUE_MAX);
+ char value[PROPERTY_VALUE_MAX] = {0};
property_get("ro.hdmi.device_type", value, "4");
int type = atoi(value);
- mCecDevice->mDeviceType =
+ mCecDevice.mDeviceType =
(type >= DEV_TYPE_TV && type <= DEV_TYPE_VIDEO_PROCESSOR) ? type : DEV_TYPE_PLAYBACK;
memset(value, 0, PROPERTY_VALUE_MAX);
property_get("persist.sys.hdmi.keep_awake", value, "true");
- mCecDevice->mExtendControl = (!strcmp(value, "false")) ? 1 : 0;
- LOGD("device_type: %d, ext_control: %d", mCecDevice->mDeviceType, mCecDevice->mExtendControl);
+ mCecDevice.mExtendControl = (!strcmp(value, "false")) ? 1 : 0;
+ ALOGD("device_type: %d, ext_control: %d", mCecDevice.mDeviceType, mCecDevice.mExtendControl);
}
/**
@@ -49,20 +62,15 @@ void HdmiCecControl::init()
*/
int HdmiCecControl::closeCecDevice()
{
- if (mCecDevice == NULL)
- return -EINVAL;
-
- mCecDevice->mRun = false;
- while (!mCecDevice->mExited) {
+ mCecDevice.mRun = false;
+ while (!mCecDevice.mExited) {
usleep(100 * 1000);
}
- close(mCecDevice->mFd);
- delete mCecDevice->mpPortData;
- delete mCecDevice;
- mCecDevice = NULL;
+ close(mCecDevice.mFd);
+ delete mCecDevice.mpPortData;
- LOGD("%s, cec has closed.", __FUNCTION__);
+ ALOGD("%s, cec has closed.", __FUNCTION__);
return 0;
}
@@ -73,30 +81,25 @@ int HdmiCecControl::closeCecDevice()
*/
int HdmiCecControl::openCecDevice()
{
- if (mCecDevice == NULL) {
- LOGE("mCecDevice is NULL, initialize it.");
- init();
- }
-
- mCecDevice->mRun = true;
- mCecDevice->mExited = false;
- mCecDevice->mThreadId = 0;
- mCecDevice->mTotalPort = 0;
- mCecDevice->mConnectStatus = 0;
- mCecDevice->mpPortData = NULL;
- mCecDevice->mAddrBitmap = (1 << CEC_ADDR_BROADCAST);
- mCecDevice->isCecEnabled = true;
- mCecDevice->isCecControlled = false;
- mCecDevice->mFd = open(CEC_FILE, O_RDWR);
- if (mCecDevice->mFd < 0) {
+ mCecDevice.mRun = true;
+ mCecDevice.mExited = false;
+ mCecDevice.mThreadId = 0;
+ mCecDevice.mTotalPort = 0;
+ mCecDevice.mConnectStatus = 0;
+ mCecDevice.mpPortData = NULL;
+ mCecDevice.mAddrBitmap = (1 << CEC_ADDR_BROADCAST);
+ mCecDevice.isCecEnabled = true;
+ mCecDevice.isCecControlled = false;
+ mCecDevice.mFd = open(CEC_FILE, O_RDWR);
+ if (mCecDevice.mFd < 0) {
ALOGE("can't open device. fd < 0");
return -EINVAL;
}
- int ret = ioctl(mCecDevice->mFd, CEC_IOC_SET_DEV_TYPE, mCecDevice->mDeviceType);
+ int ret = ioctl(mCecDevice.mFd, CEC_IOC_SET_DEV_TYPE, mCecDevice.mDeviceType);
getBootConnectStatus();
- pthread_create(&mCecDevice->mThreadId, NULL, __threadLoop, this);
- pthread_setname_np(mCecDevice->mThreadId, "hdmi_cec_loop");
- return mCecDevice->mFd;
+ pthread_create(&mCecDevice.mThreadId, NULL, __threadLoop, this);
+ pthread_setname_np(mCecDevice.mThreadId, "hdmi_cec_loop");
+ return mCecDevice.mFd;
}
/**
@@ -107,24 +110,24 @@ void HdmiCecControl::getBootConnectStatus()
unsigned int total, i;
int port, ret;
- ret = ioctl(mCecDevice->mFd, CEC_IOC_GET_PORT_NUM, &total);
- LOGD("total port:%d, ret:%d", total, ret);
+ ret = ioctl(mCecDevice.mFd, CEC_IOC_GET_PORT_NUM, &total);
+ ALOGD("total port:%d, ret:%d", total, ret);
if (ret < 0)
return ;
if (total > MAX_PORT)
total = MAX_PORT;
- mCecDevice->mConnectStatus = 0;
+ mCecDevice.mConnectStatus = 0;
for (i = 0; i < total; i++) {
port = i + 1;
- ret = ioctl(mCecDevice->mFd, CEC_IOC_GET_CONNECT_STATUS, &port);
+ ret = ioctl(mCecDevice.mFd, CEC_IOC_GET_CONNECT_STATUS, &port);
if (ret) {
- LOGD("get port %d connected status failed, ret:%d", i, ret);
+ ALOGD("get port %d connected status failed, ret:%d", i, ret);
continue;
}
- mCecDevice->mConnectStatus |= ((port ? 1 : 0) << i);
+ mCecDevice.mConnectStatus |= ((port ? 1 : 0) << i);
}
- LOGD("mConnectStatus: %d", mCecDevice->mConnectStatus);
+ ALOGD("mConnectStatus: %d", mCecDevice.mConnectStatus);
}
void* HdmiCecControl::__threadLoop(void *user)
@@ -140,15 +143,15 @@ void HdmiCecControl::threadLoop()
hdmi_cec_event_t event;
int r = -1;
- LOGD("threadLoop start.");
- while (mCecDevice->mFd < 0) {
+ ALOGD("threadLoop start.");
+ while (mCecDevice.mFd < 0) {
usleep(1000 * 1000);
- mCecDevice->mFd = open(CEC_FILE, O_RDWR);
+ mCecDevice.mFd = open(CEC_FILE, O_RDWR);
}
- LOGD("file open ok, fd = %d.", mCecDevice->mFd);
+ ALOGD("file open ok, fd = %d.", mCecDevice.mFd);
- while (mCecDevice != NULL && mCecDevice->mRun) {
- if (!mCecDevice->isCecEnabled)
+ while (mCecDevice.mRun) {
+ if (!mCecDevice.isCecEnabled)
continue;
checkConnectStatus();
@@ -166,29 +169,29 @@ void HdmiCecControl::threadLoop()
event.cec.destination = cec_logical_address_t((msg_buf[0] >> 0) & 0xf);
event.cec.length = r - 1;
- if (mCecDevice->mDeviceType == DEV_TYPE_PLAYBACK
- && msg_buf[1] == CEC_MESSAGE_SET_MENU_LANGUAGE && mCecDevice->mExtendControl) {
- LOGD("ignore menu language change for hdmi-tx.");
+ if (mCecDevice.mDeviceType == DEV_TYPE_PLAYBACK
+ && msg_buf[1] == CEC_MESSAGE_SET_MENU_LANGUAGE && mCecDevice.mExtendControl) {
+ ALOGD("ignore menu language change for hdmi-tx.");
} else {
- if (mCecDevice->isCecControlled) {
+ if (mCecDevice.isCecControlled) {
event.eventType |= HDMI_EVENT_CEC_MESSAGE;
}
}
- LOGD("mExtendControl = %d, mDeviceType = %d, isCecControlled = %d",
- mCecDevice->mExtendControl, mCecDevice->mDeviceType, mCecDevice->isCecControlled);
+ ALOGD("mExtendControl = %d, mDeviceType = %d, isCecControlled = %d",
+ mCecDevice.mExtendControl, mCecDevice.mDeviceType, mCecDevice.isCecControlled);
/* call java method to process cec message for ext control */
- if ((mCecDevice->mExtendControl == 0x03)
- && (mCecDevice->mDeviceType == DEV_TYPE_PLAYBACK)
- && mCecDevice->isCecControlled) {
+ if ((mCecDevice.mExtendControl == 0x03)
+ && (mCecDevice.mDeviceType == DEV_TYPE_PLAYBACK)
+ && mCecDevice.isCecControlled) {
event.eventType |= HDMI_EVENT_RECEIVE_MESSAGE;
}
if (mEventListener != NULL && event.eventType != 0) {
mEventListener->onEventUpdate(&event);
}
}
- LOGE("thread end.");
- mCecDevice->mExited = true;
+ ALOGE("thread end.");
+ mCecDevice.mExited = true;
}
void HdmiCecControl::checkConnectStatus()
@@ -197,30 +200,30 @@ void HdmiCecControl::checkConnectStatus()
int i, port, ret;
hdmi_cec_event_t event;
- prev_status = mCecDevice->mConnectStatus;
- for (i = 0; i < mCecDevice->mTotalPort && mCecDevice->mpPortData != NULL; i++) {
- port = mCecDevice->mpPortData[i].port_id;
- ret = ioctl(mCecDevice->mFd, CEC_IOC_GET_CONNECT_STATUS, &port);
+ prev_status = mCecDevice.mConnectStatus;
+ for (i = 0; i < mCecDevice.mTotalPort && mCecDevice.mpPortData != NULL; i++) {
+ port = mCecDevice.mpPortData[i].port_id;
+ ret = ioctl(mCecDevice.mFd, CEC_IOC_GET_CONNECT_STATUS, &port);
if (ret) {
- LOGE("get port %d connected status failed, ret:%d\n", mCecDevice->mpPortData[i].port_id, ret);
+ ALOGE("get port %d connected status failed, ret:%d\n", mCecDevice.mpPortData[i].port_id, ret);
continue;
}
bit = prev_status & (1 << i);
if (bit ^ ((port ? 1 : 0) << i)) {//connect status has changed
- LOGD("port:%d, connect status changed, now:%d, prev_status:%x\n",
- mCecDevice->mpPortData[i].port_id, port, prev_status);
- if (mEventListener != NULL && mCecDevice->isCecEnabled && mCecDevice->isCecControlled) {
+ ALOGD("port:%d, connect status changed, now:%d, prev_status:%x\n",
+ mCecDevice.mpPortData[i].port_id, port, prev_status);
+ if (mEventListener != NULL && mCecDevice.isCecEnabled && mCecDevice.isCecControlled) {
event.eventType = HDMI_EVENT_HOT_PLUG;
event.hotplug.connected = port;
- event.hotplug.port_id = mCecDevice->mpPortData[i].port_id;
+ event.hotplug.port_id = mCecDevice.mpPortData[i].port_id;
mEventListener->onEventUpdate(&event);
}
prev_status &= ~(bit);
prev_status |= ((port ? 1 : 0) << i);
- LOGD("now mask:%x\n", prev_status);
+ ALOGD("now mask:%x\n", prev_status);
}
}
- mCecDevice->mConnectStatus = prev_status;
+ mCecDevice.mConnectStatus = prev_status;
}
int HdmiCecControl::readMessage(unsigned char *buf, int msg_cnt)
@@ -231,9 +234,9 @@ int HdmiCecControl::readMessage(unsigned char *buf, int msg_cnt)
int ret = -1;
/* maybe blocked at driver */
- ret = read(mCecDevice->mFd, buf, msg_cnt);
+ ret = read(mCecDevice.mFd, buf, msg_cnt);
if (ret < 0) {
- LOGE("read :%s failed, ret:%d\n", CEC_FILE, ret);
+ ALOGE("read :%s failed, ret:%d\n", CEC_FILE, ret);
return -1;
}
@@ -245,31 +248,34 @@ void HdmiCecControl::getPortInfos(hdmi_port_info_t* list[], int* total)
if (assertHdmiCecDevice())
return;
- ioctl(mCecDevice->mFd, CEC_IOC_GET_PORT_NUM, total);
+ ioctl(mCecDevice.mFd, CEC_IOC_GET_PORT_NUM, total);
- LOGD("total port:%d", *total);
+ ALOGD("total port:%d", *total);
if (*total > MAX_PORT)
*total = MAX_PORT;
- mCecDevice->mpPortData = new hdmi_port_info[*total];
- if (!mCecDevice->mpPortData) {
- LOGE("alloc port_data failed");
+
+ if (NULL != mCecDevice.mpPortData)
+ delete mCecDevice.mpPortData;
+ mCecDevice.mpPortData = new hdmi_port_info[*total];
+ if (!mCecDevice.mpPortData) {
+ ALOGE("alloc port_data failed");
*total = 0;
return;
}
- ioctl(mCecDevice->mFd, CEC_IOC_GET_PORT_INFO, mCecDevice->mpPortData);
+ ioctl(mCecDevice.mFd, CEC_IOC_GET_PORT_INFO, mCecDevice.mpPortData);
for (int i = 0; i < *total; i++) {
- LOGD("port %d, type:%s, id:%d, cec support:%d, arc support:%d, physical address:%x",
- i, mCecDevice->mpPortData[i].type ? "output" : "input",
- mCecDevice->mpPortData[i].port_id,
- mCecDevice->mpPortData[i].cec_supported,
- mCecDevice->mpPortData[i].arc_supported,
- mCecDevice->mpPortData[i].physical_address);
+ ALOGD("port %d, type:%s, id:%d, cec support:%d, arc support:%d, physical address:%x",
+ i, mCecDevice.mpPortData[i].type ? "output" : "input",
+ mCecDevice.mpPortData[i].port_id,
+ mCecDevice.mpPortData[i].cec_supported,
+ mCecDevice.mpPortData[i].arc_supported,
+ mCecDevice.mpPortData[i].physical_address);
}
- *list = mCecDevice->mpPortData;
- mCecDevice->mTotalPort = *total;
+ *list = mCecDevice.mpPortData;
+ mCecDevice.mTotalPort = *total;
}
int HdmiCecControl::addLogicalAddress(cec_logical_address_t address)
@@ -278,10 +284,10 @@ int HdmiCecControl::addLogicalAddress(cec_logical_address_t address)
return -EINVAL;
if (address < CEC_ADDR_BROADCAST)
- mCecDevice->mAddrBitmap |= (1 << address);
+ mCecDevice.mAddrBitmap |= (1 << address);
- if (mCecDevice->mDeviceType == DEV_TYPE_PLAYBACK && mCecDevice->mExtendControl) {
- mCecDevice->mExtendControl |= (0x02);
+ if (mCecDevice.mDeviceType == DEV_TYPE_PLAYBACK && mCecDevice.mExtendControl) {
+ mCecDevice.mExtendControl |= (0x02);
if (mEventListener != NULL) {
hdmi_cec_event_t event;
event.eventType = HDMI_EVENT_ADD_LOGICAL_ADDRESS;
@@ -289,8 +295,8 @@ int HdmiCecControl::addLogicalAddress(cec_logical_address_t address)
mEventListener->onEventUpdate(&event);
}
}
- LOGD("addr:%x, bitmap:%x\n", address, mCecDevice->mAddrBitmap);
- return ioctl(mCecDevice->mFd, CEC_IOC_ADD_LOGICAL_ADDR, address);
+ ALOGD("addr:%x, bitmap:%x\n", address, mCecDevice.mAddrBitmap);
+ return ioctl(mCecDevice.mFd, CEC_IOC_ADD_LOGICAL_ADDR, address);
}
void HdmiCecControl::clearLogicaladdress()
@@ -298,13 +304,13 @@ void HdmiCecControl::clearLogicaladdress()
if (assertHdmiCecDevice())
return;
- mCecDevice->mAddrBitmap = (1 << CEC_ADDR_BROADCAST);
- LOGD("bitmap:%x", mCecDevice->mAddrBitmap);
- if (mCecDevice->mExtendControl) {
- mCecDevice->mExtendControl &= ~(0x02);
+ mCecDevice.mAddrBitmap = (1 << CEC_ADDR_BROADCAST);
+ ALOGD("bitmap:%x", mCecDevice.mAddrBitmap);
+ if (mCecDevice.mExtendControl) {
+ mCecDevice.mExtendControl &= ~(0x02);
}
- ioctl(mCecDevice->mFd, CEC_IOC_CLR_LOGICAL_ADDR, 0);
+ ioctl(mCecDevice.mFd, CEC_IOC_CLR_LOGICAL_ADDR, 0);
}
void HdmiCecControl::setOption(int flag, int value)
@@ -315,32 +321,32 @@ void HdmiCecControl::setOption(int flag, int value)
int ret = -1;
switch (flag) {
case HDMI_OPTION_ENABLE_CEC:
- ret = ioctl(mCecDevice->mFd, CEC_IOC_SET_OPTION_ENALBE_CEC, value);
- mCecDevice->isCecEnabled = (value == 1) ? true : false;
+ ret = ioctl(mCecDevice.mFd, CEC_IOC_SET_OPTION_ENALBE_CEC, value);
+ mCecDevice.isCecEnabled = (value == 1) ? true : false;
break;
case HDMI_OPTION_WAKEUP:
- ret = ioctl(mCecDevice->mFd, CEC_IOC_SET_OPTION_WAKEUP, value);
+ ret = ioctl(mCecDevice.mFd, CEC_IOC_SET_OPTION_WAKEUP, value);
break;
case HDMI_OPTION_SYSTEM_CEC_CONTROL:
- ret = ioctl(mCecDevice->mFd, CEC_IOC_SET_OPTION_SYS_CTRL, value);
- mCecDevice->isCecControlled = (value == 1) ? true : false;
+ ret = ioctl(mCecDevice.mFd, CEC_IOC_SET_OPTION_SYS_CTRL, value);
+ mCecDevice.isCecControlled = (value == 1) ? true : false;
break;
/* set device auto-power off by uboot */
case HDMI_OPTION_CEC_AUTO_DEVICE_OFF:
- ret = ioctl(mCecDevice->mFd, CEC_IOC_SET_AUTO_DEVICE_OFF, value);
+ ret = ioctl(mCecDevice.mFd, CEC_IOC_SET_AUTO_DEVICE_OFF, value);
break;
case HDMI_OPTION_SET_LANG:
- ret = ioctl(mCecDevice->mFd, CEC_IOC_SET_OPTION_SET_LANG, value);
+ ret = ioctl(mCecDevice.mFd, CEC_IOC_SET_OPTION_SET_LANG, value);
break;
default:
break;
}
- LOGD("%s, flag:0x%x, value:0x%x, ret:%d, isCecControlled:%x", __FUNCTION__, flag, value, ret, mCecDevice->isCecControlled);
+ ALOGD("%s, flag:0x%x, value:0x%x, ret:%d, isCecControlled:%x", __FUNCTION__, flag, value, ret, mCecDevice.isCecControlled);
}
void HdmiCecControl::setAudioReturnChannel(int port, bool flag)
@@ -348,8 +354,8 @@ void HdmiCecControl::setAudioReturnChannel(int port, bool flag)
if (assertHdmiCecDevice())
return;
- int ret = ioctl(mCecDevice->mFd, CEC_IOC_SET_ARC_ENABLE, flag);
- LOGD("%s, port id:%d, flag:%x, ret:%d\n", __FUNCTION__, port, flag, ret);
+ int ret = ioctl(mCecDevice.mFd, CEC_IOC_SET_ARC_ENABLE, flag);
+ ALOGD("%s, port id:%d, flag:%x, ret:%d\n", __FUNCTION__, port, flag, ret);
}
bool HdmiCecControl::isConnected(int port)
@@ -360,10 +366,10 @@ bool HdmiCecControl::isConnected(int port)
int status = -1, ret;
/* use status pass port id */
status = port;
- ret = ioctl(mCecDevice->mFd, CEC_IOC_GET_CONNECT_STATUS, &status);
+ ret = ioctl(mCecDevice.mFd, CEC_IOC_GET_CONNECT_STATUS, &status);
if (ret)
return false;
- LOGD("%s, port:%d, connected:%s", __FUNCTION__, port, status ? "yes" : "no");
+ ALOGD("%s, port:%d, connected:%s", __FUNCTION__, port, status ? "yes" : "no");
return status;
}
@@ -372,8 +378,8 @@ int HdmiCecControl::getVersion(int* version)
if (assertHdmiCecDevice())
return -1;
- int ret = ioctl(mCecDevice->mFd, CEC_IOC_GET_VERSION, version);
- LOGD("%s, version:%x, ret = %d", __FUNCTION__, *version, ret);
+ int ret = ioctl(mCecDevice.mFd, CEC_IOC_GET_VERSION, version);
+ ALOGD("%s, version:%x, ret = %d", __FUNCTION__, *version, ret);
return ret;
}
@@ -382,8 +388,8 @@ int HdmiCecControl::getVendorId(uint32_t* vendorId)
if (assertHdmiCecDevice())
return -1;
- int ret = ioctl(mCecDevice->mFd, CEC_IOC_GET_VENDOR_ID, vendorId);
- LOGD("%s, vendorId: %x, ret = %d", __FUNCTION__, *vendorId, ret);
+ int ret = ioctl(mCecDevice.mFd, CEC_IOC_GET_VENDOR_ID, vendorId);
+ ALOGD("%s, vendorId: %x, ret = %d", __FUNCTION__, *vendorId, ret);
return ret;
}
@@ -392,8 +398,8 @@ int HdmiCecControl::getPhysicalAddress(uint16_t* addr)
if (assertHdmiCecDevice())
return -EINVAL;
- int ret = ioctl(mCecDevice->mFd, CEC_IOC_GET_PHYSICAL_ADDR, addr);
- LOGD("%s, physical addr: %x, ret = %d", __FUNCTION__, *addr, ret);
+ int ret = ioctl(mCecDevice.mFd, CEC_IOC_GET_PHYSICAL_ADDR, addr);
+ ALOGD("%s, physical addr: %x, ret = %d", __FUNCTION__, *addr, ret);
return ret;
}
@@ -403,11 +409,11 @@ int HdmiCecControl::sendMessage(const cec_message_t* message, bool isExtend)
return -EINVAL;
if (isExtend) {
- LOGD("isExtend = %d, mExtendControl = %d", isExtend, mCecDevice->mExtendControl);
+ ALOGD("isExtend = %d, mExtendControl = %d", isExtend, mCecDevice.mExtendControl);
return sendExtMessage(message);
}
/* don't send message if controlled by extend */
- if (mCecDevice->mExtendControl == 0x03 && hasHandledByExtend(message)) {
+ if (mCecDevice.mExtendControl == 0x03 && hasHandledByExtend(message)) {
return HDMI_RESULT_SUCCESS;
}
@@ -432,8 +438,8 @@ int HdmiCecControl::sendExtMessage(const cec_message_t* message)
{
int i, addr;
cec_message_t msg;
- if (mCecDevice->mDeviceType == DEV_TYPE_PLAYBACK) {
- addr = mCecDevice->mAddrBitmap;
+ if (mCecDevice.mDeviceType == DEV_TYPE_PLAYBACK) {
+ addr = mCecDevice.mAddrBitmap;
addr &= 0x7fff;
for (i = 0; i < 15; i++) {
if (addr & 1) {
@@ -461,14 +467,14 @@ int HdmiCecControl::send(const cec_message_t* message)
memset(msg_buf, 0, sizeof(msg_buf));
msg_buf[0] = ((message->initiator & 0xf) << 4) | (message->destination & 0xf);
memcpy(msg_buf + 1, message->body, message->length);
- ret = write(mCecDevice->mFd, msg_buf, message->length + 1);
+ ret = write(mCecDevice.mFd, msg_buf, message->length + 1);
printCecMessage(message, ret);
return ret;
}
bool HdmiCecControl::assertHdmiCecDevice()
{
- return !mCecDevice || mCecDevice->mFd < 0;
+ return mCecDevice.mFd < 0;
}
void HdmiCecControl::setEventObserver(const sp<HdmiCecEventListener> &eventListener)
@@ -476,6 +482,4 @@ void HdmiCecControl::setEventObserver(const sp<HdmiCecEventListener> &eventListe
mEventListener = eventListener;
}
-
-
};//namespace android
diff --git a/services/hdmicec/libhdmi_cec/HdmiCecControl.h b/services/hdmicec/libhdmi_cec/HdmiCecControl.h
index d49bf24..99ad506 100644
--- a/services/hdmicec/libhdmi_cec/HdmiCecControl.h
+++ b/services/hdmicec/libhdmi_cec/HdmiCecControl.h
@@ -111,7 +111,7 @@ private:
bool assertHdmiCecDevice();
bool hasHandledByExtend(const cec_message_t* message);
- hdmi_device_t *mCecDevice;
+ hdmi_device_t mCecDevice;
sp<HdmiCecEventListener> mEventListener;
};
diff --git a/services/hdmicec/server/Android.mk b/services/hdmicec/server/Android.mk
index a5f7ffd..e348720 100644
--- a/services/hdmicec/server/Android.mk
+++ b/services/hdmicec/server/Android.mk
@@ -3,14 +3,21 @@ include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES:= \
- main.cpp \
- HdmiCecService.cpp
+ main_hdmicec.cpp \
+ HdmiCecService.cpp \
+ DroidHdmiCec.cpp
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/../libhdmi_cec \
- $(LOCAL_PATH)/../binder
+ $(LOCAL_PATH)/../binder \
+ external/libcxx/include \
+ system/libhidl/transport/include/hidl
LOCAL_SHARED_LIBRARIES := \
+ vendor.amlogic.hardware.hdmicec@1.0_vendor \
+ libbase \
+ libhidlbase \
+ libhidltransport \
libcutils \
libutils \
libbinder \
@@ -20,10 +27,14 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_STATIC_LIBRARIES := \
libhdmi_cec_static
-LOCAL_MODULE:= hdmi_cec
+LOCAL_CPPFLAGS += -std=c++14
+LOCAL_INIT_RC := hdmicecd.rc
+
+LOCAL_MODULE:= hdmicecd
+
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26 && echo OK),OK)
LOCAL_PROPRIETARY_MODULE := true
endif
-include $(BUILD_EXECUTABLE) \ No newline at end of file
+include $(BUILD_EXECUTABLE)
diff --git a/services/hdmicec/server/DroidHdmiCec.cpp b/services/hdmicec/server/DroidHdmiCec.cpp
new file mode 100644
index 0000000..0760605
--- a/dev/null
+++ b/services/hdmicec/server/DroidHdmiCec.cpp
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2016 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.
+ * @author Tellen Yu
+ * @version 1.0
+ * @date 2017/9/25
+ * @par function description:
+ * - 1 droidlogic hdmi cec hwbinder service
+ */
+
+#define LOG_TAG "hdmicecd"
+
+#include <inttypes.h>
+#include <string>
+#include "../binder/HdmiCecBase.h"
+#include "DroidHdmiCec.h"
+
+namespace vendor {
+namespace amlogic {
+namespace hardware {
+namespace hdmicec {
+namespace V1_0 {
+namespace implementation {
+
+
+void DroidHdmiCec::instantiate()
+{
+ DroidHdmiCec *pcec = new DroidHdmiCec();
+}
+
+DroidHdmiCec::DroidHdmiCec()
+{
+ mHdmiCecControl = new HdmiCecControl();
+ mHdmiCecControl->setEventObserver(this);
+}
+
+DroidHdmiCec::~DroidHdmiCec()
+{
+ delete mHdmiCecControl;
+}
+
+Return<void> DroidHdmiCec::openCecDevice(openCecDevice_cb _hidl_cb)
+{
+ int32_t fd = -1;
+ if (NULL != mHdmiCecControl) {
+ fd = mHdmiCecControl->openCecDevice();
+ }
+
+ _hidl_cb(Result::SUCCESS, fd);
+ return Void();
+}
+
+Return<void> DroidHdmiCec::closeCecDevice()
+{
+ if (NULL != mHdmiCecControl) {
+ mHdmiCecControl->closeCecDevice();
+ }
+ return Void();
+}
+
+Return<int32_t> DroidHdmiCec::getCecVersion()
+{
+ int version = 0;
+ if (NULL != mHdmiCecControl) {
+ return mHdmiCecControl->getVersion(&version);
+ }
+ return version;
+}
+
+Return<uint32_t> DroidHdmiCec::getVendorId()
+{
+ uint32_t vendorId = 0;
+ if (NULL != mHdmiCecControl) {
+ return mHdmiCecControl->getVendorId(&vendorId);
+ }
+ return vendorId;
+}
+
+Return<void> DroidHdmiCec::getPhysicalAddress(getPhysicalAddress_cb _hidl_cb)
+{
+ uint16_t addr = 0;
+ if (NULL != mHdmiCecControl) {
+ mHdmiCecControl->getPhysicalAddress(&addr);
+ }
+
+ _hidl_cb(Result::SUCCESS, addr);
+ return Void();
+}
+
+Return<SendMessageResult> DroidHdmiCec::sendMessage(const CecMessage& message, bool isExtend)
+{
+ if (message.body.size() > CEC_MESSAGE_BODY_MAX_LENGTH) {
+ ALOGE("sendMessage body size > %d", CEC_MESSAGE_BODY_MAX_LENGTH);
+ return static_cast<SendMessageResult>(HDMI_RESULT_FAIL);
+ }
+
+ if (NULL != mHdmiCecControl) {
+ //change message from hwbinder data structure to needed data structure
+ cec_message_t msg;
+ msg.initiator = static_cast<cec_logical_address_t>(message.initiator);
+ msg.destination = static_cast<cec_logical_address_t>(message.destination);
+
+ for (size_t i = 0; i < message.body.size(); ++i) {
+ msg.body[i] = message.body[i];
+ }
+ msg.length = message.body.size();
+
+ return static_cast<SendMessageResult>(mHdmiCecControl->sendMessage(&msg, isExtend));
+ }
+ return static_cast<SendMessageResult>(HDMI_RESULT_FAIL);
+}
+
+Return<void> DroidHdmiCec::getPortInfo(getPortInfo_cb _hidl_cb)
+{
+ hdmi_port_info_t *legacyPorts;
+ int numPorts;
+ hidl_vec<HdmiPortInfo> portInfos;
+ if (NULL != mHdmiCecControl) {
+
+ mHdmiCecControl->getPortInfos(&legacyPorts, &numPorts);
+ portInfos.resize(numPorts);
+ for (int i = 0; i < numPorts; ++i) {
+ portInfos[i] = {
+ .type = static_cast<HdmiPortType>(legacyPorts[i].type),
+ .portId = static_cast<uint32_t>(legacyPorts[i].port_id),
+ .cecSupported = legacyPorts[i].cec_supported != 0,
+ .arcSupported = legacyPorts[i].arc_supported != 0,
+ .physicalAddress = legacyPorts[i].physical_address
+ };
+ /*
+ ALOGD("droidhdmicec port %d, type:%s, id:%d, cec support:%d, arc support:%d, physical address:%x",
+ i, (HDMI_OUTPUT==static_cast<hdmi_port_type_t>(portInfos[i].type)) ? "output" : "input",
+ portInfos[i].portId,
+ portInfos[i].cecSupported?1:0,
+ portInfos[i].arcSupported?1:0,
+ portInfos[i].physicalAddress);*/
+ }
+
+ _hidl_cb(portInfos);
+ }
+ return Void();
+
+}
+
+Return<Result> DroidHdmiCec::addLogicalAddress(CecLogicalAddress addr)
+{
+ if (NULL != mHdmiCecControl) {
+ mHdmiCecControl->addLogicalAddress(static_cast<cec_logical_address_t>(addr));
+ return Result::SUCCESS;
+ }
+ return Result::FAILURE_UNKNOWN;
+}
+
+Return<void> DroidHdmiCec::clearLogicalAddress()
+{
+ if (NULL != mHdmiCecControl) {
+ mHdmiCecControl->clearLogicaladdress();
+ }
+ return Void();
+}
+
+Return<void> DroidHdmiCec::setOption(OptionKey key, bool value)
+{
+ if (NULL != mHdmiCecControl) {
+ mHdmiCecControl->setOption((int)key, value);
+ }
+ return Void();
+}
+
+Return<void> DroidHdmiCec::enableAudioReturnChannel(int32_t portId, bool enable)
+{
+ if (NULL != mHdmiCecControl) {
+ mHdmiCecControl->setAudioReturnChannel(portId, enable);
+ }
+ return Void();
+}
+
+Return<bool> DroidHdmiCec::isConnected(int32_t portId)
+{
+ if (NULL != mHdmiCecControl) {
+ return mHdmiCecControl->isConnected(portId);
+ }
+ return false;
+}
+
+Return<void> DroidHdmiCec::setCallback(const sp<IDroidHdmiCecCallback>& callback)
+{
+ if (callback != NULL) {
+ mClients.push_back(callback);
+ }
+ return Void();
+}
+
+void DroidHdmiCec::onEventUpdate(const hdmi_cec_event_t* event)
+{
+ //change native data structure to hwbinder data structure
+ CecEvent hidlEvent;
+ hidlEvent.eventType = event->eventType;
+ if (HDMI_EVENT_ADD_LOGICAL_ADDRESS == event->eventType) {
+ hidlEvent.logicalAddress = event->logicalAddress;
+ }
+ else if (HDMI_EVENT_HOT_PLUG == event->eventType) {
+ hidlEvent.hotplug.connected = (0 == event->hotplug.connected)?false:true;
+ hidlEvent.hotplug.portId = event->hotplug.port_id;
+ }
+ //HDMI_EVENT_CEC_MESSAGE or HDMI_EVENT_RECEIVE_MESSAGE
+ else if (0 != event->eventType) {
+ hidlEvent.cec.initiator = static_cast<CecLogicalAddress>(event->cec.initiator);
+ hidlEvent.cec.destination = static_cast<CecLogicalAddress>(event->cec.destination);
+ for (size_t i = 0; i < event->cec.length; i++) {
+ hidlEvent.cec.body[i] = event->cec.body[i];
+ }
+ }
+
+ int clientSize = mClients.size();
+ ALOGV("%s, %s, client size:%d", __FUNCTION__, getEventType(event->eventType), clientSize);
+
+ for (int i = 0; i < clientSize; i++) {
+ mClients[i]->notifyCallback(hidlEvent);
+ }
+}
+
+const char* DroidHdmiCec::getEventType(int eventType)
+{
+ switch (eventType) {
+ case HDMI_EVENT_CEC_MESSAGE:
+ return "cec message";
+ case HDMI_EVENT_HOT_PLUG:
+ return "hotplug message";
+ case HDMI_EVENT_ADD_LOGICAL_ADDRESS:
+ return "add logical address for extend";
+ case HDMI_EVENT_RECEIVE_MESSAGE:
+ return "cec message for extend";
+ case (HDMI_EVENT_CEC_MESSAGE | HDMI_EVENT_RECEIVE_MESSAGE):
+ return "cec message for system and extend";
+ default:
+ return "unknown message";
+ }
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace hdmicec
+} // namespace hardware
+} // namespace amlogic
+} // namespace vendor
diff --git a/services/hdmicec/server/DroidHdmiCec.h b/services/hdmicec/server/DroidHdmiCec.h
new file mode 100644
index 0000000..c060f6a
--- a/dev/null
+++ b/services/hdmicec/server/DroidHdmiCec.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2016 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.
+ * @author Tellen Yu
+ * @version 1.0
+ * @date 2017/9/25
+ * @par function description:
+ * - 1 droidlogic hdmi cec hwbinder service
+ */
+
+#ifndef ANDROID_DROIDLOGIC_HDMI_CEC_V1_0_H
+#define ANDROID_DROIDLOGIC_HDMI_CEC_V1_0_H
+
+#include <utils/Mutex.h>
+#include <vector>
+#include <HdmiCecControl.h>
+#include <vendor/amlogic/hardware/hdmicec/1.0/IDroidHdmiCEC.h>
+
+namespace vendor {
+namespace amlogic {
+namespace hardware {
+namespace hdmicec {
+namespace V1_0 {
+namespace implementation {
+
+using ::vendor::amlogic::hardware::hdmicec::V1_0::IDroidHdmiCEC;
+using ::vendor::amlogic::hardware::hdmicec::V1_0::IDroidHdmiCecCallback;
+using ::vendor::amlogic::hardware::hdmicec::V1_0::Result;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+using namespace android;
+
+class DroidHdmiCec : public IDroidHdmiCEC, public HdmiCecEventListener {
+public:
+ DroidHdmiCec();
+ virtual ~DroidHdmiCec();
+
+ Return<void> openCecDevice(openCecDevice_cb _hidl_cb) override;
+ Return<void> closeCecDevice() override;
+ Return<int32_t> getCecVersion() override;
+ Return<uint32_t> getVendorId() override;
+ Return<void> getPhysicalAddress(getPhysicalAddress_cb _hidl_cb) override;
+ Return<SendMessageResult> sendMessage(const CecMessage& message, bool isExtend) override;
+
+ Return<void> getPortInfo(getPortInfo_cb _hidl_cb) override;
+ Return<Result> addLogicalAddress(CecLogicalAddress addr) override;
+ Return<void> clearLogicalAddress() override;
+ Return<void> setOption(OptionKey key, bool value) override;
+ Return<void> enableAudioReturnChannel(int32_t portId, bool enable) override;
+ Return<bool> isConnected(int32_t portId) override;
+
+ Return<void> setCallback(const sp<IDroidHdmiCecCallback>& callback) override;
+
+ virtual void onEventUpdate(const hdmi_cec_event_t* event);
+
+ static void instantiate();
+
+private:
+ const char* getEventType(int eventType);
+
+ HdmiCecControl *mHdmiCecControl;
+ std::vector<sp<IDroidHdmiCecCallback>> mClients;
+
+ mutable Mutex mLock;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace hdmicec
+} // namespace hardware
+} // namespace amlogic
+} // namespace vendor
+#endif /* ANDROID_DROIDLOGIC_HDMI_CEC_V1_0_H */
diff --git a/services/hdmicec/server/hdmicecd.rc b/services/hdmicec/server/hdmicecd.rc
new file mode 100644
index 0000000..8a4ad44
--- a/dev/null
+++ b/services/hdmicec/server/hdmicecd.rc
@@ -0,0 +1,6 @@
+on early-boot
+ start hdmicecd
+
+service hdmicecd /vendor/bin/hdmicecd
+ user root
+ group system
diff --git a/services/hdmicec/server/main.cpp b/services/hdmicec/server/main.cpp
deleted file mode 100644
index 7fe4589..0000000
--- a/services/hdmicec/server/main.cpp
+++ b/dev/null
@@ -1,22 +0,0 @@
-#define LOG_NDEBUG 0
-#define LOG_TAG "HdmiCecService"
-
-#include <binder/IPCThreadState.h>
-#include <binder/ProcessState.h>
-#include <binder/IServiceManager.h>
-
-#include "HdmiCecService.h"
-
-using namespace android;
-
-int main(int argc __unused, char** argv __unused)
-{
- sp<ProcessState> proc(ProcessState::self());
- sp<IServiceManager> sm = defaultServiceManager();
- HdmiCecService::instantiate();
- ProcessState::self()->startThreadPool();
- IPCThreadState::self()->joinThreadPool();
-
- return 0;
-}
-
diff --git a/services/hdmicec/server/main_hdmicec.cpp b/services/hdmicec/server/main_hdmicec.cpp
new file mode 100644
index 0000000..38b33e1
--- a/dev/null
+++ b/services/hdmicec/server/main_hdmicec.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 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.
+ * @author Tellen Yu
+ * @version 1.0
+ * @date 2017/9/25
+ * @par function description:
+ * - 1 droidlogic hdmi cec daemon
+ */
+
+#define LOG_TAG "hdmicecd"
+
+#include <binder/IPCThreadState.h>
+#include <binder/ProcessState.h>
+#include <binder/IServiceManager.h>
+#include <cutils/properties.h>
+#include <HidlTransportSupport.h>
+
+#include "HdmiCecService.h"
+#include "DroidHdmiCec.h"
+
+using namespace android;
+using ::android::hardware::configureRpcThreadpool;
+using ::vendor::amlogic::hardware::hdmicec::V1_0::implementation::DroidHdmiCec;
+using ::vendor::amlogic::hardware::hdmicec::V1_0::IDroidHdmiCEC;
+
+
+int main(int argc __unused, char** argv __unused)
+{
+ bool treble = property_get_bool("persist.hdmi_cec.treble", true);
+ if (treble) {
+ android::ProcessState::initWithDriver("/dev/vndbinder");
+ }
+
+ ALOGI("hdmi cec daemon starting in %s mode", treble?"treble":"normal");
+ configureRpcThreadpool(4, false);
+ sp<ProcessState> proc(ProcessState::self());
+
+ if (treble) {
+ sp<IDroidHdmiCEC>hidlHdmiCec = new DroidHdmiCec();
+ if (hidlHdmiCec == nullptr) {
+ ALOGE("Cannot create IDroidHdmiCEC service");
+ } else if (hidlHdmiCec->registerAsService() != OK) {
+ ALOGE("Cannot register IDroidHdmiCEC service.");
+ } else {
+ ALOGI("Treble IDroidHdmiCEC service created.");
+ }
+ }
+ else {
+ HdmiCecService::instantiate();
+ }
+
+ /*
+ * This thread is just going to process Binder transactions.
+ */
+ IPCThreadState::self()->joinThreadPool();
+}
+
diff --git a/services/systemcontrol/Android.mk b/services/systemcontrol/Android.mk
index 88dc167..f940def 100644
--- a/services/systemcontrol/Android.mk
+++ b/services/systemcontrol/Android.mk
@@ -2,6 +2,7 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
+ SystemControlClient.cpp \
ISystemControlService.cpp \
ISystemControlNotify.cpp
@@ -11,6 +12,12 @@ LOCAL_SHARED_LIBRARIES := \
liblog \
libbinder
+LOCAL_SHARED_LIBRARIES += \
+ vendor.amlogic.hardware.systemcontrol@1.0_vendor \
+ libbase \
+ libhidlbase \
+ libhidltransport
+
LOCAL_MODULE:= libsystemcontrolservice
LOCAL_MODULE_TAGS := optional
@@ -50,6 +57,7 @@ LOCAL_SRC_FILES:= \
SysWrite.cpp \
SystemControl.cpp \
SystemControlHal.cpp \
+ SystemControlService.cpp \
DisplayMode.cpp \
Dimension.cpp \
SysTokenizer.cpp \
@@ -74,14 +82,15 @@ LOCAL_SHARED_LIBRARIES := \
libm
LOCAL_SHARED_LIBRARIES += \
- vendor.amlogic.hardware.systemcontrol@1.0 \
+ vendor.amlogic.hardware.systemcontrol@1.0_vendor \
libbase \
libhidlbase \
libhidltransport
LOCAL_C_INCLUDES := \
external/zlib \
- external/libcxx/include
+ external/libcxx/include \
+ system/libhidl/transport/include/hidl
LOCAL_MODULE:= systemcontrol
diff --git a/services/systemcontrol/DisplayMode.cpp b/services/systemcontrol/DisplayMode.cpp
index b5d32b5..64f8599 100644
--- a/services/systemcontrol/DisplayMode.cpp
+++ b/services/systemcontrol/DisplayMode.cpp
@@ -1525,7 +1525,7 @@ void DisplayMode::notifyEvent(int event) {
}
}
-void DisplayMode::setListener(const sp<ISystemControlNotify>& listener) {
+void DisplayMode::setListener(const sp<SystemControlNotify>& listener) {
mNotifyListener = listener;
}
#endif
diff --git a/services/systemcontrol/DisplayMode.h b/services/systemcontrol/DisplayMode.h
index 82ee9d6..827a5da 100644
--- a/services/systemcontrol/DisplayMode.h
+++ b/services/systemcontrol/DisplayMode.h
@@ -39,7 +39,7 @@
#include "ubootenv/Ubootenv.h"
#ifndef RECOVERY_MODE
-#include "ISystemControlNotify.h"
+#include "SystemControlNotify.h"
using namespace android;
#endif
@@ -429,7 +429,7 @@ public:
HDCPTxAuth *geTxAuth();
#ifndef RECOVERY_MODE
void notifyEvent(int event);
- void setListener(const sp<ISystemControlNotify>& listener);
+ void setListener(const sp<SystemControlNotify>& listener);
#endif
virtual void onTxEvent (char* switchName, char* hpdstate, int outputState);
@@ -496,7 +496,7 @@ private:
HDCPRxAuth *pRxAuth = NULL;
#ifndef RECOVERY_MODE
- sp<ISystemControlNotify> mNotifyListener;
+ sp<SystemControlNotify> mNotifyListener;
#endif
};
diff --git a/services/systemcontrol/SystemControl.cpp b/services/systemcontrol/SystemControl.cpp
index 5373b36..d53b2a0 100644
--- a/services/systemcontrol/SystemControl.cpp
+++ b/services/systemcontrol/SystemControl.cpp
@@ -40,6 +40,8 @@ namespace android {
SystemControl* SystemControl::instantiate(const char *cfgpath) {
SystemControl *syscontrol = new SystemControl(cfgpath);
+
+ //in full treble mode, only use hwbinder or vndbinder, can not use binder
android::status_t ret = defaultServiceManager()->addService(
String16("system_control"), syscontrol);
@@ -47,7 +49,6 @@ SystemControl* SystemControl::instantiate(const char *cfgpath) {
ALOGE("Couldn't register system control service!");
}
ALOGI("instantiate add system_control service result:%d", ret);
-
return syscontrol;
}
@@ -398,7 +399,7 @@ void SystemControl::setDigitalMode(const String16& mode) {
}
void SystemControl::setListener(const sp<ISystemControlNotify>& listener) {
- pDisplayMode->setListener(listener);
+ //pDisplayMode->setListener(listener);
}
void SystemControl::setOsdMouseMode(const String16& mode) {
diff --git a/services/systemcontrol/SystemControlClient.cpp b/services/systemcontrol/SystemControlClient.cpp
new file mode 100644
index 0000000..fd1f4c6
--- a/dev/null
+++ b/services/systemcontrol/SystemControlClient.cpp
@@ -0,0 +1,435 @@
+/*
+ * Copyright (C) 2011 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.
+ * @author tellen
+ * @version 1.0
+ * @date 2017/10/18
+ * @par function description:
+ * - 1 system control apis for other vendor process
+ */
+
+#define LOG_TAG "SystemControlClient"
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <android-base/logging.h>
+
+#include <SystemControlClient.h>
+
+namespace android {
+
+SystemControlClient::SystemControlClient() {
+ mSysCtrl = ISystemControl::getService();
+
+ mDeathRecipient = new SystemControlDeathRecipient();
+ Return<bool> linked = mSysCtrl->linkToDeath(mDeathRecipient, /*cookie*/ 0);
+ if (!linked.isOk()) {
+ LOG(ERROR) << "Transaction error in linking to system service death: " << linked.description().c_str();
+ } else if (!linked) {
+ LOG(ERROR) << "Unable to link to system service death notifications";
+ } else {
+ LOG(INFO) << "Link to system service death notification successful";
+ }
+}
+
+bool SystemControlClient::getProperty(const std::string& key, std::string& value) {
+ mSysCtrl->getProperty(key, [&value](const Result &ret, const hidl_string& v) {
+ if (Result::OK == ret) {
+ value = v;
+ }
+ });
+
+ return true;
+}
+
+bool SystemControlClient::getPropertyString(const std::string& key, std::string& value, std::string& def) {
+ mSysCtrl->getPropertyString(key, def, [&value](const Result &ret, const hidl_string& v) {
+ if (Result::OK == ret) {
+ value = v;
+ }
+ });
+
+ return true;
+}
+
+int32_t SystemControlClient::getPropertyInt(const std::string& key, int32_t def) {
+ int32_t result;
+ mSysCtrl->getPropertyInt(key, def, [&result](const Result &ret, const int32_t& v) {
+ if (Result::OK == ret) {
+ result = v;
+ }
+ });
+ return result;
+}
+
+int64_t SystemControlClient::getPropertyLong(const std::string& key, int64_t def) {
+ int64_t result;
+ mSysCtrl->getPropertyLong(key, def, [&result](const Result &ret, const int64_t& v) {
+ if (Result::OK == ret) {
+ result = v;
+ }
+ });
+ return result;
+}
+
+bool SystemControlClient::getPropertyBoolean(const std::string& key, bool def) {
+ bool result;
+ mSysCtrl->getPropertyBoolean(key, def, [&result](const Result &ret, const bool& v) {
+ if (Result::OK == ret) {
+ result = v;
+ }
+ });
+ return result;
+}
+
+void SystemControlClient::setProperty(const std::string& key, const std::string& value) {
+ mSysCtrl->setProperty(key, value);
+}
+
+bool SystemControlClient::readSysfs(const std::string& path, std::string& value) {
+ mSysCtrl->readSysfs(path, [&value](const Result &ret, const hidl_string& v) {
+ if (Result::OK == ret) {
+ value = v;
+ }
+ });
+
+ return true;
+}
+
+bool SystemControlClient::writeSysfs(const std::string& path, const std::string& value) {
+ Result rtn = mSysCtrl->writeSysfs(path, value);
+ if (rtn == Result::OK) {
+ return true;
+ }
+ return false;
+}
+
+bool SystemControlClient::writeSysfs(const std::string& path, const char *value, const int size) {
+ std::string writeValue(value, size);
+ Result rtn = mSysCtrl->writeSysfs(path, writeValue);
+ if (rtn == Result::OK) {
+ return true;
+ }
+ return false;
+}
+
+int32_t SystemControlClient::readHdcpRX22Key(char *value, int size) {
+ std::string key;
+ int32_t len;
+ mSysCtrl->readHdcpRX22Key(size, [&key, &len](const Result &ret, const hidl_string& v, const int32_t& l) {
+ if (Result::OK == ret) {
+ key = v;
+ len = l;
+ }
+ });
+
+ memcpy(value, key.c_str(), len);
+ return len;
+}
+
+bool SystemControlClient::writeHdcpRX22Key(const char *value, const int size) {
+ std::string key(value, size);
+ Result rtn = mSysCtrl->writeHdcpRX22Key(key);
+ if (rtn == Result::OK) {
+ return true;
+ }
+ return false;
+}
+
+int32_t SystemControlClient::readHdcpRX14Key(char *value, int size) {
+ std::string key;
+ int32_t len;
+ mSysCtrl->readHdcpRX14Key(size, [&key, &len](const Result &ret, const hidl_string& v, const int32_t& l) {
+ if (Result::OK == ret) {
+ key = v;
+ len = l;
+ }
+ });
+
+ memcpy(value, key.c_str(), len);
+ return len;
+}
+
+bool SystemControlClient::writeHdcpRX14Key(const char *value, const int size) {
+ std::string key(value, size);
+ Result rtn = mSysCtrl->writeHdcpRX14Key(key);
+ if (rtn == Result::OK) {
+ return true;
+ }
+ return false;
+}
+
+bool SystemControlClient::writeHdcpRXImg(const std::string& path) {
+ Result rtn = mSysCtrl->writeHdcpRXImg(path);
+ if (rtn == Result::OK) {
+ return true;
+ }
+ return false;
+}
+
+bool SystemControlClient::getBootEnv(const std::string& key, std::string& value) {
+ mSysCtrl->getBootEnv(key, [&value](const Result &ret, const hidl_string& v) {
+ if (Result::OK == ret) {
+ value = v;
+ }
+ });
+ return true;
+}
+
+void SystemControlClient::setBootEnv(const std::string& key, const std::string& value) {
+ mSysCtrl->setBootEnv(key, value);
+}
+
+void SystemControlClient::getDroidDisplayInfo(int &type, std::string& socType, std::string& defaultUI,
+ int &fb0w, int &fb0h, int &fb0bits, int &fb0trip,
+ int &fb1w, int &fb1h, int &fb1bits, int &fb1trip) {
+
+ mSysCtrl->getDroidDisplayInfo([&](const Result &ret, const DroidDisplayInfo& info) {
+ if (Result::OK == ret) {
+ type = info.type;
+ socType = info.socType;
+ defaultUI = info.defaultUI;
+ fb0w = info.fb0w;
+ fb0h = info.fb0h;
+ fb0bits = info.fb0bits;
+ fb0trip = info.fb0trip;
+ fb1w = info.fb1w;
+ fb1h = info.fb1h;
+ fb1bits = info.fb1bits;
+ fb1trip = info.fb1trip;
+ }
+ });
+}
+
+void SystemControlClient::loopMountUnmount(int &isMount, const std::string& path) {
+ mSysCtrl->loopMountUnmount(isMount, path);
+}
+
+void SystemControlClient::setMboxOutputMode(const std::string& mode) {
+ mSysCtrl->setSourceOutputMode(mode);
+}
+
+void SystemControlClient::setSinkOutputMode(const std::string& mode) {
+ mSysCtrl->setSinkOutputMode(mode);
+}
+
+void SystemControlClient::setDigitalMode(const std::string& mode) {
+ mSysCtrl->setDigitalMode(mode);
+}
+
+void SystemControlClient::setOsdMouseMode(const std::string& mode) {
+ mSysCtrl->setOsdMouseMode(mode);
+}
+
+void SystemControlClient::setOsdMousePara(int x, int y, int w, int h) {
+ mSysCtrl->setOsdMousePara(x, y, w, h);
+}
+
+void SystemControlClient::setPosition(int left, int top, int width, int height) {
+ mSysCtrl->setPosition(left, top, width, height);
+}
+
+void SystemControlClient::getPosition(const std::string& mode, int &outx, int &outy, int &outw, int &outh) {
+ mSysCtrl->getPosition(mode, [&outx, &outy, &outw, &outh](const Result &ret,
+ const int32_t& x, const int32_t& y, const int32_t& w, const int32_t& h) {
+ if (Result::OK == ret) {
+ outx = x;
+ outy = y;
+ outw = w;
+ outh = h;
+ }
+ });
+}
+
+void SystemControlClient::saveDeepColorAttr(const std::string& mode, const std::string& dcValue) {
+ mSysCtrl->saveDeepColorAttr(mode, dcValue);
+}
+
+void SystemControlClient::getDeepColorAttr(const std::string& mode, std::string& value) {
+ mSysCtrl->getDeepColorAttr(mode, [&value](const Result &ret, const hidl_string& v) {
+ if (Result::OK == ret) {
+ value = v;
+ }
+ });
+}
+
+void SystemControlClient::setDolbyVisionEnable(int state) {
+ mSysCtrl->setDolbyVisionState(state);
+}
+
+bool SystemControlClient::isTvSupportDolbyVision(std::string& mode) {
+ bool supported = false;
+ mSysCtrl->sinkSupportDolbyVision([&mode, &supported](const Result &ret, const hidl_string& sinkMode, const bool &isSupport) {
+ if (Result::OK == ret) {
+ mode = sinkMode;
+ supported = isSupport;
+ }
+ });
+
+ return supported;
+}
+
+int64_t SystemControlClient::resolveResolutionValue(const std::string& mode) {
+ int64_t value = 0;
+ mSysCtrl->resolveResolutionValue(mode, [&value](const Result &ret, const int64_t &v) {
+ if (Result::OK == ret) {
+ value = v;
+ }
+ });
+ return value;
+}
+
+void SystemControlClient::setHdrMode(const std::string& mode) {
+ mSysCtrl->setHdrMode(mode);
+}
+
+void SystemControlClient::setSdrMode(const std::string& mode) {
+ mSysCtrl->setSdrMode(mode);
+}
+
+void SystemControlClient::setListener(const sp<ISystemControlCallback> callback) {
+ Return<void> ret = mSysCtrl->setCallback(callback);
+}
+
+bool SystemControlClient::getSupportDispModeList(std::vector<std::string>& supportDispModes) {
+ mSysCtrl->getSupportDispModeList([&supportDispModes](const Result &ret, const hidl_vec<hidl_string> list) {
+ if (Result::OK == ret) {
+ for (size_t i = 0; i < list.size(); i++) {
+ supportDispModes.push_back(list[i]);
+ }
+ } else {
+ supportDispModes.clear();
+ }
+ });
+
+ if (supportDispModes.empty()) {
+ LOG(ERROR) << "syscontrol::readEdidList FAIL.";
+ return false;
+ }
+
+ return true;
+}
+
+bool SystemControlClient::getActiveDispMode(std::string& activeDispMode) {
+ mSysCtrl->getActiveDispMode([&activeDispMode](const Result &ret, const hidl_string& mode) {
+ if (Result::OK == ret)
+ activeDispMode = mode.c_str();
+ else
+ activeDispMode.clear();
+ });
+
+ if (activeDispMode.empty()) {
+ LOG(ERROR) << "system control client getActiveDispMode FAIL.";
+ return false;
+ }
+
+ return true;
+}
+
+bool SystemControlClient::setActiveDispMode(std::string& activeDispMode) {
+ Result rtn = mSysCtrl->setActiveDispMode(activeDispMode);
+ if (rtn == Result::OK) {
+ return true;
+ }
+ return false;
+}
+
+void SystemControlClient::isHDCPTxAuthSuccess(int &status) {
+ Result rtn = mSysCtrl->isHDCPTxAuthSuccess();
+ if (rtn == Result::OK) {
+ status = 1;
+ }
+ else {
+ status = 0;
+ }
+}
+
+//3D
+int32_t SystemControlClient::set3DMode(const std::string& mode3d) {
+ mSysCtrl->set3DMode(mode3d);
+ return 0;
+}
+
+void SystemControlClient::init3DSetting(void) {
+ mSysCtrl->init3DSetting();
+}
+
+int SystemControlClient::getVideo3DFormat(void) {
+ int32_t value = 0;
+ mSysCtrl->getVideo3DFormat([&value](const Result &ret, const int32_t &v) {
+ if (Result::OK == ret) {
+ value = v;
+ }
+ });
+ return value;
+}
+
+int SystemControlClient::getDisplay3DTo2DFormat(void) {
+ int32_t value = 0;
+ mSysCtrl->getDisplay3DTo2DFormat([&value](const Result &ret, const int32_t &v) {
+ if (Result::OK == ret) {
+ value = v;
+ }
+ });
+ return value;
+}
+
+bool SystemControlClient::setDisplay3DTo2DFormat(int format) {
+ mSysCtrl->setDisplay3DTo2DFormat(format);
+ return true;
+}
+
+bool SystemControlClient::setDisplay3DFormat(int format) {
+ mSysCtrl->setDisplay3DFormat(format);
+ return true;
+}
+
+int SystemControlClient::getDisplay3DFormat(void) {
+ int32_t value = 0;
+ mSysCtrl->getDisplay3DFormat([&value](const Result &ret, const int32_t &v) {
+ if (Result::OK == ret) {
+ value = v;
+ }
+ });
+ return value;
+}
+
+bool SystemControlClient::setOsd3DFormat(int format) {
+ mSysCtrl->setOsd3DFormat(format);
+ return true;
+}
+
+bool SystemControlClient::switch3DTo2D(int format) {
+ mSysCtrl->switch3DTo2D(format);
+ return true;
+}
+
+bool SystemControlClient::switch2DTo3D(int format) {
+ mSysCtrl->switch2DTo3D(format);
+ return true;
+}
+
+void SystemControlClient::autoDetect3DForMbox() {
+ mSysCtrl->autoDetect3DForMbox();
+}
+//3D end
+
+void SystemControlClient::SystemControlDeathRecipient::serviceDied(uint64_t cookie,
+ const ::android::wp<::android::hidl::base::V1_0::IBase>& who) {
+ LOG(ERROR) << "system control service died. need release some resources";
+}
+
+}; // namespace android
diff --git a/services/systemcontrol/SystemControlClient.h b/services/systemcontrol/SystemControlClient.h
new file mode 100644
index 0000000..d1493c9
--- a/dev/null
+++ b/services/systemcontrol/SystemControlClient.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2011 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.
+ * @author tellen
+ * @version 1.0
+ * @date 2017/10/18
+ * @par function description:
+ * - 1 system control apis for other vendor process
+ */
+
+#ifndef ANDROID_SYSTEMCONTROLCLIENT_H
+#define ANDROID_SYSTEMCONTROLCLIENT_H
+
+#include <utils/Errors.h>
+#include "ISystemControlNotify.h"
+#include <string>
+#include <vector>
+
+#include <vendor/amlogic/hardware/systemcontrol/1.0/ISystemControl.h>
+using ::vendor::amlogic::hardware::systemcontrol::V1_0::ISystemControl;
+using ::vendor::amlogic::hardware::systemcontrol::V1_0::ISystemControlCallback;
+using ::vendor::amlogic::hardware::systemcontrol::V1_0::Result;
+using ::vendor::amlogic::hardware::systemcontrol::V1_0::DroidDisplayInfo;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::hardware::Return;
+
+namespace android {
+
+class SystemControlClient
+{
+public:
+ SystemControlClient();
+
+ bool getProperty(const std::string& key, std::string& value);
+ bool getPropertyString(const std::string& key, std::string& value, std::string& def);
+ int32_t getPropertyInt(const std::string& key, int32_t def);
+ int64_t getPropertyLong(const std::string& key, int64_t def);
+
+ bool getPropertyBoolean(const std::string& key, bool def);
+ void setProperty(const std::string& key, const std::string& value);
+
+ bool readSysfs(const std::string& path, std::string& value);
+ bool writeSysfs(const std::string& path, const std::string& value);
+ bool writeSysfs(const std::string& path, const char *value, const int size);
+
+ int32_t readHdcpRX22Key(char *value, int size);
+ bool writeHdcpRX22Key(const char *value, const int size);
+ int32_t readHdcpRX14Key(char *value, int size);
+ bool writeHdcpRX14Key(const char *value, const int size);
+ bool writeHdcpRXImg(const std::string& path);
+
+ void setBootEnv(const std::string& key, const std::string& value);
+ bool getBootEnv(const std::string& key, std::string& value);
+ void getDroidDisplayInfo(int &type, std::string& socType, std::string& defaultUI,
+ int &fb0w, int &fb0h, int &fb0bits, int &fb0trip,
+ int &fb1w, int &fb1h, int &fb1bits, int &fb1trip);
+
+ void loopMountUnmount(int &isMount, const std::string& path);
+
+ void setMboxOutputMode(const std::string& mode);
+ void setSinkOutputMode(const std::string& mode);
+
+ void setDigitalMode(const std::string& mode);
+ void setListener(const sp<ISystemControlCallback> callback);
+ void setOsdMouseMode(const std::string& mode);
+ void setOsdMousePara(int x, int y, int w, int h);
+ void setPosition(int left, int top, int width, int height);
+ void getPosition(const std::string& mode, int &x, int &y, int &w, int &h);
+ void getDeepColorAttr(const std::string& mode, std::string& value);
+ void saveDeepColorAttr(const std::string& mode, const std::string& dcValue);
+ int64_t resolveResolutionValue(const std::string& mode);
+ void setDolbyVisionEnable(int state);
+ bool isTvSupportDolbyVision(std::string& mode);
+ void setHdrMode(const std::string& mode);
+ void setSdrMode(const std::string& mode);
+
+ int32_t set3DMode(const std::string& mode3d);
+ void init3DSetting(void);
+ int getVideo3DFormat(void);
+ int getDisplay3DTo2DFormat(void);
+ bool setDisplay3DTo2DFormat(int format);
+ bool setDisplay3DFormat(int format);
+ int getDisplay3DFormat(void);
+ bool setOsd3DFormat(int format);
+ bool switch3DTo2D(int format);
+ bool switch2DTo3D(int format);
+ void autoDetect3DForMbox(void);
+ bool getSupportDispModeList(std::vector<std::string>& supportDispModes);
+ bool getActiveDispMode(std::string& activeDispMode);
+ bool setActiveDispMode(std::string& activeDispMode);
+
+ void isHDCPTxAuthSuccess(int &status);
+
+ private:
+ struct SystemControlDeathRecipient : public android::hardware::hidl_death_recipient {
+ // hidl_death_recipient interface
+ virtual void serviceDied(uint64_t cookie,
+ const ::android::wp<::android::hidl::base::V1_0::IBase>& who) override;
+ };
+ sp<SystemControlDeathRecipient> mDeathRecipient = nullptr;
+
+ sp<ISystemControl> mSysCtrl;
+
+};
+
+}; // namespace android
+
+#endif // ANDROID_SYSTEMCONTROLCLIENT_H \ No newline at end of file
diff --git a/services/systemcontrol/SystemControlHal.cpp b/services/systemcontrol/SystemControlHal.cpp
index 3ffc2cb..51bc5cf 100644
--- a/services/systemcontrol/SystemControlHal.cpp
+++ b/services/systemcontrol/SystemControlHal.cpp
@@ -44,21 +44,34 @@ namespace systemcontrol {
namespace V1_0 {
namespace implementation {
-using ::vendor::amlogic::hardware::systemcontrol::V1_0::ISystemControl;
-using ::vendor::amlogic::hardware::systemcontrol::V1_0::Result;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-
-SystemControlHal::SystemControlHal(SystemControl * control)
+SystemControlHal::SystemControlHal(SystemControlService * control)
: mSysControl(control) {
+
+ control->setListener(this);
}
SystemControlHal::~SystemControlHal() {
}
+/*
+event:
+EVENT_OUTPUT_MODE_CHANGE = 0,
+EVENT_DIGITAL_MODE_CHANGE = 1,
+EVENT_HDMI_PLUG_OUT = 2,
+EVENT_HDMI_PLUG_IN = 3,
+EVENT_HDMI_AUDIO_OUT = 4,
+EVENT_HDMI_AUDIO_IN = 5,
+*/
+void SystemControlHal::onEvent(int event) {
+ int clientSize = mClients.size();
+
+ ALOGI("onEvent event:%d, client size:%d", event, clientSize);
+
+ for (int i = 0; i < clientSize; i++) {
+ mClients[i]->notifyCallback(event);
+ }
+}
+
Return<void> SystemControlHal::getSupportDispModeList(getSupportDispModeList_cb _hidl_cb) {
std::vector<std::string> supportModes;
mSysControl->getSupportDispModeList(&supportModes);
@@ -100,12 +113,303 @@ Return<Result> SystemControlHal::isHDCPTxAuthSuccess() {
return (status==1)?Result::OK:Result::FAIL;
}
-//ISystemControl* HIDL_FETCH_ISystemControl(const char* /* name */) {
-// return new SystemControlHal();
-//}
+Return<void> SystemControlHal::getProperty(const hidl_string &key, getProperty_cb _hidl_cb) {
+ std::string value;
+ mSysControl->getProperty(key, &value);
+
+ ALOGI("getProperty key :%s, value:%s", key.c_str(), value.c_str());
+ _hidl_cb(Result::OK, value);
+ return Void();
+}
+
+Return<void> SystemControlHal::getPropertyString(const hidl_string &key, const hidl_string &def, getPropertyString_cb _hidl_cb) {
+ std::string value;
+ mSysControl->getPropertyString(key, &value, def);
+
+ ALOGI("getPropertyString key :%s, value:%s", key.c_str(), value.c_str());
+ _hidl_cb(Result::OK, value);
+ return Void();
+}
+
+Return<void> SystemControlHal::getPropertyInt(const hidl_string &key, int32_t def, getPropertyInt_cb _hidl_cb) {
+ int32_t value = mSysControl->getPropertyInt(key, def);
+
+ ALOGI("getPropertyInt key :%s, value:%d", key.c_str(), value);
+ _hidl_cb(Result::OK, value);
+ return Void();
+}
+
+Return<void> SystemControlHal::getPropertyLong(const hidl_string &key, int64_t def, getPropertyLong_cb _hidl_cb) {
+ int64_t value = mSysControl->getPropertyLong(key, def);
+
+ ALOGI("getPropertyLong key :%s, value:%ld", key.c_str(), value);
+ _hidl_cb(Result::OK, value);
+ return Void();
+}
+
+Return<void> SystemControlHal::getPropertyBoolean(const hidl_string &key, bool def, getPropertyBoolean_cb _hidl_cb) {
+ bool value = mSysControl->getPropertyBoolean(key, def);
+
+ ALOGI("getPropertyBoolean key :%s, value:%d", key.c_str(), value);
+ _hidl_cb(Result::OK, value);
+ return Void();
+}
+
+Return<Result> SystemControlHal::setProperty(const hidl_string &key, const hidl_string &value) {
+ mSysControl->setProperty(key, value);
+
+ ALOGI("setProperty key :%s, value:%s", key.c_str(), value.c_str());
+ return Result::OK;
+}
+
+Return<void> SystemControlHal::readSysfs(const hidl_string &path, readSysfs_cb _hidl_cb) {
+ std::string value;
+ mSysControl->readSysfs(path, value);
+
+ ALOGI("readSysfs path :%s, value:%s", path.c_str(), value.c_str());
+ _hidl_cb(Result::OK, value);
+ return Void();
+}
+
+Return<Result> SystemControlHal::writeSysfs(const hidl_string &path, const hidl_string &value) {
+ ALOGI("writeSysfs path :%s, value:%s", path.c_str(), value.c_str());
+ return mSysControl->writeSysfs(path, value)?Result::OK:Result::FAIL;
+}
+
+Return<void> SystemControlHal::readHdcpRX22Key(int32_t size, readHdcpRX22Key_cb _hidl_cb) {
+ char *value = (char *)malloc(size);
+ int len = mSysControl->readHdcpRX22Key(value, size);
+
+ std::string valueStr(value, len);
+
+ ALOGI("readHdcpRX22Key size :%d, value:%s", size, value);
+ _hidl_cb(Result::OK, valueStr, len);
+ free(value);
+ return Void();
+}
+
+Return<Result> SystemControlHal::writeHdcpRX22Key(const hidl_string &key) {
+ ALOGI("writeHdcpRX22Key key:%s", key.c_str());
+ return mSysControl->writeHdcpRX22Key(key.c_str(), key.size())?Result::OK:Result::FAIL;
+}
+
+Return<void> SystemControlHal::readHdcpRX14Key(int32_t size, readHdcpRX14Key_cb _hidl_cb) {
+ char *value = (char *)malloc(size);
+ int len = mSysControl->readHdcpRX14Key(value, size);
+
+ std::string valueStr(value, len);
+
+ ALOGI("readHdcpRX14Key size :%d, value:%s", size, value);
+ _hidl_cb(Result::OK, valueStr, len);
+ free(value);
+ return Void();
+}
+
+Return<Result> SystemControlHal::writeHdcpRX14Key(const hidl_string &key) {
+ ALOGI("writeHdcpRX14Key key:%s", key.c_str());
+ return mSysControl->writeHdcpRX14Key(key.c_str(), key.size())?Result::OK:Result::FAIL;
+}
+
+Return<Result> SystemControlHal::writeHdcpRXImg(const hidl_string &path) {
+ ALOGI("writeHdcpRXImg path:%s", path.c_str());
+ return mSysControl->writeHdcpRXImg(path)?Result::OK:Result::FAIL;
+}
+
+Return<void> SystemControlHal::getBootEnv(const hidl_string &key, getBootEnv_cb _hidl_cb) {
+ std::string value;
+ mSysControl->getBootEnv(key, value);
+
+ ALOGI("getBootEnv key :%s, value:%s", key.c_str(), value.c_str());
+ _hidl_cb(Result::OK, value);
+ return Void();
+}
+
+Return<void> SystemControlHal::setBootEnv(const hidl_string &key, const hidl_string &value) {
+ mSysControl->setBootEnv(key, value);
+
+ ALOGI("setBootEnv key :%s, value:%s", key.c_str(), value.c_str());
+ return Void();
+}
+
+Return<void> SystemControlHal::getDroidDisplayInfo(getDroidDisplayInfo_cb _hidl_cb) {
+ DroidDisplayInfo info;
+
+ std::string type;
+ std::string ui;
+ mSysControl->getDroidDisplayInfo(info.type, type, ui,
+ info.fb0w, info.fb0h, info.fb0bits, info.fb0trip,
+ info.fb1w, info.fb1h, info.fb1bits, info.fb1trip);
+
+ info.socType = type;
+ info.defaultUI = ui;
+ _hidl_cb(Result::OK, info);
+ return Void();
+}
+
+Return<void> SystemControlHal::loopMountUnmount(int32_t isMount, const hidl_string& path) {
+ ALOGI("loopMountUnmount isMount :%d, path:%s", isMount, path.c_str());
+ mSysControl->loopMountUnmount(isMount, path);
+ return Void();
+}
+
+Return<void> SystemControlHal::setSourceOutputMode(const hidl_string& mode) {
+ ALOGI("setSourceOutputMode mode:%s", mode.c_str());
+ mSysControl->setSourceOutputMode(mode);
+ return Void();
+}
+
+Return<void> SystemControlHal::setSinkOutputMode(const hidl_string& mode) {
+ ALOGI("setSinkOutputMode mode:%s", mode.c_str());
+ mSysControl->setSinkOutputMode(mode);
+ return Void();
+}
+
+Return<void> SystemControlHal::setDigitalMode(const hidl_string& mode) {
+ ALOGI("setDigitalMode mode:%s", mode.c_str());
+ mSysControl->setDigitalMode(mode);
+ return Void();
+}
+
+Return<void> SystemControlHal::setOsdMouseMode(const hidl_string& mode) {
+ ALOGI("setOsdMouseMode mode:%s", mode.c_str());
+ mSysControl->setOsdMouseMode(mode);
+ return Void();
+}
+
+Return<void> SystemControlHal::setOsdMousePara(int32_t x, int32_t y, int32_t w, int32_t h) {
+ mSysControl->setOsdMousePara(x, y, w, h);
+ return Void();
+}
+
+Return<void> SystemControlHal::setPosition(int32_t left, int32_t top, int32_t width, int32_t height) {
+ mSysControl->setPosition(left, top, width, height);
+ return Void();
+}
+
+Return<void> SystemControlHal::getPosition(const hidl_string& mode, getPosition_cb _hidl_cb) {
+ int x, y, w, h;
+ mSysControl->getPosition(mode, x, y, w, h);
+ _hidl_cb(Result::OK, x, y, w, h);
+ return Void();
+}
+
+Return<void> SystemControlHal::saveDeepColorAttr(const hidl_string& mode, const hidl_string& dcValue) {
+ mSysControl->saveDeepColorAttr(mode, dcValue);
+ return Void();
+}
+
+Return<void> SystemControlHal::getDeepColorAttr(const hidl_string &mode, getDeepColorAttr_cb _hidl_cb) {
+ std::string value;
+ mSysControl->getDeepColorAttr(mode, value);
+
+ ALOGI("getDeepColorAttr mode :%s, value:%s", mode.c_str(), value.c_str());
+ _hidl_cb(Result::OK, value);
+ return Void();
+}
+
+Return<void> SystemControlHal::setDolbyVisionState(int32_t state) {
+ mSysControl->setDolbyVisionEnable(state);
+ return Void();
+}
+
+Return<void> SystemControlHal::sinkSupportDolbyVision(sinkSupportDolbyVision_cb _hidl_cb) {
+ std::string mode;
+ bool support = mSysControl->isTvSupportDolbyVision(mode);
+
+ ALOGI("getDeepColorAttr mode :%s, dv support:%d", mode.c_str(), support);
+ _hidl_cb(Result::OK, mode, support);
+ return Void();
+}
+
+Return<void> SystemControlHal::setHdrMode(const hidl_string& mode) {
+ ALOGI("setHdrMode mode:%s", mode.c_str());
+ mSysControl->setHdrMode(mode);
+ return Void();
+}
+
+Return<void> SystemControlHal::setSdrMode(const hidl_string& mode) {
+ ALOGI("setSdrMode mode:%s", mode.c_str());
+ mSysControl->setSdrMode(mode);
+ return Void();
+}
+
+Return<void> SystemControlHal::resolveResolutionValue(const hidl_string& mode, resolveResolutionValue_cb _hidl_cb) {
+ int64_t value = mSysControl->resolveResolutionValue(mode);
+ _hidl_cb(Result::OK, value);
+ return Void();
+}
+
+Return<void> SystemControlHal::setCallback(const sp<ISystemControlCallback>& callback) {
+ if (callback != nullptr) {
+ mClients.push_back(callback);
+ }
+ return Void();
+}
+
+//for 3D
+Return<void> SystemControlHal::set3DMode(const hidl_string& mode) {
+ ALOGI("set3DMode mode:%s", mode.c_str());
+ mSysControl->set3DMode(mode);
+ return Void();
+}
+
+Return<void> SystemControlHal::init3DSetting() {
+ mSysControl->init3DSetting();
+ return Void();
+}
+
+Return<void> SystemControlHal::getVideo3DFormat(getVideo3DFormat_cb _hidl_cb) {
+ int32_t format = mSysControl->getVideo3DFormat();
+ _hidl_cb(Result::OK, format);
+ return Void();
+}
+
+Return<void> SystemControlHal::getDisplay3DTo2DFormat(getDisplay3DTo2DFormat_cb _hidl_cb) {
+ int32_t format = mSysControl->getDisplay3DTo2DFormat();
+ _hidl_cb(Result::OK, format);
+ return Void();
+}
+
+Return<void> SystemControlHal::setDisplay3DTo2DFormat(int32_t format) {
+ mSysControl->setDisplay3DTo2DFormat(format);
+ return Void();
+}
+
+Return<void> SystemControlHal::setDisplay3DFormat(int32_t format) {
+ mSysControl->setDisplay3DFormat(format);
+ return Void();
+}
+
+Return<void> SystemControlHal::getDisplay3DFormat(getDisplay3DFormat_cb _hidl_cb) {
+ int32_t format = mSysControl->getDisplay3DFormat();
+ _hidl_cb(Result::OK, format);
+ return Void();
+}
+
+Return<void> SystemControlHal::setOsd3DFormat(int32_t format) {
+ mSysControl->setOsd3DFormat(format);
+ return Void();
+}
+
+Return<void> SystemControlHal::switch3DTo2D(int32_t format) {
+ mSysControl->switch3DTo2D(format);
+ return Void();
+}
+
+Return<void> SystemControlHal::switch2DTo3D(int32_t format) {
+ mSysControl->switch2DTo3D(format);
+ return Void();
+}
+
+Return<void> SystemControlHal::autoDetect3DForMbox() {
+ mSysControl->autoDetect3DForMbox();
+ return Void();
+}
+//3D end
+
} // namespace implementation
} // namespace V1_0
} // namespace systemcontrol
} // namespace hardware
} // namespace android
-} // namespace vendor \ No newline at end of file
+} // namespace vendor
diff --git a/services/systemcontrol/SystemControlHal.h b/services/systemcontrol/SystemControlHal.h
index f210fab..4dc17ad 100644
--- a/services/systemcontrol/SystemControlHal.h
+++ b/services/systemcontrol/SystemControlHal.h
@@ -23,7 +23,8 @@
#define ANDROID_DROIDLOGIC_SYSTEM_CONTROL_V1_0_SYSTEM_CONTROL_HAL_H
#include <vendor/amlogic/hardware/systemcontrol/1.0/ISystemControl.h>
-#include <SystemControl.h>
+#include <SystemControlNotify.h>
+#include <SystemControlService.h>
namespace vendor {
namespace amlogic {
@@ -33,28 +34,77 @@ namespace V1_0 {
namespace implementation {
using ::vendor::amlogic::hardware::systemcontrol::V1_0::ISystemControl;
+using ::vendor::amlogic::hardware::systemcontrol::V1_0::ISystemControlCallback;
using ::vendor::amlogic::hardware::systemcontrol::V1_0::Result;
+using ::vendor::amlogic::hardware::systemcontrol::V1_0::DroidDisplayInfo;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
-struct SystemControlHal : public ISystemControl {
+struct SystemControlHal : public ISystemControl, public SystemControlNotify {
public:
- SystemControlHal(SystemControl * control);
+ SystemControlHal(SystemControlService * control);
~SystemControlHal();
Return<void> getSupportDispModeList(getSupportDispModeList_cb _hidl_cb) override;
Return<void> getActiveDispMode(getActiveDispMode_cb _hidl_cb) override;
Return<Result> setActiveDispMode(const hidl_string &activeDispMode) override;
Return<Result> isHDCPTxAuthSuccess() override;
+ Return<void> getProperty(const hidl_string &key, getProperty_cb _hidl_cb) override;
+ Return<void> getPropertyString(const hidl_string &key, const hidl_string &def, getPropertyString_cb _hidl_cb) override;
+ Return<void> getPropertyInt(const hidl_string &key, int32_t def, getPropertyInt_cb _hidl_cb) override;
+ Return<void> getPropertyLong(const hidl_string &key, int64_t def, getPropertyLong_cb _hidl_cb) override;
+ Return<void> getPropertyBoolean(const hidl_string &key, bool def, getPropertyBoolean_cb _hidl_cb) override;
+ Return<Result> setProperty(const hidl_string &key, const hidl_string &value) override;
+ Return<void> readSysfs(const hidl_string &path, readSysfs_cb _hidl_cb) override;
+ Return<Result> writeSysfs(const hidl_string &path, const hidl_string &value) override;
+ Return<void> readHdcpRX22Key(int32_t size, readHdcpRX22Key_cb _hidl_cb) override;
+ Return<Result> writeHdcpRX22Key(const hidl_string &key) override;
+ Return<void> readHdcpRX14Key(int32_t size, readHdcpRX14Key_cb _hidl_cb) override;
+ Return<Result> writeHdcpRX14Key(const hidl_string &key) override;
+ Return<Result> writeHdcpRXImg(const hidl_string &path) override;
+ Return<void> getBootEnv(const hidl_string &key, getBootEnv_cb _hidl_cb) override;
+ Return<void> setBootEnv(const hidl_string &key, const hidl_string &value) override;
+ Return<void> getDroidDisplayInfo(getDroidDisplayInfo_cb _hidl_cb) override;
+ Return<void> loopMountUnmount(int32_t isMount, const hidl_string& path) override;
+ Return<void> setSourceOutputMode(const hidl_string& mode) override;
+ Return<void> setSinkOutputMode(const hidl_string& mode) override;
+ Return<void> setDigitalMode(const hidl_string& mode) override;
+ Return<void> setOsdMouseMode(const hidl_string& mode) override;
+ Return<void> setOsdMousePara(int32_t x, int32_t y, int32_t w, int32_t h) override;
+ Return<void> setPosition(int32_t left, int32_t top, int32_t width, int32_t height) override;
+ Return<void> getPosition(const hidl_string& mode, getPosition_cb _hidl_cb) override;
+ Return<void> saveDeepColorAttr(const hidl_string& mode, const hidl_string& dcValue) override;
+ Return<void> getDeepColorAttr(const hidl_string &mode, getDeepColorAttr_cb _hidl_cb) override;
+ Return<void> setDolbyVisionState(int32_t state) override;
+ Return<void> sinkSupportDolbyVision(sinkSupportDolbyVision_cb _hidl_cb) override;
+ Return<void> setHdrMode(const hidl_string& mode) override;
+ Return<void> setSdrMode(const hidl_string& mode) override;
+ Return<void> resolveResolutionValue(const hidl_string& mode, resolveResolutionValue_cb _hidl_cb) override;
+ Return<void> setCallback(const sp<ISystemControlCallback>& callback) override;
+
+ //for 3D
+ Return<void> set3DMode(const hidl_string& mode) override;
+ Return<void> init3DSetting() override;
+ Return<void> getVideo3DFormat(getVideo3DFormat_cb _hidl_cb) override;
+ Return<void> getDisplay3DTo2DFormat(getDisplay3DTo2DFormat_cb _hidl_cb) override;
+ Return<void> setDisplay3DTo2DFormat(int32_t format) override;
+ Return<void> setDisplay3DFormat(int32_t format) override;
+ Return<void> getDisplay3DFormat(getDisplay3DFormat_cb _hidl_cb) override;
+ Return<void> setOsd3DFormat(int32_t format) override;
+ Return<void> switch3DTo2D(int32_t format) override;
+ Return<void> switch2DTo3D(int32_t format) override;
+ Return<void> autoDetect3DForMbox() override;
+
+ virtual void onEvent(int event);
+
private:
- SystemControl *mSysControl;
+ SystemControlService *mSysControl;
+ std::vector<sp<ISystemControlCallback>> mClients;
};
-//extern "C" ISystemControl* HIDL_FETCH_ISystemControl(const char* name);
-
} // namespace implementation
} // namespace V1_0
} // namespace systemcontrol
diff --git a/services/systemcontrol/SystemControlNotify.h b/services/systemcontrol/SystemControlNotify.h
new file mode 100644
index 0000000..2450f21
--- a/dev/null
+++ b/services/systemcontrol/SystemControlNotify.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011 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.
+ * @author tellen
+ * @version 1.0
+ * @date 2017/10/18
+ * @par function description:
+ * - 1 control system sysfs proc env & property
+ */
+
+#ifndef ANDROID_SYSTEM_CONTROL_NOTIFY_H
+#define ANDROID_SYSTEM_CONTROL_NOTIFY_H
+
+#include <utils/RefBase.h>
+
+namespace android {
+
+class SystemControlNotify : virtual public RefBase
+{
+public:
+ SystemControlNotify() {}
+ virtual ~SystemControlNotify(){}
+ virtual void onEvent(int event) = 0;
+};
+
+}; // namespace android
+
+#endif // ANDROID_SYSTEM_CONTROL_NOTIFY_H \ No newline at end of file
diff --git a/services/systemcontrol/SystemControlService.cpp b/services/systemcontrol/SystemControlService.cpp
new file mode 100644
index 0000000..80be699
--- a/dev/null
+++ b/services/systemcontrol/SystemControlService.cpp
@@ -0,0 +1,656 @@
+/*
+ * Copyright (C) 2011 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.
+ * @author Tellen Yu
+ * @version 1.0
+ * @date 2017/09/20
+ * @par function description:
+ * - 1 system control interface
+ */
+
+#define LOG_TAG "SystemControl"
+//#define LOG_NDEBUG 0
+
+#include <fcntl.h>
+#include <utils/Log.h>
+#include <cutils/properties.h>
+#include <stdint.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <private/android_filesystem_config.h>
+#include <pthread.h>
+
+#include "SystemControlService.h"
+
+namespace android {
+
+SystemControlService* SystemControlService::instantiate(const char *cfgpath) {
+ SystemControlService *sysControlIntf = new SystemControlService(cfgpath);
+ return sysControlIntf;
+}
+
+SystemControlService::SystemControlService(const char *path)
+ : mLogLevel(LOG_LEVEL_DEFAULT) {
+
+ ALOGI("SystemControlService instantiate begin");
+ pUbootenv = new Ubootenv();
+ pSysWrite = new SysWrite();
+
+ pDisplayMode = new DisplayMode(path, pUbootenv);
+ pDisplayMode->init();
+
+ pDimension = new Dimension(pDisplayMode, pSysWrite);
+
+ //if ro.firstboot is true, we should clear first boot flag
+ const char* firstBoot = pUbootenv->getValue("ubootenv.var.firstboot");
+ if (firstBoot && (strcmp(firstBoot, "1") == 0)) {
+ ALOGI("ubootenv.var.firstboot first_boot:%s, clear it to 0", firstBoot);
+ if ( pUbootenv->updateValue("ubootenv.var.firstboot", "0") < 0 )
+ ALOGE("set firstboot to 0 fail");
+ }
+
+ ALOGI("SystemControlService instantiate done");
+}
+
+SystemControlService::~SystemControlService() {
+ delete pUbootenv;
+ delete pSysWrite;
+ delete pDisplayMode;
+ delete pDimension;
+}
+
+int SystemControlService::permissionCheck() {
+ /*
+ // codes that require permission check
+ IPCThreadState* ipc = IPCThreadState::self();
+ const int pid = ipc->getCallingPid();
+ const int uid = ipc->getCallingUid();
+
+ if ((uid != AID_GRAPHICS) && (uid != AID_MEDIA) &&( uid != AID_MEDIA_CODEC) &&
+ !PermissionCache::checkPermission(String16("droidlogic.permission.SYSTEM_CONTROL"), pid, uid)) {
+ ALOGE("Permission Denial: "
+ "can't use system control service pid=%d, uid=%d", pid, uid);
+ return PERMISSION_DENIED;
+ }
+
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("system_control service permissionCheck pid=%d, uid=%d", pid, uid);
+ }
+ */
+
+ return NO_ERROR;
+}
+
+bool SystemControlService::getSupportDispModeList(std::vector<std::string> *supportDispModes) {
+ const char *delim = "\n";
+ char value[MODE_LEN] = {0};
+ hdmi_data_t data;
+
+ pDisplayMode->getHdmiData(&data);
+ char *ptr = strtok(data.edid, delim);
+ while (ptr != NULL) {
+ int len = strlen(ptr);
+ if (ptr[len - 1] == '*')
+ ptr[len - 1] = '\0';
+
+ (*supportDispModes).push_back(std::string(ptr));
+ ptr = strtok(NULL, delim);
+ }
+
+ return true;
+}
+
+bool SystemControlService::getActiveDispMode(std::string *activeDispMode) {
+ char mode[MODE_LEN] = {0};
+ bool ret = pSysWrite->readSysfs(SYSFS_DISPLAY_MODE, mode);
+ *activeDispMode = mode;
+ return ret;
+}
+
+bool SystemControlService::setActiveDispMode(std::string& activeDispMode) {
+ setSourceOutputMode(activeDispMode.c_str());
+ return true;
+}
+
+//read write property and sysfs
+bool SystemControlService::getProperty(const std::string &key, std::string *value) {
+ char buf[PROPERTY_VALUE_MAX] = {0};
+ bool ret = pSysWrite->getProperty(key.c_str(), buf);
+ *value = buf;
+ return ret;
+}
+
+bool SystemControlService::getPropertyString(const std::string &key, std::string *value, const std::string &def) {
+ char buf[PROPERTY_VALUE_MAX] = {0};
+ bool ret = pSysWrite->getPropertyString(key.c_str(), (char *)buf, def.c_str());
+ *value = buf;
+ return ret;
+}
+
+int32_t SystemControlService::getPropertyInt(const std::string &key, int32_t def) {
+ return pSysWrite->getPropertyInt(key.c_str(), def);
+}
+
+int64_t SystemControlService::getPropertyLong(const std::string &key, int64_t def) {
+ return pSysWrite->getPropertyLong(key.c_str(), def);
+}
+
+bool SystemControlService::getPropertyBoolean(const std::string& key, bool def) {
+ return pSysWrite->getPropertyBoolean(key.c_str(), def);
+}
+
+void SystemControlService::setProperty(const std::string& key, const std::string& value) {
+ if (NO_ERROR == permissionCheck()) {
+ pSysWrite->setProperty(key.c_str(), value.c_str());
+ traceValue("setProperty", key, value);
+ }
+}
+
+bool SystemControlService::readSysfs(const std::string& path, std::string& value) {
+ if (NO_ERROR == permissionCheck()) {
+ char buf[MAX_STR_LEN] = {0};
+ bool ret = pSysWrite->readSysfs(path.c_str(), buf);
+ value = buf;
+
+ traceValue("readSysfs", path, value);
+ return ret;
+ }
+
+ return false;
+}
+
+bool SystemControlService::writeSysfs(const std::string& path, const std::string& value) {
+ if (NO_ERROR == permissionCheck()) {
+ traceValue("writeSysfs", path, value);
+
+ return pSysWrite->writeSysfs(path.c_str(), value.c_str());
+ }
+
+ return false;
+}
+
+bool SystemControlService::writeSysfs(const std::string& path, const char *value, const int size) {
+ if (NO_ERROR == permissionCheck()) {
+ traceValue("writeSysfs", path, size);
+
+ bool ret = pSysWrite->writeSysfs(path.c_str(), value, size);
+ return ret;
+ }
+
+ return false;
+}
+
+int32_t SystemControlService::readHdcpRX22Key(char *value __attribute__((unused)), int size __attribute__((unused))) {
+ /*if (NO_ERROR == permissionCheck()) {
+ traceValue(String16("readHdcpRX22Key"), size);
+ int len = pDisplayMode->readHdcpRX22Key(value, size);
+ return len;
+ }*/
+ return 0;
+}
+
+bool SystemControlService::writeHdcpRX22Key(const char *value, const int size) {
+ if (NO_ERROR == permissionCheck()) {
+ traceValue("writeHdcp22Key", "", size);
+
+ bool ret = pDisplayMode->writeHdcpRX22Key(value, size);
+ return ret;
+ }
+ return false;
+}
+
+int32_t SystemControlService::readHdcpRX14Key(char *value __attribute__((unused)), int size __attribute__((unused))) {
+ /*if (NO_ERROR == permissionCheck()) {
+ traceValue(String16("readHdcpRX14Key"), size);
+ int len = pDisplayMode->readHdcpRX14Key(value, size);
+ return len;
+ }*/
+ return 0;
+}
+
+bool SystemControlService::writeHdcpRX14Key(const char *value, const int size) {
+ if (NO_ERROR == permissionCheck()) {
+ traceValue("writeHdcp14Key", "", size);
+
+ bool ret = pDisplayMode->writeHdcpRX14Key(value, size);
+ return ret;
+ }
+ return false;
+}
+
+bool SystemControlService::writeHdcpRXImg(const std::string& path) {
+ if (NO_ERROR == permissionCheck()) {
+ traceValue("writeSysfs", path, "");
+
+ return pDisplayMode->writeHdcpRXImg(path.c_str());
+ }
+
+ return false;
+}
+
+//set or get uboot env
+bool SystemControlService::getBootEnv(const std::string& key, std::string& value) {
+ const char* p_value = pUbootenv->getValue(key.c_str());
+ if (p_value) {
+ value = p_value;
+ return true;
+ }
+ return false;
+}
+
+void SystemControlService::setBootEnv(const std::string& key, const std::string& value) {
+ if (NO_ERROR == permissionCheck()) {
+ pUbootenv->updateValue(key.c_str(), value.c_str());
+ traceValue("setBootEnv", key, value);
+ }
+}
+
+void SystemControlService::getDroidDisplayInfo(int &type, std::string& socType, std::string& defaultUI,
+ int &fb0w, int &fb0h, int &fb0bits, int &fb0trip,
+ int &fb1w, int &fb1h, int &fb1bits, int &fb1trip) {
+ if (NO_ERROR == permissionCheck()) {
+ char bufType[MAX_STR_LEN] = {0};
+ char bufUI[MAX_STR_LEN] = {0};
+ pDisplayMode->getDisplayInfo(type, bufType, bufUI);
+ socType = bufType;
+ defaultUI = bufUI;
+ pDisplayMode->getFbInfo(fb0w, fb0h, fb0bits, fb0trip, fb1w, fb1h, fb1bits, fb1trip);
+ }
+}
+
+void SystemControlService::loopMountUnmount(int isMount, const std::string& path) {
+ if (NO_ERROR == permissionCheck()) {
+ traceValue("loopMountUnmount", (isMount==1)?"mount":"unmount", path);
+
+ if (isMount == 1) {
+ char mountPath[MAX_STR_LEN] = {0};
+
+ strncpy(mountPath, path.c_str(), path.size());
+
+ const char *cmd[4] = {"vdc", "loop", "mount", mountPath};
+ vdc_loop(4, (char **)cmd);
+ } else {
+ const char *cmd[3] = {"vdc", "loop", "unmount"};
+ vdc_loop(3, (char **)cmd);
+ }
+ }
+}
+
+void SystemControlService::setSourceOutputMode(const std::string& mode) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("set output mode :%s", mode.c_str());
+ }
+
+ pDisplayMode->setSourceOutputMode(mode.c_str());
+}
+
+void SystemControlService::setSinkOutputMode(const std::string& mode) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("set sink output mode :%s", mode.c_str());
+ }
+
+ pDisplayMode->setSinkOutputMode(mode.c_str());
+}
+
+void SystemControlService::setDigitalMode(const std::string& mode) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("set Digital mode :%s", mode.c_str());
+ }
+
+ pDisplayMode->setDigitalMode(mode.c_str());
+}
+
+void SystemControlService::setOsdMouseMode(const std::string& mode) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("set osd mouse mode :%s", mode.c_str());
+ }
+
+ pDisplayMode->setOsdMouse(mode.c_str());
+}
+
+void SystemControlService::setOsdMousePara(int x, int y, int w, int h) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("set osd mouse parameter x:%d y:%d w:%d h:%d", x, y, w, h);
+ }
+ pDisplayMode->setOsdMouse(x, y, w, h);
+}
+
+void SystemControlService::setPosition(int left, int top, int width, int height) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("set position x:%d y:%d w:%d h:%d", left, top, width, height);
+ }
+ pDisplayMode->setPosition(left, top, width, height);
+}
+
+void SystemControlService::getPosition(const std::string& mode, int &x, int &y, int &w, int &h) {
+ int position[4] = { 0, 0, 0, 0 };
+ pDisplayMode->getPosition(mode.c_str(), position);
+ x = position[0];
+ y = position[1];
+ w = position[2];
+ h = position[3];
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("get position x:%d y:%d w:%d h:%d", x, y, w, h);
+ }
+}
+
+void SystemControlService::setDolbyVisionEnable(int state) {
+ pDisplayMode->setDolbyVisionEnable(state);
+}
+
+bool SystemControlService::isTvSupportDolbyVision(std::string& mode) {
+ char value[MODE_LEN] = {0};
+ bool ret = pDisplayMode->isTvSupportDolbyVision(value);
+ mode = value;
+ return ret;
+}
+
+void SystemControlService::isHDCPTxAuthSuccess(int &status) {
+ int value=0;
+ pDisplayMode->isHDCPTxAuthSuccess(&value);
+ status = value;
+}
+
+void SystemControlService::saveDeepColorAttr(const std::string& mode, const std::string& dcValue) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("set deep color attr %s\n", dcValue.c_str());
+ }
+ char outputmode[64];
+ char value[64];
+ strcpy(outputmode, mode.c_str());
+ strcpy(value, dcValue.c_str());
+ pDisplayMode->saveDeepColorAttr(outputmode, value);
+}
+
+void SystemControlService::getDeepColorAttr(const std::string& mode, std::string& value) {
+ char buf[PROPERTY_VALUE_MAX] = {0};
+ pDisplayMode->getDeepColorAttr(mode.c_str(), buf);
+ value = buf;
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("get deep color attr mode %s, value %s ", mode.c_str(), value.c_str());
+ }
+}
+
+void SystemControlService::setHdrMode(const std::string& mode) {
+ pDisplayMode->setHdrMode(mode.c_str());
+}
+
+void SystemControlService::setSdrMode(const std::string& mode) {
+ pDisplayMode->setSdrMode(mode.c_str());
+}
+
+int64_t SystemControlService::resolveResolutionValue(const std::string& mode) {
+ int64_t value = pDisplayMode->resolveResolutionValue(mode.c_str());
+ return value;
+}
+
+void SystemControlService::setListener(const sp<SystemControlNotify>& listener) {
+ pDisplayMode->setListener(listener);
+}
+
+//3D
+int32_t SystemControlService::set3DMode(const std::string& mode3d) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("set 3d mode :%s", mode3d.c_str());
+ }
+
+ return pDimension->set3DMode(mode3d.c_str());
+}
+
+void SystemControlService::init3DSetting(void) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("init3DSetting\n");
+ }
+
+ pDimension->init3DSetting();
+}
+
+int32_t SystemControlService::getVideo3DFormat(void) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("getVideo3DFormat\n");
+ }
+
+ return pDimension->getVideo3DFormat();
+}
+
+int32_t SystemControlService::getDisplay3DTo2DFormat(void) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("getDisplay3DTo2DFormat\n");
+ }
+
+ return pDimension->getDisplay3DTo2DFormat();
+}
+
+bool SystemControlService::setDisplay3DTo2DFormat(int format) {
+ bool ret = false;
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("setDisplay3DTo2DFormat format:%d\n", format);
+ }
+
+ return pDimension->setDisplay3DTo2DFormat(format);
+}
+
+bool SystemControlService::setDisplay3DFormat(int format) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("setDisplay3DFormat format:%d\n", format);
+ }
+
+ return pDimension->setDisplay3DFormat(format);
+}
+
+int32_t SystemControlService::getDisplay3DFormat(void) {
+ return pDimension->getDisplay3DFormat();
+}
+
+bool SystemControlService::setOsd3DFormat(int format) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("setOsd3DFormat format:%d\n", format);
+ }
+
+ return pDimension->setOsd3DFormat(format);
+}
+
+bool SystemControlService::switch3DTo2D(int format) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("switch3DTo2D format:%d\n", format);
+ }
+
+ return pDimension->switch3DTo2D(format);
+}
+
+bool SystemControlService::switch2DTo3D(int format) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("switch2DTo3D format:%d\n", format);
+ }
+
+ return pDimension->switch2DTo3D(format);
+}
+
+void SystemControlService::autoDetect3DForMbox() {
+ if (mLogLevel > LOG_LEVEL_1) {
+ ALOGI("autoDetect3DForMbox\n");
+ }
+
+ pDimension->autoDetect3DForMbox();
+}
+//3D end
+
+void SystemControlService::traceValue(const std::string& type, const std::string& key, const std::string& value) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ /*
+ String16 procName;
+ int pid = IPCThreadState::self()->getCallingPid();
+ int uid = IPCThreadState::self()->getCallingUid();
+
+ getProcName(pid, procName);
+
+ ALOGI("%s [ %s ] [ %s ] from pid=%d, uid=%d, process name=%s",
+ String8(type).string(), String8(key).string(), String8(value).string(),
+ pid, uid,
+ String8(procName).string());
+ */
+ }
+}
+
+void SystemControlService::traceValue(const std::string& type, const std::string& key, const int size) {
+ if (mLogLevel > LOG_LEVEL_1) {
+ /*
+ String16 procName;
+ int pid = IPCThreadState::self()->getCallingPid();
+ int uid = IPCThreadState::self()->getCallingUid();
+
+ getProcName(pid, procName);
+
+ ALOGI("%s [ %s ] [ %d ] from pid=%d, uid=%d, process name=%s",
+ String8(type).string(), String8(key).string(), size,
+ pid, uid,
+ String8(procName).string());
+ */
+ }
+}
+
+void SystemControlService::setLogLevel(int level) {
+ if (level > (LOG_LEVEL_TOTAL - 1)) {
+ ALOGE("out of range level=%d, max=%d", level, LOG_LEVEL_TOTAL);
+ return;
+ }
+
+ mLogLevel = level;
+ pSysWrite->setLogLevel(level);
+ pDisplayMode->setLogLevel(level);
+ pDimension->setLogLevel(level);
+}
+
+int SystemControlService::getLogLevel() {
+ return mLogLevel;
+}
+
+int SystemControlService::getProcName(pid_t pid, String16& procName) {
+ char proc_path[MAX_STR_LEN];
+ char cmdline[64];
+ int fd;
+
+ strcpy(cmdline, "unknown");
+
+ sprintf(proc_path, "/proc/%d/cmdline", pid);
+ fd = open(proc_path, O_RDONLY);
+ if (fd >= 0) {
+ int rc = read(fd, cmdline, sizeof(cmdline)-1);
+ cmdline[rc] = 0;
+ close(fd);
+
+ procName.setTo(String16(cmdline));
+ return 0;
+ }
+
+ return -1;
+}
+
+status_t SystemControlService::dump(int fd, const Vector<String16>& args) {
+#if 0
+ const size_t SIZE = 256;
+ char buffer[SIZE];
+ String8 result;
+
+ Mutex::Autolock lock(mLock);
+
+ int len = args.size();
+ for (int i = 0; i < len; i ++) {
+ String16 debugLevel("-l");
+ String16 bootenv("-b");
+ String16 display("-d");
+ String16 dimension("-dms");
+ String16 hdcp("-hdcp");
+ String16 help("-h");
+ if (args[i] == debugLevel) {
+ if (i + 1 < len) {
+ String8 levelStr(args[i+1]);
+ int level = atoi(levelStr.string());
+ setLogLevel(level);
+
+ result.append(String8::format("Setting log level to %d.\n", level));
+ break;
+ }
+ }
+ else if (args[i] == bootenv) {
+ if ((i + 3 < len) && (args[i + 1] == String16("set"))) {
+ setBootEnv(args[i+2], args[i+3]);
+
+ result.append(String8::format("set bootenv key:[%s] value:[%s]\n",
+ String8(args[i+2]).string(), String8(args[i+3]).string()));
+ break;
+ }
+ else if (((i + 2) <= len) && (args[i + 1] == String16("get"))) {
+ if ((i + 2) == len) {
+ result.appendFormat("get all bootenv\n");
+ pUbootenv->printValues();
+ }
+ else {
+ String16 value;
+ getBootEnv(args[i+2], value);
+
+ result.append(String8::format("get bootenv key:[%s] value:[%s]\n",
+ String8(args[i+2]).string(), String8(value).string()));
+ }
+ break;
+ }
+ else {
+ result.appendFormat(
+ "dump bootenv format error!! should use:\n"
+ "dumpsys system_control -b [set |get] key value \n");
+ }
+ }
+ else if (args[i] == display) {
+ /*
+ String8 displayInfo;
+ pDisplayMode->dump(displayInfo);
+ result.append(displayInfo);*/
+
+ char buf[4096] = {0};
+ pDisplayMode->dump(buf);
+ result.append(String8(buf));
+ break;
+ }
+ else if (args[i] == dimension) {
+ char buf[4096] = {0};
+ pDimension->dump(buf);
+ result.append(String8(buf));
+ break;
+ }
+ else if (args[i] == hdcp) {
+ pDisplayMode->hdcpSwitch();
+ break;
+ }
+ else if (args[i] == help) {
+ result.appendFormat(
+ "system_control service use to control the system sysfs property and boot env \n"
+ "in multi-user mode, normal process will have not system privilege \n"
+ "usage: \n"
+ "dumpsys system_control -l value \n"
+ "dumpsys system_control -b [set |get] key value \n"
+ "-l: debug level \n"
+ "-b: set or get bootenv \n"
+ "-d: dump display mode info \n"
+ "-hdcp: stop hdcp and start hdcp tx \n"
+ "-h: help \n");
+ }
+ }
+
+ write(fd, result.string(), result.size());
+#endif
+ return NO_ERROR;
+}
+
+} // namespace android
+
diff --git a/services/systemcontrol/SystemControlService.h b/services/systemcontrol/SystemControlService.h
new file mode 100644
index 0000000..39e8db4
--- a/dev/null
+++ b/services/systemcontrol/SystemControlService.h
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2011 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.
+ * @author Tellen Yu
+ * @version 1.0
+ * @date 2017/09/20
+ * @par function description:
+ * - 1 system control interface
+ */
+
+#ifndef ANDROID_SYSTEM_CONTROL_SERVICE_H
+#define ANDROID_SYSTEM_CONTROL_SERVICE_H
+
+#include <utils/Errors.h>
+#include <utils/String8.h>
+#include <utils/String16.h>
+#include <utils/Mutex.h>
+#include <ISystemControlService.h>
+
+#include "SysWrite.h"
+#include "common.h"
+#include "DisplayMode.h"
+#include "Dimension.h"
+#include <string>
+#include <vector>
+
+#include "ubootenv/Ubootenv.h"
+
+extern "C" int vdc_loop(int argc, char **argv);
+
+namespace android {
+// ----------------------------------------------------------------------------
+
+class SystemControlService
+{
+public:
+ SystemControlService(const char *path);
+ virtual ~SystemControlService();
+
+ bool getSupportDispModeList(std::vector<std::string> *supportDispModes);
+ bool getActiveDispMode(std::string *activeDispMode);
+ bool setActiveDispMode(std::string& activeDispMode);
+ //read write property and sysfs
+ bool getProperty(const std::string &key, std::string *value);
+ bool getPropertyString(const std::string &key, std::string *value, const std::string &def);
+ int32_t getPropertyInt(const std::string &key, int32_t def);
+ int64_t getPropertyLong(const std::string &key, int64_t def);
+ bool getPropertyBoolean(const std::string& key, bool def);
+ void setProperty(const std::string& key, const std::string& value);
+ bool readSysfs(const std::string& path, std::string& value);
+ bool writeSysfs(const std::string& path, const std::string& value);
+ bool writeSysfs(const std::string& path, const char *value, const int size);
+ int32_t readHdcpRX22Key(char *value __attribute__((unused)), int size __attribute__((unused)));
+ bool writeHdcpRX22Key(const char *value, const int size);
+ int32_t readHdcpRX14Key(char *value __attribute__((unused)), int size __attribute__((unused)));
+ bool writeHdcpRX14Key(const char *value, const int size);
+ bool writeHdcpRXImg(const std::string& path);
+ //set or get uboot env
+ bool getBootEnv(const std::string& key, std::string& value);
+ void setBootEnv(const std::string& key, const std::string& value);
+ void getDroidDisplayInfo(int &type, std::string& socType, std::string& defaultUI,
+ int &fb0w, int &fb0h, int &fb0bits, int &fb0trip,
+ int &fb1w, int &fb1h, int &fb1bits, int &fb1trip);
+ void loopMountUnmount(int isMount, const std::string& path);
+ void setSourceOutputMode(const std::string& mode);
+ void setSinkOutputMode(const std::string& mode);
+ void setDigitalMode(const std::string& mode);
+ void setOsdMouseMode(const std::string& mode);
+ void setOsdMousePara(int x, int y, int w, int h);
+ void setPosition(int left, int top, int width, int height);
+ void getPosition(const std::string& mode, int &x, int &y, int &w, int &h);
+ void setDolbyVisionEnable(int state);
+ bool isTvSupportDolbyVision(std::string& mode);
+ void isHDCPTxAuthSuccess(int &status);
+ void saveDeepColorAttr(const std::string& mode, const std::string& dcValue);
+ void getDeepColorAttr(const std::string& mode, std::string& value);
+ void setHdrMode(const std::string& mode);
+ void setSdrMode(const std::string& mode);
+ int64_t resolveResolutionValue(const std::string& mode);
+ void setListener(const sp<SystemControlNotify>& listener);
+
+ //3D
+ int32_t set3DMode(const std::string& mode3d);
+ void init3DSetting(void);
+ int32_t getVideo3DFormat(void);
+ int32_t getDisplay3DTo2DFormat(void);
+ bool setDisplay3DTo2DFormat(int format);
+ bool setDisplay3DFormat(int format);
+ int32_t getDisplay3DFormat(void);
+ bool setOsd3DFormat(int format);
+ bool switch3DTo2D(int format);
+ bool switch2DTo3D(int format);
+ void autoDetect3DForMbox();
+ //3D end
+ static SystemControlService* instantiate(const char *cfgpath);
+
+ virtual status_t dump(int fd, const Vector<String16>& args);
+
+ int getLogLevel();
+
+private:
+ int permissionCheck();
+ void setLogLevel(int level);
+ void traceValue(const std::string& type, const std::string& key, const std::string& value);
+ void traceValue(const std::string& type, const std::string& key, const int size);
+ int getProcName(pid_t pid, String16& procName);
+
+ mutable Mutex mLock;
+
+ int mLogLevel;
+
+ SysWrite *pSysWrite;
+ DisplayMode *pDisplayMode;
+ Dimension *pDimension;
+ Ubootenv *pUbootenv;
+};
+
+// ----------------------------------------------------------------------------
+
+} // namespace android
+#endif // ANDROID_SYSTEM_CONTROL_SERVICE_H \ No newline at end of file
diff --git a/services/systemcontrol/main_systemcontrol.cpp b/services/systemcontrol/main_systemcontrol.cpp
index b858c92..f162603 100644
--- a/services/systemcontrol/main_systemcontrol.cpp
+++ b/services/systemcontrol/main_systemcontrol.cpp
@@ -30,20 +30,21 @@
#include <binder/IServiceManager.h>
#include <cutils/properties.h>
#include <utils/Log.h>
+#include <HidlTransportSupport.h>
#include "SystemControl.h"
+#include "SystemControlService.h"
#include "SystemControlHal.h"
using namespace android;
+using ::android::hardware::configureRpcThreadpool;
using ::vendor::amlogic::hardware::systemcontrol::V1_0::implementation::SystemControlHal;
using ::vendor::amlogic::hardware::systemcontrol::V1_0::ISystemControl;
using ::vendor::amlogic::hardware::systemcontrol::V1_0::Result;
int main(int argc, char** argv)
{
- //using ::android::hardware::configureRpcThreadpool;
-
//char value[PROPERTY_VALUE_MAX];
const char* path = NULL;
if(argc >= 2){
@@ -52,17 +53,16 @@ int main(int argc, char** argv)
bool treble = property_get_bool("persist.system_control.treble", true);
if (treble) {
- //android::ProcessState::initWithDriver("/dev/vndbinder");
+ android::ProcessState::initWithDriver("/dev/vndbinder");
}
- ALOGI("systemcontrol starting in %s mode", treble?"teble":"normal");
- //configureRpcThreadpool(64, false);
- //ProcessState::self()->setThreadPoolMaxThreadCount(4);
+ ALOGI("systemcontrol starting in %s mode", treble?"treble":"normal");
+ configureRpcThreadpool(16, false);
sp<ProcessState> proc(ProcessState::self());
- SystemControl *control = SystemControl::instantiate(path);
if (treble) {
- sp<ISystemControl> controlHal = new SystemControlHal(control);
+ SystemControlService *controlIntf = SystemControlService::instantiate(path);
+ sp<ISystemControl> controlHal = new SystemControlHal(controlIntf);
if (controlHal == nullptr) {
ALOGE("Cannot create ISystemControl service");
} else if (controlHal->registerAsService() != OK) {
@@ -71,6 +71,9 @@ int main(int argc, char** argv)
ALOGI("Treble ISystemControl service created.");
}
}
+ else {
+ SystemControl *control = SystemControl::instantiate(path);
+ }
/*
* This thread is just going to process Binder transactions.
diff --git a/services/systemcontrol/systemcontrol.rc b/services/systemcontrol/systemcontrol.rc
index 0f15546..a859e52 100644
--- a/services/systemcontrol/systemcontrol.rc
+++ b/services/systemcontrol/systemcontrol.rc
@@ -3,4 +3,4 @@ on early-boot
service system_control /vendor/bin/systemcontrol
user root
- group system \ No newline at end of file
+ group system
diff --git a/services/systemcontrol/ubootenv/Ubootenv.cpp b/services/systemcontrol/ubootenv/Ubootenv.cpp
index 6f2d211..beebeb7 100644
--- a/services/systemcontrol/ubootenv/Ubootenv.cpp
+++ b/services/systemcontrol/ubootenv/Ubootenv.cpp
@@ -30,7 +30,7 @@ Ubootenv::Ubootenv() :
init();
- printValues();
+ //printValues();
}
Ubootenv::~Ubootenv() {