9

Looking for solution to integrate COSU mode in Android.I have already gone through below links,

https://developer.android.com/work/cosu.html

Has anyone implemented it successfully?

cjd
  • 549
  • 3
  • 11
  • If this helps in any way, I did it by disabling the back press and volume keys and pinning the app since my app had only single screen. Other attempts went futile for me. – Abhi Jun 29 '17 at 15:14

3 Answers3

5

Take a look at this tutorial and that repository with example.

...
if (mDevicePolicyManager.isLockTaskPermitted(
        getApplicationContext().getPackageName())) {
    Intent lockIntent = new Intent(getApplicationContext(),
            LockedActivity.class);
    lockIntent.putExtra(EXTRA_FILEPATH, mCurrentPhotoPath);
    startActivity(lockIntent);
    finish();
} else {
    Toast.makeText(getApplicationContext(),
            R.string.not_lock_whitelisted,Toast.LENGTH_SHORT)
            .show();
}
...
Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
3

You might want to try Google's new Android Management API, it allows to manage COSU devices without having to build an on-device agent (a device policy controller).

Fred
  • 2,191
  • 1
  • 12
  • 14
1

I decided neither way was very good. I used device policy ownership to prevent installing any other apps, wrote a launcher app (so we were the homescreen), made it a system app and used the statusbar manager apis (which aren't well known) to remove the recents button and prevent the status bar from being opened so there was no way to launch any app but mine.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127