├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── raw
│ │ │ │ ├── paycomp.mp3
│ │ │ │ ├── payrecv.mp3
│ │ │ │ ├── wx_lack.mp3
│ │ │ │ ├── zfb_lack.mp3
│ │ │ │ └── networkerror.mp3
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_log.xml
│ │ │ │ ├── sample_log_item_comp.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── content_main.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── java
│ │ │ └── xyz
│ │ │ │ └── loadnl
│ │ │ │ └── payrecord
│ │ │ │ ├── IMessageHander.java
│ │ │ │ ├── data
│ │ │ │ ├── LogItem.java
│ │ │ │ ├── AppConst.java
│ │ │ │ └── OrderData.java
│ │ │ │ ├── BatteryReceiver.java
│ │ │ │ ├── LogActivity.java
│ │ │ │ ├── util
│ │ │ │ ├── DBHelper.java
│ │ │ │ ├── AppUtil.java
│ │ │ │ └── DBManager.java
│ │ │ │ ├── MainService.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── NotificationMonitorService.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── xyz
│ │ │ └── loadnl
│ │ │ └── payrecord
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── xyz
│ │ └── loadnl
│ │ └── payrecord
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
├── build.gradle
└── app.iml
├── .gitignore
├── settings.gradle
├── local.properties
├── gradle.properties
├── PayRecord.iml
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /app/build/
2 | /gradle/
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/paycomp.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/raw/paycomp.mp3
--------------------------------------------------------------------------------
/app/src/main/res/raw/payrecv.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/raw/payrecv.mp3
--------------------------------------------------------------------------------
/app/src/main/res/raw/wx_lack.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/raw/wx_lack.mp3
--------------------------------------------------------------------------------
/app/src/main/res/raw/zfb_lack.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/raw/zfb_lack.mp3
--------------------------------------------------------------------------------
/app/src/main/res/raw/networkerror.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/raw/networkerror.mp3
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loadnl/payrecord/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/java/xyz/loadnl/payrecord/IMessageHander.java:
--------------------------------------------------------------------------------
1 | package xyz.loadnl.payrecord;
2 |
3 | import android.os.Message;
4 |
5 |
6 |
7 | public interface IMessageHander {
8 | void handMessage(Message msg);
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/loadnl/payrecord/data/LogItem.java:
--------------------------------------------------------------------------------
1 | package xyz.loadnl.payrecord.data;
2 |
3 |
4 |
5 | public class LogItem {
6 | public int id;
7 | public String log_value;
8 | public int log_type;
9 | public String create_dt;
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file should *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk.dir=/Users/loadnl/Library/Android/sdk
11 |
--------------------------------------------------------------------------------
/app/src/test/java/xyz/loadnl/payrecord/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package xyz.loadnl.payrecord;
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 | }
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
15 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/loadnl/payrecord/data/AppConst.java:
--------------------------------------------------------------------------------
1 | package xyz.loadnl.payrecord.data;
2 |
3 | /**
4 | * Create by loadnl
5 | * Date: 2019/4/1
6 | * Function:
7 | **/
8 | public class AppConst {
9 |
10 | public static boolean PlaySounds = true;
11 | public static final String CHANNEL_Front = "Front";
12 | public static final String CHANNEL_ID = "ID";
13 | public static final String IntentAction = "xyz.loadnl.Notification";
14 |
15 | public static int Battery=0;
16 | public static int DetaTime = 0;//手机和服务器的时间差
17 |
18 | public static final String KeyMute = "mute";
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/loadnl/payrecord/data/OrderData.java:
--------------------------------------------------------------------------------
1 | package xyz.loadnl.payrecord.data;
2 |
3 |
4 |
5 | public class OrderData {
6 | public String payType;
7 | public String username;
8 | public String money;
9 | public String sign;
10 | public String ranStr;
11 | public int dianYuan;
12 | public long time;
13 | public OrderData(final String payType, final String money, final String username, boolean dianYuan){
14 | this.payType = payType;
15 | this.username = username;
16 | this.money = money;
17 | this.dianYuan = dianYuan?1:0;
18 | time = System.currentTimeMillis()/1000 - AppConst.DetaTime;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/loadnl/payrecord/BatteryReceiver.java:
--------------------------------------------------------------------------------
1 | package xyz.loadnl.payrecord;
2 |
3 |
4 | import android.content.BroadcastReceiver;
5 | import android.content.Context;
6 | import android.content.Intent;
7 |
8 | import xyz.loadnl.payrecord.data.AppConst;
9 |
10 |
11 | public class BatteryReceiver extends BroadcastReceiver {
12 | @Override
13 | public void onReceive(Context context, Intent intent) {
14 | if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
15 | //获取当前电量
16 | int level = intent.getIntExtra("level", 0);
17 | //电量的总刻度
18 | int scale = intent.getIntExtra("scale", 100);
19 | //把它转成百分比
20 | int rate = (level * 100) / scale;
21 | AppConst.Battery = rate;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/xyz/loadnl/payrecord/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package xyz.loadnl.payrecord;
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("xyz.loadnl.payrecord", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/PayRecord.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_log.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "xyz.loadnl.payrecord"
7 | minSdkVersion 21
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'com.android.support:appcompat-v7:28.0.0'
24 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
25 | implementation 'com.android.support:design:28.0.0'
26 | testImplementation 'junit:junit:4.12'
27 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
28 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | PayRecord
3 | Settings
4 |
5 | 登录
6 | 确定
7 | "支付服务"
8 | 微信
9 | 支付宝
10 | 日志记录
11 | 服务权限
12 | 打开权限设置
13 | 静音
14 | 订单管理
15 | 二维码管理
16 | 商户密钥
17 | 获取Token
18 | 开启
19 | 关闭
20 | appid
21 | token
22 | \n1:点击获取Token,捐赠1元可以获取一个TOKEN
23 | 日志记录
24 | 退出
25 | 自定义接口>
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/loadnl/payrecord/LogActivity.java:
--------------------------------------------------------------------------------
1 | package xyz.loadnl.payrecord;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 | import android.widget.LinearLayout;
7 | import android.widget.TextView;
8 |
9 |
10 |
11 | import java.util.ArrayList;
12 |
13 | import xyz.loadnl.payrecord.data.LogItem;
14 | import xyz.loadnl.payrecord.util.DBManager;
15 |
16 | public class LogActivity extends AppCompatActivity {
17 | private LinearLayout container;
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_log);
23 | container = findViewById(R.id.log_container);
24 | }
25 |
26 | @Override
27 | protected void onResume() {
28 | super.onResume();
29 | container.removeAllViews();
30 | AddLogItem();
31 | }
32 |
33 | private void AddLogItem(){
34 | DBManager db = new DBManager(this);
35 | ArrayList list = db.getLogList(0,0);
36 | for (LogItem item:list) {
37 | View view = View.inflate(this, R.layout.sample_log_item_comp, null);
38 | updateText(item,view);
39 | container.addView(view);
40 | }
41 | }
42 |
43 | private void updateText(LogItem data, View view){
44 | TextView textView = view.findViewById(R.id.text_id);
45 | textView.setText(""+data.id);
46 | textView = view.findViewById(R.id.text_create_dt);
47 | textView.setText(data.create_dt);
48 | textView = view.findViewById(R.id.text_type);
49 | textView.setText(""+data.log_type);
50 | textView = view.findViewById(R.id.text_value);
51 | textView.setText(data.log_value);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/loadnl/payrecord/util/DBHelper.java:
--------------------------------------------------------------------------------
1 | package xyz.loadnl.payrecord.util;
2 |
3 | import android.content.Context;
4 | import android.database.sqlite.SQLiteDatabase;
5 | import android.database.sqlite.SQLiteOpenHelper;
6 |
7 | /**
8 | *
9 |
10 | * @ClassName: DBHelper
11 |
12 | * @Description: TODO(这里用一句话描述这个类的作用)
13 |
14 | * @date 2018年6月23日 下午1:27:16
15 |
16 | *
17 | */
18 | public class DBHelper extends SQLiteOpenHelper {
19 | private static DBHelper sInstance;
20 | public DBHelper(Context context) {
21 | super(context, "loadnl.db", null, 2);
22 | }
23 |
24 | @Override
25 | public void onCreate(SQLiteDatabase db) {
26 | // db.execSQL("CREATE TABLE IF NOT EXISTS ukafu" +
27 | // "(_id INTEGER PRIMARY KEY AUTOINCREMENT, money varchar, mark varchar, type varchar, payurl varchar, dt varchar)");
28 | db.execSQL("CREATE TABLE IF NOT EXISTS loadnl (key_m varchar primary key,value_m varchar)");
29 | String sql = "CREATE TABLE IF NOT EXISTS loadnl_log(id integer primary key autoincrement,log_value varchar(512),log_type int(11),create_dt varchar(20))";
30 | db.execSQL(sql);
31 | }
32 |
33 | @Override
34 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
35 | if(newVersion==2){
36 | String sql = "CREATE TABLE IF NOT EXISTS loadnl_log(id integer primary key autoincrement,log_value varchar(512),log_type int(11),create_dt varchar(20))";
37 | db.execSQL(sql);
38 | }
39 | }
40 |
41 | public static DBHelper getInstance(Context context) {
42 |
43 | // Use the application context, which will ensure that you
44 | // don't accidentally leak an Activity's context.
45 | // See this article for more information: http://bit.ly/6LRzfx
46 | if (sInstance == null) {
47 | sInstance = new DBHelper(context.getApplicationContext());
48 | }
49 | return sInstance;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/sample_log_item_comp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
8 |
9 |
13 |
14 |
18 |
19 |
26 |
27 |
34 |
35 |
42 |
43 |
44 |
49 |
50 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/loadnl/payrecord/util/AppUtil.java:
--------------------------------------------------------------------------------
1 | package xyz.loadnl.payrecord.util;
2 |
3 | import android.content.Context;
4 | import android.content.pm.PackageManager;
5 | import android.os.Build;
6 | import android.provider.Settings;
7 | import android.util.Log;
8 |
9 | import java.security.MessageDigest;
10 | import java.security.NoSuchAlgorithmException;
11 |
12 |
13 | public class AppUtil {
14 | public static String getUniqueId(Context context) {
15 | String androidID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
16 | String id = androidID + Build.SERIAL;
17 | return toMD5(id);
18 | }
19 |
20 |
21 | public static String toMD5(String text){
22 | //获取摘要器 MessageDigest
23 | MessageDigest messageDigest;
24 | try {
25 | messageDigest = MessageDigest.getInstance("MD5");
26 | } catch (NoSuchAlgorithmException e) {
27 | Log.e("ZYKJ", "Md5Bug", e);
28 | return null;
29 | }
30 |
31 | //通过摘要器对字符串的二进制字节数组进行hash计算
32 | byte[] digest = messageDigest.digest(text.getBytes());
33 |
34 | StringBuilder sb = new StringBuilder();
35 | for (int i = 0; i < digest.length; i++) {
36 | //循环每个字符 将计算结果转化为正整数;
37 | int digestInt = digest[i] & 0xff;
38 | //将10进制转化为较短的16进制
39 | String hexString = Integer.toHexString(digestInt);
40 | //转化结果如果是个位数会省略0,因此判断并补0
41 | if (hexString.length() < 2) {
42 | sb.append(0);
43 | }
44 | //将循环结果添加到缓冲区
45 | sb.append(hexString);
46 | }
47 | //返回整个结果
48 | return sb.toString();
49 | }
50 |
51 |
52 | public static String randString(int len){
53 | StringBuilder sb = new StringBuilder(len);
54 | char[] seqs = new char[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G','H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R','S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2','3', '4', '5', '6', '7', '8', '9'};
55 | int total = seqs.length;
56 | for (int i=0;i
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
34 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
49 |
50 |
51 |
52 |
53 |
58 |
59 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/loadnl/payrecord/util/DBManager.java:
--------------------------------------------------------------------------------
1 | package xyz.loadnl.payrecord.util;
2 |
3 | import android.content.ContentValues;
4 | import android.content.Context;
5 | import android.database.Cursor;
6 | import android.database.sqlite.SQLiteDatabase;
7 | import java.sql.Date;
8 | import java.text.SimpleDateFormat;
9 | import java.util.ArrayList;
10 |
11 | import xyz.loadnl.payrecord.data.LogItem;
12 |
13 | /**
14 | * @ClassName: DBManager
15 | * @Description: TODO(这里用一句话描述这个类的作用)
16 | * @date 2018年6月23日 下午1:27:22
17 | */
18 | public class DBManager {
19 | private SQLiteDatabase db;
20 | private DBHelper helper;
21 | private final String tableaName="loadnl";
22 |
23 | public DBManager(Context context) {
24 | helper = DBHelper.getInstance(context);
25 | db = helper.getWritableDatabase();
26 | }
27 |
28 | public String getConfig(String name) {
29 | Cursor c = db.query(tableaName,new String[]{"value_m"},"key_m=?",new String[]{name},null,null,null);
30 | String rs = "";
31 | while (c.moveToNext()) {
32 | rs = c.getString(c.getColumnIndex("value_m"));
33 | break;
34 | }
35 | c.close();
36 | return rs;
37 | }
38 |
39 | public boolean hasConfig(String name){
40 | Cursor c = db.query(tableaName,new String[]{"value_m"},"key_m=?",new String[]{name},null,null,null);
41 | return c.moveToNext();
42 | }
43 |
44 | public boolean setConfig(String name, String value){
45 | ContentValues values = new ContentValues();
46 | values.put("key_m",name);
47 | values.put("value_m",value);
48 | long n;
49 | if(hasConfig(name)){
50 | n = db.update(tableaName,values,"key_m=?",new String[]{name});
51 | }else{
52 | n = db.insert(tableaName,null,values);
53 | }
54 | return n>0;
55 | }
56 |
57 | public long addLog(String log, int type){
58 | ContentValues values = new ContentValues();
59 | values.put("log_value",log);
60 | values.put("log_type",type);
61 | SimpleDateFormat sd = new SimpleDateFormat("yy-MM-dd hh:mm:ss");
62 | values.put("create_dt",sd.format(new Date(System.currentTimeMillis())));
63 | return db.insert(tableaName+"_log",null,values);
64 | }
65 |
66 | public Cursor getLog(int page, int type){
67 | if(page<1){
68 | page = 1;
69 | }
70 | int from = (page-1)*25;
71 | String pageStr = from+","+25;
72 | Cursor c;
73 | if(type>0){
74 | c = db.query(tableaName+"_log",new String[]{"*"},"log_type=?",new String[]{type+""},null,null,"id desc",pageStr);
75 | }else{
76 | c = db.query(tableaName+"_log",new String[]{"*"},null,null,null,null,"id desc",pageStr);
77 | }
78 | return c;
79 | }
80 |
81 | public ArrayList getLogList(int page, int type){
82 | ArrayList list = new ArrayList<>();
83 | Cursor c = getLog(page,type);
84 | int idIdx = c.getColumnIndex("id");
85 | int valueIdx = c.getColumnIndex("log_value");
86 | int typeIdx = c.getColumnIndex("log_type");
87 | int dateIdx = c.getColumnIndex("create_dt");
88 | while(c.moveToNext()){
89 | LogItem item = new LogItem();
90 | item.id = c.getInt(idIdx);
91 | item.log_value = c.getString(valueIdx);
92 | item.log_type = c.getInt(typeIdx);
93 | item.create_dt = c.getString(dateIdx);
94 | list.add(item);
95 | }
96 | return list;
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/loadnl/payrecord/MainService.java:
--------------------------------------------------------------------------------
1 |
2 | package xyz.loadnl.payrecord;
3 |
4 | import android.app.Notification;
5 | import android.app.NotificationChannel;
6 | import android.app.NotificationManager;
7 | import android.app.Service;
8 | import android.content.Context;
9 | import android.content.Intent;
10 | import android.media.MediaPlayer;
11 | import android.os.Binder;
12 | import android.os.Build;
13 | import android.os.Handler;
14 | import android.os.IBinder;
15 | import android.os.Message;
16 | import android.os.PowerManager;
17 | import android.support.v4.app.NotificationCompat;
18 | import android.util.Log;
19 |
20 | import xyz.loadnl.payrecord.data.AppConst;
21 |
22 |
23 | /**
24 | * 后台进程.确保进入后台也在运行
25 | */
26 | public class MainService extends Service implements Runnable, MediaPlayer.OnCompletionListener {
27 | private Handler handler;
28 | private IMessageHander msgHander;
29 | private MediaPlayer payComp;
30 | private PowerManager.WakeLock wakeLock;
31 | public static final String CHANNEL_ID = "zhi_yi_px_pay";
32 | private NotificationChannel mNotificationChannel;
33 | @Override
34 | public void onCreate() {
35 | super.onCreate();
36 | Log.i("ZYKJ", "mainactivity");
37 | handler = new Handler(getMainLooper()){
38 | @Override
39 | public void handleMessage(Message msg) {
40 | if(msgHander!=null){
41 | msgHander.handMessage(msg);
42 | }
43 | }
44 | };
45 | new Thread(this,"MainService").start();
46 | //保持黑屏状态执行
47 | PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
48 | wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, MainService.class.getName());
49 | if(wakeLock!=null){
50 | wakeLock.acquire();
51 | }else{
52 | Log.w("ZYKJ","wakeLock is null");
53 | }
54 | //声音播放也不成功
55 | payComp = MediaPlayer.create(this, R.raw.paycomp);
56 | payComp.setOnCompletionListener(this);
57 | //
58 | Log.i("ZYKJ","MainService Start");
59 | NotificationManager mNM =(NotificationManager)getSystemService(Service.NOTIFICATION_SERVICE);
60 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
61 | mNotificationChannel = new NotificationChannel(AppConst.CHANNEL_Front, "pxapy", NotificationManager.IMPORTANCE_DEFAULT);
62 | mNotificationChannel.setDescription("个人支付的监控");
63 | mNM.createNotificationChannel(mNotificationChannel);
64 | }
65 | NotificationCompat.Builder nb = new NotificationCompat.Builder(this,AppConst.CHANNEL_Front);//
66 | nb.setContentTitle("UKAFU个人支付").setTicker("UKAFU个人支付").setSmallIcon(R.mipmap.ic_launcher);
67 | nb.setWhen(System.currentTimeMillis());
68 | Notification notification = nb.build();
69 | startForeground(1,notification);
70 | Log.i("ZYKJ","MainService Started");
71 | }
72 |
73 | @Override
74 | public IBinder onBind(Intent intent) {
75 | return new MyBinder();
76 | }
77 |
78 | @Override
79 | public int onStartCommand(Intent intent, int flags, int startId) {
80 | super.onStartCommand(intent, flags, startId);
81 | // if(AppConst.ManualExit) return START_NOT_STICKY;
82 | return START_STICKY;
83 | }
84 |
85 | public void setMessageHander(IMessageHander hander){
86 | msgHander = hander;
87 | }
88 |
89 | @Override
90 | public void onCompletion(MediaPlayer mediaPlayer) {
91 |
92 | }
93 |
94 | class MyBinder extends Binder {
95 | public MainService getService() {
96 | return MainService.this;
97 | }
98 | }
99 |
100 | @Override
101 | public void run() {
102 | while(true){
103 | try {
104 | Thread.sleep(30000);
105 | } catch (InterruptedException e) {
106 | Log.e("ZYKJ","service thread",e);
107 | }
108 | // Message msg = new Message();
109 | // msg.what = 1;
110 | // msg.obj = "time";
111 | // handler.sendMessage(msg);
112 | //发送在线通知,保持让系统时时刻刻直到app在线
113 | // RequestUtils.getRequest(AppConst.authUrl("person/active/app?version="+getApplicationContext().getApplicationInfo()),handler);
114 |
115 | }
116 | }
117 |
118 |
119 | /**
120 | * 支付通知发送成功的时候.播报声音.
121 | * 在听到 微信到账1元之后.听到支付已完成,就知道系统没毛病.如果不能同时听到2声音.表示又问题了..
122 | * 但是这个播放声音我的手机老是出毛病.重启后就好了..
123 | */
124 | public void payCompSounds(){
125 | if (AppConst.PlaySounds) {payComp.start();}
126 | }
127 |
128 |
129 | /**
130 | * 据说这样能提高存活率,貌似也不太稳定
131 | */
132 | @Override
133 | public void onDestroy() {
134 | // if(AppConst.ManualExit) return;
135 | if(payComp!=null){
136 | payComp.release();
137 | payComp= null;
138 | }
139 | if(wakeLock!=null){
140 | wakeLock.release();
141 | wakeLock = null;
142 | }
143 | Intent localIntent = new Intent();
144 | localIntent.setClass(this, MainService.class);
145 | startService(localIntent);
146 | }
147 | }
148 |
149 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
18 |
19 |
23 |
24 |
28 |
29 |
37 |
38 |
46 |
47 |
55 |
56 |
60 |
61 |
72 |
73 |
83 |
84 |
85 |
86 |
91 |
101 |
112 |
113 |
114 |
115 |
116 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
18 |
19 |
23 |
24 |
28 |
29 |
37 |
38 |
46 |
47 |
55 |
56 |
60 |
61 |
72 |
73 |
83 |
84 |
85 |
86 |
91 |
101 |
112 |
113 |
114 |
115 |
116 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/loadnl/payrecord/MainActivity.java:
--------------------------------------------------------------------------------
1 | package xyz.loadnl.payrecord;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.BroadcastReceiver;
5 | import android.content.ComponentName;
6 | import android.content.DialogInterface;
7 | import android.content.Intent;
8 | import android.content.IntentFilter;
9 | import android.content.ServiceConnection;
10 | import android.content.pm.PackageManager;
11 | import android.net.Uri;
12 | import android.os.Build;
13 | import android.os.Bundle;
14 | import android.os.Handler;
15 | import android.os.IBinder;
16 | import android.os.Message;
17 | import android.provider.Settings;
18 | import android.support.design.widget.FloatingActionButton;
19 | import android.support.design.widget.Snackbar;
20 | import android.support.v7.app.AppCompatActivity;
21 | import android.support.v7.widget.Toolbar;
22 | import android.text.TextUtils;
23 | import android.util.Log;
24 | import android.view.KeyEvent;
25 | import android.view.View;
26 | import android.view.Menu;
27 | import android.view.MenuItem;
28 | import android.widget.Button;
29 | import android.widget.CompoundButton;
30 | import android.widget.Switch;
31 | import android.widget.TextView;
32 | import android.widget.Toast;
33 |
34 | import org.json.JSONException;
35 | import org.json.JSONObject;
36 |
37 | import java.io.IOException;
38 |
39 | import xyz.loadnl.payrecord.data.AppConst;
40 | import xyz.loadnl.payrecord.util.DBManager;
41 |
42 | public class MainActivity extends AppCompatActivity {
43 | private final static String TRUE = "true";
44 | private final static String FALSE = "false";
45 | private final static String LogTag = "loadnl";
46 |
47 | private Switch swt_fuwu;
48 | private Switch swt_service;
49 | private Switch swt_mute;
50 | private Button btn_qrcode;
51 | private Button btn_merchant;
52 | private Button btn_log;
53 | private TextView textView;
54 | private DBManager dbm;
55 |
56 | private Handler handler;
57 |
58 |
59 | // private NotificationChannel mNotificationChannel;
60 |
61 | private MainService service;
62 | private IMessageHander msgHander = new IMessageHander() {
63 | @Override
64 | public void handMessage(Message msg) {
65 | Log.i(LogTag,msg.obj.toString());
66 | }
67 | };
68 | private ServiceConnection conn = new ServiceConnection() {
69 | @Override
70 | public void onServiceConnected(ComponentName name, IBinder binder) {
71 | MainService.MyBinder myBinder = (MainService.MyBinder) binder;
72 | service = myBinder.getService();
73 | service.setMessageHander(msgHander);
74 | Log.i(LogTag, "MainActive - onServiceConnected");
75 | }
76 |
77 | @Override
78 | public void onServiceDisconnected(ComponentName name) {
79 | Log.i(LogTag, "MainActive - onServiceDisconnected");
80 | }
81 | };
82 |
83 | //不知到什么原因.广播收不到
84 | // private BroadcastReceiver receiver = new BootRecevier(){} ;
85 |
86 |
87 | public MainActivity() {
88 | }
89 |
90 | // private void mHandMessage(Message msg){
91 | // if(msg.what == 1){
92 | // String code = msg.obj.toString();
93 | // AlertDialog.Builder builder = new AlertDialog.Builder(this);
94 | // builder.setTitle("获取绑定码");
95 | // builder.setMessage("您得绑定码为: "+code+" ,请通过商户后台添加绑定,在绑定成功之前.请勿关闭");
96 | // builder.setIcon(R.drawable.icon);
97 | // builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
98 | // @Override
99 | // public void onCancel(DialogInterface dialog) {
100 | // RequestUtils.getRequest(AppConst.authUrl("person/Merchant/delBindCode"),new IHttpResponse() {
101 | //
102 | // @Override
103 | // public void OnHttpData(String data) {
104 | //
105 | // }
106 | //
107 | // @Override
108 | // public void OnHttpDataError(IOException e) {
109 | //
110 | // }
111 | // });
112 | // }
113 | // }).show();
114 | // }
115 | // }
116 |
117 | @Override
118 | protected void onCreate(Bundle savedInstanceState) {
119 | super.onCreate(savedInstanceState);
120 | Log.i("ZYKJ", "mainactivity");
121 | setContentView(R.layout.activity_main);
122 |
123 | swt_fuwu = (Switch)findViewById(R.id.p1);
124 | swt_service = (Switch)findViewById(R.id.service);
125 | swt_mute = (Switch)findViewById(R.id.mute);
126 |
127 | btn_qrcode = (Button) findViewById(R.id.btn_qrcode);
128 | btn_merchant = (Button)findViewById(R.id.btn_merchant);
129 | btn_log = (Button)findViewById(R.id.btn_log);
130 |
131 | swt_service.setChecked(false);
132 | // handler = new Handler(){
133 | // public void handleMessage(Message msg) {
134 | // mHandMessage(msg);
135 | // }
136 | // };
137 |
138 | dbm = new DBManager(this);
139 | //
140 | swt_mute.setChecked(!AppConst.PlaySounds);
141 |
142 |
143 |
144 | // IntentFilter filter = new IntentFilter(AppConst.IntentAction);
145 | // registerReceiver(receiver,filter);
146 |
147 | swt_fuwu.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
148 | @Override
149 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
150 | if(isChecked != enabedPrivileges){
151 | openNotificationListenSettings();
152 | }
153 | }
154 | });
155 |
156 | swt_service.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
157 | @Override
158 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
159 | if(isChecked){
160 | checkStatus();
161 | }
162 | }
163 | });
164 |
165 | // btn_qrcode.setOnClickListener(new View.OnClickListener() {
166 | // @Override
167 | // public void onClick(View view) {
168 | // openQrcode();
169 | // }
170 | // });
171 | btn_log.setOnClickListener(new View.OnClickListener() {
172 | @Override
173 | public void onClick(View view) {
174 | Intent intent = new Intent(MainActivity.this, LogActivity.class);
175 | startActivity(intent);
176 | }
177 | });
178 |
179 |
180 | // 静音
181 | swt_mute.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
182 | @Override
183 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
184 | changeMutestate(isChecked);
185 | }
186 | });
187 |
188 | Intent intent = new Intent(this, MainService.class);
189 | intent.putExtra("from", "MainActive");
190 | bindService(intent, conn, BIND_AUTO_CREATE);
191 | // 手动关闭服务之后 需要重新绑定服务 所以在onCreate处调用
192 | toggleNotificationListenerService();
193 | //
194 | checkStatus();
195 | }
196 |
197 | @Override
198 | protected void onResume() {
199 | super.onResume();
200 | checkStatus();
201 | }
202 |
203 | @Override
204 | public boolean onCreateOptionsMenu(Menu menu) {
205 | getMenuInflater().inflate(R.menu.menu_main, menu);
206 | return super.onCreateOptionsMenu(menu);
207 | }
208 |
209 | // public boolean onOptionsItemSelected(MenuItem item) {
210 | // switch (item.getItemId()) {
211 | // case R.id.action_bindcode:
212 | // RequestUtils.getRequest(AppConst.authUrl("person/Merchant/addBindCode"), new IHttpResponse() {
213 | // @Override
214 | // public void OnHttpData(String data) {
215 | // try{
216 | // JSONObject json = new JSONObject(data);
217 | // String code = ""+json.getJSONObject("data").getInt("bind_code");
218 | // Message msg = new Message();
219 | // msg.what = 1;
220 | // msg.obj = code;
221 | // MainActivity.this.handler.sendMessage(msg);
222 | // }
223 | // catch (JSONException je){
224 | // Log.i("yyk","msg === "+je.getMessage());
225 | // }
226 | //
227 | // }
228 | //
229 | // @Override
230 | // public void OnHttpDataError(IOException e) {
231 | //
232 | // }
233 | // });
234 | // break;
235 | // case R.id.action_exitapp:
236 | // exit();
237 | // break;
238 | // }
239 | // return true;
240 | // }
241 | /** 退出 */
242 | private void exit(){
243 | unbindService(conn);
244 | disableNotificationService();
245 | }
246 | /** 退出調用
247 | * 功能 Disable掉 NotificationService 直接退出App
248 | * */
249 | private void disableNotificationService(){
250 | // 先disable 服务
251 | PackageManager localPackageManager = getPackageManager();
252 | localPackageManager.setComponentEnabledSetting(new ComponentName(this, NotificationMonitorService.class),
253 | PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);// 最后一个参数 DONT_KILL_APP或者0。 0说明杀死包含该组件的app
254 | //
255 | }
256 |
257 | private boolean enabedPrivileges;
258 | private void checkStatus(){
259 | //权限开启.才能启动服务
260 | boolean enabled = isEnabled();
261 | enabedPrivileges = enabled;
262 | swt_fuwu.setChecked(enabled);
263 | if(!enabled){
264 | swt_service.setEnabled(false);
265 | return;
266 | }
267 | swt_service.setEnabled(true);
268 | //开启服务
269 | ComponentName name = startService(new Intent(this, NotificationMonitorService.class));
270 | if(name ==null) {
271 | swt_service.setChecked(false);
272 | Toast.makeText(getApplicationContext(), "服务开启失败", Toast.LENGTH_LONG).show();
273 | return;
274 | }
275 | // 手动关闭服务之后 需要重新设置服务 所以在onCreate处调用
276 | // toggleNotificationListenerService();
277 | swt_service.setChecked(true);
278 |
279 | //微信支付宝开启
280 |
281 | }
282 |
283 | private void changeMutestate(boolean ischecked){
284 | AppConst.PlaySounds = !ischecked;
285 | dbm.setConfig(AppConst.KeyMute,""+AppConst.PlaySounds);
286 | }
287 |
288 | @Override
289 | public boolean onKeyDown(int keyCode, KeyEvent event) {
290 | if(keyCode == KeyEvent.KEYCODE_BACK){
291 | keyCode = KeyEvent.KEYCODE_HOME;
292 | }
293 | return super.onKeyDown(keyCode, event);
294 | }
295 |
296 | private boolean isEnabled()
297 | {
298 | String str = getPackageName();
299 | String localObject = Settings.Secure.getString(getContentResolver(), "enabled_notification_listeners");
300 | if (!TextUtils.isEmpty(localObject))
301 | {
302 | String[] strArr = (localObject).split(":");
303 | int i = 0;
304 | while (i < strArr.length)
305 | {
306 | ComponentName localComponentName = ComponentName.unflattenFromString(strArr[i]);
307 | if ((localComponentName != null) && (TextUtils.equals(str, localComponentName.getPackageName())))
308 | return true;
309 | i += 1;
310 | }
311 | }
312 | return false;
313 | }
314 |
315 | @Override
316 | protected void onDestroy() {
317 | super.onDestroy();
318 |
319 | // unregisterReceiver(receiver);
320 |
321 | }
322 |
323 |
324 | // private void openQrcode(){
325 | // Intent intent = new Intent(MainActivity.this, QrcodeActivity.class);
326 | // startActivity(intent);
327 | // }
328 |
329 | // private void sendNotice(){
330 | // Log.i("ZYKJ","MainActivity Send Notice");
331 | // NotificationManager mNM =(NotificationManager)getSystemService(Service.NOTIFICATION_SERVICE);
332 | // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
333 | // mNotificationChannel = new NotificationChannel(AppConst.CHANNEL_Test, "pxapy", NotificationManager.IMPORTANCE_DEFAULT);
334 | // mNotificationChannel.setDescription("个人支付的监控");
335 | // mNM.createNotificationChannel(mNotificationChannel);
336 | // Log.i("ZYKJ","MainActivity create mNotificationChannel");
337 | // }
338 | // Notification notification = new NotificationCompat.Builder(this,AppConst.CHANNEL_Test)
339 | // .setContentTitle("通知监控").setContentText("测试号通过扫码向你付款0.01元").setSmallIcon(R.mipmap.ic_launcher)
340 | // .setWhen(System.currentTimeMillis()).setChannelId(AppConst.CHANNEL_Test).build();
341 | //
342 | // /**
343 | // * 注意,我们使用出来。incoming_message ID 通知。它可以是任何整数,但我们使用 资源id字符串相关
344 | // * 通知。它将永远是一个独特的号码在你的 应用程序。
345 | // */
346 | // mNM.notify(2,notification);
347 | // Log.i("ZYKJ","MainActivity Send Notice Comp");
348 | // }
349 |
350 | private void toggleNotificationListenerService()
351 | {
352 | PackageManager localPackageManager = getPackageManager();
353 | localPackageManager.setComponentEnabledSetting(new ComponentName(this, NotificationMonitorService.class),
354 | PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
355 | localPackageManager.setComponentEnabledSetting(new ComponentName(this, NotificationMonitorService.class),
356 | PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
357 | }
358 | //
359 | // private void openPowerSetting(){
360 | // Intent powerUsageIntent = new Intent(Settings.ACTION_APPLICATION_SETTINGS);
361 | // ResolveInfo resolveInfo = getPackageManager().resolveActivity(powerUsageIntent, 0);
362 | // if(resolveInfo != null){
363 | // startActivity(powerUsageIntent);
364 | // }
365 | // }
366 |
367 | /**
368 | * 打开通知权限设置.一般手机根本找不到哪里设置
369 | */
370 | private void openNotificationListenSettings()
371 | {
372 |
373 | try {
374 | Intent intent;
375 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
376 | intent = new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS);
377 | } else {
378 | intent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
379 | }
380 | startActivity(intent);
381 | } catch (Exception e) {
382 | e.printStackTrace();
383 | }
384 |
385 | }
386 |
387 |
388 | }
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/loadnl/payrecord/NotificationMonitorService.java:
--------------------------------------------------------------------------------
1 | package xyz.loadnl.payrecord;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.app.Notification;
5 | import android.app.NotificationChannel;
6 | import android.app.NotificationManager;
7 | import android.app.Service;
8 | import android.content.Context;
9 | import android.content.Intent;
10 | import android.content.IntentFilter;
11 | import android.media.MediaPlayer;
12 | import android.net.Uri;
13 | import android.os.Build;
14 | import android.os.Bundle;
15 | import android.os.PowerManager;
16 | import android.service.notification.NotificationListenerService;
17 | import android.service.notification.StatusBarNotification;
18 | import android.support.v4.app.NotificationCompat;
19 | import android.text.TextUtils;
20 | import android.util.Log;
21 | import android.widget.Toast;
22 |
23 |
24 |
25 | import java.util.ArrayList;
26 | import java.util.regex.Matcher;
27 | import java.util.regex.Pattern;
28 |
29 | import xyz.loadnl.payrecord.data.AppConst;
30 | import xyz.loadnl.payrecord.data.OrderData;
31 | import xyz.loadnl.payrecord.util.AppUtil;
32 | import xyz.loadnl.payrecord.util.DBManager;
33 |
34 | public class NotificationMonitorService extends NotificationListenerService {
35 |
36 | private static final String TAG = "NMService";
37 | private static final String AliPay = "ALIPAY";
38 | private static final String WeixinPay = "WXPAY";
39 | private static final String JxYmf_Pay = "JXYMF";
40 | private static final String JxYmf_PKG = "com.buybal.buybalpay.nxy.jxymf";
41 | //12-03 12:02:44.593 9737-9737/com.zhiyi.onepay I/ZYKJ: Notification posted [com.buybal.buybalpay.nxy.jxymf]:收款通知 & 一笔收款交易已完成,金额0.01元
42 | private static int version;
43 | // private MyHandler handler;
44 | public long lastTimePosted = System.currentTimeMillis();
45 | private Pattern pJxYmf_Nofity;
46 | private Pattern pAlipay;
47 | private Pattern pAlipay2;
48 | private Pattern pAlipayDianyuan;
49 | private Pattern pWeixin;
50 | private MediaPlayer payComp;
51 | private MediaPlayer payRecv;
52 | private MediaPlayer payNetWorkError;
53 | private PowerManager.WakeLock wakeLock;
54 | private DBManager dbManager;
55 | private BatteryReceiver batteryReceiver;
56 |
57 |
58 | public void onCreate() {
59 | super.onCreate();
60 | version = AppUtil.getVersionCode(this);
61 | sendingList = new ArrayList<>();
62 |
63 | Toast.makeText(getApplicationContext(), "启动服务", Toast.LENGTH_LONG).show();
64 | //支付宝
65 | String pattern = "(\\S*)通过扫码向你付款([\\d\\.]+)元";
66 | pAlipay = Pattern.compile(pattern);
67 | pattern = "成功收款([\\d\\.]+)元。享免费提现等更多专属服务,点击查看";
68 | pAlipay2 = Pattern.compile(pattern);
69 | pAlipayDianyuan = Pattern.compile("支付宝成功收款([\\d\\.]+)元。收钱码收钱提现免费,赶紧推荐顾客使用");
70 | pWeixin = Pattern.compile("微信支付收款([\\d\\.]+)元");
71 | pJxYmf_Nofity = Pattern.compile("一笔收款交易已完成,金额([\\d\\.]+)元");
72 | payComp = MediaPlayer.create(this, R.raw.paycomp);
73 | payRecv = MediaPlayer.create(this, R.raw.payrecv);
74 | payNetWorkError = MediaPlayer.create(this, R.raw.networkerror);
75 | dbManager = new DBManager(this);
76 | // if (AppConst.AppId < 1) {
77 | // String appid = dbManager.getConfig(AppConst.KeyAppId);
78 | // if (!TextUtils.isEmpty(appid)) {
79 | // AppConst.AppId = Integer.parseInt(appid);
80 | // String token = dbManager.getConfig(AppConst.KeyToken);
81 | // if (!TextUtils.isEmpty(token)) {
82 | // AppConst.Token = token;
83 | // }
84 | // String secret = dbManager.getConfig(AppConst.KeySecret);
85 | // if (!TextUtils.isEmpty(secret)) {
86 | // AppConst.Secret = secret;
87 | // }
88 | // }
89 | // // 推送前判断下playSounds
90 | // String mute = dbManager.getConfig(AppConst.KeyMute);
91 | // if(!TextUtils.isEmpty(mute)){
92 | // AppConst.PlaySounds = Boolean.parseBoolean(mute);
93 | // }
94 | // }
95 | Log.i("loadnl", "Notification Monitor Service start");
96 | // new Thread(this).start();
97 |
98 | NotificationManager mNM = (NotificationManager) getSystemService(Service.NOTIFICATION_SERVICE);
99 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && mNM != null) {
100 | NotificationChannel mNotificationChannel = mNM.getNotificationChannel(AppConst.CHANNEL_ID);
101 | if (mNotificationChannel == null) {
102 | mNotificationChannel = new NotificationChannel(AppConst.CHANNEL_ID, "payRecord", NotificationManager.IMPORTANCE_DEFAULT);
103 | mNotificationChannel.setDescription("个人支付的监控");
104 | mNM.createNotificationChannel(mNotificationChannel);
105 | }
106 | }
107 | NotificationCompat.Builder nb = new NotificationCompat.Builder(this, AppConst.CHANNEL_ID);//
108 |
109 | nb.setContentTitle("PayRecord").setTicker("PayRecord个人支付").setSmallIcon(R.mipmap.ic_launcher);
110 | nb.setContentText("个人支付运行中.请保持此通知一直存在");
111 | //nb.setContent(new RemoteViews(getPackageName(),R.layout.layout));
112 | nb.setWhen(System.currentTimeMillis());
113 | Notification notification = nb.build();
114 | startForeground(1, notification);
115 |
116 | PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
117 | //保持cpu一直运行,不管屏幕是否黑屏
118 | if (pm != null && wakeLock == null) {
119 | wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getCanonicalName());
120 | wakeLock.acquire();
121 | }
122 |
123 | IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
124 | batteryReceiver = new BatteryReceiver();
125 | registerReceiver(batteryReceiver, intentFilter);
126 |
127 |
128 | }
129 |
130 |
131 | public void onDestroy() {
132 | if (wakeLock != null) {
133 | wakeLock.release();
134 | wakeLock = null;
135 | }
136 | Intent localIntent = new Intent();
137 | localIntent.setClass(this, NotificationMonitorService.class);
138 | startService(localIntent);
139 | unregisterReceiver(batteryReceiver);
140 | }
141 |
142 |
143 | public void onNotificationPosted(StatusBarNotification sbn) {
144 | Bundle bundle = sbn.getNotification().extras;
145 | String pkgName = sbn.getPackageName();
146 | if (getPackageName().equals(pkgName)) {
147 | //测试成功
148 | Log.e(TAG,"测试成功");
149 | Log.i(TAG, "测试成功");
150 | Intent intent = new Intent();
151 | intent.setAction(AppConst.IntentAction);
152 | Uri uri = new Uri.Builder().scheme("app").path("log").query("msg=测试成功").build();
153 | intent.setData(uri);
154 | sendBroadcast(intent);
155 | //payRecv.start();
156 | playMedia(payRecv);
157 | return;
158 | }
159 | String title = bundle.getString("android.title");
160 | String text = bundle.getString("android.text");
161 | Log.d(TAG, "Notification posted [" + pkgName + "]:" + title + " & " + text);
162 | if(text == null){
163 | //没有消息.
164 | return;
165 | }
166 | this.lastTimePosted = System.currentTimeMillis();
167 | //支付宝com.eg.android.AlipayGphone
168 | //com.eg.android.AlipayGphone]:支付宝通知 & 新哥通过扫码向你付款0.01元
169 | if (pkgName.equals("com.eg.android.AlipayGphone") && text != null) {
170 | // 现在创建 matcher 对象
171 | do {
172 | Matcher m = pAlipay.matcher(text);
173 | if (m.find()) {
174 | String uname = m.group(1);
175 | String money = m.group(2);
176 | postMethod(AliPay, money, uname, false);
177 | break;
178 | }
179 | m = pAlipay2.matcher(text);
180 | if (m.find()) {
181 | String money = m.group(1);
182 | postMethod(AliPay, money, "支付宝用户", false);
183 | break;
184 | }
185 | m = pAlipayDianyuan.matcher(text);
186 | if (m.find()) {
187 | String money = m.group(1);
188 | postMethod(AliPay, money, "支付宝-店员", true);
189 | break;
190 | }
191 | Log.w(TAG, "匹配失败" + text);
192 | } while (false);
193 | }
194 | //微信
195 | //com.tencent.mm]:微信支付 & 微信支付收款0.01元
196 | else if (pkgName.equals("com.tencent.mm") && text != null) {
197 | // 现在创建 matcher 对象
198 | Matcher m = pWeixin.matcher(text);
199 | if (m.find()) {
200 | String uname = "微信用户";
201 | String money = m.group(1);
202 | postMethod(WeixinPay, money, uname, false);
203 | }
204 | }else if(pkgName.equals(JxYmf_PKG)){
205 | Matcher m = pJxYmf_Nofity.matcher(text);
206 | if(m.find()){
207 | String uname = "一码付";
208 | String money = m.group(1);
209 | postMethod(JxYmf_Pay, money, uname, false);
210 | }
211 | }
212 | }
213 |
214 |
215 | // @Override
216 | // public void run() {
217 | // while (true) {
218 | // try {
219 | // Thread.sleep(5000);
220 | // } catch (InterruptedException e) {
221 | // Log.e(TAG, "service thread", e);
222 | // }
223 | // if(!sendingList.isEmpty()) {
224 | // OrderData data;
225 | // synchronized (sendingList){
226 | // data = sendingList.remove(0);
227 | // }
228 | // postMethod(data);
229 | // }
230 | // long now = System.currentTimeMillis();
231 | // do {
232 | // //10秒内有交互,取消
233 | // if (now - lastNetTime < 10000) {
234 | // Log.d(TAG, "10秒内有交互");
235 | // break;
236 | // }
237 | // //发送在线通知,保持让系统时时刻刻直到app在线,5秒发送一次
238 | // if (now - lastSendTime < 5000) {
239 | // Log.d(TAG, "5秒内有交互");
240 | // break;
241 | // }
242 | // postState();
243 | // //20秒,没消息了.提示网络异常
244 | // if (now - lastNetTime > 20000) {
245 | // playMedia(payNetWorkError);
246 | // }
247 | // } while (false);
248 | // }
249 | // }
250 |
251 |
252 | public void onNotificationRemoved(StatusBarNotification paramStatusBarNotification) {
253 | if (Build.VERSION.SDK_INT >= 19) {
254 | Bundle localObject = paramStatusBarNotification.getNotification().extras;
255 | String pkgName = paramStatusBarNotification.getPackageName();
256 | String title = localObject.getString("android.title");
257 | String text = (localObject).getString("android.text");
258 | Log.e(TAG, "Notification removed [" + pkgName + "]:" + title + " & " + text);
259 | }
260 | }
261 |
262 | public int onStartCommand(Intent paramIntent, int paramInt1, int paramInt2) {
263 | return START_NOT_STICKY;
264 | }
265 |
266 | private ArrayList sendingList;
267 |
268 | /**
269 | * 获取道的支付通知发送到服务器
270 | *
271 | * @param payType 支付方式
272 | * @param money 支付金额
273 | * @param username 支付者名字
274 | */
275 | public void postMethod(final String payType, final String money, final String username, boolean dianYuan) {
276 | dbManager.addLog("new order:" + payType + "," + money + "," + username, 101);
277 | playMedia(payRecv);
278 | // String app_id = "" + AppConst.AppId;
279 | // String rndStr = AppUtil.randString(16);
280 | // OrderData data = new OrderData(payType, money, username, dianYuan);
281 | // String sign = AppUtil.toMD5(app_id + AppConst.Secret + data.time + version + rndStr + payType + money + username);
282 | // data.sign = sign;
283 | // data.ranStr = rndStr;
284 | // postMethod(data);
285 | }
286 |
287 | // private void postMethod(final OrderData data) {
288 | // if (data == null) {
289 | // return;
290 | // }
291 | // RequestUtils.getRequest(AppConst.HostUrl + "person/notify/pay?type=" + data.payType
292 | // + "&money=" + data.money
293 | // + "&uname=" + data.username
294 | // + "&appid=" + "" + AppConst.AppId
295 | // + "&rndstr=" + data.ranStr
296 | // + "&sign=" + data.sign
297 | // + "&time=" + data.time
298 | // + "&dianyuan=" + data.dianYuan
299 | // + "&version=" + version
300 | // , new IHttpResponse() {
301 | // @Override
302 | // public void OnHttpData(String data) {
303 | // dbManager.addLog(data, 200);
304 | // handleMessage(data, 1);
305 | // }
306 | //
307 | // @Override
308 | // public void OnHttpDataError(IOException e) {
309 | // dbManager.addLog("http error," + e.getMessage(), 500);
310 | // sendingList.add(data);
311 | // }
312 | // });
313 | //
314 | // }
315 |
316 | private long lastSendTime;
317 |
318 | /**
319 | * 发送错误信息到服务器
320 | */
321 | // public void postState() {
322 | // lastSendTime = System.currentTimeMillis();
323 | // Log.d(AppConst.TAG_LOG, "发送在线信息");
324 | // RequestUtils.getRequest(AppConst.authUrl("person/state/online") + "&v=" + AppConst.version + "&b=" + AppConst.Battery, new IHttpResponse() {
325 | // @Override
326 | // public void OnHttpData(String data) {
327 | // handleMessage(data, 3);
328 | // }
329 | //
330 | // @Override
331 | // public void OnHttpDataError(IOException e) {
332 | // Log.w(AppConst.TAG_LOG,e);
333 | // }
334 | // });
335 | //
336 | // }
337 |
338 |
339 | private long lastNetTime;
340 |
341 | // public boolean handleMessage(String message, int arg1) {
342 | // lastNetTime = System.currentTimeMillis();
343 | // if (message == null || message.isEmpty()) {
344 | // return true;
345 | // }
346 | // String msg = message;
347 | // Log.i(AppConst.TAG_LOG, msg);
348 | // JSONObject json;
349 | // try {
350 | // json = new JSONObject(msg);
351 | //
352 | // if (json.getInt("code") != 0) {
353 | // String emsg = json.getString("msg");
354 | // Log.w(AppConst.TAG_LOG, emsg);
355 | // return false;
356 | // }
357 | // if (json.has("time")) {
358 | // int time = json.getInt("time");
359 | // int dt = (int) (System.currentTimeMillis() / 1000) - time;
360 | // AppConst.DetaTime = (dt + AppConst.DetaTime * 9) / 10;
361 | // Log.d(AppConst.TAG_LOG, "服务器时间差" + AppConst.DetaTime);
362 | // }
363 | // if (arg1 == 3) {
364 | // return true;
365 | // }
366 | // playMedia(payComp);
367 | //
368 | // } catch (JSONException e) {
369 | // Log.w(AppConst.TAG_LOG, e);
370 | // }
371 | //
372 | // return true;
373 | // }
374 |
375 | private void playMedia(MediaPlayer media) {
376 | if (AppConst.PlaySounds) {
377 | media.start();
378 | }
379 | }
380 | }
--------------------------------------------------------------------------------