|
75 | 75 | import static openscience.crowdsource.video.experiments.AppConfigService.externalSDCardOpenscienceTmpPath; |
76 | 76 | import static openscience.crowdsource.video.experiments.AppConfigService.externalSDCardPath; |
77 | 77 | import static openscience.crowdsource.video.experiments.AppConfigService.initAppConfig; |
| 78 | +import static openscience.crowdsource.video.experiments.AppConfigService.libOpenCLFileName; |
| 79 | +import static openscience.crowdsource.video.experiments.AppConfigService.maliGLESFilePaths; |
78 | 80 | import static openscience.crowdsource.video.experiments.AppConfigService.parsePredictionRawResult; |
79 | 81 | import static openscience.crowdsource.video.experiments.AppConfigService.url_cserver; |
80 | 82 | import static openscience.crowdsource.video.experiments.RecognitionScenarioService.PRELOADING_TEXT; |
81 | 83 | import static openscience.crowdsource.video.experiments.Utils.createDirIfNotExist; |
82 | | -import static openscience.crowdsource.video.experiments.Utils.getABI; |
83 | 84 | import static openscience.crowdsource.video.experiments.Utils.validateReturnCode; |
84 | 85 |
|
85 | 86 | /** |
@@ -930,7 +931,7 @@ public void println(String text) { |
930 | 931 |
|
931 | 932 | //patrh open cl version |
932 | 933 | String openCLlibPath = null; |
933 | | -// openCLlibPath = patchOpenCL(); temporary disabled |
| 934 | + openCLlibPath = patchOpenCLIfRequired(); |
934 | 935 |
|
935 | 936 | if (openCLlibPath != null) { |
936 | 937 | libPath = libPath + ":" + openCLlibPath; |
@@ -1147,47 +1148,53 @@ private void showIsThatCorrectDialog(final String recognitionResultText, final S |
1147 | 1148 | openResultActivity(); |
1148 | 1149 | } |
1149 | 1150 |
|
1150 | | - private String patchOpenCL() { |
1151 | | - String libOpenCLFileName = "libOpenCL.so"; |
1152 | | - String fromFilePath = "/system/vendor/lib/egl/libGLES_mali.so"; |
| 1151 | + private String patchOpenCLIfRequired() { |
| 1152 | + if (PlatformFeaturesService.isOpenCLSupported()) { |
| 1153 | + // patch is not required |
| 1154 | + return null; |
| 1155 | + } |
1153 | 1156 |
|
1154 | | - String targetAppFileDir = AppConfigService.getLocalAppPath() + File.separator + "openscience" + File.separator + "code/libopencl/armeabi-v7a"; |
1155 | | - String targetAppFilePath = targetAppFileDir + File.separator + libOpenCLFileName; |
| 1157 | + for (String fromFilePath : maliGLESFilePaths) { |
1156 | 1158 |
|
1157 | | - String[] rmResult = openme.openme_run_program("rm " + targetAppFilePath, null, targetAppFileDir); |
1158 | | - if (rmResult[0].isEmpty() && rmResult[1].isEmpty() && rmResult[2].isEmpty()) { |
1159 | | - publishProgress(" * File " + targetAppFilePath + " successfully removed...\n"); |
1160 | | - } else { |
1161 | | - publishProgress("\nError removing file " + fromFilePath + " ..." + rmResult[0] + " " + rmResult[1] + " " + rmResult[2]); |
1162 | | - } |
| 1159 | + String targetAppFileDir = AppConfigService.getLocalAppPath() + File.separator + "openscience" + File.separator + "code/libopencl"; |
| 1160 | + String targetAppFilePath = targetAppFileDir + File.separator + libOpenCLFileName; |
1163 | 1161 |
|
| 1162 | + String[] rmResult = openme.openme_run_program("rm " + targetAppFilePath, null, targetAppFileDir); |
| 1163 | + if (rmResult[0].isEmpty() && rmResult[1].isEmpty() && rmResult[2].isEmpty()) { |
| 1164 | + publishProgress(" * File " + targetAppFilePath + " successfully removed...\n"); |
| 1165 | + } else { |
| 1166 | + publishProgress("\nError removing file " + fromFilePath + " ..." + rmResult[0] + " " + rmResult[1] + " " + rmResult[2]); |
| 1167 | + } |
1164 | 1168 |
|
1165 | | - File appfp = new File(targetAppFileDir); |
1166 | | - if (!appfp.exists()) { |
1167 | | - if (!appfp.mkdirs()) { |
1168 | | - publishProgress("\nError creating dir (" + targetAppFileDir + ") ..."); |
1169 | | - return null; |
| 1169 | + |
| 1170 | + File appfp = new File(targetAppFileDir); |
| 1171 | + if (!appfp.exists()) { |
| 1172 | + if (!appfp.mkdirs()) { |
| 1173 | + publishProgress("\nError creating dir (" + targetAppFileDir + ") ..."); |
| 1174 | + return null; |
| 1175 | + } |
1170 | 1176 | } |
1171 | | - } |
1172 | 1177 |
|
1173 | 1178 |
|
1174 | | - try { |
1175 | | - copy_bin_file(fromFilePath, targetAppFilePath); |
1176 | | - publishProgress("\n * File " + fromFilePath + " successfully copied to " + targetAppFilePath); |
1177 | | - } catch (IOException e) { |
1178 | | - e.printStackTrace(); |
1179 | | - publishProgress("\nError copying file " + fromFilePath + " to " + targetAppFilePath + " ..." + e.getLocalizedMessage()); |
1180 | | - return null; |
1181 | | - } |
| 1179 | + try { |
| 1180 | + copy_bin_file(fromFilePath, targetAppFilePath); |
| 1181 | + publishProgress("\n * File " + fromFilePath + " successfully copied to " + targetAppFilePath); |
| 1182 | + } catch (IOException e) { |
| 1183 | + e.printStackTrace(); |
| 1184 | + publishProgress("\nError copying file " + fromFilePath + " to " + targetAppFilePath + " ..." + e.getLocalizedMessage()); |
| 1185 | + return null; |
| 1186 | + } |
1182 | 1187 |
|
1183 | | - String[] chmodResult = openme.openme_run_program(COMMAND_CHMOD_744 + " " + targetAppFilePath, null, targetAppFileDir); |
1184 | | - if (chmodResult[0].isEmpty() && chmodResult[1].isEmpty() && chmodResult[2].isEmpty()) { |
1185 | | - publishProgress(" * File " + targetAppFilePath + " successfully set as executable ...\n"); |
1186 | | - } else { |
1187 | | - publishProgress("\nError setting file " + fromFilePath + " as executable ..."); |
1188 | | - return null; |
| 1188 | + String[] chmodResult = openme.openme_run_program(COMMAND_CHMOD_744 + " " + targetAppFilePath, null, targetAppFileDir); |
| 1189 | + if (chmodResult[0].isEmpty() && chmodResult[1].isEmpty() && chmodResult[2].isEmpty()) { |
| 1190 | + publishProgress(" * File " + targetAppFilePath + " successfully set as executable ...\n"); |
| 1191 | + } else { |
| 1192 | + publishProgress("\nError setting file " + fromFilePath + " as executable ..."); |
| 1193 | + return null; |
| 1194 | + } |
| 1195 | + return targetAppFileDir; |
1189 | 1196 | } |
1190 | | - return targetAppFileDir; |
| 1197 | + return null; |
1191 | 1198 | } |
1192 | 1199 | } |
1193 | 1200 |
|
|
0 commit comments