diff --git a/android/.classpath b/android/.classpath
deleted file mode 100644
index 5176974..0000000
--- a/android/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/android/.gitignore b/android/.gitignore
index 3f4e5ce..4d78963 100644
--- a/android/.gitignore
+++ b/android/.gitignore
@@ -1,2 +1,8 @@
-/bin/
-/gen/
+*.iml
+.gradle
+local.properties
+.idea
+.DS_Store
+build
+captures
+.externalNativeBuild
diff --git a/android/.project b/android/.project
deleted file mode 100644
index 25d86df..0000000
--- a/android/.project
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
- GT_trunk
- GT Console
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
- net.sourceforge.metrics.builder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
- net.sourceforge.metrics.nature
-
-
diff --git a/android/.settings/org.eclipse.core.resources.prefs b/android/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 99f26c0..0000000
--- a/android/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,2 +0,0 @@
-eclipse.preferences.version=1
-encoding/=UTF-8
diff --git a/android/.settings/org.eclipse.jdt.core.prefs b/android/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index b080d2d..0000000
--- a/android/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/android/LICENSE.TXT b/android/LICENSE.TXT
deleted file mode 100644
index 81111a1..0000000
--- a/android/LICENSE.TXT
+++ /dev/null
@@ -1,101 +0,0 @@
-Tencent is pleased to support the open source community by making Tencent GT (Version 2.4) available.
-Notwithstanding anything to the contrary herein, any previous version of Tencent GT shall not be subject to the license hereunder. All right, title, and interest, including all intellectual property rights, in and to the previous version of Tencent GT (including any and all copies thereof) shall be owned and retained by Tencent and subject to the license under the Tencent GT End User License Agreement (http://gt.qq.com/wp-content/EULA_EN.html).
-Copyright (C) 2015 THL A29 Limited, a Tencent company. All rights reserved.
-If you have downloaded a copy of the Tencent GT binary from Tencent, please note that the Tencent GT binary is licensed under the MIT License.
-If you have downloaded a copy of the Tencent GT source code from Tencent, please note that Tencent GT source code is licensed under the MIT License, except for the third-party components listed below which are subject to different license terms. Your integration of Tencent GT into your own projects may require compliance with the MIT License, as well as the other licenses applicable to the third-party components included within Tencent GT.
-A copy of the MIT License is included in this file.
-
-Other dependencies and licenses:
-
-Open Source Software Licensed Under the Apache License, Version 2.0 (the "License"):
-----------------------------------------------------------------------------------------
-
-Drag-sort-listview Version 0.6.1
-Copyright (c) 2012 Carl Bauer
-
-
-Terms of the Apache License, Version 2.0:
----------------------------------------------------
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
-"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
-
-"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
-
-"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
-
-"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
-
-"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
-
-"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
-
-"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
-
-"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
-
-"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
-
-"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
-
-a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
-
-b) You must cause any modified files to carry prominent notices stating that You changed the files; and
-
-c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
-
-d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
-
-You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
-9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
-
-
-
-
-
-Open Source Software Licensed Under the MIT License (the "License"):
-----------------------------------------------------------------------------------------
-
-1. BeeFramework Version 0.6.0
-Copyright (c) 2014-2015, Geek Zoo Studio
-
-2. LeveyTabBarController Version master-20130421
-Copyright (c) 2010 SlyFairy.
-All rights reserved.
-
-3. SVProgressHUD Version 1.1.3
-Copyright (c) 2011-2014 Sam Vermette
-
-4. TSPopover Version master-20120521
-Copyright (C) 2012 Takashi Saito
-
-5. WKVerticalScrollBar Version master-20120628
-Copyright (c) 2012 litl, LLC
-Copyright (c) 2012 WKVerticalScrollBar authors
-
-
-Terms of the MIT License:
---------------------------------------------------------------------
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/android/app/.gitignore b/android/app/.gitignore
new file mode 100644
index 0000000..a4f6ad6
--- /dev/null
+++ b/android/app/.gitignore
@@ -0,0 +1,2 @@
+*.iml
+/build
diff --git a/android/app/build.gradle b/android/app/build.gradle
new file mode 100644
index 0000000..363b228
--- /dev/null
+++ b/android/app/build.gradle
@@ -0,0 +1,30 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 23
+ buildToolsVersion "26.0.0"
+
+ defaultConfig {
+ applicationId "com.tencent.wstt.gt"
+ minSdkVersion 14
+ targetSdkVersion 23
+
+ ndk {
+ moduleName "mem_fill_tool"
+ }
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+ }
+ }
+}
+
+dependencies {
+ compile files('libs/android-support-v13.jar')
+ compile files('libs/bugly_crash_release.jar')
+ compile files('libs/mid-sdk-3.6.jar')
+ compile files('libs/mta-sdk-2.2.1.jar')
+}
diff --git a/android/libs/android-support-v13.jar b/android/app/libs/android-support-v13.jar
similarity index 100%
rename from android/libs/android-support-v13.jar
rename to android/app/libs/android-support-v13.jar
diff --git a/android/libs/bugly_crash_release.jar b/android/app/libs/bugly_crash_release.jar
similarity index 100%
rename from android/libs/bugly_crash_release.jar
rename to android/app/libs/bugly_crash_release.jar
diff --git a/android/libs/mid-sdk-3.6.jar b/android/app/libs/mid-sdk-3.6.jar
similarity index 100%
rename from android/libs/mid-sdk-3.6.jar
rename to android/app/libs/mid-sdk-3.6.jar
diff --git a/android/libs/mta-sdk-2.2.1.jar b/android/app/libs/mta-sdk-2.2.1.jar
similarity index 100%
rename from android/libs/mta-sdk-2.2.1.jar
rename to android/app/libs/mta-sdk-2.2.1.jar
diff --git a/android/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
similarity index 97%
rename from android/AndroidManifest.xml
rename to android/app/src/main/AndroidManifest.xml
index 1dc284c..78fbd88 100644
--- a/android/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -4,8 +4,8 @@
coreApp="true"
package="com.tencent.wstt.gt"
android:installLocation="auto"
- android:versionCode="22065"
- android:versionName="2.2.6.5" >
+ android:versionCode="22066"
+ android:versionName="2.2.6.6" >
-
0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- // 授权了就可以保存了,do nothing即可
- // 接收了危险权限后,再弹出悬浮窗处理特殊权限,这样还可以避过ACTION_MANAGE_OVERLAY_PERMISSION不支持API23之前的问题
- if (!isFloatViewAllowed)
- {
- requestAlertWindowPermission();
- }
- else if (!isWriteSettingAllowed)
- {
- // 在已获取AlertWindow权限的情况下,继续直接在这里判断WriteSetting权限
- requestWriteSettingPermission();
- }
- // 在授权后,需要将之前没权限创建的目录重新创建一次
- Env.init();
- } else {
- ToastUtil.ShowLongToast(GTApp.getContext(),
- "Permission not enough. Please consider granting it this permission.");
- }
- }
- }
- }
-
- @TargetApi(23)
- private void requestAlertWindowPermission() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- // 判断是否有SYSTEM_ALERT_WINDOW权限
- if(!Settings.canDrawOverlays(this)) {
- // 申请SYSTEM_ALERT_WINDOW权限
- Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
- Uri.parse("package:" + getPackageName()));
- try{
- startActivityForResult(intent, REQUEST_FLOAT_VIEW);
- }
- catch(Exception e)
- {
- // 有的定制系统会抛异常,这样的系统也不需要额外的悬浮窗授权
- }
- }
- }
- }
-
- @TargetApi(23)
- private void requestWriteSettingPermission() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- // 判断是否有WRITE_SETTINGS权限
- if(!Settings.System.canWrite(this)) {
- // 申请WRITE_SETTINGS权限
- Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS,
- Uri.parse("package:" + getPackageName()));
- try{
- startActivityForResult(intent, REQUEST_WRITE_SETTINGS);
- }
- catch(Exception e)
- {
- // 有的定制系统会抛异常,这样的系统也不需要额外的悬浮窗授权
- }
- }
- }
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- isActived = false;
- }
-
- @Override
- protected void onSaveInstanceState(Bundle savedInstanceState)
- {
- savedInstanceState.putInt("curTabId", curTabId);
- super.onSaveInstanceState(savedInstanceState);
- }
-
- /*
- * 在Activity重新加载时,要先清除遗留的Fragment
- */
- private void removeFragments() {
- FragmentManager fragmentManager = getSupportFragmentManager();
- FragmentTransaction transaction = fragmentManager.beginTransaction();
-
- Fragment fragment = fragmentManager.findFragmentByTag("a");
- if (fragment != null) {
- transaction.remove(fragment);
- }
- fragment = fragmentManager.findFragmentByTag("b");
- if (fragment != null) {
- transaction.remove(fragment);
- }
- fragment = fragmentManager.findFragmentByTag("c");
- if (fragment != null) {
- transaction.remove(fragment);
- }
- fragment = fragmentManager.findFragmentByTag("d");
- if (fragment != null) {
- transaction.remove(fragment);
- }
- fragment = fragmentManager.findFragmentByTag("e");
- if (fragment != null) {
- transaction.remove(fragment);
- }
- transaction.commitAllowingStateLoss();
- }
-
- /**
- * 在这里获取到每个需要用到的控件的实例,并给它们设置好必要的点击事件。
- */
- private void initViews() {
- autLayout = findViewById(R.id.aut_layout);
- paramLayout = findViewById(R.id.param_layout);
- perfLayout = findViewById(R.id.perf_layout);
- logLayout = findViewById(R.id.log_layout);
- pluginLayout = findViewById(R.id.plugin_layout);
-
- autImage = (ImageView) findViewById(R.id.aut_image);
- paramImage = (ImageView) findViewById(R.id.param_image);
- perfImage = (ImageView) findViewById(R.id.perf_image);
- logImage = (ImageView) findViewById(R.id.log_image);
- pluginImage = (ImageView) findViewById(R.id.plugin_image);
-
- autText = (TextView) findViewById(R.id.aut_text);
- paramText = (TextView) findViewById(R.id.param_text);
- perfText = (TextView) findViewById(R.id.perf_text);
- logText = (TextView) findViewById(R.id.log_text);
- pluginText = (TextView) findViewById(R.id.plugin_text);
-
- autLayout.setOnClickListener(this);
- paramLayout.setOnClickListener(this);
- perfLayout.setOnClickListener(this);
- logLayout.setOnClickListener(this);
- pluginLayout.setOnClickListener(this);
- }
-
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.aut_layout:
- curTabId = 0;
- setTabSelection(0);
- break;
- case R.id.param_layout:
- curTabId = 1;
- setTabSelection(1);
- break;
- case R.id.perf_layout:
- curTabId = 2;
- setTabSelection(2);
- break;
- case R.id.log_layout:
- curTabId = 3;
- setTabSelection(3);
- break;
- case R.id.plugin_layout:
- curTabId = 4;
- setTabSelection(4);
- break;
- default:
- break;
- }
- }
-
- /**
- * 根据传入的index参数来设置选中的tab页。
- *
- * @param index
- * 每个tab页对应的下标。
- */
- private synchronized void setTabSelection(int index) {
- // 每次选中之前先清楚掉上次的选中状态
- clearSelection();
- // 开启一个Fragment事务
- FragmentManager fragmentManager = getSupportFragmentManager();
- FragmentTransaction transaction = fragmentManager.beginTransaction();
- // 先隐藏掉所有的Fragment,以防止有多个Fragment显示在界面上的情况
- hideFragments(transaction); //TODO
-
- switch (index) {
- case 0:
- // 当点击了AUT tab时,改变控件的图片和文字颜色
- autImage.setImageResource(R.drawable.tab_selected_border);
- autText.setTextColor(Color.WHITE);
- if (autFragment == null) {
- autFragment = new GTAUTFragment();
- transaction.add(R.id.content, autFragment, "a");
- } else {
- transaction.show(autFragment);
- }
- break;
- case 1:
- // 当点击了参数 tab时,改变控件的图片和文字颜色
- paramImage.setImageResource(R.drawable.tab_selected_border);
- paramText.setTextColor(Color.WHITE);
- if (paramFragment == null) {
- paramFragment = new GTParamTopFragment();
- transaction.add(R.id.content, paramFragment, "b");
- } else {
- transaction.show(paramFragment);
- paramFragment.onShow(true);
- }
- break;
- case 2:
- // 当点击了耗时 tab时,改变控件的图片和文字颜色
- perfImage.setImageResource(R.drawable.tab_selected_border);
- perfText.setTextColor(Color.WHITE);
- if (perfFragment == null) {
- perfFragment = new GTPerfFragment();
- transaction.add(R.id.content, perfFragment, "c");
- } else {
- transaction.show(perfFragment);
- }
- break;
- case 3:
- // 当点击了日志 tab时,改变控件的图片和文字颜色
- logImage.setImageResource(R.drawable.tab_selected_border);
- logText.setTextColor(Color.WHITE);
- if (logFragment == null) {
- logFragment = new GTLogFragment();
- transaction.add(R.id.content, logFragment, "d");
- } else {
- transaction.show(logFragment);
- }
- break;
- case 4:
- default:
- // 当点击了插件 tab时,改变控件的图片和文字颜色
- pluginImage.setImageResource(R.drawable.tab_selected_border);
- pluginText.setTextColor(Color.WHITE);
- if (pluginFragment == null) {
- pluginFragment = new GTPluginFragment();
- transaction.add(R.id.content, pluginFragment, "e");
- } else {
- transaction.show(pluginFragment);
- }
- break;
- }
- /*
- * 直接使用commit()可能会出错:
- * IllegalStateException: Can not perform this action after onSaveInstanceState:\
- *
- * @see http://developer.android.com/reference/android/app/FragmentTransaction.html#commitAllowingStateLoss()
- *
- * 大致意思是说我使用的 commit方法是在Activity的onSaveInstanceState()之后调用的,这样会出错,因为onSaveInstanceState
- * 方法是在该Activity即将被销毁前调用,来保存Activity数据的,如果在保存玩状态后再给它添加Fragment就会出错。解决办法就
- * 是把commit()方法替换成 commitAllowingStateLoss()就行了,其效果是一样的。
- */
- // transaction.commit();
- transaction.commitAllowingStateLoss();
- }
-
- /**
- * 清除掉所有的选中状态。
- */
- private void clearSelection() {
- int defaultColor = getResources().getColor(R.color.tab_default_textcolor);
- autImage.setImageResource(R.drawable.tab_default_border);
- autText.setTextColor(defaultColor);
- paramImage.setImageResource(R.drawable.tab_default_border);
- paramText.setTextColor(defaultColor);
- perfImage.setImageResource(R.drawable.tab_default_border);
- perfText.setTextColor(defaultColor);
- logImage.setImageResource(R.drawable.tab_default_border);
- logText.setTextColor(defaultColor);
- pluginImage.setImageResource(R.drawable.tab_default_border);
- pluginText.setTextColor(defaultColor);
- }
-
- /**
- * 将所有的Fragment都置为隐藏状态。
- *
- * @param transaction
- * 用于对Fragment执行操作的事务
- */
- private void hideFragments(FragmentTransaction transaction) {
- if (autFragment != null) {
- transaction.hide(autFragment);
- }
- if (paramFragment != null) {
- paramFragment.onShow(false);
- transaction.hide(paramFragment);
- }
- if (perfFragment != null) {
- transaction.hide(perfFragment);
- }
- if (logFragment != null) {
- transaction.hide(logFragment);
- }
- if (pluginFragment != null) {
- transaction.hide(pluginFragment);
- }
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK){
- dlgIsShow = false;
-
- moveTaskToBack(true);
- return true;
- }
- return super.onKeyDown(keyCode, event);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- int item_id = item.getItemId();
- Intent intent = null;
-
- switch (item_id) {
- case R.id.exit:
- GTApp.exitGT();
- break;
- case R.id.log_switch:
- intent = new Intent(this, GTLogSwitchActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- break;
- case R.id.air_console:
- intent = new Intent(this, GTACSettingActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- break;
- case R.id.intervals:
- intent = new Intent(this, GTIntervalSettingActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- break;
- case R.id.about:
- intent = new Intent(this, GTAboutActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- break;
- }
-
- return false;
- }
-
- /* 进行验证码验证,或者进行快速登录的回调,这两个是进行快速登录可能遇到的情况 */
- @Override
- @TargetApi(23) // 目前api23以下都不可能触发REQUEST_FLOAT_VIEW和REQUEST_WRITE_SETTINGS这俩分支
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- switch (requestCode) {
- case REQUEST_FLOAT_VIEW:
- // 判断是否有SYSTEM_ALERT_WINDOW权限
- if(Settings.canDrawOverlays(this)) {
- // 得到权限,置标志位,相应的提示用户重启GT等
- isFloatViewAllowed = true;
- GTPref.getGTPref().edit().putBoolean(GTPref.FLOAT_ALLOWED, true).commit();
-
- // 因为授权之前的启动悬浮窗会报异常关闭,所以这里重新启动悬浮窗服务
- if ( GTPref.getGTPref().getBoolean(GTPref.AC_SWITCH_FLAG, true))
- {
- Intent intent = new Intent(this, GTLogo.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startService(intent);
-
- Intent mintent = new Intent(this, GTFloatView.class);
- mintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startService(mintent);
- }
- }
- else
- {
- isFloatViewAllowed = false;
- GTPref.getGTPref().edit().putBoolean(GTPref.FLOAT_ALLOWED, false).commit();
- }
-
- // 为了设计简单点,这里在悬浮窗权限通过后才继续进行WriteSetting权限的申请
- if (!isWriteSettingAllowed)
- {
- requestWriteSettingPermission();
- }
- break;
- case REQUEST_WRITE_SETTINGS:
- if(Settings.System.canWrite(this)) {
- isWriteSettingAllowed = true;
- GTPref.getGTPref().edit().putBoolean(GTPref.WRITE_SETTINGS, true).commit();
- }
- else
- {
- isWriteSettingAllowed = false;
- GTPref.getGTPref().edit().putBoolean(GTPref.WRITE_SETTINGS, false).commit();
- }
- break;
- default:
- break;
- }
- }
-}
+/*
+ * Tencent is pleased to support the open source community by making
+ * Tencent GT (Version 2.4 and subsequent versions) available.
+ *
+ * Notwithstanding anything to the contrary herein, any previous version
+ * of Tencent GT shall not be subject to the license hereunder.
+ * All right, title, and interest, including all intellectual property rights,
+ * in and to the previous version of Tencent GT (including any and all copies thereof)
+ * shall be owned and retained by Tencent and subject to the license under the
+ * Tencent GT End User License Agreement (http://gt.qq.com/wp-content/EULA_EN.html).
+ *
+ * Copyright (C) 2015 THL A29 Limited, a Tencent company. All rights reserved.
+ *
+ * Licensed under the MIT License (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://opensource.org/licenses/MIT
+ *
+ * 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.tencent.wstt.gt.activity;
+
+import com.tencent.wstt.gt.GTApp;
+import com.tencent.wstt.gt.R;
+import com.tencent.wstt.gt.api.utils.Env;
+import com.tencent.wstt.gt.dao.GTPref;
+import com.tencent.wstt.gt.service.GTFloatView;
+import com.tencent.wstt.gt.service.GTLogo;
+import com.tencent.wstt.gt.utils.ToastUtil;
+
+import android.Manifest;
+import android.annotation.TargetApi;
+import android.app.Notification;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.support.v4.content.ContextCompat;
+import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+public class GTMainActivity extends GTBaseFragmentActivity implements OnClickListener {
+
+ // Android6.x之后,需要由用户明确授权的权限,放在MainActivity里提前做申请交互
+ private static final int REQUEST_NEED_PERMISSION = 101;
+ // 悬浮窗的权限是特殊权限,需要单独处理
+ private static final int REQUEST_FLOAT_VIEW = 102;
+ private static boolean isFloatViewAllowed = GTPref.getGTPref().getBoolean(GTPref.FLOAT_ALLOWED, false);
+
+ // 电量测试需要的WRITE_SETTINGS的权限是特殊权限,需要单独处理
+ private static final int REQUEST_WRITE_SETTINGS = 103;
+ private static boolean isWriteSettingAllowed = GTPref.getGTPref().getBoolean(GTPref.WRITE_SETTINGS, false);
+
+ // 页面碎片对象
+ private GTAUTFragment autFragment;
+ private GTParamTopFragment paramFragment;
+ private GTPerfFragment perfFragment;
+ private GTLogFragment logFragment;
+ private GTPluginFragment pluginFragment;
+
+ // 页面布局
+ private View autLayout;
+ private View paramLayout;
+ private View perfLayout;
+ private View logLayout;
+ private View pluginLayout;
+
+ // 在Tab布局上显示的图标的控件
+ private ImageView autImage;
+ private ImageView paramImage;
+ private ImageView perfImage;
+ private ImageView logImage;
+ private ImageView pluginImage;
+
+ private TextView autText;
+ private TextView paramText;
+ private TextView perfText;
+ private TextView logText;
+ private TextView pluginText;
+
+ public static boolean isActived = false;
+ public static Notification notification;
+ public static boolean dlgIsShow = false;
+
+ private int curTabId;
+
+ private static GTMainActivity instance;
+ public static GTMainActivity getInstance() {
+ return instance;
+ }
+
+ public GTMainActivity()
+ {
+ instance = this;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.gt_activity_main);
+ // 初始化布局元素
+ initViews();
+
+ // 重新初始化各页
+ removeFragments();
+
+ // 第一次启动时选中第0个tab
+ if (savedInstanceState != null)
+ {
+ setTabSelection(savedInstanceState.getInt("curTabId"));
+ }
+ else
+ {
+ setTabSelection(0);
+ }
+ isActived = true;
+
+ boolean hasPermission = (ContextCompat.checkSelfPermission(this,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
+
+ hasPermission = hasPermission && (ContextCompat.checkSelfPermission(this,
+ Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED);
+
+ hasPermission = hasPermission && (ContextCompat.checkSelfPermission(this,
+ Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED);
+
+ if (!hasPermission) {
+ ActivityCompat.requestPermissions(
+ this,
+ new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE,
+ Manifest.permission.ACCESS_FINE_LOCATION,
+ Manifest.permission.READ_PHONE_STATE},
+ REQUEST_NEED_PERMISSION);
+ }
+ else // 若前三个已赋予,则只判断悬浮窗权限和WriteSetting权限
+ {
+ requestAlertWindowPermission();
+ }
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+ switch (requestCode) {
+ case REQUEST_NEED_PERMISSION: {
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ // 授权了就可以保存了,do nothing即可
+ // 接收了危险权限后,再弹出悬浮窗处理特殊权限,这样还可以避过ACTION_MANAGE_OVERLAY_PERMISSION不支持API23之前的问题
+ if (!isFloatViewAllowed)
+ {
+ requestAlertWindowPermission();
+ }
+ else if (!isWriteSettingAllowed)
+ {
+ // 在已获取AlertWindow权限的情况下,继续直接在这里判断WriteSetting权限
+ requestWriteSettingPermission();
+ }
+ // 在授权后,需要将之前没权限创建的目录重新创建一次
+ Env.init();
+ } else {
+ ToastUtil.ShowLongToast(GTApp.getContext(),
+ "Permission not enough. Please consider granting it this permission.");
+ }
+ }
+ }
+ }
+
+ @TargetApi(23)
+ private void requestAlertWindowPermission() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ // 判断是否有SYSTEM_ALERT_WINDOW权限
+ if(!Settings.canDrawOverlays(this)) {
+ // 申请SYSTEM_ALERT_WINDOW权限
+ Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
+ Uri.parse("package:" + getPackageName()));
+ try{
+ startActivityForResult(intent, REQUEST_FLOAT_VIEW);
+ }
+ catch(Exception e)
+ {
+ // 有的定制系统会抛异常,这样的系统也不需要额外的悬浮窗授权
+ }
+ }
+ }
+ }
+
+ @TargetApi(23)
+ private void requestWriteSettingPermission() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ // 判断是否有WRITE_SETTINGS权限
+ if(!Settings.System.canWrite(this)) {
+ // 申请WRITE_SETTINGS权限
+ Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS,
+ Uri.parse("package:" + getPackageName()));
+ try{
+ startActivityForResult(intent, REQUEST_WRITE_SETTINGS);
+ }
+ catch(Exception e)
+ {
+ // 有的定制系统会抛异常,这样的系统也不需要额外的悬浮窗授权
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ isActived = false;
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle savedInstanceState)
+ {
+ savedInstanceState.putInt("curTabId", curTabId);
+ super.onSaveInstanceState(savedInstanceState);
+ }
+
+ /*
+ * 在Activity重新加载时,要先清除遗留的Fragment
+ */
+ private void removeFragments() {
+ FragmentManager fragmentManager = getSupportFragmentManager();
+ FragmentTransaction transaction = fragmentManager.beginTransaction();
+
+ Fragment fragment = fragmentManager.findFragmentByTag("a");
+ if (fragment != null) {
+ transaction.remove(fragment);
+ }
+ fragment = fragmentManager.findFragmentByTag("b");
+ if (fragment != null) {
+ transaction.remove(fragment);
+ }
+ fragment = fragmentManager.findFragmentByTag("c");
+ if (fragment != null) {
+ transaction.remove(fragment);
+ }
+ fragment = fragmentManager.findFragmentByTag("d");
+ if (fragment != null) {
+ transaction.remove(fragment);
+ }
+ fragment = fragmentManager.findFragmentByTag("e");
+ if (fragment != null) {
+ transaction.remove(fragment);
+ }
+ transaction.commitAllowingStateLoss();
+ }
+
+ /**
+ * 在这里获取到每个需要用到的控件的实例,并给它们设置好必要的点击事件。
+ */
+ private void initViews() {
+ autLayout = findViewById(R.id.aut_layout);
+ paramLayout = findViewById(R.id.param_layout);
+ perfLayout = findViewById(R.id.perf_layout);
+ logLayout = findViewById(R.id.log_layout);
+ pluginLayout = findViewById(R.id.plugin_layout);
+
+ autImage = (ImageView) findViewById(R.id.aut_image);
+ paramImage = (ImageView) findViewById(R.id.param_image);
+ perfImage = (ImageView) findViewById(R.id.perf_image);
+ logImage = (ImageView) findViewById(R.id.log_image);
+ pluginImage = (ImageView) findViewById(R.id.plugin_image);
+
+ autText = (TextView) findViewById(R.id.aut_text);
+ paramText = (TextView) findViewById(R.id.param_text);
+ perfText = (TextView) findViewById(R.id.perf_text);
+ logText = (TextView) findViewById(R.id.log_text);
+ pluginText = (TextView) findViewById(R.id.plugin_text);
+
+ autLayout.setOnClickListener(this);
+ paramLayout.setOnClickListener(this);
+ perfLayout.setOnClickListener(this);
+ logLayout.setOnClickListener(this);
+ pluginLayout.setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.aut_layout:
+ curTabId = 0;
+ setTabSelection(0);
+ break;
+ case R.id.param_layout:
+ curTabId = 1;
+ setTabSelection(1);
+ break;
+ case R.id.perf_layout:
+ curTabId = 2;
+ setTabSelection(2);
+ break;
+ case R.id.log_layout:
+ curTabId = 3;
+ setTabSelection(3);
+ break;
+ case R.id.plugin_layout:
+ curTabId = 4;
+ setTabSelection(4);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * 根据传入的index参数来设置选中的tab页。
+ *
+ * @param index
+ * 每个tab页对应的下标。
+ */
+ private synchronized void setTabSelection(int index) {
+ // 每次选中之前先清楚掉上次的选中状态
+ clearSelection();
+ // 开启一个Fragment事务
+ FragmentManager fragmentManager = getSupportFragmentManager();
+ FragmentTransaction transaction = fragmentManager.beginTransaction();
+ // 先隐藏掉所有的Fragment,以防止有多个Fragment显示在界面上的情况
+ hideFragments(transaction); //TODO
+
+ switch (index) {
+ case 0:
+ // 当点击了AUT tab时,改变控件的图片和文字颜色
+ autImage.setImageResource(R.drawable.tab_selected_border);
+ autText.setTextColor(Color.WHITE);
+ if (autFragment == null) {
+ autFragment = new GTAUTFragment();
+ transaction.add(R.id.content, autFragment, "a");
+ } else {
+ transaction.show(autFragment);
+ }
+ break;
+ case 1:
+ // 当点击了参数 tab时,改变控件的图片和文字颜色
+ paramImage.setImageResource(R.drawable.tab_selected_border);
+ paramText.setTextColor(Color.WHITE);
+ if (paramFragment == null) {
+ paramFragment = new GTParamTopFragment();
+ transaction.add(R.id.content, paramFragment, "b");
+ } else {
+ transaction.show(paramFragment);
+ paramFragment.onShow(true);
+ }
+ break;
+ case 2:
+ // 当点击了耗时 tab时,改变控件的图片和文字颜色
+ perfImage.setImageResource(R.drawable.tab_selected_border);
+ perfText.setTextColor(Color.WHITE);
+ if (perfFragment == null) {
+ perfFragment = new GTPerfFragment();
+ transaction.add(R.id.content, perfFragment, "c");
+ } else {
+ transaction.show(perfFragment);
+ }
+ break;
+ case 3:
+ // 当点击了日志 tab时,改变控件的图片和文字颜色
+ logImage.setImageResource(R.drawable.tab_selected_border);
+ logText.setTextColor(Color.WHITE);
+ if (logFragment == null) {
+ logFragment = new GTLogFragment();
+ transaction.add(R.id.content, logFragment, "d");
+ } else {
+ transaction.show(logFragment);
+ }
+ break;
+ case 4:
+ default:
+ // 当点击了插件 tab时,改变控件的图片和文字颜色
+ pluginImage.setImageResource(R.drawable.tab_selected_border);
+ pluginText.setTextColor(Color.WHITE);
+ if (pluginFragment == null) {
+ pluginFragment = new GTPluginFragment();
+ transaction.add(R.id.content, pluginFragment, "e");
+ } else {
+ transaction.show(pluginFragment);
+ }
+ break;
+ }
+ /*
+ * 直接使用commit()可能会出错:
+ * IllegalStateException: Can not perform this action after onSaveInstanceState:\
+ *
+ * @see http://developer.android.com/reference/android/app/FragmentTransaction.html#commitAllowingStateLoss()
+ *
+ * 大致意思是说我使用的 commit方法是在Activity的onSaveInstanceState()之后调用的,这样会出错,因为onSaveInstanceState
+ * 方法是在该Activity即将被销毁前调用,来保存Activity数据的,如果在保存玩状态后再给它添加Fragment就会出错。解决办法就
+ * 是把commit()方法替换成 commitAllowingStateLoss()就行了,其效果是一样的。
+ */
+ // transaction.commit();
+ transaction.commitAllowingStateLoss();
+ }
+
+ /**
+ * 清除掉所有的选中状态。
+ */
+ private void clearSelection() {
+ int defaultColor = getResources().getColor(R.color.tab_default_textcolor);
+ autImage.setImageResource(R.drawable.tab_default_border);
+ autText.setTextColor(defaultColor);
+ paramImage.setImageResource(R.drawable.tab_default_border);
+ paramText.setTextColor(defaultColor);
+ perfImage.setImageResource(R.drawable.tab_default_border);
+ perfText.setTextColor(defaultColor);
+ logImage.setImageResource(R.drawable.tab_default_border);
+ logText.setTextColor(defaultColor);
+ pluginImage.setImageResource(R.drawable.tab_default_border);
+ pluginText.setTextColor(defaultColor);
+ }
+
+ /**
+ * 将所有的Fragment都置为隐藏状态。
+ *
+ * @param transaction
+ * 用于对Fragment执行操作的事务
+ */
+ private void hideFragments(FragmentTransaction transaction) {
+ if (autFragment != null) {
+ transaction.hide(autFragment);
+ }
+ if (paramFragment != null) {
+ paramFragment.onShow(false);
+ transaction.hide(paramFragment);
+ }
+ if (perfFragment != null) {
+ transaction.hide(perfFragment);
+ }
+ if (logFragment != null) {
+ transaction.hide(logFragment);
+ }
+ if (pluginFragment != null) {
+ transaction.hide(pluginFragment);
+ }
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK){
+ dlgIsShow = false;
+
+ moveTaskToBack(true);
+ return true;
+ }
+ return super.onKeyDown(keyCode, event);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ int item_id = item.getItemId();
+ Intent intent = null;
+
+ switch (item_id) {
+ case R.id.exit:
+ GTApp.exitGT();
+ break;
+ case R.id.log_switch:
+ intent = new Intent(this, GTLogSwitchActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent);
+ break;
+ case R.id.air_console:
+ intent = new Intent(this, GTACSettingActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent);
+ break;
+ case R.id.intervals:
+ intent = new Intent(this, GTIntervalSettingActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent);
+ break;
+ case R.id.about:
+ intent = new Intent(this, GTAboutActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent);
+ break;
+ }
+
+ return false;
+ }
+
+ /* 进行验证码验证,或者进行快速登录的回调,这两个是进行快速登录可能遇到的情况 */
+ @Override
+ @TargetApi(23) // 目前api23以下都不可能触发REQUEST_FLOAT_VIEW和REQUEST_WRITE_SETTINGS这俩分支
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ switch (requestCode) {
+ case REQUEST_FLOAT_VIEW:
+ // 判断是否有SYSTEM_ALERT_WINDOW权限
+ if(Settings.canDrawOverlays(this)) {
+ // 得到权限,置标志位,相应的提示用户重启GT等
+ isFloatViewAllowed = true;
+ GTPref.getGTPref().edit().putBoolean(GTPref.FLOAT_ALLOWED, true).commit();
+
+ // 因为授权之前的启动悬浮窗会报异常关闭,所以这里重新启动悬浮窗服务
+ if ( GTPref.getGTPref().getBoolean(GTPref.AC_SWITCH_FLAG, true))
+ {
+ Intent intent = new Intent(this, GTLogo.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startService(intent);
+
+ Intent mintent = new Intent(this, GTFloatView.class);
+ mintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startService(mintent);
+ }
+ }
+ else
+ {
+ isFloatViewAllowed = false;
+ GTPref.getGTPref().edit().putBoolean(GTPref.FLOAT_ALLOWED, false).commit();
+ }
+
+ // 为了设计简单点,这里在悬浮窗权限通过后才继续进行WriteSetting权限的申请
+ if (!isWriteSettingAllowed)
+ {
+ requestWriteSettingPermission();
+ }
+ break;
+ case REQUEST_WRITE_SETTINGS:
+ if(Settings.System.canWrite(this)) {
+ isWriteSettingAllowed = true;
+ GTPref.getGTPref().edit().putBoolean(GTPref.WRITE_SETTINGS, true).commit();
+ }
+ else
+ {
+ isWriteSettingAllowed = false;
+ GTPref.getGTPref().edit().putBoolean(GTPref.WRITE_SETTINGS, false).commit();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+}
diff --git a/android/src/com/tencent/wstt/gt/activity/GTOpMulPerfActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTOpMulPerfActivity.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTOpMulPerfActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTOpMulPerfActivity.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTOpSMActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTOpSMActivity.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTOpSMActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTOpSMActivity.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTOpSinglePerfActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTOpSinglePerfActivity.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTOpSinglePerfActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTOpSinglePerfActivity.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTParamInEditFragment.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamInEditFragment.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTParamInEditFragment.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamInEditFragment.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTParamInEditListAdapter.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamInEditListAdapter.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTParamInEditListAdapter.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamInEditListAdapter.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTParamInFragment.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamInFragment.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTParamInFragment.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamInFragment.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTParamInListAdapter.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamInListAdapter.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTParamInListAdapter.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamInListAdapter.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTParamListBaseAdapter.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamListBaseAdapter.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTParamListBaseAdapter.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamListBaseAdapter.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTParamOutEditFragment.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamOutEditFragment.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTParamOutEditFragment.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamOutEditFragment.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTParamOutEditListAdapter.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamOutEditListAdapter.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTParamOutEditListAdapter.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamOutEditListAdapter.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTParamOutFragment.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamOutFragment.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTParamOutFragment.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamOutFragment.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTParamOutListAdapter.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamOutListAdapter.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTParamOutListAdapter.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamOutListAdapter.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTParamTopFragment.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamTopFragment.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTParamTopFragment.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTParamTopFragment.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTPerfFragment.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTPerfFragment.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTPerfFragment.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTPerfFragment.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTPerfGroupDetailActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTPerfGroupDetailActivity.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTPerfGroupDetailActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTPerfGroupDetailActivity.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTPluginFragment.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTPluginFragment.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTPluginFragment.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTPluginFragment.java
diff --git a/android/src/com/tencent/wstt/gt/activity/GTShowPackageActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/GTShowPackageActivity.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/GTShowPackageActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/GTShowPackageActivity.java
diff --git a/android/src/com/tencent/wstt/gt/activity/ShowhtmlActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/ShowhtmlActivity.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/ShowhtmlActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/ShowhtmlActivity.java
diff --git a/android/src/com/tencent/wstt/gt/activity/SplashActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/SplashActivity.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/SplashActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/SplashActivity.java
diff --git a/android/src/com/tencent/wstt/gt/activity/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/activity/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/activity/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/activity/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/api/base/GTLog.java b/android/app/src/main/java/com/tencent/wstt/gt/api/base/GTLog.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/base/GTLog.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/base/GTLog.java
diff --git a/android/src/com/tencent/wstt/gt/api/base/GTTime.java b/android/app/src/main/java/com/tencent/wstt/gt/api/base/GTTime.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/base/GTTime.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/base/GTTime.java
diff --git a/android/src/com/tencent/wstt/gt/api/base/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/api/base/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/base/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/base/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/BatteryUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/BatteryUtils.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/BatteryUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/BatteryUtils.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/CMDExecute.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/CMDExecute.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/CMDExecute.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/CMDExecute.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/Constant.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/Constant.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/Constant.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/Constant.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/CpuUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/CpuUtils.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/CpuUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/CpuUtils.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/DeviceUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/DeviceUtils.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/DeviceUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/DeviceUtils.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/DumpsysMemInfoPkgParseUtil.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/DumpsysMemInfoPkgParseUtil.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/DumpsysMemInfoPkgParseUtil.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/DumpsysMemInfoPkgParseUtil.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/Env.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/Env.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/Env.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/Env.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/FpsTimerTask.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/FpsTimerTask.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/FpsTimerTask.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/FpsTimerTask.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/MemFillTool.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/MemFillTool.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/MemFillTool.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/MemFillTool.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/MemUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/MemUtils.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/MemUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/MemUtils.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/NetUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/NetUtils.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/NetUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/NetUtils.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/ProcessUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/ProcessUtils.java
similarity index 96%
rename from android/src/com/tencent/wstt/gt/api/utils/ProcessUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/ProcessUtils.java
index a9477ed..0025a71 100644
--- a/android/src/com/tencent/wstt/gt/api/utils/ProcessUtils.java
+++ b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/ProcessUtils.java
@@ -1,787 +1,787 @@
-/*
- * Tencent is pleased to support the open source community by making
- * Tencent GT (Version 2.4 and subsequent versions) available.
- *
- * Notwithstanding anything to the contrary herein, any previous version
- * of Tencent GT shall not be subject to the license hereunder.
- * All right, title, and interest, including all intellectual property rights,
- * in and to the previous version of Tencent GT (including any and all copies thereof)
- * shall be owned and retained by Tencent and subject to the license under the
- * Tencent GT End User License Agreement (http://gt.qq.com/wp-content/EULA_EN.html).
- *
- * Copyright (C) 2015 THL A29 Limited, a Tencent company. All rights reserved.
- *
- * Licensed under the MIT License (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://opensource.org/licenses/MIT
- *
- * 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.tencent.wstt.gt.api.utils;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import com.tencent.wstt.gt.GTApp;
-import com.tencent.wstt.gt.utils.FileUtil;
-import com.tencent.wstt.gt.utils.StringUtil;
-import com.tencent.wstt.gt.utils.ToastUtil;
-
-import android.app.ActivityManager;
-import android.app.ActivityManager.RunningAppProcessInfo;
-import android.content.Context;
-import android.util.SparseArray;
-
-/**
- * 进程信息工具类。
- */
-public class ProcessUtils {
-
- private static IProcess processUtil;
-
- /**
- * 根据手机系统的版本号,适配ProcessUtils的实现,全局调用一次即可。
- * Android4.x及以下系统,用老的方式效率更高。
- * Android5.x及以上系统,用shell命令方式。
- */
- synchronized public static void init()
- {
- if (Env.API < 21)
- {
- processUtil = new Process4x();
- }
- else if (Env.API < 23) // 5.x+
- {
- processUtil = new Process5x();
- }
- else // 6.x+
- {
- processUtil = new Process6x();
- }
- }
-
- public static String getPackageByUid(int uid)
- {
- return processUtil.getPackageByUid(uid);
- }
-
- /*
- * 在选择被测应用后应该更新,包括广播和sdk自动化中,注意广播和sdk自动化中执行su操作有风险
- */
- public static boolean initUidPkgCache()
- {
- return processUtil.initUidPkgCache();
- }
-
- /**
- * 是否至少有一个进程在运行指定包名的应用程序
- *
- * @param pkgName
- * 指定的包名
- * @return 是否至少有一个进程在运行指定包名的应用程序
- */
- public static boolean hasProcessRunPkg(String pkgName) {
- return processUtil.hasProcessRunPkg(pkgName);
- }
-
- /**
- * 根据进程名,获取进程UID,反查UID,性能需要高
- *
- * 当前进程的上下文环境
- * @param pName
- * 进程名
- * @return 进程UID
- */
- public static int getProcessUID(String pName) {
- return processUtil.getProcessUID(pName);
- }
-
- /**
- * 根据进程名,获取进程PID
- *
- * 当前进程的上下文环境
- * @param pName
- * 进程名
- * @return 进程PID
- */
- public static int getProcessPID(String pName) {
- return processUtil.getProcessPID(pName);
- }
-
- /**
- * 判断进程是否在运行。
- *
- * @param sPid
- * 进程号
- * @return true 正在运行;false 停止运行
- */
- public static boolean isProcessAlive(String sPid) {
- return processUtil.isProcessAlive(sPid);
- }
-
- public static List getAllRunningAppProcessInfo() {
- return processUtil.getAllRunningAppProcessInfo();
- }
-
- public static void killprocess(String proc, int cmd) {
- processUtil.killprocess(proc, cmd);
- }
-
- private static void killprocessNormal(String proc, int killMethod) {
- try {
- ArrayList pid_list = new ArrayList();
-
- ProcessBuilder execBuilder = null;
-
- execBuilder = new ProcessBuilder("sh", "-c", "ps |grep " + proc);
-
- execBuilder.redirectErrorStream(true);
-
- Process exec = null;
- exec = execBuilder.start();
- InputStream is = exec.getInputStream();
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
-
- String line = "";
- while ((line = reader.readLine()) != null) {
- String regEx = "\\s[0-9][0-9]*\\s";
- Pattern pat = Pattern.compile(regEx);
- Matcher mat = pat.matcher(line);
- if (mat.find()) {
- String temp = mat.group();
- temp = temp.replaceAll("\\s", "");
- pid_list.add(temp);
- }
- }
-
- for (int i = 0; i < pid_list.size(); i++) {
- execBuilder = new ProcessBuilder("su", "-c", "kill", "-" + killMethod, pid_list.get(i));
- exec = null;
- exec = execBuilder.start();
-
- execBuilder = new ProcessBuilder("su", "-c", "kill" + " -" + killMethod + " " + pid_list.get(i));
- exec = null;
- exec = execBuilder.start();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public static class ProcessInfo
- {
- public String name; // 进程名
- public int pid; // PID
- public int ppid; // 父PID
- public int uid; // UID
-
- public ProcessInfo(int pid, String name, int ppid, int uid)
- {
- this.pid = pid;
- this.name = name;
- this.ppid = ppid;
- this.uid = uid;
- }
-
- @Override
- public int hashCode()
- {
- int result = 17;
- if (name != null)
- result = 37 * result + name.hashCode();
- result = 37 * result + (int) (pid ^ (pid >>> 32));
- result = 37 * result + (int) (ppid ^ (ppid >>> 32));
- result = 37 * result + (int) (uid ^ (uid >>> 32));
- return result;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o instanceof ProcessInfo)
- {
- ProcessInfo another = (ProcessInfo)o;
- if (this.pid == another.pid
- && this.ppid == another.ppid
- && this.name != null
- && another.name != null
- && this.name.equals(another.name))
- {
- return true;
- }
- }
- return false;
- }
- }
-
- static interface IProcess {
- List getAllRunningAppProcessInfo();
- String getPackageByUid(int uid);
- int getProcessPID(String pName);
- int getProcessUID(String pName);
- boolean hasProcessRunPkg(String pkgName);
- boolean isProcessAlive(String sPid);
- void killprocess(String proc, int cmd);
- boolean initUidPkgCache();
- }
-
- static class Process5x implements IProcess
- {
- private boolean isRootcheckedResult = true;
-
- private Map procInfoCache =
- new HashMap();
- // uid和package的对应
- private SparseArray uidPkgCache = null;
-
- private SparseArray getUidPkgCache()
- {
- return uidPkgCache;
- }
-
- @Override
- public List getAllRunningAppProcessInfo() {
- List appProcessList = new ArrayList();
-
- // 先取Android进程的父进程zygote的进程号,64位app对应的是zygote64
- int zygotePid = -1;
- int zygotePid64 = -1;
-
- /*
- * 如果使用了较新版本的root权限控制工具,ps命令会看不到zygote进程,这时需要用su命令
- */
- boolean needRoot = true;
-
- // 先尝试sh命令
- BufferedReader readerZ = null;
- try {
- ProcessBuilder execBuilderZ = null;
- execBuilderZ = new ProcessBuilder("sh", "-c", "ps |grep zygote");
- execBuilderZ.redirectErrorStream(true);
- Process execZ = execBuilderZ.start();
- InputStream isZ = execZ.getInputStream();
- readerZ = new BufferedReader(
- new InputStreamReader(isZ));
- String lineZ = "";
-
- while ((lineZ = readerZ.readLine()) != null) {
- needRoot = false;
- String[] arrayZ = lineZ.trim().split("\\s+");
- if (arrayZ.length >= 9) {
- if (arrayZ[8].equals("zygote"))
- {
- zygotePid = Integer.parseInt(arrayZ[1]);
- }
- else if (arrayZ[8].equals("zygote64"))
- {
- zygotePid64 = Integer.parseInt(arrayZ[1]);
- }
- }
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- } finally {
- FileUtil.closeReader(readerZ);
- }
-
- /*
- * sh若搞不定,改用su权限执行ps命令
- */
- if (needRoot)
- {
- try {
- ProcessBuilder execBuilderZ = null;
- execBuilderZ = new ProcessBuilder("su", "-c", "ps |grep zygote");
- execBuilderZ.redirectErrorStream(true);
- Process execZ = execBuilderZ.start();
- InputStream isZ = execZ.getInputStream();
- readerZ = new BufferedReader(
- new InputStreamReader(isZ));
- String lineZ = "";
-
- while ((lineZ = readerZ.readLine()) != null) {
- String[] arrayZ = lineZ.trim().split("\\s+");
- if (arrayZ.length >= 9) {
- if (arrayZ[8].equals("zygote"))
- {
- zygotePid = Integer.parseInt(arrayZ[1]);
- }
- else if (arrayZ[8].equals("zygote64"))
- {
- zygotePid64 = Integer.parseInt(arrayZ[1]);
- }
- }
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- } finally {
- FileUtil.closeReader(readerZ);
- }
- }
-
- if (zygotePid < 0)
- {
- return appProcessList;
- }
-
- // 正式取可用的Android进程,前面不管是sh还是su搞定的,这里都用sh即可。
- BufferedReader reader = null;
- try {
- ProcessBuilder execBuilder = null;
- execBuilder = new ProcessBuilder("sh", "-c", "ps |grep u0_a");
- execBuilder.redirectErrorStream(true);
- Process exec = null;
- exec = execBuilder.start();
- InputStream is = exec.getInputStream();
- reader = new BufferedReader(
- new InputStreamReader(is));
-
- String line = "";
- while ((line = reader.readLine()) != null) {
- String[] array = line.trim().split("\\s+");
- if (array.length >= 9) {
- int uid = Integer.parseInt(array[0].substring(4)) + 10000;
- int pid = Integer.parseInt(array[1]);
- int ppid = Integer.parseInt(array[2]);
- // 过滤掉系统子进程,只留下父进程是zygote的进程
- if (ppid == zygotePid || ppid == zygotePid64)
- {
- ProcessInfo pi = new ProcessInfo(pid, array[8], ppid, uid);
- appProcessList.add(pi);
- procInfoCache.put(array[8], pi);
- }
-
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- finally
- {
- FileUtil.closeReader(reader);
- }
-
- return appProcessList;
- }
-
- @Override
- public String getPackageByUid(int uid) {
- if (uidPkgCache == null)
- {
- initUidPkgCache();
- }
- return uidPkgCache.get(uid);
- }
-
- @Override
- public int getProcessPID(String pName) {
- int pId = -1;
- List appProcessInfos = getAllRunningAppProcessInfo();
- for (ProcessInfo info : appProcessInfos) {
- if (info.name.equals(pName)) {
- pId = info.pid;
- break;
- }
- }
- return pId;
- }
-
- @Override
- public int getProcessUID(String pName) {
- int uId = 0;
- if (procInfoCache.isEmpty())
- {
- List appProcessInfos = getAllRunningAppProcessInfo();
-
- for (ProcessInfo pi : appProcessInfos) {
- if (pi.name.equals(pName)) {
-
- uId = pi.uid;
- break;
- }
- }
- }
- else // uid和pName都不会变,所以从缓存查
- {
- ProcessInfo pi = procInfoCache.get(pName);
- /*
- * 但是有初始记录的进程并不是主进程的情况,比如:
- * 微信往往是com.tencent.mm:push进程活着,而com.tencent.mm进程初始是不在的
- * 此时需要找与com.tencent.mm相似的com.tencent.mm:push进程信息作为替代
- */
- if (pi == null)
- {
- for (ProcessInfo tpi : procInfoCache.values())
- {
- if (tpi.name.startsWith(pName))
- {
- pi = tpi;
- procInfoCache.put(pName, pi);
- break;
- }
- }
- }
- uId = pi == null ? -1 : pi.uid;
- }
- return uId;
- }
-
- @Override
- public boolean hasProcessRunPkg(String pkgName) {
- if (pkgName == null) return false;
- int uid = -1;
-
- int len = getUidPkgCache().size();
- // 如果是没有root过的手机,uidPkgCache是空的,采用替代方案,但对于进程命名中不包括包名的没有办法
- if (len != 0)
- {
- for (int i = 0; i < len; i++)
- {
- if (pkgName.equals(getUidPkgCache().valueAt(i)))
- {
- uid = getUidPkgCache().keyAt(i);
- break;
- }
- }
-
- if (uid == -1) return false;
- List appProcessInfos = getAllRunningAppProcessInfo();
- for (ProcessInfo info : appProcessInfos) {
- if (info.uid == uid)
- {
- return true;
- }
- }
- return false;
- }
- else // 替代方案
- {
- List appProcessInfos = getAllRunningAppProcessInfo();
- for (ProcessInfo info : appProcessInfos) {
- if (info.name.contains(pkgName))
- {
- return true;
- }
- }
- return false;
- }
- }
-
- @Override
- public boolean isProcessAlive(String sPid) {
- boolean isAlive = false;
- if (sPid != null) {
- // 采用进入目录的方式判断会比较快
- BufferedReader reader = null;
- try {
- ProcessBuilder execBuilder = null;
- execBuilder = new ProcessBuilder("sh", "-c", "cd proc/" + sPid);
- execBuilder.redirectErrorStream(true);
- Process exec = null;
- exec = execBuilder.start();
- InputStream is = exec.getInputStream();
- reader = new BufferedReader(
- new InputStreamReader(is));
-
- String line = reader.readLine();
- if (line == null) {
- return true;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- finally
- {
- FileUtil.closeReader(reader);
- }
- }
-
- return isAlive;
- }
-
- @Override
- public void killprocess(String proc, int cmd) {
- killprocessNormal(proc, cmd);
- }
-
- @Override
- public boolean initUidPkgCache() {
- if (!isRootcheckedResult)
- {
- return false;
- }
-
- uidPkgCache = new SparseArray();
- String pkgListPath = "/data/system/packages.list";
- try {
- CMDExecute.doCmd("chmod 777 " + pkgListPath);
- } catch (Exception e) {
- ToastUtil.ShowShortToast(GTApp.getContext(), "root needed!");
- isRootcheckedResult = false;
- return false;
- }
- BufferedReader br = null;
- try {
- br = new BufferedReader(new FileReader(pkgListPath));
- String temp;
- while((temp = br.readLine()) != null){
- String[] tempArray = temp.trim().split("\\s+");
- if(tempArray.length > 2){
- if(StringUtil.isNumeric(tempArray[1])){
- uidPkgCache.put(Integer.parseInt(tempArray[1]), tempArray[0]);
- }
- }
- }
- if (uidPkgCache.size() <= 0)
- {
- isRootcheckedResult = false;
- return false;
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- isRootcheckedResult = false;
- return false;
- }
- finally
- {
- FileUtil.closeReader(br);
- }
- isRootcheckedResult = true;
- return true;
- }
- }
-
- static class Process4x implements IProcess
- {
- // uid和package的对应
- private SparseArray uidPkgCache = null;
-
- private SparseArray getUidPkgCache()
- {
- return uidPkgCache;
- }
-
- @Override
- public List getAllRunningAppProcessInfo() {
- ActivityManager am = (ActivityManager) GTApp.getContext()
- .getSystemService(Context.ACTIVITY_SERVICE);
- List appProcessList = am
- .getRunningAppProcesses();
- List ret = new ArrayList();
- for (ActivityManager.RunningAppProcessInfo info : appProcessList)
- {
- // pid目前不需要,默认赋值为-1
- ProcessInfo processInfo = new ProcessInfo(info.pid, info.processName, -1, info.uid);
- ret.add(processInfo);
- }
-
- return ret;
- }
-
- @Override
- public String getPackageByUid(int uid) {
- // Android4.x不需要此方法
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getProcessPID(String pName) {
- int pId = -1;
- ActivityManager am = (ActivityManager) GTApp.getContext()
- .getSystemService(Context.ACTIVITY_SERVICE);
- List appProcessList = am
- .getRunningAppProcesses();
- int pLength = appProcessList.size();
- for (int i = 0; i < pLength; i++) {
- if (appProcessList.get(i).processName.equals(pName)) {
- pId = appProcessList.get(i).pid;
- break;
- }
- }
- return pId;
- }
-
- @Override
- public int getProcessUID(String pName) {
- int uId = 0;
- ActivityManager am = (ActivityManager) GTApp.getContext()
- .getSystemService(Context.ACTIVITY_SERVICE);
- List appProcessList = am
- .getRunningAppProcesses();
- int pLength = appProcessList.size();
- for (int i = 0; i < pLength; i++) {
- if (appProcessList.get(i).processName.equals(pName)) {
- uId = appProcessList.get(i).uid;
- break;
- }
- }
- return uId;
- }
-
- @Override
- public boolean hasProcessRunPkg(String pkgName) {
- if (pkgName == null) return false;
- int uid = -1;
- int len = getUidPkgCache().size();
- for (int i = 0; i < len; i++)
- {
- if (pkgName.equals(getUidPkgCache().valueAt(i)))
- {
- uid = getUidPkgCache().keyAt(i);
- break;
- }
- }
-
- List appProcessInfos = getAllRunningAppProcessInfo();
- for (ProcessInfo info : appProcessInfos) {
- if (info.uid == uid)
- {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public boolean isProcessAlive(String sPid) {
- boolean isAlive = false;
- if (sPid != null && GTApp.getContext() != null) {
- int pid = -1;
- try
- {
- pid = Integer.parseInt(sPid);
- }
- catch (Exception e)
- {
- return false;
- }
-
- ActivityManager am = (ActivityManager) GTApp.getContext()
- .getSystemService(Context.ACTIVITY_SERVICE);
- List appProcessList = am
- .getRunningAppProcesses();
- for (RunningAppProcessInfo info : appProcessList) {
- if (info.pid == pid) {
- isAlive = true;
- break;
- }
- }
- }
-
- return isAlive;
- }
-
- @Override
- public void killprocess(String proc, int cmd) {
- killprocessNormal(proc, cmd);
- }
-
- @Override
- public boolean initUidPkgCache() {
- // do nothing for 4.x
- uidPkgCache = new SparseArray();
- ActivityManager am = (ActivityManager) GTApp.getContext()
- .getSystemService(Context.ACTIVITY_SERVICE);
- List appProcessList = am
- .getRunningAppProcesses();
- for (RunningAppProcessInfo info : appProcessList) {
- String[] pkgList = info.pkgList;
- for (String pkg : pkgList)
- {
- uidPkgCache.put(info.uid, pkg);
- }
- }
- return true;
- }
- }
-
- /**
- * 6.x系统中直接用ps命令取的即是可操作的进程
- */
- static class Process6x extends Process5x
- {
- // 有的6.x系统,在ps命令的策略上和5.x还是一样的,此时应该用5x的策略
- static boolean isLike5x = false;
-
- @Override
- public List getAllRunningAppProcessInfo() {
- if (isLike5x)
- {
- return super.getAllRunningAppProcessInfo();
- }
- List appProcessList = new ArrayList();
-
- // 正式取可用的Android进程
- BufferedReader reader = null;
- try {
- ProcessBuilder execBuilder = null;
- execBuilder = new ProcessBuilder("sh", "-c", "ps");
- execBuilder.redirectErrorStream(true);
- Process exec = null;
- exec = execBuilder.start();
- InputStream is = exec.getInputStream();
- reader = new BufferedReader(
- new InputStreamReader(is));
-
- String line = "";
- while ((line = reader.readLine()) != null) {
- String[] array = line.trim().split("\\s+");
- if (array.length >= 9) {
- // 先屏蔽常用的shell命令进程
- if (array[8].equals("su") || array[8].equals("sh")
- || array[8].equals("sush") || array[8].equals("ps"))
- {
- continue;
- }
- int uid = -1;
- try
- {
- uid = Integer.parseInt(array[0].substring(4)) + 10000;
- }
- catch (Exception e)
- {
- // 如果异常了,说明取到了系统进程信息,则判定为该6.x系统的策略和5.x一致,应尝试5.x的策略
- isLike5x = true;
- FileUtil.closeReader(reader); // 提前关闭流
- return super.getAllRunningAppProcessInfo();
- }
-
- int pid = Integer.parseInt(array[1]);
- int ppid = Integer.parseInt(array[2]);
-
- ProcessInfo pi = new ProcessInfo(pid, array[8], ppid, uid);
- appProcessList.add(pi);
- super.procInfoCache.put(array[8], pi);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- finally
- {
- FileUtil.closeReader(reader);
- }
-
- return appProcessList;
- }
- }
-}
+/*
+ * Tencent is pleased to support the open source community by making
+ * Tencent GT (Version 2.4 and subsequent versions) available.
+ *
+ * Notwithstanding anything to the contrary herein, any previous version
+ * of Tencent GT shall not be subject to the license hereunder.
+ * All right, title, and interest, including all intellectual property rights,
+ * in and to the previous version of Tencent GT (including any and all copies thereof)
+ * shall be owned and retained by Tencent and subject to the license under the
+ * Tencent GT End User License Agreement (http://gt.qq.com/wp-content/EULA_EN.html).
+ *
+ * Copyright (C) 2015 THL A29 Limited, a Tencent company. All rights reserved.
+ *
+ * Licensed under the MIT License (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://opensource.org/licenses/MIT
+ *
+ * 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.tencent.wstt.gt.api.utils;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.tencent.wstt.gt.GTApp;
+import com.tencent.wstt.gt.utils.FileUtil;
+import com.tencent.wstt.gt.utils.StringUtil;
+import com.tencent.wstt.gt.utils.ToastUtil;
+
+import android.app.ActivityManager;
+import android.app.ActivityManager.RunningAppProcessInfo;
+import android.content.Context;
+import android.util.SparseArray;
+
+/**
+ * 进程信息工具类。
+ */
+public class ProcessUtils {
+
+ private static IProcess processUtil;
+
+ /**
+ * 根据手机系统的版本号,适配ProcessUtils的实现,全局调用一次即可。
+ * Android4.x及以下系统,用老的方式效率更高。
+ * Android5.x及以上系统,用shell命令方式。
+ */
+ synchronized public static void init()
+ {
+ if (Env.API < 21)
+ {
+ processUtil = new Process4x();
+ }
+ else if (Env.API < 23) // 5.x+
+ {
+ processUtil = new Process5x();
+ }
+ else // 6.x+
+ {
+ processUtil = new Process6x();
+ }
+ }
+
+ public static String getPackageByUid(int uid)
+ {
+ return processUtil.getPackageByUid(uid);
+ }
+
+ /*
+ * 在选择被测应用后应该更新,包括广播和sdk自动化中,注意广播和sdk自动化中执行su操作有风险
+ */
+ public static boolean initUidPkgCache()
+ {
+ return processUtil.initUidPkgCache();
+ }
+
+ /**
+ * 是否至少有一个进程在运行指定包名的应用程序
+ *
+ * @param pkgName
+ * 指定的包名
+ * @return 是否至少有一个进程在运行指定包名的应用程序
+ */
+ public static boolean hasProcessRunPkg(String pkgName) {
+ return processUtil.hasProcessRunPkg(pkgName);
+ }
+
+ /**
+ * 根据进程名,获取进程UID,反查UID,性能需要高
+ *
+ * 当前进程的上下文环境
+ * @param pName
+ * 进程名
+ * @return 进程UID
+ */
+ public static int getProcessUID(String pName) {
+ return processUtil.getProcessUID(pName);
+ }
+
+ /**
+ * 根据进程名,获取进程PID
+ *
+ * 当前进程的上下文环境
+ * @param pName
+ * 进程名
+ * @return 进程PID
+ */
+ public static int getProcessPID(String pName) {
+ return processUtil.getProcessPID(pName);
+ }
+
+ /**
+ * 判断进程是否在运行。
+ *
+ * @param sPid
+ * 进程号
+ * @return true 正在运行;false 停止运行
+ */
+ public static boolean isProcessAlive(String sPid) {
+ return processUtil.isProcessAlive(sPid);
+ }
+
+ public static List getAllRunningAppProcessInfo() {
+ return processUtil.getAllRunningAppProcessInfo();
+ }
+
+ public static void killprocess(String proc, int cmd) {
+ processUtil.killprocess(proc, cmd);
+ }
+
+ private static void killprocessNormal(String proc, int killMethod) {
+ try {
+ ArrayList pid_list = new ArrayList();
+
+ ProcessBuilder execBuilder = null;
+
+ execBuilder = new ProcessBuilder("sh", "-c", "ps |grep " + proc);
+
+ execBuilder.redirectErrorStream(true);
+
+ Process exec = null;
+ exec = execBuilder.start();
+ InputStream is = exec.getInputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+
+ String line = "";
+ while ((line = reader.readLine()) != null) {
+ String regEx = "\\s[0-9][0-9]*\\s";
+ Pattern pat = Pattern.compile(regEx);
+ Matcher mat = pat.matcher(line);
+ if (mat.find()) {
+ String temp = mat.group();
+ temp = temp.replaceAll("\\s", "");
+ pid_list.add(temp);
+ }
+ }
+
+ for (int i = 0; i < pid_list.size(); i++) {
+ execBuilder = new ProcessBuilder("su", "-c", "kill", "-" + killMethod, pid_list.get(i));
+ exec = null;
+ exec = execBuilder.start();
+
+ execBuilder = new ProcessBuilder("su", "-c", "kill" + " -" + killMethod + " " + pid_list.get(i));
+ exec = null;
+ exec = execBuilder.start();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static class ProcessInfo
+ {
+ public String name; // 进程名
+ public int pid; // PID
+ public int ppid; // 父PID
+ public int uid; // UID
+
+ public ProcessInfo(int pid, String name, int ppid, int uid)
+ {
+ this.pid = pid;
+ this.name = name;
+ this.ppid = ppid;
+ this.uid = uid;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = 17;
+ if (name != null)
+ result = 37 * result + name.hashCode();
+ result = 37 * result + (int) (pid ^ (pid >>> 32));
+ result = 37 * result + (int) (ppid ^ (ppid >>> 32));
+ result = 37 * result + (int) (uid ^ (uid >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o instanceof ProcessInfo)
+ {
+ ProcessInfo another = (ProcessInfo)o;
+ if (this.pid == another.pid
+ && this.ppid == another.ppid
+ && this.name != null
+ && another.name != null
+ && this.name.equals(another.name))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ static interface IProcess {
+ List getAllRunningAppProcessInfo();
+ String getPackageByUid(int uid);
+ int getProcessPID(String pName);
+ int getProcessUID(String pName);
+ boolean hasProcessRunPkg(String pkgName);
+ boolean isProcessAlive(String sPid);
+ void killprocess(String proc, int cmd);
+ boolean initUidPkgCache();
+ }
+
+ static class Process5x implements IProcess
+ {
+ private boolean isRootcheckedResult = true;
+
+ private Map procInfoCache =
+ new HashMap();
+ // uid和package的对应
+ private SparseArray uidPkgCache = null;
+
+ private SparseArray getUidPkgCache()
+ {
+ return uidPkgCache;
+ }
+
+ @Override
+ public List getAllRunningAppProcessInfo() {
+ List appProcessList = new ArrayList();
+
+ // 先取Android进程的父进程zygote的进程号,64位app对应的是zygote64
+ int zygotePid = -1;
+ int zygotePid64 = -1;
+
+ /*
+ * 如果使用了较新版本的root权限控制工具,ps命令会看不到zygote进程,这时需要用su命令
+ */
+ boolean needRoot = true;
+
+ // 先尝试sh命令
+ BufferedReader readerZ = null;
+ try {
+ ProcessBuilder execBuilderZ = null;
+ execBuilderZ = new ProcessBuilder("sh", "-c", "ps |grep zygote");
+ execBuilderZ.redirectErrorStream(true);
+ Process execZ = execBuilderZ.start();
+ InputStream isZ = execZ.getInputStream();
+ readerZ = new BufferedReader(
+ new InputStreamReader(isZ));
+ String lineZ = "";
+
+ while ((lineZ = readerZ.readLine()) != null) {
+ needRoot = false;
+ String[] arrayZ = lineZ.trim().split("\\s+");
+ if (arrayZ.length >= 9) {
+ if (arrayZ[8].equals("zygote"))
+ {
+ zygotePid = Integer.parseInt(arrayZ[1]);
+ }
+ else if (arrayZ[8].equals("zygote64"))
+ {
+ zygotePid64 = Integer.parseInt(arrayZ[1]);
+ }
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ FileUtil.closeReader(readerZ);
+ }
+
+ /*
+ * sh若搞不定,改用su权限执行ps命令
+ */
+ if (needRoot)
+ {
+ try {
+ ProcessBuilder execBuilderZ = null;
+ execBuilderZ = new ProcessBuilder("su", "-c", "ps |grep zygote");
+ execBuilderZ.redirectErrorStream(true);
+ Process execZ = execBuilderZ.start();
+ InputStream isZ = execZ.getInputStream();
+ readerZ = new BufferedReader(
+ new InputStreamReader(isZ));
+ String lineZ = "";
+
+ while ((lineZ = readerZ.readLine()) != null) {
+ String[] arrayZ = lineZ.trim().split("\\s+");
+ if (arrayZ.length >= 9) {
+ if (arrayZ[8].equals("zygote"))
+ {
+ zygotePid = Integer.parseInt(arrayZ[1]);
+ }
+ else if (arrayZ[8].equals("zygote64"))
+ {
+ zygotePid64 = Integer.parseInt(arrayZ[1]);
+ }
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ FileUtil.closeReader(readerZ);
+ }
+ }
+
+ if (zygotePid < 0)
+ {
+ return appProcessList;
+ }
+
+ // 正式取可用的Android进程,前面不管是sh还是su搞定的,这里都用sh即可。
+ BufferedReader reader = null;
+ try {
+ ProcessBuilder execBuilder = null;
+ execBuilder = new ProcessBuilder("sh", "-c", "ps |grep u0_a");
+ execBuilder.redirectErrorStream(true);
+ Process exec = null;
+ exec = execBuilder.start();
+ InputStream is = exec.getInputStream();
+ reader = new BufferedReader(
+ new InputStreamReader(is));
+
+ String line = "";
+ while ((line = reader.readLine()) != null) {
+ String[] array = line.trim().split("\\s+");
+ if (array.length >= 9) {
+ int uid = Integer.parseInt(array[0].substring(4)) + 10000;
+ int pid = Integer.parseInt(array[1]);
+ int ppid = Integer.parseInt(array[2]);
+ // 过滤掉系统子进程,只留下父进程是zygote的进程
+ if (ppid == zygotePid || ppid == zygotePid64)
+ {
+ ProcessInfo pi = new ProcessInfo(pid, array[8], ppid, uid);
+ appProcessList.add(pi);
+ procInfoCache.put(array[8], pi);
+ }
+
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally
+ {
+ FileUtil.closeReader(reader);
+ }
+
+ return appProcessList;
+ }
+
+ @Override
+ public String getPackageByUid(int uid) {
+ if (uidPkgCache == null)
+ {
+ initUidPkgCache();
+ }
+ return uidPkgCache.get(uid);
+ }
+
+ @Override
+ public int getProcessPID(String pName) {
+ int pId = -1;
+ List appProcessInfos = getAllRunningAppProcessInfo();
+ for (ProcessInfo info : appProcessInfos) {
+ if (info.name.equals(pName)) {
+ pId = info.pid;
+ break;
+ }
+ }
+ return pId;
+ }
+
+ @Override
+ public int getProcessUID(String pName) {
+ int uId = 0;
+ if (procInfoCache.isEmpty())
+ {
+ List appProcessInfos = getAllRunningAppProcessInfo();
+
+ for (ProcessInfo pi : appProcessInfos) {
+ if (pi.name.equals(pName)) {
+
+ uId = pi.uid;
+ break;
+ }
+ }
+ }
+ else // uid和pName都不会变,所以从缓存查
+ {
+ ProcessInfo pi = procInfoCache.get(pName);
+ /*
+ * 但是有初始记录的进程并不是主进程的情况,比如:
+ * 微信往往是com.tencent.mm:push进程活着,而com.tencent.mm进程初始是不在的
+ * 此时需要找与com.tencent.mm相似的com.tencent.mm:push进程信息作为替代
+ */
+ if (pi == null)
+ {
+ for (ProcessInfo tpi : procInfoCache.values())
+ {
+ if (tpi.name.startsWith(pName))
+ {
+ pi = tpi;
+ procInfoCache.put(pName, pi);
+ break;
+ }
+ }
+ }
+ uId = pi == null ? -1 : pi.uid;
+ }
+ return uId;
+ }
+
+ @Override
+ public boolean hasProcessRunPkg(String pkgName) {
+ if (pkgName == null) return false;
+ int uid = -1;
+
+ int len = getUidPkgCache().size();
+ // 如果是没有root过的手机,uidPkgCache是空的,采用替代方案,但对于进程命名中不包括包名的没有办法
+ if (len != 0)
+ {
+ for (int i = 0; i < len; i++)
+ {
+ if (pkgName.equals(getUidPkgCache().valueAt(i)))
+ {
+ uid = getUidPkgCache().keyAt(i);
+ break;
+ }
+ }
+
+ if (uid == -1) return false;
+ List appProcessInfos = getAllRunningAppProcessInfo();
+ for (ProcessInfo info : appProcessInfos) {
+ if (info.uid == uid)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ else // 替代方案
+ {
+ List appProcessInfos = getAllRunningAppProcessInfo();
+ for (ProcessInfo info : appProcessInfos) {
+ if (info.name.contains(pkgName))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ @Override
+ public boolean isProcessAlive(String sPid) {
+ boolean isAlive = false;
+ if (sPid != null) {
+ // 采用进入目录的方式判断会比较快
+ BufferedReader reader = null;
+ try {
+ ProcessBuilder execBuilder = null;
+ execBuilder = new ProcessBuilder("sh", "-c", "cd proc/" + sPid);
+ execBuilder.redirectErrorStream(true);
+ Process exec = null;
+ exec = execBuilder.start();
+ InputStream is = exec.getInputStream();
+ reader = new BufferedReader(
+ new InputStreamReader(is));
+
+ String line = reader.readLine();
+ if (line == null) {
+ return true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally
+ {
+ FileUtil.closeReader(reader);
+ }
+ }
+
+ return isAlive;
+ }
+
+ @Override
+ public void killprocess(String proc, int cmd) {
+ killprocessNormal(proc, cmd);
+ }
+
+ @Override
+ public boolean initUidPkgCache() {
+ if (!isRootcheckedResult)
+ {
+ return false;
+ }
+
+ uidPkgCache = new SparseArray();
+ String pkgListPath = "/data/system/packages.list";
+ try {
+ CMDExecute.doCmd("chmod 777 " + pkgListPath);
+ } catch (Exception e) {
+ ToastUtil.ShowShortToast(GTApp.getContext(), "root needed!");
+ isRootcheckedResult = false;
+ return false;
+ }
+ BufferedReader br = null;
+ try {
+ br = new BufferedReader(new FileReader(pkgListPath));
+ String temp;
+ while((temp = br.readLine()) != null){
+ String[] tempArray = temp.trim().split("\\s+");
+ if(tempArray.length > 2){
+ if(StringUtil.isNumeric(tempArray[1])){
+ uidPkgCache.put(Integer.parseInt(tempArray[1]), tempArray[0]);
+ }
+ }
+ }
+ if (uidPkgCache.size() <= 0)
+ {
+ isRootcheckedResult = false;
+ return false;
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ isRootcheckedResult = false;
+ return false;
+ }
+ finally
+ {
+ FileUtil.closeReader(br);
+ }
+ isRootcheckedResult = true;
+ return true;
+ }
+ }
+
+ static class Process4x implements IProcess
+ {
+ // uid和package的对应
+ private SparseArray uidPkgCache = null;
+
+ private SparseArray getUidPkgCache()
+ {
+ return uidPkgCache;
+ }
+
+ @Override
+ public List getAllRunningAppProcessInfo() {
+ ActivityManager am = (ActivityManager) GTApp.getContext()
+ .getSystemService(Context.ACTIVITY_SERVICE);
+ List appProcessList = am
+ .getRunningAppProcesses();
+ List ret = new ArrayList();
+ for (ActivityManager.RunningAppProcessInfo info : appProcessList)
+ {
+ // pid目前不需要,默认赋值为-1
+ ProcessInfo processInfo = new ProcessInfo(info.pid, info.processName, -1, info.uid);
+ ret.add(processInfo);
+ }
+
+ return ret;
+ }
+
+ @Override
+ public String getPackageByUid(int uid) {
+ // Android4.x不需要此方法
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int getProcessPID(String pName) {
+ int pId = -1;
+ ActivityManager am = (ActivityManager) GTApp.getContext()
+ .getSystemService(Context.ACTIVITY_SERVICE);
+ List appProcessList = am
+ .getRunningAppProcesses();
+ int pLength = appProcessList.size();
+ for (int i = 0; i < pLength; i++) {
+ if (appProcessList.get(i).processName.equals(pName)) {
+ pId = appProcessList.get(i).pid;
+ break;
+ }
+ }
+ return pId;
+ }
+
+ @Override
+ public int getProcessUID(String pName) {
+ int uId = 0;
+ ActivityManager am = (ActivityManager) GTApp.getContext()
+ .getSystemService(Context.ACTIVITY_SERVICE);
+ List appProcessList = am
+ .getRunningAppProcesses();
+ int pLength = appProcessList.size();
+ for (int i = 0; i < pLength; i++) {
+ if (appProcessList.get(i).processName.equals(pName)) {
+ uId = appProcessList.get(i).uid;
+ break;
+ }
+ }
+ return uId;
+ }
+
+ @Override
+ public boolean hasProcessRunPkg(String pkgName) {
+ if (pkgName == null) return false;
+ int uid = -1;
+ int len = getUidPkgCache().size();
+ for (int i = 0; i < len; i++)
+ {
+ if (pkgName.equals(getUidPkgCache().valueAt(i)))
+ {
+ uid = getUidPkgCache().keyAt(i);
+ break;
+ }
+ }
+
+ List appProcessInfos = getAllRunningAppProcessInfo();
+ for (ProcessInfo info : appProcessInfos) {
+ if (info.uid == uid)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isProcessAlive(String sPid) {
+ boolean isAlive = false;
+ if (sPid != null && GTApp.getContext() != null) {
+ int pid = -1;
+ try
+ {
+ pid = Integer.parseInt(sPid);
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+
+ ActivityManager am = (ActivityManager) GTApp.getContext()
+ .getSystemService(Context.ACTIVITY_SERVICE);
+ List appProcessList = am
+ .getRunningAppProcesses();
+ for (RunningAppProcessInfo info : appProcessList) {
+ if (info.pid == pid) {
+ isAlive = true;
+ break;
+ }
+ }
+ }
+
+ return isAlive;
+ }
+
+ @Override
+ public void killprocess(String proc, int cmd) {
+ killprocessNormal(proc, cmd);
+ }
+
+ @Override
+ public boolean initUidPkgCache() {
+ // do nothing for 4.x
+ uidPkgCache = new SparseArray();
+ ActivityManager am = (ActivityManager) GTApp.getContext()
+ .getSystemService(Context.ACTIVITY_SERVICE);
+ List appProcessList = am
+ .getRunningAppProcesses();
+ for (RunningAppProcessInfo info : appProcessList) {
+ String[] pkgList = info.pkgList;
+ for (String pkg : pkgList)
+ {
+ uidPkgCache.put(info.uid, pkg);
+ }
+ }
+ return true;
+ }
+ }
+
+ /**
+ * 6.x系统中直接用ps命令取的即是可操作的进程
+ */
+ static class Process6x extends Process5x
+ {
+ // 有的6.x系统,在ps命令的策略上和5.x还是一样的,此时应该用5x的策略
+ static boolean isLike5x = false;
+
+ @Override
+ public List getAllRunningAppProcessInfo() {
+ if (isLike5x)
+ {
+ return super.getAllRunningAppProcessInfo();
+ }
+ List appProcessList = new ArrayList();
+
+ // 正式取可用的Android进程
+ BufferedReader reader = null;
+ try {
+ ProcessBuilder execBuilder = null;
+ execBuilder = new ProcessBuilder("sh", "-c", "ps");
+ execBuilder.redirectErrorStream(true);
+ Process exec = null;
+ exec = execBuilder.start();
+ InputStream is = exec.getInputStream();
+ reader = new BufferedReader(
+ new InputStreamReader(is));
+
+ String line = "";
+ while ((line = reader.readLine()) != null) {
+ String[] array = line.trim().split("\\s+");
+ if (array.length >= 9) {
+ // 先屏蔽常用的shell命令进程
+ if (array[8].equals("su") || array[8].equals("sh")
+ || array[8].equals("sush") || array[8].equals("ps"))
+ {
+ continue;
+ }
+ int uid = -1;
+ try
+ {
+ uid = Integer.parseInt(array[0].substring(4)) + 10000;
+ }
+ catch (Exception e)
+ {
+ // 如果异常了,说明取到了系统进程信息,则判定为该6.x系统的策略和5.x一致,应尝试5.x的策略
+ isLike5x = true;
+ FileUtil.closeReader(reader); // 提前关闭流
+ return super.getAllRunningAppProcessInfo();
+ }
+
+ int pid = Integer.parseInt(array[1]);
+ int ppid = Integer.parseInt(array[2]);
+
+ ProcessInfo pi = new ProcessInfo(pid, array[8], ppid, uid);
+ appProcessList.add(pi);
+ super.procInfoCache.put(array[8], pi);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally
+ {
+ FileUtil.closeReader(reader);
+ }
+
+ return appProcessList;
+ }
+ }
+}
diff --git a/android/src/com/tencent/wstt/gt/api/utils/SMUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/SMUtils.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/SMUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/SMUtils.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/SignalUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/SignalUtils.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/SignalUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/SignalUtils.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/WidgetUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/WidgetUtils.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/WidgetUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/WidgetUtils.java
diff --git a/android/src/com/tencent/wstt/gt/api/utils/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/api/utils/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/api/utils/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/api/utils/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/autotest/GTAutoTestInternal.java b/android/app/src/main/java/com/tencent/wstt/gt/autotest/GTAutoTestInternal.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/autotest/GTAutoTestInternal.java
rename to android/app/src/main/java/com/tencent/wstt/gt/autotest/GTAutoTestInternal.java
diff --git a/android/src/com/tencent/wstt/gt/autotest/ProOutParaQueryEntry.java b/android/app/src/main/java/com/tencent/wstt/gt/autotest/ProOutParaQueryEntry.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/autotest/ProOutParaQueryEntry.java
rename to android/app/src/main/java/com/tencent/wstt/gt/autotest/ProOutParaQueryEntry.java
diff --git a/android/src/com/tencent/wstt/gt/communicate/ClientConnectGT.java b/android/app/src/main/java/com/tencent/wstt/gt/communicate/ClientConnectGT.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/communicate/ClientConnectGT.java
rename to android/app/src/main/java/com/tencent/wstt/gt/communicate/ClientConnectGT.java
diff --git a/android/src/com/tencent/wstt/gt/communicate/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/communicate/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/communicate/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/communicate/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/dao/GTPref.java b/android/app/src/main/java/com/tencent/wstt/gt/dao/GTPref.java
similarity index 97%
rename from android/src/com/tencent/wstt/gt/dao/GTPref.java
rename to android/app/src/main/java/com/tencent/wstt/gt/dao/GTPref.java
index fc4dd97..5940c03 100644
--- a/android/src/com/tencent/wstt/gt/dao/GTPref.java
+++ b/android/app/src/main/java/com/tencent/wstt/gt/dao/GTPref.java
@@ -1,73 +1,73 @@
-/*
- * Tencent is pleased to support the open source community by making
- * Tencent GT (Version 2.4 and subsequent versions) available.
- *
- * Notwithstanding anything to the contrary herein, any previous version
- * of Tencent GT shall not be subject to the license hereunder.
- * All right, title, and interest, including all intellectual property rights,
- * in and to the previous version of Tencent GT (including any and all copies thereof)
- * shall be owned and retained by Tencent and subject to the license under the
- * Tencent GT End User License Agreement (http://gt.qq.com/wp-content/EULA_EN.html).
- *
- * Copyright (C) 2015 THL A29 Limited, a Tencent company. All rights reserved.
- *
- * Licensed under the MIT License (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://opensource.org/licenses/MIT
- *
- * 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.tencent.wstt.gt.dao;
-
-import com.tencent.wstt.gt.GTApp;
-
-import android.content.SharedPreferences;
-
-public class GTPref {
- public static final String GT_SP_NAME = "gt_SharedPreferences";
-
- // 日志用的开关,boolean型参数
- public static final String LOG_MASTER_SWITCH = "log_master_switch";
- public static final String LOG_AUTOSAVE_SWITCH = "log_autosave_switch";
- public static final String LOG_AUTOSAVEFLUSH_SWITCH = "log_autosaveflush_switch";
- public static final String LOG_SAVE_DEFAULT_SEG = "log_save_default_seg";
-
- // 性能统计间隔
- public static final String INTERVAL_PERF = "interval_perf";
- public static final String INTERVAL_PERF_POS = "interval_perf_pos";
-
- // FPS采集间隔
- public static final String INTERVAL_FPS = "interval_fps";
- public static final String INTERVAL_FPS_POS = "interval_fps_pos";
-
- // 性能统计用的开关
- public static final String PERF_MASTER_SWITCH = "perf_master_switch";
-
- // 控制台设置类型
- public static final String AC_SWITCH = "ac_switch_type";
- public static final String AC_SWITCH_FLAG = "ac_switch_type_flag"; // 是否启用悬浮图标的开关
-
- // 是否已授权弹出悬浮框标志,在API23以上起作用
- public static final String FLOAT_ALLOWED = "ac_float_allowed_flag";
-
- // 是否已授权允许WRITE_SETTINGS,在API23以上起作用
- public static final String WRITE_SETTINGS = "write_settings_allowed_flag";
-
- // 法律条款接受与否
- public static final String PREFERENCE_EULA_ACCEPTED = "eula.accepted";
-
- // 出参历史页的告警区域是否折叠的开关
-// public static final String OP_PERF_DETAIL_WARN_AREA_FOLD = "op_perf_detail_wf";
-
- private static SharedPreferences gt_SP =
- GTApp.getContext().getSharedPreferences(GT_SP_NAME, 0);
-
- public static SharedPreferences getGTPref()
- {
- return gt_SP;
- }
-}
+/*
+ * Tencent is pleased to support the open source community by making
+ * Tencent GT (Version 2.4 and subsequent versions) available.
+ *
+ * Notwithstanding anything to the contrary herein, any previous version
+ * of Tencent GT shall not be subject to the license hereunder.
+ * All right, title, and interest, including all intellectual property rights,
+ * in and to the previous version of Tencent GT (including any and all copies thereof)
+ * shall be owned and retained by Tencent and subject to the license under the
+ * Tencent GT End User License Agreement (http://gt.qq.com/wp-content/EULA_EN.html).
+ *
+ * Copyright (C) 2015 THL A29 Limited, a Tencent company. All rights reserved.
+ *
+ * Licensed under the MIT License (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://opensource.org/licenses/MIT
+ *
+ * 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.tencent.wstt.gt.dao;
+
+import com.tencent.wstt.gt.GTApp;
+
+import android.content.SharedPreferences;
+
+public class GTPref {
+ public static final String GT_SP_NAME = "gt_SharedPreferences";
+
+ // 日志用的开关,boolean型参数
+ public static final String LOG_MASTER_SWITCH = "log_master_switch";
+ public static final String LOG_AUTOSAVE_SWITCH = "log_autosave_switch";
+ public static final String LOG_AUTOSAVEFLUSH_SWITCH = "log_autosaveflush_switch";
+ public static final String LOG_SAVE_DEFAULT_SEG = "log_save_default_seg";
+
+ // 性能统计间隔
+ public static final String INTERVAL_PERF = "interval_perf";
+ public static final String INTERVAL_PERF_POS = "interval_perf_pos";
+
+ // FPS采集间隔
+ public static final String INTERVAL_FPS = "interval_fps";
+ public static final String INTERVAL_FPS_POS = "interval_fps_pos";
+
+ // 性能统计用的开关
+ public static final String PERF_MASTER_SWITCH = "perf_master_switch";
+
+ // 控制台设置类型
+ public static final String AC_SWITCH = "ac_switch_type";
+ public static final String AC_SWITCH_FLAG = "ac_switch_type_flag"; // 是否启用悬浮图标的开关
+
+ // 是否已授权弹出悬浮框标志,在API23以上起作用
+ public static final String FLOAT_ALLOWED = "ac_float_allowed_flag";
+
+ // 是否已授权允许WRITE_SETTINGS,在API23以上起作用
+ public static final String WRITE_SETTINGS = "write_settings_allowed_flag";
+
+ // 法律条款接受与否
+ public static final String PREFERENCE_EULA_ACCEPTED = "eula.accepted";
+
+ // 出参历史页的告警区域是否折叠的开关
+// public static final String OP_PERF_DETAIL_WARN_AREA_FOLD = "op_perf_detail_wf";
+
+ private static SharedPreferences gt_SP =
+ GTApp.getContext().getSharedPreferences(GT_SP_NAME, 0);
+
+ public static SharedPreferences getGTPref()
+ {
+ return gt_SP;
+ }
+}
diff --git a/android/src/com/tencent/wstt/gt/dao/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/dao/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/dao/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/dao/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/engine/DefaultParaRunEngine.java b/android/app/src/main/java/com/tencent/wstt/gt/engine/DefaultParaRunEngine.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/engine/DefaultParaRunEngine.java
rename to android/app/src/main/java/com/tencent/wstt/gt/engine/DefaultParaRunEngine.java
diff --git a/android/src/com/tencent/wstt/gt/engine/ProcPerfParaRunEngine.java b/android/app/src/main/java/com/tencent/wstt/gt/engine/ProcPerfParaRunEngine.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/engine/ProcPerfParaRunEngine.java
rename to android/app/src/main/java/com/tencent/wstt/gt/engine/ProcPerfParaRunEngine.java
diff --git a/android/src/com/tencent/wstt/gt/engine/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/engine/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/engine/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/engine/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/internal/DaemonHandler.java b/android/app/src/main/java/com/tencent/wstt/gt/internal/DaemonHandler.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/internal/DaemonHandler.java
rename to android/app/src/main/java/com/tencent/wstt/gt/internal/DaemonHandler.java
diff --git a/android/src/com/tencent/wstt/gt/internal/GTDaemonThread.java b/android/app/src/main/java/com/tencent/wstt/gt/internal/GTDaemonThread.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/internal/GTDaemonThread.java
rename to android/app/src/main/java/com/tencent/wstt/gt/internal/GTDaemonThread.java
diff --git a/android/src/com/tencent/wstt/gt/internal/GTDaemonThreadManager.java b/android/app/src/main/java/com/tencent/wstt/gt/internal/GTDaemonThreadManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/internal/GTDaemonThreadManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/internal/GTDaemonThreadManager.java
diff --git a/android/src/com/tencent/wstt/gt/internal/GTMemoryDaemonHelper.java b/android/app/src/main/java/com/tencent/wstt/gt/internal/GTMemoryDaemonHelper.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/internal/GTMemoryDaemonHelper.java
rename to android/app/src/main/java/com/tencent/wstt/gt/internal/GTMemoryDaemonHelper.java
diff --git a/android/src/com/tencent/wstt/gt/internal/GTMemoryDaemonThread.java b/android/app/src/main/java/com/tencent/wstt/gt/internal/GTMemoryDaemonThread.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/internal/GTMemoryDaemonThread.java
rename to android/app/src/main/java/com/tencent/wstt/gt/internal/GTMemoryDaemonThread.java
diff --git a/android/src/com/tencent/wstt/gt/internal/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/internal/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/internal/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/internal/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/log/AbsLogController.java b/android/app/src/main/java/com/tencent/wstt/gt/log/AbsLogController.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/AbsLogController.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/AbsLogController.java
diff --git a/android/src/com/tencent/wstt/gt/log/CleanTempLogException.java b/android/app/src/main/java/com/tencent/wstt/gt/log/CleanTempLogException.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/CleanTempLogException.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/CleanTempLogException.java
diff --git a/android/src/com/tencent/wstt/gt/log/GTGWInternal.java b/android/app/src/main/java/com/tencent/wstt/gt/log/GTGWInternal.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/GTGWInternal.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/GTGWInternal.java
diff --git a/android/src/com/tencent/wstt/gt/log/GTLogInternal.java b/android/app/src/main/java/com/tencent/wstt/gt/log/GTLogInternal.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/GTLogInternal.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/GTLogInternal.java
diff --git a/android/src/com/tencent/wstt/gt/log/GTTimeInternal.java b/android/app/src/main/java/com/tencent/wstt/gt/log/GTTimeInternal.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/GTTimeInternal.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/GTTimeInternal.java
diff --git a/android/src/com/tencent/wstt/gt/log/GWSaveEntry.java b/android/app/src/main/java/com/tencent/wstt/gt/log/GWSaveEntry.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/GWSaveEntry.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/GWSaveEntry.java
diff --git a/android/src/com/tencent/wstt/gt/log/ICacheable.java b/android/app/src/main/java/com/tencent/wstt/gt/log/ICacheable.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/ICacheable.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/ICacheable.java
diff --git a/android/src/com/tencent/wstt/gt/log/ITimed.java b/android/app/src/main/java/com/tencent/wstt/gt/log/ITimed.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/ITimed.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/ITimed.java
diff --git a/android/src/com/tencent/wstt/gt/log/LogController.java b/android/app/src/main/java/com/tencent/wstt/gt/log/LogController.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/LogController.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/LogController.java
diff --git a/android/src/com/tencent/wstt/gt/log/LogListener.java b/android/app/src/main/java/com/tencent/wstt/gt/log/LogListener.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/LogListener.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/LogListener.java
diff --git a/android/src/com/tencent/wstt/gt/log/LogSearchController.java b/android/app/src/main/java/com/tencent/wstt/gt/log/LogSearchController.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/LogSearchController.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/LogSearchController.java
diff --git a/android/src/com/tencent/wstt/gt/log/LogTaskConsumer.java b/android/app/src/main/java/com/tencent/wstt/gt/log/LogTaskConsumer.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/LogTaskConsumer.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/LogTaskConsumer.java
diff --git a/android/src/com/tencent/wstt/gt/log/LogTimeController.java b/android/app/src/main/java/com/tencent/wstt/gt/log/LogTimeController.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/LogTimeController.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/LogTimeController.java
diff --git a/android/src/com/tencent/wstt/gt/log/LogUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/log/LogUtils.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/LogUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/LogUtils.java
diff --git a/android/src/com/tencent/wstt/gt/log/NormalLogAdapter.java b/android/app/src/main/java/com/tencent/wstt/gt/log/NormalLogAdapter.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/NormalLogAdapter.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/NormalLogAdapter.java
diff --git a/android/src/com/tencent/wstt/gt/log/RemoveRangeArrayList.java b/android/app/src/main/java/com/tencent/wstt/gt/log/RemoveRangeArrayList.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/RemoveRangeArrayList.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/RemoveRangeArrayList.java
diff --git a/android/src/com/tencent/wstt/gt/log/SearchLogAdapter.java b/android/app/src/main/java/com/tencent/wstt/gt/log/SearchLogAdapter.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/SearchLogAdapter.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/SearchLogAdapter.java
diff --git a/android/src/com/tencent/wstt/gt/log/TempLogConsumer.java b/android/app/src/main/java/com/tencent/wstt/gt/log/TempLogConsumer.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/TempLogConsumer.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/TempLogConsumer.java
diff --git a/android/src/com/tencent/wstt/gt/log/logcat/AbsLogcatReader.java b/android/app/src/main/java/com/tencent/wstt/gt/log/logcat/AbsLogcatReader.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/logcat/AbsLogcatReader.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/logcat/AbsLogcatReader.java
diff --git a/android/src/com/tencent/wstt/gt/log/logcat/ArrayUtil.java b/android/app/src/main/java/com/tencent/wstt/gt/log/logcat/ArrayUtil.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/logcat/ArrayUtil.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/logcat/ArrayUtil.java
diff --git a/android/src/com/tencent/wstt/gt/log/logcat/LogFileAdapter.java b/android/app/src/main/java/com/tencent/wstt/gt/log/logcat/LogFileAdapter.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/logcat/LogFileAdapter.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/logcat/LogFileAdapter.java
diff --git a/android/src/com/tencent/wstt/gt/log/logcat/LogLine.java b/android/app/src/main/java/com/tencent/wstt/gt/log/logcat/LogLine.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/logcat/LogLine.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/logcat/LogLine.java
diff --git a/android/src/com/tencent/wstt/gt/log/logcat/LogcatHelper.java b/android/app/src/main/java/com/tencent/wstt/gt/log/logcat/LogcatHelper.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/logcat/LogcatHelper.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/logcat/LogcatHelper.java
diff --git a/android/src/com/tencent/wstt/gt/log/logcat/LogcatReader.java b/android/app/src/main/java/com/tencent/wstt/gt/log/logcat/LogcatReader.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/logcat/LogcatReader.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/logcat/LogcatReader.java
diff --git a/android/src/com/tencent/wstt/gt/log/logcat/LogcatReaderLoader.java b/android/app/src/main/java/com/tencent/wstt/gt/log/logcat/LogcatReaderLoader.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/logcat/LogcatReaderLoader.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/logcat/LogcatReaderLoader.java
diff --git a/android/src/com/tencent/wstt/gt/log/logcat/MultipleLogcatReader.java b/android/app/src/main/java/com/tencent/wstt/gt/log/logcat/MultipleLogcatReader.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/logcat/MultipleLogcatReader.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/logcat/MultipleLogcatReader.java
diff --git a/android/src/com/tencent/wstt/gt/log/logcat/RuntimeHelper.java b/android/app/src/main/java/com/tencent/wstt/gt/log/logcat/RuntimeHelper.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/logcat/RuntimeHelper.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/logcat/RuntimeHelper.java
diff --git a/android/src/com/tencent/wstt/gt/log/logcat/SaveLogHelper.java b/android/app/src/main/java/com/tencent/wstt/gt/log/logcat/SaveLogHelper.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/logcat/SaveLogHelper.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/logcat/SaveLogHelper.java
diff --git a/android/src/com/tencent/wstt/gt/log/logcat/SingleLogcatReader.java b/android/app/src/main/java/com/tencent/wstt/gt/log/logcat/SingleLogcatReader.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/logcat/SingleLogcatReader.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/logcat/SingleLogcatReader.java
diff --git a/android/src/com/tencent/wstt/gt/log/logcat/VersionHelper.java b/android/app/src/main/java/com/tencent/wstt/gt/log/logcat/VersionHelper.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/logcat/VersionHelper.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/logcat/VersionHelper.java
diff --git a/android/src/com/tencent/wstt/gt/log/logcat/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/log/logcat/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/logcat/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/logcat/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/log/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/log/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/log/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/log/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/manager/AUTClient.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/AUTClient.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/AUTClient.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/AUTClient.java
diff --git a/android/src/com/tencent/wstt/gt/manager/AUTManager.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/AUTManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/AUTManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/AUTManager.java
diff --git a/android/src/com/tencent/wstt/gt/manager/Client.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/Client.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/Client.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/Client.java
diff --git a/android/src/com/tencent/wstt/gt/manager/ClientFactory.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/ClientFactory.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/ClientFactory.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/ClientFactory.java
diff --git a/android/src/com/tencent/wstt/gt/manager/ClientManager.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/ClientManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/ClientManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/ClientManager.java
diff --git a/android/src/com/tencent/wstt/gt/manager/ConnectedClient.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/ConnectedClient.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/ConnectedClient.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/ConnectedClient.java
diff --git a/android/src/com/tencent/wstt/gt/manager/ConnectedClientFactory.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/ConnectedClientFactory.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/ConnectedClientFactory.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/ConnectedClientFactory.java
diff --git a/android/src/com/tencent/wstt/gt/manager/ConnectedOutParaManager.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/ConnectedOutParaManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/ConnectedOutParaManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/ConnectedOutParaManager.java
diff --git a/android/src/com/tencent/wstt/gt/manager/DefaultClient.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/DefaultClient.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/DefaultClient.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/DefaultClient.java
diff --git a/android/src/com/tencent/wstt/gt/manager/DefaultInParaManager.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/DefaultInParaManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/DefaultInParaManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/DefaultInParaManager.java
diff --git a/android/src/com/tencent/wstt/gt/manager/DefaultOutParaManager.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/DefaultOutParaManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/DefaultOutParaManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/DefaultOutParaManager.java
diff --git a/android/src/com/tencent/wstt/gt/manager/EmptyClient.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/EmptyClient.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/EmptyClient.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/EmptyClient.java
diff --git a/android/src/com/tencent/wstt/gt/manager/EmptyInParaManager.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/EmptyInParaManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/EmptyInParaManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/EmptyInParaManager.java
diff --git a/android/src/com/tencent/wstt/gt/manager/EmptyOutParaManager.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/EmptyOutParaManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/EmptyOutParaManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/EmptyOutParaManager.java
diff --git a/android/src/com/tencent/wstt/gt/manager/GlobalClient.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/GlobalClient.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/GlobalClient.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/GlobalClient.java
diff --git a/android/src/com/tencent/wstt/gt/manager/IInParaManager.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/IInParaManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/IInParaManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/IInParaManager.java
diff --git a/android/src/com/tencent/wstt/gt/manager/IOutParaManager.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/IOutParaManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/IOutParaManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/IOutParaManager.java
diff --git a/android/src/com/tencent/wstt/gt/manager/IpUIManager.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/IpUIManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/IpUIManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/IpUIManager.java
diff --git a/android/src/com/tencent/wstt/gt/manager/OpPerfBridge.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/OpPerfBridge.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/OpPerfBridge.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/OpPerfBridge.java
diff --git a/android/src/com/tencent/wstt/gt/manager/OpPerfManager.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/OpPerfManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/OpPerfManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/OpPerfManager.java
diff --git a/android/src/com/tencent/wstt/gt/manager/OpUIManager.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/OpUIManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/OpUIManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/OpUIManager.java
diff --git a/android/src/com/tencent/wstt/gt/manager/OpWarningManager.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/OpWarningManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/OpWarningManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/OpWarningManager.java
diff --git a/android/src/com/tencent/wstt/gt/manager/ParamConst.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/ParamConst.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/ParamConst.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/ParamConst.java
diff --git a/android/src/com/tencent/wstt/gt/manager/SingleInstanceClientFactory.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/SingleInstanceClientFactory.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/SingleInstanceClientFactory.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/SingleInstanceClientFactory.java
diff --git a/android/src/com/tencent/wstt/gt/manager/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/manager/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/manager/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/manager/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/BaseService.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/BaseService.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/BaseService.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/BaseService.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/PluginControler.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/PluginControler.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/PluginControler.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/PluginControler.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/PluginItem.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/PluginItem.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/PluginItem.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/PluginItem.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/PluginManager.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/PluginManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/PluginManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/PluginManager.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/PluginTaskExecutor.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/PluginTaskExecutor.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/PluginTaskExecutor.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/PluginTaskExecutor.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/battery/BTBroadcast.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/battery/BTBroadcast.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/battery/BTBroadcast.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/battery/BTBroadcast.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/battery/BatteryPluginItem.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/battery/BatteryPluginItem.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/battery/BatteryPluginItem.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/battery/BatteryPluginItem.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/battery/BatteryPluginListener.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/battery/BatteryPluginListener.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/battery/BatteryPluginListener.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/battery/BatteryPluginListener.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/battery/GTBatteryActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/battery/GTBatteryActivity.java
similarity index 96%
rename from android/src/com/tencent/wstt/gt/plugin/battery/GTBatteryActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/battery/GTBatteryActivity.java
index cb289f0..660e84d 100644
--- a/android/src/com/tencent/wstt/gt/plugin/battery/GTBatteryActivity.java
+++ b/android/app/src/main/java/com/tencent/wstt/gt/plugin/battery/GTBatteryActivity.java
@@ -1,252 +1,252 @@
-/*
- * Tencent is pleased to support the open source community by making
- * Tencent GT (Version 2.4 and subsequent versions) available.
- *
- * Notwithstanding anything to the contrary herein, any previous version
- * of Tencent GT shall not be subject to the license hereunder.
- * All right, title, and interest, including all intellectual property rights,
- * in and to the previous version of Tencent GT (including any and all copies thereof)
- * shall be owned and retained by Tencent and subject to the license under the
- * Tencent GT End User License Agreement (http://gt.qq.com/wp-content/EULA_EN.html).
- *
- * Copyright (C) 2015 THL A29 Limited, a Tencent company. All rights reserved.
- *
- * Licensed under the MIT License (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://opensource.org/licenses/MIT
- *
- * 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.tencent.wstt.gt.plugin.battery;
-
-import android.os.Bundle;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.inputmethod.EditorInfo;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.CompoundButton.OnCheckedChangeListener;
-import android.widget.EditText;
-import android.widget.TextView;
-
-import com.tencent.wstt.gt.GTApp;
-import com.tencent.wstt.gt.R;
-import com.tencent.wstt.gt.activity.GTBaseActivity;
-import com.tencent.wstt.gt.utils.ToastUtil;
-
-public class GTBatteryActivity extends GTBaseActivity
- implements BatteryPluginListener, OnCheckedChangeListener {
-
- private TextView battery_back_gt;
-
- private TextView tv_switch;
- private EditText et_refresh_rate;
- private EditText et_brightness;
-
- private CheckBox cb_I;
- private CheckBox cb_U;
- private CheckBox cb_Power;
- private CheckBox cb_Temp;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.pi_battery);
-
- battery_back_gt = (TextView)findViewById(R.id.battery_back_gt);
- battery_back_gt.setOnClickListener(back);
-
- tv_switch = (TextView)findViewById(R.id.sample_switch);
- et_refresh_rate = (EditText)findViewById(R.id.et_refresh_rate);
- et_refresh_rate.setText(Integer.toString(GTBatteryEngine.getInstance().getRefreshRate()));
- et_refresh_rate.setInputType(EditorInfo.TYPE_CLASS_PHONE);
-
- et_brightness = (EditText)findViewById(R.id.et_brightness);
- if (GTBatteryEngine.getInstance().getBrightness() > 0)
- {
- et_brightness.setText(Integer.toString(GTBatteryEngine.getInstance().getBrightness()));
- }
- et_brightness.setInputType(EditorInfo.TYPE_CLASS_PHONE);
- if (GTBatteryEngine.getInstance().isStarted())
- {
- tv_switch.setBackgroundResource(R.drawable.switch_off_border);
- tv_switch.setText(getString(R.string.stop));
- }
- else
- {
- tv_switch.setBackgroundResource(R.drawable.switch_on_border);
- tv_switch.setText(getString(R.string.start));
- }
-
- tv_switch.setOnClickListener(switchOnClickListener);
-
- cb_I = (CheckBox)findViewById(R.id.cb_I);
- cb_U = (CheckBox)findViewById(R.id.cb_U);
- cb_Power = (CheckBox)findViewById(R.id.cb_Power);
- cb_Temp = (CheckBox)findViewById(R.id.cb_Temp);
-
- cb_I.setChecked(GTBatteryEngine.getInstance().isState_cb_I());
- cb_U.setChecked(GTBatteryEngine.getInstance().isState_cb_U());
- cb_Power.setChecked(GTBatteryEngine.getInstance().isState_cb_P());
- cb_Temp.setChecked(GTBatteryEngine.getInstance().isState_cb_T());
-
- cb_I.setOnCheckedChangeListener(this);
- cb_U.setOnCheckedChangeListener(this);
- cb_Power.setOnCheckedChangeListener(this);
- cb_Temp.setOnCheckedChangeListener(this);
-
- GTBatteryEngine.getInstance().addListener(this);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- GTBatteryEngine.getInstance().removeListener(this);
- }
-
- private OnClickListener back = new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- finish();
- }
- };
-
- private OnClickListener switchOnClickListener = new OnClickListener() {
-
- @Override
- public void onClick(View v) {
-
- if (! GTBatteryEngine.getInstance().isStarted())
- {
- int refreshRate = 250;
- int brightness = -1;
- try {
- refreshRate = Integer.parseInt(et_refresh_rate.getText().toString().trim());
- }
- catch(Exception e)
- {
-// ToastUtil.ShowShortToast(this, "输入的刷新率或亮度不是数字!");
- ToastUtil.ShowShortToast(GTBatteryActivity.this, getString(R.string.pi_battery_sample_tip));
- return;
- }
-
-
- if (! et_brightness.getText().toString().trim().equals(""))
- {
- try {
- brightness = Integer.parseInt(et_brightness.getText().toString().trim());
- }
- catch(Exception e)
- {
-// ToastUtil.ShowShortToast(this, "输入的刷新率或亮度不是数字!");
- ToastUtil.ShowShortToast(GTBatteryActivity.this, getString(R.string.pi_battery_sample_tip));
- return;
- }
- }
-
- GTBatteryEngine.getInstance().doStart(refreshRate, brightness);
- }
- else
- {
- GTBatteryEngine.getInstance().doStop();
- }
- }
- };
-
- @Override
- public void onBatteryStart()
- {
- runOnUiThread(new Runnable(){
-
- @Override
- public void run() {
- tv_switch.setBackgroundResource(R.drawable.switch_off_border);
- tv_switch.setText(getString(R.string.stop));
- }
- });
- }
-
- @Override
- public void onBatteryStop()
- {
- runOnUiThread(new Runnable(){
-
- @Override
- public void run() {
- tv_switch.setBackgroundResource(R.drawable.switch_on_border);
- tv_switch.setText(getString(R.string.start));
-// ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_battery_sample_tip4);
- }
- });
- }
-
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if (GTBatteryEngine.getInstance().isStarted())
- {
- buttonView.setOnCheckedChangeListener(null);
- buttonView.setChecked(!isChecked);
- buttonView.setOnCheckedChangeListener(this);
- ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_battery_sample_tip3);
- return;
- }
-
- switch (buttonView.getId())
- {
- case R.id.cb_I:
- GTBatteryEngine.getInstance().updateI(isChecked);
- break;
-
- case R.id.cb_U:
- GTBatteryEngine.getInstance().updateU(isChecked);
- break;
-
- case R.id.cb_Power:
- GTBatteryEngine.getInstance().updateP(isChecked);
- break;
-
- case R.id.cb_Temp:
- GTBatteryEngine.getInstance().updateT(isChecked);
- break;
- }
- }
-
- @Override
- public void onBatteryException(final String e) {
- ToastUtil.ShowShortToast(GTBatteryActivity.this, e);
- }
-
- @Override
- public void onUpdateI(boolean isSelected) {
- cb_I.setOnCheckedChangeListener(null);
- cb_I.setChecked(isSelected);
- cb_I.setOnCheckedChangeListener(this);
- }
-
- @Override
- public void onUpdateU(boolean isSelected) {
- cb_U.setOnCheckedChangeListener(null);
- cb_U.setChecked(isSelected);
- cb_U.setOnCheckedChangeListener(this);
- }
-
- @Override
- public void onUpdateT(boolean isSelected) {
- cb_Temp.setOnCheckedChangeListener(null);
- cb_Temp.setChecked(isSelected);
- cb_Temp.setOnCheckedChangeListener(this);
- }
-
- @Override
- public void onUpdateP(boolean isSelected) {
- cb_Power.setOnCheckedChangeListener(null);
- cb_Power.setChecked(isSelected);
- cb_Power.setOnCheckedChangeListener(this);
- }
-}
+/*
+ * Tencent is pleased to support the open source community by making
+ * Tencent GT (Version 2.4 and subsequent versions) available.
+ *
+ * Notwithstanding anything to the contrary herein, any previous version
+ * of Tencent GT shall not be subject to the license hereunder.
+ * All right, title, and interest, including all intellectual property rights,
+ * in and to the previous version of Tencent GT (including any and all copies thereof)
+ * shall be owned and retained by Tencent and subject to the license under the
+ * Tencent GT End User License Agreement (http://gt.qq.com/wp-content/EULA_EN.html).
+ *
+ * Copyright (C) 2015 THL A29 Limited, a Tencent company. All rights reserved.
+ *
+ * Licensed under the MIT License (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://opensource.org/licenses/MIT
+ *
+ * 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.tencent.wstt.gt.plugin.battery;
+
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.inputmethod.EditorInfo;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import com.tencent.wstt.gt.GTApp;
+import com.tencent.wstt.gt.R;
+import com.tencent.wstt.gt.activity.GTBaseActivity;
+import com.tencent.wstt.gt.utils.ToastUtil;
+
+public class GTBatteryActivity extends GTBaseActivity
+ implements BatteryPluginListener, OnCheckedChangeListener {
+
+ private TextView battery_back_gt;
+
+ private TextView tv_switch;
+ private EditText et_refresh_rate;
+ private EditText et_brightness;
+
+ private CheckBox cb_I;
+ private CheckBox cb_U;
+ private CheckBox cb_Power;
+ private CheckBox cb_Temp;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.pi_battery);
+
+ battery_back_gt = (TextView)findViewById(R.id.battery_back_gt);
+ battery_back_gt.setOnClickListener(back);
+
+ tv_switch = (TextView)findViewById(R.id.sample_switch);
+ et_refresh_rate = (EditText)findViewById(R.id.et_refresh_rate);
+ et_refresh_rate.setText(Integer.toString(GTBatteryEngine.getInstance().getRefreshRate()));
+ et_refresh_rate.setInputType(EditorInfo.TYPE_CLASS_PHONE);
+
+ et_brightness = (EditText)findViewById(R.id.et_brightness);
+ if (GTBatteryEngine.getInstance().getBrightness() > 0)
+ {
+ et_brightness.setText(Integer.toString(GTBatteryEngine.getInstance().getBrightness()));
+ }
+ et_brightness.setInputType(EditorInfo.TYPE_CLASS_PHONE);
+ if (GTBatteryEngine.getInstance().isStarted())
+ {
+ tv_switch.setBackgroundResource(R.drawable.switch_off_border);
+ tv_switch.setText(getString(R.string.stop));
+ }
+ else
+ {
+ tv_switch.setBackgroundResource(R.drawable.switch_on_border);
+ tv_switch.setText(getString(R.string.start));
+ }
+
+ tv_switch.setOnClickListener(switchOnClickListener);
+
+ cb_I = (CheckBox)findViewById(R.id.cb_I);
+ cb_U = (CheckBox)findViewById(R.id.cb_U);
+ cb_Power = (CheckBox)findViewById(R.id.cb_Power);
+ cb_Temp = (CheckBox)findViewById(R.id.cb_Temp);
+
+ cb_I.setChecked(GTBatteryEngine.getInstance().isState_cb_I());
+ cb_U.setChecked(GTBatteryEngine.getInstance().isState_cb_U());
+ cb_Power.setChecked(GTBatteryEngine.getInstance().isState_cb_P());
+ cb_Temp.setChecked(GTBatteryEngine.getInstance().isState_cb_T());
+
+ cb_I.setOnCheckedChangeListener(this);
+ cb_U.setOnCheckedChangeListener(this);
+ cb_Power.setOnCheckedChangeListener(this);
+ cb_Temp.setOnCheckedChangeListener(this);
+
+ GTBatteryEngine.getInstance().addListener(this);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ GTBatteryEngine.getInstance().removeListener(this);
+ }
+
+ private OnClickListener back = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ finish();
+ }
+ };
+
+ private OnClickListener switchOnClickListener = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+
+ if (! GTBatteryEngine.getInstance().isStarted())
+ {
+ int refreshRate = 250;
+ int brightness = -1;
+ try {
+ refreshRate = Integer.parseInt(et_refresh_rate.getText().toString().trim());
+ }
+ catch(Exception e)
+ {
+// ToastUtil.ShowShortToast(this, "输入的刷新率或亮度不是数字!");
+ ToastUtil.ShowShortToast(GTBatteryActivity.this, getString(R.string.pi_battery_sample_tip));
+ return;
+ }
+
+
+ if (! et_brightness.getText().toString().trim().equals(""))
+ {
+ try {
+ brightness = Integer.parseInt(et_brightness.getText().toString().trim());
+ }
+ catch(Exception e)
+ {
+// ToastUtil.ShowShortToast(this, "输入的刷新率或亮度不是数字!");
+ ToastUtil.ShowShortToast(GTBatteryActivity.this, getString(R.string.pi_battery_sample_tip));
+ return;
+ }
+ }
+
+ GTBatteryEngine.getInstance().doStart(refreshRate, brightness);
+ }
+ else
+ {
+ GTBatteryEngine.getInstance().doStop();
+ }
+ }
+ };
+
+ @Override
+ public void onBatteryStart()
+ {
+ runOnUiThread(new Runnable(){
+
+ @Override
+ public void run() {
+ tv_switch.setBackgroundResource(R.drawable.switch_off_border);
+ tv_switch.setText(getString(R.string.stop));
+ }
+ });
+ }
+
+ @Override
+ public void onBatteryStop()
+ {
+ runOnUiThread(new Runnable(){
+
+ @Override
+ public void run() {
+ tv_switch.setBackgroundResource(R.drawable.switch_on_border);
+ tv_switch.setText(getString(R.string.start));
+// ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_battery_sample_tip4);
+ }
+ });
+ }
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (GTBatteryEngine.getInstance().isStarted())
+ {
+ buttonView.setOnCheckedChangeListener(null);
+ buttonView.setChecked(!isChecked);
+ buttonView.setOnCheckedChangeListener(this);
+ ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_battery_sample_tip3);
+ return;
+ }
+
+ switch (buttonView.getId())
+ {
+ case R.id.cb_I:
+ GTBatteryEngine.getInstance().updateI(isChecked);
+ break;
+
+ case R.id.cb_U:
+ GTBatteryEngine.getInstance().updateU(isChecked);
+ break;
+
+ case R.id.cb_Power:
+ GTBatteryEngine.getInstance().updateP(isChecked);
+ break;
+
+ case R.id.cb_Temp:
+ GTBatteryEngine.getInstance().updateT(isChecked);
+ break;
+ }
+ }
+
+ @Override
+ public void onBatteryException(final String e) {
+ ToastUtil.ShowShortToast(GTBatteryActivity.this, e);
+ }
+
+ @Override
+ public void onUpdateI(boolean isSelected) {
+ cb_I.setOnCheckedChangeListener(null);
+ cb_I.setChecked(isSelected);
+ cb_I.setOnCheckedChangeListener(this);
+ }
+
+ @Override
+ public void onUpdateU(boolean isSelected) {
+ cb_U.setOnCheckedChangeListener(null);
+ cb_U.setChecked(isSelected);
+ cb_U.setOnCheckedChangeListener(this);
+ }
+
+ @Override
+ public void onUpdateT(boolean isSelected) {
+ cb_Temp.setOnCheckedChangeListener(null);
+ cb_Temp.setChecked(isSelected);
+ cb_Temp.setOnCheckedChangeListener(this);
+ }
+
+ @Override
+ public void onUpdateP(boolean isSelected) {
+ cb_Power.setOnCheckedChangeListener(null);
+ cb_Power.setChecked(isSelected);
+ cb_Power.setOnCheckedChangeListener(this);
+ }
+}
diff --git a/android/src/com/tencent/wstt/gt/plugin/battery/GTBatteryEngine.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/battery/GTBatteryEngine.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/battery/GTBatteryEngine.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/battery/GTBatteryEngine.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/battery/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/battery/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/battery/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/battery/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/gps/GPSMockBroadcast.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GPSMockBroadcast.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/gps/GPSMockBroadcast.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GPSMockBroadcast.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/gps/GPSRecordListener.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GPSRecordListener.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/gps/GPSRecordListener.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GPSRecordListener.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/gps/GPSReplayListener.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GPSReplayListener.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/gps/GPSReplayListener.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GPSReplayListener.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/gps/GTGPSActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSActivity.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/gps/GTGPSActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSActivity.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/gps/GTGPSPluginItem.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSPluginItem.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/gps/GTGPSPluginItem.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSPluginItem.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/gps/GTGPSRecordEngine.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSRecordEngine.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/gps/GTGPSRecordEngine.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSRecordEngine.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/gps/GTGPSReplayActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSReplayActivity.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/gps/GTGPSReplayActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSReplayActivity.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/gps/GTGPSReplayEngine.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSReplayEngine.java
similarity index 96%
rename from android/src/com/tencent/wstt/gt/plugin/gps/GTGPSReplayEngine.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSReplayEngine.java
index 0bb0b32..b6760cd 100644
--- a/android/src/com/tencent/wstt/gt/plugin/gps/GTGPSReplayEngine.java
+++ b/android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSReplayEngine.java
@@ -1,544 +1,544 @@
-/*
- * Tencent is pleased to support the open source community by making
- * Tencent GT (Version 2.4 and subsequent versions) available.
- *
- * Notwithstanding anything to the contrary herein, any previous version
- * of Tencent GT shall not be subject to the license hereunder.
- * All right, title, and interest, including all intellectual property rights,
- * in and to the previous version of Tencent GT (including any and all copies thereof)
- * shall be owned and retained by Tencent and subject to the license under the
- * Tencent GT End User License Agreement (http://gt.qq.com/wp-content/EULA_EN.html).
- *
- * Copyright (C) 2015 THL A29 Limited, a Tencent company. All rights reserved.
- *
- * Licensed under the MIT License (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://opensource.org/licenses/MIT
- *
- * 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.tencent.wstt.gt.plugin.gps;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.tencent.wstt.gt.GTApp;
-import com.tencent.wstt.gt.R;
-import com.tencent.wstt.gt.api.utils.Env;
-import com.tencent.wstt.gt.plugin.BaseService;
-import com.tencent.wstt.gt.utils.FileUtil;
-import com.tencent.wstt.gt.utils.GTUtils;
-import com.tencent.wstt.gt.utils.ToastUtil;
-
-import android.content.Context;
-import android.content.Intent;
-import android.location.Location;
-import android.location.LocationManager;
-import android.location.LocationProvider;
-import android.os.AsyncTask;
-import android.os.IBinder;
-import android.util.Log;
-
-/**
- * GPS回放引擎
- */
-public class GTGPSReplayEngine extends BaseService {
- private static GTGPSReplayEngine INSTANCE;
- private MockGpsProvider mMockGpsProviderTask = null;
- private LocationManager locationManager = null;
-
- private List listeners;
- private boolean isReplay = false;
- public String selectedItem;
- public int selectedItemPos = -1;
-
- /*回放gps文件的总长度*/
- public int mGPSFileLength = 0;
- /*回放gps文件的当前进度*/
- public int index = 0;
- /*回放速率*/
- public int mreplayspeed;
-
- private static final String GPS_MOCK_ACTION = "com.tencent.wstt.gt.ACTION_GPS_MOCK";
-
- public static GTGPSReplayEngine getInstance() {
- if (null == INSTANCE) {
- INSTANCE = new GTGPSReplayEngine();
- }
- return INSTANCE;
- }
-
- private GTGPSReplayEngine()
- {
- listeners = new ArrayList();
- }
-
- public synchronized void addListener(GPSReplayListener listener)
- {
- listeners.add(listener);
- }
-
- public synchronized void removeListener(GPSReplayListener listener)
- {
- listeners.remove(listener);
- }
-
- synchronized public boolean isReplay()
- {
- return isReplay;
- }
-
- @Override
- public void onCreate(Context context) {
- super.onCreate(context);
- locationManager = (LocationManager) context
- .getSystemService(Context.LOCATION_SERVICE);
- }
-
- @Override
- public void onStart(Intent intent) {
- super.onStart(intent);
- if (null == intent)
- {
- return;
- }
-
- selectedItemPos = intent.getIntExtra("seq", -1);
- int progess = Math.min(100, intent.getIntExtra("progress", 0));
- mreplayspeed = intent.getIntExtra("replayspeed", 1);
- index = getGPSFileLength() * progess / 100;
- if (-1 == selectedItemPos)
- {
- selectedItem = intent.getStringExtra("filename");
- if (null == selectedItem)
- {
- // 还有一种可能是直接提供给服务的是经纬度坐标
- String lng = intent.getStringExtra("lng");
- String lat = intent.getStringExtra("lat");
- if (lng == null || lat == null)
- {
- // 通知观察者需要选择一个文件或文件序号
- for (GPSReplayListener listener : listeners)
- {
- listener.onReplayFail(
- GTApp.getContext().getString(R.string.pi_gps_replay_tip));
- }
- }
- else
- {
- replay(lng, lat);
- }
- }
- else
- {
- // 按文件名回放
- replay(selectedItem);
- }
- }
- else // 按序号回放
- {
- // 先找好对应的文件名,再按文件名回放
- ArrayList items = GTGPSUtils.getGPSFileList();
- if (items.size() > 0 && items.size() > selectedItemPos && !items.get(0).equals("empty"))
- replay(items.get(selectedItemPos));
- }
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- stopReplay(); // 停止回放
- }
-
- @Override
- public IBinder onBind() {
- return null;
- }
-
- private boolean isAllowMock()
- {
- if (!locationManager.isProviderEnabled(MockGpsProvider.GPS_MOCK_PROVIDER)) {
- try
- {
- locationManager.addTestProvider(MockGpsProvider.GPS_MOCK_PROVIDER,
- false, false, false, false, true, false, false, 0, 5);
- locationManager.setTestProviderEnabled(
- MockGpsProvider.GPS_MOCK_PROVIDER, true);
- }
- catch(SecurityException e)
- {
- // 如果之前未在开发者选项中手动打开“允许模拟GPS”,这里可能会抛安全异常
- for (GPSReplayListener listener : listeners)
- {
- listener.onReplayFail(
- GTApp.getContext().getString(R.string.pi_gps_warn_tip));
- }
- return false;
- }
- }
- return true;
- }
-
- /*
- * 模拟指定点
- */
- private void replay(String sLng, String sLat)
- {
- if (! isAllowMock())
- {
- return;
- }
-
- if (locationManager.isProviderEnabled(MockGpsProvider.GPS_MOCK_PROVIDER)) {
- try {
- double lng = Double.parseDouble(sLng);
- double lat = Double.parseDouble(sLat);
-
- // check坐标点的合法性
- if (lng < -180 || lng > 180 || lat < -90 || lat > 90)
- {
- // 通知观察者
- for (GPSReplayListener listener : listeners)
- {
- listener.onReplayFail(
- GTApp.getContext().getString(R.string.pi_gps_warn_tip2));
- }
- return;
- }
- // 为了使用AsyncTask需要转普通数组
- StringBuilder sb = new StringBuilder();
- sb.append(lng);
- sb.append(",");
- sb.append(lat);
- sb.append(",");
- sb.append(0);
- sb.append(",");
- sb.append(0);
- sb.append(",");
- sb.append(0);
- sb.append(",");
- sb.append(0); // 时间,不过不关注填啥
- sb.append(",");
- sb.append(0);
- sb.append(",");
- sb.append(0);
- String[] coordinates = new String[]{sb.toString()};
-
- if (mMockGpsProviderTask == null) {
- String replayRecordFileName = GTUtils.getSaveDate() + "_.gps";
- mMockGpsProviderTask = new MockGpsProvider(replayRecordFileName);
- }
- isReplay = true;
- mMockGpsProviderTask.execute(coordinates);
- } catch (Exception e) {
- isReplay = false;
- return;
- }
- }
- }
-
- /*
- * 模拟轨迹
- */
- private void replay(String fileName)
- {
- if (! isAllowMock())
- {
- return;
- }
-
- if (locationManager.isProviderEnabled(MockGpsProvider.GPS_MOCK_PROVIDER)) {
- BufferedReader reader= null;
- try {
- List data = new ArrayList();
-
- File f = new File(Env.ROOT_GPS_FOLDER, fileName);
- InputStream is = new FileInputStream(f);
- reader = new BufferedReader(new InputStreamReader(is));
-
- String line = null;
- while ((line = reader.readLine()) != null) {
- data.add(line);
- }
- if (data.size() == 0)
- {
- // 通知观察者
- for (GPSReplayListener listener : listeners)
- {
- listener.onReplayFail(
- GTApp.getContext().getString(R.string.pi_gps_warn_tip2));
- }
- return;
- }
- mGPSFileLength = data.size();
- // 为了使用AsyncTask需要转普通数组
- String[] coordinates = new String[mGPSFileLength];
- data.toArray(coordinates);
-
- if (mMockGpsProviderTask == null) {
- mMockGpsProviderTask = new MockGpsProvider(selectedItem);
- }
- isReplay = true;
- mMockGpsProviderTask.execute(coordinates);
- } catch (Exception e) {
- isReplay = false;
- return;
- }
- finally
- {
- FileUtil.closeReader(reader);
- }
- }
- }
-
- private void stopReplay()
- {
- isReplay = false;
- try {
- stopMockLocation();
- } catch (Exception e) {
- }
- }
-
- private void sendMockBroadcast(Context context, String type)
- {
- Intent intent = new Intent();
- intent.setAction(GPS_MOCK_ACTION);
- intent.putExtra("type", type);
- context.sendBroadcast(intent);
- }
-
- /**
- * add on 20140630
- * 退出应用前也需要调用停止模拟位置,否则手机的正常GPS定位不会恢复
- */
- public void stopMockLocation()
- {
- try {
- mMockGpsProviderTask.cancel(true);
- mMockGpsProviderTask = null;
- } catch (Exception e) {
- }
-
- try {
- LocationManager locationManager = (LocationManager)
- GTApp.getContext().getSystemService(Context.LOCATION_SERVICE);
- locationManager
- .removeTestProvider(MockGpsProvider.GPS_MOCK_PROVIDER);
- } catch (Exception e) {
- }
-
- sendMockBroadcast(GTApp.getContext(), "stop");
- }
-
- /**
- * 得带当前GPS回放到了百分之多少
- */
- public double getPercentage() {
- if (mGPSFileLength != 0 && index != 0) {
- return ((double) index / (double) mGPSFileLength);
- }
- return 0.0;
- }
-
- /**
- * 得带当前GPS回放速率
- */
- public int getReplaySpeed() {
- return mreplayspeed;
- }
-
- /**
- * 得带当前GPS回放文件的总数
- */
- public int getGPSFileLength() {
- return mGPSFileLength;
- }
-
- private class MockGpsProvider extends AsyncTask {
- public static final String LOG_TAG = "GpsMockProvider";
- public static final String GPS_MOCK_PROVIDER = LocationManager.GPS_PROVIDER;
- public String orgiFileName;
-
-// public Integer index = 0;
-
- public MockGpsProvider(String fileName)
- {
- this.orgiFileName = fileName;
- }
-
- @Override
- protected Void doInBackground(String... data) {
-
- boolean hasMockEnd = false;
-
- double nowtimeStamp;
- List timezones = new ArrayList();
-
- sendMockBroadcast(GTApp.getContext(), "start");
-
- for (GPSReplayListener listener : listeners)
- {
- listener.onReplayStart();
- }
-
-
- /*
- * 修改为保持最后1点的位置
- */
- while(true)
- {
- if (!isReplay()) {
- break;
- }
- String str = data[index];// 先获取当前点,下一句就index就切到下一个了
- if (index < data.length - 1) // 到最后一点就不加序号了
- {
- // add on 20141216 赶在index++前把本点回放的时间记录了
- timezones.add(System.currentTimeMillis());
- if (index + mreplayspeed > data.length - 1) {
- index++;
- } else {
- index += mreplayspeed;
- }
-
- }
- // add on 20150108 到最后一点立即发出广播通知测试程序回放逻辑已结束
- else if (!hasMockEnd) {
- sendMockBroadcast(GTApp.getContext(), "end");
- hasMockEnd = true;
-
- for (GPSReplayListener listener : listeners)
- {
- listener.onReplayEnd();
- }
- }
-
- Location location = new Location(GPS_MOCK_PROVIDER);
-
- try {
- String[] parts = str.split(",");
- nowtimeStamp = Double.valueOf(parts[6]);
- location.setTime(System.currentTimeMillis());
- location.setLatitude(Double.valueOf(parts[1]));
- location.setLongitude(Double.valueOf(parts[0]));
- location.setAccuracy((Float.valueOf(parts[2])));
- location.setAltitude(Double.valueOf(parts[7]));
- location.setBearing(Float.valueOf(parts[3]));
- location.setSpeed(Float.valueOf(parts[4]));
- /*
- * 因为setElapsedRealtimeNanos在Android4.0后才支持,
- * 为了避免Android4.0之后报异常,用反射的方式补完location对象
- * location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
- */
- try
- {
- Method method = Location.class.getMethod("makeComplete");
- if (method != null) {
- method.invoke(location);
- }
- }
- catch (NoSuchMethodException e) {
- // Andorid4.0以下没有这个方法,直接跳过即可
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- catch (Exception e) {
- break;
- }
-
- Log.i(LOG_TAG, location.toString());
-
- // 提供新的位置信息
- try
- {
- locationManager.addTestProvider(
- LocationManager.GPS_PROVIDER,
- "requiresNetwork" == "", "requiresSatellite" == "",
- "requiresCell" == "", "hasMonetaryCost" == "",
- "supportsAltitude" == "supportsAltitude",
- "supportsSpeed" == "supportsSpeed",
- "supportsBearing" == "supportsBearing",
- android.location.Criteria.POWER_LOW,
- android.location.Criteria.ACCURACY_FINE);
- locationManager.setTestProviderStatus(GPS_MOCK_PROVIDER,
- LocationProvider.AVAILABLE, null,
- System.currentTimeMillis());
- locationManager.setTestProviderLocation(GPS_MOCK_PROVIDER,
- location);
- }
- catch(Exception e)
- {
- // 如果未开位置模拟,这里可能出异常
- ToastUtil.ShowLongToast(GTApp.getContext(),
- GTApp.getContext().getString(R.string.pi_gps_warn_tip));
- break;
- }
-
- // 如果是最后一点,默认停2s
- if (index == data.length - 1)
- {
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
-
- }
- }
- else
- {
- // 如果是最后一点,间隔默认按2s算
- int interval = 2000;
- try {
- if (index < data.length) {
- String next = data[index];
- String[] parts = next.split(",");
- interval = (int) ((Double.valueOf(parts[6]) - nowtimeStamp) * 1000);
-
- if (interval <= 0) // 针对复制的数据,时间间隔没错开的情况的保护
- {
- interval = 2000;
- }
- }
- Log.i("interval", String.valueOf(interval));
- if (mreplayspeed == 1)
- {
- Thread.sleep(interval);
- }
- else
- {
- Thread.sleep(1000);
- }
- if (Thread.currentThread().isInterrupted())
- throw new InterruptedException("");
- } catch (InterruptedException e) {
- break;
- }
- }
- }
-
- index = 0;
- for (GPSReplayListener listener : listeners)
- {
- listener.onReplayStop();
- }
-
- return null;
- }
-
- @Override
- protected void onProgressUpdate(Integer... values) {
- Log.d(LOG_TAG, "onProgressUpdate():" + values[0]);
- }
- }
-}
+/*
+ * Tencent is pleased to support the open source community by making
+ * Tencent GT (Version 2.4 and subsequent versions) available.
+ *
+ * Notwithstanding anything to the contrary herein, any previous version
+ * of Tencent GT shall not be subject to the license hereunder.
+ * All right, title, and interest, including all intellectual property rights,
+ * in and to the previous version of Tencent GT (including any and all copies thereof)
+ * shall be owned and retained by Tencent and subject to the license under the
+ * Tencent GT End User License Agreement (http://gt.qq.com/wp-content/EULA_EN.html).
+ *
+ * Copyright (C) 2015 THL A29 Limited, a Tencent company. All rights reserved.
+ *
+ * Licensed under the MIT License (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://opensource.org/licenses/MIT
+ *
+ * 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.tencent.wstt.gt.plugin.gps;
+
+import android.content.Context;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationManager;
+import android.location.LocationProvider;
+import android.os.AsyncTask;
+import android.os.IBinder;
+import android.util.Log;
+
+import com.tencent.wstt.gt.GTApp;
+import com.tencent.wstt.gt.R;
+import com.tencent.wstt.gt.api.utils.Env;
+import com.tencent.wstt.gt.plugin.BaseService;
+import com.tencent.wstt.gt.utils.FileUtil;
+import com.tencent.wstt.gt.utils.GTUtils;
+import com.tencent.wstt.gt.utils.ToastUtil;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * GPS回放引擎
+ */
+public class GTGPSReplayEngine extends BaseService {
+ private static GTGPSReplayEngine INSTANCE;
+ private MockGpsProvider mMockGpsProviderTask = null;
+ private LocationManager locationManager = null;
+
+ private List listeners;
+ private boolean isReplay = false;
+ public String selectedItem;
+ public int selectedItemPos = -1;
+
+ /*回放gps文件的总长度*/
+ public int mGPSFileLength = 0;
+ /*回放gps文件的当前进度*/
+ public int index = 0;
+ /*回放速率*/
+ public int mreplayspeed;
+
+ private static final String GPS_MOCK_ACTION = "com.tencent.wstt.gt.ACTION_GPS_MOCK";
+
+ public static GTGPSReplayEngine getInstance() {
+ if (null == INSTANCE) {
+ INSTANCE = new GTGPSReplayEngine();
+ }
+ return INSTANCE;
+ }
+
+ private GTGPSReplayEngine()
+ {
+ listeners = new ArrayList();
+ }
+
+ public synchronized void addListener(GPSReplayListener listener)
+ {
+ listeners.add(listener);
+ }
+
+ public synchronized void removeListener(GPSReplayListener listener)
+ {
+ listeners.remove(listener);
+ }
+
+ synchronized public boolean isReplay()
+ {
+ return isReplay;
+ }
+
+ @Override
+ public void onCreate(Context context) {
+ super.onCreate(context);
+ locationManager = (LocationManager) context
+ .getSystemService(Context.LOCATION_SERVICE);
+ }
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ if (null == intent)
+ {
+ return;
+ }
+
+ selectedItemPos = intent.getIntExtra("seq", -1);
+ int progess = Math.min(100, intent.getIntExtra("progress", 0));
+ mreplayspeed = intent.getIntExtra("replayspeed", 1);
+ index = getGPSFileLength() * progess / 100;
+ if (-1 == selectedItemPos)
+ {
+ selectedItem = intent.getStringExtra("filename");
+ if (null == selectedItem)
+ {
+ // 还有一种可能是直接提供给服务的是经纬度坐标
+ String lng = intent.getStringExtra("lng");
+ String lat = intent.getStringExtra("lat");
+ if (lng == null || lat == null)
+ {
+ // 通知观察者需要选择一个文件或文件序号
+ for (GPSReplayListener listener : listeners)
+ {
+ listener.onReplayFail(
+ GTApp.getContext().getString(R.string.pi_gps_replay_tip));
+ }
+ }
+ else
+ {
+ replay(lng, lat);
+ }
+ }
+ else
+ {
+ // 按文件名回放
+ replay(selectedItem);
+ }
+ }
+ else // 按序号回放
+ {
+ // 先找好对应的文件名,再按文件名回放
+ ArrayList items = GTGPSUtils.getGPSFileList();
+ if (items.size() > 0 && items.size() > selectedItemPos && !items.get(0).equals("empty"))
+ replay(items.get(selectedItemPos));
+ }
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ stopReplay(); // 停止回放
+ }
+
+ @Override
+ public IBinder onBind() {
+ return null;
+ }
+
+ private boolean isAllowMock()
+ {
+ if (!locationManager.isProviderEnabled(MockGpsProvider.GPS_MOCK_PROVIDER)) {
+ try
+ {
+ locationManager.addTestProvider(MockGpsProvider.GPS_MOCK_PROVIDER,
+ false, false, false, false, true, false, false, 0, 5);
+ locationManager.setTestProviderEnabled(
+ MockGpsProvider.GPS_MOCK_PROVIDER, true);
+ }
+ catch(SecurityException e)
+ {
+ // 如果之前未在开发者选项中手动打开“允许模拟GPS”,这里可能会抛安全异常
+ for (GPSReplayListener listener : listeners)
+ {
+ listener.onReplayFail(
+ GTApp.getContext().getString(R.string.pi_gps_warn_tip));
+ }
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /*
+ * 模拟指定点
+ */
+ private void replay(String sLng, String sLat)
+ {
+ if (! isAllowMock())
+ {
+ return;
+ }
+
+ if (locationManager.isProviderEnabled(MockGpsProvider.GPS_MOCK_PROVIDER)) {
+ try {
+ double lng = Double.parseDouble(sLng);
+ double lat = Double.parseDouble(sLat);
+
+ // check坐标点的合法性
+ if (lng < -180 || lng > 180 || lat < -90 || lat > 90)
+ {
+ // 通知观察者
+ for (GPSReplayListener listener : listeners)
+ {
+ listener.onReplayFail(
+ GTApp.getContext().getString(R.string.pi_gps_warn_tip2));
+ }
+ return;
+ }
+ // 为了使用AsyncTask需要转普通数组
+ StringBuilder sb = new StringBuilder();
+ sb.append(lng);
+ sb.append(",");
+ sb.append(lat);
+ sb.append(",");
+ sb.append(0);
+ sb.append(",");
+ sb.append(0);
+ sb.append(",");
+ sb.append(0);
+ sb.append(",");
+ sb.append(0); // 时间,不过不关注填啥
+ sb.append(",");
+ sb.append(0);
+ sb.append(",");
+ sb.append(0);
+ String[] coordinates = new String[]{sb.toString()};
+
+ if (mMockGpsProviderTask == null) {
+ String replayRecordFileName = GTUtils.getSaveDate() + "_.gps";
+ mMockGpsProviderTask = new MockGpsProvider(replayRecordFileName);
+ }
+ isReplay = true;
+ mMockGpsProviderTask.execute(coordinates);
+ } catch (Exception e) {
+ isReplay = false;
+ return;
+ }
+ }
+ }
+
+ /*
+ * 模拟轨迹
+ */
+ private void replay(String fileName)
+ {
+ if (! isAllowMock())
+ {
+ return;
+ }
+
+ if (locationManager.isProviderEnabled(MockGpsProvider.GPS_MOCK_PROVIDER)) {
+ BufferedReader reader= null;
+ try {
+ List data = new ArrayList();
+
+ File f = new File(Env.ROOT_GPS_FOLDER, fileName);
+ InputStream is = new FileInputStream(f);
+ reader = new BufferedReader(new InputStreamReader(is));
+
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ data.add(line);
+ }
+ if (data.size() == 0)
+ {
+ // 通知观察者
+ for (GPSReplayListener listener : listeners)
+ {
+ listener.onReplayFail(
+ GTApp.getContext().getString(R.string.pi_gps_warn_tip2));
+ }
+ return;
+ }
+ mGPSFileLength = data.size();
+ // 为了使用AsyncTask需要转普通数组
+ String[] coordinates = new String[mGPSFileLength];
+ data.toArray(coordinates);
+
+ if (mMockGpsProviderTask == null) {
+ mMockGpsProviderTask = new MockGpsProvider(selectedItem);
+ }
+ isReplay = true;
+ mMockGpsProviderTask.execute(coordinates);
+ } catch (Exception e) {
+ isReplay = false;
+ return;
+ }
+ finally
+ {
+ FileUtil.closeReader(reader);
+ }
+ }
+ }
+
+ private void stopReplay()
+ {
+ isReplay = false;
+ try {
+ stopMockLocation();
+ } catch (Exception e) {
+ }
+ }
+
+ private void sendMockBroadcast(Context context, String type)
+ {
+ Intent intent = new Intent();
+ intent.setAction(GPS_MOCK_ACTION);
+ intent.putExtra("type", type);
+ context.sendBroadcast(intent);
+ }
+
+ /**
+ * add on 20140630
+ * 退出应用前也需要调用停止模拟位置,否则手机的正常GPS定位不会恢复
+ */
+ public void stopMockLocation()
+ {
+ try {
+ mMockGpsProviderTask.cancel(true);
+ mMockGpsProviderTask = null;
+ } catch (Exception e) {
+ }
+
+ try {
+ LocationManager locationManager = (LocationManager)
+ GTApp.getContext().getSystemService(Context.LOCATION_SERVICE);
+ locationManager
+ .removeTestProvider(MockGpsProvider.GPS_MOCK_PROVIDER);
+ } catch (Exception e) {
+ }
+
+ sendMockBroadcast(GTApp.getContext(), "stop");
+ }
+
+ /**
+ * 得带当前GPS回放到了百分之多少
+ */
+ public double getPercentage() {
+ if (mGPSFileLength != 0 && index != 0) {
+ return ((double) index / (double) mGPSFileLength);
+ }
+ return 0.0;
+ }
+
+ /**
+ * 得带当前GPS回放速率
+ */
+ public int getReplaySpeed() {
+ return mreplayspeed;
+ }
+
+ /**
+ * 得带当前GPS回放文件的总数
+ */
+ public int getGPSFileLength() {
+ return mGPSFileLength;
+ }
+
+ private class MockGpsProvider extends AsyncTask {
+ public static final String LOG_TAG = "GpsMockProvider";
+ public static final String GPS_MOCK_PROVIDER = LocationManager.GPS_PROVIDER;
+ public String orgiFileName;
+
+// public Integer index = 0;
+
+ public MockGpsProvider(String fileName)
+ {
+ this.orgiFileName = fileName;
+ }
+
+ @Override
+ protected Void doInBackground(String... data) {
+
+ boolean hasMockEnd = false;
+
+ double nowtimeStamp;
+ List timezones = new ArrayList();
+
+ sendMockBroadcast(GTApp.getContext(), "start");
+
+ for (GPSReplayListener listener : listeners)
+ {
+ listener.onReplayStart();
+ }
+
+
+ /*
+ * 修改为保持最后1点的位置
+ */
+ while(true)
+ {
+ if (!isReplay()) {
+ break;
+ }
+ String str = data[index];// 先获取当前点,下一句就index就切到下一个了
+ if (index < data.length - 1) // 到最后一点就不加序号了
+ {
+ // add on 20141216 赶在index++前把本点回放的时间记录了
+ timezones.add(System.currentTimeMillis());
+ if (index + mreplayspeed > data.length - 1) {
+ index++;
+ } else {
+ index += mreplayspeed;
+ }
+
+ }
+ // add on 20150108 到最后一点立即发出广播通知测试程序回放逻辑已结束
+ else if (!hasMockEnd) {
+ sendMockBroadcast(GTApp.getContext(), "end");
+ hasMockEnd = true;
+
+ for (GPSReplayListener listener : listeners)
+ {
+ listener.onReplayEnd();
+ }
+ }
+
+ Location location = new Location(GPS_MOCK_PROVIDER);
+
+ try {
+ String[] parts = str.split(",");
+ nowtimeStamp = Double.valueOf(parts[6]);
+ location.setTime(System.currentTimeMillis());
+ location.setLatitude(Double.valueOf(parts[1]));
+ location.setLongitude(Double.valueOf(parts[0]));
+ location.setAccuracy((Float.valueOf(parts[2])));
+ location.setAltitude(Double.valueOf(parts[7]));
+ location.setBearing(Float.valueOf(parts[3]));
+ location.setSpeed(Float.valueOf(parts[4]));
+ /*
+ * 因为setElapsedRealtimeNanos在Android4.0后才支持,
+ * 为了避免Android4.0之后报异常,用反射的方式补完location对象
+ * location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
+ */
+ try
+ {
+ Method method = Location.class.getMethod("makeComplete");
+ if (method != null) {
+ method.invoke(location);
+ }
+ }
+ catch (NoSuchMethodException e) {
+ // Andorid4.0以下没有这个方法,直接跳过即可
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ catch (Exception e) {
+ break;
+ }
+
+ Log.i(LOG_TAG, location.toString());
+
+ // 提供新的位置信息
+ try
+ {
+ locationManager.addTestProvider(
+ LocationManager.GPS_PROVIDER,
+ "requiresNetwork" == "", "requiresSatellite" == "",
+ "requiresCell" == "", "hasMonetaryCost" == "",
+ "supportsAltitude" == "supportsAltitude",
+ "supportsSpeed" == "supportsSpeed",
+ "supportsBearing" == "supportsBearing",
+ android.location.Criteria.POWER_LOW,
+ android.location.Criteria.ACCURACY_FINE);
+ locationManager.setTestProviderStatus(GPS_MOCK_PROVIDER,
+ LocationProvider.AVAILABLE, null,
+ System.currentTimeMillis());
+ locationManager.setTestProviderLocation(GPS_MOCK_PROVIDER,
+ location);
+ }
+ catch(Exception e)
+ {
+ // 如果未开位置模拟,这里可能出异常
+ ToastUtil.ShowLongToast(GTApp.getContext(),
+ GTApp.getContext().getString(R.string.pi_gps_warn_tip));
+ break;
+ }
+
+ // 如果是最后一点,默认停2s
+ if (index == data.length - 1)
+ {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+
+ }
+ }
+ else
+ {
+ // 如果是最后一点,间隔默认按2s算
+ int interval = 2000;
+ try {
+ if (index < data.length) {
+ String next = data[index];
+ String[] parts = next.split(",");
+ interval = (int) ((Double.valueOf(parts[6]) - nowtimeStamp) * 1000);
+
+ if (interval <= 0) // 针对复制的数据,时间间隔没错开的情况的保护
+ {
+ interval = 2000;
+ }
+ }
+ Log.i("interval", String.valueOf(interval));
+ if (mreplayspeed == 1)
+ {
+ Thread.sleep(interval);
+ }
+ else
+ {
+ Thread.sleep(1000);
+ }
+ if (Thread.currentThread().isInterrupted())
+ throw new InterruptedException("");
+ } catch (InterruptedException e) {
+ break;
+ }
+ }
+ }
+
+ index = 0;
+ for (GPSReplayListener listener : listeners)
+ {
+ listener.onReplayStop();
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void onProgressUpdate(Integer... values) {
+ Log.d(LOG_TAG, "onProgressUpdate():" + values[0]);
+ }
+ }
+}
diff --git a/android/src/com/tencent/wstt/gt/plugin/gps/GTGPSTaskExecutor.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSTaskExecutor.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/gps/GTGPSTaskExecutor.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSTaskExecutor.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/gps/GTGPSTool.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSTool.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/gps/GTGPSTool.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSTool.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/gps/GTGPSUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSUtils.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/gps/GTGPSUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/gps/GTGPSUtils.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/internal/BaseServiceConnection.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/internal/BaseServiceConnection.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/internal/BaseServiceConnection.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/internal/BaseServiceConnection.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/internal/PluginService.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/internal/PluginService.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/internal/PluginService.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/internal/PluginService.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/internal/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/internal/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/internal/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/internal/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/listener/IPluginListener.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/listener/IPluginListener.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/listener/IPluginListener.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/listener/IPluginListener.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/listener/PluginListener.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/listener/PluginListener.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/listener/PluginListener.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/listener/PluginListener.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/listener/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/listener/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/listener/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/listener/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/memfill/GTMemFillActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/memfill/GTMemFillActivity.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/memfill/GTMemFillActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/memfill/GTMemFillActivity.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/memfill/GTMemFillEngine.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/memfill/GTMemFillEngine.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/memfill/GTMemFillEngine.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/memfill/GTMemFillEngine.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/memfill/GTMemFillListener.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/memfill/GTMemFillListener.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/memfill/GTMemFillListener.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/memfill/GTMemFillListener.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/memfill/GTMemFillPluginItem.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/memfill/GTMemFillPluginItem.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/memfill/GTMemFillPluginItem.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/memfill/GTMemFillPluginItem.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/memfill/MFBroadcast.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/memfill/MFBroadcast.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/memfill/MFBroadcast.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/memfill/MFBroadcast.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/memfill/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/memfill/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/memfill/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/memfill/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/screenlock/GTScreenlockActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/screenlock/GTScreenlockActivity.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/screenlock/GTScreenlockActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/screenlock/GTScreenlockActivity.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/screenlock/PartialWakeLock.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/screenlock/PartialWakeLock.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/screenlock/PartialWakeLock.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/screenlock/PartialWakeLock.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/screenlock/ScreenWakeLock.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/screenlock/ScreenWakeLock.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/screenlock/ScreenWakeLock.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/screenlock/ScreenWakeLock.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/screenlock/ScreenlockPluginItem.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/screenlock/ScreenlockPluginItem.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/screenlock/ScreenlockPluginItem.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/screenlock/ScreenlockPluginItem.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/screenlock/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/screenlock/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/screenlock/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/screenlock/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/smtools/SMActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMActivity.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/smtools/SMActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMActivity.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/smtools/SMBroadcast.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMBroadcast.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/smtools/SMBroadcast.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMBroadcast.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/smtools/SMDataService.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMDataService.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/smtools/SMDataService.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMDataService.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/smtools/SMLogService.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMLogService.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/smtools/SMLogService.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMLogService.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/smtools/SMPluginListener.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMPluginListener.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/smtools/SMPluginListener.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMPluginListener.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/smtools/SMServiceHelper.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMServiceHelper.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/smtools/SMServiceHelper.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMServiceHelper.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/smtools/SMToolsPluginItem.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMToolsPluginItem.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/smtools/SMToolsPluginItem.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/SMToolsPluginItem.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/smtools/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/smtools/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/smtools/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/tcpdump/CaptureBroadcast.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/tcpdump/CaptureBroadcast.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/tcpdump/CaptureBroadcast.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/tcpdump/CaptureBroadcast.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/tcpdump/GTCaptureActivity.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/tcpdump/GTCaptureActivity.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/tcpdump/GTCaptureActivity.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/tcpdump/GTCaptureActivity.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/tcpdump/GTCaptureEngine.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/tcpdump/GTCaptureEngine.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/tcpdump/GTCaptureEngine.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/tcpdump/GTCaptureEngine.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/tcpdump/GTCaptureListener.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/tcpdump/GTCaptureListener.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/tcpdump/GTCaptureListener.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/tcpdump/GTCaptureListener.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/tcpdump/TcpdumpPluginItem.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/tcpdump/TcpdumpPluginItem.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/tcpdump/TcpdumpPluginItem.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/tcpdump/TcpdumpPluginItem.java
diff --git a/android/src/com/tencent/wstt/gt/plugin/tcpdump/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/plugin/tcpdump/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/plugin/tcpdump/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/plugin/tcpdump/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/proInfo/floatView/GTMemHelperFloatview.java b/android/app/src/main/java/com/tencent/wstt/gt/proInfo/floatView/GTMemHelperFloatview.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/proInfo/floatView/GTMemHelperFloatview.java
rename to android/app/src/main/java/com/tencent/wstt/gt/proInfo/floatView/GTMemHelperFloatview.java
diff --git a/android/src/com/tencent/wstt/gt/proInfo/floatView/MemInfo.java b/android/app/src/main/java/com/tencent/wstt/gt/proInfo/floatView/MemInfo.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/proInfo/floatView/MemInfo.java
rename to android/app/src/main/java/com/tencent/wstt/gt/proInfo/floatView/MemInfo.java
diff --git a/android/src/com/tencent/wstt/gt/proInfo/floatView/MemInfoByCMD.java b/android/app/src/main/java/com/tencent/wstt/gt/proInfo/floatView/MemInfoByCMD.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/proInfo/floatView/MemInfoByCMD.java
rename to android/app/src/main/java/com/tencent/wstt/gt/proInfo/floatView/MemInfoByCMD.java
diff --git a/android/src/com/tencent/wstt/gt/receiver/BaseCommandReceiver.java b/android/app/src/main/java/com/tencent/wstt/gt/receiver/BaseCommandReceiver.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/receiver/BaseCommandReceiver.java
rename to android/app/src/main/java/com/tencent/wstt/gt/receiver/BaseCommandReceiver.java
diff --git a/android/src/com/tencent/wstt/gt/receiver/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/receiver/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/receiver/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/receiver/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/service/GTFloatView.java b/android/app/src/main/java/com/tencent/wstt/gt/service/GTFloatView.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/service/GTFloatView.java
rename to android/app/src/main/java/com/tencent/wstt/gt/service/GTFloatView.java
diff --git a/android/src/com/tencent/wstt/gt/service/GTLogo.java b/android/app/src/main/java/com/tencent/wstt/gt/service/GTLogo.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/service/GTLogo.java
rename to android/app/src/main/java/com/tencent/wstt/gt/service/GTLogo.java
diff --git a/android/src/com/tencent/wstt/gt/service/GTService.java b/android/app/src/main/java/com/tencent/wstt/gt/service/GTService.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/service/GTService.java
rename to android/app/src/main/java/com/tencent/wstt/gt/service/GTService.java
diff --git a/android/src/com/tencent/wstt/gt/service/GTServiceController.java b/android/app/src/main/java/com/tencent/wstt/gt/service/GTServiceController.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/service/GTServiceController.java
rename to android/app/src/main/java/com/tencent/wstt/gt/service/GTServiceController.java
diff --git a/android/src/com/tencent/wstt/gt/service/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/service/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/service/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/service/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/ChangedListener.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/ChangedListener.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/ChangedListener.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/ChangedListener.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/CleanLogBuff.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/CleanLogBuff.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/CleanLogBuff.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/CleanLogBuff.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/DataRecorder.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/DataRecorder.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/DataRecorder.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/DataRecorder.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/EndLogBuff.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/EndLogBuff.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/EndLogBuff.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/EndLogBuff.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/GroupTimeEntry.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/GroupTimeEntry.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/GroupTimeEntry.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/GroupTimeEntry.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/LogBuff.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/LogBuff.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/LogBuff.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/LogBuff.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/LogEntry.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/LogEntry.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/LogEntry.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/LogEntry.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/MatchedEntry.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/MatchedEntry.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/MatchedEntry.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/MatchedEntry.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/NamedEntry.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/NamedEntry.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/NamedEntry.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/NamedEntry.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/StartAutoLogBuff.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/StartAutoLogBuff.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/StartAutoLogBuff.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/StartAutoLogBuff.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/StartLogBuff.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/StartLogBuff.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/StartLogBuff.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/StartLogBuff.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/TagQueryEntry.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/TagQueryEntry.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/TagQueryEntry.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/TagQueryEntry.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/TagTimeEntry.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/TagTimeEntry.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/TagTimeEntry.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/TagTimeEntry.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/ThresholdEntry.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/ThresholdEntry.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/ThresholdEntry.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/ThresholdEntry.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/TimeEntry.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/TimeEntry.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/TimeEntry.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/TimeEntry.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/ValueBuff.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/ValueBuff.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/ValueBuff.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/ValueBuff.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/WarningEntry.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/WarningEntry.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/WarningEntry.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/WarningEntry.java
diff --git a/android/src/com/tencent/wstt/gt/ui/model/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/ui/model/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/ui/model/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/ui/model/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/utils/AppInfo.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/AppInfo.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/AppInfo.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/AppInfo.java
diff --git a/android/src/com/tencent/wstt/gt/utils/BitmapUtil.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/BitmapUtil.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/BitmapUtil.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/BitmapUtil.java
diff --git a/android/src/com/tencent/wstt/gt/utils/BrightnessUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/BrightnessUtils.java
similarity index 97%
rename from android/src/com/tencent/wstt/gt/utils/BrightnessUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/BrightnessUtils.java
index 46bb259..7211e6f 100644
--- a/android/src/com/tencent/wstt/gt/utils/BrightnessUtils.java
+++ b/android/app/src/main/java/com/tencent/wstt/gt/utils/BrightnessUtils.java
@@ -1,71 +1,71 @@
-/*
- * Tencent is pleased to support the open source community by making
- * Tencent GT (Version 2.4 and subsequent versions) available.
- *
- * Notwithstanding anything to the contrary herein, any previous version
- * of Tencent GT shall not be subject to the license hereunder.
- * All right, title, and interest, including all intellectual property rights,
- * in and to the previous version of Tencent GT (including any and all copies thereof)
- * shall be owned and retained by Tencent and subject to the license under the
- * Tencent GT End User License Agreement (http://gt.qq.com/wp-content/EULA_EN.html).
- *
- * Copyright (C) 2015 THL A29 Limited, a Tencent company. All rights reserved.
- *
- * Licensed under the MIT License (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://opensource.org/licenses/MIT
- *
- * 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.tencent.wstt.gt.utils;
-
-import android.net.Uri;
-import android.provider.Settings;
-
-import com.tencent.wstt.gt.GTApp;
-
-public class BrightnessUtils {
-
- /**
- * 设置为非自动调节亮度的模式
- */
- public static void setManualMode() {
- try {
- Settings.System.putInt(GTApp.getContext().getContentResolver(),
- Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
- }catch(Exception e) { // api23以上需要申请权限android.permission.WRITE_SETTINGS
- e.fillInStackTrace();
- }
- }
-
- /**
- * 设置当前屏幕亮度值 0--255
- */
- public static void setScreenBrightness(int value) {
- try {
- Settings.System.putInt(GTApp.getContext().getContentResolver(),
- Settings.System.SCREEN_BRIGHTNESS, value);
- } catch (Exception localException) { // api23以上需要申请权限android.permission.WRITE_SETTINGS
- localException.printStackTrace();
- }
- }
-
- /**
- * 保存亮度设置状态
- *
- * @param resolver
- * @param brightness
- */
- public static void saveBrightness(int brightness) {
- Uri uri = android.provider.Settings.System
- .getUriFor("screen_brightness");
- android.provider.Settings.System.putInt(GTApp.getContext()
- .getContentResolver(), "screen_brightness", brightness);
- GTApp.getContext().getContentResolver().notifyChange(uri, null);
- }
-}
+/*
+ * Tencent is pleased to support the open source community by making
+ * Tencent GT (Version 2.4 and subsequent versions) available.
+ *
+ * Notwithstanding anything to the contrary herein, any previous version
+ * of Tencent GT shall not be subject to the license hereunder.
+ * All right, title, and interest, including all intellectual property rights,
+ * in and to the previous version of Tencent GT (including any and all copies thereof)
+ * shall be owned and retained by Tencent and subject to the license under the
+ * Tencent GT End User License Agreement (http://gt.qq.com/wp-content/EULA_EN.html).
+ *
+ * Copyright (C) 2015 THL A29 Limited, a Tencent company. All rights reserved.
+ *
+ * Licensed under the MIT License (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://opensource.org/licenses/MIT
+ *
+ * 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.tencent.wstt.gt.utils;
+
+import android.net.Uri;
+import android.provider.Settings;
+
+import com.tencent.wstt.gt.GTApp;
+
+public class BrightnessUtils {
+
+ /**
+ * 设置为非自动调节亮度的模式
+ */
+ public static void setManualMode() {
+ try {
+ Settings.System.putInt(GTApp.getContext().getContentResolver(),
+ Settings.System.SCREEN_BRIGHTNESS_MODE,
+ Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
+ }catch(Exception e) { // api23以上需要申请权限android.permission.WRITE_SETTINGS
+ e.fillInStackTrace();
+ }
+ }
+
+ /**
+ * 设置当前屏幕亮度值 0--255
+ */
+ public static void setScreenBrightness(int value) {
+ try {
+ Settings.System.putInt(GTApp.getContext().getContentResolver(),
+ Settings.System.SCREEN_BRIGHTNESS, value);
+ } catch (Exception localException) { // api23以上需要申请权限android.permission.WRITE_SETTINGS
+ localException.printStackTrace();
+ }
+ }
+
+ /**
+ * 保存亮度设置状态
+ *
+ * @param resolver
+ * @param brightness
+ */
+ public static void saveBrightness(int brightness) {
+ Uri uri = android.provider.Settings.System
+ .getUriFor("screen_brightness");
+ android.provider.Settings.System.putInt(GTApp.getContext()
+ .getContentResolver(), "screen_brightness", brightness);
+ GTApp.getContext().getContentResolver().notifyChange(uri, null);
+ }
+}
diff --git a/android/src/com/tencent/wstt/gt/utils/CommonString.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/CommonString.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/CommonString.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/CommonString.java
diff --git a/android/src/com/tencent/wstt/gt/utils/DoubleUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/DoubleUtils.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/DoubleUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/DoubleUtils.java
diff --git a/android/src/com/tencent/wstt/gt/utils/FileUtil.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/FileUtil.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/FileUtil.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/FileUtil.java
diff --git a/android/src/com/tencent/wstt/gt/utils/GTFrameUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/GTFrameUtils.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/GTFrameUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/GTFrameUtils.java
diff --git a/android/src/com/tencent/wstt/gt/utils/GTUtils.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/GTUtils.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/GTUtils.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/GTUtils.java
diff --git a/android/src/com/tencent/wstt/gt/utils/LibManager.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/LibManager.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/LibManager.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/LibManager.java
diff --git a/android/src/com/tencent/wstt/gt/utils/NotificationHelper.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/NotificationHelper.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/NotificationHelper.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/NotificationHelper.java
diff --git a/android/src/com/tencent/wstt/gt/utils/PerformanceUtil.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/PerformanceUtil.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/PerformanceUtil.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/PerformanceUtil.java
diff --git a/android/src/com/tencent/wstt/gt/utils/RootUtil.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/RootUtil.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/RootUtil.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/RootUtil.java
diff --git a/android/src/com/tencent/wstt/gt/utils/StringUtil.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/StringUtil.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/StringUtil.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/StringUtil.java
diff --git a/android/src/com/tencent/wstt/gt/utils/ToastUtil.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/ToastUtil.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/ToastUtil.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/ToastUtil.java
diff --git a/android/src/com/tencent/wstt/gt/utils/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/utils/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/utils/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/utils/package-info.java
diff --git a/android/src/com/tencent/wstt/gt/views/GTCheckBox.java b/android/app/src/main/java/com/tencent/wstt/gt/views/GTCheckBox.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/views/GTCheckBox.java
rename to android/app/src/main/java/com/tencent/wstt/gt/views/GTCheckBox.java
diff --git a/android/src/com/tencent/wstt/gt/views/GTMulOpPerfDetailView.java b/android/app/src/main/java/com/tencent/wstt/gt/views/GTMulOpPerfDetailView.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/views/GTMulOpPerfDetailView.java
rename to android/app/src/main/java/com/tencent/wstt/gt/views/GTMulOpPerfDetailView.java
diff --git a/android/src/com/tencent/wstt/gt/views/GTOutParaPerfDialog.java b/android/app/src/main/java/com/tencent/wstt/gt/views/GTOutParaPerfDialog.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/views/GTOutParaPerfDialog.java
rename to android/app/src/main/java/com/tencent/wstt/gt/views/GTOutParaPerfDialog.java
diff --git a/android/src/com/tencent/wstt/gt/views/GTPerfDetailView.java b/android/app/src/main/java/com/tencent/wstt/gt/views/GTPerfDetailView.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/views/GTPerfDetailView.java
rename to android/app/src/main/java/com/tencent/wstt/gt/views/GTPerfDetailView.java
diff --git a/android/src/com/tencent/wstt/gt/views/PatchedTextView.java b/android/app/src/main/java/com/tencent/wstt/gt/views/PatchedTextView.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/views/PatchedTextView.java
rename to android/app/src/main/java/com/tencent/wstt/gt/views/PatchedTextView.java
diff --git a/android/src/com/tencent/wstt/gt/views/package-info.java b/android/app/src/main/java/com/tencent/wstt/gt/views/package-info.java
similarity index 100%
rename from android/src/com/tencent/wstt/gt/views/package-info.java
rename to android/app/src/main/java/com/tencent/wstt/gt/views/package-info.java
diff --git a/android/jni/Android.mk b/android/app/src/main/jni/Android.mk
similarity index 100%
rename from android/jni/Android.mk
rename to android/app/src/main/jni/Android.mk
diff --git a/android/jni/Application.mk b/android/app/src/main/jni/Application.mk
similarity index 100%
rename from android/jni/Application.mk
rename to android/app/src/main/jni/Application.mk
diff --git a/android/jni/com_tencent_wstt_gt_api_utils_MemFillTool.c b/android/app/src/main/jni/com_tencent_wstt_gt_api_utils_MemFillTool.c
similarity index 100%
rename from android/jni/com_tencent_wstt_gt_api_utils_MemFillTool.c
rename to android/app/src/main/jni/com_tencent_wstt_gt_api_utils_MemFillTool.c
diff --git a/android/jni/com_tencent_wstt_gt_api_utils_MemFillTool.h b/android/app/src/main/jni/com_tencent_wstt_gt_api_utils_MemFillTool.h
similarity index 100%
rename from android/jni/com_tencent_wstt_gt_api_utils_MemFillTool.h
rename to android/app/src/main/jni/com_tencent_wstt_gt_api_utils_MemFillTool.h
diff --git a/android/jni/log.h b/android/app/src/main/jni/log.h
similarity index 100%
rename from android/jni/log.h
rename to android/app/src/main/jni/log.h
diff --git a/android/libs/armeabi-v7a/libMtaNativeCrash.so b/android/app/src/main/jniLibs/armeabi-v7a/libMtaNativeCrash.so
similarity index 100%
rename from android/libs/armeabi-v7a/libMtaNativeCrash.so
rename to android/app/src/main/jniLibs/armeabi-v7a/libMtaNativeCrash.so
diff --git a/android/libs/armeabi/libMtaNativeCrash.so b/android/app/src/main/jniLibs/armeabi/libMtaNativeCrash.so
similarity index 100%
rename from android/libs/armeabi/libMtaNativeCrash.so
rename to android/app/src/main/jniLibs/armeabi/libMtaNativeCrash.so
diff --git a/android/libs/mips/libMtaNativeCrash.so b/android/app/src/main/jniLibs/mips/libMtaNativeCrash.so
similarity index 100%
rename from android/libs/mips/libMtaNativeCrash.so
rename to android/app/src/main/jniLibs/mips/libMtaNativeCrash.so
diff --git a/android/libs/x86/libMtaNativeCrash.so b/android/app/src/main/jniLibs/x86/libMtaNativeCrash.so
similarity index 100%
rename from android/libs/x86/libMtaNativeCrash.so
rename to android/app/src/main/jniLibs/x86/libMtaNativeCrash.so
diff --git a/android/res/color/button_text_blue.xml b/android/app/src/main/res/color/button_text_blue.xml
similarity index 97%
rename from android/res/color/button_text_blue.xml
rename to android/app/src/main/res/color/button_text_blue.xml
index b44c112..6228769 100644
--- a/android/res/color/button_text_blue.xml
+++ b/android/app/src/main/res/color/button_text_blue.xml
@@ -1,4 +1,4 @@
-
+
-
-
-
- GT
- Back
- Start
- Stop
- Description:
-
- AGREEMENT
- I know
- Refuse
- I have read and accept all the terms of this Agreement
- Tencent
- Terms and Privacy
- Copyright© 1998#8211;2014 Tencent
- All Rights Reserved
-
- Dump
- GC
- Refresh
- HeapSize:0 \nAllocated:0
-
- 0.0
- 10s
- 0.1s
- sKey
- Key
- value
- Input
- 0 / 0
- ALL
- TAG
- 0
- 1
- Empty
- Detail
- [
- ]
- -
- )
- (
- n/a
- off
- PSS
- Private Dirty
- CPU
- jiffies
- Net
- Cancel
- Installed Application List
- appName
- -p -s 0 -vv -w
- cpu [unknow]
- curFreq
- curGov
- Sys
- Scal
- Cpu Freq
- Back
- init
- Info
- Set
- MaxFreq
- MinFreq
- Governor
- Apply
- 12_June_2011
- 6177
- SomeActivity
- verbose
- debug
- info
- warn
- error
- assert
- Add Filters
- Delete Filters
-
- About GT
- About
- Account
- Log Switch
- AirConsole
- Message Switch
- Intervals
- Exit
- Homepage
- Feedback
- Log
- GTLog Switch
- GTLog auto save
- Auto save quick flush
- Retain GTLog prefix
- Logcat auto save as GTLog
- AirConsole
- AirConsole Quick Switch
- Show profiler switch
- Show G&W switch
- Show AirConsole
- Message Switch
- Update Message Remind
- Intervals
- Gather Interval:
- Gather FPS Interval\r\n(need GT restart):
-
- Save
- Save to local:
- Save File
- Delete
- Delete all
- delete log?
- Operate:
- Clear
- clear data?
- Clear and Reset
- clear and reset data?
- Cancel
- Upload
- rename
- Rename
- attention
- load
- input name must be normal letter.
- input value must digit
- /sdcard/GT/GW/
- description:
-
- AUT
- AUT
- refresh
- lanuch
- APP Under Debug:
- choose debug app..
- Memory Info
- Mem Assistant:
- Other Info
- Attention
- this operation may clear history data of current App,continue?
- please stop G/W first.
- can not start App:
-
- in
- out
- Para.
- edit
- done
- Drag
- Out Param Items
- In Param Items
- Gather & Warning(G&W)
- Show on Air-console(<=3)
- Optional Parameters
- Disabled Parameters
- please select at least one item.
- delete all selected history data.
- save data to sdcard complete
-
- Prof.
- Profiling..
- Not Start Profiling
- Counts
- Sum
- Max
- Ave.
- Score
- Good
- Bad
-
- Detail
- Val:
- Count:
- Ave:
- Max:
- Min:
- select observe item here
-
- Warning Area(Enable)
- Warning Area(Disable)
- Warning Area(
- Warning Area(disable
- Time(s)
- Out of Range
- MAX
- MIN
- Warning Times:
- WTimes:
-
- Log
- GTLog
- LogCat
- by message
- input keyword here
- results
- no saved logs
- open log
-
- Plugin
- This plug-in is used to collect current, voltage, power, temperature, Google Nexus4/Nexus5 and ZTE_Red_Bull_V5 can accurately output current value. Before use to determine the sampling rate, recommended 100ms~1000ms, and then check the observed items (current I / voltage U / electricity)
- This is a tcpdump plugin. Press "start" directly to capture network packets. The file that records the network data will be saved until the button "stop" clicked. The saved files can be analysed by wireshark.
- This is a wakelock control plug-in, click on the Full wakelock, the phone will not take the initiative off the screen and off the screen manually, it will not go to sleep. When you click Partial wakelock, the phone will not sleep after the off-screen.
- This plugin can be used for filling memory. GT will allocate xxxxMB memory in native, if the button "fill" clicked. The total memory occupied by GT can be tracked in pss.
- GPS Collection: Click "Record" to start. The collection file is saved in /GT/Log/gps directory.\r\nGPS Replay: Choose a GPS Collection file and click "Replay" to start. The system settings should: 1. only enable the GPS function while others remain disabled in the location services; 2. select the "Allow mock locations" in the Developer options.
- Drag seekbar to change replay progress, become effective after click save button.
- Usage :Check(if OK)->select App->Start\nSetting:Check(if NOT OK)->Modify->Restart\nNotice :if want resume setting, Resume->Restart
- This plugin can upload collected data to web.The web resource is Provided by bugly.qq.com and use QQ account quick login.Notice:\r\n1.install Mobile QQ first.\r\n2.regist product on bugly.qq.com.
- GTBattery
- display battery,Nexus 4/5 supported
- Samping Rate(ms):
- input digit greater than 100
- the sample rate or brightness you typed is not a number!
- The Input parameter should be greater than 100!
- must stop current debug first!
- this phone or system not adapted
- Select observed items:
- I:
- U:
- Power:
- Temp:
- Set Brightness(0–255):
- GTPcap
- capture the network traffic by tcpdump
- Save Folder Name
- Argument
- GTScreenlock
- prevent from screen being locked or sleep
- Full wakelock
- Partial wakelock
- GTMemFill
- Fill Memory
- Alloc memory(MB):
- fill memory or free memory:
- Fill
- Free
- less than 1100
- GTSMTools
- App Smoothness Debug
- Check
- Modify
- Resume
- Restart
- 月光宝盒
- record&replay GPS
- Record
- Stop Record
- Replay
- Stop Replay
- please choose a file
- Tag
- Please allow mock locations in Developer options.
- Empty location record.
- Please do not operate files when replaying.
- normal speed
- x2 speed
- x4 speed
- Use Detail
- about
- Required can not empty
+
+
+
+
+
+ GT
+ Back
+ Start
+ Stop
+ Description:
+
+ AGREEMENT
+ I know
+ Refuse
+ I have read and accept all the terms of this Agreement
+ Tencent
+ Terms and Privacy
+ Copyright© 1998#8211;2014 Tencent
+ All Rights Reserved
+
+ Dump
+ GC
+ Refresh
+ HeapSize:0 \nAllocated:0
+
+ 0.0
+ 10s
+ 0.1s
+ sKey
+ Key
+ value
+ Input
+ 0 / 0
+ ALL
+ TAG
+ 0
+ 1
+ Empty
+ Detail
+ [
+ ]
+ -
+ )
+ (
+ n/a
+ off
+ PSS
+ Private Dirty
+ CPU
+ jiffies
+ Net
+ Cancel
+ Installed Application List
+ appName
+ -p -s 0 -vv -w
+ cpu [unknow]
+ curFreq
+ curGov
+ Sys
+ Scal
+ Cpu Freq
+ Back
+ init
+ Info
+ Set
+ MaxFreq
+ MinFreq
+ Governor
+ Apply
+ 12_June_2011
+ 6177
+ SomeActivity
+ verbose
+ debug
+ info
+ warn
+ error
+ assert
+ Add Filters
+ Delete Filters
+
+ About GT
+ About
+ Account
+ Log Switch
+ AirConsole
+ Message Switch
+ Intervals
+ Exit
+ Homepage
+ Feedback
+ Log
+ GTLog Switch
+ GTLog auto save
+ Auto save quick flush
+ Retain GTLog prefix
+ Logcat auto save as GTLog
+ AirConsole
+ AirConsole Quick Switch
+ Show profiler switch
+ Show G&W switch
+ Show AirConsole
+ Message Switch
+ Update Message Remind
+ Intervals
+ Gather Interval:
+ Gather FPS Interval\r\n(need GT restart):
+
+ Save
+ Save to local:
+ Save File
+ Delete
+ Delete all
+ delete log?
+ Operate:
+ Clear
+ clear data?
+ Clear and Reset
+ clear and reset data?
+ Cancel
+ Upload
+ rename
+ Rename
+ attention
+ load
+ input name must be normal letter.
+ input value must digit
+ /sdcard/GT/GW/
+ description:
+
+ AUT
+ AUT
+ refresh
+ lanuch
+ APP Under Debug:
+ choose debug app..
+ Memory Info
+ Mem Assistant:
+ Other Info
+ Attention
+ this operation may clear history data of current App,continue?
+ please stop G/W first.
+ can not start App:
+
+ in
+ out
+ Para.
+ edit
+ done
+ Drag
+ Out Param Items
+ In Param Items
+ Gather & Warning(G&W)
+ Show on Air-console(<=3)
+ Optional Parameters
+ Disabled Parameters
+ please select at least one item.
+ delete all selected history data.
+ save data to sdcard complete
+
+ Prof.
+ Profiling..
+ Not Start Profiling
+ Counts
+ Sum
+ Max
+ Ave.
+ Score
+ Good
+ Bad
+
+ Detail
+ Val:
+ Count:
+ Ave:
+ Max:
+ Min:
+ select observe item here
+
+ Warning Area(Enable)
+ Warning Area(Disable)
+ Warning Area(
+ Warning Area(disable
+ Time(s)
+ Out of Range
+ MAX
+ MIN
+ Warning Times:
+ WTimes:
+
+ Log
+ GTLog
+ LogCat
+ by message
+ input keyword here
+ results
+ no saved logs
+ open log
+
+ Plugin
+ This plug-in is used to collect current, voltage, power, temperature, Google Nexus4/Nexus5 and ZTE_Red_Bull_V5 can accurately output current value. Before use to determine the sampling rate, recommended 100ms~1000ms, and then check the observed items (current I / voltage U / electricity)
+ This is a tcpdump plugin. Press "start" directly to capture network packets. The file that records the network data will be saved until the button "stop" clicked. The saved files can be analysed by wireshark.
+ This is a wakelock control plug-in, click on the Full wakelock, the phone will not take the initiative off the screen and off the screen manually, it will not go to sleep. When you click Partial wakelock, the phone will not sleep after the off-screen.
+ This plugin can be used for filling memory. GT will allocate xxxxMB memory in native, if the button "fill" clicked. The total memory occupied by GT can be tracked in pss.
+ GPS Collection: Click "Record" to start. The collection file is saved in /GT/Log/gps directory.\r\nGPS Replay: Choose a GPS Collection file and click "Replay" to start. The system settings should: 1. only enable the GPS function while others remain disabled in the location services; 2. select the "Allow mock locations" in the Developer options.
+ Drag seekbar to change replay progress, become effective after click save button.
+ Usage :Check(if OK)->select App->Start\nSetting:Check(if NOT OK)->Modify->Restart\nNotice :if want resume setting, Resume->Restart
+ This plugin can upload collected data to web.The web resource is Provided by bugly.qq.com and use QQ account quick login.Notice:\r\n1.install Mobile QQ first.\r\n2.regist product on bugly.qq.com.
+ GTBattery
+ display battery,Nexus 4/5 supported
+ Samping Rate(ms):
+ input digit greater than 100
+ the sample rate or brightness you typed is not a number!
+ The Input parameter should be greater than 100!
+ must stop current debug first!
+ this phone or system not adapted
+ Select observed items:
+ I:
+ U:
+ Power:
+ Temp:
+ Set Brightness(0–255):
+ GTPcap
+ capture the network traffic by tcpdump
+ Save Folder Name
+ Argument
+ GTScreenlock
+ prevent from screen being locked or sleep
+ Full wakelock
+ Partial wakelock
+ GTMemFill
+ Fill Memory
+ Alloc memory(MB):
+ fill memory or free memory:
+ Fill
+ Free
+ less than 1100
+ GTSMTools
+ App Smoothness Debug
+ Check
+ Modify
+ Resume
+ Restart
+ 月光宝盒
+ record&replay GPS
+ Record
+ Stop Record
+ Replay
+ Stop Replay
+ please choose a file
+ Tag
+ Please allow mock locations in Developer options.
+ Empty location record.
+ Please do not operate files when replaying.
+ normal speed
+ x2 speed
+ x4 speed
+ Use Detail
+ about
+ Required can not empty
\ No newline at end of file
diff --git a/android/res/values/arrays.xml b/android/app/src/main/res/values/arrays.xml
similarity index 97%
rename from android/res/values/arrays.xml
rename to android/app/src/main/res/values/arrays.xml
index 56026b3..7173cb7 100644
--- a/android/res/values/arrays.xml
+++ b/android/app/src/main/res/values/arrays.xml
@@ -1,4 +1,4 @@
-
+
-
-
-
- GT
- 返回
- 开始
- 停止
- 描述:
-
- 软件许可协议
- 接受
- 拒绝
- 我已经阅读并同意以上条款
- 腾讯公司
- Terms and Privacy
- Copyright© 1998#8211;2015 Tencent
- All Rights Reserved
-
- Dump
- GC
- Refresh
- HeapSize:0 \nAllocated:0
-
- 0.0
- 10s
- 0.1s
- sKey
- Key
- value
- Input
- 0 / 0
- ALL
- TAG
- 0
- 1
- Empty
- Detail
- [
- ]
- /
- -
- )
- (
- n/a
- off
- PSS
- Private Dirty
- CPU
- jiffies
- Net
- Cancel
- Installed Application List
- appName
- -p -s 0 -vv -w
- cpu [unknow]
- curFreq
- curGov
- Sys
- Scal
- Cpu Freq
- Back
- init
- Info
- Set
- MaxFreq
- MinFreq
- Governor
- Apply
- 12_June_2011
- 6177
- SomeActivity
- verbose
- debug
- info
- warn
- error
- assert
- Add Filters
- Delete Filters
-
- 关于GT
- 关于
- 帐号
- 日志
- 悬浮窗
- 消息
- 间隔
- 退出
- 主页
- 反馈
- 日志
- GT日志总开关
- GT日志自动保存
- 自动保存快速刷新
- 保留GT日志前缀
- Logcat以GTLog形式自动保存
- 悬浮窗
- 悬浮窗显示统计开关切换
- 显示耗时统计开关
- 显示 G&W开关
- 显示悬浮框
- 消息
- 允许弹出升级提示
- 间隔
- 性能数据采集间隔:
- FPS采集间隔(重启GT生效):
-
- 保存
- 将选中的数据保存在:
- [必填]
- [非必填]
- 保存文件
- 删除
- 删除所有
- 删除日志?
- 操作:
- 清理
- 清理数据?
- 清理并重置
- 清理并重置数据?
- 确定
- 取消
- 上传
- 重命名
- 请输入
- attention
- load
- 输入的文字不能包含特殊字符
- 输入的必须是数字
- /sdcard/GT/GW/
- 备注:
-
- AUT
- AUT
- 刷新
- 启动
- 被调试的应用:
- 请选择被调试的应用..
- 内存指标
- 内存助手:
- 其他指标
- 警告
- 本操作将清理当前被调试的应用已记录的调试数据,是否继续?
- 请先停止数据采集
- 无法启动应用:
-
- 入参
- 出参
- 参数
- 编辑
- 完成
- 拖拽
- 出参列表
- 入参列表
- 数据采集与告警操作栏(G&W)
- 悬浮窗展示的参数(<=3)
- 已关注的参数
- 已取消关注的参数
- 请选中至少一个关注项!
- 删除所有选中的历史数据
- 数据已保存到手机!
-
- 耗时
- 统计中..
- 该功能需配合GT的SDK使用
- 次数
- 合计
- 最大值
- 平均值
-
- 详情
- 当前值:
- 次数:
- 平均值:
- 最大值:
- 最小值:
- 整体分:
- 流畅:
- 卡顿:
-
- 请选择关注的项
-
- 告警区(可用)
- 告警区(停用)
- 告警区(
- 告警设置(停用
- 时间(s)
- 告警阈值
- 最大边界
- 最小边界
- 告警次数:
- 告警次数:
-
- 日志
- GTLog
- LogCat
- 按文本过滤
- 请输入搜索关键字
- 结果
- 没有已保存的日志文件.
- 打开日志
-
- 插件
- 本插件用于采集电流、电压、电量、温度值,已知Google Nexus4/Nexus5和中兴红牛V5能够准确的输出电流值。使用前先确定采样率,推荐100ms~1000ms,然后勾选被观测项(电流I/电压U/电量Power/温度Temp),点Start确定后,会在出参界面显示选中的观测项。
- 这是一个抓包插件,直接点击Start即可抓包,点击Stop后保存已抓包的内容到文件。抓包文件可用PC上的Wireshark软件分析。
- 这是一个wakelock的控制插件,当点击Full wakelock时,手机不会主动灭屏,并且手动灭屏了也不会进入休眠状态。当点击Partial wakelock时,手机灭屏后也不会休眠。
- 这是一个内存填充插件,当点击fill时,会为GT进程在Native层分配xxxMB的内存。GT所占用的内存数在PSS数据中可以体现出来。
- GPS采集:点击record开始采集,再点击会停止采集。文件存放在gt日志目录下的gps目录里。\r\nGPS回放:选择gps目录里的文件,点击replay开始,再点击停止。回放需要系统设置如下:1、设置里的位置选项,只打开通过GPS定位,其他关闭。2、开发者选项里选择允许模仿位置。
- 拖动进度条改变GPS回放的进度后,点击保存即可生效。
- 使用:检测(结果为OK)->选中被调试的进程->启动调试\n设置:检测(结果NOT OK)->点击更改->点击重启\n注意:无需检测时请点击停止调试,调试完毕时请点击恢复并重启系统还原设置
- 本插件用于将采集的数据上传到web端进行展示。GT的web资源由Bugly平台提供,Bugly平台可以使用QQ帐号快速登录,使用前请确保:\r\n1.手机上安装了手机QQ\r\n2.在bugly.qq.com注册过产品\r\n
- 耗电数据采集
- 采集电流电量指标,支持Nexus4/5和红牛V5等
- 采样间隔(ms):
- 输入的数字必须大于100
- 您输入刷新率或亮度不是数字!
- 输入的数字应大于100!
- 请先停止已进行的耗电数据采集!
- 该机型或系统尚未适配
- 选择关注的指标:
- 电流:
- 电压:
- 电量:
- 温度:
- 固定屏幕亮度(0–255):
- 抓包
- 使用tcpdump抓包
- 保存目录名
- 参数调整
- Wakelock锁
- 可以设置手机不自动灭屏或休眠
- Full wakelock
- Partial wakelock
- 内存填充
- 内存填充
- 分配内存数(MB):
- 填充或释放内存:
- 填充
- 释放
- 输入的数字请小于1100
- 流畅度调试
- 流畅度调试
- 检测
- 更改
- 恢复
- 重启
- 月光宝盒
- 录制GPS轨迹并模拟回放
- 录制
- 结束录制
- 回放
- 结束回放
- 请选择一个路径文件
- 打标记
- 请在开发者选项里允许模拟位置
- 选择的是空位置文件!
- 请不要在回放的时候做文件操作
- 正常速回放
- 2倍速回放
- 4倍速回放
- 使用详情
- 关于
- *必填项不能为空!
-
+
+
+
+
+
+ GT
+ 返回
+ 开始
+ 停止
+ 描述:
+
+ 软件许可协议
+ 接受
+ 拒绝
+ 我已经阅读并同意以上条款
+ 腾讯公司
+ Terms and Privacy
+ Copyright© 1998#8211;2015 Tencent
+ All Rights Reserved
+
+ Dump
+ GC
+ Refresh
+ HeapSize:0 \nAllocated:0
+
+ 0.0
+ 10s
+ 0.1s
+ sKey
+ Key
+ value
+ Input
+ 0 / 0
+ ALL
+ TAG
+ 0
+ 1
+ Empty
+ Detail
+ [
+ ]
+ /
+ -
+ )
+ (
+ n/a
+ off
+ PSS
+ Private Dirty
+ CPU
+ jiffies
+ Net
+ Cancel
+ Installed Application List
+ appName
+ -p -s 0 -vv -w
+ cpu [unknow]
+ curFreq
+ curGov
+ Sys
+ Scal
+ Cpu Freq
+ Back
+ init
+ Info
+ Set
+ MaxFreq
+ MinFreq
+ Governor
+ Apply
+ 12_June_2011
+ 6177
+ SomeActivity
+ verbose
+ debug
+ info
+ warn
+ error
+ assert
+ Add Filters
+ Delete Filters
+
+ 关于GT
+ 关于
+ 帐号
+ 日志
+ 悬浮窗
+ 消息
+ 间隔
+ 退出
+ 主页
+ 反馈
+ 日志
+ GT日志总开关
+ GT日志自动保存
+ 自动保存快速刷新
+ 保留GT日志前缀
+ Logcat以GTLog形式自动保存
+ 悬浮窗
+ 悬浮窗显示统计开关切换
+ 显示耗时统计开关
+ 显示 G&W开关
+ 显示悬浮框
+ 消息
+ 允许弹出升级提示
+ 间隔
+ 性能数据采集间隔:
+ FPS采集间隔(重启GT生效):
+
+ 保存
+ 将选中的数据保存在:
+ [必填]
+ [非必填]
+ 保存文件
+ 删除
+ 删除所有
+ 删除日志?
+ 操作:
+ 清理
+ 清理数据?
+ 清理并重置
+ 清理并重置数据?
+ 确定
+ 取消
+ 上传
+ 重命名
+ 请输入
+ attention
+ load
+ 输入的文字不能包含特殊字符
+ 输入的必须是数字
+ /sdcard/GT/GW/
+ 备注:
+
+ AUT
+ AUT
+ 刷新
+ 启动
+ 被调试的应用:
+ 请选择被调试的应用..
+ 内存指标
+ 内存助手:
+ 其他指标
+ 警告
+ 本操作将清理当前被调试的应用已记录的调试数据,是否继续?
+ 请先停止数据采集
+ 无法启动应用:
+
+ 入参
+ 出参
+ 参数
+ 编辑
+ 完成
+ 拖拽
+ 出参列表
+ 入参列表
+ 数据采集与告警操作栏(G&W)
+ 悬浮窗展示的参数(<=3)
+ 已关注的参数
+ 已取消关注的参数
+ 请选中至少一个关注项!
+ 删除所有选中的历史数据
+ 数据已保存到手机!
+
+ 耗时
+ 统计中..
+ 该功能需配合GT的SDK使用
+ 次数
+ 合计
+ 最大值
+ 平均值
+
+ 详情
+ 当前值:
+ 次数:
+ 平均值:
+ 最大值:
+ 最小值:
+ 整体分:
+ 流畅:
+ 卡顿:
+
+ 请选择关注的项
+
+ 告警区(可用)
+ 告警区(停用)
+ 告警区(
+ 告警设置(停用
+ 时间(s)
+ 告警阈值
+ 最大边界
+ 最小边界
+ 告警次数:
+ 告警次数:
+
+ 日志
+ GTLog
+ LogCat
+ 按文本过滤
+ 请输入搜索关键字
+ 结果
+ 没有已保存的日志文件.
+ 打开日志
+
+ 插件
+ 本插件用于采集电流、电压、电量、温度值,已知Google Nexus4/Nexus5和中兴红牛V5能够准确的输出电流值。使用前先确定采样率,推荐100ms~1000ms,然后勾选被观测项(电流I/电压U/电量Power/温度Temp),点Start确定后,会在出参界面显示选中的观测项。
+ 这是一个抓包插件,直接点击Start即可抓包,点击Stop后保存已抓包的内容到文件。抓包文件可用PC上的Wireshark软件分析。
+ 这是一个wakelock的控制插件,当点击Full wakelock时,手机不会主动灭屏,并且手动灭屏了也不会进入休眠状态。当点击Partial wakelock时,手机灭屏后也不会休眠。
+ 这是一个内存填充插件,当点击fill时,会为GT进程在Native层分配xxxMB的内存。GT所占用的内存数在PSS数据中可以体现出来。
+ GPS采集:点击record开始采集,再点击会停止采集。文件存放在gt日志目录下的gps目录里。\r\nGPS回放:选择gps目录里的文件,点击replay开始,再点击停止。回放需要系统设置如下:1、设置里的位置选项,只打开通过GPS定位,其他关闭。2、开发者选项里选择允许模仿位置。
+ 拖动进度条改变GPS回放的进度后,点击保存即可生效。
+ 使用:检测(结果为OK)->选中被调试的进程->启动调试\n设置:检测(结果NOT OK)->点击更改->点击重启\n注意:无需检测时请点击停止调试,调试完毕时请点击恢复并重启系统还原设置
+ 本插件用于将采集的数据上传到web端进行展示。GT的web资源由Bugly平台提供,Bugly平台可以使用QQ帐号快速登录,使用前请确保:\r\n1.手机上安装了手机QQ\r\n2.在bugly.qq.com注册过产品\r\n
+ 耗电数据采集
+ 采集电流电量指标,支持Nexus4/5和红牛V5等
+ 采样间隔(ms):
+ 输入的数字必须大于100
+ 您输入刷新率或亮度不是数字!
+ 输入的数字应大于100!
+ 请先停止已进行的耗电数据采集!
+ 该机型或系统尚未适配
+ 选择关注的指标:
+ 电流:
+ 电压:
+ 电量:
+ 温度:
+ 固定屏幕亮度(0–255):
+ 抓包
+ 使用tcpdump抓包
+ 保存目录名
+ 参数调整
+ Wakelock锁
+ 可以设置手机不自动灭屏或休眠
+ Full wakelock
+ Partial wakelock
+ 内存填充
+ 内存填充
+ 分配内存数(MB):
+ 填充或释放内存:
+ 填充
+ 释放
+ 输入的数字请小于1100
+ 流畅度调试
+ 流畅度调试
+ 检测
+ 更改
+ 恢复
+ 重启
+ 月光宝盒
+ 录制GPS轨迹并模拟回放
+ 录制
+ 结束录制
+ 回放
+ 结束回放
+ 请选择一个路径文件
+ 打标记
+ 请在开发者选项里允许模拟位置
+ 选择的是空位置文件!
+ 请不要在回放的时候做文件操作
+ 正常速回放
+ 2倍速回放
+ 4倍速回放
+ 使用详情
+ 关于
+ *必填项不能为空!
+
\ No newline at end of file
diff --git a/android/res/values/styles.xml b/android/app/src/main/res/values/styles.xml
similarity index 97%
rename from android/res/values/styles.xml
rename to android/app/src/main/res/values/styles.xml
index a256a8f..96c59e8 100644
--- a/android/res/values/styles.xml
+++ b/android/app/src/main/res/values/styles.xml
@@ -1,4 +1,4 @@
-
+