Skip to content
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

Fix Warnings #28

Open
hajoha opened this issue Jul 15, 2024 · 2 comments
Open

Fix Warnings #28

hajoha opened this issue Jul 15, 2024 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@hajoha
Copy link
Contributor

hajoha commented Jul 15, 2024

Bug Report

Context

  • Device: all
  • Carrier Privileges (Y/N):
  • Android Version: all
  • App Version: all
  • Git Hash: all

Description

Fix warnings while compiling

How to Reproduce

add this to app/build.gradle under compileOptions

tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
        }

Additional Context

> Task :app:compileDebugJavaWithJavac
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/OpenMobileNetworkToolkit.java:32: warning: [deprecation] onLoadConfig(CarrierIdentifier) in CarrierService has been deprecated
    public PersistableBundle onLoadConfig(CarrierIdentifier id) {
                             ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/OpenMobileNetworkToolkit.java:86: warning: [deprecation] KEY_CARRIER_VOLTE_PROVISIONING_REQUIRED_BOOL in CarrierConfigManager has been deprecated
        configForSubId.putBoolean(CarrierConfigManager.KEY_CARRIER_VOLTE_PROVISIONING_REQUIRED_BOOL, spg.getSharedPreference(SPType.carrier_sp).getBoolean("switch_KEY_CARRIER_VOLTE_PROVISIONING_REQUIRED_BOOL", false));
                                                      ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/OpenMobileNetworkToolkit.java:87: warning: [deprecation] KEY_CARRIER_VOLTE_PROVISIONED_BOOL in CarrierConfigManager has been deprecated
        configForSubId.putBoolean(CarrierConfigManager.KEY_CARRIER_VOLTE_PROVISIONED_BOOL, spg.getSharedPreference(SPType.carrier_sp).getBoolean("switch_KEY_CARRIER_VOLTE_PROVISIONED_BOOL", false));
                                                      ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/OpenMobileNetworkToolkit.java:107: warning: [deprecation] KEY_CARRIER_UT_PROVISIONING_REQUIRED_BOOL in CarrierConfigManager has been deprecated
        configForSubId.putBoolean(CarrierConfigManager.KEY_CARRIER_UT_PROVISIONING_REQUIRED_BOOL, spg.getSharedPreference(SPType.carrier_sp).getBoolean("switch_KEY_CARRIER_SUPPORTS_SS_OVER_UT_BOOL", false));
                                                      ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/WorkProfile/SetupProfileFragment.java:66: warning: [deprecation] EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME in DevicePolicyManager has been deprecated
                DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME,
                                   ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/WorkProfile/SetupProfileFragment.java:79: warning: [deprecation] startActivityForResult(Intent,int) in Fragment has been deprecated
            startActivityForResult(intent, REQUEST_PROVISION_MANAGED_PROFILE);
            ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/WorkProfile/SetupProfileFragment.java:88: warning: [deprecation] onActivityResult(int,int,Intent) in Fragment has been deprecated
    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
                ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/WorkProfile/SetupProfileFragment.java:98: warning: [deprecation] onActivityResult(int,int,Intent) in Fragment has been deprecated
        super.onActivityResult(requestCode, resultCode, data);
             ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/WorkProfile/BasicManagedProfileFragment.java:89: warning: [deprecation] GET_UNINSTALLED_PACKAGES in PackageManager has been deprecated
                packageFlags = PackageManager.GET_UNINSTALLED_PACKAGES;
                                             ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/WorkProfile/BasicManagedProfileFragment.java:179: warning: [deprecation] GET_UNINSTALLED_PACKAGES in PackageManager has been deprecated
                packageFlags = PackageManager.GET_UNINSTALLED_PACKAGES;
                                             ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/SwipeController.java:164: warning: [deprecation] getAdapterPosition() in ViewHolder has been deprecated
                            buttonsActions.onLeftClicked(viewHolder.getAdapterPosition());
                                                                   ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/SwipeController.java:166: warning: [deprecation] getAdapterPosition() in ViewHolder has been deprecated
                            buttonsActions.onRightClicked(viewHolder.getAdapterPosition());
                                                                    ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/DataProvider/NetworkInformation.java:149: warning: [deprecation] NETWORK_TYPE_IDEN in TelephonyManager has been deprecated
            case TelephonyManager.NETWORK_TYPE_IDEN:
                                 ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/DataProvider/NetworkCallback.java:360: warning: [deprecation] NetworkInfo in android.net has been deprecated
            NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
            ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/DataProvider/NetworkCallback.java:360: warning: [deprecation] getNetworkInfo(Network) in ConnectivityManager has been deprecated
            NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
                                                         ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/DataProvider/NetworkCallback.java:361: warning: [deprecation] getType() in NetworkInfo has been deprecated
            int networktype = networkInfo.getType();
                                         ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/DataProvider/NetworkCallback.java:362: warning: [deprecation] getSubtype() in NetworkInfo has been deprecated
            int networksubtype = networkInfo.getSubtype();
                                            ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/DataProvider/NetworkCallback.java:363: warning: [deprecation] getTypeName() in NetworkInfo has been deprecated
            String typename = networkInfo.getTypeName();
                                         ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/DataProvider/NetworkCallback.java:364: warning: [deprecation] getSubtypeName() in NetworkInfo has been deprecated
            String subtypename = networkInfo.getSubtypeName();
                                            ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/DataProvider/NetworkCallback.java:794: warning: [deprecation] NetworkInfo in android.net has been deprecated
            NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
            ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/DataProvider/NetworkCallback.java:794: warning: [deprecation] getActiveNetworkInfo() in ConnectivityManager has been deprecated
            NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
                                                         ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/DataProvider/NetworkCallback.java:817: warning: [deprecation] getTypeName() in NetworkInfo has been deprecated
            Log.d(TAG, "Network Type Name: " + networkInfo.getTypeName());
                                                          ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/CarrierSettingsFragment.java:84: warning: [deprecation] get(String) in BaseBundle has been deprecated
            Object obj = bundle.get(key);
                               ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Ping/PingService.java:233: warning: [unchecked] unchecked method invocation: method removeObserver in class LiveData is applied to given types
                    wm.getWorkInfoByIdLiveData(pingWR.getId()).removeObserver(this);
                                                                             ^
  required: Observer<? super T>
  found:    <anonymous Observer>
  where T is a type-variable:
    T extends Object declared in class LiveData
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Ping/PingService.java:233: warning: [unchecked] unchecked conversion
                    wm.getWorkInfoByIdLiveData(pingWR.getId()).removeObserver(this);
                                                                              ^
  required: Observer<? super T>
  found:    <anonymous Observer>
  where T is a type-variable:
    T extends Object declared in class LiveData
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Ping/PingService.java:238: warning: [unchecked] unchecked method invocation: method observeForever in class LiveData is applied to given types
            wm.getWorkInfoByIdLiveData(pingWR.getId()).observeForever(observer);
                                                                     ^
  required: Observer<? super T>
  found:    Observer
  where T is a type-variable:
    T extends Object declared in class LiveData
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Ping/PingService.java:238: warning: [unchecked] unchecked conversion
            wm.getWorkInfoByIdLiveData(pingWR.getId()).observeForever(observer);
                                                                      ^
  required: Observer<? super T>
  found:    Observer
  where T is a type-variable:
    T extends Object declared in class LiveData
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/LoggingService.java:315: warning: [deprecation] stopForeground(boolean) in Service has been deprecated
        stopForeground(true);
        ^
/opt/github-omnt/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3RecyclerViewAdapter.java:79: warning: [unchecked] unchecked cast
                    (HashMap<String, Integer>) selectedRuns.clone();
                                                                 ^
  required: HashMap<String,Integer>
  found:    Object
29 warnings
@hajoha hajoha added the bug Something isn't working label Jul 15, 2024
@hajoha hajoha added this to the Release 0.4 milestone Jul 15, 2024
@hajoha hajoha self-assigned this Jul 15, 2024
@hajoha
Copy link
Contributor Author

hajoha commented Jul 15, 2024

@derpeter could you please take a look at this as well?

@hajoha hajoha changed the title [BUG] - Fix Warnings Fix Warnings Jul 17, 2024
PeterHasse added a commit that referenced this issue Jul 17, 2024
the rest needs more refactoring or ah higher min SDK version
@PeterHasse
Copy link
Contributor

Good catch we should revisit this form time to time. For some of the deprecation there is no fix without raising min SDK version. There i propose to keep them until they are deprecated for good

RkShaRkz added a commit to Cloud-City-RS/OMNTelcoMetrics that referenced this issue Nov 4, 2024
Update from upstream since we were 93 commits behind

Alright, we were 93 commits behind, now we should be up to speed... or probably +1 ahead due to the merge commit.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
	- Introduced a new `SharedPreferencesGrouper` class for improved management of shared preferences.
	- Added multiple new fragments including `DetailFragment`, `QuickFragment`, and `SharedPreferencesIOFragment`.
	- Implemented a `MultiSelectDialogFragment` for user-friendly multi-selection of preferences.
	- Enhanced UI with new layouts for displaying cell information (CDMA, GSM, LTE, NR).
	- Added new utility methods in `Iperf3Utils` for converting protocol and mode identifiers to strings.
	- Introduced a `PingFragment` for managing ping operations with a modern UI.
	- Added new layouts for quick views of various network types.
	- New `CloudCityConstants` class for centralized string constants related to Cloud City.
	- New `CloudCityParamsRepository` for managing application parameters related to the Cloud City service.
	- Added `sentry.properties` for Sentry integration to track errors and performance metrics.

- **Bug Fixes**
	- Improved error handling across various components, including logging exceptions instead of printing stack traces.

- **Documentation**
	- Updated comments and documentation across various classes for better clarity and maintainability.

- **Style**
	- Enhanced UI elements with Material Design components and improved layout structures.

- **Chores**
	- Cleaned up unused imports and removed deprecated code sections for better code hygiene.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->


* added available location provider to home screen

* removed inacurate log message

* add basic config file export/import

* update to use SPG instead of default SharedPreferences

* wifi logging implemented. Needed some refactoring on permissions requests. Also fixes some issues on cp handling

* add config GUI

* update template config

* add dynamic clearance of ScrollView if Clear button is pressed

* rename

* refactor MainActivity to prevent to early access of the data provider

* android studio code optimization, lets hope for the best ;-)

