blob: d5c92b81a1aa8bb3c391f30445fd546b264950b9 [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
Wink Savillefea89c32013-09-25 14:43:59 -070031 private HfaLogic mHfaLogic;
32
Santos Cordon00d7a432013-09-17 14:07:14 -070033 @Override
34 public void onCreate() {
Santos Cordoncd76f8b2013-09-23 17:59:50 -070035 Log.i(TAG, "service started");
36 }
37
38 @Override
39 public int onStartCommand(Intent intent, int flags, int startId) {
40 final PendingIntent otaResponseIntent = intent.getParcelableExtra(
41 OtaUtils.EXTRA_OTASP_RESULT_CODE_PENDING_INTENT);
42
Wink Savillefea89c32013-09-25 14:43:59 -070043 mHfaLogic = new HfaLogic(this, new HfaLogic.HfaLogicCallback() {
Santos Cordon00d7a432013-09-17 14:07:14 -070044 @Override
45 public void onSuccess() {
46 Log.i(TAG, "onSuccess");
47 onComplete();
48 }
49
50 @Override
51 public void onError(String msg) {
52 Log.i(TAG, "onError: " + msg);
53 // We do not respond from this service. On success or failure
54 // we do the same thing...finish.
55 onComplete();
56 }
Wink Savillefea89c32013-09-25 14:43:59 -070057 }, otaResponseIntent);
58 mHfaLogic.start();
Santos Cordon00d7a432013-09-17 14:07:14 -070059
Santos Cordoncd76f8b2013-09-23 17:59:50 -070060 return START_STICKY;
Santos Cordon00d7a432013-09-17 14:07:14 -070061 }
62
63 @Override
64 public IBinder onBind(Intent intent) {
65 return null;
66 }
67
68 private void onComplete() {
69 stopSelf();
70 }
71}