From ae093e242813bf21a7a1ea526430ab79b5c107da Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Thu, 1 Sep 2016 15:03:51 +0100 Subject: [PATCH 1/2] Show approprate text when enrolling fingerprint Inform the user that unlocking device by fingerprint is disabled if the device admin has disallowed it. Bug: 27201226 Change-Id: Id1694f07a9421ebfe3c777f2a6b624a836bff2d5 --- res/values/strings.xml | 4 ++++ .../FingerprintEnrollIntroduction.java | 24 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 61f370b5eb8..633c111a8bc 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -746,8 +746,12 @@ Unlock with fingerprint + + Use your fingerprint Just touch the fingerprint sensor to unlock your phone, authorize purchases, or sign in to apps. Be careful whose fingerprints you add. Even one added print can do any of these things.\n\nNote: Your fingerprint may be less secure than a strong pattern or PIN. + + Just touch the fingerprint sensor to authorize purchases, or sign in to apps. Be careful whose fingerprints you add. Even one added print can do any of these things.\n\nNote: You can\u2019t use your fingerprint to unlock this device. For more information, contact your organization\u2019s admin. Just touch the fingerprint sensor to unlock your phone, authorize purchases, or sign in to apps. Be careful whose fingerprints you add. Even one added print can do any of these things.\n\nNote: Your fingerprint may be less secure than a strong pattern or PIN. diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollIntroduction.java b/src/com/android/settings/fingerprint/FingerprintEnrollIntroduction.java index 23755fdf5db..627cb78eb41 100644 --- a/src/com/android/settings/fingerprint/FingerprintEnrollIntroduction.java +++ b/src/com/android/settings/fingerprint/FingerprintEnrollIntroduction.java @@ -26,12 +26,14 @@ import android.os.UserManager; import android.util.Log; import android.view.View; import android.widget.Button; +import android.widget.TextView; import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.settings.ChooseLockGeneric; import com.android.settings.ChooseLockSettingsHelper; import com.android.settings.R; import com.android.settingslib.HelpUtils; +import com.android.settingslib.RestrictedLockUtils; import com.android.setupwizardlib.span.LinkSpan; /** @@ -48,12 +50,21 @@ public class FingerprintEnrollIntroduction extends FingerprintEnrollBase private UserManager mUserManager; private boolean mHasPassword; + private boolean mFingerprintUnlockDisabledByAdmin; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + mFingerprintUnlockDisabledByAdmin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled( + this, DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT, mUserId) != null; + setContentView(R.layout.fingerprint_enroll_introduction); - setHeaderText(R.string.security_settings_fingerprint_enroll_introduction_title); + if (mFingerprintUnlockDisabledByAdmin) { + setHeaderText(R.string + .security_settings_fingerprint_enroll_introduction_title_unlock_disabled); + } else { + setHeaderText(R.string.security_settings_fingerprint_enroll_introduction_title); + } final Button cancelButton = (Button) findViewById(R.id.fingerprint_cancel_button); cancelButton.setOnClickListener(this); @@ -160,6 +171,17 @@ public class FingerprintEnrollIntroduction extends FingerprintEnrollBase finish(); } + @Override + protected void initViews() { + super.initViews(); + + TextView description = (TextView) findViewById(R.id.description_text); + if (mFingerprintUnlockDisabledByAdmin) { + description.setText(R.string + .security_settings_fingerprint_enroll_introduction_message_unlock_disabled); + } + } + @Override public void onClick(LinkSpan span) { if ("url".equals(span.getId())) { From 7bd19b889173477a21d16573b13f468ccab80f8b Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Mon, 12 Sep 2016 15:00:53 -0700 Subject: [PATCH 2/2] Add ability to disable data warning. - Add a preference to disable data warning. - Disable data usage chart in summary page when data warning is turned off. Bug: 26934313 Test: Manually turned on/off data warning and inspected UI. Test: ag/1440361 Change-Id: I6d5b86b8502647781c52cf940f276e1969251b59 --- res/xml/billing_cycle.xml | 4 +++ .../android/settings/SummaryPreference.java | 22 +++++++++--- .../datausage/BillingCycleSettings.java | 34 ++++++++++++++++--- .../settings/datausage/DataUsageSummary.java | 18 +++++++--- 4 files changed, 64 insertions(+), 14 deletions(-) diff --git a/res/xml/billing_cycle.xml b/res/xml/billing_cycle.xml index 9beebce6872..8c77ad624ee 100644 --- a/res/xml/billing_cycle.xml +++ b/res/xml/billing_cycle.xml @@ -21,6 +21,10 @@ android:key="billing_cycle" android:title="@string/billing_cycle" /> + + diff --git a/src/com/android/settings/SummaryPreference.java b/src/com/android/settings/SummaryPreference.java index 38449b1e03f..d129661c02c 100644 --- a/src/com/android/settings/SummaryPreference.java +++ b/src/com/android/settings/SummaryPreference.java @@ -34,6 +34,7 @@ public class SummaryPreference extends Preference { private int mLeft, mMiddle, mRight; private boolean mColorsSet = false; + private boolean mChartEnabled = true; private float mLeftRatio, mMiddleRatio, mRightRatio; private String mStartLabel; private String mEndLabel; @@ -43,6 +44,13 @@ public class SummaryPreference extends Preference { setLayoutResource(R.layout.settings_summary_preference); } + public void setChartEnabled(boolean enabled) { + if (mChartEnabled != enabled) { + mChartEnabled = enabled; + notifyChanged(); + } + } + public void setAmount(String amount) { mAmount = amount; if (mAmount != null && mUnits != null) { @@ -85,12 +93,18 @@ public class SummaryPreference extends Preference { super.onBindViewHolder(holder); LinearColorBar colorBar = (LinearColorBar) holder.itemView.findViewById(R.id.color_bar); - colorBar.setRatios(mLeftRatio, mMiddleRatio, mRightRatio); - if (mColorsSet) { - colorBar.setColors(mLeft, mMiddle, mRight); + + if (mChartEnabled) { + colorBar.setVisibility(View.VISIBLE); + colorBar.setRatios(mLeftRatio, mMiddleRatio, mRightRatio); + if (mColorsSet) { + colorBar.setColors(mLeft, mMiddle, mRight); + } + } else { + colorBar.setVisibility(View.GONE); } - if (!TextUtils.isEmpty(mStartLabel) || !TextUtils.isEmpty(mEndLabel)) { + if (mChartEnabled && (!TextUtils.isEmpty(mStartLabel) || !TextUtils.isEmpty(mEndLabel))) { holder.findViewById(R.id.label_bar).setVisibility(View.VISIBLE); ((TextView) holder.findViewById(android.R.id.text1)).setText(mStartLabel); ((TextView) holder.findViewById(android.R.id.text2)).setText(mEndLabel); diff --git a/src/com/android/settings/datausage/BillingCycleSettings.java b/src/com/android/settings/datausage/BillingCycleSettings.java index 796aad77fbc..d755a7b8247 100644 --- a/src/com/android/settings/datausage/BillingCycleSettings.java +++ b/src/com/android/settings/datausage/BillingCycleSettings.java @@ -34,6 +34,7 @@ import android.view.View; import android.widget.EditText; import android.widget.NumberPicker; import android.widget.Spinner; + import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.settings.R; import com.android.settingslib.NetworkPolicyEditor; @@ -55,6 +56,7 @@ public class BillingCycleSettings extends DataUsageBase implements private static final String TAG_WARNING_EDITOR = "warningEditor"; private static final String KEY_BILLING_CYCLE = "billing_cycle"; + private static final String KEY_SET_DATA_WARNING = "set_data_warning"; private static final String KEY_DATA_WARNING = "data_warning"; private static final String KEY_SET_DATA_LIMIT = "set_data_limit"; private static final String KEY_DATA_LIMIT = "data_limit"; @@ -62,6 +64,7 @@ public class BillingCycleSettings extends DataUsageBase implements private NetworkTemplate mNetworkTemplate; private Preference mBillingCycle; private Preference mDataWarning; + private SwitchPreference mEnableDataWarning; private SwitchPreference mEnableDataLimit; private Preference mDataLimit; private DataUsageController mDataUsageController; @@ -77,6 +80,8 @@ public class BillingCycleSettings extends DataUsageBase implements addPreferencesFromResource(R.xml.billing_cycle); mBillingCycle = findPreference(KEY_BILLING_CYCLE); + mEnableDataWarning = (SwitchPreference) findPreference(KEY_SET_DATA_WARNING); + mEnableDataWarning.setOnPreferenceChangeListener(this); mDataWarning = findPreference(KEY_DATA_WARNING); mEnableDataLimit = (SwitchPreference) findPreference(KEY_SET_DATA_LIMIT); mEnableDataLimit.setOnPreferenceChangeListener(this); @@ -93,10 +98,15 @@ public class BillingCycleSettings extends DataUsageBase implements NetworkPolicy policy = services.mPolicyEditor.getPolicy(mNetworkTemplate); mBillingCycle.setSummary(getString(R.string.billing_cycle_summary, policy != null ? policy.cycleDay : 1)); - mDataWarning.setSummary(Formatter.formatFileSize(getContext(), - policy != null - ? policy.warningBytes - : mDataUsageController.getDefaultWarningLevel())); + if (policy != null && policy.warningBytes != WARNING_DISABLED) { + mDataWarning.setSummary(Formatter.formatFileSize(getContext(), policy.warningBytes)); + mDataWarning.setEnabled(true); + mEnableDataWarning.setChecked(true); + } else { + mDataWarning.setSummary(null); + mDataWarning.setEnabled(false); + mEnableDataWarning.setChecked(false); + } if (policy != null && policy.limitBytes != LIMIT_DISABLED) { mDataLimit.setSummary(Formatter.formatFileSize(getContext(), policy.limitBytes)); mDataLimit.setEnabled(true); @@ -133,6 +143,14 @@ public class BillingCycleSettings extends DataUsageBase implements setPolicyLimitBytes(LIMIT_DISABLED); } return true; + } else if (mEnableDataWarning == preference) { + boolean enabled = (Boolean) newValue; + if (enabled) { + setPolicyWarningBytes(mDataUsageController.getDefaultWarningLevel()); + } else { + setPolicyWarningBytes(WARNING_DISABLED); + } + return true; } return false; } @@ -148,6 +166,12 @@ public class BillingCycleSettings extends DataUsageBase implements updatePrefs(); } + private void setPolicyWarningBytes(long warningBytes) { + if (LOGD) Log.d(TAG, "setPolicyWarningBytes()"); + services.mPolicyEditor.setPolicyWarningBytes(mNetworkTemplate, warningBytes); + updatePrefs(); + } + @Override public NetworkPolicyEditor getNetworkPolicyEditor() { return services.mPolicyEditor; @@ -255,7 +279,7 @@ public class BillingCycleSettings extends DataUsageBase implements bytesString = "0"; } final long bytes = (long) (Float.valueOf(bytesString) - * (spinner.getSelectedItemPosition() == 0 ? MB_IN_BYTES : GB_IN_BYTES)); + * (spinner.getSelectedItemPosition() == 0 ? MB_IN_BYTES : GB_IN_BYTES)); if (isLimit) { editor.setPolicyLimitBytes(template, bytes); } else { diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java index f975d115804..fb05699a33c 100644 --- a/src/com/android/settings/datausage/DataUsageSummary.java +++ b/src/com/android/settings/datausage/DataUsageSummary.java @@ -246,16 +246,24 @@ public class DataUsageSummary extends DataUsageBase implements Indexable, DataUs formatTitle(context, getString(mDataUsageTemplate), info.usageLevel)); long limit = mDataInfoController.getSummaryLimit(info); mSummaryPreference.setSummary(info.period); - mSummaryPreference.setLabels(Formatter.formatFileSize(context, 0), - Formatter.formatFileSize(context, limit)); - mSummaryPreference.setRatios(info.usageLevel / (float) limit, 0, - (limit - info.usageLevel) / (float) limit); + + if (limit <= 0) { + mSummaryPreference.setChartEnabled(false); + } else { + mSummaryPreference.setChartEnabled(true); + mSummaryPreference.setLabels(Formatter.formatFileSize(context, 0), + Formatter.formatFileSize(context, limit)); + mSummaryPreference.setRatios(info.usageLevel / (float) limit, 0, + (limit - info.usageLevel) / (float) limit); + } } - if (mLimitPreference != null) { + if (mLimitPreference != null && (info.warningLevel > 0 || info.limitLevel > 0)) { String warning = Formatter.formatFileSize(context, info.warningLevel); String limit = Formatter.formatFileSize(context, info.limitLevel); mLimitPreference.setSummary(getString(info.limitLevel <= 0 ? R.string.cell_warning_only : R.string.cell_warning_and_limit, warning, limit)); + } else if (mLimitPreference != null) { + mLimitPreference.setSummary(null); } PreferenceScreen screen = getPreferenceScreen();