omnt / OpenMobileNetworkToolkit

OpenMobileNetworkToolkit
BSD 3-Clause Clear License
28 stars 6 forks source link

Fix Warnings #28

Open hajoha opened 4 months ago

hajoha commented 4 months ago

Bug Report

Context

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 commented 4 months ago

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

PeterHasse commented 4 months ago

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