Add Conn Man testing tools.
First test toggles wifi on/off forever (must have wifi associated to start, or at least a remembered network in range) Second test toggles the screen on off so you can test wifi cycle from that point. Lastly adds some network-feature tests using mms or hipri net features. bug: 2170806
This commit is contained in:
@@ -34,6 +34,11 @@
|
|||||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||||
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
||||||
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
<uses-permission android:name="android.permission.DEVICE_POWER" />
|
||||||
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||||
|
|
||||||
<application android:label="Dev Tools"
|
<application android:label="Dev Tools"
|
||||||
android:icon="@drawable/ic_launcher_devtools">
|
android:icon="@drawable/ic_launcher_devtools">
|
||||||
@@ -88,6 +93,12 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity android:name="Details">
|
<activity android:name="Details">
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name="Connectivity" android:label="Connectivity" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.TEST" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
<activity android:name="DevelopmentSettings" android:label="Development Settings" >
|
<activity android:name="DevelopmentSettings" android:label="Development Settings" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|||||||
206
apps/Development/res/layout/connectivity.xml
Normal file
206
apps/Development/res/layout/connectivity.xml
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
/* //device/apps/Settings/assets/res/any/layout/keyboard_version.xml
|
||||||
|
**
|
||||||
|
** Copyright 2006, The Android Open Source Project
|
||||||
|
**
|
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
** you may not use this file except in compliance with the License.
|
||||||
|
** You may obtain a copy of the License at
|
||||||
|
**
|
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
**
|
||||||
|
** Unless required by applicable law or agreed to in writing, software
|
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
** See the License for the specific language governing permissions and
|
||||||
|
** limitations under the License.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<Button android:id="@+id/enableWifi"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/enable_wifi" />
|
||||||
|
<Button android:id="@+id/disableWifi"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/disable_wifi" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- divider line -->
|
||||||
|
<View android:background="#FFFFFFFF"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="3dip" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingTop="4dip"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<Button android:id="@+id/startDelayedCycle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/start_toggling" />
|
||||||
|
<Button android:id="@+id/stopDelayedCycle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/stop_toggling" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/wifi_on_duration" />
|
||||||
|
<EditText android:id="@+id/dc_wifi_on_duration"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minEms="15" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/wifi_off_duration" />
|
||||||
|
<EditText android:id="@+id/dc_wifi_off_duration"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minEms="15"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/wifi_cycles_done" />
|
||||||
|
<TextView android:id="@+id/dc_wifi_cycles_done"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minEms="15"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- divider line -->
|
||||||
|
<View android:background="#FFFFFFFF"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="3dip" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingTop="4dip"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<Button android:id="@+id/startScreenCycle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/start_screen_toggling" />
|
||||||
|
<Button android:id="@+id/stopScreenCycle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/stop_screen_toggling" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/wifi_on_duration" />
|
||||||
|
<EditText android:id="@+id/sc_wifi_on_duration"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minEms="15" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/wifi_off_duration" />
|
||||||
|
<EditText android:id="@+id/sc_wifi_off_duration"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minEms="15"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/wifi_cycles_done" />
|
||||||
|
<TextView android:id="@+id/sc_wifi_cycles_done"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minEms="15"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- divider line -->
|
||||||
|
<View android:background="#FFFFFFFF"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="3dip" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingTop="4dip"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<Button android:id="@+id/start_mms"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/start_mms" />
|
||||||
|
<Button android:id="@+id/stop_mms"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/stop_mms" />
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<Button android:id="@+id/start_hipri"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/start_hipri" />
|
||||||
|
<Button android:id="@+id/stop_hipri"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/stop_hipri" />
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<Button android:id="@+id/crash"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/crash" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -21,6 +21,23 @@
|
|||||||
<string name="menu_upload_exceptions">Upload Exceptions</string>
|
<string name="menu_upload_exceptions">Upload Exceptions</string>
|
||||||
<string name="menu_clear_exceptions">Clear Exceptions</string>
|
<string name="menu_clear_exceptions">Clear Exceptions</string>
|
||||||
|
|
||||||
|
<string name="enable_wifi">Enable Wifi</string>
|
||||||
|
<string name="disable_wifi">Disable Wifi</string>
|
||||||
|
<string name="wifi_on_duration">Wifi on (ms): </string>
|
||||||
|
<string name="wifi_off_duration">Wifi off (ms): </string>
|
||||||
|
<string name="wifi_cycles_done">Cycles done: </string>
|
||||||
|
<string name="start_toggling">Start Wifi Toggle</string>
|
||||||
|
<string name="stop_toggling">Stop Wifi Toggle</string>
|
||||||
|
<string name="start_screen_toggling">Start Screen Toggle</string>
|
||||||
|
<string name="stop_screen_toggling">Stop Screen Toggle</string>
|
||||||
|
|
||||||
|
<string name="start_mms">Start MMS</string>
|
||||||
|
<string name="stop_mms">Stop MMS</string>
|
||||||
|
<string name="start_hipri">Start HiPri</string>
|
||||||
|
<string name="stop_hipri">Stop HiPri</string>
|
||||||
|
<string name="crash">CRASH</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="device_info_default">unknown</string>
|
<string name="device_info_default">unknown</string>
|
||||||
<string name="device_info_uptime">Uptime</string>
|
<string name="device_info_uptime">Uptime</string>
|
||||||
<string name="device_info_awaketime">Awake Time</string>
|
<string name="device_info_awaketime">Awake Time</string>
|
||||||
|
|||||||
351
apps/Development/src/com/android/development/Connectivity.java
Normal file
351
apps/Development/src/com/android/development/Connectivity.java
Normal file
@@ -0,0 +1,351 @@
|
|||||||
|
/* //device/apps/Settings/src/com/android/settings/Keyguard.java
|
||||||
|
**
|
||||||
|
** Copyright 2006, The Android Open Source Project
|
||||||
|
**
|
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
** you may not use this file except in compliance with the License.
|
||||||
|
** You may obtain a copy of the License at
|
||||||
|
**
|
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
**
|
||||||
|
** Unless required by applicable law or agreed to in writing, software
|
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
** See the License for the specific language governing permissions and
|
||||||
|
** limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.development;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.ActivityManagerNative;
|
||||||
|
import android.app.AlarmManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.os.RemoteException;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.PowerManager;
|
||||||
|
import android.os.PowerManager.WakeLock;
|
||||||
|
import android.os.ServiceManager;
|
||||||
|
import android.os.ServiceManagerNative;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.IWindowManager;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
|
|
||||||
|
import com.android.internal.telephony.Phone;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Connectivity extends Activity {
|
||||||
|
private static final String TAG = "Connectivity";
|
||||||
|
|
||||||
|
private static final int EVENT_TOGGLE_WIFI = 1;
|
||||||
|
private static final int EVENT_TOGGLE_SCREEN = 2;
|
||||||
|
|
||||||
|
private Button mEnableWifiButton;
|
||||||
|
private Button mDisableWifiButton;
|
||||||
|
|
||||||
|
private Button mStartDelayedCycleButton;
|
||||||
|
private Button mStopDelayedCycleButton;
|
||||||
|
private EditText mDCOnDurationEdit;
|
||||||
|
private EditText mDCOffDurationEdit;
|
||||||
|
private TextView mDCCycleCountView;
|
||||||
|
private long mDCOnDuration = 120000;
|
||||||
|
private long mDCOffDuration = 120000;
|
||||||
|
private int mDCCycleCount = 0;
|
||||||
|
|
||||||
|
private Button mStartScreenCycleButton;
|
||||||
|
private Button mStopScreenCycleButton;
|
||||||
|
private EditText mSCOnDurationEdit;
|
||||||
|
private EditText mSCOffDurationEdit;
|
||||||
|
private TextView mSCCycleCountView;
|
||||||
|
private long mSCOnDuration = 120000;
|
||||||
|
private long mSCOffDuration = 12000;
|
||||||
|
private int mSCCycleCount = 0;
|
||||||
|
|
||||||
|
private Button mStartMmsButton;
|
||||||
|
private Button mStopMmsButton;
|
||||||
|
private Button mStartHiPriButton;
|
||||||
|
private Button mStopHiPriButton;
|
||||||
|
private Button mCrashButton;
|
||||||
|
|
||||||
|
private boolean mDelayedCycleStarted = false;
|
||||||
|
|
||||||
|
private WifiManager mWm;
|
||||||
|
private PowerManager mPm;
|
||||||
|
private ConnectivityManager mCm;
|
||||||
|
|
||||||
|
private WakeLock mWakeLock = null;
|
||||||
|
private WakeLock mScreenonWakeLock = null;
|
||||||
|
|
||||||
|
private boolean mScreenOffToggleRunning = false;
|
||||||
|
private boolean mScreenOff = false;
|
||||||
|
|
||||||
|
private static final String CONNECTIVITY_TEST_ALARM =
|
||||||
|
"com.android.development.CONNECTIVITY_TEST_ALARM";
|
||||||
|
private static final String TEST_ALARM_EXTRA = "CONNECTIVITY_TEST_EXTRA";
|
||||||
|
private static final String TEST_ALARM_ON_EXTRA = "CONNECTIVITY_TEST_ON_EXTRA";
|
||||||
|
private static final String TEST_ALARM_OFF_EXTRA = "CONNECTIVITY_TEST_OFF_EXTRA";
|
||||||
|
private static final String TEST_ALARM_CYCLE_EXTRA = "CONNECTIVITY_TEST_CYCLE_EXTRA";
|
||||||
|
private static final String SCREEN_ON = "SCREEN_ON";
|
||||||
|
private static final String SCREEN_OFF = "SCREEN_OFF";
|
||||||
|
public BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (intent.getAction().equals(CONNECTIVITY_TEST_ALARM)) {
|
||||||
|
String extra = (String)intent.getExtra(TEST_ALARM_EXTRA);
|
||||||
|
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
|
||||||
|
Long on = new Long(120000);
|
||||||
|
Long off = new Long(120000);
|
||||||
|
int cycle = 0;
|
||||||
|
try {
|
||||||
|
on = Long.parseLong((String)intent.getExtra(TEST_ALARM_ON_EXTRA));
|
||||||
|
off = Long.parseLong((String)intent.getExtra(TEST_ALARM_OFF_EXTRA));
|
||||||
|
cycle = Integer.parseInt((String)intent.getExtra(TEST_ALARM_CYCLE_EXTRA));
|
||||||
|
} catch (Exception e) {}
|
||||||
|
|
||||||
|
if (extra.equals(SCREEN_ON)) {
|
||||||
|
mScreenonWakeLock = mPm.newWakeLock(PowerManager.FULL_WAKE_LOCK |
|
||||||
|
PowerManager.ACQUIRE_CAUSES_WAKEUP,
|
||||||
|
"ConnectivityTest");
|
||||||
|
mScreenonWakeLock.acquire();
|
||||||
|
|
||||||
|
mSCCycleCount = cycle+1;
|
||||||
|
mSCOnDuration = on;
|
||||||
|
mSCOffDuration = off;
|
||||||
|
mSCCycleCountView.setText(Integer.toString(mSCCycleCount));
|
||||||
|
|
||||||
|
scheduleAlarm(mSCOnDuration, SCREEN_OFF);
|
||||||
|
} else if (extra.equals(SCREEN_OFF)) {
|
||||||
|
|
||||||
|
mSCCycleCount = cycle;
|
||||||
|
mSCOnDuration = on;
|
||||||
|
mSCOffDuration = off;
|
||||||
|
|
||||||
|
mScreenonWakeLock.release();
|
||||||
|
mScreenonWakeLock = null;
|
||||||
|
scheduleAlarm(mSCOffDuration, SCREEN_ON);
|
||||||
|
pm.goToSleep(SystemClock.uptimeMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public Handler mHandler2 = new Handler() {
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
switch(msg.what) {
|
||||||
|
case EVENT_TOGGLE_WIFI:
|
||||||
|
Log.e(TAG, "EVENT_TOGGLE_WIFI");
|
||||||
|
if (mDelayedCycleStarted && mWm != null) {
|
||||||
|
long delay;
|
||||||
|
switch (mWm.getWifiState()) {
|
||||||
|
case WifiManager.WIFI_STATE_ENABLED:
|
||||||
|
case WifiManager.WIFI_STATE_ENABLING:
|
||||||
|
mWm.setWifiEnabled(false);
|
||||||
|
delay = mDCOffDuration;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mWm.setWifiEnabled(true);
|
||||||
|
delay = mDCOnDuration;
|
||||||
|
mDCCycleCount++;
|
||||||
|
mDCCycleCountView.setText(Integer.toString(mDCCycleCount));
|
||||||
|
}
|
||||||
|
sendMessageDelayed(obtainMessage(EVENT_TOGGLE_WIFI),
|
||||||
|
delay);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle icicle) {
|
||||||
|
super.onCreate(icicle);
|
||||||
|
|
||||||
|
setContentView(R.layout.connectivity);
|
||||||
|
|
||||||
|
mWm = (WifiManager)getSystemService(Context.WIFI_SERVICE);
|
||||||
|
mPm = (PowerManager)getSystemService(Context.POWER_SERVICE);
|
||||||
|
mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
|
||||||
|
mEnableWifiButton = (Button)findViewById(R.id.enableWifi);
|
||||||
|
mEnableWifiButton.setOnClickListener(mEnableWifiClicked);
|
||||||
|
mDisableWifiButton = (Button)findViewById(R.id.disableWifi);
|
||||||
|
mDisableWifiButton.setOnClickListener(mDisableWifiClicked);
|
||||||
|
|
||||||
|
mStartDelayedCycleButton = (Button)findViewById(R.id.startDelayedCycle);
|
||||||
|
mStartDelayedCycleButton.setOnClickListener(mStartDelayedCycleClicked);
|
||||||
|
mStopDelayedCycleButton = (Button)findViewById(R.id.stopDelayedCycle);
|
||||||
|
mStopDelayedCycleButton.setOnClickListener(mStopDelayedCycleClicked);
|
||||||
|
mDCOnDurationEdit = (EditText)findViewById(R.id.dc_wifi_on_duration);
|
||||||
|
mDCOnDurationEdit.setText(Long.toString(mDCOnDuration));
|
||||||
|
mDCOffDurationEdit = (EditText)findViewById(R.id.dc_wifi_off_duration);
|
||||||
|
mDCOffDurationEdit.setText(Long.toString(mDCOffDuration));
|
||||||
|
mDCCycleCountView = (TextView)findViewById(R.id.dc_wifi_cycles_done);
|
||||||
|
mDCCycleCountView.setText(Integer.toString(mDCCycleCount));
|
||||||
|
|
||||||
|
mStartScreenCycleButton = (Button)findViewById(R.id.startScreenCycle);
|
||||||
|
mStartScreenCycleButton.setOnClickListener(mStartScreenCycleClicked);
|
||||||
|
mStopScreenCycleButton = (Button)findViewById(R.id.stopScreenCycle);
|
||||||
|
mStopScreenCycleButton.setOnClickListener(mStopScreenCycleClicked);
|
||||||
|
mSCOnDurationEdit = (EditText)findViewById(R.id.sc_wifi_on_duration);
|
||||||
|
mSCOnDurationEdit.setText(Long.toString(mSCOnDuration));
|
||||||
|
mSCOffDurationEdit = (EditText)findViewById(R.id.sc_wifi_off_duration);
|
||||||
|
mSCOffDurationEdit.setText(Long.toString(mSCOffDuration));
|
||||||
|
mSCCycleCountView = (TextView)findViewById(R.id.sc_wifi_cycles_done);
|
||||||
|
mSCCycleCountView.setText(Integer.toString(mSCCycleCount));
|
||||||
|
|
||||||
|
mStartMmsButton = (Button)findViewById(R.id.start_mms);
|
||||||
|
mStartMmsButton.setOnClickListener(mStartMmsClicked);
|
||||||
|
mStopMmsButton = (Button)findViewById(R.id.stop_mms);
|
||||||
|
mStopMmsButton.setOnClickListener(mStopMmsClicked);
|
||||||
|
mStartHiPriButton = (Button)findViewById(R.id.start_hipri);
|
||||||
|
mStartHiPriButton.setOnClickListener(mStartHiPriClicked);
|
||||||
|
mStopHiPriButton = (Button)findViewById(R.id.stop_hipri);
|
||||||
|
mStopHiPriButton.setOnClickListener(mStopHiPriClicked);
|
||||||
|
mCrashButton = (Button)findViewById(R.id.crash);
|
||||||
|
mCrashButton.setOnClickListener(mCrashClicked);
|
||||||
|
|
||||||
|
registerReceiver(mReceiver, new IntentFilter(CONNECTIVITY_TEST_ALARM));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
|
||||||
|
private View.OnClickListener mStartDelayedCycleClicked = new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (!mDelayedCycleStarted) {
|
||||||
|
mDelayedCycleStarted = true;
|
||||||
|
try {
|
||||||
|
mDCOnDuration = Long.parseLong(mDCOnDurationEdit.getText().toString());
|
||||||
|
mDCOffDuration = Long.parseLong(mDCOffDurationEdit.getText().toString());
|
||||||
|
} catch (Exception e) { };
|
||||||
|
mDCCycleCount = 0;
|
||||||
|
|
||||||
|
mWakeLock = mPm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "ConnectivityTest");
|
||||||
|
mWakeLock.acquire();
|
||||||
|
mHandler2.sendMessage(mHandler2.obtainMessage(EVENT_TOGGLE_WIFI));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private View.OnClickListener mStopDelayedCycleClicked = new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (mDelayedCycleStarted) {
|
||||||
|
mDelayedCycleStarted = false;
|
||||||
|
mWakeLock.release();
|
||||||
|
mWakeLock = null;
|
||||||
|
if(mHandler2.hasMessages(EVENT_TOGGLE_WIFI)) {
|
||||||
|
mHandler2.removeMessages(EVENT_TOGGLE_WIFI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private View.OnClickListener mEnableWifiClicked = new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
mWm.setWifiEnabled(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private View.OnClickListener mDisableWifiClicked = new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
mWm.setWifiEnabled(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private View.OnClickListener mStartScreenCycleClicked = new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
mSCOnDuration = Long.parseLong(mSCOnDurationEdit.getText().toString());
|
||||||
|
mSCOffDuration = Long.parseLong(mSCOffDurationEdit.getText().toString());
|
||||||
|
} catch (Exception e) { };
|
||||||
|
mSCCycleCount = 0;
|
||||||
|
|
||||||
|
mScreenonWakeLock = mPm.newWakeLock(PowerManager.FULL_WAKE_LOCK,
|
||||||
|
"ConnectivityTest");
|
||||||
|
mScreenonWakeLock.acquire();
|
||||||
|
|
||||||
|
scheduleAlarm(10, SCREEN_OFF);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private void scheduleAlarm(long delayMs, String eventType) {
|
||||||
|
AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
|
||||||
|
Intent i = new Intent(CONNECTIVITY_TEST_ALARM);
|
||||||
|
|
||||||
|
i.putExtra(TEST_ALARM_EXTRA, eventType);
|
||||||
|
i.putExtra(TEST_ALARM_ON_EXTRA, Long.toString(mSCOnDuration));
|
||||||
|
i.putExtra(TEST_ALARM_OFF_EXTRA, Long.toString(mSCOffDuration));
|
||||||
|
i.putExtra(TEST_ALARM_CYCLE_EXTRA, Integer.toString(mSCCycleCount));
|
||||||
|
|
||||||
|
PendingIntent p = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
||||||
|
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delayMs, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private View.OnClickListener mStopScreenCycleClicked = new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private View.OnClickListener mStartMmsClicked = new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
mCm.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_MMS);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private View.OnClickListener mStopMmsClicked = new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
mCm.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_MMS);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private View.OnClickListener mStartHiPriClicked = new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
mCm.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
|
||||||
|
Phone.FEATURE_ENABLE_HIPRI);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private View.OnClickListener mStopHiPriClicked = new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
mCm.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
|
||||||
|
Phone.FEATURE_ENABLE_HIPRI);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private View.OnClickListener mCrashClicked = new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
ConnectivityManager foo = null;
|
||||||
|
foo.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
|
||||||
|
Phone.FEATURE_ENABLE_MMS);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user