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
diff --git a/Tethering/Android.bp b/Tethering/Android.bp
index 60c1f2b..495c9d7 100644
--- a/Tethering/Android.bp
+++ b/Tethering/Android.bp
@@ -41,6 +41,7 @@
"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 d3d2962..175b480 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.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 @@
private static final String TAG = TetheringService.class.getSimpleName();
private TetheringConnector mConnector;
+ private SettingsShim mSettingsShim;
@Override
public void onCreate() {
@@ -74,6 +76,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();
}
/**
@@ -306,8 +310,8 @@
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);
}
/**