forked from flutter-tizen/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tizen_package_manager] Add tizen_package_manager package (flutter-ti…
…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
Showing
28 changed files
with
1,494 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.DS_Store | ||
.dart_tool/ | ||
|
||
.packages | ||
.pub/ | ||
|
||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## 0.1.0 | ||
|
||
* Initial release. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# tizen_package_manager | ||
|
||
[](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> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
32 changes: 32 additions & 0 deletions
32
packages/tizen_package_manager/example/integration_test/tizen_package_manager_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
Oops, something went wrong.