Skip to content

Adds storage not low requirement#7395

Closed
jdegroot-dss wants to merge 4 commits intogoogle:dev-v2from
jdegroot-dss:add-storage-not-low-requirement
Closed

Adds storage not low requirement#7395
jdegroot-dss wants to merge 4 commits intogoogle:dev-v2from
jdegroot-dss:add-storage-not-low-requirement

Conversation

@jdegroot-dss
Copy link
Copy Markdown
Contributor

Added monitoring storage levels in RequirementsWatcher
Added dependency on extension-workmanager to the demo app to be able to test with WorkManagerScheduler
Added getSupportedRequirements method to Scheduler interface
Implemented getSupportedRequirements for schedulers

Added monitoring storage levels in RequirementsWatcher
Added dependency on extension-workmanager to the demo app to be able to test with WorkManagerScheduler
Added getSupportedRequirements method to Scheduler interface
Implemented getSupportedRequirements for schedulers
private boolean isStorageNotLow(Context context) {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK);
intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdegroot-dss It works only for internal storage. When downloading to external storage, this method of determining is useless and even false. If there is no space in the internal storage, we cannot download to the external storage when this requirement is enabled

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdegroot-dss Does this affect your intended usage at all, or is it fine for your use case? It still seems OK to support this to me, although perhaps this should be made clearer in the documentation. If someone is placing content onto external storage they can just not use the feature.

If it's still useful for you, please just confirm this here and I'll look at getting it merged in. Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads up @vigneshvg, I was unaware of that limitation.

@ojw28 I don't think this will affect our use case and it would still be useful to have. Agreed with updating the documentation. Do we want to restrict the usage of the requirement if downloads are going to external storage?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just making it clear in the documentation is enough.

} else {
switch (intent.getAction()) {
case Intent.ACTION_DEVICE_STORAGE_OK:
return true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess based on the comment above that you copied this code from elsewhere, but if ACTION_DEVICE_STORAGE_OK is not sticky, how does this case ever occur :)? Seems to me we can completely remove ACTION_DEVICE_STORAGE_OK from this case without any change in behavior?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a summary, I wonder whether this entire method can just be:

@Nullable Intent intent =
    context.registerReceiver(null, new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW));
return intent == null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to fix this. I can do it when I merge. Although please check whether the proposed alternative is sufficient!

Copy link
Copy Markdown
Contributor Author

@jdegroot-dss jdegroot-dss May 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct! Tested this and it works as expected.

@Override
public Requirements getSupportedRequirements(Requirements requirements) {
Requirements supportedRequirements = requirements;
if (Util.SDK_INT < 26) {
Copy link
Copy Markdown
Contributor

@ojw28 ojw28 May 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. If it's supported for API level 26 and above, it needs wiring up in the buildJobInfo method below, doesn't it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to fix this. I can do it when I merge. Just confirming that the comment is correct is fine :).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, that is correct.

ojw28 added a commit that referenced this pull request May 29, 2020
@ojw28
Copy link
Copy Markdown
Contributor

ojw28 commented Jun 2, 2020

I'm not sure why our tooling didn't mark this as merged, but it was (with some non-functional changes) in 496a315. Thanks!

@ojw28 ojw28 closed this Jun 2, 2020
@google google locked and limited conversation to collaborators Aug 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants