Skip to content

Commit

Permalink
[tizen_package_manager] Add tizen_package_manager package (flutter-ti…
Browse files Browse the repository at this point in the history
…zen#330)

* initial commit of package manager

* fix README file

* fix code review issues

* remove install/uninstall test and event listen test

* fix code review issues.

* fix dart analyze issue

* remove space in README

* fix code review issues on native implementation

* additional fix on native implementation

* Remove plugin definition file and callback function move into class static member
  • Loading branch information
jkpu authored Feb 28, 2022
1 parent 1becadd commit a9d357f
Show file tree
Hide file tree
Showing 28 changed files with 1,494 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
- packages/tizen_app_manager/**/*
'p: tizen_audio_manager':
- packages/tizen_audio_manager/**/*
'p: tizen_package_manager':
- packages/tizen_package_manager/**/*
'p: url_launcher':
- packages/url_launcher/**/*
'p: video_player':
Expand Down
1 change: 1 addition & 0 deletions .github/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins:
sqflite: ["wearable-5.5", "tv-6.0"]
tizen_app_manager: ["wearable-5.5", "tv-6.0"]
tizen_audio_manager: ["wearable-5.5", "tv-6.0"]
tizen_package_manager: ["wearable-5.5", "tv-6.0"]
wakelock: ["wearable-5.5"]

# Not supported by emulators.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The _"non-endorsed"_ status means that the plugin is not endorsed by the origina
| [**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 |
| [**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 |
| [**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 |
| [**tizen_package_manager**](packages/tizen_package_manager) | (Tizen-only) | [![pub package](https://img.shields.io/pub/v/tizen_package_manager.svg)](https://pub.dev/packages/tizen_package_manager) | N/A |
| [**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 |
| [**video_player_tizen**](packages/video_player) | [video_player](https://github.com/flutter/plugins/tree/master/packages/video_player) (1st-party) | [![pub package](https://img.shields.io/pub/v/video_player_tizen.svg)](https://pub.dev/packages/video_player_tizen) | No |
| [**wakelock_tizen**](packages/wakelock) | [wakelock](https://github.com/creativecreatorormaybenot/wakelock) (3rd-party) | [![pub package](https://img.shields.io/pub/v/wakelock_tizen.svg)](https://pub.dev/packages/wakelock_tizen) | No |
Expand Down Expand Up @@ -70,6 +71,7 @@ The _"non-endorsed"_ status means that the plugin is not endorsed by the origina
| [**tizen_app_manager**](packages/tizen_app_manager) | ✔️ | ✔️ | ✔️ | ✔️ |
| [**tizen_audio_manager**](packages/tizen_audio_manager) | ✔️ | ✔️ | ✔️ | ✔️ |
| [**tizen_notification**](packages/tizen_notification) || ✔️ | ✔️ | ✔️ | API not supported |
| [**tizen_package_manager**](packages/tizen_package_manager) | ✔️ | ✔️ | ✔️ | ✔️ |
| [**url_launcher_tizen**](packages/url_launcher) | ✔️ || ✔️ || No browser app |
| [**video_player_tizen**](packages/video_player) | ✔️ | ✔️ | ⚠️ || Functional limitations (see README)<br>TV emulator issue |
| [**wakelock_tizen**](packages/wakelock) | ✔️ | ✔️ ||| Cannot override system display setting |
Expand Down
7 changes: 7 additions & 0 deletions packages/tizen_package_manager/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
.dart_tool/

.packages
.pub/

build/
4 changes: 4 additions & 0 deletions packages/tizen_package_manager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 0.1.0

* Initial release.

25 changes: 25 additions & 0 deletions packages/tizen_package_manager/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the names of the copyright holders nor the names of the
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58 changes: 58 additions & 0 deletions packages/tizen_package_manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# tizen_package_manager

[![pub package](https://img.shields.io/pub/v/tizen_package_manager.svg)](https://pub.dev/packages/tizen_package_manager)

Tizen package manager API. Used for getting installed package info.

## Usage

To use this package, add `tizen_package_manager` as a dependency in your `pubspec.yaml` file.

```yaml
dependencies:
tizen_package_manager: ^0.1.0
```
### Retrieving specific package info
To retrieve information of a specific package, use the `getPackageInfo` method which returns an instance of `PackageInfo`.

```dart
var packageId = 'org.tizen.settings';
var packageInfo = await PackageManager.getPackageInfo(packageId);
```

### Retrieving all packages' info

To retrieve information of all packages installed on a Tizen device, use `getPackagesInfo` method.

```dart
var packageList = await PackageManager.getPackagesInfo();
for (var package in packageList) {
// Handle each package's info.
}
```

### Monitoring package events

You can listen for package events using `onInstallProgressChanged`, `onUninstallProgressChanged`, and `onUpdateProgressChanged`.

```dart
_subscription = PackageManager.onInstallProgressChanged.listen((event) {
// A package is being installed.
});
...
_subscription.cancel();
```

## Required privileges

Privileges are required to use the package manager functionality. Add required privileges in tizen-manifest.xml of your application.

```xml
<privileges>
<privilege>http://tizen.org/privilege/packagemanager.info</privilege>
<!-- The below is optional for install/uninstall and platform privilge -->
<privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
</privileges>
```
46 changes: 46 additions & 0 deletions packages/tizen_package_manager/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
7 changes: 7 additions & 0 deletions packages/tizen_package_manager/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# tizen_package_manager_example

Demonstrates how to use the tizen_package_manager plugin.

## Getting Started

To run this app on your Tizen device, use [flutter-tizen](https://github.com/flutter-tizen/flutter-tizen).
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:tizen_package_manager/package_manager.dart';

import 'package:tizen_package_manager_example/main.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

testWidgets('Can get current package info', (WidgetTester tester) async {
// These test are based on the example app.
final PackageInfo info =
await PackageManager.getPackageInfo(currentPackageId);
expect(info.packageId, 'com.example.tizen_package_manager_example');
expect(info.label, 'tizen_package_manager_example');
expect(info.packageType, PackageType.tpk);
expect(info.version, '1.0.0');
expect(info.isPreloaded, false);
expect(info.isSystem, false);
expect(info.isRemovable, true);
});

testWidgets('Can get all installed packages info',
(WidgetTester tester) async {
final List<PackageInfo> infos = await PackageManager.getPackagesInfo();
expect(infos.isNotEmpty, true);
});
}
Loading

0 comments on commit a9d357f

Please sign in to comment.