Browse Source

更新gradle配置

leijie 5 years ago
parent
commit
159af1e6d0

+ 3 - 2
.gitignore

@ -1,2 +1,3 @@
1
/.DS_Store
2
.class
1
/.DS_Store
2
.class
3
ipu-plugin-basic/build

+ 54 - 0
ipu-plugin-basic/build.gradle

@ -0,0 +1,54 @@
1
allprojects {
2
    repositories {
3
        jcenter()
4
        maven { url "http://114.215.100.48:9090/nexus/content/groups/public/"}
5
        maven { url "http://114.215.100.48:9090/nexus/content/repositories/ipu-snapshots/"}
6
    }
7
}
8
9
apply plugin: 'com.android.library'
10
android {
11
    compileSdkVersion 23
12
    buildToolsVersion "26.0.2"
13
14
    defaultConfig {
15
        minSdkVersion 11
16
        targetSdkVersion 23
17
    }
18
19
        //源文件目录设置
20
    sourceSets {
21
        main {
22
            assets.srcDirs = ['src/main/java/assets']
23
            resources.srcDirs = ['src/main/java/']
24
            resources.includes = ['**/*.properties']
25
        }
26
27
    }
28
29
    aaptOptions.cruncherEnabled = false;
30
    aaptOptions.useNewCruncher = false;
31
32
    buildTypes {
33
        release {
34
            minifyEnabled false
35
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
36
        }
37
    }
38
}
39
40
41
42
dependencies {
43
    provided "com.ai.ipu:ipu-basic:${IPU_VERSION}"
44
    provided "com.ai.ipu.mobile:ipu-mobile-basic:${IPU_VERSION}"
45
    provided "com.ai.ipu.mobile:ipu-count-client:${IPU_VERSION}"
46
    compileOnly 'com.android.support:appcompat-v7:23.0.1'
47
48
    implementation 'com.qihoo360.replugin:replugin-host-lib:2.3.1'
49
50
    compileOnly project(':ipu-mobile-framework')
51
    provided "com.ai.ipu.mobile:ipu-plugin-extend:${IPU_VERSION}"
52
    provided "android:android-lite-http:${Http}"
53
    provided "com.ai.ipu.mobile:ipu-mobile-ui:${IPU_VERSION}"
54
}

+ 19 - 0
ipu-plugin-basic/gradle.properties

@ -0,0 +1,19 @@
1
## Project-wide Gradle settings.
2
#
3
# For more details on how to configure your build environment visit
4
# http://www.gradle.org/docs/current/userguide/build_environment.html
5
#
6
# Specifies the JVM arguments used for the daemon process.
7
# The setting is particularly useful for tweaking memory settings.
8
# Default value: -Xmx1024m -XX:MaxPermSize=256m
9
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
10
#
11
# When configured, Gradle will run in incubating parallel mode.
12
# This option should only be used with decoupled projects. More details, visit
13
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
14
# org.gradle.parallel=true
15
#
16
android_support_v4=1.0
17
IPU_VERSION=3.0-SNAPSHOT
18
Http=1.0
19

+ 10 - 0
ipu-plugin-basic/src/main/AndroidManifest.xml

@ -0,0 +1,10 @@
1
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
    package="com.ai.ipu.mobile"
3
    android:versionCode="1"
4
    android:versionName="1.0" >
5
6
    <uses-sdk
7
        android:minSdkVersion="11"
8
        android:targetSdkVersion="22" />
9
10
</manifest>

+ 62 - 22
ipu-plugin-basic/src/main/java/com/ai/ipu/mobile/plugin/MobileNetWork.java

@ -14,6 +14,7 @@ import android.content.Intent;
14 14
import android.net.Uri;
15 15
import android.os.AsyncTask;
16 16
import android.os.Build;
17
import android.util.Log;
17 18
import android.widget.Toast;
18 19
19 20
import com.ai.ipu.basic.file.FileUtil;
@ -223,6 +224,7 @@ public class MobileNetWork extends Plugin {
223 224
                    data.put("X_RESULTCODE", -1);
224 225
                    data.put("X_RESULTINFO", e.getMessage());
225 226
                    result = data.toString();
227
					Log.i("algo" , "dataRequest" + e.toString() + "data:" + data.toString());
226 228
                }
227 229
			}
228 230
			return result;
