1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include <signal.h> 18#include <sys/types.h> 19#include <sys/stat.h> 20#include <dirent.h> 21#include <unistd.h> 22#include <dlfcn.h> 23#include <stdlib.h> 24#include "dmprofile.h" 25#include "xpl_dm_Manager.h" 26#include "dm_uri_utils.h" 27#include "xpl_Logger.h" 28#include "dmtTreeImpl.hpp" 29 30#ifdef FEAT_DM_VERSION_FLEX 31#include "SETUP_GetFlex.h" 32#endif 33 34static DMString dm_version; 35static CPCHAR dm_poc_enabled = NULL; 36 37SYNCML_DM_RET_STATUS_T XPL_DM_Init() 38{ 39 if( 0 == dm_version.length() ) 40 { 41#ifdef FEAT_DM_VERSION_FLEX 42 CPCHAR ver = getenv("dm_setting_version"); 43 if ( ver == NULL ) 44 { 45 BOOLEAN bIsVersion12; 46 getFlexBit_setupflex(DL_DB_FEATURE_ID_DM_PROTOCOL_VERSION_12_AVAILABLE,&bIsVersion12); 47 if ( bIsVersion12 ) 48 { 49 dm_version = SYNCML_REP_PROTOCOL_VERSION_1_2; 50 } 51 else 52 { 53 dm_version = "1.1.2"; 54 } 55 } 56 else 57 { 58 dm_version = ver; 59 } 60#else 61 CPCHAR ver = getenv("dm_setting_version"); 62 if ( ver == NULL ) 63 { 64 dm_version = SYNCML_REP_PROTOCOL_VERSION_1_2; 65 } 66 else 67 { 68 dm_version = ver; 69 } 70#endif 71 } 72#ifdef FEAT_DM_VERSION_FLEX 73 if ( dm_poc_enabled == NULL ) 74 { 75 BOOLEAN bIsEnabled = TRUE; 76 getFlexBit_setupflex(DL_DB_FEATURE_ID_POC_PROVISION_VIA_OMADM__AVAILABLE,&bIsEnabled); 77 dm_poc_enabled = (bIsEnabled)?"1":"0"; 78 } 79#endif 80 return SYNCML_DM_SUCCESS; 81} 82 83SYNCML_DM_RET_STATUS_T XPL_DM_DeInit() 84{ 85 dm_version = NULL; 86 return SYNCML_DM_SUCCESS; 87} 88 89 90BOOLEAN XPL_DM_IsFeatureEnabled(CPCHAR pUri) 91{ 92 return TRUE; 93} 94 95 96static const char * session_lib = "libdmssession.so"; 97//static const char * dm_android_setting_root = "/data/dm/dmt_data"; 98static const char * dm_android_setting_root = "/data/data/com.android.omadm.service/files/dm/dmt_data"; 99//static const char * dm_android_setting_plugin = "/data/dm/plugin"; 100static const char * dm_android_setting_plugin = "/data/data/com.android.omadm.service/files/dm/plugin"; 101 102CPCHAR XPL_DM_GetEnv(SYNCML_DM_ENVIRONMENT_T env_var) 103{ 104 105 106 switch ( env_var ) 107 { 108 case SYNCML_DM_SETTINGS_PATH : 109 if (getenv("dm_setting_root") == NULL) { 110 return dm_android_setting_root; 111 } 112 else { 113 return getenv("dm_setting_root"); 114 } 115 case SYNCML_DM_PLUGINS_PATH : 116 if (getenv("dm_setting_plugin") == NULL) { 117 return dm_android_setting_plugin; 118 } 119 else { 120 return getenv("dm_setting_plugin"); 121 } 122 case SYNCML_DM_SECURITY_LEVEL : 123 return getenv("DM_SRV_SEC_LEVEL"); 124 case SYNCML_DM_ESCAPE_CHAR : 125 return getenv("DM_ESCAPE_CHAR"); 126 case SYNCML_DM_MEMORY_AGING_INTERVAL : 127 return getenv("DM_AGING_CHECK_INTERVAL"); 128 case SYNCML_DM_MEMORY_AGING_TIME : 129 return getenv("DM_AGING_TIME"); 130 case SYNCML_DM_POWER_FAIL_IJECTION : 131 return getenv("power_fail"); 132 133 case SYNCML_DM_DUMP_SESSION_PACKAGE_PATH : 134 return getenv("DUMP_SYNCML_PATH"); 135 136 case SYNCML_DM_SESSION_LIB : 137 return session_lib; 138 139 case SYNCML_DM_VERSION: 140 return dm_version.GetBuffer(); 141 142 case SYNCML_DM_DMACC_ROOT_PATH: 143 return ( dm_version == SYNCML_REP_PROTOCOL_VERSION_1_2 ) 144 ? DM_DMACC_1_2_URI 145 : DM_DMACC_1_1_URI; 146 147 case SYNCML_DM_NODENAME_SERVERID: 148 return ( dm_version == SYNCML_REP_PROTOCOL_VERSION_1_2 ) 149 ? DM_SERVERID_1_2 150 : DM_SERVERID_1_1; 151 152 case SYNCML_DM_SESSION_ID: 153 return "./DevDetail/Ext/Conf/PMF/Agents/syncmldm/Sessionid"; 154 155 case SYNCML_DM_FEATURE_ID_POC_PROVISION_VIA_OMADM: 156 return dm_poc_enabled; 157 158 } 159 160 return NULL; 161 162} 163 164#define DM_CHUNK_BUFFER_LJ 8192 165 166/*================================================================================================== 167 FUNCTION : XPL_DM_GetChunkSize 168 169 DESCRIPTION : Get chunk buffer size for Linux-Java platform 170 ARGUMENT PASSED : 171 172 OUTPUT PARAMETER: 173 RETURN VALUE : 174 IMPORTANT NOTES : 175 ==================================================================================================*/ 176UINT32 XPL_DM_GetChunkSize() 177{ 178 return DM_CHUNK_BUFFER_LJ; 179} 180