Skip to content

Commit 9cb6f0f

Browse files
authored
Merge pull request #7 from okmsbun/develop
Develop
2 parents 7a5b018 + cb40f80 commit 9cb6f0f

8 files changed

Lines changed: 700 additions & 37 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: only-develop-to-main
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
7+
jobs:
8+
enforce:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Allow only develop -> main PRs
12+
run: |
13+
echo "head_ref: ${{ github.head_ref }}"
14+
echo "base_ref: ${{ github.base_ref }}"
15+
if [ "${{ github.base_ref }}" = "main" ] && [ "${{ github.head_ref }}" != "develop" ]; then
16+
echo "Only PRs from 'develop' to 'main' are allowed."
17+
exit 1
18+
fi

.github/workflows/quality.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Quality
2+
3+
on:
4+
pull_request:
5+
branches: ["develop"]
6+
7+
jobs:
8+
quality:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Setup Dart
15+
uses: dart-lang/setup-dart@v1
16+
with:
17+
sdk: stable
18+
19+
- name: Cache pub
20+
uses: actions/cache@v4
21+
with:
22+
path: |
23+
~/.pub-cache
24+
.dart_tool
25+
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-pub-
28+
29+
- name: Install dependencies
30+
run: dart pub get
31+
32+
- name: Check formatting
33+
run: dart format --set-exit-if-changed .
34+
35+
- name: Static analysis
36+
run: dart analyze
37+
38+
- name: pub.dev dry-run
39+
run: dart pub publish --dry-run

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
branches: ["develop"]
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Setup Dart
15+
uses: dart-lang/setup-dart@v1
16+
with:
17+
sdk: stable
18+
19+
- name: Cache pub
20+
uses: actions/cache@v4
21+
with:
22+
path: |
23+
~/.pub-cache
24+
.dart_tool
25+
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-pub-
28+
29+
- name: Install dependencies
30+
run: dart pub get
31+
32+
- name: Run tests
33+
run: dart test

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.6.0
2+
- **BREAKING**: Removed `requestedPermissions` field from `AppInfo` class to improve performance and reduce memory usage
3+
- Added new API: `getRequestedPermissions(String packageName)` to fetch app permissions on demand
4+
- Added comprehensive unit tests for `AppInfo`, `AppChangeType`, and `AppChangeEvent` classes
5+
16
## 0.5.1
27
- Expanded `AppInfo` with additional Android-facing fields: `category`, `targetSdkVersion`, `minSdkVersion`, `enabled`, `processName`, `installLocation`, `requestedPermissions`.
38

lib/flutter_device_apps_platform_interface.dart

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class AppInfo {
2626
this.enabled,
2727
this.processName,
2828
this.installLocation,
29-
this.requestedPermissions,
3029
});
3130

