|
|
@@ -4,6 +4,7 @@ import android.accessibilityservice.AccessibilityServiceInfo;
|
|
|
import android.content.Context;
|
|
|
import android.content.SharedPreferences;
|
|
|
import android.content.pm.ServiceInfo;
|
|
|
+import android.content.res.AssetManager;
|
|
|
import android.provider.Settings;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
@@ -20,9 +21,15 @@ import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import java.io.DataOutputStream;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
@@ -77,6 +84,9 @@ public class Utils {
|
|
|
p.waitFor();
|
|
|
|
|
|
Log.i(TAG, "Output: " + res);
|
|
|
+ if (err.length() > 0) {
|
|
|
+ Log.i(TAG, "Error: " + err);
|
|
|
+ }
|
|
|
|
|
|
return res.toString();
|
|
|
}
|
|
|
@@ -198,4 +208,45 @@ public class Utils {
|
|
|
IndeterminateDrawable progressIndicatorDrawable = IndeterminateDrawable.createCircularDrawable(context, spec);
|
|
|
button.setIcon(progressIndicatorDrawable);
|
|
|
}
|
|
|
+
|
|
|
+ public static boolean copyAssetFolder(AssetManager assetManager,
|
|
|
+ String fromAssetPath, String toPath) {
|
|
|
+ try {
|
|
|
+ String[] files = assetManager.list(fromAssetPath);
|
|
|
+ new File(toPath).mkdirs();
|
|
|
+ boolean res = true;
|
|
|
+ for (String file : files)
|
|
|
+ if (file.contains("."))
|
|
|
+ res &= copyAsset(assetManager,
|
|
|
+ fromAssetPath + "/" + file,
|
|
|
+ toPath + "/" + file);
|
|
|
+ else
|
|
|
+ res &= copyAssetFolder(assetManager,
|
|
|
+ fromAssetPath + "/" + file,
|
|
|
+ toPath + "/" + file);
|
|
|
+ return res;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static boolean copyAsset(AssetManager assetManager,
|
|
|
+ String fromAssetPath, String toPath) {
|
|
|
+ InputStream in = null;
|
|
|
+ OutputStream out = null;
|
|
|
+ try {
|
|
|
+ in = assetManager.open(fromAssetPath);
|
|
|
+ new File(toPath).createNewFile();
|
|
|
+ out = Files.newOutputStream(Paths.get(toPath));
|
|
|
+ IOUtils.copy(in, out);
|
|
|
+ in.close();
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ return true;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|