Home | History | Annotate | Download | only in transaction
      1 /*
      2  * Copyright (C) 2008 Esmertec AG.
      3  * Copyright (C) 2008 The Android Open Source Project
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at
      8  *
      9  *      http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  */
     17 
     18 package com.android.mms.transaction;
     19 
     20 import android.content.Context;
     21 import android.util.Log;
     22 
     23 /**
     24  * Default retry scheme, based on specs.
     25  */
     26 public class DefaultRetryScheme extends AbstractRetryScheme {
     27     private static final String TAG = "DefaultRetryScheme";
     28     private static final boolean DEBUG = false;
     29     private static final boolean LOCAL_LOGV = false;
     30 
     31     private static final int[] sDefaultRetryScheme = {
     32         0, 1 * 60 * 1000, 5 * 60 * 1000, 10 * 60 * 1000, 30 * 60 * 1000};
     33 
     34     public DefaultRetryScheme(Context context, int retriedTimes) {
     35         super(retriedTimes);
     36 
     37         mRetriedTimes = mRetriedTimes < 0 ? 0 : mRetriedTimes;
     38         mRetriedTimes = mRetriedTimes >= sDefaultRetryScheme.length
     39                 ? sDefaultRetryScheme.length - 1 : mRetriedTimes;
     40 
     41         // TODO Get retry scheme from preference.
     42     }
     43 
     44     @Override
     45     public int getRetryLimit() {
     46         return sDefaultRetryScheme.length;
     47     }
     48 
     49     @Override
     50     public long getWaitingInterval() {
     51         if (LOCAL_LOGV) {
     52             Log.v(TAG, "Next int: " + sDefaultRetryScheme[mRetriedTimes]);
     53         }
     54         return sDefaultRetryScheme[mRetriedTimes];
     55     }
     56 }
     57