Merge "Clear media switcher items when in phone call" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
12dcbe7c71
@@ -24,6 +24,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -76,14 +77,8 @@ public class MediaOutputSlice implements CustomSliceable {
|
||||
final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
|
||||
.setAccentColor(COLOR_NOT_TINTED);
|
||||
|
||||
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (!adapter.isEnabled()) {
|
||||
Log.d(TAG, "getSlice() Bluetooth is off");
|
||||
return listBuilder.build();
|
||||
}
|
||||
|
||||
if (getWorker() == null) {
|
||||
Log.d(TAG, "getSlice() Can not get worker through uri!");
|
||||
if (!isVisible()) {
|
||||
Log.d(TAG, "getSlice() is not visible");
|
||||
return listBuilder.build();
|
||||
}
|
||||
|
||||
@@ -198,4 +193,19 @@ public class MediaOutputSlice implements CustomSliceable {
|
||||
public Class getBackgroundWorkerClass() {
|
||||
return MediaDeviceUpdateWorker.class;
|
||||
}
|
||||
|
||||
private boolean isVisible() {
|
||||
// To decide Slice's visibility.
|
||||
// Return true if
|
||||
// 1. phone is not in ongoing call mode
|
||||
// 2. worker is not null
|
||||
// 3. Bluetooth is enabled
|
||||
final TelephonyManager telephonyManager =
|
||||
(TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||
|
||||
return telephonyManager.getCallState() == TelephonyManager.CALL_STATE_IDLE
|
||||
&& adapter.isEnabled()
|
||||
&& getWorker() != null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user