Sharing data with the environment (Environment Exchange or MADA โ Mobile Application Data Access) is a little-known but powerful Android feature that allows applications to communicate with external systems on operating system level. It is used for debugging, test automation and integration with enterprise solutions. However, by default this option is hidden and requires manual activation via Developer Settings or ADBcommands.
If you are a developer, tester, or just like to delve into the hidden features of Android, this feature will open up new horizons. For example, with its help you can transfer data between isolated applications without using shared storageemulate interaction with sensors or even integrate a smartphone with industrial equipment. But there are nuances: incorrect settings can lead to data leaks or conflicts in the operation of the OS. Next, we will figure out how to enable exchange with the environment on different versions of Android, what risks it carries and where it is used in practice.
What is exchange with the environment on Android and why do you need it
Function exchange with the environment (in the documentation Google appears as Environment Exchange or MADA) was introduced in Android 10 as part of the architecture for the interaction of applications with external systems. Essentially, this is a mechanism that allows:
- ๐ Exchange data between applications without using standard Intents (for example, for testing isolated environments).
- ๐ฅ๏ธ Integrate a mobile device with corporate systems (ERP, CRM) or industrial equipment.
- ๐ ๏ธ Emulate the operation of sensors or hardware modules for debugging (for example, simulate a GPS signal without real movement).
- ๐ Restrict access to data at the OS level (useful for MDM solutions).
The main difference from the usual exchange methods (for example, through ContentProvider or SharedPreferences) is work at the kernel level Android. This means that data is transferred directly between processes, bypassing standard security mechanisms. On the one hand, this speeds up interaction, on the other hand, it requires caution: incorrect configuration can break application isolation or create vulnerabilities.
Who uses this function?
- ๐จโ๐ป Developers - for testing applications in isolated environments (for example, banking applications with high requirements for security).
- ๐ข Corporate users โfor integrating smartphones into the company's infrastructure (for example, transferring data from a barcode scanner to 1C).
- ๐ฌ Security Researchers โfor analyzing vulnerabilities in interprocess communication.
โ ๏ธ Attention: Beginning Android 13, Google has tightened controls over the use of MADA. Some features may be blocked for applications without special certificates. Before setting up, check the current restrictions in documentation for developers.
Preparing the device: enable developer mode
Before activating exchange with the environment, you must unlock developer settings. This step is required for all versions of Android starting from 4.2 Jelly Bean. The instructions are universal, but the path to the menu may differ slightly depending on the shell (MIUI, One UI, ColorOS etc.).
How to enable developer mode:
- Open
Settings โ About phone. - Find item
Build number(orMIUI versionfor Xiaomi). - Tap on it 7 times in a row. After 3-4 clicks, a notification โYou are almost a developer!โ will appear.
- Enter the PIN code or pattern if the system prompts.
After activation, a new section will appear in the main settings menu - For developers (or Developer options). In some firmware (for example, on Samsung) it may be hidden in Additional settings.
โ๏ธ Preparing to enable exchange with the environment
Important: on devices with Android 12+ additional confirmation may be required via ADB. If the option for sharing with the environment is inactive, run the command:
adb shell settings put global hidden_api_policy 1
How to enable sharing with the environment through settings Android
If your goal is testing or debugging, the easiest way is to activate the function through the graphical interface. The method works on most devices with Android 10โ14, but may not be available on custom firmware (for example, LineageOS or CalyxOS).
Step-by-step guide:
- Open
Settings โ System โ For Developers. - Scroll down to the block
Debugging. - Find the option
Exchange with the environment(orEnvironment Exchangeon English firmware). - Activate the switch. The system may request confirmation via PIN or password.
- Reboot the device (required for use) changes!).
If the option is missing, try:
- ๐ Enable
USB debuggingand connect the device to the PC. - ๐ Update the firmware to the latest version (on on some devices, the function appears after the update).
- ๐ ๏ธ Use
ADB-commands (see the next section).
| Android version | The presence of an option in the GUI | Requires ADB? | Restrictions |
|---|---|---|---|
| Android 10โ11 | Yes (hidden) | No | Works only for debug applications |
| Android 12 | Yes (with confirmation) | Sometimes | Restrictions for applications without a certificate |
| Android 13+ | No (ADB only) | Yes | Requires app signing with a platform key |
โ ๏ธ Attention: On devices with Samsung Knox or Huawei EMS enabling exchange with the environment may reset security certificates. This will affect the operation of banking applications and corporate email clients.
Activating exchange with the environment via ADB
If the option is not available in the graphical interface (which is typical for Android 13+), it can be enabled via ADB. This method requires connecting the device to the computer and installed drivers. Android SDK Platform-Tools.
Instructions for Windows/macOS/Linux:
- Connect your smartphone to the PC via USB and enable
USB debuggingon the device screen. - Open a terminal (or
Command Prompt) and run the command:adb devicesMake sure that the device is detected (should its serial number will be displayed).
- Enter the command to activate exchange with the environment:
adb shell settings put global environment_exchange_enabled 1 - Reboot the device:
adb reboot
To check the status, run:
adb shell settings get global environment_exchange_enabled
If the command returns 1, the function is activated. The value 0 or an empty line means that sharing is disabled.
Additional commands for setting:
- ๐ง Allow sharing for a specific package:
adb shell am compat enable ENVIRONMENT_EXCHANGE com.example.app - ๐ Block sharing for all applications:
adb shell settings put global environment_exchange_enabled 0
If, after activation via ADB, the function does not work, check whether it is blocked by an antivirus or MDM solution (for example, MobileIron or VMware Workspace ONE).
Setting access rights and security
Enabling exchange with the environment opens potential vulnerabilities, so you need to configure access rights. By default, the function is only available for system applications and applications signed by the platform. To allow exchange for third-party apps, you will need:
- Add permission to
AndroidManifest.xml:<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" /><uses-permission android:name="android.permission.MANAGE_ENVIRONMENT_EXCHANGE" /> - Sign the application with a key corresponding to the platform key (for Android 13+).
- Configure
SELinuxpolicies (requires root access).
For testing, you can temporarily relax the restrictions with the command:
adb shell setenforce 0
โ ๏ธ This disables SELinux completely โuse only in an isolated environment!
Security recommendations:
- ๐ Use communication with the environment only in test builds applications.
- ๐ฑ Restrict access to the function through
Device Policy Controller(for corporate devices). - ๐ Regularly check the logs for suspicious activity:
adb logcat | grep "EnvironmentExchange"
Practical examples of use
Exchange with the environment is used in highly specialized scenarios. Let's consider several real cases:
1. Testing banking applications
Banks often use isolated environments for processing payments. data-i="193">you can emulate the interaction between the security module and the main application without real transactions. Example of a command for transmitting test data: MADA You can emulate the interaction between the security module and the main application without real transactions. Example command for transmitting test data:
adb shell am broadcast -a android.intent.action.ENVIRONMENT_EXCHANGE \--es package "com.bank.app" \
--es key "transaction_data" \
--es value "test_12345"
2. Integration with industrial equipment
In warehouses or factories, smartphones can act as terminals for reading data from sensors. Exchange with the environment allows you to transfer readings directly to the corporate system, bypassing the cloud. services. Example of setup for Zebra TC52:
- ๐ฑ Activate
Environment Exchangevia ADB. - ๐ Connect a barcode scanner via USB-OTG.
- ๐ค Configure data transfer in JSON format:
{"device_id": "TC52_001",
"scan_data": "123456789",
"timestamp": 1625097600
}
3. Debugging the operation of sensors
To test applications that depend on GPS or accelerometer, you can emulate sensor data. Example of a command to simulate coordinates:
adb shell am broadcast -a android.intent.action.ENVIRONMENT_EXCHANGE \--es package "com.example.navapp" \
--es key "mock_location" \
--es value "55.7558,37.6173" # Moscow coordinates
What will happen if an attacker gains access to MADA?
Using communication with the environment, you can intercept data between applications, replace sensor responses, or even execute code on behalf of system processes. For example, an attack can simulate a successful payment in a banking application, while the money is not debited.
Common problems and theirs. solutions
When working with exchange with the environment, users encounter typical errors. Let's look at the most common ones:
| Problem | Possible reason | Solution |
|---|---|---|
| The option is missing in settings | Outdated firmware or custom ROM | Update Android or use ADB |
| ADB command returns "not found" | No support in the kernel | Check Android version (requires 10+) |
| The application does not receive data | There are not enough permissions in AndroidManifest |
Add MANAGE_ENVIRONMENT_EXCHANGE |
| The device is overheating | Excessive data sharing in the background mode | Limit the exchange rate via JobScheduler |
If, after activating the function, the device begins to slow down or discharge quickly, check:
- ๐ Activity of processes via
adb shell top. - ๐ Battery usage in
Settings โ Battery. - ๐ก๏ธ Logs for exchange cycles:
adb logcat -s "EnvironmentExchange:W"
โ ๏ธ Attention: On devices with Android 14 and newer, exchange with the environment may conflict with the function Private Compute Core (isolated data processing). If the voice assistant or camera stops working after activation, disable MADA or update the firmware.
Sharing with the environment is a powerful tool, but its activation requires understanding the consequences Always test the function in an isolated environment before using it on working devices.
FAQ: Frequently asked questions about sharing with the environment. environment
Is it possible to enable exchange with the environment without root access?
Yes, on most devices with Android 10โ13 this is possible through developer settings or ADBHowever, for full operation (for example, changes SELinux-politician) may require root.
Will the function work on custom firmware (LineageOS, Pixel Experience)?
Depends on the build LineageOS 20+ support MADA usually present, but can be disabled by default. On unofficial firmware the function is often absent due to the modified kernel.
How to disable communication with the environment if the device begins to lag?
Run the command:
adb shell settings put global environment_exchange_enabled 0
Then restart your device. If the problem persists, reset the settings to factory settings (Settings โ System โ Reset).
Is it possible to use this feature to bypass application restrictions (for example, cheats in games)?
Technically yes, but this violates Google Play rules. If such use is detected, the account may be blocked and the device blacklisted. Play Protect.
Where can I find the log of interaction between applications via MADA?
The logs are stored in /data/log/environment_exchange, but access to them requires root access. An alternative is filtering through logcat:
adb logcat | grep -E "EnvExchange|MADA"