2016-08-26 4 views
3

나는 명령으로, 내 응용 프로그램 (ROOT 또는 NFC없이) 내 태블릿의 device_owner을 설정하려고 : (나는 키오스크 앱을하기 때문에)device_owner를 내 Android 앱에 어떻게 설정할 수 있습니까?

adb shell dpm set-device-owner com.test.my_device_owner_app/.MyDeviceAdminReceiver 

가 많은 사이트에 기록 된 좋아한다. 내가 공장 재설정을 만들어 우선, 그럼 난 내 응용 프로그램을 설치하고 난 쉘에서이 명령을 쓴하지만 대답은 :

java.lang.IllegalStateException : 는 장치 소유자 만 장치를 설정하려고 이미 프로비저닝되었습니다.
android.os.Parcel.readException에서     android.app.admin.IDevicePolicyManager에서 (Parcel.java:1554) android.os.Parcel.readException에서
    (Parcel.java:1499)
    $ 스텁 $ Proxy.setDeviceOwner com.android.commands.dpm.Dpm.runSetDeviceOwner (Dpm.java:114)에서 (IDevicePolicyManager.java:3212)
   
    com.android.commands.dpm.Dpm에서 .onRun (Dpm.java:82)
com.android.internal.os.BaseCommand.run에서 43,210   (BaseCommand.java:47) com.android.commands.dpm.Dpm.main에서
    (Dpm.java:38)
   에서 COM .android.internal.os.RuntimeInit.nativeFinishInit (기본 방법)
com.android.internal.os.RuntimeInit.main에서     (RuntimeInit.java:249) 이제

, 내가 어떻게 해결할 수 있습니다 이 문제는 태블릿을 뿌리 뽑기 않고?

+0

문제를 해결하는 방법을 알아 냈습니까? 나는 lenovo a10-30을 가지고있다. lenovo가 설정 중에 생성하는 숨겨진 계정이있는 것 같아서 기기가 이미 제공되었다고 말합니다. – kash

+0

nope .... 아직이 태블릿에서는 device_owner를 설정할 수 없습니다. – mf87

답변

0

Lenovo Yoga 2 Tablet에서도 동일한 문제가 발생합니다.

이 문제를 조사하는 동안 찾은 일부 dpm 소스가 있습니다. 여기

if (!allowedToSetDeviceOwnerOnDevice()) { 
     throw new IllegalStateException(
       "Trying to set device owner but device is already provisioned."); 
    } 

    if (mDeviceOwner != null && mDeviceOwner.hasDeviceOwner()) { 
     throw new IllegalStateException(
       "Trying to set device owner but device owner is already set."); 
    } 

그리고

/** 
* Device owner can only be set on an unprovisioned device, unless it was initiated by "adb", in 
* which case we allow it if no account is associated with the device. 
*/ 
private boolean allowedToSetDeviceOwnerOnDevice() { 
    int callingId = Binder.getCallingUid(); 
    if (callingId == Process.SHELL_UID || callingId == Process.ROOT_UID) { 
     return AccountManager.get(mContext).getAccounts().length == 0; 
    } else { 
     return Settings.Global.getInt(mContext.getContentResolver(), 
       Settings.Global.DEVICE_PROVISIONED, 0) == 0; 
    } 
} 

그래서 첫째 모든 계정이 제거되어 있는지 확인 allowedToSetDeviceOwnerOnDevice 구현을합니다. 설정> 계정을 확인하십시오. Lenovos bloatware는 로컬 캘린더 계정을 생성했습니다. 그것을 제거해야합니다. 루트 액세스

SO answer for manually creating the device_owner.xml을 참조하십시오이 사람들을 위해

. 구현에서 알 수 있듯이 dpm은 해답에서 설명한 것과 동일한 작업을 수행합니다. 그건 그렇고, 나는 문제없이 name 속성을 남겨 둡니다.당신이 else 경우를 볼 때

, 당신은 요가 태블릿

settings put global device_provisioned 0 

내 경험을 호출하여 테스트를 우회 할 수있다하더라도 내가 다시 공장 일을하고 device_owner을 시도, 루트 액세스 권한이

.xml 메서드 나는 어제 성공하지 못했습니다. (스와이 같은) dpm 명령을 실행하기 위해 오늘 내가했던 어떤

는 구글 계정 (I 생략 한 어제이 부분)로 로그인했습니다 및 설정에서도 삭제이 계정 후> 계정 나는 할 수 있었다 성공적으로 내가 루트 액세스 권한이없는 내 구글 계정으로 로그인없이 다른 요가 2 태블릿을 가지고 성공적으로 장치 소유자를 설정 한

업데이트.

추천 할만한 앱 : 키오스크 모드 앱을 설치 한 다음 Android Studio를 닫으세요. 어쩌면 다른 원인이 Binder.getCallingUid() 일 수 있습니다.

관련 문제