am 2ba9fc1b: am e810b397: am 49541edb: am 77566dd1: Merge "Use BluetoothController for status bar icon status" into mnc-dev
* commit '2ba9fc1ba7b4f1bd19a9254ea280f66770443dc4': Use BluetoothController for status bar icon status
This commit is contained in:
@@ -603,7 +603,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
|
|
||||||
// Lastly, call to the icon policy to install/update all the icons.
|
// Lastly, call to the icon policy to install/update all the icons.
|
||||||
mIconPolicy = new PhoneStatusBarPolicy(mContext, mCastController, mHotspotController,
|
mIconPolicy = new PhoneStatusBarPolicy(mContext, mCastController, mHotspotController,
|
||||||
mUserInfoController);
|
mUserInfoController, mBluetoothController);
|
||||||
mIconPolicy.setCurrentUserSetup(mUserSetup);
|
mIconPolicy.setCurrentUserSetup(mUserSetup);
|
||||||
mSettingsObserver.onChange(false); // set up
|
mSettingsObserver.onChange(false); // set up
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import android.app.AlarmManager;
|
|||||||
import android.app.AlarmManager.AlarmClockInfo;
|
import android.app.AlarmManager.AlarmClockInfo;
|
||||||
import android.app.IUserSwitchObserver;
|
import android.app.IUserSwitchObserver;
|
||||||
import android.app.StatusBarManager;
|
import android.app.StatusBarManager;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -41,6 +40,8 @@ import com.android.internal.telephony.IccCardConstants;
|
|||||||
import com.android.internal.telephony.TelephonyIntents;
|
import com.android.internal.telephony.TelephonyIntents;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.qs.tiles.DndTile;
|
import com.android.systemui.qs.tiles.DndTile;
|
||||||
|
import com.android.systemui.statusbar.policy.BluetoothController;
|
||||||
|
import com.android.systemui.statusbar.policy.BluetoothController.Callback;
|
||||||
import com.android.systemui.statusbar.policy.CastController;
|
import com.android.systemui.statusbar.policy.CastController;
|
||||||
import com.android.systemui.statusbar.policy.CastController.CastDevice;
|
import com.android.systemui.statusbar.policy.CastController.CastDevice;
|
||||||
import com.android.systemui.statusbar.policy.HotspotController;
|
import com.android.systemui.statusbar.policy.HotspotController;
|
||||||
@@ -51,7 +52,7 @@ import com.android.systemui.statusbar.policy.UserInfoController;
|
|||||||
* bar at boot time. It goes through the normal API for icons, even though it probably
|
* bar at boot time. It goes through the normal API for icons, even though it probably
|
||||||
* strictly doesn't need to.
|
* strictly doesn't need to.
|
||||||
*/
|
*/
|
||||||
public class PhoneStatusBarPolicy {
|
public class PhoneStatusBarPolicy implements Callback {
|
||||||
private static final String TAG = "PhoneStatusBarPolicy";
|
private static final String TAG = "PhoneStatusBarPolicy";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
|
||||||
@@ -82,12 +83,11 @@ public class PhoneStatusBarPolicy {
|
|||||||
|
|
||||||
private int mZen;
|
private int mZen;
|
||||||
|
|
||||||
private boolean mBluetoothEnabled = false;
|
|
||||||
|
|
||||||
private boolean mManagedProfileFocused = false;
|
private boolean mManagedProfileFocused = false;
|
||||||
private boolean mManagedProfileIconVisible = true;
|
private boolean mManagedProfileIconVisible = true;
|
||||||
|
|
||||||
private boolean mKeyguardVisible = true;
|
private boolean mKeyguardVisible = true;
|
||||||
|
private BluetoothController mBluetooth;
|
||||||
|
|
||||||
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
@@ -96,10 +96,6 @@ public class PhoneStatusBarPolicy {
|
|||||||
if (action.equals(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)) {
|
if (action.equals(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)) {
|
||||||
updateAlarm();
|
updateAlarm();
|
||||||
}
|
}
|
||||||
else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) ||
|
|
||||||
action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
|
|
||||||
updateBluetooth();
|
|
||||||
}
|
|
||||||
else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) ||
|
else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) ||
|
||||||
action.equals(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION)) {
|
action.equals(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION)) {
|
||||||
updateVolumeZen();
|
updateVolumeZen();
|
||||||
@@ -114,10 +110,12 @@ public class PhoneStatusBarPolicy {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public PhoneStatusBarPolicy(Context context, CastController cast, HotspotController hotspot,
|
public PhoneStatusBarPolicy(Context context, CastController cast, HotspotController hotspot,
|
||||||
UserInfoController userInfoController) {
|
UserInfoController userInfoController, BluetoothController bluetooth) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mCast = cast;
|
mCast = cast;
|
||||||
mHotspot = hotspot;
|
mHotspot = hotspot;
|
||||||
|
mBluetooth = bluetooth;
|
||||||
|
mBluetooth.addStateChangedCallback(this);
|
||||||
mService = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE);
|
mService = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE);
|
||||||
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
mUserInfoController = userInfoController;
|
mUserInfoController = userInfoController;
|
||||||
@@ -127,8 +125,6 @@ public class PhoneStatusBarPolicy {
|
|||||||
filter.addAction(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED);
|
filter.addAction(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED);
|
||||||
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
|
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
|
||||||
filter.addAction(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION);
|
filter.addAction(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION);
|
||||||
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
|
|
||||||
filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
|
|
||||||
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
|
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
|
||||||
filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED);
|
filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED);
|
||||||
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
|
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
|
||||||
@@ -275,23 +271,31 @@ public class PhoneStatusBarPolicy {
|
|||||||
updateAlarm();
|
updateAlarm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBluetoothDevicesChanged() {
|
||||||
|
updateBluetooth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBluetoothStateChange(boolean enabled) {
|
||||||
|
updateBluetooth();
|
||||||
|
}
|
||||||
|
|
||||||
private final void updateBluetooth() {
|
private final void updateBluetooth() {
|
||||||
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
|
||||||
int iconId = R.drawable.stat_sys_data_bluetooth;
|
int iconId = R.drawable.stat_sys_data_bluetooth;
|
||||||
String contentDescription =
|
String contentDescription =
|
||||||
mContext.getString(R.string.accessibility_quick_settings_bluetooth_on);
|
mContext.getString(R.string.accessibility_quick_settings_bluetooth_on);
|
||||||
if (adapter != null) {
|
boolean bluetoothEnabled = false;
|
||||||
mBluetoothEnabled = (adapter.getState() == BluetoothAdapter.STATE_ON);
|
if (mBluetooth != null) {
|
||||||
if (adapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED) {
|
bluetoothEnabled = mBluetooth.isBluetoothEnabled();
|
||||||
|
if (mBluetooth.isBluetoothConnected()) {
|
||||||
iconId = R.drawable.stat_sys_data_bluetooth_connected;
|
iconId = R.drawable.stat_sys_data_bluetooth_connected;
|
||||||
contentDescription = mContext.getString(R.string.accessibility_bluetooth_connected);
|
contentDescription = mContext.getString(R.string.accessibility_bluetooth_connected);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
mBluetoothEnabled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mService.setIcon(SLOT_BLUETOOTH, iconId, 0, contentDescription);
|
mService.setIcon(SLOT_BLUETOOTH, iconId, 0, contentDescription);
|
||||||
mService.setIconVisibility(SLOT_BLUETOOTH, mBluetoothEnabled);
|
mService.setIconVisibility(SLOT_BLUETOOTH, bluetoothEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void updateTTY(Intent intent) {
|
private final void updateTTY(Intent intent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user