Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc956309 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Update warning dialog on work profile deletion.

Bug: 20024761
Change-Id: I23b0eaa7742d9d23a29a2a48ab6e3d92fe310560
parent 79670bbe
Loading
Loading
Loading
Loading
+73 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingTop="@dimen/delete_profile_dialog_padding_top"
    android:paddingLeft="@dimen/delete_profile_dialog_padding_left_right"
    android:paddingRight="@dimen/delete_profile_dialog_padding_left_right"
    android:fadeScrollbars="false" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/delete_managed_profile_opening_paragraph"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/opening_paragraph_delete_profile_unknown_company"
            style="@style/TextAppearance.RemoveDialogContent" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="@dimen/mdm_app_info_height"
            android:layout_alignParentLeft="true"
            android:layout_centerInParent="true"
            android:layout_gravity="center_vertical"
            android:orientation="horizontal"
            android:paddingBottom="@dimen/mdm_app_info_padding_top_bottom"
            android:paddingTop="@dimen/mdm_app_info_padding_top_bottom" >

            <ImageView
                android:id="@+id/delete_managed_profile_mdm_icon_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scaleType="centerInside"
                android:gravity="center_vertical" />

            <TextView
                android:id="@+id/delete_managed_profile_device_manager_name"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center_vertical"
                android:paddingLeft="@dimen/mdm_app_name_padding_left"
                style="@style/TextAppearance.RemoveDialogContent" />
        </LinearLayout>

        <TextView
            android:id="@+id/delete_managed_profile_closing_paragraph"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/work_profile_confirm_remove_message"
            style="@style/TextAppearance.RemoveDialogContent" />
    </LinearLayout>

</ScrollView>
 No newline at end of file
+7 −0
Original line number Diff line number Diff line
@@ -232,4 +232,11 @@
    <dimen name="fab_margin">16dp</dimen>
    <dimen name="fab_elevation">12dp</dimen>
    <dimen name="fab_press_translation_z">9dp</dimen>

    <!-- Delete managed profile dialog -->
    <dimen name="delete_profile_dialog_padding_top">16dp</dimen>
    <dimen name="delete_profile_dialog_padding_left_right">24dp</dimen>
    <dimen name="mdm_app_info_height">72dp</dimen>
    <dimen name="mdm_app_info_padding_top_bottom">8dp</dimen>
    <dimen name="mdm_app_name_padding_left">16dp</dimen>
</resources>
+3 −1
Original line number Diff line number Diff line
@@ -5443,7 +5443,7 @@
    <!-- User removal confirmation message [CHAR LIMIT=none] -->
    <string name="user_confirm_remove_message">All apps and data will be deleted.</string>
    <!-- Work profile removal confirmation message [CHAR LIMIT=none] -->
    <string name="work_profile_confirm_remove_message">All apps and data in this profile will be deleted.</string>
    <string name="work_profile_confirm_remove_message">All apps and data in this profile will be deleted if you continue.</string>
    <!-- User profile removal confirmation message [CHAR LIMIT=none] -->
    <string name="user_profile_confirm_remove_message">All apps and data will be deleted.</string>
    <!-- Setting label to show that a new user is being added [CHAR LIMIT=30] -->
@@ -6275,6 +6275,8 @@

    <!-- Title for a work profile. [CHAR LIMIT=25] -->
    <string name="managed_user_title">Work profile</string>
    <!-- Opening string on the dialog that prompts the user to confirm that they really want to delete their existing work profile. The administration app icon and name appear after the final colon. [CHAR LIMIT=NONE] -->
    <string name="opening_paragraph_delete_profile_unknown_company">This profile is managed by:</string>

    <!-- Summary Title for saying that the preference is experimental and will evolve over time due to User feedback. [CHAR LIMIT=NONE] -->
    <string name="experimental_preference">(Experimental)</string>
+6 −1
Original line number Diff line number Diff line
@@ -327,4 +327,9 @@
        <item name="android:textColor">?android:attr/textColorPrimary</item>
        <item name="android:textStyle">normal</item>
    </style>

    <style name="TextAppearance.RemoveDialogContent" parent="@android:style/TextAppearance.Material">
        <item name="android:textSize">16sp</item>
        <item name="android:textColor">?android:attr/textColorPrimary</item>
    </style>
</resources>
 No newline at end of file
+27 −1
Original line number Diff line number Diff line
@@ -22,9 +22,11 @@ import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.AlertDialog;
import android.app.AppGlobals;
import android.app.Dialog;
import android.app.Fragment;
import android.app.IActivityManager;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -32,6 +34,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -1153,4 +1156,27 @@ public final class Utils {
            view.setVisibility(shown ? View.VISIBLE : View.INVISIBLE);
        }
    }

    /**
     * Returns the application info of the currently installed MDM package.
     */
    public static ApplicationInfo getAdminApplicationInfo(Context context, int profileId) {
        DevicePolicyManager dpm =
                (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
        ComponentName mdmPackage = dpm.getProfileOwnerAsUser(profileId);
        if (mdmPackage == null) {
            return null;
        }
        String mdmPackageName = mdmPackage.getPackageName();
        try {
            IPackageManager ipm = AppGlobals.getPackageManager();
            ApplicationInfo mdmApplicationInfo =
                    ipm.getApplicationInfo(mdmPackageName, 0, profileId);
            return mdmApplicationInfo;
        } catch (RemoteException e) {
            Log.e(TAG, "Error while retrieving application info for package " + mdmPackageName
                    + ", userId " + profileId, e);
            return null;
        }
    }
}
 No newline at end of file
Loading