OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 package com.google.media.networktester; |
| 12 |
| 13 import android.app.Activity; |
| 14 import android.content.Context; |
| 15 import android.net.ConnectivityManager; |
| 16 import android.net.NetworkInfo; |
| 17 import android.os.Bundle; |
| 18 import android.os.Handler; |
| 19 import android.os.ParcelFileDescriptor; |
| 20 import android.view.View; |
| 21 import android.view.View.OnClickListener; |
| 22 import android.view.WindowManager; |
| 23 import android.widget.Button; |
| 24 |
| 25 public class MainActivity extends Activity { |
| 26 Button startButton; |
| 27 Button stopButton; |
| 28 NetworkTester networkTester = null; |
| 29 Handler mainThreadHandler; |
| 30 |
| 31 @Override |
| 32 protected void onCreate(Bundle savedInstanceState) { |
| 33 super.onCreate(savedInstanceState); |
| 34 setContentView(R.layout.activity_main); |
| 35 startButton = (Button) findViewById(R.id.start_button); |
| 36 startButton.setOnClickListener(new OnClickListener() { |
| 37 @Override |
| 38 public void onClick(View v) { |
| 39 startTest(); |
| 40 } |
| 41 }); |
| 42 stopButton = (Button) findViewById(R.id.stop_button); |
| 43 stopButton.setOnClickListener(new OnClickListener() { |
| 44 @Override |
| 45 public void onClick(View v) { |
| 46 stopTest(); |
| 47 } |
| 48 }); |
| 49 mainThreadHandler = new Handler(); |
| 50 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
| 51 } |
| 52 |
| 53 private void startTest() { |
| 54 if (networkTester == null) { |
| 55 networkTester = new NetworkTester(); |
| 56 networkTester.start(); |
| 57 } |
| 58 } |
| 59 |
| 60 private void stopTest() { |
| 61 if (networkTester != null) { |
| 62 networkTester.interrupt(); |
| 63 networkTester = null; |
| 64 } |
| 65 } |
| 66 } |
OLD | NEW |