준 최
Jul 06, 2017
9:10 am

The problem arises here : getSystemService(EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE);

Hi.

 

Yesterday's answer:

Https://seap.samsung.com/forum-topic/block-specific-url-access-and-how-create-url-whitelist

 

EnterpriseDeviceManager edm = (EnterpriseDeviceManager) getSystemService(
               EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE);
       Firewall firewall = edm.getFirewall();

       List<DomainFilterRule> rules = new ArrayList<DomainFilterRule>();

       // Deny list , domains to block
       List<String> denyList = new ArrayList<String>();
       denyList.add("www.google.com");
       denyList.add("*android.com");
       denyList.add("www.samsung*");

       // Allow list, domains to allow
       List<String> allowList = new ArrayList<String>();
       allowList.add("www.youtube.com");

       // In order to validate the application's signature related to the rule, fill this
       // variable with the desired signature.
       String signature = null;

       // DNS server 1
       String dns1 = "8.8.8.8";
       // DNS server 2
       String dns2 = "8.8.4.4";

       // add rule for chrome application
       rules.add(new DomainFilterRule(new AppIdentity("com.android.chrome", signature), denyList,
               allowList, dns1, dns2));
       try {
           FirewallResponse[] response = firewall.addDomainFilterRules(rules);
           if (FirewallResponse.Result.SUCCESS == response[0].getResult()) {
               // success
           } else {
               // failed
           }
       } catch (SecurityException ex) {
           // missing required MDM permission
       }

 

I followed the code in this answer and started developing.

But it does not work normally.

 

The problem arises here.

EnterpriseDeviceManager edm = (EnterpriseDeviceManager) getSystemService(EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE);

 

 

Error:

EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE (error occurred code) -> Must be one of: Context.POWER_SERVICE, Context.WINDOW_SERVICE ~~~~ ....

 

It is said that there is no ENTERPRISE_POLICY_SERVICE in the

EnterpriseDeviceManager.

 

Perhaps I should change this code.

EnterpriseDeviceManager edm = (EnterpriseDeviceManager) getSystemService (

                EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE);

 

I wonder why not. Or how?

 

I am sorry to bother you by asking a lot of questions recently.

thank you.

Samuel Veloso
Jul 07, 2017
5:42 pm

Hi,

Please change the following from:

edm = (EnterpriseDeviceManager) getSystemService(EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE);

to 

edm = new EnterpriseDeviceManager(this);

To avoid your error. 

Best regards,

Samuel

Germán Ceballos
Feb 23, 2018
7:32 pm

Hi Samuel i got the same problem that there is no ENTERPRISE_POLICY_SERVICE in the EnterpriseDeviceManager. but when a try to use 
edm = new EnterpriseDeviceManager(this); a got a new error

"EnterpriseDeviceManager() is not public in 'com.samsung.android.knox.EnterpriseDeviceManager'."

How can i fix this?

Comments

Hi,

I have the same issue. When I rebuilt the project:

Error:(24, 39) error: constructor EnterpriseDeviceManager in class EnterpriseDeviceManager cannot be applied to given types;
required: no arguments
found: MainActivity
reason: actual and formal argument lists differ in length

So I went here:

https://seap.samsung.com/api-references/android-standard/reference/andro... > "Alternative constructor that currently ignores the handler argument. The constructor will be used in future versions to report callbacks. The callbacks will run in the provided handler. NOTE: It is recommended to use getSystemService(String)"

I changed the code to: 

edm = EnterpriseDeviceManager.getInstance(this); 

This compiled. However:

java.lang.RuntimeException: Stub!

- occurred at runtime.

Any help would be appreciated.

Best regards,

Mandy

Mandy LeeMar 01, 2018 at 11:31 pm
Mandy Lee
Mar 01, 2018
11:33 pm

Hi,

I have the same issue. When I rebuilt the project:

Error:(24, 39) error: constructor EnterpriseDeviceManager in class EnterpriseDeviceManager cannot be applied to given types;
required: no arguments
found: MainActivity
reason: actual and formal argument lists differ in length

So I went here:

https://seap.samsung.com/api-references/android-standard/reference/andro... > "Alternative constructor that currently ignores the handler argument. The constructor will be used in future versions to report callbacks. The callbacks will run in the provided handler. NOTE: It is recommended to use getSystemService(String)"

I changed the code to: 

edm = EnterpriseDeviceManager.getInstance(this); 

This compiled. However:

