Santos Cordon | 00d7a43 | 2013-09-17 14:07:14 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.phone; |
| 18 | |
Santos Cordon | cd76f8b | 2013-09-23 17:59:50 -0700 | [diff] [blame] | 19 | import android.app.PendingIntent; |
Santos Cordon | 00d7a43 | 2013-09-17 14:07:14 -0700 | [diff] [blame] | 20 | import android.app.Service; |
| 21 | import android.content.Intent; |
| 22 | import android.os.IBinder; |
| 23 | import android.util.Log; |
| 24 | |
| 25 | /** |
| 26 | * Service for performing HfaActivation without any UI. |
| 27 | */ |
| 28 | public class HfaService extends Service { |
| 29 | private static final String TAG = HfaService.class.getSimpleName(); |
| 30 | |
Wink Saville | fea89c3 | 2013-09-25 14:43:59 -0700 | [diff] [blame^] | 31 | private HfaLogic mHfaLogic; |
| 32 | |
Santos Cordon | 00d7a43 | 2013-09-17 14:07:14 -0700 | [diff] [blame] | 33 | @Override |
| 34 | public void onCreate() { |
Santos Cordon | cd76f8b | 2013-09-23 17:59:50 -0700 | [diff] [blame] | 35 | 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 Saville | fea89c3 | 2013-09-25 14:43:59 -0700 | [diff] [blame^] | 43 | mHfaLogic = new HfaLogic(this, new HfaLogic.HfaLogicCallback() { |
Santos Cordon | 00d7a43 | 2013-09-17 14:07:14 -0700 | [diff] [blame] | 44 | @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 Saville | fea89c3 | 2013-09-25 14:43:59 -0700 | [diff] [blame^] | 57 | }, otaResponseIntent); |
| 58 | mHfaLogic.start(); |
Santos Cordon | 00d7a43 | 2013-09-17 14:07:14 -0700 | [diff] [blame] | 59 | |
Santos Cordon | cd76f8b | 2013-09-23 17:59:50 -0700 | [diff] [blame] | 60 | return START_STICKY; |
Santos Cordon | 00d7a43 | 2013-09-17 14:07:14 -0700 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public IBinder onBind(Intent intent) { |
| 65 | return null; |
| 66 | } |
| 67 | |
| 68 | private void onComplete() { |
| 69 | stopSelf(); |
| 70 | } |
| 71 | } |