浏览代码

ipu-count-test工程初始化

huangbo 9 年之前
父节点
当前提交
5029a9b459

+ 9 - 0
ipu-count-test/.classpath

@ -0,0 +1,9 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="src" path="gen"/>
5
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
7
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
8
	<classpathentry kind="output" path="bin/classes"/>
9
</classpath>

+ 3 - 0
ipu-count-test/.gitignore

@ -0,0 +1,3 @@
1
bin/
2
gen/
3
.settings/

+ 33 - 0
ipu-count-test/.project

@ -0,0 +1,33 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>ipu-count-test</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.jdt.core.javabuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
		<buildCommand>
24
			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25
			<arguments>
26
			</arguments>
27
		</buildCommand>
28
	</buildSpec>
29
	<natures>
30
		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31
		<nature>org.eclipse.jdt.core.javanature</nature>
32
	</natures>
33
</projectDescription>

+ 32 - 0
ipu-count-test/AndroidManifest.xml

@ -0,0 +1,32 @@
1
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
    package="com.ai.ipu.count"
3
    android:versionCode="1"
4
    android:versionName="1.0" >
5

6
    <uses-sdk
7
        android:minSdkVersion="10"
8
        android:targetSdkVersion="10" />
9
    <uses-permission android:name="android.permission.INTERNET"/>
10
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
11
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
12
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
13
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
14
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
15

16
    <application
17
        android:allowBackup="true"
18
        android:icon="@drawable/ic_launcher"
19
        android:label="@string/app_name"
20
        android:theme="@style/AppTheme" 
21
        android:name="com.ai.ipu.count.test.TestApplication">
22
        
23
        <activity 
24
            android:name="com.ai.ipu.count.test.TestActivity">
25
            <intent-filter >
26
                <action android:name="android.intent.action.MAIN"/>
27
                <category android:name="android.intent.category.LAUNCHER"/>
28
            </intent-filter>
29
        </activity>
30
    </application>
31

32
</manifest>

+ 26 - 0
ipu-count-test/assets/count-config.xml

@ -0,0 +1,26 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<config>
3
    
4
        <delegate name="firstDele" class="com.ai.ipu.count.test.TestBeanImpl">
5
            <aspect class="com.ai.ipu.count.test.TestLogImpl"/>
6
            <method>sayHello</method>
7
        </delegate>
8
        
9
        <delegate name="secondDele" class="com.ai.ipu.count.test.TestBeanImpl2">
10
            <aspect class="com.ai.ipu.count.test.TestLogImpl"/>
11
            <method>sayBey</method>
12
            <method>sayHello</method>
13
        </delegate>
14
  
15
    
16
    <!-- <aspect class="com.ai.ipu.count.test.TestLogImpl">
17
        <delegate class="com.ai.ipu.count.test.TestBeanImpl">
18
            <method>sayHello</method>
19
        </delegate>
20
        
21
        <delegate class="com.ai.ipu.count.test.TestBeanImpl2">
22
            <method>sayHello</method>
23
            <method>sayHey</method>
24
        </delegate>
25
    </aspect> -->
26
</config>

二进制
ipu-count-test/libs/android-support-v4.jar


二进制
ipu-count-test/libs/ipu-count.jar


+ 20 - 0
ipu-count-test/proguard-project.txt

@ -0,0 +1,20 @@
1
# To enable ProGuard in your project, edit project.properties
2
# to define the proguard.config property as described in that file.
3
#
4
# Add project specific ProGuard rules here.
5
# By default, the flags in this file are appended to flags specified
6
# in ${sdk.dir}/tools/proguard/proguard-android.txt
7
# You can edit the include path and order by changing the ProGuard
8
# include property in project.properties.
9
#
10
# For more details, see
11
#   http://developer.android.com/guide/developing/tools/proguard.html
12
13
# Add any project specific keep options here:
14
15
# If your project uses WebView with JS, uncomment the following
16
# and specify the fully qualified class name to the JavaScript interface
17
# class:
18
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19
#   public *;
20
#}

+ 15 - 0
ipu-count-test/project.properties

@ -0,0 +1,15 @@
1
# This file is automatically generated by Android Tools.
2
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3
#
4
# This file must be checked in Version Control Systems.
5
#
6
# To customize properties used by the Ant build system edit
7
# "ant.properties", and override values to adapt the script to your
8
# project structure.
9
#
10
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12
13
# Project target.
14
target=android-15
15
android.library=false

二进制
ipu-count-test/res/drawable-hdpi/ic_launcher.png


二进制
ipu-count-test/res/drawable-mdpi/ic_launcher.png


二进制
ipu-count-test/res/drawable-xhdpi/ic_launcher.png


+ 5 - 0
ipu-count-test/res/values/strings.xml

@ -0,0 +1,5 @@
1
<resources>
2

3
    <string name="app_name">ipu-count-test</string>
4