@ -257,14 +259,30 @@ public class MobileNetWork extends Plugin {
257 259
	 * 新增头字段参数
258 260
	 */
259 261
	private String requestBizData(String dataAction, IData param,IData headers) throws Exception {
260
		Map<String,String> postData = transPostData(dataAction, param);
261
		String dataUrl = HttpTool.toQueryStringWithEncode(postData);
262
		BizManager.recordReqUrl(MobileConfig.getInstance().getRequestUrl());
263
		String result = (null == headers) ? HttpTool.httpRequest(MobileConfig.getInstance().getRequestUrl(),
264
				dataUrl, Constant.HTTP_POST) : HttpTool.httpRequest(MobileConfig.getInstance().getRequestUrl(),
265
						dataUrl, Constant.HTTP_POST,headers);
266
		if (ServerDataConfig.isEncrypt(dataAction)) {
267
			result = MobileSecurity.responseDecrypt(result);
262
		String result = null;
263
		Map<String,String> postData = new HashMap<>();
264
		try {
265
			try {
266
				 postData = transPostData(dataAction, param);
267
			}catch (Exception e){
268
				Log.i("algo","transPostData111:"+ dataAction + ";" + result + e.toString());
269
			}
270
			String dataUrl = HttpTool.toQueryStringWithEncode(postData);
271
			BizManager.recordReqUrl(MobileConfig.getInstance().getRequestUrl());
272
			result = (null == headers) ? HttpTool.httpRequest(MobileConfig.getInstance().getRequestUrl(),
273
					dataUrl, Constant.HTTP_POST) : HttpTool.httpRequest(MobileConfig.getInstance().getRequestUrl(),
274
					dataUrl, Constant.HTTP_POST,headers);
275
			if (ServerDataConfig.isEncrypt(dataAction)) {
276
				try {
277
					result = MobileSecurity.responseDecrypt(result);
278
				}catch (Exception e){
279
					Log.i("algo","responseDecrypt:"+ dataAction + ";" + result);
280
					throw  e;
281
				}
282
			}
283
		}catch (Exception e){
284
			Log.i("algo","transpostData:"+ dataAction + ";" + param + ";" + e.toString() + e.getMessage() + ";" + e.getCause());
285
			throw  e;
268 286
		}
269 287
		return result;
270 288
	}
@ -291,22 +309,44 @@ public class MobileNetWork extends Plugin {
291 309
	public Map<String, String> transPostData(String dataAction, IData dataParam) throws Exception {
292 310
		// TODO Auto-generated method stub
293 311
		Map<String, String> postData = new HashMap<String, String>();
294
		postData.put(Constant.Server.ACTION, dataAction);
295
		if (ServerDataConfig.isEncrypt(dataAction)) {
296
			MobileSecurity.init();
297
			/* 参数加密处理 */
298
			String key = MobileSecurity.getDesKey();
299
			postData.put(Constant.Server.KEY, key);
300
			
301
			if(dataParam!=null){
302
				String encryptData = MobileSecurity.requestEncrypt(dataParam.toString());
303
				postData.put(Constant.Server.DATA, encryptData);
312
			postData.put(Constant.Server.ACTION, dataAction);
313
314
		try {
315
			ServerDataConfig.isEncrypt(dataAction);
316
		}
317
			catch (Exception e){
318
				Log.i("algo","transPostData222:" + dataAction + dataParam.toString() +  e.toString());
319
				throw e;
304 320
			}
305
		} else {
306
			if (dataParam != null) {
307
				postData.put(Constant.Server.DATA, dataParam.toString());
321
			if (ServerDataConfig.isEncrypt(dataAction)) {
322
				try {
323
					MobileSecurity.init();
324
				}catch (Exception e){
325
					Log.i("algo","MobileSecurity.init()" +  e.toString());
326
					throw e;
327
				}
328
			/* 参数加密处理 */
329
				try {
330
					String key = MobileSecurity.getDesKey();
331
					postData.put(Constant.Server.KEY, key);
332
				}catch (Exception e){
333
					Log.i("algo","MobileSecurity.getDesKey()" +  e.toString());
334
					throw e;
335
				}
336
				if(dataParam!=null){
337
					try {
338
						String encryptData = MobileSecurity.requestEncrypt(dataParam.toString());
339
						postData.put(Constant.Server.DATA, encryptData);
340
					}catch (Exception e){
341
						Log.i("algo","MobileSecurity.requestEncrypt()" +  e.toString());
342
						throw e;
343
					}
344
				}
345
			} else {
346
				if (dataParam != null) {
347
					postData.put(Constant.Server.DATA, dataParam.toString());
348
				}
308 349
			}
309
		}
310 350
		return postData;
311 351
	}
312 352