diff options
author | Adrian Roos <roosa@google.com> | 2016-09-24 02:07:38 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-09-24 02:07:38 +0000 |
commit | 3b09d5028c2bda2bc38ff4c748ee2accfb4412f1 (patch) | |
tree | 070dcecf7aefba22199a1412b42e34a18f4e5b29 | |
parent | bb5985b9a542f700cbb620e75455582c0d2c28a3 (diff) | |
parent | 316bf544843ae581336fa157355c76774e0e0cbc (diff) |
Show PLMN on CryptKeeper
am: 316bf54484
Change-Id: Ia1e078cca8e29aa0f36b46daf74ce91ec1a90f48
8 files changed, 251 insertions, 14 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java index 60d9c39a6d23..8b220d4d63df 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -384,7 +384,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(); diff --git a/packages/SystemUI/res/layout/emergency_cryptkeeper_text.xml b/packages/SystemUI/res/layout/emergency_cryptkeeper_text.xml new file mode 100644 index 000000000000..0a1730a72920 --- /dev/null +++ b/packages/SystemUI/res/layout/emergency_cryptkeeper_text.xml @@ -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" + />
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/status_bar.xml b/packages/SystemUI/res/layout/status_bar.xml index 39c16d711897..63af3e0c9f30 100644 --- a/packages/SystemUI/res/layout/status_bar.xml +++ b/packages/SystemUI/res/layout/status_bar.xml @@ -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> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 714c88df182e..4283eb85addb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -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. @@ -4245,7 +4283,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() { @@ -4730,7 +4768,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() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/EmergencyCryptkeeperText.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/EmergencyCryptkeeperText.java new file mode 100644 index 000000000000..8abfb89b3f69 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/EmergencyCryptkeeperText.java @@ -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); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/EncryptionHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/EncryptionHelper.java new file mode 100644 index 000000000000..639e50cf4e58 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/EncryptionHelper.java @@ -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); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java index 348e0b003997..5f1b8719c9b0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java @@ -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 { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java index 7893a1a0880a..37e6a2ab8ead 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java @@ -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() { |