summaryrefslogtreecommitdiffstats
path: root/tests/wifitests/src/com/android/server/wifi/BinderUtil.java
diff options
context:
space:
mode:
authorBartosz Fabianowski <bartfab@google.com>2016-02-12 10:30:55 +0100
committerBartosz Fabianowski <bartfab@google.com>2016-02-12 10:30:55 +0100
commit0fb9cf43830d67894b519c9a6271320c4842a5c0 (patch)
tree776bdaf325ad9741093e799ba774a7ea3090f112 /tests/wifitests/src/com/android/server/wifi/BinderUtil.java
parent75ad7fa297007a0cfe1b5a02f45c78441d819d42 (diff)
downloadandroid_frameworks_opt_net_wifi-0fb9cf43830d67894b519c9a6271320c4842a5c0.tar.gz
android_frameworks_opt_net_wifi-0fb9cf43830d67894b519c9a6271320c4842a5c0.tar.bz2
android_frameworks_opt_net_wifi-0fb9cf43830d67894b519c9a6271320c4842a5c0.zip
Allow managed profile to modify networks
If the current foreground user has a managed profile, apps running in that profile should have the same permissions to add/remove/modify networks as apps running as the foreground user itself. This is a re-submit of https://partner-android-review.googlesource.com/#/c/529950/ with updated unit tests that will also work after merging to N/master. BUG=26867426 Change-Id: If97734abad801ae1264919c91c3ef4236469cfde
Diffstat (limited to 'tests/wifitests/src/com/android/server/wifi/BinderUtil.java')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/BinderUtil.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/BinderUtil.java b/tests/wifitests/src/com/android/server/wifi/BinderUtil.java
new file mode 100644
index 000000000..107de7c8d
--- /dev/null
+++ b/tests/wifitests/src/com/android/server/wifi/BinderUtil.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.wifi;
+
+import android.os.Binder;
+
+/**
+ * Utilities for faking the calling uid in Binder.
+ */
+public class BinderUtil {
+ /**
+ * Fake the calling uid in Binder.
+ * @param uid the calling uid that Binder should return from now on
+ */
+ public static void setUid(int uid) {
+ Binder.restoreCallingIdentity((((long) uid) << 32) | Binder.getCallingPid());
+ }
+}