Giter Site home page Giter Site logo

enterprise-samples's Introduction

Android Enterprise Samples Repository

This repository contains a set of individual Android Studio projects to help you get started writing/understanding Android Enterprise features.

enterprise-samples's People

Contributors

codingjeremy avatar owahltinez avatar pfmaggi avatar sh7411usa avatar yaraki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enterprise-samples's Issues

BasicManagedProfile sample not working on Android 10

While the sample woks flawlessly on Android 8.1, on Android 10 the creation of a Work Profile stars anc completes but no DEVICE_ADMIN_ENABLED event is never captured by the BasicDeviceAdminReceiver.
As a consequence the Work Profile is never enabled.

EDIT: adding more detail.
I tryed bypassing the receiver (BasicDeviceAdminReceiver) whose only purpose is starting the Profile enabling process in EnableProfileActivity.
In this class just two things are done:

  • setting Profile name
  • enabling Profile
    It seems that DevicePolicyManager is crashing on setProfileName() or, if commented, on setProfileEnabled: hence Profile is never enabled.
    This is confirmed in device Settings where the Profile is available but marked as "not jet available".
    The error is:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.basicmanagedprofile/com.example.android.basicmanagedprofile.EnableProfileActivity}: java.lang.SecurityException: No active admin ComponentInfo

When I run the program, the following error

Issue by zhushi91
Monday Mar 28, 2016 at 09:55 GMT
Originally opened as googlearchive/android-AppRestrictionEnforcer#1


Process: com.example.android.apprestrictionenforcer, PID: 5884
java.lang.NoSuchMethodError: android.app.admin.DevicePolicyManager.isProfileOwnerApp
at com.example.android.apprestrictionenforcer.MainActivity.onCreate(MainActivity.java:36)
at android.app.Activity.performCreate(Activity.java:5245)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249)
at android.app.ActivityThread.access$800(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5052)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)

Delete deprecated samples

Most of the samples presents in this repository are based on top of the device admin APIs.

For this reason the following sample needs to be removed:

  • AppRestrictionEnforcer
  • BasicManagedProfile
  • DeviceOwner
  • NfcProvisioning

The following, updated sample should also be renamed:

  • AppRestrictionSchema to ManagedConfigurations

Google Play gives parse error using app restriction in this sample

Issue by MSohm
Thursday Sep 29, 2016 at 18:55 GMT
Originally opened as googlearchive/android-AppRestrictionSchema#1


When uploading a version of this sample AppRestrictionSchema to Google Play, it is rejected with the following error:

Upload failed
You uploaded an APK which specifies an app restrictions schema document in its manifest, but there were parsing errors in the document. Restriction profile has one or more invalid nested restrictions.

To reproduce:

  1. Import sample into Android Studio.
  2. Rename package to remove example and be unique.
  3. Generated a signed APK.
  4. Upload APK to Google Play.

Expected Results.
APK accepted by Google Play.

Actual Results:
Google Play fails to parse the APK with error quoted above.

Global settings not working on Google Nexus

Issue by vishalkohad121
Monday Jun 15, 2015 at 12:26 GMT
Originally opened as googlearchive/android-DeviceOwner#1


Hi,

I have installed this sample app and disable auto time and timezone from app but still I am able to configure time and timezone from default settings of device.

According to my understanding if i disable these setting from sample app then user will not able to configured these settings from default settings of device.

Please check and let me know if i am doing something wrong.

Thanks

Does this work at all, seriously?

Issue by nickfurnesschubb
Thursday Aug 18, 2016 at 16:38 GMT
Originally opened as googlearchive/android-DeviceOwner#3


I have tried this a few times without success thinking Android 5 was just to qwerky however i have tried with an Android 6 phone and i still cannot get this to work.

I have attached my version of all files. Included with screenshots of my provision app and the error i see when it attempts to go to a web location to get the apk. I have tested this address in a browser to make sure the download works.
I use a checksum utility to generate the checksum value for me.

Can anybody help and point out what is missing. Can anyone hold their hand up and honestly say they have got this working?

GitHubFiles.zip

android-DeviceOwner-master.zip

Versioning/conditional compilation problems.

