Skip to content

[camerax] Explicitly remove READ_EXTERNAL_STORAGE permission #4700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
dec3d69
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 May 1, 2023
0e0333b
Merge remote-tracking branch 'upstream/main'
camsim99 May 2, 2023
bd7ac99
Merge remote-tracking branch 'upstream/main'
camsim99 May 3, 2023
5c3363b
Merge remote-tracking branch 'upstream/main'
camsim99 May 10, 2023
fed9621
Undo changes
camsim99 May 10, 2023
5aabe34
Merge remote-tracking branch 'upstream/main'
camsim99 May 12, 2023
2b9a352
Merge remote-tracking branch 'upstream/main'
camsim99 May 25, 2023
a1173da
Merge remote-tracking branch 'upstream/main'
camsim99 May 30, 2023
cbc3d6b
Merge remote-tracking branch 'upstream/main'
camsim99 May 30, 2023
cae5a4c
Merge remote-tracking branch 'upstream/main'
camsim99 Jun 1, 2023
72283db
Merge remote-tracking branch 'upstream/main'
camsim99 Jun 5, 2023
166a77c
Merge remote-tracking branch 'upstream/main'
camsim99 Jun 5, 2023
399780e
Merge remote-tracking branch 'upstream/main'
camsim99 Jun 14, 2023
8d5d0e7
Merge remote-tracking branch 'upstream/main'
camsim99 Jun 26, 2023
084d960
Merge remote-tracking branch 'upstream/main'
camsim99 Jul 12, 2023
d2a59ac
Merge remote-tracking branch 'upstream/main'
camsim99 Jul 17, 2023
a1422bf
Merge remote-tracking branch 'upstream/main'
camsim99 Jul 17, 2023
bdd87a6
Merge remote-tracking branch 'upstream/main'
camsim99 Jul 18, 2023
137a28b
Merge remote-tracking branch 'upstream/main'
camsim99 Jul 19, 2023
bc0db5a
Merge remote-tracking branch 'upstream/main'
camsim99 Jul 20, 2023
d04b466
Merge remote-tracking branch 'upstream/main'
camsim99 Jul 21, 2023
a9cfe87
Merge remote-tracking branch 'upstream/main'
camsim99 Jul 24, 2023
a32def1
Merge remote-tracking branch 'upstream/main'
camsim99 Aug 2, 2023
4785148
Merge remote-tracking branch 'upstream/main'
camsim99 Aug 14, 2023
b13dd3c
Remove permission
camsim99 Aug 14, 2023
157e2e1
Formatting
camsim99 Aug 14, 2023
46ed3e3
Bump compile sdk version
camsim99 Aug 15, 2023
2f605b2
Merge remote-tracking branch 'upstream/main' into camx_readperm
camsim99 Aug 15, 2023
7bf2b92
Revert "Merge remote-tracking branch 'upstream/main' into camx_readperm"
camsim99 Aug 15, 2023
6396e46
Revert "Merge remote-tracking branch 'upstream/main' into camx_readperm"
camsim99 Aug 15, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/scorecards-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@a09933a12a80f87b87005513f0abb1494c27a716 # v1.0.26
uses: github/codeql-action/upload-sarif@5b6282e01c62d02e720b81eb8a51204f527c3624 # v1.0.26
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion packages/camera/camera_android_camerax/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 0.5.0+14

* Wraps classes needed to implement resolution configuration for video recording.
* Explicitly removes `READ_EXTERNAL_STORAGE` permission that may otherwise be implied from `WRITE_EXTERNAL_STORAGE`.

## 0.5.0+13

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ public void setUp(
binaryMessenger, new ResolutionStrategyHostApiImpl(instanceManager));
GeneratedCameraXLibrary.AspectRatioStrategyHostApi.setup(
binaryMessenger, new AspectRatioStrategyHostApiImpl(instanceManager));
GeneratedCameraXLibrary.FallbackStrategyHostApi.setup(
binaryMessenger, new FallbackStrategyHostApiImpl(instanceManager));
GeneratedCameraXLibrary.QualitySelectorHostApi.setup(
binaryMessenger, new QualitySelectorHostApiImpl(instanceManager));
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -104,43 +104,6 @@ private LiveDataSupportedType(final int index) {
}
}

/**
* Video quality constraints that will be used by a QualitySelector to choose an appropriate video
* resolution.
*
* <p>These are pre-defined quality constants that are universally used for video.
*
* <p>See https://developer.android.com/reference/androidx/camera/video/Quality.
*/
public enum VideoQualityConstraint {
SD(0),
HD(1),
FHD(2),
UHD(3),
LOWEST(4),
HIGHEST(5);

final int index;

private VideoQualityConstraint(final int index) {
this.index = index;
}
}

/** Fallback rules for selecting video resolution. */
public enum VideoResolutionFallbackRule {
HIGHER_QUALITY_OR_LOWER_THAN(0),
HIGHER_QUALITY_THAN(1),
LOWER_QUALITY_OR_HIGHER_THAN(2),
LOWER_QUALITY_THAN(3);

final int index;

private VideoResolutionFallbackRule(final int index) {
this.index = index;
}
}

