Merge "Apply delivery group policies to CLOSE_SYSTEM_DIALOG broadcast." into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
dfe57f710f
@@ -3619,6 +3619,17 @@ class ContextImpl extends Context {
|
||||
scheduleFinalCleanup(getClass().getName(), getOuterContext().getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeSystemDialogs() {
|
||||
final Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
|
||||
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||
final Bundle options = BroadcastOptions.makeBasic()
|
||||
.setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT)
|
||||
.setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
|
||||
.toBundle();
|
||||
sendBroadcast(intent, null /* receiverPermission */, options);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -7873,4 +7873,15 @@ public abstract class Context {
|
||||
public boolean isConfigurationContext() {
|
||||
throw new RuntimeException("Not implemented. Must override in a subclass.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes temporary system dialogs. Some examples of temporary system dialogs are the
|
||||
* notification window-shade and the recent tasks dialog.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS)
|
||||
public void closeSystemDialogs() {
|
||||
throw new RuntimeException("Not implemented. Must override in a subclass.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1484,4 +1484,15 @@ public class ContextWrapper extends Context {
|
||||
// Do nothing if the callback hasn't been registered to Application Context by
|
||||
// super.unregisterComponentCallbacks() for Application that is targeting prior to T.
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes temporary system dialogs. Some examples of temporary system dialogs are the
|
||||
* notification window-shade and the recent tasks dialog.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS)
|
||||
public void closeSystemDialogs() {
|
||||
mBase.closeSystemDialogs();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ public class DynamicSystemInstallationService extends Service
|
||||
Log.e(TAG, "Failed to disable DynamicSystem.");
|
||||
|
||||
// Dismiss status bar and show a toast.
|
||||
sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
|
||||
closeSystemDialogs();
|
||||
Toast.makeText(this,
|
||||
getString(R.string.toast_failed_to_disable_dynsystem),
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
||||
@@ -1697,7 +1697,7 @@ public class BugreportProgressService extends Service {
|
||||
}
|
||||
|
||||
private void collapseNotificationBar() {
|
||||
sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
|
||||
closeSystemDialogs();
|
||||
}
|
||||
|
||||
private static Looper newLooper(String name) {
|
||||
|
||||
@@ -109,7 +109,7 @@ class BroadcastSender @Inject constructor(
|
||||
@AnyThread
|
||||
fun closeSystemDialogs() {
|
||||
sendInBackground {
|
||||
context.sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
|
||||
context.closeSystemDialogs()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -772,9 +772,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
|
||||
mSaverConfirmation.dismiss();
|
||||
}
|
||||
// Also close the notification shade, if it's open.
|
||||
mBroadcastSender.sendBroadcast(
|
||||
new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
|
||||
.setFlags(Intent.FLAG_RECEIVER_FOREGROUND));
|
||||
mBroadcastSender.closeSystemDialogs();
|
||||
|
||||
final Uri uri = Uri.parse(getURL());
|
||||
Context context = widget.getContext();
|
||||
|
||||
@@ -205,7 +205,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList
|
||||
}, false, false);
|
||||
|
||||
// Close quick shade
|
||||
sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
|
||||
closeSystemDialogs();
|
||||
break;
|
||||
}
|
||||
return Service.START_STICKY;
|
||||
|
||||
@@ -946,7 +946,7 @@ public class ScreenshotController {
|
||||
transitionDestination, onTransitionEnd,
|
||||
longScreenshot);
|
||||
// TODO: Do this via ActionIntentExecutor instead.
|
||||
mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
|
||||
mContext.closeSystemDialogs();
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ public class WifiDebuggingSecondaryUserActivity extends AlertActivity
|
||||
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||
registerReceiver(mWifiChangeReceiver, filter);
|
||||
// Close quick shade
|
||||
sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
|
||||
closeSystemDialogs();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentCaptor
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations
|
||||
@@ -126,13 +125,10 @@ class BroadcastSenderTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun sendCloseSystemDialogs_dispatchesWithWakelock() {
|
||||
val intentCaptor = ArgumentCaptor.forClass(Intent::class.java)
|
||||
|
||||
broadcastSender.closeSystemDialogs()
|
||||
|
||||
runExecutorAssertingWakelock {
|
||||
verify(mockContext).sendBroadcast(intentCaptor.capture())
|
||||
assertThat(intentCaptor.value.action).isEqualTo(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
|
||||
verify(mockContext).closeSystemDialogs()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,10 @@ final class DreamController {
|
||||
// Time to allow the dream to perform an exit transition when waking up.
|
||||
private static final int DREAM_FINISH_TIMEOUT = 5 * 1000;
|
||||
|
||||
// Extras used with ACTION_CLOSE_SYSTEM_DIALOGS broadcast
|
||||
private static final String EXTRA_REASON_KEY = "reason";
|
||||
private static final String EXTRA_REASON_VALUE = "dream";
|
||||
|
||||
private final Context mContext;
|
||||
private final Handler mHandler;
|
||||
private final Listener mListener;
|
||||
@@ -77,6 +81,7 @@ final class DreamController {
|
||||
private final Bundle mDreamingStartedStoppedOptions = createDreamingStartedStoppedOptions();
|
||||
|
||||
private final Intent mCloseNotificationShadeIntent;
|
||||
private final Bundle mCloseNotificationShadeOptions;
|
||||
|
||||
private DreamRecord mCurrentDream;
|
||||
|
||||
@@ -96,7 +101,14 @@ final class DreamController {
|
||||
mListener = listener;
|
||||
mActivityTaskManager = mContext.getSystemService(ActivityTaskManager.class);
|
||||
mCloseNotificationShadeIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
||||
mCloseNotificationShadeIntent.putExtra("reason", "dream");
|
||||
mCloseNotificationShadeIntent.putExtra(EXTRA_REASON_KEY, EXTRA_REASON_VALUE);
|
||||
mCloseNotificationShadeIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||
mCloseNotificationShadeOptions = BroadcastOptions.makeBasic()
|
||||
.setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT)
|
||||
.setDeliveryGroupMatchingKey(Intent.ACTION_CLOSE_SYSTEM_DIALOGS,
|
||||
EXTRA_REASON_VALUE)
|
||||
.setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
|
||||
.toBundle();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +161,8 @@ final class DreamController {
|
||||
Trace.traceBegin(Trace.TRACE_TAG_POWER, "startDream");
|
||||
try {
|
||||
// Close the notification shade. No need to send to all, but better to be explicit.
|
||||
mContext.sendBroadcastAsUser(mCloseNotificationShadeIntent, UserHandle.ALL);
|
||||
mContext.sendBroadcastAsUser(mCloseNotificationShadeIntent, UserHandle.ALL,
|
||||
null /* receiverPermission */, mCloseNotificationShadeOptions);
|
||||
|
||||
Slog.i(TAG, "Starting dream: name=" + name
|
||||
+ ", isPreviewMode=" + isPreviewMode + ", canDoze=" + canDoze
|
||||
|
||||
Reference in New Issue
Block a user