forked from c-kzxvldkhX/receiptnotice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
weihuagu
committed
Jan 22, 2020
1 parent
4677188
commit 2dea83e
Showing
12 changed files
with
223 additions
and
50 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,76 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.weihuagu.receiptnotice"> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.WAKE_LOCK"/> | ||
<application | ||
android:name=".MainApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.AppCompat.Light.NoActionBar" | ||
android:networkSecurityConfig="@xml/network_security_config"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".FileLogActivity" | ||
android:label="@string/filelog_title"> | ||
<intent-filter > | ||
<action android:name="com.weihuagu.receiptnotice.showfilelog"/> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".IllustrateDecryptActivity" | ||
android:label="@string/illustratedecrypt_title"> | ||
<intent-filter> | ||
<action android:name="com.weihuagu.receiptnotice.illustratedecryptmethod"/> | ||
<category android:name="android.intent.category.DEFAULT"/> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name="com.github.pedrovgs.lynx.LynxActivity"/> | ||
<activity android:name=".PreferenceActivity"/> | ||
|
||
<service android:name=".NLService" | ||
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"> | ||
<intent-filter> | ||
<action android:name="android.service.notification.NotificationListenerService" /> | ||
</intent-filter> | ||
</service> | ||
<service android:name=".NotificationCollectorMonitorService"/> | ||
<uses-library | ||
android:name="org.apache.http.legacy" | ||
android:required="false" /> | ||
</application> | ||
</manifest> | ||
package="com.weihuagu.receiptnotice"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.WAKE_LOCK" /> | ||
|
||
<application | ||
android:name=".MainApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:networkSecurityConfig="@xml/network_security_config" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.AppCompat.Light.NoActionBar"> | ||
<meta-data | ||
android:name="com.google.android.actions" | ||
android:resource="@xml/receiptnoticeaccessibilityservice_config" /> | ||
|
||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<action android:name="android.intent.action.VIEW" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".FileLogActivity" | ||
android:label="@string/filelog_title"> | ||
<intent-filter> | ||
<action android:name="com.weihuagu.receiptnotice.showfilelog" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".IllustrateDecryptActivity" | ||
android:label="@string/illustratedecrypt_title"> | ||
<intent-filter> | ||
<action android:name="com.weihuagu.receiptnotice.illustratedecryptmethod" /> | ||
|
||
<category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name="com.github.pedrovgs.lynx.LynxActivity" /> | ||
<activity android:name=".PreferenceActivity" /> | ||
|
||
<service | ||
android:name=".NLService" | ||
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"> | ||
<intent-filter> | ||
<action android:name="android.service.notification.NotificationListenerService" /> | ||
</intent-filter> | ||
</service> | ||
<service | ||
android:label="@string/accessibilityservicename" | ||
android:name=".ReceiptnoticeAccessibilityService" | ||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVIC"> | ||
<intent-filter> | ||
<action android:name="android.accessibilityservice.AccessibilityService" /> | ||
</intent-filter> | ||
|
||
<meta-data | ||
android:name="android.accessibilityservice" | ||
android:resource="@xml/receiptnoticeaccessibilityservice_config" /> | ||
</service> | ||
<service android:name=".NotificationCollectorMonitorService" /> | ||
|
||
<uses-library | ||
android:name="org.apache.http.legacy" | ||
android:required="false" /> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/src/main/java/com/weihuagu/receiptnotice/ReceiptnoticeAccessibilityService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.weihuagu.receiptnotice; | ||
|
||
import android.accessibilityservice.AccessibilityService; | ||
import android.view.accessibility.AccessibilityEvent; | ||
|
||
public class ReceiptnoticeAccessibilityService extends AccessibilityService { | ||
@Override | ||
public void onAccessibilityEvent(AccessibilityEvent event) { | ||
final int eventType = event.getEventType(); | ||
//根据事件回调类型进行处理 | ||
switch (eventType) { | ||
//当通知栏发生改变时 | ||
case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED: | ||
|
||
break; | ||
//当窗口的状态发生改变时 | ||
case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: | ||
|
||
break; | ||
} | ||
|
||
|
||
} | ||
|
||
@Override | ||
public void onInterrupt() { | ||
|
||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
app/src/main/java/com/weihuagu/receiptnotice/audiorecognize/AudioHub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.weihuagu.receiptnotice.audiorecognize; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Collection; | ||
import java.util.HashSet; | ||
|
||
import android.media.AudioFormat; | ||
import android.media.AudioRecord; | ||
import android.media.MediaRecorder.AudioSource; | ||
|
||
public class AudioHub { | ||
private boolean isRecord = false; | ||
private final static int sampleRate = 8000; | ||
private static int channelConfig = AudioFormat.CHANNEL_IN_STEREO; | ||
private int bufferSize = 0; | ||
private int bufferSizeInBytes =AudioRecord.getMinBufferSize(sampleRate, | ||
channelConfig, AudioFormat.ENCODING_PCM_16BIT); | ||
|
||
private final AudioRecord recorder; | ||
|
||
public AudioHub() throws IOException{ | ||
bufferSize=bufferSizeInBytes; | ||
recorder = new AudioRecord( | ||
AudioSource.VOICE_RECOGNITION, sampleRate, | ||
AudioFormat.CHANNEL_IN_MONO, | ||
AudioFormat.ENCODING_PCM_16BIT, bufferSizeInBytes); | ||
if (recorder.getState() == AudioRecord.STATE_UNINITIALIZED) { | ||
recorder.release(); | ||
throw new IOException( | ||
"Failed to initialize recorder. Microphone might be already in use."); | ||
} | ||
} | ||
|
||
private void startRecord() { | ||
recorder.startRecording(); | ||
// 让录制状态为true | ||
isRecord = true; | ||
// 开启音频文件写入线程 | ||
new Thread(new AudioRecordThread()).start(); | ||
} | ||
private void stopRecord() { | ||
close(); | ||
} | ||
|
||
private void close() { | ||
if (recorder != null) { | ||
System.out.println("stopRecord"); | ||
isRecord = false; | ||
recorder.stop(); | ||
recorder.release();//释放资源 | ||
} | ||
} | ||
|
||
private void getRecordData(){ | ||
short[] buffer = new short[bufferSize]; | ||
recorder.read(buffer, 0, buffer.length); // Skip the first buffer, usually zeroes | ||
|
||
} | ||
|
||
class AudioRecordThread implements Runnable { | ||
@Override | ||
public void run() { | ||
getRecordData();//往文件中写入裸数据 | ||
|
||
} | ||
} | ||
|
||
|
||
|
||
} |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/com/weihuagu/receiptnotice/audiorecognize/RecordService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.weihuagu.receiptnotice.audiorecognize; | ||
|
||
import android.app.Service; | ||
import android.content.Intent; | ||
import android.os.IBinder;;import androidx.annotation.Nullable; | ||
|
||
public class RecordService extends Service { | ||
@Nullable | ||
@Override | ||
public IBinder onBind(Intent intent) { | ||
return null; | ||
} | ||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
try { | ||
AudioHub hub=new AudioHub(); | ||
}catch (Exception e){ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/src/main/res/xml/receiptnoticeaccessibilityservice_config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version ="1.0" encoding ="utf-8"?> | ||
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:accessibilityEventTypes="typeNotificationStateChanged|typeWindowStateChanged|typeWindowContentChanged|typeWindowsChanged" | ||
android:accessibilityFeedbackType="feedbackGeneric" | ||
android:accessibilityFlags="flagDefault" | ||
android:canRetrieveWindowContent="true" | ||
android:description="@string/accessibility_service_description" | ||
android:notificationTimeout="100" | ||
android:packageNames="com.eg.android.AlipayGphone" /> |