Since: API level 2
public class

BrowserPolicy

extends Object
java.lang.Object
   ↳ com.samsung.android.knox.browser.BrowserPolicy

Class Overview

This class provides APIs to control browser settings. The user cannot change the settings provided by this policy once the settings are disabled. The policies are applied only to Samsung browser. The policies do not apply to any third-party browser.

Since
API level 2
MDM 2.0

Summary

Public Methods
boolean addWebBookmarkBitmap(Uri uri, String title, Bitmap iconBm)
API to add a Web bookmark to the Android native Web browser by bitmap.
boolean addWebBookmarkByteBuffer(Uri uri, String title, byte[] iconBuffer)
API to add a Web bookmark to the Android native Web browser.
boolean clearHttpProxy()
API to clear Http Proxy setting.
boolean deleteWebBookmark(Uri uri, String title)
API to delete a Web bookmark from the Android native Web browser.
boolean getAutoFillSetting()
API to get the browser autofill setting.
boolean getCookiesSetting()
API to get the browser cookies setting.
boolean getForceFraudWarningSetting()
API to get the browser show security Warnings setting.
String getHttpProxy()
API to retrieve Http Proxy setting.
boolean getJavaScriptSetting()
API to get the browser JavaScript setting.
boolean getPopupsSetting()
API to get pop-up browser setting.
boolean setAutoFillSetting(boolean enable)
API to enable or disable the browser autofill setting.
boolean setCookiesSetting(boolean enable)
API to enable or disable the browser cookies setting.
boolean setForceFraudWarningSetting(boolean enable)
API to enable or disable the browser show security Warnings setting.
boolean setHttpProxy(String proxySetting)
API to set Http Proxy setting.
boolean setJavaScriptSetting(boolean enable)
API to enable or disable the browser JavaScript setting.
boolean setPopupsSetting(boolean enable)
API to enable or disable the pop-up browser setting.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public boolean addWebBookmarkBitmap (Uri uri, String title, Bitmap iconBm)

Since: API level 2

API to add a Web bookmark to the Android native Web browser by bitmap.

