postedmap) {
144 | // TODO Auto-generated method stub
145 | Log.d(TAG, "Post Receive-post error");
146 | LogUtil.postResultLog(returnstr[0], returnstr[1], returnstr[2]);
147 | PreferenceUtil preference = new PreferenceUtil(getBaseContext());
148 | if (preference.isPostRepeat()) {
149 | String repeatlimit = preference.getPostRepeatNum();
150 | int limitnum = Integer.parseInt(repeatlimit);
151 | String repeatnumstr = postedmap.get("repeatnum");
152 | int repeatnum = Integer.parseInt(repeatnumstr);
153 | if (repeatnum <= limitnum) {
154 |
155 | }
156 |
157 | }
158 |
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/payment-listener/src/main/java/com/lhalcyon/pl/service/NotificationForegroundMonitorService.java:
--------------------------------------------------------------------------------
1 | package com.lhalcyon.pl.service;
2 |
3 |
4 | import android.app.ActivityManager;
5 | import android.app.NotificationChannel;
6 | import android.app.NotificationManager;
7 | import android.app.Service;
8 | import android.content.ComponentName;
9 | import android.content.Context;
10 | import android.content.Intent;
11 | import android.content.pm.PackageManager;
12 | import android.os.IBinder;
13 | import android.os.Process;
14 | import android.support.v4.app.NotificationCompat;
15 | import android.util.Log;
16 |
17 | import com.lhalcyon.pl.PLInitializer;
18 | import com.lhalcyon.pl.R;
19 |
20 | import java.util.List;
21 | import java.util.Random;
22 |
23 |
24 | /**
25 | * Created by xinghui on 9/20/16.
26 | *
27 | * calling this in your Application's onCreate
28 | * startService(new Intent(this, NotificationCollectorMonitorService.class));
29 | *
30 | * BY THE WAY Don't Forget to Add the Service to the AndroidManifest.xml File.
31 | *
32 | */
33 | public class NotificationForegroundMonitorService extends Service {
34 |
35 | private static final String CHANNEL_ID = "com.appname.notification.channel";
36 |
37 | /**
38 | * {@link Log#isLoggable(String, int)}
39 | *
40 | * IllegalArgumentException is thrown if the tag.length() > 23.
41 | */
42 | private static final String TAG = "NotifiCollectorMonitor";
43 |
44 | @Override
45 | public void onCreate() {
46 | super.onCreate();
47 | ensureCollectorRunning();
48 |
49 | }
50 |
51 | @Override
52 | public int onStartCommand(Intent intent, int flags, int startId) {
53 | return START_STICKY;
54 | }
55 |
56 |
57 | private void ensureCollectorRunning() {
58 | ComponentName collectorComponent = new ComponentName(this, /*NotificationListenerService Inheritance*/ NLService.class);
59 | Log.v(TAG, "ensureCollectorRunning collectorComponent: " + collectorComponent);
60 | ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
61 | boolean collectorRunning = false;
62 | List runningServices = manager.getRunningServices(Integer.MAX_VALUE);
63 | if (runningServices == null) {
64 | Log.w(TAG, "ensureCollectorRunning() runningServices is NULL");
65 | return;
66 | }
67 | for (ActivityManager.RunningServiceInfo service : runningServices) {
68 | if (service.service.equals(collectorComponent)) {
69 | Log.w(TAG, "ensureCollectorRunning service - pid: " + service.pid + ", currentPID: " + Process.myPid() + ", clientPackage: " + service.clientPackage + ", clientCount: " + service.clientCount
70 | + ", clientLabel: " + ((service.clientLabel == 0) ? "0" : "(" + getResources().getString(service.clientLabel) + ")"));
71 | if (service.pid == Process.myPid() /*&& service.clientCount > 0 && !TextUtils.isEmpty(service.clientPackage)*/) {
72 | collectorRunning = true;
73 | }
74 | }
75 | }
76 | if (collectorRunning) {
77 | Log.d(TAG, "ensureCollectorRunning: collector is running");
78 | return;
79 | }
80 | Log.d(TAG, "ensureCollectorRunning: collector not running, reviving...");
81 | toggleNotificationListenerService(true);
82 | }
83 |
84 | private void toggleNotificationListenerService(boolean isForeground) {
85 | Log.d(TAG, "toggleNotificationListenerService() called");
86 | ComponentName thisComponent = new ComponentName(this, /*getClass()*/ NLService.class);
87 | PackageManager pm = getPackageManager();
88 | pm.setComponentEnabledSetting(thisComponent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
89 | pm.setComponentEnabledSetting(thisComponent, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
90 | if (isForeground && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
91 | //设定的通知渠道名称
92 | String channelName = "picasso";
93 | //设置通知的重要程度
94 | int importance = NotificationManager.IMPORTANCE_DEFAULT;
95 | //构建通知渠道
96 | NotificationChannel channel = new NotificationChannel(CHANNEL_ID, channelName, importance);
97 | channel.setDescription("picasso description");
98 | //在创建的通知渠道上发送通知
99 | NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID);
100 | builder.setSmallIcon(R.mipmap.ic_notifier) //设置通知图标
101 | .setBadgeIconType(R.mipmap.ic_notifier)
102 | .setContentTitle(PLInitializer.shared().getNotificationTitle())//设置通知标题
103 | .setContentText(PLInitializer.shared().getNotificationDesc())//设置通知内容
104 | .setAutoCancel(false) //用户触摸时,自动关闭
105 | .setOngoing(true);//设置处于运行状态
106 | //向系统注册通知渠道,注册后不能改变重要性以及其他通知行为
107 | NotificationManager notificationManager = (NotificationManager) getBaseContext().getSystemService(Context.NOTIFICATION_SERVICE);
108 | if (notificationManager != null) {
109 | notificationManager.createNotificationChannel(channel);
110 | }
111 | //将服务置于启动状态 NOTIFICATION_ID指的是创建的通知的ID
112 | startForeground(new Random().nextInt(2000), builder.build());
113 | } else {
114 | // do nothing
115 | }
116 |
117 | }
118 |
119 | @Override
120 | public IBinder onBind(Intent intent) {
121 | return null;
122 | }
123 |
124 | public class DeviceBean {
125 | public String deviceid;
126 | public String connectedtime;
127 |
128 | public void setDeviceid(String deviceid) {
129 | this.deviceid = deviceid;
130 | }
131 |
132 | public void setTime(String time) {
133 | this.connectedtime = time;
134 | }
135 |
136 | }
137 |
138 |
139 | }
140 |
--------------------------------------------------------------------------------
/payment-listener/src/main/java/com/lhalcyon/pl/support/ILog.java:
--------------------------------------------------------------------------------
1 | package com.lhalcyon.pl.support;
2 |
3 | /**
4 | *
5 | * Create by : L
6 | * Create Time: 2019/7/3
7 | * Brief Desc :
8 | *
9 | */
10 | public interface ILog {
11 |
12 |
13 | void info(String message);
14 | }
15 |
--------------------------------------------------------------------------------
/payment-listener/src/main/java/com/lhalcyon/pl/support/OnNotificationReceivedListener.java:
--------------------------------------------------------------------------------
1 | package com.lhalcyon.pl.support;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | *
7 | * Create by : L
8 | * Create Time: 2019/7/3
9 | * Brief Desc :
10 | *
11 | */
12 | public interface OnNotificationReceivedListener {
13 |
14 | void onPaymentTypeReceived(Map params);
15 |
16 | void onUndefineNotificationReceived(String pkg,String content);
17 | }
18 |
--------------------------------------------------------------------------------
/payment-listener/src/main/java/com/lhalcyon/pl/util/DeviceInfoUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Created By WeihuaGu (email:weihuagu_work@163.com)
3 | */
4 |
5 | package com.lhalcyon.pl.util;
6 |
7 | import android.os.Build;
8 |
9 | import java.util.UUID;
10 |
11 | public class DeviceInfoUtil {
12 | /**
13 | * Return pseudo unique ID
14 | * @return ID
15 | */
16 | public static String getUniquePsuedoID() {
17 | // If all else fails, if the user does have lower than API 9 (lower
18 | // than Gingerbread), has reset their device or 'Secure.ANDROID_ID'
19 | // returns 'null', then simply the ID returned will be solely based
20 | // off their Android device information. This is where the collisions
21 | // can happen.
22 | // Thanks http://www.pocketmagic.net/?p=1662!
23 | // Try not to use DISPLAY, HOST or ID - these items could change.
24 | // If there are collisions, there will be overlapping data
25 | String m_szDevIDShort = "35" + (Build.BOARD.length() % 10) + (Build.BRAND.length() % 10) + (Build.CPU_ABI.length() % 10) + (Build.DEVICE.length() % 10) + (Build.MANUFACTURER.length() % 10) + (Build.MODEL.length() % 10) + (Build.PRODUCT.length() % 10);
26 |
27 | // Thanks to @Roman SL!
28 | // http://stackoverflow.com/a/4789483/950427
29 | // Only devices with API >= 9 have android.os.Build.SERIAL
30 | // http://developer.android.com/reference/android/os/Build.html#SERIAL
31 | // If a user upgrades software or roots their device, there will be a duplicate entry
32 | String serial = null;
33 | try {
34 | serial = Build.class.getField("SERIAL").get(null).toString();
35 |
36 | // Go ahead and return the serial for api => 9
37 | return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
38 | } catch (Exception exception) {
39 | // String needs to be initialized
40 | serial = "serial"; // some value
41 | }
42 |
43 | // Thanks @Joe!
44 | // http://stackoverflow.com/a/2853253/950427
45 | // Finally, combine the values we have found by using the UUID class to create a unique identifier
46 | return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/payment-listener/src/main/java/com/lhalcyon/pl/util/LogUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Created By WeihuaGu (email:weihuagu_work@163.com)
3 | * Copyright (c) 2017
4 | * All right reserved.
5 | */
6 |
7 | package com.lhalcyon.pl.util;
8 |
9 | import android.util.Log;
10 |
11 |
12 | public class LogUtil {
13 | public static String TAG="NLService";
14 | public static String DEBUGTAG="NLDebugService";
15 | public static String EXCEPTIONTAG="NLExceptionService";
16 | public static void infoLog(String info){
17 | Log.i(TAG,info);
18 | }
19 |
20 | public static void debugLog(String info){
21 | Log.d(TAG,info);
22 | }
23 |
24 | public static void debugLogWithDeveloper(String info){
25 | Log.d(DEBUGTAG,info);
26 | }
27 |
28 | public static void debugLogWithJava(String info){
29 | System.out.println(DEBUGTAG+":"+info);
30 | }
31 |
32 | public static void postRecordLog(String tasknum,String post){
33 | Log.i(TAG,"*********************************");
34 | Log.i(TAG,"开始推送 随机序列号:"+tasknum);
35 | Log.i(TAG,post);
36 | }
37 |
38 | public static void postResultLog(String tasknum,String result,String returnstr){
39 |
40 | Log.i(TAG,"推送结果 随机序列号:"+tasknum);
41 | Log.i(TAG,"推送结果:"+result);
42 | Log.i(TAG,"返回内容:" + returnstr);
43 | Log.i(TAG,"------------------------------------------");
44 |
45 |
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/payment-listener/src/main/java/com/lhalcyon/pl/util/NotificationUtil.java:
--------------------------------------------------------------------------------
1 | package com.lhalcyon.pl.util;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.support.v4.app.NotificationManagerCompat;
6 |
7 | /**
8 | *
9 | * Create by : L
10 | * Create Time: 2019/7/2
11 | * Brief Desc :
12 | *
13 | */
14 | public class NotificationUtil {
15 |
16 |
17 | /**
18 | * 开启通知栏设置界面
19 | * @param context 上下文
20 | */
21 | public static void startNotificationActivity(Context context){
22 | context.startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS").setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
23 | }
24 |
25 |
26 | /**
27 | *
28 | * @return 是否已授权通知栏
29 | */
30 | public static boolean isNotificationServiceEnable(Context context) {
31 | return NotificationManagerCompat.getEnabledListenerPackages(context).contains(context.getPackageName());
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/payment-listener/src/main/java/com/lhalcyon/pl/util/PreferenceUtil.java:
--------------------------------------------------------------------------------
1 | package com.lhalcyon.pl.util;
2 | import android.content.Context;
3 | import android.content.SharedPreferences;
4 | import android.preference.PreferenceManager;
5 |
6 | public class PreferenceUtil {
7 | SharedPreferences sharedPref=null;
8 | Context context=null;
9 | public PreferenceUtil(Context context){
10 | this.context=context;
11 | init();
12 | }
13 | public void init(){
14 | sharedPref=PreferenceManager.getDefaultSharedPreferences(this.context);
15 |
16 | }
17 | public String getDeviceid(){
18 | return this.sharedPref.getString("deviceid","");
19 | }
20 | public boolean isEncrypt(){
21 | return this.sharedPref.getBoolean("isencrypt",false);
22 | }
23 | public boolean isEcho(){
24 | return this.sharedPref.getBoolean("isecho",false);
25 | }
26 | public String getEchoServer(){
27 | return this.sharedPref.getString("echoserver",null);
28 | }
29 | public String getEchoInterval(){
30 | return this.sharedPref.getString("echointerval","");
31 | }
32 | public String getEncryptMethod(){
33 | return this.sharedPref.getString("encryptmethod",null);
34 | }
35 | public String getPasswd(){
36 | return this.sharedPref.getString("passwd",null);
37 | }
38 | public boolean isRemoveNotification(){
39 | return this.sharedPref.getBoolean("isremovenotification",false);
40 | }
41 | public boolean isPostRepeat(){
42 | return this.sharedPref.getBoolean("ispostrepeat",false);
43 | }
44 | public String getPostRepeatNum(){
45 | return this.sharedPref.getString("postrepeatnum","3");
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/payment-listener/src/main/res/drawable/ic_notifier_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-anydpi-v26/ic_notifier.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-anydpi-v26/ic_notifier_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-hdpi/ic_notifier.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-hdpi/ic_notifier.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-hdpi/ic_notifier_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-hdpi/ic_notifier_foreground.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-hdpi/ic_notifier_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-hdpi/ic_notifier_round.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-mdpi/ic_notifier.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-mdpi/ic_notifier.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-mdpi/ic_notifier_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-mdpi/ic_notifier_foreground.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-mdpi/ic_notifier_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-mdpi/ic_notifier_round.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-xhdpi/ic_notifier.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-xhdpi/ic_notifier.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-xhdpi/ic_notifier_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-xhdpi/ic_notifier_foreground.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-xhdpi/ic_notifier_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-xhdpi/ic_notifier_round.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-xxhdpi/ic_notifier.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-xxhdpi/ic_notifier.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-xxhdpi/ic_notifier_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-xxhdpi/ic_notifier_foreground.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-xxhdpi/ic_notifier_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-xxhdpi/ic_notifier_round.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-xxxhdpi/ic_notifier.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-xxxhdpi/ic_notifier.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-xxxhdpi/ic_notifier_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-xxxhdpi/ic_notifier_foreground.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/mipmap-xxxhdpi/ic_notifier_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/payment-listener/src/main/res/mipmap-xxxhdpi/ic_notifier_round.png
--------------------------------------------------------------------------------
/payment-listener/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Payment-Listener
3 |
4 |
--------------------------------------------------------------------------------
/payment-listener/src/test/java/com/lhalcyon/pl/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.lhalcyon.pl;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':payment-listener', ':test-app'
2 |
--------------------------------------------------------------------------------
/test-app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/test-app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 |
6 |
7 |
8 | defaultConfig {
9 | applicationId "org.loois.test_app"
10 | minSdkVersion 21
11 | targetSdkVersion 26
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 |
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | compileOptions {
27 | targetCompatibility 1.8
28 | sourceCompatibility 1.8
29 | }
30 |
31 | lintOptions {
32 | abortOnError false
33 | checkReleaseBuilds false
34 |
35 |
36 | }
37 |
38 | }
39 |
40 | dependencies {
41 | implementation fileTree(include: ['*.jar'], dir: 'libs')
42 | implementation 'com.android.support:appcompat-v7:26.1.0'
43 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
44 | testImplementation 'junit:junit:4.12'
45 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
46 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
47 | implementation project(':payment-listener')
48 | }
49 |
--------------------------------------------------------------------------------
/test-app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/test-app/src/androidTest/java/org/loois/test_app/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package org.loois.test_app;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("org.loois.test_app", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/test-app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/test-app/src/main/java/org/loois/test_app/MainActivity.java:
--------------------------------------------------------------------------------
1 | package org.loois.test_app;
2 |
3 | import android.app.Notification;
4 | import android.app.NotificationManager;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.graphics.BitmapFactory;
8 | import android.os.Bundle;
9 | import android.support.v4.app.NotificationCompat;
10 | import android.support.v7.app.AppCompatActivity;
11 | import android.support.v7.widget.SwitchCompat;
12 | import android.util.Log;
13 | import android.view.View;
14 | import android.widget.TextView;
15 |
16 | import com.lhalcyon.pl.PLInitializer;
17 | import com.lhalcyon.pl.service.NotificationCollectorMonitorService;
18 | import com.lhalcyon.pl.service.NotificationForegroundMonitorService;
19 | import com.lhalcyon.pl.support.ILog;
20 | import com.lhalcyon.pl.support.OnNotificationReceivedListener;
21 | import com.lhalcyon.pl.util.NotificationUtil;
22 |
23 | import java.util.Map;
24 |
25 | public class MainActivity extends AppCompatActivity {
26 |
27 | SwitchCompat mSwitchCompat;
28 |
29 | TextView mTextView;
30 |
31 | Context mContext;
32 |
33 | @Override
34 | protected void onCreate(Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_main);
37 |
38 | mTextView = findViewById(R.id.content);
39 |
40 | mSwitchCompat = findViewById(R.id.notifySwitch);
41 |
42 |
43 | mContext = this;
44 |
45 | PLInitializer.shared()
46 | .setLog(new ILog() {
47 | @Override
48 | public void info(String message) {
49 | Log.i("监听", message);
50 | }
51 | })
52 | .setNotificationTitle("Piccaso")
53 | .setNotificationDesc("正在自动确认收款")
54 | .setNotificationReceivedListener(new OnNotificationReceivedListener() {
55 | @Override
56 | public void onPaymentTypeReceived(Map params) {
57 | mTextView.setText(params.toString());
58 | showNotification(params.get("title"), params.get("money") + " | " + params.get("content"));
59 | }
60 |
61 | @Override
62 | public void onUndefineNotificationReceived(String pkg, String content) {
63 | System.out.println(pkg);
64 | System.out.println(content);
65 | }
66 | });
67 | }
68 |
69 | private void showNotification(String title, String content) {
70 | NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
71 | Notification notification = new NotificationCompat.Builder(this, "payment-listener")
72 | .setContentTitle(title)
73 | .setContentText(content)
74 | .setWhen(System.currentTimeMillis())
75 | .setSmallIcon(R.drawable.ic_launcher_foreground)
76 | .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_foreground))
77 | .setAutoCancel(true)
78 | .build();
79 | assert manager != null;
80 | manager.notify(2, notification);
81 | }
82 |
83 |
84 | public void onTestNotify(View v) {
85 | showNotification("123", "234dsklj");
86 | }
87 |
88 | @Override
89 | protected void onResume() {
90 | super.onResume();
91 | setStatus();
92 |
93 | }
94 |
95 | public void onStartService(View v){
96 | startService(new Intent(this, NotificationCollectorMonitorService.class));
97 | }
98 |
99 | public void onStopService(View v){
100 | stopService(new Intent(this, NotificationCollectorMonitorService.class));
101 | }
102 |
103 | public void onStartForeService(View v){
104 | startService(new Intent(this, NotificationForegroundMonitorService.class));
105 | }
106 |
107 | public void onStopForeService(View v){
108 | stopService(new Intent(this, NotificationForegroundMonitorService.class));
109 | }
110 |
111 |
112 |
113 | public void onJumpNotifySetting(View v) {
114 | NotificationUtil.startNotificationActivity(mContext);
115 | }
116 |
117 | private void setStatus() {
118 | boolean notificationServiceEnable = NotificationUtil.isNotificationServiceEnable(mContext);
119 | Log.i("Notify enable:", "" + notificationServiceEnable);
120 | mSwitchCompat.setChecked(notificationServiceEnable);
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/test-app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/test-app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
16 |
21 |
26 |
31 |
36 |
41 |
46 |
51 |
56 |
61 |
66 |
71 |
76 |
81 |
86 |
91 |
96 |
101 |
106 |
111 |
116 |
121 |
126 |
131 |
136 |
141 |
146 |
151 |
156 |
161 |
166 |
171 |
172 |
--------------------------------------------------------------------------------
/test-app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
14 |
15 |
23 |
24 |
28 |
29 |
30 |
31 |
32 |
33 |
36 |
37 |
42 |
43 |
48 |
49 |
50 |
51 |
54 |
55 |
60 |
61 |
66 |
67 |
68 |
69 |
70 |
76 |
77 |
85 |
86 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/test-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/test-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/test-app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/test-app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test-app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/test-app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test-app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/test-app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test-app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/test-app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test-app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/test-app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/test-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test-app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/test-app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/test-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/test-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhalcyon/payment-listener/aa7149f425cbf64609348d8725909654aa8fdfc7/test-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test-app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/test-app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 支付监听
3 |
4 |
--------------------------------------------------------------------------------
/test-app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/test-app/src/test/java/org/loois/test_app/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package org.loois.test_app;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------