Initial implementation of DPM.ACTION_SHOW_NEW_USER_DISCLAIMER.

This intent is broadcasted the first time a new user is added when the
device is managed by a device owner. Upon receiving it:

- A notification is shown.
- When the user taps the notification it launches an activity with a
  "Accept" button.
- When the user taps the button, the activity is dismissed and DPM is
  called to acknowledge that user accepted it.
- If the user never taps the notification or for some reason the
  button is not tapped, the intent will be sent again the next time
  the user is switched to.

There's still some polishing work to be done (like using the proper
resource strings), but the overall workflow is done.

Test: adb shell dumpsys activity service com.android.car/.PerUserCarService

Test: manual verification (automated tests will be added later
Bug: 175057848

Change-Id: I0063a28c5df226456da5c8abcd42d63b07dc4149
diff --git a/car-admin-ui-lib/src/main/java/com/android/car/admin/ui/ManagedDeviceTextView.java b/car-admin-ui-lib/src/main/java/com/android/car/admin/ui/ManagedDeviceTextView.java
index c636e28..9d2fc49 100644
--- a/car-admin-ui-lib/src/main/java/com/android/car/admin/ui/ManagedDeviceTextView.java
+++ b/car-admin-ui-lib/src/main/java/com/android/car/admin/ui/ManagedDeviceTextView.java
@@ -50,27 +50,32 @@
             return;
         }
 
-        Resources res = getResources();
-        CharSequence text;
+        CharSequence text = getManagedDeviceText(context);
+        if (DEBUG) Log.d(TAG, "setting text to '" + text + "'");
+
+        setText(text);
+    }
+
+    /**
+     * Gets the text indicating that the device is managed by an organization.
+     */
+    public static CharSequence getManagedDeviceText(Context context) {
+        Resources res = context.getResources();
         try {
             DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
             CharSequence orgName = dpm.getDeviceOwnerOrganizationName();
             if (orgName != null) {
-                text = res.getString(R.string.car_admin_ui_managed_device_message_by_org, orgName);
-            } else {
-                if (DEBUG) {
-                    Log.d(TAG, "organization name not set, using device owner app name instead");
-                }
-                text = res.getString(R.string.car_admin_ui_managed_device_message_by_app,
-                        dpm.getDeviceOwnerNameOnAnyUser());
+                return res.getString(R.string.car_admin_ui_managed_device_message_by_org, orgName);
             }
+            if (DEBUG) {
+                Log.d(TAG, "organization name not set, using device owner app name instead");
+            }
+            return res.getString(R.string.car_admin_ui_managed_device_message_by_app,
+                    dpm.getDeviceOwnerNameOnAnyUser());
         } catch (Exception e) {
             Log.w(TAG, "error getting name of device owner organization", e);
-            text = res.getString(R.string.car_admin_ui_managed_device_message_generic);
+            return res.getString(R.string.car_admin_ui_managed_device_message_generic);
         }
-        if (DEBUG) Log.d(TAG, "setting text to '" + text + "'");
-
-        setText(text);
     }
 
     private static boolean isManagedDevice(Context context) {