2 * Copyright (C) 2013 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com
.android
.internal
.telephony
.dataconnection
;
19 import android
.content
.BroadcastReceiver
;
20 import android
.content
.Context
;
21 import android
.content
.Intent
;
22 import android
.content
.IntentFilter
;
23 import android
.os
.Build
;
24 import android
.os
.Handler
;
25 import android
.telephony
.Rlog
;
27 import com
.android
.internal
.telephony
.PhoneBase
;
30 * To bring down all DC's send the following intent:
32 * adb shell am broadcast -a com.android.internal.telephony.dataconnection.action_deactivate_all
34 public class DcTesterDeactivateAll
{
35 private static final String LOG_TAG
= "DcTesterDeacativeAll";
36 private static final boolean DBG
= true;
38 private PhoneBase mPhone
;
39 private DcController mDcc
;
41 public static String sActionDcTesterDeactivateAll
=
42 "com.android.internal.telephony.dataconnection.action_deactivate_all";
45 // The static intent receiver one for all instances and we assume this
46 // is running on the same thread as Dcc.
47 protected BroadcastReceiver sIntentReceiver
= new BroadcastReceiver() {
49 public void onReceive(Context context
, Intent intent
) {
50 String action
= intent
.getAction();
51 if (DBG
) log("sIntentReceiver.onReceive: action=" + action
);
52 if (action
.equals(sActionDcTesterDeactivateAll
)
53 || action
.equals(mPhone
.getActionDetached())) {
54 log("Send DEACTIVATE to all Dcc's");
56 for (DataConnection dc
: mDcc
.mDcListAll
) {
60 if (DBG
) log("onReceive: mDcc is null, ignoring");
63 if (DBG
) log("onReceive: unknown action=" + action
);
68 DcTesterDeactivateAll(PhoneBase phone
, DcController dcc
, Handler handler
) {
72 if (Build
.IS_DEBUGGABLE
) {
73 IntentFilter filter
= new IntentFilter();
75 filter
.addAction(sActionDcTesterDeactivateAll
);
76 log("register for intent action=" + sActionDcTesterDeactivateAll
);
78 filter
.addAction(mPhone
.getActionDetached());
79 log("register for intent action=" + mPhone
.getActionDetached());
81 phone
.getContext().registerReceiver(sIntentReceiver
, filter
, null, handler
);
86 if (Build
.IS_DEBUGGABLE
) {
87 mPhone
.getContext().unregisterReceiver(sIntentReceiver
);
91 private static void log(String s
) {