java.lang.RuntimeException: Stub!

- occurred at runtime.

Any help would be appreciated.

Best regards,

Mandy

Comments

Hi Mandy,

Can you let me know what import types are being used for the jar files in the projects build.gradle file? You can also check this in Project Structure for Android Studio.

Thanks,

Sam

Samuel GoldwaxMar 02, 2018 at 5:53 pm

Hi Sam,

Thanks for your help.

build.gradle -

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.test.myapplication"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation files('libs/knoxsdk.jar')
}

Best regards,

Mandy

Mandy LeeMar 04, 2018 at 8:48 pm
Mandy Lee
Mar 04, 2018
8:49 pm

Hi Sam,

Thanks for your help.

build.gradle -

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.test.myapplication"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation files('libs/knoxsdk.jar')
}

Best regards,

Mandy

Samuel Goldwax
Mar 05, 2018
6:55 pm

Hi Mandy,

Could you let me know the model, OS, and Knox version of the device you're running on? It's possible you need to also have the supportlib.jar in your project as well if you're using Knox SDK.

Thanks,

Sam

Comments

Dear Sam,

I am primarily testing on a Samsung Tab A, Lollipop. If KLMS Agent is Knox, version 2.5.481.

I tried supportlib.jar without success.

To clarify, is the code below okay?

edm = EnterpriseDeviceManager.getInstance(this); 

- or must it be the code below.

edm = new EnterpriseDeviceManager(this);

Is there a sample project? The only EnterpriseDeviceManager sample project I could find had android.app.enterprise.EnterpriseDeviceManager rather than com.samsung.android.knox.EnterpriseDeviceManager.

Many thanks,

Mandy

Mandy LeeMar 05, 2018 at 10:15 pm
Mandy Lee
Mar 05, 2018
10:15 pm

Dear Sam,

I am primarily testing on a Samsung Tab A, Lollipop. If KLMS Agent is Knox, version 2.5.481.

I tried supportlib.jar without success.

To clarify, is the code below okay?

edm = EnterpriseDeviceManager.getInstance(this); 

- or must it be the code below.

edm = new EnterpriseDeviceManager(this);

Is there a sample project? The only EnterpriseDeviceManager sample project I could find had android.app.enterprise.EnterpriseDeviceManager rather than com.samsung.android.knox.EnterpriseDeviceManager.

Many thanks,

Mandy

Samuel Goldwax
Mar 08, 2018
6:21 pm

Hi Mandy,

I can confirm that for the Knox SDK, edm = EnterpriseDeviceManager.getInstance(this); is the correct implementation. You can check out sample code for license activation here. This sample app also contains logic for activating Knox SDK functionality on older devices since it sounds like the device you're using can't support Knox SDK on it's own.

Thanks,

Sam

Comments

Hi Sam,

Thanks for the link to the project.

The message below is displayed in Android Studio. I searched this forum, where others had the same issue, as well as the web but could not find a fix.

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Kind regards,

Mandy

Mandy LeeMar 13, 2018 at 10:31 pm
Mandy Lee
Mar 13, 2018
10:31 pm

Hi Sam,

Thanks for the link to the project.

The message below is displayed in Android Studio. I searched this forum, where others had the same issue, as well as the web but could not find a fix.

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Kind regards,

Mandy

Samuel Goldwax
Mar 19, 2018
5:18 pm

Hi Mandy,

For the Knox SDK, the getInstance method should be used. 

There is sample code for license activation available here. If the device is running Knox version < 2.8, you'll need to look at the backwards compatibility sample app. You can check the Knox version of a device in About Device in the Settings app.

Thanks,
Sam

Comments

Hi Sam,

After working on something else for a while, I tested on an Oreo device and it all worked perfectly. Thank-you.

I noticed that the licenses have changed and will be changing further after July 2019. I intend to prevent certain apps from running and prevent device erasing. Do I need to purchase license to achieve this now and / or after July 2019? Also, should I post new questions like this as a new post?

Best regards,

Mandy

Mandy LeeOct 10, 2018 at 1:26 am
Jenna S.Samsung SEAP Moderator
Oct 10, 2018
8:59 pm

Hello Mandy,

When your license expires, you will need to purchase a new license key, but until then you are fine. In the future you should create a new post, however it is fine for now.

Best regards,

Jenna

Comments

Hi Jenna,

Thanks very much.

Best regards,

Mandy

Mandy LeeOct 18, 2018 at 12:13 am