Skip to content

Commit

Permalink
Hotfix/0.5.x to dev (#207)
Browse files Browse the repository at this point in the history
* fix trace build bug

* fix CheckedDatabaseListActivity 兼容性crash

* try catch OutOfMemoryError

* fix npe

* fix permission crash

* 1. style check  2. upload 0.5.2 to jcenter 3. add ‘armeabi’ back to abiFilters
  • Loading branch information
txfelixzhou authored Apr 22, 2019
1 parent 2786e3f commit 8623c49
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 14 deletions.
2 changes: 1 addition & 1 deletion matrix/matrix-android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion matrix/matrix-android/matrix-io-canary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
}
}

0 comments on commit 8623c49

Please sign in to comment.