From 9ec6f0e41a68677232c442d9fba24debe8c8791c Mon Sep 17 00:00:00 2001 From: Chaohui Wang Date: Mon, 30 May 2022 01:01:55 +0800 Subject: [PATCH] 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 --- Android.bp | 15 ++++++-- src/com/android/settings/ChangeIds.java | 35 +++++++++++++++++++ .../ManageApplications.java | 13 +------ 3 files changed, 48 insertions(+), 15 deletions(-) create mode 100644 src/com/android/settings/ChangeIds.java diff --git a/Android.bp b/Android.bp index 619a390d8b8..5bf5514cbc4 100644 --- a/Android.bp +++ b/Android.bp @@ -35,6 +35,15 @@ java_library { ], } +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 @@ android_library { "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 @@ filegroup { // 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 00000000000..1f772016d5f --- /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 ead9840af7a..e12bc1cc76a 100644 --- a/src/com/android/settings/applications/manageapplications/ManageApplications.java +++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java @@ -18,6 +18,7 @@ package com.android.settings.applications.manageapplications; 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.Activity; 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 class ManageApplications extends InstrumentedFragment 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;