From bd918aad632f92ed33f0a1cd0de0e2a09e61edcb Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Thu, 21 Jan 2016 10:49:39 -0800 Subject: [PATCH] Don't show TextView "share" option for an unprovisioned device Bug 26600141 Change-Id: Ifc59752c146c2203a66cdd463b648a891ebf12c8 --- core/java/android/widget/TextView.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 81ebdb3bd3ff..7535caa8981f 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -645,6 +645,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ private Editor mEditor; + private static final int DEVICE_PROVISIONED_UNKNOWN = 0; + private static final int DEVICE_PROVISIONED_NO = 1; + private static final int DEVICE_PROVISIONED_YES = 2; + + /** + * Some special options such as sharing selected text should only be shown if the device + * is provisioned. Only check the provisioned state once for a given view instance. + */ + private int mDeviceProvisionedState = DEVICE_PROVISIONED_UNKNOWN; + /* * Kick-start the font cache for the zygote process (to pay the cost of * initializing freetype for our default font only once). @@ -9613,7 +9623,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } boolean canShare() { - return canCopy(); + return canCopy() && isDeviceProvisioned(); + } + + boolean isDeviceProvisioned() { + if (mDeviceProvisionedState == DEVICE_PROVISIONED_UNKNOWN) { + mDeviceProvisionedState = Settings.Global.getInt( + mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0 + ? DEVICE_PROVISIONED_YES + : DEVICE_PROVISIONED_NO; + } + return mDeviceProvisionedState == DEVICE_PROVISIONED_YES; } boolean canPaste() { -- 2.11.0