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

Commit 8c3041d1 authored by Rajeev Kumar's avatar Rajeev Kumar Committed by Android (Google) Code Review
Browse files

Merge "Update Quick Settings footer and dialog text for a financed device" into sc-dev

parents fbefbb64 a9ad16f1
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -38,7 +38,6 @@
                android:id="@+id/device_management_subtitle"
                android:id="@+id/device_management_subtitle"
                android:layout_width="match_parent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/monitoring_title_device_owned"
                style="@style/DeviceManagementDialogTitle"
                style="@style/DeviceManagementDialogTitle"
                android:paddingBottom="@dimen/qs_footer_dialog_subtitle_padding"
                android:paddingBottom="@dimen/qs_footer_dialog_subtitle_padding"
            />
            />
+9 −0
Original line number Original line Diff line number Diff line
@@ -1257,6 +1257,9 @@
    <!-- Disclosure at the bottom of Quick Settings that indicates that the user's device belongs to their organization, and the organization can monitor network traffic on that device. The placeholder is the organization's name. [CHAR LIMIT=100] -->
    <!-- Disclosure at the bottom of Quick Settings that indicates that the user's device belongs to their organization, and the organization can monitor network traffic on that device. The placeholder is the organization's name. [CHAR LIMIT=100] -->
    <string name="quick_settings_disclosure_named_management_monitoring"><xliff:g id="organization_name" example="Foo, Inc.">%1$s</xliff:g> owns this device and may monitor network traffic</string>
    <string name="quick_settings_disclosure_named_management_monitoring"><xliff:g id="organization_name" example="Foo, Inc.">%1$s</xliff:g> owns this device and may monitor network traffic</string>


    <!-- Disclosure at the bottom of Quick Settings that indicates that the user's financed device belongs to the Creditor. The placeholder is the Creditor's name. [CHAR LIMIT=100] -->
    <string name="quick_settings_financed_disclosure_named_management">This device is provided by <xliff:g id="organization_name" example="Foo, Inc.">%s</xliff:g></string>

    <!-- Disclosure at the bottom of Quick Settings that indicates that the user's device belongs to their organization, and the device is connected to a VPN. The placeholder is the VPN name. [CHAR LIMIT=100] -->
    <!-- Disclosure at the bottom of Quick Settings that indicates that the user's device belongs to their organization, and the device is connected to a VPN. The placeholder is the VPN name. [CHAR LIMIT=100] -->
    <string name="quick_settings_disclosure_management_named_vpn">This device belongs to your organization and is connected to <xliff:g id="vpn_app" example="Foo VPN App">%1$s</xliff:g></string>
    <string name="quick_settings_disclosure_management_named_vpn">This device belongs to your organization and is connected to <xliff:g id="vpn_app" example="Foo VPN App">%1$s</xliff:g></string>


@@ -1296,6 +1299,9 @@
    <!-- Disclosure at the bottom of Quick Settings that indicates that the device is connected to a VPN. The placeholder is the VPN name. [CHAR LIMIT=100] -->
    <!-- Disclosure at the bottom of Quick Settings that indicates that the device is connected to a VPN. The placeholder is the VPN name. [CHAR LIMIT=100] -->
    <string name="quick_settings_disclosure_named_vpn">This device is connected to <xliff:g id="vpn_app" example="Foo VPN App">%1$s</xliff:g></string>
    <string name="quick_settings_disclosure_named_vpn">This device is connected to <xliff:g id="vpn_app" example="Foo VPN App">%1$s</xliff:g></string>


    <!-- Monitoring dialog title for financed device [CHAR LIMIT=60] -->
    <string name="monitoring_title_financed_device">This device is provided by <xliff:g id="organization_name" example="Foo, Inc.">%s</xliff:g></string>

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


