toolkit/mozapps/update/updater/progressui_gonk.cpp

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:63891cb945dd
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=8 et :
3 */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
6 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7
8 #include <assert.h>
9 #include <stdio.h>
10
11 #include <string>
12
13 #include "android/log.h"
14
15 #include "progressui.h"
16
17 #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoUpdater" , ## args)
18
19 using namespace std;
20
21 int InitProgressUI(int *argc, char ***argv)
22 {
23 return 0;
24 }
25
26 int ShowProgressUI()
27 {
28 LOG("Starting to apply update ...\n");
29 return 0;
30 }
31
32 void QuitProgressUI()
33 {
34 LOG("Finished applying update\n");
35 }
36
37 void UpdateProgressUI(float progress)
38 {
39 assert(0.0f <= progress && progress <= 100.0f);
40
41 static const size_t kProgressBarLength = 50;
42 static size_t sLastNumBars;
43 size_t numBars = size_t(float(kProgressBarLength) * progress / 100.0f);
44 if (numBars == sLastNumBars) {
45 return;
46 }
47 sLastNumBars = numBars;
48
49 size_t numSpaces = kProgressBarLength - numBars;
50 string bars(numBars, '=');
51 string spaces(numSpaces, ' ');
52 LOG("Progress [ %s%s ]\n", bars.c_str(), spaces.c_str());
53 }

mercurial