diff options
author | calderwoodra <calderwoodra@google.com> | 2017-07-17 13:17:21 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-07-25 09:03:04 -0700 |
commit | 758e559760fad15661635854c85116366bc091a4 (patch) | |
tree | 9947967b9d71a555c6957a444891449e95ddf347 /java/com/android/dialer/util | |
parent | 55e2443f1aa9619a3330d2d7496ea5272e5266d9 (diff) |
Replaced video calling/camera permission dialog with a toast.
Since we are given the camera permission by default for video calling, we don't
need to request it from the framework. But, for privacy reasons, we still need
to tell the user that we have it.
Since we're changing the preference for call composer, v10.1 users will see this
this toast again if they've never made a video call.
The toast is shown in the following situations:
1. If a user receives a video call
2. If a user makes a video call
3. If the user opens call composer
The toast doesn't show:
1. If the user has already seen the toast anywhere before
2. If the user has revoked the system permission and grants it
with a system dialog
Bug: 36608790,63405063
Test: manual
PiperOrigin-RevId: 162258610
Change-Id: Ie93413c9c2e1f083919e7183eb920100b06fd4a4
Diffstat (limited to 'java/com/android/dialer/util')
-rw-r--r-- | java/com/android/dialer/util/PermissionsUtil.java | 26 | ||||
-rw-r--r-- | java/com/android/dialer/util/res/values/strings.xml | 2 |
2 files changed, 28 insertions, 0 deletions
diff --git a/java/com/android/dialer/util/PermissionsUtil.java b/java/com/android/dialer/util/PermissionsUtil.java index 34828317d..cb973680d 100644 --- a/java/com/android/dialer/util/PermissionsUtil.java +++ b/java/com/android/dialer/util/PermissionsUtil.java @@ -38,6 +38,7 @@ import android.content.pm.PackageManager; import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; import android.support.v4.content.LocalBroadcastManager; +import android.widget.Toast; import com.android.dialer.common.LogUtil; import java.util.ArrayList; import java.util.Arrays; @@ -47,6 +48,7 @@ import java.util.List; /** Utility class to help with runtime permissions. */ public class PermissionsUtil { + private static final String PREFERENCE_CAMERA_ALLOWED_BY_USER = "camera_allowed_by_user"; private static final String PERMISSION_PREFERENCE = "dialer_permissions"; private static final String CEQUINT_PERMISSION = "com.cequint.ecid.CALLER_ID_LOOKUP"; @@ -207,4 +209,28 @@ public class PermissionsUtil { } return permissionsCurrentlyDenied.toArray(new String[permissionsCurrentlyDenied.size()]); } + + /** + * Since we are granted the camera permission automatically as a first-party app, we need to show + * a toast to let users know the permission was granted for privacy reasons. + * + * @return true if we've already shown the camera privacy toast. + */ + public static boolean hasCameraPrivacyToastShown(@NonNull Context context) { + return DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(context) + .getBoolean(PREFERENCE_CAMERA_ALLOWED_BY_USER, false); + } + + public static void showCameraPermissionToast(@NonNull Context context) { + Toast.makeText(context, context.getString(R.string.camera_privacy_text), Toast.LENGTH_LONG) + .show(); + setCameraPrivacyToastShown(context); + } + + public static void setCameraPrivacyToastShown(@NonNull Context context) { + DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(context) + .edit() + .putBoolean(PREFERENCE_CAMERA_ALLOWED_BY_USER, true) + .apply(); + } } diff --git a/java/com/android/dialer/util/res/values/strings.xml b/java/com/android/dialer/util/res/values/strings.xml index 43ea6e31a..a4d944c19 100644 --- a/java/com/android/dialer/util/res/values/strings.xml +++ b/java/com/android/dialer/util/res/values/strings.xml @@ -39,4 +39,6 @@ <!-- Text for button which indicates that the user wants to proceed with an action. --> <string name="dialog_continue">Continue</string> + <!-- Text presented to the user explaining that we have enabled the camera permission automatically [CHAR LIMIT=NONE] --> + <string name="camera_privacy_text">Camera permission enabled</string> </resources> |