Merge "Allow DPMs to restrict Remote Input on Keyguard" into nyc-dev
am: ef505d628a
* commit 'ef505d628ae96f175fca871013da8c24271667dc':
Allow DPMs to restrict Remote Input on Keyguard
Change-Id: I5746a924564e8eb866b0c0e0a1e0205a38896f89
This commit is contained in:
@@ -15,14 +15,15 @@
|
||||
~ limitations under the License
|
||||
-->
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/lockscreen_remote_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="20dp"
|
||||
android:paddingStart="20dp"
|
||||
android:paddingEnd="?android:attr/dialogPreferredPadding"
|
||||
@@ -32,4 +33,13 @@
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/lockscreen_remote_input"
|
||||
/>
|
||||
</FrameLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/restricted_lock_icon_remote_input"
|
||||
android:layout_width="@dimen/restricted_icon_size"
|
||||
android:layout_height="@dimen/restricted_icon_size"
|
||||
android:src="@drawable/ic_info"
|
||||
android:layout_marginEnd="?android:attr/dialogPreferredPadding"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:scaleType="centerInside" />
|
||||
</LinearLayout>
|
@@ -65,7 +65,7 @@
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<CheckBox
|
||||
<com.android.settings.RestrictedCheckBox
|
||||
android:id="@+id/lockscreen_remote_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@@ -66,7 +66,7 @@
|
||||
|
||||
<!-- Place the checkbox inside RadioGroup and use SuwRadioButton style instead of
|
||||
SuwCheckBox style so that the checkbox and text is aligned with radio buttons. -->
|
||||
<CheckBox
|
||||
<com.android.settings.RestrictedRadioButton
|
||||
android:id="@+id/lockscreen_remote_input"
|
||||
style="@style/SuwRadioButton"
|
||||
android:layout_width="wrap_content"
|
||||
|
75
src/com/android/settings/RestrictedCheckBox.java
Normal file
75
src/com/android/settings/RestrictedCheckBox.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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
|
||||
*/
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
/**
|
||||
* A checkbox that can be restricted by device policy, in which case it shows a dialog explaining
|
||||
* what component restricted it.
|
||||
*/
|
||||
public class RestrictedCheckBox extends CheckBox {
|
||||
private Context mContext;
|
||||
private boolean mDisabledByAdmin;
|
||||
private EnforcedAdmin mEnforcedAdmin;
|
||||
|
||||
public RestrictedCheckBox(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public RestrictedCheckBox(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performClick() {
|
||||
if (mDisabledByAdmin) {
|
||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext, mEnforcedAdmin);
|
||||
return true;
|
||||
}
|
||||
return super.performClick();
|
||||
}
|
||||
|
||||
public void setDisabledByAdmin(EnforcedAdmin admin) {
|
||||
final boolean disabled = (admin != null);
|
||||
mEnforcedAdmin = admin;
|
||||
if (mDisabledByAdmin != disabled) {
|
||||
mDisabledByAdmin = disabled;
|
||||
RestrictedLockUtils.setTextViewAsDisabledByAdmin(mContext, this, mDisabledByAdmin);
|
||||
if (mDisabledByAdmin) {
|
||||
getButtonDrawable().setColorFilter(mContext.getColor(R.color.disabled_text_color),
|
||||
PorterDuff.Mode.MULTIPLY);
|
||||
} else {
|
||||
getButtonDrawable().clearColorFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDisabledByAdmin() {
|
||||
return mDisabledByAdmin;
|
||||
}
|
||||
}
|
@@ -288,6 +288,9 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
}
|
||||
|
||||
public void disableSuggestion(Tile suggestion) {
|
||||
if (mSuggestionParser == null) {
|
||||
return;
|
||||
}
|
||||
if (mSuggestionParser.dismissSuggestion(suggestion)) {
|
||||
mContext.getPackageManager().setComponentEnabledSetting(
|
||||
suggestion.intent.getComponent(),
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
@@ -177,6 +178,9 @@ public class ConfigureNotificationSettings extends SettingsPreferenceFragment {
|
||||
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
|
||||
}
|
||||
|
||||
mLockscreen.setRemoteInputRestricted(RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
|
||||
mContext, DevicePolicyManager.KEYGUARD_DISABLE_REMOTE_INPUT, UserHandle.myUserId()));
|
||||
|
||||
mLockscreen.setEntries(entries.toArray(new CharSequence[entries.size()]));
|
||||
mLockscreen.setEntryValues(values.toArray(new CharSequence[values.size()]));
|
||||
updateLockscreenNotifications();
|
||||
@@ -239,6 +243,10 @@ public class ConfigureNotificationSettings extends SettingsPreferenceFragment {
|
||||
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
|
||||
}
|
||||
|
||||
mLockscreen.setRemoteInputRestricted(RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
|
||||
mContext, DevicePolicyManager.KEYGUARD_DISABLE_REMOTE_INPUT,
|
||||
mProfileChallengeUserId));
|
||||
|
||||
mLockscreenProfile.setEntries(entries.toArray(new CharSequence[entries.size()]));
|
||||
mLockscreenProfile.setEntryValues(values.toArray(new CharSequence[values.size()]));
|
||||
// Work profile does not support this settings as we do not have a policy to enforce it yet
|
||||
|
@@ -19,6 +19,7 @@ package com.android.settings.notification;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.RestrictedListPreference;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
@@ -32,6 +33,7 @@ import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
@@ -42,6 +44,7 @@ public class NotificationLockscreenPreference extends RestrictedListPreference {
|
||||
private boolean mShowRemoteInput;
|
||||
private boolean mRemoteInputCheckBoxEnabled = true;
|
||||
private int mUserId = UserHandle.myUserId();
|
||||
private RestrictedLockUtils.EnforcedAdmin mAdminRestrictingRemoteInput;
|
||||
|
||||
public NotificationLockscreenPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -51,6 +54,10 @@ public class NotificationLockscreenPreference extends RestrictedListPreference {
|
||||
mRemoteInputCheckBoxEnabled = enabled;
|
||||
}
|
||||
|
||||
public void setRemoteInputRestricted(RestrictedLockUtils.EnforcedAdmin admin) {
|
||||
mAdminRestrictingRemoteInput = admin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
final Context context = getContext();
|
||||
@@ -81,9 +88,19 @@ public class NotificationLockscreenPreference extends RestrictedListPreference {
|
||||
protected void onDialogCreated(Dialog dialog) {
|
||||
super.onDialogCreated(dialog);
|
||||
dialog.create();
|
||||
CheckBox view = (CheckBox) dialog.findViewById(R.id.lockscreen_remote_input);
|
||||
view.setChecked(!mAllowRemoteInput);
|
||||
view.setOnCheckedChangeListener(mListener);
|
||||
CheckBox checkbox = (CheckBox) dialog.findViewById(R.id.lockscreen_remote_input);
|
||||
checkbox.setChecked(!mAllowRemoteInput);
|
||||
checkbox.setOnCheckedChangeListener(mListener);
|
||||
checkbox.setEnabled(mAdminRestrictingRemoteInput == null);
|
||||
|
||||
View restricted = dialog.findViewById(R.id.restricted_lock_icon_remote_input);
|
||||
restricted.setVisibility(mAdminRestrictingRemoteInput == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
if (mAdminRestrictingRemoteInput != null) {
|
||||
checkbox.setClickable(false);
|
||||
dialog.findViewById(com.android.internal.R.id.customPanel)
|
||||
.setOnClickListener(mListener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,7 +139,7 @@ public class NotificationLockscreenPreference extends RestrictedListPreference {
|
||||
}
|
||||
|
||||
private class Listener implements DialogInterface.OnClickListener,
|
||||
CompoundButton.OnCheckedChangeListener {
|
||||
CompoundButton.OnCheckedChangeListener, View.OnClickListener {
|
||||
|
||||
private final DialogInterface.OnClickListener mInner;
|
||||
private View mView;
|
||||
@@ -150,5 +167,13 @@ public class NotificationLockscreenPreference extends RestrictedListPreference {
|
||||
public void setView(View view) {
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == com.android.internal.R.id.customPanel) {
|
||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(),
|
||||
mAdminRestrictingRemoteInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -32,6 +33,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.RestrictedCheckBox;
|
||||
import com.android.settings.RestrictedRadioButton;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
@@ -81,7 +83,7 @@ public class RedactionInterstitial extends SettingsActivity {
|
||||
private RadioGroup mRadioGroup;
|
||||
private RestrictedRadioButton mShowAllButton;
|
||||
private RestrictedRadioButton mRedactSensitiveButton;
|
||||
private CheckBox mRemoteInputCheckbox;
|
||||
private RestrictedCheckBox mRemoteInputCheckbox;
|
||||
private int mUserId;
|
||||
|
||||
@Override
|
||||
@@ -102,7 +104,8 @@ public class RedactionInterstitial extends SettingsActivity {
|
||||
mShowAllButton = (RestrictedRadioButton) view.findViewById(R.id.show_all);
|
||||
mRedactSensitiveButton =
|
||||
(RestrictedRadioButton) view.findViewById(R.id.redact_sensitive);
|
||||
mRemoteInputCheckbox = (CheckBox) view.findViewById(R.id.lockscreen_remote_input);
|
||||
mRemoteInputCheckbox =
|
||||
(RestrictedCheckBox) view.findViewById(R.id.lockscreen_remote_input);
|
||||
mRemoteInputCheckbox.setOnCheckedChangeListener(this);
|
||||
|
||||
mRadioGroup.setOnCheckedChangeListener(this);
|
||||
@@ -129,6 +132,9 @@ public class RedactionInterstitial extends SettingsActivity {
|
||||
KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
|
||||
checkNotificationFeaturesAndSetDisabled(mRedactSensitiveButton,
|
||||
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
|
||||
mRemoteInputCheckbox.setDisabledByAdmin(
|
||||
RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(getActivity(),
|
||||
DevicePolicyManager.KEYGUARD_DISABLE_REMOTE_INPUT, mUserId));
|
||||
loadFromSettings();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user