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
diff --git a/Tethering/Android.bp b/Tethering/Android.bp
index 89f1505..3ca340f 100644
--- a/Tethering/Android.bp
+++ b/Tethering/Android.bp
@@ -40,6 +40,7 @@
"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 3438b9b..9509b56 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.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 @@
private static final String TAG = TetheringService.class.getSimpleName();
private TetheringConnector mConnector;
+ private SettingsShim mSettingsShim;
@Override
public void onCreate() {
@@ -75,6 +77,8 @@
// 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 @@
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);
}