Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f045007 authored by Bartosz Fabianowski's avatar Bartosz Fabianowski
Browse files

Add enterprise disclosure to Keyguard screen

With this CL, a disclosure text is shown on the Keyguard screen when
a Device Owner is managing the device.

Bug: 32692748
Test: runtest --path frameworks/base/packages/SystemUI/tests

Change-Id: I7a48df7dc010c39b2db94fcd26b75313a7ceee08
parent 52a0daed
Loading
Loading
Loading
Loading
+26 −7
Original line number Diff line number Diff line
@@ -24,18 +24,37 @@
    android:outlineProvider="none"
    android:elevation="5dp" > <!-- Put it above the status bar header -->

    <com.android.systemui.statusbar.phone.KeyguardIndicationTextView
        android:id="@+id/keyguard_indication_text"
    <LinearLayout
        android:id="@+id/keyguard_indication_area"
        android:forceHasOverlappingRendering="false"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/keyguard_indication_margin_bottom"
        android:layout_gravity="bottom|center_horizontal"
        android:orientation="vertical">

        <com.android.systemui.statusbar.phone.KeyguardIndicationTextView
            android:id="@+id/keyguard_indication_enterprise_disclosure"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:textStyle="italic"
            android:textColor="#ffffff"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:visibility="gone" />

        <com.android.systemui.statusbar.phone.KeyguardIndicationTextView
            android:id="@+id/keyguard_indication_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:textStyle="italic"
            android:textColor="#ffffff"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:accessibilityLiveRegion="polite" />

    </LinearLayout>

    <FrameLayout
        android:id="@+id/preview_container"
        android:layout_width="match_parent"
+6 −0
Original line number Diff line number Diff line
@@ -840,6 +840,12 @@
    <!-- Shows when people have pressed the unlock icon to explain how to unlock. [CHAR LIMIT=60] -->
    <string name="keyguard_unlock">Swipe up to unlock</string>

    <!-- Text on keyguard screen indicating that the device is enterprise-managed by a Device Owner [CHAR LIMIT=60] -->
    <string name="do_disclosure_generic">This device is managed</string>

    <!-- Text on keyguard screen indicating that the device is enterprise-managed by a Device Owner [CHAR LIMIT=40] -->
    <string name="do_disclosure_with_name">This device is managed by <xliff:g id="organization_name" example="Foo, Inc.">%s</xliff:g></string>

    <!-- Shows when people have clicked on the phone icon [CHAR LIMIT=60] -->
    <string name="phone_hint">Swipe from icon for phone</string>

+46 −4
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar;

import android.app.ActivityManager;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -36,6 +37,7 @@ import android.text.TextUtils;
import android.text.format.Formatter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

