Overview
This guide describes a method of programmatically removing a Google account from a device when the device user logs out. It is intended as guidance for creating a line-of-business app that supports shared-device log-in. Triggered when a user logs out, an API can perform the task autonomously, reducing the manual interventions required for scrubbing personal data from a shared Zebra device when a shift has ended.
Requirements
Removing a Google account programmatically involves two primary steps:
Step 1 is to grant permission to an app for managing Google accounts on a device, and is required just one time for each device. This is performed by scanning a barcode on the device or by pushing XML to devices via EMM system. The barcode and the XML can both be created in a single process using Zebra StageNow.
Step 2 is to create the app that removes the Google account, the primary function of which can be triggered each time a user logs out. The app must be created using EMDK for Android and its Profile Manager, which generates the code needed to instruct Zebra's DevAdmin service to remove the account.
The processes for both steps are explained below.
I. Grant Permission
This section briefly describes the process of creating a settings Profile in StageNow. Detailed instructions can be found in the StageNow Create a Profile guide section.
Create a StageNow Profile
- Open StageNow and create a new "Xpert Mode" Profile.
- Select Access Manager (AccessMgr) to configure application permissions.
- In the Access Manager configuration, specify the following details:
- Service Access Action: "Allow Caller to Call Service"
- Service Identifier:
delegation-zebra-privileged-api-scope - Caller Package Name: [package name] (of the Google-removal app; e.g.
com.myCompany.myGoogleRemover) - Caller Signature: [
signature.crt] (certificate file; e.g.GoogleRemover.crt)
Generate Barcode and Deploy
When finished entering data (before saving the Profile), the StageNow Access Manager settings should look similar to the image below, with the last two fields populated with file names that match the Google-removal app and its certificate:
Click image to enlarge; ESC to exit.
- Proceed to the Publish process in StageNow and select a barcode type (usually PDF417).
- Click the "Test" button to generate a barcode for testing the configured settings.
- Launch the StageNow app on a Zebra device designated for testing.
- Scan the barcode to apply the settings on the device.‡
- After a successful test, the barcode can be distributed and/or XML exported for deployment using an EMM system.
‡ Permission settings can be deployed to devices before installation of the app, which essentially "pre-approves" the app prior to installation.
II. Implement Google Removal App
This section briefly describes the requirements for creating an app to submit XML to the DevAdmin service to remove a Google account. Details for using Profile Manager to generate XML can be found in the Profile Manager Programmer's Guide.
Integrate with EMDK for Android
- Build an app with Zebra EMDK for Android.
- Create and bind with a
ProfileManagerinstance. - Fetch the device user's Google account name.
For help with the requirements above, an app implementation can be found in the EMDK Clock Sample App.
Detect Logout, Generate XML
- Detect a user logout from the host device.
- Generate XML using the Profile Manager component.
- Specify the "ProfileName" XML value as desired.
- Dynamically populate the "RemoveAccountName" value with the device user's fetched Google account name. This value must match EXACTLY with the name of the account being removed.
The generated XML should look similar to the code below:
<?xml version="1.0" encoding="utf-8"?>
<characteristic type="Profile">
<parm name="ProfileName" value="AccountRemovalProfile"/>
<characteristic type="DevAdmin" version="15.4">
<parm name="RemoveAccountName" value="user-account-to-remove@example.com"/>
</characteristic>
</characteristic>
MX 15.4 is required for access to this DevAdmin API.
Submit XML, Handle Response
- Submit the XML to the
ProfileManager.processProfile()method. - Design the app to handle synchronous feedback provided by EMDK on status of the operation.
- Present success/failure responses to user and/or write to a log file accessible by Zebra RxLogger.
Zebra strongly recommends testing any developed solution on multiple devices before general deployment.