Skip to content

Commit

Permalink
[debug] demo for double catches iqiyi#24
Browse files Browse the repository at this point in the history
  • Loading branch information
clang-clang-clang committed Nov 12, 2019
1 parent ffa4f18 commit 4ffbf0e
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,33 @@
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import xcrash.XCrash;

public class MyService extends Service {
private final String TAG = "DoubleCatch";
private int constructCnt = 0;
private int createCnt = 0;
private int startCommandCnt = 0;
private int bindCnt = 0;

public MyService() {
Log.d(TAG, "MyService: constructCnt is " + constructCnt++);
Log.d(TAG, "MyService: thread is " + Thread.currentThread());
Log.d(TAG, "MyService: object is " + this.hashCode());
}

@Override
public void onCreate() {
Log.d(TAG, "MyService: createCnt is " + createCnt++);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG, "MyService: startCommandCnt is " + startCommandCnt++);
Log.d(TAG, "MyService: Process is " + android.os.Process.myPid());

String type = intent.getStringExtra("type");
if (type != null) {
if (type.equals("native")) {
Expand All @@ -29,6 +43,13 @@ public int onStartCommand(Intent intent, int flags, int startId) {

@Override
public IBinder onBind(Intent intent) {
Log.d(TAG, "MyService: bindCnt is " + bindCnt++);
return null;
}

@Override
protected void finalize() throws Throwable {
Log.d(TAG, "MyService: invoke finalize");
super.finalize();
}
}

0 comments on commit 4ffbf0e

Please sign in to comment.