• Hello
Search Results for

    Show / Hide Table of Contents

    Android - Installed Apps - Monitor (Pro)

    Locally installed cheating or hacking apps are frequently used to gain advantages, whether to modify an app or manipulate its memory for some kind of benefit. Because these types of apps are typically installed on a user's device, their installation cannot be prevented. However, it is possible to identify which apps a user has installed and respond accordingly.

    Monitor

    The 'AndroidInstalledApplicationMonitor' (class AndroidInstalledApplicationMonitor, namespace GUPS.AntiCheat.Monitor.Android) reads the apps installed on the device (system apps are ignored) and emits an AndroidInstalledApplicationStatus to its observers. The status carries the package names of the blacklisted apps that were found on the device.

    Status

    The monitor emits an AndroidInstalledApplicationStatus, which implements IAndroidStatus (and therefore IWatchedSubject):

    public struct AndroidInstalledApplicationStatus : IAndroidStatus
    {
        // True if the list could not be retrieved (e.g. a JNI failure).
        public bool FailedToRetrieveData { get; }
    
        // The blacklisted package names currently installed on the device.
        public List<string> Applications { get; }
    }
    
    • FailedToRetrieveData: True when the installed apps could not be retrieved or an exception occurred; the list is then not valid.
    • Applications: The blacklisted package names that are currently installed on the device. Only apps that match the blacklist configured in the project settings are returned, not every installed app.

    Lifecycle and timing

    The monitor reads the installed apps once, in its OnStart callback, and then notifies observers a single time with the resulting AndroidInstalledApplicationStatus. If the installed apps could not be read, it still notifies with FailedToRetrieveData set to true.

    Configuration

    There are no inspector fields on this monitor. The blacklisted package names are configured in the AntiCheat project settings and validated by the detector (see 'Detect Disallowed Apps'). Go to 'Project Settings -> GuardingPearSoftware -> AntiCheat' and open the 'Android - Device - Settings' section.

    In the AntiCheat Project Settings, assign the blacklisted package names.

    Development builds

    The paired detector honors the global 'Verify development builds' switch. By default it validates the app only in release builds, so the check is skipped in development builds and inside the Unity editor. Enable this option in 'Project Settings -> GuardingPearSoftware -> AntiCheat' while testing.

    Enable 'Verify development builds' to also validate the app in development builds and the editor.

    Supported Platforms

    The monitor is only available on Android platforms.

    Requirements

    Requires an Android build with at least Android 4.4 (API level 19) (December 2013).

    How To Use

    Attach the 'AndroidInstalledApplicationMonitor' to a child GameObject of the 'AntiCheat-Monitor' and pair it with the 'AndroidDeviceCheatingDetector'.

    Add Monitor Component

    Add the 'AndroidInstalledApplicationMonitor' MonoBehavior from the 'GUPS.AntiCheat.Monitor.Android' namespace to your 'AntiCheat-Monitor' GameObject, or better, to a child GameObject.

    Add the 'AndroidInstalledApplicationMonitor' as a Component.

    Consume the status in code

    Besides pairing the monitor with a detector, you can subscribe your own observer to receive the AndroidInstalledApplicationStatus directly. Every monitor derives from AMonitor and exposes Subscribe(IObserver<IWatchedSubject>), which returns an IDisposable you can dispose to unsubscribe.

    using System;
    using GUPS.AntiCheat.Core.Watch;
    using GUPS.AntiCheat.Monitor.Android;
    using UnityEngine;
    
    public class AndroidInstalledAppsStatusLogger : MonoBehaviour, IObserver<IWatchedSubject>
    {
        private void Start()
        {
            var monitor = GetComponentInChildren<AndroidInstalledApplicationMonitor>();
            monitor.Subscribe(this);
        }
    
        public void OnNext(IWatchedSubject subject)
        {
            if (subject is AndroidInstalledApplicationStatus status)
            {
                if (status.FailedToRetrieveData)
                {
                    Debug.LogWarning("Could not read the installed apps.");
                    return;
                }
    
                Debug.Log($"Found {status.Applications.Count} blacklisted apps.");
            }
        }
    
        public void OnError(Exception error) { }
        public void OnCompleted() { }
    }
    

    Detect Disallowed Apps

    To react to the sent status and thus validate the installed apps, you need a detector. To do this, use the 'AndroidDeviceCheatingDetector', a detector designed to analyse the status sent by the 'AndroidInstalledApplicationMonitor' and validate it for disallowed installed apps.

    In This Article
    Back to top GuardingPearSoftware documentation