summaryrefslogtreecommitdiff
authorFrank Chen <frank.chen@amlogic.com>2016-02-26 03:38:20 (GMT)
committer Frank Chen <frank.chen@amlogic.com>2016-03-01 07:44:41 (GMT)
commit818c76da5902b9dfb464083d6a013f9a601ddb44 (patch)
tree891f39d371fb2e3058785ffe99ad3abb60a3fae4
parentc0558b0ca4ec5d7bfe59f08f4bebd727ea6bdb68 (diff)
downloadsystem-818c76da5902b9dfb464083d6a013f9a601ddb44.zip
system-818c76da5902b9dfb464083d6a013f9a601ddb44.tar.gz
system-818c76da5902b9dfb464083d6a013f9a601ddb44.tar.bz2
PD#119721 add libinstaboot_support
Change-Id: I8a7b31b079dd22eef2d3d9b3682cb25e205758bb
Diffstat
-rw-r--r--libinstaboot_support/Android.mk28
-rw-r--r--libinstaboot_support/InstabootSupport.cpp148
-rw-r--r--libinstaboot_support/InstabootSupport.h29
3 files changed, 205 insertions, 0 deletions
diff --git a/libinstaboot_support/Android.mk b/libinstaboot_support/Android.mk
new file mode 100644
index 0000000..f8dbb6e
--- a/dev/null
+++ b/libinstaboot_support/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ InstabootSupport.cpp
+
+LOCAL_C_INCLUDES += system/core/fs_mgr/include \
+ external/fw_env \
+ system/extras/ext4_utils \
+ system/vold \
+ vendor/amlogic/frameworks/services/systemcontrol \
+ vendor/amlogic/frameworks/tv/include
+
+LOCAL_MODULE := libinstaboot_support
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils \
+ libdl \
+ libutils \
+ liblog \
+ libbinder \
+ libsystemcontrolservice \
+ libc \
+ libtvplay
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/libinstaboot_support/InstabootSupport.cpp b/libinstaboot_support/InstabootSupport.cpp
new file mode 100644
index 0000000..a26f3a0
--- a/dev/null
+++ b/libinstaboot_support/InstabootSupport.cpp
@@ -0,0 +1,148 @@
+/*
+**
+** Copyright 2006, 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.
+*/
+#define LOG_TAG "Ibms"
+#include "utils/Log.h"
+#include "utils/misc.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <utils/KeyedVector.h>
+#include <utils/String8.h>
+#include <utils/String16.h>
+#include <utils/Vector.h>
+#include <binder/MemoryDealer.h>
+#include <binder/IInterface.h>
+#include <binder/IServiceManager.h>
+#include <cutils/properties.h>
+
+#include "ISystemControlService.h"
+#include "InstabootSupport.h"
+
+#include "CTv.h"
+
+using namespace android;
+
+CTv * mCTv;
+
+sp<ISystemControlService> mSysWrite = NULL;
+
+int checkSystemControlService() {
+ const String16 name("system_control");
+ if (mSysWrite == NULL) {
+ status_t status = getService(name, &mSysWrite);
+
+ if (NO_ERROR != status) {
+ ALOGE("Couldn't get connection to system_control service\n");
+ mSysWrite = NULL;
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int reInit(void) {
+ ALOGI("InstabootSupport reinit");
+
+ if (checkSystemControlService())
+ return -1;
+
+ mSysWrite->reInit();
+
+ return 0;
+}
+
+int resetDisplay(void) {
+ ALOGI("InstabootSupport resetDisplay");
+ if (checkSystemControlService())
+ return -1;
+
+ mSysWrite->instabootResetDisplay();
+ return 0;
+}
+
+int setOsdMouse(char *mode) {
+ ALOGI("InstabootSupport setOsdMouse");
+ if (checkSystemControlService())
+ return -1;
+
+ String16 mod(mode);
+ mSysWrite->setOsdMouseMode(mod);
+ return 0;
+}
+
+int getEnv(char *name, char *value, char const* def) {
+ ALOGI("InstabootSupport getEnv");
+ if (checkSystemControlService())
+ return -1;
+
+ String16 val;
+ bool res = mSysWrite->getBootEnv(String16(name), val);
+ if (res) {
+ strcpy(value, String8(val).string());
+ } else {
+ strcpy(value, def);
+ }
+ return 0;
+}
+
+bool isSupportTv() {
+ char prop[PROPERTY_VALUE_MAX] = {0};
+ property_get("init.svc.tvd", prop, "stoped");
+ if (strcmp(prop, "running") != 0) {
+ ALOGD("no tvserver is running");
+ return true;
+ }
+ return false;
+}
+
+int tvserver_suspend() {
+ char prop[PROPERTY_VALUE_MAX] = {0};
+ property_get("init.svc.tvd", prop, "stoped");
+ if (strcmp(prop, "running") != 0) {
+ ALOGD("no tvserver is running");
+ return 1;
+ }
+
+ if (mCTv == NULL) {
+ mCTv = new CTv();
+ }
+ ALOGD("suspend tvserver");
+ mCTv->DoSuspend(1); //1 is instaboot suspend
+ return 0;
+}
+
+int tvserver_resume() {
+ char prop[PROPERTY_VALUE_MAX] = {0};
+ property_get("init.svc.tvd", prop, "stoped");
+ if (strcmp(prop, "running") != 0) {
+ ALOGD("no tvserver is running");
+ return 1;
+ }
+
+ if (mCTv != NULL) {
+ ALOGD("resume tvserver");
+ mCTv->DoResume(1);
+ return 0;
+ }
+ ALOGD("didn't suspend tvserver, so just pass resume");
+ return 1;
+}
diff --git a/libinstaboot_support/InstabootSupport.h b/libinstaboot_support/InstabootSupport.h
new file mode 100644
index 0000000..3636c0f
--- a/dev/null
+++ b/libinstaboot_support/InstabootSupport.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef _INSTABOOT_DISPLAY_H
+#define _INSTABOOT_DISPLAY_H
+
+int reInit(void);
+int resetDisplay(void);
+int setOsdMouse(char *mode);
+int getEnv(char *name, char *value, char const* def);
+
+bool isSupportTv();
+int tvserver_suspend();
+int tvserver_resume();
+
+#endif