Advanced tips to secure inter-app communication
Hands-on practice demonstrates the best use of permissions. Where an AI-based custom permission made the communication secured between two apps. Most of the time we do intercommunication based on protection level “signature”. But it is possible to change the protection level to “normal” or “dangerous”. See the example codes below for dangerous and normal permissions
<permission
android:name="your permission name"
android:description="@string/description"
android:label="@string/label"
android:permissionGroup="android.permission-group.PERSONAL_INFO"
android:protectionLevel="dangerous" />
<permission
android:name="your permission name"
android:description="@string/description"
android:label="@string/label"
android:permissionGroup="android.permission-group.PERSONAL_INFO"
android:protectionLevel="normal" />
**Note : Here permission name, description, label and permissionGroup strings must be saved under “res/values/string.xml” file. Either the permission would not work properly.
There are some other ways to improve the communication. Like we can send the package name as the category attribute of intent filter. See the example below
package="YourPackageName".
<receiver android:name=".MyReceiver">
<intent-filter>
<action android:name="com.arabin.CUSTOM_ACTION"/>
<category android:name="YourPackageName"/>
</intent-filter>
</receiver>