1 /* 2 * Copyright (C) 2015 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.messaging.datamodel.action; 18 19 import android.app.PendingIntent; 20 import android.content.Context; 21 import android.os.Bundle; 22 23 /** 24 * Class providing interface for the ActionService - can be stubbed for testing 25 */ 26 public class ActionService { makeStartActionPendingIntent(final Context context, final Action action, final int requestCode, final boolean launchesAnActivity)27 protected static PendingIntent makeStartActionPendingIntent(final Context context, 28 final Action action, final int requestCode, final boolean launchesAnActivity) { 29 return ActionServiceImpl.makeStartActionPendingIntent(context, action, requestCode, 30 launchesAnActivity); 31 } 32 33 /** 34 * Start an action by posting it over the the ActionService 35 */ startAction(final Action action)36 public void startAction(final Action action) { 37 ActionServiceImpl.startAction(action); 38 } 39 40 /** 41 * Schedule a delayed action by posting it over the the ActionService 42 */ scheduleAction(final Action action, final int code, final long delayMs)43 public void scheduleAction(final Action action, final int code, 44 final long delayMs) { 45 ActionServiceImpl.scheduleAction(action, code, delayMs); 46 } 47 48 /** 49 * Process a response from the BackgroundWorker in the ActionService 50 */ handleResponseFromBackgroundWorker( final Action action, final Bundle response)51 protected void handleResponseFromBackgroundWorker( 52 final Action action, final Bundle response) { 53 ActionServiceImpl.handleResponseFromBackgroundWorker(action, response); 54 } 55 56 /** 57 * Process a failure from the BackgroundWorker in the ActionService 58 */ handleFailureFromBackgroundWorker(final Action action, final Exception exception)59 protected void handleFailureFromBackgroundWorker(final Action action, 60 final Exception exception) { 61 ActionServiceImpl.handleFailureFromBackgroundWorker(action, exception); 62 } 63 } 64