From b94c51537066089eace6e23e31287bf7807a9ed0 Mon Sep 17 00:00:00 2001 From: markchien Date: Mon, 10 May 2021 00:34:47 +0800 Subject: [PATCH] Use SettingsShim to hide different implementation in shim TetheringService call different Settings API to check write settings permission between R and S. Bug: 182211575 Test: install S module to R device and both run mts tests build with S and R. Change-Id: I3e7f6525e9776992bd96b17c132b749b12285bbd Merged-In: I3e7f6525e9776992bd96b17c132b749b12285bbd --- Tethering/Android.bp | 1 + .../networkstack/tethering/TetheringService.java | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Tethering/Android.bp b/Tethering/Android.bp index 60c1f2b871..495c9d77d5 100644 --- a/Tethering/Android.bp +++ b/Tethering/Android.bp @@ -41,6 +41,7 @@ java_defaults { "net-utils-device-common", "net-utils-device-common-netlink", "netd-client", + "NetworkStackApiCurrentShims", ], libs: [ "framework-connectivity", diff --git a/Tethering/src/com/android/networkstack/tethering/TetheringService.java b/Tethering/src/com/android/networkstack/tethering/TetheringService.java index d3d2962c9f..175b480297 100644 --- a/Tethering/src/com/android/networkstack/tethering/TetheringService.java +++ b/Tethering/src/com/android/networkstack/tethering/TetheringService.java @@ -47,13 +47,14 @@ import android.os.IBinder; import android.os.Looper; import android.os.RemoteException; import android.os.ResultReceiver; -import android.provider.Settings; import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.internal.annotations.VisibleForTesting; +import com.android.networkstack.apishim.SettingsShimImpl; +import com.android.networkstack.apishim.common.SettingsShim; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -67,6 +68,7 @@ public class TetheringService extends Service { private static final String TAG = TetheringService.class.getSimpleName(); private TetheringConnector mConnector; + private SettingsShim mSettingsShim; @Override public void onCreate() { @@ -74,6 +76,8 @@ public class TetheringService extends Service { // The Tethering object needs a fully functional context to start, so this can't be done // in the constructor. mConnector = new TetheringConnector(makeTethering(deps), TetheringService.this); + + mSettingsShim = SettingsShimImpl.newInstance(); } /** @@ -306,8 +310,8 @@ public class TetheringService extends Service { boolean checkAndNoteWriteSettingsOperation(@NonNull Context context, int uid, @NonNull String callingPackage, @Nullable String callingAttributionTag, boolean throwException) { - return Settings.checkAndNoteWriteSettingsOperation(context, uid, callingPackage, - throwException); + return mSettingsShim.checkAndNoteWriteSettingsOperation(context, uid, callingPackage, + callingAttributionTag, throwException); } /**