The build versioning checks (all of them) check for a change in the definition of what must be sent via NFC, which depends on the receiving device's version. You can't know that at runtime (unless there's some 2-way information flow). (See code involving Build.VERSION.SDK_INT >= 23 and EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME).

Having an old device around to support NFC provisioning seems a perfectly reasonable thing to do.

It clearly will work correctly if the sending and receiving device are the same Android release. If they are not the same (or at least sufficiently different) it may or may not work. In my very limited testing I saw no problems, but I don't have the hardware to thoroughly test.

I can think of a number of ways to address this issue, but getting the "right" solution would be guesswork on my part.

(I've also submitted a pull request with other changes, but I chose not to try to address this issue there, except that I allowed installation on the (ancient) device I wanted to use as NFC sender - which worked fine in my very limited testing.)

Unable de download administration app

Issue by lduparc
Tuesday May 03, 2016 at 06:46 GMT
Originally opened as googlearchive/android-NfcProvisioning#1


Using this sample app with the deviceOwner app installed on the master device, the child device is encrypted and started on Android for Work setup page but it is not able to download the administration app to the child device.

I'm using a Motorola X Style (XT1572) on Android 6.0 for my tests.
Do I have to define a specific configuration in order to be able to download the admin app ?

Properties are the following :

DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME,
                "com.example.androidmdm");
DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION,
                "https://drive.google.com/file/d/XXXXXXXXXXX/view?usp=sharing");
DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM,
                "base64 and sha-256 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION");

Error on create profile

Issue by jaelsonapolinario
Tuesday May 31, 2016 at 19:28 GMT
Originally opened as googlearchive/android-AppRestrictionEnforcer#2


05-31 16:18:37.959 4397-4540/com.example.android.apprestrictionenforcer D/OpenGLRenderer: endAllStagingAnimators on 0xb7808448 (RippleDrawable) with handle 0xb7806b40
05-31 16:19:27.108 5980-5980/com.example.android.apprestrictionenforcer E/InstantRun: Failed to create directory /data/data/com.example.android.apprestrictionenforcer/files/instant-run/dex
05-31 16:19:27.129 5980-5980/com.example.android.apprestrictionenforcer A/InstantRun: Couldn't create dex code folder
05-31 16:19:27.149 5980-5980/com.example.android.apprestrictionenforcer D/AndroidRuntime: Shutting down VM

                                                                                      --------- beginning of crash

05-31 16:19:27.151 5980-5980/com.example.android.apprestrictionenforcer E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.apprestrictionenforcer, PID: 5980
java.lang.RuntimeException: Unable to instantiate receiver com.example.android.apprestrictionenforcer.EnforcerDeviceAdminReceiver: java.lang.ClassNotFoundException: Didn't find class "com.example.android.apprestrictionenforcer.EnforcerDeviceAdminReceiver" on path: DexPathList[[zip file "/data/app/com.example.android.apprestrictionenforcer-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2620)
at android.app.ActivityThread.access$1700(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.android.apprestrictionenforcer.EnforcerDeviceAdminReceiver" on path: DexPathList[[zip file "/data/app/com.example.android.apprestrictionenforcer-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2615)
at android.app.ActivityThread.access$1700(ActivityThread.java:155) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5343) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) 
Suppressed: java.lang.ClassNotFoundException: com.example.android.apprestrictionenforcer.EnforcerDeviceAdminReceiver
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 11 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

TYPE_CHOICE on Android 6 not working

Issue by kreuli
Wednesday Jun 22, 2016 at 21:36 GMT
Originally opened as googlearchive/android-AppRestrictions#1


Hi,

on my Android 6 device (Samsung Tab S2), the value for the TYPE_CHOICE RestrictionEntry does not show up in the restricted profile, 'getSelectedString' returns an empty string instead of the selected value.
The other two types TYPE_BOOLEAN and TYPE_MULTI_SELECT work correctly.
The sample works successfully on my Android 4.4.2 device (LG Tab Pro).
Is this a known issue in Android 6?

Cheers,
Ulrich

How to install the sample app

Issue by lduparc
Tuesday May 03, 2016 at 06:50 GMT
Originally opened as googlearchive/android-DeviceOwner#2


I'm using the NfcProvisionning sample app but I'm not able to install the deviceOwner app on the child device. This app is already installed on the master device, the child device is well encrypted and the wifi connected but I receive an error during the admin app download.

I test with a Motorola X Style (XT1572) and a Motorola X Force (XT1580) on Android 6.0

How to pass Enrolment Token using NFC sample

Hi,

I have been using NFC sample to enroll an Android device, I followed all the steps mentioned here: https://developers.google.com/android/work/play/emm-api/prov-devices#nfc_method

