summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjunjiez <junjiez@codeaurora.org>2016-08-05 10:59:39 +0800
committerArne Coucheron <arco68@gmail.com>2016-09-08 01:57:21 +0200
commitc79bd4d34880c7be662208ddfe35d81559a3459a (patch)
treedb79069425c5a09402c57c1f1a70f2bb448a7970
parentcef0045f3c2fb06543be8cdccf6e42364b997ace (diff)
downloadandroid_packages_apps_Snap-c79bd4d34880c7be662208ddfe35d81559a3459a.zip
android_packages_apps_Snap-c79bd4d34880c7be662208ddfe35d81559a3459a.tar.gz
android_packages_apps_Snap-c79bd4d34880c7be662208ddfe35d81559a3459a.tar.bz2
SnapdragonCamera: fix invoke camera failture caused by permissions
When the other apps want to invoke camera by intent, if the permission needed by camera is not granted, camera will restart and the intent will be lost, so check the permission first before invoke camera with intents Change-Id: I2c403d2cd78453cc8afcda374969dac87a6becf6 CRs-Fixed: 1047924
-rwxr-xr-xAndroidManifest.xml34
-rw-r--r--src/com/android/camera/CameraActivity.java3
-rw-r--r--src/com/android/camera/PermissionsActivity.java26
3 files changed, 44 insertions, 19 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index fe8ced2..23b517a 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -52,18 +52,6 @@
android:taskAffinity="com.android.camera.CameraActivity"
android:theme="@style/Theme.Camera"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" >
- <intent-filter>
- <action android:name="android.media.action.IMAGE_CAPTURE" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.media.action.STILL_IMAGE_CAMERA" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
</activity>
<activity
@@ -88,12 +76,32 @@
</intent-filter>
</activity-alias>
+ <activity-alias
+ android:name="com.android.camera.PhotoCamera"
+ android:icon="@mipmap/ic_launcher_camera"
+ android:label="@string/app_name"
+ android:launchMode="singleTop"
+ android:targetActivity="com.android.camera.PermissionsActivity">
+ <intent-filter>
+ <action android:name="android.media.action.IMAGE_CAPTURE" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.media.action.STILL_IMAGE_CAMERA" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity-alias>
+
<!-- Video camera and capture use the Camcorder label and icon. -->
<activity-alias
android:name="com.android.camera.VideoCamera"
android:label="@string/video_camera_label"
android:launchMode="singleTop"
- android:targetActivity="com.android.camera.CameraActivity">
+ android:targetActivity="com.android.camera.PermissionsActivity">
<intent-filter>
<action android:name="android.media.action.VIDEO_CAMERA" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index c4cd401..3458e8c 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -1739,8 +1739,7 @@ public class CameraActivity extends Activity
mHasCriticalPermissions = false;
}
- if ((checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) !=
- PackageManager.PERMISSION_GRANTED) || !mHasCriticalPermissions) {
+ if (!mHasCriticalPermissions) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean isRequestShown = prefs.getBoolean(CameraSettings.KEY_REQUEST_PERMISSION, false);
if(!isRequestShown || !mHasCriticalPermissions) {
diff --git a/src/com/android/camera/PermissionsActivity.java b/src/com/android/camera/PermissionsActivity.java
index c720d21..e623be2 100644
--- a/src/com/android/camera/PermissionsActivity.java
+++ b/src/com/android/camera/PermissionsActivity.java
@@ -33,16 +33,20 @@ public class PermissionsActivity extends Activity {
private boolean mFlagHasMicrophonePermission;
private boolean mFlagHasStoragePermission;
private boolean mCriticalPermissionDenied;
+ private Intent mIntent;
+ private boolean mIsReturnResult;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ mIntent = getIntent();
+ mIsReturnResult = false;
}
@Override
protected void onResume() {
super.onResume();
- if (!mCriticalPermissionDenied) {
+ if (!mCriticalPermissionDenied && !mIsReturnResult) {
mNumPermissionsToRequest = 0;
checkPermissions();
} else {
@@ -164,9 +168,16 @@ public class PermissionsActivity extends Activity {
}
private void handlePermissionsSuccess() {
- Intent intent = new Intent(this, CameraActivity.class);
- startActivity(intent);
- finish();
+ if (mIntent != null) {
+ mIsReturnResult = true;
+ mIntent.setClass(this, CameraActivity.class);
+ startActivityForResult(mIntent, 1);
+ } else {
+ mIsReturnResult = false;
+ Intent intent = new Intent(this, CameraActivity.class);
+ startActivity(intent);
+ finish();
+ }
}
private void handlePermissionsFailure() {
@@ -192,4 +203,11 @@ public class PermissionsActivity extends Activity {
})
.show();
}
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ setResult(resultCode, data);
+ finish();
+ }
}