blob: 3aeed4d2803db2c24e5cde5f38de300607717bfd [file] [log] [blame]
Santos Cordon00d7a432013-09-17 14:07:14 -07001/*
2 * Copyright (C) 2013 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.phone;
18
Santos Cordoncd76f8b2013-09-23 17:59:50 -070019import android.app.PendingIntent;
Santos Cordon00d7a432013-09-17 14:07:14 -070020import android.app.Service;
21import android.content.Intent;
22import android.os.IBinder;
23import android.util.Log;
24
25/**
26 * Service for performing HfaActivation without any UI.
27 */
28public class HfaService extends Service {
29 private static final String TAG = HfaService.class.getSimpleName();
30
31 @Override
32 public void onCreate() {
Santos Cordoncd76f8b2013-09-23 17:59:50 -070033 Log.i(TAG, "service started");
34 }
35
36 @Override
37 public int onStartCommand(Intent intent, int flags, int startId) {
38 final PendingIntent otaResponseIntent = intent.getParcelableExtra(
39 OtaUtils.EXTRA_OTASP_RESULT_CODE_PENDING_INTENT);
40
Santos Cordon00d7a432013-09-17 14:07:14 -070041 new HfaLogic(this, new HfaLogic.HfaLogicCallback() {
42 @Override
43 public void onSuccess() {
44 Log.i(TAG, "onSuccess");
45 onComplete();
46 }
47
48 @Override
49 public void onError(String msg) {
50 Log.i(TAG, "onError: " + msg);
51 // We do not respond from this service. On success or failure
52 // we do the same thing...finish.
53 onComplete();
54 }
Santos Cordoncd76f8b2013-09-23 17:59:50 -070055 }, otaResponseIntent).start();
Santos Cordon00d7a432013-09-17 14:07:14 -070056
Santos Cordoncd76f8b2013-09-23 17:59:50 -070057 return START_STICKY;
Santos Cordon00d7a432013-09-17 14:07:14 -070058 }
59
60 @Override
61 public IBinder onBind(Intent intent) {
62 return null;
63 }
64
65 private void onComplete() {
66 stopSelf();
67 }
68}