diff --git a/matrix/matrix-android/gradle.properties b/matrix/matrix-android/gradle.properties index 3abf64cb7..6e8d67800 100644 --- a/matrix/matrix-android/gradle.properties +++ b/matrix/matrix-android/gradle.properties @@ -14,5 +14,5 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro # org.gradle.parallel=true #Tue Jun 20 10:24:33 CST 2017 -VERSION_NAME_PREFIX=0.5.1 +VERSION_NAME_PREFIX=0.5.2 VERSION_NAME_SUFFIX= \ No newline at end of file diff --git a/matrix/matrix-android/matrix-android-lib/src/main/java/com/tencent/matrix/plugin/DefaultPluginListener.java b/matrix/matrix-android/matrix-android-lib/src/main/java/com/tencent/matrix/plugin/DefaultPluginListener.java index 76bc64ed3..46e1794f6 100644 --- a/matrix/matrix-android/matrix-android-lib/src/main/java/com/tencent/matrix/plugin/DefaultPluginListener.java +++ b/matrix/matrix-android/matrix-android-lib/src/main/java/com/tencent/matrix/plugin/DefaultPluginListener.java @@ -56,7 +56,7 @@ public void onDestroy(Plugin plugin) { @Override public void onReportIssue(Issue issue) { - MatrixLog.i(TAG, "report issue content: %s", issue); + MatrixLog.i(TAG, "report issue content: %s", issue == null ? "" : issue); } } diff --git a/matrix/matrix-android/matrix-gradle-plugin/src/main/java/com/tencent/matrix/trace/Configuration.java b/matrix/matrix-android/matrix-gradle-plugin/src/main/java/com/tencent/matrix/trace/Configuration.java index cdc0abbc4..6202b0bb9 100644 --- a/matrix/matrix-android/matrix-gradle-plugin/src/main/java/com/tencent/matrix/trace/Configuration.java +++ b/matrix/matrix-android/matrix-gradle-plugin/src/main/java/com/tencent/matrix/trace/Configuration.java @@ -4,7 +4,6 @@ import com.tencent.matrix.javalib.util.Util; import com.tencent.matrix.trace.retrace.MappingCollector; -import java.io.File; import java.util.HashSet; public class Configuration { diff --git a/matrix/matrix-android/matrix-io-canary/build.gradle b/matrix/matrix-android/matrix-io-canary/build.gradle index 02b1899f8..0f3ecd8c4 100644 --- a/matrix/matrix-android/matrix-io-canary/build.gradle +++ b/matrix/matrix-android/matrix-io-canary/build.gradle @@ -15,7 +15,7 @@ android { cppFlags "-std=gnu++11 -frtti -fexceptions" } ndk { - abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" + abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64" } } } diff --git a/matrix/matrix-android/matrix-trace-canary/src/main/java/com/tencent/matrix/trace/core/AppMethodBeat.java b/matrix/matrix-android/matrix-trace-canary/src/main/java/com/tencent/matrix/trace/core/AppMethodBeat.java index 8a773d705..2837e2a4a 100644 --- a/matrix/matrix-android/matrix-trace-canary/src/main/java/com/tencent/matrix/trace/core/AppMethodBeat.java +++ b/matrix/matrix-android/matrix-trace-canary/src/main/java/com/tencent/matrix/trace/core/AppMethodBeat.java @@ -426,7 +426,7 @@ public long[] copyData(IndexRecord startRecord, IndexRecord endRecord) { return data; } return data; - } catch (Exception e) { + } catch (OutOfMemoryError e) { MatrixLog.e(TAG, e.toString()); return data; } finally { diff --git a/matrix/matrix-android/matrix-trace-canary/src/main/res/layout/float_frame_view.xml b/matrix/matrix-android/matrix-trace-canary/src/main/res/layout/float_frame_view.xml index dfa6efdd6..5cd53bc85 100644 --- a/matrix/matrix-android/matrix-trace-canary/src/main/res/layout/float_frame_view.xml +++ b/matrix/matrix-android/matrix-trace-canary/src/main/res/layout/float_frame_view.xml @@ -8,7 +8,7 @@ android:id="@+id/fps_view" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="4dp" + android:padding="6dp" android:text="60.00 FPS" android:textColor="@android:color/holo_green_dark" android:textSize="16dp" /> diff --git a/samples/sample-android/app/src/main/java/sample/tencent/matrix/trace/TestTraceMainActivity.java b/samples/sample-android/app/src/main/java/sample/tencent/matrix/trace/TestTraceMainActivity.java index f2d305e69..f84522a66 100644 --- a/samples/sample-android/app/src/main/java/sample/tencent/matrix/trace/TestTraceMainActivity.java +++ b/samples/sample-android/app/src/main/java/sample/tencent/matrix/trace/TestTraceMainActivity.java @@ -18,32 +18,37 @@ import android.app.Activity; import android.content.Intent; +import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.Debug; import android.os.SystemClock; +import android.provider.Settings; import android.support.annotation.Nullable; -import android.util.Log; import android.view.View; -import android.view.ViewTreeObserver; +import android.webkit.PermissionRequest; import android.widget.Toast; +import com.tencent.matrix.AppForegroundDelegate; import com.tencent.matrix.Matrix; +import com.tencent.matrix.listeners.IAppForeground; import com.tencent.matrix.plugin.Plugin; import com.tencent.matrix.trace.TracePlugin; import com.tencent.matrix.trace.core.AppMethodBeat; import com.tencent.matrix.trace.view.FrameDecorator; import com.tencent.matrix.util.MatrixLog; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; +import java.security.Permission; import sample.tencent.matrix.R; import sample.tencent.matrix.issue.IssueFilter; -public class TestTraceMainActivity extends Activity { +import static android.Manifest.permission.SYSTEM_ALERT_WINDOW; + +public class TestTraceMainActivity extends Activity implements IAppForeground { private static String TAG = "Matrix.TestTraceMainActivity"; FrameDecorator decorator; + private static final int PERMISSION_REQUEST_CODE = 0x02; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -57,9 +62,30 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { plugin.start(); } decorator = FrameDecorator.create(this); - decorator.show(); + if (!canDrawOverlays()) { + requestWindowPermission(); + } else { + decorator.show(); + } + + AppForegroundDelegate.INSTANCE.addListener(this); + } + + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + MatrixLog.i(TAG, "requestCode:%s resultCode:%s", requestCode, resultCode); + if (requestCode == PERMISSION_REQUEST_CODE) { + if (canDrawOverlays()) { + decorator.show(); + } else { + Toast.makeText(this, "fail to request ACTION_MANAGE_OVERLAY_PERMISSION", Toast.LENGTH_LONG).show(); + } + } } + @Override protected void onDestroy() { super.onDestroy(); @@ -68,9 +94,28 @@ protected void onDestroy() { MatrixLog.i(TAG, "plugin-trace stop"); plugin.stop(); } - decorator.dismiss(); + if (canDrawOverlays()) { + decorator.dismiss(); + } + AppForegroundDelegate.INSTANCE.removeListener(this); + } + + private boolean canDrawOverlays() { + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + return Settings.canDrawOverlays(this); + } else { + return true; + } + } + + private void requestWindowPermission() { + Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, + Uri.parse("package:" + getPackageName())); + startActivityForResult(intent, PERMISSION_REQUEST_CODE); } + public void testEnter(View view) { Intent intent = new Intent(this, TestEnterActivity.class); startActivity(intent); @@ -164,4 +209,15 @@ private void tryHeavyMethod() { Debug.getMemoryInfo(new Debug.MemoryInfo()); } + @Override + public void onForeground(boolean isForeground) { + if (!canDrawOverlays()) { + return; + } + if (!isForeground) { + decorator.dismiss(); + } else { + decorator.show(); + } + } }