@@ -1330,6 +1336,9 @@
    <!-- Dialog that a user can access via Quick Settings. The dialog describes what the IT admin can monitor (and the changes they can make) on the user's device. [CHAR LIMIT=NONE]-->
    <!-- Dialog that a user can access via Quick Settings. The dialog describes what the IT admin can monitor (and the changes they can make) on the user's device. [CHAR LIMIT=NONE]-->
    <string name="monitoring_description_named_management">This device belongs to <xliff:g id="organization_name" example="Foo, Inc.">%1$s</xliff:g>.\n\nYour IT admin can monitor and manage settings, corporate access, apps, data associated with your device, and your device\'s location information.\n\nFor more information, contact your IT admin.</string>
    <string name="monitoring_description_named_management">This device belongs to <xliff:g id="organization_name" example="Foo, Inc.">%1$s</xliff:g>.\n\nYour IT admin can monitor and manage settings, corporate access, apps, data associated with your device, and your device\'s location information.\n\nFor more information, contact your IT admin.</string>


    <!-- Dialog that a user can access via Quick Settings. The dialog describes what a Creditor can monitor (and the changes they can make) on the user's financed device. [CHAR LIMIT=NONE]-->
    <string name="monitoring_financed_description_named_management"><xliff:g id="organization_name" example="Foo, Inc.">%1$s</xliff:g> may be able to access data associated with this device and change this device\’s settings.\n\nIf you have questions, contact <xliff:g id="organization_name" example="Foo, Inc.">%2$s</xliff:g>.</string>

    <!-- Dialog that a user can access via Quick Settings. The dialog describes what the IT admin can monitor (and the changes they can make) on the user's device. [CHAR LIMIT=NONE]-->
    <!-- Dialog that a user can access via Quick Settings. The dialog describes what the IT admin can monitor (and the changes they can make) on the user's device. [CHAR LIMIT=NONE]-->
    <string name="monitoring_description_management">This device belongs to your organization.\n\nYour IT admin can monitor and manage settings, corporate access, apps, data associated with your device, and your device\'s location information.\n\nFor more information, contact your IT admin.</string>
    <string name="monitoring_description_management">This device belongs to your organization.\n\nYour IT admin can monitor and manage settings, corporate access, apps, data associated with your device, and your device\'s location information.\n\nFor more information, contact your IT admin.</string>


+36 −9
Original line number Original line Diff line number Diff line
@@ -15,6 +15,8 @@
 */
 */
package com.android.systemui.qs;
package com.android.systemui.qs;


import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;

import static com.android.systemui.qs.dagger.QSFragmentModule.QS_SECURITY_FOOTER_VIEW;
import static com.android.systemui.qs.dagger.QSFragmentModule.QS_SECURITY_FOOTER_VIEW;


import android.app.AlertDialog;
import android.app.AlertDialog;
@@ -244,8 +246,14 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
            if (organizationName == null) {
            if (organizationName == null) {
                return mContext.getString(R.string.quick_settings_disclosure_management);
                return mContext.getString(R.string.quick_settings_disclosure_management);
            }
            }
            if (isFinancedDevice()) {
                return mContext.getString(
                        R.string.quick_settings_financed_disclosure_named_management,
                        organizationName);
            } else {
                return mContext.getString(R.string.quick_settings_disclosure_named_management,
                return mContext.getString(R.string.quick_settings_disclosure_named_management,
                        organizationName);
                        organizationName);
            }
        } // end if(isDeviceManaged)
        } // end if(isDeviceManaged)
        if (hasCACertsInWorkProfile) {
        if (hasCACertsInWorkProfile) {
            if (workProfileOrganizationName == null) {
            if (workProfileOrganizationName == null) {
@@ -355,6 +363,10 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
                .inflate(R.layout.quick_settings_footer_dialog, null, false);
                .inflate(R.layout.quick_settings_footer_dialog, null, false);


        // device management section
        // device management section
        TextView deviceManagementSubtitle =
                dialogView.findViewById(R.id.device_management_subtitle);
        deviceManagementSubtitle.setText(getManagementTitle(deviceOwnerOrganization));

        CharSequence managementMessage = getManagementMessage(isDeviceManaged,
        CharSequence managementMessage = getManagementMessage(isDeviceManaged,
                deviceOwnerOrganization, isProfileOwnerOfOrganizationOwnedDevice,
                deviceOwnerOrganization, isProfileOwnerOfOrganizationOwnedDevice,
                workProfileOrganizationName);
                workProfileOrganizationName);
@@ -468,7 +480,8 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
        }
        }
    }
    }


    private String getSettingsButton() {
    @VisibleForTesting
    String getSettingsButton() {
        return mContext.getString(R.string.monitoring_button_view_policies);
        return mContext.getString(R.string.monitoring_button_view_policies);
    }
    }