5
</resources>

+ 20 - 0
ipu-count-test/res/values/styles.xml

@ -0,0 +1,20 @@
1
<resources>
2

3
    <!--
4
        Base application theme, dependent on API level. This theme is replaced
5
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
6
    -->
7
    <style name="AppBaseTheme" parent="android:Theme.Light">
8
        <!--
9
            Theme customizations available in newer API levels can go in
10
            res/values-vXX/styles.xml, while customizations related to
11
            backward-compatibility can go here.
12
        -->
13
    </style>
14

15
    <!-- Application theme. -->
16
    <style name="AppTheme" parent="AppBaseTheme">
17
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
18
    </style>
19

20
</resources>

+ 128 - 0
ipu-count-test/src/com/ai/ipu/count/test/TestActivity.java

@ -0,0 +1,128 @@
1
package com.ai.ipu.count.test;
2

3
import java.io.IOException;
4
import java.util.concurrent.ExecutorService;
5
import java.util.concurrent.Executors;
6

7
import android.app.Activity;
8
import android.os.Bundle;
9
import android.view.View;
10
import android.view.View.OnClickListener;
11
import android.widget.Button;
12
import android.widget.LinearLayout;
13
import android.widget.LinearLayout.LayoutParams;
14
import android.widget.TextView;
15

16
import com.ai.ipu.count.proxy.IpuCountContext;
17
import com.ai.ipu.count.util.IpuConstant;
18
import com.ai.ipu.count.util.IpuUDPHelper;
19
import com.ai.ipu.count.util.IpuUDPUtil;
20

21
public class TestActivity extends Activity {
22
	private boolean isStart = false;
23
	@Override
24
	protected void onCreate(Bundle savedInstanceState) {
25
		super.onCreate(savedInstanceState);
26
		LinearLayout layout = new LinearLayout(this);
27
		layout.setOrientation(LinearLayout.VERTICAL);
28
		layout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
29
		
30
		Button button = null;
31
		/*普通插码的演示*/
32
		button = new Button(this);
33
		button.setText("1-普通插码");
34
		button.setOnClickListener(new OnClickListener() {
35
			@Override
36
			public void onClick(View paramView) {
37
				// TODO Auto-generated method stub
38
				TestBeanInterface obj1 = (TestBeanInterface) IpuCountContext.getDelegate("secondDele");
39
				obj1.sayBey();
40
			}
41
		});
42
		layout.addView(button);
43
		
44
		button = new Button(this);
45
		button.setText("2-异常情况");
46
		button.setOnClickListener(new OnClickListener() {
47
			@Override
48
			public void onClick(View paramView) {
49
				// TODO Auto-generated method stub
50
				if(true){
51
					throw new NullPointerException("异常情况测试");
52
				}
53
			}
54
		});
55
		layout.addView(button);
56
		
57
		final ExecutorService exec = Executors.newCachedThreadPool();
58
		final TestUDPServer server = new TestUDPServer();
59
		button = new Button(this);
60
		button.setText("启动UDP服务");
61
		final Button _button = button;
62
		button.setOnClickListener(new OnClickListener() {
63
			@Override
64
			public void onClick(View paramView) {
65
				// TODO Auto-generated method stub
66
				if(isStart){
67
					exec.shutdownNow();
68
					_button.setText("启动UDP服务");
69
					isStart = false;
70
				}else{
71
					exec.execute(server);
72
					_button.setText("停止UDP服务");
73
					isStart = true;
74
				}
75
			}
76
		});
77
		layout.addView(button);
78
		
79
		button = new Button(this);
80
		button.setText("发送UDP日志");
81
		button.setOnClickListener(new OnClickListener() {
82
			@Override
83
			public void onClick(View paramView) {
84
				// TODO Auto-generated method stub
85
				new Thread(new Runnable() {
86
					@Override
87
					public void run() {
88
						try {
89
							IpuUDPHelper.send("Hello UDP");
90
						} catch (IOException e) {
91
							e.printStackTrace();
92
						}
93
					}
94
				}).start();
95
			}
96
		});
97
		layout.addView(button);
98
		
99
		
100
		button = new Button(this);
101
		button.setText("3-清除日志文件");
102
		button.setOnClickListener(new View.OnClickListener() {
103
			@Override
104
			public void onClick(View v) {
105
				try {
106
					IpuUDPUtil.FileUtil.getInstance(getApplicationContext()).clear(IpuConstant.LOG_FILE_NAME);
107
				} catch (IOException e) {
108
					e.printStackTrace();
109
				}
110
			}
111
		});
112
		layout.addView(button);
113
		
114
		final TextView textView = new TextView(this);
115
		textView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
116
		textView.setHint("显示内容");
117
		layout.addView(textView);
118
		
119
		
120
		/*TestBeanInterface bind = (TestBeanInterface) new IpuDynaProxy().bind(new TestBeanImpl(), new TestLogImpl(),new String[]{"sayHello"});
121
		String sayHello = bind.sayHello();
122
		Toast.makeText(getApplicationContext(), sayHello, Toast.LENGTH_SHORT).show();
123
		bind.sayBey();*/
124
		
125
		setContentView(layout);
126
	}
127

128
}