* Fix some of the deprecation warnings mentioned in omnt#28
the rest needs more refactoring or ah higher min SDK version

* fix duplicate switch entry because of typo

* move to separate Dir

* fix bug

* rework cell information code to be more robust for situation where no UICC is present or network is not available.

Moved code from homefragment to main activity which only needs to be called once

linter care

* fix log icon reference not valid as to early access

* update doc and fix Select Diag for Config import

* pretty print config

* update

* update

* remove DefaultSharedPreference

* fix bug & add support for indefinitely running iperf3

* Added wifi standard to log / homescreen

* check background permission on each start

* update ping

* refactor make it more readable

* remove Intent

* update Fragment if Cancel via Notification is clicked

* fix "show neighbour cell setting did not take effect for home screen"

* removed usage printStackTrace as it is considered bad practice in favor of using the logging framework

* removed usage printStackTrace as it is considered bad practice in favor of using the logging framework

* refactor some warnings in logging service

* refactor some warnings in logging service

* Print units to wifi information

* Print units to wifi information

* first part of fixing subscription selection

* fix defaultsharedpreferences bug

* Make sure to repopulate the data provider after an TM change

* fix import config

* fix wifi bug

* split Homefragment into Quick View and Detail

* add CellInformation to QuickView

* add LTE/NR

