Merge "Specify disallowed action in AdminSupportDetailsDialog"
This commit is contained in:
committed by
Android (Google) Code Review
commit
15e53a3f57
@@ -30,7 +30,7 @@
|
|||||||
android:src="@drawable/ic_info"
|
android:src="@drawable/ic_info"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:contentDescription="@null" />
|
android:contentDescription="@null" />
|
||||||
<TextView
|
<TextView android:id="@+id/admin_support_dialog_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="@dimen/admin_details_dialog_padding"
|
android:paddingStart="@dimen/admin_details_dialog_padding"
|
||||||
|
|||||||
@@ -7492,9 +7492,18 @@
|
|||||||
<!-- Summary of device info page [CHAR LIMIT=NONE] -->
|
<!-- Summary of device info page [CHAR LIMIT=NONE] -->
|
||||||
<string name="about_summary">Android <xliff:g id="version" example="6.0">%1$s</xliff:g></string>
|
<string name="about_summary">Android <xliff:g id="version" example="6.0">%1$s</xliff:g></string>
|
||||||
|
|
||||||
<!-- TODO: Update these strings with the finalized ones. -->
|
|
||||||
<!-- Title for dialog displayed when user clicks on a setting locked by an admin [CHAR LIMIT=30] -->
|
<!-- Title for dialog displayed when user clicks on a setting locked by an admin [CHAR LIMIT=30] -->
|
||||||
<string name="disabled_by_policy_title">Action not allowed</string>
|
<string name="disabled_by_policy_title">Action not allowed</string>
|
||||||
|
<!-- Title for dialog displayed to tell user that changing volume was disallowed by an admin [CHAR LIMIT=50] -->
|
||||||
|
<string name="disabled_by_policy_title_adjust_volume">Can\'t change volume</string>
|
||||||
|
<!-- Title for dialog displayed to tell user that outgoing calls were disabled by an admin [CHAR LIMIT=50] -->
|
||||||
|
<string name="disabled_by_policy_title_outgoing_calls">Calling not allowed</string>
|
||||||
|
<!-- Title for dialog displayed to tell user that sending SMS were disabled by an admin [CHAR LIMIT=50] -->
|
||||||
|
<string name="disabled_by_policy_title_sms">SMS not allowed</string>
|
||||||
|
<!-- Title for dialog displayed to tell user that the camera was disabled by an admin [CHAR LIMIT=50] -->
|
||||||
|
<string name="disabled_by_policy_title_camera">Camera not allowed</string>
|
||||||
|
<!-- Title for dialog displayed to tell user that screenshots are disabled by an admin [CHAR LIMIT=50] -->
|
||||||
|
<string name="disabled_by_policy_title_screen_capture">Screenshot not allowed</string>
|
||||||
<!-- Shown when the user tries to change a settings locked by an admin [CHAR LIMIT=200] -->
|
<!-- Shown when the user tries to change a settings locked by an admin [CHAR LIMIT=200] -->
|
||||||
<string name="default_admin_support_msg">This action is disabled. Contact your organization\'s administrator to learn more.</string>
|
<string name="default_admin_support_msg">This action is disabled. Contact your organization\'s administrator to learn more.</string>
|
||||||
<!-- Shown in dialog to allow user to see more information about the device admin [CHAR LIMIT=30] -->
|
<!-- Shown in dialog to allow user to see more information about the device admin [CHAR LIMIT=30] -->
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import android.os.Bundle;
|
|||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -39,6 +40,8 @@ import android.widget.TextView;
|
|||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ShowAdminSupportDetailsDialog extends Activity
|
public class ShowAdminSupportDetailsDialog extends Activity
|
||||||
implements DialogInterface.OnDismissListener {
|
implements DialogInterface.OnDismissListener {
|
||||||
|
|
||||||
@@ -46,17 +49,20 @@ public class ShowAdminSupportDetailsDialog extends Activity
|
|||||||
|
|
||||||
private EnforcedAdmin mEnforcedAdmin;
|
private EnforcedAdmin mEnforcedAdmin;
|
||||||
private View mDialogView;
|
private View mDialogView;
|
||||||
|
private String mRestriction = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
mEnforcedAdmin = getAdminDetailsFromIntent(getIntent());
|
mEnforcedAdmin = getAdminDetailsFromIntent(getIntent());
|
||||||
|
mRestriction = getRestrictionFromIntent(getIntent());
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
mDialogView = LayoutInflater.from(builder.getContext()).inflate(
|
mDialogView = LayoutInflater.from(builder.getContext()).inflate(
|
||||||
R.layout.admin_support_details_dialog, null);
|
R.layout.admin_support_details_dialog, null);
|
||||||
initializeDialogViews(mDialogView, mEnforcedAdmin.component, mEnforcedAdmin.userId);
|
initializeDialogViews(mDialogView, mEnforcedAdmin.component, mEnforcedAdmin.userId,
|
||||||
|
mRestriction);
|
||||||
builder.setOnDismissListener(this)
|
builder.setOnDismissListener(this)
|
||||||
.setPositiveButton(R.string.okay, null)
|
.setPositiveButton(R.string.okay, null)
|
||||||
.setView(mDialogView)
|
.setView(mDialogView)
|
||||||
@@ -67,9 +73,12 @@ public class ShowAdminSupportDetailsDialog extends Activity
|
|||||||
public void onNewIntent(Intent intent) {
|
public void onNewIntent(Intent intent) {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
EnforcedAdmin admin = getAdminDetailsFromIntent(intent);
|
EnforcedAdmin admin = getAdminDetailsFromIntent(intent);
|
||||||
if (!mEnforcedAdmin.equals(admin)) {
|
String restriction = getRestrictionFromIntent(intent);
|
||||||
|
if (!mEnforcedAdmin.equals(admin) || !Objects.equals(mRestriction, restriction)) {
|
||||||
mEnforcedAdmin = admin;
|
mEnforcedAdmin = admin;
|
||||||
initializeDialogViews(mDialogView, mEnforcedAdmin.component, mEnforcedAdmin.userId);
|
mRestriction = restriction;
|
||||||
|
initializeDialogViews(mDialogView, mEnforcedAdmin.component, mEnforcedAdmin.userId,
|
||||||
|
mRestriction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +92,13 @@ public class ShowAdminSupportDetailsDialog extends Activity
|
|||||||
return admin;
|
return admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeDialogViews(View root, ComponentName admin, int userId) {
|
private String getRestrictionFromIntent(Intent intent) {
|
||||||
|
if (intent == null) return null;
|
||||||
|
return intent.getStringExtra(DevicePolicyManager.EXTRA_RESTRICTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeDialogViews(View root, ComponentName admin, int userId,
|
||||||
|
String restriction) {
|
||||||
if (admin != null) {
|
if (admin != null) {
|
||||||
if (!RestrictedLockUtils.isAdminInCurrentUserOrProfile(this, admin)
|
if (!RestrictedLockUtils.isAdminInCurrentUserOrProfile(this, admin)
|
||||||
|| !RestrictedLockUtils.isCurrentUserOrProfile(this, userId)) {
|
|| !RestrictedLockUtils.isCurrentUserOrProfile(this, userId)) {
|
||||||
@@ -106,9 +121,41 @@ public class ShowAdminSupportDetailsDialog extends Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setAdminSupportTitle(root, restriction);
|
||||||
setAdminSupportDetails(this, root, new EnforcedAdmin(admin, userId), true);
|
setAdminSupportDetails(this, root, new EnforcedAdmin(admin, userId), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setAdminSupportTitle(View root, String restriction) {
|
||||||
|
final TextView titleView = (TextView) root.findViewById(R.id.admin_support_dialog_title);
|
||||||
|
if (titleView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (restriction == null) {
|
||||||
|
titleView.setText(R.string.disabled_by_policy_title);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch(restriction) {
|
||||||
|
case UserManager.DISALLOW_ADJUST_VOLUME:
|
||||||
|
titleView.setText(R.string.disabled_by_policy_title_adjust_volume);
|
||||||
|
break;
|
||||||
|
case UserManager.DISALLOW_OUTGOING_CALLS:
|
||||||
|
titleView.setText(R.string.disabled_by_policy_title_outgoing_calls);
|
||||||
|
break;
|
||||||
|
case UserManager.DISALLOW_SMS:
|
||||||
|
titleView.setText(R.string.disabled_by_policy_title_sms);
|
||||||
|
break;
|
||||||
|
case DevicePolicyManager.POLICY_DISABLE_CAMERA:
|
||||||
|
titleView.setText(R.string.disabled_by_policy_title_camera);
|
||||||
|
break;
|
||||||
|
case DevicePolicyManager.POLICY_DISABLE_SCREEN_CAPTURE:
|
||||||
|
titleView.setText(R.string.disabled_by_policy_title_screen_capture);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Use general text if no specialized title applies
|
||||||
|
titleView.setText(R.string.disabled_by_policy_title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setAdminSupportDetails(final Activity activity, View root,
|
public static void setAdminSupportDetails(final Activity activity, View root,
|
||||||
final EnforcedAdmin enforcedAdmin, final boolean finishActivity) {
|
final EnforcedAdmin enforcedAdmin, final boolean finishActivity) {
|
||||||
if (enforcedAdmin == null) {
|
if (enforcedAdmin == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user