blob: e57b1673c261aa8e05891c2efd063a482543f0a3 [file] [log] [blame]
Jiachen Zhaof39362e2018-03-30 15:24:26 -07001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.update.ui;
18
19import android.app.Activity;
20import android.os.UpdateEngine;
21import android.os.UpdateEngineCallback;
22
23/** Main update activity. */
24public class SystemUpdateActivity extends Activity {
25
26 private UpdateEngine updateEngine;
27 private UpdateEngineCallbackImpl updateEngineCallbackImpl = new UpdateEngineCallbackImpl(this);
28
29 @Override
30 public void onResume() {
31 super.onResume();
32 updateEngine = new UpdateEngine();
33 updateEngine.bind(updateEngineCallbackImpl);
34 }
35
36 @Override
37 public void onPause() {
38 updateEngine.unbind();
39 super.onPause();
40 }
41
42 void onStatusUpdate(int i, float v) {
43 // Handle update engine status update
44 }
45
46 void onPayloadApplicationComplete(int i) {
47 // Handle apply payload completion
48 }
49
50 private static class UpdateEngineCallbackImpl extends UpdateEngineCallback {
51
52 private final SystemUpdateActivity activity;
53
54 public UpdateEngineCallbackImpl(SystemUpdateActivity activity) {
55 this.activity = activity;
56 }
57
58 @Override
59 public void onStatusUpdate(int i, float v) {
60 activity.onStatusUpdate(i, v);
61 }
62
63 @Override
64 public void onPayloadApplicationComplete(int i) {
65 activity.onPayloadApplicationComplete(i);
66 }
67 }
68}