EmergencyCryptkeeperText: Make sure we update if airplane mode changes
Fixes a race condition that could case the emergency text to show when it should not, if airplane mode was queried before it was set by the radio layer. Change-Id: I146f2877e300d105d8a53af130be46b02ec965b2 Test: Boot into cryptkeeper with a SIM, verify that it does not show 'Emergency Calls Only' until emergency call is initiated. Fixes: 33278862 Fixes: 32063642
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package com.android.systemui.statusbar.policy;
|
package com.android.systemui.statusbar.policy;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
@@ -41,12 +42,20 @@ import java.util.List;
|
|||||||
public class EmergencyCryptkeeperText extends TextView {
|
public class EmergencyCryptkeeperText extends TextView {
|
||||||
|
|
||||||
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||||
private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
|
private final KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onPhoneStateChanged(int phoneState) {
|
public void onPhoneStateChanged(int phoneState) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(intent.getAction())) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public EmergencyCryptkeeperText(Context context, @Nullable AttributeSet attrs) {
|
public EmergencyCryptkeeperText(Context context, @Nullable AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@@ -58,6 +67,8 @@ public class EmergencyCryptkeeperText extends TextView {
|
|||||||
super.onAttachedToWindow();
|
super.onAttachedToWindow();
|
||||||
mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
|
mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
|
||||||
mKeyguardUpdateMonitor.registerCallback(mCallback);
|
mKeyguardUpdateMonitor.registerCallback(mCallback);
|
||||||
|
getContext().registerReceiver(mReceiver,
|
||||||
|
new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +78,7 @@ public class EmergencyCryptkeeperText extends TextView {
|
|||||||
if (mKeyguardUpdateMonitor != null) {
|
if (mKeyguardUpdateMonitor != null) {
|
||||||
mKeyguardUpdateMonitor.removeCallback(mCallback);
|
mKeyguardUpdateMonitor.removeCallback(mCallback);
|
||||||
}
|
}
|
||||||
|
getContext().unregisterReceiver(mReceiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
|||||||
Reference in New Issue
Block a user