Администратор не имеет com.sec.enterprise.knox.permission.KNOX_CCM ИЛИ com.samsung.android.knox.permission.KNOX_CCM_KEYSTORE - PullRequest
2 голосов
/ 23 октября 2019

Я пытаюсь получить доступ к TIMAKeystore CCM, который я использую для samsung knox SDK

Выполнение следующих действий:

  startAdminIfNeeded(activity)
//assumes admin is already on
  activateKPELicense(activity)
 //assumes license has been activated
  enableCCM(activity)


private fun startAdminIfNeeded(context: Context) {
    val deviceAdmin = ComponentName(context, SampleAdminReceiver::class.java)

    val dpm = context.getSystemService(DEVICE_POLICY_SERVICE) as DevicePolicyManager

    val adminActive = dpm.isAdminActive(deviceAdmin)

    if (!adminActive) {
        val intent = Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN)
        intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, deviceAdmin)
        if (context is Activity) {
            context.startActivityForResult(intent, 100)
        }
    }
}



    private fun activateKPELicense(context: Context) {
    // Instantiate the KnoxEnterpriseLicenseManager class to use the activateLicense method
    val kpeManager = KnoxEnterpriseLicenseManager.getInstance(context.applicationContext)

    try {
        kpeManager.activateLicense(KPE_LICENSE_KEY)

    } catch (e: Exception) {
        Log.e(TAG, "exception", e)
    }
}


private var mCCMProfileObj: CCMProfile? = null
private var mCertificateProfile: CertificateProfile? = null

@Throws(SecurityException::class)
private fun enableCCM(context: Context): Boolean {
    mCCMProfileObj = CCMProfile() // Initialize a CCMProfile object
    mCCMProfileObj?.accessControlMethod = CCMProfile.AccessControlMethod.LOCK_STATE // Set its accessControlMethod to the default method
    mCertificateProfile = CertificateProfile()
    mCCMProfileObj?.packageList = listOf(context.packageName) // Set the CCM Profile's packageList to that of whitelisted packages by user
    mCCMProfileObj?.whiteListAllPackages = false
    val ekm = EnterpriseKnoxManager.getInstance(context.applicationContext) // Instantiate the EnterpriseKnoxManager class
    val clientCertificateManager = ekm.clientCertificateManagerPolicy // Get the ClientCertificateManager where the setCCMProfile method lives
    return clientCertificateManager.setCCMProfile(mCCMProfileObj) // Apply the CCM Profile
}

Лицензия, которую я использую, одна из двух:

1. KPE development license - which gives this error
2. KPE Enterprise free trial license - which fails to validate

Чего мне не хватает?

...