summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/CameraActivity.java
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-07-19 18:11:05 -0700
committerSteve Kondik <steve@cyngn.com>2016-08-18 15:07:20 -0700
commit7d7a688e13c9ae8e958387ba0207c7a4af0e4df0 (patch)
tree666b825fc98eb5dbcb7f71bd9cd83448b7c74db8 /src/com/android/camera/CameraActivity.java
parent219fbf4d3d7c47039c79822af26bace2849375e4 (diff)
downloadandroid_packages_apps_Snap-7d7a688e13c9ae8e958387ba0207c7a4af0e4df0.tar.gz
android_packages_apps_Snap-7d7a688e13c9ae8e958387ba0207c7a4af0e4df0.tar.bz2
android_packages_apps_Snap-7d7a688e13c9ae8e958387ba0207c7a4af0e4df0.zip
SnapdragonCamera: Remove custom location permission request window
When user enables the GPS locaion setting, use Android's run-time permission request interface to get the permission. Change-Id: Ib17171aeff5ccf20e2b00da08243dee1a3383611 CRs-Fixed: 1038039
Diffstat (limited to 'src/com/android/camera/CameraActivity.java')
-rw-r--r--src/com/android/camera/CameraActivity.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index a22a7ae41..0e0978d83 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -162,6 +162,9 @@ public class CameraActivity extends Activity
private static final int HIDE_ACTION_BAR = 1;
private static final long SHOW_ACTION_BAR_TIMEOUT_MS = 3000;
+ /** Permission request code */
+ private static final int PERMISSIONS_REQUEST_ACCESS_COARSE_LOCATION = 1;
+
/** Whether onResume should reset the view to the preview. */
private boolean mResetToPreviewOnResume = true;
@@ -1971,6 +1974,37 @@ public class CameraActivity extends Activity
return mInCameraApp;
}
+ public void requestLocationPermission() {
+ if (checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED) {
+ Log.v(TAG, "Request Location permission");
+ mCurrentModule.waitingLocationPermissionResult(true);
+ requestPermissions(
+ new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
+ PERMISSIONS_REQUEST_ACCESS_COARSE_LOCATION);
+ }
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode,
+ String permissions[], int[] grantResults) {
+ switch (requestCode) {
+ case PERMISSIONS_REQUEST_ACCESS_COARSE_LOCATION: {
+ // If request is cancelled, the result arrays are empty.
+ mCurrentModule.waitingLocationPermissionResult(false);
+ if (grantResults.length > 0
+ && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ Log.v(TAG, "Location permission is granted");
+ mCurrentModule.enableRecordingLocation(true);
+ } else {
+ Log.w(TAG, "Location permission is denied");
+ mCurrentModule.enableRecordingLocation(false);
+ }
+ break;
+ }
+ }
+ }
+
@Override
public void onModuleSelected(int moduleIndex) {
if (mCurrentModuleIndex == moduleIndex) {