Source:
<code>private void addIfPermissionEnforcementExist(String installedPackageName, Context context) { JSONObject permittedApp; String permittedPackageName; String permissionName; int permissionType; Log.d(TAG, "addIfPremissionEnforcementExist triggered."); try { String permittedAppData = Preference.getString(context, Constants.RuntimePermissionPolicy.PERMITTED_APP_DATA); if (permittedAppData != null && permittedAppData != "") { JSONArray permittedAppsData = new JSONArray(permittedAppData); if (!permittedAppsData.equals(null)) { for (int i = 0; i < permittedAppsData.length(); i++) { permittedApp = new JSONObject(permittedAppsData.getString(i)); permittedPackageName = permittedApp.getString(Constants.RuntimePermissionPolicy.PACKAGE_NAME); <START> Log.d(TAG, permittedPackageName + " <-> " + installedPackageName); <END> if (Objects.equals(permittedPackageName, installedPackageName)) { Log.d(TAG, "packageName found of payload."); permissionName = permittedApp.getString(Constants.RuntimePermissionPolicy.PERMISSION_NAME); permissionType = Integer.parseInt(permittedApp.getString(Constants.RuntimePermissionPolicy.PERMISSION_TYPE)); if (permissionName.equals(Constants.RuntimePermissionPolicy.ALL_PERMISSIONS)) { String[] permissionList = context.getResources().getStringArray(R.array.runtime_permission_list_array); for (String permission : permissionList) { devicePolicyManager.setPermissionGrantState(cdmfDeviceAdmin, permittedPackageName, permission, permissionType); } } devicePolicyManager.setPermissionGrantState(cdmfDeviceAdmin, permittedPackageName, permissionName, permissionType); break; } } } } } catch (JSONException e) { Log.e(TAG, "Invalid JSON format.."); } }</code><technical_language>print debug logs if debug is enabled</technical_language>

Target:
private void addIfPermissionEnforcementExist(String installedPackageName, Context context) { JSONObject permittedApp; String permittedPackageName; String permissionName; int permissionType; Log.d(TAG, "addIfPremissionEnforcementExist triggered."); try { String permittedAppData = Preference.getString(context, Constants.RuntimePermissionPolicy.PERMITTED_APP_DATA); if (permittedAppData != null && permittedAppData != "") { JSONArray permittedAppsData = new JSONArray(permittedAppData); if (!permittedAppsData.equals(null)) { for (int i = 0; i < permittedAppsData.length(); i++) { permittedApp = new JSONObject(permittedAppsData.getString(i)); permittedPackageName = permittedApp.getString(Constants.RuntimePermissionPolicy.PACKAGE_NAME); if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, permittedPackageName + " <-> " + installedPackageName); } if (Objects.equals(permittedPackageName, installedPackageName)) { if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "packageName found of payload."); } permissionName = permittedApp.getString(Constants.RuntimePermissionPolicy.PERMISSION_NAME); permissionType = Integer.parseInt(permittedApp.getString(Constants.RuntimePermissionPolicy.PERMISSION_TYPE)); if (permissionName.equals(Constants.RuntimePermissionPolicy.ALL_PERMISSIONS)) { String[] permissionList = context.getResources().getStringArray(R.array.runtime_permission_list_array); for (String permission : permissionList) { devicePolicyManager.setPermissionGrantState(cdmfDeviceAdmin, permittedPackageName, permission, permissionType); } } devicePolicyManager.setPermissionGrantState(cdmfDeviceAdmin, permittedPackageName, permissionName, permissionType); break; } } } } } catch (JSONException e) { Log.e(TAG, "Invalid JSON format.."); } }