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

Commit 24ac55e6 authored by Selim Cinek's avatar Selim Cinek
Browse files

Added a warning when the profile has an owner

Also fixed a bug where a post in the QSFooter
was not always on the mainthread leading to a
crash.

Bug: 17066115
Change-Id: Iea9e1032973058ed5e63e70da4dc0bcf34fa59a3
parent e6afe9c7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2456,10 +2456,10 @@ public class DevicePolicyManager {
     * @throws IllegalArgumentException if the userId is invalid.
     */
    @SystemApi
    public String getProfileOwnerNameAsUser(UserHandle user) throws IllegalArgumentException {
    public String getProfileOwnerNameAsUser(int userId) throws IllegalArgumentException {
        if (mService != null) {
            try {
                return mService.getProfileOwnerName(user.getIdentifier());
                return mService.getProfileOwnerName(userId);
            } catch (RemoteException re) {
                Log.w(TAG, "Failed to get profile owner");
                throw new IllegalArgumentException(
+24 −0
Original line number Diff line number Diff line
@@ -837,12 +837,18 @@
    <!-- Footer device owned text [CHAR LIMIT=50] -->
    <string name="device_owned_footer">Device may be monitored</string>

    <!-- Footer profile owned text [CHAR LIMIT=50] -->
    <string name="profile_owned_footer">Profile may be monitored</string>

    <!-- Footer vpn present text [CHAR LIMIT=50] -->
    <string name="vpn_footer">Network may be monitored</string>

    <!-- Monitoring dialog title for device owned devices [CHAR LIMIT=35] -->
    <string name="monitoring_title_device_owned">Device monitoring</string>

    <!-- Monitoring dialog title for profile owned devices [CHAR LIMIT=35] -->
    <string name="monitoring_title_profile_owned">Profile monitoring</string>

    <!-- Monitoring dialog title for normal devices  [CHAR LIMIT=35]-->
    <string name="monitoring_title">Network monitoring</string>

@@ -867,6 +873,24 @@
    <!-- Monitoring dialog legacy VPN with device owner text [CHAR LIMIT=300] -->
    <string name="monitoring_description_legacy_vpn_device_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you\'re connected to a VPN (\"<xliff:g id="application">%2$s</xliff:g>\"). Your VPN service provider can monitor network activity too.</string>

    <!-- Monitoring dialog profile owner body text [CHAR LIMIT=300] -->
    <string name="monitoring_description_profile_owned">This profile is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator can monitor your device and network activity, including emails, apps and secure websites.\n\nFor more information, contact your administrator.</string>

    <!-- Monitoring dialog device and profile owner body text [CHAR LIMIT=300] -->
    <string name="monitoring_description_device_and_profile_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\nYour profile is managed by:\n<xliff:g id="organization">%2$s</xliff:g>\n\nYour administrator can monitor your device and network activity, including emails, apps and secure websites.\n\nFor more information, contact your administrator.</string>

    <!-- Monitoring dialog non-legacy VPN with profile owner text [CHAR LIMIT=300] -->
    <string name="monitoring_description_vpn_profile_owned">This profile is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you gave \"<xliff:g id="application">%2$s</xliff:g>\" permission to set up a VPN connection. This app can monitor network activity too.</string>

    <!-- Monitoring dialog legacy VPN with profile owner text [CHAR LIMIT=300] -->
    <string name="monitoring_description_legacy_vpn_profile_owned">This profile is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you\'re connected to a VPN (\"<xliff:g id="application">%2$s</xliff:g>\"). Your VPN service provider can monitor network activity too.</string>

    <!-- Monitoring dialog non-legacy VPN with device and profile owner text [CHAR LIMIT=300] -->
    <string name="monitoring_description_vpn_device_and_profile_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\nYour profile is managed by:\n<xliff:g id="organization">%2$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you gave \"<xliff:g id="application">%3$s</xliff:g>\" permission to set up a VPN connection. This app can monitor network activity too.</string>

    <!-- Monitoring dialog legacy VPN with device and profile owner text [CHAR LIMIT=300] -->
    <string name="monitoring_description_legacy_vpn_device_and_profile_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\nYour profile is managed by:\n<xliff:g id="organization">%2$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you\'re connected to a VPN (\"<xliff:g id="application">%3$s</xliff:g>\"). Your VPN service provider can monitor network activity too.</string>

    <!-- Indication on the keyguard that appears when the user disables trust agents until the next time they unlock manually. [CHAR LIMIT=NONE] -->
    <string name="keyguard_indication_trust_disabled">Device will stay locked until you manually unlock</string>

+60 −12
Original line number Diff line number Diff line
@@ -24,11 +24,9 @@ import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

@@ -37,7 +35,6 @@ import com.android.systemui.R;
import com.android.systemui.statusbar.phone.QSTileHost;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.SecurityController;
import com.android.systemui.statusbar.policy.SecurityController.VpnCallback;

public class QSFooter implements OnClickListener, DialogInterface.OnClickListener {
    protected static final String TAG = "QSFooter";
@@ -53,6 +50,7 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
    private AlertDialog mDialog;
    private QSTileHost mHost;
    private Handler mHandler;
    private final Handler mMainHandler;

    private boolean mIsVisible;
    private boolean mIsIconVisible;
@@ -65,6 +63,7 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
        mFooterText = (TextView) mRootView.findViewById(R.id.footer_text);
        mFooterIcon = (ImageView) mRootView.findViewById(R.id.footer_icon);
        mContext = context;
        mMainHandler = new Handler();
    }

    public void setHost(QSTileHost host) {
@@ -113,14 +112,19 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
            mFooterTextId = R.string.device_owned_footer;
            mIsVisible = true;
            mIsIconVisible = false;
        } else if (mSecurityController.hasProfileOwner()) {
            mFooterTextId = R.string.profile_owned_footer;
            mIsVisible = true;
            mIsIconVisible = false;
        } else if (mSecurityController.isVpnEnabled()) {
            mFooterTextId = R.string.vpn_footer;
            mIsVisible = true;
            mIsIconVisible = true;
        } else {
            mIsVisible = false;
            mIsIconVisible = false;
        }
        mRootView.post(mUpdateDisplayState);
        mMainHandler.post(mUpdateDisplayState);
    }

    @Override
@@ -155,6 +159,28 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene

    private String getMessage() {
        if (mSecurityController.hasDeviceOwner()) {
            if (mSecurityController.hasProfileOwner()) {
                if (mSecurityController.isVpnEnabled()) {
                    if (mSecurityController.isLegacyVpn()) {
                        return mContext.getString(
                                R.string.monitoring_description_legacy_vpn_device_and_profile_owned,
                                mSecurityController.getDeviceOwnerName(),
                                mSecurityController.getProfileOwnerName(),
                                mSecurityController.getLegacyVpnName());
                    } else {
                        return mContext.getString(
                                R.string.monitoring_description_vpn_device_and_profile_owned,
                                mSecurityController.getDeviceOwnerName(),
                                mSecurityController.getProfileOwnerName(),
                                mSecurityController.getVpnApp());
                    }
                } else {
                    return mContext.getString(
                            R.string.monitoring_description_device_and_profile_owned,
                            mSecurityController.getDeviceOwnerName(),
                            mSecurityController.getProfileOwnerName());
                }
            } else {
                if (mSecurityController.isVpnEnabled()) {
                    if (mSecurityController.isLegacyVpn()) {
                        return mContext.getString(
@@ -170,6 +196,25 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
                    return mContext.getString(R.string.monitoring_description_device_owned,
                            mSecurityController.getDeviceOwnerName());
                }
            }
        } else if (mSecurityController.hasProfileOwner()) {
            if (mSecurityController.isVpnEnabled()) {
                if (mSecurityController.isLegacyVpn()) {
                    return mContext.getString(
                            R.string.monitoring_description_legacy_vpn_profile_owned,
                            mSecurityController.getProfileOwnerName(),
                            mSecurityController.getLegacyVpnName());
                } else {
                    return mContext.getString(
                            R.string.monitoring_description_vpn_profile_owned,
                            mSecurityController.getProfileOwnerName(),
                            mSecurityController.getVpnApp());
                }
            } else {
                return mContext.getString(
                        R.string.monitoring_description_profile_owned,
                        mSecurityController.getProfileOwnerName());
            }
        } else {
            if (mSecurityController.isLegacyVpn()) {
                return mContext.getString(R.string.monitoring_description_legacy_vpn,
@@ -186,6 +231,9 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
        if (mSecurityController.hasDeviceOwner()) {
            return R.string.monitoring_title_device_owned;
        }
        if (mSecurityController.hasProfileOwner()) {
            return R.string.monitoring_title_profile_owned;
        }
        return R.string.monitoring_title;
    }

@@ -200,9 +248,9 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
        }
    };

    private class Callback implements VpnCallback {
    private class Callback implements SecurityController.SecurityControllerCallback {
        @Override
        public void onVpnStateChanged() {
        public void onStateChanged() {
            refreshState();
        }
    }
+1 −0
Original line number Diff line number Diff line
@@ -119,6 +119,7 @@ public class QSTileHost implements QSTile.Host {
                for (QSTile<?> tile : mTiles.values()) {
                    tile.userSwitch(newUserId);
                }
                mSecurity.onUserSwitched(newUserId);
                mObserver.register();
            }
        };
+7 −4
Original line number Diff line number Diff line
@@ -18,18 +18,21 @@ package com.android.systemui.statusbar.policy;
public interface SecurityController {

    boolean hasDeviceOwner();
    boolean hasProfileOwner();
    String getDeviceOwnerName();
    String getProfileOwnerName();
    boolean isVpnEnabled();
    String getVpnApp();
    boolean isLegacyVpn();
    String getLegacyVpnName();
    void disconnectFromVpn();
    void onUserSwitched(int newUserId);

    void addCallback(VpnCallback callback);
    void removeCallback(VpnCallback callback);
    void addCallback(SecurityControllerCallback callback);
    void removeCallback(SecurityControllerCallback callback);

    public interface VpnCallback {
        void onVpnStateChanged();
    public interface SecurityControllerCallback {
        void onStateChanged();
    }

}
Loading