program tip

Android의 키오스크 모드

radiobox 2020. 8. 2. 18:02
반응형

Android의 키오스크 모드


CF .NET 엔터프라이즈 응용 프로그램을 Android 장치에서 실행하기 위해 이식 할 수 있는지 여부와 방법을 평가하는 중입니다. Windows Mobile 전화의 응용 프로그램은 부팅 후 응용 프로그램이 전체 화면 모드로 자동 시작되고 사용자가 실수로 또는 전화의 다른 부분에 액세스 할 수없는 키오스크 모드에서 실행됩니다.

Android에서 부팅 후 하나의 응용 프로그램이 자동 시작되고 사용자가 실수로 (또는 의도적으로) Android 장치의 다른 부분에 액세스하지 못하게 할 수 있습니까?


android.intent.action.BOOT_COMPLETEDBroadcastReceiver 의도를 듣고 부팅을 통해 응용 프로그램을 자동 시작할 수 있습니다. 활동에서 자신을 새로운 기본 홈 화면으로 등록하고 키를 처리 할 수 ​​있습니다 [1].

프레임 워크를 수정하지 않고 처리 할 수없는 인스턴스가 있다고 생각합니다 (현재 활성화 된 응용 프로그램을 표시하기 위해 홈을 길게 누르는 것과 같이). 그러나 실수 할 수도 있습니다.

그러나 충분할 수있는 프로토 타입의 경우.

땜질을 즐기십시오!

[1]:

<intent-filter>
 <action android:name="android.intent.action.MAIN" />
 <category android:name="android.intent.category.HOME" />
 <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

키오스크를 사용하도록이를 사용자 정의 (메뉴에 대한 액세스 비활성화, 애플리케이션 추가 제한 등) 할 수 있습니다. http://code.google.com/p/android-launcher-plus/


새로운 Android L Preview에서 Google은 Task Locking 을 발표 했습니다. 그러나 루트가 필요한 것 같습니다.

L Developer Preview에는 사용자가 앱을 떠나거나 알림으로 인해 중단되는 것을 일시적으로 제한 할 수있는 새로운 작업 잠금 API가 도입되었습니다. 예를 들어 Android에서 높은 스테이크 평가 요구 사항을 지원하기 위해 교육 앱을 개발하는 경우에 사용할 수 있습니다. 앱이이 모드를 활성화하면 앱이 모드를 종료 할 때까지 알림을 보거나 다른 앱에 액세스하거나 홈 화면으로 돌아갈 수 없습니다.

무단 사용을 방지하기 위해 승인 된 앱만 작업 잠금을 활성화 할 수 있습니다. 또한 작업 잠금 권한 부여는 android.app.admin.DevicePolicyManager.setLockTaskComponents()방법을 통해 특별히 구성된 장치 소유자 앱에 의해 부여되어야합니다 .

장치 소유자를 설정하려면 다음 단계를 수행하십시오.

  • Android userdebug빌드를 실행하는 디바이스 를 개발 시스템에 연결하십시오.
  • 기기 소유자 앱을 설치하십시오.
  • device_owner.xml파일을 작성 /data/system하여 장치 디렉토리에 저장하십시오 .
$ adb root
$ adb shell stop
$ rm /tmp/device_owner.xml
$ echo "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>" >> /tmp/device_owner.xml
$ echo "&device-owner package=\"<your_device_owner_package>\" name=\"*<your_organization_name>\" />" >> /tmp/device_owner.xml
$ adb push /tmp/device_owner.xml /data/system/device_owner.xml
$ adb reboot

앱에서 작업 잠금 API를 사용하기 전에 DevicePolicyManager.isLockTaskPermitted ()를 호출하여 활동이 인증되었는지 확인하십시오.

작업 잠금을 활성화하려면 android.app.Activity.startLockTask()승인 된 활동에서 전화 하십시오.

작업 잠금이 활성화되면 다음 동작이 적용됩니다.

  • 상태 표시 줄이 비어 있고 사용자 알림 및 상태 정보가 숨겨져 있습니다.
  • 홈 및 최근 앱 버튼이 숨겨져 있습니다.
  • 다른 앱은 새로운 활동을 시작하지 않을 수 있습니다.
  • 현재 작업이 새 작업을 생성하지 않는 한 현재 앱이 새 활동을 시작할 수 있습니다.
  • 승인 된 활동이 전화를 걸 때까지 사용자는 앱에서 잠금 상태를 유지합니다 Activity.stopLockTask().

이것을 잠시 동안 검색 한 후 좋은 해결책을 찾았습니다. 이것은 루팅 된 장치에서만 작동하지만이 하나의 응용 프로그램에만 해당된다면 루팅은 문제가되지 않아야합니다.

또한 다른 방법은 http://thebitplague.wordpress.com/2013/04/05/kiosk-mode-on-the-nexus-7/확인하십시오.


