DcFailBringUp.java revision 0e664d8c9ff3a1f2ab03d2bef4268615335ea1a2
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 17package com.android.internal.telephony.dataconnection; 18 19import android.content.Intent; 20import android.telephony.Rlog; 21 22import com.android.internal.telephony.RILConstants; 23 24/** 25 * A package visible class for supporting testing failing bringUp commands. This 26 * saves the parameters from a action_fail_bringup intent. See 27 * {@link DataConnection#doOnConnect} and {@see DcTesterFailBringUpAll} for more info. 28 */ 29class DcFailBringUp { 30 private static final String LOG_TAG = "DcFailBringUp"; 31 private static final boolean DBG = true; 32 33 static final String INTENT_BASE = DataConnection.class.getPackage().getName(); 34 35 static final String ACTION_FAIL_BRINGUP = "action_fail_bringup"; 36 37 // counter with its --ei option name and default value 38 static final String COUNTER = "counter"; 39 static final int DEFAULT_COUNTER = 2; 40 int mCounter; 41 42 // failCause with its --ei option name and default value 43 static final String FAIL_CAUSE = "fail_cause"; 44 static final DcFailCause DEFAULT_FAIL_CAUSE = DcFailCause.ERROR_UNSPECIFIED; 45 DcFailCause mFailCause; 46 47 // suggestedRetryTime with its --ei option name and default value 48 static final String SUGGESTED_RETRY_TIME = "suggested_retry_time"; 49 static final int DEFAULT_SUGGESTED_RETRY_TIME = RILConstants.MAX_INT; 50 int mSuggestedRetryTime; 51 52 // Get the Extra Intent parameters 53 void saveParameters(Intent intent, String s) { 54 if (DBG) log(s + ".saveParameters: action=" + intent.getAction()); 55 mCounter = intent.getIntExtra(COUNTER, DEFAULT_COUNTER); 56 mFailCause = DcFailCause.fromInt( 57 intent.getIntExtra(FAIL_CAUSE, DEFAULT_FAIL_CAUSE.getErrorCode())); 58 mSuggestedRetryTime = 59 intent.getIntExtra(SUGGESTED_RETRY_TIME, DEFAULT_SUGGESTED_RETRY_TIME); 60 if (DBG) { 61 log(s + ".saveParameters: " + this); 62 } 63 } 64 65 void saveParameters(int counter, int failCause, int suggestedRetryTime) { 66 mCounter = counter; 67 mFailCause = DcFailCause.fromInt(failCause); 68 mSuggestedRetryTime = suggestedRetryTime; 69 } 70 71 @Override 72 public String toString() { 73 return "{mCounter=" + mCounter + 74 " mFailCause=" + mFailCause + 75 " mSuggestedRetryTime=" + mSuggestedRetryTime + "}"; 76 77 } 78 79 private static void log(String s) { 80 Rlog.d(LOG_TAG, s); 81 } 82} 83