安卓手机监控类应用实现原理分析

2024/07/08 android 共 4670 字,约 14 分钟

所有权限情况

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
<uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"/>
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED"/>
<uses-feature
              android:name="android.hardware.telephony"
              android:required="false"/>
<uses-feature
              android:name="android.hardware.touchscreen"
              android:required="false"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
<uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE"/>
<permission
            android:name="com.qustodio.qustodioapp.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
            android:protectionLevel="signature"/>
<uses-permission android:name="com.qustodio.qustodioapp.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"/>

android.permission.BIND_DEVICE_ADMIN

防卸载

  1. 直接在手机里操作卸载无法卸载。
  2. 使用adb uninstall 命令卸载失败:DELETE_FAILED_DEVICE_POLICY_MANAGER

receiver情况

android.app.action.DEVICE_ADMIN_ENABLED
android.intent.action.BOOT_COMPLETED
android.intent.action.MY_PACKAGE_REPLACED
android.intent.action.HEADSET_PLUG
com.qustodio.qustodioapp.action.PROCESS_UPDATES
com.google.android.c2dm.intent.RECEIVE
android.intent.action.ACTION_POWER_CONNECTED
android.intent.action.ACTION_POWER_DISCONNECTED
android.intent.action.BATTERY_OKAY
android.intent.action.BATTERY_LOW
android.intent.action.DEVICE_STORAGE_LOW
android.intent.action.DEVICE_STORAGE_OK
android.net.conn.CONNECTIVITY_CHANGE
android.intent.action.TIME_SET
android.intent.action.TIMEZONE_CHANGED
androidx.work.impl.background.systemalarm.UpdateProxies
androidx.work.diagnostics.REQUEST_DIAGNOSTICS
androidx.profileinstaller.action.INSTALL_PROFILE
androidx.profileinstaller.action.SKIP_FILE
androidx.profileinstaller.action.SAVE_PROFILE
androidx.profileinstaller.action.BENCHMARK_OPERATION

应用使用统计

所需权限:PACKAGE_USAGE_STATS

<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/>

相关代码:UsageStatsManager usageStatsManager = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE)

    public final String q() {
        List<x7.a> y02;
        String e02;
        String str = this.f21923c;
        y02 = x.y0(this.f21925e);
        UsageStatsManager usageStatsManager = (UsageStatsManager) this.f21921a.getSystemService("usagestats");
        if (usageStatsManager != null) {
            long b10 = b();
            UsageEvents queryEvents = usageStatsManager.queryEvents(g(b10, this.f21924d), b10);
            m.e(queryEvents, "usageStatsManager.queryE…s(startTime, currentTime)");
            if (!k()) {
                this.f21923c = "";
            } else {
                d(queryEvents);
            }
        }
        if (!m.a(str, this.f21923c)) {
            Log.d(f21920g, "New app detected in foreground: " + this.f21923c);
        }
        if (h(str, y02)) {
            int size = this.f21925e.size();
            e02 = x.e0(this.f21925e, ",", null, null, 0, null, null, 62, null);
            Log.d(f21920g, "All apps detected in foreground (" + size + "): [" + e02 + "]");
        }
        return this.f21923c;
    }

应用参考

文档信息

Search

    Table of Contents