Merge "[Provider Model] Fix the panel non responsive issue" into sc-dev
This commit is contained in:
@@ -46,6 +46,7 @@ import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||
import com.android.settings.network.telephony.NetworkProviderWorker;
|
||||
import com.android.settings.slices.CustomSliceable;
|
||||
import com.android.settings.slices.SliceBackgroundWorker;
|
||||
import com.android.settings.slices.SliceBroadcastReceiver;
|
||||
import com.android.settings.slices.SliceBuilderUtils;
|
||||
import com.android.settings.wifi.WifiUtils;
|
||||
import com.android.settings.wifi.slice.WifiSlice;
|
||||
@@ -163,6 +164,18 @@ public class ProviderModelSlice extends WifiSlice {
|
||||
return listBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PendingIntent getBroadcastIntent(Context context) {
|
||||
final Intent intent = new Intent(getUri().toString())
|
||||
// The FLAG_RECEIVER_FOREGROUND flag is necessary to avoid the intent delay of
|
||||
// the first sending after the device restarts
|
||||
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
|
||||
.setData(getUri())
|
||||
.setClass(context, SliceBroadcastReceiver.class);
|
||||
return PendingIntent.getBroadcast(context, 0 /* requestCode */, intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the current carrier's mobile data status.
|
||||
*/
|
||||
|
@@ -142,6 +142,16 @@ public class ProviderModelSliceTest {
|
||||
mockBuilder();
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void getBroadcastIntent_shouldHaveFlagReceiverForeground() {
|
||||
final PendingIntent pendingIntent = mMockProviderModelSlice.getBroadcastIntent(mContext);
|
||||
|
||||
final int flags = pendingIntent.getIntent().getFlags();
|
||||
assertThat(flags & Intent.FLAG_RECEIVER_FOREGROUND)
|
||||
.isEqualTo(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void getSlice_noWifiAndHasCarrierNoData_oneCarrier() {
|
||||
|
Reference in New Issue
Block a user