Consistent reporting of failure conditions

Querying for the state of the exact-alarm permission produced
inconsistent results depending on circumstances.  This is now fixed so
the failure reporting is invariant.

Bug: 193032972
Test: manual
Test: atest CtsAlarmManagerTestCases
Change-Id: Ie1cc126cec568b6f53ebe6049e57ed13abdfd5bb
This commit is contained in:
Christopher Tate
2021-07-13 13:08:54 -07:00
parent 51204c444a
commit 35f567467e

View File

@@ -2593,7 +2593,7 @@ public class AlarmManagerService extends SystemService {
final int uid = mPackageManagerInternal.getPackageUid(packageName, 0, userId);
if (callingUid != uid && !UserHandle.isCore(callingUid)) {
throw new SecurityException("Uid " + callingUid
+ " cannot query hasScheduleExactAlarm for uid " + uid);
+ " cannot query hasScheduleExactAlarm for package " + packageName);
}
return (uid > 0) ? hasScheduleExactAlarmInternal(packageName, uid) : false;
}