Merge "Snap for 8992082 from 52f17b820abfbd9590215915d95aea878174b85e to gki13-boot-release" into gki13-boot-release
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a7f188f..b9cf2a7 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -31,6 +31,7 @@
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="com.android.gallery3d.permission.GALLERY_PROVIDER" />
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<supports-screens android:smallScreens="false"
android:normalScreens="true" android:largeScreens="true"
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index f2d568e..4659692 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -26,9 +26,6 @@
import android.content.res.Configuration;
import android.graphics.Rect;
import android.net.Uri;
-import android.nfc.NfcAdapter;
-import android.nfc.NfcAdapter.CreateBeamUrisCallback;
-import android.nfc.NfcEvent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -179,8 +176,6 @@
private Path mDeletePath;
private boolean mDeleteIsFocus; // whether the deleted item was in focus
- private Uri[] mNfcPushUris = new Uri[1];
-
private final MyMenuVisibilityListener mMenuVisibilityListener =
new MyMenuVisibilityListener();
@@ -364,7 +359,6 @@
Intent shareIntent = createShareIntent(mCurrentPhoto);
mActionBar.setShareIntents(panoramaIntent, shareIntent, PhotoPage.this);
- setNfcBeamPushUri(contentUri);
}
break;
}
@@ -383,7 +377,6 @@
mSetPathString = data.getString(KEY_MEDIA_SET_PATH);
mReadOnlyView = data.getBoolean(KEY_READONLY);
mOriginalSetPathString = mSetPathString;
- setupNfcBeamPush();
String itemPathString = data.getString(KEY_MEDIA_ITEM_PATH);
Path itemPath = itemPathString != null ?
Path.fromString(data.getString(KEY_MEDIA_ITEM_PATH)) :
@@ -617,26 +610,6 @@
}
}
- @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
- private void setupNfcBeamPush() {
- if (!ApiHelper.HAS_SET_BEAM_PUSH_URIS) return;
-
- NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mActivity);
- if (adapter != null) {
- adapter.setBeamPushUris(null, mActivity);
- adapter.setBeamPushUrisCallback(new CreateBeamUrisCallback() {
- @Override
- public Uri[] createBeamUris(NfcEvent event) {
- return mNfcPushUris;
- }
- }, mActivity);
- }
- }
-
- private void setNfcBeamPushUri(Uri uri) {
- mNfcPushUris[0] = uri;
- }
-
private static Intent createShareIntent(MediaObject mediaObject) {
int type = mediaObject.getMediaType();
return new Intent(Intent.ACTION_SEND)
diff --git a/src/com/android/gallery3d/app/VideoUtils.java b/src/com/android/gallery3d/app/VideoUtils.java
index 359cf76..b969586 100644
--- a/src/com/android/gallery3d/app/VideoUtils.java
+++ b/src/com/android/gallery3d/app/VideoUtils.java
@@ -174,6 +174,11 @@
retrieverSrc.setDataSource(srcPath);
String degreesString = retrieverSrc.extractMetadata(
MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);
+ try {
+ retrieverSrc.release();
+ } catch (IOException e) {
+ // Ignore errors occurred while releasing the MediaMetadataRetriever.
+ }
if (degreesString != null) {
int degrees = Integer.parseInt(degreesString);
if (degrees >= 0) {
diff --git a/src/com/android/gallery3d/util/SaveVideoFileUtils.java b/src/com/android/gallery3d/util/SaveVideoFileUtils.java
index bef75ba..7c6ba5e 100644
--- a/src/com/android/gallery3d/util/SaveVideoFileUtils.java
+++ b/src/com/android/gallery3d/util/SaveVideoFileUtils.java
@@ -28,6 +28,7 @@
import com.android.gallery3d.filtershow.tools.SaveImage.ContentResolverQueryCallback;
import java.io.File;
+import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -101,7 +102,7 @@
values.put(Video.Media.DATE_ADDED, nowInSec);
values.put(Video.Media.DATA, mDstFileInfo.mFile.getAbsolutePath());
values.put(Video.Media.SIZE, mDstFileInfo.mFile.length());
- int durationMs = retriveVideoDurationMs(mDstFileInfo.mFile.getPath());
+ int durationMs = retrieveVideoDurationMs(mDstFileInfo.mFile.getPath());
values.put(Video.Media.DURATION, durationMs);
// Copy the data taken and location info from src.
String[] projection = new String[] {
@@ -137,7 +138,7 @@
return contentResolver.insert(Video.Media.EXTERNAL_CONTENT_URI, values);
}
- public static int retriveVideoDurationMs(String path) {
+ private static int retrieveVideoDurationMs(String path) {
int durationMs = 0;
// Calculate the duration of the destination file.
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
@@ -147,7 +148,11 @@
if (duration != null) {
durationMs = Integer.parseInt(duration);
}
- retriever.release();
+ try {
+ retriever.release();
+ } catch (IOException e) {
+ // Ignore errors occurred while releasing the retriever.
+ }
return durationMs;
}
diff --git a/src/com/android/photos/SelectionManager.java b/src/com/android/photos/SelectionManager.java
index 98b827b..eccf73f 100644
--- a/src/com/android/photos/SelectionManager.java
+++ b/src/com/android/photos/SelectionManager.java
@@ -19,13 +19,9 @@
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
-import android.nfc.NfcAdapter;
-import android.nfc.NfcAdapter.CreateBeamUrisCallback;
-import android.nfc.NfcEvent;
import android.provider.MediaStore.Files.FileColumns;
import android.widget.ShareActionProvider;
-import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.util.GalleryUtils;
@@ -33,7 +29,6 @@
public class SelectionManager {
private Activity mActivity;
- private NfcAdapter mNfcAdapter;
private SelectedUriSource mUriSource;
private Intent mShareIntent = new Intent();
@@ -43,18 +38,6 @@
public SelectionManager(Activity activity) {
mActivity = activity;
- if (ApiHelper.AT_LEAST_16) {
- mNfcAdapter = NfcAdapter.getDefaultAdapter(mActivity);
- mNfcAdapter.setBeamPushUrisCallback(new CreateBeamUrisCallback() {
- @Override
- public Uri[] createBeamUris(NfcEvent arg0) {
- // This will have been preceded by a call to onItemSelectedStateChange
- if (mCachedShareableUris == null) return null;
- return mCachedShareableUris.toArray(
- new Uri[mCachedShareableUris.size()]);
- }
- }, mActivity);
- }
}
public void setSelectedUriSource(SelectedUriSource source) {