3231
/// Creates an [AppInfo] from a map of key-value pairs.
@@ -52,9 +51,6 @@ class AppInfo {
5251
final bool? enabled = m['enabled'] != null ? bool.tryParse(m['enabled']!.toString()) : null;
5352
final int? installLocation =
5453
m['installLocation'] != null ? int.tryParse(m['installLocation']!.toString()) : null;
55-
final List<String>? requestedPermissions = m['requestedPermissions'] is List<dynamic>
56-
? (m['requestedPermissions']! as List<dynamic>).map((e) => e.toString()).toList()
57-
: null;
5854

5955
return AppInfo(
6056
packageName: m['packageName']?.toString(),
@@ -72,7 +68,6 @@ class AppInfo {
7268
enabled: enabled,
7369
processName: m['processName']?.toString(),
7470
installLocation: installLocation,
75-
requestedPermissions: requestedPermissions,
7671
);
7772
}
7873

@@ -100,47 +95,23 @@ class AppInfo {
10095
/// The app icon as raw bytes, if requested and available.
10196
final Uint8List? iconBytes;
10297

103-
/// App category (Android [ApplicationInfo.category], API 26+). Raw int from platform. Null when not set or API < 26.
98+
/// App category (Android ApplicationInfo.category, API 26+). Raw int from platform. Null when not set or API < 26.
10499
final int? category;
105100

106-
/// Target SDK version (Android [ApplicationInfo.targetSdkVersion]).
101+
/// Target SDK version (Android ApplicationInfo.targetSdkVersion).
107102
final int? targetSdkVersion;
108103

109-
/// Min SDK version (Android [ApplicationInfo.minSdkVersion]).
104+
/// Min SDK version (Android ApplicationInfo.minSdkVersion).
110105
final int? minSdkVersion;
111106

112-
/// Whether the app is enabled (Android [ApplicationInfo.enabled]).
107+
/// Whether the app is enabled (Android ApplicationInfo.enabled).
113108
final bool? enabled;
114109

115-
/// Process name (Android [ApplicationInfo.processName]).
110+
/// Process name (Android ApplicationInfo.processName).
116111
final String? processName;
117112

118-
/// Install location (Android [PackageInfo.installLocation]).
113+
/// Install location (Android PackageInfo.installLocation).
119114
final int? installLocation;
120-
121-
/// Requested permissions (Android [PackageInfo.requestedPermissions]).
122-
final List<String>? requestedPermissions;
123-
124-
/// Converts this [AppInfo] to a map representation.
125-
///
126-
/// Useful for serialization to platform channels or other data formats.
127-
Map<String, Object?> toMap() => {
128-
'packageName': packageName,
129-
'appName': appName,
130-
'versionName': versionName,
131-
'versionCode': versionCode,
132-
'firstInstallTime': firstInstallTime?.millisecondsSinceEpoch,
133-
'lastUpdateTime': lastUpdateTime?.millisecondsSinceEpoch,
134-
'isSystem': isSystem,
135-
'iconBytes': iconBytes,
136-
'category': category,
137-
'targetSdkVersion': targetSdkVersion,
138-
'minSdkVersion': minSdkVersion,
139-
'enabled': enabled,
140-
'processName': processName,
141-
'installLocation': installLocation,
142-
'requestedPermissions': requestedPermissions,
143-
};
144115
}
145116

146117
/// Base class every platform implementation must extend.
@@ -175,6 +146,12 @@ abstract class FlutterDeviceAppsPlatform extends PlatformInterface {
175146
/// Gets details for a single app.
176147
Future<AppInfo?> getApp(String packageName, {bool includeIcon = false});
177148

149+
/// Gets the requested permissions for a specific app.
150+
///
151+
/// Implementations should return the Android PackageInfo.requestedPermissions
152+
/// list for the given [packageName], or null if not available.
153+
Future<List<String>?> getRequestedPermissions(String packageName);
154+
178155
/// Best-effort: launches an app by package name. Returns false if not launchable.
179156
Future<bool> openApp(String packageName);
180157

@@ -222,6 +199,10 @@ class _UnimplementedPlatform extends FlutterDeviceAppsPlatform {
222199
Future<AppInfo?> getApp(String packageName, {bool includeIcon = false}) =>
223200
Future.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));
224201

202+
@override
203+
Future<List<String>?> getRequestedPermissions(String packageName) =>
204+
Future.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));
205+
225206
@override
226207
Future<bool> openApp(String packageName) =>
227208
Future.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));

pubspec.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_device_apps_platform_interface
22
description: Platform-agnostic API contract for flutter_device_apps (federated).
3-
version: 0.5.1
3+
version: 0.6.0
44
repository: https://github.com/okmsbun/flutter_device_apps_platform_interface
55
issue_tracker: https://github.com/okmsbun/flutter_device_apps_platform_interface/issues
66
topics:
@@ -17,4 +17,5 @@ dependencies:
1717
plugin_platform_interface: ^2.1.8
1818

1919
dev_dependencies:
20-
lints: ^6.0.0
20+
lints: ^6.1.0
21+
test: ^1.29.0

0 commit comments

Comments
 (0)