I have been passing WiFi info, locale, the DPC package and it seems all of them are working and my device gets connected with the WiFI but the enrolment token is not working. After taking a while, it says updating the device and take me to enter/scan the QR code screen to continue.

here is my code, where I am adding enrolment token:

private void gatherAdminExtras(HashMap<String, String> values) {
        Properties props = new Properties();
        Set<String> keys = new HashSet<>(values.keySet());
        for (String key : keys) {
            if (key.startsWith("android.app.extra")) {
                continue;
            }
            props.put(key, values.get(key));
            values.remove(key);
        }
        StringWriter sw = new StringWriter();
        try{
            props.store(sw, "{\"com.google.android.apps.work.clouddpc.EXTRA_ENROLLMENT_TOKEN\": \"{Enrolment_Token}\"}");
            values.put(DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE,
                    sw.toString());
            Log.d(TAG, "Admin extras bundle=" + values.get(
                    DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE));
        } catch (IOException e) {
            Log.e(TAG, "Unable to build admin extras bundle");
        }
    }

Help appreciated, thanks.

BasicManagedProfile App is not working in Android Q device.

Issue by byodhcl
Wednesday Aug 28, 2019 at 08:43 GMT
Originally opened as googlearchive/android-BasicManagedProfile#9


Problem: When tried to install the Sample app(BasicManagedProfile), it is not setting up the work profile into the device hence the app is not setup as DO/PO app.

Reproduction Steps:

  1. Install the app into Android Q device(We built the app based on the sample app code with Android 29 version sdk – We also modified the manifest file by changing the sdk version accordingly)

  2. Click on the button “setup profile”.

  3. Observe that – it will be setting up the work profile.

  4. Click on “next” once work profile installation is done.

  5. Observe that - flow will not be redirected into app after clicked on next.
    Expected result: Flow should be auto-redirected into App where app should display the option mentioned from the second screenshot attached for this app.
    https://github.com/googlesamples/android-BasicManagedProfile/blob/master/screenshots/set_up.png

  6. Observe that - no work profile configuraiton is applied on the device.
    Expected result : After installed the work profile, we can see both Personal and Work option enabled from the device.

  7. Observer that – when manually open the app after installation, still it ask to click on “setup profile” that means our app is not set as “PO” app.
    Expected result: It should display the option as mentioned from the 5th step expected result as device is already set as DO owner app.

Attached the video recording by reproducing the issue.
https://drive.google.com/file/d/1mLnDFwSnhB2KLn495DDfitKuvyYiCOqb/view?usp=sharing

Kindly check the issue. Also attached the bug report captured by reproducing the issue.
bugreport-blueline-QPP6.190730.005-2019-08-28-13-59-30.zip

Why PACKAGE DOWNLOAD LOCATION is nothing?

Issue by ghost
Monday Nov 28, 2016 at 07:48 GMT
Originally opened as googlearchive/android-NfcProvisioning#2


Why this sample don't contain EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION?
It seems require.

Document says
"A String extra holding a url that specifies the download location of the device admin package. When not provided it is assumed that the device admin package is already installed"
REF:
https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html

But, We must do factory reset to enable DeviceOwner feature, therefore, device don't have admin package.

Android NfcProvisioning Sample does not work on Android 10 (Pixel 2) trying to provision DO on Android 8 (Samsung S7)

I am trying the sample app, installed on a Pixel 2 (Android 10) to provision а factory reset Samsung S7 with Android 8.0. For a device owner I am using the Test DPC app. However it seems that the createNdefMessage is not called at all - nothing happens on the NFC programmer app either.
I see the API is deprecated but it is still the recommended approach for NFC provisioning. Note that NFC provisioning is officially supported from Android 6+ looking at the Android Management API documentation. Nevertheless, I can find places that say that Android Beam (used by NFC) will work on Android 9 and below: https://support.google.com/nexus/answer/2781895?hl=en also https://www.xda-developers.com/google-deprecate-android-beam-api-nfc-share-files/
Additionally on the Android 10 I can not find a Setting to enable/disable the Beam.

So could you please help me with:

  • Is NFC provisioning not possible from Android 10 NFC programmer device? If so, maybe you could update the documentation.
  • If it is not supported, could you recommend another option to automatically provision a device - w/o the need to point the device at a QR code, enter an identifier/URL or have a device manufacturer configure something.

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.