* refactor

* update quick view

* update quick view

* update quick view

* update quick view

* add CDMA

* add detail view

* add detail view for every celltype

* update signal strength

* remove pretty print json

* update

* update

* update

* move Display code back to Fragment

* add GSM quickview

* add NR

* Add QuickView to Hoimescreen vol. 2 (#33)

* add CDMA

* rename

* add LTE

* fix format issue

* bump gradle to 8.6.0

* use MaterialTextView

* add function comments

* clean up

---------

Co-authored-by: hajoha <[email protected]>

* fix wrong value in RSSI for wifi

* fix LTE/GSM/CDMA influx export

* reworked duplicate logging strings

* Clean up logging. Bumb some dependencies. Change app version to 0.4.

* Clean up logging. Bumb some dependencies. Change app version to 0.4.
Some further cleanup of logging refactoring.
uncomment some code we will use in the future to make linter happy

* Clean up logging. Bumb some dependencies. Change app version to 0.4.
Some further cleanup of logging refactoring.
Uncomment some code we will use in the future to make linter happy.
Reworked subscription settings code to better handle no UICC present

* Clean up logging. Bumb some dependencies. Change app version to 0.4.
Some further cleanup of logging refactoring.
Uncomment some code we will use in the future to make linter happy.
Reworked subscription settings code to better handle no UICC present
Update Changelog
Bump gradle version

* Clean up logging. Bumb some dependencies. Change app version to 0.4.
Some further cleanup of logging refactoring.
Uncomment some code we will use in the future to make linter happy.
Reworked subscription settings code to better handle no UICC present
Update Changelog
Bump gradle version

* clean up failed merge from 91cad78

* code cleanup and typo fix

* update changelog

* fixed wrong button state of ping fragment button after app start
some cleanup in ping fragment

* Add supported android versions to readme

* typo in readme

* remove deprecated checks and vars vom loggingservice

* removed unneccessary call on update all information for quick view

* cleanup in preparation for 0.4 release

* bump influx client version to 7.2.0

* added Wifi Security Type to wifi information

* Add alternative solution to enable carrier permissions

* Add docs about IMS activation

* Extract CloudCity changes to MainActivity

EDIT: streamline even further, we'll rename these later on

* Extract CloudCity changes to LoggingService

* Address own CR comments - handle NPE

* Fix prefilling of server params in logging settings part of the settings screen

So, since they changed how they work with things and have kinda-but-not-really moved away from
SharedPreferences by using their new SharedPreferencesGrouper which is just a dispatcher to many
different shared preferences, the prefilling was broken by them started using the "logging_sp"
SharedPreferences for the logging settings, while the cloud city-related preferenes were being
saved in the default one.

But apart from that, a new "source of truth" was made, the CloudCityParamsRepository which
will hopefully hold all data together (and save them in it's own 'normal' sharedpref :( )
until it diverges from the values saved in their logging_sp shared pref.

A new application class was made as well, which initializes the repository, and cloud city-related
(string) parameters were extracted to the new CloudCityConstants class.

the rest of the files were affected by minor refactoring or importing the new CloudCityConstants

tl;dr - the prefilling works fine now again.

* Integrate Sentry crashreporting for project mobile-app by using it's DSN (in metadata)

* Move LoggingService cloudcity updates from main thread

While extracting everything to have less changes in OMNT classes and more code
in our "composite" classes, i accidentally used Looper.myLooper() instead of the
old handler that was being used... so logging service would update every second
on the UI thread.

Whoops. My bad.

* Previous fix wasn't so great, abandon the CloudCityHandler

Makes no sense for the LoggingService to just have a handler which it'll pass over to our methods.
Since our methods instantiate a new internal handler for the update thread, might as well also
instantiate a new HandlerThread which will force the updates to a background thread (away from the main thread).

So this fix is more resiliant to problems than the previous one (which also didn't work since the handler was never instantiated)

* Update sentry project to new project

* Add sentry properties so AndroidCI workflow can work again

* More sentry updates

* Separate the sentry.properties into two...

So, according to the very bad and ambiguous documentation, there should apparently
be two sentry.properties file:
1. where I originally put it, that just sets the DSN
2. one in the project root that defines the project, org and authToken

So lets try this and see where that gets us.

* Update auth token with the new one I made

* Remove auth token from sentry.properties and just keep it as a repo secret

* Revert "Remove auth token from sentry.properties and just keep it as a repo secret"

This reverts commit e42638f.

* Turn off sentry debug logs

* Add coderabbit's CR suggestion to cache after loading from shared pref

* Rework the last fix

* Apply similar isBlank() fix to other places that were using regular isBlank()

After all, the String#isBlank() is introduced in Java11 aka API34 so for devices running lower APIs
we shouldn't use it; so we have to roll out our own version using String.trim().isEmpty() instead

The Util method checks the API level and acts accordingly.

---------

Co-authored-by: Peter Hasse <[email protected]>
Co-authored-by: Johann <[email protected]>
Co-authored-by: derpeter <[email protected]>
Co-authored-by: hajoha <[email protected]>
Co-authored-by: PeterHasse <[email protected]>
Co-authored-by: Johann <[email protected]>
Co-authored-by: errdemk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants