MCPcopy Create free account
hub / github.com/buggins/coolreader / installLibrary

Method installLibrary

android/src/org/coolreader/crengine/Engine.java:1111–1155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1109 private boolean force_install_library = false;
1110
1111 private void installLibrary() {
1112 try {
1113 if (force_install_library)
1114 throw new Exception("forcing install");
1115 // try loading library w/o manual installation
1116 log.i("trying to load library " + LIBRARY_NAME
1117 + " w/o installation");
1118 System.loadLibrary(LIBRARY_NAME);
1119 // try invoke native method
1120 //log.i("trying execute native method ");
1121 //setHyphenationMethod(HYPH_NONE, new byte[] {});
1122 log.i(LIBRARY_NAME + " loaded successfully");
1123 } catch (Exception ee) {
1124 log.i(SO_NAME + " not found using standard paths, will install manually");
1125 File sopath = mActivity.getDir("libs", Context.MODE_PRIVATE);
1126 File soname = new File(sopath, SO_NAME);
1127 try {
1128 sopath.mkdirs();
1129 File zip = new File(mActivity.getPackageCodePath());
1130 ZipFile zipfile = new ZipFile(zip);
1131 ZipEntry zipentry = zipfile.getEntry("lib/armeabi/" + SO_NAME);
1132 if (!soname.exists() || zipentry.getSize() != soname.length()) {
1133 InputStream is = zipfile.getInputStream(zipentry);
1134 OutputStream os = new FileOutputStream(soname);
1135 Log.i("cr3",
1136 "Installing JNI library "
1137 + soname.getAbsolutePath());
1138 final int BUF_SIZE = 0x10000;
1139 byte[] buf = new byte[BUF_SIZE];
1140 int n;
1141 while ((n = is.read(buf)) > 0)
1142 os.write(buf, 0, n);
1143 is.close();
1144 os.close();
1145 } else {
1146 log.i("JNI library " + soname.getAbsolutePath()
1147 + " is up to date");
1148 }
1149 System.load(soname.getAbsolutePath());
1150 //setHyphenationMethod(HYPH_NONE, new byte[] {});
1151 } catch (Exception e) {
1152 log.e("cannot install " + LIBRARY_NAME + " library", e);
1153 }
1154 }
1155 }
1156
1157 public static final BackgroundTextureInfo NO_TEXTURE = new BackgroundTextureInfo(
1158 BackgroundTextureInfo.NO_TEXTURE_ID, "(SOLID COLOR)", 0);

Callers 1

EngineMethod · 0.95

Calls 10

getDirMethod · 0.80
existsMethod · 0.80
iMethod · 0.65
eMethod · 0.65
getSizeMethod · 0.45
lengthMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected