1d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd/* 2d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Copyright (C) 2015 The Android Open Source Project 3d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * 4d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Licensed under the Apache License, Version 2.0 (the "License"); 5d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * you may not use this file except in compliance with the License. 6d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * You may obtain a copy of the License at 7d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * 8d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * http://www.apache.org/licenses/LICENSE-2.0 9d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * 10d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Unless required by applicable law or agreed to in writing, software 11d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * distributed under the License is distributed on an "AS IS" BASIS, 12d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * See the License for the specific language governing permissions and 14d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * limitations under the License. 15d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */ 16d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 17d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddpackage com.android.messaging.datamodel.action; 18d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 19d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.app.PendingIntent; 20d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.content.Context; 21d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.os.Bundle; 22d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 23d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd/** 24d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Class providing interface for the ActionService - can be stubbed for testing 25d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */ 26d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddpublic class ActionService { 27d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd protected static PendingIntent makeStartActionPendingIntent(final Context context, 28d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final Action action, final int requestCode, final boolean launchesAnActivity) { 29d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd return ActionServiceImpl.makeStartActionPendingIntent(context, action, requestCode, 30d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd launchesAnActivity); 31d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 32d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 33d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd /** 34d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Start an action by posting it over the the ActionService 35d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */ 36d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public void startAction(final Action action) { 37d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd ActionServiceImpl.startAction(action); 38d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 39d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 40d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd /** 41d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Schedule a delayed action by posting it over the the ActionService 42d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */ 43d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public void scheduleAction(final Action action, final int code, 44d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final long delayMs) { 45d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd ActionServiceImpl.scheduleAction(action, code, delayMs); 46d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 47d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 48d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd /** 49d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Process a response from the BackgroundWorker in the ActionService 50d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */ 51d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd protected void handleResponseFromBackgroundWorker( 52d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final Action action, final Bundle response) { 53d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd ActionServiceImpl.handleResponseFromBackgroundWorker(action, response); 54d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 55d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 56d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd /** 57d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Process a failure from the BackgroundWorker in the ActionService 58d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */ 59d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd protected void handleFailureFromBackgroundWorker(final Action action, 60d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final Exception exception) { 61d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd ActionServiceImpl.handleFailureFromBackgroundWorker(action, exception); 62d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 63d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd} 64