[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/app/zte_lpa/Makefile b/ap/app/zte_lpa/Makefile
new file mode 100755
index 0000000..087d058
--- /dev/null
+++ b/ap/app/zte_lpa/Makefile
@@ -0,0 +1,42 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################

+EXEC = zte_lpa

+OBJS = zte_lpa.o

+

+CFLAGS += -I$(zte_app_path)/include
+CFLAGS += -I$(zte_lib_path)/libssl/install/include
+CFLAGS += -I$(zte_lib_path)/liblpa

+CFLAGS += -g

+CFLAGS += -g -Werror=implicit-function-declaration
+

+

+LDLIBS += -lpthread  

+LDLIBS += -lnvram_sc -L$(zte_lib_path)/libnvram
+LDLIBS += -lsoft_timer_sc -L$(zte_lib_path)/libsoft_timer
+LDLIBS += -lsoftap -L$(zte_lib_path)/libsoftap
+LDLIBS += -L$(zte_lib_path)/libssl/install/lib -lssl -lcrypto
+LDLIBS += -ldl
+LDLIBS  += -latutils -L$(zte_lib_path)/libatutils
+LDLIBS += -L$(zte_lib_path)/liblpa -llpa -les10
+LDLIBS += -lm
+

+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+$(EXEC): $(OBJS)
+	$(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
+	@cp $@ $@.elf
+
+romfs:
+	$(ROMFSINST) -e CONFIG_USER_ZTE_APP /sbin/$(EXEC)
+
+clean:
+	-rm -f $(EXEC) *.elf *.gdb *.o
diff --git a/ap/app/zte_lpa/readme.txt b/ap/app/zte_lpa/readme.txt
new file mode 100755
index 0000000..8e831dc
--- /dev/null
+++ b/ap/app/zte_lpa/readme.txt
@@ -0,0 +1,19 @@
+1.zte_lpaÄ£¿é¹¦ÄÜ£º

+	´Ó´¥·¢·þÎñÆ÷»ñÈ¡eventÖ¸Á°´Ö¸ÁîÒªÇóµ÷ÓÃliblpa¿â½øÐÐÏÂÔØ¡¢¼¤»î¡¢È¥¼¤»î¡¢É¾³ý¡¢ÖØÖÃesimµÄ²Ù×÷¡£ÔÚÖ´ÐÐÍêÖ¸Áîºó£¬updataÉϱ¨Ö¸ÁîµÄÖ´Ðнá¹û¡£

+	

+2.×¢ÒâÊÂÏ

+	°´ÁªÍ¨ÒªÇó£¬Ä¿Ç°½ö¿ª»úʱ½øÐÐÒ»´ÎeventÖ¸Áî»ñÈ¡£¬ºóÐø²»ÔÙÂÖѯ¡£

+	ÏÂÔØÖ¸ÁÔÚÏÂÔØÍêprofileºó£¬ÐèÖ±½Ó¼¤»î¡£

+	ÒòÏÂÔØ·þÎñÆ÷ÏÞÖÆ£¬ÈçÏÂÔØÊ§°Ü£¬Ðè¼ä¸ô90sÔÙÖØÊÔ¡£

+	

+3.ÅäÖÃ˵Ã÷£º

+	´¥·¢ÇëÇóµÄʱ¼äÐèÒªºÍ´¥·¢·þÎñÆ÷µÄÎó²îÔÚ3·ÖÖÓÄÚ£¬ËùÒÔÐèÒª¿ªÆôsntp×Ô¶¯Í¬²½Ê±¼ä¹¦ÄÜ¡£

+	zte_lpaĬÈÏ¿ª»ú²»Æô¶¯£¬ÐèÒªÅäÖÃNV enable_lpa=1

+	ÐÞ¸ÄÓ¦ÓÃID£¬ÐèÒªÖØÐÂÅäÖÃNV lpa_appid¡¢lpa_appsecret

+	Ð޸Ĵ¥·¢·þÎñÆ÷µÄ²ÎÊý£¬ÐèÒªÖØÐÂÅäÖÃNV lpa_trigger_host¡¢lpa_trigger_port¡¢lpa_trigger_event_url¡¢lpa_trigger_updata_url

+	ÏÂÔØÊ§°Ü£¬Ä¿Ç°»áÖØÊÔÒ»´Î£¬¿Éͨ¹ýÅäÖÃNV lpa_dl_retryÐÞ¸Ä

+	updataÉϱ¨Ê§°Ü£¬Ä¿Ç°»áÖØÊÔÒ»´Î£¬¿Éͨ¹ýÅäÖÃNV lpa_updata_retryÐÞ¸Ä

+

+4.ÏÂÔØÁ÷³Ì

+	´¥·¢·þÎñÆ÷»ñÈ¡ÏÂÔØÖ¸Áî->½âÎö³öÏÂÔØ·þÎñÆ÷µØÖ·->Á¬½ÓÏÂÔØ·þÎñÆ÷->½øÐÐES9 InitiateAuthentication->ES9 AuthenticateClient->ES9 GetBoundProfilePackage£¨Ð´Èësim¿¨£©->ES9 HandleNotification->ES10c EnableProfile->Ïò´¥·¢·þÎñÆ÷Éϱ¨½á¹û

+	
\ No newline at end of file
diff --git a/ap/app/zte_lpa/zte_lpa.c b/ap/app/zte_lpa/zte_lpa.c
new file mode 100755
index 0000000..b80f265
--- /dev/null
+++ b/ap/app/zte_lpa/zte_lpa.c
@@ -0,0 +1,65 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "softap_api.h"
+#include "lpa_api.h"
+
+int main(int argc, char *argv[])
+{
+	int poll_num = 1;
+	int poll_interval = 0;
+	
+	printf("##zte_lpa start##\n");
+
+	if (-1 == lpa_init()) {
+		printf("lpa init fail!\n");
+		return -1;
+	}
+
+	lpa_exception_process();
+
+	do {
+		int next_step = 0;
+		char *command = NULL;
+//dtest
+//char activecode[] = "1$esim.wo.cn$$1.3.6.1.4.1.47814.2.4";
+//lpa_download_profile(activecode, NULL);
+//lpa_enable_profile("98689091170012145989");
+//lpa_memory_reset();
+//return 0;
+		command = lpa_trigger_event(&next_step);
+
+		switch (next_step) {
+			case 1:
+				lpa_download_profile(command, NULL);
+				break;
+			case 2:
+				lpa_enable_profile(command);
+				break;
+			case 3:
+				lpa_disable_profile(command);
+				break;
+			case 4:
+				lpa_delete_profile(command);
+				break;
+			case 5:
+				lpa_memory_reset();
+				break;
+
+			default:
+				break;
+		}
+		if (command != NULL) 
+			free(command);
+
+		sleep(poll_interval);
+		poll_num--;
+	} while (poll_num > 0);
+
+	lpa_uninit();
+	printf("##zte_lpa end##\n");
+    return 0;
+}
+