From e6607cad6cdd5218da5fd6db75bb5c9e8470f1e2 Mon Sep 17 00:00:00 2001
From: dxl <64101226@qq.com>
Date: Thu, 13 Aug 2020 17:55:54 +0800
Subject: [PATCH] add some string
---
app_main/src/main/res/values-en/strings.xml | 2 +
app_main/src/main/res/values-zh/strings.xml | 2 +
app_main/src/main/res/values/strings.xml | 3 +-
termux-app/build.gradle | 2 +-
.../java/com/termux/app/TermuxActivity.java | 6 +-
.../java/com/termux/app/TermuxService.java | 24 ++++---
.../java/cn/dxl/common/util/FileUtils.java | 65 +++++++++++--------
7 files changed, 62 insertions(+), 42 deletions(-)
diff --git a/app_main/src/main/res/values-en/strings.xml b/app_main/src/main/res/values-en/strings.xml
index d3d05295..37816397 100644
--- a/app_main/src/main/res/values-en/strings.xml
+++ b/app_main/src/main/res/values-en/strings.xml
@@ -328,5 +328,7 @@
The complete terminal view is suitable for developers or masters, while the simple terminal view is suitable for novice users.
Unselected
请稍等
+ select
+ Proxmark3 External Work Directory
\ No newline at end of file
diff --git a/app_main/src/main/res/values-zh/strings.xml b/app_main/src/main/res/values-zh/strings.xml
index 7b99e2e7..c5fa6597 100644
--- a/app_main/src/main/res/values-zh/strings.xml
+++ b/app_main/src/main/res/values-zh/strings.xml
@@ -334,5 +334,7 @@
完整的终端视图适合开发人员或大师,而简单终端视图适合新手用户。
未选择
请稍等。
+ 选择
+ Proxmark3 外部工作目录
\ No newline at end of file
diff --git a/app_main/src/main/res/values/strings.xml b/app_main/src/main/res/values/strings.xml
index 43923b0c..9335ef84 100644
--- a/app_main/src/main/res/values/strings.xml
+++ b/app_main/src/main/res/values/strings.xml
@@ -299,7 +299,6 @@
Custom firmware
Select BootRom
Select FullImage
- Will use TERMUX implement UI
1. Your FW can\'t than for client version too low or high , you need go flash FW.
2. Check \'Auto Go\', it will auto go to terminal view.
Auto Go
@@ -328,5 +327,7 @@
The complete terminal view is suitable for developers or masters, while the simple terminal view is suitable for novice users.
Unselected
Please wait.
+ select
+ Proxmark3 External Work Directory
\ No newline at end of file
diff --git a/termux-app/build.gradle b/termux-app/build.gradle
index 62665010..79e20fbc 100644
--- a/termux-app/build.gradle
+++ b/termux-app/build.gradle
@@ -15,7 +15,7 @@ android {
defaultConfig {
// applicationId "com.termux"
- minSdkVersion 24
+ minSdkVersion 21
targetSdkVersion 28
versionCode 95
versionName "0.95"
diff --git a/termux-app/src/main/java/com/termux/app/TermuxActivity.java b/termux-app/src/main/java/com/termux/app/TermuxActivity.java
index b157e364..ed525dd6 100644
--- a/termux-app/src/main/java/com/termux/app/TermuxActivity.java
+++ b/termux-app/src/main/java/com/termux/app/TermuxActivity.java
@@ -67,6 +67,8 @@ import java.util.regex.Pattern;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.PermissionChecker;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
@@ -198,10 +200,10 @@ public final class TermuxActivity extends Activity implements ServiceConnection
* For processes to access shared internal storage (/sdcard) we need this permission.
*/
public boolean ensureStoragePermissionGranted() {
- if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ if (PermissionChecker.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PermissionChecker.PERMISSION_GRANTED) {
return true;
} else {
- requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUESTCODE_PERMISSION_STORAGE);
+ ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUESTCODE_PERMISSION_STORAGE);
return false;
}
}
diff --git a/termux-app/src/main/java/com/termux/app/TermuxService.java b/termux-app/src/main/java/com/termux/app/TermuxService.java
index 64bcf5b9..b8ec27a3 100644
--- a/termux-app/src/main/java/com/termux/app/TermuxService.java
+++ b/termux-app/src/main/java/com/termux/app/TermuxService.java
@@ -56,6 +56,7 @@ public final class TermuxService extends Service implements SessionChangedCallba
public static final String FILES_PATH = "/data/data/" + packageName + "/files";
public static final String PREFIX_PATH = FILES_PATH + "/usr";
public static final String HOME_PATH = FILES_PATH + "/home";
+ public static String PM3_CWD = null;
private static final int NOTIFICATION_ID = 1337;
@@ -122,7 +123,7 @@ public final class TermuxService extends Service implements SessionChangedCallba
if (mWakeLock == null) {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, EmulatorDebug.LOG_TAG);
- mWakeLock.acquire();
+ mWakeLock.acquire(10 * 60 * 1000L /*10 minutes*/);
// http://tools.android.com/tech-docs/lint-in-studio-2-3#TOC-WifiManager-Leak
WifiManager wm = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
@@ -130,16 +131,18 @@ public final class TermuxService extends Service implements SessionChangedCallba
mWifiLock.acquire();
String packageName = getPackageName();
- if (!pm.isIgnoringBatteryOptimizations(packageName)) {
- Intent whitelist = new Intent();
- whitelist.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
- whitelist.setData(Uri.parse("package:" + packageName));
- whitelist.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ if (!pm.isIgnoringBatteryOptimizations(packageName)) {
+ Intent whitelist = new Intent();
+ whitelist.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
+ whitelist.setData(Uri.parse("package:" + packageName));
+ whitelist.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- try {
- startActivity(whitelist);
- } catch (ActivityNotFoundException e) {
- Log.e(EmulatorDebug.LOG_TAG, "Failed to call ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS", e);
+ try {
+ startActivity(whitelist);
+ } catch (ActivityNotFoundException e) {
+ Log.e(EmulatorDebug.LOG_TAG, "Failed to call ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS", e);
+ }
}
}
@@ -299,6 +302,7 @@ public final class TermuxService extends Service implements SessionChangedCallba
TerminalSession createTermSession(String executablePath, String[] arguments, String cwd, boolean failSafe) {
new File(HOME_PATH).mkdirs();
+ if (PM3_CWD != null) cwd = PM3_CWD;
if (cwd == null) cwd = HOME_PATH;
String[] env = BackgroundJob.buildEnvironment(failSafe, cwd);
diff --git a/utils/src/main/java/cn/dxl/common/util/FileUtils.java b/utils/src/main/java/cn/dxl/common/util/FileUtils.java
index c106cca8..84b65468 100644
--- a/utils/src/main/java/cn/dxl/common/util/FileUtils.java
+++ b/utils/src/main/java/cn/dxl/common/util/FileUtils.java
@@ -354,43 +354,52 @@ public class FileUtils {
private static String getFilePathByUri_BELOWAPI11(Uri uri) {
// 以 content:// 开头的,比如 content://media/extenral/images/media/17766
- if (ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
- String path = null;
- String[] projection = new String[]{MediaStore.Images.Media.DATA};
- Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
+ try {
+ if (ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
+ String path = null;
+ String[] projection = new String[]{MediaStore.Images.Media.DATA};
+ Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
+ if (cursor != null) {
+ if (cursor.moveToFirst()) {
+ try {
+ int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
+ if (columnIndex > -1) {
+ path = cursor.getString(columnIndex);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ cursor.close();
+ }
+ return path;
+ }
+ } catch (Exception e) {
+ return null;
+ }
+ return null;
+ }
+
+ private static String getFilePathByUri_API11to18(Uri contentUri) {
+ String result = null;
+ try {
+ String[] projection = {MediaStore.Images.Media.DATA};
+
+ CursorLoader cursorLoader = new CursorLoader(context, contentUri, projection, null, null, null);
+ Cursor cursor = cursorLoader.loadInBackground();
if (cursor != null) {
if (cursor.moveToFirst()) {
try {
- int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
- if (columnIndex > -1) {
- path = cursor.getString(columnIndex);
- }
+ int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
+ result = cursor.getString(column_index);
} catch (Exception e) {
e.printStackTrace();
}
}
cursor.close();
}
- return path;
- }
- return null;
- }
-
- private static String getFilePathByUri_API11to18(Uri contentUri) {
- String[] projection = {MediaStore.Images.Media.DATA};
- String result = null;
- CursorLoader cursorLoader = new CursorLoader(context, contentUri, projection, null, null, null);
- Cursor cursor = cursorLoader.loadInBackground();
- if (cursor != null) {
- if (cursor.moveToFirst()) {
- try {
- int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
- result = cursor.getString(column_index);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- cursor.close();
+ } catch (Exception e) {
+ return null;
}
return result;
}