Closed
Bug 1510611
Opened 6 years ago
Closed 6 years ago
Lint Error: Calling new methods on older versions
Categories
(GeckoView :: General, enhancement, P5)
Tracking
(firefox66 fixed)
RESOLVED
FIXED
mozilla66
Tracking | Status | |
---|---|---|
firefox66 | --- | fixed |
People
(Reporter: fluffyemily, Assigned: fluffyemily)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
This check scans through all the Android API calls in the application and warns about any calls that are not available on all versions targeted by this application (according to its minimum SDK attribute in the manifest).
If you really want to use this API and don't need to support older devices just set the minSdkVersion in your build.gradle or AndroidManifest.xml files.
If your code is deliberately accessing newer APIs, and you have ensured (e.g. with conditional execution) that this code will only ever be called on a supported platform, then you can annotate your class or method with the @TargetApi annotation specifying the local minimum SDK to apply, such as @TargetApi(11), such that this check considers 11 rather than your manifest file's minimum SDK as the required API level.
If you are deliberately setting android: attributes in style definitions, make sure you place this in a values-vNN folder in order to avoid running into runtime conflicts on certain devices where manufacturers have added custom attributes whose ids conflict with the new ones on later platforms.
Similarly, you can use tools:targetApi="11" in an XML file to indicate that the element will only be inflated in an adequate context.
This issue currently affects:
ContentUriUtils.java
GeckoAppShell.java
GeckoMediaDrmBridgeV21.java
GeckoSurfaceTexture.java
GeckoSystemStateListener.java
JellyBeanAsyncCodec.java
LollipopAsyncCodec.java
MediaDrmProxy.java
SpeechSynthesisService.java
VsyncSource.java
Assignee | ||
Comment 1•6 years ago
|
||
- `GeckoSurfaceTexture`: Added `@RequiresApi` annotation to contructor that uses `KITKAT` level superclass constructor it is not used incorrectly.
- `VsyncSource`: Added `@RequiresApi` annotation to `getRefreshRate` method, plus comment explaining that the `DisplayManager` class used by this method is API level 17+
- `GeckoMediaDRMBridgeV21`: Added `@TargetAPI` annotation to class definition as the entire class uses code API level 18 upwards.
- `JellyBeanAsyncCodec`: Removed brackets from around version check so the linter recognises it as a valid API check. Updated code to use `BUILD_VERSION` flag rather than hardcoded version number.
- `LollipopAsyncCodec`: Added `@TargetAPI` annotation to class definition as the entire class is API level 21 upwards.
- `MediaDrmProxy`: Suppress "NewAPI" lint warnings. Version is being done inside `isSystemSupported` method and therefore not picked up by linter. Updated `isSystemSupported` to use `VERSION_CODES` constant.
- `ContentUriUtils`: Suppress "NewAPI" lint warnings. Version is being checked from `isKitKat` variable and therefore not picked up by linter.
- `GeckoAppShell`: Update `getAudioOutputFramesPerBuffer` & `getAudioOutputSampleRate` methods to use `VERSION` and `VERSION_CODES` inside version check so it is picked up by linter.
- `GeckoSystemStateListener`: Added `@RequiresApi` annotation to `prefersReducedMotion` method, plus comment explaining that the `Settings.Global` class used by this method is API level 17+
- `SpeechSynthesisService`: Add version check to `run` to ensure that `TextToSpeech#getDefaultLanguage` is only called under the correct version.
Assignee | ||
Updated•6 years ago
|
Assignee: nobody → etoop
Updated•6 years ago
|
Pushed by etoop@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/985b82d30afa
Ensure that the correct API levels are being enforced andx handled. r=geckoview-reviewers,snorp
Comment 3•6 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 6 years ago
status-firefox66:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 66
Updated•6 years ago
|
Product: Firefox for Android → GeckoView
Updated•6 years ago
|
Keywords: good-first-bug
Target Milestone: Firefox 66 → mozilla66
You need to log in
before you can comment on or make changes to this bug.
Description
•