diff options
12 files changed, 89 insertions, 214 deletions
diff --git a/cmds/interrupter/Android.bp b/cmds/interrupter/Android.bp deleted file mode 100644 index d7f744d0834e..000000000000 --- a/cmds/interrupter/Android.bp +++ /dev/null @@ -1,20 +0,0 @@ -package { - // See: http://go/android-license-faq - // A large-scale-change added 'default_applicable_licenses' to import - // all of the 'license_kinds' from "frameworks_base_license" - // to get the below license kinds: - // SPDX-license-identifier-Apache-2.0 - default_applicable_licenses: ["frameworks_base_license"], -} - -cc_library_shared { - name: "interrupter", - host_supported: true, - srcs: ["interrupter.c"], - cflags: [ - "-Wall", - "-Werror", - "-Wunused", - "-Wunreachable-code", - ], -} diff --git a/cmds/interrupter/interrupter.c b/cmds/interrupter/interrupter.c deleted file mode 100644 index 8bb522a26cec..000000000000 --- a/cmds/interrupter/interrupter.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2012, 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. - */ - -#define _GNU_SOURCE - -/** - * The probability of a syscall failing from 0.0 to 1.0 - */ -#define PROBABILITY 0.9 - - - -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> - -/* for various intercepted calls */ -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <fcntl.h> - -#include <dlfcn.h> - -#include "interrupter.h" - -static int probability = PROBABILITY * RAND_MAX; - -static int maybe_interrupt() { - if (rand() < probability) { - return 1; - } - return 0; -} - -DEFINE_INTERCEPT(read, ssize_t, int, void*, size_t); -DEFINE_INTERCEPT(write, ssize_t, int, const void*, size_t); -DEFINE_INTERCEPT(accept, int, int, struct sockaddr*, socklen_t*); -DEFINE_INTERCEPT(creat, int, const char*, mode_t); diff --git a/cmds/interrupter/interrupter.h b/cmds/interrupter/interrupter.h deleted file mode 100644 index 9ad0277eebbe..000000000000 --- a/cmds/interrupter/interrupter.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2012, 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. - */ - -#define CONCATENATE(arg1, arg2) CONCATENATE1(arg1, arg2) -#define CONCATENATE1(arg1, arg2) CONCATENATE2(arg1, arg2) -#define CONCATENATE2(arg1, arg2) arg1##arg2 - -#define INTERRUPTER(sym) \ - if (real_##sym == NULL) \ - __init_##sym(); \ - if (maybe_interrupt()) { \ - errno = EINTR; \ - return -1; \ - } - -#define CALL_FUNCTION_1(sym, ret, type1) \ -ret (*real_##sym)(type1) = NULL; \ -ret sym(type1 arg1) { \ - INTERRUPTER(sym) \ - return real_##sym(arg1); \ -} - -#define CALL_FUNCTION_2(sym, ret, type1, type2) \ -ret (*real_##sym)(type1, type2) = NULL; \ -ret sym(type1 arg1, type2 arg2) { \ - INTERRUPTER(sym) \ - return real_##sym(arg1, arg2); \ -} - -#define CALL_FUNCTION_3(sym, ret, type1, type2, type3) \ -ret (*real_##sym)(type1, type2, type3) = NULL; \ -ret sym(type1 arg1, type2 arg2, type3 arg3) { \ - INTERRUPTER(sym) \ - return real_##sym(arg1, arg2, arg3); \ -} - -#define CALL_FUNCTION_4(sym, ret, type1, type2, type3, type4) \ -ret (*real_##sym)(type1, type2, type3, type4) = NULL; \ -ret sym(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ - INTERRUPTER(sym) \ - return real_##sym(arg1, arg2, arg3, arg4); \ -} - -#define CALL_FUNCTION_5(sym, ret, type1, type2, type3, type4, type5) \ -ret (*real_##sym)(type1, type2, type3, type4, type5) = NULL; \ -ret sym(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \ - INTERRUPTER(sym) \ - return real_##sym(arg1, arg2, arg3, arg4, arg5); \ -} - -#define DEFINE_INTERCEPT_N(N, sym, ret, ...) \ -static void __init_##sym(void); \ -CONCATENATE(CALL_FUNCTION_, N)(sym, ret, __VA_ARGS__) \ -static void __init_##sym(void) { \ - real_##sym = dlsym(RTLD_NEXT, #sym); \ - if (real_##sym == NULL) { \ - fprintf(stderr, "Error hooking " #sym ": %s\n", dlerror()); \ - } \ -} - -#define INTERCEPT_NARG(...) INTERCEPT_NARG_N(__VA_ARGS__, INTERCEPT_RSEQ_N()) -#define INTERCEPT_NARG_N(...) INTERCEPT_ARG_N(__VA_ARGS__) -#define INTERCEPT_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N -#define INTERCEPT_RSEQ_N() 8, 7, 6, 5, 4, 3, 2, 1, 0 - -#define DEFINE_INTERCEPT(sym, ret, ...) DEFINE_INTERCEPT_N(INTERCEPT_NARG(__VA_ARGS__), sym, ret, __VA_ARGS__) diff --git a/core/java/Android.bp b/core/java/Android.bp index 3f6e65b95c93..22566b75c987 100644 --- a/core/java/Android.bp +++ b/core/java/Android.bp @@ -639,43 +639,8 @@ java_library { // protolog end -// Whether to enable read-only system feature codegen. -gen_readonly_feature_apis = select(release_flag("RELEASE_USE_SYSTEM_FEATURE_BUILD_FLAGS"), { - true: "true", - false: "false", - default: "false", -}) - -// Generates com.android.internal.pm.RoSystemFeatures, optionally compiling in -// details about fixed system features defined by build flags. When disabled, -// the APIs are simply passthrough stubs with no meaningful side effects. -// TODO(b/203143243): Implement the `--feature=` aggregation directly with a native soong module. -genrule { +java_system_features_srcs { name: "systemfeatures-gen-srcs", - cmd: "$(location systemfeatures-gen-tool) com.android.internal.pm.RoSystemFeatures " + - // --readonly=false (default) makes the codegen an effective no-op passthrough API. - " --readonly=" + gen_readonly_feature_apis + - " --feature=AUTOMOTIVE:" + select(release_flag("RELEASE_SYSTEM_FEATURE_AUTOMOTIVE"), { - any @ value: value, - default: "", - }) + " --feature=EMBEDDED:" + select(release_flag("RELEASE_SYSTEM_FEATURE_EMBEDDED"), { - any @ value: value, - default: "", - }) + " --feature=LEANBACK:" + select(release_flag("RELEASE_SYSTEM_FEATURE_LEANBACK"), { - any @ value: value, - default: "", - }) + " --feature=PC:" + select(release_flag("RELEASE_SYSTEM_FEATURE_PC"), { - any @ value: value, - default: "", - }) + " --feature=TELEVISION:" + select(release_flag("RELEASE_SYSTEM_FEATURE_TELEVISION"), { - any @ value: value, - default: "", - }) + " --feature=WATCH:" + select(release_flag("RELEASE_SYSTEM_FEATURE_WATCH"), { - any @ value: value, - default: "", - }) + " > $(out)", - out: [ - "RoSystemFeatures.java", - ], - tools: ["systemfeatures-gen-tool"], + full_class_name: "com.android.internal.pm.RoSystemFeatures", + visibility: ["//visibility:private"], } diff --git a/core/java/android/os/RemoteCallbackList.java b/core/java/android/os/RemoteCallbackList.java index d5630fd46eb4..4123209eb755 100644 --- a/core/java/android/os/RemoteCallbackList.java +++ b/core/java/android/os/RemoteCallbackList.java @@ -214,7 +214,7 @@ public class RemoteCallbackList<E extends IInterface> { if (mFrozenCalleePolicy != FROZEN_CALLEE_POLICY_UNSET) { try { mBinder.removeFrozenStateChangeCallback(this); - } catch (UnsupportedOperationException e) { + } catch (UnsupportedOperationException | IllegalArgumentException e) { // The kernel does not support frozen notifications. Ignore the error and move // on. } diff --git a/core/tests/systemproperties/src/android/os/SystemPropertiesTest.java b/core/tests/systemproperties/src/android/os/SystemPropertiesTest.java index 75aca1b8820c..7ce2ed823540 100644 --- a/core/tests/systemproperties/src/android/os/SystemPropertiesTest.java +++ b/core/tests/systemproperties/src/android/os/SystemPropertiesTest.java @@ -23,10 +23,11 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import android.platform.test.ravenwood.RavenwoodConfig; +import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; +import org.junit.Rule; import org.junit.Test; import java.util.Objects; @@ -39,8 +40,8 @@ public class SystemPropertiesTest { private static final String PERSIST_KEY = "persist.sys.testkey"; private static final String NONEXIST_KEY = "doesnotexist_2341431"; - @RavenwoodConfig.Config - public static final RavenwoodConfig mRavenwood = new RavenwoodConfig.Builder() + @Rule + public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() .setSystemPropertyMutable(KEY, null) .setSystemPropertyMutable(UNSET_KEY, null) .setSystemPropertyMutable(PERSIST_KEY, null) diff --git a/packages/SettingsProvider/src/com/android/providers/settings/OWNERS b/packages/SettingsProvider/src/com/android/providers/settings/OWNERS index 0b7181606247..b0086c180cbd 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/OWNERS +++ b/packages/SettingsProvider/src/com/android/providers/settings/OWNERS @@ -1 +1,2 @@ -per-file WritableNamespacePrefixes.java = cbrubaker@google.com,tedbauer@google.com +per-file WritableNamespacePrefixes.java = mpgroover@google.com,tedbauer@google.com +per-file WritableNamespaces.java = mpgroover@google.com,tedbauer@google.com diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/OWNERS b/packages/SystemUI/src/com/android/systemui/statusbar/OWNERS index 9de229e2ddb8..a594ad64c1a7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/OWNERS +++ b/packages/SystemUI/src/com/android/systemui/statusbar/OWNERS @@ -14,6 +14,14 @@ per-file *Keyboard* = set noparent per-file *Keyboard* = file:../keyguard/OWNERS per-file *Keyguard* = set noparent per-file *Keyguard* = file:../keyguard/OWNERS +# Not setting noparent here, since *Notification* also matches some status bar notification chips files (statusbar/chips/notification) which should be owned by the status bar team. +per-file *Notification* = file:notification/OWNERS +# Not setting noparent here, since *Mode* matches many other classes (e.g., *ViewModel*) +per-file *Mode* = file:notification/OWNERS +per-file *RemoteInput* = set noparent +per-file *RemoteInput* = file:notification/OWNERS +per-file *EmptyShadeView* = set noparent +per-file *EmptyShadeView* = file:notification/OWNERS per-file *Lockscreen* = set noparent per-file *Lockscreen* = file:../keyguard/OWNERS per-file *Scrim* = set noparent diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java index 619c8e30c78e..7ca9239d2062 100644 --- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java +++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java @@ -142,34 +142,32 @@ public final class RavenwoodConfig { } /** - * Configure the given system property as immutable for the duration of the test. - * Read access to the key is allowed, and write access will fail. When {@code value} is - * {@code null}, the value is left as undefined. - * - * All properties in the {@code debug.*} namespace are automatically mutable, with no - * developer action required. - * - * Has no effect on non-Ravenwood environments. + * @deprecated Use {@link RavenwoodRule.Builder#setSystemPropertyImmutable(String, Object)} */ + @Deprecated public Builder setSystemPropertyImmutable(@NonNull String key, @Nullable Object value) { - mConfig.mSystemProperties.setValue(key, value); - mConfig.mSystemProperties.setAccessReadOnly(key); return this; } /** - * Configure the given system property as mutable for the duration of the test. - * Both read and write access to the key is allowed, and its value will be reset between - * each test. When {@code value} is {@code null}, the value is left as undefined. - * - * All properties in the {@code debug.*} namespace are automatically mutable, with no - * developer action required. - * - * Has no effect on non-Ravenwood environments. + * @deprecated Use {@link RavenwoodRule.Builder#setSystemPropertyMutable(String, Object)} */ + @Deprecated public Builder setSystemPropertyMutable(@NonNull String key, @Nullable Object value) { + return this; + } + + Builder setSystemPropertyImmutableReal(@NonNull String key, + @Nullable Object value) { + mConfig.mSystemProperties.setValue(key, value); + mConfig.mSystemProperties.setAccessReadOnly(key); + return this; + } + + Builder setSystemPropertyMutableReal(@NonNull String key, + @Nullable Object value) { mConfig.mSystemProperties.setValue(key, value); mConfig.mSystemProperties.setAccessReadWrite(key); return this; diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java index f7acd9022300..5681a9040f63 100644 --- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java +++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java @@ -152,7 +152,7 @@ public final class RavenwoodRule implements TestRule { * Has no effect on non-Ravenwood environments. */ public Builder setSystemPropertyImmutable(@NonNull String key, @Nullable Object value) { - mBuilder.setSystemPropertyImmutable(key, value); + mBuilder.setSystemPropertyImmutableReal(key, value); return this; } @@ -167,7 +167,7 @@ public final class RavenwoodRule implements TestRule { * Has no effect on non-Ravenwood environments. */ public Builder setSystemPropertyMutable(@NonNull String key, @Nullable Object value) { - mBuilder.setSystemPropertyMutable(key, value); + mBuilder.setSystemPropertyMutableReal(key, value); return this; } diff --git a/services/core/java/com/android/server/SystemConfig.java b/services/core/java/com/android/server/SystemConfig.java index 9b987e9850c4..8c83ad70625a 100644 --- a/services/core/java/com/android/server/SystemConfig.java +++ b/services/core/java/com/android/server/SystemConfig.java @@ -1319,6 +1319,7 @@ public class SystemConfig { } XmlUtils.skipCurrentTag(parser); } break; + case "disabled-in-sku": case "disabled-until-used-preinstalled-carrier-app": { if (allowAppConfigs) { String pkgname = parser.getAttributeValue(null, "package"); @@ -1335,6 +1336,24 @@ public class SystemConfig { } XmlUtils.skipCurrentTag(parser); } break; + case "enabled-in-sku-override": { + if (allowAppConfigs) { + String pkgname = parser.getAttributeValue(null, "package"); + if (pkgname == null) { + Slog.w(TAG, + "<" + name + "> without " + + "package in " + permFile + " at " + + parser.getPositionDescription()); + } else if (!mDisabledUntilUsedPreinstalledCarrierApps.remove(pkgname)) { + Slog.w(TAG, + "<" + name + "> packagename:" + pkgname + " not included" + + "in disabled-in-sku"); + } + } else { + logNotAllowedInPartition(name, permFile, parser); + } + XmlUtils.skipCurrentTag(parser); + } break; case "privapp-permissions": { if (allowPrivappPermissions) { // privapp permissions from system, apex, vendor, product and diff --git a/services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java b/services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java index 3bc089fb3f5d..842c441e09f2 100644 --- a/services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java +++ b/services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java @@ -691,6 +691,40 @@ public class SystemConfigTest { assertThat(actual).isEqualTo(expected); } + /** + * Tests that readPermissions works correctly for the tags: + * disabled-in-sku, enabled-in-sku-override. + * I.e. that disabled-in-sku add package to block list and + * enabled-in-sku-override removes package from the list. + */ + @Test + public void testDisablePackageInSku() throws Exception { + final String disable_in_sku = + "<config>\n" + + " <disabled-in-sku package=\"com.sony.product1.app\"/>\n" + + " <disabled-in-sku package=\"com.sony.product2.app\"/>\n" + + "</config>\n"; + + final String enable_in_sku_override = + "<config>\n" + + " <enabled-in-sku-override package=\"com.sony.product2.app\"/>\n" + + "</config>\n"; + + final File folder1 = createTempSubfolder("folder1"); + createTempFile(folder1, "permissionFile1.xml", disable_in_sku); + + final File folder2 = createTempSubfolder("folder2"); + createTempFile(folder2, "permissionFile2.xml", enable_in_sku_override); + + readPermissions(folder1, /* Grant all permission flags */ ~0); + readPermissions(folder2, /* Grant all permission flags */ ~0); + + final ArraySet<String> blocklist = mSysConfig.getDisabledUntilUsedPreinstalledCarrierApps(); + + assertThat(blocklist).contains("com.sony.product1.app"); + assertThat(blocklist).doesNotContain("com.sony.product2.app"); + } + private void parseSharedLibraries(String contents) throws IOException { File folder = createTempSubfolder("permissions_folder"); createTempFile(folder, "permissions.xml", contents); |