Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Sync nnbd branch #3157

Merged
merged 14 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/android_alarm_manager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.5+15

* Update android compileSdkVersion to 29.

## 0.4.5+14

* Keep handling deprecated Android v1 classes for backward compatibility.
Expand Down
2 changes: 1 addition & 1 deletion packages/android_alarm_manager/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ project.getTasks().withType(JavaCompile){
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
compileSdkVersion 29
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand Down
2 changes: 1 addition & 1 deletion packages/android_alarm_manager/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Demonstrates how to use the android_alarm_manager plugin.
## Getting Started

For help getting started with Flutter, view our online
[documentation](http://flutter.io/).
[documentation](https://flutter.dev/).
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 29

lintOptions {
disable 'InvalidPackage'
Expand Down
2 changes: 1 addition & 1 deletion packages/android_alarm_manager/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Flutter plugin for accessing the Android AlarmManager service, and
# 0.4.y+z is compatible with 1.0.0, if you land a breaking change bump
# the version to 2.0.0.
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
version: 0.4.5+14
version: 0.4.5+15
homepage: https://github.com/flutter/plugins/tree/master/packages/android_alarm_manager

dependencies:
Expand Down
4 changes: 4 additions & 0 deletions packages/android_intent/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.7+6

* Update android compileSdkVersion to 29.

## 0.3.7+5

* Android Code Inspection and Clean up.
Expand Down
2 changes: 1 addition & 1 deletion packages/android_intent/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ project.getTasks().withType(JavaCompile){
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
minSdkVersion 16
Expand Down
2 changes: 1 addition & 1 deletion packages/android_intent/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Demonstrates how to use the android_intent plugin.
## Getting Started

For help getting started with Flutter, view our online
[documentation](http://flutter.io/).
[documentation](https://flutter.dev/).
2 changes: 1 addition & 1 deletion packages/android_intent/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 29

lintOptions {
disable 'InvalidPackage'
Expand Down
2 changes: 1 addition & 1 deletion packages/android_intent/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ homepage: https://github.com/flutter/plugins/tree/master/packages/android_intent
# 0.3.y+z is compatible with 1.0.0, if you land a breaking change bump
# the version to 2.0.0.
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
version: 0.3.7+5
version: 0.3.7+6

flutter:
plugin:
Expand Down
4 changes: 4 additions & 0 deletions packages/battery/battery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.7

* Update android compileSdkVersion to 29.

## 1.0.6

* Keep handling deprecated Android v1 classes for backward compatibility.
Expand Down
2 changes: 1 addition & 1 deletion packages/battery/battery/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
minSdkVersion 16
Expand Down
2 changes: 1 addition & 1 deletion packages/battery/battery/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Demonstrates how to use the battery plugin.
## Getting Started

For help getting started with Flutter, view our online
[documentation](http://flutter.io/).
[documentation](https://flutter.dev/).
2 changes: 1 addition & 1 deletion packages/battery/battery/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 29

lintOptions {
disable 'InvalidPackage'
Expand Down
2 changes: 1 addition & 1 deletion packages/battery/battery/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: battery
description: Flutter plugin for accessing information about the battery state
(full, charging, discharging) on Android and iOS.
homepage: https://github.com/flutter/plugins/tree/master/packages/battery/battery
version: 1.0.6
version: 1.0.7

flutter:
plugin:
Expand Down
8 changes: 8 additions & 0 deletions packages/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.5.8+9

* Update android compileSdkVersion to 29.

## 0.5.8+8

* Fixed garbled audio (in video) by setting audio encoding bitrate.

## 0.5.8+7

* Keep handling deprecated Android v1 classes for backward compatibility.
Expand Down
3 changes: 2 additions & 1 deletion packages/camera/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ project.getTasks().withType(JavaCompile){
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
minSdkVersion 21
Expand All @@ -51,4 +51,5 @@ android {

dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:3.5.13'
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import androidx.annotation.NonNull;
import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugins.camera.media.MediaRecorderBuilder;
import io.flutter.view.TextureRegistry.SurfaceTextureEntry;
import java.io.File;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -82,7 +83,6 @@ public Camera(
if (activity == null) {
throw new IllegalStateException("No activity available!");
}

this.cameraName = cameraName;
this.enableAudio = enableAudio;
this.flutterTexture = flutterTexture;
Expand Down Expand Up @@ -120,23 +120,12 @@ private void prepareMediaRecorder(String outputFilePath) throws IOException {
if (mediaRecorder != null) {
mediaRecorder.release();
}
mediaRecorder = new MediaRecorder();

// There's a specific order that mediaRecorder expects. Do not change the order
// of these function calls.
if (enableAudio) mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mediaRecorder.setOutputFormat(recordingProfile.fileFormat);
if (enableAudio) mediaRecorder.setAudioEncoder(recordingProfile.audioCodec);
mediaRecorder.setVideoEncoder(recordingProfile.videoCodec);
mediaRecorder.setVideoEncodingBitRate(recordingProfile.videoBitRate);
if (enableAudio) mediaRecorder.setAudioSamplingRate(recordingProfile.audioSampleRate);
mediaRecorder.setVideoFrameRate(recordingProfile.videoFrameRate);
mediaRecorder.setVideoSize(recordingProfile.videoFrameWidth, recordingProfile.videoFrameHeight);
mediaRecorder.setOutputFile(outputFilePath);
mediaRecorder.setOrientationHint(getMediaOrientation());

mediaRecorder.prepare();

mediaRecorder =
new MediaRecorderBuilder(recordingProfile, outputFilePath)
.setEnableAudio(enableAudio)
.setMediaOrientation(getMediaOrientation())
.build();
}

@SuppressLint("MissingPermission")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package io.flutter.plugins.camera.media;

import android.media.CamcorderProfile;
import android.media.MediaRecorder;
import androidx.annotation.NonNull;
import java.io.IOException;

public class MediaRecorderBuilder {
static class MediaRecorderFactory {
MediaRecorder makeMediaRecorder() {
return new MediaRecorder();
}
}

private final String outputFilePath;
private final CamcorderProfile recordingProfile;
private final MediaRecorderFactory recorderFactory;

private boolean enableAudio;
private int mediaOrientation;

public MediaRecorderBuilder(
@NonNull CamcorderProfile recordingProfile, @NonNull String outputFilePath) {
this(recordingProfile, outputFilePath, new MediaRecorderFactory());
}

MediaRecorderBuilder(
@NonNull CamcorderProfile recordingProfile,
@NonNull String outputFilePath,
MediaRecorderFactory helper) {
this.outputFilePath = outputFilePath;
this.recordingProfile = recordingProfile;
this.recorderFactory = helper;
}

public MediaRecorderBuilder setEnableAudio(boolean enableAudio) {
this.enableAudio = enableAudio;
return this;
}

public MediaRecorderBuilder setMediaOrientation(int orientation) {
this.mediaOrientation = orientation;
return this;
}

public MediaRecorder build() throws IOException {
MediaRecorder mediaRecorder = recorderFactory.makeMediaRecorder();

// There's a specific order that mediaRecorder expects. Do not change the order
// of these function calls.
if (enableAudio) {
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setAudioEncodingBitRate(recordingProfile.audioBitRate);
}
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mediaRecorder.setOutputFormat(recordingProfile.fileFormat);
if (enableAudio) mediaRecorder.setAudioEncoder(recordingProfile.audioCodec);
mediaRecorder.setVideoEncoder(recordingProfile.videoCodec);
mediaRecorder.setVideoEncodingBitRate(recordingProfile.videoBitRate);
if (enableAudio) mediaRecorder.setAudioSamplingRate(recordingProfile.audioSampleRate);
mediaRecorder.setVideoFrameRate(recordingProfile.videoFrameRate);
mediaRecorder.setVideoSize(recordingProfile.videoFrameWidth, recordingProfile.videoFrameHeight);
mediaRecorder.setOutputFile(outputFilePath);
mediaRecorder.setOrientationHint(this.mediaOrientation);

mediaRecorder.prepare();

return mediaRecorder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public void sendCameraClosingEvent() {

private Map<String, String> decodeSentMessage(ByteBuffer sentMessage) {
sentMessage.position(0);
//noinspection unchecked
return (Map<String, String>) StandardMethodCodec.INSTANCE.decodeEnvelope(sentMessage);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package io.flutter.plugins.camera.media;

import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.*;

import android.media.CamcorderProfile;
import android.media.MediaRecorder;
import java.io.IOException;
import java.lang.reflect.Constructor;
import org.junit.Test;
import org.mockito.InOrder;

public class MediaRecorderBuilderTest {
@Test
public void ctor_test() {
MediaRecorderBuilder builder =
new MediaRecorderBuilder(CamcorderProfile.get(CamcorderProfile.QUALITY_1080P), "");

assertNotNull(builder);
}

@Test
public void build_Should_set_values_in_correct_order_When_audio_is_disabled() throws IOException {
CamcorderProfile recorderProfile = getEmptyCamcorderProfile();
MediaRecorderBuilder.MediaRecorderFactory mockFactory =
mock(MediaRecorderBuilder.MediaRecorderFactory.class);
MediaRecorder mockMediaRecorder = mock(MediaRecorder.class);
String outputFilePath = "mock_video_file_path";
int mediaOrientation = 1;
MediaRecorderBuilder builder =
new MediaRecorderBuilder(recorderProfile, outputFilePath, mockFactory)
.setEnableAudio(false)
.setMediaOrientation(mediaOrientation);

when(mockFactory.makeMediaRecorder()).thenReturn(mockMediaRecorder);

MediaRecorder recorder = builder.build();

InOrder inOrder = inOrder(recorder);
inOrder.verify(recorder).setVideoSource(MediaRecorder.VideoSource.SURFACE);
inOrder.verify(recorder).setOutputFormat(recorderProfile.fileFormat);
inOrder.verify(recorder).setVideoEncoder(recorderProfile.videoCodec);
inOrder.verify(recorder).setVideoEncodingBitRate(recorderProfile.videoBitRate);
inOrder.verify(recorder).setVideoFrameRate(recorderProfile.videoFrameRate);
inOrder
.verify(recorder)
.setVideoSize(recorderProfile.videoFrameWidth, recorderProfile.videoFrameHeight);
inOrder.verify(recorder).setOutputFile(outputFilePath);
inOrder.verify(recorder).setOrientationHint(mediaOrientation);
inOrder.verify(recorder).prepare();
}

@Test
public void build_Should_set_values_in_correct_order_When_audio_is_enabled() throws IOException {
CamcorderProfile recorderProfile = getEmptyCamcorderProfile();
MediaRecorderBuilder.MediaRecorderFactory mockFactory =
mock(MediaRecorderBuilder.MediaRecorderFactory.class);
MediaRecorder mockMediaRecorder = mock(MediaRecorder.class);
String outputFilePath = "mock_video_file_path";
int mediaOrientation = 1;
MediaRecorderBuilder builder =
new MediaRecorderBuilder(recorderProfile, outputFilePath, mockFactory)
.setEnableAudio(true)
.setMediaOrientation(mediaOrientation);

when(mockFactory.makeMediaRecorder()).thenReturn(mockMediaRecorder);

MediaRecorder recorder = builder.build();

InOrder inOrder = inOrder(recorder);
inOrder.verify(recorder).setAudioSource(MediaRecorder.AudioSource.MIC);
inOrder.verify(recorder).setAudioEncodingBitRate(recorderProfile.audioBitRate);
inOrder.verify(recorder).setVideoSource(MediaRecorder.VideoSource.SURFACE);
inOrder.verify(recorder).setOutputFormat(recorderProfile.fileFormat);
inOrder.verify(recorder).setAudioEncoder(recorderProfile.audioCodec);
inOrder.verify(recorder).setVideoEncoder(recorderProfile.videoCodec);
inOrder.verify(recorder).setVideoEncodingBitRate(recorderProfile.videoBitRate);
inOrder.verify(recorder).setAudioSamplingRate(recorderProfile.audioSampleRate);
inOrder.verify(recorder).setVideoFrameRate(recorderProfile.videoFrameRate);
inOrder
.verify(recorder)
.setVideoSize(recorderProfile.videoFrameWidth, recorderProfile.videoFrameHeight);
inOrder.verify(recorder).setOutputFile(outputFilePath);
inOrder.verify(recorder).setOrientationHint(mediaOrientation);
inOrder.verify(recorder).prepare();
}

private CamcorderProfile getEmptyCamcorderProfile() {
try {
Constructor<CamcorderProfile> constructor =
CamcorderProfile.class.getDeclaredConstructor(
int.class, int.class, int.class, int.class, int.class, int.class, int.class,
int.class, int.class, int.class, int.class, int.class);

constructor.setAccessible(true);
return constructor.newInstance(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
} catch (Exception ignored) {
}

return null;
}
}
2 changes: 1 addition & 1 deletion packages/camera/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 29

lintOptions {
disable 'InvalidPackage'
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera
description: A Flutter plugin for getting information about and controlling the
camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video,
and streaming image buffers to dart.
version: 0.5.8+7
version: 0.5.8+9

homepage: https://github.com/flutter/plugins/tree/master/packages/camera

Expand Down
Loading