@@ -490,8 +503,13 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
            return null;
            return null;
        }
        }
        if (isDeviceManaged && organizationName != null) {
        if (isDeviceManaged && organizationName != null) {
            if (isFinancedDevice()) {
                return mContext.getString(R.string.monitoring_financed_description_named_management,
                        organizationName, organizationName);
            } else {
                return mContext.getString(
                return mContext.getString(
                        R.string.monitoring_description_named_management, organizationName);
                        R.string.monitoring_description_named_management, organizationName);
            }
        } else if (isProfileOwnerOfOrganizationOwnedDevice && workProfileOrganizationName != null) {
        } else if (isProfileOwnerOfOrganizationOwnedDevice && workProfileOrganizationName != null) {
            return mContext.getString(
            return mContext.getString(
                    R.string.monitoring_description_named_management, workProfileOrganizationName);
                    R.string.monitoring_description_named_management, workProfileOrganizationName);
@@ -557,12 +575,21 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
        return message;
        return message;
    }
    }


    private int getTitle(String deviceOwner) {
    @VisibleForTesting
        if (deviceOwner != null) {
    CharSequence getManagementTitle(CharSequence deviceOwnerOrganization) {
            return R.string.monitoring_title_device_owned;
        if (deviceOwnerOrganization != null && isFinancedDevice()) {
            return mContext.getString(R.string.monitoring_title_financed_device,
                    deviceOwnerOrganization);
        } else {
        } else {
            return R.string.monitoring_title;
            return mContext.getString(R.string.monitoring_title_device_owned);
        }
    }
    }

    private boolean isFinancedDevice() {
        return mSecurityController.isDeviceManaged()
                && mSecurityController.getDeviceOwnerType(
                        mSecurityController.getDeviceOwnerComponentOnAnyUser())
                == DEVICE_OWNER_TYPE_FINANCED;
    }
    }


    private final Runnable mUpdateIcon = new Runnable() {
    private final Runnable mUpdateIcon = new Runnable() {
+5 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.policy;
package com.android.systemui.statusbar.policy;


import android.app.admin.DeviceAdminInfo;
import android.app.admin.DeviceAdminInfo;
import android.content.ComponentName;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;


import com.android.systemui.Dumpable;
import com.android.systemui.Dumpable;
@@ -33,6 +34,10 @@ public interface SecurityController extends CallbackController<SecurityControlle
    String getProfileOwnerName();
    String getProfileOwnerName();
    CharSequence getDeviceOwnerOrganizationName();
    CharSequence getDeviceOwnerOrganizationName();
    CharSequence getWorkProfileOrganizationName();
    CharSequence getWorkProfileOrganizationName();
    /** Device owner component even if not on this user. **/
    ComponentName getDeviceOwnerComponentOnAnyUser();
    /** Device owner type for a device owner. **/
    int getDeviceOwnerType(ComponentName admin);
    boolean isNetworkLoggingEnabled();
    boolean isNetworkLoggingEnabled();
    boolean isVpnEnabled();
    boolean isVpnEnabled();
    boolean isVpnRestricted();
    boolean isVpnRestricted();
+14 −0
Original line number Original line Diff line number Diff line
@@ -15,9 +15,11 @@
 */
 */
package com.android.systemui.statusbar.policy;
package com.android.systemui.statusbar.policy;


import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.admin.DeviceAdminInfo;
import android.app.admin.DeviceAdminInfo;
import android.app.admin.DevicePolicyManager;
import android.app.admin.DevicePolicyManager;
import android.app.admin.DevicePolicyManager.DeviceOwnerType;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
@@ -224,6 +226,18 @@ public class SecurityControllerImpl extends CurrentUserTracker implements Securi
        return null;
        return null;
    }
    }


    @Override
    @Nullable
    public ComponentName getDeviceOwnerComponentOnAnyUser() {
        return mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser();
    }

    @Override
    @DeviceOwnerType
    public int getDeviceOwnerType(@NonNull ComponentName admin) {
        return mDevicePolicyManager.getDeviceOwnerType(admin);
    }

    @Override
    @Override
    public boolean isNetworkLoggingEnabled() {
    public boolean isNetworkLoggingEnabled() {
        return mDevicePolicyManager.isNetworkLoggingEnabled(null);
        return mDevicePolicyManager.isNetworkLoggingEnabled(null);
Loading