提交 2ad075f9 编写于 作者: A andrewleo

Added: write N/A in TopActivity column when sdk is higher than 21; android 7.0 toast

上级 9b04c52e
##Emmagee - a practical, handy performance test tool for specified Android App
Emmagee is a practical, handy performance test tool for specified Android App, which can monitor CPU, memory,
network traffic, battery current and status([Some devices are not supported](https://github.com/NetEase/Emmagee/wiki/Some-devices-are-not-supported)), new features such as top activity and heap size if rooted([Root Toast may continously show](https://github.com/NetEase/Emmagee/wiki/FAQ)), are also supported in the [latest version](https://github.com/NetEase/Emmagee/releases). Additionally, it also provides several cool features such as customizing interval of collecting data,
rendering real-time process status in a floating window, and much more.
* Homepage: https://github.com/NetEase/Emmagee
* Wiki: https://github.com/NetEase/Emmagee/wiki
* Issues: https://github.com/NetEase/Emmagee/issues
* FAQ: https://github.com/NetEase/Emmagee/wiki/FAQ
* Tags: Android, Java
<img src="https://github.com/andrewleo/pictures/blob/master/Emmagee/V2.0/homepage.png" width="180px" />
&nbsp;
<img src="https://github.com/andrewleo/pictures/blob/master/Emmagee/V2.0/settings.png" width="180px" />
&nbsp;
<img src="https://github.com/andrewleo/pictures/blob/master/Emmagee/V2.0/mailsettings.png" width="180px" />
## Why should I use Emmagee?
Unlike most other performance test tools that only do system-level monitoring, Emmagee provides the ability to monitor any single App. Other advantages that
you should not miss:
* Open source
* Easy to use
* Process-specific monitoring, including CPU, memory, network traffic, battery current, launching time and status
* Floating window that renders real-time process status
* CSV format report that can be converted into any other format you want
* User-defined collecting interval
* Fully support Android 2.2 and above
## How to use Emmagee?
First of all ,you should have Emmagee.apk,download [here](https://github.com/NetEase/Emmagee/releases) or
build the apk file youself [here](https://github.com/NetEase/Emmagee/wiki/How-to-build-emmage.apk%3F),then :
1. Start Emmagee App
2. Configure interval
3. Select a target process
4. Click Start button
And Enjoy!
If you want to stop the test, just go back to Emmagee and click Stop button.
## Coming Soon
* We want you to decide!
## How to Contribute?
You are welcome to contribute to Emmagee, meanwhile you'd better follow the rules below
* It's *NOT* recommended to submit a pull request directly to Emmagee's `master` branch. `develop` branch is more appropriate
* Follow common Java coding conventions
* Put all Java class files under *com.netease* package
* Add the following [license](#license) in each Java class file
## Contributors
* NetEase, Inc.
* [yrom](https://github.com/yrom)
* [LukeOwncloud](https://github.com/LukeOwncloud)
## License
(The Apache License)
Copyright (c) 2012-2015 NetEase, Inc. and other contributors
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.
## Emmagee - a practical, handy performance test tool for specified Android App
Emmagee is a practical, handy performance test tool for specified Android App, which can monitor CPU, memory,
network traffic, battery current and status([Some devices are not supported](https://github.com/NetEase/Emmagee/wiki/Some-devices-are-not-supported)), new features such as top activity and heap size if rooted([Root Toast may continously show](https://github.com/NetEase/Emmagee/wiki/FAQ)), are also supported in the [latest version](https://github.com/NetEase/Emmagee/releases). Additionally, it also provides several cool features such as customizing interval of collecting data,
rendering real-time process status in a floating window, and much more.
* Homepage: https://github.com/NetEase/Emmagee
* Wiki: https://github.com/NetEase/Emmagee/wiki
* Issues: https://github.com/NetEase/Emmagee/issues
* FAQ: https://github.com/NetEase/Emmagee/wiki/FAQ
* Tags: Android, Java
<img src="https://github.com/andrewleo/pictures/blob/master/Emmagee/V2.0/homepage.png" width="180px" />
&nbsp;
<img src="https://github.com/andrewleo/pictures/blob/master/Emmagee/V2.0/settings.png" width="180px" />
&nbsp;
<img src="https://github.com/andrewleo/pictures/blob/master/Emmagee/V2.0/mailsettings.png" width="180px" />
## Why should I use Emmagee?
Unlike most other performance test tools that only do system-level monitoring, Emmagee provides the ability to monitor any single App. Other advantages that
you should not miss:
* Open source
* Easy to use
* Process-specific monitoring, including CPU, memory, network traffic, battery current, launching time and status
* Floating window that renders real-time process status
* CSV format report that can be converted into any other format you want
* User-defined collecting interval
* Fully support Android 2.2 and above
## How to use Emmagee?
First of all ,you should have Emmagee.apk,download [here](https://github.com/NetEase/Emmagee/releases) or
build the apk file youself [here](https://github.com/NetEase/Emmagee/wiki/How-to-build-emmage.apk%3F),then :
1. Start Emmagee App
2. Configure interval
3. Select a target process
4. Click Start button
And Enjoy!
If you want to stop the test, just go back to Emmagee and click Stop button.
## Android 5.0 and above
* `Android 5.0 and above`: getRunningTasks() and getRunningAppProcesses() are deprecated and only return your application process, so it is unable to get TopActivity from Android 5.0.
* `Android 7.0`: Google has restricted access to /proc, and also can not get pid of target application from TOP command in Android 7.0, I am so sorry to tell that 7.0 can not be supported.
## Coming Soon
* We want you to decide!
## How to Contribute?
You are welcome to contribute to Emmagee, meanwhile you'd better follow the rules below
* It's *NOT* recommended to submit a pull request directly to Emmagee's `master` branch. `develop` branch is more appropriate
* Follow common Java coding conventions
* Put all Java class files under *com.netease* package
* Add the following [license](#license) in each Java class file
## Contributors
* NetEase, Inc.
* [yrom](https://github.com/yrom)
* [LukeOwncloud](https://github.com/LukeOwncloud)
## License
(The Apache License)
Copyright (c) 2012-2015 NetEase, Inc. and other contributors
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.
......@@ -30,6 +30,7 @@
android:singleLine="true"
android:text="@string/setting"
android:textColor="@color/white"
android:textStyle="bold"
android:textSize="@dimen/text_size_big" />
<LinearLayout
......
......@@ -88,4 +88,5 @@
<string name="stop_when_exited">应用退出后停止监听</string>
<string name="update_list">列表更新成功</string>
<string name="nougat_warning">由于Google的限制,Emmagee无法支持7.0及以上版本</string>
</resources>
......@@ -87,4 +87,5 @@
<string name="stop_when_exited">Stop monitoring when app exited</string>
<string name="update_list">Update List Successfully</string>
<string name="nougat_warning">Don\'t support 7.0 and above while Google has restricted access to shell commands and file system</string>
</resources>
......@@ -16,20 +16,20 @@
*/
package com.netease.qa.emmagee.activity;
import com.netease.qa.emmagee.R;
import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.netease.qa.emmagee.R;
/**
* About Page of Emmagee
*
......
......@@ -19,6 +19,10 @@ package com.netease.qa.emmagee.activity;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.netease.qa.emmagee.R;
import com.netease.qa.emmagee.utils.EncryptData;
import com.netease.qa.emmagee.utils.Settings;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
......@@ -27,17 +31,13 @@ import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.netease.qa.emmagee.R;
import com.netease.qa.emmagee.utils.EncryptData;
import com.netease.qa.emmagee.utils.Settings;
/**
* Mail Setting Page of Emmagee
*
......
......@@ -29,6 +29,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
......@@ -86,46 +87,50 @@ public class MainPageActivity extends Activity {
btnTest.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
monitorService = new Intent();
monitorService.setClass(MainPageActivity.this, EmmageeService.class);
if (getString(R.string.start_test).equals(btnTest.getText().toString())) {
ListAdapter adapter = (ListAdapter) lstViProgramme.getAdapter();
if (adapter.checkedProg != null) {
String packageName = adapter.checkedProg.getPackageName();
String processName = adapter.checkedProg.getProcessName();
Intent intent = getPackageManager().getLaunchIntentForPackage(packageName);
String startActivity = "";
Log.d(LOG_TAG, packageName);
// clear logcat
try {
Runtime.getRuntime().exec("logcat -c");
} catch (IOException e) {
Log.d(LOG_TAG, e.getMessage());
if (Build.VERSION.SDK_INT < 24) {
monitorService = new Intent();
monitorService.setClass(MainPageActivity.this, EmmageeService.class);
if (getString(R.string.start_test).equals(btnTest.getText().toString())) {
ListAdapter adapter = (ListAdapter) lstViProgramme.getAdapter();
if (adapter.checkedProg != null) {
String packageName = adapter.checkedProg.getPackageName();
String processName = adapter.checkedProg.getProcessName();
Intent intent = getPackageManager().getLaunchIntentForPackage(packageName);
String startActivity = "";
Log.d(LOG_TAG, packageName);
// clear logcat
try {
Runtime.getRuntime().exec("logcat -c");
} catch (IOException e) {
Log.d(LOG_TAG, e.getMessage());
}
try {
startActivity = intent.resolveActivity(getPackageManager()).getShortClassName();
startActivity(intent);
} catch (Exception e) {
Toast.makeText(MainPageActivity.this, getString(R.string.can_not_start_app_toast), Toast.LENGTH_LONG).show();
return;
}
waitForAppStart(packageName);
monitorService.putExtra("processName", processName);
monitorService.putExtra("pid", pid);
monitorService.putExtra("uid", uid);
monitorService.putExtra("packageName", packageName);
monitorService.putExtra("startActivity", startActivity);
startService(monitorService);
isServiceStop = false;
btnTest.setText(getString(R.string.stop_test));
} else {
Toast.makeText(MainPageActivity.this, getString(R.string.choose_app_toast), Toast.LENGTH_LONG).show();
}
try {
startActivity = intent.resolveActivity(getPackageManager()).getShortClassName();
startActivity(intent);
} catch (Exception e) {
Toast.makeText(MainPageActivity.this, getString(R.string.can_not_start_app_toast), Toast.LENGTH_LONG).show();
return;
}
waitForAppStart(packageName);
monitorService.putExtra("processName", processName);
monitorService.putExtra("pid", pid);
monitorService.putExtra("uid", uid);
monitorService.putExtra("packageName", packageName);
monitorService.putExtra("startActivity", startActivity);
startService(monitorService);
isServiceStop = false;
btnTest.setText(getString(R.string.stop_test));
} else {
Toast.makeText(MainPageActivity.this, getString(R.string.choose_app_toast), Toast.LENGTH_LONG).show();
btnTest.setText(getString(R.string.start_test));
Toast.makeText(MainPageActivity.this, getString(R.string.test_result_file_toast) + EmmageeService.resultFilePath,
Toast.LENGTH_LONG).show();
stopService(monitorService);
}
} else {
btnTest.setText(getString(R.string.start_test));
Toast.makeText(MainPageActivity.this, getString(R.string.test_result_file_toast) + EmmageeService.resultFilePath,
Toast.LENGTH_LONG).show();
stopService(monitorService);
Toast.makeText(MainPageActivity.this, getString(R.string.nougat_warning),Toast.LENGTH_LONG).show();
}
}
});
......
......@@ -18,14 +18,17 @@ package com.netease.qa.emmagee.activity;
import java.io.DataOutputStream;
import com.netease.qa.emmagee.R;
import com.netease.qa.emmagee.utils.Settings;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
......@@ -35,9 +38,6 @@ import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
import com.netease.qa.emmagee.R;
import com.netease.qa.emmagee.utils.Settings;
/**
* Setting Page of Emmagee
*
......
......@@ -32,6 +32,20 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
import com.netease.qa.emmagee.R;
import com.netease.qa.emmagee.activity.MainPageActivity;
import com.netease.qa.emmagee.utils.Constants;
import com.netease.qa.emmagee.utils.CpuInfo;
import com.netease.qa.emmagee.utils.CurrentInfo;
import com.netease.qa.emmagee.utils.EncryptData;
import com.netease.qa.emmagee.utils.FpsInfo;
import com.netease.qa.emmagee.utils.MailSender;
import com.netease.qa.emmagee.utils.MemoryInfo;
import com.netease.qa.emmagee.utils.MyApplication;
import com.netease.qa.emmagee.utils.ProcessInfo;
import com.netease.qa.emmagee.utils.Programe;
import com.netease.qa.emmagee.utils.Settings;
import android.app.Activity;
import android.app.PendingIntent;
import android.app.Service;
......@@ -60,20 +74,6 @@ import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.netease.qa.emmagee.R;
import com.netease.qa.emmagee.activity.MainPageActivity;
import com.netease.qa.emmagee.utils.Constants;
import com.netease.qa.emmagee.utils.CpuInfo;
import com.netease.qa.emmagee.utils.CurrentInfo;
import com.netease.qa.emmagee.utils.EncryptData;
import com.netease.qa.emmagee.utils.FpsInfo;
import com.netease.qa.emmagee.utils.MailSender;
import com.netease.qa.emmagee.utils.MemoryInfo;
import com.netease.qa.emmagee.utils.MyApplication;
import com.netease.qa.emmagee.utils.ProcessInfo;
import com.netease.qa.emmagee.utils.Programe;
import com.netease.qa.emmagee.utils.Settings;
/**
* Service running in background
*
......
......@@ -29,14 +29,13 @@ import java.util.Calendar;
import java.util.Locale;
import java.util.regex.Pattern;
import com.netease.qa.emmagee.R;
import com.netease.qa.emmagee.service.EmmageeService;
import android.content.Context;
import android.os.Build;
import android.util.Log;
import com.netease.qa.emmagee.R;
/**
* operate CPU information
*
......
package com.netease.qa.emmagee.utils;
import javax.mail.*;
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
/**
* Customized Authenticator
......
package com.netease.qa.emmagee.utils;
import java.security.*;
import java.security.Key;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
......
......@@ -21,7 +21,6 @@ import java.io.DataOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import android.app.ActivityManager;
import android.content.Context;
......
......@@ -210,6 +210,9 @@ public class ProcessInfo {
ActivityManager manager = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
// Note: getRunningTasks is deprecated in API 21(Official)
// if (Build.VERSION.SDK_INT >= 21) {
// return Constants.NA;
// }
List<RunningTaskInfo> runningTaskInfos = manager.getRunningTasks(1);
if (runningTaskInfos != null)
return (runningTaskInfos.get(0).topActivity).toString();
......
......@@ -16,10 +16,6 @@
*/
package com.netease.qa.emmagee.utils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import android.net.TrafficStats;
import android.util.Log;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册