Google은 최근 Android 5.1 이상을 실행하는 모든 Android 기기에 키오스크 모드를 쉽게 설정하고 다양한 정책을 설정할 수 있는 Android 관리 API출시했습니다 .


Android 기기의 단일 목적 기기 설정 페이지 에서 더 많은 정보를 쉽게 얻을 수있는 방법에 대해 설명했습니다.

이제 Android 6.0 Marshmallow 이상 장치를 회사 소유의 일회용 (COSU) 장치 로 쉽게 구성 할 수 있습니다 .


포럼 게시물 에서 다른 가능한 기술을 찾았 습니다 . 그 게시물 인용 :

http://www.basic4ppc.com/forum/basic4android-getting-started-tutorials/10839-android-kiosk-mode-tutorial.html

Using the following methods you can build an application that will prevent "regular" users from playing with anything other than your application.

The application is made of two modules. The main activity and a service. The service is configured to start at boot. When the service is started it checks if the activity is running or not. If it is not running it uses a timer to start the main activity.

When the activity is paused it schedules the service to start in one second: Code:

Sub Activity_Pause (UserClosed As Boolean)
    If kiosk Then StartServiceAt(KioskService, DateTime.Now + 1 * DateTime.TicksPerSecond, false)    
End Sub

If the user presses on the home screen, the home screen will appear for several seconds. However your application will return to the front after a few seconds and the user will not be able to interact with any other applications or change the settings.

The service is set to be a foreground service. This prevents Android from killing our service. Press on the Stop button to deactivate kiosk mode.

There appears to be an example kiosk-mode code ZIP file available for download, too.


Xposed framework can do this. It needs root and there is a possibility that it won't work on every and all platforms. Look for disable() method in class android.app.StatusBarManager.

Here in Android source code

Look here on how to write your own module: Xposed development tutorial

It's much easier than you think at first glance. Good Luck!


Starting your app on boot

the BEST way to accomplish this is setting your app as the launcher

<activity ...
  android:launchMode="singleInstance"
  android:windowActionBar="false">
    <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.HOME" />
      <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

Locking your app

the most reliable way is to use a device with Lollipop or greater and make use of

startLockTask

first you must set your app as the device owner. NB your device must be unprovisioned: if you registered it you should do a factory reset and skip the account registration.

to be able to register your app you must first setup a DeviceAdminReceiver component:

package com.example.myapp;

public class MyDeviceAdminReceiver extends android.app.admin.DeviceAdminReceiver {
    @Override
    public void onEnabled(Context context, Intent intent) {
        Toast.makeText(context, "Device admin permission received", Toast.LENGTH_SHORT).show();
    }

    @Override
    public CharSequence onDisableRequested(Context context, Intent intent) {
        return "are you sure?";
    }

    @Override
    public void onDisabled(Context context, Intent intent) {
        Toast.makeText(context, "Device admin permission revoked", Toast.LENGTH_SHORT).show();
    }


    @Override
    public void onLockTaskModeExiting(Context context, Intent intent) {
        // here you must re-lock your app. make your activity know of this event and make it call startLockTask again!
    }
}

once you have an unprovisioned device you can launch the following command from adb (no root required)

adb shell dpm set-device-owner com.example.myapp/.MyDeviceAdminReceiver

to avoid android asking the user permissions to pin your app you must call setLockTaskPackages

finally!

@Override
public void onResume(){
    super.onResume();
    DevicePolicyManager mDevicePolicyManager = (DevicePolicyManager) getSystemService(
            Context.DEVICE_POLICY_SERVICE);
    ComponentName mAdminComponentName = new ComponentName(getApplicationContext(), MyDeviceAdminReceiver.class);
    mDevicePolicyManager.setLockTaskPackages(mAdminComponentName, new String[]{getPackageName()});
    startLockTask();
}
@Override
public void finish(){
    stopLockTask();
    super.finish();
}

Along with setting up your application with a BOOT receiver, and this answer for preventing status bar expansion, this solution works on 4.4 and above as a complete kiosk app :

Place in your onCreate():

    final View view = (View) findViewById(android.R.id.content);
    if (view != null) {
        //"hides" back, home and return button on screen. 
        view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE |
                                   View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
                                   View.SYSTEM_UI_FLAG_IMMERSIVE |
                                   View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
                                   View.SYSTEM_UI_FLAG_FULLSCREEN);
        view.setOnSystemUiVisibilityChangeListener
                (new View.OnSystemUiVisibilityChangeListener() {
                    @Override
                    public void onSystemUiVisibilityChange(int visibility) {
                        // Note that system bars will only be "visible" if none of the
                        // LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.
                        if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                            view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE |
                                    View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
                                    View.SYSTEM_UI_FLAG_IMMERSIVE |
                                    View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
                                    View.SYSTEM_UI_FLAG_FULLSCREEN);
                        }
                    }
                });
    }

This will completely hide the back button, apps and home button.

참고URL : https://stackoverflow.com/questions/2068084/kiosk-mode-in-android

반응형