-
-
Notifications
You must be signed in to change notification settings - Fork 874
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port
Environment.isExternalStorageManager
(#1218)
- Loading branch information
1 parent
05f587a
commit 40e41a2
Showing
9 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
..._android/android/src/main/java/com/baseflow/permissionhandler/EnvironmentHostApiImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.baseflow.permissionhandler; | ||
|
||
import android.os.Build; | ||
import android.os.Environment; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.RequiresApi; | ||
|
||
import com.baseflow.instancemanager.InstanceManager; | ||
import com.baseflow.permissionhandler.PermissionHandlerPigeon.EnvironmentHostApi; | ||
|
||
import io.flutter.plugin.common.BinaryMessenger; | ||
|
||
/** | ||
* Host API implementation for `Environment`. | ||
* | ||
* <p>This class may handle instantiating and adding native object instances that are attached to a | ||
* Dart instance or handle method calls on the associated native class or an instance of the class. | ||
*/ | ||
public class EnvironmentHostApiImpl implements EnvironmentHostApi { | ||
// To ease adding additional methods, this value is added prematurely. | ||
@SuppressWarnings({"unused", "FieldCanBeLocal"}) | ||
private final BinaryMessenger binaryMessenger; | ||
|
||
// To ease adding additional methods, this value is added prematurely. | ||
@SuppressWarnings({"unused", "FieldCanBeLocal"}) | ||
private final InstanceManager instanceManager; | ||
|
||
/** | ||
* Constructs an {@link EnvironmentHostApiImpl}. | ||
* | ||
* @param binaryMessenger used to communicate with Dart over asynchronous messages | ||
* @param instanceManager maintains instances stored to communicate with attached Dart objects | ||
*/ | ||
public EnvironmentHostApiImpl( | ||
@NonNull BinaryMessenger binaryMessenger, | ||
@NonNull InstanceManager instanceManager | ||
) { | ||
this.binaryMessenger = binaryMessenger; | ||
this.instanceManager = instanceManager; | ||
} | ||
|
||
@RequiresApi(api = Build.VERSION_CODES.R) | ||
@NonNull | ||
@Override | ||
public Boolean isExternalStorageManager() { | ||
return Environment.isExternalStorageManager(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
permission_handler_android/lib/src/android_object_mirrors/environment.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import '../permission_handler.pigeon.dart'; | ||
|
||
/// Provides access to environment variables. | ||
/// | ||
/// See https://developer.android.com/reference/android/os/Environment. | ||
class Environment { | ||
const Environment._(); | ||
|
||
static final EnvironmentHostApi _hostApi = EnvironmentHostApi(); | ||
|
||
/// Returns whether the calling app has All Files Access on the primary shared/external storage media. | ||
/// | ||
/// Declaring the permission [Manifest.permission.manageExternalStorage] is | ||
/// not enough to gain the access. To request access, use | ||
/// [Settings.actionManageAppAllFilesAccessPermission]. | ||
/// | ||
/// See https://developer.android.com/reference/android/os/Environment#isExternalStorageManager(). | ||
static Future<bool> isExternalStorageManager() { | ||
return _hostApi.isExternalStorageManager(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters