Merge "Use SettingsShim to hide different implementation in shim" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-05-15 06:27:38 +00:00
committed by Android (Google) Code Review
2 changed files with 7 additions and 2 deletions

View File

@@ -41,6 +41,7 @@ java_defaults {
"net-utils-framework-common", "net-utils-framework-common",
"net-utils-device-common", "net-utils-device-common",
"netd-client", "netd-client",
"NetworkStackApiCurrentShims",
], ],
libs: [ libs: [
"framework-connectivity", "framework-connectivity",

View File

@@ -46,13 +46,14 @@ import android.os.IBinder;
import android.os.Looper; import android.os.Looper;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ResultReceiver; import android.os.ResultReceiver;
import android.provider.Settings;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.android.internal.annotations.VisibleForTesting; 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.FileDescriptor;
import java.io.PrintWriter; import java.io.PrintWriter;
@@ -66,6 +67,7 @@ public class TetheringService extends Service {
private static final String TAG = TetheringService.class.getSimpleName(); private static final String TAG = TetheringService.class.getSimpleName();
private TetheringConnector mConnector; private TetheringConnector mConnector;
private SettingsShim mSettingsShim;
@Override @Override
public void onCreate() { public void onCreate() {
@@ -73,6 +75,8 @@ public class TetheringService extends Service {
// The Tethering object needs a fully functional context to start, so this can't be done // The Tethering object needs a fully functional context to start, so this can't be done
// in the constructor. // in the constructor.
mConnector = new TetheringConnector(makeTethering(deps), TetheringService.this); mConnector = new TetheringConnector(makeTethering(deps), TetheringService.this);
mSettingsShim = SettingsShimImpl.newInstance();
} }
/** /**
@@ -294,7 +298,7 @@ public class TetheringService extends Service {
boolean checkAndNoteWriteSettingsOperation(@NonNull Context context, int uid, boolean checkAndNoteWriteSettingsOperation(@NonNull Context context, int uid,
@NonNull String callingPackage, @Nullable String callingAttributionTag, @NonNull String callingPackage, @Nullable String callingAttributionTag,
boolean throwException) { boolean throwException) {
return Settings.checkAndNoteWriteSettingsOperation(context, uid, callingPackage, return mSettingsShim.checkAndNoteWriteSettingsOperation(context, uid, callingPackage,
callingAttributionTag, throwException); callingAttributionTag, throwException);
} }