/** Generated class from Pigeon that represents data sent in messages. */
public static final class ResolutionInfo {
private @NonNull Long width;
Expand Down Expand Up @@ -1593,11 +1556,7 @@ public void create(@NonNull Long identifierArg, @NonNull Reply<Void> callback) {
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
public interface RecorderHostApi {

void create(
@NonNull Long identifier,
@Nullable Long aspectRatio,
@Nullable Long bitRate,
@Nullable Long qualitySelectorId);
void create(@NonNull Long identifier, @Nullable Long aspectRatio, @Nullable Long bitRate);

@NonNull
Long getAspectRatio(@NonNull Long identifier);
Expand Down Expand Up @@ -1628,13 +1587,11 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable RecorderHo
Number identifierArg = (Number) args.get(0);
Number aspectRatioArg = (Number) args.get(1);
Number bitRateArg = (Number) args.get(2);
Number qualitySelectorIdArg = (Number) args.get(3);
try {
api.create(
(identifierArg == null) ? null : identifierArg.longValue(),
(aspectRatioArg == null) ? null : aspectRatioArg.longValue(),
(bitRateArg == null) ? null : bitRateArg.longValue(),
(qualitySelectorIdArg == null) ? null : qualitySelectorIdArg.longValue());
(bitRateArg == null) ? null : bitRateArg.longValue());
wrapped.add(0, null);
} catch (Throwable exception) {
ArrayList<Object> wrappedError = wrapError(exception);
Expand Down Expand Up @@ -2980,165 +2937,4 @@ public void create(
channelReply -> callback.reply(null));
}
}

private static class QualitySelectorHostApiCodec extends StandardMessageCodec {
public static final QualitySelectorHostApiCodec INSTANCE = new QualitySelectorHostApiCodec();

private QualitySelectorHostApiCodec() {}

@Override
protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) {
switch (type) {
case (byte) 128:
return ResolutionInfo.fromList((ArrayList<Object>) readValue(buffer));
default:
return super.readValueOfType(type, buffer);
}
}

@Override
protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) {
if (value instanceof ResolutionInfo) {
stream.write(128);
writeValue(stream, ((ResolutionInfo) value).toList());
} else {
super.writeValue(stream, value);
}
}
}

/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
public interface QualitySelectorHostApi {

void create(
@NonNull Long identifier,
@NonNull List<Long> videoQualityConstraintIndexList,
@Nullable Long fallbackStrategyId);

@NonNull
ResolutionInfo getResolution(
@NonNull Long cameraInfoId, @NonNull VideoQualityConstraint quality);

/** The codec used by QualitySelectorHostApi. */
static @NonNull MessageCodec<Object> getCodec() {
return QualitySelectorHostApiCodec.INSTANCE;
}
/**
* Sets up an instance of `QualitySelectorHostApi` to handle messages through the
* `binaryMessenger`.
*/
static void setup(
@NonNull BinaryMessenger binaryMessenger, @Nullable QualitySelectorHostApi api) {
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger, "dev.flutter.pigeon.QualitySelectorHostApi.create", getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
ArrayList<Object> wrapped = new ArrayList<Object>();
ArrayList<Object> args = (ArrayList<Object>) message;
Number identifierArg = (Number) args.get(0);
List<Long> videoQualityConstraintIndexListArg = (List<Long>) args.get(1);
Number fallbackStrategyIdArg = (Number) args.get(2);
try {
api.create(
(identifierArg == null) ? null : identifierArg.longValue(),
videoQualityConstraintIndexListArg,
(fallbackStrategyIdArg == null) ? null : fallbackStrategyIdArg.longValue());
wrapped.add(0, null);
} catch (Throwable exception) {
ArrayList<Object> wrappedError = wrapError(exception);
wrapped = wrappedError;
}
reply.reply(wrapped);
});
} else {
channel.setMessageHandler(null);
}
}
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.QualitySelectorHostApi.getResolution",
getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
ArrayList<Object> wrapped = new ArrayList<Object>();
ArrayList<Object> args = (ArrayList<Object>) message;
Number cameraInfoIdArg = (Number) args.get(0);
VideoQualityConstraint qualityArg =
args.get(1) == null ? null : VideoQualityConstraint.values()[(int) args.get(1)];
try {
ResolutionInfo output =
api.getResolution(
(cameraInfoIdArg == null) ? null : cameraInfoIdArg.longValue(),
qualityArg);
wrapped.add(0, output);
} catch (Throwable exception) {
ArrayList<Object> wrappedError = wrapError(exception);
wrapped = wrappedError;
}
reply.reply(wrapped);
});
} else {
channel.setMessageHandler(null);
}
}
}
}
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
public interface FallbackStrategyHostApi {

void create(
@NonNull Long identifier,
@NonNull VideoQualityConstraint quality,
@NonNull VideoResolutionFallbackRule fallbackRule);

/** The codec used by FallbackStrategyHostApi. */
static @NonNull MessageCodec<Object> getCodec() {
return new StandardMessageCodec();
}
/**
* Sets up an instance of `FallbackStrategyHostApi` to handle messages through the
* `binaryMessenger`.
*/
static void setup(
@NonNull BinaryMessenger binaryMessenger, @Nullable FallbackStrategyHostApi api) {
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger, "dev.flutter.pigeon.FallbackStrategyHostApi.create", getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
ArrayList<Object> wrapped = new ArrayList<Object>();
ArrayList<Object> args = (ArrayList<Object>) message;
Number identifierArg = (Number) args.get(0);
VideoQualityConstraint qualityArg =
args.get(1) == null ? null : VideoQualityConstraint.values()[(int) args.get(1)];
VideoResolutionFallbackRule fallbackRuleArg =
args.get(2) == null
? null
: VideoResolutionFallbackRule.values()[(int) args.get(2)];
try {
api.create(
(identifierArg == null) ? null : identifierArg.longValue(),
qualityArg,
fallbackRuleArg);
wrapped.add(0, null);
} catch (Throwable exception) {
ArrayList<Object> wrappedError = wrapError(exception);
wrapped = wrappedError;
}
reply.reply(wrapped);
});
} else {
channel.setMessageHandler(null);
}
}
}
}
}
Loading