Project

General

Profile

Actions

Improvement #10875

closed

Improvement #10736: Improve Data usage policy and actions

Add actions when exceeding wifi allowance limits

Added by Kavin Prathaban 2 months ago. Updated 24 days ago.

Status:
Closed
Priority:
None
Assignee:
Start date:
03/13/2024
Due date:
03/13/2024
% Done:

100%

Estimated time:
8:00 h
Device Type:
Android
Component:
Type:
Android

Files

Screenshot from 2024-04-05 12-01-47.png (77.6 KB) Screenshot from 2024-04-05 12-01-47.png [1] Arshana Atapattu, 04/05/2024 06:39 AM
Screenshot from 2024-04-05 12-06-16.png (85.5 KB) Screenshot from 2024-04-05 12-06-16.png [2] Arshana Atapattu, 04/05/2024 06:39 AM
Screenshot_20240405_115413_Settings.jpg (210 KB) Screenshot_20240405_115413_Settings.jpg [4] Arshana Atapattu, 04/05/2024 06:42 AM
Screenshot_20240405_121116_Settings.jpg (146 KB) Screenshot_20240405_121116_Settings.jpg [5] Arshana Atapattu, 04/05/2024 06:43 AM
Screenshot_20240405_121124_Settings.jpg (142 KB) Screenshot_20240405_121124_Settings.jpg [6] Arshana Atapattu, 04/05/2024 06:44 AM
Screenshot from 2024-04-05 12-16-39.png (76.4 KB) Screenshot from 2024-04-05 12-16-39.png [7] Arshana Atapattu, 04/05/2024 06:48 AM
Screenshot from 2024-04-05 12-19-59.png (145 KB) Screenshot from 2024-04-05 12-19-59.png [9] Arshana Atapattu, 04/05/2024 06:50 AM
Screenshot from 2024-04-05 12-20-09.png (156 KB) Screenshot from 2024-04-05 12-20-09.png [10] Arshana Atapattu, 04/05/2024 06:51 AM
logcat.logcat (4.96 MB) logcat.logcat [11] Arshana Atapattu, 04/05/2024 06:54 AM
Actions #2

Updated by Inosh Perara 2 months 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");

Actions #3

Updated by Inosh Perara 2 months ago

  • Due date set to 03/13/2024
  • Status changed from New to QA
  • % Done changed from 0 to 100
  • Estimated time set to 8:00 h
  • Device Type set to Android
  • Type set to Android
Actions #4

Updated by Arshana Atapattu about 1 month ago

  • Assignee set to Inosh Perara

Updated by Arshana Atapattu about 1 month ago

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]
[1]

[2]
[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]
[4]

[5]
[5]

[6]
[6]

Updated by Arshana Atapattu about 1 month ago

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]
[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]
[9]

[10]
[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.

Actions #8

Updated by Arshana Atapattu about 1 month ago

  • Status changed from QA to Needs Improvement

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.

Actions #9

Updated by Kavin Prathaban about 1 month 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)

Ticket: https://roadmap.entgra.net/issues/11008

Actions #10

Updated by Arshana Atapattu about 1 month 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":[
]
}
Actions #11

Updated by Kavin Prathaban 27 days ago

  • Status changed from Needs Improvement to QA

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.

Actions #12

Updated by Arshana Atapattu 24 days ago

  • Status changed from QA to QA Accept

This is working

Actions #13

Updated by Arshana Atapattu 24 days ago

  • Status changed from QA Accept to Closed

Closing due to QA accept

Actions

Also available in: Atom PDF