Merge changes Ia0726197,I3698d82d
* changes: Update documentation Add package to DND alarm broadcast
This commit is contained in:
committed by
Android (Google) Code Review
commit
da0bba543d
@@ -7915,7 +7915,7 @@ public class Notification implements Parcelable
|
||||
* Adds a message for display by this notification. Convenience call for a simple
|
||||
* {@link Message} in {@link #addMessage(Notification.MessagingStyle.Message)}.
|
||||
* @param text A {@link CharSequence} to be displayed as the message content
|
||||
* @param timestamp Time at which the message arrived
|
||||
* @param timestamp Time in milliseconds at which the message arrived
|
||||
* @param sender A {@link CharSequence} to be used for displaying the name of the
|
||||
* sender. Should be <code>null</code> for messages by the current user, in which case
|
||||
* the platform will insert {@link #getUserDisplayName()}.
|
||||
@@ -7937,7 +7937,7 @@ public class Notification implements Parcelable
|
||||
* Adds a message for display by this notification. Convenience call for a simple
|
||||
* {@link Message} in {@link #addMessage(Notification.MessagingStyle.Message)}.
|
||||
* @param text A {@link CharSequence} to be displayed as the message content
|
||||
* @param timestamp Time at which the message arrived
|
||||
* @param timestamp Time in milliseconds at which the message arrived
|
||||
* @param sender The {@link Person} who sent the message.
|
||||
* Should be <code>null</code> for messages by the current user, in which case
|
||||
* the platform will insert the user set in {@code MessagingStyle(Person)}.
|
||||
|
||||
@@ -40,6 +40,7 @@ import android.util.Slog;
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.server.notification.NotificationManagerService.DumpFilter;
|
||||
import com.android.server.pm.PackageManagerService;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
@@ -218,12 +219,7 @@ public class ScheduleConditionProvider extends SystemConditionProviderService {
|
||||
|
||||
private void updateAlarm(long now, long time) {
|
||||
final AlarmManager alarms = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
|
||||
final PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext,
|
||||
REQUEST_CODE_EVALUATE,
|
||||
new Intent(ACTION_EVALUATE)
|
||||
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
|
||||
.putExtra(EXTRA_TIME, time),
|
||||
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
||||
final PendingIntent pendingIntent = getPendingIntent(time);
|
||||
alarms.cancel(pendingIntent);
|
||||
if (time > now) {
|
||||
if (DEBUG) Slog.d(TAG, String.format("Scheduling evaluate for %s, in %s, now=%s",
|
||||
@@ -234,6 +230,17 @@ public class ScheduleConditionProvider extends SystemConditionProviderService {
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
PendingIntent getPendingIntent(long time) {
|
||||
return PendingIntent.getBroadcast(mContext,
|
||||
REQUEST_CODE_EVALUATE,
|
||||
new Intent(ACTION_EVALUATE)
|
||||
.setPackage(PackageManagerService.PLATFORM_PACKAGE_NAME)
|
||||
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
|
||||
.putExtra(EXTRA_TIME, time),
|
||||
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
||||
}
|
||||
|
||||
public long getNextAlarm() {
|
||||
final AlarmManager.AlarmClockInfo info = mAlarmManager.getNextAlarmClock(
|
||||
ActivityManager.getCurrentUser());
|
||||
|
||||
@@ -7,6 +7,7 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.app.Application;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.service.notification.Condition;
|
||||
@@ -18,6 +19,7 @@ import android.testing.TestableLooper.RunWithLooper;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.server.UiServiceTestCase;
|
||||
import com.android.server.pm.PackageManagerService;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -326,6 +328,12 @@ public class ScheduleConditionProviderTest extends UiServiceTestCase {
|
||||
assertEquals(Condition.STATE_FALSE, condition.state);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPendingIntent() {
|
||||
PendingIntent pi = mService.getPendingIntent(1000);
|
||||
assertEquals(PackageManagerService.PLATFORM_PACKAGE_NAME, pi.getIntent().getPackage());
|
||||
}
|
||||
|
||||
private Calendar getNow() {
|
||||
Calendar now = new GregorianCalendar();
|
||||
now.set(Calendar.HOUR_OF_DAY, 14);
|
||||
|
||||
Reference in New Issue
Block a user