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