+ 16 - 0
ipu-count-test/src/com/ai/ipu/count/test/TestApplication.java

@ -0,0 +1,16 @@
1
package com.ai.ipu.count.test;
2

3
import android.app.Application;
4

5
import com.ai.ipu.count.IpuCrashHandler;
6
import com.ai.ipu.count.IpuReport;
7

8
public class TestApplication extends Application {
9
	@Override
10
	public void onCreate() {
11
		super.onCreate();
12
		//移到IpuReport的initiate方法中
13
//		IpuCrashHandler.getInstance().init(getApplicationContext());
14
		IpuReport.initiate(getApplicationContext());
15
	}
16
}

+ 17 - 0
ipu-count-test/src/com/ai/ipu/count/test/TestBeanImpl.java

@ -0,0 +1,17 @@
1
package com.ai.ipu.count.test;
2

3
public class TestBeanImpl implements TestBeanInterface{
4

5
	@Override
6
	public String sayHello() {
7
		System.out.println("------------sayHello-----------");
8
		return "sayHello";
9
//		throw new NullPointerException("空指针异常");
10
	}
11

12
	@Override
13
	public void sayBey() {
14
		System.out.println("------------sayBey-----------");
15
	}
16

17
}

+ 16 - 0
ipu-count-test/src/com/ai/ipu/count/test/TestBeanImpl2.java

@ -0,0 +1,16 @@
1
package com.ai.ipu.count.test;
2

3
public class TestBeanImpl2 implements TestBeanInterface{
4

5
	@Override
6
	public String sayHello() {
7
		System.out.println("##############sayHello2#################");
8
		return "sayHello2";
9
	}
10

11
	@Override
12
	public void sayBey() {
13
		System.out.println("##############sayBey2#################");
14
	}
15

16
}

+ 6 - 0
ipu-count-test/src/com/ai/ipu/count/test/TestBeanInterface.java

@ -0,0 +1,6 @@
1
package com.ai.ipu.count.test;
2

3
public interface TestBeanInterface {
4
	String sayHello();
5
	void sayBey();
6
}

+ 24 - 0
ipu-count-test/src/com/ai/ipu/count/test/TestLogImpl.java

@ -0,0 +1,24 @@
1
package com.ai.ipu.count.test;
2

3
import java.lang.reflect.Method;
4

5
import com.ai.ipu.count.proxy.IpuLogInterface;
6

7
public class TestLogImpl implements IpuLogInterface{
8

9
	@Override
10
	public void beforeAdvice(Method method,Object[] args) {
11
		System.out.println("beforeAdvice::" + method.toString());
12
	}
13

14
	@Override
15
	public void afterAdvice(Method method,Object[] args) {
16
		System.out.println("afterAdvice::" + method.getName());
17
	}
18

19
	@Override
20
	public void afterThrowAdvice(Method method,Object[] args,Exception e) {
21
		String localizedMessage = e.getLocalizedMessage();
22
		System.out.println("afterThrowAdvice::" + localizedMessage);
23
	}
24
}

+ 56 - 0
ipu-count-test/src/com/ai/ipu/count/test/TestUDPServer.java

@ -0,0 +1,56 @@
1
package com.ai.ipu.count.test;
2

3
import java.io.IOException;
4
import java.net.DatagramPacket;
5
import java.net.DatagramSocket;
6
import java.net.SocketException;
7

8
import android.util.Log;
9

10
public class TestUDPServer implements Runnable {
11

12
	private static final int PORT = 6001;
13

14
	private byte[] msg = new byte[1024];
15

16
	private boolean life = true;
17

18
	public TestUDPServer() {
19
	}
20

21
	/**
22
	 * @return the life
23
	 */
24
	public boolean isLife() {
25
		return life;
26
	}
27

28
	/**
29
	 * @param life
30
	 *            the life to set
31
	 */
32
	public void setLife(boolean life) {
33
		this.life = life;
34
	}
35

36
	@Override
37
	public void run() {
38
		Log.e("", "服务启动了");
39
		DatagramSocket dSocket = null;
40
		DatagramPacket dPacket = new DatagramPacket(msg, msg.length);
41
		try {
42
			dSocket = new DatagramSocket(PORT);
43
			while (life) {
44
				try {
45
					dSocket.receive(dPacket);
46
					Log.i("msg sever received", new String(dPacket.getData()));
47
				} catch (IOException e) {
48
					e.printStackTrace();
49
				}
50
			}
51
		} catch (SocketException e) {
52
			e.printStackTrace();
53
		}
54
	}
55

56
}