From dfa5697a7076ebc4ae318305c6df291d37a8b0a4 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. Ignore-AOSP-First: to address the conflict Change-Id: I3e7f6525e9776992bd96b17c132b749b12285bbd --- Tethering/Android.bp | 1 + .../android/networkstack/tethering/TetheringService.java | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Tethering/Android.bp b/Tethering/Android.bp index 89f1505b0c..3ca340fa96 100644 --- a/Tethering/Android.bp +++ b/Tethering/Android.bp @@ -40,6 +40,7 @@ java_defaults { "net-utils-framework-common", "net-utils-device-common", "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 3438b9beac..9509b56ce6 100644 --- a/Tethering/src/com/android/networkstack/tethering/TetheringService.java +++ b/Tethering/src/com/android/networkstack/tethering/TetheringService.java @@ -48,13 +48,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; @@ -68,6 +69,7 @@ public class TetheringService extends Service { private static final String TAG = TetheringService.class.getSimpleName(); private TetheringConnector mConnector; + private SettingsShim mSettingsShim; @Override public void onCreate() { @@ -75,6 +77,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(); } /** @@ -298,7 +302,7 @@ 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, + return mSettingsShim.checkAndNoteWriteSettingsOperation(context, uid, callingPackage, callingAttributionTag, throwException); }