Skip to content

Commit

Permalink
chore: remove manage all file permission (#745)
Browse files Browse the repository at this point in the history
* Remove custom data folder setting

* Show resolved path in error screen

* Remove MANAGE_EXTERNAL_STORAGE permission

* Remove package file_picker and permission_handler

* Remove FLUTTER_CACHE_FOLDER and FLUTTER_DATA_FOLDER
  • Loading branch information
anhappdev authored Jun 18, 2024
1 parent ab738d9 commit 09e4b41
Show file tree
Hide file tree
Showing 17 changed files with 25 additions and 396 deletions.
18 changes: 0 additions & 18 deletions docs/custom-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,6 @@ Data directory can be changed in settings, except for iOS, and its possible loca
You can specify the full path, which will not depend on the data folder.
Absolute path is only available for the task config path. All local resources in the task config must point to the data folder.

## Overriding default folders

You can change the data folder without using graphical interface.

Use `--dart-define=FLUTTER_DATA_FOLDER=<value>` to specify the folder you want to use.
It will still be possible to choose a different folder via UI but the app will use specified folder by default.

If you build the app using makefile commands, use `FLUTTER_DATA_FOLDER` environment variable. For example: `make flutter/test/integration FLUTTER_CACHE_FOLDER=/my/folder/path`

You can also override app cache folder.
Use `--dart-define=FLUTTER_CACHE_FOLDER=<value>` for manual build or `FLUTTER_CACHE_FOLDER` env for makefile script.
Note that it's impossible to change the cache folder from the UI.

These options are intended for CI use, and possibly for internal testing.
Never use them for any public builds.

These options are not available on iOS.

## Using external resources on an iPhone

On iOS an application resource folder can be found in `On My iPhone` -> `<app name>`.
Expand Down
2 changes: 0 additions & 2 deletions flutter/android/android-docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ flutter_common_docker_flags= \
--env FIREBASE_CRASHLYTICS_ENABLED=${FIREBASE_CRASHLYTICS_ENABLED} \
--env FLUTTER_BUILD_NUMBER=${FLUTTER_BUILD_NUMBER} \
--env FLUTTER_FORCE_PUB_GET=1 \
--env FLUTTER_DATA_FOLDER=${FLUTTER_DATA_FOLDER} \
--env FLUTTER_CACHE_FOLDER=${FLUTTER_CACHE_FOLDER} \
${proxy_docker_args} \
${backend_qti_flutter_docker_args} \
${backend_samsung_docker_args} \
Expand Down
6 changes: 2 additions & 4 deletions flutter/android/android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,15 @@ flutter/android/apk:
cd flutter && ${_start_args} flutter --no-version-check build apk \
${flutter_official_build_arg} \
${flutter_firebase_crashlytics_arg} \
${flutter_build_number_arg} \
${flutter_folder_args}
${flutter_build_number_arg}
cp -f flutter/build/app/outputs/flutter-apk/app-release.apk ${flutter_android_apk_release_path}.apk
.PHONY: flutter/android/appbundle
flutter/android/appbundle:
mkdir -p $$(dirname ${flutter_android_apk_release_path})
cd flutter && ${_start_args} flutter --no-version-check build appbundle \
${flutter_official_build_arg} \
${flutter_firebase_crashlytics_arg} \
${flutter_build_number_arg} \
${flutter_folder_args}
${flutter_build_number_arg}
cp -f flutter/build/app/outputs/bundle/release/app-release.aab ${flutter_android_apk_release_path}.aab

FLUTTER_ANDROID_APK_TEST_MAIN?=test-main.apk
Expand Down
1 change: 0 additions & 1 deletion flutter/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
Expand Down
16 changes: 1 addition & 15 deletions flutter/flutter.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@ flutter/check/build-number:
@[ -n "$$FLUTTER_BUILD_NUMBER" ] \
|| (echo FLUTTER_BUILD_NUMBER env must be explicitly set; exit 1)

ifneq (${FLUTTER_DATA_FOLDER},)
flutter_data_folder_arg="--dart-define=FLUTTER_DATA_FOLDER=${FLUTTER_DATA_FOLDER}"
else
flutter_data_folder_arg=
endif
ifneq (${FLUTTER_CACHE_FOLDER},)
flutter_cache_folder_arg="--dart-define=FLUTTER_CACHE_FOLDER=${FLUTTER_CACHE_FOLDER}"
else
flutter_cache_folder_arg=
endif
flutter_folder_args=${flutter_data_folder_arg} ${flutter_cache_folder_arg}

FIREBASE_CRASHLYTICS_ENABLED?=false
flutter_firebase_crashlytics_arg="--dart-define=FIREBASE_CRASHLYTICS_ENABLED=${FIREBASE_CRASHLYTICS_ENABLED}"

Expand Down Expand Up @@ -180,15 +168,13 @@ flutter/test/integration:
${flutter_test_device_arg} \
${flutter_official_build_arg} \
${flutter_firebase_crashlytics_arg} \
${flutter_perf_test_arg} \
${flutter_folder_args}
${flutter_perf_test_arg}

.PHONY: flutter/run
flutter/run:
cd flutter && ${_start_args} \
flutter --no-version-check \
run \
${flutter_folder_args} \
${flutter_test_device_arg} \
${flutter_official_build_arg} \
${flutter_firebase_crashlytics_arg}
Expand Down
12 changes: 0 additions & 12 deletions flutter/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ PODS:
- Flutter
- device_info_plus (0.0.1):
- Flutter
- file_picker (0.0.1):
- Flutter
- Firebase/Auth (10.25.0):
- Firebase/CoreOnly
- FirebaseAuth (~> 10.25.0)
Expand Down Expand Up @@ -147,8 +145,6 @@ PODS:
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- permission_handler_apple (9.1.1):
- Flutter
- PromisesObjC (2.4.0)
- PromisesSwift (2.4.0):
- PromisesObjC (= 2.4.0)
Expand All @@ -168,7 +164,6 @@ PODS:
DEPENDENCIES:
- desktop_webview_auth (from `.symlinks/plugins/desktop_webview_auth/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- firebase_app_check (from `.symlinks/plugins/firebase_app_check/ios`)
- firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
Expand All @@ -179,7 +174,6 @@ DEPENDENCIES:
- integration_test (from `.symlinks/plugins/integration_test/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- share (from `.symlinks/plugins/share/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
Expand Down Expand Up @@ -216,8 +210,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/desktop_webview_auth/ios"
device_info_plus:
:path: ".symlinks/plugins/device_info_plus/ios"
file_picker:
:path: ".symlinks/plugins/file_picker/ios"
firebase_app_check:
:path: ".symlinks/plugins/firebase_app_check/ios"
firebase_auth:
Expand All @@ -238,8 +230,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
share:
:path: ".symlinks/plugins/share/ios"
share_plus:
Expand All @@ -255,7 +245,6 @@ SPEC CHECKSUMS:
AppCheckCore: db04d539b37794558391bc56bc65e2440b01a195
desktop_webview_auth: d645139460ef203d50bd0cdb33356785dd939cce
device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d
file_picker: 684373a825f14becb5556cf6c5b88610290914b2
Firebase: 0312a2352584f782ea56f66d91606891d4607f06
firebase_app_check: b67baa1ab3942b51fde8855f614f543d9d6b4dba
firebase_auth: 76ea642e91a9e914b3af751a416046ce1a965cf4
Expand Down Expand Up @@ -284,7 +273,6 @@ SPEC CHECKSUMS:
nanopb: 438bc412db1928dac798aa6fd75726007be04262
package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
RecaptchaInterop: 7d1a4a01a6b2cb1610a47ef3f85f0c411434cb21
Expand Down
4 changes: 0 additions & 4 deletions flutter/lib/app_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ class DartDefine {
bool.fromEnvironment('FIREBASE_CRASHLYTICS_ENABLED', defaultValue: false);
static const isFastMode =
bool.fromEnvironment('FAST_MODE', defaultValue: false);
static const defaultCacheFolder =
String.fromEnvironment('FLUTTER_CACHE_FOLDER');
static const defaultDataFolder =
String.fromEnvironment('FLUTTER_DATA_FOLDER');
}

class WidgetKeys {
Expand Down
14 changes: 1 addition & 13 deletions flutter/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,6 @@
"settingsTaskConfigLocalResource": "local",
"settingsTaskConfigError": "Path to config is invalid:",
"settingsTaskDataFolderTitle": "Data folder",
"settingsTaskDataFolderDesc": "Task config may contain non-downloadable files that must be managed manually.",
"settingsTaskDataFolderDefault": "Default",
"settingsTaskDataFolderApp": "Application folder",
"settingsTaskDataFolderCustom": "Custom folder",
"settingsTaskDataFolderSelected": "Selected data folder",
"settingsTaskDataFolderWarning": "Folder <path> does not exist or is not accessible",
"settingsTaskDataFolderPermissionRequired": "Access all file permission",
"settingsTaskDataFolderPermissionNotGranted": "Access all file permission is required to use custom folder but not granted. Tap here to grant the permission.",
"settingsTaskDataFolderPermissionGranted": "Access all file permission is required to use custom folder and already granted.",
"settingsTaskCacheFolderTitle": "Cache folder",
"settingsTaskCacheFolderDesc": "Cache folder contains downloadable data.\nThis folder can only be changed during build.",
"settingsTaskCacheFolderDefault": "Default",
"settingsClearCache": "Clear cache",
"settingsClearCacheConfirm": "All loaded resources will be deleted and downloaded again. Continue?",
"settingsUnableSpecifyConfiguration": "Could not specify until benchmarks is running or content is loading",
Expand All @@ -100,7 +88,7 @@
"dialogCancel": "Cancel",
"dialogTitleConfirm": "Confirm?",
"dialogContentOfflineWarning": "Offline mode is enabled but following internet resources are defined in the configuration. Do you want to continue?",
"dialogContentMissingFiles": "Selected datasets directory does not contain files for following benchmarks:",
"dialogContentMissingFiles": "The following files don't exist:",
"dialogContentChecksumError": "The following files failed checksum validation:",
"dialogContentNoSelectedBenchmarkError": "Please select at least one benchmark.",

Expand Down
28 changes: 8 additions & 20 deletions flutter/lib/resources/resource_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import 'package:flutter/foundation.dart';
import 'package:crypto/crypto.dart';
import 'package:path_provider/path_provider.dart';

import 'package:mlperfbench/app_constants.dart';
import 'package:mlperfbench/resources/cache_manager.dart';
import 'package:mlperfbench/resources/resource.dart';
import 'package:mlperfbench/resources/result_manager.dart';
import 'package:mlperfbench/resources/utils.dart';
import 'package:mlperfbench/store.dart';
import 'package:mlperfbench/ui/settings/data_folder_type.dart';

class ResourceManager {
static const _dataPrefix = 'local://';
Expand Down Expand Up @@ -60,18 +58,11 @@ class ResourceManager {
}

String getDataFolder() {
switch (parseDataFolderType(store.dataFolderType)) {
case DataFolderType.default_:
if (DartDefine.defaultDataFolder.isNotEmpty) {
return DartDefine.defaultDataFolder;
} else {
return applicationDirectory;
}
case DataFolderType.appFolder:
return applicationDirectory;
case DataFolderType.custom:
return store.customDataFolder;
}
return applicationDirectory;
}

String getDataPrefix() {
return _dataPrefix;
}

Future<bool> isResourceExist(String? uri) async {
Expand Down Expand Up @@ -152,11 +143,7 @@ class ResourceManager {
Future<void> initSystemPaths() async {
applicationDirectory = await getApplicationDirectory();
await Directory(applicationDirectory).create(recursive: true);
if (DartDefine.defaultCacheFolder.isNotEmpty) {
_loadedResourcesDir = DartDefine.defaultCacheFolder;
} else {
_loadedResourcesDir = '$applicationDirectory/$_loadedResourcesDirName';
}
_loadedResourcesDir = '$applicationDirectory/$_loadedResourcesDirName';
await Directory(_loadedResourcesDir).create();

cacheManager = CacheManager(_loadedResourcesDir);
Expand All @@ -167,7 +154,8 @@ class ResourceManager {
final missingResources = <String>[];
for (var r in resources) {
if (!await isResourceExist(r.path)) {
missingResources.add(r.path);
final resolvedPath = get(r.path);
missingResources.add(resolvedPath);
}
}
return missingResources;
Expand Down
16 changes: 0 additions & 16 deletions flutter/lib/store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,6 @@ class Store extends ChangeNotifier {
notifyListeners();
}

String get dataFolderType => _getString(StoreConstants.dataFolderType);

set dataFolderType(String value) {
_storeFromDisk.setString(StoreConstants.dataFolderType, value);
notifyListeners();
}

String get customDataFolder => _getString(StoreConstants.customDataFolder);

set customDataFolder(String value) {
_storeFromDisk.setString(StoreConstants.customDataFolder, value);
notifyListeners();
}

String get taskSelection => _getString(StoreConstants.taskSelection);

set taskSelection(String value) {
Expand Down Expand Up @@ -152,8 +138,6 @@ class StoreConstants {
static const previousExtendedResult = 'previous extended result';
static const previousAppVersion = 'previous app version';
static const keepLogs = 'keep_logs';
static const dataFolderType = 'data folder type';
static const customDataFolder = 'custom data folder';
static const taskSelection = 'disabled_tasks';
static const testMinDuration = 'test min duration';
static const testCooldownDuration = 'test cooldown duration';
Expand Down
17 changes: 0 additions & 17 deletions flutter/lib/ui/settings/data_folder_type.dart

This file was deleted.

Loading

0 comments on commit 09e4b41

Please sign in to comment.