Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/path_provider/path_provider_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.3.1

* Removes dependency on `PathUtils` to avoid a potential
`ClassNotFoundException` when running in release mode.

## 2.3.0

* Changes internal implementation to use JNI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7279,151 +7279,6 @@ final class $Context$Type$ extends jni$_.JType<Context> {
String get signature => r'Landroid/content/Context;';
}

/// from: `io.flutter.util.PathUtils`
extension type PathUtils._(jni$_.JObject _$this) implements jni$_.JObject {
static final _class = jni$_.JClass.forName(r'io/flutter/util/PathUtils');

/// The type which includes information such as the signature of this class.
static const jni$_.JType<PathUtils> type = $PathUtils$Type$();
static final _id_new$ = _class.constructorId(r'()V');

static final _new$ =
jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
)
>
>('globalEnv_NewObject')
.asFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
)
>();

/// from: `public void <init>()`
/// The returned object must be released after use, by calling the [release] method.
factory PathUtils() {
return _new$(
_class.reference.pointer,
_id_new$.pointer,
).object<PathUtils>();
}

static final _id_getFilesDir = _class.staticMethodId(
r'getFilesDir',
r'(Landroid/content/Context;)Ljava/lang/String;',
);

static final _getFilesDir =
jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.VarArgs<(jni$_.Pointer<jni$_.Void>,)>,
)
>
>('globalEnv_CallStaticObjectMethod')
.asFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.Pointer<jni$_.Void>,
)
>();

/// from: `static public java.lang.String getFilesDir(android.content.Context context)`
/// The returned object must be released after use, by calling the [release] method.
static jni$_.JString getFilesDir(Context context) {
final _$context = context.reference;
return _getFilesDir(
_class.reference.pointer,
_id_getFilesDir.pointer,
_$context.pointer,
).object<jni$_.JString>();
}

static final _id_getDataDirectory = _class.staticMethodId(
r'getDataDirectory',
r'(Landroid/content/Context;)Ljava/lang/String;',
);

static final _getDataDirectory =
jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.VarArgs<(jni$_.Pointer<jni$_.Void>,)>,
)
>
>('globalEnv_CallStaticObjectMethod')
.asFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.Pointer<jni$_.Void>,
)
>();

/// from: `static public java.lang.String getDataDirectory(android.content.Context context)`
/// The returned object must be released after use, by calling the [release] method.
static jni$_.JString getDataDirectory(Context context) {
final _$context = context.reference;
return _getDataDirectory(
_class.reference.pointer,
_id_getDataDirectory.pointer,
_$context.pointer,
).object<jni$_.JString>();
}

static final _id_getCacheDirectory = _class.staticMethodId(
r'getCacheDirectory',
r'(Landroid/content/Context;)Ljava/lang/String;',
);

static final _getCacheDirectory =
jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.VarArgs<(jni$_.Pointer<jni$_.Void>,)>,
)
>
>('globalEnv_CallStaticObjectMethod')
.asFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.Pointer<jni$_.Void>,
)
>();

/// from: `static public java.lang.String getCacheDirectory(android.content.Context context)`
/// The returned object must be released after use, by calling the [release] method.
static jni$_.JString getCacheDirectory(Context context) {
final _$context = context.reference;
return _getCacheDirectory(
_class.reference.pointer,
_id_getCacheDirectory.pointer,
_$context.pointer,
).object<jni$_.JString>();
}
}

final class $PathUtils$Type$ extends jni$_.JType<PathUtils> {
@jni$_.internal
const $PathUtils$Type$();

@jni$_.internal
@core$_.override
String get signature => r'Lio/flutter/util/PathUtils;';
}

/// from: `java.io.File`
extension type File._(jni$_.JObject _$this) implements jni$_.JObject {
static final _class = jni$_.JClass.forName(r'java/io/File');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,23 @@ class PathProviderAndroid extends PathProviderPlatform {

@override
Future<String?> getApplicationSupportPath() async {
return PathUtils.getFilesDir(
_applicationContext,
).toDartString(releaseOriginal: true);
final File? file = _applicationContext.filesDir;
final String? path = file?.path?.toDartString(releaseOriginal: true);
file?.release();
return path;
}

@override
Future<String?> getApplicationDocumentsPath() async {
return PathUtils.getDataDirectory(
_applicationContext,
).toDartString(releaseOriginal: true);
final JString directory = 'flutter'.toJString();
final File? file = _applicationContext.getDir(
directory,
Context.MODE_PRIVATE,
);
final String? path = file?.path?.toDartString(releaseOriginal: true);
file?.release();
directory.release();
return path;
}

@override
Expand Down
2 changes: 1 addition & 1 deletion packages/path_provider/path_provider_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: path_provider_android
description: Android implementation of the path_provider plugin.
repository: https://github.com/flutter/packages/tree/main/packages/path_provider/path_provider_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+path_provider%22
version: 2.3.0
version: 2.3.1

environment:
sdk: ^3.9.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ void main() {
),
classes: <String>[
'android.content.Context',
'io.flutter.util.PathUtils',
'java.io.File',
'android.os.Environment',
],
Expand Down
Loading