Skip to content

Commit

Permalink
start add mic ...;尝试使用点击通知栏进入应用获取信息
Browse files Browse the repository at this point in the history
  • Loading branch information
weihuagu committed Jan 22, 2020
1 parent 4677188 commit 2dea83e
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 50 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.
123 changes: 74 additions & 49 deletions app/src/main/AndroidManifest.xml
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>
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public void handleNotification(){
postmap.put("content",content);
postmap.put("transferor",whoTransferred(content));


//open notify
this.openNotify();

postpush.doPost(postmap);
return ;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public Map DeviceBeanReflect(DeviceBean e){
f.setAccessible(true);
try {
devicebeanmap.put((String) f.getName(), (String) f.get(e));
System.out.println("属性名:" + f.getName() + " 属性值:" + f.get(e));
//System.out.println("属性名:" + f.getName() + " 属性值:" + f.get(e));
}catch (Exception ee){
//LogUtil.debugLogWithJava(ee.getStackTrace().toString());
return devicebeanmap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.weihuagu.receiptnotice;

import android.app.PendingIntent;
import android.os.Bundle;
import android.app.Notification;
import android.service.notification.StatusBarNotification;
Expand Down Expand Up @@ -86,6 +87,15 @@ protected void printNotify(){

}

protected void openNotify(){
PendingIntent pendingIntent = notification.contentIntent;
try{
pendingIntent.send();
}catch(PendingIntent.CanceledException e){

}
}




Expand Down
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() {

}
}
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();//往文件中写入裸数据

}
}



}
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){

}
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
<string name="text_reverseshow">逆序显示</string>
<string name="text_home_fragment_tip">愿你赚很多钱</string>
<string name="text_home_fragment_nexttip">左滑切换到收款记录</string>
<string name="accessibilityservicename">receiptnotice 辅助功能</string>
<string name="accessibility_service_description"></string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<string name="filelog_title">post record</string>
<string name="illustratedecrypt_title">Illustrate Decrypt</string>
<string name="buttontext_setposturl">set the post url</string>
<string name="accessibilityservicename">receiptnotice accessibility</string>
<string name="accessibility_service_description"></string>
<string-array name="pref_entries_encryptmethod">
<item>des</item>
<item>md5</item>
Expand Down
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" />

0 comments on commit 2dea83e

Please sign in to comment.