Show PLMN on CryptKeeper

Also shows the state only once radio is enabled.

Fixes: 30301831
Change-Id: Iaf3b96c3622e20d8ada6e1f6391d6065101fb281
This commit is contained in:
Adrian Roos
2016-08-23 17:53:07 +02:00
parent 6f300c1729
commit 316bf54484
8 changed files with 251 additions and 14 deletions

View File

@@ -390,7 +390,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
}
/** @return List of SubscriptionInfo records, maybe empty but never null */
List<SubscriptionInfo> getSubscriptionInfo(boolean forceReload) {
public List<SubscriptionInfo> getSubscriptionInfo(boolean forceReload) {
List<SubscriptionInfo> sil = mSubscriptionInfo;
if (sil == null || forceReload) {
sil = mSubscriptionManager.getActiveSubscriptionInfoList();

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2016 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<com.android.systemui.statusbar.policy.EmergencyCryptkeeperText
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/emergency_cryptkeeper_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:paddingStart="6dp"
android:singleLine="true"
android:ellipsize="marquee"
android:gravity="center_vertical|start"
/>

View File

@@ -77,4 +77,11 @@
</com.android.keyguard.AlphaOptimizedLinearLayout>
</LinearLayout>
<ViewStub
android:id="@+id/emergency_cryptkeeper_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout="@layout/emergency_cryptkeeper_text"
/>
</com.android.systemui.statusbar.phone.PhoneStatusBarView>

View File

@@ -174,12 +174,14 @@ import com.android.systemui.statusbar.policy.BatteryControllerImpl;
import com.android.systemui.statusbar.policy.BluetoothControllerImpl;
import com.android.systemui.statusbar.policy.BrightnessMirrorController;
import com.android.systemui.statusbar.policy.CastControllerImpl;
import com.android.systemui.statusbar.policy.EncryptionHelper;
import com.android.systemui.statusbar.policy.FlashlightController;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.HotspotControllerImpl;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
import com.android.systemui.statusbar.policy.LocationControllerImpl;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkControllerImpl;
import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.PreviewInflater;
@@ -895,6 +897,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
initSignalCluster(mStatusBarView);
initSignalCluster(mKeyguardStatusBar);
initEmergencyCryptkeeperText();
mFlashlightController = new FlashlightController(mContext);
mKeyguardBottomArea.setFlashlightController(mFlashlightController);
@@ -1013,6 +1016,24 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
return mStatusBarView;
}
private void initEmergencyCryptkeeperText() {
View emergencyViewStub = mStatusBarWindow.findViewById(R.id.emergency_cryptkeeper_text);
if (mNetworkController.hasEmergencyCryptKeeperText()) {
if (emergencyViewStub != null) {
((ViewStub) emergencyViewStub).inflate();
}
mNetworkController.addSignalCallback(new NetworkController.SignalCallback() {
@Override
public void setIsAirplaneMode(NetworkController.IconState icon) {
recomputeDisableFlags(true /* animate */);
}
});
} else if (emergencyViewStub != null) {
ViewGroup parent = (ViewGroup) emergencyViewStub.getParent();
parent.removeView(emergencyViewStub);
}
}
protected BatteryController createBatteryController() {
return new BatteryControllerImpl(mContext);
}
@@ -2337,6 +2358,14 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
state |= StatusBarManager.DISABLE_NOTIFICATION_ICONS;
state |= StatusBarManager.DISABLE_SYSTEM_INFO;
}
if (mNetworkController != null && EncryptionHelper.IS_DATA_ENCRYPTED) {
if (mNetworkController.hasEmergencyCryptKeeperText()) {
state |= StatusBarManager.DISABLE_NOTIFICATION_ICONS;
}
if (!mNetworkController.isRadioOn()) {
state |= StatusBarManager.DISABLE_SYSTEM_INFO;
}
}
return state;
}
@@ -2441,6 +2470,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
}
/**
* Reapplies the disable flags as last requested by StatusBarManager.
*
* This needs to be called if state used by {@link #adjustDisableFlags} changes.
*/
private void recomputeDisableFlags(boolean animate) {
disable(mDisabledUnmodified1, mDisabledUnmodified2, animate);
}
@Override
protected BaseStatusBar.H createHandler() {
return new PhoneStatusBar.H();
@@ -2734,7 +2772,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
visibilityChanged(true);
mWaitingForKeyguardExit = false;
disable(mDisabledUnmodified1, mDisabledUnmodified2, !force /* animate */);
recomputeDisableFlags(!force /* animate */);
setInteracting(StatusBarManager.WINDOW_STATUS_BAR, true);
}
@@ -2876,7 +2914,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
runPostCollapseRunnables();
setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false);
showBouncer();
disable(mDisabledUnmodified1, mDisabledUnmodified2, true /* animate */);
recomputeDisableFlags(true /* animate */);
// Trimming will happen later if Keyguard is showing - doing it here might cause a jank in
// the bouncer appear animation.
@@ -4254,7 +4292,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
startTime + fadeoutDuration
- StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION,
StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION);
disable(mDisabledUnmodified1, mDisabledUnmodified2, fadeoutDuration > 0 /* animate */);
recomputeDisableFlags(fadeoutDuration > 0 /* animate */);
}
public boolean isKeyguardFadingAway() {
@@ -4739,7 +4777,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
public void setBouncerShowing(boolean bouncerShowing) {
super.setBouncerShowing(bouncerShowing);
mStatusBarView.setBouncerShowing(bouncerShowing);
disable(mDisabledUnmodified1, mDisabledUnmodified2, true /* animate */);
recomputeDisableFlags(true /* animate */);
}
public void onStartedGoingToSleep() {

View File

@@ -0,0 +1,124 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.systemui.statusbar.policy;
import android.annotation.Nullable;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.provider.Settings;
import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.TextView;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import java.util.List;
public class EmergencyCryptkeeperText extends TextView {
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
@Override
public void onPhoneStateChanged(int phoneState) {
update();
}
};
public EmergencyCryptkeeperText(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
setVisibility(GONE);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
mKeyguardUpdateMonitor.registerCallback(mCallback);
update();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (mKeyguardUpdateMonitor != null) {
mKeyguardUpdateMonitor.removeCallback(mCallback);
}
}
public void update() {
boolean hasMobile = ConnectivityManager.from(mContext)
.isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
boolean airplaneMode = (Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, 0) == 1);
if (!hasMobile || airplaneMode) {
setText(null);
setVisibility(GONE);
return;
}
boolean allSimsMissing = true;
CharSequence displayText = null;
List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
final int N = subs.size();
for (int i = 0; i < N; i++) {
int subId = subs.get(i).getSubscriptionId();
IccCardConstants.State simState = mKeyguardUpdateMonitor.getSimState(subId);
CharSequence carrierName = subs.get(i).getCarrierName();
if (simState.iccCardExist() && !TextUtils.isEmpty(carrierName)) {
allSimsMissing = false;
displayText = carrierName;
}
}
if (allSimsMissing) {
if (N != 0) {
// Shows "Emergency calls only" on devices that are voice-capable.
// This depends on mPlmn containing the text "Emergency calls only" when the radio
// has some connectivity. Otherwise it should show "No service"
// Grab the first subscription, because they all should contain the emergency text,
// described above.
displayText = subs.get(0).getCarrierName();
} else {
// We don't have a SubscriptionInfo to get the emergency calls only from.
// Grab it from the old sticky broadcast if possible instead. We can use it
// here because no subscriptions are active, so we don't have
// to worry about MSIM clashing.
displayText = getContext().getText(
com.android.internal.R.string.emergency_calls_only);
Intent i = getContext().registerReceiver(null,
new IntentFilter(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION));
if (i != null) {
displayText = i.getStringExtra(TelephonyIntents.EXTRA_PLMN);
}
}
}
setText(displayText);
setVisibility(TextUtils.isEmpty(displayText) ? GONE : VISIBLE);
}
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.systemui.statusbar.policy;
import android.os.SystemProperties;
/**
* Helper for determining whether the phone is decrypted yet.
*/
public class EncryptionHelper {
public static final boolean IS_DATA_ENCRYPTED = isDataEncrypted();
private static boolean isDataEncrypted() {
String voldState = SystemProperties.get("vold.decrypt");
return "1".equals(voldState) || "trigger_restart_min_framework".equals(voldState);
}
}

View File

@@ -41,20 +41,20 @@ public interface NetworkController {
void removeEmergencyListener(EmergencyListener listener);
public interface SignalCallback {
void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
boolean activityIn, boolean activityOut, String description);
default void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
boolean activityIn, boolean activityOut, String description) {}
void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
default void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
int qsType, boolean activityIn, boolean activityOut, String typeContentDescription,
String description, boolean isWide, int subId);
void setSubs(List<SubscriptionInfo> subs);
void setNoSims(boolean show);
String description, boolean isWide, int subId) {}
default void setSubs(List<SubscriptionInfo> subs) {}
default void setNoSims(boolean show) {}
void setEthernetIndicators(IconState icon);
default void setEthernetIndicators(IconState icon) {}
void setIsAirplaneMode(IconState icon);
default void setIsAirplaneMode(IconState icon) {}
void setMobileDataEnabled(boolean enabled);
default void setMobileDataEnabled(boolean enabled) {}
}
public interface EmergencyListener {

View File

@@ -819,6 +819,14 @@ public class NetworkControllerImpl extends BroadcastReceiver
return info;
}
public boolean hasEmergencyCryptKeeperText() {
return EncryptionHelper.IS_DATA_ENCRYPTED;
}
public boolean isRadioOn() {
return !mAirplaneMode;
}
private class SubListener extends OnSubscriptionsChangedListener {
@Override
public void onSubscriptionsChanged() {