Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d3c3a2fd authored by YK Hung's avatar YK Hung Committed by Android (Google) Code Review
Browse files

Merge "[Security] Verify the permission first before querying installed apps" into tm-dev

parents a4a14e9b 42d5979f
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -69,15 +69,6 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity implements
            return;
        }

        ApplicationInfo ai;
        try {
            ai = getPackageManager().getApplicationInfo(mPackageName, 0);
        } catch (PackageManager.NameNotFoundException e) {
            debugLog("Requested package doesn't exist: " + mPackageName);
            finish();
            return;
        }

        if (getPackageManager().checkPermission(
                Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, mPackageName)
                != PackageManager.PERMISSION_GRANTED) {
@@ -87,6 +78,15 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity implements
            return;
        }

        ApplicationInfo ai;
        try {
            ai = getPackageManager().getApplicationInfo(mPackageName, 0);
        } catch (PackageManager.NameNotFoundException e) {
            debugLog("Requested package doesn't exist: " + mPackageName);
            finish();
            return;
        }

        final AlertController.AlertParams p = mAlertParams;
        final CharSequence appLabel = ai.loadSafeLabel(getPackageManager(),
                PackageItemInfo.DEFAULT_MAX_LABEL_SIZE_PX, PackageItemInfo.SAFE_LABEL_FLAG_TRIM