[Security] Verify the permission first before querying installed apps

Verify the target app "REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" permission first before querying installed apps information to avoid the exposed the installed apps information and improve the performance by applying the early return flow.

Bug: 227753723
Test: make RunSettingsRoboTests
Change-Id: Ib5826b8082f4bf14f93d5ff4d2d332dc395bf9a8
1 file changed