From 3bc52765682c773c5bcacbd44d8516e5879bb737 Mon Sep 17 00:00:00 2001 From: Chiachang Wang Date: Thu, 25 Nov 2021 14:17:57 +0800 Subject: [PATCH] Enable strict_updatability_linting in connectivity src Bug: 188851968 Test: m lint-check Change-Id: I3cd06ea16f05cb37d9369a48dd0285d8239fd764 --- Tethering/Android.bp | 7 +++ Tethering/common/TetheringLib/Android.bp | 1 + framework/Android.bp | 1 + framework/lint-baseline.xml | 48 ------------------- .../net/util/MultinetworkPolicyTracker.java | 8 +++- service/Android.bp | 3 ++ service/lint-baseline.xml | 37 -------------- .../android/server/ConnectivityService.java | 8 ++++ 8 files changed, 26 insertions(+), 87 deletions(-) delete mode 100644 framework/lint-baseline.xml delete mode 100644 service/lint-baseline.xml diff --git a/Tethering/Android.bp b/Tethering/Android.bp index 3c49383e80..20efc3e61d 100644 --- a/Tethering/Android.bp +++ b/Tethering/Android.bp @@ -56,6 +56,7 @@ java_defaults { ], plugins: ["java_api_finder"], manifest: "AndroidManifestBase.xml", + lint: { strict_updatability_linting: true }, } // build tethering static library, used to compile both variants of the tethering. @@ -69,6 +70,7 @@ android_library { "NetworkStackApiCurrentShims", ], apex_available: ["com.android.tethering"], + lint: { strict_updatability_linting: true }, } android_library { @@ -81,6 +83,7 @@ android_library { "NetworkStackApiStableShims", ], apex_available: ["com.android.tethering"], + lint: { strict_updatability_linting: true }, } // Due to b/143733063, APK can't access a jni lib that is in APEX (but not in the APK). @@ -147,6 +150,7 @@ java_defaults { optimize: { proguard_flags_files: ["proguard.flags"], }, + lint: { strict_updatability_linting: true }, } // Non-updatable tethering running in the system server process for devices not using the module @@ -159,6 +163,7 @@ android_app { // InProcessTethering is a replacement for Tethering overrides: ["Tethering"], apex_available: ["com.android.tethering"], + lint: { strict_updatability_linting: true }, } // Updatable tethering packaged for finalized API @@ -175,6 +180,7 @@ android_app { "privapp_whitelist_com.android.networkstack.tethering", ], apex_available: ["com.android.tethering"], + lint: { strict_updatability_linting: true }, } android_app { @@ -190,6 +196,7 @@ android_app { "privapp_whitelist_com.android.networkstack.tethering", ], apex_available: ["com.android.tethering"], + lint: { strict_updatability_linting: true }, } sdk { diff --git a/Tethering/common/TetheringLib/Android.bp b/Tethering/common/TetheringLib/Android.bp index 6e645704ca..c82a9937bf 100644 --- a/Tethering/common/TetheringLib/Android.bp +++ b/Tethering/common/TetheringLib/Android.bp @@ -53,6 +53,7 @@ java_sdk_library { apex_available: ["com.android.tethering"], permitted_packages: ["android.net"], min_sdk_version: "30", + lint: { strict_updatability_linting: true }, } filegroup { diff --git a/framework/Android.bp b/framework/Android.bp index d31f74fe0d..e765ee8bd2 100644 --- a/framework/Android.bp +++ b/framework/Android.bp @@ -112,6 +112,7 @@ java_sdk_library { apex_available: [ "com.android.tethering", ], + lint: { strict_updatability_linting: true }, } cc_library_shared { diff --git a/framework/lint-baseline.xml b/framework/lint-baseline.xml deleted file mode 100644 index 099202f97c..0000000000 --- a/framework/lint-baseline.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/framework/src/android/net/util/MultinetworkPolicyTracker.java b/framework/src/android/net/util/MultinetworkPolicyTracker.java index 3e7cb80258..c1790c992c 100644 --- a/framework/src/android/net/util/MultinetworkPolicyTracker.java +++ b/framework/src/android/net/util/MultinetworkPolicyTracker.java @@ -20,6 +20,7 @@ import static android.net.ConnectivitySettingsManager.NETWORK_AVOID_BAD_WIFI; import static android.net.ConnectivitySettingsManager.NETWORK_METERED_MULTIPATH_PREFERENCE; import android.annotation.NonNull; +import android.annotation.TargetApi; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; @@ -29,6 +30,7 @@ import android.content.res.Resources; import android.database.ContentObserver; import android.net.ConnectivityResources; import android.net.Uri; +import android.os.Build; import android.os.Handler; import android.provider.Settings; import android.telephony.SubscriptionManager; @@ -92,8 +94,8 @@ public class MultinetworkPolicyTracker { } } } - - @VisibleForTesting + // TODO: Set the mini sdk to 31 and remove @TargetApi annotation when b/205923322 is addressed. + @VisibleForTesting @TargetApi(Build.VERSION_CODES.S) protected class ActiveDataSubscriptionIdListener extends TelephonyCallback implements TelephonyCallback.ActiveDataSubscriptionIdListener { @Override @@ -107,6 +109,8 @@ public class MultinetworkPolicyTracker { this(ctx, handler, null); } + // TODO: Set the mini sdk to 31 and remove @TargetApi annotation when b/205923322 is addressed. + @TargetApi(Build.VERSION_CODES.S) public MultinetworkPolicyTracker(Context ctx, Handler handler, Runnable avoidBadWifiCallback) { mContext = ctx; mResources = new ConnectivityResources(ctx); diff --git a/service/Android.bp b/service/Android.bp index 3ff7a7c23d..d1abdec15d 100644 --- a/service/Android.bp +++ b/service/Android.bp @@ -80,6 +80,7 @@ java_library { apex_available: [ "com.android.tethering", ], + lint: { strict_updatability_linting: true }, } java_library { @@ -96,6 +97,7 @@ java_library { apex_available: [ "com.android.tethering", ], + lint: { strict_updatability_linting: true }, } java_library { @@ -110,6 +112,7 @@ java_library { apex_available: [ "com.android.tethering", ], + lint: { strict_updatability_linting: true }, } filegroup { diff --git a/service/lint-baseline.xml b/service/lint-baseline.xml deleted file mode 100644 index 119b64ff95..0000000000 --- a/service/lint-baseline.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java index 222f5c8379..145f4c1e67 100644 --- a/service/src/com/android/server/ConnectivityService.java +++ b/service/src/com/android/server/ConnectivityService.java @@ -98,6 +98,7 @@ import static java.util.Map.Entry; import android.Manifest; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.TargetApi; import android.app.AppOpsManager; import android.app.BroadcastOptions; import android.app.PendingIntent; @@ -853,6 +854,9 @@ public class ConnectivityService extends IConnectivityManager.Stub mTypeLists = new ArrayList[ConnectivityManager.MAX_NETWORK_TYPE + 1]; } + // TODO: Set the mini sdk to 31 and remove @TargetApi annotation when b/205923322 is + // addressed. + @TargetApi(Build.VERSION_CODES.S) public void loadSupportedTypes(@NonNull Context ctx, @NonNull TelephonyManager tm) { final PackageManager pm = ctx.getPackageManager(); if (pm.hasSystemFeature(FEATURE_WIFI)) { @@ -2760,6 +2764,8 @@ public class ConnectivityService extends IConnectivityManager.Stub sendStickyBroadcast(makeGeneralIntent(info, bcastType)); } + // TODO: Set the mini sdk to 31 and remove @TargetApi annotation when b/205923322 is addressed. + @TargetApi(Build.VERSION_CODES.S) private void sendStickyBroadcast(Intent intent) { synchronized (this) { if (!mSystemReady @@ -6109,6 +6115,8 @@ public class ConnectivityService extends IConnectivityManager.Stub } } + // TODO: Set the mini sdk to 31 and remove @TargetApi annotation when b/205923322 is addressed. + @TargetApi(Build.VERSION_CODES.S) private boolean isTargetSdkAtleast(int version, int callingUid, @NonNull String callingPackageName) { final UserHandle user = UserHandle.getUserHandleForUid(callingUid);