import com.android.internal.app.IBatteryStats;
import com.android.keyguard.KeyguardUpdateMonitor;
@@ -58,7 +60,9 @@ public class KeyguardIndicationController {
    private static final long TRANSIENT_FP_ERROR_TIMEOUT = 1300;

    private final Context mContext;
    private final ViewGroup mIndicationArea;
    private final KeyguardIndicationTextView mTextView;
    private final KeyguardIndicationTextView mDisclosure;
    private final UserManager mUserManager;
    private final IBatteryStats mBatteryInfo;

@@ -78,10 +82,16 @@ public class KeyguardIndicationController {
    private int mChargingWattage;
    private String mMessageToShowOnScreenOn;

    public KeyguardIndicationController(Context context, KeyguardIndicationTextView textView,
    private final DevicePolicyManager mDevicePolicyManager;

    public KeyguardIndicationController(Context context, ViewGroup indicationArea,
            LockIcon lockIcon) {
        mContext = context;
        mTextView = textView;
        mIndicationArea = indicationArea;
        mTextView = (KeyguardIndicationTextView) indicationArea.findViewById(
                R.id.keyguard_indication_text);
        mDisclosure = (KeyguardIndicationTextView) indicationArea.findViewById(
                R.id.keyguard_indication_enterprise_disclosure);
        mLockIcon = lockIcon;

        Resources res = context.getResources();
@@ -92,14 +102,39 @@ public class KeyguardIndicationController {
        mBatteryInfo = IBatteryStats.Stub.asInterface(
                ServiceManager.getService(BatteryStats.SERVICE_NAME));

        mDevicePolicyManager = (DevicePolicyManager) context.getSystemService(
                Context.DEVICE_POLICY_SERVICE);

        KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitor);
        context.registerReceiverAsUser(mTickReceiver, UserHandle.SYSTEM,
                new IntentFilter(Intent.ACTION_TIME_TICK), null, null);

        updateDisclosure();
    }

    private void updateDisclosure() {
        if (mDevicePolicyManager == null) {
            return;
        }

        if (mDevicePolicyManager.isDeviceManaged()) {
            final CharSequence organizationName =
                    mDevicePolicyManager.getDeviceOwnerOrganizationName();
            if (organizationName != null) {
                mDisclosure.switchIndication(mContext.getResources().getString(
                        R.string.do_disclosure_with_name, organizationName));
            } else {
                mDisclosure.switchIndication(R.string.do_disclosure_generic);
            }
            mDisclosure.setVisibility(View.VISIBLE);
        } else {
            mDisclosure.setVisibility(View.GONE);
        }
    }

    public void setVisible(boolean visible) {
        mVisible = visible;
        mTextView.setVisibility(visible ? View.VISIBLE : View.GONE);
        mIndicationArea.setVisibility(visible ? View.VISIBLE : View.GONE);
        if (visible) {
            hideTransientIndication();
            updateIndication();
@@ -241,6 +276,13 @@ public class KeyguardIndicationController {
            updateIndication();
        }

        @Override
        public void onKeyguardVisibilityChanged(boolean showing) {
            if (showing) {
                updateDisclosure();
            }
        }

        @Override
        public void onFingerprintHelp(int msgId, String helpString) {
            KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+14 −6
Original line number Diff line number Diff line
@@ -107,6 +107,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    private KeyguardAffordanceView mRightAffordanceView;
    private KeyguardAffordanceView mLeftAffordanceView;
    private LockIcon mLockIcon;
    private ViewGroup mIndicationArea;
    private TextView mEnterpriseDisclosure;
    private TextView mIndicationText;
    private ViewGroup mPreviewContainer;

@@ -208,6 +210,9 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        mRightAffordanceView = (KeyguardAffordanceView) findViewById(R.id.camera_button);
        mLeftAffordanceView = (KeyguardAffordanceView) findViewById(R.id.left_button);
        mLockIcon = (LockIcon) findViewById(R.id.lock_icon);
        mIndicationArea = (ViewGroup) findViewById(R.id.keyguard_indication_area);
        mEnterpriseDisclosure = (TextView) findViewById(
                R.id.keyguard_indication_enterprise_disclosure);
        mIndicationText = (TextView) findViewById(R.id.keyguard_indication_text);
        watchForCameraPolicyChanges();
        updateCameraVisibility();
@@ -252,13 +257,16 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        super.onConfigurationChanged(newConfig);
        int indicationBottomMargin = getResources().getDimensionPixelSize(
                R.dimen.keyguard_indication_margin_bottom);
        MarginLayoutParams mlp = (MarginLayoutParams) mIndicationText.getLayoutParams();
        MarginLayoutParams mlp = (MarginLayoutParams) mIndicationArea.getLayoutParams();
        if (mlp.bottomMargin != indicationBottomMargin) {
            mlp.bottomMargin = indicationBottomMargin;
            mIndicationText.setLayoutParams(mlp);
            mIndicationArea.setLayoutParams(mlp);
        }

        // Respect font size setting.
        mEnterpriseDisclosure.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                getResources().getDimensionPixelSize(
                        com.android.internal.R.dimen.text_size_small_material));
        mIndicationText.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                getResources().getDimensionPixelSize(
                        com.android.internal.R.dimen.text_size_small_material));
@@ -595,8 +603,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        return mLockIcon;
    }

    public View getIndicationView() {
        return mIndicationText;
    public View getIndicationArea() {
        return mIndicationArea;
    }

    @Override
@@ -658,8 +666,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        if (mRightAffordanceView.getVisibility() == View.VISIBLE) {
            startFinishDozeAnimationElement(mRightAffordanceView, delay);
        }
        mIndicationText.setAlpha(0f);
        mIndicationText.animate()
        mIndicationArea.setAlpha(0f);
        mIndicationArea.animate()
                .alpha(1f)
                .setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN)
                .setDuration(NotificationPanelView.DOZE_ANIMATION_DURATION);
+2 −2
Original line number Diff line number Diff line
@@ -1006,14 +1006,14 @@ public abstract class PanelView extends FrameLayout {
        });
        animator.start();
        mHeightAnimator = animator;
        mKeyguardBottomArea.getIndicationView().animate()
        mKeyguardBottomArea.getIndicationArea().animate()
                .translationY(-mHintDistance)
                .setDuration(250)
                .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
                .withEndAction(new Runnable() {
                    @Override
                    public void run() {
                        mKeyguardBottomArea.getIndicationView().animate()
                        mKeyguardBottomArea.getIndicationArea().animate()
                                .translationY(0)
                                .setDuration(450)
                                .setInterpolator(mBounceInterpolator)
Loading