@@ -0,0 +1,230 @@
2+ * Copyright (C) 2018 The UBports project
4+ * Written by: Marius Gripsgard <marius@ubports.com>
6+ * This program is free software; you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation; version 3.
10+ * This program is distributed in the hope that it will be useful,
11+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ * GNU General Public License for more details.
15+ * You should have received a copy of the GNU General Public License
16+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20+import QtQuick.Layouts 1.1
21+import Ubuntu.Components 1.3
22+import Ubuntu.SystemImage 0.1
24+import ".." as LocalComponents
26+LocalComponents.Page {
28+ objectName: "firmwareUpdatePage"
30+ title: i18n.tr("firmware Update")
31+ forwardButtonSourceComponent: forwardButton
33+ skip: !SystemImage.SupportsFirmwareUpdate() || !online
35+ property bool online: NetworkingStatus.online
36+ property bool hasUpdate: false
37+ property bool isUpdating: false
38+ property bool isChecking: true
39+ property var partitions: ""
42+ if (!SystemImage.SupportsFirmwareUpdate())
44+ systemUpdatePage.isChecking = true
45+ SystemImage.checkForFirmwareUpdate()
49+ if (!SystemImage.SupportsFirmwareUpdate())
51+ systemUpdatePage.isUpdating = true
52+ SystemImage.updateFirmware()
57+ onCheckForFirmwareUpdateDone: {
58+ var updateobj = JSON.parse(updateObj);
59+ if (Array.isArray(updateobj) && updateobj.length > 0) {
60+ for (var u in updateobj) {
62+ if (systemUpdatePage.partitions === "")
63+ systemUpdatePage.partitions += updateobj[u].file
65+ systemUpdatePage.partitions += ", " + updateobj[u].file
67+ systemUpdatePage.hasUpdate = true;
69+ console.log(updateobj);
70+ systemUpdatePage.isChecking = false;
72+ onUpdateFirmwareDone: {
73+ var updateobj = JSON.parse(updateObj);
74+ if (Array.isArray(updateobj) && updateobj.length === 0) {
75+ // This means success!
76+ systemUpdatePage.hasUpdate = false;
77+ systemUpdatePage.partitions = "";
78+ System.skipUntilFinishedPage();
79+ SystemImage.reboot();
82+ console.log(updateobj);
83+ systemUpdatePage.isUpdating = false;
91+ leftMargin: systemUpdatePage.leftMargin
92+ rightMargin: systemUpdatePage.rightMargin
93+ topMargin: systemUpdatePage.customMargin
96+ opacity: spinner.visible ? 0.5 : 1
97+ Behavior on opacity {
98+ UbuntuNumberAnimation {}
102+ anchors.horizontalCenter: parent.horizontalCenter
103+ font.weight: Font.Light
105+ textSize: Label.Medium
106+ text: systemUpdatePage.hasUpdate ? i18n.tr("There is a firmware update available!")
107+ : i18n.tr("Firmware is up to date!")
114+ rowSpacing: units.gu(1)
115+ columnSpacing: units.gu(2)
116+ anchors.horizontalCenter: parent.horizontalCenter
121+ Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
124+ name: "security-alert"
128+ font.weight: Font.Normal
129+ textSize: Label.Medium
130+ text: i18n.tr("Firmware Update")
134+ font.weight: Font.Light
136+ text: systemUpdatePage.partitions
140+ font.weight: Font.Light
142+ text: i18n.tr("The device will automatically restart after installing is done.")
147+ anchors.left: parent.left
148+ anchors.leftMargin: 3
149+ anchors.horizontalCenter: parent.horizontalCenter
150+ color: theme.palette.normal.foreground
152+ width: buttonLabel.paintedWidth + units.gu(3)
153+ height: buttonLabel.paintedHeight + units.gu(1.8)
158+ text: i18n.tr("Install and restart now")
159+ font.weight: Font.Light
160+ anchors.horizontalCenter: parent.horizontalCenter
161+ anchors.centerIn: parent
166+ objectName: "installButton"
167+ anchors.fill: parent
168+ anchors.horizontalCenter: parent.horizontalCenter
170+ systemUpdatePage.flash()
174+ transformOrigin: Item.Top
175+ scale: button.pressed ? 0.98 : 1.0
178+ duration: UbuntuAnimation.SnapDuration
179+ easing.type: Easing.Linear
187+ anchors.centerIn: systemUpdatePage
188+ visible: systemUpdatePage.isChecking || systemUpdatePage.isUpdating
191+ anchors.horizontalCenter: parent.horizontalCenter
192+ running: parent.visible
197+ width: systemUpdatePage.width - units.gu(3)
199+ text: i18n.tr("Downloading and Flashing firmware updates, this could take a few minutes...")
200+ visible: systemUpdatePage.isUpdating
206+ text: i18n.tr("Checking for firmware update")
207+ visible: systemUpdatePage.isChecking
210+ Component.onCompleted: systemUpdatePage.check()
215+ target: NetworkingStatus
218+ systemUpdatePage.check()
225+ LocalComponents.StackButton {
226+ text: systemUpdatePage.hasUpdate ? i18n.tr("Next") : i18n.tr("Skip")
227+ onClicked: pageStack.next()