Improvement #10875
closedImprovement #10736: Improve Data usage policy and actions
Add actions when exceeding wifi allowance limits
100%
Files
Updated by Inosh Perara about 1 year ago
Updated by Inosh Perara about 1 year ago
Revoke by removing all packages
Preference.removePreference(this, Constants.PreferenceFlag.WIFI_BLOCKED_PACKAGES);
Add app to block
Preference.upsertStringSet(this, Constants.PreferenceFlag.WIFI_BLOCKED_PACKAGES, "com.android.chrome");
Updated by Inosh Perara about 1 year ago
- Due date set to 13/03/2024
- Status changed from New to 12
- % Done changed from 0 to 100
- Estimated time set to 8:00 h
Updated by Arshana Atapattu about 1 year ago
- File Screenshot from 2024-04-05 12-01-47.png Screenshot from 2024-04-05 12-01-47.png added
- File Screenshot from 2024-04-05 12-06-16.png Screenshot from 2024-04-05 12-06-16.png added
- File Screenshot_20240405_115413_Settings.jpg Screenshot_20240405_115413_Settings.jpg added
- File Screenshot_20240405_121116_Settings.jpg Screenshot_20240405_121116_Settings.jpg added
- File Screenshot_20240405_121124_Settings.jpg Screenshot_20240405_121124_Settings.jpg added
- Status changed from 12 to 9
On staging server(6.0.0)
Agent version: 4.05.00.11
There are 2 issues. 2nd issue is the critical issue.
Note: 2nd issue was added as a separate comment.
Issue 1)
When applied the "Per App Network Usage Configuration" policy [1] the apps were disabled even if the wifi usage was not exceeded.
allowed app usage limit 10MB
Note: the app usage restricted app was You tube music and that app was not even installed on the device!.
The policy was created along with the "Block Apps from using Metered Connection" policy part [2].
policy payload [3]
Note: this policy had mentioned 4 apps. and on the device side this 4 apps were disabled(due to "Per App Network Usage Configuration") applying on the device [4]
Network usage of the device [5] [6]
[1]
[2]
[3] {"policyName":"App usage policy","description":"App usage policy","active":true,"compliance":"enforce","ownershipType":null,"policyType":"GENERAL","profile":{"profileName":"App usage policy","deviceType":"android","profileFeaturesList":[{"featureCode":"APP_USAGE","deviceType":"android","content":{"isNetworkUsageEnabled":true,"appsNetworkUsageData":[{"packageName":" com.google.android.apps.youtube.music","allowedData":"10","allowedDataType":1024,"periodTimeType":86400}],"isNetworkUsageNotificationsEnabled":false,"isNetworkUsageHideAppsEnabled":false,"appsNetworkUsageDataBillingDate":"5","isBlockMeteredConnectionEnabled":true,"appsToBlockMeteredConnection":[{"appName":"YoutTube","packageName":"com.google.android.youtube"},{"appName":"chrome","packageName":"com.android.chrome"},{"appName":"youtube music","packageName":" com.google.android.apps.youtube.music"},{"packageName":"com.android.vending","appName":"playstore"}],"isMeteredConnectionNotificationsEnabled":true,"isMeteredConnectionHideAppsEnabled":true},"correctiveActions":[]}]},"deviceGroups":[{"id":59,"name":"Test Devices"}],"roles":["ANY"],"users":[]}
[4]
[5]
[6]
Updated by Arshana Atapattu about 1 year ago
- File Screenshot from 2024-04-05 12-16-39.png Screenshot from 2024-04-05 12-16-39.png added
- File Screenshot from 2024-04-05 12-19-59.png Screenshot from 2024-04-05 12-19-59.png added
- File Screenshot from 2024-04-05 12-20-09.png Screenshot from 2024-04-05 12-20-09.png added
- File logcat.logcat logcat.logcat added
Issue 2) CRITICAL
When the "Per App Network Usage Configuration" was applied with the "Enable Notifications" and "Hide Applications" (ticked) [7] on device side policy applying and policy revoking getting failed.
Once this failed no other policies cannot be applied on the device due to policy revoke is keep failing.
policy payload [8]
error on operation log:
for POLICY_REVOKE: [9]
for POLICY_BUNDLE: [10]
[7]
[8]
{"policyName":"App usage policy","description":"App usage policy","active":true,"compliance":"enforce","ownershipType":null,"policyType":"GENERAL","profile":{"profileName":"App usage policy","deviceType":"android","profileFeaturesList":[{"featureCode":"APP_USAGE","deviceType":"android","content":{"isNetworkUsageEnabled":true,"appsNetworkUsageData":[{"packageName":" com.google.android.apps.youtube.music","allowedData":"10","allowedDataType":1024,"periodTimeType":86400}],"isNetworkUsageNotificationsEnabled":true,"isNetworkUsageHideAppsEnabled":true,"appsNetworkUsageDataBillingDate":"5","isBlockMeteredConnectionEnabled":true,"appsToBlockMeteredConnection":[{"appName":"YoutTube","packageName":"com.google.android.youtube"},{"appName":"chrome","packageName":"com.android.chrome"},{"appName":"youtube music","packageName":" com.google.android.apps.youtube.music"},{"packageName":"com.android.vending","appName":"playstore"}],"isMeteredConnectionNotificationsEnabled":true,"isMeteredConnectionHideAppsEnabled":true},"correctiveActions":[]}]},"deviceGroups":[{"id":59,"name":"Test Devices"}],"roles":["ANY"],"users":[]}
Logcat when a policy revoke and whe na policy bundle applied [11]
Extracted error log from logcat: [12]
[9]
[10]
[12]
2024-04-05 12:23:02.974 32296-32478 OperationProcessor io.entgra.iot.agent I Operation code POLICY_REVOKE
2024-04-05 12:23:02.976 1354-2409 WindowManager system_server D rotationForOrientation, orientationSource=ActivityRecord{6f203f5 u0 io.entgra.iot.agent/org.wso2.iot.agent.activities.AlreadyRegisteredActivity} t27}
2024-04-05 12:23:02.981 32296-32478 MessageSyncService io.entgra.iot.agent E Failed to perform operation
org.wso2.iot.agent.AndroidAgentException: Unrecoverable error with payload.
at org.wso2.iot.agent.services.operation.OperationProcessor.doTask(OperationProcessor.java:450)
at org.wso2.iot.agent.services.MessageSyncService.performOperation(MessageSyncService.java:222)
at org.wso2.iot.agent.services.MessageSyncService.onReceiveAPIResult(MessageSyncService.java:854)
at org.wso2.iot.agent.proxy.APIController$3.parseNetworkResponse(APIController.java:209)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:144)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
at org.wso2.iot.agent.services.PolicyRevokeHandler.revokeDataUsagePerAppPerNetwork(PolicyRevokeHandler.java:941)
at org.wso2.iot.agent.services.PolicyRevokeHandler.revokeAppUsageConfigurationPolicy(PolicyRevokeHandler.java:912)
at org.wso2.iot.agent.services.PolicyRevokeHandler.revokeExistingPolicy(PolicyRevokeHandler.java:386)
at org.wso2.iot.agent.utils.CommonUtils.revokePolicy(CommonUtils.java:472)
at org.wso2.iot.agent.services.operation.OperationManager.revokePolicy(OperationManager.java:2701)
at org.wso2.iot.agent.services.operation.OperationProcessor.doTask(OperationProcessor.java:230)
at org.wso2.iot.agent.services.MessageSyncService.performOperation(MessageSyncService.java:222)
at org.wso2.iot.agent.services.MessageSyncService.onReceiveAPIResult(MessageSyncService.java:854)
at org.wso2.iot.agent.proxy.APIController$3.parseNetworkResponse(APIController.java:209)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:144)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)
2024-04-05 12:23:02.981 32296-32478 MessageSyncService io.entgra.iot.agent I COMMAND operation finished with code: POLICY_REVOKE
2024-04-05 12:23:02.981 32296-32478 OperationProcessor io.entgra.iot.agent I Operation code POLICY_BUNDLE
2024-04-05 12:23:02.983 1354-2409 WindowManager system_server V Changing focus from Window{14300be u0 io.entgra.iot.agent/org.wso2.iot.agent.activities.AlreadyRegisteredActivity} to null displayId=0 Callers=com.android.server.wm.RootWindowContainer.updateFocusedWindowLocked:595 com.android.server.wm.WindowManagerService.updateFocusedWindowLocked:6803 com.android.server.wm.ActivityTaskManagerService.setResumedActivityUncheckLocked:5755 com.android.server.wm.TaskFragment.onActivityStateChanged:807
2024-04-05 12:23:02.983 1354-2409 MARsPolicyManager system_server D onPackageResumedFG pkgName = io.entgra.iot.agent, userId = 0
2024-04-05 12:23:02.993 32296-32478 MessageSyncService io.entgra.iot.agent E Failed to perform operation
org.wso2.iot.agent.AndroidAgentException: Unrecoverable error with payload.
at org.wso2.iot.agent.services.operation.OperationProcessor.doTask(OperationProcessor.java:450)
at org.wso2.iot.agent.services.MessageSyncService.performOperation(MessageSyncService.java:222)
at org.wso2.iot.agent.services.MessageSyncService.onReceiveAPIResult(MessageSyncService.java:854)
at org.wso2.iot.agent.proxy.APIController$3.parseNetworkResponse(APIController.java:209)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:144)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
at org.wso2.iot.agent.services.PolicyRevokeHandler.revokeDataUsagePerAppPerNetwork(PolicyRevokeHandler.java:941)
at org.wso2.iot.agent.services.PolicyRevokeHandler.revokeAppUsageConfigurationPolicy(PolicyRevokeHandler.java:912)
at org.wso2.iot.agent.services.PolicyRevokeHandler.revokeExistingPolicy(PolicyRevokeHandler.java:386)
at org.wso2.iot.agent.utils.CommonUtils.revokePolicy(CommonUtils.java:472)
at org.wso2.iot.agent.services.operation.OperationManager.revokePolicy(OperationManager.java:2701)
at org.wso2.iot.agent.services.operation.OperationProcessor.setPolicyBundle(OperationProcessor.java:513)
at org.wso2.iot.agent.services.operation.OperationProcessor.doTask(OperationProcessor.java:218)
at org.wso2.iot.agent.services.MessageSyncService.performOperation(MessageSyncService.java:222)
at org.wso2.iot.agent.services.MessageSyncService.onReceiveAPIResult(MessageSyncService.java:854)
at org.wso2.iot.agent.proxy.APIController$3.parseNetworkResponse(APIController.java:209)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:144)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)
2024-04-05 12:23:02.993 32296-32478 MessageSyncService io.entgra.iot.agent I POLICY operation finished with code: POLICY_BUNDLE
2024-04-05 12:23:02.993 32296-32478 MessageSyncService io.entgra.iot.agent I done execution of operations
2024-04-05 12:23:02.993 32296-32478 MessageSyncService io.entgra.iot.agent I Not a monitoring operation
2024-04-05 12:23:02.993 32296-32478 MessageSyncService io.entgra.iot.agent I performOperation requireImmediateSyncing true
2024-04-05 12:23:02.993 32296-32478 MessageSyncService io.entgra.iot.agent I Finish syncing in message sync service.
Updated by Kavin Prathaban about 1 year ago
- Status changed from 9 to 12
Updated by Arshana Atapattu about 1 year ago
- Status changed from 12 to 11
The notification which showed the apps that were not in the device is fixed.
The "Per App Network Usage Configuration" did not applied when checking with wifi(Youtube app was able to use even after exceeding data allocation).
upon updating the policy again and republished, it showed the above critical issue(policy revoke and policy bundle failure)
Note: in this case the initial policy apply is working(In here 2 package names of existing apps were used), but when the policy is unpublished and republished, or updating the policy and apply changes to all devices will result in above critical error.
To-do: Need to test this feature with only mobile data and, wifi and mobile data combination.
Updated by Kavin Prathaban about 1 year ago
Cause of the issue is networkType attribute is not passed from the frontend. This happens for periodTimeType, allowedDataType attributes too.
This happens because of the CustomSelect input used in the Table. The CustomSelect is not sending the default key value pair to the payload. When CustomSelect is used in other places this works fine. But when used inside a Table coloumn this breaks.
This happens in other similar places where this is implemented (Ex:- Runtime Permission Policy)
Updated by Arshana Atapattu about 1 year ago
When the policy was applied(wifi), the mentioned apps were able to use more than the allocated data.
EX: The YouTube app was allocated 10MB. But using wifi this app was able to exceed the allocated 10MB and still use the app ..
Policy payload:
{
"policyName":"App usage Test Policy",
"description":"Polciy",
"active":true,
"compliance":"enforce",
"ownershipType":null,
"policyType":"GENERAL",
"profile":{
"profileName":"App usage Test Policy",
"deviceType":"android",
"profileFeaturesList":[
{
"featureCode":"APP_USAGE",
"deviceType":"android",
"content":{
"isNetworkUsageEnabled":true,
"appsNetworkUsageData":[
{
"packageName":"com.android.chrome",
"allowedData":"10",
"allowedDataType":1024,
"periodTimeType":86400,
"networkType":"wifi"
},
{
"packageName":" com.google.android.youtube",
"allowedData":"10",
"allowedDataType":1024,
"periodTimeType":86400,
"networkType":"wifi"
}
],
"isNetworkUsageNotificationsEnabled":true,
"isNetworkUsageHideAppsEnabled":true,
"appsNetworkUsageDataBillingDate":"7",
"isBlockMeteredConnectionEnabled":false
},
"correctiveActions":[
]
}
]
},
"deviceGroups":[
{
"id":59,
"name":"Test Devices"
}
],
"roles":[
"ANY"
],
"users":[
]
}
Updated by Kavin Prathaban 12 months ago
- Status changed from 11 to 12
PR:
https://repository.entgra.net/proprietary/android-agent/pulls/74
Fix added for apps continuosly running in foreground without disabling the WiFi after violating the data limit. Here the continuous monitoring frequency is 5 minutes. There can be a delay of applying the policy when a data limit is passed. But within 5 minutes this should work.