Skip to content

Commit 1becadd

Browse files
authored
[tizen_app_manager] Add tizen_app_manager package (flutter-tizen#325)
* initial commit of application_manager plugin * modify related yml file and fix lint errors * rename pacakge: from tizen_application_manager to tizen_app_manager * add integration_test and fix dart analysis issues * Fix code review issues and add documents * integrate test pages code to main dart * split launch/terminate event stream * fix style format issues * modify README and fix typo * use get_error_message() and fix some review issues * fix conflict file * fix some tizen native code issue * Fix API documents and code review issues * fix dart analysis issue * fix some minor issues
1 parent 3196114 commit 1becadd

29 files changed

+1824
-0
lines changed

.github/labeler.yml

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
- packages/share_plus/**/*
3838
'p: tizen_app_control':
3939
- packages/tizen_app_control/**/*
40+
'p: tizen_app_manager':
41+
- packages/tizen_app_manager/**/*
4042
'p: tizen_audio_manager':
4143
- packages/tizen_audio_manager/**/*
4244
'p: url_launcher':

.github/recipe.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ plugins:
1212
share_plus: ["wearable-5.5"]
1313
shared_preferences: ["wearable-5.5", "tv-6.0"]
1414
sqflite: ["wearable-5.5", "tv-6.0"]
15+
tizen_app_manager: ["wearable-5.5", "tv-6.0"]
1516
tizen_audio_manager: ["wearable-5.5", "tv-6.0"]
1617
wakelock: ["wearable-5.5"]
1718

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The _"non-endorsed"_ status means that the plugin is not endorsed by the origina
3434
| [**shared_preferences_tizen**](packages/shared_preferences) | [shared_preferences](https://github.com/flutter/plugins/tree/master/packages/shared_preferences) (1st-party) | [![pub package](https://img.shields.io/pub/v/shared_preferences_tizen.svg)](https://pub.dev/packages/shared_preferences_tizen) | No |
3535
| [**sqflite_tizen**](packages/sqflite) | [sqflite](https://github.com/tekartik/sqflite) (3rd-party) | [![pub package](https://img.shields.io/pub/v/sqflite_tizen.svg)](https://pub.dev/packages/sqflite_tizen) | No |
3636
| [**tizen_app_control**](packages/tizen_app_control) | (Tizen-only) | [![pub package](https://img.shields.io/pub/v/tizen_app_control.svg)](https://pub.dev/packages/tizen_app_control) | N/A |
37+
| [**tizen_app_manager**](packages/tizen_app_manager) | (Tizen-only) | [![pub package](https://img.shields.io/pub/v/tizen_app_manager.svg)](https://pub.dev/packages/tizen_app_manager) | N/A |
3738
| [**tizen_audio_manager**](packages/tizen_audio_manager) | (Tizen-only) | [![pub package](https://img.shields.io/pub/v/tizen_audio_manager.svg)](https://pub.dev/packages/tizen_audio_manager) | N/A |
3839
| [**tizen_notification**](packages/tizen_notification) | (Tizen-only) | [![pub package](https://img.shields.io/pub/v/tizen_notification.svg)](https://pub.dev/packages/tizen_notification) | N/A |
3940
| [**url_launcher_tizen**](packages/url_launcher) | [url_launcher](https://github.com/flutter/plugins/tree/master/packages/url_launcher) (1st-party) | [![pub package](https://img.shields.io/pub/v/url_launcher_tizen.svg)](https://pub.dev/packages/url_launcher_tizen) | No |
@@ -66,6 +67,7 @@ The _"non-endorsed"_ status means that the plugin is not endorsed by the origina
6667
| [**shared_preferences_tizen**](packages/shared_preferences) | ✔️ | ✔️ | ✔️ | ✔️ |
6768
| [**sqflite_tizen**](packages/sqflite) | ✔️ | ✔️ | ✔️ | ✔️ |
6869
| [**tizen_app_control**](packages/tizen_app_control) | ✔️ | ✔️ | ✔️ | ✔️ |
70+
| [**tizen_app_manager**](packages/tizen_app_manager) | ✔️ | ✔️ | ✔️ | ✔️ |
6971
| [**tizen_audio_manager**](packages/tizen_audio_manager) | ✔️ | ✔️ | ✔️ | ✔️ |
7072
| [**tizen_notification**](packages/tizen_notification) || ✔️ | ✔️ | ✔️ | API not supported |
7173
| [**url_launcher_tizen**](packages/url_launcher) | ✔️ || ✔️ || No browser app |

packages/tizen_app_manager/.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
.dart_tool/
3+
4+
.packages
5+
.pub/
6+
7+
build/
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## 0.1.0
2+
3+
* Initial release.
4+

packages/tizen_app_manager/LICENSE

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without modification,
4+
are permitted provided that the following conditions are met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the names of the copyright holders nor the names of the
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

packages/tizen_app_manager/README.md

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# tizen_app_manager
2+
3+
[![pub package](https://img.shields.io/pub/v/tizen_app_manager.svg)](https://pub.dev/packages/tizen_app_manager)
4+
5+
Tizen application manager API. Used for getting installed app info and getting running context info of specific app.
6+
7+
## Usage
8+
9+
To use this package, add `tizen_app_manager` as a dependency in your `pubspec.yaml` file.
10+
11+
```yaml
12+
dependencies:
13+
tizen_app_manager: ^0.1.0
14+
```
15+
16+
### Retrieving current app info
17+
18+
To retrieve information of the current app, get app ID with `currentAppId` and then get `AppInfo` with `getAppInfo` method.
19+
20+
```dart
21+
var appId = await AppManager.currentAppId;
22+
var appInfo = await AppManager.getAppInfo(appId);
23+
```
24+
25+
### Retrieving all apps info
26+
27+
To retrieve information of all apps installed on a Tizen device, use `getInstalledApps` method.
28+
29+
```dart
30+
var apps = await AppManager.getInstalledApps();
31+
for (var app in apps) {
32+
// Handle each app's info.
33+
}
34+
```
35+
36+
### Getting app running context
37+
38+
To get specific app running context, create `AppRunningContext` instance.
39+
40+
```dart
41+
var appId = await AppManager.currentAppId;
42+
var appContext = AppRunningContext(appId: appId);
43+
```
44+
45+
### Monitoring app events
46+
47+
You can listen for app state change by subscribing to the stream.
48+
49+
```dart
50+
final List<StreamSubscription<AppRunningContext>> _subscriptions =
51+
<StreamSubscription<AppRunningContext>>[];
52+
53+
@override
54+
void initState() {
55+
super.initState();
56+
57+
_subscriptions.add(AppManager.onAppLaunched
58+
.listen((AppRunningContext event) {
59+
// Handle the launched event.
60+
...
61+
event.dispose();
62+
}));
63+
_subscriptions.add(AppManager.onAppTerminated
64+
.listen((AppRunningContext event) {
65+
// Handle the terminated event.
66+
...
67+
event.dispose();
68+
}));
69+
}
70+
71+
@override
72+
void dispose() {
73+
super.dispose();
74+
75+
_subscriptions.forEach((StreamSubscription subscription) => subscription.cancel());
76+
_subscriptions.clear();
77+
}
78+
```
79+
80+
## Required privileges
81+
82+
The following privilege is required to invoke `AppRunningContext.resume()`. Add required privileges in `tizen-manifest.xml` of your application.
83+
84+
```xml
85+
<privileges>
86+
<privilege>http://tizen.org/privilege/appmanager.launch</privilege>
87+
</privileges>
88+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
**/ios/Flutter/.last_build_id
26+
.dart_tool/
27+
.flutter-plugins
28+
.flutter-plugins-dependencies
29+
.packages
30+
.pub-cache/
31+
.pub/
32+
/build/
33+
34+
# Web related
35+
lib/generated_plugin_registrant.dart
36+
37+
# Symbolication related
38+
app.*.symbols
39+
40+
# Obfuscation related
41+
app.*.map.json
42+
43+
# Android Studio will place build artifacts here
44+
/android/app/debug
45+
/android/app/profile
46+
/android/app/release
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# tizen_app_manager_example
2+
3+
Demonstrates how to use the tizen_app_manager plugin.
4+
5+
## Getting Started
6+
7+
To run this app on your Tizen device, use [flutter-tizen](https://github.com/flutter-tizen/flutter-tizen).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter_test/flutter_test.dart';
6+
import 'package:integration_test/integration_test.dart';
7+
import 'package:tizen_app_manager/app_manager.dart';
8+
9+
import 'package:tizen_app_manager_example/main.dart';
10+
11+
void main() {
12+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
13+
14+
testWidgets('Can get current app info', (WidgetTester tester) async {
15+
// These test are based on the example app.
16+
final String appId = await AppManager.currentAppId;
17+
expect(appId, 'com.example.tizen_app_manager_example');
18+
final AppInfo appInfo = await AppManager.getAppInfo(appId);
19+
expect(appInfo.packageId, 'com.example.tizen_app_manager_example');
20+
expect(appInfo.label, 'tizen_app_manager_example');
21+
expect(appInfo.appType, 'dotnet');
22+
});
23+
24+
testWidgets('Can get current app running context',
25+
(WidgetTester tester) async {
26+
await tester.pumpWidget(const MyApp());
27+
28+
final String appId = await AppManager.currentAppId;
29+
final AppRunningContext context = AppRunningContext(appId: appId);
30+
expect(context.appState, AppState.foreground);
31+
expect(context.processId, isPositive);
32+
expect(context.isTerminated, isFalse);
33+
});
34+
}

0 commit comments

Comments
 (0)