1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/update/updater/progressui_gonk.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * vim: sw=2 ts=8 et : 1.6 + */ 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.9 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#include <assert.h> 1.12 +#include <stdio.h> 1.13 + 1.14 +#include <string> 1.15 + 1.16 +#include "android/log.h" 1.17 + 1.18 +#include "progressui.h" 1.19 + 1.20 +#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoUpdater" , ## args) 1.21 + 1.22 +using namespace std; 1.23 + 1.24 +int InitProgressUI(int *argc, char ***argv) 1.25 +{ 1.26 + return 0; 1.27 +} 1.28 + 1.29 +int ShowProgressUI() 1.30 +{ 1.31 + LOG("Starting to apply update ...\n"); 1.32 + return 0; 1.33 +} 1.34 + 1.35 +void QuitProgressUI() 1.36 +{ 1.37 + LOG("Finished applying update\n"); 1.38 +} 1.39 + 1.40 +void UpdateProgressUI(float progress) 1.41 +{ 1.42 + assert(0.0f <= progress && progress <= 100.0f); 1.43 + 1.44 + static const size_t kProgressBarLength = 50; 1.45 + static size_t sLastNumBars; 1.46 + size_t numBars = size_t(float(kProgressBarLength) * progress / 100.0f); 1.47 + if (numBars == sLastNumBars) { 1.48 + return; 1.49 + } 1.50 + sLastNumBars = numBars; 1.51 + 1.52 + size_t numSpaces = kProgressBarLength - numBars; 1.53 + string bars(numBars, '='); 1.54 + string spaces(numSpaces, ' '); 1.55 + LOG("Progress [ %s%s ]\n", bars.c_str(), spaces.c_str()); 1.56 +}