/*
 * Copyright (C) 2015 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.secspace.lib.common.utils;

import android.os.UserManager;


/**
 * Utility methods for user restrictions.
 * <p>
 * <p>See {@link UserManagerService} for the method suffixes.
 */
public class UserRestrictionsUtil {
    private static final String TAG = "UserRestrictionsUtil";

    private UserRestrictionsUtil() {
    }


    public static final String[] USER_RESTRICTIONS = new String[]{
            UserManager.DISALLOW_CONFIG_WIFI,
//            UserManager.DISALLOW_CONFIG_LOCALE,
//            UserManager.DISALLOW_MODIFY_ACCOUNTS,
//            UserManager.DISALLOW_INSTALL_APPS,
//            UserManager.DISALLOW_UNINSTALL_APPS,
//            UserManager.DISALLOW_SHARE_LOCATION,
//            UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,
            UserManager.DISALLOW_CONFIG_BLUETOOTH,
            UserManager.DISALLOW_BLUETOOTH,
            UserManager.DISALLOW_BLUETOOTH_SHARING,
            UserManager.DISALLOW_USB_FILE_TRANSFER,
//            UserManager.DISALLOW_CONFIG_CREDENTIALS,
//            UserManager.DISALLOW_REMOVE_USER,
//            UserManager.DISALLOW_REMOVE_MANAGED_PROFILE,
//            UserManager.DISALLOW_DEBUGGING_FEATURES,
//            UserManager.DISALLOW_CONFIG_VPN,
//            UserManager.DISALLOW_CONFIG_DATE_TIME,
            UserManager.DISALLOW_CONFIG_TETHERING,
//            UserManager.DISALLOW_NETWORK_RESET,
//            UserManager.DISALLOW_FACTORY_RESET,
//            UserManager.DISALLOW_ADD_USER,
//            UserManager.DISALLOW_ADD_MANAGED_PROFILE,
//            UserManager.ENSURE_VERIFY_APPS,
//            UserManager.DISALLOW_CONFIG_CELL_BROADCASTS,
            UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS,
//            UserManager.DISALLOW_APPS_CONTROL,
//            UserManager.DISALLOW_MOUNT_PHYSICAL_MEDIA,
//            UserManager.DISALLOW_UNMUTE_MICROPHONE,
//            UserManager.DISALLOW_ADJUST_VOLUME,
            UserManager.DISALLOW_OUTGOING_CALLS,
            UserManager.DISALLOW_SMS,
//            UserManager.DISALLOW_FUN,
//            UserManager.DISALLOW_CREATE_WINDOWS,
//            UserManager.DISALLOW_SYSTEM_ERROR_DIALOGS,
//            UserManager.DISALLOW_CROSS_PROFILE_COPY_PASTE,
//            UserManager.DISALLOW_OUTGOING_BEAM,
//            UserManager.DISALLOW_SAFE_BOOT,
//            UserManager.ALLOW_PARENT_PROFILE_APP_LINKING,
//            UserManager.DISALLOW_DATA_ROAMING,
//            UserManager.DISALLOW_SET_USER_ICON,
//            UserManager.DISALLOW_SET_WALLPAPER,
//            UserManager.DISALLOW_AUTOFILL,
//            UserManager.DISALLOW_USER_SWITCH,
//            UserManager.DISALLOW_UNIFIED_PASSWORD,
            UserManager.DISALLOW_CONFIG_LOCATION,
//            UserManager.DISALLOW_AIRPLANE_MODE,
//            UserManager.DISALLOW_CONFIG_BRIGHTNESS,
//            UserManager.DISALLOW_SHARE_INTO_MANAGED_PROFILE,
//            UserManager.DISALLOW_AMBIENT_DISPLAY,
//            UserManager.DISALLOW_CONFIG_SCREEN_TIMEOUT,
//            UserManager.DISALLOW_PRINTING
    };

    /**
     * User restrictions that cannot be set by profile owners of secondary users. When set by DO
     * they will be applied to all users.
     */
    private static final String[] PRIMARY_USER_ONLY_RESTRICTIONS = new String[]{
            UserManager.DISALLOW_BLUETOOTH,
            UserManager.DISALLOW_USB_FILE_TRANSFER,
            UserManager.DISALLOW_CONFIG_TETHERING,
            UserManager.DISALLOW_NETWORK_RESET,
            UserManager.DISALLOW_FACTORY_RESET,
            UserManager.DISALLOW_ADD_USER,
            UserManager.DISALLOW_CONFIG_CELL_BROADCASTS,
            UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS,
            UserManager.DISALLOW_MOUNT_PHYSICAL_MEDIA,
            UserManager.DISALLOW_SMS,
            UserManager.DISALLOW_FUN,
            UserManager.DISALLOW_SAFE_BOOT,
            UserManager.DISALLOW_CREATE_WINDOWS,
            UserManager.DISALLOW_DATA_ROAMING,
            UserManager.DISALLOW_AIRPLANE_MODE
    };

    /**
     * User restrictions that cannot be set by profile owners. Applied to all users.
     */
    private static final String[] DEVICE_OWNER_ONLY_RESTRICTIONS = new String[]{
            UserManager.DISALLOW_USER_SWITCH
    };


    /**
     * Special user restrictions that can be applied to a user as well as to all users globally,
     * depending on callers.  When device owner sets them, they'll be applied to all users.
     */
    private static final String[] GLOBAL_RESTRICTIONS = new String[]{
            UserManager.DISALLOW_ADJUST_VOLUME,
            UserManager.DISALLOW_BLUETOOTH_SHARING,
            UserManager.DISALLOW_CONFIG_DATE_TIME,
            UserManager.DISALLOW_SYSTEM_ERROR_DIALOGS,
            UserManager.DISALLOW_UNMUTE_MICROPHONE
    };

    /**
     * User restrictions that default to {@code true} for device owners.
     */
    private static final String[] DEFAULT_ENABLED_FOR_DEVICE_OWNERS = new String[]{
            UserManager.DISALLOW_ADD_MANAGED_PROFILE
    };

    /**
     * User restrictions that default to {@code true} for managed profile owners.
     * <p>
     * NB: {@link UserManager#DISALLOW_INSTALL_UNKNOWN_SOURCES} is also set by default but it is
     * not set to existing profile owners unless they used to have INSTALL_NON_MARKET_APPS disabled
     * in settings. So it is handled separately.
     */
    private static final String[] DEFAULT_ENABLED_FOR_MANAGED_PROFILES = new String[]{
            UserManager.DISALLOW_BLUETOOTH_SHARING
    };

    /**
     * Special user restrictions that are always applied to all users no matter who sets them.
     */
    private static final String[] PROFILE_GLOBAL_RESTRICTIONS = new String[]{
            UserManager.ENSURE_VERIFY_APPS,
            UserManager.DISALLOW_AIRPLANE_MODE
    };
}
