Reputation: 41
Inside my application I need to set alarms and when they fire I'm trying to trigger them in my Receiver.
In order to deal with Dozo mode from marshmallow 6.0, if the device version is greater or equal to 6.0 I'm using alarmManger.setAlarmClock() method. This works fine is almost all the devices except OPPO devices
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
final AlarmManager.AlarmClockInfo alarmClockInfo = new AlarmManager.AlarmClockInfo(fireDate.getTime(), pendingIntent);
alarmManager.setAlarmClock(alarmClockInfo, pendingIntent);
//alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, fireDate.getTime(), pendingIntent);
} else {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, fireDate.getTime(), pendingIntent);
}
====================================================================== from Terminal, I got logs using : adb shell dumpsys alarm.
Batch{b778e8c num=1 start=35988972 end=35988972 flgs=0x3}:
RTC_WAKEUP #0: Alarm{b9e89d5 type 0 when 1547501400600 ######.######}
tag=*walarm*:######.######.Reminder
type=0 whenElapsed=+9h49m0s741ms when=2019-01-15 03:00:00
window=0 repeatInterval=0 count=0 flags=0x3
Alarm clock:
triggerTime=2019-01-15 03:00:00
showIntent=PendingIntent{3dc5ea: PendingIntentRecord{d66ec2a ######.###### broadcastIntent}}
operation=PendingIntent{996c0db: PendingIntentRecord{d66ec2a ######.###### broadcastIntent}}
the batch is unique and the flag value is set to 0x3, this is how it will be for alarmClocks. For most of the brands the result is same, but in oppo the flag is set to 0x8
Batch{b778e8c num=1 start=35988972 end=35988972 flgs=0x8}:
RTC_WAKEUP #0: Alarm{b9e89d5 type 0 when 1547501400600 ######.######}
tag=*walarm*:######.######.Reminder
type=0 whenElapsed=+9h49m0s741ms when=2019-01-15 03:00:00
window=0 repeatInterval=0 count=0 flags=0x8
Alarm clock:
triggerTime=2019-01-15 03:00:00
showIntent=PendingIntent{3dc5ea: PendingIntentRecord{d66ec2a ######.###### broadcastIntent}}
operation=PendingIntent{996c0db: PendingIntentRecord{d66ec2a ######.###### broadcastIntent}}
Batch{3450b8d num=1 start=464582537 end=464582537 flgs=0x9}:
RTC_WAKEUP #0: Alarm{32536c5 type 0 when 1547690400000 ######.###### whenElapsed 464582537 windowLength 0 maxWhenElapsed 464582537 repeatInterval 0 action }
tag=*walarm*:######.######.ALARM_ALERT
type=0 whenElapsed=+17h4m45s187ms when=2019-01-17 07:30:00
window=0 repeatInterval=0 count=0 flags=0x9
Alarm clock:
triggerTime=2019-01-17 07:30:00
showIntent=PendingIntent{ee6881a: PendingIntentRecord{97c18f0 ######.###### startActivity (whitelist: 902f275:+30s0ms)}}
operation=PendingIntent{3bc0f4b: PendingIntentRecord{2bd8d28 ######.###### broadcastIntent}}
Inside opp phones to get alarms it should be a single batch and flag should be set to 0x9
OTHER Phones: flag = 0x3 is required to trigger it as alarm, alarmManager.setAlarmClock() is setting the flag = 0x3, works fine.
OPPO Phones: flag =0x9 is required to trigger it as alarm. But, alarmManager.setAlarmClock() is setting the flag = 0x8.
What method should I call to make the flag = 0x9 in oppo devices?
Upvotes: 4
Views: 459