• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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.vvm.omtp.scheduling;
18 
19 import android.content.Context;
20 import android.content.Intent;
21 
22 import com.android.phone.vvm.omtp.VvmLog;
23 
24 /**
25  * Task to block another task of the same ID from being queued for a certain amount of time.
26  */
27 public class BlockerTask extends BaseTask {
28 
29     private static final String TAG = "BlockerTask";
30 
31     public static final String EXTRA_TASK_ID = "extra_task_id";
32     public static final String EXTRA_BLOCK_FOR_MILLIS = "extra_block_for_millis";
33 
BlockerTask()34     public BlockerTask() {
35         super(TASK_INVALID);
36     }
37 
38     @Override
onCreate(Context context, Intent intent, int flags, int startId)39     public void onCreate(Context context, Intent intent, int flags, int startId) {
40         super.onCreate(context, intent, flags, startId);
41         setId(intent.getIntExtra(EXTRA_TASK_ID, TASK_INVALID));
42         setExecutionTime(getTimeMillis() + intent.getIntExtra(EXTRA_BLOCK_FOR_MILLIS, 0));
43     }
44 
45     @Override
onExecuteInBackgroundThread()46     public void onExecuteInBackgroundThread() {
47         // Do nothing.
48     }
49 
50     @Override
onDuplicatedTaskAdded(Task task)51     public void onDuplicatedTaskAdded(Task task) {
52         VvmLog
53             .v(TAG, task.toString() + "blocked, " + getReadyInMilliSeconds() + "millis remaining");
54     }
55 }
56