Enable Kotlin for Settings App
Currently Kotlin files cannot build with library app-compat-annotations.
Only one @ChangeId need this library, create separate build target
library Settings-change-ids to solve this issue.
After this cl, Kotlin could be used for Settings App.
Fix: 229037247
Test: make Settings
Change-Id: I4a0d99425c9e6cc2cbc015d2561daa68609ca0fd
diff --git a/Android.bp b/Android.bp
index 619a390..5bf5514 100644
--- a/Android.bp
+++ b/Android.bp
@@ -35,6 +35,15 @@
],
}
+java_library {
+ name: "Settings-change-ids",
+ srcs: ["src/com/android/settings/ChangeIds.java"],
+ libs: [
+ "app-compat-annotations",
+ ],
+}
+
+
// Build the Settings APK
android_library {
name: "Settings-core",
@@ -77,18 +86,18 @@
"lottie",
"WifiTrackerLib",
"SettingsLibActivityEmbedding",
+ "Settings-change-ids",
],
libs: [
"telephony-common",
"ims-common",
- "app-compat-annotations",
],
}
platform_compat_config {
name: "settings-platform-compat-config",
- src: ":Settings-core",
+ src: ":Settings-change-ids",
system_ext_specific: true,
}
@@ -126,7 +135,7 @@
// over all the sources together.
filegroup {
name: "Settings_srcs",
- srcs: ["src/**/*.java"],
+ srcs: ["src/**/*.java", "src/**/*.kt"],
}
filegroup {
diff --git a/src/com/android/settings/ChangeIds.java b/src/com/android/settings/ChangeIds.java
new file mode 100644
index 0000000..1f77201
--- /dev/null
+++ b/src/com/android/settings/ChangeIds.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2022 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.settings;
+
+import android.compat.annotation.ChangeId;
+import android.compat.annotation.LoggingOnly;
+
+/**
+ * All the {@link ChangeId} used for Settings App.
+ */
+public class ChangeIds {
+ /**
+ * Intents with action {@code android.settings.MANAGE_APP_OVERLAY_PERMISSION}
+ * and data URI scheme {@code package} don't go to the app-specific screen for managing the
+ * permission anymore. Instead, they redirect to this screen for managing all the apps that have
+ * requested such permission.
+ */
+ @ChangeId
+ @LoggingOnly
+ public static final long CHANGE_RESTRICT_SAW_INTENT = 135920175L;
+}
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index ead9840..e12bc1c 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -18,6 +18,7 @@
import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE;
+import static com.android.settings.ChangeIds.CHANGE_RESTRICT_SAW_INTENT;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_ALL;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_BLOCKED;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_DISABLED;
@@ -37,8 +38,6 @@
import android.app.ActivityManager;
import android.app.settings.SettingsEnums;
import android.app.usage.IUsageStatsManager;
-import android.compat.annotation.ChangeId;
-import android.compat.annotation.LoggingOnly;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -190,16 +189,6 @@
public static final int STORAGE_TYPE_DEFAULT = 0; // Show all apps that are not categorized.
public static final int STORAGE_TYPE_LEGACY = 1; // Show apps even if they can be categorized.
- /**
- * Intents with action {@code android.settings.MANAGE_APP_OVERLAY_PERMISSION}
- * and data URI scheme {@code package} don't go to the app-specific screen for managing the
- * permission anymore. Instead, they redirect to this screen for managing all the apps that have
- * requested such permission.
- */
- @ChangeId
- @LoggingOnly
- private static final long CHANGE_RESTRICT_SAW_INTENT = 135920175L;
-
// sort order
@VisibleForTesting
int mSortOrder = R.id.sort_order_alpha;