Skip to content

Commit

Permalink
## 4.2.1.8 (#77)
Browse files Browse the repository at this point in the history
* Implement custom removable storage handling for Android 11
* Add permission to publish GPS location in background on Android 11
  • Loading branch information
takdeveloper authored Apr 21, 2021
1 parent 0fcabf4 commit 7aeb482
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 21 deletions.
5 changes: 5 additions & 0 deletions VERSION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Version History

## 4.2.1.8

* Implement custom removable storage handling for Android 11
* Add permission to publish GPS location in background on Android 11

## 4.2.1.7

* Adjust DPI for GeoPDF to make maps more readable
Expand Down
2 changes: 1 addition & 1 deletion atak/ATAK/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import java.util.regex.Pattern
buildscript {

ext.ATAK_VERSION = "4.2.1"
ext.ATAK_VERSION_SUBMINOR = ".7"
ext.ATAK_VERSION_SUBMINOR = ".8"

ext.jacocoVersion = '0.8.5'

Expand Down
1 change: 1 addition & 0 deletions atak/ATAK/app/proguard-release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,4 @@

# make sure jassimp is happy
-keep class jassimp.** {*;}
-keep class com.atakmap.coremap.filesystem.RemovableStorageHelper {*;}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Environment;
import androidx.annotation.NonNull;
import android.util.AttributeSet;
Expand Down Expand Up @@ -35,6 +36,7 @@
import com.atakmap.app.R;
import com.atakmap.coremap.filesystem.FileSystemUtils;

import java.util.Map;
import java.util.regex.Pattern;

import org.apache.commons.lang.StringUtils;
Expand All @@ -48,6 +50,7 @@
import java.util.Comparator;
import java.util.List;

import com.atakmap.coremap.filesystem.RemovableStorageHelper;
import com.atakmap.coremap.io.DefaultIOProvider;
import com.atakmap.coremap.io.IOProvider;
import com.atakmap.coremap.io.IOProviderFactory;
Expand Down Expand Up @@ -120,7 +123,9 @@ public void setExternalButton(View sdcardButton) {
sdcardButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
String android_storage = System.getenv("ANDROID_STORAGE");
final String android_storage =
RemovableStorageHelper.getRemovableStorageDirectory()[0];

if (android_storage != null)
setCurrentPath(new File(android_storage));
}
Expand Down
3 changes: 3 additions & 0 deletions atak/ATAK/app/src/main/java/com/atakmap/app/ATAKActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

import com.atakmap.android.data.ClearContentTask;
import com.atakmap.android.dropdown.DropDownManager;
import com.atakmap.coremap.filesystem.RemovableStorageHelper;
import com.atakmap.os.FileObserver;
import com.atakmap.android.gui.HintDialogHelper;
import com.atakmap.android.http.rest.HTTPRequestService;
Expand Down Expand Up @@ -148,6 +149,8 @@ public class ATAKActivity extends MapActivity implements
@Override
public void onCreate(final Bundle savedInstanceState) {

RemovableStorageHelper.init(this);

_controlPrefs = PreferenceManager.getDefaultSharedPreferences(this);

// please note - this should never be set to false unless being called as part of
Expand Down
20 changes: 19 additions & 1 deletion atak/ATAK/app/src/main/java/com/atakmap/app/Permissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,25 @@ private static void showWarning(final Activity a) {
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
a.requestPermissions(locationPermissionsList, REQUEST_ID);

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
AlertDialog.Builder ab = new AlertDialog.Builder(a);
ab.setTitle("Android 11");
ab.setMessage("Android 11 restricts the use of GPS in the background. "
+ "To continue publish your location for use by your team when ATAK is in the background, you will need to ATAK and enable \'Allow All of the Time\'\n\n"
+ "Please note - ATAK does not collect GPS information while it is not running.");
ab.setCancelable(false);
ab.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
a.requestPermissions(new String[] { Manifest.permission.ACCESS_BACKGROUND_LOCATION }, REQUEST_ID);
}
});
ab.show();
} else {
a.requestPermissions(locationPermissionsList, REQUEST_ID);
}
}
});
AlertDialog ad = builder.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,24 +317,20 @@ private static void envFindMountRootDirs(Set<File> retval) {

String android_storage = System.getenv("ANDROID_STORAGE");
if (android_storage != null) {
File f = new File(android_storage);
if (IOProviderFactory.exists(f) && IOProviderFactory.isDirectory(f)
&& IOProviderFactory.canRead(f)) {
File[] subdirs = IOProviderFactory.listFiles(f);
if (subdirs != null) {
for (File subdir : subdirs) {
if (subdir != null) {
File root = new File(subdir,
ATAK_ROOT_DIRECTORY);
if (IOProviderFactory.isDirectory(root)
&& IOProviderFactory.canRead(root)) {
try {
root = subdir.getCanonicalFile();
retval.add(root);
Log.d(TAG, "found atak directory under: "
+ root);
} catch (IOException ignored) {
}
String[] directories = RemovableStorageHelper.getRemovableStorageDirectory();
if (directories != null) {
for (String subdir : directories) {
if (subdir != null) {
File root = new File(subdir,
ATAK_ROOT_DIRECTORY);
if (IOProviderFactory.isDirectory(root)
&& IOProviderFactory.canRead(root)) {
try {
root = new File(subdir).getCanonicalFile();
retval.add(root);
Log.d(TAG, "found atak directory under: "
+ root);
} catch (IOException ignored) {
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.atakmap.coremap.filesystem;

import android.content.Context;
import android.os.Build;

import com.atakmap.coremap.io.IOProviderFactory;
import com.atakmap.coremap.log.Log;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class RemovableStorageHelper {

private static Context context;
private static final String TAG = "RemovableStorageHelper";

public static void init(Context ctx) {
context = ctx;
}

/**
* Returns the actual removable storage directory as provided by utilizing the cached directory
*
* @return the value of "ANDROID_STORAGE" as an environment variable, otherwise if on Android 11
* returns the appropriate removable storage directories.
*/
public static String[] getRemovableStorageDirectory() {

final String android_storage = System.getenv("ANDROID_STORAGE");

final List<String> mount_points = new ArrayList<>();

// Android 11 change - "ANDROID_STORAGE" is no longer readable
// utilize a very narrow scoped change to allow for backporting to 4.2.1
// already released
if (Build.VERSION.SDK_INT > 29) {

if (context == null) {
Log.d(TAG, "RemovableStorageHelper not initialized, returning " + android_storage);
return new String[]{android_storage};
}
final File[] folders = context.getExternalCacheDirs();
for (File f : folders) {
try {
final String path = f.getCanonicalPath();
if (path.startsWith(android_storage) && !path.contains("emulated/0")) {
try {
String[] pathSplit = path.split("/");
String sdcardMntPt = pathSplit[1] + "/" + pathSplit[2] + "/";
mount_points.add(sdcardMntPt);
} catch (Exception e) {
Log.e(TAG, "error finding removable sdcard", e);
}
}
} catch (Exception e){
Log.e(TAG, "error finding: " + f);
}
}

} else {
File f = new File(android_storage);
if (IOProviderFactory.exists(f) && IOProviderFactory.isDirectory(f)
&& IOProviderFactory.canRead(f)) {
File[] subdirs = IOProviderFactory.listFiles(f);
for (File subdir : subdirs) {
try {
String path = subdir.getCanonicalPath();
if (!path.contains("emulated/0"))
mount_points.add(path);
} catch (Exception e) {
Log.e(TAG, "error finding: " + subdir);
}
}
}


}
if (mount_points.isEmpty())
mount_points.add(android_storage);

return mount_points.toArray(new String[0]);
}
}
Binary file modified depends/assimp-4.0.1-mod.tar.gz
Binary file not shown.
Binary file modified depends/gdal-2.4.4-mod.tar.gz
Binary file not shown.
Binary file modified depends/tinygltf-2.4.1-mod.tar.gz
Binary file not shown.
Binary file modified depends/tinygltfloader-0.9.5-mod.tar.gz
Binary file not shown.
Binary file modified pluginsdk.zip
Binary file not shown.

0 comments on commit 7aeb482

Please sign in to comment.