Parameters
uri The website URI to connect to it e.g: Uri uriBook = Uri.parse("http://www.google.com.br");
title A name for the bookmark.
iconBm The thumbnail representing the bookmark (optional). e.g :Bitmap iconBm = BitmapFactory.decodeFile("/data/system/brasil.png"); NOTE: This parameter will no longer be used from MDM 5.0 on, please pass null as value.
Returns
  • true if add a web bookmark success, else false.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely add a Web bookmark on the device. The setting icon is optional. NOTE: From MDM 5.0 on, setting icon for bookmarks is no longer supported.

  String uri = "http://www.google.com.br";
  String title = "BrasilBookmark";
  String imagePath = "/data/system/brasil.png";
  Uri uriBook = Uri.parse(uri);

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 BrowserPolicy browserPolicy = edm.getBrowserPolicy();
  try {
      Bitmap iconBm = BitmapFactory.decodeFile(imagePath);
      boolean result = browserPolicy.addWebBookmarkBitmap(uriBook,
                       title, iconBm);
      if(result == true){
          Log.d(TAG, "addWebBookmarkBitmap has succeeded!");
      }else {
        Log.d(TAG, "addWebBookmarkBitmap has failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
  String uri = "http://www.google.com.br";
  String title = "BrasilBookmark";
  String imagePath = "/data/system/brasil.png";
  Uri uriBook = Uri.parse(uri);

 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
 BrowserPolicy browserPolicy = kcm.getBrowserPolicy();
  try {
      Bitmap iconBm = BitmapFactory.decodeFile(imagePath);
      boolean result = browserPolicy.addWebBookmarkBitmap(uriBook,
                       title, iconBm);
      if(result == true){
          Log.d(TAG, "addWebBookmarkBitmap has succeeded!");
      }else {
        Log.d(TAG, "addWebBookmarkBitmap has failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 

Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_BROWSER_SETTINGS" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean addWebBookmarkByteBuffer (Uri uri, String title, byte[] iconBuffer)

Since: API level 2

API to add a Web bookmark to the Android native Web browser.

Parameters
uri The Web site URI to connect to it. For example, Uri uriBook = Uri.parse("http://www.google.com.br").
title A name for the bookmark.
iconBuffer The thumbnail representing the bookmark (optional). NOTE: This parameter will no longer be used from MDM 5.0 on, please pass null as value.
Returns
  • true if add a web bookmark was successful, else false.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely add a Web bookmark on the device. The setting icon is optional. NOTE: From MDM 5.0 on, setting icon for bookmarks is no longer supported.

  String uri = "http://www.google.com.br";
  String title  = "BrasilBookmark";
  String imagePath = "/data/system/brasil.png";
  Uri uriBook = Uri.parse(uri);
  
  //convert bitmap to bytes
  static byte[] bitmapToBytes(Bitmap bm) {
    if (bm == null) {
        return null;
    }
    final ByteArrayOutputStream os = new ByteArrayOutputStream();
    bm.compress(Bitmap.CompressFormat.PNG, 100, os);
    return os.toByteArray();
  }

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 BrowserPolicy browserPolicy = edm.getBrowserPolicy();
  
  try{
      Bitmap iconBm = BitmapFactory.decodeFile(imagePath);
      byte[] iconBuffer = bitmapToBytes(iconBm);
      boolean result = browserPolicy.addWebBookmarkByteBuffer(uriBook,
                       title, iconBuffer);

      if(result == true){
          Log.d(TAG, "addWebBookmarkByteBuffer has succeeded!");
      }else {
          Log.d(TAG,"addWebBookmarkByteBuffer has failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
  String uri = "http://www.google.com.br";
  String title  = "BrasilBookmark";
  String imagePath = "/data/system/brasil.png";
  Uri uriBook = Uri.parse(uri);
  
  //convert bitmap to bytes
  static byte[] bitmapToBytes(Bitmap bm) {
    if (bm == null) {
        return null;
    }
    final ByteArrayOutputStream os = new ByteArrayOutputStream();
    bm.compress(Bitmap.CompressFormat.PNG, 100, os);
    return os.toByteArray();
  }

 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
 BrowserPolicy browserPolicy = kcm.getBrowserPolicy();
  
  try{
      Bitmap iconBm = BitmapFactory.decodeFile(imagePath);
      byte[] iconBuffer = bitmapToBytes(iconBm);
      boolean result = browserPolicy.addWebBookmarkByteBuffer(uriBook,
                       title, iconBuffer);

      if(result == true){
          Log.d(TAG, "addWebBookmarkByteBuffer has succeeded!");
      }else {
          Log.d(TAG,"addWebBookmarkByteBuffer has failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 

Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_BROWSER_SETTINGS" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean clearHttpProxy ()

Since: API level 7

API to clear Http Proxy setting.

Returns
  • true if success, else false
Throws
SecurityException If caller does not have required permissions
Usage
Administrator can use this API to clear Http proxy if it was set earlier by him.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 BrowserPolicy browserPolicy = edm.getBrowserPolicy();
 try {
     boolean result = browserPolicy.clearHttpProxy();
     if (result == true) {
         Log.d(TAG, " clearHttpProxy is success !!!");
     } else {
         Log.d(TAG, " clearHttpProxy is failure !!!");
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
 BrowserPolicy browserPolicy = kcm.getBrowserPolicy();
 try {
     boolean result = browserPolicy.clearHttpProxy();
     if (result == true) {
         Log.d(TAG, " clearHttpProxy is success !!!");
     } else {
         Log.d(TAG, " clearHttpProxy is failure !!!");
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_BROWSER_PROXY" permission which has a protection level of signature.
Since
API level 7
MDM 4.0.1
Multiuser Environment
User Scope

public boolean deleteWebBookmark (Uri uri, String title)

Since: API level 2

API to delete a Web bookmark from the Android native Web browser.

Parameters
uri The URI that matches the website.
title The name that describes the bookmark.
Returns
  • true if deletion of the web bookmark is successful, else false.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remove a Web bookmark from the Web browser. The URI and title must match to remove it successfully.

  String uri = "http://www.google.com.br";
  String title = "BrasilBookmark";
  Uri uriBook = Uri.parse(uri); 
    
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 BrowserPolicy browserPolicy = edm.getBrowserPolicy();
  try{
      Bitmap  iconBm = BitmapFactory.decodeFile(imagePath);
      boolean result = miscPolicy.deleteWebBookmark(uriBook ,
                       title);
      if(result == true){
          Log.d(TAG, "deleteWebBookmark has succeeded!");
      }else {
          Log.d(TAG, "deleteWebBookmark has failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
  String uri = "http://www.google.com.br";
  String title = "BrasilBookmark";
  Uri uriBook = Uri.parse(uri);

 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
 BrowserPolicy browserPolicy = kcm.getBrowserPolicy();
  try{
      Bitmap  iconBm = BitmapFactory.decodeFile(imagePath);
      boolean result = browserPolicy.deleteWebBookmark(uriBook ,
                       title);
      if(result == true){
          Log.d(TAG, "deleteWebBookmark has succeeded!");
      }else {
          Log.d(TAG, "deleteWebBookmark has failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 

Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_BROWSER_SETTINGS" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean getAutoFillSetting ()

Since: API level 2

API to get the browser autofill setting.

Returns
  • true if enabled, false if disabled
Usage

An administrator can use this API to get the browser autofill setting. If false, a website is prevented from providing autofill suggestions when the user is filling in form data. The user cannot change the setting value. If true, the user can change the setting.

Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean getCookiesSetting ()

Since: API level 2

API to get the browser cookies setting.

Returns
  • true if enabled, false if disabled
Usage

An administrator can use this API to get the browser cookies setting. If false, websites are prevented from storing cookies on the device. The user also cannot change the value. If true, the user can enable or disable this setting.

Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean getForceFraudWarningSetting ()

Since: API level 2

API to get the browser show security Warnings setting.

Returns
  • true if enabled, false if disabled
Usage

An administrator can use this API to get the browser show security warnings setting. If true, untrusted certificate security warnings are shown to the user, and the user cannot change the setting value. If false, the user can change the setting.

Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public String getHttpProxy ()

Since: API level 7

API to retrieve Http Proxy setting.

Returns
  • a String with proxy settings (ip:port). null if no proxy has been set.
Throws
SecurityException If caller does not have required permissions
Usage
Administrator can use this API to retrieve Http proxy settings.
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 BrowserPolicy browserPolicy = edm.getBrowserPolicy();
 try {
     String ip_port = browserPolicy.getHttpProxy();
     if (ip_port != null) {
         Log.d(TAG, " Proxy settings = " + ip_port);
     } else {
         Log.d(TAG, "No proxy has been set yet.");
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
 BrowserPolicy browserPolicy = kcm.getBrowserPolicy();
 try {
     String ip_port = browserPolicy.getHttpProxy();
     if (ip_port != null) {
         Log.d(TAG, " Proxy settings = " + ip_port);
     } else {
         Log.d(TAG, "No proxy has been set yet.");
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 
Since
API level 7
MDM 4.0.1
Multiuser Environment
User Scope

public boolean getJavaScriptSetting ()

Since: API level 2

API to get the browser JavaScript setting.

Returns
  • true if enabled, false if disabled
Usage

An administrator can use this API to get the browser JavaScript setting. If false, the browser is prevented from running JavaScript code for a website. The user also cannot change the setting. If true, the user can enable or disable JavaScript.

Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean getPopupsSetting ()

Since: API level 2

API to get pop-up browser setting.

Returns
  • true if enabled, false if disabled
Usage

An administrator can use this API to get the browser force pop-up setting. If false, websites are not allowed to pop up a new browser window. The user also cannot change this value. If true, the user can change this setting.

Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setAutoFillSetting (boolean enable)

Since: API level 2

API to enable or disable the browser autofill setting.

Parameters
enable true to enable, false to disable
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
If set to false, this function overrides the default browser autofill setting. The setting is applied to Samsung browser in order to prevent any website from providing autofill suggestions when a user is filling in form data on the webpage, even if the user has previously filled in the form. The user cannot change the setting from false to true (i.e., the corresponding UI is also disabled). When set to true, the default browser setting is restored, and the user can change the browser autofill setting.

NOTE: Since MDM 5.6, this policy is no longer supported by Chrome.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 BrowserPolicy browserPolicy = edm.getBrowserPolicy();
 try {
     // enable:webpage or website will provide suggestion while filling
     // the form

     // disable:webpage or website should not provide any
     // suggestion while filling the form Example :create a new gmail or
     // yahoo account.
     boolean result = browserPolicy.setAutoFillSetting(true);
     if (result == true) {
         Log.d(TAG, " setAutoFillSetting has succeeded!");
     } else {
         Log.d(TAG, " setAutoFillSetting has failed.");
     }

 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
 BrowserPolicy browserPolicy = kcm.getBrowserPolicy();
  try {
      //enable:webpage or website will provide suggestion while filling
      //the form

      //disable:webpage or website should not provide any
      //suggestion while filling the form Example :create a new gmail or
      //yahoo account.
      boolean result = browserPolicy.setAutoFillSetting(true);
      if(result == true){
          Log.d(TAG," setAutoFillSetting has succeeded!");
      }else{
          Log.d(TAG," setAutoFillSetting has failed.");
      }

  }catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_BROWSER_SETTINGS" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setCookiesSetting (boolean enable)

Since: API level 2

API to enable or disable the browser cookies setting.

Parameters
enable true to enable, false to disable
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
If set to false, this function overrides the default browser cookies setting. This setting is applied to Samsung browser in order to prevent any website from storing cookies related to the website on the device. A website that make use of cookies to preload user authentication information cannot do so. The user cannot change the setting from false to true (i.e., the corresponding UI is also disabled). When set to true, the default browser setting is restored, and the user can change the browser cookies setting.

NOTE: Since MDM 5.6, this policy is no longer supported by Chrome.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 BrowserPolicy browserPolicy = edm.getBrowserPolicy();
 try {
     // enable: webpage or website can store cookies info to navigate the
     // web page.Webpage will show always current state of the web page.

     // disable: webpage or website cann't store cookies info .So if we
     // navigate the web page,it will always ask the authorisation info.

     boolean result = browserPolicy.setCookiesSetting(true);
     if (result == true) {
         Log.d(TAG, " setCookiesSetting has succeeded!");
     } else {
         Log.d(TAG, " setCookiesSetting has failed.");
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
 BrowserPolicy browserPolicy = kcm.getBrowserPolicy();
  try {
      //enable: webpage or website can store cookies info to navigate the
      //web page.Webpage will show always current state of the web page.

      //disable: webpage or website cann't store cookies info .So if we
      //navigate the web page,it will always ask the authorisation info.

      boolean result = browserPolicy.setCookiesSetting(true);
      if(result == true){
          Log.d(TAG," setCookiesSetting has succeeded!");
      }else{
          Log.d(TAG," setCookiesSetting has failed.");
      }
  }catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_BROWSER_SETTINGS" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setForceFraudWarningSetting (boolean enable)

Since: API level 2

API to enable or disable the browser show security Warnings setting.

Parameters
enable true to enable, false to disable
Returns
  • true if success
Throws
SecurityException If caller does not have required permissions
Usage
If set to true, this function overrides the browser default show security warnings setting. This setting is applied to Samsung browser in order to force the browser to show an untrusted certificate security warning to the user when applicable. If the user tries to connect to a website whose certificate is not present in the certificate trust chain used by the browser, the security warning is shown. The user cannot change the setting from true to false (i.e., the corresponding UI is also disabled). When set to false, the default browser setting is restored, and the user can change the show security warning setting.
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 BrowserPolicy browserPolicy = edm.getBrowserPolicy();
 try {
     // enable:webpage or website will show security warning,if you don't
     // have trusted certificates

     // disable:webpage or website should not show security warning,even
     // though if you don't have trusted certificates

     boolean result = browserPolicy.setForceFraudWarningSetting(true);
     if (result == true) {
         Log.d(TAG, " setForceFraudWarningSetting has succeeded!");
     } else {
         Log.d(TAG, " setForceFraudWarningSetting has failed.");
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
 BrowserPolicy browserPolicy = kcm.getBrowserPolicy();
  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  BrowserPolicy browserPolicy = edm.getBrowserPolicy();
  try {
      //enable:webpage or website will show security warning,if you don't
      //have trusted certificates

      //disable:webpage or website should not show security warning,even
      //though if you don't  have trusted certificates

      boolean result = browserPolicy.setForceFraudWarningSetting(true);
      if(result == true){
          Log.d(TAG," setForceFraudWarningSetting has succeeded!");
      }else{
          Log.d(TAG," setForceFraudWarningSetting has failed.");
      }
  }catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_BROWSER_SETTINGS" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setHttpProxy (String proxySetting)

Since: API level 7

API to set Http Proxy setting.

Parameters
proxySetting "IP:PORT" or "HOSTNAME:PORT"
Returns
  • true if success, else false
Throws
SecurityException If caller does not have required permissions
Usage
Administrator can use this API to set Http proxy which is used by browser application. This policy can be set by only one administrator at a time.The default port is 80 and is set in case of not set the PORT value.

NOTE 1: This policy must not be simultaneously used with Firewall IPTABLES rules or Firewall Proxy policies.

NOTE 2: Since MDM 5.6, this policy is no longer supported by Chrome.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 BrowserPolicy browserPolicy = edm.getBrowserPolicy();
 try {
     boolean result = browserPolicy.setHttpProxy("1.1.1.1:8888");
     if (result == true) {
         Log.d(TAG, " setHttpProxy is success !!!");
     } else {
         Log.d(TAG, " setHttpProxy is failure !!!");
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
 BrowserPolicy browserPolicy = kcm.getBrowserPolicy();
 try {
     boolean result = browserPolicy.setHttpProxy("1.1.1.1:8888");
     if (result == true) {
         Log.d(TAG, " setHttpProxy is success !!!");
     } else {
         Log.d(TAG, " setHttpProxy is failure !!!");
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_BROWSER_PROXY" permission which has a protection level of signature.
Since
API level 7
MDM 4.0.1
Multiuser Environment
User Scope

public boolean setJavaScriptSetting (boolean enable)

Since: API level 2

API to enable or disable the browser JavaScript setting.

Parameters
enable true to enable, false to disable
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
If set to false, this function overrides the browser default JavaScript setting. This setting is applied to Samsung browser in order to prevent the browser from running JavaScript code for a website. A website that requires JavaScript to be active in achieving a function (for example, an animation) is prevented from executing the function. The user cannot change the setting from false to true (i.e., the corresponding UI is also disabled). When set to true, the default browser setting is restored, and the user can change the JavaScript setting.

NOTE: Since MDM 5.6, this policy is no longer supported by Chrome.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 BrowserPolicy browserPolicy = edm.getBrowserPolicy();
 try {
     // enable:javascript supported webpage or website will open properly
     // disable:javascript supported webpage or website should not open properly
     boolean result = browserPolicy.setJavaScriptSetting(true);
     if (result == true) {
         Log.d(TAG, " setJavaScriptSetting has succeeded!");
     } else {
         Log.d(TAG, " setJavaScriptSetting has failed.");
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
 BrowserPolicy browserPolicy = kcm.getBrowserPolicy();
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 BrowserPolicy browserPolicy = edm.getBrowserPolicy();
  try {
      //enable:javascript supported webpage or website will open properly
      //disable:javascript supported webpage or website should not open properly
      boolean result = browserPolicy.setJavaScriptSetting(true);
      if(result == true){
          Log.d(TAG," setJavaScriptSetting has succeeded!");
      }else{
          Log.d(TAG," setJavaScriptSetting has failed.");
      }
  }catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_BROWSER_SETTINGS" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setPopupsSetting (boolean enable)

Since: API level 2

API to enable or disable the pop-up browser setting.

Parameters
enable true to enable, false to disable
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
If set to false, the setting overrides the default pop-up browser setting to prevent any website from popping up new browser windows when the user navigates to a website that invokes such action. The setting applies to Samsung browser. The user cannot change the setting from false to true (i.e., the corresponding UI is also be disabled). When set to true, the default browser setting is restored, and the user can change pop-up settings.

NOTE: Since MDM 5.6, this policy is no longer supported by Chrome.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 BrowserPolicy browserPolicy = edm.getBrowserPolicy();
 try {
     // enable: webpage or website can show pop-up windows
     // disable: webpage or website can't show pop-up windows
     boolean result = browserPolicy.setPopupsSetting(true);
     if (result == true) {
         Log.d(TAG, " setPopupsSetting has succeeded!");
     } else {
         Log.d(TAG, " setPopupsSetting has failed.");
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
 BrowserPolicy browserPolicy = kcm.getBrowserPolicy();
  try {
      //enable: webpage or website can show pop-up windows
      //disable: webpage or website can't show pop-up windows
      boolean result = browserPolicy.setPopupsSetting(true);
      if(result == true){
          Log.d(TAG," setPopupsSetting has succeeded!");
      }else{
          Log.d(TAG," setPopupsSetting has failed.");
      }
  }catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_BROWSER_SETTINGS" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope