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