diff options
120 files changed, 1220 insertions, 1096 deletions
diff --git a/apex/Android.bp b/apex/Android.bp index abebfa39fada..362cf95b3832 100644 --- a/apex/Android.bp +++ b/apex/Android.bp @@ -29,6 +29,16 @@ mainline_stubs_args = // TODO: remove this server classes are cleaned up. mainline_stubs_args += "--hide-package com.android.server " +priv_apps = " " + + "--show-annotation android.annotation.SystemApi\\(" + + "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS," + + "\\) " + +module_libs = " " + + " --show-annotation android.annotation.SystemApi\\(" + + "client=android.annotation.SystemApi.Client.MODULE_LIBRARIES," + + "\\) " + stubs_defaults { name: "framework-module-stubs-defaults-publicapi", args: mainline_stubs_args, @@ -37,36 +47,23 @@ stubs_defaults { stubs_defaults { name: "framework-module-stubs-defaults-systemapi", - args: mainline_stubs_args + - " --show-annotation android.annotation.SystemApi\\(" + - "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS," + - "process=android.annotation.SystemApi.Process.ALL\\) ", + args: mainline_stubs_args + priv_apps, installable: false, } +// The defaults for module_libs comes in two parts - defaults for API checks +// and defaults for stub generation. This is because we want the API txt +// files to *only* include the module_libs_api, but the stubs to include +// module_libs_api as well as priv_apps. + stubs_defaults { - name: "framework-module-stubs-defaults-module_apps_api", - args: mainline_stubs_args + - " --show-annotation android.annotation.SystemApi\\(" + - "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS," + - "process=android.annotation.SystemApi.Process.ALL\\) " + - " --show-annotation android.annotation.SystemApi\\(" + - "client=android.annotation.SystemApi.Client.MODULE_APPS," + - "process=android.annotation.SystemApi.Process.ALL\\) ", + name: "framework-module-api-defaults-module_libs_api", + args: mainline_stubs_args + module_libs, installable: false, } stubs_defaults { name: "framework-module-stubs-defaults-module_libs_api", - args: mainline_stubs_args + - " --show-annotation android.annotation.SystemApi\\(" + - "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS," + - "process=android.annotation.SystemApi.Process.ALL\\) " + - " --show-annotation android.annotation.SystemApi\\(" + - "client=android.annotation.SystemApi.Client.MODULE_APPS," + - "process=android.annotation.SystemApi.Process.ALL\\) " + - " --show-annotation android.annotation.SystemApi\\(" + - "client=android.annotation.SystemApi.Client.MODULE_LIBRARIES," + - "process=android.annotation.SystemApi.Process.ALL\\) ", + args: mainline_stubs_args + module_libs + priv_apps, installable: false, } diff --git a/api/current.txt b/api/current.txt index 5ac58d043660..2416493fac9d 100644 --- a/api/current.txt +++ b/api/current.txt @@ -14860,10 +14860,11 @@ package android.graphics { method public void offset(int, int); method public void set(@NonNull android.graphics.Outline); method public void setAlpha(@FloatRange(from=0.0, to=1.0) float); - method public void setConvexPath(@NonNull android.graphics.Path); + method @Deprecated public void setConvexPath(@NonNull android.graphics.Path); method public void setEmpty(); method public void setOval(int, int, int, int); method public void setOval(@NonNull android.graphics.Rect); + method public void setPath(@NonNull android.graphics.Path); method public void setRect(int, int, int, int); method public void setRect(@NonNull android.graphics.Rect); method public void setRoundRect(int, int, int, int, float); diff --git a/api/module-app-current.txt b/api/module-app-current.txt index dadbd79e0e8d..d802177e249b 100644 --- a/api/module-app-current.txt +++ b/api/module-app-current.txt @@ -1,21 +1 @@ // Signature format: 2.0 -package android.app { - - public final class NotificationChannel implements android.os.Parcelable { - method public void setBlockableSystem(boolean); - } - -} - -package android.provider { - - public final class DocumentsContract { - method @NonNull public static android.net.Uri buildDocumentUriAsUser(@NonNull String, @NonNull String, @NonNull android.os.UserHandle); - } - - public static final class Settings.Global extends android.provider.Settings.NameValueTable { - field public static final String COMMON_CRITERIA_MODE = "common_criteria_mode"; - } - -} - diff --git a/api/system-current.txt b/api/system-current.txt index ff2d308da01c..3548b6cf5e15 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -665,6 +665,7 @@ package android.app { method public int getUserLockedFields(); method public boolean isDeleted(); method public void populateFromXml(org.xmlpull.v1.XmlPullParser); + method public void setBlockableSystem(boolean); method public org.json.JSONObject toJson() throws org.json.JSONException; method public void writeXml(org.xmlpull.v1.XmlSerializer) throws java.io.IOException; field public static final int USER_LOCKED_SOUND = 32; // 0x20 @@ -9460,6 +9461,7 @@ package android.provider { } public final class DocumentsContract { + method @NonNull public static android.net.Uri buildDocumentUriAsUser(@NonNull String, @NonNull String, @NonNull android.os.UserHandle); method public static boolean isManageMode(@NonNull android.net.Uri); method @NonNull public static android.net.Uri setManageMode(@NonNull android.net.Uri); field public static final String ACTION_DOCUMENT_ROOT_SETTINGS = "android.provider.action.DOCUMENT_ROOT_SETTINGS"; @@ -9620,6 +9622,7 @@ package android.provider { field public static final String AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES = "autofill_compat_mode_allowed_packages"; field public static final String CARRIER_APP_NAMES = "carrier_app_names"; field public static final String CARRIER_APP_WHITELIST = "carrier_app_whitelist"; + field public static final String COMMON_CRITERIA_MODE = "common_criteria_mode"; field public static final String DEFAULT_SM_DP_PLUS = "default_sm_dp_plus"; field public static final String DEVICE_DEMO_MODE = "device_demo_mode"; field public static final String DEVICE_PROVISIONING_MOBILE_DATA_ENABLED = "device_provisioning_mobile_data"; diff --git a/cmds/statsd/Android.bp b/cmds/statsd/Android.bp index bd4397afaeb7..2237bf2b2acb 100644 --- a/cmds/statsd/Android.bp +++ b/cmds/statsd/Android.bp @@ -122,7 +122,6 @@ cc_defaults { "libbase", "libcutils", "liblog", - "libplatformprotos", "libprotoutil", "libstatslog", "libstatssocket", diff --git a/cmds/statsd/src/HashableDimensionKey.cpp b/cmds/statsd/src/HashableDimensionKey.cpp index 109785f649e4..5b75b97a0764 100644 --- a/cmds/statsd/src/HashableDimensionKey.cpp +++ b/cmds/statsd/src/HashableDimensionKey.cpp @@ -16,8 +16,6 @@ #define DEBUG false // STOPSHIP if true #include "Log.h" -#include <mutex> - #include "HashableDimensionKey.h" #include "FieldValue.h" diff --git a/cmds/statsd/src/StatsLogProcessor.cpp b/cmds/statsd/src/StatsLogProcessor.cpp index 34818145a922..879b3c3e52aa 100644 --- a/cmds/statsd/src/StatsLogProcessor.cpp +++ b/cmds/statsd/src/StatsLogProcessor.cpp @@ -20,11 +20,7 @@ #include "StatsLogProcessor.h" #include <android-base/file.h> -#include <dirent.h> #include <frameworks/base/cmds/statsd/src/active_config_list.pb.h> -#include <log/log_event_list.h> -#include <utils/Errors.h> -#include <utils/SystemClock.h> #include "android-base/stringprintf.h" #include "atoms_info.h" @@ -47,8 +43,6 @@ using android::util::FIELD_TYPE_INT64; using android::util::FIELD_TYPE_MESSAGE; using android::util::FIELD_TYPE_STRING; using android::util::ProtoOutputStream; -using std::make_unique; -using std::unique_ptr; using std::vector; namespace android { diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp index 05281f79592f..8a8c1e6ff0ac 100644 --- a/cmds/statsd/src/StatsService.cpp +++ b/cmds/statsd/src/StatsService.cpp @@ -27,12 +27,10 @@ #include "subscriber/SubscriberReporter.h" #include <android-base/file.h> -#include <android-base/stringprintf.h> #include <android-base/strings.h> #include <binder/IPCThreadState.h> #include <binder/PermissionController.h> #include <cutils/multiuser.h> -#include <dirent.h> #include <frameworks/base/cmds/statsd/src/statsd_config.pb.h> #include <frameworks/base/cmds/statsd/src/uid_data.pb.h> #include <private/android_filesystem_config.h> @@ -41,17 +39,13 @@ #include <stdlib.h> #include <sys/system_properties.h> #include <unistd.h> -#include <utils/Looper.h> #include <utils/String16.h> -#include <chrono> using namespace android; using android::base::StringPrintf; using android::util::FIELD_COUNT_REPEATED; -using android::util::FIELD_TYPE_INT64; using android::util::FIELD_TYPE_MESSAGE; -using android::util::ProtoReader; namespace android { namespace os { diff --git a/cmds/statsd/src/StatsService.h b/cmds/statsd/src/StatsService.h index f2079d9f278f..3bfaa9842950 100644 --- a/cmds/statsd/src/StatsService.h +++ b/cmds/statsd/src/StatsService.h @@ -37,11 +37,9 @@ #include <binder/ParcelFileDescriptor.h> #include <utils/Looper.h> -#include <deque> #include <mutex> using namespace android; -using namespace android::base; using namespace android::binder; using namespace android::frameworks::stats::V1_0; using namespace android::os; diff --git a/cmds/statsd/src/anomaly/AlarmMonitor.h b/cmds/statsd/src/anomaly/AlarmMonitor.h index bca858e67f13..219695ef5e43 100644 --- a/cmds/statsd/src/anomaly/AlarmMonitor.h +++ b/cmds/statsd/src/anomaly/AlarmMonitor.h @@ -21,8 +21,6 @@ #include <android/os/IStatsCompanionService.h> #include <utils/RefBase.h> -#include <queue> -#include <set> #include <unordered_set> #include <vector> diff --git a/cmds/statsd/src/anomaly/AnomalyTracker.h b/cmds/statsd/src/anomaly/AnomalyTracker.h index e9414735b82b..794ee988ef55 100644 --- a/cmds/statsd/src/anomaly/AnomalyTracker.h +++ b/cmds/statsd/src/anomaly/AnomalyTracker.h @@ -16,8 +16,6 @@ #pragma once -#include <memory> // unique_ptr - #include <stdlib.h> #include <gtest/gtest_prod.h> diff --git a/cmds/statsd/src/anomaly/subscriber_util.cpp b/cmds/statsd/src/anomaly/subscriber_util.cpp index 4c30c4cb223c..5a4a41d01de6 100644 --- a/cmds/statsd/src/anomaly/subscriber_util.cpp +++ b/cmds/statsd/src/anomaly/subscriber_util.cpp @@ -17,10 +17,6 @@ #define DEBUG false // STOPSHIP if true #include "Log.h" -#include <android/os/IIncidentManager.h> -#include <android/os/IncidentReportArgs.h> -#include <binder/IServiceManager.h> - #include "external/Perfetto.h" #include "subscriber/IncidentdReporter.h" #include "subscriber/SubscriberReporter.h" diff --git a/cmds/statsd/src/condition/CombinationConditionTracker.cpp b/cmds/statsd/src/condition/CombinationConditionTracker.cpp index 69aae3d1e31c..2d7f912dac84 100644 --- a/cmds/statsd/src/condition/CombinationConditionTracker.cpp +++ b/cmds/statsd/src/condition/CombinationConditionTracker.cpp @@ -18,15 +18,10 @@ #include "Log.h" #include "CombinationConditionTracker.h" -#include <log/logprint.h> - namespace android { namespace os { namespace statsd { -using std::map; -using std::string; -using std::unique_ptr; using std::unordered_map; using std::vector; diff --git a/cmds/statsd/src/condition/ConditionTracker.h b/cmds/statsd/src/condition/ConditionTracker.h index e94ea6586f05..26de88860ab4 100644 --- a/cmds/statsd/src/condition/ConditionTracker.h +++ b/cmds/statsd/src/condition/ConditionTracker.h @@ -21,10 +21,8 @@ #include "matchers/LogMatchingTracker.h" #include "matchers/matcher_util.h" -#include <log/logprint.h> #include <utils/RefBase.h> -#include <unordered_set> #include <unordered_map> namespace android { diff --git a/cmds/statsd/src/condition/ConditionWizard.cpp b/cmds/statsd/src/condition/ConditionWizard.cpp index 4f44a69ba980..c542032b48ea 100644 --- a/cmds/statsd/src/condition/ConditionWizard.cpp +++ b/cmds/statsd/src/condition/ConditionWizard.cpp @@ -14,14 +14,11 @@ * limitations under the License. */ #include "ConditionWizard.h" -#include <unordered_set> namespace android { namespace os { namespace statsd { -using std::map; -using std::string; using std::vector; ConditionState ConditionWizard::query(const int index, const ConditionKey& parameters, diff --git a/cmds/statsd/src/condition/SimpleConditionTracker.cpp b/cmds/statsd/src/condition/SimpleConditionTracker.cpp index 0c92149f4c96..61760f3e29b2 100644 --- a/cmds/statsd/src/condition/SimpleConditionTracker.cpp +++ b/cmds/statsd/src/condition/SimpleConditionTracker.cpp @@ -24,11 +24,7 @@ namespace android { namespace os { namespace statsd { -using std::map; -using std::string; -using std::unique_ptr; using std::unordered_map; -using std::vector; SimpleConditionTracker::SimpleConditionTracker( const ConfigKey& key, const int64_t& id, const int index, diff --git a/cmds/statsd/src/condition/StateConditionTracker.cpp b/cmds/statsd/src/condition/StateConditionTracker.cpp index 7f3eeddba831..d19a1761ac00 100644 --- a/cmds/statsd/src/condition/StateConditionTracker.cpp +++ b/cmds/statsd/src/condition/StateConditionTracker.cpp @@ -23,8 +23,6 @@ namespace android { namespace os { namespace statsd { -using std::string; -using std::unordered_set; using std::vector; StateConditionTracker::StateConditionTracker(const ConfigKey& key, const int64_t& id, const int index, diff --git a/cmds/statsd/src/condition/condition_util.cpp b/cmds/statsd/src/condition/condition_util.cpp index 35e03e45c785..60b8c53e91e1 100644 --- a/cmds/statsd/src/condition/condition_util.cpp +++ b/cmds/statsd/src/condition/condition_util.cpp @@ -18,11 +18,6 @@ #include "condition_util.h" -#include <log/event_tag_map.h> -#include <log/log_event_list.h> -#include <log/logprint.h> -#include <utils/Errors.h> -#include <unordered_map> #include "../matchers/matcher_util.h" #include "ConditionTracker.h" #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" @@ -32,9 +27,6 @@ namespace android { namespace os { namespace statsd { -using std::set; -using std::string; -using std::unordered_map; using std::vector; diff --git a/cmds/statsd/src/config/ConfigListener.h b/cmds/statsd/src/config/ConfigListener.h index 54e77701b7dc..dcd5e52feefd 100644 --- a/cmds/statsd/src/config/ConfigListener.h +++ b/cmds/statsd/src/config/ConfigListener.h @@ -19,14 +19,12 @@ #include "config/ConfigKey.h" #include <utils/RefBase.h> -#include <string> namespace android { namespace os { namespace statsd { using android::RefBase; -using std::string; /** * Callback for different subsystems inside statsd to implement to find out diff --git a/cmds/statsd/src/config/ConfigManager.cpp b/cmds/statsd/src/config/ConfigManager.cpp index 972adf7d4d05..986955bc5f39 100644 --- a/cmds/statsd/src/config/ConfigManager.cpp +++ b/cmds/statsd/src/config/ConfigManager.cpp @@ -25,8 +25,6 @@ #include "stats_util.h" #include "stats_log_util.h" -#include <android-base/file.h> -#include <dirent.h> #include <stdio.h> #include <vector> #include "android-base/stringprintf.h" @@ -35,9 +33,7 @@ namespace android { namespace os { namespace statsd { -using std::map; using std::pair; -using std::set; using std::string; using std::vector; diff --git a/cmds/statsd/src/config/ConfigManager.h b/cmds/statsd/src/config/ConfigManager.h index 88e864a2520b..2095173e8959 100644 --- a/cmds/statsd/src/config/ConfigManager.h +++ b/cmds/statsd/src/config/ConfigManager.h @@ -20,9 +20,7 @@ #include "config/ConfigListener.h" #include <android/os/IPendingIntentRef.h> -#include <map> #include <mutex> -#include <set> #include <string> #include <stdio.h> diff --git a/cmds/statsd/src/external/Perfetto.cpp b/cmds/statsd/src/external/Perfetto.cpp index 0c4c3301e61e..85b660efc956 100644 --- a/cmds/statsd/src/external/Perfetto.cpp +++ b/cmds/statsd/src/external/Perfetto.cpp @@ -21,12 +21,8 @@ #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" // Alert #include <android-base/unique_fd.h> -#include <errno.h> -#include <fcntl.h> #include <inttypes.h> -#include <sys/types.h> #include <sys/wait.h> -#include <unistd.h> #include <string> diff --git a/cmds/statsd/src/external/PullDataReceiver.h b/cmds/statsd/src/external/PullDataReceiver.h index d2193f41b80a..dd5c0cfa04c1 100644 --- a/cmds/statsd/src/external/PullDataReceiver.h +++ b/cmds/statsd/src/external/PullDataReceiver.h @@ -15,8 +15,6 @@ */ #pragma once -#include <utils/String16.h> -#include <unordered_map> #include <utils/RefBase.h> #include "StatsPuller.h" #include "logd/LogEvent.h" diff --git a/cmds/statsd/src/external/StatsCallbackPuller.h b/cmds/statsd/src/external/StatsCallbackPuller.h index ac88524a72ee..fe6af19e3901 100644 --- a/cmds/statsd/src/external/StatsCallbackPuller.h +++ b/cmds/statsd/src/external/StatsCallbackPuller.h @@ -17,7 +17,6 @@ #pragma once #include <android/os/IPullAtomCallback.h> -#include <utils/String16.h> #include "StatsPuller.h" diff --git a/cmds/statsd/src/external/StatsPullerManager.cpp b/cmds/statsd/src/external/StatsPullerManager.cpp index fef213dad60e..988a53f5d028 100644 --- a/cmds/statsd/src/external/StatsPullerManager.cpp +++ b/cmds/statsd/src/external/StatsPullerManager.cpp @@ -37,12 +37,8 @@ #include "TrainInfoPuller.h" #include "statslog.h" -using std::make_shared; -using std::map; using std::shared_ptr; -using std::string; using std::vector; -using std::list; namespace android { namespace os { diff --git a/cmds/statsd/src/external/StatsPullerManager.h b/cmds/statsd/src/external/StatsPullerManager.h index f5d6057c2aec..aef16dcf2147 100644 --- a/cmds/statsd/src/external/StatsPullerManager.h +++ b/cmds/statsd/src/external/StatsPullerManager.h @@ -23,8 +23,6 @@ #include <utils/threads.h> #include <list> -#include <string> -#include <unordered_map> #include <vector> #include "PullDataReceiver.h" diff --git a/cmds/statsd/src/guardrail/StatsdStats.cpp b/cmds/statsd/src/guardrail/StatsdStats.cpp index a836bd14c012..3054b6d2204b 100644 --- a/cmds/statsd/src/guardrail/StatsdStats.cpp +++ b/cmds/statsd/src/guardrail/StatsdStats.cpp @@ -36,7 +36,6 @@ using android::util::FIELD_TYPE_MESSAGE; using android::util::FIELD_TYPE_STRING; using android::util::ProtoOutputStream; using std::lock_guard; -using std::map; using std::shared_ptr; using std::string; using std::vector; diff --git a/cmds/statsd/src/logd/LogEvent.h b/cmds/statsd/src/logd/LogEvent.h index 583dae2f1b21..3db26765326d 100644 --- a/cmds/statsd/src/logd/LogEvent.h +++ b/cmds/statsd/src/logd/LogEvent.h @@ -20,11 +20,9 @@ #include <android/frameworks/stats/1.0/types.h> #include <android/util/ProtoOutputStream.h> -#include <log/log_read.h> #include <private/android_logger.h> #include <stats_event_list.h> #include <stats_event.h> -#include <utils/Errors.h> #include <string> #include <vector> diff --git a/cmds/statsd/src/logd/LogEventQueue.h b/cmds/statsd/src/logd/LogEventQueue.h index b4fd63f119e6..9dda3d24c571 100644 --- a/cmds/statsd/src/logd/LogEventQueue.h +++ b/cmds/statsd/src/logd/LogEventQueue.h @@ -19,10 +19,8 @@ #include "LogEvent.h" #include <condition_variable> -#include <memory> #include <mutex> #include <queue> -#include <thread> namespace android { namespace os { diff --git a/cmds/statsd/src/main.cpp b/cmds/statsd/src/main.cpp index 7d446a9a1ed6..58bfeb337da4 100644 --- a/cmds/statsd/src/main.cpp +++ b/cmds/statsd/src/main.cpp @@ -20,16 +20,11 @@ #include "StatsService.h" #include "socket/StatsSocketListener.h" -#include <binder/IInterface.h> #include <binder/IPCThreadState.h> #include <binder/IServiceManager.h> #include <binder/ProcessState.h> -#include <binder/Status.h> #include <hidl/HidlTransportSupport.h> #include <utils/Looper.h> -#include <utils/StrongPointer.h> - -#include <memory> #include <stdio.h> #include <sys/stat.h> diff --git a/cmds/statsd/src/matchers/CombinationLogMatchingTracker.cpp b/cmds/statsd/src/matchers/CombinationLogMatchingTracker.cpp index 15c067ee936d..b94a9572113e 100644 --- a/cmds/statsd/src/matchers/CombinationLogMatchingTracker.cpp +++ b/cmds/statsd/src/matchers/CombinationLogMatchingTracker.cpp @@ -24,8 +24,6 @@ namespace os { namespace statsd { using std::set; -using std::string; -using std::unique_ptr; using std::unordered_map; using std::vector; diff --git a/cmds/statsd/src/matchers/CombinationLogMatchingTracker.h b/cmds/statsd/src/matchers/CombinationLogMatchingTracker.h index 2a3f08da7b96..55bc46059fc1 100644 --- a/cmds/statsd/src/matchers/CombinationLogMatchingTracker.h +++ b/cmds/statsd/src/matchers/CombinationLogMatchingTracker.h @@ -16,9 +16,6 @@ #ifndef COMBINATION_LOG_MATCHING_TRACKER_H #define COMBINATION_LOG_MATCHING_TRACKER_H -#include <log/log_read.h> -#include <log/logprint.h> -#include <set> #include <unordered_map> #include <vector> #include "LogMatchingTracker.h" diff --git a/cmds/statsd/src/matchers/EventMatcherWizard.cpp b/cmds/statsd/src/matchers/EventMatcherWizard.cpp index 8418e9833509..025c9a87b16b 100644 --- a/cmds/statsd/src/matchers/EventMatcherWizard.cpp +++ b/cmds/statsd/src/matchers/EventMatcherWizard.cpp @@ -14,14 +14,11 @@ * limitations under the License. */ #include "EventMatcherWizard.h" -#include <unordered_set> namespace android { namespace os { namespace statsd { -using std::map; -using std::string; using std::vector; MatchingState EventMatcherWizard::matchLogEvent(const LogEvent& event, int matcher_index) { diff --git a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp index 31b3db524e80..082daf5a1916 100644 --- a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp +++ b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp @@ -23,8 +23,6 @@ namespace android { namespace os { namespace statsd { -using std::string; -using std::unique_ptr; using std::unordered_map; using std::vector; diff --git a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.h b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.h index 28b339caa466..a0f6a888bd44 100644 --- a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.h +++ b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.h @@ -17,9 +17,6 @@ #ifndef SIMPLE_LOG_MATCHING_TRACKER_H #define SIMPLE_LOG_MATCHING_TRACKER_H -#include <log/log_read.h> -#include <log/logprint.h> -#include <set> #include <unordered_map> #include <vector> #include "LogMatchingTracker.h" diff --git a/cmds/statsd/src/matchers/matcher_util.cpp b/cmds/statsd/src/matchers/matcher_util.cpp index 476fae37899d..1f8bbd7f528c 100644 --- a/cmds/statsd/src/matchers/matcher_util.cpp +++ b/cmds/statsd/src/matchers/matcher_util.cpp @@ -23,7 +23,6 @@ using std::set; using std::string; -using std::unordered_map; using std::vector; namespace android { diff --git a/cmds/statsd/src/matchers/matcher_util.h b/cmds/statsd/src/matchers/matcher_util.h index 15b4a9799a93..1ab3e87b5fed 100644 --- a/cmds/statsd/src/matchers/matcher_util.h +++ b/cmds/statsd/src/matchers/matcher_util.h @@ -18,11 +18,6 @@ #include "logd/LogEvent.h" -#include <log/log_read.h> -#include <log/logprint.h> -#include <set> -#include <string> -#include <unordered_map> #include <vector> #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" #include "packages/UidMap.h" diff --git a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp index 4ab6fd48f1db..83983e80d479 100644 --- a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp +++ b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp @@ -21,8 +21,6 @@ #include "GaugeMetricProducer.h" #include "../stats_log_util.h" -#include <cutils/log.h> - using android::util::FIELD_COUNT_REPEATED; using android::util::FIELD_TYPE_BOOL; using android::util::FIELD_TYPE_FLOAT; diff --git a/cmds/statsd/src/metrics/MetricProducer.cpp b/cmds/statsd/src/metrics/MetricProducer.cpp index 5c29cb3c27fe..be754e29b5bd 100644 --- a/cmds/statsd/src/metrics/MetricProducer.cpp +++ b/cmds/statsd/src/metrics/MetricProducer.cpp @@ -33,7 +33,6 @@ namespace android { namespace os { namespace statsd { -using std::map; // for ActiveMetric const int FIELD_ID_ACTIVE_METRIC_ID = 1; diff --git a/cmds/statsd/src/metrics/MetricProducer.h b/cmds/statsd/src/metrics/MetricProducer.h index 99f0c64bd47c..d721514ed1f0 100644 --- a/cmds/statsd/src/metrics/MetricProducer.h +++ b/cmds/statsd/src/metrics/MetricProducer.h @@ -18,7 +18,6 @@ #define METRIC_PRODUCER_H #include <frameworks/base/cmds/statsd/src/active_config_list.pb.h> -#include <log/logprint.h> #include <utils/RefBase.h> #include <unordered_map> diff --git a/cmds/statsd/src/metrics/MetricsManager.cpp b/cmds/statsd/src/metrics/MetricsManager.cpp index 088f607ecfce..536700f3bfe7 100644 --- a/cmds/statsd/src/metrics/MetricsManager.cpp +++ b/cmds/statsd/src/metrics/MetricsManager.cpp @@ -18,9 +18,7 @@ #include "MetricsManager.h" -#include <log/logprint.h> #include <private/android_filesystem_config.h> -#include <utils/SystemClock.h> #include "CountMetricProducer.h" #include "atoms_info.h" @@ -42,10 +40,8 @@ using android::util::FIELD_TYPE_MESSAGE; using android::util::FIELD_TYPE_STRING; using android::util::ProtoOutputStream; -using std::make_unique; using std::set; using std::string; -using std::unordered_map; using std::vector; namespace android { diff --git a/cmds/statsd/src/metrics/ValueMetricProducer.cpp b/cmds/statsd/src/metrics/ValueMetricProducer.cpp index d2db6e9c9ead..2a5b5302b619 100644 --- a/cmds/statsd/src/metrics/ValueMetricProducer.cpp +++ b/cmds/statsd/src/metrics/ValueMetricProducer.cpp @@ -21,7 +21,6 @@ #include "../guardrail/StatsdStats.h" #include "../stats_log_util.h" -#include <cutils/log.h> #include <limits.h> #include <stdlib.h> @@ -33,12 +32,8 @@ using android::util::FIELD_TYPE_INT64; using android::util::FIELD_TYPE_MESSAGE; using android::util::FIELD_TYPE_STRING; using android::util::ProtoOutputStream; -using std::list; -using std::make_pair; -using std::make_shared; using std::map; using std::shared_ptr; -using std::unique_ptr; using std::unordered_map; namespace android { diff --git a/cmds/statsd/src/metrics/ValueMetricProducer.h b/cmds/statsd/src/metrics/ValueMetricProducer.h index 19fb6942928f..50317b341843 100644 --- a/cmds/statsd/src/metrics/ValueMetricProducer.h +++ b/cmds/statsd/src/metrics/ValueMetricProducer.h @@ -17,8 +17,6 @@ #pragma once #include <gtest/gtest_prod.h> -#include <utils/threads.h> -#include <list> #include "anomaly/AnomalyTracker.h" #include "condition/ConditionTimer.h" #include "condition/ConditionTracker.h" diff --git a/cmds/statsd/src/metrics/duration_helper/OringDurationTracker.h b/cmds/statsd/src/metrics/duration_helper/OringDurationTracker.h index c3aad668aa78..f44e3275b83d 100644 --- a/cmds/statsd/src/metrics/duration_helper/OringDurationTracker.h +++ b/cmds/statsd/src/metrics/duration_helper/OringDurationTracker.h @@ -19,7 +19,6 @@ #include "DurationTracker.h" -#include <set> namespace android { namespace os { namespace statsd { diff --git a/cmds/statsd/src/metrics/metrics_manager_util.cpp b/cmds/statsd/src/metrics/metrics_manager_util.cpp index 17f62b056426..40a313a14eab 100644 --- a/cmds/statsd/src/metrics/metrics_manager_util.cpp +++ b/cmds/statsd/src/metrics/metrics_manager_util.cpp @@ -40,7 +40,6 @@ #include "stats_util.h" using std::set; -using std::string; using std::unordered_map; using std::vector; diff --git a/cmds/statsd/src/metrics/metrics_manager_util.h b/cmds/statsd/src/metrics/metrics_manager_util.h index 95b2ab81fa53..5ebb232694a4 100644 --- a/cmds/statsd/src/metrics/metrics_manager_util.h +++ b/cmds/statsd/src/metrics/metrics_manager_util.h @@ -16,7 +16,6 @@ #pragma once -#include <memory> #include <set> #include <unordered_map> #include <vector> diff --git a/cmds/statsd/src/packages/PackageInfoListener.h b/cmds/statsd/src/packages/PackageInfoListener.h index fcdbe69dbbd1..6c50a8c41770 100644 --- a/cmds/statsd/src/packages/PackageInfoListener.h +++ b/cmds/statsd/src/packages/PackageInfoListener.h @@ -17,7 +17,6 @@ #ifndef STATSD_PACKAGE_INFO_LISTENER_H #define STATSD_PACKAGE_INFO_LISTENER_H -#include <utils/RefBase.h> #include <string> namespace android { diff --git a/cmds/statsd/src/packages/UidMap.cpp b/cmds/statsd/src/packages/UidMap.cpp index 7e63bbff2d0a..ab0e86e24b02 100644 --- a/cmds/statsd/src/packages/UidMap.cpp +++ b/cmds/statsd/src/packages/UidMap.cpp @@ -21,10 +21,6 @@ #include "guardrail/StatsdStats.h" #include "packages/UidMap.h" -#include <android/os/IStatsCompanionService.h> -#include <binder/IServiceManager.h> -#include <utils/Errors.h> - #include <inttypes.h> using namespace android; diff --git a/cmds/statsd/src/packages/UidMap.h b/cmds/statsd/src/packages/UidMap.h index 2d3f6ee9c2e8..bfac6e3431b0 100644 --- a/cmds/statsd/src/packages/UidMap.h +++ b/cmds/statsd/src/packages/UidMap.h @@ -21,10 +21,8 @@ #include "packages/PackageInfoListener.h" #include "stats_util.h" -#include <binder/IResultReceiver.h> #include <binder/IShellCallback.h> #include <gtest/gtest_prod.h> -#include <log/logprint.h> #include <stdio.h> #include <utils/RefBase.h> #include <list> diff --git a/cmds/statsd/src/shell/ShellSubscriber.cpp b/cmds/statsd/src/shell/ShellSubscriber.cpp index f7e32d4aed26..d6a04336bc46 100644 --- a/cmds/statsd/src/shell/ShellSubscriber.cpp +++ b/cmds/statsd/src/shell/ShellSubscriber.cpp @@ -18,7 +18,6 @@ #include "ShellSubscriber.h" -#include <android-base/file.h> #include "matchers/matcher_util.h" #include "stats_log_util.h" diff --git a/cmds/statsd/src/shell/ShellSubscriber.h b/cmds/statsd/src/shell/ShellSubscriber.h index 8e54a8b00091..86d85901083a 100644 --- a/cmds/statsd/src/shell/ShellSubscriber.h +++ b/cmds/statsd/src/shell/ShellSubscriber.h @@ -22,7 +22,6 @@ #include <binder/IResultReceiver.h> #include <condition_variable> #include <mutex> -#include <string> #include <thread> #include "external/StatsPullerManager.h" #include "frameworks/base/cmds/statsd/src/shell/shell_config.pb.h" diff --git a/cmds/statsd/src/socket/StatsSocketListener.cpp b/cmds/statsd/src/socket/StatsSocketListener.cpp index cdb4d3a10f27..8f0f480cb862 100755 --- a/cmds/statsd/src/socket/StatsSocketListener.cpp +++ b/cmds/statsd/src/socket/StatsSocketListener.cpp @@ -27,9 +27,6 @@ #include <unistd.h> #include <cutils/sockets.h> -#include <private/android_filesystem_config.h> -#include <private/android_logger.h> -#include <unordered_map> #include "StatsSocketListener.h" #include "guardrail/StatsdStats.h" diff --git a/cmds/statsd/src/state/StateManager.h b/cmds/statsd/src/state/StateManager.h index 8bc24612be90..8b3a4218238c 100644 --- a/cmds/statsd/src/state/StateManager.h +++ b/cmds/statsd/src/state/StateManager.h @@ -15,7 +15,6 @@ */ #pragma once -#include <gtest/gtest_prod.h> #include <inttypes.h> #include <utils/RefBase.h> diff --git a/cmds/statsd/src/stats_log_util.cpp b/cmds/statsd/src/stats_log_util.cpp index 76c193679eef..8e0c62869932 100644 --- a/cmds/statsd/src/stats_log_util.cpp +++ b/cmds/statsd/src/stats_log_util.cpp @@ -17,12 +17,8 @@ #include "hash.h" #include "stats_log_util.h" -#include <logd/LogEvent.h> #include <private/android_filesystem_config.h> -#include <utils/Log.h> #include <set> -#include <stack> -#include <utils/Log.h> #include <utils/SystemClock.h> using android::util::AtomsInfo; diff --git a/cmds/statsd/src/statscompanion_util.h b/cmds/statsd/src/statscompanion_util.h index ff702f23f6d1..dc4f28361214 100644 --- a/cmds/statsd/src/statscompanion_util.h +++ b/cmds/statsd/src/statscompanion_util.h @@ -18,12 +18,6 @@ #include "StatsLogProcessor.h" -using namespace android; -using namespace android::base; -using namespace android::binder; -using namespace android::os; -using namespace std; - namespace android { namespace os { namespace statsd { diff --git a/cmds/statsd/src/storage/StorageManager.cpp b/cmds/statsd/src/storage/StorageManager.cpp index 9b48a02c7f78..507297c6c401 100644 --- a/cmds/statsd/src/storage/StorageManager.cpp +++ b/cmds/statsd/src/storage/StorageManager.cpp @@ -23,10 +23,8 @@ #include "stats_log_util.h" #include <android-base/file.h> -#include <dirent.h> #include <private/android_filesystem_config.h> #include <fstream> -#include <iostream> namespace android { namespace os { diff --git a/cmds/statsd/src/subscriber/IncidentdReporter.cpp b/cmds/statsd/src/subscriber/IncidentdReporter.cpp index f1320c2f746d..d86e29131661 100644 --- a/cmds/statsd/src/subscriber/IncidentdReporter.cpp +++ b/cmds/statsd/src/subscriber/IncidentdReporter.cpp @@ -24,7 +24,6 @@ #include <android/os/IIncidentManager.h> #include <android/os/IncidentReportArgs.h> #include <android/util/ProtoOutputStream.h> -#include <binder/IBinder.h> #include <binder/IServiceManager.h> #include <vector> diff --git a/cmds/statsd/src/subscriber/SubscriberReporter.cpp b/cmds/statsd/src/subscriber/SubscriberReporter.cpp index a37cad14fcbc..160b57e27c6c 100644 --- a/cmds/statsd/src/subscriber/SubscriberReporter.cpp +++ b/cmds/statsd/src/subscriber/SubscriberReporter.cpp @@ -20,7 +20,6 @@ #include "SubscriberReporter.h" using std::lock_guard; -using std::unordered_map; namespace android { namespace os { diff --git a/core/java/android/app/NotificationChannel.java b/core/java/android/app/NotificationChannel.java index 5a4622e0b245..4b24e098b3c6 100644 --- a/core/java/android/app/NotificationChannel.java +++ b/core/java/android/app/NotificationChannel.java @@ -15,8 +15,6 @@ */ package android.app; -import static android.annotation.SystemApi.Client.MODULE_APPS; - import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.TestApi; @@ -362,7 +360,7 @@ public final class NotificationChannel implements Parcelable { * @param blockableSystem if {@code true}, allows users to block notifications on this channel. * @hide */ - @SystemApi(client = MODULE_APPS) + @SystemApi @TestApi public void setBlockableSystem(boolean blockableSystem) { mBlockableSystem = blockableSystem; diff --git a/core/java/android/app/timedetector/ManualTimeSuggestion.java b/core/java/android/app/timedetector/ManualTimeSuggestion.java index 50de73855511..da51ce2a6aff 100644 --- a/core/java/android/app/timedetector/ManualTimeSuggestion.java +++ b/core/java/android/app/timedetector/ManualTimeSuggestion.java @@ -29,10 +29,18 @@ import java.util.List; import java.util.Objects; /** - * A time signal from a manual (user provided) source. The value consists of the number of - * milliseconds elapsed since 1/1/1970 00:00:00 UTC and the time according to the elapsed realtime - * clock when that number was established. The elapsed realtime clock is considered accurate but - * volatile, so time signals must not be persisted across device resets. + * A time signal from a manual (user provided) source. + * + * <p>{@code utcTime} is the suggested time. The {@code utcTime.value} is the number of milliseconds + * elapsed since 1/1/1970 00:00:00 UTC. The {@code utcTime.referenceTimeMillis} is the value of the + * elapsed realtime clock when the {@code utcTime.value} was established. + * Note that the elapsed realtime clock is considered accurate but it is volatile, so time + * suggestions cannot be persisted across device resets. + * + * <p>{@code debugInfo} contains debugging metadata associated with the suggestion. This is used to + * record why the suggestion exists and how it was entered. This information exists only to aid in + * debugging and therefore is used by {@link #toString()}, but it is not for use in detection + * logic and is not considered in {@link #hashCode()} or {@link #equals(Object)}. * * @hide */ @@ -49,10 +57,8 @@ public final class ManualTimeSuggestion implements Parcelable { } }; - @NonNull - private final TimestampedValue<Long> mUtcTime; - @Nullable - private ArrayList<String> mDebugInfo; + @NonNull private final TimestampedValue<Long> mUtcTime; + @Nullable private ArrayList<String> mDebugInfo; public ManualTimeSuggestion(@NonNull TimestampedValue<Long> utcTime) { mUtcTime = Objects.requireNonNull(utcTime); diff --git a/core/java/android/app/timedetector/NetworkTimeSuggestion.java b/core/java/android/app/timedetector/NetworkTimeSuggestion.java index 17e9c5a79fa5..89fd6f31e042 100644 --- a/core/java/android/app/timedetector/NetworkTimeSuggestion.java +++ b/core/java/android/app/timedetector/NetworkTimeSuggestion.java @@ -29,10 +29,18 @@ import java.util.List; import java.util.Objects; /** - * A time signal from a network time source like NTP. The value consists of the number of - * milliseconds elapsed since 1/1/1970 00:00:00 UTC and the time according to the elapsed realtime - * clock when that number was established. The elapsed realtime clock is considered accurate but - * volatile, so time signals must not be persisted across device resets. + * A time signal from a network time source like NTP. + * + * <p>{@code utcTime} contains the suggested time. The {@code utcTime.value} is the number of + * milliseconds elapsed since 1/1/1970 00:00:00 UTC. The {@code utcTime.referenceTimeMillis} is the + * value of the elapsed realtime clock when the {@code utcTime.value} was established. + * Note that the elapsed realtime clock is considered accurate but it is volatile, so time + * suggestions cannot be persisted across device resets. + * + * <p>{@code debugInfo} contains debugging metadata associated with the suggestion. This is used to + * record why the suggestion exists and how it was determined. This information exists only to aid + * in debugging and therefore is used by {@link #toString()}, but it is not for use in detection + * logic and is not considered in {@link #hashCode()} or {@link #equals(Object)}. * * @hide */ @@ -49,10 +57,8 @@ public final class NetworkTimeSuggestion implements Parcelable { } }; - @NonNull - private final TimestampedValue<Long> mUtcTime; - @Nullable - private ArrayList<String> mDebugInfo; + @NonNull private final TimestampedValue<Long> mUtcTime; + @Nullable private ArrayList<String> mDebugInfo; public NetworkTimeSuggestion(@NonNull TimestampedValue<Long> utcTime) { mUtcTime = Objects.requireNonNull(utcTime); diff --git a/core/java/android/app/timedetector/PhoneTimeSuggestion.java b/core/java/android/app/timedetector/PhoneTimeSuggestion.java index eab88383fa1d..16288e82d452 100644 --- a/core/java/android/app/timedetector/PhoneTimeSuggestion.java +++ b/core/java/android/app/timedetector/PhoneTimeSuggestion.java @@ -32,12 +32,22 @@ import java.util.Objects; * A time suggestion from an identified telephony source. e.g. from NITZ information from a specific * radio. * - * <p>The time value can be {@code null} to indicate that the telephony source has entered an - * "un-opinionated" state and any previous suggestions from the source are being withdrawn. When not - * {@code null}, the value consists of the number of milliseconds elapsed since 1/1/1970 00:00:00 - * UTC and the time according to the elapsed realtime clock when that number was established. The - * elapsed realtime clock is considered accurate but volatile, so time suggestions must not be - * persisted across device resets. + * <p>{@code slotIndex} identifies the suggestion source. This enables detection logic to identify + * suggestions from the same source when there are several in use. + * + * <p>{@code utcTime}. When not {@code null}, the {@code utcTime.value} is the number of + * milliseconds elapsed since 1/1/1970 00:00:00 UTC. The {@code utcTime.referenceTimeMillis} is the + * value of the elapsed realtime clock when the {@code utcTime.value} was established. + * Note that the elapsed realtime clock is considered accurate but it is volatile, so time + * suggestions cannot be persisted across device resets. {@code utcTime} can be {@code null} to + * indicate that the telephony source has entered an "un-opinionated" state and any previous + * suggestion from the source is being withdrawn. + * + * <p>{@code debugInfo} contains debugging metadata associated with the suggestion. This is used to + * record why the suggestion exists, e.g. what triggered it to be made and what heuristic was used + * to determine the time or its absence. This information exists only to aid in debugging and + * therefore is used by {@link #toString()}, but it is not for use in detection logic and is not + * considered in {@link #hashCode()} or {@link #equals(Object)}. * * @hide */ @@ -93,16 +103,18 @@ public final class PhoneTimeSuggestion implements Parcelable { } /** - * Returns an identifier for the source of this suggestion. When a device has several sim slots - * or equivalent, it is used to identify which one the suggestion is from. + * Returns an identifier for the source of this suggestion. + * + * <p>See {@link PhoneTimeSuggestion} for more information about {@code slotIndex}. */ public int getSlotIndex() { return mSlotIndex; } /** - * Returns the suggestion. {@code null} means that the caller is no longer sure what time it - * is. + * Returns the suggested time or {@code null} if there isn't one. + * + * <p>See {@link PhoneTimeSuggestion} for more information about {@code utcTime}. */ @Nullable public TimestampedValue<Long> getUtcTime() { @@ -110,8 +122,9 @@ public final class PhoneTimeSuggestion implements Parcelable { } /** - * Returns debug metadata for the suggestion. The information is present in {@link #toString()} - * but is not considered for {@link #equals(Object)} and {@link #hashCode()}. + * Returns debug metadata for the suggestion. + * + * <p>See {@link PhoneTimeSuggestion} for more information about {@code debugInfo}. */ @NonNull public List<String> getDebugInfo() { @@ -120,9 +133,9 @@ public final class PhoneTimeSuggestion implements Parcelable { } /** - * Associates information with the instance that can be useful for debugging / logging. The - * information is present in {@link #toString()} but is not considered for - * {@link #equals(Object)} and {@link #hashCode()}. + * Associates information with the instance that can be useful for debugging / logging. + * + * <p>See {@link PhoneTimeSuggestion} for more information about {@code debugInfo}. */ public void addDebugInfo(@NonNull String debugInfo) { if (mDebugInfo == null) { @@ -132,9 +145,9 @@ public final class PhoneTimeSuggestion implements Parcelable { } /** - * Associates information with the instance that can be useful for debugging / logging. The - * information is present in {@link #toString()} but is not considered for - * {@link #equals(Object)} and {@link #hashCode()}. + * Associates information with the instance that can be useful for debugging / logging. + * + * <p>See {@link PhoneTimeSuggestion} for more information about {@code debugInfo}. */ public void addDebugInfo(@NonNull List<String> debugInfo) { if (mDebugInfo == null) { @@ -181,12 +194,20 @@ public final class PhoneTimeSuggestion implements Parcelable { @Nullable private TimestampedValue<Long> mUtcTime; @Nullable private List<String> mDebugInfo; - /** Creates a builder with the specified {@code slotIndex}. */ + /** + * Creates a builder with the specified {@code slotIndex}. + * + * <p>See {@link PhoneTimeSuggestion} for more information about {@code slotIndex}. + */ public Builder(int slotIndex) { mSlotIndex = slotIndex; } - /** Returns the builder for call chaining. */ + /** + * Returns the builder for call chaining. + * + * <p>See {@link PhoneTimeSuggestion} for more information about {@code utcTime}. + */ @NonNull public Builder setUtcTime(@Nullable TimestampedValue<Long> utcTime) { if (utcTime != null) { @@ -198,7 +219,11 @@ public final class PhoneTimeSuggestion implements Parcelable { return this; } - /** Returns the builder for call chaining. */ + /** + * Returns the builder for call chaining. + * + * <p>See {@link PhoneTimeSuggestion} for more information about {@code debugInfo}. + */ @NonNull public Builder addDebugInfo(@NonNull String debugInfo) { if (mDebugInfo == null) { diff --git a/core/java/android/app/timezonedetector/ManualTimeZoneSuggestion.java b/core/java/android/app/timezonedetector/ManualTimeZoneSuggestion.java index a6b953b42f8f..3a9adc72aab1 100644 --- a/core/java/android/app/timezonedetector/ManualTimeZoneSuggestion.java +++ b/core/java/android/app/timezonedetector/ManualTimeZoneSuggestion.java @@ -28,10 +28,14 @@ import java.util.List; import java.util.Objects; /** - * A time signal from a manual (user provided) source. The value consists of the number of - * milliseconds elapsed since 1/1/1970 00:00:00 UTC and the time according to the elapsed realtime - * clock when that number was established. The elapsed realtime clock is considered accurate but - * volatile, so time signals must not be persisted across device resets. + * A time signal from a manual (user provided) source. + * + * <p>{@code zoneId} contains the suggested time zone ID, e.g. "America/Los_Angeles". + * + * <p>{@code debugInfo} contains debugging metadata associated with the suggestion. This is used to + * record why the suggestion exists and how it was entered. This information exists only to aid in + * debugging and therefore is used by {@link #toString()}, but it is not for use in detection logic + * and is not considered in {@link #hashCode()} or {@link #equals(Object)}. * * @hide */ @@ -48,10 +52,8 @@ public final class ManualTimeZoneSuggestion implements Parcelable { } }; - @NonNull - private final String mZoneId; - @Nullable - private ArrayList<String> mDebugInfo; + @NonNull private final String mZoneId; + @Nullable private ArrayList<String> mDebugInfo; public ManualTimeZoneSuggestion(@NonNull String zoneId) { mZoneId = Objects.requireNonNull(zoneId); diff --git a/core/java/android/app/timezonedetector/PhoneTimeZoneSuggestion.java b/core/java/android/app/timezonedetector/PhoneTimeZoneSuggestion.java index ebaf951130ca..0544ccd3f4c5 100644 --- a/core/java/android/app/timezonedetector/PhoneTimeZoneSuggestion.java +++ b/core/java/android/app/timezonedetector/PhoneTimeZoneSuggestion.java @@ -34,10 +34,14 @@ import java.util.Objects; * A time zone suggestion from an identified telephony source, e.g. from MCC and NITZ information * associated with a specific radio. * - * <p>The time zone ID can be {@code null} to indicate that the telephony source has entered an - * "un-opinionated" state and any previous suggestions from that source are being withdrawn. - * When not {@code null}, the value consists of a suggested time zone ID and metadata that can be - * used to judge quality / certainty of the suggestion. + * <p>{@code slotIndex} identifies the suggestion source. This enables detection logic to identify + * suggestions from the same source when there are several in use. + * + * <p>{@code zoneId}. When not {@code null}, {@code zoneId} contains the suggested time zone ID, + * e.g. "America/Los_Angeles". Suggestion metadata like {@code matchType} and {@code quality} can be + * used to judge quality / certainty of the suggestion. {@code zoneId} can be {@code null} to + * indicate that the telephony source has entered an "un-opinionated" state and any previous + * suggestion from the same source is being withdrawn. * * <p>{@code matchType} must be set to {@link #MATCH_TYPE_NA} when {@code zoneId} is {@code null}, * and one of the other {@code MATCH_TYPE_} values when it is not {@code null}. @@ -45,6 +49,12 @@ import java.util.Objects; * <p>{@code quality} must be set to {@link #QUALITY_NA} when {@code zoneId} is {@code null}, * and one of the other {@code QUALITY_} values when it is not {@code null}. * + * <p>{@code debugInfo} contains debugging metadata associated with the suggestion. This is used to + * record why the suggestion exists, e.g. what triggered it to be made and what heuristic was used + * to determine the time zone or its absence. This information exists only to aid in debugging and + * therefore is used by {@link #toString()}, but it is not for use in detection logic and is not + * considered in {@link #hashCode()} or {@link #equals(Object)}. + * * @hide */ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) @@ -131,38 +141,11 @@ public final class PhoneTimeZoneSuggestion implements Parcelable { */ public static final int QUALITY_MULTIPLE_ZONES_WITH_DIFFERENT_OFFSETS = 3; - /** - * The ID of the phone this suggestion is associated with. For multiple-sim devices this - * helps to establish source so filtering / stickiness can be implemented. - */ private final int mSlotIndex; - - /** - * The suggestion. {@code null} means there is no current suggestion and any previous suggestion - * should be forgotten. - */ - @Nullable - private final String mZoneId; - - /** - * The type of "match" used to establish the time zone. - */ - @MatchType - private final int mMatchType; - - /** - * A measure of the quality of the time zone suggestion, i.e. how confident one could be in - * it. - */ - @Quality - private final int mQuality; - - /** - * Free-form debug information about how the suggestion was derived. Used for debug only, - * intentionally not used in equals(), etc. - */ - @Nullable - private List<String> mDebugInfo; + @Nullable private final String mZoneId; + @MatchType private final int mMatchType; + @Quality private final int mQuality; + @Nullable private List<String> mDebugInfo; private PhoneTimeZoneSuggestion(Builder builder) { mSlotIndex = builder.mSlotIndex; @@ -203,8 +186,9 @@ public final class PhoneTimeZoneSuggestion implements Parcelable { } /** - * Returns an identifier for the source of this suggestion. When a device has several sim slots - * or equivalent, it is used to identify which one the suggestion is from. + * Returns an identifier for the source of this suggestion. + * + * <p>See {@link PhoneTimeZoneSuggestion} for more information about {@code slotIndex}. */ public int getSlotIndex() { return mSlotIndex; @@ -212,8 +196,9 @@ public final class PhoneTimeZoneSuggestion implements Parcelable { /** * Returns the suggested time zone Olson ID, e.g. "America/Los_Angeles". {@code null} means that - * the caller is no longer sure what the current time zone is. See - * {@link PhoneTimeZoneSuggestion} for the associated {@code matchType} / {@code quality} rules. + * the caller is no longer sure what the current time zone is. + * + * <p>See {@link PhoneTimeZoneSuggestion} for more information about {@code zoneId}. */ @Nullable public String getZoneId() { @@ -222,8 +207,9 @@ public final class PhoneTimeZoneSuggestion implements Parcelable { /** * Returns information about how the suggestion was determined which could be used to rank - * suggestions when several are available from different sources. See - * {@link PhoneTimeZoneSuggestion} for the associated rules. + * suggestions when several are available from different sources. + * + * <p>See {@link PhoneTimeZoneSuggestion} for more information about {@code matchType}. */ @MatchType public int getMatchType() { @@ -231,8 +217,9 @@ public final class PhoneTimeZoneSuggestion implements Parcelable { } /** - * Returns information about the likelihood of the suggested zone being correct. See - * {@link PhoneTimeZoneSuggestion} for the associated rules. + * Returns information about the likelihood of the suggested zone being correct. + * + * <p>See {@link PhoneTimeZoneSuggestion} for more information about {@code quality}. */ @Quality public int getQuality() { @@ -240,8 +227,9 @@ public final class PhoneTimeZoneSuggestion implements Parcelable { } /** - * Returns debug metadata for the suggestion. The information is present in {@link #toString()} - * but is not considered for {@link #equals(Object)} and {@link #hashCode()}. + * Returns debug metadata for the suggestion. + * + * <p>See {@link PhoneTimeZoneSuggestion} for more information about {@code debugInfo}. */ @NonNull public List<String> getDebugInfo() { @@ -250,9 +238,9 @@ public final class PhoneTimeZoneSuggestion implements Parcelable { } /** - * Associates information with the instance that can be useful for debugging / logging. The - * information is present in {@link #toString()} but is not considered for - * {@link #equals(Object)} and {@link #hashCode()}. + * Associates information with the instance that can be useful for debugging / logging. + * + * <p>See {@link PhoneTimeZoneSuggestion} for more information about {@code debugInfo}. */ public void addDebugInfo(@NonNull String debugInfo) { if (mDebugInfo == null) { @@ -262,9 +250,9 @@ public final class PhoneTimeZoneSuggestion implements Parcelable { } /** - * Associates information with the instance that can be useful for debugging / logging. The - * information is present in {@link #toString()} but is not considered for - * {@link #equals(Object)} and {@link #hashCode()}. + * Associates information with the instance that can be useful for debugging / logging. + * + * <p>See {@link PhoneTimeZoneSuggestion} for more information about {@code debugInfo}. */ public void addDebugInfo(@NonNull List<String> debugInfo) { if (mDebugInfo == null) { @@ -317,12 +305,19 @@ public final class PhoneTimeZoneSuggestion implements Parcelable { @Quality private int mQuality; @Nullable private List<String> mDebugInfo; + /** + * Creates a builder with the specified {@code slotIndex}. + * + * <p>See {@link PhoneTimeZoneSuggestion} for more information about {@code slotIndex}. + */ public Builder(int slotIndex) { mSlotIndex = slotIndex; } /** * Returns the builder for call chaining. + * + * <p>See {@link PhoneTimeZoneSuggestion} for more information about {@code zoneId}. */ @NonNull public Builder setZoneId(@Nullable String zoneId) { @@ -330,21 +325,33 @@ public final class PhoneTimeZoneSuggestion implements Parcelable { return this; } - /** Returns the builder for call chaining. */ + /** + * Returns the builder for call chaining. + * + * <p>See {@link PhoneTimeZoneSuggestion} for more information about {@code matchType}. + */ @NonNull public Builder setMatchType(@MatchType int matchType) { mMatchType = matchType; return this; } - /** Returns the builder for call chaining. */ + /** + * Returns the builder for call chaining. + * + * <p>See {@link PhoneTimeZoneSuggestion} for more information about {@code quality}. + */ @NonNull public Builder setQuality(@Quality int quality) { mQuality = quality; return this; } - /** Returns the builder for call chaining. */ + /** + * Returns the builder for call chaining. + * + * <p>See {@link PhoneTimeZoneSuggestion} for more information about {@code debugInfo}. + */ @NonNull public Builder addDebugInfo(@NonNull String debugInfo) { if (mDebugInfo == null) { diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index da9cc8a47a39..49e1d5e4f213 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -38,6 +38,7 @@ import android.app.Dialog; import android.compat.annotation.UnsupportedAppUsage; import android.content.ComponentName; import android.content.Context; +import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; @@ -451,6 +452,9 @@ public class InputMethodService extends AbstractInputMethodService { @Nullable private InlineSuggestionsRequestInfo mInlineSuggestionsRequestInfo = null; + private boolean mAutomotiveHideNavBarForKeyboard; + private boolean mIsAutomotive; + /** * An opaque {@link Binder} token of window requesting {@link InputMethodImpl#showSoftInput} * The original app window token is passed from client app window. @@ -1230,6 +1234,11 @@ public class InputMethodService extends AbstractInputMethodService { super.onCreate(); mImm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); mSettingsObserver = SettingsObserver.createAndRegister(this); + + mIsAutomotive = isAutomotive(); + mAutomotiveHideNavBarForKeyboard = getApplicationContext().getResources().getBoolean( + com.android.internal.R.bool.config_automotiveHideNavBarForKeyboard); + // TODO(b/111364446) Need to address context lifecycle issue if need to re-create // for update resources & configuration correctly when show soft input // in non-default display. @@ -1239,12 +1248,16 @@ public class InputMethodService extends AbstractInputMethodService { WindowManager.LayoutParams.TYPE_INPUT_METHOD, Gravity.BOTTOM, false); mWindow.getWindow().getAttributes().setFitInsetsTypes(WindowInsets.Type.statusBars()); - // IME layout should always be inset by navigation bar, no matter it's current visibility. + // IME layout should always be inset by navigation bar, no matter its current visibility, + // unless automotive requests it, since automotive may hide the navigation bar. mWindow.getWindow().getDecorView().setOnApplyWindowInsetsListener( (v, insets) -> v.onApplyWindowInsets( new WindowInsets.Builder(insets).setInsets( navigationBars(), - insets.getInsetsIgnoringVisibility(navigationBars())) + mIsAutomotive && mAutomotiveHideNavBarForKeyboard + ? android.graphics.Insets.NONE + : insets.getInsetsIgnoringVisibility(navigationBars()) + ) .build())); // For ColorView in DecorView to work, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS needs to be set @@ -3284,6 +3297,11 @@ public class InputMethodService extends AbstractInputMethodService { : IME_VISIBLE) : 0); } + private boolean isAutomotive() { + return getApplicationContext().getPackageManager().hasSystemFeature( + PackageManager.FEATURE_AUTOMOTIVE); + } + /** * Performs a dump of the InputMethodService's internal state. Override * to add your own information to the dump. diff --git a/core/java/android/inputmethodservice/SoftInputWindow.java b/core/java/android/inputmethodservice/SoftInputWindow.java index 356b3448430a..0513feef801f 100644 --- a/core/java/android/inputmethodservice/SoftInputWindow.java +++ b/core/java/android/inputmethodservice/SoftInputWindow.java @@ -21,7 +21,6 @@ import static java.lang.annotation.RetentionPolicy.SOURCE; import android.annotation.IntDef; import android.app.Dialog; import android.content.Context; -import android.content.pm.PackageManager; import android.graphics.Rect; import android.os.Debug; import android.os.IBinder; @@ -51,7 +50,6 @@ public class SoftInputWindow extends Dialog { final int mWindowType; final int mGravity; final boolean mTakesFocus; - final boolean mAutomotiveHideNavBarForKeyboard; private final Rect mBounds = new Rect(); @Retention(SOURCE) @@ -136,8 +134,6 @@ public class SoftInputWindow extends Dialog { mWindowType = windowType; mGravity = gravity; mTakesFocus = takesFocus; - mAutomotiveHideNavBarForKeyboard = context.getResources().getBoolean( - com.android.internal.R.bool.config_automotiveHideNavBarForKeyboard); initDockWindow(); } @@ -251,11 +247,6 @@ public class SoftInputWindow extends Dialog { windowModFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; } - if (isAutomotive() && mAutomotiveHideNavBarForKeyboard) { - windowSetFlags |= WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; - windowModFlags |= WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; - } - getWindow().setFlags(windowSetFlags, windowModFlags); } @@ -347,10 +338,6 @@ public class SoftInputWindow extends Dialog { mWindowState = newState; } - private boolean isAutomotive() { - return getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE); - } - private static String stateToString(@SoftInputWindowState int state) { switch (state) { case SoftInputWindowState.TOKEN_PENDING: diff --git a/core/java/android/os/incremental/IncrementalFileStorages.java b/core/java/android/os/incremental/IncrementalFileStorages.java index a0bfc1bf56b8..4a668791aeb9 100644 --- a/core/java/android/os/incremental/IncrementalFileStorages.java +++ b/core/java/android/os/incremental/IncrementalFileStorages.java @@ -31,17 +31,10 @@ package android.os.incremental; * @throws IllegalStateException the session is not an Incremental installation session. */ -import static dalvik.system.VMRuntime.getInstructionSet; - import android.annotation.NonNull; import android.annotation.Nullable; import android.content.pm.DataLoaderParams; import android.content.pm.InstallationFile; -import android.os.IVold; -import android.os.Process; -import android.os.RemoteException; -import android.os.ServiceManager; -import android.util.ArraySet; import android.util.Slog; import java.io.File; @@ -58,26 +51,14 @@ import java.util.Random; public final class IncrementalFileStorages { private static final String TAG = "IncrementalFileStorages"; private @Nullable IncrementalStorage mDefaultStorage; - private @Nullable IncrementalStorage mApkStorage; - private @Nullable IncrementalStorage mObbStorage; private @Nullable String mDefaultDir; - private @Nullable String mObbDir; private @NonNull IncrementalManager mIncrementalManager; - private @Nullable ArraySet<String> mLibDirs; - private @NonNull String mPackageName; private @NonNull File mStageDir; /** - * Set up files and directories used in an installation session. - * Currently only used by Incremental Installation. - * For Incremental installation, the expected outcome of this function is: - * 0) All the files are in defaultStorage - * 1) All APK files are in the same directory, bound to mApkStorage, and bound to the - * InstallerSession's stage dir. The files are linked from mApkStorage to defaultStorage. - * 2) All lib files are in the sub directories as their names suggest, and in the same parent - * directory as the APK files. The files are linked from mApkStorage to defaultStorage. - * 3) OBB files are in another directory that is different from APK files and lib files, bound - * to mObbStorage. The files are linked from mObbStorage to defaultStorage. + * Set up files and directories used in an installation session. Only used by Incremental. + * All the files will be created in defaultStorage. + * TODO(b/133435829): code clean up * * @throws IllegalStateException the session is not an Incremental installation session. */ @@ -85,7 +66,6 @@ public final class IncrementalFileStorages { @NonNull File stageDir, @NonNull IncrementalManager incrementalManager, @NonNull DataLoaderParams dataLoaderParams) { - mPackageName = packageName; mStageDir = stageDir; mIncrementalManager = incrementalManager; if (dataLoaderParams.getComponentName().getPackageName().equals("local")) { @@ -114,83 +94,23 @@ public final class IncrementalFileStorages { } if (file.getFileType() == InstallationFile.FILE_TYPE_APK) { addApkFile(file); - } else if (file.getFileType() == InstallationFile.FILE_TYPE_OBB) { - addObbFile(file); - } else if (file.getFileType() == InstallationFile.FILE_TYPE_LIB) { - addLibFile(file); } else { throw new IOException("Unknown file type: " + file.getFileType()); } } private void addApkFile(@NonNull InstallationFile apk) throws IOException { - // Create a storage for APK files and lib files final String stageDirPath = mStageDir.getAbsolutePath(); - if (mApkStorage == null) { - mApkStorage = mIncrementalManager.createStorage(stageDirPath, mDefaultStorage, - IncrementalManager.CREATE_MODE_CREATE - | IncrementalManager.CREATE_MODE_TEMPORARY_BIND); - mApkStorage.bind(stageDirPath); - } - - if (!new File(mDefaultDir, apk.getName()).exists()) { - mDefaultStorage.makeFile(apk.getName(), apk.getSize(), null, + mDefaultStorage.bind(stageDirPath); + String apkName = apk.getName(); + File targetFile = Paths.get(stageDirPath, apkName).toFile(); + if (!targetFile.exists()) { + mDefaultStorage.makeFile(apkName, apk.getSize(), null, apk.getMetadata(), 0, null, null, null); } - // Assuming APK files are already named properly, e.g., "base.apk" - mDefaultStorage.makeLink(apk.getName(), mApkStorage, apk.getName()); - } - - private void addLibFile(@NonNull InstallationFile lib) throws IOException { - // TODO(b/136132412): remove this after we have incfs support for lib file mapping - if (mApkStorage == null) { - throw new IOException("Cannot add lib file without adding an apk file first"); - } - if (mLibDirs == null) { - mLibDirs = new ArraySet<>(); + if (targetFile.exists()) { + Slog.i(TAG, "!!! created: " + targetFile.getAbsolutePath()); } - String current = ""; - final Path libDirPath = Paths.get(lib.getName()).getParent(); - final int numDirComponents = libDirPath.getNameCount(); - for (int i = 0; i < numDirComponents; i++) { - String dirName = libDirPath.getName(i).toString(); - try { - dirName = getInstructionSet(dirName); - } catch (IllegalArgumentException ignored) { - } - current += dirName; - if (!mLibDirs.contains(current)) { - mDefaultStorage.makeDirectory(current); - mApkStorage.makeDirectory(current); - mLibDirs.add(current); - } - current += '/'; - } - String libFilePath = current + Paths.get(lib.getName()).getFileName(); - mDefaultStorage.makeFile(libFilePath, lib.getSize(), null, lib.getMetadata(), 0, null, null, - null); - mDefaultStorage.makeLink(libFilePath, mApkStorage, libFilePath); - } - - private void addObbFile(@NonNull InstallationFile obb) throws IOException { - if (mObbStorage == null) { - // Create a storage for OBB files - mObbDir = getTempDir(); - if (mObbDir == null) { - throw new IOException("Failed to create obb storage directory."); - } - mObbStorage = mIncrementalManager.createStorage( - mObbDir, mDefaultStorage, - IncrementalManager.CREATE_MODE_CREATE - | IncrementalManager.CREATE_MODE_TEMPORARY_BIND); - } - mDefaultStorage.makeFile(obb.getName(), obb.getSize(), null, obb.getMetadata(), 0, null, - null, null); - mDefaultStorage.makeLink(obb.getName(), mObbStorage, obb.getName()); - } - - private boolean hasObb() { - return (mObbStorage != null && mObbDir != null); } /** @@ -208,35 +128,6 @@ public final class IncrementalFileStorages { * Sets up obb storage directory and create bindings. */ public void finishSetUp() { - if (!hasObb()) { - return; - } - final String obbDir = "/storage/emulated/0/Android/obb"; - final String packageObbDir = String.format("%s/%s", obbDir, mPackageName); - final String packageObbDirRoot = - String.format("/mnt/runtime/%s/emulated/0/Android/obb/", mPackageName); - final String[] obbDirs = { - packageObbDirRoot + "read", - packageObbDirRoot + "write", - packageObbDirRoot + "full", - packageObbDirRoot + "default", - String.format("/data/media/0/Android/obb/%s", mPackageName), - packageObbDir, - }; - try { - Slog.i(TAG, "Creating obb directory '" + packageObbDir + "'"); - final IVold vold = IVold.Stub.asInterface(ServiceManager.getServiceOrThrow("vold")); - vold.setupAppDir(packageObbDir, obbDir, Process.ROOT_UID); - for (String d : obbDirs) { - mObbStorage.bindPermanent(d); - } - } catch (ServiceManager.ServiceNotFoundException ex) { - Slog.e(TAG, "vold service is not found."); - cleanUp(); - } catch (IOException | RemoteException ex) { - Slog.e(TAG, "Failed to create obb dir at: " + packageObbDir, ex); - cleanUp(); - } } /** @@ -247,26 +138,12 @@ public final class IncrementalFileStorages { if (mDefaultStorage != null && mDefaultDir != null) { try { mDefaultStorage.unBind(mDefaultDir); + mDefaultStorage.unBind(mStageDir.getAbsolutePath()); } catch (IOException ignored) { } mDefaultDir = null; mDefaultStorage = null; } - if (mApkStorage != null && mStageDir != null) { - try { - mApkStorage.unBind(mStageDir.getAbsolutePath()); - } catch (IOException ignored) { - } - mApkStorage = null; - } - if (mObbStorage != null && mObbDir != null) { - try { - mObbStorage.unBind(mObbDir); - } catch (IOException ignored) { - } - mObbDir = null; - mObbStorage = null; - } } private String getTempDir() { diff --git a/core/java/android/os/incremental/IncrementalStorage.java b/core/java/android/os/incremental/IncrementalStorage.java index 91dda0899a63..e5d1b43d5921 100644 --- a/core/java/android/os/incremental/IncrementalStorage.java +++ b/core/java/android/os/incremental/IncrementalStorage.java @@ -174,9 +174,12 @@ public final class IncrementalStorage { @Nullable byte[] metadata, int hashAlgorithm, @Nullable byte[] rootHash, @Nullable byte[] additionalData, @Nullable byte[] signature) throws IOException { try { + if (id == null && metadata == null) { + throw new IOException("File ID and metadata cannot both be null"); + } final IncrementalNewFileParams params = new IncrementalNewFileParams(); params.size = size; - params.metadata = metadata; + params.metadata = (metadata == null ? new byte[0] : metadata); params.fileId = idToBytes(id); if (hashAlgorithm != 0 || signature != null) { params.signature = new IncrementalSignature(); @@ -354,9 +357,10 @@ public final class IncrementalStorage { * @param id The id to convert * @return Byte array that contains the same ID. */ - public static byte[] idToBytes(UUID id) { + @NonNull + public static byte[] idToBytes(@Nullable UUID id) { if (id == null) { - return null; + return new byte[0]; } final ByteBuffer buf = ByteBuffer.wrap(new byte[UUID_BYTE_SIZE]); buf.putLong(id.getMostSignificantBits()); @@ -370,7 +374,8 @@ public final class IncrementalStorage { * @param bytes The id in byte array format, 16 bytes long * @return UUID constructed from the byte array. */ - public static UUID bytesToId(byte[] bytes) { + @NonNull + public static UUID bytesToId(byte[] bytes) throws IllegalArgumentException { if (bytes.length != UUID_BYTE_SIZE) { throw new IllegalArgumentException("Expected array of size " + UUID_BYTE_SIZE + ", got " + bytes.length); diff --git a/core/java/android/provider/DocumentsContract.java b/core/java/android/provider/DocumentsContract.java index bb1c8ed165c9..47f24615d60a 100644 --- a/core/java/android/provider/DocumentsContract.java +++ b/core/java/android/provider/DocumentsContract.java @@ -16,8 +16,6 @@ package android.provider; -import static android.annotation.SystemApi.Client.MODULE_APPS; - import static com.android.internal.util.Preconditions.checkCollectionElementsNotNull; import static com.android.internal.util.Preconditions.checkCollectionNotEmpty; @@ -955,7 +953,7 @@ public final class DocumentsContract { * * @hide */ - @SystemApi(client = MODULE_APPS) + @SystemApi @NonNull public static Uri buildDocumentUriAsUser( @NonNull String authority, @NonNull String documentId, @NonNull UserHandle user) { diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index b62142c01c9b..30e4eee08e8d 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -14055,7 +14055,7 @@ public final class Settings { * means Common Criteria mode is enabled. * @hide */ - @SystemApi(client = SystemApi.Client.MODULE_APPS) + @SystemApi public static final String COMMON_CRITERIA_MODE = "common_criteria_mode"; } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 2b4b71f01aa5..549035fe6c69 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -3348,7 +3348,6 @@ public final class ViewRootImpl implements ViewParent, private void performLayout(WindowManager.LayoutParams lp, int desiredWindowWidth, int desiredWindowHeight) { - mLayoutRequested = false; mScrollMayChange = true; mInLayout = true; diff --git a/core/jni/android_view_RenderNode.cpp b/core/jni/android_view_RenderNode.cpp index 538861e21d96..a8246c7d84b7 100644 --- a/core/jni/android_view_RenderNode.cpp +++ b/core/jni/android_view_RenderNode.cpp @@ -151,11 +151,11 @@ static jboolean android_view_RenderNode_setOutlineRoundRect(CRITICAL_JNI_PARAMS_ return true; } -static jboolean android_view_RenderNode_setOutlineConvexPath(CRITICAL_JNI_PARAMS_COMMA jlong renderNodePtr, +static jboolean android_view_RenderNode_setOutlinePath(CRITICAL_JNI_PARAMS_COMMA jlong renderNodePtr, jlong outlinePathPtr, jfloat alpha) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); SkPath* outlinePath = reinterpret_cast<SkPath*>(outlinePathPtr); - renderNode->mutateStagingProperties().mutableOutline().setConvexPath(outlinePath, alpha); + renderNode->mutateStagingProperties().mutableOutline().setPath(outlinePath, alpha); renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); return true; } @@ -684,7 +684,7 @@ static const JNINativeMethod gMethods[] = { { "nSetProjectionReceiver","(JZ)Z", (void*) android_view_RenderNode_setProjectionReceiver }, { "nSetOutlineRoundRect", "(JIIIIFF)Z", (void*) android_view_RenderNode_setOutlineRoundRect }, - { "nSetOutlineConvexPath", "(JJF)Z", (void*) android_view_RenderNode_setOutlineConvexPath }, + { "nSetOutlinePath", "(JJF)Z", (void*) android_view_RenderNode_setOutlinePath }, { "nSetOutlineEmpty", "(J)Z", (void*) android_view_RenderNode_setOutlineEmpty }, { "nSetOutlineNone", "(J)Z", (void*) android_view_RenderNode_setOutlineNone }, { "nHasShadow", "(J)Z", (void*) android_view_RenderNode_hasShadow }, diff --git a/core/proto/android/server/activitymanagerservice.proto b/core/proto/android/server/activitymanagerservice.proto index 1426932ec04a..0a2fd7093a49 100644 --- a/core/proto/android/server/activitymanagerservice.proto +++ b/core/proto/android/server/activitymanagerservice.proto @@ -55,87 +55,8 @@ message ActivityManagerServiceProto { message ActivityManagerServiceDumpActivitiesProto { option (.android.msg_privacy).dest = DEST_AUTOMATIC; - optional ActivityStackSupervisorProto activity_stack_supervisor = 1; -} - -message ActivityStackSupervisorProto { - option (.android.msg_privacy).dest = DEST_AUTOMATIC; - - optional .com.android.server.wm.ConfigurationContainerProto configuration_container = 1 [deprecated=true]; - repeated ActivityDisplayProto displays = 2; - optional KeyguardControllerProto keyguard_controller = 3; - // TODO(b/111541062): Focused stack and resumed activity are now per-display. Topmost instances - // can be obtained from top display and these fields can be removed. - optional int32 focused_stack_id = 4; - optional .com.android.server.wm.IdentifierProto resumed_activity = 5; - // Whether or not the home activity is the recents activity. This is needed for the CTS tests to - // know what activity types to check for when invoking splitscreen multi-window. - optional bool is_home_recents_component = 6; - repeated .com.android.server.wm.IdentifierProto pending_activities = 7; - optional .com.android.server.wm.RootWindowContainerProto root_window_container = 8; -} - -/* represents ActivityStackSupervisor.ActivityDisplay */ -message ActivityDisplayProto { - option (.android.msg_privacy).dest = DEST_AUTOMATIC; - - // To be removed soon. - optional .com.android.server.wm.ConfigurationContainerProto configuration_container = 1 [deprecated=true]; - optional int32 id = 2; - repeated ActivityStackProto stacks = 3; - optional int32 focused_stack_id = 4; - optional .com.android.server.wm.IdentifierProto resumed_activity = 5; - optional bool single_task_instance = 6; - optional .com.android.server.wm.DisplayContentProto display = 7; -} - -message ActivityStackProto { - option (.android.msg_privacy).dest = DEST_AUTOMATIC; - - // To be removed soon. - optional .com.android.server.wm.ConfigurationContainerProto configuration_container = 1 [deprecated=true]; - optional int32 id = 2; - repeated TaskRecordProto tasks = 3; - optional .com.android.server.wm.IdentifierProto resumed_activity = 4; - optional int32 display_id = 5; - optional bool fullscreen = 6; - optional .android.graphics.RectProto bounds = 7; - optional .com.android.server.wm.StackProto stack = 8; -} - -message TaskRecordProto { - option (.android.msg_privacy).dest = DEST_AUTOMATIC; - - // To be removed soon. - optional .com.android.server.wm.ConfigurationContainerProto configuration_container = 1 [deprecated=true]; - optional int32 id = 2; - repeated .com.android.server.wm.ActivityRecordProto activities = 3; - optional int32 stack_id = 4; - optional .android.graphics.RectProto last_non_fullscreen_bounds = 5; - optional string real_activity = 6; - optional string orig_activity = 7; - optional int32 activity_type = 8; - optional int32 resize_mode = 9; - optional bool fullscreen = 10; - optional .android.graphics.RectProto bounds = 11; - optional int32 min_width = 12; - optional int32 min_height = 13; - optional .com.android.server.wm.TaskProto task = 14; -} - -message KeyguardControllerProto { - option (.android.msg_privacy).dest = DEST_AUTOMATIC; - - optional bool keyguard_showing = 1; - repeated KeyguardOccludedProto keyguard_occluded_states= 2; - optional bool aod_showing = 3; -} - -message KeyguardOccludedProto { - option (.android.msg_privacy).dest = DEST_AUTOMATIC; - - optional int32 display_id = 1; - optional bool keyguard_occluded = 2; + reserved 1; // activity_stack_supervisor + optional .com.android.server.wm.RootWindowContainerProto root_window_container = 2; } // "dumpsys activity --proto broadcasts" @@ -669,8 +590,6 @@ message ActivityManagerServiceDumpProcessesProto { optional int64 previous_proc_visible_time_ms = 17; optional ProcessRecordProto heavy_weight_proc = 18; optional .android.content.ConfigurationProto global_configuration = 19; - // ActivityStackSupervisorProto dumps these values as well, still here? - // repeated ActivityDisplayProto displays = 20; optional bool config_will_change = 21; diff --git a/core/proto/android/server/vibratorservice.proto b/core/proto/android/server/vibratorservice.proto new file mode 100644 index 000000000000..281a25e55dc2 --- /dev/null +++ b/core/proto/android/server/vibratorservice.proto @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2020 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. + */ + +syntax = "proto2"; +package com.android.server; + +option java_multiple_files = true; + +import "frameworks/base/core/proto/android/privacy.proto"; + +message WaveformProto { + option (.android.msg_privacy).dest = DEST_AUTOMATIC; + repeated int32 timings = 1; + repeated int32 amplitudes = 2; + required bool repeat = 3; +} + +message PrebakedProto { + option (.android.msg_privacy).dest = DEST_AUTOMATIC; + optional int32 effect_id = 1; + optional int32 effect_strength = 2; + optional int32 fallback = 3; +} + +// A com.android.os.VibrationEffect object. +message VibrationEffectProto { + option (.android.msg_privacy).dest = DEST_AUTOMATIC; + optional WaveformProto waveform = 1; + optional PrebakedProto prebaked = 2; +} + +message VibrationProto { + option (.android.msg_privacy).dest = DEST_AUTOMATIC; + optional int64 start_time = 1; + optional VibrationEffectProto effect = 2; + optional VibrationEffectProto origin_effect = 3; +} + +message VibratorServiceDumpProto { + option (.android.msg_privacy).dest = DEST_AUTOMATIC; + optional VibrationProto current_vibration = 1; + optional bool is_vibrating = 2; + optional VibrationProto current_external_vibration = 3; + optional bool vibrator_under_external_control = 4; + optional bool low_power_mode = 5; + optional int32 haptic_feedback_intensity = 6; + optional int32 notification_intensity = 7; + optional int32 ring_intensity = 8; + repeated VibrationProto previous_ring_vibrations = 9; + repeated VibrationProto previous_notification_vibrations = 10; + repeated VibrationProto previous_alarm_vibrations = 11; + repeated VibrationProto previous_vibrations = 12; +}
\ No newline at end of file diff --git a/core/proto/android/server/windowmanagerservice.proto b/core/proto/android/server/windowmanagerservice.proto index 7c8f62c14b1e..b0b9ce6f9968 100644 --- a/core/proto/android/server/windowmanagerservice.proto +++ b/core/proto/android/server/windowmanagerservice.proto @@ -54,8 +54,14 @@ message RootWindowContainerProto { optional WindowContainerProto window_container = 1; repeated DisplayContentProto displays = 2; + reserved 3; // IdentifierProto windows /* window references in top down z order */ - repeated IdentifierProto windows = 3; + repeated WindowStateProto windows = 4; + optional KeyguardControllerProto keyguard_controller = 5; + // Whether or not the home activity is the recents activity. This is needed for the CTS tests to + // know what activity types to check for when invoking splitscreen multi-window. + optional bool is_home_recents_component = 6; + repeated IdentifierProto pending_activities = 7; } message BarControllerProto { @@ -94,6 +100,21 @@ message KeyguardServiceDelegateProto { optional InteractiveState interactive_state = 5; } +message KeyguardControllerProto { + option (.android.msg_privacy).dest = DEST_AUTOMATIC; + + optional bool keyguard_showing = 1; + repeated KeyguardOccludedProto keyguard_occluded_states = 2; + optional bool aod_showing = 3; +} + +message KeyguardOccludedProto { + option (.android.msg_privacy).dest = DEST_AUTOMATIC; + + optional int32 display_id = 1; + optional bool keyguard_occluded = 2; +} + /* represents PhoneWindowManager */ message WindowManagerPolicyProto { option (.android.msg_privacy).dest = DEST_AUTOMATIC; @@ -145,7 +166,7 @@ message DisplayContentProto { optional WindowContainerProto window_container = 1; optional int32 id = 2; - repeated StackProto stacks = 3; + reserved 3; // stacks optional DockedStackDividerControllerProto docked_stack_divider_controller = 4; // Will be removed soon. optional PinnedStackControllerProto pinned_stack_controller = 5 [deprecated=true]; @@ -166,6 +187,12 @@ message DisplayContentProto { repeated IdentifierProto changing_apps = 19; repeated WindowTokenProto overlay_windows = 20; optional DisplayAreaProto root_display_area = 21; + + + optional bool single_task_instance = 22; + optional int32 focused_root_task_id = 23; + optional .com.android.server.wm.IdentifierProto resumed_activity = 24; + repeated TaskProto tasks = 25; } /* represents DisplayArea object */ @@ -191,7 +218,6 @@ message DisplayAreaChildProto { repeated string unknown = 3; } - /* represents DisplayFrames */ message DisplayFramesProto { option (.android.msg_privacy).dest = DEST_AUTOMATIC; @@ -214,39 +240,41 @@ message PinnedStackControllerProto { optional .android.graphics.RectProto movement_bounds = 2 [deprecated=true]; } -/* represents TaskStack */ -message StackProto { - option (.android.msg_privacy).dest = DEST_AUTOMATIC; - - optional WindowContainerProto window_container = 1; - optional int32 id = 2; - repeated TaskProto tasks = 3; - optional bool fills_parent = 4; - optional .android.graphics.RectProto bounds = 5; - optional bool animation_background_surface_is_dimming = 6 [deprecated=true]; - optional bool defer_removal = 7; - optional float minimize_amount = 8; - optional bool adjusted_for_ime = 9; - optional float adjust_ime_amount = 10; - optional float adjust_divider_amount = 11; - optional .android.graphics.RectProto adjusted_bounds = 12; - optional bool animating_bounds = 13; -} - /* represents Task */ message TaskProto { option (.android.msg_privacy).dest = DEST_AUTOMATIC; optional WindowContainerProto window_container = 1; optional int32 id = 2; - repeated ActivityRecordProto activity = 3; + reserved 3; // activity optional bool fills_parent = 4; optional .android.graphics.RectProto bounds = 5; optional .android.graphics.RectProto displayed_bounds = 6; - // Will be removed soon. - optional bool defer_removal = 7 [deprecated=true]; + optional bool defer_removal = 7; optional int32 surface_width = 8; optional int32 surface_height = 9; + + repeated TaskProto tasks = 10; + repeated ActivityRecordProto activities = 11; + + optional .com.android.server.wm.IdentifierProto resumed_activity = 12; + optional string real_activity = 13; + optional string orig_activity = 14; + + optional int32 display_id = 15; + optional int32 root_task_id = 16; + optional int32 activity_type = 17; + optional int32 resize_mode = 18; + optional int32 min_width = 19; + optional int32 min_height = 20; + + optional .android.graphics.RectProto adjusted_bounds = 21; + optional .android.graphics.RectProto last_non_fullscreen_bounds = 22; + optional bool adjusted_for_ime = 23; + optional float adjust_ime_amount = 24; + optional float adjust_divider_amount = 25; + optional bool animating_bounds = 26; + optional float minimize_amount = 27; } /* represents ActivityRecordProto */ @@ -271,17 +299,15 @@ message ActivityRecordProto { optional int32 num_drawn_windows = 15; optional bool all_drawn = 16; optional bool last_all_drawn = 17; - // Will be removed soon - optional bool removed = 18 [deprecated=true]; + reserved 18; // removed optional IdentifierProto starting_window = 19; optional bool starting_displayed = 20; - optional bool starting_moved = 21; + optional bool starting_moved = 201; optional bool visible_set_from_transferred_starting_window = 22; repeated .android.graphics.RectProto frozen_bounds = 23; optional bool visible = 24; - // To be removed soon. - optional .com.android.server.wm.ConfigurationContainerProto configuration_container = 25 [deprecated=true]; - optional .com.android.server.wm.IdentifierProto identifier = 26; + reserved 25; // configuration_container + optional IdentifierProto identifier = 26; optional string state = 27; optional bool front_of_task = 28; optional int32 proc_id = 29; diff --git a/graphics/java/android/graphics/Outline.java b/graphics/java/android/graphics/Outline.java index 91a60c327bf0..c12159cfd7a4 100644 --- a/graphics/java/android/graphics/Outline.java +++ b/graphics/java/android/graphics/Outline.java @@ -43,7 +43,7 @@ public final class Outline { /** @hide */ public static final int MODE_ROUND_RECT = 1; /** @hide */ - public static final int MODE_CONVEX_PATH = 2; + public static final int MODE_PATH = 2; /** @hide */ @Retention(RetentionPolicy.SOURCE) @@ -51,7 +51,7 @@ public final class Outline { value = { MODE_EMPTY, MODE_ROUND_RECT, - MODE_CONVEX_PATH, + MODE_PATH, }) public @interface Mode {} @@ -60,7 +60,7 @@ public final class Outline { public int mMode = MODE_EMPTY; /** - * Only guaranteed to be non-null when mode == MODE_CONVEX_PATH + * Only guaranteed to be non-null when mode == MODE_PATH * * @hide */ @@ -124,7 +124,7 @@ public final class Outline { * @see android.view.View#setClipToOutline(boolean) */ public boolean canClip() { - return mMode != MODE_CONVEX_PATH; + return mMode != MODE_PATH; } /** @@ -157,7 +157,7 @@ public final class Outline { */ public void set(@NonNull Outline src) { mMode = src.mMode; - if (src.mMode == MODE_CONVEX_PATH) { + if (src.mMode == MODE_PATH) { if (mPath == null) { mPath = new Path(); } @@ -194,7 +194,7 @@ public final class Outline { return; } - if (mMode == MODE_CONVEX_PATH) { + if (mMode == MODE_PATH) { // rewind here to avoid thrashing the allocations, but could alternately clear ref mPath.rewind(); } @@ -213,7 +213,7 @@ public final class Outline { /** * Populates {@code outBounds} with the outline bounds, if set, and returns * {@code true}. If no outline bounds are set, or if a path has been set - * via {@link #setConvexPath(Path)}, returns {@code false}. + * via {@link #setPath(Path)}, returns {@code false}. * * @param outRect the rect to populate with the outline bounds, if set * @return {@code true} if {@code outBounds} was populated with outline @@ -229,7 +229,7 @@ public final class Outline { /** * Returns the rounded rect radius, if set, or a value less than 0 if a path has - * been set via {@link #setConvexPath(Path)}. A return value of {@code 0} + * been set via {@link #setPath(Path)}. A return value of {@code 0} * indicates a non-rounded rect. * * @return the rounded rect radius, or value < 0 @@ -259,7 +259,7 @@ public final class Outline { mPath.rewind(); } - mMode = MODE_CONVEX_PATH; + mMode = MODE_PATH; mPath.addOval(left, top, right, bottom, Path.Direction.CW); mRect.setEmpty(); mRadius = RADIUS_UNDEFINED; @@ -279,9 +279,21 @@ public final class Outline { * @param convexPath used to construct the Outline. As of * {@link android.os.Build.VERSION_CODES#Q}, it is no longer required to be * convex. + * + * @deprecated The path is no longer required to be convex. Use {@link #setPath} instead. */ + @Deprecated public void setConvexPath(@NonNull Path convexPath) { - if (convexPath.isEmpty()) { + setPath(convexPath); + } + + /** + * Sets the Outline to a {@link android.graphics.Path path}. + * + * @param path used to construct the Outline. + */ + public void setPath(@NonNull Path path) { + if (path.isEmpty()) { setEmpty(); return; } @@ -290,8 +302,8 @@ public final class Outline { mPath = new Path(); } - mMode = MODE_CONVEX_PATH; - mPath.set(convexPath); + mMode = MODE_PATH; + mPath.set(path); mRect.setEmpty(); mRadius = RADIUS_UNDEFINED; } @@ -302,7 +314,7 @@ public final class Outline { public void offset(int dx, int dy) { if (mMode == MODE_ROUND_RECT) { mRect.offset(dx, dy); - } else if (mMode == MODE_CONVEX_PATH) { + } else if (mMode == MODE_PATH) { mPath.offset(dx, dy); } } diff --git a/graphics/java/android/graphics/RenderNode.java b/graphics/java/android/graphics/RenderNode.java index 17e3b4465130..3835b2d493c5 100644 --- a/graphics/java/android/graphics/RenderNode.java +++ b/graphics/java/android/graphics/RenderNode.java @@ -687,8 +687,8 @@ public final class RenderNode { outline.mRect.left, outline.mRect.top, outline.mRect.right, outline.mRect.bottom, outline.mRadius, outline.mAlpha); - case Outline.MODE_CONVEX_PATH: - return nSetOutlineConvexPath(mNativeRenderNode, outline.mPath.mNativePath, + case Outline.MODE_PATH: + return nSetOutlinePath(mNativeRenderNode, outline.mPath.mNativePath, outline.mAlpha); } @@ -1620,7 +1620,7 @@ public final class RenderNode { int right, int bottom, float radius, float alpha); @CriticalNative - private static native boolean nSetOutlineConvexPath(long renderNode, long nativePath, + private static native boolean nSetOutlinePath(long renderNode, long nativePath, float alpha); @CriticalNative diff --git a/graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java b/graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java index 928e607abbbe..746378e10bc7 100644 --- a/graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java +++ b/graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java @@ -387,7 +387,7 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback @Override public void getOutline(@NonNull Outline outline) { - outline.setConvexPath(mMask); + outline.setPath(mMask); } /** @hide */ diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index 3881955d2632..f053f392b97e 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -1915,7 +1915,7 @@ public class GradientDrawable extends Drawable { case RECTANGLE: if (st.mRadiusArray != null) { buildPathIfDirty(); - outline.setConvexPath(mPath); + outline.setPath(mPath); return; } diff --git a/graphics/java/android/graphics/drawable/shapes/RoundRectShape.java b/graphics/java/android/graphics/drawable/shapes/RoundRectShape.java index 475e0bb70f2b..28ba60577fb1 100644 --- a/graphics/java/android/graphics/drawable/shapes/RoundRectShape.java +++ b/graphics/java/android/graphics/drawable/shapes/RoundRectShape.java @@ -94,7 +94,7 @@ public class RoundRectShape extends RectShape { for (int i = 1; i < 8; i++) { if (mOuterRadii[i] != radius) { // can't call simple constructors, use path - outline.setConvexPath(mPath); + outline.setPath(mPath); return; } } diff --git a/libs/hwui/Outline.h b/libs/hwui/Outline.h index f1c38031980e..2eb2c7c7e299 100644 --- a/libs/hwui/Outline.h +++ b/libs/hwui/Outline.h @@ -26,7 +26,7 @@ namespace uirenderer { class Outline { public: - enum class Type { None = 0, Empty = 1, ConvexPath = 2, RoundRect = 3 }; + enum class Type { None = 0, Empty = 1, Path = 2, RoundRect = 3 }; Outline() : mShouldClip(false), mType(Type::None), mRadius(0), mAlpha(0.0f) {} @@ -57,12 +57,12 @@ public: } } - void setConvexPath(const SkPath* outline, float alpha) { + void setPath(const SkPath* outline, float alpha) { if (!outline) { setEmpty(); return; } - mType = Type::ConvexPath; + mType = Type::Path; mPath = *outline; mBounds.set(outline->getBounds()); mAlpha = alpha; diff --git a/media/java/android/media/AudioAttributes.java b/media/java/android/media/AudioAttributes.java index 114c0f1f6bf3..fe0c2d21d442 100644 --- a/media/java/android/media/AudioAttributes.java +++ b/media/java/android/media/AudioAttributes.java @@ -1427,7 +1427,10 @@ public final class AudioAttributes implements Parcelable { } } - static int capturePolicyToFlags(@CapturePolicy int capturePolicy, int flags) { + /** + * @hide + */ + public static int capturePolicyToFlags(@CapturePolicy int capturePolicy, int flags) { switch (capturePolicy) { case ALLOW_CAPTURE_BY_NONE: flags |= FLAG_NO_MEDIA_PROJECTION | FLAG_NO_SYSTEM_CAPTURE; diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 861b76d2b153..7b17f9f764fb 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -1547,23 +1547,22 @@ public class AudioManager { * {@link AudioAttributes#ALLOW_CAPTURE_BY_ALL}, * {@link AudioAttributes#ALLOW_CAPTURE_BY_SYSTEM}, * {@link AudioAttributes#ALLOW_CAPTURE_BY_NONE}. - * @throws IllegalArgumentException if the argument is not a valid value. + * @throws RuntimeException if the argument is not a valid value. */ public void setAllowedCapturePolicy(@AudioAttributes.CapturePolicy int capturePolicy) { - int flags = AudioAttributes.capturePolicyToFlags(capturePolicy, 0x0); - // TODO: got trough AudioService and save a cache to restore in case of AP crash // TODO: also pass the package in case multiple packages have the same UID - int result = AudioSystem.setAllowedCapturePolicy(Process.myUid(), flags); - if (result != AudioSystem.AUDIO_STATUS_OK) { - Log.e(TAG, "Could not setAllowedCapturePolicy: " + result); - return; + final IAudioService service = getService(); + try { + int result = service.setAllowedCapturePolicy(capturePolicy); + if (result != AudioSystem.AUDIO_STATUS_OK) { + Log.e(TAG, "Could not setAllowedCapturePolicy: " + result); + return; + } + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - mCapturePolicy = capturePolicy; } - @AudioAttributes.CapturePolicy - private int mCapturePolicy = AudioAttributes.ALLOW_CAPTURE_BY_ALL; - /** * Return the capture policy. * @return the capture policy set by {@link #setAllowedCapturePolicy(int)} or @@ -1571,7 +1570,13 @@ public class AudioManager { */ @AudioAttributes.CapturePolicy public int getAllowedCapturePolicy() { - return mCapturePolicy; + int result = AudioAttributes.ALLOW_CAPTURE_BY_ALL; + try { + result = getService().getAllowedCapturePolicy(); + } catch (RemoteException e) { + Log.e(TAG, "Failed to query allowed capture policy: " + e); + } + return result; } //==================================================================== diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl index 1f97be5c3f4d..64c5c05b5621 100644 --- a/media/java/android/media/IAudioService.aidl +++ b/media/java/android/media/IAudioService.aidl @@ -282,6 +282,10 @@ interface IAudioService { List<AudioDeviceAddress> getDevicesForAttributes(in AudioAttributes attributes); + int setAllowedCapturePolicy(in int capturePolicy); + + int getAllowedCapturePolicy(); + // WARNING: read warning at top of file, new methods that need to be used by native // code via IAudioManager.h need to be added to the top section. } diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java index fa1392644735..50a50633f43c 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java @@ -448,12 +448,8 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList int bottomInset = getRootWindowInsets() != null ? getRootWindowInsets().getStableInsetBottom() : 0; - int mh = mDisplaySize.y - windowLocation[1] - mSettingsIconHeight - mPointerHeight + return mDisplaySize.y - windowLocation[1] - mSettingsIconHeight - mPointerHeight - mPointerMargin - bottomInset; - Log.i(TAG, "max exp height: " + mh); -// return mDisplaySize.y - windowLocation[1] - mSettingsIconHeight - mPointerHeight -// - mPointerMargin - bottomInset; - return mh; } /** diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleFlyoutView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleFlyoutView.java index 4194352f93bd..5b9ea7dd5e3a 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleFlyoutView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleFlyoutView.java @@ -431,7 +431,7 @@ public class BubbleFlyoutView extends FrameLayout { final float interpolatedRadius = getInterpolatedRadius(); rectPath.addRoundRect(mBgRect, interpolatedRadius, interpolatedRadius, Path.Direction.CW); - outline.setConvexPath(rectPath); + outline.setPath(rectPath); // Get rid of the triangle path once it has disappeared behind the flyout. if (mPercentStillFlyout > 0.5f) { diff --git a/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingControllerImpl.kt index 48d2fa68d198..0a2a9255c3ea 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingControllerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingControllerImpl.kt @@ -170,7 +170,7 @@ open class ControlsBindingControllerImpl @Inject constructor( override fun bindServices(components: List<ComponentName>) { components.forEach { val provider = retrieveLifecycleManager(it) - backgroundExecutor.execute { provider.bindPermanently() } + backgroundExecutor.execute { provider.bindService() } } } @@ -233,7 +233,7 @@ open class ControlsBindingControllerImpl @Inject constructor( provider.lastLoadCallback?.invoke(list) ?: run { Log.w(TAG, "Null callback") } - provider.maybeUnbindAndRemoveCallback() + provider.unbindService() } } diff --git a/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsProviderLifecycleManager.kt b/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsProviderLifecycleManager.kt index 739ca7ec0c29..b4bd82c84e1a 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsProviderLifecycleManager.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsProviderLifecycleManager.kt @@ -56,9 +56,7 @@ class ControlsProviderLifecycleManager( val token: IBinder = Binder() @GuardedBy("subscriptions") private val subscriptions = mutableListOf<IControlsSubscription>() - private var unbindImmediate = false private var requiresBound = false - private var isBound = false @GuardedBy("queuedMessages") private val queuedMessages: MutableSet<Message> = ArraySet() private var wrapper: ServiceWrapper? = null @@ -98,30 +96,22 @@ class ControlsProviderLifecycleManager( } bindTryCount++ try { - isBound = context.bindServiceAsUser(intent, serviceConnection, BIND_FLAGS, user) + context.bindServiceAsUser(intent, serviceConnection, BIND_FLAGS, user) } catch (e: SecurityException) { Log.e(TAG, "Failed to bind to service", e) - isBound = false } } else { if (DEBUG) { Log.d(TAG, "Unbinding service $intent") } bindTryCount = 0 - wrapper = null - if (isBound) { + wrapper?.run { context.unbindService(serviceConnection) - isBound = false } + wrapper = null } } - fun bindPermanently() { - unbindImmediate = false - unqueueMessage(Message.Unbind) - bindService(true) - } - private val serviceConnection = object : ServiceConnection { override fun onServiceConnected(name: ComponentName, service: IBinder) { if (DEBUG) Log.d(TAG, "onServiceConnected $name") @@ -135,7 +125,7 @@ class ControlsProviderLifecycleManager( override fun onServiceDisconnected(name: ComponentName?) { if (DEBUG) Log.d(TAG, "onServiceDisconnected $name") - isBound = false + wrapper = null bindService(false) } } @@ -197,6 +187,15 @@ class ControlsProviderLifecycleManager( } } + private fun invokeOrQueue(f: () -> Unit, msg: Message) { + wrapper?.run { + f() + } ?: run { + queueMessage(msg) + bindService(true) + } + } + fun maybeBindAndLoad(callback: LoadCallback) { unqueueMessage(Message.Unbind) lastLoadCallback = callback @@ -205,22 +204,12 @@ class ControlsProviderLifecycleManager( Log.d(TAG, "Timeout waiting onLoad for $componentName") loadCallbackService.accept(token, emptyList()) }, LOAD_TIMEOUT, TimeUnit.MILLISECONDS) - if (isBound) { - load() - } else { - queueMessage(Message.Load) - unbindImmediate = true - bindService(true) - } + + invokeOrQueue(::load, Message.Load) } fun maybeBindAndSubscribe(controlIds: List<String>) { - if (isBound) { - subscribe(controlIds) - } else { - queueMessage(Message.Subscribe(controlIds)) - bindService(true) - } + invokeOrQueue({ subscribe(controlIds) }, Message.Subscribe(controlIds)) } private fun subscribe(controlIds: List<String>) { @@ -234,12 +223,7 @@ class ControlsProviderLifecycleManager( } fun maybeBindAndSendAction(controlId: String, action: ControlAction) { - if (isBound) { - action(controlId, action) - } else { - queueMessage(Message.Action(controlId, action)) - bindService(true) - } + invokeOrQueue({ action(controlId, action) }, Message.Action(controlId, action)) } private fun action(controlId: String, action: ControlAction) { @@ -276,25 +260,23 @@ class ControlsProviderLifecycleManager( } } - fun maybeUnbindAndRemoveCallback() { + fun bindService() { + unqueueMessage(Message.Unbind) + bindService(true) + } + + fun unbindService() { lastLoadCallback = null onLoadCanceller?.run() onLoadCanceller = null - if (unbindImmediate) { - bindService(false) - } - } - fun unbindService() { - unbindImmediate = true - maybeUnbindAndRemoveCallback() + bindService(false) } override fun toString(): String { return StringBuilder("ControlsProviderLifecycleManager(").apply { append("component=$componentName") append(", user=$user") - append(", bound=$isBound") append(")") }.toString() } @@ -314,4 +296,4 @@ class ControlsProviderLifecycleManager( override val type = MSG_ACTION } } -}
\ No newline at end of file +} diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java index f33c931479ba..45c07a3e4693 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java @@ -1801,6 +1801,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, void dismissImmediately() { mShowing = false; + if (mControlsUiController != null) mControlsUiController.hide(); dismissPanel(); resetOrientation(); completeDismiss(); diff --git a/packages/SystemUI/src/com/android/systemui/recents/TriangleShape.java b/packages/SystemUI/src/com/android/systemui/recents/TriangleShape.java index de8e6ea4a0cb..7ebebaaef122 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/TriangleShape.java +++ b/packages/SystemUI/src/com/android/systemui/recents/TriangleShape.java @@ -70,6 +70,6 @@ public class TriangleShape extends PathShape { @Override public void getOutline(@NonNull Outline outline) { - outline.setConvexPath(mTriangularPath); + outline.setPath(mTriangularPath); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java index 28f4136d5ecb..049cafa4ccde 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java @@ -93,7 +93,7 @@ public abstract class ExpandableOutlineView extends ExpandableView { } else { Path clipPath = getClipPath(false /* ignoreTranslation */); if (clipPath != null) { - outline.setConvexPath(clipPath); + outline.setPath(clipPath); } } outline.setAlpha(mOutlineAlpha); diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlsBindingControllerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlsBindingControllerImplTest.kt index c1ebae735c7a..89c1636e953f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlsBindingControllerImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlsBindingControllerImplTest.kt @@ -103,7 +103,7 @@ class ControlsBindingControllerTest : SysuiTestCase() { assertEquals(setOf(TEST_COMPONENT_NAME_1, TEST_COMPONENT_NAME_2), providers.map { it.componentName }.toSet()) providers.forEach { - verify(it).bindPermanently() + verify(it).bindService() } } @@ -215,4 +215,4 @@ class TestableControlsBindingControllerImpl( providers.add(provider) return provider } -}
\ No newline at end of file +} diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlsProviderLifecycleManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlsProviderLifecycleManagerTest.kt index 3f1435be8b3f..40566dc39c9e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlsProviderLifecycleManagerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlsProviderLifecycleManagerTest.kt @@ -99,13 +99,13 @@ class ControlsProviderLifecycleManagerTest : SysuiTestCase() { @Test fun testBindService() { - manager.bindPermanently() + manager.bindService() assertTrue(mContext.isBound(componentName)) } @Test fun testUnbindService() { - manager.bindPermanently() + manager.bindService() manager.unbindService() assertFalse(mContext.isBound(componentName)) } @@ -125,7 +125,7 @@ class ControlsProviderLifecycleManagerTest : SysuiTestCase() { fun testMaybeUnbind_bindingAndCallback() { manager.maybeBindAndLoad {} - manager.maybeUnbindAndRemoveCallback() + manager.unbindService() assertFalse(mContext.isBound(componentName)) assertNull(manager.lastLoadCallback) } diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/EventDispatcher.java b/services/accessibility/java/com/android/server/accessibility/gestures/EventDispatcher.java index 5ac3b69549c1..667364c9c901 100644 --- a/services/accessibility/java/com/android/server/accessibility/gestures/EventDispatcher.java +++ b/services/accessibility/java/com/android/server/accessibility/gestures/EventDispatcher.java @@ -301,7 +301,7 @@ class EventDispatcher { * @param policyFlags The policy flags associated with the event. */ void sendUpForInjectedDownPointers(MotionEvent prototype, int policyFlags) { - int pointerIdBits = 0; + int pointerIdBits = prototype.getPointerIdBits(); final int pointerCount = prototype.getPointerCount(); for (int i = 0; i < pointerCount; i++) { final int pointerId = prototype.getPointerId(i); @@ -309,10 +309,10 @@ class EventDispatcher { if (!isInjectedPointerDown(pointerId)) { continue; } - pointerIdBits |= (1 << pointerId); - final int action = computeInjectionAction(MotionEvent.ACTION_UP, i); + final int action = computeInjectionAction(MotionEvent.ACTION_POINTER_UP, i); sendMotionEvent( prototype, action, mState.getLastReceivedEvent(), pointerIdBits, policyFlags); + pointerIdBits &= ~(1 << pointerId); } } } diff --git a/services/core/java/android/app/usage/UsageStatsManagerInternal.java b/services/core/java/android/app/usage/UsageStatsManagerInternal.java index a8be66990fff..5c2cbfa63a2b 100644 --- a/services/core/java/android/app/usage/UsageStatsManagerInternal.java +++ b/services/core/java/android/app/usage/UsageStatsManagerInternal.java @@ -215,9 +215,14 @@ public abstract class UsageStatsManagerInternal { /** * Returns the events for the user in the given time period. + * + * @param obfuscateInstantApps whether instant app package names need to be obfuscated in the + * result. + * @param hideShortcutInvocationEvents whether the {@link UsageEvents.Event#SHORTCUT_INVOCATION} + * events need to be excluded from the result. */ public abstract UsageEvents queryEventsForUser(@UserIdInt int userId, long beginTime, - long endTime, boolean shouldObfuscateInstantApps); + long endTime, boolean obfuscateInstantApps, boolean hideShortcutInvocationEvents); /** * Used to persist the last time a job was run for this app, in order to make decisions later diff --git a/services/core/java/com/android/server/VibratorService.java b/services/core/java/com/android/server/VibratorService.java index 6bc090a4f7ba..79b3a7b0d114 100644 --- a/services/core/java/com/android/server/VibratorService.java +++ b/services/core/java/com/android/server/VibratorService.java @@ -66,6 +66,7 @@ import android.util.DebugUtils; import android.util.Slog; import android.util.SparseArray; import android.util.StatsLog; +import android.util.proto.ProtoOutputStream; import android.view.InputDevice; import com.android.internal.annotations.GuardedBy; @@ -165,6 +166,7 @@ public class VibratorService extends IVibratorService.Stub private ExternalVibration mCurrentExternalVibration; private boolean mVibratorUnderExternalControl; private boolean mLowPowerMode; + private boolean mIsVibrating; private int mHapticFeedbackIntensity; private int mNotificationIntensity; private int mRingIntensity; @@ -327,6 +329,14 @@ public class VibratorService extends IVibratorService.Stub .append(mReason) .toString(); } + + void dumpProto(ProtoOutputStream proto, long fieldId) { + synchronized (this) { + final long token = proto.start(fieldId); + proto.write(VibrationProto.START_TIME, mStartTimeDebug); + proto.end(token); + } + } } private static final class ScaleLevel { @@ -1363,6 +1373,7 @@ public class VibratorService extends IVibratorService.Stub StatsLog.write_non_chained(StatsLog.VIBRATOR_STATE_CHANGED, uid, null, StatsLog.VIBRATOR_STATE_CHANGED__STATE__ON, millis); mCurVibUid = uid; + mIsVibrating = true; } catch (RemoteException e) { } } @@ -1376,6 +1387,7 @@ public class VibratorService extends IVibratorService.Stub } catch (RemoteException e) { } mCurVibUid = -1; } + mIsVibrating = false; } private void setVibratorUnderExternalControl(boolean externalControl) { @@ -1390,6 +1402,93 @@ public class VibratorService extends IVibratorService.Stub vibratorSetExternalControl(externalControl); } + private void dumpInternal(PrintWriter pw) { + pw.println("Vibrator Service:"); + synchronized (mLock) { + pw.print(" mCurrentVibration="); + if (mCurrentVibration != null) { + pw.println(mCurrentVibration.toInfo().toString()); + } else { + pw.println("null"); + } + pw.print(" mCurrentExternalVibration=" + mCurrentExternalVibration); + pw.println(" mVibratorUnderExternalControl=" + mVibratorUnderExternalControl); + pw.println(" mIsVibrating=" + mIsVibrating); + pw.println(" mLowPowerMode=" + mLowPowerMode); + pw.println(" mHapticFeedbackIntensity=" + mHapticFeedbackIntensity); + pw.println(" mNotificationIntensity=" + mNotificationIntensity); + pw.println(" mRingIntensity=" + mRingIntensity); + pw.println(" mSupportedEffects=" + mSupportedEffects); + pw.println(); + pw.println(" Previous ring vibrations:"); + for (VibrationInfo info : mPreviousRingVibrations) { + pw.print(" "); + pw.println(info.toString()); + } + + pw.println(" Previous notification vibrations:"); + for (VibrationInfo info : mPreviousNotificationVibrations) { + pw.println(" " + info); + } + + pw.println(" Previous alarm vibrations:"); + for (VibrationInfo info : mPreviousAlarmVibrations) { + pw.println(" " + info); + } + + pw.println(" Previous vibrations:"); + for (VibrationInfo info : mPreviousVibrations) { + pw.println(" " + info); + } + + pw.println(" Previous external vibrations:"); + for (ExternalVibration vib : mPreviousExternalVibrations) { + pw.println(" " + vib); + } + } + } + + private void dumpProto(FileDescriptor fd) { + final ProtoOutputStream proto = new ProtoOutputStream(fd); + + synchronized (mLock) { + if (mCurrentVibration != null) { + mCurrentVibration.toInfo().dumpProto(proto, + VibratorServiceDumpProto.CURRENT_VIBRATION); + } + proto.write(VibratorServiceDumpProto.IS_VIBRATING, mIsVibrating); + proto.write(VibratorServiceDumpProto.VIBRATOR_UNDER_EXTERNAL_CONTROL, + mVibratorUnderExternalControl); + proto.write(VibratorServiceDumpProto.LOW_POWER_MODE, mLowPowerMode); + proto.write(VibratorServiceDumpProto.HAPTIC_FEEDBACK_INTENSITY, + mHapticFeedbackIntensity); + proto.write(VibratorServiceDumpProto.NOTIFICATION_INTENSITY, + mNotificationIntensity); + proto.write(VibratorServiceDumpProto.RING_INTENSITY, mRingIntensity); + + for (VibrationInfo info : mPreviousRingVibrations) { + info.dumpProto(proto, + VibratorServiceDumpProto.PREVIOUS_RING_VIBRATIONS); + } + + for (VibrationInfo info : mPreviousNotificationVibrations) { + info.dumpProto(proto, + VibratorServiceDumpProto.PREVIOUS_NOTIFICATION_VIBRATIONS); + } + + for (VibrationInfo info : mPreviousAlarmVibrations) { + info.dumpProto(proto, + VibratorServiceDumpProto.PREVIOUS_ALARM_VIBRATIONS); + } + + for (VibrationInfo info : mPreviousVibrations) { + info.dumpProto(proto, + VibratorServiceDumpProto.PREVIOUS_VIBRATIONS); + } + } + proto.flush(); + } + private class VibrateThread extends Thread { private final VibrationEffect.Waveform mWaveform; private final int mUid; @@ -1556,47 +1655,22 @@ public class VibratorService extends IVibratorService.Stub protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; - pw.println("Vibrator Service:"); - synchronized (mLock) { - pw.print(" mCurrentVibration="); - if (mCurrentVibration != null) { - pw.println(mCurrentVibration.toInfo().toString()); - } else { - pw.println("null"); - } - pw.print(" mCurrentExternalVibration=" + mCurrentExternalVibration); - pw.println(" mVibratorUnderExternalControl=" + mVibratorUnderExternalControl); - pw.println(" mLowPowerMode=" + mLowPowerMode); - pw.println(" mHapticFeedbackIntensity=" + mHapticFeedbackIntensity); - pw.println(" mNotificationIntensity=" + mNotificationIntensity); - pw.println(" mRingIntensity=" + mRingIntensity); - pw.println(" mSupportedEffects=" + mSupportedEffects); - pw.println(); - pw.println(" Previous ring vibrations:"); - for (VibrationInfo info : mPreviousRingVibrations) { - pw.print(" "); - pw.println(info.toString()); - } - - pw.println(" Previous notification vibrations:"); - for (VibrationInfo info : mPreviousNotificationVibrations) { - pw.println(" " + info); - } + final long ident = Binder.clearCallingIdentity(); - pw.println(" Previous alarm vibrations:"); - for (VibrationInfo info : mPreviousAlarmVibrations) { - pw.println(" " + info); + boolean isDumpProto = false; + for (String arg : args) { + if (arg.equals("--proto")) { + isDumpProto = true; } - - pw.println(" Previous vibrations:"); - for (VibrationInfo info : mPreviousVibrations) { - pw.println(" " + info); - } - - pw.println(" Previous external vibrations:"); - for (ExternalVibration vib : mPreviousExternalVibrations) { - pw.println(" " + vib); + } + try { + if (isDumpProto) { + dumpProto(fd); + } else { + dumpInternal(pw); } + } finally { + Binder.restoreCallingIdentity(ident); } } diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 8f6bd212da19..b2548af0f576 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -1068,6 +1068,27 @@ public class AudioService extends IAudioService.Stub } } + // Restore capture policies + synchronized (mPlaybackMonitor) { + HashMap<Integer, Integer> allowedCapturePolicies = + mPlaybackMonitor.getAllAllowedCapturePolicies(); + for (HashMap.Entry<Integer, Integer> entry : allowedCapturePolicies.entrySet()) { + int result = AudioSystem.setAllowedCapturePolicy( + entry.getKey(), + AudioAttributes.capturePolicyToFlags(entry.getValue(), 0x0)); + if (result != AudioSystem.AUDIO_STATUS_OK) { + Log.e(TAG, "Failed to restore capture policy, uid: " + + entry.getKey() + ", capture policy: " + entry.getValue() + + ", result: " + result); + // When restoring capture policy failed, set the capture policy as + // ALLOW_CAPTURE_BY_ALL, which will result in removing the cached + // capture policy in PlaybackActivityMonitor. + mPlaybackMonitor.setAllowedCapturePolicy( + entry.getKey(), AudioAttributes.ALLOW_CAPTURE_BY_ALL); + } + } + } + onIndicateSystemReady(); // indicate the end of reconfiguration phase to audio HAL AudioSystem.setParameters("restarting=false"); @@ -7298,6 +7319,43 @@ public class AudioService extends IAudioService.Stub mPlaybackMonitor.releasePlayer(piid, Binder.getCallingUid()); } + /** + * Specifies whether the audio played by this app may or may not be captured by other apps or + * the system. + * + * @param capturePolicy one of + * {@link AudioAttributes#ALLOW_CAPTURE_BY_ALL}, + * {@link AudioAttributes#ALLOW_CAPTURE_BY_SYSTEM}, + * {@link AudioAttributes#ALLOW_CAPTURE_BY_NONE}. + * @return AudioSystem.AUDIO_STATUS_OK if set allowed capture policy succeed. + * @throws IllegalArgumentException if the argument is not a valid value. + */ + public int setAllowedCapturePolicy(int capturePolicy) { + int callingUid = Binder.getCallingUid(); + int flags = AudioAttributes.capturePolicyToFlags(capturePolicy, 0x0); + final long identity = Binder.clearCallingIdentity(); + synchronized (mPlaybackMonitor) { + int result = AudioSystem.setAllowedCapturePolicy(callingUid, flags); + if (result == AudioSystem.AUDIO_STATUS_OK) { + mPlaybackMonitor.setAllowedCapturePolicy(callingUid, capturePolicy); + } + Binder.restoreCallingIdentity(identity); + return result; + } + } + + /** + * Return the capture policy. + * @return the cached capture policy for the calling uid. + */ + public int getAllowedCapturePolicy() { + int callingUid = Binder.getCallingUid(); + final long identity = Binder.clearCallingIdentity(); + int capturePolicy = mPlaybackMonitor.getAllowedCapturePolicy(callingUid); + Binder.restoreCallingIdentity(identity); + return capturePolicy; + } + //====================== // Audio device management //====================== diff --git a/services/core/java/com/android/server/audio/PlaybackActivityMonitor.java b/services/core/java/com/android/server/audio/PlaybackActivityMonitor.java index f8ba55bcd092..98f409ea98e7 100644 --- a/services/core/java/com/android/server/audio/PlaybackActivityMonitor.java +++ b/services/core/java/com/android/server/audio/PlaybackActivityMonitor.java @@ -160,6 +160,12 @@ public final class PlaybackActivityMonitor new AudioPlaybackConfiguration(pic, newPiid, Binder.getCallingUid(), Binder.getCallingPid()); apc.init(); + synchronized (mAllowedCapturePolicies) { + int uid = apc.getClientUid(); + if (mAllowedCapturePolicies.containsKey(uid)) { + updateAllowedCapturePolicy(apc, mAllowedCapturePolicies.get(uid)); + } + } sEventLogger.log(new NewPlayerEvent(apc)); synchronized(mPlayerLock) { mPlayers.put(newPiid, apc); @@ -169,6 +175,13 @@ public final class PlaybackActivityMonitor public void playerAttributes(int piid, @NonNull AudioAttributes attr, int binderUid) { final boolean change; + synchronized (mAllowedCapturePolicies) { + if (mAllowedCapturePolicies.containsKey(binderUid) + && attr.getAllowedCapturePolicy() < mAllowedCapturePolicies.get(binderUid)) { + attr = new AudioAttributes.Builder(attr) + .setAllowedCapturePolicy(mAllowedCapturePolicies.get(binderUid)).build(); + } + } synchronized(mPlayerLock) { final AudioPlaybackConfiguration apc = mPlayers.get(new Integer(piid)); if (checkConfigurationCaller(piid, apc, binderUid)) { @@ -284,6 +297,69 @@ public final class PlaybackActivityMonitor } } + /** + * A map of uid to capture policy. + */ + private final HashMap<Integer, Integer> mAllowedCapturePolicies = + new HashMap<Integer, Integer>(); + + /** + * Cache allowed capture policy, which specifies whether the audio played by the app may or may + * not be captured by other apps or the system. + * + * @param uid the uid of requested app + * @param capturePolicy one of + * {@link AudioAttributes#ALLOW_CAPTURE_BY_ALL}, + * {@link AudioAttributes#ALLOW_CAPTURE_BY_SYSTEM}, + * {@link AudioAttributes#ALLOW_CAPTURE_BY_NONE}. + */ + public void setAllowedCapturePolicy(int uid, int capturePolicy) { + synchronized (mAllowedCapturePolicies) { + if (capturePolicy == AudioAttributes.ALLOW_CAPTURE_BY_ALL) { + // When the capture policy is ALLOW_CAPTURE_BY_ALL, it is okay to + // remove it from cached capture policy as it is the default value. + mAllowedCapturePolicies.remove(uid); + return; + } else { + mAllowedCapturePolicies.put(uid, capturePolicy); + } + } + synchronized (mPlayerLock) { + for (AudioPlaybackConfiguration apc : mPlayers.values()) { + if (apc.getClientUid() == uid) { + updateAllowedCapturePolicy(apc, capturePolicy); + } + } + } + } + + /** + * Return the capture policy for given uid. + * @param uid the uid to query its cached capture policy. + * @return cached capture policy for given uid or AudioAttributes.ALLOW_CAPTURE_BY_ALL + * if there is not cached capture policy. + */ + public int getAllowedCapturePolicy(int uid) { + return mAllowedCapturePolicies.getOrDefault(uid, AudioAttributes.ALLOW_CAPTURE_BY_ALL); + } + + /** + * Return all cached capture policies. + */ + public HashMap<Integer, Integer> getAllAllowedCapturePolicies() { + return mAllowedCapturePolicies; + } + + private void updateAllowedCapturePolicy(AudioPlaybackConfiguration apc, int capturePolicy) { + AudioAttributes attr = apc.getAudioAttributes(); + if (attr.getAllowedCapturePolicy() >= capturePolicy) { + return; + } + apc.handleAudioAttributesEvent( + new AudioAttributes.Builder(apc.getAudioAttributes()) + .setAllowedCapturePolicy(capturePolicy).build()); + } + // Implementation of AudioPlaybackConfiguration.PlayerDeathMonitor @Override public void playerDeath(int piid) { @@ -331,6 +407,12 @@ public final class PlaybackActivityMonitor // log sEventLogger.dump(pw); } + synchronized (mAllowedCapturePolicies) { + pw.println("\n allowed capture policies:"); + for (HashMap.Entry<Integer, Integer> entry : mAllowedCapturePolicies.entrySet()) { + pw.println(" uid: " + entry.getKey() + " policy: " + entry.getValue()); + } + } } /** diff --git a/services/core/java/com/android/server/pm/ApexManager.java b/services/core/java/com/android/server/pm/ApexManager.java index 4ff37a2040dd..42bc464e943f 100644 --- a/services/core/java/com/android/server/pm/ApexManager.java +++ b/services/core/java/com/android/server/pm/ApexManager.java @@ -291,6 +291,14 @@ public abstract class ApexManager { public abstract boolean restoreCeData(int userId, int rollbackId, String apexPackageName); /** + * Deletes snapshots of the device encrypted apex data directories for the given + * {@code rollbackId}. + * + * @return boolean true if the delete was successful + */ + public abstract boolean destroyDeSnapshots(int rollbackId); + + /** * Dumps various state information to the provided {@link PrintWriter} object. * * @param pw the {@link PrintWriter} object to send information to. @@ -720,6 +728,17 @@ public abstract class ApexManager { } } + @Override + public boolean destroyDeSnapshots(int rollbackId) { + try { + mApexService.destroyDeSnapshots(rollbackId); + return true; + } catch (Exception e) { + Slog.e(TAG, e.getMessage(), e); + return false; + } + } + /** * Dump information about the packages contained in a particular cache * @param packagesCache the cache to print information about. @@ -933,6 +952,11 @@ public abstract class ApexManager { } @Override + public boolean destroyDeSnapshots(int rollbackId) { + throw new UnsupportedOperationException(); + } + + @Override void dump(PrintWriter pw, String packageName) { // No-op } diff --git a/services/core/java/com/android/server/rollback/Rollback.java b/services/core/java/com/android/server/rollback/Rollback.java index cb583cd42412..e0143ae4841b 100644 --- a/services/core/java/com/android/server/rollback/Rollback.java +++ b/services/core/java/com/android/server/rollback/Rollback.java @@ -44,6 +44,7 @@ import android.util.SparseLongArray; import com.android.internal.annotations.GuardedBy; import com.android.internal.util.ArrayUtils; import com.android.internal.util.IndentingPrintWriter; +import com.android.server.pm.ApexManager; import java.io.File; import java.io.IOException; @@ -651,15 +652,23 @@ class Rollback { */ void delete(AppDataRollbackHelper dataHelper) { synchronized (mLock) { + boolean containsApex = false; for (PackageRollbackInfo pkgInfo : info.getPackages()) { - IntArray snapshottedUsers = pkgInfo.getSnapshottedUsers(); - for (int i = 0; i < snapshottedUsers.size(); i++) { - // Destroy app data snapshot. - int userId = snapshottedUsers.get(i); - - dataHelper.destroyAppDataSnapshot(info.getRollbackId(), pkgInfo, userId); + if (pkgInfo.isApex()) { + containsApex = true; + } else { + IntArray snapshottedUsers = pkgInfo.getSnapshottedUsers(); + for (int i = 0; i < snapshottedUsers.size(); i++) { + // Destroy app data snapshot. + int userId = snapshottedUsers.get(i); + + dataHelper.destroyAppDataSnapshot(info.getRollbackId(), pkgInfo, userId); + } } } + if (containsApex) { + ApexManager.getInstance().destroyDeSnapshots(info.getRollbackId()); + } RollbackStore.deleteRollback(this); mState = ROLLBACK_STATE_DELETED; diff --git a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java index 2ef0015f2b7d..0502d0bfa933 100644 --- a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java +++ b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java @@ -1212,7 +1212,7 @@ class ActivityMetricsLogger { final ProtoOutputStream protoOutputStream = new ProtoOutputStream(LAUNCH_OBSERVER_ACTIVITY_RECORD_PROTO_CHUNK_SIZE); // Write this data out as the top-most ActivityRecordProto (i.e. it is not a sub-object). - record.dumpDebug(protoOutputStream); + record.dumpDebug(protoOutputStream, WindowTraceLogLevel.ALL); final byte[] bytes = protoOutputStream.getBytes(); Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 7af097b3f260..df6dfc4d8ffe 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -7506,17 +7506,19 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * Write all fields to an {@code ActivityRecordProto}. This assumes the * {@code ActivityRecordProto} is the outer-most proto data. */ - void dumpDebug(ProtoOutputStream proto) { + void dumpDebug(ProtoOutputStream proto, @WindowTraceLogLevel int logLevel) { writeNameToProto(proto, NAME); - super.dumpDebug(proto, WINDOW_TOKEN, WindowTraceLogLevel.ALL); + super.dumpDebug(proto, WINDOW_TOKEN, logLevel); proto.write(LAST_SURFACE_SHOWING, mLastSurfaceShowing); proto.write(IS_WAITING_FOR_TRANSITION_START, isWaitingForTransitionStart()); - proto.write(IS_ANIMATING, isAnimating()); - if (mThumbnail != null) { + proto.write(IS_ANIMATING, isAnimating(PARENTS)); + if (mThumbnail != null){ mThumbnail.dumpDebug(proto, THUMBNAIL); } proto.write(FILLS_PARENT, mOccludesParent); proto.write(APP_STOPPED, mAppStopped); + proto.write(TRANSLUCENT, !occludesParent()); + proto.write(VISIBLE, mVisible); proto.write(VISIBLE_REQUESTED, mVisibleRequested); proto.write(CLIENT_VISIBLE, mClientVisible); proto.write(DEFER_HIDING_CLIENT, mDeferHidingClient); @@ -7539,24 +7541,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A writeIdentifierToProto(proto, IDENTIFIER); proto.write(STATE, mState.toString()); - proto.write(VISIBLE_REQUESTED, mVisibleRequested); proto.write(FRONT_OF_TASK, isRootOfTask()); if (hasProcess()) { proto.write(PROC_ID, app.getPid()); } - proto.write(TRANSLUCENT, !occludesParent()); - proto.write(VISIBLE, mVisible); } - public void dumpDebug(ProtoOutputStream proto, long fieldId) { - final long token = proto.start(fieldId); - dumpDebug(proto); - proto.end(token); - } - - /** - * Copied from old AppWindowToken. - */ @Override public void dumpDebug(ProtoOutputStream proto, long fieldId, @WindowTraceLogLevel int logLevel) { @@ -7566,36 +7556,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } final long token = proto.start(fieldId); - writeNameToProto(proto, NAME); - super.dumpDebug(proto, WINDOW_TOKEN, logLevel); - proto.write(LAST_SURFACE_SHOWING, mLastSurfaceShowing); - proto.write(IS_WAITING_FOR_TRANSITION_START, isWaitingForTransitionStart()); - proto.write(IS_ANIMATING, isAnimating(PARENTS)); - if (mThumbnail != null){ - mThumbnail.dumpDebug(proto, THUMBNAIL); - } - proto.write(FILLS_PARENT, mOccludesParent); - proto.write(APP_STOPPED, mAppStopped); - proto.write(VISIBLE_REQUESTED, mVisibleRequested); - proto.write(CLIENT_VISIBLE, mClientVisible); - proto.write(DEFER_HIDING_CLIENT, mDeferHidingClient); - proto.write(REPORTED_DRAWN, reportedDrawn); - proto.write(REPORTED_VISIBLE, reportedVisible); - proto.write(NUM_INTERESTING_WINDOWS, mNumInterestingWindows); - proto.write(NUM_DRAWN_WINDOWS, mNumDrawnWindows); - proto.write(ALL_DRAWN, allDrawn); - proto.write(LAST_ALL_DRAWN, mLastAllDrawn); - if (startingWindow != null) { - startingWindow.writeIdentifierToProto(proto, STARTING_WINDOW); - } - proto.write(STARTING_DISPLAYED, startingDisplayed); - proto.write(STARTING_MOVED, startingMoved); - proto.write(VISIBLE_SET_FROM_TRANSFERRED_STARTING_WINDOW, - mVisibleSetFromTransferredStartingWindow); - for (Rect bounds : mFrozenBounds) { - bounds.dumpDebug(proto, FROZEN_BOUNDS); - } - proto.write(VISIBLE, mVisible); + dumpDebug(proto, logLevel); proto.end(token); } diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java index 0d72d84d1649..d5961a881c36 100644 --- a/services/core/java/com/android/server/wm/ActivityStack.java +++ b/services/core/java/com/android/server/wm/ActivityStack.java @@ -60,10 +60,18 @@ import static android.view.WindowManager.TRANSIT_TASK_OPEN_BEHIND; import static android.view.WindowManager.TRANSIT_TASK_TO_BACK; import static android.view.WindowManager.TRANSIT_TASK_TO_FRONT; -import static com.android.server.am.ActivityStackProto.DISPLAY_ID; -import static com.android.server.am.ActivityStackProto.FULLSCREEN; -import static com.android.server.am.ActivityStackProto.RESUMED_ACTIVITY; -import static com.android.server.am.ActivityStackProto.STACK; +import static com.android.server.wm.TaskProto.ACTIVITIES; +import static com.android.server.wm.TaskProto.ACTIVITY_TYPE; +import static com.android.server.wm.TaskProto.BOUNDS; +import static com.android.server.wm.TaskProto.DISPLAYED_BOUNDS; +import static com.android.server.wm.TaskProto.DISPLAY_ID; +import static com.android.server.wm.TaskProto.LAST_NON_FULLSCREEN_BOUNDS; +import static com.android.server.wm.TaskProto.MIN_HEIGHT; +import static com.android.server.wm.TaskProto.MIN_WIDTH; +import static com.android.server.wm.TaskProto.ORIG_ACTIVITY; +import static com.android.server.wm.TaskProto.REAL_ACTIVITY; +import static com.android.server.wm.TaskProto.RESIZE_MODE; +import static com.android.server.wm.TaskProto.RESUMED_ACTIVITY; import static com.android.server.wm.ActivityStack.ActivityState.PAUSED; import static com.android.server.wm.ActivityStack.ActivityState.PAUSING; import static com.android.server.wm.ActivityStack.ActivityState.RESUMED; @@ -107,15 +115,19 @@ import static com.android.server.wm.BoundsAnimationController.NO_PIP_MODE_CHANGE import static com.android.server.wm.BoundsAnimationController.SCHEDULE_PIP_MODE_CHANGED_ON_END; import static com.android.server.wm.BoundsAnimationController.SCHEDULE_PIP_MODE_CHANGED_ON_START; import static com.android.server.wm.DragResizeMode.DRAG_RESIZE_MODE_DOCKED_DIVIDER; -import static com.android.server.wm.StackProto.ADJUSTED_BOUNDS; -import static com.android.server.wm.StackProto.ADJUSTED_FOR_IME; -import static com.android.server.wm.StackProto.ADJUST_DIVIDER_AMOUNT; -import static com.android.server.wm.StackProto.ADJUST_IME_AMOUNT; -import static com.android.server.wm.StackProto.ANIMATING_BOUNDS; -import static com.android.server.wm.StackProto.DEFER_REMOVAL; -import static com.android.server.wm.StackProto.FILLS_PARENT; -import static com.android.server.wm.StackProto.MINIMIZE_AMOUNT; -import static com.android.server.wm.StackProto.WINDOW_CONTAINER; +import static com.android.server.wm.TaskProto.ADJUSTED_BOUNDS; +import static com.android.server.wm.TaskProto.ADJUSTED_FOR_IME; +import static com.android.server.wm.TaskProto.ADJUST_DIVIDER_AMOUNT; +import static com.android.server.wm.TaskProto.ADJUST_IME_AMOUNT; +import static com.android.server.wm.TaskProto.ANIMATING_BOUNDS; +import static com.android.server.wm.TaskProto.DEFER_REMOVAL; +import static com.android.server.wm.TaskProto.FILLS_PARENT; +import static com.android.server.wm.TaskProto.MINIMIZE_AMOUNT; +import static com.android.server.wm.TaskProto.ROOT_TASK_ID; +import static com.android.server.wm.TaskProto.SURFACE_HEIGHT; +import static com.android.server.wm.TaskProto.SURFACE_WIDTH; +import static com.android.server.wm.TaskProto.TASKS; +import static com.android.server.wm.TaskProto.WINDOW_CONTAINER; import static com.android.server.wm.WindowContainer.AnimationFlags.CHILDREN; import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; @@ -4925,49 +4937,66 @@ class ActivityStack extends Task implements BoundsAnimationTarget { @Override public void dumpDebug(ProtoOutputStream proto, long fieldId, @WindowTraceLogLevel int logLevel) { + if (logLevel == WindowTraceLogLevel.CRITICAL && !isVisible()) { + return; + } + final long token = proto.start(fieldId); - dumpDebugInnerStackOnly(proto, STACK, logLevel); - proto.write(com.android.server.am.ActivityStackProto.ID, getRootTaskId()); + super.dumpDebug(proto, WINDOW_CONTAINER, logLevel); + + proto.write(TaskProto.ID, mTaskId); + proto.write(DISPLAY_ID, getDisplayId()); + proto.write(ROOT_TASK_ID, getRootTaskId()); + + for (int i = mChildren.size() - 1; i >= 0; --i) { + final WindowContainer child = mChildren.get(i); + if (child instanceof Task) { + child.dumpDebug(proto, TASKS, logLevel); + } else if (child instanceof ActivityRecord) { + child.dumpDebug(proto, ACTIVITIES, logLevel); + } else { + throw new IllegalStateException("Unknown child type: " + child); + } + } - forAllTasks((t) -> { - t.dumpDebugInner(proto, com.android.server.am.ActivityStackProto.TASKS, logLevel); - }, true /* traverseTopToBottom */, this); if (mResumedActivity != null) { mResumedActivity.writeIdentifierToProto(proto, RESUMED_ACTIVITY); } - proto.write(DISPLAY_ID, getDisplayId()); - if (!matchParentBounds()) { - final Rect bounds = getRequestedOverrideBounds(); - bounds.dumpDebug(proto, com.android.server.am.ActivityStackProto.BOUNDS); + if (realActivity != null) { + proto.write(REAL_ACTIVITY, realActivity.flattenToShortString()); + } + if (origActivity != null) { + proto.write(ORIG_ACTIVITY, origActivity.flattenToShortString()); } + proto.write(ACTIVITY_TYPE, getActivityType()); + proto.write(RESIZE_MODE, mResizeMode); + proto.write(MIN_WIDTH, mMinWidth); + proto.write(MIN_HEIGHT, mMinHeight); - // TODO: Remove, no longer needed with windowingMode. - proto.write(FULLSCREEN, matchParentBounds()); - proto.end(token); - } + proto.write(FILLS_PARENT, matchParentBounds()); - // TODO(proto-merge): Remove once protos for ActivityStack and TaskStack are merged. - void dumpDebugInnerStackOnly(ProtoOutputStream proto, long fieldId, - @WindowTraceLogLevel int logLevel) { - if (logLevel == WindowTraceLogLevel.CRITICAL && !isVisible()) { - return; + if (!matchParentBounds()) { + final Rect bounds = getRequestedOverrideBounds(); + bounds.dumpDebug(proto, BOUNDS); + } + getOverrideDisplayedBounds().dumpDebug(proto, DISPLAYED_BOUNDS); + mAdjustedBounds.dumpDebug(proto, ADJUSTED_BOUNDS); + if (mLastNonFullscreenBounds != null) { + mLastNonFullscreenBounds.dumpDebug(proto, LAST_NON_FULLSCREEN_BOUNDS); } - final long token = proto.start(fieldId); - super.dumpDebug(proto, WINDOW_CONTAINER, logLevel); - proto.write(StackProto.ID, getRootTaskId()); - forAllTasks((t) -> { - t.dumpDebugInnerTaskOnly(proto, StackProto.TASKS, logLevel); - }, true /* traverseTopToBottom */, this); - proto.write(FILLS_PARENT, matchParentBounds()); - getRawBounds().dumpDebug(proto, StackProto.BOUNDS); proto.write(DEFER_REMOVAL, mDeferRemoval); proto.write(MINIMIZE_AMOUNT, mMinimizeAmount); proto.write(ADJUSTED_FOR_IME, mAdjustedForIme); proto.write(ADJUST_IME_AMOUNT, mAdjustImeAmount); proto.write(ADJUST_DIVIDER_AMOUNT, mAdjustDividerAmount); - mAdjustedBounds.dumpDebug(proto, ADJUSTED_BOUNDS); proto.write(ANIMATING_BOUNDS, mBoundsAnimating); + + if (mSurfaceControl != null) { + proto.write(SURFACE_WIDTH, mSurfaceControl.getWidth()); + proto.write(SURFACE_HEIGHT, mSurfaceControl.getHeight()); + } + proto.end(token); } } diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index d6e707795d50..5a5976bf58ad 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -69,6 +69,7 @@ import static com.android.server.am.ActivityManagerService.ANR_TRACE_DIR; import static com.android.server.am.ActivityManagerService.MY_PID; import static com.android.server.am.ActivityManagerService.STOCK_PM_FLAGS; import static com.android.server.am.ActivityManagerService.dumpStackTraces; +import static com.android.server.am.ActivityManagerServiceDumpActivitiesProto.ROOT_WINDOW_CONTAINER; import static com.android.server.am.ActivityManagerServiceDumpProcessesProto.CONFIG_WILL_CHANGE; import static com.android.server.am.ActivityManagerServiceDumpProcessesProto.CONTROLLER; import static com.android.server.am.ActivityManagerServiceDumpProcessesProto.CURRENT_TRACKER; @@ -257,7 +258,6 @@ import com.android.server.SystemServiceManager; import com.android.server.UiThread; import com.android.server.Watchdog; import com.android.server.am.ActivityManagerService; -import com.android.server.am.ActivityManagerServiceDumpActivitiesProto; import com.android.server.am.ActivityManagerServiceDumpProcessesProto; import com.android.server.am.AppTimeTracker; import com.android.server.am.BaseErrorDialog; @@ -6963,10 +6963,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { public void writeActivitiesToProto(ProtoOutputStream proto) { synchronized (mGlobalLock) { // The output proto of "activity --proto activities" - // is ActivityManagerServiceDumpActivitiesProto - mRootWindowContainer.dumpDebug(proto, - ActivityManagerServiceDumpActivitiesProto.ACTIVITY_STACK_SUPERVISOR, - WindowTraceLogLevel.ALL); + mRootWindowContainer.dumpDebug( + proto, ROOT_WINDOW_CONTAINER, WindowTraceLogLevel.ALL); } } diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 81af0fe24ba7..16ac9fb41f30 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -17,6 +17,7 @@ package com.android.server.wm; import static android.app.ActivityTaskManager.INVALID_STACK_ID; +import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; @@ -83,10 +84,9 @@ import static android.view.WindowManager.TRANSIT_ACTIVITY_OPEN; import static android.view.WindowManager.TRANSIT_TASK_OPEN; import static android.view.WindowManager.TRANSIT_TASK_TO_FRONT; -import static com.android.server.am.ActivityDisplayProto.DISPLAY; -import static com.android.server.am.ActivityDisplayProto.FOCUSED_STACK_ID; -import static com.android.server.am.ActivityDisplayProto.RESUMED_ACTIVITY; -import static com.android.server.am.ActivityDisplayProto.SINGLE_TASK_INSTANCE; +import static com.android.server.wm.DisplayContentProto.FOCUSED_ROOT_TASK_ID; +import static com.android.server.wm.DisplayContentProto.RESUMED_ACTIVITY; +import static com.android.server.wm.DisplayContentProto.SINGLE_TASK_INSTANCE; import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM; import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG; import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT; @@ -111,7 +111,7 @@ import static com.android.server.wm.DisplayContentProto.OVERLAY_WINDOWS; import static com.android.server.wm.DisplayContentProto.ROOT_DISPLAY_AREA; import static com.android.server.wm.DisplayContentProto.ROTATION; import static com.android.server.wm.DisplayContentProto.SCREEN_ROTATION_ANIMATION; -import static com.android.server.wm.DisplayContentProto.STACKS; +import static com.android.server.wm.DisplayContentProto.TASKS; import static com.android.server.wm.DisplayContentProto.WINDOW_CONTAINER; import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ADD_REMOVE; import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS; @@ -2733,30 +2733,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo public void dumpDebug(ProtoOutputStream proto, long fieldId, @WindowTraceLogLevel int logLevel) { - final long token = proto.start(fieldId); - dumpDebugInner(proto, DISPLAY, logLevel); - proto.write(com.android.server.am.ActivityDisplayProto.ID, mDisplayId); - proto.write(SINGLE_TASK_INSTANCE, mSingleTaskInstance); - final ActivityStack focusedStack = getFocusedStack(); - if (focusedStack != null) { - proto.write(FOCUSED_STACK_ID, focusedStack.getRootTaskId()); - final ActivityRecord focusedActivity = focusedStack.getDisplay().getResumedActivity(); - if (focusedActivity != null) { - focusedActivity.writeIdentifierToProto(proto, RESUMED_ACTIVITY); - } - } else { - proto.write(FOCUSED_STACK_ID, INVALID_STACK_ID); - } - for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) { - final ActivityStack stack = getStackAt(stackNdx); - stack.dumpDebug(proto, com.android.server.am.ActivityDisplayProto.STACKS, logLevel); - } - proto.end(token); - } - - // TODO(proto-merge): Remove once protos for ActivityDisplay and DisplayContent are merged. - public void dumpDebugInner(ProtoOutputStream proto, long fieldId, - @WindowTraceLogLevel int logLevel) { // Critical log level logs only visible elements to mitigate performance overheard if (logLevel == WindowTraceLogLevel.CRITICAL && !isVisible()) { return; @@ -2764,11 +2740,12 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final long token = proto.start(fieldId); super.dumpDebug(proto, WINDOW_CONTAINER, logLevel); + proto.write(ID, mDisplayId); mRootDisplayArea.dumpDebug(proto, ROOT_DISPLAY_AREA, logLevel); - for (int stackNdx = mTaskContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) { - final ActivityStack stack = mTaskContainers.getChildAt(stackNdx); - stack.dumpDebugInnerStackOnly(proto, STACKS, logLevel); + for (int i = mTaskContainers.getChildCount() - 1; i >= 0; --i) { + final ActivityStack stack = mTaskContainers.getChildAt(i); + stack.dumpDebug(proto, TASKS, logLevel); } mDividerControllerLocked.dumpDebug(proto, DOCKED_STACK_DIVIDER_CONTROLLER); for (int i = mOverlayContainers.getChildCount() - 1; i >= 0; --i) { @@ -2796,6 +2773,19 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo for (int i = mChangingApps.size() - 1; i >= 0; i--) { mChangingApps.valueAt(i).writeIdentifierToProto(proto, CHANGING_APPS); } + + proto.write(SINGLE_TASK_INSTANCE, mSingleTaskInstance); + final ActivityStack focusedStack = getFocusedStack(); + if (focusedStack != null) { + proto.write(FOCUSED_ROOT_TASK_ID, focusedStack.getRootTaskId()); + final ActivityRecord focusedActivity = focusedStack.getDisplay().getResumedActivity(); + if (focusedActivity != null) { + focusedActivity.writeIdentifierToProto(proto, RESUMED_ACTIVITY); + } + } else { + proto.write(FOCUSED_ROOT_TASK_ID, INVALID_TASK_ID); + } + proto.end(token); } diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 40c335b0592b..c78707a2204e 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -335,6 +335,13 @@ public class DisplayPolicy { IApplicationToken mFocusedApp; + // The states of decor windows from the last layout. These are used to generate another display + // layout in different bounds but with the same states. + private boolean mLastNavVisible; + private boolean mLastNavTranslucent; + private boolean mLastNavAllowedHidden; + private boolean mLastNotificationShadeForcesShowingNavigation; + int mLastSystemUiFlags; // Bits that we are in the process of clearing, so we want to prevent // them from being set by applications until everything has been updated @@ -1425,6 +1432,46 @@ public class DisplayPolicy { } } + private void simulateLayoutDecorWindow(WindowState win, DisplayFrames displayFrames, int uiMode, + InsetsState insetsState, WindowFrames simulatedWindowFrames, Runnable layout) { + win.setSimulatedWindowFrames(simulatedWindowFrames); + try { + layout.run(); + } finally { + win.setSimulatedWindowFrames(null); + } + mDisplayContent.getInsetsStateController().computeSimulatedState(insetsState, win, + displayFrames, simulatedWindowFrames); + } + + /** + * Computes the frames of display (its logical size, rotation and cutout should already be set) + * used to layout window. The result of display frames and insets state should be the same as + * using {@link #beginLayoutLw}, but this method only changes the given display frames, insets + * state and some temporal states. In other words, it doesn't change the window frames used to + * show on screen. + */ + void simulateLayoutDisplay(DisplayFrames displayFrames, InsetsState insetsState, int uiMode) { + displayFrames.onBeginLayout(); + final WindowFrames simulatedWindowFrames = new WindowFrames(); + if (mNavigationBar != null) { + simulateLayoutDecorWindow( + mNavigationBar, displayFrames, uiMode, insetsState, simulatedWindowFrames, + () -> layoutNavigationBar(displayFrames, uiMode, mLastNavVisible, + mLastNavTranslucent, mLastNavAllowedHidden, + mLastNotificationShadeForcesShowingNavigation, + false /* isRealLayout */)); + } + if (mStatusBar != null) { + simulateLayoutDecorWindow( + mStatusBar, displayFrames, uiMode, insetsState, simulatedWindowFrames, + () -> layoutStatusBar(displayFrames, mLastSystemUiFlags, + false /* isRealLayout */)); + } + layoutScreenDecorWindows(displayFrames, simulatedWindowFrames); + postAdjustDisplayFrames(displayFrames); + } + /** * Called when layout of the windows is about to start. * @@ -1483,14 +1530,23 @@ public class DisplayPolicy { navVisible |= !canHideNavigationBar(); boolean updateSysUiVisibility = layoutNavigationBar(displayFrames, uiMode, navVisible, - navTranslucent, navAllowedHidden, notificationShadeForcesShowingNavigation); + navTranslucent, navAllowedHidden, notificationShadeForcesShowingNavigation, + true /* isRealLayout */); if (DEBUG_LAYOUT) Slog.i(TAG, "mDock rect:" + displayFrames.mDock); - updateSysUiVisibility |= layoutStatusBar(displayFrames, sysui, isKeyguardShowing); + updateSysUiVisibility |= layoutStatusBar(displayFrames, sysui, true /* isRealLayout */); if (updateSysUiVisibility) { updateSystemUiVisibilityLw(); } - layoutScreenDecorWindows(displayFrames); + layoutScreenDecorWindows(displayFrames, null /* transientFrames */); + postAdjustDisplayFrames(displayFrames); + mLastNavVisible = navVisible; + mLastNavTranslucent = navTranslucent; + mLastNavAllowedHidden = navAllowedHidden; + mLastNotificationShadeForcesShowingNavigation = notificationShadeForcesShowingNavigation; + } + /** Enforces the last layout policy for display frames. */ + private void postAdjustDisplayFrames(DisplayFrames displayFrames) { if (displayFrames.mDisplayCutoutSafe.top > displayFrames.mUnrestricted.top) { // Make sure that the zone we're avoiding for the cutout is at least as tall as the // status bar; otherwise fullscreen apps will end up cutting halfway into the status @@ -1509,7 +1565,15 @@ public class DisplayPolicy { displayFrames.mContent.inset(mForwardedInsets); } - private void layoutScreenDecorWindows(DisplayFrames displayFrames) { + /** + * Layout the decor windows with {@link #PRIVATE_FLAG_IS_SCREEN_DECOR}. + * + * @param displayFrames The display frames to be layouted. + * @param simulatedFrames Non-null if the caller only needs the result of display frames (see + * {@link WindowState#mSimulatedWindowFrames}). + */ + private void layoutScreenDecorWindows(DisplayFrames displayFrames, + WindowFrames simulatedFrames) { if (mScreenDecorWindows.isEmpty()) { return; } @@ -1527,17 +1591,24 @@ public class DisplayPolicy { continue; } - w.getWindowFrames().setFrames(displayFrames.mUnrestricted /* parentFrame */, + final boolean isSimulatedLayout = simulatedFrames != null; + if (isSimulatedLayout) { + w.setSimulatedWindowFrames(simulatedFrames); + } + final WindowFrames windowFrames = w.getLayoutingWindowFrames(); + windowFrames.setFrames(displayFrames.mUnrestricted /* parentFrame */, displayFrames.mUnrestricted /* displayFrame */, displayFrames.mUnrestricted /* contentFrame */, displayFrames.mUnrestricted /* visibleFrame */, sTmpRect /* decorFrame */, displayFrames.mUnrestricted /* stableFrame */); - w.getWindowFrames().setDisplayCutout(displayFrames.mDisplayCutout); - w.computeFrameLw(); - if (w.getControllableInsetProvider() != null) { - w.getControllableInsetProvider().updateSourceFrame(); + try { + w.computeFrame(displayFrames); + } finally { + if (isSimulatedLayout) { + w.setSimulatedWindowFrames(null); + } } - final Rect frame = w.getFrameLw(); + final Rect frame = windowFrames.mFrame; if (frame.left <= 0 && frame.top <= 0) { // Docked at left or top. @@ -1580,29 +1651,21 @@ public class DisplayPolicy { displayFrames.mContent.set(dockFrame); } - private boolean layoutStatusBar(DisplayFrames displayFrames, int sysui, - boolean isKeyguardShowing) { + private boolean layoutStatusBar(DisplayFrames displayFrames, int sysui, boolean isRealLayout) { // decide where the status bar goes ahead of time if (mStatusBar == null) { return false; } // apply any navigation bar insets sTmpRect.setEmpty(); - final WindowFrames windowFrames = mStatusBar.getWindowFrames(); + final WindowFrames windowFrames = mStatusBar.getLayoutingWindowFrames(); windowFrames.setFrames(displayFrames.mUnrestricted /* parentFrame */, displayFrames.mUnrestricted /* displayFrame */, displayFrames.mStable /* contentFrame */, displayFrames.mStable /* visibleFrame */, sTmpRect /* decorFrame */, displayFrames.mStable /* stableFrame */); - windowFrames.setDisplayCutout(displayFrames.mDisplayCutout); - // Let the status bar determine its size. - mStatusBar.computeFrameLw(); - - // Update the source frame to provide insets to other windows during layout. - if (mStatusBar.getControllableInsetProvider() != null) { - mStatusBar.getControllableInsetProvider().updateSourceFrame(); - } + mStatusBar.computeFrame(displayFrames); // For layout, the status bar is always at the top with our fixed height. displayFrames.mStable.top = displayFrames.mUnrestricted.top @@ -1611,12 +1674,14 @@ public class DisplayPolicy { displayFrames.mStable.top = Math.max(displayFrames.mStable.top, displayFrames.mDisplayCutoutSafe.top); - // Tell the bar controller where the collapsed status bar content is - sTmpRect.set(mStatusBar.getContentFrameLw()); - sTmpRect.intersect(displayFrames.mDisplayCutoutSafe); - sTmpRect.top = mStatusBar.getContentFrameLw().top; // Ignore top display cutout inset - sTmpRect.bottom = displayFrames.mStable.top; // Use collapsed status bar size - mStatusBarController.setContentFrame(sTmpRect); + if (isRealLayout) { + // Tell the bar controller where the collapsed status bar content is. + sTmpRect.set(windowFrames.mContentFrame); + sTmpRect.intersect(displayFrames.mDisplayCutoutSafe); + sTmpRect.top = windowFrames.mContentFrame.top; // Ignore top display cutout inset + sTmpRect.bottom = displayFrames.mStable.top; // Use collapsed status bar size + mStatusBarController.setContentFrame(sTmpRect); + } boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0 || mDisplayContent.getInsetsPolicy().isTransient(ITYPE_STATUS_BAR); @@ -1651,7 +1716,7 @@ public class DisplayPolicy { private boolean layoutNavigationBar(DisplayFrames displayFrames, int uiMode, boolean navVisible, boolean navTranslucent, boolean navAllowedHidden, - boolean statusBarForcesShowingNavigation) { + boolean statusBarForcesShowingNavigation, boolean isRealLayout) { if (mNavigationBar == null) { return false; } @@ -1665,13 +1730,13 @@ public class DisplayPolicy { final int displayHeight = displayFrames.mDisplayHeight; final int displayWidth = displayFrames.mDisplayWidth; final Rect dockFrame = displayFrames.mDock; - mNavigationBarPosition = navigationBarPosition(displayWidth, displayHeight, rotation); + final int navBarPosition = navigationBarPosition(displayWidth, displayHeight, rotation); final Rect cutoutSafeUnrestricted = sTmpRect; cutoutSafeUnrestricted.set(displayFrames.mUnrestricted); cutoutSafeUnrestricted.intersectUnchecked(displayFrames.mDisplayCutoutSafe); - if (mNavigationBarPosition == NAV_BAR_BOTTOM) { + if (navBarPosition == NAV_BAR_BOTTOM) { // It's a system nav bar or a portrait screen; nav bar goes on bottom. final int top = cutoutSafeUnrestricted.bottom - getNavigationBarHeight(rotation, uiMode); @@ -1695,7 +1760,7 @@ public class DisplayPolicy { // of animating on or off, then we can tell the app that it is covered by it. displayFrames.mSystem.bottom = top; } - } else if (mNavigationBarPosition == NAV_BAR_RIGHT) { + } else if (navBarPosition == NAV_BAR_RIGHT) { // Landscape screen; nav bar goes to the right. final int left = cutoutSafeUnrestricted.right - getNavigationBarWidth(rotation, uiMode); @@ -1717,7 +1782,7 @@ public class DisplayPolicy { // animating on or off, then we can tell the app that it is covered by it. displayFrames.mSystem.right = left; } - } else if (mNavigationBarPosition == NAV_BAR_LEFT) { + } else if (navBarPosition == NAV_BAR_LEFT) { // Seascape screen; nav bar goes to the left. final int right = cutoutSafeUnrestricted.left + getNavigationBarWidth(rotation, uiMode); @@ -1748,17 +1813,17 @@ public class DisplayPolicy { displayFrames.mContent.set(dockFrame); // And compute the final frame. sTmpRect.setEmpty(); - mNavigationBar.getWindowFrames().setFrames(navigationFrame /* parentFrame */, + final WindowFrames windowFrames = mNavigationBar.getLayoutingWindowFrames(); + windowFrames.setFrames(navigationFrame /* parentFrame */, navigationFrame /* displayFrame */, displayFrames.mDisplayCutoutSafe /* contentFrame */, navigationFrame /* visibleFrame */, sTmpRect /* decorFrame */, navigationFrame /* stableFrame */); - mNavigationBar.getWindowFrames().setDisplayCutout(displayFrames.mDisplayCutout); - mNavigationBar.computeFrameLw(); - if (mNavigationBar.getControllableInsetProvider() != null) { - mNavigationBar.getControllableInsetProvider().updateSourceFrame(); + mNavigationBar.computeFrame(displayFrames); + if (isRealLayout) { + mNavigationBarPosition = navBarPosition; + mNavigationBarController.setContentFrame(windowFrames.mContentFrame); } - mNavigationBarController.setContentFrame(mNavigationBar.getContentFrameLw()); if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + navigationFrame); return mNavigationBarController.checkHiddenLw(); @@ -1886,7 +1951,6 @@ public class DisplayPolicy { final Rect sf = windowFrames.mStableFrame; dcf.setEmpty(); windowFrames.setParentFrameWasClippedByDisplayCutout(false); - windowFrames.setDisplayCutout(displayFrames.mDisplayCutout); final boolean hasNavBar = hasNavigationBar() && mNavigationBar != null && mNavigationBar.isVisibleLw(); @@ -2311,10 +2375,7 @@ public class DisplayPolicy { windowFrames.setContentChanged(true); } - win.computeFrameLw(); - if (win.getControllableInsetProvider() != null) { - win.getControllableInsetProvider().updateSourceFrame(); - } + win.computeFrame(displayFrames); // Dock windows carve out the bottom of the screen, so normal windows // can't appear underneath them. if (type == TYPE_INPUT_METHOD && win.isVisibleLw() diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java index e6c1969d4a22..0418afaf033a 100644 --- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java +++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java @@ -186,6 +186,17 @@ class InsetsSourceProvider { } } + /** @return A new source computed by the specified window frame in the given display frames. */ + InsetsSource createSimulatedSource(DisplayFrames displayFrames, WindowFrames windowFrames) { + final InsetsSource source = new InsetsSource(mSource); + mTmpRect.set(windowFrames.mFrame); + if (mFrameProvider != null) { + mFrameProvider.accept(displayFrames, mWin, mTmpRect); + } + source.setFrame(mTmpRect); + return source; + } + /** * Called when a layout pass has occurred. */ diff --git a/services/core/java/com/android/server/wm/InsetsStateController.java b/services/core/java/com/android/server/wm/InsetsStateController.java index 289ac4cd5d44..caaa4305406c 100644 --- a/services/core/java/com/android/server/wm/InsetsStateController.java +++ b/services/core/java/com/android/server/wm/InsetsStateController.java @@ -179,6 +179,24 @@ class InsetsStateController { } } + /** + * Computes insets state of the insets provider window in the display frames. + * + * @param state The output state. + * @param win The owner window of insets provider. + * @param displayFrames The display frames to create insets source. + * @param windowFrames The specified frames to represent the owner window. + */ + void computeSimulatedState(InsetsState state, WindowState win, DisplayFrames displayFrames, + WindowFrames windowFrames) { + for (int i = mProviders.size() - 1; i >= 0; i--) { + final InsetsSourceProvider provider = mProviders.valueAt(i); + if (provider.mWin == win) { + state.addSource(provider.createSimulatedSource(displayFrames, windowFrames)); + } + } + } + boolean isFakeTarget(@InternalInsetsType int type, InsetsControlTarget target) { return mTypeFakeControlTargetMap.get(type) == target; } diff --git a/services/core/java/com/android/server/wm/KeyguardController.java b/services/core/java/com/android/server/wm/KeyguardController.java index ad65e101fd15..00947d766e89 100644 --- a/services/core/java/com/android/server/wm/KeyguardController.java +++ b/services/core/java/com/android/server/wm/KeyguardController.java @@ -31,11 +31,11 @@ import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_TO_SHADE; import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER; -import static com.android.server.am.KeyguardControllerProto.AOD_SHOWING; -import static com.android.server.am.KeyguardControllerProto.KEYGUARD_OCCLUDED_STATES; -import static com.android.server.am.KeyguardControllerProto.KEYGUARD_SHOWING; -import static com.android.server.am.KeyguardOccludedProto.DISPLAY_ID; -import static com.android.server.am.KeyguardOccludedProto.KEYGUARD_OCCLUDED; +import static com.android.server.wm.KeyguardControllerProto.AOD_SHOWING; +import static com.android.server.wm.KeyguardControllerProto.KEYGUARD_OCCLUDED_STATES; +import static com.android.server.wm.KeyguardControllerProto.KEYGUARD_SHOWING; +import static com.android.server.wm.KeyguardOccludedProto.DISPLAY_ID; +import static com.android.server.wm.KeyguardOccludedProto.KEYGUARD_OCCLUDED; import static com.android.server.wm.ActivityStackSupervisor.PRESERVE_WINDOWS; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME; diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index a13399bcb69c..2fdcbc9083f6 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -16,7 +16,6 @@ package com.android.server.wm; -import static android.app.ActivityTaskManager.INVALID_STACK_ID; import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; @@ -41,12 +40,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; import static android.view.WindowManager.TRANSIT_CRASHING_ACTIVITY_CLOSE; import static android.view.WindowManager.TRANSIT_SHOW_SINGLE_TASK_DISPLAY; -import static com.android.server.am.ActivityStackSupervisorProto.FOCUSED_STACK_ID; -import static com.android.server.am.ActivityStackSupervisorProto.IS_HOME_RECENTS_COMPONENT; -import static com.android.server.am.ActivityStackSupervisorProto.KEYGUARD_CONTROLLER; -import static com.android.server.am.ActivityStackSupervisorProto.PENDING_ACTIVITIES; -import static com.android.server.am.ActivityStackSupervisorProto.RESUMED_ACTIVITY; -import static com.android.server.am.ActivityStackSupervisorProto.ROOT_WINDOW_CONTAINER; import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT; import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; import static com.android.server.wm.ActivityStack.ActivityState.PAUSED; @@ -74,6 +67,9 @@ import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION; import static com.android.server.wm.ProtoLogGroup.WM_SHOW_SURFACE_ALLOC; import static com.android.server.wm.ProtoLogGroup.WM_SHOW_TRANSACTIONS; import static com.android.server.wm.RootWindowContainerProto.DISPLAYS; +import static com.android.server.wm.RootWindowContainerProto.IS_HOME_RECENTS_COMPONENT; +import static com.android.server.wm.RootWindowContainerProto.KEYGUARD_CONTROLLER; +import static com.android.server.wm.RootWindowContainerProto.PENDING_ACTIVITIES; import static com.android.server.wm.RootWindowContainerProto.WINDOWS; import static com.android.server.wm.RootWindowContainerProto.WINDOW_CONTAINER; import static com.android.server.wm.Task.REPARENT_LEAVE_STACK_IN_PLACE; @@ -1278,7 +1274,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } - public void dumpDebugInner(ProtoOutputStream proto, long fieldId, + @Override + public void dumpDebug(ProtoOutputStream proto, long fieldId, @WindowTraceLogLevel int logLevel) { if (logLevel == WindowTraceLogLevel.CRITICAL && !isVisible()) { return; @@ -1290,14 +1287,20 @@ class RootWindowContainer extends WindowContainer<DisplayContent> final int count = mChildren.size(); for (int i = 0; i < count; ++i) { final DisplayContent displayContent = mChildren.get(i); - displayContent.dumpDebugInner(proto, DISPLAYS, logLevel); + displayContent.dumpDebug(proto, DISPLAYS, logLevel); } } if (logLevel == WindowTraceLogLevel.ALL) { forAllWindows((w) -> { - w.writeIdentifierToProto(proto, WINDOWS); + w.dumpDebug(proto, WINDOWS, logLevel); }, true); } + + mStackSupervisor.getKeyguardController().dumpDebug(proto, KEYGUARD_CONTROLLER); + proto.write(IS_HOME_RECENTS_COMPONENT, + mStackSupervisor.mRecentTasks.isRecentsComponentHomeActivity(mCurrentUser)); + mService.getActivityStartController().dumpDebug(proto, PENDING_ACTIVITIES); + proto.end(token); } @@ -3541,15 +3544,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } - public void dumpDisplays(PrintWriter pw) { - for (int i = getChildCount() - 1; i >= 0; --i) { - final DisplayContent display = getChildAt(i); - pw.print("[id:" + display.mDisplayId + " stacks:"); - display.dumpStacks(pw); - pw.print("]"); - } - } - boolean dumpActivities(FileDescriptor fd, PrintWriter pw, boolean dumpAll, boolean dumpClient, String dumpPackage) { boolean printed = false; @@ -3578,34 +3572,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> return printed; } - @Override - public void dumpDebug(ProtoOutputStream proto, long fieldId, - @WindowTraceLogLevel int logLevel) { - final long token = proto.start(fieldId); - dumpDebugInner(proto, ROOT_WINDOW_CONTAINER, logLevel); - for (int displayNdx = 0; displayNdx < getChildCount(); ++displayNdx) { - final DisplayContent displayContent = getChildAt(displayNdx); - displayContent.dumpDebug(proto, - com.android.server.am.ActivityStackSupervisorProto.DISPLAYS, logLevel); - } - mStackSupervisor.getKeyguardController().dumpDebug(proto, KEYGUARD_CONTROLLER); - // TODO(b/111541062): Update tests to look for resumed activities on all displays - final ActivityStack focusedStack = getTopDisplayFocusedStack(); - if (focusedStack != null) { - proto.write(FOCUSED_STACK_ID, focusedStack.getRootTaskId()); - final ActivityRecord focusedActivity = focusedStack.getDisplay().getResumedActivity(); - if (focusedActivity != null) { - focusedActivity.writeIdentifierToProto(proto, RESUMED_ACTIVITY); - } - } else { - proto.write(FOCUSED_STACK_ID, INVALID_STACK_ID); - } - proto.write(IS_HOME_RECENTS_COMPONENT, - mStackSupervisor.mRecentTasks.isRecentsComponentHomeActivity(mCurrentUser)); - mService.getActivityStartController().dumpDebug(proto, PENDING_ACTIVITIES); - proto.end(token); - } - private final class SleepTokenImpl extends ActivityTaskManagerInternal.SleepToken { private final String mTag; private final long mAcquireTime; diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 28dc2a42da2a..87c91ef6b96c 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -61,17 +61,6 @@ import static android.view.SurfaceControl.METADATA_TASK_ID; import static com.android.internal.policy.DecorView.DECOR_SHADOW_FOCUSED_HEIGHT_IN_DIP; import static com.android.internal.policy.DecorView.DECOR_SHADOW_UNFOCUSED_HEIGHT_IN_DIP; -import static com.android.server.am.TaskRecordProto.ACTIVITIES; -import static com.android.server.am.TaskRecordProto.ACTIVITY_TYPE; -import static com.android.server.am.TaskRecordProto.FULLSCREEN; -import static com.android.server.am.TaskRecordProto.LAST_NON_FULLSCREEN_BOUNDS; -import static com.android.server.am.TaskRecordProto.MIN_HEIGHT; -import static com.android.server.am.TaskRecordProto.MIN_WIDTH; -import static com.android.server.am.TaskRecordProto.ORIG_ACTIVITY; -import static com.android.server.am.TaskRecordProto.REAL_ACTIVITY; -import static com.android.server.am.TaskRecordProto.RESIZE_MODE; -import static com.android.server.am.TaskRecordProto.STACK_ID; -import static com.android.server.am.TaskRecordProto.TASK; import static com.android.server.wm.ActivityRecord.STARTING_WINDOW_SHOWN; import static com.android.server.wm.ActivityStack.ActivityState.RESUMED; import static com.android.server.wm.ActivityStackSupervisor.ON_TOP; @@ -90,7 +79,6 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLAS import static com.android.server.wm.ActivityTaskManagerService.TAG_STACK; import static com.android.server.wm.DragResizeMode.DRAG_RESIZE_MODE_DOCKED_DIVIDER; import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ADD_REMOVE; -import static com.android.server.wm.TaskProto.ACTIVITY; import static com.android.server.wm.TaskProto.DISPLAYED_BOUNDS; import static com.android.server.wm.TaskProto.FILLS_PARENT; import static com.android.server.wm.TaskProto.SURFACE_HEIGHT; @@ -3160,29 +3148,6 @@ class Task extends WindowContainer<WindowContainer> { } } - // TODO(proto-merge): Remove once protos for TaskRecord and Task are merged. - void dumpDebugInnerTaskOnly(ProtoOutputStream proto, long fieldId, - @WindowTraceLogLevel int logLevel) { - if (logLevel == WindowTraceLogLevel.CRITICAL && !isVisible()) { - return; - } - - final long token = proto.start(fieldId); - super.dumpDebug(proto, WINDOW_CONTAINER, logLevel); - proto.write(TaskProto.ID, mTaskId); - forAllActivities((r) -> { - r.dumpDebug(proto, ACTIVITY); - }); - proto.write(FILLS_PARENT, matchParentBounds()); - getBounds().dumpDebug(proto, TaskProto.BOUNDS); - mOverrideDisplayedBounds.dumpDebug(proto, DISPLAYED_BOUNDS); - if (mSurfaceControl != null) { - proto.write(SURFACE_WIDTH, mSurfaceControl.getWidth()); - proto.write(SURFACE_HEIGHT, mSurfaceControl.getHeight()); - } - proto.end(token); - } - @Override void dump(PrintWriter pw, String prefix, boolean dumpAll) { super.dump(pw, prefix, dumpAll); @@ -3395,43 +3360,6 @@ class Task extends WindowContainer<WindowContainer> { return toString(); } - void dumpDebugInner(ProtoOutputStream proto, long fieldId, - @WindowTraceLogLevel int logLevel) { - if (logLevel == WindowTraceLogLevel.CRITICAL && !isVisible()) { - return; - } - - final long token = proto.start(fieldId); - dumpDebugInnerTaskOnly(proto, TASK, logLevel); - proto.write(com.android.server.am.TaskRecordProto.ID, mTaskId); - - forAllActivities((r) -> { - r.dumpDebug(proto, ACTIVITIES); - }); - proto.write(STACK_ID, getRootTaskId()); - if (mLastNonFullscreenBounds != null) { - mLastNonFullscreenBounds.dumpDebug(proto, LAST_NON_FULLSCREEN_BOUNDS); - } - if (realActivity != null) { - proto.write(REAL_ACTIVITY, realActivity.flattenToShortString()); - } - if (origActivity != null) { - proto.write(ORIG_ACTIVITY, origActivity.flattenToShortString()); - } - proto.write(ACTIVITY_TYPE, getActivityType()); - proto.write(RESIZE_MODE, mResizeMode); - // TODO: Remove, no longer needed with windowingMode. - proto.write(FULLSCREEN, matchParentBounds()); - - if (!matchParentBounds()) { - final Rect bounds = getRequestedOverrideBounds(); - bounds.dumpDebug(proto, com.android.server.am.TaskRecordProto.BOUNDS); - } - proto.write(MIN_WIDTH, mMinWidth); - proto.write(MIN_HEIGHT, mMinHeight); - proto.end(token); - } - /** @see #getNumRunningActivities(TaskActivitiesReport) */ static class TaskActivitiesReport implements Consumer<ActivityRecord> { int numRunning; diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 563bb26a280f..98c584fc743a 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -5912,7 +5912,7 @@ public class WindowManagerService extends IWindowManager.Stub */ void dumpDebugLocked(ProtoOutputStream proto, @WindowTraceLogLevel int logLevel) { mPolicy.dumpDebug(proto, POLICY); - mRoot.dumpDebugInner(proto, ROOT_WINDOW_CONTAINER, logLevel); + mRoot.dumpDebug(proto, ROOT_WINDOW_CONTAINER, logLevel); final DisplayContent topFocusedDisplayContent = mRoot.getTopFocusedDisplayContent(); if (topFocusedDisplayContent.mCurrentFocus != null) { topFocusedDisplayContent.mCurrentFocus.writeIdentifierToProto(proto, FOCUSED_WINDOW); diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 1faf48fadad7..42e5bbc1c1ee 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -417,6 +417,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP private final WindowFrames mWindowFrames = new WindowFrames(); + /** The frames used to compute a temporal layout appearance. */ + private WindowFrames mSimulatedWindowFrames; + /** * Usually empty. Set to the task's tempInsetFrame. See *{@link android.app.IActivityTaskManager#resizeDockedStack}. @@ -972,6 +975,16 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP return super.getDisplayedBounds(); } + void computeFrame(DisplayFrames displayFrames) { + getLayoutingWindowFrames().setDisplayCutout(displayFrames.mDisplayCutout); + computeFrameLw(); + // Update the source frame to provide insets to other windows during layout. If the + // simulated frames exist, then this is not computing a stable result so just skip. + if (mControllableInsetProvider != null && mSimulatedWindowFrames == null) { + mControllableInsetProvider.updateSourceFrame(); + } + } + @Override public void computeFrameLw() { if (mWillReplaceWindow && (mAnimatingExit || !mReplacingRemoveRequested)) { @@ -987,6 +1000,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP final boolean isFullscreenAndFillsDisplay = !inMultiWindowMode() && matchesDisplayBounds(); final boolean windowsAreFloating = task != null && task.isFloating(); final DisplayContent dc = getDisplayContent(); + final WindowFrames windowFrames = getLayoutingWindowFrames(); mInsetFrame.set(getBounds()); @@ -1008,43 +1022,43 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP imeWin != null && imeWin.isVisibleNow() && isInputMethodAdjustTarget; if (isFullscreenAndFillsDisplay || layoutInParentFrame()) { // We use the parent frame as the containing frame for fullscreen and child windows - mWindowFrames.mContainingFrame.set(mWindowFrames.mParentFrame); - layoutDisplayFrame = mWindowFrames.mDisplayFrame; - layoutContainingFrame = mWindowFrames.mParentFrame; + windowFrames.mContainingFrame.set(windowFrames.mParentFrame); + layoutDisplayFrame = windowFrames.mDisplayFrame; + layoutContainingFrame = windowFrames.mParentFrame; layoutXDiff = 0; layoutYDiff = 0; } else { - mWindowFrames.mContainingFrame.set(getDisplayedBounds()); + windowFrames.mContainingFrame.set(getDisplayedBounds()); if (mActivityRecord != null && !mActivityRecord.mFrozenBounds.isEmpty()) { // If the bounds are frozen, we still want to translate the window freely and only // freeze the size. Rect frozen = mActivityRecord.mFrozenBounds.peek(); - mWindowFrames.mContainingFrame.right = - mWindowFrames.mContainingFrame.left + frozen.width(); - mWindowFrames.mContainingFrame.bottom = - mWindowFrames.mContainingFrame.top + frozen.height(); + windowFrames.mContainingFrame.right = + windowFrames.mContainingFrame.left + frozen.width(); + windowFrames.mContainingFrame.bottom = + windowFrames.mContainingFrame.top + frozen.height(); } // IME is up and obscuring this window. Adjust the window position so it is visible. if (isImeTarget) { if (inFreeformWindowingMode()) { // Push the freeform window up to make room for the IME. However, don't push // it up past the top of the screen. - final int bottomOverlap = mWindowFrames.mContainingFrame.bottom - - mWindowFrames.mVisibleFrame.bottom; + final int bottomOverlap = windowFrames.mContainingFrame.bottom + - windowFrames.mVisibleFrame.bottom; if (bottomOverlap > 0) { - final int distanceToTop = Math.max(mWindowFrames.mContainingFrame.top - - mWindowFrames.mContentFrame.top, 0); + final int distanceToTop = Math.max(windowFrames.mContainingFrame.top + - windowFrames.mContentFrame.top, 0); int offs = Math.min(bottomOverlap, distanceToTop); - mWindowFrames.mContainingFrame.offset(0, -offs); + windowFrames.mContainingFrame.offset(0, -offs); mInsetFrame.offset(0, -offs); } - } else if (!inPinnedWindowingMode() && mWindowFrames.mContainingFrame.bottom - > mWindowFrames.mParentFrame.bottom) { + } else if (!inPinnedWindowingMode() && windowFrames.mContainingFrame.bottom + > windowFrames.mParentFrame.bottom) { // But in docked we want to behave like fullscreen and behave as if the task // were given smaller bounds for the purposes of layout. Skip adjustments for // the pinned stack, they are handled separately in the PinnedStackController. - mWindowFrames.mContainingFrame.bottom = mWindowFrames.mParentFrame.bottom; + windowFrames.mContainingFrame.bottom = windowFrames.mParentFrame.bottom; } } @@ -1052,8 +1066,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // In floating modes (e.g. freeform, pinned) we have only to set the rectangle // if it wasn't set already. No need to intersect it with the (visible) // "content frame" since it is allowed to be outside the visible desktop. - if (mWindowFrames.mContainingFrame.isEmpty()) { - mWindowFrames.mContainingFrame.set(mWindowFrames.mContentFrame); + if (windowFrames.mContainingFrame.isEmpty()) { + windowFrames.mContainingFrame.set(windowFrames.mContentFrame); } } @@ -1063,115 +1077,115 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // PIP edge case: When going from pinned to fullscreen, we apply a // tempInsetFrame for the full task - but we're still at the start of the animation. // To prevent a jump if there's a letterbox, restrict to the parent frame. - mInsetFrame.intersectUnchecked(mWindowFrames.mParentFrame); - mWindowFrames.mContainingFrame.intersectUnchecked(mWindowFrames.mParentFrame); + mInsetFrame.intersectUnchecked(windowFrames.mParentFrame); + windowFrames.mContainingFrame.intersectUnchecked(windowFrames.mParentFrame); } - layoutDisplayFrame = new Rect(mWindowFrames.mDisplayFrame); - mWindowFrames.mDisplayFrame.set(mWindowFrames.mContainingFrame); - layoutXDiff = mInsetFrame.left - mWindowFrames.mContainingFrame.left; - layoutYDiff = mInsetFrame.top - mWindowFrames.mContainingFrame.top; + layoutDisplayFrame = new Rect(windowFrames.mDisplayFrame); + windowFrames.mDisplayFrame.set(windowFrames.mContainingFrame); + layoutXDiff = mInsetFrame.left - windowFrames.mContainingFrame.left; + layoutYDiff = mInsetFrame.top - windowFrames.mContainingFrame.top; layoutContainingFrame = mInsetFrame; mTmpRect.set(0, 0, dc.getDisplayInfo().logicalWidth, dc.getDisplayInfo().logicalHeight); - subtractInsets(mWindowFrames.mDisplayFrame, layoutContainingFrame, layoutDisplayFrame, + subtractInsets(windowFrames.mDisplayFrame, layoutContainingFrame, layoutDisplayFrame, mTmpRect); if (!layoutInParentFrame()) { - subtractInsets(mWindowFrames.mContainingFrame, layoutContainingFrame, - mWindowFrames.mParentFrame, mTmpRect); - subtractInsets(mInsetFrame, layoutContainingFrame, mWindowFrames.mParentFrame, + subtractInsets(windowFrames.mContainingFrame, layoutContainingFrame, + windowFrames.mParentFrame, mTmpRect); + subtractInsets(mInsetFrame, layoutContainingFrame, windowFrames.mParentFrame, mTmpRect); } layoutDisplayFrame.intersect(layoutContainingFrame); } - final int pw = mWindowFrames.mContainingFrame.width(); - final int ph = mWindowFrames.mContainingFrame.height(); + final int pw = windowFrames.mContainingFrame.width(); + final int ph = windowFrames.mContainingFrame.height(); if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) { mLastRequestedWidth = mRequestedWidth; mLastRequestedHeight = mRequestedHeight; - mWindowFrames.setContentChanged(true); + windowFrames.setContentChanged(true); } - final int fw = mWindowFrames.mFrame.width(); - final int fh = mWindowFrames.mFrame.height(); + final int fw = windowFrames.mFrame.width(); + final int fh = windowFrames.mFrame.height(); - applyGravityAndUpdateFrame(layoutContainingFrame, layoutDisplayFrame); + applyGravityAndUpdateFrame(windowFrames, layoutContainingFrame, layoutDisplayFrame); // Make sure the content and visible frames are inside of the // final window frame. - if (windowsAreFloating && !mWindowFrames.mFrame.isEmpty()) { - final int visBottom = mWindowFrames.mVisibleFrame.bottom; - final int contentBottom = mWindowFrames.mContentFrame.bottom; - mWindowFrames.mContentFrame.set(mWindowFrames.mFrame); - mWindowFrames.mVisibleFrame.set(mWindowFrames.mContentFrame); - mWindowFrames.mStableFrame.set(mWindowFrames.mContentFrame); + if (windowsAreFloating && !windowFrames.mFrame.isEmpty()) { + final int visBottom = windowFrames.mVisibleFrame.bottom; + final int contentBottom = windowFrames.mContentFrame.bottom; + windowFrames.mContentFrame.set(windowFrames.mFrame); + windowFrames.mVisibleFrame.set(windowFrames.mContentFrame); + windowFrames.mStableFrame.set(windowFrames.mContentFrame); if (isImeTarget && inFreeformWindowingMode()) { // After displacing a freeform window to make room for the ime, any part of // the window still covered by IME should be inset. - if (contentBottom + layoutYDiff < mWindowFrames.mContentFrame.bottom) { - mWindowFrames.mContentFrame.bottom = contentBottom + layoutYDiff; + if (contentBottom + layoutYDiff < windowFrames.mContentFrame.bottom) { + windowFrames.mContentFrame.bottom = contentBottom + layoutYDiff; } - if (visBottom + layoutYDiff < mWindowFrames.mVisibleFrame.bottom) { - mWindowFrames.mVisibleFrame.bottom = visBottom + layoutYDiff; + if (visBottom + layoutYDiff < windowFrames.mVisibleFrame.bottom) { + windowFrames.mVisibleFrame.bottom = visBottom + layoutYDiff; } } } else if (mAttrs.type == TYPE_DOCK_DIVIDER) { - dc.getDockedDividerController().positionDockedStackedDivider(mWindowFrames.mFrame); - mWindowFrames.mContentFrame.set(mWindowFrames.mFrame); - if (!mWindowFrames.mFrame.equals(mWindowFrames.mLastFrame)) { + dc.getDockedDividerController().positionDockedStackedDivider(windowFrames.mFrame); + windowFrames.mContentFrame.set(windowFrames.mFrame); + if (!windowFrames.mFrame.equals(windowFrames.mLastFrame)) { mMovedByResize = true; } } else { - mWindowFrames.mContentFrame.set( - Math.max(mWindowFrames.mContentFrame.left, mWindowFrames.mFrame.left), - Math.max(mWindowFrames.mContentFrame.top, mWindowFrames.mFrame.top), - Math.min(mWindowFrames.mContentFrame.right, mWindowFrames.mFrame.right), - Math.min(mWindowFrames.mContentFrame.bottom, mWindowFrames.mFrame.bottom)); + windowFrames.mContentFrame.set( + Math.max(windowFrames.mContentFrame.left, windowFrames.mFrame.left), + Math.max(windowFrames.mContentFrame.top, windowFrames.mFrame.top), + Math.min(windowFrames.mContentFrame.right, windowFrames.mFrame.right), + Math.min(windowFrames.mContentFrame.bottom, windowFrames.mFrame.bottom)); - mWindowFrames.mVisibleFrame.set( - Math.max(mWindowFrames.mVisibleFrame.left, mWindowFrames.mFrame.left), - Math.max(mWindowFrames.mVisibleFrame.top, mWindowFrames.mFrame.top), - Math.min(mWindowFrames.mVisibleFrame.right, mWindowFrames.mFrame.right), - Math.min(mWindowFrames.mVisibleFrame.bottom, mWindowFrames.mFrame.bottom)); + windowFrames.mVisibleFrame.set( + Math.max(windowFrames.mVisibleFrame.left, windowFrames.mFrame.left), + Math.max(windowFrames.mVisibleFrame.top, windowFrames.mFrame.top), + Math.min(windowFrames.mVisibleFrame.right, windowFrames.mFrame.right), + Math.min(windowFrames.mVisibleFrame.bottom, windowFrames.mFrame.bottom)); - mWindowFrames.mStableFrame.set( - Math.max(mWindowFrames.mStableFrame.left, mWindowFrames.mFrame.left), - Math.max(mWindowFrames.mStableFrame.top, mWindowFrames.mFrame.top), - Math.min(mWindowFrames.mStableFrame.right, mWindowFrames.mFrame.right), - Math.min(mWindowFrames.mStableFrame.bottom, mWindowFrames.mFrame.bottom)); + windowFrames.mStableFrame.set( + Math.max(windowFrames.mStableFrame.left, windowFrames.mFrame.left), + Math.max(windowFrames.mStableFrame.top, windowFrames.mFrame.top), + Math.min(windowFrames.mStableFrame.right, windowFrames.mFrame.right), + Math.min(windowFrames.mStableFrame.bottom, windowFrames.mFrame.bottom)); } if (mAttrs.type == TYPE_DOCK_DIVIDER) { - final WmDisplayCutout c = mWindowFrames.mDisplayCutout.calculateRelativeTo( - mWindowFrames.mDisplayFrame); - mWindowFrames.calculateDockedDividerInsets(c.getDisplayCutout().getSafeInsets()); + final WmDisplayCutout c = windowFrames.mDisplayCutout.calculateRelativeTo( + windowFrames.mDisplayFrame); + windowFrames.calculateDockedDividerInsets(c.getDisplayCutout().getSafeInsets()); } else { getDisplayContent().getBounds(mTmpRect); - mWindowFrames.calculateInsets( + windowFrames.calculateInsets( windowsAreFloating, isFullscreenAndFillsDisplay, mTmpRect); } - mWindowFrames.setDisplayCutout( - mWindowFrames.mDisplayCutout.calculateRelativeTo(mWindowFrames.mFrame)); + windowFrames.setDisplayCutout( + windowFrames.mDisplayCutout.calculateRelativeTo(windowFrames.mFrame)); // Offset the actual frame by the amount layout frame is off. - mWindowFrames.offsetFrames(-layoutXDiff, -layoutYDiff); + windowFrames.offsetFrames(-layoutXDiff, -layoutYDiff); - mWindowFrames.mCompatFrame.set(mWindowFrames.mFrame); + windowFrames.mCompatFrame.set(windowFrames.mFrame); if (inSizeCompatMode()) { // If there is a size compatibility scale being applied to the // window, we need to apply this to its insets so that they are // reported to the app in its coordinate space. - mWindowFrames.scaleInsets(mInvGlobalScale); + windowFrames.scaleInsets(mInvGlobalScale); // Also the scaled frame that we report to the app needs to be // adjusted to be in its coordinate space. - mWindowFrames.mCompatFrame.scale(mInvGlobalScale); + windowFrames.mCompatFrame.scale(mInvGlobalScale); } - if (mIsWallpaper && (fw != mWindowFrames.mFrame.width() - || fh != mWindowFrames.mFrame.height())) { + if (mIsWallpaper && (fw != windowFrames.mFrame.width() + || fh != windowFrames.mFrame.height())) { final DisplayContent displayContent = getDisplayContent(); if (displayContent != null) { final DisplayInfo displayInfo = displayContent.getDisplayInfo(); @@ -1181,7 +1195,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } // Calculate relative frame - mWindowFrames.mRelFrame.set(mWindowFrames.mFrame); + windowFrames.mRelFrame.set(windowFrames.mFrame); WindowContainer parent = getParent(); int parentLeft = 0; int parentTop = 0; @@ -1193,15 +1207,15 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP parentLeft = parentBounds.left; parentTop = parentBounds.top; } - mWindowFrames.mRelFrame.offsetTo(mWindowFrames.mFrame.left - parentLeft, - mWindowFrames.mFrame.top - parentTop); + windowFrames.mRelFrame.offsetTo(windowFrames.mFrame.left - parentLeft, + windowFrames.mFrame.top - parentTop); if (DEBUG_LAYOUT || DEBUG) { Slog.v(TAG, "Resolving (mRequestedWidth=" + mRequestedWidth + ", mRequestedheight=" + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph - + "): frame=" + mWindowFrames.mFrame.toShortString() - + " " + mWindowFrames.getInsetsInfo() + + "): frame=" + windowFrames.mFrame.toShortString() + + " " + windowFrames.getInsetsInfo() + " " + mAttrs.getTitle()); } } @@ -3986,7 +4000,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } } - private void applyGravityAndUpdateFrame(Rect containingFrame, Rect displayFrame) { + private void applyGravityAndUpdateFrame(WindowFrames windowFrames, Rect containingFrame, + Rect displayFrame) { final int pw = containingFrame.width(); final int ph = containingFrame.height(); final Task task = getTask(); @@ -4056,19 +4071,19 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // Set mFrame Gravity.apply(mAttrs.gravity, w, h, containingFrame, (int) (x + mAttrs.horizontalMargin * pw), - (int) (y + mAttrs.verticalMargin * ph), mWindowFrames.mFrame); + (int) (y + mAttrs.verticalMargin * ph), windowFrames.mFrame); // Now make sure the window fits in the overall display frame. if (fitToDisplay) { - Gravity.applyDisplay(mAttrs.gravity, displayFrame, mWindowFrames.mFrame); + Gravity.applyDisplay(mAttrs.gravity, displayFrame, windowFrames.mFrame); } // We need to make sure we update the CompatFrame as it is used for // cropping decisions, etc, on systems where we lack a decor layer. - mWindowFrames.mCompatFrame.set(mWindowFrames.mFrame); + windowFrames.mCompatFrame.set(windowFrames.mFrame); if (inSizeCompatMode) { // See comparable block in computeFrameLw. - mWindowFrames.mCompatFrame.scale(mInvGlobalScale); + windowFrames.mCompatFrame.scale(mInvGlobalScale); } } @@ -5533,6 +5548,22 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP return mWindowFrames; } + /** + * If the transient frame is set, the computed result won't be used in real layout. So this + * frames must be cleared when the simulated computation is done. + */ + void setSimulatedWindowFrames(WindowFrames windowFrames) { + mSimulatedWindowFrames = windowFrames; + } + + /** + * Use this method only when the simulated frames may be set, so it is clearer that the calling + * path may be used to simulate layout. + */ + WindowFrames getLayoutingWindowFrames() { + return mSimulatedWindowFrames != null ? mSimulatedWindowFrames : mWindowFrames; + } + void resetContentChanged() { mWindowFrames.setContentChanged(false); } diff --git a/services/incremental/BinderIncrementalService.cpp b/services/incremental/BinderIncrementalService.cpp index f1b637f516ea..91d05723a605 100644 --- a/services/incremental/BinderIncrementalService.cpp +++ b/services/incremental/BinderIncrementalService.cpp @@ -111,10 +111,9 @@ binder::Status BinderIncrementalService::openStorage(const std::string& path, binder::Status BinderIncrementalService::createStorage(const std::string& path, const DataLoaderParamsParcel& params, int32_t createMode, int32_t* _aidl_return) { - *_aidl_return = - mImpl.createStorage(path, const_cast<DataLoaderParamsParcel&&>(params), - android::incremental::IncrementalService::CreateOptions( - createMode)); + *_aidl_return = mImpl.createStorage(path, const_cast<DataLoaderParamsParcel&&>(params), + android::incremental::IncrementalService::CreateOptions( + createMode)); return ok(); } @@ -195,7 +194,7 @@ binder::Status BinderIncrementalService::makeFile( return ok(); } - *_aidl_return = mImpl.makeFile(storageId, path, 0555, fileId, nfp); + *_aidl_return = mImpl.makeFile(storageId, path, 0777, fileId, nfp); return ok(); } binder::Status BinderIncrementalService::makeFileFromRange(int32_t storageId, diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp index 414c66c866db..e4a37dde7758 100644 --- a/services/incremental/IncrementalService.cpp +++ b/services/incremental/IncrementalService.cpp @@ -30,7 +30,6 @@ #include <binder/BinderService.h> #include <binder/ParcelFileDescriptor.h> #include <binder/Status.h> - #include <openssl/sha.h> #include <sys/stat.h> #include <uuid/uuid.h> @@ -612,13 +611,18 @@ int IncrementalService::bind(StorageId storage, std::string_view source, std::st if (!ifs) { return -EINVAL; } - auto normSource = path::normalize(source); std::unique_lock l(ifs->lock); const auto storageInfo = ifs->storages.find(storage); if (storageInfo == ifs->storages.end()) { return -EINVAL; } + std::string normSource; + if (path::isAbsolute(source)) { + normSource = path::normalize(source); + } else { + normSource = path::normalize(path::join(storageInfo->second.name, source)); + } if (!path::startsWith(normSource, storageInfo->second.name)) { return -EINVAL; } @@ -673,7 +677,20 @@ int IncrementalService::unbind(StorageId storage, std::string_view target) { int IncrementalService::makeFile(StorageId storage, std::string_view path, int mode, FileId id, incfs::NewFileParams params) { if (auto ifs = getIfs(storage)) { - auto err = mIncFs->makeFile(ifs->control, path, mode, id, params); + const auto storageInfo = ifs->storages.find(storage); + if (storageInfo == ifs->storages.end()) { + return -EINVAL; + } + std::string normPath; + if (path::isAbsolute(path)) { + normPath = path::normalize(path); + } else { + normPath = path::normalize(path::join(storageInfo->second.name, path)); + } + if (!path::startsWith(normPath, storageInfo->second.name)) { + return -EINVAL; + } + auto err = mIncFs->makeFile(ifs->control, normPath, mode, id, params); if (err) { return err; } diff --git a/services/people/java/com/android/server/people/data/DataManager.java b/services/people/java/com/android/server/people/data/DataManager.java index 13cce414ea7c..4212072088e1 100644 --- a/services/people/java/com/android/server/people/data/DataManager.java +++ b/services/people/java/com/android/server/people/data/DataManager.java @@ -373,7 +373,7 @@ public class DataManager { @WorkerThread void queryUsageStatsService(@UserIdInt int userId, long currentTime, long lastQueryTime) { UsageEvents usageEvents = mUsageStatsManagerInternal.queryEventsForUser( - userId, lastQueryTime, currentTime, false); + userId, lastQueryTime, currentTime, false, false); if (usageEvents == null) { return; } diff --git a/services/tests/servicestests/src/com/android/server/accessibility/gestures/TouchExplorerTest.java b/services/tests/servicestests/src/com/android/server/accessibility/gestures/TouchExplorerTest.java index a4ceadb3028b..9053234aa220 100644 --- a/services/tests/servicestests/src/com/android/server/accessibility/gestures/TouchExplorerTest.java +++ b/services/tests/servicestests/src/com/android/server/accessibility/gestures/TouchExplorerTest.java @@ -89,9 +89,12 @@ public class TouchExplorerTest { @Override public void onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) { - MotionEventMatcher lastEventMatcher = new MotionEventMatcher(mLastEvent); mEvents.add(0, event.copy()); - assertThat(rawEvent, lastEventMatcher); + // LastEvent may not match if we're clearing the state + if (mLastEvent != null) { + MotionEventMatcher lastEventMatcher = new MotionEventMatcher(mLastEvent); + assertThat(rawEvent, lastEventMatcher); + } } @Override @@ -126,6 +129,31 @@ public class TouchExplorerTest { } @Test + public void upEventWhenInTwoFingerMove_clearsState() { + goFromStateClearTo(STATE_MOVING_2FINGERS); + + send(upEvent()); + assertState(STATE_CLEAR); + } + + @Test + public void clearEventsWhenInTwoFingerMove_clearsStateAndSendsUp() { + goFromStateClearTo(STATE_MOVING_2FINGERS); + + // Clear last event so we don't try to match against anything when cleanup events are sent + // for the clear + mLastEvent = null; + mTouchExplorer.clearEvents(InputDevice.SOURCE_TOUCHSCREEN); + assertState(STATE_CLEAR); + List<MotionEvent> events = getCapturedEvents(); + assertCapturedEvents( + MotionEvent.ACTION_DOWN, + MotionEvent.ACTION_POINTER_DOWN, + MotionEvent.ACTION_POINTER_UP, + MotionEvent.ACTION_UP); + } + + @Test public void testTwoFingersDrag_shouldDraggingAndActionDown() { goFromStateClearTo(STATE_DRAGGING_2FINGERS); @@ -268,6 +296,12 @@ public class TouchExplorerTest { DEFAULT_Y, 0)); } + private MotionEvent upEvent() { + MotionEvent event = downEvent(); + event.setAction(MotionEvent.ACTION_UP); + return event; + } + private MotionEvent pointerDownEvent() { final int secondPointerId = 0x0100; final int action = MotionEvent.ACTION_POINTER_DOWN | secondPointerId; diff --git a/services/tests/servicestests/src/com/android/server/people/data/DataManagerTest.java b/services/tests/servicestests/src/com/android/server/people/data/DataManagerTest.java index 9f3d656188e1..91da761ce229 100644 --- a/services/tests/servicestests/src/com/android/server/people/data/DataManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/people/data/DataManagerTest.java @@ -332,7 +332,7 @@ public final class DataManagerTest { events.add(e); UsageEvents usageEvents = new UsageEvents(events, new String[]{}); when(mUsageStatsManagerInternal.queryEventsForUser(anyInt(), anyLong(), anyLong(), - anyBoolean())).thenReturn(usageEvents); + anyBoolean(), anyBoolean())).thenReturn(usageEvents); mDataManager.onUserUnlocked(USER_ID_PRIMARY); diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java index 5ba676d1c544..9dbaa4c9ca82 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java @@ -73,6 +73,9 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import java.io.PrintWriter; +import java.io.StringWriter; + /** * Tests for the {@link DisplayPolicy} class. * @@ -122,9 +125,13 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase { } private void updateDisplayFrames() { + mFrames = createDisplayFrames(); + } + + private DisplayFrames createDisplayFrames() { final Pair<DisplayInfo, WmDisplayCutout> info = displayInfoAndCutoutForRotation(mRotation, mHasDisplayCutout); - mFrames = new DisplayFrames(mDisplayContent.getDisplayId(), info.first, info.second); + return new DisplayFrames(mDisplayContent.getDisplayId(), info.first, info.second); } @Test @@ -824,6 +831,49 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase { assertThat(outDisplayCutout, is(new DisplayCutout.ParcelableWrapper())); } + /** + * Verify that {@link DisplayPolicy#simulateLayoutDisplay} outputs the same display frames as + * {@link DisplayPolicy#beginLayoutLw}. + */ + @Test + public void testSimulateLayoutDisplay() { + assertSimulateLayoutSameDisplayFrames(); + setRotation(ROTATION_90); + assertSimulateLayoutSameDisplayFrames(); + addDisplayCutout(); + assertSimulateLayoutSameDisplayFrames(); + } + + private void assertSimulateLayoutSameDisplayFrames() { + final int uiMode = 0; + final String prefix = ""; + final InsetsState simulatedInsetsState = new InsetsState(); + final DisplayFrames simulatedDisplayFrames = createDisplayFrames(); + mDisplayContent.mDisplayFrames = mFrames; + mDisplayPolicy.beginLayoutLw(mFrames, uiMode); + mDisplayContent.getInsetsStateController().onPostLayout(); + mDisplayPolicy.simulateLayoutDisplay(simulatedDisplayFrames, simulatedInsetsState, uiMode); + + final StringWriter realFramesDump = new StringWriter(); + mFrames.dump(prefix, new PrintWriter(realFramesDump)); + final StringWriter simulatedFramesDump = new StringWriter(); + simulatedDisplayFrames.dump(prefix, new PrintWriter(simulatedFramesDump)); + + assertEquals(realFramesDump.toString(), simulatedFramesDump.toString()); + + final StringWriter realInsetsDump = new StringWriter(); + final InsetsState realInsetsState = new InsetsState( + mDisplayContent.getInsetsStateController().getRawInsetsState()); + // Exclude comparing IME insets because currently the simulated layout only focuses on the + // insets from status bar and navigation bar. + realInsetsState.removeSource(InsetsState.ITYPE_IME); + realInsetsState.dump(prefix, new PrintWriter(realInsetsDump)); + final StringWriter simulatedInsetsDump = new StringWriter(); + simulatedInsetsState.dump(prefix, new PrintWriter(simulatedInsetsDump)); + + assertEquals(realInsetsDump.toString(), simulatedInsetsDump.toString()); + } + @Test public void forceShowSystemBars_clearsSystemUIFlags() { mDisplayPolicy.mLastSystemUiFlags |= SYSTEM_UI_FLAG_FULLSCREEN; diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java index 14852d0f4161..48b6e2aaad5c 100644 --- a/services/usage/java/com/android/server/usage/UsageStatsService.java +++ b/services/usage/java/com/android/server/usage/UsageStatsService.java @@ -2117,9 +2117,9 @@ public class UsageStatsService extends SystemService implements @Override public UsageEvents queryEventsForUser(int userId, long beginTime, long endTime, - boolean shouldObfuscateInstantApps) { + boolean obfuscateInstantApps, boolean hideShortcutInvocationEvents) { return UsageStatsService.this.queryEvents( - userId, beginTime, endTime, shouldObfuscateInstantApps, false); + userId, beginTime, endTime, obfuscateInstantApps, hideShortcutInvocationEvents); } @Override |