Skip to content

Fix Arm64 detection logic for devices#40373

Closed
rpzrpzrpz wants to merge 1 commit into
flutter:masterfrom
rpzrpzrpz:fix-64bit-os-detect
Closed

Fix Arm64 detection logic for devices#40373
rpzrpzrpz wants to merge 1 commit into
flutter:masterfrom
rpzrpzrpz:fix-64bit-os-detect

Conversation

@rpzrpzrpz

@rpzrpzrpz rpzrpzrpz commented Sep 12, 2019

Copy link
Copy Markdown

Description

Flutter tools assumes that all 64 bit ARM cpus are able to run 64 bit code.

There are manufacturers that use 64 bit ARM cpus while installing 32 bit Android OS on it.

Added code that looks at the OS for 32 or 64 bit arm so dev tools do not try to download
64 bit code to 32 bit Operating systems.

Tests

As far as tests, I have tested with my available android devices including Kindle Fire 8 and Motorola LG v30.

But this is device detection, so it requires physical devices more than I have available.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • [ x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • [ x] I signed the [CLA].
  • [ x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • [?] I updated/added relevant documentation (doc comments with ///).
  • [?] All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read [Handling breaking changes]). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • [X ] No, this is not a breaking change.

@fluttergithubbot

Copy link
Copy Markdown
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. While there are exceptions to this rule, if this patch modifies code it is probably not an exception.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@fluttergithubbot fluttergithubbot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 12, 2019
@googlebot

Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@rpzrpzrpz

Copy link
Copy Markdown
Author

@googlebot I signed it!

@googlebot

Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@jmagman jmagman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  1. You have analyzer issues, braces go on the same line, spaces between // and the comment text. Match the code around where you are changing.
   info • Prefer final for variable declarations if they are not reassigned • packages/flutter_tools/lib/src/android/android_device.dart:195:18 • prefer_final_locals

Check out the style guide: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
2. You will needs tests for this. See android_device_test.dart.

Comment thread AUTHORS
Diego Velásquez <[email protected]>
Sarbagya Dhaubanjar <[email protected]> No newline at end of file
Sarbagya Dhaubanjar <[email protected]>
Mark Diener <[email protected]> No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-add the newline.

case 'arm64-v8a':
_platform = TargetPlatform.android_arm64;

//Original code assumed that CPU was enough. But you need to verify 64 bit OS as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This code will be around for a long time and edited by many people, so comments like "original code" aren't super informative. A better comment would explain why just checking the CPU isn't sufficient.

String gabilist = await _getProperty('ro.product.cpu.abilist');
if (gabilist == null)
{
//Have not seen a device without an abilist in adb, but it is possible.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very possible. #10330.

}

//Confirm that our 64 bit arm cpu has a 64 bit OS running on it
if (gabilist.contains('arm64-v8a') == true)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't need the == true.

}
else
{
//Sorry Amazon Kindle Fire 8, You tried trick me, but you failed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This comment is cute, but not super informative. Maybe something like:

Some devices, like the Kindle Fire 8, misreport abilist as <blah>.  Fall back to android_arm64. 

@jonahwilliams jonahwilliams left a comment

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.

We should have some existing tests that cover this code. They should be updated with new cases + synthetic devices to ensure this logic is covered and doesn't get accidentally reverted

//Original code assumed that CPU was enough. But you need to verify 64 bit OS as well.
String gabilist = await _getProperty('ro.product.cpu.abilist');
if (gabilist == 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.

Please follow the style guide at https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo

In this case place the opening brace on the same line as the if.

case 'arm64-v8a':
_platform = TargetPlatform.android_arm64;

//Original code assumed that CPU was enough. But you need to verify 64 bit OS as well.

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.

Some links to external documentation or issues here would be helpful too.

@jmagman

jmagman commented Sep 12, 2019

Copy link
Copy Markdown
Member
  1. You will needs tests for this. See android_device_test.dart.

To clarify, that probably means mock out out the results of the 'ro.product.cpu.abilist' property fetch, to make sure the TargetPlatform gets set correctly, and also making sure other tests have it mocked out so they pass (returns null instead of actually fetching some value from a plugged in device, for example).

@zanderso zanderso added the waiting for response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 20, 2019
@rpzrpzrpz

Copy link
Copy Markdown
Author

I will get back to this very shortly. I am just trying to get some other deadlines met in the meantime.

@jonahwilliams

Copy link
Copy Markdown
Contributor

Closing due to lack of activity. I've filled #44999 to capture the issue here

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tool Affects the "flutter" command-line tool. See also t: labels. waiting for response The Flutter team cannot make further progress on this issue until the original reporter responds

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants