diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2018-09-10 02:17:12 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2018-09-10 02:17:12 -0700 |
commit | 32b1b58465e7f4b79d37f22594ce0d38a1c3a9f0 (patch) | |
tree | 2d018b97c7644872780899ca5b07ce11318219fd /src | |
parent | a5be66738d693e3be2c6df60de7f6cef77cdb333 (diff) | |
parent | e3e73ab80b01e0c4ea11412e032626a363da97d9 (diff) | |
download | android_packages_apps_Gallery2-32b1b58465e7f4b79d37f22594ce0d38a1c3a9f0.tar.gz android_packages_apps_Gallery2-32b1b58465e7f4b79d37f22594ce0d38a1c3a9f0.tar.bz2 android_packages_apps_Gallery2-32b1b58465e7f4b79d37f22594ce0d38a1c3a9f0.zip |
Merge e3e73ab80b01e0c4ea11412e032626a363da97d9 on remote branch
Change-Id: Iee1d62acc65d10f81f62878aa7a009770e05be37
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/gallery3d/app/MovieActivity.java | 17 | ||||
-rwxr-xr-x | src/com/android/gallery3d/app/MoviePlayer.java | 16 | ||||
-rwxr-xr-x | src/com/android/gallery3d/app/MuteVideo.java | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | src/com/android/gallery3d/app/PackagesMonitor.java | 25 | ||||
-rwxr-xr-x[-rw-r--r--] | src/com/android/gallery3d/app/TrimVideo.java | 8 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java | 1 | ||||
-rwxr-xr-x | src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java | 19 | ||||
-rwxr-xr-x[-rw-r--r--] | src/com/android/gallery3d/gadget/WidgetConfigure.java | 9 | ||||
-rw-r--r-- | src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java | 38 |
9 files changed, 122 insertions, 18 deletions
diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java index 9b274c2db..f5e7a65fb 100644 --- a/src/com/android/gallery3d/app/MovieActivity.java +++ b/src/com/android/gallery3d/app/MovieActivity.java @@ -49,6 +49,7 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; +import android.os.SystemProperties; import android.provider.MediaStore; import android.provider.OpenableColumns; import android.view.Gravity; @@ -241,13 +242,15 @@ public class MovieActivity extends AbstractPermissionActivity { // But for the performance (and battery), we remove the background here. win.setBackgroundDrawable(null); initMovieHooker(intent, savedInstanceState); - // Determine available/supported effects - final Descriptor[] effects = AudioEffect.queryEffects(); - for (final Descriptor effect : effects) { - if (effect.type.equals(AudioEffect.EFFECT_TYPE_VIRTUALIZER)) { - mVirtualizerSupported = true; - } else if (effect.type.equals(AudioEffect.EFFECT_TYPE_BASS_BOOST)) { - mBassBoostSupported = true; + if (!SystemProperties.getBoolean("persist.sys.galley.disable_audioeffects", false)) { + // Determine available/supported effects + final Descriptor[] effects = AudioEffect.queryEffects(); + for (final Descriptor effect : effects) { + if (effect.type.equals(AudioEffect.EFFECT_TYPE_VIRTUALIZER)) { + mVirtualizerSupported = true; + } else if (effect.type.equals(AudioEffect.EFFECT_TYPE_BASS_BOOST)) { + mBassBoostSupported = true; + } } } diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java index 9b6e38659..06773f800 100755 --- a/src/com/android/gallery3d/app/MoviePlayer.java +++ b/src/com/android/gallery3d/app/MoviePlayer.java @@ -67,6 +67,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.util.HashMap; import java.util.Map; +import java.util.Timer; public class MoviePlayer implements MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener, @@ -194,6 +195,18 @@ public class MoviePlayer implements } }; + public interface TimerProgress { + void startTimer(); + } + + private TimerProgress mTimerController = new TimerProgress() { + @Override + public void startTimer() { + mHandler.removeCallbacks(mProgressChecker); + mHandler.post(mProgressChecker); + } + }; + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -234,6 +247,7 @@ public class MoviePlayer implements mVideoView.setOnErrorListener(this); mVideoView.setOnCompletionListener(this); + mVideoView.setTimerProgress(mTimerController); if (mVirtualizer != null) { mVirtualizer.release(); @@ -515,7 +529,7 @@ public class MoviePlayer implements mHandler.postDelayed(mPlayingChecker, 250); } - mHandler.post(mProgressChecker); + mTimerController.startTimer(); } private void pauseVideoMoreThanThreeMinutes() { diff --git a/src/com/android/gallery3d/app/MuteVideo.java b/src/com/android/gallery3d/app/MuteVideo.java index bbb9fca7c..3b4226722 100755 --- a/src/com/android/gallery3d/app/MuteVideo.java +++ b/src/com/android/gallery3d/app/MuteVideo.java @@ -30,6 +30,7 @@ import org.codeaurora.gallery.R; import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.util.SaveVideoFileInfo; import com.android.gallery3d.util.SaveVideoFileUtils; +import android.support.v4.content.FileProvider; import java.io.IOException; @@ -122,8 +123,12 @@ public class MuteVideo { // Show the result only when the activity not // stopped. Intent intent = new Intent(android.content.Intent.ACTION_VIEW); - intent.setDataAndType(Uri.fromFile(mDstFileInfo.mFile), "video/*"); + intent.setDataAndType( + FileProvider.getUriForFile(mActivity, + "com.android.gallery3d.fileprovider", + mDstFileInfo.mFile), "video/*"); intent.putExtra(MediaStore.EXTRA_FINISH_ON_COMPLETION, false); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); mActivity.startActivity(intent); } } diff --git a/src/com/android/gallery3d/app/PackagesMonitor.java b/src/com/android/gallery3d/app/PackagesMonitor.java index 9b2412f1b..7fc0059b5 100644..100755 --- a/src/com/android/gallery3d/app/PackagesMonitor.java +++ b/src/com/android/gallery3d/app/PackagesMonitor.java @@ -17,10 +17,14 @@ package com.android.gallery3d.app; import android.app.IntentService; +import android.app.Notification; +import android.app.NotificationChannel; +import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.os.Build; import android.preference.PreferenceManager; import com.android.gallery3d.picasasource.PicasaSource; @@ -37,7 +41,11 @@ public class PackagesMonitor extends BroadcastReceiver { @Override public void onReceive(final Context context, final Intent intent) { intent.setClass(context, AsyncService.class); - context.startService(intent); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + context.startForegroundService(intent); + } else { + context.startService(intent); + } } public static class AsyncService extends IntentService { @@ -46,6 +54,21 @@ public class PackagesMonitor extends BroadcastReceiver { } @Override + public void onCreate() { + super.onCreate(); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + String channelId = "GalleryPackagesMonitorAsync"; + NotificationChannel channel = new NotificationChannel(channelId, channelId, + NotificationManager.IMPORTANCE_LOW); + NotificationManager manager = + (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + manager.createNotificationChannel(channel); + startForeground(KEY_PACKAGES_VERSION.hashCode(), + new Notification.Builder(getApplicationContext(), channelId).build()); + } + } + + @Override protected void onHandleIntent(Intent intent) { onReceiveAsync(this, intent); } diff --git a/src/com/android/gallery3d/app/TrimVideo.java b/src/com/android/gallery3d/app/TrimVideo.java index ec85de234..8daf39890 100644..100755 --- a/src/com/android/gallery3d/app/TrimVideo.java +++ b/src/com/android/gallery3d/app/TrimVideo.java @@ -35,6 +35,7 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import android.widget.VideoView; +import android.support.v4.content.FileProvider; import org.codeaurora.gallery.R; import com.android.gallery3d.util.SaveVideoFileInfo; @@ -42,6 +43,7 @@ import com.android.gallery3d.util.SaveVideoFileUtils; import java.io.File; import java.io.IOException; +import java.net.URI; public class TrimVideo extends Activity implements MediaPlayer.OnErrorListener, @@ -318,8 +320,12 @@ public class TrimVideo extends Activity implements mProgress = null; // Show the result only when the activity not stopped. Intent intent = new Intent(android.content.Intent.ACTION_VIEW); - intent.setDataAndType(Uri.fromFile(mDstFileInfo.mFile), "video/*"); + intent.setDataAndType( + FileProvider.getUriForFile(mContext, + "com.android.gallery3d.fileprovider", + mDstFileInfo.mFile), "video/*"); intent.putExtra(MediaStore.EXTRA_FINISH_ON_COMPLETION, false); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(intent); finish(); } diff --git a/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java b/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java index 2bd121641..f5a56897d 100644 --- a/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java +++ b/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java @@ -156,6 +156,7 @@ public class ImagePreset { } public void updateOrAddFilterRepresentation(FilterRepresentation rep) { + if (rep == null) return; int pos = getPositionForRepresentation(rep); if (pos != -1) { mFilters.elementAt(pos).useParametersFrom(rep); diff --git a/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java b/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java index 9a88e03e9..cd3dfe7d2 100755 --- a/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java +++ b/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java @@ -17,6 +17,7 @@ package com.android.gallery3d.filtershow.pipeline; import android.app.Notification; +import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.Service; import android.content.Context; @@ -26,6 +27,7 @@ import android.graphics.Bitmap; import android.graphics.Rect; import android.net.Uri; import android.os.Binder; +import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.util.Log; @@ -243,11 +245,18 @@ public class ProcessingService extends Service { mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mNotifyMgr.cancelAll(); - mBuilder = - new Notification.Builder(this) - .setSmallIcon(R.drawable.filtershow_button_fx) - .setContentTitle(getString(R.string.filtershow_notification_label)) - .setContentText(getString(R.string.filtershow_notification_message)); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + String channelId = "GallerySavingRequest"; + NotificationChannel channel = new NotificationChannel(channelId, channelId, + NotificationManager.IMPORTANCE_DEFAULT); + mNotifyMgr.createNotificationChannel(channel); + mBuilder = new Notification.Builder(this, channelId); + } else { + mBuilder = new Notification.Builder(this); + } + mBuilder.setSmallIcon(R.drawable.filtershow_button_fx) + .setContentTitle(getString(R.string.filtershow_notification_label)) + .setContentText(getString(R.string.filtershow_notification_message)); startForeground(mNotificationId, mBuilder.build()); diff --git a/src/com/android/gallery3d/gadget/WidgetConfigure.java b/src/com/android/gallery3d/gadget/WidgetConfigure.java index f674f3038..fd5aa6cdd 100644..100755 --- a/src/com/android/gallery3d/gadget/WidgetConfigure.java +++ b/src/com/android/gallery3d/gadget/WidgetConfigure.java @@ -25,6 +25,7 @@ import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.widget.RemoteViews; +import android.widget.Toast; import org.codeaurora.gallery.R; import com.android.gallery3d.app.AlbumPicker; @@ -148,6 +149,14 @@ public class WidgetConfigure extends Activity { int widgetWidth = Math.round(width * scale); int widgetHeight = Math.round(height * scale); + if (data.getData() != null && data.getData().toString().contains("/video/media")) { + Toast.makeText(this, "Please select one picture", Toast.LENGTH_LONG).show(); + Intent request = new Intent(this, DialogPicker.class) + .setAction(Intent.ACTION_GET_CONTENT) + .setType("image/*"); + startActivityForResult(request, REQUEST_GET_PHOTO); + return; + } mPickedItem = data.getData(); Intent request = new Intent(CropActivity.CROP_ACTION, mPickedItem) .putExtra(CropExtras.KEY_OUTPUT_X, widgetWidth) diff --git a/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java b/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java index 01061db52..6b5a9bef0 100644 --- a/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java +++ b/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java @@ -15,6 +15,7 @@ import android.media.MediaPlayer.OnInfoListener; import android.net.Uri; import android.os.Handler; import android.os.Message; +import android.os.PersistableBundle; import android.util.AttributeSet; import android.util.Log; import android.view.KeyEvent; @@ -27,6 +28,7 @@ import android.view.accessibility.AccessibilityNodeInfo; import android.widget.MediaController; import android.widget.MediaController.MediaPlayerControl; +import com.android.gallery3d.app.MoviePlayer; import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.ApiHelper.Metadata; @@ -84,6 +86,7 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr private MediaPlayer.OnVideoSizeChangedListener mVideoSizeListener; private MediaPlayer.OnPreparedListener mPreparedListener; private ScreenModeManager mScreenManager; + private MoviePlayer.TimerProgress mTimerController; private int mCurrentBufferPercentage; private OnErrorListener mOnErrorListener; private OnInfoListener mOnInfoListener; @@ -563,7 +566,7 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr mMediaController.hide(); } if (mOnCompletionListener != null) { - Log.d(TAG, "OnCompletion: " + mMediaPlayer.getMetrics()); + printMetrics("OnCompletion: "); mOnCompletionListener.onCompletion(mMediaPlayer); } } @@ -620,6 +623,16 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr mOnInfoListener = l; } + /** + * Register a callback to start Timer for time progress bar + * occurs during this.start() + * + * @param c The callback that will be run + */ + public void setTimerProgress(MoviePlayer.TimerProgress c) { + mTimerController = c; + } + SurfaceHolder.Callback mSHCallback = new SurfaceHolder.Callback() { public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { @@ -771,6 +784,7 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr if (mIsShowDialog) return; if (isInPlaybackState()) { mMediaPlayer.start(); + mTimerController.startTimer(); mCurrentState = STATE_PLAYING; } mTargetState = STATE_PLAYING; @@ -800,10 +814,30 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr } } */ - Log.d(TAG, "Suspend: " + mMediaPlayer.getMetrics()); + printMetrics("Suspend: "); release(false); } + private void printMetrics(String preLog) { + if (mMediaPlayer == null)return; + PersistableBundle metrics = mMediaPlayer.getMetrics(); + if (metrics != null) { + long frames = metrics.getLong(MediaPlayer.MetricsConstants.FRAMES); + long dropFrames = metrics.getLong(MediaPlayer.MetricsConstants.FRAMES_DROPPED); + float percentageDropped = (frames == 0) ? 0 : (100*(float)dropFrames/frames); + String log = preLog + "\n" + + "CODEC_AUDIO: " + metrics.getString(MediaPlayer.MetricsConstants.CODEC_AUDIO) + "\n" + + "DURATION: " + metrics.getLong(MediaPlayer.MetricsConstants.DURATION) + "\n" + + "CODEC_VIDEO: " + metrics.getString(MediaPlayer.MetricsConstants.CODEC_VIDEO) + "\n" + + "MIME_TYPE_VIDEO: " + metrics.getString(MediaPlayer.MetricsConstants.MIME_TYPE_VIDEO) + "\n" + + "MIME_TYPE_AUDIO: " + metrics.getString(MediaPlayer.MetricsConstants.MIME_TYPE_AUDIO) + "\n" + + "FRAMES: " + frames + " DROP: " + dropFrames + " DropPecentage: " + percentageDropped + "%" + "\n" + + "RESOLUTION: " + metrics.getInt(MediaPlayer.MetricsConstants.WIDTH) + "x" + + metrics.getInt(MediaPlayer.MetricsConstants.HEIGHT); + Log.d(TAG, log); + } + } + public void resume() { // HTTP streaming (with suspended status) will call mMediaPlayer->resume(), // others will call openVideo() |