Merge "Move the waiting for the publishing of content provider to client side"
diff --git a/Android.bp b/Android.bp
index 0780f88..e756b34 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1415,3 +1415,30 @@
name: "framework-telephony-jarjar-rules",
srcs: ["telephony/framework-telephony-jarjar-rules.txt"],
}
+
+// protolog start
+filegroup {
+ name: "protolog-common-src",
+ srcs: [
+ "core/java/com/android/internal/protolog/common/**/*.java",
+ ],
+}
+
+java_library {
+ name: "protolog-lib",
+ platform_apis: true,
+ srcs: [
+ "core/java/com/android/internal/protolog/ProtoLogImpl.java",
+ "core/java/com/android/internal/protolog/ProtoLogViewerConfigReader.java",
+ ":protolog-common-src",
+ ],
+}
+
+java_library {
+ name: "protolog-groups",
+ srcs: [
+ "core/java/com/android/internal/protolog/ProtoLogGroup.java",
+ ":protolog-common-src",
+ ],
+}
+// protolog end
diff --git a/StubLibraries.bp b/StubLibraries.bp
index 0fe34fb..2bd5aee 100644
--- a/StubLibraries.bp
+++ b/StubLibraries.bp
@@ -311,15 +311,6 @@
compile_dex: true,
}
-java_defaults {
- name: "android_stubs_dists_default",
- dist: {
- targets: ["sdk", "win_sdk"],
- tag: ".jar",
- dest: "android.jar",
- },
-}
-
java_library_static {
name: "android_monolith_stubs_current",
srcs: [ ":api-stubs-docs" ],
@@ -355,21 +346,7 @@
name: "android_system_monolith_stubs_current",
srcs: [ ":system-api-stubs-docs" ],
static_libs: [ "private-stub-annotations-jar" ],
- defaults: [
- "android_defaults_stubs_current",
- "android_stubs_dists_default",
- ],
- dist: {
- dir: "apistubs/android/system",
- },
- dists: [
- {
- // Legacy dist path
- targets: ["sdk", "win_sdk"],
- tag: ".jar",
- dest: "android_system.jar",
- },
- ],
+ defaults: ["android_defaults_stubs_current"],
}
java_library_static {
@@ -401,34 +378,14 @@
name: "android_test_stubs_current",
srcs: [ ":test-api-stubs-docs" ],
static_libs: [ "private-stub-annotations-jar" ],
- defaults: [
- "android_defaults_stubs_current",
- "android_stubs_dists_default",
- ],
- dist: {
- dir: "apistubs/android/test",
- },
- dists: [
- {
- // Legacy dist path
- targets: ["sdk", "win_sdk"],
- tag: ".jar",
- dest: "android_test.jar",
- },
- ],
+ defaults: ["android_defaults_stubs_current"],
}
java_library_static {
name: "android_module_lib_stubs_current",
srcs: [ ":module-lib-api-stubs-docs-non-updatable" ],
- defaults: [
- "android_defaults_stubs_current",
- "android_stubs_dists_default",
- ],
+ defaults: ["android_defaults_stubs_current"],
libs: ["sdk_system_29_android"],
- dist: {
- dir: "apistubs/android/module-lib",
- },
}
java_library_static {
diff --git a/api/current.txt b/api/current.txt
index b70103b..69700f3 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -5596,6 +5596,7 @@
method public android.graphics.drawable.Icon getIcon();
method public android.app.RemoteInput[] getRemoteInputs();
method public int getSemanticAction();
+ method public boolean isAuthenticationRequired();
method public boolean isContextual();
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.app.Notification.Action> CREATOR;
@@ -5625,6 +5626,7 @@
method @NonNull public android.app.Notification.Action.Builder extend(android.app.Notification.Action.Extender);
method @NonNull public android.os.Bundle getExtras();
method @NonNull public android.app.Notification.Action.Builder setAllowGeneratedReplies(boolean);
+ method @NonNull public android.app.Notification.Action.Builder setAuthenticationRequired(boolean);
method @NonNull public android.app.Notification.Action.Builder setContextual(boolean);
method @NonNull public android.app.Notification.Action.Builder setSemanticAction(int);
}
@@ -24065,6 +24067,8 @@
method public boolean isSink();
method public boolean isSource();
field public static final int TYPE_AUX_LINE = 19; // 0x13
+ field public static final int TYPE_BLE_HEADSET = 26; // 0x1a
+ field public static final int TYPE_BLE_SPEAKER = 27; // 0x1b
field public static final int TYPE_BLUETOOTH_A2DP = 8; // 0x8
field public static final int TYPE_BLUETOOTH_SCO = 7; // 0x7
field public static final int TYPE_BUILTIN_EARPIECE = 1; // 0x1
diff --git a/api/module-lib-current.txt b/api/module-lib-current.txt
index 3f3b8ea..b587ea1 100644
--- a/api/module-lib-current.txt
+++ b/api/module-lib-current.txt
@@ -39,6 +39,14 @@
}
+package android.media.session {
+
+ public final class MediaSession {
+ field public static final int FLAG_EXCLUSIVE_GLOBAL_PRIORITY = 65536; // 0x10000
+ }
+
+}
+
package android.net {
public final class TetheringConstants {
@@ -86,6 +94,7 @@
}
public interface Parcelable {
+ method public default int getStability();
field public static final int PARCELABLE_STABILITY_LOCAL = 0; // 0x0
field public static final int PARCELABLE_STABILITY_VINTF = 1; // 0x1
}
diff --git a/api/system-current.txt b/api/system-current.txt
index 88fe40a..721523c9 100755
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -301,6 +301,7 @@
field public static final int config_helpIntentNameKey = 17039390; // 0x104001e
field public static final int config_helpPackageNameKey = 17039387; // 0x104001b
field public static final int config_helpPackageNameValue = 17039388; // 0x104001c
+ field public static final int config_systemAutomotiveCluster = 17039400; // 0x1040028
field public static final int config_systemGallery = 17039399; // 0x1040027
}
@@ -7141,6 +7142,8 @@
field @Deprecated public static final int METERED_OVERRIDE_METERED = 1; // 0x1
field @Deprecated public static final int METERED_OVERRIDE_NONE = 0; // 0x0
field @Deprecated public static final int METERED_OVERRIDE_NOT_METERED = 2; // 0x2
+ field @Deprecated public static final int RANDOMIZATION_AUTO = 3; // 0x3
+ field @Deprecated public static final int RANDOMIZATION_ENHANCED = 2; // 0x2
field @Deprecated public static final int RANDOMIZATION_NONE = 0; // 0x0
field @Deprecated public static final int RANDOMIZATION_PERSISTENT = 1; // 0x1
field @Deprecated public static final int RECENT_FAILURE_AP_UNABLE_TO_HANDLE_NEW_STA = 17; // 0x11
@@ -10489,7 +10492,7 @@
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getCurrentTtyMode();
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getDefaultDialerPackage(@NonNull android.os.UserHandle);
method @Deprecated public android.content.ComponentName getDefaultPhoneApp();
- method public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsForPackage();
+ method @Deprecated public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsForPackage();
method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsSupportingScheme(String);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean isInEmergencyCall();
method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isRinging();
diff --git a/api/test-current.txt b/api/test-current.txt
index 963ef7c..3332525 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -42,6 +42,7 @@
public static final class R.string {
field public static final int config_defaultAssistant = 17039393; // 0x1040021
field public static final int config_defaultDialer = 17039395; // 0x1040023
+ field public static final int config_systemAutomotiveCluster = 17039400; // 0x1040028
field public static final int config_systemGallery = 17039399; // 0x1040027
}
diff --git a/cmds/idmap2/idmap2d/Idmap2Service.cpp b/cmds/idmap2/idmap2d/Idmap2Service.cpp
index a6c402c..15e22a3 100644
--- a/cmds/idmap2/idmap2d/Idmap2Service.cpp
+++ b/cmds/idmap2/idmap2d/Idmap2Service.cpp
@@ -166,7 +166,7 @@
Status Idmap2Service::createIdmap(const std::string& target_apk_path,
const std::string& overlay_apk_path, int32_t fulfilled_policies,
bool enforce_overlayable, int32_t user_id ATTRIBUTE_UNUSED,
- aidl::nullable<std::string>* _aidl_return) {
+ std::optional<std::string>* _aidl_return) {
assert(_aidl_return);
SYSTRACE << "Idmap2Service::createIdmap " << target_apk_path << " " << overlay_apk_path;
_aidl_return->reset();
@@ -214,7 +214,7 @@
return error("failed to write to idmap path " + idmap_path);
}
- *_aidl_return = aidl::make_nullable<std::string>(idmap_path);
+ *_aidl_return = idmap_path;
return ok();
}
diff --git a/cmds/idmap2/idmap2d/Idmap2Service.h b/cmds/idmap2/idmap2d/Idmap2Service.h
index ea931c9..1a44519 100644
--- a/cmds/idmap2/idmap2d/Idmap2Service.h
+++ b/cmds/idmap2/idmap2d/Idmap2Service.h
@@ -21,7 +21,6 @@
#include <android-base/unique_fd.h>
#include <binder/BinderService.h>
-#include <binder/Nullable.h>
#include "android/os/BnIdmap2.h"
@@ -47,7 +46,7 @@
binder::Status createIdmap(const std::string& target_apk_path,
const std::string& overlay_apk_path, int32_t fulfilled_policies,
bool enforce_overlayable, int32_t user_id,
- aidl::nullable<std::string>* _aidl_return) override;
+ std::optional<std::string>* _aidl_return) override;
private:
// Cache the crc of the android framework package since the crc cannot change without a reboot.
diff --git a/cmds/statsd/Android.bp b/cmds/statsd/Android.bp
index 1579715..7c41951 100644
--- a/cmds/statsd/Android.bp
+++ b/cmds/statsd/Android.bp
@@ -85,8 +85,9 @@
"src/metrics/EventMetricProducer.cpp",
"src/metrics/GaugeMetricProducer.cpp",
"src/metrics/MetricProducer.cpp",
- "src/metrics/metrics_manager_util.cpp",
"src/metrics/MetricsManager.cpp",
+ "src/metrics/parsing_utils/config_update_utils.cpp",
+ "src/metrics/parsing_utils/metrics_manager_util.cpp",
"src/metrics/ValueMetricProducer.cpp",
"src/packages/UidMap.cpp",
"src/shell/shell_config.proto",
@@ -322,6 +323,8 @@
"tests/metrics/metrics_test_helper.cpp",
"tests/metrics/OringDurationTracker_test.cpp",
"tests/metrics/ValueMetricProducer_test.cpp",
+ "tests/metrics/parsing_utils/config_update_utils_test.cpp",
+ "tests/metrics/parsing_utils/metrics_manager_util_test.cpp",
"tests/MetricsManager_test.cpp",
"tests/shell/ShellSubscriber_test.cpp",
"tests/state/StateTracker_test.cpp",
diff --git a/cmds/statsd/src/StatsLogProcessor.cpp b/cmds/statsd/src/StatsLogProcessor.cpp
index 6327490..7bee4e2 100644
--- a/cmds/statsd/src/StatsLogProcessor.cpp
+++ b/cmds/statsd/src/StatsLogProcessor.cpp
@@ -546,7 +546,8 @@
}
} else {
// Preserve the existing MetricsManager, update necessary components and metadata in place.
- configValid = it->second->updateConfig(timestampNs, config);
+ configValid = it->second->updateConfig(config, mTimeBaseNs, timestampNs,
+ mAnomalyAlarmMonitor, mPeriodicAlarmMonitor);
if (configValid) {
// TODO(b/162323476): refresh TTL, ensure init() is handled properly.
mUidMap->OnConfigUpdated(key);
diff --git a/cmds/statsd/src/hash.h b/cmds/statsd/src/hash.h
index cfe869f..bd6b0cd 100644
--- a/cmds/statsd/src/hash.h
+++ b/cmds/statsd/src/hash.h
@@ -22,6 +22,7 @@
namespace os {
namespace statsd {
+// Uses murmur2 hashing algorithm.
extern uint32_t Hash32(const char *data, size_t n, uint32_t seed);
extern uint64_t Hash64(const char* data, size_t n, uint64_t seed);
diff --git a/cmds/statsd/src/matchers/CombinationLogMatchingTracker.cpp b/cmds/statsd/src/matchers/CombinationLogMatchingTracker.cpp
index b94a957..60bcc26 100644
--- a/cmds/statsd/src/matchers/CombinationLogMatchingTracker.cpp
+++ b/cmds/statsd/src/matchers/CombinationLogMatchingTracker.cpp
@@ -27,8 +27,9 @@
using std::unordered_map;
using std::vector;
-CombinationLogMatchingTracker::CombinationLogMatchingTracker(const int64_t& id, const int index)
- : LogMatchingTracker(id, index) {
+CombinationLogMatchingTracker::CombinationLogMatchingTracker(const int64_t& id, const int index,
+ const uint64_t protoHash)
+ : LogMatchingTracker(id, index, protoHash) {
}
CombinationLogMatchingTracker::~CombinationLogMatchingTracker() {
diff --git a/cmds/statsd/src/matchers/CombinationLogMatchingTracker.h b/cmds/statsd/src/matchers/CombinationLogMatchingTracker.h
index 55bc4605..6b8a7fb 100644
--- a/cmds/statsd/src/matchers/CombinationLogMatchingTracker.h
+++ b/cmds/statsd/src/matchers/CombinationLogMatchingTracker.h
@@ -28,7 +28,7 @@
// Represents a AtomMatcher_Combination in the StatsdConfig.
class CombinationLogMatchingTracker : public virtual LogMatchingTracker {
public:
- CombinationLogMatchingTracker(const int64_t& id, const int index);
+ CombinationLogMatchingTracker(const int64_t& id, const int index, const uint64_t protoHash);
bool init(const std::vector<AtomMatcher>& allLogMatchers,
const std::vector<sp<LogMatchingTracker>>& allTrackers,
diff --git a/cmds/statsd/src/matchers/LogMatchingTracker.h b/cmds/statsd/src/matchers/LogMatchingTracker.h
index 88ab4e6..49a41ad 100644
--- a/cmds/statsd/src/matchers/LogMatchingTracker.h
+++ b/cmds/statsd/src/matchers/LogMatchingTracker.h
@@ -33,8 +33,8 @@
class LogMatchingTracker : public virtual RefBase {
public:
- LogMatchingTracker(const int64_t& id, const int index)
- : mId(id), mIndex(index), mInitialized(false){};
+ LogMatchingTracker(const int64_t& id, const int index, const uint64_t protoHash)
+ : mId(id), mIndex(index), mInitialized(false), mProtoHash(protoHash){};
virtual ~LogMatchingTracker(){};
@@ -69,10 +69,14 @@
return mAtomIds;
}
- const int64_t& getId() const {
+ int64_t getId() const {
return mId;
}
+ uint64_t getProtoHash() const {
+ return mProtoHash;
+ }
+
protected:
// Name of this matching. We don't really need the name, but it makes log message easy to debug.
const int64_t mId;
@@ -87,6 +91,14 @@
// return kNotMatched when we receive an event with an id not in the list. This is especially
// useful when we have a complex CombinationLogMatcherTracker.
std::set<int> mAtomIds;
+
+ // Hash of the AtomMatcher's proto bytes from StatsdConfig.
+ // Used to determine if the definition of this matcher has changed across a config update.
+ const uint64_t mProtoHash;
+
+ FRIEND_TEST(MetricsManagerTest, TestCreateLogTrackerSimple);
+ FRIEND_TEST(MetricsManagerTest, TestCreateLogTrackerCombination);
+ FRIEND_TEST(ConfigUpdateTest, TestUpdateMatchers);
};
} // namespace statsd
diff --git a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp
index 082daf5a..ff47d35 100644
--- a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp
+++ b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp
@@ -26,11 +26,11 @@
using std::unordered_map;
using std::vector;
-
SimpleLogMatchingTracker::SimpleLogMatchingTracker(const int64_t& id, const int index,
+ const uint64_t protoHash,
const SimpleAtomMatcher& matcher,
- const UidMap& uidMap)
- : LogMatchingTracker(id, index), mMatcher(matcher), mUidMap(uidMap) {
+ const sp<UidMap>& uidMap)
+ : LogMatchingTracker(id, index, protoHash), mMatcher(matcher), mUidMap(uidMap) {
if (!matcher.has_atom_id()) {
mInitialized = false;
} else {
diff --git a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.h b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.h
index a0f6a88..e58e012 100644
--- a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.h
+++ b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.h
@@ -29,9 +29,8 @@
class SimpleLogMatchingTracker : public virtual LogMatchingTracker {
public:
- SimpleLogMatchingTracker(const int64_t& id, const int index,
- const SimpleAtomMatcher& matcher,
- const UidMap& uidMap);
+ SimpleLogMatchingTracker(const int64_t& id, const int index, const uint64_t protoHash,
+ const SimpleAtomMatcher& matcher, const sp<UidMap>& uidMap);
~SimpleLogMatchingTracker();
@@ -46,7 +45,7 @@
private:
const SimpleAtomMatcher mMatcher;
- const UidMap& mUidMap;
+ const sp<UidMap> mUidMap;
};
} // namespace statsd
diff --git a/cmds/statsd/src/matchers/matcher_util.cpp b/cmds/statsd/src/matchers/matcher_util.cpp
index 2b4c6a3..e6d9122 100644
--- a/cmds/statsd/src/matchers/matcher_util.cpp
+++ b/cmds/statsd/src/matchers/matcher_util.cpp
@@ -81,14 +81,15 @@
return matched;
}
-bool tryMatchString(const UidMap& uidMap, const FieldValue& fieldValue, const string& str_match) {
+bool tryMatchString(const sp<UidMap>& uidMap, const FieldValue& fieldValue,
+ const string& str_match) {
if (isAttributionUidField(fieldValue) || isUidField(fieldValue)) {
int uid = fieldValue.mValue.int_value;
auto aidIt = UidMap::sAidToUidMapping.find(str_match);
if (aidIt != UidMap::sAidToUidMapping.end()) {
return ((int)aidIt->second) == uid;
}
- std::set<string> packageNames = uidMap.getAppNamesFromUid(uid, true /* normalize*/);
+ std::set<string> packageNames = uidMap->getAppNamesFromUid(uid, true /* normalize*/);
return packageNames.find(str_match) != packageNames.end();
} else if (fieldValue.mValue.getType() == STRING) {
return fieldValue.mValue.str_value == str_match;
@@ -96,7 +97,7 @@
return false;
}
-bool matchesSimple(const UidMap& uidMap, const FieldValueMatcher& matcher,
+bool matchesSimple(const sp<UidMap>& uidMap, const FieldValueMatcher& matcher,
const vector<FieldValue>& values, int start, int end, int depth) {
if (depth > 2) {
ALOGE("Depth > 3 not supported");
@@ -353,7 +354,7 @@
}
}
-bool matchesSimple(const UidMap& uidMap, const SimpleAtomMatcher& simpleMatcher,
+bool matchesSimple(const sp<UidMap>& uidMap, const SimpleAtomMatcher& simpleMatcher,
const LogEvent& event) {
if (event.GetTagId() != simpleMatcher.atom_id()) {
return false;
diff --git a/cmds/statsd/src/matchers/matcher_util.h b/cmds/statsd/src/matchers/matcher_util.h
index 1ab3e87..130b606 100644
--- a/cmds/statsd/src/matchers/matcher_util.h
+++ b/cmds/statsd/src/matchers/matcher_util.h
@@ -36,8 +36,8 @@
bool combinationMatch(const std::vector<int>& children, const LogicalOperation& operation,
const std::vector<MatchingState>& matcherResults);
-bool matchesSimple(const UidMap& uidMap,
- const SimpleAtomMatcher& simpleMatcher, const LogEvent& wrapper);
+bool matchesSimple(const sp<UidMap>& uidMap, const SimpleAtomMatcher& simpleMatcher,
+ const LogEvent& wrapper);
} // namespace statsd
} // namespace os
diff --git a/cmds/statsd/src/metrics/MetricsManager.cpp b/cmds/statsd/src/metrics/MetricsManager.cpp
index 189d811..2c3deca 100644
--- a/cmds/statsd/src/metrics/MetricsManager.cpp
+++ b/cmds/statsd/src/metrics/MetricsManager.cpp
@@ -26,7 +26,8 @@
#include "guardrail/StatsdStats.h"
#include "matchers/CombinationLogMatchingTracker.h"
#include "matchers/SimpleLogMatchingTracker.h"
-#include "metrics_manager_util.h"
+#include "parsing_utils/config_update_utils.h"
+#include "parsing_utils/metrics_manager_util.h"
#include "state/StateManager.h"
#include "stats_log_util.h"
#include "stats_util.h"
@@ -76,13 +77,14 @@
// Init the ttl end timestamp.
refreshTtl(timeBaseNs);
- mConfigValid = initStatsdConfig(
- key, config, *uidMap, pullerManager, anomalyAlarmMonitor, periodicAlarmMonitor,
- timeBaseNs, currentTimeNs, mTagIds, mAllAtomMatchers, mAllConditionTrackers,
- mAllMetricProducers, mAllAnomalyTrackers, mAllPeriodicAlarmTrackers,
- mConditionToMetricMap, mTrackerToMetricMap, mTrackerToConditionMap,
- mActivationAtomTrackerToMetricMap, mDeactivationAtomTrackerToMetricMap,
- mAlertTrackerMap, mMetricIndexesWithActivation, mNoReportMetricIds);
+ mConfigValid =
+ initStatsdConfig(key, config, uidMap, pullerManager, anomalyAlarmMonitor,
+ periodicAlarmMonitor, timeBaseNs, currentTimeNs, mTagIds,
+ mAllAtomMatchers, mLogTrackerMap, mAllConditionTrackers,
+ mAllMetricProducers, mAllAnomalyTrackers, mAllPeriodicAlarmTrackers,
+ mConditionToMetricMap, mTrackerToMetricMap, mTrackerToConditionMap,
+ mActivationAtomTrackerToMetricMap, mDeactivationAtomTrackerToMetricMap,
+ mAlertTrackerMap, mMetricIndexesWithActivation, mNoReportMetricIds);
mHashStringsInReport = config.hash_strings_in_metric_report();
mVersionStringsInReport = config.version_strings_in_metric_report();
@@ -195,7 +197,19 @@
VLOG("~MetricsManager()");
}
-bool MetricsManager::updateConfig(const int64_t currentTimeNs, const StatsdConfig& config) {
+bool MetricsManager::updateConfig(const StatsdConfig& config, const int64_t timeBaseNs,
+ const int64_t currentTimeNs,
+ const sp<AlarmMonitor>& anomalyAlarmMonitor,
+ const sp<AlarmMonitor>& periodicAlarmMonitor) {
+ vector<sp<LogMatchingTracker>> newAtomMatchers;
+ unordered_map<int64_t, int> newLogTrackerMap;
+ mTagIds.clear();
+ mConfigValid =
+ updateStatsdConfig(mConfigKey, config, mUidMap, mPullerManager, anomalyAlarmMonitor,
+ periodicAlarmMonitor, timeBaseNs, currentTimeNs, mAllAtomMatchers,
+ mLogTrackerMap, mTagIds, newAtomMatchers, newLogTrackerMap);
+ mAllAtomMatchers = newAtomMatchers;
+ mLogTrackerMap = newLogTrackerMap;
return mConfigValid;
}
diff --git a/cmds/statsd/src/metrics/MetricsManager.h b/cmds/statsd/src/metrics/MetricsManager.h
index 042de29..6f9a2336 100644
--- a/cmds/statsd/src/metrics/MetricsManager.h
+++ b/cmds/statsd/src/metrics/MetricsManager.h
@@ -46,7 +46,9 @@
virtual ~MetricsManager();
- bool updateConfig(const int64_t currentTimeNs, const StatsdConfig& config);
+ bool updateConfig(const StatsdConfig& config, const int64_t timeBaseNs,
+ const int64_t currentTimeNs, const sp<AlarmMonitor>& anomalyAlarmMonitor,
+ const sp<AlarmMonitor>& periodicAlarmMonitor);
// Return whether the configuration is valid.
bool isConfigValid() const;
@@ -237,6 +239,12 @@
// Hold all periodic alarm trackers.
std::vector<sp<AlarmTracker>> mAllPeriodicAlarmTrackers;
+ // To make updating configs faster, we map the id of a LogMatchingTracker, MetricProducer, and
+ // ConditionTracker to its index in the corresponding vector.
+
+ // Maps the id of an atom matcher to its index in mAllAtomMatchers.
+ std::unordered_map<int64_t, int> mLogTrackerMap;
+
// To make the log processing more efficient, we want to do as much filtering as possible
// before we go into individual trackers and conditions to match.
diff --git a/cmds/statsd/src/metrics/parsing_utils/config_update_utils.cpp b/cmds/statsd/src/metrics/parsing_utils/config_update_utils.cpp
new file mode 100644
index 0000000..562e291
--- /dev/null
+++ b/cmds/statsd/src/metrics/parsing_utils/config_update_utils.cpp
@@ -0,0 +1,203 @@
+/*
+ * 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.
+ */
+
+#define DEBUG false // STOPSHIP if true
+
+#include "config_update_utils.h"
+
+#include "external/StatsPullerManager.h"
+#include "hash.h"
+#include "metrics_manager_util.h"
+
+namespace android {
+namespace os {
+namespace statsd {
+
+// Recursive function to determine if a matcher needs to be updated. Populates matcherToUpdate.
+// Returns whether the function was successful or not.
+bool determineMatcherUpdateStatus(const StatsdConfig& config, const int matcherIdx,
+ const unordered_map<int64_t, int>& oldLogTrackerMap,
+ const vector<sp<LogMatchingTracker>>& oldAtomMatchers,
+ const unordered_map<int64_t, int>& newLogTrackerMap,
+ vector<UpdateStatus>& matchersToUpdate,
+ vector<bool>& cycleTracker) {
+ // Have already examined this matcher.
+ if (matchersToUpdate[matcherIdx] != UPDATE_UNKNOWN) {
+ return true;
+ }
+
+ const AtomMatcher& matcher = config.atom_matcher(matcherIdx);
+ int64_t id = matcher.id();
+ // Check if new matcher.
+ const auto& oldLogTrackerIt = oldLogTrackerMap.find(id);
+ if (oldLogTrackerIt == oldLogTrackerMap.end()) {
+ matchersToUpdate[matcherIdx] = UPDATE_REPLACE;
+ return true;
+ }
+
+ // This is an existing matcher. Check if it has changed.
+ string serializedMatcher;
+ if (!matcher.SerializeToString(&serializedMatcher)) {
+ ALOGE("Unable to serialize matcher %lld", (long long)id);
+ return false;
+ }
+ uint64_t newProtoHash = Hash64(serializedMatcher);
+ if (newProtoHash != oldAtomMatchers[oldLogTrackerIt->second]->getProtoHash()) {
+ matchersToUpdate[matcherIdx] = UPDATE_REPLACE;
+ return true;
+ }
+
+ switch (matcher.contents_case()) {
+ case AtomMatcher::ContentsCase::kSimpleAtomMatcher: {
+ matchersToUpdate[matcherIdx] = UPDATE_PRESERVE;
+ return true;
+ }
+ case AtomMatcher::ContentsCase::kCombination: {
+ // Recurse to check if children have changed.
+ cycleTracker[matcherIdx] = true;
+ UpdateStatus status = UPDATE_PRESERVE;
+ for (const int64_t childMatcherId : matcher.combination().matcher()) {
+ const auto& childIt = newLogTrackerMap.find(childMatcherId);
+ if (childIt == newLogTrackerMap.end()) {
+ ALOGW("Matcher %lld not found in the config", (long long)childMatcherId);
+ return false;
+ }
+ const int childIdx = childIt->second;
+ if (cycleTracker[childIdx]) {
+ ALOGE("Cycle detected in matcher config");
+ return false;
+ }
+ if (!determineMatcherUpdateStatus(config, childIdx, oldLogTrackerMap,
+ oldAtomMatchers, newLogTrackerMap,
+ matchersToUpdate, cycleTracker)) {
+ return false;
+ }
+
+ if (matchersToUpdate[childIdx] == UPDATE_REPLACE) {
+ status = UPDATE_REPLACE;
+ break;
+ }
+ }
+ matchersToUpdate[matcherIdx] = status;
+ cycleTracker[matcherIdx] = false;
+ return true;
+ }
+ default: {
+ ALOGE("Matcher \"%lld\" malformed", (long long)id);
+ return false;
+ }
+ }
+ return true;
+}
+
+bool updateLogTrackers(const StatsdConfig& config, const sp<UidMap>& uidMap,
+ const unordered_map<int64_t, int>& oldLogTrackerMap,
+ const vector<sp<LogMatchingTracker>>& oldAtomMatchers, set<int>& allTagIds,
+ unordered_map<int64_t, int>& newLogTrackerMap,
+ vector<sp<LogMatchingTracker>>& newAtomMatchers) {
+ const int atomMatcherCount = config.atom_matcher_size();
+
+ vector<AtomMatcher> matcherProtos;
+ matcherProtos.reserve(atomMatcherCount);
+ newAtomMatchers.reserve(atomMatcherCount);
+
+ // Maps matcher id to their position in the config. For fast lookup of dependencies.
+ for (int i = 0; i < atomMatcherCount; i++) {
+ const AtomMatcher& matcher = config.atom_matcher(i);
+ if (newLogTrackerMap.find(matcher.id()) != newLogTrackerMap.end()) {
+ ALOGE("Duplicate atom matcher found for id %lld", (long long)matcher.id());
+ return false;
+ }
+ newLogTrackerMap[matcher.id()] = i;
+ matcherProtos.push_back(matcher);
+ }
+
+ // For combination matchers, we need to determine if any children need to be updated.
+ vector<UpdateStatus> matchersToUpdate(atomMatcherCount, UPDATE_UNKNOWN);
+ vector<bool> cycleTracker(atomMatcherCount, false);
+ for (int i = 0; i < atomMatcherCount; i++) {
+ if (!determineMatcherUpdateStatus(config, i, oldLogTrackerMap, oldAtomMatchers,
+ newLogTrackerMap, matchersToUpdate, cycleTracker)) {
+ return false;
+ }
+ }
+
+ for (int i = 0; i < atomMatcherCount; i++) {
+ const AtomMatcher& matcher = config.atom_matcher(i);
+ const int64_t id = matcher.id();
+ switch (matchersToUpdate[i]) {
+ case UPDATE_PRESERVE: {
+ const auto& oldLogTrackerIt = oldLogTrackerMap.find(id);
+ if (oldLogTrackerIt == oldLogTrackerMap.end()) {
+ ALOGE("Could not find AtomMatcher %lld in the previous config, but expected it "
+ "to be there",
+ (long long)id);
+ return false;
+ }
+ const int oldIndex = oldLogTrackerIt->second;
+ newAtomMatchers.push_back(oldAtomMatchers[oldIndex]);
+ break;
+ }
+ case UPDATE_REPLACE: {
+ sp<LogMatchingTracker> tracker = createLogTracker(matcher, i, uidMap);
+ if (tracker == nullptr) {
+ return false;
+ }
+ newAtomMatchers.push_back(tracker);
+ break;
+ }
+ default: {
+ ALOGE("Matcher \"%lld\" update state is unknown. This should never happen",
+ (long long)id);
+ return false;
+ }
+ }
+ }
+
+ std::fill(cycleTracker.begin(), cycleTracker.end(), false);
+ for (auto& matcher : newAtomMatchers) {
+ if (!matcher->init(matcherProtos, newAtomMatchers, newLogTrackerMap, cycleTracker)) {
+ return false;
+ }
+ // Collect all the tag ids that are interesting. TagIds exist in leaf nodes only.
+ const set<int>& tagIds = matcher->getAtomIds();
+ allTagIds.insert(tagIds.begin(), tagIds.end());
+ }
+
+ return true;
+}
+
+bool updateStatsdConfig(const ConfigKey& key, const StatsdConfig& config, const sp<UidMap>& uidMap,
+ const sp<StatsPullerManager>& pullerManager,
+ const sp<AlarmMonitor>& anomalyAlarmMonitor,
+ const sp<AlarmMonitor>& periodicAlarmMonitor, const int64_t timeBaseNs,
+ const int64_t currentTimeNs,
+ const vector<sp<LogMatchingTracker>>& oldAtomMatchers,
+ const unordered_map<int64_t, int>& oldLogTrackerMap, set<int>& allTagIds,
+ vector<sp<LogMatchingTracker>>& newAtomMatchers,
+ unordered_map<int64_t, int>& newLogTrackerMap) {
+ if (!updateLogTrackers(config, uidMap, oldLogTrackerMap, oldAtomMatchers, allTagIds,
+ newLogTrackerMap, newAtomMatchers)) {
+ ALOGE("updateLogMatchingTrackers failed");
+ return false;
+ }
+
+ return true;
+}
+
+} // namespace statsd
+} // namespace os
+} // namespace android
\ No newline at end of file
diff --git a/cmds/statsd/src/metrics/parsing_utils/config_update_utils.h b/cmds/statsd/src/metrics/parsing_utils/config_update_utils.h
new file mode 100644
index 0000000..951ab03
--- /dev/null
+++ b/cmds/statsd/src/metrics/parsing_utils/config_update_utils.h
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <vector>
+
+#include "anomaly/AlarmMonitor.h"
+#include "external/StatsPullerManager.h"
+#include "matchers/LogMatchingTracker.h"
+
+namespace android {
+namespace os {
+namespace statsd {
+
+// Helper functions for MetricsManager to update itself from a new StatsdConfig.
+// *Note*: only updateStatsdConfig() should be called from outside this file.
+// All other functions are intermediate steps, created to make unit testing easier.
+
+// Possible update states for a component. PRESERVE means we should keep the existing one.
+// REPLACE means we should create a new one, either because it didn't exist or it changed.
+enum UpdateStatus {
+ UPDATE_UNKNOWN = 0,
+ UPDATE_PRESERVE = 1,
+ UPDATE_REPLACE = 2,
+};
+
+// Recursive function to determine if a matcher needs to be updated.
+// input:
+// [config]: the input StatsdConfig
+// [matcherIdx]: the index of the current matcher to be updated
+// [newLogTrackerMap]: matcher id to index mapping in the input StatsdConfig
+// [oldLogTrackerMap]: matcher id to index mapping in the existing MetricsManager
+// [oldAtomMatchers]: stores the existing LogMatchingTrackers
+// output:
+// [matchersToUpdate]: vector of the update status of each matcher. The matcherIdx index will
+// be updated from UPDATE_UNKNOWN after this call.
+// [cycleTracker]: intermediate param used during recursion.
+bool determineMatcherUpdateStatus(const StatsdConfig& config, const int matcherIdx,
+ const unordered_map<int64_t, int>& oldLogTrackerMap,
+ const vector<sp<LogMatchingTracker>>& oldAtomMatchers,
+ const unordered_map<int64_t, int>& newLogTrackerMap,
+ vector<UpdateStatus>& matchersToUpdate,
+ vector<bool>& cycleTracker);
+
+// Updates the LogMatchingTrackers.
+// input:
+// [config]: the input StatsdConfig
+// [oldLogTrackerMap]: existing matcher id to index mapping
+// [oldAtomMatchers]: stores the existing LogMatchingTrackers
+// output:
+// [allTagIds]: contains the set of all interesting tag ids to this config.
+// [newLogTrackerMap]: new matcher id to index mapping
+// [newAtomMatchers]: stores the new LogMatchingTrackers
+bool updateLogTrackers(const StatsdConfig& config, const sp<UidMap>& uidMap,
+ const unordered_map<int64_t, int>& oldLogTrackerMap,
+ const vector<sp<LogMatchingTracker>>& oldAtomMatchers, set<int>& allTagIds,
+ unordered_map<int64_t, int>& newLogTrackerMap,
+ vector<sp<LogMatchingTracker>>& newAtomMatchers);
+
+// Updates the existing MetricsManager from a new StatsdConfig.
+// Parameters are the members of MetricsManager. See MetricsManager for declaration.
+bool updateStatsdConfig(const ConfigKey& key, const StatsdConfig& config, const sp<UidMap>& uidMap,
+ const sp<StatsPullerManager>& pullerManager,
+ const sp<AlarmMonitor>& anomalyAlarmMonitor,
+ const sp<AlarmMonitor>& periodicAlarmMonitor, const int64_t timeBaseNs,
+ const int64_t currentTimeNs,
+ const std::vector<sp<LogMatchingTracker>>& oldAtomMatchers,
+ const unordered_map<int64_t, int>& oldLogTrackerMap,
+ std::set<int>& allTagIds,
+ std::vector<sp<LogMatchingTracker>>& newAtomMatchers,
+ unordered_map<int64_t, int>& newLogTrackerMap);
+
+} // namespace statsd
+} // namespace os
+} // namespace android
\ No newline at end of file
diff --git a/cmds/statsd/src/metrics/metrics_manager_util.cpp b/cmds/statsd/src/metrics/parsing_utils/metrics_manager_util.cpp
similarity index 90%
rename from cmds/statsd/src/metrics/metrics_manager_util.cpp
rename to cmds/statsd/src/metrics/parsing_utils/metrics_manager_util.cpp
index 8917c36..52ef95d 100644
--- a/cmds/statsd/src/metrics/metrics_manager_util.cpp
+++ b/cmds/statsd/src/metrics/parsing_utils/metrics_manager_util.cpp
@@ -22,10 +22,10 @@
#include <inttypes.h>
#include "FieldValue.h"
-#include "MetricProducer.h"
#include "condition/CombinationConditionTracker.h"
#include "condition/SimpleConditionTracker.h"
#include "external/StatsPullerManager.h"
+#include "hash.h"
#include "matchers/CombinationLogMatchingTracker.h"
#include "matchers/EventMatcherWizard.h"
#include "matchers/SimpleLogMatchingTracker.h"
@@ -33,6 +33,7 @@
#include "metrics/DurationMetricProducer.h"
#include "metrics/EventMetricProducer.h"
#include "metrics/GaugeMetricProducer.h"
+#include "metrics/MetricProducer.h"
#include "metrics/ValueMetricProducer.h"
#include "state/StateManager.h"
#include "stats_util.h"
@@ -61,6 +62,28 @@
} // namespace
+sp<LogMatchingTracker> createLogTracker(const AtomMatcher& logMatcher, const int index,
+ const sp<UidMap>& uidMap) {
+ string serializedMatcher;
+ if (!logMatcher.SerializeToString(&serializedMatcher)) {
+ ALOGE("Unable to serialize matcher %lld", (long long)logMatcher.id());
+ return nullptr;
+ }
+ uint64_t protoHash = Hash64(serializedMatcher);
+ switch (logMatcher.contents_case()) {
+ case AtomMatcher::ContentsCase::kSimpleAtomMatcher:
+ return new SimpleLogMatchingTracker(logMatcher.id(), index, protoHash,
+ logMatcher.simple_atom_matcher(), uidMap);
+ break;
+ case AtomMatcher::ContentsCase::kCombination:
+ return new CombinationLogMatchingTracker(logMatcher.id(), index, protoHash);
+ break;
+ default:
+ ALOGE("Matcher \"%lld\" malformed", (long long)logMatcher.id());
+ return nullptr;
+ }
+}
+
bool handleMetricWithLogTrackers(const int64_t what, const int metricIndex,
const bool usedForDimension,
const vector<sp<LogMatchingTracker>>& allAtomMatchers,
@@ -184,9 +207,7 @@
// to provide the producer with state about its activators and deactivators.
// Returns false if there are errors.
bool handleMetricActivation(
- const StatsdConfig& config,
- const int64_t metricId,
- const int metricIndex,
+ const StatsdConfig& config, const int64_t metricId, const int metricIndex,
const unordered_map<int64_t, int>& metricToActivationMap,
const unordered_map<int64_t, int>& logTrackerMap,
unordered_map<int, vector<int>>& activationAtomTrackerToMetricMap,
@@ -210,10 +231,11 @@
return false;
}
- ActivationType activationType = (activation.has_activation_type()) ?
- activation.activation_type() : metricActivation.activation_type();
- std::shared_ptr<Activation> activationWrapper = std::make_shared<Activation>(
- activationType, activation.ttl_seconds() * NS_PER_SEC);
+ ActivationType activationType = (activation.has_activation_type())
+ ? activation.activation_type()
+ : metricActivation.activation_type();
+ std::shared_ptr<Activation> activationWrapper =
+ std::make_shared<Activation>(activationType, activation.ttl_seconds() * NS_PER_SEC);
int atomMatcherIndex = itr->second;
activationAtomTrackerToMetricMap[atomMatcherIndex].push_back(metricIndex);
@@ -235,7 +257,7 @@
return true;
}
-bool initLogTrackers(const StatsdConfig& config, const UidMap& uidMap,
+bool initLogTrackers(const StatsdConfig& config, const sp<UidMap>& uidMap,
unordered_map<int64_t, int>& logTrackerMap,
vector<sp<LogMatchingTracker>>& allAtomMatchers, set<int>& allTagIds) {
vector<AtomMatcher> matcherConfigs;
@@ -245,22 +267,12 @@
for (int i = 0; i < atomMatcherCount; i++) {
const AtomMatcher& logMatcher = config.atom_matcher(i);
-
int index = allAtomMatchers.size();
- switch (logMatcher.contents_case()) {
- case AtomMatcher::ContentsCase::kSimpleAtomMatcher:
- allAtomMatchers.push_back(new SimpleLogMatchingTracker(
- logMatcher.id(), index, logMatcher.simple_atom_matcher(), uidMap));
- break;
- case AtomMatcher::ContentsCase::kCombination:
- allAtomMatchers.push_back(
- new CombinationLogMatchingTracker(logMatcher.id(), index));
- break;
- default:
- ALOGE("Matcher \"%lld\" malformed", (long long)logMatcher.id());
- return false;
- // continue;
+ sp<LogMatchingTracker> tracker = createLogTracker(logMatcher, index, uidMap);
+ if (tracker == nullptr) {
+ return false;
}
+ allAtomMatchers.push_back(tracker);
if (logTrackerMap.find(logMatcher.id()) != logTrackerMap.end()) {
ALOGE("Duplicate AtomMatcher found!");
return false;
@@ -383,7 +395,7 @@
const MetricActivation& metricActivation = config.metric_activation(i);
int64_t metricId = metricActivation.metric_id();
if (metricToActivationMap.find(metricId) != metricToActivationMap.end()) {
- ALOGE("Metric %lld has multiple MetricActivations", (long long) metricId);
+ ALOGE("Metric %lld has multiple MetricActivations", (long long)metricId);
return false;
}
metricToActivationMap.insert({metricId, i});
@@ -402,9 +414,8 @@
metricMap.insert({metric.id(), metricIndex});
int trackerIndex;
if (!handleMetricWithLogTrackers(metric.what(), metricIndex,
- metric.has_dimensions_in_what(),
- allAtomMatchers, logTrackerMap, trackerToMetricMap,
- trackerIndex)) {
+ metric.has_dimensions_in_what(), allAtomMatchers,
+ logTrackerMap, trackerToMetricMap, trackerIndex)) {
return false;
}
@@ -438,10 +449,10 @@
unordered_map<int, shared_ptr<Activation>> eventActivationMap;
unordered_map<int, vector<shared_ptr<Activation>>> eventDeactivationMap;
- bool success = handleMetricActivation(config, metric.id(), metricIndex,
- metricToActivationMap, logTrackerMap, activationAtomTrackerToMetricMap,
- deactivationAtomTrackerToMetricMap, metricsWithActivation, eventActivationMap,
- eventDeactivationMap);
+ bool success = handleMetricActivation(
+ config, metric.id(), metricIndex, metricToActivationMap, logTrackerMap,
+ activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap,
+ metricsWithActivation, eventActivationMap, eventDeactivationMap);
if (!success) return false;
sp<MetricProducer> countProducer =
@@ -544,10 +555,10 @@
unordered_map<int, shared_ptr<Activation>> eventActivationMap;
unordered_map<int, vector<shared_ptr<Activation>>> eventDeactivationMap;
- bool success = handleMetricActivation(config, metric.id(), metricIndex,
- metricToActivationMap, logTrackerMap, activationAtomTrackerToMetricMap,
- deactivationAtomTrackerToMetricMap, metricsWithActivation, eventActivationMap,
- eventDeactivationMap);
+ bool success = handleMetricActivation(
+ config, metric.id(), metricIndex, metricToActivationMap, logTrackerMap,
+ activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap,
+ metricsWithActivation, eventActivationMap, eventDeactivationMap);
if (!success) return false;
sp<MetricProducer> durationMetric = new DurationMetricProducer(
@@ -591,10 +602,10 @@
unordered_map<int, shared_ptr<Activation>> eventActivationMap;
unordered_map<int, vector<shared_ptr<Activation>>> eventDeactivationMap;
- bool success = handleMetricActivation(config, metric.id(), metricIndex,
- metricToActivationMap, logTrackerMap, activationAtomTrackerToMetricMap,
- deactivationAtomTrackerToMetricMap, metricsWithActivation, eventActivationMap,
- eventDeactivationMap);
+ bool success = handleMetricActivation(
+ config, metric.id(), metricIndex, metricToActivationMap, logTrackerMap,
+ activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap,
+ metricsWithActivation, eventActivationMap, eventDeactivationMap);
if (!success) return false;
sp<MetricProducer> eventMetric =
@@ -626,9 +637,8 @@
metricMap.insert({metric.id(), metricIndex});
int trackerIndex;
if (!handleMetricWithLogTrackers(metric.what(), metricIndex,
- metric.has_dimensions_in_what(),
- allAtomMatchers, logTrackerMap, trackerToMetricMap,
- trackerIndex)) {
+ metric.has_dimensions_in_what(), allAtomMatchers,
+ logTrackerMap, trackerToMetricMap, trackerIndex)) {
return false;
}
@@ -718,9 +728,8 @@
metricMap.insert({metric.id(), metricIndex});
int trackerIndex;
if (!handleMetricWithLogTrackers(metric.what(), metricIndex,
- metric.has_dimensions_in_what(),
- allAtomMatchers, logTrackerMap, trackerToMetricMap,
- trackerIndex)) {
+ metric.has_dimensions_in_what(), allAtomMatchers,
+ logTrackerMap, trackerToMetricMap, trackerIndex)) {
return false;
}
@@ -775,10 +784,10 @@
unordered_map<int, shared_ptr<Activation>> eventActivationMap;
unordered_map<int, vector<shared_ptr<Activation>>> eventDeactivationMap;
- bool success = handleMetricActivation(config, metric.id(), metricIndex,
- metricToActivationMap, logTrackerMap, activationAtomTrackerToMetricMap,
- deactivationAtomTrackerToMetricMap, metricsWithActivation, eventActivationMap,
- eventDeactivationMap);
+ bool success = handleMetricActivation(
+ config, metric.id(), metricIndex, metricToActivationMap, logTrackerMap,
+ activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap,
+ metricsWithActivation, eventActivationMap, eventDeactivationMap);
if (!success) return false;
sp<MetricProducer> gaugeProducer = new GaugeMetricProducer(
@@ -813,8 +822,7 @@
return true;
}
-bool initAlerts(const StatsdConfig& config,
- const unordered_map<int64_t, int>& metricProducerMap,
+bool initAlerts(const StatsdConfig& config, const unordered_map<int64_t, int>& metricProducerMap,
unordered_map<int64_t, int>& alertTrackerMap,
const sp<AlarmMonitor>& anomalyAlarmMonitor,
vector<sp<MetricProducer>>& allMetricProducers,
@@ -832,8 +840,8 @@
return false;
}
if (alert.trigger_if_sum_gt() < 0 || alert.num_buckets() <= 0) {
- ALOGW("invalid alert: threshold=%f num_buckets= %d",
- alert.trigger_if_sum_gt(), alert.num_buckets());
+ ALOGW("invalid alert: threshold=%f num_buckets= %d", alert.trigger_if_sum_gt(),
+ alert.num_buckets());
return false;
}
const int metricIndex = itr->second;
@@ -853,14 +861,13 @@
}
if (subscription.subscriber_information_case() ==
Subscription::SubscriberInformationCase::SUBSCRIBER_INFORMATION_NOT_SET) {
- ALOGW("subscription \"%lld\" has no subscriber info.\"",
- (long long)subscription.id());
+ ALOGW("subscription \"%lld\" has no subscriber info.\"", (long long)subscription.id());
return false;
}
const auto& itr = alertTrackerMap.find(subscription.rule_id());
if (itr == alertTrackerMap.end()) {
ALOGW("subscription \"%lld\" has unknown rule id: \"%lld\"",
- (long long)subscription.id(), (long long)subscription.rule_id());
+ (long long)subscription.id(), (long long)subscription.rule_id());
return false;
}
const int anomalyTrackerIndex = itr->second;
@@ -870,12 +877,11 @@
}
bool initAlarms(const StatsdConfig& config, const ConfigKey& key,
- const sp<AlarmMonitor>& periodicAlarmMonitor,
- const int64_t timeBaseNs, const int64_t currentTimeNs,
- vector<sp<AlarmTracker>>& allAlarmTrackers) {
+ const sp<AlarmMonitor>& periodicAlarmMonitor, const int64_t timeBaseNs,
+ const int64_t currentTimeNs, vector<sp<AlarmTracker>>& allAlarmTrackers) {
unordered_map<int64_t, int> alarmTrackerMap;
int64_t startMillis = timeBaseNs / 1000 / 1000;
- int64_t currentTimeMillis = currentTimeNs / 1000 /1000;
+ int64_t currentTimeMillis = currentTimeNs / 1000 / 1000;
for (int i = 0; i < config.alarm_size(); i++) {
const Alarm& alarm = config.alarm(i);
if (alarm.offset_millis() <= 0) {
@@ -888,8 +894,7 @@
}
alarmTrackerMap.insert(std::make_pair(alarm.id(), allAlarmTrackers.size()));
allAlarmTrackers.push_back(
- new AlarmTracker(startMillis, currentTimeMillis,
- alarm, key, periodicAlarmMonitor));
+ new AlarmTracker(startMillis, currentTimeMillis, alarm, key, periodicAlarmMonitor));
}
for (int i = 0; i < config.subscription_size(); ++i) {
const Subscription& subscription = config.subscription(i);
@@ -898,14 +903,13 @@
}
if (subscription.subscriber_information_case() ==
Subscription::SubscriberInformationCase::SUBSCRIBER_INFORMATION_NOT_SET) {
- ALOGW("subscription \"%lld\" has no subscriber info.\"",
- (long long)subscription.id());
+ ALOGW("subscription \"%lld\" has no subscriber info.\"", (long long)subscription.id());
return false;
}
const auto& itr = alarmTrackerMap.find(subscription.rule_id());
if (itr == alarmTrackerMap.end()) {
ALOGW("subscription \"%lld\" has unknown rule id: \"%lld\"",
- (long long)subscription.id(), (long long)subscription.rule_id());
+ (long long)subscription.id(), (long long)subscription.rule_id());
return false;
}
const int trackerIndex = itr->second;
@@ -914,12 +918,13 @@
return true;
}
-bool initStatsdConfig(const ConfigKey& key, const StatsdConfig& config, UidMap& uidMap,
+bool initStatsdConfig(const ConfigKey& key, const StatsdConfig& config, const sp<UidMap>& uidMap,
const sp<StatsPullerManager>& pullerManager,
const sp<AlarmMonitor>& anomalyAlarmMonitor,
const sp<AlarmMonitor>& periodicAlarmMonitor, const int64_t timeBaseNs,
const int64_t currentTimeNs, set<int>& allTagIds,
vector<sp<LogMatchingTracker>>& allAtomMatchers,
+ unordered_map<int64_t, int>& logTrackerMap,
vector<sp<ConditionTracker>>& allConditionTrackers,
vector<sp<MetricProducer>>& allMetricProducers,
vector<sp<AnomalyTracker>>& allAnomalyTrackers,
@@ -930,9 +935,7 @@
unordered_map<int, std::vector<int>>& activationAtomTrackerToMetricMap,
unordered_map<int, std::vector<int>>& deactivationAtomTrackerToMetricMap,
unordered_map<int64_t, int>& alertTrackerMap,
- vector<int>& metricsWithActivation,
- std::set<int64_t>& noReportMetricIds) {
- unordered_map<int64_t, int> logTrackerMap;
+ vector<int>& metricsWithActivation, std::set<int64_t>& noReportMetricIds) {
unordered_map<int64_t, int> conditionTrackerMap;
vector<ConditionState> initialConditionCache;
unordered_map<int64_t, int> metricProducerMap;
@@ -969,8 +972,8 @@
ALOGE("initAlerts failed");
return false;
}
- if (!initAlarms(config, key, periodicAlarmMonitor,
- timeBaseNs, currentTimeNs, allPeriodicAlarmTrackers)) {
+ if (!initAlarms(config, key, periodicAlarmMonitor, timeBaseNs, currentTimeNs,
+ allPeriodicAlarmTrackers)) {
ALOGE("initAlarms failed");
return false;
}
diff --git a/cmds/statsd/src/metrics/metrics_manager_util.h b/cmds/statsd/src/metrics/parsing_utils/metrics_manager_util.h
similarity index 86%
rename from cmds/statsd/src/metrics/metrics_manager_util.h
rename to cmds/statsd/src/metrics/parsing_utils/metrics_manager_util.h
index 96b5c26..ed9951f 100644
--- a/cmds/statsd/src/metrics/metrics_manager_util.h
+++ b/cmds/statsd/src/metrics/parsing_utils/metrics_manager_util.h
@@ -20,16 +20,28 @@
#include <unordered_map>
#include <vector>
-#include "../anomaly/AlarmTracker.h"
-#include "../condition/ConditionTracker.h"
-#include "../external/StatsPullerManager.h"
-#include "../matchers/LogMatchingTracker.h"
-#include "../metrics/MetricProducer.h"
+#include "anomaly/AlarmTracker.h"
+#include "condition/ConditionTracker.h"
+#include "external/StatsPullerManager.h"
+#include "matchers/LogMatchingTracker.h"
+#include "metrics/MetricProducer.h"
namespace android {
namespace os {
namespace statsd {
+// Helper functions for creating individual config components from StatsdConfig.
+// Should only be called from metrics_manager_util and config_update_utils.
+
+// Create a LogMatchingTracker.
+// input:
+// [logMatcher]: the input AtomMatcher from the StatsdConfig
+// [index]: the index of the matcher
+// output:
+// new LogMatchingTracker, or null if the tracker is unable to be created
+sp<LogMatchingTracker> createLogTracker(const AtomMatcher& logMatcher, const int index,
+ const sp<UidMap>& uidMap);
+
// Helper functions for MetricsManager to initialize from StatsdConfig.
// *Note*: only initStatsdConfig() should be called from outside.
// All other functions are intermediate
@@ -44,8 +56,7 @@
// [logTrackerMap]: this map should contain matcher name to index mapping
// [allAtomMatchers]: should store the sp to all the LogMatchingTracker
// [allTagIds]: contains the set of all interesting tag ids to this config.
-bool initLogTrackers(const StatsdConfig& config,
- const UidMap& uidMap,
+bool initLogTrackers(const StatsdConfig& config, const sp<UidMap>& uidMap,
std::unordered_map<int64_t, int>& logTrackerMap,
std::vector<sp<LogMatchingTracker>>& allAtomMatchers,
std::set<int>& allTagIds);
@@ -97,7 +108,7 @@
// [trackerToMetricMap]: contains the mapping from log tracker to MetricProducer index.
bool initMetrics(
const ConfigKey& key, const StatsdConfig& config, const int64_t timeBaseTimeNs,
- const int64_t currentTimeNs, UidMap& uidMap, const sp<StatsPullerManager>& pullerManager,
+ const int64_t currentTimeNs, const sp<StatsPullerManager>& pullerManager,
const std::unordered_map<int64_t, int>& logTrackerMap,
const std::unordered_map<int64_t, int>& conditionTrackerMap,
const std::unordered_map<int, std::vector<MetricConditionLink>>& eventConditionLinks,
@@ -116,12 +127,13 @@
// Initialize MetricsManager from StatsdConfig.
// Parameters are the members of MetricsManager. See MetricsManager for declaration.
-bool initStatsdConfig(const ConfigKey& key, const StatsdConfig& config, UidMap& uidMap,
+bool initStatsdConfig(const ConfigKey& key, const StatsdConfig& config, const sp<UidMap>& uidMap,
const sp<StatsPullerManager>& pullerManager,
const sp<AlarmMonitor>& anomalyAlarmMonitor,
const sp<AlarmMonitor>& periodicAlarmMonitor, const int64_t timeBaseNs,
const int64_t currentTimeNs, std::set<int>& allTagIds,
std::vector<sp<LogMatchingTracker>>& allAtomMatchers,
+ std::unordered_map<int64_t, int>& logTrackerMap,
std::vector<sp<ConditionTracker>>& allConditionTrackers,
std::vector<sp<MetricProducer>>& allMetricProducers,
vector<sp<AnomalyTracker>>& allAnomalyTrackers,
@@ -132,8 +144,7 @@
unordered_map<int, std::vector<int>>& activationAtomTrackerToMetricMap,
unordered_map<int, std::vector<int>>& deactivationAtomTrackerToMetricMap,
std::unordered_map<int64_t, int>& alertTrackerMap,
- vector<int>& metricsWithActivation,
- std::set<int64_t>& noReportMetricIds);
+ vector<int>& metricsWithActivation, std::set<int64_t>& noReportMetricIds);
} // namespace statsd
} // namespace os
diff --git a/cmds/statsd/src/shell/ShellSubscriber.cpp b/cmds/statsd/src/shell/ShellSubscriber.cpp
index fd883c2..9d8f0c2 100644
--- a/cmds/statsd/src/shell/ShellSubscriber.cpp
+++ b/cmds/statsd/src/shell/ShellSubscriber.cpp
@@ -191,7 +191,7 @@
mProto.clear();
int count = 0;
for (const auto& event : data) {
- if (matchesSimple(*mUidMap, matcher, *event)) {
+ if (matchesSimple(mUidMap, matcher, *event)) {
count++;
uint64_t atomToken = mProto.start(util::FIELD_TYPE_MESSAGE |
util::FIELD_COUNT_REPEATED | FIELD_ID_ATOM);
@@ -209,7 +209,7 @@
mProto.clear();
for (const auto& matcher : mSubscriptionInfo->mPushedMatchers) {
- if (matchesSimple(*mUidMap, matcher, event)) {
+ if (matchesSimple(mUidMap, matcher, event)) {
uint64_t atomToken = mProto.start(util::FIELD_TYPE_MESSAGE |
util::FIELD_COUNT_REPEATED | FIELD_ID_ATOM);
event.ToProto(mProto);
diff --git a/cmds/statsd/tests/LogEntryMatcher_test.cpp b/cmds/statsd/tests/LogEntryMatcher_test.cpp
index 6264c07..92cd04f 100644
--- a/cmds/statsd/tests/LogEntryMatcher_test.cpp
+++ b/cmds/statsd/tests/LogEntryMatcher_test.cpp
@@ -110,7 +110,7 @@
} // anonymous namespace
TEST(AtomMatcherTest, TestSimpleMatcher) {
- UidMap uidMap;
+ sp<UidMap> uidMap = new UidMap();
// Set up the matcher
AtomMatcher matcher;
@@ -129,7 +129,7 @@
}
TEST(AtomMatcherTest, TestAttributionMatcher) {
- UidMap uidMap;
+ sp<UidMap> uidMap = new UidMap();
std::vector<int> attributionUids = {1111, 2222, 3333};
std::vector<string> attributionTags = {"location1", "location2", "location3"};
@@ -204,7 +204,7 @@
"pkg0");
EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
- uidMap.updateMap(
+ uidMap->updateMap(
1, {1111, 1111, 2222, 3333, 3333} /* uid list */, {1, 1, 2, 1, 2} /* version list */,
{android::String16("v1"), android::String16("v1"), android::String16("v2"),
android::String16("v1"), android::String16("v2")},
@@ -356,8 +356,8 @@
}
TEST(AtomMatcherTest, TestUidFieldMatcher) {
- UidMap uidMap;
- uidMap.updateMap(
+ sp<UidMap> uidMap = new UidMap();
+ uidMap->updateMap(
1, {1111, 1111, 2222, 3333, 3333} /* uid list */, {1, 1, 2, 1, 2} /* version list */,
{android::String16("v1"), android::String16("v1"), android::String16("v2"),
android::String16("v1"), android::String16("v2")},
@@ -392,8 +392,8 @@
}
TEST(AtomMatcherTest, TestNeqAnyStringMatcher) {
- UidMap uidMap;
- uidMap.updateMap(
+ sp<UidMap> uidMap = new UidMap();
+ uidMap->updateMap(
1, {1111, 1111, 2222, 3333, 3333} /* uid list */, {1, 1, 2, 1, 2} /* version list */,
{android::String16("v1"), android::String16("v1"), android::String16("v2"),
android::String16("v1"), android::String16("v2")},
@@ -453,8 +453,8 @@
}
TEST(AtomMatcherTest, TestEqAnyStringMatcher) {
- UidMap uidMap;
- uidMap.updateMap(
+ sp<UidMap> uidMap = new UidMap();
+ uidMap->updateMap(
1, {1111, 1111, 2222, 3333, 3333} /* uid list */, {1, 1, 2, 1, 2} /* version list */,
{android::String16("v1"), android::String16("v1"), android::String16("v2"),
android::String16("v1"), android::String16("v2")},
@@ -517,7 +517,7 @@
}
TEST(AtomMatcherTest, TestBoolMatcher) {
- UidMap uidMap;
+ sp<UidMap> uidMap = new UidMap();
// Set up the matcher
AtomMatcher matcher;
auto simpleMatcher = matcher.mutable_simple_atom_matcher();
@@ -550,7 +550,7 @@
}
TEST(AtomMatcherTest, TestStringMatcher) {
- UidMap uidMap;
+ sp<UidMap> uidMap = new UidMap();
// Set up the matcher
AtomMatcher matcher;
auto simpleMatcher = matcher.mutable_simple_atom_matcher();
@@ -568,7 +568,7 @@
}
TEST(AtomMatcherTest, TestMultiFieldsMatcher) {
- UidMap uidMap;
+ sp<UidMap> uidMap = new UidMap();
// Set up the matcher
AtomMatcher matcher;
auto simpleMatcher = matcher.mutable_simple_atom_matcher();
@@ -597,7 +597,7 @@
}
TEST(AtomMatcherTest, TestIntComparisonMatcher) {
- UidMap uidMap;
+ sp<UidMap> uidMap = new UidMap();
// Set up the matcher
AtomMatcher matcher;
auto simpleMatcher = matcher.mutable_simple_atom_matcher();
@@ -654,7 +654,7 @@
}
TEST(AtomMatcherTest, TestFloatComparisonMatcher) {
- UidMap uidMap;
+ sp<UidMap> uidMap = new UidMap();
// Set up the matcher
AtomMatcher matcher;
auto simpleMatcher = matcher.mutable_simple_atom_matcher();
diff --git a/cmds/statsd/tests/MetricsManager_test.cpp b/cmds/statsd/tests/MetricsManager_test.cpp
index 6259757..8dd6083 100644
--- a/cmds/statsd/tests/MetricsManager_test.cpp
+++ b/cmds/statsd/tests/MetricsManager_test.cpp
@@ -28,7 +28,7 @@
#include "src/metrics/GaugeMetricProducer.h"
#include "src/metrics/MetricProducer.h"
#include "src/metrics/ValueMetricProducer.h"
-#include "src/metrics/metrics_manager_util.h"
+#include "src/metrics/parsing_utils/metrics_manager_util.h"
#include "src/state/StateManager.h"
#include "statsd_test_util.h"
@@ -48,7 +48,6 @@
namespace {
const ConfigKey kConfigKey(0, 12345);
-const long kAlertId = 3;
const long timeBaseSec = 1000;
@@ -90,287 +89,6 @@
metric->set_bucket(ONE_MINUTE);
metric->mutable_dimensions_in_what()->set_field(2 /*SCREEN_STATE_CHANGE*/);
metric->mutable_dimensions_in_what()->add_child()->set_field(1);
-
- config.add_no_report_metric(3);
-
- auto alert = config.add_alert();
- alert->set_id(kAlertId);
- alert->set_metric_id(3);
- alert->set_num_buckets(10);
- alert->set_refractory_period_secs(100);
- alert->set_trigger_if_sum_gt(100);
- return config;
-}
-
-StatsdConfig buildCircleMatchers() {
- StatsdConfig config;
- config.set_id(12345);
-
- AtomMatcher* eventMatcher = config.add_atom_matcher();
- eventMatcher->set_id(StringToId("SCREEN_IS_ON"));
-
- SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
- simpleAtomMatcher->set_atom_id(2 /*SCREEN_STATE_CHANGE*/);
- simpleAtomMatcher->add_field_value_matcher()->set_field(
- 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/);
- simpleAtomMatcher->mutable_field_value_matcher(0)->set_eq_int(
- 2 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_ON*/);
-
- eventMatcher = config.add_atom_matcher();
- eventMatcher->set_id(StringToId("SCREEN_ON_OR_OFF"));
-
- AtomMatcher_Combination* combination = eventMatcher->mutable_combination();
- combination->set_operation(LogicalOperation::OR);
- combination->add_matcher(StringToId("SCREEN_IS_ON"));
- // Circle dependency
- combination->add_matcher(StringToId("SCREEN_ON_OR_OFF"));
-
- return config;
-}
-
-StatsdConfig buildAlertWithUnknownMetric() {
- StatsdConfig config;
- config.set_id(12345);
-
- AtomMatcher* eventMatcher = config.add_atom_matcher();
- eventMatcher->set_id(StringToId("SCREEN_IS_ON"));
-
- CountMetric* metric = config.add_count_metric();
- metric->set_id(3);
- metric->set_what(StringToId("SCREEN_IS_ON"));
- metric->set_bucket(ONE_MINUTE);
- metric->mutable_dimensions_in_what()->set_field(2 /*SCREEN_STATE_CHANGE*/);
- metric->mutable_dimensions_in_what()->add_child()->set_field(1);
-
- auto alert = config.add_alert();
- alert->set_id(3);
- alert->set_metric_id(2);
- alert->set_num_buckets(10);
- alert->set_refractory_period_secs(100);
- alert->set_trigger_if_sum_gt(100);
- return config;
-}
-
-StatsdConfig buildMissingMatchers() {
- StatsdConfig config;
- config.set_id(12345);
-
- AtomMatcher* eventMatcher = config.add_atom_matcher();
- eventMatcher->set_id(StringToId("SCREEN_IS_ON"));
-
- SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
- simpleAtomMatcher->set_atom_id(2 /*SCREEN_STATE_CHANGE*/);
- simpleAtomMatcher->add_field_value_matcher()->set_field(
- 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/);
- simpleAtomMatcher->mutable_field_value_matcher(0)->set_eq_int(
- 2 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_ON*/);
-
- eventMatcher = config.add_atom_matcher();
- eventMatcher->set_id(StringToId("SCREEN_ON_OR_OFF"));
-
- AtomMatcher_Combination* combination = eventMatcher->mutable_combination();
- combination->set_operation(LogicalOperation::OR);
- combination->add_matcher(StringToId("SCREEN_IS_ON"));
- // undefined matcher
- combination->add_matcher(StringToId("ABC"));
-
- return config;
-}
-
-StatsdConfig buildMissingPredicate() {
- StatsdConfig config;
- config.set_id(12345);
-
- CountMetric* metric = config.add_count_metric();
- metric->set_id(3);
- metric->set_what(StringToId("SCREEN_EVENT"));
- metric->set_bucket(ONE_MINUTE);
- metric->set_condition(StringToId("SOME_CONDITION"));
-
- AtomMatcher* eventMatcher = config.add_atom_matcher();
- eventMatcher->set_id(StringToId("SCREEN_EVENT"));
-
- SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
- simpleAtomMatcher->set_atom_id(2);
-
- return config;
-}
-
-StatsdConfig buildDimensionMetricsWithMultiTags() {
- StatsdConfig config;
- config.set_id(12345);
-
- AtomMatcher* eventMatcher = config.add_atom_matcher();
- eventMatcher->set_id(StringToId("BATTERY_VERY_LOW"));
- SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
- simpleAtomMatcher->set_atom_id(2);
-
- eventMatcher = config.add_atom_matcher();
- eventMatcher->set_id(StringToId("BATTERY_VERY_VERY_LOW"));
- simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
- simpleAtomMatcher->set_atom_id(3);
-
- eventMatcher = config.add_atom_matcher();
- eventMatcher->set_id(StringToId("BATTERY_LOW"));
-
- AtomMatcher_Combination* combination = eventMatcher->mutable_combination();
- combination->set_operation(LogicalOperation::OR);
- combination->add_matcher(StringToId("BATTERY_VERY_LOW"));
- combination->add_matcher(StringToId("BATTERY_VERY_VERY_LOW"));
-
- // Count process state changes, slice by uid, while SCREEN_IS_OFF
- CountMetric* metric = config.add_count_metric();
- metric->set_id(3);
- metric->set_what(StringToId("BATTERY_LOW"));
- metric->set_bucket(ONE_MINUTE);
- // This case is interesting. We want to dimension across two atoms.
- metric->mutable_dimensions_in_what()->add_child()->set_field(1);
-
- auto alert = config.add_alert();
- alert->set_id(kAlertId);
- alert->set_metric_id(3);
- alert->set_num_buckets(10);
- alert->set_refractory_period_secs(100);
- alert->set_trigger_if_sum_gt(100);
- return config;
-}
-
-StatsdConfig buildCirclePredicates() {
- StatsdConfig config;
- config.set_id(12345);
-
- AtomMatcher* eventMatcher = config.add_atom_matcher();
- eventMatcher->set_id(StringToId("SCREEN_IS_ON"));
-
- SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
- simpleAtomMatcher->set_atom_id(2 /*SCREEN_STATE_CHANGE*/);
- simpleAtomMatcher->add_field_value_matcher()->set_field(
- 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/);
- simpleAtomMatcher->mutable_field_value_matcher(0)->set_eq_int(
- 2 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_ON*/);
-
- eventMatcher = config.add_atom_matcher();
- eventMatcher->set_id(StringToId("SCREEN_IS_OFF"));
-
- simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
- simpleAtomMatcher->set_atom_id(2 /*SCREEN_STATE_CHANGE*/);
- simpleAtomMatcher->add_field_value_matcher()->set_field(
- 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/);
- simpleAtomMatcher->mutable_field_value_matcher(0)->set_eq_int(
- 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_OFF*/);
-
- auto condition = config.add_predicate();
- condition->set_id(StringToId("SCREEN_IS_ON"));
- SimplePredicate* simplePredicate = condition->mutable_simple_predicate();
- simplePredicate->set_start(StringToId("SCREEN_IS_ON"));
- simplePredicate->set_stop(StringToId("SCREEN_IS_OFF"));
-
- condition = config.add_predicate();
- condition->set_id(StringToId("SCREEN_IS_EITHER_ON_OFF"));
-
- Predicate_Combination* combination = condition->mutable_combination();
- combination->set_operation(LogicalOperation::OR);
- combination->add_predicate(StringToId("SCREEN_IS_ON"));
- combination->add_predicate(StringToId("SCREEN_IS_EITHER_ON_OFF"));
-
- return config;
-}
-
-StatsdConfig buildConfigWithDifferentPredicates() {
- StatsdConfig config;
- config.set_id(12345);
-
- auto pulledAtomMatcher =
- CreateSimpleAtomMatcher("SUBSYSTEM_SLEEP", util::SUBSYSTEM_SLEEP_STATE);
- *config.add_atom_matcher() = pulledAtomMatcher;
- auto screenOnAtomMatcher = CreateScreenTurnedOnAtomMatcher();
- *config.add_atom_matcher() = screenOnAtomMatcher;
- auto screenOffAtomMatcher = CreateScreenTurnedOffAtomMatcher();
- *config.add_atom_matcher() = screenOffAtomMatcher;
- auto batteryNoneAtomMatcher = CreateBatteryStateNoneMatcher();
- *config.add_atom_matcher() = batteryNoneAtomMatcher;
- auto batteryUsbAtomMatcher = CreateBatteryStateUsbMatcher();
- *config.add_atom_matcher() = batteryUsbAtomMatcher;
-
- // Simple condition with InitialValue set to default (unknown).
- auto screenOnUnknownPredicate = CreateScreenIsOnPredicate();
- *config.add_predicate() = screenOnUnknownPredicate;
-
- // Simple condition with InitialValue set to false.
- auto screenOnFalsePredicate = config.add_predicate();
- screenOnFalsePredicate->set_id(StringToId("ScreenIsOnInitialFalse"));
- SimplePredicate* simpleScreenOnFalsePredicate =
- screenOnFalsePredicate->mutable_simple_predicate();
- simpleScreenOnFalsePredicate->set_start(screenOnAtomMatcher.id());
- simpleScreenOnFalsePredicate->set_stop(screenOffAtomMatcher.id());
- simpleScreenOnFalsePredicate->set_initial_value(SimplePredicate_InitialValue_FALSE);
-
- // Simple condition with InitialValue set to false.
- auto onBatteryFalsePredicate = config.add_predicate();
- onBatteryFalsePredicate->set_id(StringToId("OnBatteryInitialFalse"));
- SimplePredicate* simpleOnBatteryFalsePredicate =
- onBatteryFalsePredicate->mutable_simple_predicate();
- simpleOnBatteryFalsePredicate->set_start(batteryNoneAtomMatcher.id());
- simpleOnBatteryFalsePredicate->set_stop(batteryUsbAtomMatcher.id());
- simpleOnBatteryFalsePredicate->set_initial_value(SimplePredicate_InitialValue_FALSE);
-
- // Combination condition with both simple condition InitialValues set to false.
- auto screenOnFalseOnBatteryFalsePredicate = config.add_predicate();
- screenOnFalseOnBatteryFalsePredicate->set_id(StringToId("ScreenOnFalseOnBatteryFalse"));
- screenOnFalseOnBatteryFalsePredicate->mutable_combination()->set_operation(
- LogicalOperation::AND);
- addPredicateToPredicateCombination(*screenOnFalsePredicate,
- screenOnFalseOnBatteryFalsePredicate);
- addPredicateToPredicateCombination(*onBatteryFalsePredicate,
- screenOnFalseOnBatteryFalsePredicate);
-
- // Combination condition with one simple condition InitialValue set to unknown and one set to
- // false.
- auto screenOnUnknownOnBatteryFalsePredicate = config.add_predicate();
- screenOnUnknownOnBatteryFalsePredicate->set_id(StringToId("ScreenOnUnknowneOnBatteryFalse"));
- screenOnUnknownOnBatteryFalsePredicate->mutable_combination()->set_operation(
- LogicalOperation::AND);
- addPredicateToPredicateCombination(screenOnUnknownPredicate,
- screenOnUnknownOnBatteryFalsePredicate);
- addPredicateToPredicateCombination(*onBatteryFalsePredicate,
- screenOnUnknownOnBatteryFalsePredicate);
-
- // Simple condition metric with initial value false.
- ValueMetric* metric1 = config.add_value_metric();
- metric1->set_id(StringToId("ValueSubsystemSleepWhileScreenOnInitialFalse"));
- metric1->set_what(pulledAtomMatcher.id());
- *metric1->mutable_value_field() =
- CreateDimensions(util::SUBSYSTEM_SLEEP_STATE, {4 /* time sleeping field */});
- metric1->set_bucket(FIVE_MINUTES);
- metric1->set_condition(screenOnFalsePredicate->id());
-
- // Simple condition metric with initial value unknown.
- ValueMetric* metric2 = config.add_value_metric();
- metric2->set_id(StringToId("ValueSubsystemSleepWhileScreenOnInitialUnknown"));
- metric2->set_what(pulledAtomMatcher.id());
- *metric2->mutable_value_field() =
- CreateDimensions(util::SUBSYSTEM_SLEEP_STATE, {4 /* time sleeping field */});
- metric2->set_bucket(FIVE_MINUTES);
- metric2->set_condition(screenOnUnknownPredicate.id());
-
- // Combination condition metric with initial values false and false.
- ValueMetric* metric3 = config.add_value_metric();
- metric3->set_id(StringToId("ValueSubsystemSleepWhileScreenOnFalseDeviceUnpluggedFalse"));
- metric3->set_what(pulledAtomMatcher.id());
- *metric3->mutable_value_field() =
- CreateDimensions(util::SUBSYSTEM_SLEEP_STATE, {4 /* time sleeping field */});
- metric3->set_bucket(FIVE_MINUTES);
- metric3->set_condition(screenOnFalseOnBatteryFalsePredicate->id());
-
- // Combination condition metric with initial values unknown and false.
- ValueMetric* metric4 = config.add_value_metric();
- metric4->set_id(StringToId("ValueSubsystemSleepWhileScreenOnUnknownDeviceUnpluggedFalse"));
- metric4->set_what(pulledAtomMatcher.id());
- *metric4->mutable_value_field() =
- CreateDimensions(util::SUBSYSTEM_SLEEP_STATE, {4 /* time sleeping field */});
- metric4->set_bucket(FIVE_MINUTES);
- metric4->set_condition(screenOnUnknownOnBatteryFalsePredicate->id());
-
return config;
}
@@ -379,274 +97,6 @@
}
} // anonymous namespace
-TEST(MetricsManagerTest, TestInitialConditions) {
- UidMap uidMap;
- sp<StatsPullerManager> pullerManager = new StatsPullerManager();
- sp<AlarmMonitor> anomalyAlarmMonitor;
- sp<AlarmMonitor> periodicAlarmMonitor;
- StatsdConfig config = buildConfigWithDifferentPredicates();
- set<int> allTagIds;
- vector<sp<LogMatchingTracker>> allAtomMatchers;
- vector<sp<ConditionTracker>> allConditionTrackers;
- vector<sp<MetricProducer>> allMetricProducers;
- std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
- std::vector<sp<AlarmTracker>> allAlarmTrackers;
- unordered_map<int, std::vector<int>> conditionToMetricMap;
- unordered_map<int, std::vector<int>> trackerToMetricMap;
- unordered_map<int, std::vector<int>> trackerToConditionMap;
- unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
- unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
- unordered_map<int64_t, int> alertTrackerMap;
- vector<int> metricsWithActivation;
- std::set<int64_t> noReportMetricIds;
-
- EXPECT_TRUE(initStatsdConfig(
- kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor, periodicAlarmMonitor,
- timeBaseSec, timeBaseSec, allTagIds, allAtomMatchers, allConditionTrackers,
- allMetricProducers, allAnomalyTrackers, allAlarmTrackers, conditionToMetricMap,
- trackerToMetricMap, trackerToConditionMap, activationAtomTrackerToMetricMap,
- deactivationAtomTrackerToMetricMap, alertTrackerMap, metricsWithActivation,
- noReportMetricIds));
- ASSERT_EQ(4u, allMetricProducers.size());
- ASSERT_EQ(5u, allConditionTrackers.size());
-
- ConditionKey queryKey;
- vector<ConditionState> conditionCache(5, ConditionState::kNotEvaluated);
-
- allConditionTrackers[3]->isConditionMet(queryKey, allConditionTrackers, false, conditionCache);
- allConditionTrackers[4]->isConditionMet(queryKey, allConditionTrackers, false, conditionCache);
- EXPECT_EQ(ConditionState::kUnknown, conditionCache[0]);
- EXPECT_EQ(ConditionState::kFalse, conditionCache[1]);
- EXPECT_EQ(ConditionState::kFalse, conditionCache[2]);
- EXPECT_EQ(ConditionState::kFalse, conditionCache[3]);
- EXPECT_EQ(ConditionState::kUnknown, conditionCache[4]);
-
- EXPECT_EQ(ConditionState::kFalse, allMetricProducers[0]->mCondition);
- EXPECT_EQ(ConditionState::kUnknown, allMetricProducers[1]->mCondition);
- EXPECT_EQ(ConditionState::kFalse, allMetricProducers[2]->mCondition);
- EXPECT_EQ(ConditionState::kUnknown, allMetricProducers[3]->mCondition);
-}
-
-TEST(MetricsManagerTest, TestGoodConfig) {
- UidMap uidMap;
- sp<StatsPullerManager> pullerManager = new StatsPullerManager();
- sp<AlarmMonitor> anomalyAlarmMonitor;
- sp<AlarmMonitor> periodicAlarmMonitor;
- StatsdConfig config = buildGoodConfig();
- set<int> allTagIds;
- vector<sp<LogMatchingTracker>> allAtomMatchers;
- vector<sp<ConditionTracker>> allConditionTrackers;
- vector<sp<MetricProducer>> allMetricProducers;
- std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
- std::vector<sp<AlarmTracker>> allAlarmTrackers;
- unordered_map<int, std::vector<int>> conditionToMetricMap;
- unordered_map<int, std::vector<int>> trackerToMetricMap;
- unordered_map<int, std::vector<int>> trackerToConditionMap;
- unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
- unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
- unordered_map<int64_t, int> alertTrackerMap;
- vector<int> metricsWithActivation;
- std::set<int64_t> noReportMetricIds;
-
- EXPECT_TRUE(initStatsdConfig(kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor,
- periodicAlarmMonitor, timeBaseSec, timeBaseSec, allTagIds,
- allAtomMatchers, allConditionTrackers, allMetricProducers,
- allAnomalyTrackers, allAlarmTrackers, conditionToMetricMap,
- trackerToMetricMap, trackerToConditionMap,
- activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap,
- alertTrackerMap, metricsWithActivation,
- noReportMetricIds));
- ASSERT_EQ(1u, allMetricProducers.size());
- ASSERT_EQ(1u, allAnomalyTrackers.size());
- ASSERT_EQ(1u, noReportMetricIds.size());
- ASSERT_EQ(1u, alertTrackerMap.size());
- EXPECT_NE(alertTrackerMap.find(kAlertId), alertTrackerMap.end());
- EXPECT_EQ(alertTrackerMap.find(kAlertId)->second, 0);
-}
-
-TEST(MetricsManagerTest, TestDimensionMetricsWithMultiTags) {
- UidMap uidMap;
- sp<StatsPullerManager> pullerManager = new StatsPullerManager();
- sp<AlarmMonitor> anomalyAlarmMonitor;
- sp<AlarmMonitor> periodicAlarmMonitor;
- StatsdConfig config = buildDimensionMetricsWithMultiTags();
- set<int> allTagIds;
- vector<sp<LogMatchingTracker>> allAtomMatchers;
- vector<sp<ConditionTracker>> allConditionTrackers;
- vector<sp<MetricProducer>> allMetricProducers;
- std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
- std::vector<sp<AlarmTracker>> allAlarmTrackers;
- unordered_map<int, std::vector<int>> conditionToMetricMap;
- unordered_map<int, std::vector<int>> trackerToMetricMap;
- unordered_map<int, std::vector<int>> trackerToConditionMap;
- unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
- unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
- unordered_map<int64_t, int> alertTrackerMap;
- vector<int> metricsWithActivation;
- std::set<int64_t> noReportMetricIds;
-
- EXPECT_FALSE(initStatsdConfig(kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor,
- periodicAlarmMonitor, timeBaseSec, timeBaseSec, allTagIds,
- allAtomMatchers, allConditionTrackers, allMetricProducers,
- allAnomalyTrackers, allAlarmTrackers, conditionToMetricMap,
- trackerToMetricMap, trackerToConditionMap,
- activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap,
- alertTrackerMap, metricsWithActivation,
- noReportMetricIds));
-}
-
-TEST(MetricsManagerTest, TestCircleLogMatcherDependency) {
- UidMap uidMap;
- sp<StatsPullerManager> pullerManager = new StatsPullerManager();
- sp<AlarmMonitor> anomalyAlarmMonitor;
- sp<AlarmMonitor> periodicAlarmMonitor;
- StatsdConfig config = buildCircleMatchers();
- set<int> allTagIds;
- vector<sp<LogMatchingTracker>> allAtomMatchers;
- vector<sp<ConditionTracker>> allConditionTrackers;
- vector<sp<MetricProducer>> allMetricProducers;
- std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
- std::vector<sp<AlarmTracker>> allAlarmTrackers;
- unordered_map<int, std::vector<int>> conditionToMetricMap;
- unordered_map<int, std::vector<int>> trackerToMetricMap;
- unordered_map<int, std::vector<int>> trackerToConditionMap;
- unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
- unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
- unordered_map<int64_t, int> alertTrackerMap;
- vector<int> metricsWithActivation;
- std::set<int64_t> noReportMetricIds;
-
- EXPECT_FALSE(initStatsdConfig(kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor,
- periodicAlarmMonitor, timeBaseSec, timeBaseSec, allTagIds,
- allAtomMatchers, allConditionTrackers, allMetricProducers,
- allAnomalyTrackers, allAlarmTrackers, conditionToMetricMap,
- trackerToMetricMap, trackerToConditionMap,
- activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap,
- alertTrackerMap, metricsWithActivation,
- noReportMetricIds));
-}
-
-TEST(MetricsManagerTest, TestMissingMatchers) {
- UidMap uidMap;
- sp<StatsPullerManager> pullerManager = new StatsPullerManager();
- sp<AlarmMonitor> anomalyAlarmMonitor;
- sp<AlarmMonitor> periodicAlarmMonitor;
- StatsdConfig config = buildMissingMatchers();
- set<int> allTagIds;
- vector<sp<LogMatchingTracker>> allAtomMatchers;
- vector<sp<ConditionTracker>> allConditionTrackers;
- vector<sp<MetricProducer>> allMetricProducers;
- std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
- std::vector<sp<AlarmTracker>> allAlarmTrackers;
- unordered_map<int, std::vector<int>> conditionToMetricMap;
- unordered_map<int, std::vector<int>> trackerToMetricMap;
- unordered_map<int, std::vector<int>> trackerToConditionMap;
- unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
- unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
- unordered_map<int64_t, int> alertTrackerMap;
- vector<int> metricsWithActivation;
- std::set<int64_t> noReportMetricIds;
- EXPECT_FALSE(initStatsdConfig(kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor,
- periodicAlarmMonitor, timeBaseSec, timeBaseSec, allTagIds,
- allAtomMatchers, allConditionTrackers, allMetricProducers,
- allAnomalyTrackers, allAlarmTrackers, conditionToMetricMap,
- trackerToMetricMap, trackerToConditionMap,
- activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap,
- alertTrackerMap, metricsWithActivation,
- noReportMetricIds));
-}
-
-TEST(MetricsManagerTest, TestMissingPredicate) {
- UidMap uidMap;
- sp<StatsPullerManager> pullerManager = new StatsPullerManager();
- sp<AlarmMonitor> anomalyAlarmMonitor;
- sp<AlarmMonitor> periodicAlarmMonitor;
- StatsdConfig config = buildMissingPredicate();
- set<int> allTagIds;
- vector<sp<LogMatchingTracker>> allAtomMatchers;
- vector<sp<ConditionTracker>> allConditionTrackers;
- vector<sp<MetricProducer>> allMetricProducers;
- std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
- std::vector<sp<AlarmTracker>> allAlarmTrackers;
- unordered_map<int, std::vector<int>> conditionToMetricMap;
- unordered_map<int, std::vector<int>> trackerToMetricMap;
- unordered_map<int, std::vector<int>> trackerToConditionMap;
- unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
- unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
- unordered_map<int64_t, int> alertTrackerMap;
- vector<int> metricsWithActivation;
- std::set<int64_t> noReportMetricIds;
- EXPECT_FALSE(initStatsdConfig(kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor,
- periodicAlarmMonitor, timeBaseSec, timeBaseSec, allTagIds,
- allAtomMatchers, allConditionTrackers, allMetricProducers,
- allAnomalyTrackers, allAlarmTrackers, conditionToMetricMap,
- trackerToMetricMap, trackerToConditionMap,
- activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap,
- alertTrackerMap, metricsWithActivation, noReportMetricIds));
-}
-
-TEST(MetricsManagerTest, TestCirclePredicateDependency) {
- UidMap uidMap;
- sp<StatsPullerManager> pullerManager = new StatsPullerManager();
- sp<AlarmMonitor> anomalyAlarmMonitor;
- sp<AlarmMonitor> periodicAlarmMonitor;
- StatsdConfig config = buildCirclePredicates();
- set<int> allTagIds;
- vector<sp<LogMatchingTracker>> allAtomMatchers;
- vector<sp<ConditionTracker>> allConditionTrackers;
- vector<sp<MetricProducer>> allMetricProducers;
- std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
- std::vector<sp<AlarmTracker>> allAlarmTrackers;
- unordered_map<int, std::vector<int>> conditionToMetricMap;
- unordered_map<int, std::vector<int>> trackerToMetricMap;
- unordered_map<int, std::vector<int>> trackerToConditionMap;
- unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
- unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
- unordered_map<int64_t, int> alertTrackerMap;
- vector<int> metricsWithActivation;
- std::set<int64_t> noReportMetricIds;
-
- EXPECT_FALSE(initStatsdConfig(kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor,
- periodicAlarmMonitor, timeBaseSec, timeBaseSec, allTagIds,
- allAtomMatchers, allConditionTrackers, allMetricProducers,
- allAnomalyTrackers, allAlarmTrackers, conditionToMetricMap,
- trackerToMetricMap, trackerToConditionMap,
- activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap,
- alertTrackerMap, metricsWithActivation,
- noReportMetricIds));
-}
-
-TEST(MetricsManagerTest, testAlertWithUnknownMetric) {
- UidMap uidMap;
- sp<StatsPullerManager> pullerManager = new StatsPullerManager();
- sp<AlarmMonitor> anomalyAlarmMonitor;
- sp<AlarmMonitor> periodicAlarmMonitor;
- StatsdConfig config = buildAlertWithUnknownMetric();
- set<int> allTagIds;
- vector<sp<LogMatchingTracker>> allAtomMatchers;
- vector<sp<ConditionTracker>> allConditionTrackers;
- vector<sp<MetricProducer>> allMetricProducers;
- std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
- std::vector<sp<AlarmTracker>> allAlarmTrackers;
- unordered_map<int, std::vector<int>> conditionToMetricMap;
- unordered_map<int, std::vector<int>> trackerToMetricMap;
- unordered_map<int, std::vector<int>> trackerToConditionMap;
- unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
- unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
- unordered_map<int64_t, int> alertTrackerMap;
- vector<int> metricsWithActivation;
- std::set<int64_t> noReportMetricIds;
-
- EXPECT_FALSE(initStatsdConfig(kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor,
- periodicAlarmMonitor, timeBaseSec, timeBaseSec, allTagIds,
- allAtomMatchers, allConditionTrackers, allMetricProducers,
- allAnomalyTrackers, allAlarmTrackers, conditionToMetricMap,
- trackerToMetricMap, trackerToConditionMap,
- activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap,
- alertTrackerMap, metricsWithActivation,
- noReportMetricIds));
-}
-
TEST(MetricsManagerTest, TestLogSources) {
string app1 = "app1";
set<int32_t> app1Uids = {1111, 11111};
@@ -680,7 +130,7 @@
sp<AlarmMonitor> anomalyAlarmMonitor;
sp<AlarmMonitor> periodicAlarmMonitor;
- StatsdConfig config = buildGoodConfig();
+ StatsdConfig config;
config.add_allowed_log_source("AID_SYSTEM");
config.add_allowed_log_source(app1);
config.add_default_pull_packages("AID_SYSTEM");
@@ -744,7 +194,7 @@
sp<AlarmMonitor> anomalyAlarmMonitor;
sp<AlarmMonitor> periodicAlarmMonitor;
- StatsdConfig config = buildGoodConfig();
+ StatsdConfig config;
config.add_whitelisted_atom_ids(3);
config.add_whitelisted_atom_ids(4);
diff --git a/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp b/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp
index caea42d..d96ff8a 100644
--- a/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp
+++ b/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp
@@ -47,7 +47,6 @@
const ConfigKey kConfigKey(0, 12345);
const int tagId = 1;
const int64_t metricId = 123;
-const int64_t atomMatcherId = 678;
const int logEventMatcherIndex = 0;
const int64_t bucketStartTimeNs = 10 * NS_PER_SEC;
const int64_t bucketSizeNs = TimeUnitToBucketSizeInMillis(ONE_MINUTE) * 1000000LL;
@@ -94,11 +93,8 @@
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
- sp<EventMatcherWizard> eventMatcherWizard = new EventMatcherWizard({
- new SimpleLogMatchingTracker(atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ sp<EventMatcherWizard> eventMatcherWizard =
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
@@ -127,12 +123,8 @@
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, kConfigKey, _, _, _)).WillOnce(Return());
@@ -217,12 +209,8 @@
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
GaugeMetricProducer gaugeProducer(kConfigKey, metric, -1 /*-1 meaning no condition*/, {},
wizard, logEventMatcherIndex, eventMatcherWizard,
@@ -301,12 +289,9 @@
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
+
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, kConfigKey, _, _, _)).WillOnce(Return());
EXPECT_CALL(*pullerManager, UnRegisterReceiver(tagId, kConfigKey, _)).WillOnce(Return());
@@ -378,12 +363,8 @@
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, kConfigKey, _, _, _)).WillOnce(Return());
@@ -428,12 +409,8 @@
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
int64_t conditionChangeNs = bucketStartTimeNs + 8;
@@ -502,12 +479,8 @@
dim->set_field(tagId);
dim->add_child()->set_field(1);
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
EXPECT_CALL(*wizard, query(_, _, _))
@@ -577,12 +550,8 @@
gaugeFieldMatcher->set_field(tagId);
gaugeFieldMatcher->add_child()->set_field(2);
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
GaugeMetricProducer gaugeProducer(kConfigKey, metric, -1 /*-1 meaning no condition*/, {},
wizard, logEventMatcherIndex, eventMatcherWizard, tagId, -1,
@@ -657,12 +626,8 @@
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
EXPECT_CALL(*pullerManager, Pull(tagId, kConfigKey, _, _))
@@ -729,12 +694,8 @@
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
EXPECT_CALL(*pullerManager, Pull(tagId, kConfigKey, _, _))
@@ -807,12 +768,8 @@
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
EXPECT_CALL(*pullerManager, Pull(tagId, kConfigKey, bucketStartTimeNs + 3, _))
diff --git a/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp b/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp
index 9889250..5524ebc 100644
--- a/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp
+++ b/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp
@@ -46,7 +46,6 @@
const ConfigKey kConfigKey(0, 12345);
const int tagId = 1;
const int64_t metricId = 123;
-const int64_t atomMatcherId = 678;
const int logEventMatcherIndex = 0;
const int64_t bucketStartTimeNs = 10000000000;
const int64_t bucketSizeNs = TimeUnitToBucketSizeInMillis(ONE_MINUTE) * 1000000LL;
@@ -99,12 +98,8 @@
public:
static sp<ValueMetricProducer> createValueProducerNoConditions(
sp<MockStatsPullerManager>& pullerManager, ValueMetric& metric) {
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, kConfigKey, _, _, _))
.WillOnce(Return());
@@ -122,12 +117,8 @@
static sp<ValueMetricProducer> createValueProducerWithCondition(
sp<MockStatsPullerManager>& pullerManager, ValueMetric& metric,
ConditionState conditionAfterFirstBucketPrepared) {
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, kConfigKey, _, _, _))
.WillOnce(Return());
@@ -147,12 +138,8 @@
sp<MockStatsPullerManager>& pullerManager, ValueMetric& metric,
vector<int32_t> slicedStateAtoms,
unordered_map<int, unordered_map<int, int64_t>> stateGroupMap) {
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, kConfigKey, _, _, _))
.WillOnce(Return());
@@ -172,12 +159,8 @@
vector<int32_t> slicedStateAtoms,
unordered_map<int, unordered_map<int, int64_t>> stateGroupMap,
ConditionState conditionAfterFirstBucketPrepared) {
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, kConfigKey, _, _, _))
.WillOnce(Return());
@@ -237,12 +220,8 @@
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
int64_t startTimeBase = 11;
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
@@ -267,12 +246,8 @@
TEST(ValueMetricProducerTest, TestFirstBucket) {
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
@@ -421,15 +396,11 @@
TEST(ValueMetricProducerTest, TestPulledEventsWithFiltering) {
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
- auto keyValue = atomMatcher.add_field_value_matcher();
- keyValue->set_field(1);
- keyValue->set_eq_int(3);
+ FieldValueMatcher fvm;
+ fvm.set_field(1);
+ fvm.set_eq_int(3);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex, {fvm});
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, kConfigKey, _, _, _)).WillOnce(Return());
@@ -698,12 +669,8 @@
TEST_P(ValueMetricProducerTest_PartialBucket, TestPushedEvents) {
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
@@ -759,12 +726,8 @@
TEST_P(ValueMetricProducerTest_PartialBucket, TestPulledValue) {
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
int64_t partialBucketSplitTimeNs = bucket2StartTimeNs + 150;
@@ -820,12 +783,8 @@
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
metric.set_split_bucket_for_app_upgrade(false);
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, kConfigKey, _, _, _)).WillOnce(Return());
@@ -900,12 +859,8 @@
TEST(ValueMetricProducerTest, TestPushedEventsWithoutCondition) {
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
@@ -944,12 +899,8 @@
TEST(ValueMetricProducerTest, TestPushedEventsWithCondition) {
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
@@ -1015,12 +966,8 @@
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
@@ -1360,12 +1307,8 @@
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
metric.set_aggregation_type(ValueMetric::MIN);
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
@@ -1404,12 +1347,8 @@
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
metric.set_aggregation_type(ValueMetric::MAX);
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
@@ -1447,12 +1386,8 @@
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
metric.set_aggregation_type(ValueMetric::AVG);
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
@@ -1495,12 +1430,8 @@
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
metric.set_aggregation_type(ValueMetric::SUM);
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
@@ -1539,12 +1470,8 @@
metric.set_aggregation_type(ValueMetric::MIN);
metric.set_use_diff(true);
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
@@ -1611,12 +1538,8 @@
metric.set_aggregation_type(ValueMetric::MIN);
metric.set_use_diff(true);
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
@@ -2140,12 +2063,8 @@
TEST(ValueMetricProducerTest, TestResetBaseOnPullTooLate) {
ValueMetric metric = ValueMetricProducerTestHelper::createMetricWithCondition();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, kConfigKey, _, _, _)).WillOnce(Return());
@@ -2963,12 +2882,8 @@
TEST(ValueMetricProducerTest, TestPullNeededFastDump) {
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, kConfigKey, _, _, _)).WillOnce(Return());
@@ -3001,12 +2916,8 @@
TEST(ValueMetricProducerTest, TestFastDumpWithoutCurrentBucket) {
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, kConfigKey, _, _, _)).WillOnce(Return());
@@ -3045,12 +2956,8 @@
TEST(ValueMetricProducerTest, TestPullNeededNoTimeConstraints) {
ValueMetric metric = ValueMetricProducerTestHelper::createMetric();
- UidMap uidMap;
- SimpleAtomMatcher atomMatcher;
- atomMatcher.set_atom_id(tagId);
sp<EventMatcherWizard> eventMatcherWizard =
- new EventMatcherWizard({new SimpleLogMatchingTracker(
- atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ createEventMatcherWizard(tagId, logEventMatcherIndex);
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, kConfigKey, _, _, _)).WillOnce(Return());
diff --git a/cmds/statsd/tests/metrics/parsing_utils/config_update_utils_test.cpp b/cmds/statsd/tests/metrics/parsing_utils/config_update_utils_test.cpp
new file mode 100644
index 0000000..6b50fe5
--- /dev/null
+++ b/cmds/statsd/tests/metrics/parsing_utils/config_update_utils_test.cpp
@@ -0,0 +1,382 @@
+// 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.
+
+#include "src/metrics/parsing_utils/config_update_utils.h"
+
+#include <gtest/gtest.h>
+#include <private/android_filesystem_config.h>
+#include <stdio.h>
+
+#include <set>
+#include <unordered_map>
+#include <vector>
+
+#include "frameworks/base/cmds/statsd/src/statsd_config.pb.h"
+#include "src/metrics/parsing_utils/metrics_manager_util.h"
+#include "tests/statsd_test_util.h"
+
+using namespace testing;
+using android::sp;
+using android::os::statsd::Predicate;
+using std::map;
+using std::set;
+using std::unordered_map;
+using std::vector;
+
+#ifdef __ANDROID__
+
+namespace android {
+namespace os {
+namespace statsd {
+
+namespace {
+
+ConfigKey key(123, 456);
+const int64_t timeBaseNs = 1000;
+sp<UidMap> uidMap = new UidMap();
+sp<StatsPullerManager> pullerManager = new StatsPullerManager();
+sp<AlarmMonitor> anomalyAlarmMonitor;
+sp<AlarmMonitor> periodicAlarmMonitor;
+set<int> allTagIds;
+vector<sp<LogMatchingTracker>> oldAtomMatchers;
+unordered_map<int64_t, int> oldLogTrackerMap;
+vector<sp<ConditionTracker>> oldConditionTrackers;
+vector<sp<MetricProducer>> oldMetricProducers;
+std::vector<sp<AnomalyTracker>> oldAnomalyTrackers;
+std::vector<sp<AlarmTracker>> oldAlarmTrackers;
+unordered_map<int, std::vector<int>> conditionToMetricMap;
+unordered_map<int, std::vector<int>> trackerToMetricMap;
+unordered_map<int, std::vector<int>> trackerToConditionMap;
+unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
+unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
+unordered_map<int64_t, int> alertTrackerMap;
+vector<int> metricsWithActivation;
+std::set<int64_t> noReportMetricIds;
+
+class ConfigUpdateTest : public ::testing::Test {
+public:
+ ConfigUpdateTest() {
+ }
+
+ void SetUp() override {
+ allTagIds.clear();
+ oldAtomMatchers.clear();
+ oldLogTrackerMap.clear();
+ oldConditionTrackers.clear();
+ oldMetricProducers.clear();
+ oldAnomalyTrackers.clear();
+ oldAlarmTrackers.clear();
+ conditionToMetricMap.clear();
+ trackerToMetricMap.clear();
+ trackerToConditionMap.clear();
+ activationAtomTrackerToMetricMap.clear();
+ deactivationAtomTrackerToMetricMap.clear();
+ alertTrackerMap.clear();
+ metricsWithActivation.clear();
+ noReportMetricIds.clear();
+ }
+};
+
+bool initConfig(const StatsdConfig& config) {
+ return initStatsdConfig(key, config, uidMap, pullerManager, anomalyAlarmMonitor,
+ periodicAlarmMonitor, timeBaseNs, timeBaseNs, allTagIds,
+ oldAtomMatchers, oldLogTrackerMap, oldConditionTrackers,
+ oldMetricProducers, oldAnomalyTrackers, oldAlarmTrackers,
+ conditionToMetricMap, trackerToMetricMap, trackerToConditionMap,
+ activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap,
+ alertTrackerMap, metricsWithActivation, noReportMetricIds);
+}
+
+} // anonymous namespace
+
+TEST_F(ConfigUpdateTest, TestSimpleMatcherPreserve) {
+ StatsdConfig config;
+ AtomMatcher matcher = CreateSimpleAtomMatcher("TEST", /*atom=*/10);
+ int64_t matcherId = matcher.id();
+ *config.add_atom_matcher() = matcher;
+
+ // Create an initial config.
+ EXPECT_TRUE(initConfig(config));
+
+ vector<UpdateStatus> matchersToUpdate(1, UPDATE_UNKNOWN);
+ vector<bool> cycleTracker(1, false);
+ unordered_map<int64_t, int> newLogTrackerMap;
+ newLogTrackerMap[matcherId] = 0;
+ EXPECT_TRUE(determineMatcherUpdateStatus(config, 0, oldLogTrackerMap, oldAtomMatchers,
+ newLogTrackerMap, matchersToUpdate, cycleTracker));
+ EXPECT_EQ(matchersToUpdate[0], UPDATE_PRESERVE);
+}
+
+TEST_F(ConfigUpdateTest, TestSimpleMatcherReplace) {
+ StatsdConfig config;
+ AtomMatcher matcher = CreateSimpleAtomMatcher("TEST", /*atom=*/10);
+ *config.add_atom_matcher() = matcher;
+
+ EXPECT_TRUE(initConfig(config));
+
+ StatsdConfig newConfig;
+ // Same id, different atom, so should be replaced.
+ AtomMatcher newMatcher = CreateSimpleAtomMatcher("TEST", /*atom=*/11);
+ int64_t matcherId = newMatcher.id();
+ EXPECT_EQ(matcherId, matcher.id());
+ *newConfig.add_atom_matcher() = newMatcher;
+
+ vector<UpdateStatus> matchersToUpdate(1, UPDATE_UNKNOWN);
+ vector<bool> cycleTracker(1, false);
+ unordered_map<int64_t, int> newLogTrackerMap;
+ newLogTrackerMap[matcherId] = 0;
+ EXPECT_TRUE(determineMatcherUpdateStatus(newConfig, 0, oldLogTrackerMap, oldAtomMatchers,
+ newLogTrackerMap, matchersToUpdate, cycleTracker));
+ EXPECT_EQ(matchersToUpdate[0], UPDATE_REPLACE);
+}
+
+TEST_F(ConfigUpdateTest, TestCombinationMatcherPreserve) {
+ StatsdConfig config;
+ AtomMatcher matcher1 = CreateSimpleAtomMatcher("TEST1", /*atom=*/10);
+ int64_t matcher1Id = matcher1.id();
+ *config.add_atom_matcher() = matcher1;
+
+ AtomMatcher matcher2 = CreateSimpleAtomMatcher("TEST2", /*atom=*/11);
+ *config.add_atom_matcher() = matcher2;
+ int64_t matcher2Id = matcher2.id();
+
+ AtomMatcher matcher3;
+ matcher3.set_id(StringToId("TEST3"));
+ AtomMatcher_Combination* combination = matcher3.mutable_combination();
+ combination->set_operation(LogicalOperation::OR);
+ combination->add_matcher(matcher1Id);
+ combination->add_matcher(matcher2Id);
+ int64_t matcher3Id = matcher3.id();
+ *config.add_atom_matcher() = matcher3;
+
+ EXPECT_TRUE(initConfig(config));
+
+ StatsdConfig newConfig;
+ unordered_map<int64_t, int> newLogTrackerMap;
+ // Same matchers, different order, all should be preserved.
+ *newConfig.add_atom_matcher() = matcher2;
+ newLogTrackerMap[matcher2Id] = 0;
+ *newConfig.add_atom_matcher() = matcher3;
+ newLogTrackerMap[matcher3Id] = 1;
+ *newConfig.add_atom_matcher() = matcher1;
+ newLogTrackerMap[matcher1Id] = 2;
+
+ vector<UpdateStatus> matchersToUpdate(3, UPDATE_UNKNOWN);
+ vector<bool> cycleTracker(3, false);
+ // Only update the combination. It should recurse the two child matchers and preserve all 3.
+ EXPECT_TRUE(determineMatcherUpdateStatus(newConfig, 1, oldLogTrackerMap, oldAtomMatchers,
+ newLogTrackerMap, matchersToUpdate, cycleTracker));
+ EXPECT_EQ(matchersToUpdate[0], UPDATE_PRESERVE);
+ EXPECT_EQ(matchersToUpdate[1], UPDATE_PRESERVE);
+ EXPECT_EQ(matchersToUpdate[2], UPDATE_PRESERVE);
+}
+
+TEST_F(ConfigUpdateTest, TestCombinationMatcherReplace) {
+ StatsdConfig config;
+ AtomMatcher matcher1 = CreateSimpleAtomMatcher("TEST1", /*atom=*/10);
+ int64_t matcher1Id = matcher1.id();
+ *config.add_atom_matcher() = matcher1;
+
+ AtomMatcher matcher2 = CreateSimpleAtomMatcher("TEST2", /*atom=*/11);
+ *config.add_atom_matcher() = matcher2;
+ int64_t matcher2Id = matcher2.id();
+
+ AtomMatcher matcher3;
+ matcher3.set_id(StringToId("TEST3"));
+ AtomMatcher_Combination* combination = matcher3.mutable_combination();
+ combination->set_operation(LogicalOperation::OR);
+ combination->add_matcher(matcher1Id);
+ combination->add_matcher(matcher2Id);
+ int64_t matcher3Id = matcher3.id();
+ *config.add_atom_matcher() = matcher3;
+
+ EXPECT_TRUE(initConfig(config));
+
+ // Change the logical operation of the combination matcher, causing a replacement.
+ matcher3.mutable_combination()->set_operation(LogicalOperation::AND);
+
+ StatsdConfig newConfig;
+ unordered_map<int64_t, int> newLogTrackerMap;
+ *newConfig.add_atom_matcher() = matcher2;
+ newLogTrackerMap[matcher2Id] = 0;
+ *newConfig.add_atom_matcher() = matcher3;
+ newLogTrackerMap[matcher3Id] = 1;
+ *newConfig.add_atom_matcher() = matcher1;
+ newLogTrackerMap[matcher1Id] = 2;
+
+ vector<UpdateStatus> matchersToUpdate(3, UPDATE_UNKNOWN);
+ vector<bool> cycleTracker(3, false);
+ // Only update the combination. The simple matchers should not be evaluated.
+ EXPECT_TRUE(determineMatcherUpdateStatus(newConfig, 1, oldLogTrackerMap, oldAtomMatchers,
+ newLogTrackerMap, matchersToUpdate, cycleTracker));
+ EXPECT_EQ(matchersToUpdate[0], UPDATE_UNKNOWN);
+ EXPECT_EQ(matchersToUpdate[1], UPDATE_REPLACE);
+ EXPECT_EQ(matchersToUpdate[2], UPDATE_UNKNOWN);
+}
+
+TEST_F(ConfigUpdateTest, TestCombinationMatcherDepsChange) {
+ StatsdConfig config;
+ AtomMatcher matcher1 = CreateSimpleAtomMatcher("TEST1", /*atom=*/10);
+ int64_t matcher1Id = matcher1.id();
+ *config.add_atom_matcher() = matcher1;
+
+ AtomMatcher matcher2 = CreateSimpleAtomMatcher("TEST2", /*atom=*/11);
+ *config.add_atom_matcher() = matcher2;
+ int64_t matcher2Id = matcher2.id();
+
+ AtomMatcher matcher3;
+ matcher3.set_id(StringToId("TEST3"));
+ AtomMatcher_Combination* combination = matcher3.mutable_combination();
+ combination->set_operation(LogicalOperation::OR);
+ combination->add_matcher(matcher1Id);
+ combination->add_matcher(matcher2Id);
+ int64_t matcher3Id = matcher3.id();
+ *config.add_atom_matcher() = matcher3;
+
+ EXPECT_TRUE(initConfig(config));
+
+ // Change a dependency of matcher 3.
+ matcher2.mutable_simple_atom_matcher()->set_atom_id(12);
+
+ StatsdConfig newConfig;
+ unordered_map<int64_t, int> newLogTrackerMap;
+ *newConfig.add_atom_matcher() = matcher2;
+ newLogTrackerMap[matcher2Id] = 0;
+ *newConfig.add_atom_matcher() = matcher3;
+ newLogTrackerMap[matcher3Id] = 1;
+ *newConfig.add_atom_matcher() = matcher1;
+ newLogTrackerMap[matcher1Id] = 2;
+
+ vector<UpdateStatus> matchersToUpdate(3, UPDATE_UNKNOWN);
+ vector<bool> cycleTracker(3, false);
+ // Only update the combination.
+ EXPECT_TRUE(determineMatcherUpdateStatus(newConfig, 1, oldLogTrackerMap, oldAtomMatchers,
+ newLogTrackerMap, matchersToUpdate, cycleTracker));
+ // Matcher 2 and matcher3 must be reevaluated. Matcher 1 might, but does not need to be.
+ EXPECT_EQ(matchersToUpdate[0], UPDATE_REPLACE);
+ EXPECT_EQ(matchersToUpdate[1], UPDATE_REPLACE);
+}
+
+TEST_F(ConfigUpdateTest, TestUpdateMatchers) {
+ StatsdConfig config;
+ // Will be preserved.
+ AtomMatcher simple1 = CreateSimpleAtomMatcher("SIMPLE1", /*atom=*/10);
+ int64_t simple1Id = simple1.id();
+ *config.add_atom_matcher() = simple1;
+
+ // Will be replaced.
+ AtomMatcher simple2 = CreateSimpleAtomMatcher("SIMPLE2", /*atom=*/11);
+ *config.add_atom_matcher() = simple2;
+ int64_t simple2Id = simple2.id();
+
+ // Will be removed.
+ AtomMatcher simple3 = CreateSimpleAtomMatcher("SIMPLE3", /*atom=*/12);
+ *config.add_atom_matcher() = simple3;
+ int64_t simple3Id = simple3.id();
+
+ // Will be preserved.
+ AtomMatcher combination1;
+ combination1.set_id(StringToId("combination1"));
+ AtomMatcher_Combination* combination = combination1.mutable_combination();
+ combination->set_operation(LogicalOperation::NOT);
+ combination->add_matcher(simple1Id);
+ int64_t combination1Id = combination1.id();
+ *config.add_atom_matcher() = combination1;
+
+ // Will be replaced since it depends on simple2.
+ AtomMatcher combination2;
+ combination2.set_id(StringToId("combination2"));
+ combination = combination2.mutable_combination();
+ combination->set_operation(LogicalOperation::AND);
+ combination->add_matcher(simple1Id);
+ combination->add_matcher(simple2Id);
+ int64_t combination2Id = combination2.id();
+ *config.add_atom_matcher() = combination2;
+
+ EXPECT_TRUE(initConfig(config));
+
+ // Change simple2, causing simple2 and combination2 to be replaced.
+ simple2.mutable_simple_atom_matcher()->set_atom_id(111);
+
+ // 2 new matchers: simple4 and combination3:
+ AtomMatcher simple4 = CreateSimpleAtomMatcher("SIMPLE4", /*atom=*/13);
+ int64_t simple4Id = simple4.id();
+
+ AtomMatcher combination3;
+ combination3.set_id(StringToId("combination3"));
+ combination = combination3.mutable_combination();
+ combination->set_operation(LogicalOperation::AND);
+ combination->add_matcher(simple4Id);
+ combination->add_matcher(simple2Id);
+ int64_t combination3Id = combination3.id();
+
+ StatsdConfig newConfig;
+ *newConfig.add_atom_matcher() = combination3;
+ *newConfig.add_atom_matcher() = simple2;
+ *newConfig.add_atom_matcher() = combination2;
+ *newConfig.add_atom_matcher() = simple1;
+ *newConfig.add_atom_matcher() = simple4;
+ *newConfig.add_atom_matcher() = combination1;
+
+ set<int> newTagIds;
+ unordered_map<int64_t, int> newLogTrackerMap;
+ vector<sp<LogMatchingTracker>> newAtomMatchers;
+ EXPECT_TRUE(updateLogTrackers(newConfig, uidMap, oldLogTrackerMap, oldAtomMatchers, newTagIds,
+ newLogTrackerMap, newAtomMatchers));
+
+ ASSERT_EQ(newTagIds.size(), 3);
+ EXPECT_EQ(newTagIds.count(10), 1);
+ EXPECT_EQ(newTagIds.count(111), 1);
+ EXPECT_EQ(newTagIds.count(13), 1);
+
+ ASSERT_EQ(newLogTrackerMap.size(), 6);
+ EXPECT_EQ(newLogTrackerMap.at(combination3Id), 0);
+ EXPECT_EQ(newLogTrackerMap.at(simple2Id), 1);
+ EXPECT_EQ(newLogTrackerMap.at(combination2Id), 2);
+ EXPECT_EQ(newLogTrackerMap.at(simple1Id), 3);
+ EXPECT_EQ(newLogTrackerMap.at(simple4Id), 4);
+ EXPECT_EQ(newLogTrackerMap.at(combination1Id), 5);
+
+ ASSERT_EQ(newAtomMatchers.size(), 6);
+ // Make sure all atom matchers are initialized:
+ for (const sp<LogMatchingTracker>& tracker : newAtomMatchers) {
+ EXPECT_TRUE(tracker->mInitialized);
+ }
+ // Make sure preserved atom matchers are the same.
+ EXPECT_EQ(oldAtomMatchers[oldLogTrackerMap.at(simple1Id)],
+ newAtomMatchers[newLogTrackerMap.at(simple1Id)]);
+ EXPECT_EQ(oldAtomMatchers[oldLogTrackerMap.at(combination1Id)],
+ newAtomMatchers[newLogTrackerMap.at(combination1Id)]);
+ // Make sure replaced matchers are different.
+ EXPECT_NE(oldAtomMatchers[oldLogTrackerMap.at(simple2Id)],
+ newAtomMatchers[newLogTrackerMap.at(simple2Id)]);
+ EXPECT_NE(oldAtomMatchers[oldLogTrackerMap.at(combination2Id)],
+ newAtomMatchers[newLogTrackerMap.at(combination2Id)]);
+
+ // Validation, make sure the matchers have the proper ids. Could do more checks here.
+ EXPECT_EQ(newAtomMatchers[0]->getId(), combination3Id);
+ EXPECT_EQ(newAtomMatchers[1]->getId(), simple2Id);
+ EXPECT_EQ(newAtomMatchers[2]->getId(), combination2Id);
+ EXPECT_EQ(newAtomMatchers[3]->getId(), simple1Id);
+ EXPECT_EQ(newAtomMatchers[4]->getId(), simple4Id);
+ EXPECT_EQ(newAtomMatchers[5]->getId(), combination1Id);
+}
+
+} // namespace statsd
+} // namespace os
+} // namespace android
+
+#else
+GTEST_LOG_(INFO) << "This test does nothing.\n";
+#endif
diff --git a/cmds/statsd/tests/metrics/parsing_utils/metrics_manager_util_test.cpp b/cmds/statsd/tests/metrics/parsing_utils/metrics_manager_util_test.cpp
new file mode 100644
index 0000000..4e97eaf
--- /dev/null
+++ b/cmds/statsd/tests/metrics/parsing_utils/metrics_manager_util_test.cpp
@@ -0,0 +1,708 @@
+// 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.
+
+#include "src/metrics/parsing_utils/metrics_manager_util.h"
+
+#include <gtest/gtest.h>
+#include <private/android_filesystem_config.h>
+#include <stdio.h>
+
+#include <set>
+#include <unordered_map>
+#include <vector>
+
+#include "frameworks/base/cmds/statsd/src/statsd_config.pb.h"
+#include "src/condition/ConditionTracker.h"
+#include "src/matchers/LogMatchingTracker.h"
+#include "src/metrics/CountMetricProducer.h"
+#include "src/metrics/GaugeMetricProducer.h"
+#include "src/metrics/MetricProducer.h"
+#include "src/metrics/ValueMetricProducer.h"
+#include "src/state/StateManager.h"
+#include "tests/metrics/metrics_test_helper.h"
+#include "tests/statsd_test_util.h"
+
+using namespace testing;
+using android::sp;
+using android::os::statsd::Predicate;
+using std::map;
+using std::set;
+using std::unordered_map;
+using std::vector;
+
+#ifdef __ANDROID__
+
+namespace android {
+namespace os {
+namespace statsd {
+
+namespace {
+const ConfigKey kConfigKey(0, 12345);
+const long kAlertId = 3;
+
+const long timeBaseSec = 1000;
+
+StatsdConfig buildGoodConfig() {
+ StatsdConfig config;
+ config.set_id(12345);
+
+ AtomMatcher* eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("SCREEN_IS_ON"));
+
+ SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
+ simpleAtomMatcher->set_atom_id(2 /*SCREEN_STATE_CHANGE*/);
+ simpleAtomMatcher->add_field_value_matcher()->set_field(
+ 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/);
+ simpleAtomMatcher->mutable_field_value_matcher(0)->set_eq_int(
+ 2 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_ON*/);
+
+ eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("SCREEN_IS_OFF"));
+
+ simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
+ simpleAtomMatcher->set_atom_id(2 /*SCREEN_STATE_CHANGE*/);
+ simpleAtomMatcher->add_field_value_matcher()->set_field(
+ 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/);
+ simpleAtomMatcher->mutable_field_value_matcher(0)->set_eq_int(
+ 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_OFF*/);
+
+ eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("SCREEN_ON_OR_OFF"));
+
+ AtomMatcher_Combination* combination = eventMatcher->mutable_combination();
+ combination->set_operation(LogicalOperation::OR);
+ combination->add_matcher(StringToId("SCREEN_IS_ON"));
+ combination->add_matcher(StringToId("SCREEN_IS_OFF"));
+
+ CountMetric* metric = config.add_count_metric();
+ metric->set_id(3);
+ metric->set_what(StringToId("SCREEN_IS_ON"));
+ metric->set_bucket(ONE_MINUTE);
+ metric->mutable_dimensions_in_what()->set_field(2 /*SCREEN_STATE_CHANGE*/);
+ metric->mutable_dimensions_in_what()->add_child()->set_field(1);
+
+ config.add_no_report_metric(3);
+
+ auto alert = config.add_alert();
+ alert->set_id(kAlertId);
+ alert->set_metric_id(3);
+ alert->set_num_buckets(10);
+ alert->set_refractory_period_secs(100);
+ alert->set_trigger_if_sum_gt(100);
+ return config;
+}
+
+StatsdConfig buildCircleMatchers() {
+ StatsdConfig config;
+ config.set_id(12345);
+
+ AtomMatcher* eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("SCREEN_IS_ON"));
+
+ SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
+ simpleAtomMatcher->set_atom_id(2 /*SCREEN_STATE_CHANGE*/);
+ simpleAtomMatcher->add_field_value_matcher()->set_field(
+ 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/);
+ simpleAtomMatcher->mutable_field_value_matcher(0)->set_eq_int(
+ 2 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_ON*/);
+
+ eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("SCREEN_ON_OR_OFF"));
+
+ AtomMatcher_Combination* combination = eventMatcher->mutable_combination();
+ combination->set_operation(LogicalOperation::OR);
+ combination->add_matcher(StringToId("SCREEN_IS_ON"));
+ // Circle dependency
+ combination->add_matcher(StringToId("SCREEN_ON_OR_OFF"));
+
+ return config;
+}
+
+StatsdConfig buildAlertWithUnknownMetric() {
+ StatsdConfig config;
+ config.set_id(12345);
+
+ AtomMatcher* eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("SCREEN_IS_ON"));
+
+ CountMetric* metric = config.add_count_metric();
+ metric->set_id(3);
+ metric->set_what(StringToId("SCREEN_IS_ON"));
+ metric->set_bucket(ONE_MINUTE);
+ metric->mutable_dimensions_in_what()->set_field(2 /*SCREEN_STATE_CHANGE*/);
+ metric->mutable_dimensions_in_what()->add_child()->set_field(1);
+
+ auto alert = config.add_alert();
+ alert->set_id(3);
+ alert->set_metric_id(2);
+ alert->set_num_buckets(10);
+ alert->set_refractory_period_secs(100);
+ alert->set_trigger_if_sum_gt(100);
+ return config;
+}
+
+StatsdConfig buildMissingMatchers() {
+ StatsdConfig config;
+ config.set_id(12345);
+
+ AtomMatcher* eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("SCREEN_IS_ON"));
+
+ SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
+ simpleAtomMatcher->set_atom_id(2 /*SCREEN_STATE_CHANGE*/);
+ simpleAtomMatcher->add_field_value_matcher()->set_field(
+ 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/);
+ simpleAtomMatcher->mutable_field_value_matcher(0)->set_eq_int(
+ 2 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_ON*/);
+
+ eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("SCREEN_ON_OR_OFF"));
+
+ AtomMatcher_Combination* combination = eventMatcher->mutable_combination();
+ combination->set_operation(LogicalOperation::OR);
+ combination->add_matcher(StringToId("SCREEN_IS_ON"));
+ // undefined matcher
+ combination->add_matcher(StringToId("ABC"));
+
+ return config;
+}
+
+StatsdConfig buildMissingPredicate() {
+ StatsdConfig config;
+ config.set_id(12345);
+
+ CountMetric* metric = config.add_count_metric();
+ metric->set_id(3);
+ metric->set_what(StringToId("SCREEN_EVENT"));
+ metric->set_bucket(ONE_MINUTE);
+ metric->set_condition(StringToId("SOME_CONDITION"));
+
+ AtomMatcher* eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("SCREEN_EVENT"));
+
+ SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
+ simpleAtomMatcher->set_atom_id(2);
+
+ return config;
+}
+
+StatsdConfig buildDimensionMetricsWithMultiTags() {
+ StatsdConfig config;
+ config.set_id(12345);
+
+ AtomMatcher* eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("BATTERY_VERY_LOW"));
+ SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
+ simpleAtomMatcher->set_atom_id(2);
+
+ eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("BATTERY_VERY_VERY_LOW"));
+ simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
+ simpleAtomMatcher->set_atom_id(3);
+
+ eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("BATTERY_LOW"));
+
+ AtomMatcher_Combination* combination = eventMatcher->mutable_combination();
+ combination->set_operation(LogicalOperation::OR);
+ combination->add_matcher(StringToId("BATTERY_VERY_LOW"));
+ combination->add_matcher(StringToId("BATTERY_VERY_VERY_LOW"));
+
+ // Count process state changes, slice by uid, while SCREEN_IS_OFF
+ CountMetric* metric = config.add_count_metric();
+ metric->set_id(3);
+ metric->set_what(StringToId("BATTERY_LOW"));
+ metric->set_bucket(ONE_MINUTE);
+ // This case is interesting. We want to dimension across two atoms.
+ metric->mutable_dimensions_in_what()->add_child()->set_field(1);
+
+ auto alert = config.add_alert();
+ alert->set_id(kAlertId);
+ alert->set_metric_id(3);
+ alert->set_num_buckets(10);
+ alert->set_refractory_period_secs(100);
+ alert->set_trigger_if_sum_gt(100);
+ return config;
+}
+
+StatsdConfig buildCirclePredicates() {
+ StatsdConfig config;
+ config.set_id(12345);
+
+ AtomMatcher* eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("SCREEN_IS_ON"));
+
+ SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
+ simpleAtomMatcher->set_atom_id(2 /*SCREEN_STATE_CHANGE*/);
+ simpleAtomMatcher->add_field_value_matcher()->set_field(
+ 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/);
+ simpleAtomMatcher->mutable_field_value_matcher(0)->set_eq_int(
+ 2 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_ON*/);
+
+ eventMatcher = config.add_atom_matcher();
+ eventMatcher->set_id(StringToId("SCREEN_IS_OFF"));
+
+ simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher();
+ simpleAtomMatcher->set_atom_id(2 /*SCREEN_STATE_CHANGE*/);
+ simpleAtomMatcher->add_field_value_matcher()->set_field(
+ 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/);
+ simpleAtomMatcher->mutable_field_value_matcher(0)->set_eq_int(
+ 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_OFF*/);
+
+ auto condition = config.add_predicate();
+ condition->set_id(StringToId("SCREEN_IS_ON"));
+ SimplePredicate* simplePredicate = condition->mutable_simple_predicate();
+ simplePredicate->set_start(StringToId("SCREEN_IS_ON"));
+ simplePredicate->set_stop(StringToId("SCREEN_IS_OFF"));
+
+ condition = config.add_predicate();
+ condition->set_id(StringToId("SCREEN_IS_EITHER_ON_OFF"));
+
+ Predicate_Combination* combination = condition->mutable_combination();
+ combination->set_operation(LogicalOperation::OR);
+ combination->add_predicate(StringToId("SCREEN_IS_ON"));
+ combination->add_predicate(StringToId("SCREEN_IS_EITHER_ON_OFF"));
+
+ return config;
+}
+
+StatsdConfig buildConfigWithDifferentPredicates() {
+ StatsdConfig config;
+ config.set_id(12345);
+
+ auto pulledAtomMatcher =
+ CreateSimpleAtomMatcher("SUBSYSTEM_SLEEP", util::SUBSYSTEM_SLEEP_STATE);
+ *config.add_atom_matcher() = pulledAtomMatcher;
+ auto screenOnAtomMatcher = CreateScreenTurnedOnAtomMatcher();
+ *config.add_atom_matcher() = screenOnAtomMatcher;
+ auto screenOffAtomMatcher = CreateScreenTurnedOffAtomMatcher();
+ *config.add_atom_matcher() = screenOffAtomMatcher;
+ auto batteryNoneAtomMatcher = CreateBatteryStateNoneMatcher();
+ *config.add_atom_matcher() = batteryNoneAtomMatcher;
+ auto batteryUsbAtomMatcher = CreateBatteryStateUsbMatcher();
+ *config.add_atom_matcher() = batteryUsbAtomMatcher;
+
+ // Simple condition with InitialValue set to default (unknown).
+ auto screenOnUnknownPredicate = CreateScreenIsOnPredicate();
+ *config.add_predicate() = screenOnUnknownPredicate;
+
+ // Simple condition with InitialValue set to false.
+ auto screenOnFalsePredicate = config.add_predicate();
+ screenOnFalsePredicate->set_id(StringToId("ScreenIsOnInitialFalse"));
+ SimplePredicate* simpleScreenOnFalsePredicate =
+ screenOnFalsePredicate->mutable_simple_predicate();
+ simpleScreenOnFalsePredicate->set_start(screenOnAtomMatcher.id());
+ simpleScreenOnFalsePredicate->set_stop(screenOffAtomMatcher.id());
+ simpleScreenOnFalsePredicate->set_initial_value(SimplePredicate_InitialValue_FALSE);
+
+ // Simple condition with InitialValue set to false.
+ auto onBatteryFalsePredicate = config.add_predicate();
+ onBatteryFalsePredicate->set_id(StringToId("OnBatteryInitialFalse"));
+ SimplePredicate* simpleOnBatteryFalsePredicate =
+ onBatteryFalsePredicate->mutable_simple_predicate();
+ simpleOnBatteryFalsePredicate->set_start(batteryNoneAtomMatcher.id());
+ simpleOnBatteryFalsePredicate->set_stop(batteryUsbAtomMatcher.id());
+ simpleOnBatteryFalsePredicate->set_initial_value(SimplePredicate_InitialValue_FALSE);
+
+ // Combination condition with both simple condition InitialValues set to false.
+ auto screenOnFalseOnBatteryFalsePredicate = config.add_predicate();
+ screenOnFalseOnBatteryFalsePredicate->set_id(StringToId("ScreenOnFalseOnBatteryFalse"));
+ screenOnFalseOnBatteryFalsePredicate->mutable_combination()->set_operation(
+ LogicalOperation::AND);
+ addPredicateToPredicateCombination(*screenOnFalsePredicate,
+ screenOnFalseOnBatteryFalsePredicate);
+ addPredicateToPredicateCombination(*onBatteryFalsePredicate,
+ screenOnFalseOnBatteryFalsePredicate);
+
+ // Combination condition with one simple condition InitialValue set to unknown and one set to
+ // false.
+ auto screenOnUnknownOnBatteryFalsePredicate = config.add_predicate();
+ screenOnUnknownOnBatteryFalsePredicate->set_id(StringToId("ScreenOnUnknowneOnBatteryFalse"));
+ screenOnUnknownOnBatteryFalsePredicate->mutable_combination()->set_operation(
+ LogicalOperation::AND);
+ addPredicateToPredicateCombination(screenOnUnknownPredicate,
+ screenOnUnknownOnBatteryFalsePredicate);
+ addPredicateToPredicateCombination(*onBatteryFalsePredicate,
+ screenOnUnknownOnBatteryFalsePredicate);
+
+ // Simple condition metric with initial value false.
+ ValueMetric* metric1 = config.add_value_metric();
+ metric1->set_id(StringToId("ValueSubsystemSleepWhileScreenOnInitialFalse"));
+ metric1->set_what(pulledAtomMatcher.id());
+ *metric1->mutable_value_field() =
+ CreateDimensions(util::SUBSYSTEM_SLEEP_STATE, {4 /* time sleeping field */});
+ metric1->set_bucket(FIVE_MINUTES);
+ metric1->set_condition(screenOnFalsePredicate->id());
+
+ // Simple condition metric with initial value unknown.
+ ValueMetric* metric2 = config.add_value_metric();
+ metric2->set_id(StringToId("ValueSubsystemSleepWhileScreenOnInitialUnknown"));
+ metric2->set_what(pulledAtomMatcher.id());
+ *metric2->mutable_value_field() =
+ CreateDimensions(util::SUBSYSTEM_SLEEP_STATE, {4 /* time sleeping field */});
+ metric2->set_bucket(FIVE_MINUTES);
+ metric2->set_condition(screenOnUnknownPredicate.id());
+
+ // Combination condition metric with initial values false and false.
+ ValueMetric* metric3 = config.add_value_metric();
+ metric3->set_id(StringToId("ValueSubsystemSleepWhileScreenOnFalseDeviceUnpluggedFalse"));
+ metric3->set_what(pulledAtomMatcher.id());
+ *metric3->mutable_value_field() =
+ CreateDimensions(util::SUBSYSTEM_SLEEP_STATE, {4 /* time sleeping field */});
+ metric3->set_bucket(FIVE_MINUTES);
+ metric3->set_condition(screenOnFalseOnBatteryFalsePredicate->id());
+
+ // Combination condition metric with initial values unknown and false.
+ ValueMetric* metric4 = config.add_value_metric();
+ metric4->set_id(StringToId("ValueSubsystemSleepWhileScreenOnUnknownDeviceUnpluggedFalse"));
+ metric4->set_what(pulledAtomMatcher.id());
+ *metric4->mutable_value_field() =
+ CreateDimensions(util::SUBSYSTEM_SLEEP_STATE, {4 /* time sleeping field */});
+ metric4->set_bucket(FIVE_MINUTES);
+ metric4->set_condition(screenOnUnknownOnBatteryFalsePredicate->id());
+
+ return config;
+}
+} // anonymous namespace
+
+TEST(MetricsManagerTest, TestInitialConditions) {
+ sp<UidMap> uidMap = new UidMap();
+ sp<StatsPullerManager> pullerManager = new StatsPullerManager();
+ sp<AlarmMonitor> anomalyAlarmMonitor;
+ sp<AlarmMonitor> periodicAlarmMonitor;
+ StatsdConfig config = buildConfigWithDifferentPredicates();
+ set<int> allTagIds;
+ vector<sp<LogMatchingTracker>> allAtomMatchers;
+ unordered_map<int64_t, int> logTrackerMap;
+ vector<sp<ConditionTracker>> allConditionTrackers;
+ vector<sp<MetricProducer>> allMetricProducers;
+ std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
+ std::vector<sp<AlarmTracker>> allAlarmTrackers;
+ unordered_map<int, std::vector<int>> conditionToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToConditionMap;
+ unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
+ unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
+ unordered_map<int64_t, int> alertTrackerMap;
+ vector<int> metricsWithActivation;
+ std::set<int64_t> noReportMetricIds;
+
+ EXPECT_TRUE(initStatsdConfig(
+ kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor, periodicAlarmMonitor,
+ timeBaseSec, timeBaseSec, allTagIds, allAtomMatchers, logTrackerMap,
+ allConditionTrackers, allMetricProducers, allAnomalyTrackers, allAlarmTrackers,
+ conditionToMetricMap, trackerToMetricMap, trackerToConditionMap,
+ activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap, alertTrackerMap,
+ metricsWithActivation, noReportMetricIds));
+ ASSERT_EQ(4u, allMetricProducers.size());
+ ASSERT_EQ(5u, allConditionTrackers.size());
+
+ ConditionKey queryKey;
+ vector<ConditionState> conditionCache(5, ConditionState::kNotEvaluated);
+
+ allConditionTrackers[3]->isConditionMet(queryKey, allConditionTrackers, false, conditionCache);
+ allConditionTrackers[4]->isConditionMet(queryKey, allConditionTrackers, false, conditionCache);
+ EXPECT_EQ(ConditionState::kUnknown, conditionCache[0]);
+ EXPECT_EQ(ConditionState::kFalse, conditionCache[1]);
+ EXPECT_EQ(ConditionState::kFalse, conditionCache[2]);
+ EXPECT_EQ(ConditionState::kFalse, conditionCache[3]);
+ EXPECT_EQ(ConditionState::kUnknown, conditionCache[4]);
+
+ EXPECT_EQ(ConditionState::kFalse, allMetricProducers[0]->mCondition);
+ EXPECT_EQ(ConditionState::kUnknown, allMetricProducers[1]->mCondition);
+ EXPECT_EQ(ConditionState::kFalse, allMetricProducers[2]->mCondition);
+ EXPECT_EQ(ConditionState::kUnknown, allMetricProducers[3]->mCondition);
+}
+
+TEST(MetricsManagerTest, TestGoodConfig) {
+ sp<UidMap> uidMap = new UidMap();
+ sp<StatsPullerManager> pullerManager = new StatsPullerManager();
+ sp<AlarmMonitor> anomalyAlarmMonitor;
+ sp<AlarmMonitor> periodicAlarmMonitor;
+ StatsdConfig config = buildGoodConfig();
+ set<int> allTagIds;
+ vector<sp<LogMatchingTracker>> allAtomMatchers;
+ unordered_map<int64_t, int> logTrackerMap;
+ vector<sp<ConditionTracker>> allConditionTrackers;
+ vector<sp<MetricProducer>> allMetricProducers;
+ std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
+ std::vector<sp<AlarmTracker>> allAlarmTrackers;
+ unordered_map<int, std::vector<int>> conditionToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToConditionMap;
+ unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
+ unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
+ unordered_map<int64_t, int> alertTrackerMap;
+ vector<int> metricsWithActivation;
+ std::set<int64_t> noReportMetricIds;
+
+ EXPECT_TRUE(initStatsdConfig(
+ kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor, periodicAlarmMonitor,
+ timeBaseSec, timeBaseSec, allTagIds, allAtomMatchers, logTrackerMap,
+ allConditionTrackers, allMetricProducers, allAnomalyTrackers, allAlarmTrackers,
+ conditionToMetricMap, trackerToMetricMap, trackerToConditionMap,
+ activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap, alertTrackerMap,
+ metricsWithActivation, noReportMetricIds));
+ ASSERT_EQ(1u, allMetricProducers.size());
+ ASSERT_EQ(1u, allAnomalyTrackers.size());
+ ASSERT_EQ(1u, noReportMetricIds.size());
+ ASSERT_EQ(1u, alertTrackerMap.size());
+ EXPECT_NE(alertTrackerMap.find(kAlertId), alertTrackerMap.end());
+ EXPECT_EQ(alertTrackerMap.find(kAlertId)->second, 0);
+}
+
+TEST(MetricsManagerTest, TestDimensionMetricsWithMultiTags) {
+ sp<UidMap> uidMap = new UidMap();
+ sp<StatsPullerManager> pullerManager = new StatsPullerManager();
+ sp<AlarmMonitor> anomalyAlarmMonitor;
+ sp<AlarmMonitor> periodicAlarmMonitor;
+ StatsdConfig config = buildDimensionMetricsWithMultiTags();
+ set<int> allTagIds;
+ vector<sp<LogMatchingTracker>> allAtomMatchers;
+ unordered_map<int64_t, int> logTrackerMap;
+ vector<sp<ConditionTracker>> allConditionTrackers;
+ vector<sp<MetricProducer>> allMetricProducers;
+ std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
+ std::vector<sp<AlarmTracker>> allAlarmTrackers;
+ unordered_map<int, std::vector<int>> conditionToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToConditionMap;
+ unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
+ unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
+ unordered_map<int64_t, int> alertTrackerMap;
+ vector<int> metricsWithActivation;
+ std::set<int64_t> noReportMetricIds;
+
+ EXPECT_FALSE(initStatsdConfig(
+ kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor, periodicAlarmMonitor,
+ timeBaseSec, timeBaseSec, allTagIds, allAtomMatchers, logTrackerMap,
+ allConditionTrackers, allMetricProducers, allAnomalyTrackers, allAlarmTrackers,
+ conditionToMetricMap, trackerToMetricMap, trackerToConditionMap,
+ activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap, alertTrackerMap,
+ metricsWithActivation, noReportMetricIds));
+}
+
+TEST(MetricsManagerTest, TestCircleLogMatcherDependency) {
+ sp<UidMap> uidMap = new UidMap();
+ sp<StatsPullerManager> pullerManager = new StatsPullerManager();
+ sp<AlarmMonitor> anomalyAlarmMonitor;
+ sp<AlarmMonitor> periodicAlarmMonitor;
+ StatsdConfig config = buildCircleMatchers();
+ set<int> allTagIds;
+ vector<sp<LogMatchingTracker>> allAtomMatchers;
+ unordered_map<int64_t, int> logTrackerMap;
+ vector<sp<ConditionTracker>> allConditionTrackers;
+ vector<sp<MetricProducer>> allMetricProducers;
+ std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
+ std::vector<sp<AlarmTracker>> allAlarmTrackers;
+ unordered_map<int, std::vector<int>> conditionToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToConditionMap;
+ unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
+ unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
+ unordered_map<int64_t, int> alertTrackerMap;
+ vector<int> metricsWithActivation;
+ std::set<int64_t> noReportMetricIds;
+
+ EXPECT_FALSE(initStatsdConfig(
+ kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor, periodicAlarmMonitor,
+ timeBaseSec, timeBaseSec, allTagIds, allAtomMatchers, logTrackerMap,
+ allConditionTrackers, allMetricProducers, allAnomalyTrackers, allAlarmTrackers,
+ conditionToMetricMap, trackerToMetricMap, trackerToConditionMap,
+ activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap, alertTrackerMap,
+ metricsWithActivation, noReportMetricIds));
+}
+
+TEST(MetricsManagerTest, TestMissingMatchers) {
+ sp<UidMap> uidMap = new UidMap();
+ sp<StatsPullerManager> pullerManager = new StatsPullerManager();
+ sp<AlarmMonitor> anomalyAlarmMonitor;
+ sp<AlarmMonitor> periodicAlarmMonitor;
+ StatsdConfig config = buildMissingMatchers();
+ set<int> allTagIds;
+ vector<sp<LogMatchingTracker>> allAtomMatchers;
+ unordered_map<int64_t, int> logTrackerMap;
+ vector<sp<ConditionTracker>> allConditionTrackers;
+ vector<sp<MetricProducer>> allMetricProducers;
+ std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
+ std::vector<sp<AlarmTracker>> allAlarmTrackers;
+ unordered_map<int, std::vector<int>> conditionToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToConditionMap;
+ unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
+ unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
+ unordered_map<int64_t, int> alertTrackerMap;
+ vector<int> metricsWithActivation;
+ std::set<int64_t> noReportMetricIds;
+ EXPECT_FALSE(initStatsdConfig(
+ kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor, periodicAlarmMonitor,
+ timeBaseSec, timeBaseSec, allTagIds, allAtomMatchers, logTrackerMap,
+ allConditionTrackers, allMetricProducers, allAnomalyTrackers, allAlarmTrackers,
+ conditionToMetricMap, trackerToMetricMap, trackerToConditionMap,
+ activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap, alertTrackerMap,
+ metricsWithActivation, noReportMetricIds));
+}
+
+TEST(MetricsManagerTest, TestMissingPredicate) {
+ sp<UidMap> uidMap = new UidMap();
+ sp<StatsPullerManager> pullerManager = new StatsPullerManager();
+ sp<AlarmMonitor> anomalyAlarmMonitor;
+ sp<AlarmMonitor> periodicAlarmMonitor;
+ StatsdConfig config = buildMissingPredicate();
+ set<int> allTagIds;
+ vector<sp<LogMatchingTracker>> allAtomMatchers;
+ unordered_map<int64_t, int> logTrackerMap;
+ vector<sp<ConditionTracker>> allConditionTrackers;
+ vector<sp<MetricProducer>> allMetricProducers;
+ std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
+ std::vector<sp<AlarmTracker>> allAlarmTrackers;
+ unordered_map<int, std::vector<int>> conditionToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToConditionMap;
+ unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
+ unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
+ unordered_map<int64_t, int> alertTrackerMap;
+ vector<int> metricsWithActivation;
+ std::set<int64_t> noReportMetricIds;
+ EXPECT_FALSE(initStatsdConfig(
+ kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor, periodicAlarmMonitor,
+ timeBaseSec, timeBaseSec, allTagIds, allAtomMatchers, logTrackerMap,
+ allConditionTrackers, allMetricProducers, allAnomalyTrackers, allAlarmTrackers,
+ conditionToMetricMap, trackerToMetricMap, trackerToConditionMap,
+ activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap, alertTrackerMap,
+ metricsWithActivation, noReportMetricIds));
+}
+
+TEST(MetricsManagerTest, TestCirclePredicateDependency) {
+ sp<UidMap> uidMap = new UidMap();
+ sp<StatsPullerManager> pullerManager = new StatsPullerManager();
+ sp<AlarmMonitor> anomalyAlarmMonitor;
+ sp<AlarmMonitor> periodicAlarmMonitor;
+ StatsdConfig config = buildCirclePredicates();
+ set<int> allTagIds;
+ vector<sp<LogMatchingTracker>> allAtomMatchers;
+ unordered_map<int64_t, int> logTrackerMap;
+ vector<sp<ConditionTracker>> allConditionTrackers;
+ vector<sp<MetricProducer>> allMetricProducers;
+ std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
+ std::vector<sp<AlarmTracker>> allAlarmTrackers;
+ unordered_map<int, std::vector<int>> conditionToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToConditionMap;
+ unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
+ unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
+ unordered_map<int64_t, int> alertTrackerMap;
+ vector<int> metricsWithActivation;
+ std::set<int64_t> noReportMetricIds;
+
+ EXPECT_FALSE(initStatsdConfig(
+ kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor, periodicAlarmMonitor,
+ timeBaseSec, timeBaseSec, allTagIds, allAtomMatchers, logTrackerMap,
+ allConditionTrackers, allMetricProducers, allAnomalyTrackers, allAlarmTrackers,
+ conditionToMetricMap, trackerToMetricMap, trackerToConditionMap,
+ activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap, alertTrackerMap,
+ metricsWithActivation, noReportMetricIds));
+}
+
+TEST(MetricsManagerTest, testAlertWithUnknownMetric) {
+ sp<UidMap> uidMap = new UidMap();
+ sp<StatsPullerManager> pullerManager = new StatsPullerManager();
+ sp<AlarmMonitor> anomalyAlarmMonitor;
+ sp<AlarmMonitor> periodicAlarmMonitor;
+ StatsdConfig config = buildAlertWithUnknownMetric();
+ set<int> allTagIds;
+ vector<sp<LogMatchingTracker>> allAtomMatchers;
+ unordered_map<int64_t, int> logTrackerMap;
+ vector<sp<ConditionTracker>> allConditionTrackers;
+ vector<sp<MetricProducer>> allMetricProducers;
+ std::vector<sp<AnomalyTracker>> allAnomalyTrackers;
+ std::vector<sp<AlarmTracker>> allAlarmTrackers;
+ unordered_map<int, std::vector<int>> conditionToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToMetricMap;
+ unordered_map<int, std::vector<int>> trackerToConditionMap;
+ unordered_map<int, std::vector<int>> activationAtomTrackerToMetricMap;
+ unordered_map<int, std::vector<int>> deactivationAtomTrackerToMetricMap;
+ unordered_map<int64_t, int> alertTrackerMap;
+ vector<int> metricsWithActivation;
+ std::set<int64_t> noReportMetricIds;
+
+ EXPECT_FALSE(initStatsdConfig(
+ kConfigKey, config, uidMap, pullerManager, anomalyAlarmMonitor, periodicAlarmMonitor,
+ timeBaseSec, timeBaseSec, allTagIds, allAtomMatchers, logTrackerMap,
+ allConditionTrackers, allMetricProducers, allAnomalyTrackers, allAlarmTrackers,
+ conditionToMetricMap, trackerToMetricMap, trackerToConditionMap,
+ activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap, alertTrackerMap,
+ metricsWithActivation, noReportMetricIds));
+}
+
+TEST(MetricsManagerTest, TestCreateLogTrackerInvalidMatcher) {
+ sp<UidMap> uidMap = new UidMap();
+ AtomMatcher matcher;
+ matcher.set_id(21);
+ EXPECT_EQ(createLogTracker(matcher, 0, uidMap), nullptr);
+}
+
+TEST(MetricsManagerTest, TestCreateLogTrackerSimple) {
+ int index = 1;
+ int64_t id = 123;
+ sp<UidMap> uidMap = new UidMap();
+ AtomMatcher matcher;
+ matcher.set_id(id);
+ SimpleAtomMatcher* simpleAtomMatcher = matcher.mutable_simple_atom_matcher();
+ simpleAtomMatcher->set_atom_id(util::SCREEN_STATE_CHANGED);
+ simpleAtomMatcher->add_field_value_matcher()->set_field(
+ 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/);
+ simpleAtomMatcher->mutable_field_value_matcher(0)->set_eq_int(
+ android::view::DisplayStateEnum::DISPLAY_STATE_ON);
+
+ sp<LogMatchingTracker> tracker = createLogTracker(matcher, index, uidMap);
+ EXPECT_NE(tracker, nullptr);
+
+ EXPECT_TRUE(tracker->mInitialized);
+ EXPECT_EQ(tracker->getId(), id);
+ EXPECT_EQ(tracker->mIndex, index);
+ const set<int>& atomIds = tracker->getAtomIds();
+ ASSERT_EQ(atomIds.size(), 1);
+ EXPECT_EQ(atomIds.count(util::SCREEN_STATE_CHANGED), 1);
+}
+
+TEST(MetricsManagerTest, TestCreateLogTrackerCombination) {
+ int index = 1;
+ int64_t id = 123;
+ sp<UidMap> uidMap = new UidMap();
+ AtomMatcher matcher;
+ matcher.set_id(id);
+ AtomMatcher_Combination* combination = matcher.mutable_combination();
+ combination->set_operation(LogicalOperation::OR);
+ combination->add_matcher(123);
+ combination->add_matcher(223);
+
+ sp<LogMatchingTracker> tracker = createLogTracker(matcher, index, uidMap);
+ EXPECT_NE(tracker, nullptr);
+
+ // Combination matchers need to be initialized first.
+ EXPECT_FALSE(tracker->mInitialized);
+ EXPECT_EQ(tracker->getId(), id);
+ EXPECT_EQ(tracker->mIndex, index);
+ const set<int>& atomIds = tracker->getAtomIds();
+ ASSERT_EQ(atomIds.size(), 0);
+}
+
+} // namespace statsd
+} // namespace os
+} // namespace android
+
+#else
+GTEST_LOG_(INFO) << "This test does nothing.\n";
+#endif
diff --git a/cmds/statsd/tests/statsd_test_util.cpp b/cmds/statsd/tests/statsd_test_util.cpp
index cee8372..0be983f 100644
--- a/cmds/statsd/tests/statsd_test_util.cpp
+++ b/cmds/statsd/tests/statsd_test_util.cpp
@@ -15,6 +15,8 @@
#include "statsd_test_util.h"
#include <aidl/android/util/StatsEventParcel.h>
+
+#include "matchers/SimpleLogMatchingTracker.h"
#include "stats_event.h"
using aidl::android::util::StatsEventParcel;
@@ -996,6 +998,20 @@
return static_cast<int64_t>(std::hash<std::string>()(str));
}
+sp<EventMatcherWizard> createEventMatcherWizard(
+ int tagId, int matcherIndex, const vector<FieldValueMatcher>& fieldValueMatchers) {
+ sp<UidMap> uidMap = new UidMap();
+ SimpleAtomMatcher atomMatcher;
+ atomMatcher.set_atom_id(tagId);
+ for (const FieldValueMatcher& fvm : fieldValueMatchers) {
+ *atomMatcher.add_field_value_matcher() = fvm;
+ }
+ uint64_t matcherHash = 0x12345678;
+ int64_t matcherId = 678;
+ return new EventMatcherWizard({new SimpleLogMatchingTracker(matcherId, matcherIndex,
+ matcherHash, atomMatcher, uidMap)});
+}
+
void ValidateWakelockAttributionUidAndTagDimension(const DimensionsValue& value, const int atomId,
const int uid, const string& tag) {
EXPECT_EQ(value.field(), atomId);
diff --git a/cmds/statsd/tests/statsd_test_util.h b/cmds/statsd/tests/statsd_test_util.h
index 3dcf4ec..1220019 100644
--- a/cmds/statsd/tests/statsd_test_util.h
+++ b/cmds/statsd/tests/statsd_test_util.h
@@ -25,6 +25,7 @@
#include "src/StatsLogProcessor.h"
#include "src/hash.h"
#include "src/logd/LogEvent.h"
+#include "src/matchers/EventMatcherWizard.h"
#include "src/packages/UidMap.h"
#include "src/stats_log_util.h"
#include "stats_event.h"
@@ -335,6 +336,9 @@
int64_t StringToId(const string& str);
+sp<EventMatcherWizard> createEventMatcherWizard(
+ int tagId, int matcherIndex, const std::vector<FieldValueMatcher>& fieldValueMatchers = {});
+
void ValidateWakelockAttributionUidAndTagDimension(const DimensionsValue& value, const int atomId,
const int uid, const string& tag);
void ValidateUidDimension(const DimensionsValue& value, int node_idx, int atomId, int uid);
diff --git a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java
index ca22bf4..d334de6 100644
--- a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java
+++ b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java
@@ -364,6 +364,18 @@
*/
public static final int FLAG_REQUEST_MULTI_FINGER_GESTURES = 0x0001000;
+ /**
+ * This flag requests that when when {@link #FLAG_REQUEST_MULTI_FINGER_GESTURES} is enabled,
+ * two-finger passthrough gestures are re-enabled. Two-finger swipe gestures are not detected,
+ * but instead passed through as one-finger gestures. In addition, three-finger swipes from the
+ * bottom of the screen are not detected, and instead are passed through unchanged. If {@link
+ * #FLAG_REQUEST_MULTI_FINGER_GESTURES} is disabled this flag has no effect.
+ *
+ * @see #FLAG_REQUEST_TOUCH_EXPLORATION_MODE
+ * @hide
+ */
+ public static final int FLAG_REQUEST_2_FINGER_PASSTHROUGH = 0x0002000;
+
/** {@hide} */
public static final int FLAG_FORCE_DIRECT_BOOT_AWARE = 0x00010000;
@@ -624,6 +636,7 @@
0);
flags = asAttributes.getInt(
com.android.internal.R.styleable.AccessibilityService_accessibilityFlags, 0);
+ flags |= FLAG_REQUEST_2_FINGER_PASSTHROUGH;
mSettingsActivityName = asAttributes.getString(
com.android.internal.R.styleable.AccessibilityService_settingsActivity);
if (asAttributes.getBoolean(com.android.internal.R.styleable
@@ -1261,6 +1274,8 @@
return "FLAG_SERVICE_HANDLES_DOUBLE_TAP";
case FLAG_REQUEST_MULTI_FINGER_GESTURES:
return "FLAG_REQUEST_MULTI_FINGER_GESTURES";
+ case FLAG_REQUEST_2_FINGER_PASSTHROUGH:
+ return "FLAG_REQUEST_2_FINGER_PASSTHROUGH";
case FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY:
return "FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY";
case FLAG_REPORT_VIEW_IDS:
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 522b8cc..5c4951e 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -3827,6 +3827,12 @@
} catch (RemoteException e) {
finishAfterTransition();
}
+
+ // Activity was launched when user tapped a link in the Autofill Save UI - Save UI must
+ // be restored now.
+ if (mIntent != null && mIntent.hasExtra(AutofillManager.EXTRA_RESTORE_SESSION_TOKEN)) {
+ restoreAutofillSaveUi();
+ }
}
/**
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index dde0be5..d67b986 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -37,6 +37,7 @@
import android.app.assist.AssistContent;
import android.app.assist.AssistStructure;
import android.app.backup.BackupAgent;
+import android.app.backup.BackupManager;
import android.app.servertransaction.ActivityLifecycleItem;
import android.app.servertransaction.ActivityLifecycleItem.LifecycleState;
import android.app.servertransaction.ActivityRelaunchItem;
@@ -289,6 +290,8 @@
private final Object mNetworkPolicyLock = new Object();
+ private static final String DEFAULT_FULL_BACKUP_AGENT = "android.app.backup.FullBackupAgent";
+
/**
* Denotes the sequence number of the process state change for which the main thread needs
* to block until the network rules are updated for it.
@@ -745,6 +748,7 @@
CompatibilityInfo compatInfo;
int backupMode;
int userId;
+ int operationType;
public String toString() {
return "CreateBackupAgentData{appInfo=" + appInfo
+ " backupAgent=" + appInfo.backupAgentName
@@ -965,12 +969,13 @@
}
public final void scheduleCreateBackupAgent(ApplicationInfo app,
- CompatibilityInfo compatInfo, int backupMode, int userId) {
+ CompatibilityInfo compatInfo, int backupMode, int userId, int operationType) {
CreateBackupAgentData d = new CreateBackupAgentData();
d.appInfo = app;
d.compatInfo = compatInfo;
d.backupMode = backupMode;
d.userId = userId;
+ d.operationType = operationType;
sendMessage(H.CREATE_BACKUP_AGENT, d);
}
@@ -4093,12 +4098,7 @@
return;
}
- String classname = data.appInfo.backupAgentName;
- // full backup operation but no app-supplied agent? use the default implementation
- if (classname == null && (data.backupMode == ApplicationThreadConstants.BACKUP_MODE_FULL
- || data.backupMode == ApplicationThreadConstants.BACKUP_MODE_RESTORE_FULL)) {
- classname = "android.app.backup.FullBackupAgent";
- }
+ String classname = getBackupAgentName(data);
try {
IBinder binder = null;
@@ -4122,7 +4122,7 @@
context.setOuterContext(agent);
agent.attach(context);
- agent.onCreate(UserHandle.of(data.userId));
+ agent.onCreate(UserHandle.of(data.userId), data.operationType);
binder = agent.onBind();
backupAgents.put(packageName, agent);
} catch (Exception e) {
@@ -4150,6 +4150,23 @@
}
}
+ private String getBackupAgentName(CreateBackupAgentData data) {
+ String agentName = data.appInfo.backupAgentName;
+ if (!UserHandle.isCore(data.appInfo.uid)
+ && data.operationType == BackupManager.OperationType.MIGRATION) {
+ // If this is a migration, use the default backup agent regardless of the app's
+ // preferences.
+ agentName = DEFAULT_FULL_BACKUP_AGENT;
+ } else {
+ // full backup operation but no app-supplied agent? use the default implementation
+ if (agentName == null && (data.backupMode == ApplicationThreadConstants.BACKUP_MODE_FULL
+ || data.backupMode == ApplicationThreadConstants.BACKUP_MODE_RESTORE_FULL)) {
+ agentName = DEFAULT_FULL_BACKUP_AGENT;
+ }
+ }
+ return agentName;
+ }
+
// Tear down a BackupAgent
private void handleDestroyBackupAgent(CreateBackupAgentData data) {
if (DEBUG_BACKUP) Slog.v(TAG, "handleDestroyBackupAgent: " + data);
@@ -5129,6 +5146,7 @@
}
}
r.setState(ON_DESTROY);
+ mLastReportedWindowingMode.remove(r.activity.getActivityToken());
}
schedulePurgeIdler();
// updatePendingActivityConfiguration() reads from mActivities to update
@@ -5371,16 +5389,8 @@
throw e.rethrowFromSystemServer();
}
- // Save the current windowing mode to be restored and compared to the new configuration's
- // windowing mode (needed because we update the last reported windowing mode when launching
- // an activity and we can't tell inside performLaunchActivity whether we are relaunching)
- final int oldWindowingMode = mLastReportedWindowingMode.getOrDefault(
- r.activity.getActivityToken(), WINDOWING_MODE_UNDEFINED);
handleRelaunchActivityInner(r, configChanges, tmp.pendingResults, tmp.pendingIntents,
pendingActions, tmp.startsNotResumed, tmp.overrideConfig, "handleRelaunchActivity");
- mLastReportedWindowingMode.put(r.activity.getActivityToken(), oldWindowingMode);
- handleWindowingModeChangeIfNeeded(r.activity, r.activity.mCurrentConfig);
-
if (pendingActions != null) {
// Only report a successful relaunch to WindowManager.
pendingActions.setReportRelaunchToWindowManager(true);
@@ -5646,10 +5656,6 @@
throw new IllegalArgumentException("Activity token not set. Is the activity attached?");
}
- // multi-window / pip mode changes, if any, should be sent before the configuration change
- // callback, see also PinnedStackTests#testConfigurationChangeOrderDuringTransition
- handleWindowingModeChangeIfNeeded(activity, newConfig);
-
final boolean movedToDifferentDisplay = isDifferentDisplay(activity, displayId);
boolean shouldReportChange = false;
if (activity.mCurrentConfig == null) {
@@ -5703,6 +5709,11 @@
}
if (shouldReportChange) {
+ // multi-window / pip mode changes, if any, should be sent before the configuration
+ // change callback, see also
+ // PinnedStackTests#testConfigurationChangeOrderDuringTransition
+ handleWindowingModeChangeIfNeeded(activity, newConfig);
+
activity.mCalled = false;
activity.onConfigurationChanged(configToReport);
if (!activity.mCalled) {
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index b40dd00..95136bb 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -2657,8 +2657,10 @@
* @hide
*/
// TODO: this should probably be @SystemApi as well
- public static @NonNull String toReceiverId(@NonNull Object obj) {
- if (obj instanceof PendingIntent) {
+ public static @NonNull String toReceiverId(@Nullable Object obj) {
+ if (obj == null) {
+ return "null";
+ } else if (obj instanceof PendingIntent) {
return toReceiverId((PendingIntent) obj);
} else {
return obj.getClass().getName() + "@" + System.identityHashCode(obj);
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 9613e58..f6b5334 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -1624,8 +1624,9 @@
}
try {
final Intent intent = ActivityManager.getService().registerReceiverWithFeature(
- mMainThread.getApplicationThread(), mBasePackageName, getAttributionTag(), rd,
- filter, broadcastPermission, userId, flags);
+ mMainThread.getApplicationThread(), mBasePackageName, getAttributionTag(),
+ AppOpsManager.toReceiverId(receiver), rd, filter, broadcastPermission, userId,
+ flags);
if (intent != null) {
intent.setExtrasClassLoader(getClassLoader());
intent.prepareToEnterProcess();
diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl
index 3b6a7b8..93dfc79 100644
--- a/core/java/android/app/IActivityManager.aidl
+++ b/core/java/android/app/IActivityManager.aidl
@@ -123,8 +123,8 @@
in IIntentReceiver receiver, in IntentFilter filter,
in String requiredPermission, int userId, int flags);
Intent registerReceiverWithFeature(in IApplicationThread caller, in String callerPackage,
- in String callingFeatureId, in IIntentReceiver receiver, in IntentFilter filter,
- in String requiredPermission, int userId, int flags);
+ in String callingFeatureId, in String receiverId, in IIntentReceiver receiver,
+ in IntentFilter filter, in String requiredPermission, int userId, int flags);
@UnsupportedAppUsage
void unregisterReceiver(in IIntentReceiver receiver);
/** @deprecated Use {@link #broadcastIntentWithFeature} instead */
@@ -288,7 +288,8 @@
void stopAppSwitches();
@UnsupportedAppUsage
void resumeAppSwitches();
- boolean bindBackupAgent(in String packageName, int backupRestoreMode, int targetUserId);
+ boolean bindBackupAgent(in String packageName, int backupRestoreMode, int targetUserId,
+ int operationType);
void backupAgentCreated(in String packageName, in IBinder agent, int userId);
void unbindBackupAgent(in ApplicationInfo appInfo);
int getUidForIntentSender(in IIntentSender sender);
diff --git a/core/java/android/app/IApplicationThread.aidl b/core/java/android/app/IApplicationThread.aidl
index e5d4a76..dc9918a 100644
--- a/core/java/android/app/IApplicationThread.aidl
+++ b/core/java/android/app/IApplicationThread.aidl
@@ -96,7 +96,7 @@
void profilerControl(boolean start, in ProfilerInfo profilerInfo, int profileType);
void setSchedulingGroup(int group);
void scheduleCreateBackupAgent(in ApplicationInfo app, in CompatibilityInfo compatInfo,
- int backupMode, int userId);
+ int backupMode, int userId, int operationType);
void scheduleDestroyBackupAgent(in ApplicationInfo app,
in CompatibilityInfo compatInfo, int userId);
void scheduleOnNewActivityOptions(IBinder token, in Bundle options);
diff --git a/core/java/android/app/IUiAutomationConnection.aidl b/core/java/android/app/IUiAutomationConnection.aidl
index 8c3180b..4c9e400 100644
--- a/core/java/android/app/IUiAutomationConnection.aidl
+++ b/core/java/android/app/IUiAutomationConnection.aidl
@@ -39,7 +39,7 @@
boolean injectInputEvent(in InputEvent event, boolean sync);
void syncInputTransactions();
boolean setRotation(int rotation);
- Bitmap takeScreenshot(in Rect crop, int rotation);
+ Bitmap takeScreenshot(in Rect crop);
boolean clearWindowContentFrameStats(int windowId);
WindowContentFrameStats getWindowContentFrameStats(int windowId);
void clearWindowAnimationFrameStats();
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 68e6561..6f3e8922 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1492,6 +1492,7 @@
private boolean mAllowGeneratedReplies = true;
private final @SemanticAction int mSemanticAction;
private final boolean mIsContextual;
+ private boolean mAuthenticationRequired;
/**
* Small icon representing the action.
@@ -1528,6 +1529,7 @@
mAllowGeneratedReplies = in.readInt() == 1;
mSemanticAction = in.readInt();
mIsContextual = in.readInt() == 1;
+ mAuthenticationRequired = in.readInt() == 1;
}
/**
@@ -1536,13 +1538,14 @@
@Deprecated
public Action(int icon, CharSequence title, PendingIntent intent) {
this(Icon.createWithResource("", icon), title, intent, new Bundle(), null, true,
- SEMANTIC_ACTION_NONE, false /* isContextual */);
+ SEMANTIC_ACTION_NONE, false /* isContextual */, false /* requireAuth */);
}
/** Keep in sync with {@link Notification.Action.Builder#Builder(Action)}! */
private Action(Icon icon, CharSequence title, PendingIntent intent, Bundle extras,
RemoteInput[] remoteInputs, boolean allowGeneratedReplies,
- @SemanticAction int semanticAction, boolean isContextual) {
+ @SemanticAction int semanticAction, boolean isContextual,
+ boolean requireAuth) {
this.mIcon = icon;
if (icon != null && icon.getType() == Icon.TYPE_RESOURCE) {
this.icon = icon.getResId();
@@ -1554,6 +1557,7 @@
this.mAllowGeneratedReplies = allowGeneratedReplies;
this.mSemanticAction = semanticAction;
this.mIsContextual = isContextual;
+ this.mAuthenticationRequired = requireAuth;
}
/**
@@ -1624,6 +1628,17 @@
}
/**
+ * Returns whether the OS should only send this action's {@link PendingIntent} on an
+ * unlocked device.
+ *
+ * If the device is locked when the action is invoked, the OS should show the keyguard and
+ * require successful authentication before invoking the intent.
+ */
+ public boolean isAuthenticationRequired() {
+ return mAuthenticationRequired;
+ }
+
+ /**
* Builder class for {@link Action} objects.
*/
public static final class Builder {
@@ -1635,6 +1650,7 @@
@Nullable private ArrayList<RemoteInput> mRemoteInputs;
private @SemanticAction int mSemanticAction;
private boolean mIsContextual;
+ private boolean mAuthenticationRequired;
/**
* Construct a new builder for {@link Action} object.
@@ -1654,7 +1670,7 @@
* @param intent the {@link PendingIntent} to fire when users trigger this action
*/
public Builder(Icon icon, CharSequence title, PendingIntent intent) {
- this(icon, title, intent, new Bundle(), null, true, SEMANTIC_ACTION_NONE);
+ this(icon, title, intent, new Bundle(), null, true, SEMANTIC_ACTION_NONE, false);
}
/**
@@ -1665,23 +1681,25 @@
public Builder(Action action) {
this(action.getIcon(), action.title, action.actionIntent,
new Bundle(action.mExtras), action.getRemoteInputs(),
- action.getAllowGeneratedReplies(), action.getSemanticAction());
+ action.getAllowGeneratedReplies(), action.getSemanticAction(),
+ action.isAuthenticationRequired());
}
private Builder(@Nullable Icon icon, @Nullable CharSequence title,
@Nullable PendingIntent intent, @NonNull Bundle extras,
@Nullable RemoteInput[] remoteInputs, boolean allowGeneratedReplies,
- @SemanticAction int semanticAction) {
+ @SemanticAction int semanticAction, boolean authRequired) {
mIcon = icon;
mTitle = title;
mIntent = intent;
mExtras = extras;
if (remoteInputs != null) {
- mRemoteInputs = new ArrayList<RemoteInput>(remoteInputs.length);
+ mRemoteInputs = new ArrayList<>(remoteInputs.length);
Collections.addAll(mRemoteInputs, remoteInputs);
}
mAllowGeneratedReplies = allowGeneratedReplies;
mSemanticAction = semanticAction;
+ mAuthenticationRequired = authRequired;
}
/**
@@ -1776,6 +1794,21 @@
}
/**
+ * Sets whether the OS should only send this action's {@link PendingIntent} on an
+ * unlocked device.
+ *
+ * If this is true and the device is locked when the action is invoked, the OS will
+ * show the keyguard and require successful authentication before invoking the intent.
+ * If this is false and the device is locked, the OS will decide whether authentication
+ * should be required.
+ */
+ @NonNull
+ public Builder setAuthenticationRequired(boolean authenticationRequired) {
+ mAuthenticationRequired = authenticationRequired;
+ return this;
+ }
+
+ /**
* Throws an NPE if we are building a contextual action missing one of the fields
* necessary to display the action.
*/
@@ -1827,7 +1860,8 @@
RemoteInput[] textInputsArr = textInputs.isEmpty()
? null : textInputs.toArray(new RemoteInput[textInputs.size()]);
return new Action(mIcon, mTitle, mIntent, mExtras, textInputsArr,
- mAllowGeneratedReplies, mSemanticAction, mIsContextual);
+ mAllowGeneratedReplies, mSemanticAction, mIsContextual,
+ mAuthenticationRequired);
}
}
@@ -1841,7 +1875,8 @@
getRemoteInputs(),
getAllowGeneratedReplies(),
getSemanticAction(),
- isContextual());
+ isContextual(),
+ isAuthenticationRequired());
}
@Override
@@ -1870,6 +1905,7 @@
out.writeInt(mAllowGeneratedReplies ? 1 : 0);
out.writeInt(mSemanticAction);
out.writeInt(mIsContextual ? 1 : 0);
+ out.writeInt(mAuthenticationRequired ? 1 : 0);
}
public static final @android.annotation.NonNull Parcelable.Creator<Action> CREATOR =
diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java
index 7477899..fb2120e 100644
--- a/core/java/android/app/ResourcesManager.java
+++ b/core/java/android/app/ResourcesManager.java
@@ -39,7 +39,6 @@
import android.util.ArrayMap;
import android.util.DisplayMetrics;
import android.util.Log;
-import android.util.LruCache;
import android.util.Pair;
import android.util.Slog;
import android.view.Display;
@@ -62,7 +61,6 @@
import java.util.Objects;
import java.util.WeakHashMap;
import java.util.function.Consumer;
-import java.util.function.Predicate;
/** @hide */
public class ResourcesManager {
@@ -129,17 +127,30 @@
}
}
- private static final boolean ENABLE_APK_ASSETS_CACHE = false;
-
/**
- * The ApkAssets we are caching and intend to hold strong references to.
+ * Loads {@link ApkAssets} and caches them to prevent their garbage collection while the
+ * instance is alive and reachable.
*/
- private final LruCache<ApkKey, ApkAssets> mLoadedApkAssets =
- (ENABLE_APK_ASSETS_CACHE) ? new LruCache<>(3) : null;
+ private class ApkAssetsSupplier {
+ final ArrayMap<ApkKey, ApkAssets> mLocalCache = new ArrayMap<>();
+
+ /**
+ * Retrieves the {@link ApkAssets} corresponding to the specified key, caches the ApkAssets
+ * within this instance, and inserts the loaded ApkAssets into the {@link #mCachedApkAssets}
+ * cache.
+ */
+ ApkAssets load(final ApkKey apkKey) throws IOException {
+ ApkAssets apkAssets = mLocalCache.get(apkKey);
+ if (apkAssets == null) {
+ apkAssets = loadApkAssets(apkKey);
+ mLocalCache.put(apkKey, apkAssets);
+ }
+ return apkAssets;
+ }
+ }
/**
- * The ApkAssets that are being referenced in the wild that we can reuse, even if they aren't
- * in our LRU cache. Bonus resources :)
+ * The ApkAssets that are being referenced in the wild that we can reuse.
*/
private final ArrayMap<ApkKey, WeakReference<ApkAssets>> mCachedApkAssets = new ArrayMap<>();
@@ -228,7 +239,8 @@
}
}
- DisplayMetrics getDisplayMetrics() {
+ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
+ public DisplayMetrics getDisplayMetrics() {
return getDisplayMetrics(Display.DEFAULT_DISPLAY,
DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS);
}
@@ -337,49 +349,78 @@
return "/data/resource-cache/" + path.substring(1).replace('/', '@') + "@idmap";
}
- private @NonNull ApkAssets loadApkAssets(String path, boolean sharedLib, boolean overlay)
- throws IOException {
- final ApkKey newKey = new ApkKey(path, sharedLib, overlay);
- ApkAssets apkAssets = null;
- if (mLoadedApkAssets != null) {
- apkAssets = mLoadedApkAssets.get(newKey);
- if (apkAssets != null && apkAssets.isUpToDate()) {
- return apkAssets;
- }
- }
+ private @NonNull ApkAssets loadApkAssets(@NonNull final ApkKey key) throws IOException {
+ ApkAssets apkAssets;
// Optimistically check if this ApkAssets exists somewhere else.
- final WeakReference<ApkAssets> apkAssetsRef = mCachedApkAssets.get(newKey);
- if (apkAssetsRef != null) {
- apkAssets = apkAssetsRef.get();
- if (apkAssets != null && apkAssets.isUpToDate()) {
- if (mLoadedApkAssets != null) {
- mLoadedApkAssets.put(newKey, apkAssets);
+ synchronized (this) {
+ final WeakReference<ApkAssets> apkAssetsRef = mCachedApkAssets.get(key);
+ if (apkAssetsRef != null) {
+ apkAssets = apkAssetsRef.get();
+ if (apkAssets != null && apkAssets.isUpToDate()) {
+ return apkAssets;
+ } else {
+ // Clean up the reference.
+ mCachedApkAssets.remove(key);
}
-
- return apkAssets;
- } else {
- // Clean up the reference.
- mCachedApkAssets.remove(newKey);
}
}
// We must load this from disk.
- if (overlay) {
- apkAssets = ApkAssets.loadOverlayFromPath(overlayPathToIdmapPath(path), 0 /*flags*/);
+ if (key.overlay) {
+ apkAssets = ApkAssets.loadOverlayFromPath(overlayPathToIdmapPath(key.path),
+ 0 /*flags*/);
} else {
- apkAssets = ApkAssets.loadFromPath(path, sharedLib ? ApkAssets.PROPERTY_DYNAMIC : 0);
+ apkAssets = ApkAssets.loadFromPath(key.path,
+ key.sharedLib ? ApkAssets.PROPERTY_DYNAMIC : 0);
}
- if (mLoadedApkAssets != null) {
- mLoadedApkAssets.put(newKey, apkAssets);
+ synchronized (this) {
+ mCachedApkAssets.put(key, new WeakReference<>(apkAssets));
}
- mCachedApkAssets.put(newKey, new WeakReference<>(apkAssets));
return apkAssets;
}
/**
+ * Retrieves a list of apk keys representing the ApkAssets that should be loaded for
+ * AssetManagers mapped to the {@param key}.
+ */
+ private static @NonNull ArrayList<ApkKey> extractApkKeys(@NonNull final ResourcesKey key) {
+ final ArrayList<ApkKey> apkKeys = new ArrayList<>();
+
+ // resDir can be null if the 'android' package is creating a new Resources object.
+ // This is fine, since each AssetManager automatically loads the 'android' package
+ // already.
+ if (key.mResDir != null) {
+ apkKeys.add(new ApkKey(key.mResDir, false /*sharedLib*/, false /*overlay*/));
+ }
+
+ if (key.mSplitResDirs != null) {
+ for (final String splitResDir : key.mSplitResDirs) {
+ apkKeys.add(new ApkKey(splitResDir, false /*sharedLib*/, false /*overlay*/));
+ }
+ }
+
+ if (key.mLibDirs != null) {
+ for (final String libDir : key.mLibDirs) {
+ // Avoid opening files we know do not have resources, like code-only .jar files.
+ if (libDir.endsWith(".apk")) {
+ apkKeys.add(new ApkKey(libDir, true /*sharedLib*/, false /*overlay*/));
+ }
+ }
+ }
+
+ if (key.mOverlayDirs != null) {
+ for (final String idmapPath : key.mOverlayDirs) {
+ apkKeys.add(new ApkKey(idmapPath, false /*sharedLib*/, true /*overlay*/));
+ }
+ }
+
+ return apkKeys;
+ }
+
+ /**
* Creates an AssetManager from the paths within the ResourcesKey.
*
* This can be overridden in tests so as to avoid creating a real AssetManager with
@@ -390,64 +431,38 @@
@VisibleForTesting
@UnsupportedAppUsage
protected @Nullable AssetManager createAssetManager(@NonNull final ResourcesKey key) {
+ return createAssetManager(key, /* apkSupplier */ null);
+ }
+
+ /**
+ * Variant of {@link #createAssetManager(ResourcesKey)} that attempts to load ApkAssets
+ * from an {@link ApkAssetsSupplier} if non-null; otherwise ApkAssets are loaded using
+ * {@link #loadApkAssets(ApkKey)}.
+ */
+ private @Nullable AssetManager createAssetManager(@NonNull final ResourcesKey key,
+ @Nullable ApkAssetsSupplier apkSupplier) {
final AssetManager.Builder builder = new AssetManager.Builder();
- // resDir can be null if the 'android' package is creating a new Resources object.
- // This is fine, since each AssetManager automatically loads the 'android' package
- // already.
- if (key.mResDir != null) {
+ final ArrayList<ApkKey> apkKeys = extractApkKeys(key);
+ for (int i = 0, n = apkKeys.size(); i < n; i++) {
+ final ApkKey apkKey = apkKeys.get(i);
try {
- builder.addApkAssets(loadApkAssets(key.mResDir, false /*sharedLib*/,
- false /*overlay*/));
+ builder.addApkAssets(
+ (apkSupplier != null) ? apkSupplier.load(apkKey) : loadApkAssets(apkKey));
} catch (IOException e) {
- Log.e(TAG, "failed to add asset path " + key.mResDir);
- return null;
- }
- }
-
- if (key.mSplitResDirs != null) {
- for (final String splitResDir : key.mSplitResDirs) {
- try {
- builder.addApkAssets(loadApkAssets(splitResDir, false /*sharedLib*/,
- false /*overlay*/));
- } catch (IOException e) {
- Log.e(TAG, "failed to add split asset path " + splitResDir);
+ if (apkKey.overlay) {
+ Log.w(TAG, String.format("failed to add overlay path '%s'", apkKey.path), e);
+ } else if (apkKey.sharedLib) {
+ Log.w(TAG, String.format(
+ "asset path '%s' does not exist or contains no resources",
+ apkKey.path), e);
+ } else {
+ Log.e(TAG, String.format("failed to add asset path '%s'", apkKey.path), e);
return null;
}
}
}
- if (key.mLibDirs != null) {
- for (final String libDir : key.mLibDirs) {
- if (libDir.endsWith(".apk")) {
- // Avoid opening files we know do not have resources,
- // like code-only .jar files.
- try {
- builder.addApkAssets(loadApkAssets(libDir, true /*sharedLib*/,
- false /*overlay*/));
- } catch (IOException e) {
- Log.w(TAG, "Asset path '" + libDir +
- "' does not exist or contains no resources.");
-
- // continue.
- }
- }
- }
- }
-
- if (key.mOverlayDirs != null) {
- for (final String idmapPath : key.mOverlayDirs) {
- try {
- builder.addApkAssets(loadApkAssets(idmapPath, false /*sharedLib*/,
- true /*overlay*/));
- } catch (IOException e) {
- Log.w(TAG, "failed to add overlay path " + idmapPath);
-
- // continue.
- }
- }
- }
-
if (key.mLoaders != null) {
for (final ResourcesLoader loader : key.mLoaders) {
builder.addLoader(loader);
@@ -480,24 +495,6 @@
pw.println("ResourcesManager:");
pw.increaseIndent();
- if (mLoadedApkAssets != null) {
- pw.print("cached apks: total=");
- pw.print(mLoadedApkAssets.size());
- pw.print(" created=");
- pw.print(mLoadedApkAssets.createCount());
- pw.print(" evicted=");
- pw.print(mLoadedApkAssets.evictionCount());
- pw.print(" hit=");
- pw.print(mLoadedApkAssets.hitCount());
- pw.print(" miss=");
- pw.print(mLoadedApkAssets.missCount());
- pw.print(" max=");
- pw.print(mLoadedApkAssets.maxSize());
- } else {
- pw.print("cached apks: 0 [cache disabled]");
- }
- pw.println();
-
pw.print("total apks: ");
pw.println(countLiveReferences(mCachedApkAssets.values()));
@@ -533,11 +530,12 @@
return config;
}
- private @Nullable ResourcesImpl createResourcesImpl(@NonNull ResourcesKey key) {
+ private @Nullable ResourcesImpl createResourcesImpl(@NonNull ResourcesKey key,
+ @Nullable ApkAssetsSupplier apkSupplier) {
final DisplayAdjustments daj = new DisplayAdjustments(key.mOverrideConfiguration);
daj.setCompatibilityInfo(key.mCompatInfo);
- final AssetManager assets = createAssetManager(key);
+ final AssetManager assets = createAssetManager(key, apkSupplier);
if (assets == null) {
return null;
}
@@ -575,9 +573,18 @@
*/
private @Nullable ResourcesImpl findOrCreateResourcesImplForKeyLocked(
@NonNull ResourcesKey key) {
+ return findOrCreateResourcesImplForKeyLocked(key, /* apkSupplier */ null);
+ }
+
+ /**
+ * Variant of {@link #findOrCreateResourcesImplForKeyLocked(ResourcesKey)} that attempts to
+ * load ApkAssets from a {@link ApkAssetsSupplier} when creating a new ResourcesImpl.
+ */
+ private @Nullable ResourcesImpl findOrCreateResourcesImplForKeyLocked(
+ @NonNull ResourcesKey key, @Nullable ApkAssetsSupplier apkSupplier) {
ResourcesImpl impl = findResourcesImplForKeyLocked(key);
if (impl == null) {
- impl = createResourcesImpl(key);
+ impl = createResourcesImpl(key, apkSupplier);
if (impl != null) {
mResourceImpls.put(key, new WeakReference<>(impl));
}
@@ -766,7 +773,7 @@
}
// Now request an actual Resources object.
- return createResources(token, key, classLoader);
+ return createResources(token, key, classLoader, /* apkSupplier */ null);
} finally {
Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
}
@@ -810,18 +817,50 @@
}
/**
+ * Creates an {@link ApkAssetsSupplier} and loads all the ApkAssets required by the {@param key}
+ * into the supplier. This should be done while the lock is not held to prevent performing I/O
+ * while holding the lock.
+ */
+ private @NonNull ApkAssetsSupplier createApkAssetsSupplierNotLocked(@NonNull ResourcesKey key) {
+ Trace.traceBegin(Trace.TRACE_TAG_RESOURCES,
+ "ResourcesManager#createApkAssetsSupplierNotLocked");
+ try {
+ if (Thread.holdsLock(this)) {
+ Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName()
+ + " is holding mLock", new Throwable());
+ }
+
+ final ApkAssetsSupplier supplier = new ApkAssetsSupplier();
+ final ArrayList<ApkKey> apkKeys = extractApkKeys(key);
+ for (int i = 0, n = apkKeys.size(); i < n; i++) {
+ final ApkKey apkKey = apkKeys.get(i);
+ try {
+ supplier.load(apkKey);
+ } catch (IOException e) {
+ Log.w(TAG, String.format("failed to preload asset path '%s'", apkKey.path), e);
+ }
+ }
+ return supplier;
+ } finally {
+ Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
+ }
+ }
+
+ /**
* Creates a Resources object set with a ResourcesImpl object matching the given key.
*
* @param activityToken The Activity this Resources object should be associated with.
* @param key The key describing the parameters of the ResourcesImpl object.
* @param classLoader The classloader to use for the Resources object.
* If null, {@link ClassLoader#getSystemClassLoader()} is used.
+ * @param apkSupplier The apk assets supplier to use when creating a new ResourcesImpl object.
* @return A Resources object that gets updated when
* {@link #applyConfigurationToResourcesLocked(Configuration, CompatibilityInfo)}
* is called.
*/
private @Nullable Resources createResources(@Nullable IBinder activityToken,
- @NonNull ResourcesKey key, @NonNull ClassLoader classLoader) {
+ @NonNull ResourcesKey key, @NonNull ClassLoader classLoader,
+ @Nullable ApkAssetsSupplier apkSupplier) {
synchronized (this) {
if (DEBUG) {
Throwable here = new Throwable();
@@ -829,7 +868,7 @@
Slog.w(TAG, "!! Get resources for activity=" + activityToken + " key=" + key, here);
}
- ResourcesImpl resourcesImpl = findOrCreateResourcesImplForKeyLocked(key);
+ ResourcesImpl resourcesImpl = findOrCreateResourcesImplForKeyLocked(key, apkSupplier);
if (resourcesImpl == null) {
return null;
}
@@ -898,7 +937,10 @@
rebaseKeyForActivity(activityToken, key);
}
- return createResources(activityToken, key, classLoader);
+ // Preload the ApkAssets required by the key to prevent performing heavy I/O while the
+ // ResourcesManager lock is held.
+ final ApkAssetsSupplier assetsSupplier = createApkAssetsSupplierNotLocked(key);
+ return createResources(activityToken, key, classLoader, assetsSupplier);
} finally {
Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
}
@@ -969,7 +1011,13 @@
final ResourcesKey newKey = rebaseActivityOverrideConfig(resources, oldConfig,
overrideConfig, displayId);
if (newKey != null) {
- updateActivityResources(resources, newKey, false);
+ final ResourcesImpl resourcesImpl =
+ findOrCreateResourcesImplForKeyLocked(newKey);
+ if (resourcesImpl != null && resourcesImpl != resources.getImpl()) {
+ // Set the ResourcesImpl, updating it for all users of this Resources
+ // object.
+ resources.setImpl(resourcesImpl);
+ }
}
}
}
@@ -1024,24 +1072,6 @@
return newKey;
}
- private void updateActivityResources(Resources resources, ResourcesKey newKey,
- boolean hasLoader) {
- final ResourcesImpl resourcesImpl;
-
- if (hasLoader) {
- // Loaders always get new Impls because they cannot be shared
- resourcesImpl = createResourcesImpl(newKey);
- } else {
- resourcesImpl = findOrCreateResourcesImplForKeyLocked(newKey);
- }
-
- if (resourcesImpl != null && resourcesImpl != resources.getImpl()) {
- // Set the ResourcesImpl, updating it for all users of this Resources
- // object.
- resources.setImpl(resourcesImpl);
- }
- }
-
public final boolean applyConfigurationToResources(@NonNull Configuration config,
@Nullable CompatibilityInfo compat) {
synchronized(this) {
diff --git a/core/java/android/app/UiAutomation.java b/core/java/android/app/UiAutomation.java
index e0951bf..109205f 100644
--- a/core/java/android/app/UiAutomation.java
+++ b/core/java/android/app/UiAutomation.java
@@ -903,7 +903,7 @@
try {
// Calling out without a lock held.
screenShot = mUiAutomationConnection.takeScreenshot(
- new Rect(0, 0, displaySize.x, displaySize.y), rotation);
+ new Rect(0, 0, displaySize.x, displaySize.y));
if (screenShot == null) {
return null;
}
diff --git a/core/java/android/app/UiAutomationConnection.java b/core/java/android/app/UiAutomationConnection.java
index ce51dba..70d5201 100644
--- a/core/java/android/app/UiAutomationConnection.java
+++ b/core/java/android/app/UiAutomationConnection.java
@@ -180,7 +180,7 @@
}
@Override
- public Bitmap takeScreenshot(Rect crop, int rotation) {
+ public Bitmap takeScreenshot(Rect crop) {
synchronized (mLock) {
throwIfCalledByNotTrustedUidLocked();
throwIfShutdownLocked();
@@ -190,7 +190,15 @@
try {
int width = crop.width();
int height = crop.height();
- return SurfaceControl.screenshot(crop, width, height, rotation);
+ final IBinder displayToken = SurfaceControl.getInternalDisplayToken();
+ final SurfaceControl.DisplayCaptureArgs captureArgs =
+ new SurfaceControl.DisplayCaptureArgs.Builder(displayToken)
+ .setSourceCrop(crop)
+ .setSize(width, height)
+ .build();
+ final SurfaceControl.ScreenshotHardwareBuffer screenshotBuffer =
+ SurfaceControl.captureDisplay(captureArgs);
+ return screenshotBuffer == null ? null : screenshotBuffer.asBitmap();
} finally {
Binder.restoreCallingIdentity(identity);
}
diff --git a/core/java/android/app/backup/BackupAgent.java b/core/java/android/app/backup/BackupAgent.java
index a789169..056cfc7 100644
--- a/core/java/android/app/backup/BackupAgent.java
+++ b/core/java/android/app/backup/BackupAgent.java
@@ -19,6 +19,7 @@
import android.annotation.Nullable;
import android.app.IBackupAgent;
import android.app.QueuedWork;
+import android.app.backup.BackupManager.OperationType;
import android.app.backup.FullBackup.BackupScheme.PathWithRequiredFlags;
import android.content.Context;
import android.content.ContextWrapper;
@@ -38,6 +39,8 @@
import android.util.ArraySet;
import android.util.Log;
+import com.android.internal.annotations.VisibleForTesting;
+
import libcore.io.IoUtils;
import org.xmlpull.v1.XmlPullParserException;
@@ -50,6 +53,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
@@ -129,6 +133,7 @@
public abstract class BackupAgent extends ContextWrapper {
private static final String TAG = "BackupAgent";
private static final boolean DEBUG = false;
+ private static final int DEFAULT_OPERATION_TYPE = OperationType.BACKUP;
/** @hide */
public static final int RESULT_SUCCESS = 0;
@@ -186,6 +191,9 @@
Handler mHandler = null;
@Nullable private UserHandle mUser;
+ // This field is written from the main thread (in onCreate), and read in a Binder thread (in
+ // onFullBackup that is called from system_server via Binder).
+ @OperationType private volatile int mOperationType = DEFAULT_OPERATION_TYPE;
Handler getHandler() {
if (mHandler == null) {
@@ -229,6 +237,13 @@
}
/**
+ * @hide
+ */
+ public void onCreate(UserHandle user) {
+ onCreate(user, DEFAULT_OPERATION_TYPE);
+ }
+
+ /**
* Provided as a convenience for agent implementations that need an opportunity
* to do one-time initialization before the actual backup or restore operation
* is begun with information about the calling user.
@@ -236,10 +251,11 @@
*
* @hide
*/
- public void onCreate(UserHandle user) {
+ public void onCreate(UserHandle user, @OperationType int operationType) {
onCreate();
mUser = user;
+ mOperationType = operationType;
}
/**
@@ -386,16 +402,13 @@
*/
public void onFullBackup(FullBackupDataOutput data) throws IOException {
FullBackup.BackupScheme backupScheme = FullBackup.getBackupScheme(this);
- if (!backupScheme.isFullBackupContentEnabled()) {
+ if (!isDeviceToDeviceMigration() && !backupScheme.isFullBackupContentEnabled()) {
return;
}
- Map<String, Set<PathWithRequiredFlags>> manifestIncludeMap;
- ArraySet<PathWithRequiredFlags> manifestExcludeSet;
+ IncludeExcludeRules includeExcludeRules;
try {
- manifestIncludeMap =
- backupScheme.maybeParseAndGetCanonicalIncludePaths();
- manifestExcludeSet = backupScheme.maybeParseAndGetCanonicalExcludePaths();
+ includeExcludeRules = getIncludeExcludeRules(backupScheme);
} catch (IOException | XmlPullParserException e) {
if (Log.isLoggable(FullBackup.TAG_XML_PARSER, Log.VERBOSE)) {
Log.v(FullBackup.TAG_XML_PARSER,
@@ -404,6 +417,10 @@
}
return;
}
+ Map<String, Set<PathWithRequiredFlags>> manifestIncludeMap
+ = includeExcludeRules.getIncludeMap();
+ Set<PathWithRequiredFlags> manifestExcludeSet
+ = includeExcludeRules.getExcludeSet();
final String packageName = getPackageName();
final ApplicationInfo appInfo = getApplicationInfo();
@@ -413,24 +430,18 @@
final Context ceContext = createCredentialProtectedStorageContext();
final String rootDir = ceContext.getDataDir().getCanonicalPath();
final String filesDir = ceContext.getFilesDir().getCanonicalPath();
- final String noBackupDir = ceContext.getNoBackupFilesDir().getCanonicalPath();
final String databaseDir = ceContext.getDatabasePath("foo").getParentFile()
.getCanonicalPath();
final String sharedPrefsDir = ceContext.getSharedPreferencesPath("foo").getParentFile()
.getCanonicalPath();
- final String cacheDir = ceContext.getCacheDir().getCanonicalPath();
- final String codeCacheDir = ceContext.getCodeCacheDir().getCanonicalPath();
final Context deContext = createDeviceProtectedStorageContext();
final String deviceRootDir = deContext.getDataDir().getCanonicalPath();
final String deviceFilesDir = deContext.getFilesDir().getCanonicalPath();
- final String deviceNoBackupDir = deContext.getNoBackupFilesDir().getCanonicalPath();
final String deviceDatabaseDir = deContext.getDatabasePath("foo").getParentFile()
.getCanonicalPath();
final String deviceSharedPrefsDir = deContext.getSharedPreferencesPath("foo")
.getParentFile().getCanonicalPath();
- final String deviceCacheDir = deContext.getCacheDir().getCanonicalPath();
- final String deviceCodeCacheDir = deContext.getCodeCacheDir().getCanonicalPath();
final String libDir = (appInfo.nativeLibraryDir != null)
? new File(appInfo.nativeLibraryDir).getCanonicalPath()
@@ -443,33 +454,36 @@
// Add the directories we always exclude.
traversalExcludeSet.add(filesDir);
- traversalExcludeSet.add(noBackupDir);
traversalExcludeSet.add(databaseDir);
traversalExcludeSet.add(sharedPrefsDir);
- traversalExcludeSet.add(cacheDir);
- traversalExcludeSet.add(codeCacheDir);
traversalExcludeSet.add(deviceFilesDir);
- traversalExcludeSet.add(deviceNoBackupDir);
traversalExcludeSet.add(deviceDatabaseDir);
traversalExcludeSet.add(deviceSharedPrefsDir);
- traversalExcludeSet.add(deviceCacheDir);
- traversalExcludeSet.add(deviceCodeCacheDir);
if (libDir != null) {
traversalExcludeSet.add(libDir);
}
+ Set<String> extraExcludedDirs = getExtraExcludeDirsIfAny(ceContext);
+ Set<String> extraExcludedDeviceDirs = getExtraExcludeDirsIfAny(deContext);
+ traversalExcludeSet.addAll(extraExcludedDirs);
+ traversalExcludeSet.addAll(extraExcludedDeviceDirs);
+
// Root dir first.
applyXmlFiltersAndDoFullBackupForDomain(
packageName, FullBackup.ROOT_TREE_TOKEN, manifestIncludeMap,
manifestExcludeSet, traversalExcludeSet, data);
traversalExcludeSet.add(rootDir);
+ // Exclude the extra directories anyway, since we've already covered them if it was needed.
+ traversalExcludeSet.addAll(extraExcludedDirs);
applyXmlFiltersAndDoFullBackupForDomain(
packageName, FullBackup.DEVICE_ROOT_TREE_TOKEN, manifestIncludeMap,
manifestExcludeSet, traversalExcludeSet, data);
traversalExcludeSet.add(deviceRootDir);
+ // Exclude the extra directories anyway, since we've already covered them if it was needed.
+ traversalExcludeSet.addAll(extraExcludedDeviceDirs);
// Data dir next.
traversalExcludeSet.remove(filesDir);
@@ -528,6 +542,41 @@
}
}
+ private Set<String> getExtraExcludeDirsIfAny(Context context) throws IOException {
+ if (isDeviceToDeviceMigration()) {
+ return Collections.emptySet();
+ }
+
+ // If this is not a migration, also exclude no-backup and cache dirs.
+ Set<String> excludedDirs = new HashSet<>();
+ excludedDirs.add(context.getCacheDir().getCanonicalPath());
+ excludedDirs.add(context.getCodeCacheDir().getCanonicalPath());
+ excludedDirs.add(context.getNoBackupFilesDir().getCanonicalPath());
+ return Collections.unmodifiableSet(excludedDirs);
+ }
+
+ private boolean isDeviceToDeviceMigration() {
+ return mOperationType == OperationType.MIGRATION;
+ }
+
+ /** @hide */
+ @VisibleForTesting
+ public IncludeExcludeRules getIncludeExcludeRules(FullBackup.BackupScheme backupScheme)
+ throws IOException, XmlPullParserException {
+ if (isDeviceToDeviceMigration()) {
+ return IncludeExcludeRules.emptyRules();
+ }
+
+ Map<String, Set<PathWithRequiredFlags>> manifestIncludeMap;
+ ArraySet<PathWithRequiredFlags> manifestExcludeSet;
+
+ manifestIncludeMap =
+ backupScheme.maybeParseAndGetCanonicalIncludePaths();
+ manifestExcludeSet = backupScheme.maybeParseAndGetCanonicalExcludePaths();
+
+ return new IncludeExcludeRules(manifestIncludeMap, manifestExcludeSet);
+ }
+
/**
* Notification that the application's current backup operation causes it to exceed
* the maximum size permitted by the transport. The ongoing backup operation is
@@ -570,7 +619,7 @@
*/
private void applyXmlFiltersAndDoFullBackupForDomain(String packageName, String domainToken,
Map<String, Set<PathWithRequiredFlags>> includeMap,
- ArraySet<PathWithRequiredFlags> filterSet, ArraySet<String> traversalExcludeSet,
+ Set<PathWithRequiredFlags> filterSet, ArraySet<String> traversalExcludeSet,
FullBackupDataOutput data) throws IOException {
if (includeMap == null || includeMap.size() == 0) {
// Do entire sub-tree for the provided token.
@@ -742,7 +791,7 @@
* @hide
*/
protected final void fullBackupFileTree(String packageName, String domain, String startingPath,
- ArraySet<PathWithRequiredFlags> manifestExcludes,
+ Set<PathWithRequiredFlags> manifestExcludes,
ArraySet<String> systemExcludes,
FullBackupDataOutput output) {
// Pull out the domain and set it aside to use when making the tarball.
@@ -811,7 +860,7 @@
}
private boolean manifestExcludesContainFilePath(
- ArraySet<PathWithRequiredFlags> manifestExcludes, String filePath) {
+ Set<PathWithRequiredFlags> manifestExcludes, String filePath) {
for (PathWithRequiredFlags exclude : manifestExcludes) {
String excludePath = exclude.getPath();
if (excludePath != null && excludePath.equals(filePath)) {
@@ -857,6 +906,11 @@
}
private boolean isFileEligibleForRestore(File destination) throws IOException {
+ if (isDeviceToDeviceMigration()) {
+ // Everything is eligible for device-to-device migration.
+ return true;
+ }
+
FullBackup.BackupScheme bs = FullBackup.getBackupScheme(this);
if (!bs.isFullBackupContentEnabled()) {
if (Log.isLoggable(FullBackup.TAG_XML_PARSER, Log.VERBOSE)) {
@@ -1265,4 +1319,53 @@
throw new IllegalStateException(mMessage);
}
}
+
+ /** @hide */
+ @VisibleForTesting
+ public static class IncludeExcludeRules {
+ private final Map<String, Set<PathWithRequiredFlags>> mManifestIncludeMap;
+ private final Set<PathWithRequiredFlags> mManifestExcludeSet;
+
+ /** @hide */
+ public IncludeExcludeRules(
+ Map<String, Set<PathWithRequiredFlags>> manifestIncludeMap,
+ Set<PathWithRequiredFlags> manifestExcludeSet) {
+ mManifestIncludeMap = manifestIncludeMap;
+ mManifestExcludeSet = manifestExcludeSet;
+ }
+
+ /** @hide */
+ @VisibleForTesting
+ public static IncludeExcludeRules emptyRules() {
+ return new IncludeExcludeRules(Collections.emptyMap(), new ArraySet<>());
+ }
+
+ private Map<String, Set<PathWithRequiredFlags>> getIncludeMap() {
+ return mManifestIncludeMap;
+ }
+
+ private Set<PathWithRequiredFlags> getExcludeSet() {
+ return mManifestExcludeSet;
+ }
+
+ /** @hide */
+ @Override
+ public int hashCode() {
+ return Objects.hash(mManifestIncludeMap, mManifestExcludeSet);
+ }
+
+ /** @hide */
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object == null || getClass() != object.getClass()) {
+ return false;
+ }
+ IncludeExcludeRules that = (IncludeExcludeRules) object;
+ return Objects.equals(mManifestIncludeMap, that.mManifestIncludeMap) &&
+ Objects.equals(mManifestExcludeSet, that.mManifestExcludeSet);
+ }
+ }
}
diff --git a/core/java/android/app/timezonedetector/TimeZoneCapabilities.java b/core/java/android/app/timezonedetector/TimeZoneCapabilities.java
index 236b006..cc0af3f 100644
--- a/core/java/android/app/timezonedetector/TimeZoneCapabilities.java
+++ b/core/java/android/app/timezonedetector/TimeZoneCapabilities.java
@@ -91,11 +91,13 @@
private final @UserIdInt int mUserId;
private final @CapabilityState int mConfigureAutoDetectionEnabled;
+ private final @CapabilityState int mConfigureGeoDetectionEnabled;
private final @CapabilityState int mSuggestManualTimeZone;
private TimeZoneCapabilities(@NonNull Builder builder) {
this.mUserId = builder.mUserId;
this.mConfigureAutoDetectionEnabled = builder.mConfigureAutoDetectionEnabled;
+ this.mConfigureGeoDetectionEnabled = builder.mConfigureGeoDetectionEnabled;
this.mSuggestManualTimeZone = builder.mSuggestManualTimeZone;
}
@@ -103,6 +105,7 @@
private static TimeZoneCapabilities createFromParcel(Parcel in) {
return new TimeZoneCapabilities.Builder(in.readInt())
.setConfigureAutoDetectionEnabled(in.readInt())
+ .setConfigureGeoDetectionEnabled(in.readInt())
.setSuggestManualTimeZone(in.readInt())
.build();
}
@@ -111,6 +114,7 @@
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(mUserId);
dest.writeInt(mConfigureAutoDetectionEnabled);
+ dest.writeInt(mConfigureGeoDetectionEnabled);
dest.writeInt(mSuggestManualTimeZone);
}
@@ -120,8 +124,8 @@
}
/**
- * Returns the user's capability state for controlling automatic time zone detection via
- * {@link TimeZoneDetector#updateConfiguration(TimeZoneConfiguration)} and {@link
+ * Returns the user's capability state for controlling whether automatic time zone detection is
+ * enabled via {@link TimeZoneDetector#updateConfiguration(TimeZoneConfiguration)} and {@link
* TimeZoneConfiguration#isAutoDetectionEnabled()}.
*/
@CapabilityState
@@ -130,6 +134,16 @@
}
/**
+ * Returns the user's capability state for controlling whether geolocation can be used to detect
+ * time zone via {@link TimeZoneDetector#updateConfiguration(TimeZoneConfiguration)} and {@link
+ * TimeZoneConfiguration#isGeoDetectionEnabled()}.
+ */
+ @CapabilityState
+ public int getConfigureGeoDetectionEnabled() {
+ return mConfigureGeoDetectionEnabled;
+ }
+
+ /**
* Returns the user's capability state for manually setting the time zone on a device via
* {@link TimeZoneDetector#suggestManualTimeZone(ManualTimeZoneSuggestion)}.
*
@@ -157,12 +171,16 @@
TimeZoneCapabilities that = (TimeZoneCapabilities) o;
return mUserId == that.mUserId
&& mConfigureAutoDetectionEnabled == that.mConfigureAutoDetectionEnabled
+ && mConfigureGeoDetectionEnabled == that.mConfigureGeoDetectionEnabled
&& mSuggestManualTimeZone == that.mSuggestManualTimeZone;
}
@Override
public int hashCode() {
- return Objects.hash(mUserId, mConfigureAutoDetectionEnabled, mSuggestManualTimeZone);
+ return Objects.hash(mUserId,
+ mConfigureAutoDetectionEnabled,
+ mConfigureGeoDetectionEnabled,
+ mSuggestManualTimeZone);
}
@Override
@@ -170,6 +188,7 @@
return "TimeZoneDetectorCapabilities{"
+ "mUserId=" + mUserId
+ ", mConfigureAutomaticDetectionEnabled=" + mConfigureAutoDetectionEnabled
+ + ", mConfigureGeoDetectionEnabled=" + mConfigureGeoDetectionEnabled
+ ", mSuggestManualTimeZone=" + mSuggestManualTimeZone
+ '}';
}
@@ -179,6 +198,7 @@
private final @UserIdInt int mUserId;
private @CapabilityState int mConfigureAutoDetectionEnabled;
+ private @CapabilityState int mConfigureGeoDetectionEnabled;
private @CapabilityState int mSuggestManualTimeZone;
/**
@@ -194,6 +214,12 @@
return this;
}
+ /** Sets the state for the geolocation time zone detection enabled config. */
+ public Builder setConfigureGeoDetectionEnabled(@CapabilityState int value) {
+ this.mConfigureGeoDetectionEnabled = value;
+ return this;
+ }
+
/** Sets the state for the suggestManualTimeZone action. */
public Builder setSuggestManualTimeZone(@CapabilityState int value) {
this.mSuggestManualTimeZone = value;
@@ -204,6 +230,7 @@
@NonNull
public TimeZoneCapabilities build() {
verifyCapabilitySet(mConfigureAutoDetectionEnabled, "configureAutoDetectionEnabled");
+ verifyCapabilitySet(mConfigureGeoDetectionEnabled, "configureGeoDetectionEnabled");
verifyCapabilitySet(mSuggestManualTimeZone, "suggestManualTimeZone");
return new TimeZoneCapabilities(this);
}
diff --git a/core/java/android/app/timezonedetector/TimeZoneConfiguration.java b/core/java/android/app/timezonedetector/TimeZoneConfiguration.java
index 047d349..6f84ee2 100644
--- a/core/java/android/app/timezonedetector/TimeZoneConfiguration.java
+++ b/core/java/android/app/timezonedetector/TimeZoneConfiguration.java
@@ -67,6 +67,10 @@
@Property
public static final String PROPERTY_AUTO_DETECTION_ENABLED = "autoDetectionEnabled";
+ /** See {@link TimeZoneConfiguration#isGeoDetectionEnabled()} for details. */
+ @Property
+ public static final String PROPERTY_GEO_DETECTION_ENABLED = "geoDetectionEnabled";
+
private final Bundle mBundle;
private TimeZoneConfiguration(Builder builder) {
@@ -86,7 +90,8 @@
/** Returns {@code true} if all known properties are set. */
public boolean isComplete() {
- return hasProperty(PROPERTY_AUTO_DETECTION_ENABLED);
+ return hasProperty(PROPERTY_AUTO_DETECTION_ENABLED)
+ && hasProperty(PROPERTY_GEO_DETECTION_ENABLED);
}
/** Returns true if the specified property is set. */
@@ -108,6 +113,28 @@
return mBundle.getBoolean(PROPERTY_AUTO_DETECTION_ENABLED);
}
+ /**
+ * Returns the value of the {@link #PROPERTY_GEO_DETECTION_ENABLED} property. This
+ * controls whether a device can use location to determine time zone. Only used when
+ * {@link #isAutoDetectionEnabled()} is true.
+ *
+ * @throws IllegalStateException if the field has not been set
+ */
+ public boolean isGeoDetectionEnabled() {
+ if (!mBundle.containsKey(PROPERTY_GEO_DETECTION_ENABLED)) {
+ throw new IllegalStateException(PROPERTY_GEO_DETECTION_ENABLED + " is not set");
+ }
+ return mBundle.getBoolean(PROPERTY_GEO_DETECTION_ENABLED);
+ }
+
+ /**
+ * Convenience method to merge this with another. The argument configuration properties have
+ * precedence.
+ */
+ public TimeZoneConfiguration with(TimeZoneConfiguration other) {
+ return new Builder(this).mergeProperties(other).build();
+ }
+
@Override
public int describeContents() {
return 0;
@@ -174,6 +201,12 @@
return this;
}
+ /** Sets the desired state of the geolocation time zone detection enabled property. */
+ public Builder setGeoDetectionEnabled(boolean enabled) {
+ this.mBundle.putBoolean(PROPERTY_GEO_DETECTION_ENABLED, enabled);
+ return this;
+ }
+
/** Returns the {@link TimeZoneConfiguration}. */
@NonNull
public TimeZoneConfiguration build() {
diff --git a/core/java/android/app/usage/UsageEvents.java b/core/java/android/app/usage/UsageEvents.java
index 3522b1b..0e6a063 100644
--- a/core/java/android/app/usage/UsageEvents.java
+++ b/core/java/android/app/usage/UsageEvents.java
@@ -199,7 +199,7 @@
public static final int NOTIFICATION_INTERRUPTION = 12;
/**
- * A Slice was pinned by the default launcher or the default assistant.
+ * A Slice was pinned by the default assistant.
* @hide
*/
@SystemApi
diff --git a/core/java/android/content/LocusId.java b/core/java/android/content/LocusId.java
index 283cea0..98e71f0 100644
--- a/core/java/android/content/LocusId.java
+++ b/core/java/android/content/LocusId.java
@@ -33,7 +33,7 @@
* by the Android System to correlate state between different subsystems such as content capture,
* shortcuts, and notifications.
*
- * <p>For example, if your app provides an activiy representing a chat between 2 users
+ * <p>For example, if your app provides an activity representing a chat between 2 users
* (say {@code A} and {@code B}, this chat state could be represented by:
*
* <pre><code>
diff --git a/core/java/android/content/res/XmlBlock.java b/core/java/android/content/res/XmlBlock.java
index cb93cbf..fcbe362 100644
--- a/core/java/android/content/res/XmlBlock.java
+++ b/core/java/android/content/res/XmlBlock.java
@@ -23,6 +23,7 @@
import android.compat.annotation.UnsupportedAppUsage;
import android.util.TypedValue;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.XmlUtils;
import dalvik.annotation.optimization.FastNative;
@@ -38,7 +39,8 @@
*
* {@hide}
*/
-final class XmlBlock implements AutoCloseable {
+@VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
+public final class XmlBlock implements AutoCloseable {
private static final boolean DEBUG=false;
@UnsupportedAppUsage
@@ -88,7 +90,8 @@
}
}
- /*package*/ final class Parser implements XmlResourceParser {
+ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
+ public final class Parser implements XmlResourceParser {
Parser(long parseState, XmlBlock block) {
mParseState = parseState;
mBlock = block;
diff --git a/core/java/android/hardware/display/DisplayManagerInternal.java b/core/java/android/hardware/display/DisplayManagerInternal.java
index 7ac8d05..c7f8915 100644
--- a/core/java/android/hardware/display/DisplayManagerInternal.java
+++ b/core/java/android/hardware/display/DisplayManagerInternal.java
@@ -260,6 +260,13 @@
int displayId, long maxFrames, long timestamp);
/**
+ * Temporarily ignore proximity-sensor-based display behavior until there is a change
+ * to the proximity sensor state. This allows the display to turn back on even if something
+ * is obstructing the proximity sensor.
+ */
+ public abstract void ignoreProximitySensorUntilChanged();
+
+ /**
* Describes the requested power state of the display.
*
* This object is intended to describe the general characteristics of the
diff --git a/core/java/android/hardware/face/FaceManager.java b/core/java/android/hardware/face/FaceManager.java
index 885d137..19cb13c 100644
--- a/core/java/android/hardware/face/FaceManager.java
+++ b/core/java/android/hardware/face/FaceManager.java
@@ -1073,12 +1073,12 @@
/**
* @hide
*/
- public abstract static class GenerateChallengeCallback {
- public abstract void onGenerateChallengeResult(long challenge);
+ public interface GenerateChallengeCallback {
+ void onGenerateChallengeResult(long challenge);
}
private abstract static class InternalGenerateChallengeCallback
- extends GenerateChallengeCallback {}
+ implements GenerateChallengeCallback {}
private class OnEnrollCancelListener implements OnCancelListener {
@Override
diff --git a/core/java/android/hardware/fingerprint/FingerprintManager.java b/core/java/android/hardware/fingerprint/FingerprintManager.java
index e384da7..71598eb 100644
--- a/core/java/android/hardware/fingerprint/FingerprintManager.java
+++ b/core/java/android/hardware/fingerprint/FingerprintManager.java
@@ -377,12 +377,12 @@
/**
* @hide
*/
- public abstract static class GenerateChallengeCallback {
- public abstract void onChallengeGenerated(long challenge);
+ public interface GenerateChallengeCallback {
+ void onChallengeGenerated(long challenge);
}
private abstract static class InternalGenerateChallengeCallback
- extends GenerateChallengeCallback {}
+ implements GenerateChallengeCallback {}
/**
* Request authentication of a crypto object. This call warms up the fingerprint hardware
@@ -581,37 +581,6 @@
}
/**
- * Same as {@link #generateChallenge(GenerateChallengeCallback)}, except blocks until the
- * TEE/hardware operation is complete.
- * @return challenge generated in the TEE/hardware
- * @hide
- */
- @RequiresPermission(MANAGE_FINGERPRINT)
- public long generateChallengeBlocking() {
- final AtomicReference<Long> result = new AtomicReference<>();
- final CountDownLatch latch = new CountDownLatch(1);
- final GenerateChallengeCallback callback = new InternalGenerateChallengeCallback() {
- @Override
- public void onChallengeGenerated(long challenge) {
- result.set(challenge);
- latch.countDown();
- }
- };
-
- generateChallenge(callback);
-
- try {
- latch.await(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- Slog.e(TAG, "Interrupted while generatingChallenge", e);
- e.printStackTrace();
- }
-
- return result.get();
- }
-
-
- /**
* Generates a unique random challenge in the TEE. A typical use case is to have it wrapped in a
* HardwareAuthenticationToken, minted by Gatekeeper upon PIN/Pattern/Password verification.
* The HardwareAuthenticationToken can then be sent to the biometric HAL together with a
diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl
index 0cce192..8f8d451 100644
--- a/core/java/android/os/INetworkManagementService.aidl
+++ b/core/java/android/os/INetworkManagementService.aidl
@@ -287,8 +287,8 @@
/**
* Control network activity of a UID over interfaces with a quota limit.
*/
- void setUidMeteredNetworkBlacklist(int uid, boolean enable);
- void setUidMeteredNetworkWhitelist(int uid, boolean enable);
+ void setUidMeteredNetworkDenylist(int uid, boolean enable);
+ void setUidMeteredNetworkAllowlist(int uid, boolean enable);
boolean setDataSaverModeEnabled(boolean enable);
void setUidCleartextNetworkPolicy(int uid, int policy);
diff --git a/core/java/android/os/Parcelable.java b/core/java/android/os/Parcelable.java
index 3d3759e..f14f66b 100644
--- a/core/java/android/os/Parcelable.java
+++ b/core/java/android/os/Parcelable.java
@@ -161,6 +161,7 @@
* @return true if this parcelable is stable.
* @hide
*/
+ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
default @Stability int getStability() {
return PARCELABLE_STABILITY_LOCAL;
}
diff --git a/core/java/android/os/PowerManagerInternal.java b/core/java/android/os/PowerManagerInternal.java
index e30a409..eb18b96 100644
--- a/core/java/android/os/PowerManagerInternal.java
+++ b/core/java/android/os/PowerManagerInternal.java
@@ -17,6 +17,7 @@
package android.os;
import android.view.Display;
+import android.view.KeyEvent;
import java.util.function.Consumer;
@@ -313,4 +314,7 @@
/** Returns information about the last wakeup event. */
public abstract PowerManager.WakeData getLastWakeup();
+
+ /** Allows power button to intercept a power key button press. */
+ public abstract boolean interceptPowerKeyDown(KeyEvent event);
}
diff --git a/core/java/android/os/SystemClock.java b/core/java/android/os/SystemClock.java
index fd68c2b..26f3af0 100644
--- a/core/java/android/os/SystemClock.java
+++ b/core/java/android/os/SystemClock.java
@@ -178,6 +178,15 @@
native public static long uptimeMillis();
/**
+ * Returns nanoseconds since boot, not counting time spent in deep sleep.
+ *
+ * @return nanoseconds of non-sleep uptime since boot.
+ * @hide
+ */
+ @CriticalNative
+ public static native long uptimeNanos();
+
+ /**
* Return {@link Clock} that starts at system boot, not counting time spent
* in deep sleep.
*
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index 2ce993d..6ef086b 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -22,8 +22,6 @@
import static android.graphics.Matrix.MSKEW_Y;
import static android.graphics.Matrix.MTRANS_X;
import static android.graphics.Matrix.MTRANS_Y;
-import static android.view.Surface.ROTATION_270;
-import static android.view.Surface.ROTATION_90;
import static android.view.SurfaceControlProto.HASH_CODE;
import static android.view.SurfaceControlProto.NAME;
@@ -590,6 +588,26 @@
public boolean containsSecureLayers() {
return mContainsSecureLayers;
}
+
+ /**
+ * Copy content of ScreenshotHardwareBuffer into a hardware bitmap and return it.
+ * Note: If you want to modify the Bitmap in software, you will need to copy the Bitmap
+ * into
+ * a software Bitmap using {@link Bitmap#copy(Bitmap.Config, boolean)}
+ *
+ * CAVEAT: This can be extremely slow; avoid use unless absolutely necessary; prefer to
+ * directly
+ * use the {@link HardwareBuffer} directly.
+ *
+ * @return Bitmap generated from the {@link HardwareBuffer}
+ */
+ public Bitmap asBitmap() {
+ if (mHardwareBuffer == null) {
+ Log.w(TAG, "Failed to take screenshot. Null screenshot object");
+ return null;
+ }
+ return Bitmap.wrapHardwareBuffer(mHardwareBuffer, mColorSpace);
+ }
}
/**
@@ -597,7 +615,7 @@
* are shared between {@link DisplayCaptureArgs} and {@link LayerCaptureArgs}
* @hide
*/
- public abstract static class CaptureArgs {
+ private abstract static class CaptureArgs {
private final int mPixelFormat;
private final Rect mSourceCrop = new Rect();
private final float mFrameScale;
@@ -615,7 +633,7 @@
*
* @param <T> A builder that extends {@link Builder}
*/
- public abstract static class Builder<T extends Builder<T>> {
+ abstract static class Builder<T extends Builder<T>> {
private int mPixelFormat = PixelFormat.RGBA_8888;
private final Rect mSourceCrop = new Rect();
private float mFrameScale = 1;
@@ -675,7 +693,6 @@
private final int mWidth;
private final int mHeight;
private final boolean mUseIdentityTransform;
- private final int mRotation;
private DisplayCaptureArgs(Builder builder) {
super(builder);
@@ -683,7 +700,6 @@
mWidth = builder.mWidth;
mHeight = builder.mHeight;
mUseIdentityTransform = builder.mUseIdentityTransform;
- mRotation = builder.mRotation;
}
/**
@@ -694,7 +710,6 @@
private int mWidth;
private int mHeight;
private boolean mUseIdentityTransform;
- private @Surface.Rotation int mRotation = Surface.ROTATION_0;
/**
* Construct a new {@link LayerCaptureArgs} with the set parameters. The builder
@@ -736,26 +751,16 @@
}
/**
- * Replace whatever transformation (rotation, scaling, translation) the surface
- * layers are currently using with the identity transformation while taking the
- * screenshot.
+ * Replace the rotation transform of the display with the identity transformation while
+ * taking the screenshot. This ensures the screenshot is taken in the ROTATION_0
+ * orientation. Set this value to false if the screenshot should be taken in the
+ * current screen orientation.
*/
public Builder setUseIdentityTransform(boolean useIdentityTransform) {
mUseIdentityTransform = useIdentityTransform;
return this;
}
- /**
- * Apply a custom clockwise rotation to the screenshot, i.e.
- * Surface.ROTATION_0,90,180,270. SurfaceFlinger will always take screenshots in its
- * native portrait orientation by default, so this is useful for returning screenshots
- * that are independent of device orientation.
- */
- public Builder setRotation(@Surface.Rotation int rotation) {
- mRotation = rotation;
- return this;
- }
-
@Override
Builder getThis() {
return this;
@@ -2221,130 +2226,16 @@
}
/**
- * @see SurfaceControl#screenshot(Rect, int, int, boolean, int)}
+ * Captures all the surfaces in a display and returns a {@link ScreenshotHardwareBuffer} with
+ * the content.
+ *
* @hide
*/
- @UnsupportedAppUsage
- public static Bitmap screenshot(Rect sourceCrop, int width, int height, int rotation) {
- return screenshot(sourceCrop, width, height, false, rotation);
- }
-
- /**
- * Copy the current screen contents into a hardware bitmap and return it.
- * Note: If you want to modify the Bitmap in software, you will need to copy the Bitmap into
- * a software Bitmap using {@link Bitmap#copy(Bitmap.Config, boolean)}
- *
- * CAVEAT: Versions of screenshot that return a {@link Bitmap} can be extremely slow; avoid use
- * unless absolutely necessary; prefer the versions that use a {@link HardwareBuffer} such as
- * {@link SurfaceControl#screenshotToBuffer(IBinder, Rect, int, int, boolean, int)}.
- *
- * @see SurfaceControl#screenshotToBuffer(IBinder, Rect, int, int, boolean, int)}
- * @hide
- */
- @UnsupportedAppUsage
- public static Bitmap screenshot(Rect sourceCrop, int width, int height,
- boolean useIdentityTransform, int rotation) {
- // TODO: should take the display as a parameter
- final IBinder displayToken = SurfaceControl.getInternalDisplayToken();
- if (displayToken == null) {
- Log.w(TAG, "Failed to take screenshot because internal display is disconnected");
- return null;
- }
-
- if (rotation == ROTATION_90 || rotation == ROTATION_270) {
- rotation = (rotation == ROTATION_90) ? ROTATION_270 : ROTATION_90;
- }
-
- SurfaceControl.rotateCropForSF(sourceCrop, rotation);
- final ScreenshotHardwareBuffer buffer = screenshotToBuffer(displayToken, sourceCrop, width,
- height, useIdentityTransform, rotation);
-
- if (buffer == null) {
- Log.w(TAG, "Failed to take screenshot");
- return null;
- }
- return Bitmap.wrapHardwareBuffer(buffer.getHardwareBuffer(), buffer.getColorSpace());
- }
-
- /**
- * Captures all the surfaces in a display and returns a {@link HardwareBuffer} with the content.
- *
- * @param display The display to take the screenshot of.
- * @param sourceCrop The portion of the screen to capture into the Bitmap; caller may
- * pass in 'new Rect()' if no cropping is desired.
- * @param width The desired width of the returned bitmap; the raw screen will be
- * scaled down to this size; caller may pass in 0 if no scaling is
- * desired.
- * @param height The desired height of the returned bitmap; the raw screen will
- * be scaled down to this size; caller may pass in 0 if no scaling
- * is desired.
- * @param useIdentityTransform Replace whatever transformation (rotation, scaling, translation)
- * the surface layers are currently using with the identity
- * transformation while taking the screenshot.
- * @param rotation Apply a custom clockwise rotation to the screenshot, i.e.
- * Surface.ROTATION_0,90,180,270. SurfaceFlinger will always take
- * screenshots in its native portrait orientation by default, so
- * this is useful for returning screenshots that are independent of
- * device orientation.
- * @return Returns a HardwareBuffer that contains the captured content.
- * @hide
- */
- public static ScreenshotHardwareBuffer screenshotToBuffer(IBinder display, Rect sourceCrop,
- int width, int height, boolean useIdentityTransform, int rotation) {
- if (display == null) {
- throw new IllegalArgumentException("displayToken must not be null");
- }
-
- DisplayCaptureArgs captureArgs = new DisplayCaptureArgs.Builder(display)
- .setSourceCrop(sourceCrop)
- .setSize(width, height)
- .setUseIdentityTransform(useIdentityTransform)
- .setRotation(rotation)
- .build();
-
+ public static ScreenshotHardwareBuffer captureDisplay(DisplayCaptureArgs captureArgs) {
return nativeCaptureDisplay(captureArgs);
}
/**
- * Like screenshotToBuffer, but if the caller is AID_SYSTEM, allows
- * for the capture of secure layers. This is used for the screen rotation
- * animation where the system server takes screenshots but does
- * not persist them or allow them to leave the server. However in other
- * cases in the system server, we mostly want to omit secure layers
- * like when we take a screenshot on behalf of the assistant.
- *
- * @hide
- */
- public static ScreenshotHardwareBuffer screenshotToBufferWithSecureLayersUnsafe(IBinder display,
- Rect sourceCrop, int width, int height, boolean useIdentityTransform,
- int rotation) {
- if (display == null) {
- throw new IllegalArgumentException("displayToken must not be null");
- }
-
- DisplayCaptureArgs captureArgs = new DisplayCaptureArgs.Builder(display)
- .setSourceCrop(sourceCrop)
- .setSize(width, height)
- .setUseIdentityTransform(useIdentityTransform)
- .setRotation(rotation)
- .setCaptureSecureLayers(true)
- .build();
-
- return nativeCaptureDisplay(captureArgs);
- }
-
- private static void rotateCropForSF(Rect crop, int rot) {
- if (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270) {
- int tmp = crop.top;
- crop.top = crop.left;
- crop.left = tmp;
- tmp = crop.right;
- crop.right = crop.bottom;
- crop.bottom = tmp;
- }
- }
-
- /**
* Captures a layer and its children and returns a {@link HardwareBuffer} with the content.
*
* @param layer The root layer to capture.
diff --git a/core/java/android/view/accessibility/IWindowMagnificationConnection.aidl b/core/java/android/view/accessibility/IWindowMagnificationConnection.aidl
index e814ec6..eb67191 100644
--- a/core/java/android/view/accessibility/IWindowMagnificationConnection.aidl
+++ b/core/java/android/view/accessibility/IWindowMagnificationConnection.aidl
@@ -29,7 +29,7 @@
oneway interface IWindowMagnificationConnection {
/**
- * Enables window magnification on specifed display with specified center and scale.
+ * Enables window magnification on specified display with given center and scale and animation.
*
* @param displayId The logical display id.
* @param scale magnification scale.
@@ -41,7 +41,7 @@
void enableWindowMagnification(int displayId, float scale, float centerX, float centerY);
/**
- * Sets the scale of the window magnifier on specifed display.
+ * Sets the scale of the window magnifier on specified display.
*
* @param displayId The logical display id.
* @param scale magnification scale.
@@ -49,14 +49,14 @@
void setScale(int displayId, float scale);
/**
- * Disables window magnification on specifed display.
+ * Disables window magnification on specified display with animation.
*
* @param displayId The logical display id.
*/
void disableWindowMagnification(int displayId);
/**
- * Moves the window magnifier on the specifed display.
+ * Moves the window magnifier on the specified display. It has no effect while animating.
*
* @param offsetX the amount in pixels to offset the window magnifier in the X direction, in
* current screen pixels.
diff --git a/core/java/android/view/textclassifier/TextClassificationSession.java b/core/java/android/view/textclassifier/TextClassificationSession.java
index fed3dbf..0008658 100644
--- a/core/java/android/view/textclassifier/TextClassificationSession.java
+++ b/core/java/android/view/textclassifier/TextClassificationSession.java
@@ -20,9 +20,11 @@
import android.annotation.WorkerThread;
import android.view.textclassifier.SelectionEvent.InvocationMethod;
+import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.Preconditions;
import java.util.Objects;
+import java.util.function.Supplier;
import sun.misc.Cleaner;
@@ -40,6 +42,9 @@
private final TextClassificationContext mClassificationContext;
private final Cleaner mCleaner;
+ private final Object mLock = new Object();
+
+ @GuardedBy("mLock")
private boolean mDestroyed;
TextClassificationSession(TextClassificationContext context, TextClassifier delegate) {
@@ -54,8 +59,7 @@
@Override
public TextSelection suggestSelection(TextSelection.Request request) {
- checkDestroyed();
- return mDelegate.suggestSelection(request);
+ return checkDestroyedAndRun(() -> mDelegate.suggestSelection(request));
}
private void initializeRemoteSession() {
@@ -67,77 +71,97 @@
@Override
public TextClassification classifyText(TextClassification.Request request) {
- checkDestroyed();
- return mDelegate.classifyText(request);
+ return checkDestroyedAndRun(() -> mDelegate.classifyText(request));
}
@Override
public TextLinks generateLinks(TextLinks.Request request) {
- checkDestroyed();
- return mDelegate.generateLinks(request);
+ return checkDestroyedAndRun(() -> mDelegate.generateLinks(request));
}
@Override
public ConversationActions suggestConversationActions(ConversationActions.Request request) {
- checkDestroyed();
- return mDelegate.suggestConversationActions(request);
+ return checkDestroyedAndRun(() -> mDelegate.suggestConversationActions(request));
}
@Override
public TextLanguage detectLanguage(TextLanguage.Request request) {
- checkDestroyed();
- return mDelegate.detectLanguage(request);
+ return checkDestroyedAndRun(() -> mDelegate.detectLanguage(request));
}
@Override
public int getMaxGenerateLinksTextLength() {
- checkDestroyed();
- return mDelegate.getMaxGenerateLinksTextLength();
+ return checkDestroyedAndRun(mDelegate::getMaxGenerateLinksTextLength);
}
@Override
public void onSelectionEvent(SelectionEvent event) {
- try {
- if (mEventHelper.sanitizeEvent(event)) {
- mDelegate.onSelectionEvent(event);
+ checkDestroyedAndRun(() -> {
+ try {
+ if (mEventHelper.sanitizeEvent(event)) {
+ mDelegate.onSelectionEvent(event);
+ }
+ } catch (Exception e) {
+ // Avoid crashing for event reporting.
+ Log.e(LOG_TAG, "Error reporting text classifier selection event", e);
}
- } catch (Exception e) {
- // Avoid crashing for event reporting.
- Log.e(LOG_TAG, "Error reporting text classifier selection event", e);
- }
+ return null;
+ });
}
@Override
public void onTextClassifierEvent(TextClassifierEvent event) {
- try {
- event.mHiddenTempSessionId = mSessionId;
- mDelegate.onTextClassifierEvent(event);
- } catch (Exception e) {
- // Avoid crashing for event reporting.
- Log.e(LOG_TAG, "Error reporting text classifier event", e);
- }
+ checkDestroyedAndRun(() -> {
+ try {
+ event.mHiddenTempSessionId = mSessionId;
+ mDelegate.onTextClassifierEvent(event);
+ } catch (Exception e) {
+ // Avoid crashing for event reporting.
+ Log.e(LOG_TAG, "Error reporting text classifier event", e);
+ }
+ return null;
+ });
}
@Override
public void destroy() {
- mCleaner.clean();
- mDestroyed = true;
+ synchronized (mLock) {
+ if (!mDestroyed) {
+ mCleaner.clean();
+ mDestroyed = true;
+ }
+ }
}
@Override
public boolean isDestroyed() {
- return mDestroyed;
+ synchronized (mLock) {
+ return mDestroyed;
+ }
}
/**
- * @throws IllegalStateException if this TextClassification session has been destroyed.
+ * Check whether the TextClassification Session was destroyed before and after the actual API
+ * invocation, and return response if not.
+ *
+ * @param responseSupplier a Supplier that represents a TextClassifier call
+ * @return the response of the TextClassifier call
+ * @throws IllegalStateException if this TextClassification session was destroyed before the
+ * call returned
* @see #isDestroyed()
* @see #destroy()
*/
- private void checkDestroyed() {
- if (mDestroyed) {
- throw new IllegalStateException("This TextClassification session has been destroyed");
+ private <T> T checkDestroyedAndRun(Supplier<T> responseSupplier) {
+ if (!isDestroyed()) {
+ T response = responseSupplier.get();
+ synchronized (mLock) {
+ if (!mDestroyed) {
+ return response;
+ }
+ }
}
+ throw new IllegalStateException(
+ "This TextClassification session has been destroyed");
}
/**
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 7683067..60f8bb7 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -154,6 +154,10 @@
// Specifies whether to use the magnifier when pressing the insertion or selection handles.
private static final boolean FLAG_USE_MAGNIFIER = true;
+ // Specifies how far to make the cursor start float when drag the cursor away from the
+ // beginning or end of the line.
+ private static final int CURSOR_START_FLOAT_DISTANCE_PX = 20;
+
private static final int DELAY_BEFORE_HANDLE_FADES_OUT = 4000;
private static final int RECENT_CUT_COPY_DURATION_MS = 15 * 1000; // 15 seconds in millis
@@ -289,6 +293,9 @@
private boolean mRenderCursorRegardlessTiming;
private Blink mBlink;
+ // Whether to let magnifier draw cursor on its surface. This is for floating cursor effect.
+ // And it can only be true when |mNewMagnifierEnabled| is true.
+ private boolean mDrawCursorOnMagnifier;
boolean mCursorVisible = true;
boolean mSelectAllOnFocus;
boolean mTextIsSelectable;
@@ -890,7 +897,7 @@
}
boolean enabled = windowSupportsHandles && mTextView.getLayout() != null;
- mInsertionControllerEnabled = enabled && isCursorVisible();
+ mInsertionControllerEnabled = enabled && (mDrawCursorOnMagnifier || isCursorVisible());
mSelectionControllerEnabled = enabled && mTextView.textCanBeSelected();
if (!mInsertionControllerEnabled) {
@@ -5101,26 +5108,38 @@
final int[] textViewLocationOnScreen = new int[2];
mTextView.getLocationOnScreen(textViewLocationOnScreen);
final float touchXInView = event.getRawX() - textViewLocationOnScreen[0];
- float leftBound = mTextView.getTotalPaddingLeft() - mTextView.getScrollX();
- float rightBound = mTextView.getTotalPaddingLeft() - mTextView.getScrollX();
- if (sameLineSelection && ((trigger == MagnifierHandleTrigger.SELECTION_END) ^ rtl)) {
- leftBound += getHorizontal(mTextView.getLayout(), otherHandleOffset);
+ float leftBound, rightBound;
+ if (mNewMagnifierEnabled) {
+ leftBound = 0;
+ rightBound = mTextView.getWidth();
+ if (touchXInView < leftBound || touchXInView > rightBound) {
+ // The touch is too far from the current line / selection, so hide the magnifier.
+ return false;
+ }
} else {
- leftBound += mTextView.getLayout().getLineLeft(lineNumber);
- }
- if (sameLineSelection && ((trigger == MagnifierHandleTrigger.SELECTION_START) ^ rtl)) {
- rightBound += getHorizontal(mTextView.getLayout(), otherHandleOffset);
- } else {
- rightBound += mTextView.getLayout().getLineRight(lineNumber);
- }
- leftBound *= mTextViewScaleX;
- rightBound *= mTextViewScaleX;
- final float contentWidth = Math.round(mMagnifierAnimator.mMagnifier.getWidth()
- / mMagnifierAnimator.mMagnifier.getZoom());
- if (touchXInView < leftBound - contentWidth / 2
- || touchXInView > rightBound + contentWidth / 2) {
- // The touch is too far from the current line / selection, so hide the magnifier.
- return false;
+ leftBound = mTextView.getTotalPaddingLeft() - mTextView.getScrollX();
+ rightBound = mTextView.getTotalPaddingLeft() - mTextView.getScrollX();
+ if (sameLineSelection && ((trigger == MagnifierHandleTrigger.SELECTION_END)
+ ^ rtl)) {
+ leftBound += getHorizontal(mTextView.getLayout(), otherHandleOffset);
+ } else {
+ leftBound += mTextView.getLayout().getLineLeft(lineNumber);
+ }
+ if (sameLineSelection && ((trigger == MagnifierHandleTrigger.SELECTION_START)
+ ^ rtl)) {
+ rightBound += getHorizontal(mTextView.getLayout(), otherHandleOffset);
+ } else {
+ rightBound += mTextView.getLayout().getLineRight(lineNumber);
+ }
+ leftBound *= mTextViewScaleX;
+ rightBound *= mTextViewScaleX;
+ final float contentWidth = Math.round(mMagnifierAnimator.mMagnifier.getWidth()
+ / mMagnifierAnimator.mMagnifier.getZoom());
+ if (touchXInView < leftBound - contentWidth / 2
+ || touchXInView > rightBound + contentWidth / 2) {
+ // The touch is too far from the current line / selection, so hide the magnifier.
+ return false;
+ }
}
final float scaledTouchXInView;
@@ -5178,7 +5197,8 @@
final Rect magnifierRect = new Rect(magnifierTopLeft.x, magnifierTopLeft.y,
magnifierTopLeft.x + mMagnifierAnimator.mMagnifier.getWidth(),
magnifierTopLeft.y + mMagnifierAnimator.mMagnifier.getHeight());
- setVisible(!handleOverlapsMagnifier(HandleView.this, magnifierRect));
+ setVisible(!handleOverlapsMagnifier(HandleView.this, magnifierRect)
+ && !mDrawCursorOnMagnifier);
final HandleView otherHandle = getOtherSelectionHandle();
if (otherHandle != null) {
otherHandle.setVisible(!handleOverlapsMagnifier(otherHandle, magnifierRect));
@@ -5208,7 +5228,20 @@
lineLeft += mTextView.getTotalPaddingLeft() - mTextView.getScrollX();
int lineRight = (int) layout.getLineRight(line);
lineRight += mTextView.getTotalPaddingLeft() - mTextView.getScrollX();
- mMagnifierAnimator.mMagnifier.setSourceHorizontalBounds(lineLeft, lineRight);
+ mDrawCursorOnMagnifier =
+ showPosInView.x < lineLeft - CURSOR_START_FLOAT_DISTANCE_PX
+ || showPosInView.x > lineRight + CURSOR_START_FLOAT_DISTANCE_PX;
+ mMagnifierAnimator.mMagnifier.setDrawCursor(
+ mDrawCursorOnMagnifier, mDrawableForCursor);
+ boolean cursorVisible = mCursorVisible;
+ // Updates cursor visibility, so that the real cursor and the float cursor on
+ // magnifier surface won't appear at the same time.
+ mCursorVisible = !mDrawCursorOnMagnifier;
+ if (mCursorVisible && !cursorVisible) {
+ // When the real cursor is a drawable, hiding/showing it would change its
+ // bounds. So, call updateCursorPosition() to correct its position.
+ updateCursorPosition();
+ }
final int lineHeight =
layout.getLineBottomWithoutSpacing(line) - layout.getLineTop(line);
float zoom = mInitialZoom;
@@ -5230,6 +5263,11 @@
if (mMagnifierAnimator != null) {
mMagnifierAnimator.dismiss();
mRenderCursorRegardlessTiming = false;
+ mDrawCursorOnMagnifier = false;
+ if (!mCursorVisible) {
+ mCursorVisible = true;
+ mTextView.invalidate();
+ }
resumeBlink();
setVisible(true);
final HandleView otherHandle = getOtherSelectionHandle();
diff --git a/core/java/android/widget/Magnifier.java b/core/java/android/widget/Magnifier.java
index 89206fda..c72eed4 100644
--- a/core/java/android/widget/Magnifier.java
+++ b/core/java/android/widget/Magnifier.java
@@ -149,9 +149,6 @@
private int mLeftCutWidth = 0;
// The width of the cut region on the right edge of the pixel copy source rect.
private int mRightCutWidth = 0;
- // The horizontal bounds of the content source in pixels, relative to the view.
- private int mLeftBound = Integer.MIN_VALUE;
- private int mRightBound = Integer.MAX_VALUE;
// The width of the ramp region in pixels on the left & right sides of the fish-eye effect.
private final int mRamp;
@@ -244,18 +241,6 @@
}
/**
- * Sets the horizontal bounds of the source when showing the magnifier.
- * This is used for new style magnifier. e.g. limit the source bounds by the text line bounds.
- *
- * @param left the left of the bounds, relative to the view.
- * @param right the right of the bounds, relative to the view.
- */
- void setSourceHorizontalBounds(int left, int right) {
- mLeftBound = left;
- mRightBound = right;
- }
-
- /**
* Shows the magnifier on the screen. The method takes the coordinates of the center
* of the content source going to be magnified and copied to the magnifier. The coordinates
* are relative to the top left corner of the magnified view. The magnifier will be
@@ -280,6 +265,14 @@
sourceCenterY + mDefaultVerticalSourceToMagnifierOffset);
}
+ private Drawable mCursorDrawable;
+ private boolean mDrawCursorEnabled;
+
+ void setDrawCursor(boolean enabled, Drawable cursorDrawable) {
+ mDrawCursorEnabled = enabled;
+ mCursorDrawable = cursorDrawable;
+ }
+
/**
* Shows the magnifier on the screen at a position that is independent from its content
* position. The first two arguments represent the coordinates of the center of the
@@ -309,8 +302,7 @@
magnifierCenterX = mClampedCenterZoomCoords.x - mViewCoordinatesInSurface[0];
magnifierCenterY = mClampedCenterZoomCoords.y - mViewCoordinatesInSurface[1];
- // mLeftBound & mRightBound (typically the text line left/right) is for magnified
- // content. However the PixelCopy requires the pre-magnified bounds.
+ // PixelCopy requires the pre-magnified bounds.
// The below logic calculates the leftBound & rightBound for the pre-magnified bounds.
final float rampPre =
(mSourceWidth - (mSourceWidth - 2 * mRamp) / mZoom) / 2;
@@ -318,7 +310,7 @@
// Calculates the pre-zoomed left edge.
// The leftEdge moves from the left of view towards to sourceCenterX, considering the
// fisheye-like zooming.
- final float x0 = sourceCenterX - mSourceWidth / 2;
+ final float x0 = sourceCenterX - mSourceWidth / 2f;
final float rampX0 = x0 + mRamp;
float leftEdge = 0;
if (leftEdge > rampX0) {
@@ -330,12 +322,12 @@
// increase per ramp zoom (ramp / rampPre).
leftEdge = x0 + rampPre - (rampX0 - leftEdge) * rampPre / mRamp;
}
- int leftBound = Math.min(Math.max((int) leftEdge, mLeftBound), mRightBound);
+ int leftBound = Math.min((int) leftEdge, mView.getWidth());
// Calculates the pre-zoomed right edge.
// The rightEdge moves from the right of view towards to sourceCenterX, considering the
// fisheye-like zooming.
- final float x1 = sourceCenterX + mSourceWidth / 2;
+ final float x1 = sourceCenterX + mSourceWidth / 2f;
final float rampX1 = x1 - mRamp;
float rightEdge = mView.getWidth();
if (rightEdge < rampX1) {
@@ -347,7 +339,7 @@
// increase per ramp zoom (ramp / rampPre).
rightEdge = x1 - rampPre + (rightEdge - rampX1) * rampPre / mRamp;
}
- int rightBound = Math.max(leftBound, Math.min((int) rightEdge, mRightBound));
+ int rightBound = Math.max(leftBound, (int) rightEdge);
// Gets the startX for new style, which should be bounded by the horizontal bounds.
// Also calculates the left/right cut width for pixel copy.
@@ -772,6 +764,23 @@
}
}
+ private void maybeDrawCursor(Canvas canvas) {
+ if (mDrawCursorEnabled) {
+ if (mCursorDrawable != null) {
+ mCursorDrawable.setBounds(
+ mSourceWidth / 2, 0,
+ mSourceWidth / 2 + mCursorDrawable.getIntrinsicWidth(), mSourceHeight);
+ mCursorDrawable.draw(canvas);
+ } else {
+ Paint paint = new Paint();
+ paint.setColor(Color.BLACK); // The cursor on magnifier is by default in black.
+ canvas.drawRect(
+ new Rect(mSourceWidth / 2 - 1, 0, mSourceWidth / 2 + 1, mSourceHeight),
+ paint);
+ }
+ }
+ }
+
private void performPixelCopy(final int startXInSurface, final int startYInSurface,
final boolean updateWindowPosition) {
if (mContentCopySurface.mSurface == null || !mContentCopySurface.mSurface.isValid()) {
@@ -827,8 +836,10 @@
final Rect dstRect = new Rect(mLeftCutWidth, 0,
mSourceWidth - mRightCutWidth, bitmap.getHeight());
can.drawBitmap(bitmap, null, dstRect, null);
+ maybeDrawCursor(can);
mWindow.updateContent(newBitmap);
} else {
+ maybeDrawCursor(new Canvas(bitmap));
mWindow.updateContent(bitmap);
}
}
diff --git a/core/java/com/android/internal/BrightnessSynchronizer.java b/core/java/com/android/internal/BrightnessSynchronizer.java
index 42724be..f08d0ef8 100644
--- a/core/java/com/android/internal/BrightnessSynchronizer.java
+++ b/core/java/com/android/internal/BrightnessSynchronizer.java
@@ -83,63 +83,25 @@
/**
* Converts between the int brightness system and the float brightness system.
*/
- public static float brightnessIntToFloat(Context context, int brightnessInt) {
- final PowerManager pm = context.getSystemService(PowerManager.class);
- final float pmMinBrightness = pm.getBrightnessConstraint(
- PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_MINIMUM);
- final float pmMaxBrightness = pm.getBrightnessConstraint(
- PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_MAXIMUM);
- final int minBrightnessInt = Math.round(brightnessFloatToIntRange(pmMinBrightness,
- PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX,
- PowerManager.BRIGHTNESS_OFF + 1, PowerManager.BRIGHTNESS_ON));
- final int maxBrightnessInt = Math.round(brightnessFloatToIntRange(pmMaxBrightness,
- PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX,
- PowerManager.BRIGHTNESS_OFF + 1, PowerManager.BRIGHTNESS_ON));
-
- return brightnessIntToFloat(brightnessInt, minBrightnessInt, maxBrightnessInt,
- pmMinBrightness, pmMaxBrightness);
- }
-
- /**
- * Converts between the int brightness system and the float brightness system.
- */
- public static float brightnessIntToFloat(int brightnessInt, int minInt, int maxInt,
- float minFloat, float maxFloat) {
+ public static float brightnessIntToFloat(int brightnessInt) {
if (brightnessInt == PowerManager.BRIGHTNESS_OFF) {
return PowerManager.BRIGHTNESS_OFF_FLOAT;
} else if (brightnessInt == PowerManager.BRIGHTNESS_INVALID) {
return PowerManager.BRIGHTNESS_INVALID_FLOAT;
} else {
- return MathUtils.constrainedMap(minFloat, maxFloat, (float) minInt, (float) maxInt,
- brightnessInt);
+ final float minFloat = PowerManager.BRIGHTNESS_MIN;
+ final float maxFloat = PowerManager.BRIGHTNESS_MAX;
+ final float minInt = PowerManager.BRIGHTNESS_OFF + 1;
+ final float maxInt = PowerManager.BRIGHTNESS_ON;
+ return MathUtils.constrainedMap(minFloat, maxFloat, minInt, maxInt, brightnessInt);
}
}
/**
* Converts between the float brightness system and the int brightness system.
*/
- public static int brightnessFloatToInt(Context context, float brightnessFloat) {
- return Math.round(brightnessFloatToIntRange(context, brightnessFloat));
- }
-
- /**
- * Converts between the float brightness system and the int brightness system, but returns
- * the converted value as a float within the int-system's range. This method helps with
- * conversions from one system to the other without losing the floating-point precision.
- */
- public static float brightnessFloatToIntRange(Context context, float brightnessFloat) {
- final PowerManager pm = context.getSystemService(PowerManager.class);
- final float minFloat = pm.getBrightnessConstraint(
- PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_MINIMUM);
- final float maxFloat = pm.getBrightnessConstraint(
- PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_MAXIMUM);
- final float minInt = brightnessFloatToIntRange(minFloat,
- PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX,
- PowerManager.BRIGHTNESS_OFF + 1, PowerManager.BRIGHTNESS_ON);
- final float maxInt = brightnessFloatToIntRange(maxFloat,
- PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX,
- PowerManager.BRIGHTNESS_OFF + 1, PowerManager.BRIGHTNESS_ON);
- return brightnessFloatToIntRange(brightnessFloat, minFloat, maxFloat, minInt, maxInt);
+ public static int brightnessFloatToInt(float brightnessFloat) {
+ return Math.round(brightnessFloatToIntRange(brightnessFloat));
}
/**
@@ -148,20 +110,24 @@
* Value returned as a float privimite (to preserve precision), but is a value within the
* int-system range.
*/
- private static float brightnessFloatToIntRange(float brightnessFloat, float minFloat,
- float maxFloat, float minInt, float maxInt) {
+ public static float brightnessFloatToIntRange(float brightnessFloat) {
if (floatEquals(brightnessFloat, PowerManager.BRIGHTNESS_OFF_FLOAT)) {
return PowerManager.BRIGHTNESS_OFF;
} else if (Float.isNaN(brightnessFloat)) {
return PowerManager.BRIGHTNESS_INVALID;
} else {
+ final float minFloat = PowerManager.BRIGHTNESS_MIN;
+ final float maxFloat = PowerManager.BRIGHTNESS_MAX;
+ final float minInt = PowerManager.BRIGHTNESS_OFF + 1;
+ final float maxInt = PowerManager.BRIGHTNESS_ON;
return MathUtils.constrainedMap(minInt, maxInt, minFloat, maxFloat, brightnessFloat);
}
}
private static float getScreenBrightnessFloat(Context context) {
return Settings.System.getFloatForUser(context.getContentResolver(),
- Settings.System.SCREEN_BRIGHTNESS_FLOAT, Float.NaN, UserHandle.USER_CURRENT);
+ Settings.System.SCREEN_BRIGHTNESS_FLOAT, PowerManager.BRIGHTNESS_INVALID_FLOAT,
+ UserHandle.USER_CURRENT);
}
private static int getScreenBrightnessInt(Context context) {
@@ -185,10 +151,10 @@
if (topOfQueue != null && topOfQueue.equals(value)) {
mWriteHistory.poll();
} else {
- if (brightnessFloatToInt(mContext, mPreferredSettingValue) == value) {
+ if (brightnessFloatToInt(mPreferredSettingValue) == value) {
return;
}
- float newBrightnessFloat = brightnessIntToFloat(mContext, value);
+ float newBrightnessFloat = brightnessIntToFloat(value);
mWriteHistory.offer(newBrightnessFloat);
mPreferredSettingValue = newBrightnessFloat;
Settings.System.putFloatForUser(mContext.getContentResolver(),
@@ -207,7 +173,7 @@
* @param value Brightness setting as float to store in int setting.
*/
private void updateBrightnessIntFromFloat(float value) {
- int newBrightnessInt = brightnessFloatToInt(mContext, value);
+ int newBrightnessInt = brightnessFloatToInt(value);
Object topOfQueue = mWriteHistory.peek();
if (topOfQueue != null && topOfQueue.equals(value)) {
mWriteHistory.poll();
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 49ad81b..fd90b56 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -206,6 +206,7 @@
public static final int SELECTION_TYPE_APP = 2;
public static final int SELECTION_TYPE_STANDARD = 3;
public static final int SELECTION_TYPE_COPY = 4;
+ public static final int SELECTION_TYPE_NEARBY = 5;
private static final int SCROLL_STATUS_IDLE = 0;
private static final int SCROLL_STATUS_SCROLLING_VERTICAL = 1;
@@ -784,8 +785,8 @@
FrameworkStatsLog.SHARESHEET_STARTED,
getReferrerPackageName(),
target.getType(),
- initialIntents == null ? 0 : initialIntents.length,
mCallerChooserTargets == null ? 0 : mCallerChooserTargets.length,
+ initialIntents == null ? 0 : initialIntents.length,
isWorkProfile(),
findPreferredContentPreview(getTargetIntent(), getContentResolver()),
target.getAction()
@@ -1135,7 +1136,8 @@
return displayContentPreview(previewType, targetIntent, getLayoutInflater(), parent);
}
- private ComponentName getNearbySharingComponent() {
+ @VisibleForTesting
+ protected ComponentName getNearbySharingComponent() {
String nearbyComponent = Settings.Secure.getString(
getContentResolver(),
Settings.Secure.NEARBY_SHARING_COMPONENT);
@@ -1148,7 +1150,8 @@
return ComponentName.unflattenFromString(nearbyComponent);
}
- private TargetInfo getNearbySharingTarget(Intent originalIntent) {
+ @VisibleForTesting
+ protected TargetInfo getNearbySharingTarget(Intent originalIntent) {
final ComponentName cn = getNearbySharingComponent();
if (cn == null) return null;
@@ -1216,14 +1219,21 @@
final TargetInfo ti = getNearbySharingTarget(originalIntent);
if (ti == null) return null;
- return createActionButton(
+ final Button b = createActionButton(
ti.getDisplayIcon(this),
ti.getDisplayLabel(),
(View unused) -> {
+ // Log share completion via nearby
+ getChooserActivityLogger().logShareTargetSelected(
+ SELECTION_TYPE_NEARBY,
+ "",
+ -1);
safelyStartActivity(ti);
finish();
}
);
+ b.setId(R.id.chooser_nearby_button);
+ return b;
}
private void addActionButton(ViewGroup parent, Button b) {
@@ -2616,7 +2626,9 @@
}
}
- static final class EmptyTargetInfo extends NotSelectableTargetInfo {
+ protected static final class EmptyTargetInfo extends NotSelectableTargetInfo {
+ public EmptyTargetInfo() {}
+
public Drawable getDisplayIcon(Context context) {
return null;
}
diff --git a/core/java/com/android/internal/app/ChooserActivityLogger.java b/core/java/com/android/internal/app/ChooserActivityLogger.java
index c26bac4..426859e 100644
--- a/core/java/com/android/internal/app/ChooserActivityLogger.java
+++ b/core/java/com/android/internal/app/ChooserActivityLogger.java
@@ -116,7 +116,9 @@
@UiEvent(doc = "User selected a standard target.")
SHARESHEET_STANDARD_TARGET_SELECTED(234),
@UiEvent(doc = "User selected the copy target.")
- SHARESHEET_COPY_TARGET_SELECTED(235);
+ SHARESHEET_COPY_TARGET_SELECTED(235),
+ @UiEvent(doc = "User selected the nearby target.")
+ SHARESHEET_NEARBY_TARGET_SELECTED(626);
private final int mId;
SharesheetTargetSelectedEvent(int id) {
@@ -136,6 +138,8 @@
return SHARESHEET_STANDARD_TARGET_SELECTED;
case ChooserActivity.SELECTION_TYPE_COPY:
return SHARESHEET_COPY_TARGET_SELECTED;
+ case ChooserActivity.SELECTION_TYPE_NEARBY:
+ return SHARESHEET_NEARBY_TARGET_SELECTED;
default:
return INVALID;
}
diff --git a/core/java/com/android/internal/os/BinderCallsStats.java b/core/java/com/android/internal/os/BinderCallsStats.java
index 201626a..f5bef0b 100644
--- a/core/java/com/android/internal/os/BinderCallsStats.java
+++ b/core/java/com/android/internal/os/BinderCallsStats.java
@@ -74,6 +74,10 @@
// Whether to collect all the data: cpu + exceptions + reply/request sizes.
private boolean mDetailedTracking = DETAILED_TRACKING_DEFAULT;
+ // If set to true, indicates that all transactions for specific UIDs are being
+ // recorded, ignoring sampling. The UidEntry.recordAllTransactions flag is also set
+ // for the UIDs being tracked.
+ private boolean mRecordingAllTransactionsForUid;
// Sampling period to control how often to track CPU usage. 1 means all calls, 100 means ~1 out
// of 100 requests.
private int mPeriodicSamplingInterval = PERIODIC_SAMPLING_INTERVAL_DEFAULT;
@@ -178,7 +182,8 @@
@Override
@Nullable
public CallSession callStarted(Binder binder, int code, int workSourceUid) {
- if (mDeviceState == null || mDeviceState.isCharging()) {
+ if (!mRecordingAllTransactionsForUid
+ && (mDeviceState == null || mDeviceState.isCharging())) {
return null;
}
@@ -190,7 +195,9 @@
s.exceptionThrown = false;
s.cpuTimeStarted = -1;
s.timeStarted = -1;
- if (shouldRecordDetailedData()) {
+ s.recordedCall = shouldRecordDetailedData();
+
+ if (mRecordingAllTransactionsForUid || s.recordedCall) {
s.cpuTimeStarted = getThreadTimeMicro();
s.timeStarted = getElapsedRealtimeMicro();
}
@@ -218,8 +225,17 @@
private void processCallEnded(CallSession s,
int parcelRequestSize, int parcelReplySize, int workSourceUid) {
- // Non-negative time signals we need to record data for this call.
- final boolean recordCall = s.cpuTimeStarted >= 0;
+ UidEntry uidEntry = null;
+ final boolean recordCall;
+ if (s.recordedCall) {
+ recordCall = true;
+ } else if (mRecordingAllTransactionsForUid) {
+ uidEntry = getUidEntry(workSourceUid);
+ recordCall = uidEntry.recordAllTransactions;
+ } else {
+ recordCall = false;
+ }
+
final long duration;
final long latencyDuration;
if (recordCall) {
@@ -238,14 +254,17 @@
synchronized (mLock) {
// This was already checked in #callStart but check again while synchronized.
- if (mDeviceState == null || mDeviceState.isCharging()) {
+ if (!mRecordingAllTransactionsForUid
+ && (mDeviceState == null || mDeviceState.isCharging())) {
return;
}
- final UidEntry uidEntry = getUidEntry(workSourceUid);
+ if (uidEntry == null) {
+ uidEntry = getUidEntry(workSourceUid);
+ }
+
uidEntry.callCount++;
uidEntry.incrementalCallCount++;
-
if (recordCall) {
uidEntry.cpuTimeMicros += duration;
uidEntry.recordedCallCount++;
@@ -357,28 +376,67 @@
for (int entryIdx = 0; entryIdx < uidEntriesSize; entryIdx++) {
final UidEntry entry = mUidEntries.valueAt(entryIdx);
for (CallStat stat : entry.getCallStatsList()) {
- ExportedCallStat exported = new ExportedCallStat();
- exported.workSourceUid = entry.workSourceUid;
- exported.callingUid = stat.callingUid;
- exported.className = stat.binderClass.getName();
- exported.binderClass = stat.binderClass;
- exported.transactionCode = stat.transactionCode;
- exported.screenInteractive = stat.screenInteractive;
- exported.cpuTimeMicros = stat.cpuTimeMicros;
- exported.maxCpuTimeMicros = stat.maxCpuTimeMicros;
- exported.latencyMicros = stat.latencyMicros;
- exported.maxLatencyMicros = stat.maxLatencyMicros;
- exported.recordedCallCount = stat.recordedCallCount;
- exported.callCount = stat.callCount;
- exported.maxRequestSizeBytes = stat.maxRequestSizeBytes;
- exported.maxReplySizeBytes = stat.maxReplySizeBytes;
- exported.exceptionCount = stat.exceptionCount;
- resultCallStats.add(exported);
+ resultCallStats.add(getExportedCallStat(entry.workSourceUid, stat));
}
}
}
// Resolve codes outside of the lock since it can be slow.
+ resolveBinderMethodNames(resultCallStats);
+
+ // Debug entries added to help validate the data.
+ if (mAddDebugEntries && mBatteryStopwatch != null) {
+ resultCallStats.add(createDebugEntry("start_time_millis", mStartElapsedTime));
+ resultCallStats.add(createDebugEntry("end_time_millis", SystemClock.elapsedRealtime()));
+ resultCallStats.add(
+ createDebugEntry("battery_time_millis", mBatteryStopwatch.getMillis()));
+ resultCallStats.add(createDebugEntry("sampling_interval", mPeriodicSamplingInterval));
+ }
+
+ return resultCallStats;
+ }
+
+ /**
+ * This method is expensive to call.
+ */
+ public ArrayList<ExportedCallStat> getExportedCallStats(int workSourceUid) {
+ ArrayList<ExportedCallStat> resultCallStats = new ArrayList<>();
+ synchronized (mLock) {
+ final UidEntry entry = getUidEntry(workSourceUid);
+ for (CallStat stat : entry.getCallStatsList()) {
+ resultCallStats.add(getExportedCallStat(workSourceUid, stat));
+ }
+ }
+
+ // Resolve codes outside of the lock since it can be slow.
+ resolveBinderMethodNames(resultCallStats);
+
+ return resultCallStats;
+ }
+
+ private ExportedCallStat getExportedCallStat(int workSourceUid, CallStat stat) {
+ ExportedCallStat exported = new ExportedCallStat();
+ exported.workSourceUid = workSourceUid;
+ exported.callingUid = stat.callingUid;
+ exported.className = stat.binderClass.getName();
+ exported.binderClass = stat.binderClass;
+ exported.transactionCode = stat.transactionCode;
+ exported.screenInteractive = stat.screenInteractive;
+ exported.cpuTimeMicros = stat.cpuTimeMicros;
+ exported.maxCpuTimeMicros = stat.maxCpuTimeMicros;
+ exported.latencyMicros = stat.latencyMicros;
+ exported.maxLatencyMicros = stat.maxLatencyMicros;
+ exported.recordedCallCount = stat.recordedCallCount;
+ exported.callCount = stat.callCount;
+ exported.maxRequestSizeBytes = stat.maxRequestSizeBytes;
+ exported.maxReplySizeBytes = stat.maxReplySizeBytes;
+ exported.exceptionCount = stat.exceptionCount;
+ return exported;
+ }
+
+ private void resolveBinderMethodNames(
+ ArrayList<ExportedCallStat> resultCallStats) {
+ // Resolve codes outside of the lock since it can be slow.
ExportedCallStat previous = null;
String previousMethodName = null;
resultCallStats.sort(BinderCallsStats::compareByBinderClassAndCode);
@@ -398,17 +456,6 @@
exported.methodName = methodName;
previous = exported;
}
-
- // Debug entries added to help validate the data.
- if (mAddDebugEntries && mBatteryStopwatch != null) {
- resultCallStats.add(createDebugEntry("start_time_millis", mStartElapsedTime));
- resultCallStats.add(createDebugEntry("end_time_millis", SystemClock.elapsedRealtime()));
- resultCallStats.add(
- createDebugEntry("battery_time_millis", mBatteryStopwatch.getMillis()));
- resultCallStats.add(createDebugEntry("sampling_interval", mPeriodicSamplingInterval));
- }
-
- return resultCallStats;
}
private ExportedCallStat createDebugEntry(String variableName, long value) {
@@ -432,33 +479,24 @@
}
/** Writes the collected statistics to the supplied {@link PrintWriter}.*/
- public void dump(PrintWriter pw, AppIdToPackageMap packageMap, boolean verbose) {
+ public void dump(PrintWriter pw, AppIdToPackageMap packageMap, int workSourceUid,
+ boolean verbose) {
synchronized (mLock) {
- dumpLocked(pw, packageMap, verbose);
+ dumpLocked(pw, packageMap, workSourceUid, verbose);
}
}
- private void dumpLocked(PrintWriter pw, AppIdToPackageMap packageMap, boolean verbose) {
- long totalCallsCount = 0;
- long totalRecordedCallsCount = 0;
- long totalCpuTime = 0;
+ private void dumpLocked(PrintWriter pw, AppIdToPackageMap packageMap, int workSourceUid,
+ boolean verbose) {
+ if (workSourceUid != Process.INVALID_UID) {
+ verbose = true;
+ }
pw.print("Start time: ");
pw.println(DateFormat.format("yyyy-MM-dd HH:mm:ss", mStartCurrentTime));
pw.print("On battery time (ms): ");
pw.println(mBatteryStopwatch != null ? mBatteryStopwatch.getMillis() : 0);
pw.println("Sampling interval period: " + mPeriodicSamplingInterval);
- final List<UidEntry> entries = new ArrayList<>();
- final int uidEntriesSize = mUidEntries.size();
- for (int i = 0; i < uidEntriesSize; i++) {
- UidEntry e = mUidEntries.valueAt(i);
- entries.add(e);
- totalCpuTime += e.cpuTimeMicros;
- totalRecordedCallsCount += e.recordedCallCount;
- totalCallsCount += e.callCount;
- }
-
- entries.sort(Comparator.<UidEntry>comparingDouble(value -> value.cpuTimeMicros).reversed());
final String datasetSizeDesc = verbose ? "" : "(top 90% by cpu time) ";
final StringBuilder sb = new StringBuilder();
pw.println("Per-UID raw data " + datasetSizeDesc
@@ -467,10 +505,15 @@
+ "latency_time_micros, max_latency_time_micros, exception_count, "
+ "max_request_size_bytes, max_reply_size_bytes, recorded_call_count, "
+ "call_count):");
- final List<ExportedCallStat> exportedCallStats = getExportedCallStats();
+ final List<ExportedCallStat> exportedCallStats;
+ if (workSourceUid != Process.INVALID_UID) {
+ exportedCallStats = getExportedCallStats(workSourceUid);
+ } else {
+ exportedCallStats = getExportedCallStats();
+ }
exportedCallStats.sort(BinderCallsStats::compareByCpuDesc);
for (ExportedCallStat e : exportedCallStats) {
- if (e.methodName.startsWith(DEBUG_ENTRY_PREFIX)) {
+ if (e.methodName != null && e.methodName.startsWith(DEBUG_ENTRY_PREFIX)) {
// Do not dump debug entries.
continue;
}
@@ -494,6 +537,30 @@
pw.println(sb);
}
pw.println();
+ final List<UidEntry> entries = new ArrayList<>();
+ long totalCallsCount = 0;
+ long totalRecordedCallsCount = 0;
+ long totalCpuTime = 0;
+
+ if (workSourceUid != Process.INVALID_UID) {
+ UidEntry e = getUidEntry(workSourceUid);
+ entries.add(e);
+ totalCpuTime += e.cpuTimeMicros;
+ totalRecordedCallsCount += e.recordedCallCount;
+ totalCallsCount += e.callCount;
+ } else {
+ final int uidEntriesSize = mUidEntries.size();
+ for (int i = 0; i < uidEntriesSize; i++) {
+ UidEntry e = mUidEntries.valueAt(i);
+ entries.add(e);
+ totalCpuTime += e.cpuTimeMicros;
+ totalRecordedCallsCount += e.recordedCallCount;
+ totalCallsCount += e.callCount;
+ }
+ entries.sort(
+ Comparator.<UidEntry>comparingDouble(value -> value.cpuTimeMicros).reversed());
+ }
+
pw.println("Per-UID Summary " + datasetSizeDesc
+ "(cpu_time, % of total cpu_time, recorded_call_count, call_count, package/uid):");
final List<UidEntry> summaryEntries = verbose ? entries
@@ -505,10 +572,13 @@
entry.recordedCallCount, entry.callCount, uidStr));
}
pw.println();
- pw.println(String.format(" Summary: total_cpu_time=%d, "
- + "calls_count=%d, avg_call_cpu_time=%.0f",
- totalCpuTime, totalCallsCount, (double) totalCpuTime / totalRecordedCallsCount));
- pw.println();
+ if (workSourceUid == Process.INVALID_UID) {
+ pw.println(String.format(" Summary: total_cpu_time=%d, "
+ + "calls_count=%d, avg_call_cpu_time=%.0f",
+ totalCpuTime, totalCallsCount,
+ (double) totalCpuTime / totalRecordedCallsCount));
+ pw.println();
+ }
pw.println("Exceptions thrown (exception_count, class_name):");
final List<Pair<String, Integer>> exceptionEntries = new ArrayList<>();
@@ -590,6 +660,22 @@
}
}
+ /**
+ * Marks the specified work source UID for total binder call tracking: detailed information
+ * will be recorded for all calls from this source ID.
+ *
+ * This is expensive and can cause memory pressure, therefore this mode should only be used
+ * for debugging.
+ */
+ public void recordAllCallsForWorkSourceUid(int workSourceUid) {
+ setDetailedTracking(true);
+
+ Slog.i(TAG, "Recording all Binder calls for UID: " + workSourceUid);
+ UidEntry uidEntry = getUidEntry(workSourceUid);
+ uidEntry.recordAllTransactions = true;
+ mRecordingAllTransactionsForUid = true;
+ }
+
public void setAddDebugEntries(boolean addDebugEntries) {
mAddDebugEntries = addDebugEntries;
}
@@ -637,6 +723,7 @@
if (mBatteryStopwatch != null) {
mBatteryStopwatch.reset();
}
+ mRecordingAllTransactionsForUid = false;
}
}
@@ -767,6 +854,8 @@
public long cpuTimeMicros;
// Call count that gets reset after delivery to BatteryStats
public long incrementalCallCount;
+ // Indicates that all transactions for the UID must be tracked
+ public boolean recordAllTransactions;
UidEntry(int uid) {
this.workSourceUid = uid;
diff --git a/core/java/com/android/internal/os/BinderInternal.java b/core/java/com/android/internal/os/BinderInternal.java
index f14d5f2..2645b8e 100644
--- a/core/java/com/android/internal/os/BinderInternal.java
+++ b/core/java/com/android/internal/os/BinderInternal.java
@@ -85,9 +85,10 @@
long timeStarted;
// Should be set to one when an exception is thrown.
boolean exceptionThrown;
+ // Detailed information should be recorded for this call when it ends.
+ public boolean recordedCall;
}
-
/**
* Responsible for resolving a work source.
*/
diff --git a/services/core/java/com/android/server/wm/ProtoLogGroup.java b/core/java/com/android/internal/protolog/ProtoLogGroup.java
similarity index 88%
rename from services/core/java/com/android/server/wm/ProtoLogGroup.java
rename to core/java/com/android/internal/protolog/ProtoLogGroup.java
index 51725ce..73d148c 100644
--- a/services/core/java/com/android/server/wm/ProtoLogGroup.java
+++ b/core/java/com/android/internal/protolog/ProtoLogGroup.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 The Android Open Source Project
+ * 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.
@@ -14,11 +14,9 @@
* limitations under the License.
*/
-package com.android.server.wm;
+package com.android.internal.protolog;
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.server.protolog.common.IProtoLogGroup;
-import com.android.server.protolog.common.ProtoLog;
+import com.android.internal.protolog.common.IProtoLogGroup;
/**
* Defines logging groups for ProtoLog.
@@ -118,16 +116,6 @@
this.mLogToLogcat = logToLogcat;
}
- /**
- * Test function for automated integration tests. Can be also called manually from adb shell.
- */
- @VisibleForTesting
- public static void testProtoLog() {
- ProtoLog.e(ProtoLogGroup.TEST_GROUP,
- "Test completed successfully: %b %d %o %x %e %g %f %% %s.",
- true, 1, 2, 3, 0.4, 0.5, 0.6, "ok");
- }
-
private static class Consts {
private static final String TAG_WM = "WindowManager";
diff --git a/services/core/java/com/android/server/protolog/ProtoLogImpl.java b/core/java/com/android/internal/protolog/ProtoLogImpl.java
similarity index 92%
rename from services/core/java/com/android/server/protolog/ProtoLogImpl.java
rename to core/java/com/android/internal/protolog/ProtoLogImpl.java
index c9d42c8..6874f10 100644
--- a/services/core/java/com/android/server/protolog/ProtoLogImpl.java
+++ b/core/java/com/android/internal/protolog/ProtoLogImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 The Android Open Source Project
+ * 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.
@@ -14,20 +14,20 @@
* limitations under the License.
*/
-package com.android.server.protolog;
+package com.android.internal.protolog;
-import static com.android.server.protolog.ProtoLogFileProto.LOG;
-import static com.android.server.protolog.ProtoLogFileProto.MAGIC_NUMBER;
-import static com.android.server.protolog.ProtoLogFileProto.MAGIC_NUMBER_H;
-import static com.android.server.protolog.ProtoLogFileProto.MAGIC_NUMBER_L;
-import static com.android.server.protolog.ProtoLogFileProto.REAL_TIME_TO_ELAPSED_TIME_OFFSET_MILLIS;
-import static com.android.server.protolog.ProtoLogFileProto.VERSION;
-import static com.android.server.protolog.ProtoLogMessage.BOOLEAN_PARAMS;
-import static com.android.server.protolog.ProtoLogMessage.DOUBLE_PARAMS;
-import static com.android.server.protolog.ProtoLogMessage.ELAPSED_REALTIME_NANOS;
-import static com.android.server.protolog.ProtoLogMessage.MESSAGE_HASH;
-import static com.android.server.protolog.ProtoLogMessage.SINT64_PARAMS;
-import static com.android.server.protolog.ProtoLogMessage.STR_PARAMS;
+import static com.android.internal.protolog.ProtoLogFileProto.LOG;
+import static com.android.internal.protolog.ProtoLogFileProto.MAGIC_NUMBER;
+import static com.android.internal.protolog.ProtoLogFileProto.MAGIC_NUMBER_H;
+import static com.android.internal.protolog.ProtoLogFileProto.MAGIC_NUMBER_L;
+import static com.android.internal.protolog.ProtoLogFileProto.REAL_TIME_TO_ELAPSED_TIME_OFFSET_MILLIS;
+import static com.android.internal.protolog.ProtoLogFileProto.VERSION;
+import static com.android.internal.protolog.ProtoLogMessage.BOOLEAN_PARAMS;
+import static com.android.internal.protolog.ProtoLogMessage.DOUBLE_PARAMS;
+import static com.android.internal.protolog.ProtoLogMessage.ELAPSED_REALTIME_NANOS;
+import static com.android.internal.protolog.ProtoLogMessage.MESSAGE_HASH;
+import static com.android.internal.protolog.ProtoLogMessage.SINT64_PARAMS;
+import static com.android.internal.protolog.ProtoLogMessage.STR_PARAMS;
import android.annotation.Nullable;
import android.os.ShellCommand;
@@ -36,10 +36,9 @@
import android.util.proto.ProtoOutputStream;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.server.protolog.common.IProtoLogGroup;
-import com.android.server.protolog.common.LogDataType;
+import com.android.internal.protolog.common.IProtoLogGroup;
+import com.android.internal.protolog.common.LogDataType;
import com.android.internal.util.TraceBuffer;
-import com.android.server.wm.ProtoLogGroup;
import java.io.File;
import java.io.IOException;
@@ -62,7 +61,7 @@
* Must be invoked after every action that could change the result of {@link #isEnabled}, eg.
* starting / stopping proto log, or enabling / disabling log groups.
*/
- static Runnable sCacheUpdater = () -> { };
+ public static Runnable sCacheUpdater = () -> { };
private static void addLogGroupEnum(IProtoLogGroup[] config) {
for (IProtoLogGroup group : config) {
@@ -289,9 +288,7 @@
}
}
-
- @VisibleForTesting
- ProtoLogImpl(File file, int bufferCapacity, ProtoLogViewerConfigReader viewerConfig) {
+ public ProtoLogImpl(File file, int bufferCapacity, ProtoLogViewerConfigReader viewerConfig) {
mLogFile = file;
mBuffer = new TraceBuffer(bufferCapacity);
mViewerConfig = viewerConfig;
diff --git a/services/core/java/com/android/server/protolog/ProtoLogViewerConfigReader.java b/core/java/com/android/internal/protolog/ProtoLogViewerConfigReader.java
similarity index 87%
rename from services/core/java/com/android/server/protolog/ProtoLogViewerConfigReader.java
rename to core/java/com/android/internal/protolog/ProtoLogViewerConfigReader.java
index 4944217..e381d30 100644
--- a/services/core/java/com/android/server/protolog/ProtoLogViewerConfigReader.java
+++ b/core/java/com/android/internal/protolog/ProtoLogViewerConfigReader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 The Android Open Source Project
+ * 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.
@@ -14,9 +14,7 @@
* limitations under the License.
*/
-package com.android.server.protolog;
-
-import static com.android.server.protolog.ProtoLogImpl.logAndPrintln;
+package com.android.internal.protolog;
import org.json.JSONException;
import org.json.JSONObject;
@@ -80,16 +78,17 @@
// Not a messageHash - skip it
}
}
- logAndPrintln(pw, "Loaded " + mLogMessageMap.size() + " log definitions from "
- + viewerConfigFilename);
+ ProtoLogImpl.logAndPrintln(pw, "Loaded " + mLogMessageMap.size()
+ + " log definitions from " + viewerConfigFilename);
} catch (FileNotFoundException e) {
- logAndPrintln(pw, "Unable to load log definitions: File "
+ ProtoLogImpl.logAndPrintln(pw, "Unable to load log definitions: File "
+ viewerConfigFilename + " not found." + e);
} catch (IOException e) {
- logAndPrintln(pw, "Unable to load log definitions: IOException while reading "
+ ProtoLogImpl.logAndPrintln(pw,
+ "Unable to load log definitions: IOException while reading "
+ viewerConfigFilename + ". " + e);
} catch (JSONException e) {
- logAndPrintln(pw,
+ ProtoLogImpl.logAndPrintln(pw,
"Unable to load log definitions: JSON parsing exception while reading "
+ viewerConfigFilename + ". " + e);
}
diff --git a/services/core/java/com/android/server/protolog/common/BitmaskConversionException.java b/core/java/com/android/internal/protolog/common/BitmaskConversionException.java
similarity index 88%
rename from services/core/java/com/android/server/protolog/common/BitmaskConversionException.java
rename to core/java/com/android/internal/protolog/common/BitmaskConversionException.java
index 7bb27b2..68b9d69 100644
--- a/services/core/java/com/android/server/protolog/common/BitmaskConversionException.java
+++ b/core/java/com/android/internal/protolog/common/BitmaskConversionException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 The Android Open Source Project
+ * 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server.protolog.common;
+package com.android.internal.protolog.common;
/**
* Error while converting a bitmask representing a list of LogDataTypes.
diff --git a/services/core/java/com/android/server/protolog/common/IProtoLogGroup.java b/core/java/com/android/internal/protolog/common/IProtoLogGroup.java
similarity index 93%
rename from services/core/java/com/android/server/protolog/common/IProtoLogGroup.java
rename to core/java/com/android/internal/protolog/common/IProtoLogGroup.java
index 2c65341..e3db468 100644
--- a/services/core/java/com/android/server/protolog/common/IProtoLogGroup.java
+++ b/core/java/com/android/internal/protolog/common/IProtoLogGroup.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 The Android Open Source Project
+ * 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server.protolog.common;
+package com.android.internal.protolog.common;
/**
* Defines a log group configuration object for ProtoLog. Should be implemented as en enum.
diff --git a/services/core/java/com/android/server/protolog/common/InvalidFormatStringException.java b/core/java/com/android/internal/protolog/common/InvalidFormatStringException.java
similarity index 89%
rename from services/core/java/com/android/server/protolog/common/InvalidFormatStringException.java
rename to core/java/com/android/internal/protolog/common/InvalidFormatStringException.java
index 947bf98..97d3dfb 100644
--- a/services/core/java/com/android/server/protolog/common/InvalidFormatStringException.java
+++ b/core/java/com/android/internal/protolog/common/InvalidFormatStringException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 The Android Open Source Project
+ * 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server.protolog.common;
+package com.android.internal.protolog.common;
/**
* Unsupported/invalid message format string error.
diff --git a/services/core/java/com/android/server/protolog/common/LogDataType.java b/core/java/com/android/internal/protolog/common/LogDataType.java
similarity index 96%
rename from services/core/java/com/android/server/protolog/common/LogDataType.java
rename to core/java/com/android/internal/protolog/common/LogDataType.java
index e73b41a..651932a 100644
--- a/services/core/java/com/android/server/protolog/common/LogDataType.java
+++ b/core/java/com/android/internal/protolog/common/LogDataType.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 The Android Open Source Project
+ * 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server.protolog.common;
+package com.android.internal.protolog.common;
import java.util.ArrayList;
import java.util.List;
diff --git a/services/core/java/com/android/server/protolog/common/ProtoLog.java b/core/java/com/android/internal/protolog/common/ProtoLog.java
similarity index 97%
rename from services/core/java/com/android/server/protolog/common/ProtoLog.java
rename to core/java/com/android/internal/protolog/common/ProtoLog.java
index b631bcb..ab58d35 100644
--- a/services/core/java/com/android/server/protolog/common/ProtoLog.java
+++ b/core/java/com/android/internal/protolog/common/ProtoLog.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 The Android Open Source Project
+ * 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server.protolog.common;
+package com.android.internal.protolog.common;
/**
* ProtoLog API - exposes static logging methods. Usage of this API is similar
diff --git a/core/java/com/android/internal/util/ScreenshotHelper.java b/core/java/com/android/internal/util/ScreenshotHelper.java
index 9bf0513..a23fc4b 100644
--- a/core/java/com/android/internal/util/ScreenshotHelper.java
+++ b/core/java/com/android/internal/util/ScreenshotHelper.java
@@ -291,7 +291,7 @@
};
Message msg = Message.obtain(null, screenshotType, screenshotRequest);
- final ServiceConnection myConn = mScreenshotConnection;
+
Handler h = new Handler(handler.getLooper()) {
@Override
public void handleMessage(Message msg) {
@@ -304,8 +304,8 @@
break;
case SCREENSHOT_MSG_PROCESS_COMPLETE:
synchronized (mScreenshotLock) {
- if (myConn != null && mScreenshotConnection == myConn) {
- mContext.unbindService(myConn);
+ if (mScreenshotConnection != null) {
+ mContext.unbindService(mScreenshotConnection);
mScreenshotConnection = null;
mScreenshotService = null;
}
@@ -368,6 +368,7 @@
}
} else {
Messenger messenger = new Messenger(mScreenshotService);
+
try {
messenger.send(msg);
} catch (RemoteException e) {
diff --git a/core/java/com/android/internal/util/StatLogger.java b/core/java/com/android/internal/util/StatLogger.java
index 29568d5..2d65090 100644
--- a/core/java/com/android/internal/util/StatLogger.java
+++ b/core/java/com/android/internal/util/StatLogger.java
@@ -84,7 +84,7 @@
* give it back to the {@link #logDurationStat(int, long)}} after the event.
*/
public long getTime() {
- return SystemClock.elapsedRealtimeNanos() / 1000;
+ return SystemClock.uptimeNanos() / 1000;
}
/**
diff --git a/core/java/com/android/internal/widget/ILockSettings.aidl b/core/java/com/android/internal/widget/ILockSettings.aidl
index e35fda1..d5d635d 100644
--- a/core/java/com/android/internal/widget/ILockSettings.aidl
+++ b/core/java/com/android/internal/widget/ILockSettings.aidl
@@ -47,8 +47,9 @@
void resetKeyStore(int userId);
VerifyCredentialResponse checkCredential(in LockscreenCredential credential, int userId,
in ICheckCredentialProgressCallback progressCallback);
- VerifyCredentialResponse verifyCredential(in LockscreenCredential credential, long challenge, int userId);
- VerifyCredentialResponse verifyTiedProfileChallenge(in LockscreenCredential credential, long challenge, int userId);
+ VerifyCredentialResponse verifyCredential(in LockscreenCredential credential, int userId, int flags);
+ VerifyCredentialResponse verifyTiedProfileChallenge(in LockscreenCredential credential, int userId, int flags);
+ VerifyCredentialResponse verifyGatekeeperPassword(in byte[] gatekeeperPassword, long challenge, int userId);
boolean checkVoldPassword(int userId);
int getCredentialType(int userId);
byte[] getHashFactor(in LockscreenCredential currentCredential, int userId);
diff --git a/core/java/com/android/internal/widget/LockPatternChecker.java b/core/java/com/android/internal/widget/LockPatternChecker.java
index 85a45fd..5adbc58 100644
--- a/core/java/com/android/internal/widget/LockPatternChecker.java
+++ b/core/java/com/android/internal/widget/LockPatternChecker.java
@@ -1,5 +1,6 @@
package com.android.internal.widget;
+import android.annotation.NonNull;
import android.os.AsyncTask;
import com.android.internal.widget.LockPatternUtils.RequestThrottledException;
@@ -41,11 +42,11 @@
/**
* Invoked when a security verification is finished.
*
- * @param attestation The attestation that the challenge was verified, or null.
+ * @param response The response, optionally containing Gatekeeper HAT or Gatekeeper Password
* @param throttleTimeoutMs The amount of time in ms to wait before reattempting
- * the call. Only non-0 if attestation is null.
+ * the call. Only non-0 if the response is {@link VerifyCredentialResponse#RESPONSE_RETRY}.
*/
- void onVerified(byte[] attestation, int throttleTimeoutMs);
+ void onVerified(@NonNull VerifyCredentialResponse response, int throttleTimeoutMs);
}
/**
@@ -53,33 +54,27 @@
*
* @param utils The LockPatternUtils instance to use.
* @param credential The credential to check.
- * @param challenge The challenge to verify against the credential.
* @param userId The user to check against the credential.
+ * @param flags See {@link LockPatternUtils.VerifyFlag}
* @param callback The callback to be invoked with the verification result.
*/
public static AsyncTask<?, ?, ?> verifyCredential(final LockPatternUtils utils,
final LockscreenCredential credential,
- final long challenge,
final int userId,
+ final @LockPatternUtils.VerifyFlag int flags,
final OnVerifyCallback callback) {
// Create a copy of the credential since checking credential is asynchrounous.
final LockscreenCredential credentialCopy = credential.duplicate();
- AsyncTask<Void, Void, byte[]> task = new AsyncTask<Void, Void, byte[]>() {
- private int mThrottleTimeout;
-
+ AsyncTask<Void, Void, VerifyCredentialResponse> task =
+ new AsyncTask<Void, Void, VerifyCredentialResponse>() {
@Override
- protected byte[] doInBackground(Void... args) {
- try {
- return utils.verifyCredential(credentialCopy, challenge, userId);
- } catch (RequestThrottledException ex) {
- mThrottleTimeout = ex.getTimeoutMs();
- return null;
- }
+ protected VerifyCredentialResponse doInBackground(Void... args) {
+ return utils.verifyCredential(credentialCopy, userId, flags);
}
@Override
- protected void onPostExecute(byte[] result) {
- callback.onVerified(result, mThrottleTimeout);
+ protected void onPostExecute(@NonNull VerifyCredentialResponse result) {
+ callback.onVerified(result, result.getTimeout());
credentialCopy.zeroize();
}
@@ -141,33 +136,27 @@
*
* @param utils The LockPatternUtils instance to use.
* @param credential The credential to check.
- * @param challenge The challenge to verify against the credential.
* @param userId The user to check against the credential.
+ * @param flags See {@link LockPatternUtils.VerifyFlag}
* @param callback The callback to be invoked with the verification result.
*/
public static AsyncTask<?, ?, ?> verifyTiedProfileChallenge(final LockPatternUtils utils,
final LockscreenCredential credential,
- final long challenge,
final int userId,
+ final @LockPatternUtils.VerifyFlag int flags,
final OnVerifyCallback callback) {
- // Create a copy of the credential since checking credential is asynchrounous.
+ // Create a copy of the credential since checking credential is asynchronous.
final LockscreenCredential credentialCopy = credential.duplicate();
- AsyncTask<Void, Void, byte[]> task = new AsyncTask<Void, Void, byte[]>() {
- private int mThrottleTimeout;
-
+ AsyncTask<Void, Void, VerifyCredentialResponse> task =
+ new AsyncTask<Void, Void, VerifyCredentialResponse>() {
@Override
- protected byte[] doInBackground(Void... args) {
- try {
- return utils.verifyTiedProfileChallenge(credentialCopy, challenge, userId);
- } catch (RequestThrottledException ex) {
- mThrottleTimeout = ex.getTimeoutMs();
- return null;
- }
+ protected VerifyCredentialResponse doInBackground(Void... args) {
+ return utils.verifyTiedProfileChallenge(credentialCopy, userId, flags);
}
@Override
- protected void onPostExecute(byte[] result) {
- callback.onVerified(result, mThrottleTimeout);
+ protected void onPostExecute(@NonNull VerifyCredentialResponse response) {
+ callback.onVerified(response, response.getTimeout());
credentialCopy.zeroize();
}
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index 93690cd..f7370d6 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -130,6 +130,18 @@
public @interface CredentialType {}
/**
+ * Flag provided to {@link #verifyCredential(LockscreenCredential, long, int, int)} . If set,
+ * the method will return the Gatekeeper Password in the {@link VerifyCredentialResponse}.
+ */
+ public static final int VERIFY_FLAG_RETURN_GK_PW = 1 << 0;
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(flag = true, value = {
+ VERIFY_FLAG_RETURN_GK_PW
+ })
+ public @interface VerifyFlag {}
+
+ /**
* Special user id for triggering the FRP verification flow.
*/
public static final int USER_FRP = UserHandle.USER_NULL + 1;
@@ -374,29 +386,46 @@
* If credential matches, return an opaque attestation that the challenge was verified.
*
* @param credential The credential to check.
- * @param challenge The challenge to verify against the credential
* @param userId The user whose credential is being verified
- * @return the attestation that the challenge was verified, or null
- * @throws RequestThrottledException if credential verification is being throttled due to
- * to many incorrect attempts.
+ * @param flags See {@link VerifyFlag}
* @throws IllegalStateException if called on the main thread.
*/
- public byte[] verifyCredential(@NonNull LockscreenCredential credential, long challenge,
- int userId) throws RequestThrottledException {
+ @NonNull
+ public VerifyCredentialResponse verifyCredential(@NonNull LockscreenCredential credential,
+ int userId, @VerifyFlag int flags) {
throwIfCalledOnMainThread();
try {
- VerifyCredentialResponse response = getLockSettings().verifyCredential(
- credential, challenge, userId);
- if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK) {
- return response.getPayload();
- } else if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_RETRY) {
- throw new RequestThrottledException(response.getTimeout());
+ final VerifyCredentialResponse response = getLockSettings().verifyCredential(
+ credential, userId, flags);
+ if (response == null) {
+ return VerifyCredentialResponse.ERROR;
} else {
- return null;
+ return response;
}
} catch (RemoteException re) {
Log.e(TAG, "failed to verify credential", re);
- return null;
+ return VerifyCredentialResponse.ERROR;
+ }
+ }
+
+ /**
+ * With the Gatekeeper Password returned via {@link #verifyCredential(LockscreenCredential,
+ * int, int)}, request Gatekeeper to create a HardwareAuthToken wrapping the given
+ * challenge.
+ */
+ @NonNull
+ public VerifyCredentialResponse verifyGatekeeperPassword(@NonNull byte[] gatekeeperPassword,
+ long challenge, int userId) {
+ try {
+ final VerifyCredentialResponse response = getLockSettings().verifyGatekeeperPassword(
+ gatekeeperPassword, challenge, userId);
+ if (response == null) {
+ return VerifyCredentialResponse.ERROR;
+ }
+ return response;
+ } catch (RemoteException e) {
+ Log.e(TAG, "failed to verify gatekeeper password", e);
+ return VerifyCredentialResponse.ERROR;
}
}
@@ -418,8 +447,9 @@
try {
VerifyCredentialResponse response = getLockSettings().checkCredential(
credential, userId, wrapCallback(progressCallback));
-
- if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK) {
+ if (response == null) {
+ return false;
+ } else if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK) {
return true;
} else if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_RETRY) {
throw new RequestThrottledException(response.getTimeout());
@@ -439,30 +469,26 @@
* verified.
*
* @param credential The parent user's credential to check.
- * @param challenge The challenge to verify against the credential
* @return the attestation that the challenge was verified, or null
* @param userId The managed profile user id
- * @throws RequestThrottledException if credential verification is being throttled due to
- * to many incorrect attempts.
+ * @param flags See {@link VerifyFlag}
* @throws IllegalStateException if called on the main thread.
*/
- public byte[] verifyTiedProfileChallenge(@NonNull LockscreenCredential credential,
- long challenge, int userId) throws RequestThrottledException {
+ @NonNull
+ public VerifyCredentialResponse verifyTiedProfileChallenge(
+ @NonNull LockscreenCredential credential, int userId, @VerifyFlag int flags) {
throwIfCalledOnMainThread();
try {
- VerifyCredentialResponse response =
- getLockSettings().verifyTiedProfileChallenge(credential, challenge, userId);
-
- if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK) {
- return response.getPayload();
- } else if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_RETRY) {
- throw new RequestThrottledException(response.getTimeout());
+ final VerifyCredentialResponse response = getLockSettings()
+ .verifyTiedProfileChallenge(credential, userId, flags);
+ if (response == null) {
+ return VerifyCredentialResponse.ERROR;
} else {
- return null;
+ return response;
}
} catch (RemoteException re) {
Log.e(TAG, "failed to verify tied profile credential", re);
- return null;
+ return VerifyCredentialResponse.ERROR;
}
}
diff --git a/core/java/com/android/internal/widget/LockscreenCredential.java b/core/java/com/android/internal/widget/LockscreenCredential.java
index 55f30fb..a488449 100644
--- a/core/java/com/android/internal/widget/LockscreenCredential.java
+++ b/core/java/com/android/internal/widget/LockscreenCredential.java
@@ -48,7 +48,7 @@
* // Process the credential in some way
* }
* </pre>
- * With this construct, we can garantee that there will be no copies of the password left in
+ * With this construct, we can guarantee that there will be no copies of the password left in
* memory when the credential goes out of scope. This should help mitigate certain class of
* attacks where the attcker gains read-only access to full device memory (cold boot attack,
* unsecured software/hardware memory dumping interfaces such as JTAG).
diff --git a/core/java/com/android/internal/widget/VerifyCredentialResponse.java b/core/java/com/android/internal/widget/VerifyCredentialResponse.java
index 7d1c706..e09eb42 100644
--- a/core/java/com/android/internal/widget/VerifyCredentialResponse.java
+++ b/core/java/com/android/internal/widget/VerifyCredentialResponse.java
@@ -16,11 +16,16 @@
package com.android.internal.widget;
+import android.annotation.IntDef;
+import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
import android.service.gatekeeper.GateKeeperResponse;
import android.util.Slog;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
/**
* Response object for a ILockSettings credential verification request.
* @hide
@@ -30,78 +35,114 @@
public static final int RESPONSE_ERROR = -1;
public static final int RESPONSE_OK = 0;
public static final int RESPONSE_RETRY = 1;
+ @IntDef({RESPONSE_ERROR,
+ RESPONSE_OK,
+ RESPONSE_RETRY})
+ @Retention(RetentionPolicy.SOURCE)
+ @interface ResponseCode {}
- public static final VerifyCredentialResponse OK = new VerifyCredentialResponse();
- public static final VerifyCredentialResponse ERROR
- = new VerifyCredentialResponse(RESPONSE_ERROR, 0, null);
+ public static final VerifyCredentialResponse OK = new VerifyCredentialResponse.Builder()
+ .build();
+ public static final VerifyCredentialResponse ERROR = fromError();
private static final String TAG = "VerifyCredentialResponse";
- private int mResponseCode;
- private byte[] mPayload;
- private int mTimeout;
+ private final @ResponseCode int mResponseCode;
+ private final int mTimeout;
+ @Nullable private final byte[] mGatekeeperHAT;
+ @Nullable private final byte[] mGatekeeperPw;
public static final Parcelable.Creator<VerifyCredentialResponse> CREATOR
= new Parcelable.Creator<VerifyCredentialResponse>() {
@Override
public VerifyCredentialResponse createFromParcel(Parcel source) {
- int responseCode = source.readInt();
- VerifyCredentialResponse response = new VerifyCredentialResponse(responseCode, 0, null);
- if (responseCode == RESPONSE_RETRY) {
- response.setTimeout(source.readInt());
- } else if (responseCode == RESPONSE_OK) {
- int size = source.readInt();
- if (size > 0) {
- byte[] payload = new byte[size];
- source.readByteArray(payload);
- response.setPayload(payload);
- }
- }
- return response;
+ final @ResponseCode int responseCode = source.readInt();
+ final int timeout = source.readInt();
+ final byte[] gatekeeperHAT = source.createByteArray();
+ final byte[] gatekeeperPassword = source.createByteArray();
+
+ return new VerifyCredentialResponse(responseCode, timeout, gatekeeperHAT,
+ gatekeeperPassword);
}
@Override
public VerifyCredentialResponse[] newArray(int size) {
return new VerifyCredentialResponse[size];
}
-
};
- public VerifyCredentialResponse() {
- mResponseCode = RESPONSE_OK;
- mPayload = null;
+ public static class Builder {
+ @Nullable private byte[] mGatekeeperHAT;
+ @Nullable private byte[] mGatekeeperPassword;
+
+ /**
+ * @param gatekeeperHAT Gatekeeper HardwareAuthToken, minted upon successful authentication.
+ */
+ public Builder setGatekeeperHAT(byte[] gatekeeperHAT) {
+ mGatekeeperHAT = gatekeeperHAT;
+ return this;
+ }
+
+ public Builder setGatekeeperPassword(byte[] gatekeeperPassword) {
+ mGatekeeperPassword = gatekeeperPassword;
+ return this;
+ }
+
+ /**
+ * Builds a VerifyCredentialResponse with {@link #RESPONSE_OK} and any other parameters
+ * that were preveiously set.
+ * @return
+ */
+ public VerifyCredentialResponse build() {
+ return new VerifyCredentialResponse(RESPONSE_OK,
+ 0 /* timeout */,
+ mGatekeeperHAT,
+ mGatekeeperPassword);
+ }
}
-
- public VerifyCredentialResponse(byte[] payload) {
- mPayload = payload;
- mResponseCode = RESPONSE_OK;
+ /**
+ * Since timeouts are always an error, provide a way to create the VerifyCredentialResponse
+ * object directly. None of the other fields (Gatekeeper HAT, Gatekeeper Password, etc)
+ * are valid in this case. Similarly, the response code will always be
+ * {@link #RESPONSE_RETRY}.
+ */
+ public static VerifyCredentialResponse fromTimeout(int timeout) {
+ return new VerifyCredentialResponse(RESPONSE_RETRY,
+ timeout,
+ null /* gatekeeperHAT */,
+ null /* gatekeeperPassword */);
}
- public VerifyCredentialResponse(int timeout) {
- mTimeout = timeout;
- mResponseCode = RESPONSE_RETRY;
- mPayload = null;
+ /**
+ * Since error (incorrect password) should never result in any of the other fields from
+ * being populated, provide a default method to return a VerifyCredentialResponse.
+ */
+ public static VerifyCredentialResponse fromError() {
+ return new VerifyCredentialResponse(RESPONSE_ERROR,
+ 0 /* timeout */,
+ null /* gatekeeperHAT */,
+ null /* gatekeeperPassword */);
}
- private VerifyCredentialResponse(int responseCode, int timeout, byte[] payload) {
+ private VerifyCredentialResponse(@ResponseCode int responseCode, int timeout,
+ @Nullable byte[] gatekeeperHAT, @Nullable byte[] gatekeeperPassword) {
mResponseCode = responseCode;
mTimeout = timeout;
- mPayload = payload;
+ mGatekeeperHAT = gatekeeperHAT;
+ mGatekeeperPw = gatekeeperPassword;
+ }
+
+ public VerifyCredentialResponse stripPayload() {
+ return new VerifyCredentialResponse(mResponseCode, mTimeout,
+ null /* gatekeeperHAT */, null /* gatekeeperPassword */);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mResponseCode);
- if (mResponseCode == RESPONSE_RETRY) {
- dest.writeInt(mTimeout);
- } else if (mResponseCode == RESPONSE_OK) {
- if (mPayload != null) {
- dest.writeInt(mPayload.length);
- dest.writeByteArray(mPayload);
- } else {
- dest.writeInt(0);
- }
- }
+ dest.writeInt(mTimeout);
+ dest.writeByteArray(mGatekeeperHAT);
+ dest.writeByteArray(mGatekeeperPw);
}
@Override
@@ -109,48 +150,51 @@
return 0;
}
- public byte[] getPayload() {
- return mPayload;
+ @Nullable
+ public byte[] getGatekeeperHAT() {
+ return mGatekeeperHAT;
+ }
+
+ @Nullable
+ public byte[] getGatekeeperPw() {
+ return mGatekeeperPw;
}
public int getTimeout() {
return mTimeout;
}
- public int getResponseCode() {
+ public @ResponseCode int getResponseCode() {
return mResponseCode;
}
- private void setTimeout(int timeout) {
- mTimeout = timeout;
+ public boolean isMatched() {
+ return mResponseCode == RESPONSE_OK;
}
- private void setPayload(byte[] payload) {
- mPayload = payload;
- }
-
- public VerifyCredentialResponse stripPayload() {
- return new VerifyCredentialResponse(mResponseCode, mTimeout, new byte[0]);
+ @Override
+ public String toString() {
+ return "Response: " + mResponseCode
+ + ", GK HAT: " + (mGatekeeperHAT != null)
+ + ", GK PW: " + (mGatekeeperPw != null);
}
public static VerifyCredentialResponse fromGateKeeperResponse(
GateKeeperResponse gateKeeperResponse) {
- VerifyCredentialResponse response;
int responseCode = gateKeeperResponse.getResponseCode();
if (responseCode == GateKeeperResponse.RESPONSE_RETRY) {
- response = new VerifyCredentialResponse(gateKeeperResponse.getTimeout());
+ return fromTimeout(gateKeeperResponse.getTimeout());
} else if (responseCode == GateKeeperResponse.RESPONSE_OK) {
byte[] token = gateKeeperResponse.getPayload();
if (token == null) {
// something's wrong if there's no payload with a challenge
Slog.e(TAG, "verifyChallenge response had no associated payload");
- response = VerifyCredentialResponse.ERROR;
+ return fromError();
} else {
- response = new VerifyCredentialResponse(token);
+ return new VerifyCredentialResponse.Builder().setGatekeeperHAT(token).build();
}
} else {
- response = VerifyCredentialResponse.ERROR;
+ return fromError();
}
- return response;
}
}
diff --git a/core/jni/android_os_SystemClock.cpp b/core/jni/android_os_SystemClock.cpp
index b1f6000..2fba445 100644
--- a/core/jni/android_os_SystemClock.cpp
+++ b/core/jni/android_os_SystemClock.cpp
@@ -37,10 +37,12 @@
static_assert(std::is_same<int64_t, jlong>::value, "jlong isn't an int64_t");
static_assert(std::is_same<decltype(uptimeMillis()), int64_t>::value,
"uptimeMillis signature change, expected int64_t return value");
+static_assert(std::is_same<decltype(uptimeNanos()), int64_t>::value,
+ "uptimeNanos signature change, expected int64_t return value");
static_assert(std::is_same<decltype(elapsedRealtime()), int64_t>::value,
- "uptimeMillis signature change, expected int64_t return value");
+ "elapsedRealtime signature change, expected int64_t return value");
static_assert(std::is_same<decltype(elapsedRealtimeNano()), int64_t>::value,
- "uptimeMillis signature change, expected int64_t return value");
+ "elapsedRealtimeNano signature change, expected int64_t return value");
/*
* native public static long currentThreadTimeMillis();
@@ -76,6 +78,7 @@
// All of these are @CriticalNative, so we can defer directly to SystemClock.h for
// some of these
{ "uptimeMillis", "()J", (void*) uptimeMillis },
+ { "uptimeNanos", "()J", (void*) uptimeNanos },
{ "elapsedRealtime", "()J", (void*) elapsedRealtime },
{ "elapsedRealtimeNanos", "()J", (void*) elapsedRealtimeNano },
diff --git a/core/jni/android_view_DisplayEventReceiver.cpp b/core/jni/android_view_DisplayEventReceiver.cpp
index e715be2..50a557bb 100644
--- a/core/jni/android_view_DisplayEventReceiver.cpp
+++ b/core/jni/android_view_DisplayEventReceiver.cpp
@@ -63,6 +63,7 @@
void dispatchHotplug(nsecs_t timestamp, PhysicalDisplayId displayId, bool connected) override;
void dispatchConfigChanged(nsecs_t timestamp, PhysicalDisplayId displayId,
int32_t configId, nsecs_t vsyncPeriod) override;
+ void dispatchNullEvent(nsecs_t timestamp, PhysicalDisplayId displayId) override {}
};
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index d6a773f..85b4fe1 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -116,7 +116,6 @@
jfieldID width;
jfieldID height;
jfieldID useIdentityTransform;
- jfieldID rotation;
} gDisplayCaptureArgsClassInfo;
static struct {
@@ -325,8 +324,6 @@
captureArgs.useIdentityTransform =
env->GetBooleanField(displayCaptureArgsObject,
gDisplayCaptureArgsClassInfo.useIdentityTransform);
- captureArgs.rotation = ui::toRotation(
- env->GetIntField(displayCaptureArgsObject, gDisplayCaptureArgsClassInfo.rotation));
return captureArgs;
}
@@ -1849,8 +1846,6 @@
GetFieldIDOrDie(env, displayCaptureArgsClazz, "mHeight", "I");
gDisplayCaptureArgsClassInfo.useIdentityTransform =
GetFieldIDOrDie(env, displayCaptureArgsClazz, "mUseIdentityTransform", "Z");
- gDisplayCaptureArgsClassInfo.rotation =
- GetFieldIDOrDie(env, displayCaptureArgsClazz, "mRotation", "I");
jclass layerCaptureArgsClazz =
FindClassOrDie(env, "android/view/SurfaceControl$LayerCaptureArgs");
diff --git a/core/jni/core_jni_helpers.h b/core/jni/core_jni_helpers.h
index eeda275..d629e0d 100644
--- a/core/jni/core_jni_helpers.h
+++ b/core/jni/core_jni_helpers.h
@@ -104,6 +104,31 @@
return std::string(defaultValue);
}
+static inline JNIEnv* GetJNIEnvironment(JavaVM* vm, jint version = JNI_VERSION_1_4) {
+ JNIEnv* env;
+ if (vm->GetEnv(reinterpret_cast<void**>(&env), version) != JNI_OK) {
+ return nullptr;
+ }
+ return env;
+}
+
+static inline JNIEnv* GetOrAttachJNIEnvironment(JavaVM* jvm, jint version = JNI_VERSION_1_4) {
+ JNIEnv* env = GetJNIEnvironment(jvm, version);
+ if (!env) {
+ int result = jvm->AttachCurrentThread(&env, nullptr);
+ LOG_ALWAYS_FATAL_IF(result != JNI_OK, "JVM thread attach failed.");
+ struct VmDetacher {
+ VmDetacher(JavaVM* vm) : mVm(vm) {}
+ ~VmDetacher() { mVm->DetachCurrentThread(); }
+
+ private:
+ JavaVM* const mVm;
+ };
+ static thread_local VmDetacher detacher(jvm);
+ }
+ return env;
+}
+
} // namespace android
#endif // CORE_JNI_HELPERS
diff --git a/core/proto/android/app/settings_enums.proto b/core/proto/android/app/settings_enums.proto
index 5b22e31..1014fbb 100644
--- a/core/proto/android/app/settings_enums.proto
+++ b/core/proto/android/app/settings_enums.proto
@@ -2698,4 +2698,9 @@
// CATEGORY: SETTINGS
// OS: S
EMERGENCY_SOS_GESTURE_SETTINGS = 1847;
+
+ // OPEN: Settings > System > Gestures > Double tap
+ // CATEGORY: SETTINGS
+ // OS: S
+ SETTINGS_COLUMBUS = 1848;
}
diff --git a/core/proto/android/app/tvsettings_enums.proto b/core/proto/android/app/tvsettings_enums.proto
index 31c5dd6..4a3c594 100644
--- a/core/proto/android/app/tvsettings_enums.proto
+++ b/core/proto/android/app/tvsettings_enums.proto
@@ -168,7 +168,11 @@
// Google Assistant > Personal results (toggle)
ACCOUNT_SLICE_REG_ACCOUNT_ASSISTANT_PERSONAL_RESULTS = 0x12134000;
- // Reserving [0x12140000, 0x12190000] for possible future settings
+ // TvSettings > Account & Sign In (Slice) > [A regular account] >
+ // Apps only mode (toggle)
+ ACCOUNT_SLICE_REG_ACCOUNT_APPS_ONLY_MODE = 0x12140000;
+
+ // Reserving [0x12150000, 0x12190000] for possible future settings
// TvSettings > Account & Sign In (Slice) > [A regular account] > Remove
ACCOUNT_SLICE_REG_ACCOUNT_REMOVE = 0x121A0000;
diff --git a/core/proto/android/server/protolog.proto b/core/proto/android/internal/protolog.proto
similarity index 98%
rename from core/proto/android/server/protolog.proto
rename to core/proto/android/internal/protolog.proto
index 34dc55b..fee7a87 100644
--- a/core/proto/android/server/protolog.proto
+++ b/core/proto/android/internal/protolog.proto
@@ -16,7 +16,7 @@
syntax = "proto2";
-package com.android.server.protolog;
+package com.android.internal.protolog;
option java_multiple_files = true;
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index fe290f3..edb9727 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1342,7 +1342,7 @@
android:priority="800" />
<!-- Allows an application to access data from sensors that the user uses to
- measure what is happening inside his/her body, such as heart rate.
+ measure what is happening inside their body, such as heart rate.
<p>Protection level: dangerous -->
<permission android:name="android.permission.BODY_SENSORS"
android:permissionGroup="android.permission-group.UNDEFINED"
diff --git a/core/res/res/values-be/strings.xml b/core/res/res/values-be/strings.xml
index cff1218..56736c0 100644
--- a/core/res/res/values-be/strings.xml
+++ b/core/res/res/values-be/strings.xml
@@ -976,7 +976,7 @@
<string name="save_password_remember" msgid="6490888932657708341">"Запомніць"</string>
<string name="save_password_never" msgid="6776808375903410659">"Ніколі"</string>
<string name="open_permission_deny" msgid="5136793905306987251">"У вас няма дазволу на адкрыццё гэтай старонкі."</string>
- <string name="text_copied" msgid="2531420577879738860">"Тэкст скапіяваны ў буфер абмену."</string>
+ <string name="text_copied" msgid="2531420577879738860">"Тэкст скапіраваны ў буфер абмену."</string>
<string name="copied" msgid="4675902854553014676">"Скапіравана"</string>
<string name="more_item_label" msgid="7419249600215749115">"Больш"</string>
<string name="prepend_shortcut_label" msgid="1743716737502867951">"Меню+"</string>
diff --git a/core/res/res/values-ca/strings.xml b/core/res/res/values-ca/strings.xml
index 2e4169e..4f55bf5 100644
--- a/core/res/res/values-ca/strings.xml
+++ b/core/res/res/values-ca/strings.xml
@@ -470,10 +470,10 @@
<string name="permdesc_wakeLock" product="tablet" msgid="2441742939101526277">"Permet que l\'aplicació impedeixi que la tauleta entri en repòs."</string>
<string name="permdesc_wakeLock" product="tv" msgid="2329298966735118796">"Permet que l\'aplicació impedeixi que el dispositiu Android TV entri en repòs."</string>
<string name="permdesc_wakeLock" product="default" msgid="3689523792074007163">"Permet que l\'aplicació impedeixi que el telèfon entri en repòs."</string>
- <string name="permlab_transmitIr" msgid="8077196086358004010">"transmissió d\'infraroigs"</string>
- <string name="permdesc_transmitIr" product="tablet" msgid="5884738958581810253">"Permet que l\'aplicació utilitzi el transmissor d\'infraroigs de la tauleta."</string>
- <string name="permdesc_transmitIr" product="tv" msgid="3278506969529173281">"Permet que l\'aplicació faci servir el transmissor d\'infraroigs del dispositiu Android TV."</string>
- <string name="permdesc_transmitIr" product="default" msgid="8484193849295581808">"Permet que l\'aplicació utilitzi el transmissor d\'infraroigs del telèfon."</string>
+ <string name="permlab_transmitIr" msgid="8077196086358004010">"transmissió d\'infrarojos"</string>
+ <string name="permdesc_transmitIr" product="tablet" msgid="5884738958581810253">"Permet que l\'aplicació utilitzi el transmissor d\'infrarojos de la tauleta."</string>
+ <string name="permdesc_transmitIr" product="tv" msgid="3278506969529173281">"Permet que l\'aplicació faci servir el transmissor d\'infrarojos del dispositiu Android TV."</string>
+ <string name="permdesc_transmitIr" product="default" msgid="8484193849295581808">"Permet que l\'aplicació utilitzi el transmissor d\'infrarojos del telèfon."</string>
<string name="permlab_setWallpaper" msgid="6959514622698794511">"establir fons de pantalla"</string>
<string name="permdesc_setWallpaper" msgid="2973996714129021397">"Permet que l\'aplicació estableixi el fons de pantalla del sistema."</string>
<string name="permlab_setWallpaperHints" msgid="1153485176642032714">"ajustament de la mida del fons de pantalla"</string>
diff --git a/core/res/res/values-es-rUS/strings.xml b/core/res/res/values-es-rUS/strings.xml
index 27ff3f0..84f3243 100644
--- a/core/res/res/values-es-rUS/strings.xml
+++ b/core/res/res/values-es-rUS/strings.xml
@@ -1937,7 +1937,7 @@
<item quantity="one">Una sugerencia de Autocompletar</item>
</plurals>
<string name="autofill_save_title" msgid="7719802414283739775">"¿Quieres guardar en "<b>"<xliff:g id="LABEL">%1$s</xliff:g>"</b>"?"</string>
- <string name="autofill_save_title_with_type" msgid="3002460014579799605">"¿Quieres guardar <xliff:g id="TYPE">%1$s</xliff:g> en "<b>"<xliff:g id="LABEL">%2$s</xliff:g>"</b>"?"</string>
+ <string name="autofill_save_title_with_type" msgid="3002460014579799605">"¿Quieres guardar la <xliff:g id="TYPE">%1$s</xliff:g> en "<b>"<xliff:g id="LABEL">%2$s</xliff:g>"</b>"?"</string>
<string name="autofill_save_title_with_2types" msgid="3783270967447869241">"¿Quieres guardar <xliff:g id="TYPE_0">%1$s</xliff:g> y <xliff:g id="TYPE_1">%2$s</xliff:g> en "<b>"<xliff:g id="LABEL">%3$s</xliff:g>"</b>"?"</string>
<string name="autofill_save_title_with_3types" msgid="6598228952100102578">"¿Quieres guardar <xliff:g id="TYPE_0">%1$s</xliff:g>, <xliff:g id="TYPE_1">%2$s</xliff:g> y <xliff:g id="TYPE_2">%3$s</xliff:g> en "<b>"<xliff:g id="LABEL">%4$s</xliff:g>"</b>"?"</string>
<string name="autofill_update_title" msgid="3630695947047069136">"¿Quieres actualizar en "<b>"<xliff:g id="LABEL">%1$s</xliff:g>"</b>"?"</string>
diff --git a/core/res/res/values-hy/strings.xml b/core/res/res/values-hy/strings.xml
index b115025..264a8fc 100644
--- a/core/res/res/values-hy/strings.xml
+++ b/core/res/res/values-hy/strings.xml
@@ -1894,7 +1894,7 @@
<string name="deprecated_target_sdk_message" msgid="5203207875657579953">"Այս հավելվածը ստեղծվել է Android-ի ավելի հին տարբերակի համար և կարող է պատշաճ չաշխատել: Ստուգեք թարմացումների առկայությունը կամ դիմեք մշակողին:"</string>
<string name="deprecated_target_sdk_app_store" msgid="8456784048558808909">"Ստուգել նոր տարբերակի առկայությունը"</string>
<string name="new_sms_notification_title" msgid="6528758221319927107">"Դուք ունեք նոր հաղորդագրություններ"</string>
- <string name="new_sms_notification_content" msgid="3197949934153460639">"Դիտելու համար բացել SMS հավելվածը"</string>
+ <string name="new_sms_notification_content" msgid="3197949934153460639">"Դիտելու համար բացել SMS-ների փոխանակման հավելվածը"</string>
<string name="profile_encrypted_title" msgid="9001208667521266472">"Որոշ գործառույթներ կարող են չաշխատել"</string>
<string name="profile_encrypted_detail" msgid="5279730442756849055">"Աշխատանքային պրոֆիլը կողպված է"</string>
<string name="profile_encrypted_message" msgid="1128512616293157802">"Հպեք՝ այն ապակողպելու համար"</string>
diff --git a/core/res/res/values-in/strings.xml b/core/res/res/values-in/strings.xml
index 688996d..085df65 100644
--- a/core/res/res/values-in/strings.xml
+++ b/core/res/res/values-in/strings.xml
@@ -866,12 +866,12 @@
<string name="lockscreen_failed_attempts_almost_glogin" product="tablet" msgid="3069635524964070596">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali salah menggambar pola pembuka kunci. Setelah <xliff:g id="NUMBER_1">%2$d</xliff:g> lagi upaya gagal, Anda akan diminta membuka kunci tablet menggunakan proses masuk Google.\n\nCoba lagi dalam <xliff:g id="NUMBER_2">%3$d</xliff:g> detik."</string>
<string name="lockscreen_failed_attempts_almost_glogin" product="tv" msgid="6399092175942158529">"Sudah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali Anda salah menggambar pola pembuka kunci. Setelah gagal <xliff:g id="NUMBER_1">%2$d</xliff:g> kali lagi, Anda akan diminta membuka kunci perangkat Android TV menggunakan login Google.\n\n Coba lagi dalam <xliff:g id="NUMBER_2">%3$d</xliff:g> detik."</string>
<string name="lockscreen_failed_attempts_almost_glogin" product="default" msgid="5691623136957148335">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali salah menggambar pola pembuka kunci. Setelah <xliff:g id="NUMBER_1">%2$d</xliff:g> lagi upaya gagal, Anda akan diminta membuka kunci ponsel menggunakan proses masuk Google.\n\nCoba lagi dalam <xliff:g id="NUMBER_2">%3$d</xliff:g> detik."</string>
- <string name="lockscreen_failed_attempts_almost_at_wipe" product="tablet" msgid="7914445759242151426">"Anda telah gagal mencoba membuka gembok tablet sebanyak <xliff:g id="NUMBER_0">%1$d</xliff:g> kali. Setelah <xliff:g id="NUMBER_1">%2$d</xliff:g> upaya gagal lagi, tablet akan disetel ulang ke setelan default pabrik dan semua data pengguna hilang."</string>
+ <string name="lockscreen_failed_attempts_almost_at_wipe" product="tablet" msgid="7914445759242151426">"Anda telah gagal mencoba membuka gembok tablet sebanyak <xliff:g id="NUMBER_0">%1$d</xliff:g> kali. Setelah <xliff:g id="NUMBER_1">%2$d</xliff:g> upaya gagal lagi, tablet akan direset ke setelan default pabrik dan semua data pengguna hilang."</string>
<string name="lockscreen_failed_attempts_almost_at_wipe" product="tv" msgid="4275591249631864248">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali gagal membuka kunci perangkat Android TV. Setelah gagal <xliff:g id="NUMBER_1">%2$d</xliff:g> kali lagi, perangkat Android TV akan direset ke default pabrik dan semua data pengguna akan hilang."</string>
- <string name="lockscreen_failed_attempts_almost_at_wipe" product="default" msgid="1166532464798446579">"Anda telah gagal mencoba membuka gembok ponsel sebanyak <xliff:g id="NUMBER_0">%1$d</xliff:g> kali. Setelah <xliff:g id="NUMBER_1">%2$d</xliff:g> upaya gagal lagi, ponsel akan disetel ulang ke setelan default pabrik dan semua data pengguna hilang."</string>
- <string name="lockscreen_failed_attempts_now_wiping" product="tablet" msgid="8682445539263683414">"Anda telah gagal mencoba membuka gembok tablet sebanyak <xliff:g id="NUMBER">%d</xliff:g> kali. Kini tablet akan disetel ulang ke setelan default pabrik."</string>
+ <string name="lockscreen_failed_attempts_almost_at_wipe" product="default" msgid="1166532464798446579">"Anda telah gagal mencoba membuka gembok ponsel sebanyak <xliff:g id="NUMBER_0">%1$d</xliff:g> kali. Setelah <xliff:g id="NUMBER_1">%2$d</xliff:g> upaya gagal lagi, ponsel akan direset ke setelan default pabrik dan semua data pengguna hilang."</string>
+ <string name="lockscreen_failed_attempts_now_wiping" product="tablet" msgid="8682445539263683414">"Anda telah gagal mencoba membuka gembok tablet sebanyak <xliff:g id="NUMBER">%d</xliff:g> kali. Kini tablet akan direset ke setelan default pabrik."</string>
<string name="lockscreen_failed_attempts_now_wiping" product="tv" msgid="2205435033340091883">"Anda telah <xliff:g id="NUMBER">%d</xliff:g> kali gagal membuka kunci perangkat Android TV. Perangkat Android TV sekarang akan direset ke default pabrik."</string>
- <string name="lockscreen_failed_attempts_now_wiping" product="default" msgid="2203704707679895487">"Anda telah gagal mencoba membuka gembok ponsel sebanyak <xliff:g id="NUMBER">%d</xliff:g> kali. Kini ponsel akan disetel ulang ke setelan default pabrik."</string>
+ <string name="lockscreen_failed_attempts_now_wiping" product="default" msgid="2203704707679895487">"Anda telah gagal mencoba membuka gembok ponsel sebanyak <xliff:g id="NUMBER">%d</xliff:g> kali. Kini ponsel akan direset ke setelan default pabrik."</string>
<string name="lockscreen_too_many_failed_attempts_countdown" msgid="6807200118164539589">"Coba lagi dalam <xliff:g id="NUMBER">%d</xliff:g> detik."</string>
<string name="lockscreen_forgot_pattern_button_text" msgid="8362442730606839031">"Lupa pola?"</string>
<string name="lockscreen_glogin_forgot_pattern" msgid="9218940117797602518">"Pembuka kunci akun"</string>
@@ -1438,7 +1438,7 @@
<string name="vpn_lockdown_config" msgid="8331697329868252169">"Ubah setelan jaringan atau VPN"</string>
<string name="upload_file" msgid="8651942222301634271">"Pilih file"</string>
<string name="no_file_chosen" msgid="4146295695162318057">"Tidak ada file yang dipilih"</string>
- <string name="reset" msgid="3865826612628171429">"Setel ulang"</string>
+ <string name="reset" msgid="3865826612628171429">"Reset"</string>
<string name="submit" msgid="862795280643405865">"Kirim"</string>
<string name="car_mode_disable_notification_title" msgid="8450693275833142896">"Aplikasi mengemudi sedang berjalan"</string>
<string name="car_mode_disable_notification_message" msgid="8954550232288567515">"Ketuk untuk keluar dari aplikasi mengemudi."</string>
@@ -1608,12 +1608,12 @@
<string name="kg_too_many_failed_pin_attempts_dialog_message" msgid="23741434207544038">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali salah mengetik PIN. \n\nCoba lagi dalam <xliff:g id="NUMBER_1">%2$d</xliff:g> detik."</string>
<string name="kg_too_many_failed_password_attempts_dialog_message" msgid="3328686432962224215">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali salah mengetik sandi. \n\nCoba lagi dalam <xliff:g id="NUMBER_1">%2$d</xliff:g> detik."</string>
<string name="kg_too_many_failed_pattern_attempts_dialog_message" msgid="7357404233979139075">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali salah menggambar pola pembuka kunci. \n\nCoba lagi dalam <xliff:g id="NUMBER_1">%2$d</xliff:g> detik."</string>
- <string name="kg_failed_attempts_almost_at_wipe" product="tablet" msgid="3479940221343361587">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali gagal saat berusaha membuka kunci tablet. Setelah <xliff:g id="NUMBER_1">%2$d</xliff:g> lagi upaya gagal, tablet akan disetel ulang ke setelan default pabrik dan semua data pengguna akan hilang."</string>
+ <string name="kg_failed_attempts_almost_at_wipe" product="tablet" msgid="3479940221343361587">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali gagal saat berusaha membuka kunci tablet. Setelah <xliff:g id="NUMBER_1">%2$d</xliff:g> lagi upaya gagal, tablet akan direset ke setelan default pabrik dan semua data pengguna akan hilang."</string>
<string name="kg_failed_attempts_almost_at_wipe" product="tv" msgid="9064457748587850217">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali gagal membuka kunci perangkat Android TV. Setelah gagal <xliff:g id="NUMBER_1">%2$d</xliff:g> kali lagi, perangkat Android TV akan direset ke default pabrik dan semua data pengguna akan hilang."</string>
- <string name="kg_failed_attempts_almost_at_wipe" product="default" msgid="5955398963754432548">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali gagal saat berusaha membuka kunci ponsel. Setelah <xliff:g id="NUMBER_1">%2$d</xliff:g> lagi upaya gagal, ponsel akan disetel ulang ke setelan default pabrik dan semua data pengguna akan hilang."</string>
- <string name="kg_failed_attempts_now_wiping" product="tablet" msgid="2299099385175083308">"Anda telah <xliff:g id="NUMBER">%d</xliff:g> kali gagal saat berusaha membuka kunci tablet. Kini tablet akan disetel ulang ke setelan default pabrik."</string>
+ <string name="kg_failed_attempts_almost_at_wipe" product="default" msgid="5955398963754432548">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali gagal saat berusaha membuka kunci ponsel. Setelah <xliff:g id="NUMBER_1">%2$d</xliff:g> lagi upaya gagal, ponsel akan direset ke setelan default pabrik dan semua data pengguna akan hilang."</string>
+ <string name="kg_failed_attempts_now_wiping" product="tablet" msgid="2299099385175083308">"Anda telah <xliff:g id="NUMBER">%d</xliff:g> kali gagal saat berusaha membuka kunci tablet. Kini tablet akan direset ke setelan default pabrik."</string>
<string name="kg_failed_attempts_now_wiping" product="tv" msgid="5045460916106267585">"Anda telah <xliff:g id="NUMBER">%d</xliff:g> kali gagal membuka kunci perangkat Android TV. Perangkat Android TV sekarang akan direset ke default pabrik."</string>
- <string name="kg_failed_attempts_now_wiping" product="default" msgid="5043730590446071189">"Anda telah <xliff:g id="NUMBER">%d</xliff:g> kali gagal saat berusaha untuk membuka kunci ponsel. Kini ponsel akan disetel ulang ke setelan default pabrik."</string>
+ <string name="kg_failed_attempts_now_wiping" product="default" msgid="5043730590446071189">"Anda telah <xliff:g id="NUMBER">%d</xliff:g> kali gagal saat berusaha untuk membuka kunci ponsel. Kini ponsel akan direset ke setelan default pabrik."</string>
<string name="kg_failed_attempts_almost_at_login" product="tablet" msgid="7086799295109717623">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali salah menggambar pola pembuka kunci. Setelah <xliff:g id="NUMBER_1">%2$d</xliff:g> lagi upaya gagal, Anda akan diminta membuka kunci tablet menggunakan akun email.\n\nCoba lagi dalam <xliff:g id="NUMBER_2">%3$d</xliff:g> detik."</string>
<string name="kg_failed_attempts_almost_at_login" product="tv" msgid="4670840383567106114">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali salah menggambar pola pembuka kunci. Setelah gagal <xliff:g id="NUMBER_1">%2$d</xliff:g> kali lagi, Anda akan diminta membuka kunci perangkat Android TV menggunakan akun email.\n\n Coba lagi dalam <xliff:g id="NUMBER_2">%3$d</xliff:g> detik."</string>
<string name="kg_failed_attempts_almost_at_login" product="default" msgid="5270861875006378092">"Anda telah <xliff:g id="NUMBER_0">%1$d</xliff:g> kali salah menggambar pola pembuka kunci. Setelah <xliff:g id="NUMBER_1">%2$d</xliff:g> lagi upaya gagal, Anda akan diminta membuka kunci ponsel menggunakan akun email.\n\nCoba lagi dalam <xliff:g id="NUMBER_2">%3$d</xliff:g> detik."</string>
@@ -1907,7 +1907,7 @@
<string name="app_info" msgid="6113278084877079851">"Info aplikasi"</string>
<string name="negative_duration" msgid="1938335096972945232">"−<xliff:g id="TIME">%1$s</xliff:g>"</string>
<string name="demo_starting_message" msgid="6577581216125805905">"Memulai demo..."</string>
- <string name="demo_restarting_message" msgid="1160053183701746766">"Menyetel ulang perangkat..."</string>
+ <string name="demo_restarting_message" msgid="1160053183701746766">"Mereset perangkat..."</string>
<string name="suspended_widget_accessibility" msgid="6331451091851326101">"<xliff:g id="LABEL">%1$s</xliff:g> dinonaktifkan"</string>
<string name="conference_call" msgid="5731633152336490471">"Konferensi Telepon"</string>
<string name="tooltip_popup_title" msgid="7863719020269945722">"Keterangan alat"</string>
diff --git a/core/res/res/values-it/strings.xml b/core/res/res/values-it/strings.xml
index 400c44a..14bfa03 100644
--- a/core/res/res/values-it/strings.xml
+++ b/core/res/res/values-it/strings.xml
@@ -1937,7 +1937,7 @@
<item quantity="one">Un suggerimento di Compilazione automatica</item>
</plurals>
<string name="autofill_save_title" msgid="7719802414283739775">"Vuoi salvare su "<b>"<xliff:g id="LABEL">%1$s</xliff:g>"</b>"?"</string>
- <string name="autofill_save_title_with_type" msgid="3002460014579799605">"Vuoi salvare <xliff:g id="TYPE">%1$s</xliff:g> su "<b>"<xliff:g id="LABEL">%2$s</xliff:g>"</b>"?"</string>
+ <string name="autofill_save_title_with_type" msgid="3002460014579799605">"Vuoi salvare la <xliff:g id="TYPE">%1$s</xliff:g> su "<b>"<xliff:g id="LABEL">%2$s</xliff:g>"</b>"?"</string>
<string name="autofill_save_title_with_2types" msgid="3783270967447869241">"Vuoi salvare <xliff:g id="TYPE_0">%1$s</xliff:g> e <xliff:g id="TYPE_1">%2$s</xliff:g> su "<b>"<xliff:g id="LABEL">%3$s</xliff:g>"</b>"?"</string>
<string name="autofill_save_title_with_3types" msgid="6598228952100102578">"Vuoi salvare <xliff:g id="TYPE_0">%1$s</xliff:g>, <xliff:g id="TYPE_1">%2$s</xliff:g> e <xliff:g id="TYPE_2">%3$s</xliff:g> su "<b>"<xliff:g id="LABEL">%4$s</xliff:g>"</b>"?"</string>
<string name="autofill_update_title" msgid="3630695947047069136">"Vuoi aggiornare su "<b>"<xliff:g id="LABEL">%1$s</xliff:g>"</b>"?"</string>
diff --git a/core/res/res/values-iw/strings.xml b/core/res/res/values-iw/strings.xml
index 2c42745..2b6d226 100644
--- a/core/res/res/values-iw/strings.xml
+++ b/core/res/res/values-iw/strings.xml
@@ -1202,7 +1202,7 @@
<string name="aerr_application_repeated" msgid="7804378743218496566">"האפליקציה <xliff:g id="APPLICATION">%1$s</xliff:g> נעצרת שוב ושוב"</string>
<string name="aerr_process_repeated" msgid="1153152413537954974">"האפליקציה <xliff:g id="PROCESS">%1$s</xliff:g> נעצרת שוב ושוב"</string>
<string name="aerr_restart" msgid="2789618625210505419">"פתח שוב את האפליקציה"</string>
- <string name="aerr_report" msgid="3095644466849299308">"משוב"</string>
+ <string name="aerr_report" msgid="3095644466849299308">"שליחת משוב"</string>
<string name="aerr_close" msgid="3398336821267021852">"סגירה"</string>
<string name="aerr_mute" msgid="2304972923480211376">"השתק עד הפעלה מחדש של המכשיר"</string>
<string name="aerr_wait" msgid="3198677780474548217">"המתן"</string>
diff --git a/core/res/res/values-ne/strings.xml b/core/res/res/values-ne/strings.xml
index fd7b1b2..bb79c21 100644
--- a/core/res/res/values-ne/strings.xml
+++ b/core/res/res/values-ne/strings.xml
@@ -1633,7 +1633,7 @@
<string name="accessibility_shortcut_menu_item_status_off" msgid="5531598275559472393">"निष्क्रिय"</string>
<string name="accessibility_enable_service_title" msgid="3931558336268541484">"<xliff:g id="SERVICE">%1$s</xliff:g> लाई तपाईंको यन्त्र पूर्ण रूपमा नियन्त्रण गर्न दिने हो?"</string>
<string name="accessibility_enable_service_encryption_warning" msgid="8603532708618236909">"तपाईंले <xliff:g id="SERVICE">%1$s</xliff:g> सक्रिय गर्नुभयो भने तपाईंको यन्त्रले डेटा इन्क्रिप्ट गर्ने सुविधाको स्तरोन्नति गर्न तपाईंको स्क्रिन लक सुविधाको प्रयोग गर्ने छैन।"</string>
- <string name="accessibility_service_warning_description" msgid="291674995220940133">"तपाईंलाई पहुँच राख्न आवश्यक पर्ने कुरामा सहयोग गर्ने अनुप्रयोगहरूमाथि पूर्ण नियन्त्रण गर्नु उपयुक्त हुन्छ तर अधिकांश अनुप्रयोगहरूका हकमा यस्तो नियन्त्रण उपयुक्त हुँदैन।"</string>
+ <string name="accessibility_service_warning_description" msgid="291674995220940133">"तपाईंलाई पहुँच राख्न आवश्यक पर्ने कुरामा सहयोग गर्ने एपमाथि पूर्ण नियन्त्रण गर्नु उपयुक्त हुन्छ तर अधिकांश अनुप्रयोगहरूका हकमा यस्तो नियन्त्रण उपयुक्त हुँदैन।"</string>
<string name="accessibility_service_screen_control_title" msgid="190017412626919776">"स्क्रिन हेर्नुहोस् र नियन्त्रण गर्नुहोस्"</string>
<string name="accessibility_service_screen_control_description" msgid="6946315917771791525">"यसले स्क्रिनमा देखिने सबै सामग्री पढ्न सक्छ र अन्य एपहरूमा उक्त सामग्री देखाउन सक्छ।"</string>
<string name="accessibility_service_action_perform_title" msgid="779670378951658160">"कारबाहीहरू हेर्नुहोस् र तिनमा कार्य गर्नुहोस्"</string>
diff --git a/core/res/res/values-sl/strings.xml b/core/res/res/values-sl/strings.xml
index 9f23a76..3ef51a7 100644
--- a/core/res/res/values-sl/strings.xml
+++ b/core/res/res/values-sl/strings.xml
@@ -1165,7 +1165,7 @@
<string name="capital_off" msgid="7443704171014626777">"IZKLOPLJENO"</string>
<string name="checked" msgid="9179896827054513119">"potrjeno"</string>
<string name="not_checked" msgid="7972320087569023342">"ni potrjeno"</string>
- <string name="whichApplication" msgid="5432266899591255759">"Dokončanje dejanja z"</string>
+ <string name="whichApplication" msgid="5432266899591255759">"Dokončanje dejanja z aplikacijo"</string>
<string name="whichApplicationNamed" msgid="6969946041713975681">"Dokončanje dejanja z aplikacijo %1$s"</string>
<string name="whichApplicationLabel" msgid="7852182961472531728">"Izvedba dejanja"</string>
<string name="whichViewApplication" msgid="5733194231473132945">"Odpiranje z aplikacijo"</string>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 8913e8b..f99be88 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1823,6 +1823,8 @@
<string name="config_defaultCallScreening" translatable="false"></string>
<!-- The name of the package that will hold the system gallery role. -->
<string name="config_systemGallery" translatable="false">com.android.gallery3d</string>
+ <!-- The name of the package that will hold the system cluster service role. -->
+ <string name="config_systemAutomotiveCluster" translatable="false"></string>
<!-- The name of the package that will be allowed to change its components' label/icon. -->
<string name="config_overrideComponentUiPackage" translatable="false"></string>
diff --git a/core/res/res/values/donottranslate.xml b/core/res/res/values/donottranslate.xml
index 3a1679c..f46f70c 100644
--- a/core/res/res/values/donottranslate.xml
+++ b/core/res/res/values/donottranslate.xml
@@ -23,7 +23,7 @@
<!-- @hide DO NOT TRANSLATE. Control aspect ratio of lock pattern -->
<string name="lock_pattern_view_aspect">square</string>
<!-- @hide DO NOT TRANSLATE. ICU pattern for "Mon, 14 January" -->
- <string name="icu_abbrev_wday_month_day_no_year">eeeMMMMd</string>
+ <string name="icu_abbrev_wday_month_day_no_year">EEEMMMMd</string>
<!-- @hide DO NOT TRANSLATE. date formatting pattern for system ui.-->
<string name="system_ui_date_pattern">@string/icu_abbrev_wday_month_day_no_year</string>
<!-- @hide DO NOT TRANSLATE Spans within this text are applied to style composing regions
diff --git a/core/res/res/values/ids.xml b/core/res/res/values/ids.xml
index bddda1b..f77c6f9 100644
--- a/core/res/res/values/ids.xml
+++ b/core/res/res/values/ids.xml
@@ -197,6 +197,9 @@
<!-- Marks the "copy to clipboard" button in the ChooserActivity -->
<item type="id" name="chooser_copy_button" />
+ <!-- Marks the "nearby" button in the ChooserActivity -->
+ <item type="id" name="chooser_nearby_button" />
+
<!-- Accessibility action identifier for {@link android.accessibilityservice.AccessibilityService#GLOBAL_ACTION_BACK}. -->
<item type="id" name="accessibilitySystemActionBack" />
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 303fde6..1e2d554 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -3069,7 +3069,8 @@
</public-group>
<public-group type="string" first-id="0x01040028">
- <!-- string definitions go here -->
+ <!-- @hide @SystemApi @TestApi -->
+ <public name="config_systemAutomotiveCluster" />
</public-group>
<public-group type="id" first-id="0x01020055">
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index d5c72da..040fad5 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -3841,6 +3841,7 @@
<java-symbol type="layout" name="chooser_dialog_item" />
<java-symbol type="drawable" name="chooser_dialog_background" />
<java-symbol type="id" name="chooser_copy_button" />
+ <java-symbol type="id" name="chooser_nearby_button" />
<java-symbol type="layout" name="chooser_action_button" />
<java-symbol type="dimen" name="chooser_action_button_icon_size" />
<java-symbol type="string" name="config_defaultNearbySharingComponent" />
diff --git a/core/tests/coretests/src/android/app/WindowContextTest.java b/core/tests/coretests/src/android/app/WindowContextTest.java
index 630e16a..0f9bc4b 100644
--- a/core/tests/coretests/src/android/app/WindowContextTest.java
+++ b/core/tests/coretests/src/android/app/WindowContextTest.java
@@ -30,7 +30,6 @@
import android.view.IWindowManager;
import android.view.WindowManagerGlobal;
-import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
@@ -47,7 +46,6 @@
* <p>This test class is a part of Window Manager Service tests and specified in
* {@link com.android.server.wm.test.filters.FrameworksTestsFilter}.
*/
-@FlakyTest(bugId = 150812449, detail = "Remove after confirmed it's stable.")
@RunWith(AndroidJUnit4.class)
@SmallTest
@Presubmit
diff --git a/core/tests/coretests/src/android/app/backup/BackupAgentTest.java b/core/tests/coretests/src/android/app/backup/BackupAgentTest.java
new file mode 100644
index 0000000..ea903f2
--- /dev/null
+++ b/core/tests/coretests/src/android/app/backup/BackupAgentTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+
+package android.app.backup;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.app.backup.BackupAgent.IncludeExcludeRules;
+import android.app.backup.BackupManager.OperationType;
+import android.app.backup.FullBackup.BackupScheme.PathWithRequiredFlags;
+import android.os.ParcelFileDescriptor;
+import android.os.UserHandle;
+import android.platform.test.annotations.Presubmit;
+import android.util.ArraySet;
+
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+@Presubmit
+@RunWith(AndroidJUnit4.class)
+public class BackupAgentTest {
+ // An arbitrary user.
+ private static final UserHandle USER_HANDLE = new UserHandle(15);
+
+ @Mock FullBackup.BackupScheme mBackupScheme;
+
+ private BackupAgent mBackupAgent;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testGetIncludeExcludeRules_isMigration_returnsEmptyRules() throws Exception {
+ mBackupAgent = getAgentForOperationType(OperationType.MIGRATION);
+
+ IncludeExcludeRules rules = mBackupAgent.getIncludeExcludeRules(mBackupScheme);
+ assertThat(rules).isEqualTo(IncludeExcludeRules.emptyRules());
+ }
+
+ @Test
+ public void testGetIncludeExcludeRules_isNotMigration_returnsRules() throws Exception {
+ PathWithRequiredFlags path = new PathWithRequiredFlags("path", /* requiredFlags */ 0);
+ Map<String, Set<PathWithRequiredFlags>> includePaths = Collections.singletonMap("test",
+ Collections.singleton(path));
+ ArraySet<PathWithRequiredFlags> excludePaths = new ArraySet<>();
+ excludePaths.add(path);
+ IncludeExcludeRules expectedRules = new IncludeExcludeRules(includePaths, excludePaths);
+
+ mBackupAgent = getAgentForOperationType(OperationType.BACKUP);
+ when(mBackupScheme.maybeParseAndGetCanonicalExcludePaths()).thenReturn(excludePaths);
+ when(mBackupScheme.maybeParseAndGetCanonicalIncludePaths()).thenReturn(includePaths);
+
+ IncludeExcludeRules rules = mBackupAgent.getIncludeExcludeRules(mBackupScheme);
+ assertThat(rules).isEqualTo(expectedRules);
+ }
+
+ private BackupAgent getAgentForOperationType(@OperationType int operationType) {
+ BackupAgent agent = new TestFullBackupAgent();
+ agent.onCreate(USER_HANDLE, operationType);
+ return agent;
+ }
+
+ private static class TestFullBackupAgent extends BackupAgent {
+
+ @Override
+ public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
+ ParcelFileDescriptor newState) throws IOException {
+ // Left empty as this is a full backup agent.
+ }
+
+ @Override
+ public void onRestore(BackupDataInput data, int appVersionCode,
+ ParcelFileDescriptor newState) throws IOException {
+ // Left empty as this is a full backup agent.
+ }
+ }
+}
diff --git a/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java b/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java
index ea8df83..2bf9848 100644
--- a/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java
+++ b/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java
@@ -495,7 +495,8 @@
@Override
public void scheduleCreateBackupAgent(ApplicationInfo applicationInfo,
- CompatibilityInfo compatibilityInfo, int i, int userId) throws RemoteException {
+ CompatibilityInfo compatibilityInfo, int i, int userId, int operatioType)
+ throws RemoteException {
}
@Override
diff --git a/core/tests/coretests/src/android/app/timezonedetector/TimeZoneCapabilitiesTest.java b/core/tests/coretests/src/android/app/timezonedetector/TimeZoneCapabilitiesTest.java
index 8a36f1d..72391f4 100644
--- a/core/tests/coretests/src/android/app/timezonedetector/TimeZoneCapabilitiesTest.java
+++ b/core/tests/coretests/src/android/app/timezonedetector/TimeZoneCapabilitiesTest.java
@@ -33,9 +33,11 @@
public void testEquals() {
TimeZoneCapabilities.Builder builder1 = new TimeZoneCapabilities.Builder(ARBITRARY_USER_ID)
.setConfigureAutoDetectionEnabled(CAPABILITY_POSSESSED)
+ .setConfigureGeoDetectionEnabled(CAPABILITY_POSSESSED)
.setSuggestManualTimeZone(CAPABILITY_POSSESSED);
TimeZoneCapabilities.Builder builder2 = new TimeZoneCapabilities.Builder(ARBITRARY_USER_ID)
.setConfigureAutoDetectionEnabled(CAPABILITY_POSSESSED)
+ .setConfigureGeoDetectionEnabled(CAPABILITY_POSSESSED)
.setSuggestManualTimeZone(CAPABILITY_POSSESSED);
{
TimeZoneCapabilities one = builder1.build();
@@ -57,6 +59,20 @@
assertEquals(one, two);
}
+ builder2.setConfigureGeoDetectionEnabled(CAPABILITY_NOT_ALLOWED);
+ {
+ TimeZoneCapabilities one = builder1.build();
+ TimeZoneCapabilities two = builder2.build();
+ assertNotEquals(one, two);
+ }
+
+ builder1.setConfigureGeoDetectionEnabled(CAPABILITY_NOT_ALLOWED);
+ {
+ TimeZoneCapabilities one = builder1.build();
+ TimeZoneCapabilities two = builder2.build();
+ assertEquals(one, two);
+ }
+
builder2.setSuggestManualTimeZone(CAPABILITY_NOT_ALLOWED);
{
TimeZoneCapabilities one = builder1.build();
@@ -76,12 +92,16 @@
public void testParcelable() {
TimeZoneCapabilities.Builder builder = new TimeZoneCapabilities.Builder(ARBITRARY_USER_ID)
.setConfigureAutoDetectionEnabled(CAPABILITY_POSSESSED)
+ .setConfigureGeoDetectionEnabled(CAPABILITY_POSSESSED)
.setSuggestManualTimeZone(CAPABILITY_POSSESSED);
assertRoundTripParcelable(builder.build());
builder.setConfigureAutoDetectionEnabled(CAPABILITY_NOT_ALLOWED);
assertRoundTripParcelable(builder.build());
+ builder.setConfigureGeoDetectionEnabled(CAPABILITY_NOT_ALLOWED);
+ assertRoundTripParcelable(builder.build());
+
builder.setSuggestManualTimeZone(CAPABILITY_NOT_ALLOWED);
assertRoundTripParcelable(builder.build());
}
diff --git a/core/tests/coretests/src/android/app/timezonedetector/TimeZoneConfigurationTest.java b/core/tests/coretests/src/android/app/timezonedetector/TimeZoneConfigurationTest.java
index ac7e9c4..00dc73e 100644
--- a/core/tests/coretests/src/android/app/timezonedetector/TimeZoneConfigurationTest.java
+++ b/core/tests/coretests/src/android/app/timezonedetector/TimeZoneConfigurationTest.java
@@ -29,8 +29,9 @@
@Test
public void testBuilder_copyConstructor() {
- TimeZoneConfiguration.Builder builder1 =
- new TimeZoneConfiguration.Builder().setAutoDetectionEnabled(true);
+ TimeZoneConfiguration.Builder builder1 = new TimeZoneConfiguration.Builder()
+ .setAutoDetectionEnabled(true)
+ .setGeoDetectionEnabled(true);
TimeZoneConfiguration configuration1 = builder1.build();
TimeZoneConfiguration configuration2 =
@@ -41,16 +42,15 @@
@Test
public void testIsComplete() {
- TimeZoneConfiguration incompleteConfiguration =
- new TimeZoneConfiguration.Builder()
- .build();
- assertFalse(incompleteConfiguration.isComplete());
+ TimeZoneConfiguration.Builder builder =
+ new TimeZoneConfiguration.Builder();
+ assertFalse(builder.build().isComplete());
- TimeZoneConfiguration completeConfiguration =
- new TimeZoneConfiguration.Builder()
- .setAutoDetectionEnabled(true)
- .build();
- assertTrue(completeConfiguration.isComplete());
+ builder.setAutoDetectionEnabled(true);
+ assertFalse(builder.build().isComplete());
+
+ builder.setGeoDetectionEnabled(true);
+ assertTrue(builder.build().isComplete());
}
@Test
@@ -122,6 +122,27 @@
TimeZoneConfiguration two = builder2.build();
assertEquals(one, two);
}
+
+ builder1.setGeoDetectionEnabled(true);
+ {
+ TimeZoneConfiguration one = builder1.build();
+ TimeZoneConfiguration two = builder2.build();
+ assertNotEquals(one, two);
+ }
+
+ builder2.setGeoDetectionEnabled(false);
+ {
+ TimeZoneConfiguration one = builder1.build();
+ TimeZoneConfiguration two = builder2.build();
+ assertNotEquals(one, two);
+ }
+
+ builder1.setGeoDetectionEnabled(false);
+ {
+ TimeZoneConfiguration one = builder1.build();
+ TimeZoneConfiguration two = builder2.build();
+ assertEquals(one, two);
+ }
}
@Test
@@ -135,5 +156,11 @@
builder.setAutoDetectionEnabled(false);
assertRoundTripParcelable(builder.build());
+
+ builder.setGeoDetectionEnabled(false);
+ assertRoundTripParcelable(builder.build());
+
+ builder.setGeoDetectionEnabled(true);
+ assertRoundTripParcelable(builder.build());
}
}
diff --git a/core/tests/coretests/src/android/view/WindowMetricsTest.java b/core/tests/coretests/src/android/view/WindowMetricsTest.java
index ddc977d..96df9dd 100644
--- a/core/tests/coretests/src/android/view/WindowMetricsTest.java
+++ b/core/tests/coretests/src/android/view/WindowMetricsTest.java
@@ -27,7 +27,6 @@
import android.os.Handler;
import android.platform.test.annotations.Presubmit;
-import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
@@ -46,7 +45,6 @@
* <p>This test class is a part of Window Manager Service tests and specified in
* {@link com.android.server.wm.test.filters.FrameworksTestsFilter}.
*/
-@FlakyTest(bugId = 148789183, detail = "Remove after confirmed it's stable.")
@RunWith(AndroidJUnit4.class)
@SmallTest
@Presubmit
diff --git a/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java b/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java
index 090645f..787879a 100644
--- a/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java
+++ b/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java
@@ -590,6 +590,54 @@
is(1));
}
+
+ @Test
+ public void testNearbyShareLogging() throws Exception {
+ Intent sendIntent = createSendTextIntent();
+ List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2);
+
+ when(ChooserWrapperActivity.sOverrides.resolverListController.getResolversForIntent(
+ Mockito.anyBoolean(),
+ Mockito.anyBoolean(),
+ Mockito.isA(List.class))).thenReturn(resolvedComponentInfos);
+
+ final ChooserWrapperActivity activity = mActivityRule
+ .launchActivity(Intent.createChooser(sendIntent, null));
+ waitForIdle();
+
+ onView(withId(R.id.chooser_nearby_button)).check(matches(isDisplayed()));
+ onView(withId(R.id.chooser_nearby_button)).perform(click());
+
+ ChooserActivityLoggerFake logger =
+ (ChooserActivityLoggerFake) activity.getChooserActivityLogger();
+ assertThat(logger.numCalls(), is(6));
+ // first one should be SHARESHEET_TRIGGERED uievent
+ assertThat(logger.get(0).atomId, is(FrameworkStatsLog.UI_EVENT_REPORTED));
+ assertThat(logger.get(0).event.getId(),
+ is(ChooserActivityLogger.SharesheetStandardEvent.SHARESHEET_TRIGGERED.getId()));
+ // second one should be SHARESHEET_STARTED event
+ assertThat(logger.get(1).atomId, is(FrameworkStatsLog.SHARESHEET_STARTED));
+ assertThat(logger.get(1).intent, is(Intent.ACTION_SEND));
+ assertThat(logger.get(1).mimeType, is("text/plain"));
+ assertThat(logger.get(1).packageName, is("com.android.frameworks.coretests"));
+ assertThat(logger.get(1).appProvidedApp, is(0));
+ assertThat(logger.get(1).appProvidedDirect, is(0));
+ assertThat(logger.get(1).isWorkprofile, is(false));
+ assertThat(logger.get(1).previewType, is(3));
+ // third one should be SHARESHEET_APP_LOAD_COMPLETE uievent
+ assertThat(logger.get(2).atomId, is(FrameworkStatsLog.UI_EVENT_REPORTED));
+ assertThat(logger.get(2).event.getId(),
+ is(ChooserActivityLogger
+ .SharesheetStandardEvent.SHARESHEET_APP_LOAD_COMPLETE.getId()));
+ // fourth and fifth are just artifacts of test set-up
+ // sixth one should be ranking atom with SHARESHEET_NEARBY_TARGET_SELECTED event
+ assertThat(logger.get(5).atomId, is(FrameworkStatsLog.RANKING_SELECTED));
+ assertThat(logger.get(5).targetType,
+ is(ChooserActivityLogger
+ .SharesheetTargetSelectedEvent.SHARESHEET_NEARBY_TARGET_SELECTED.getId()));
+ }
+
+
@Test
public void oneVisibleImagePreview() throws InterruptedException {
Uri uri = Uri.parse("android.resource://com.android.frameworks.coretests/"
diff --git a/core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java b/core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java
index d3d5caf..16a2fbd 100644
--- a/core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java
+++ b/core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java
@@ -21,6 +21,7 @@
import android.annotation.Nullable;
import android.app.usage.UsageStatsManager;
+import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -89,6 +90,18 @@
boolean getIsSelected() { return mIsSuccessfullySelected; }
+ @Override
+ protected ComponentName getNearbySharingComponent() {
+ // an arbitrary pre-installed activity that handles this type of intent
+ return ComponentName.unflattenFromString("com.google.android.apps.messaging/"
+ + "com.google.android.apps.messaging.ui.conversationlist.ShareIntentActivity");
+ }
+
+ @Override
+ protected TargetInfo getNearbySharingTarget(Intent originalIntent) {
+ return new ChooserWrapperActivity.EmptyTargetInfo();
+ }
+
UsageStatsManager getUsageStatsManager() {
if (mUsm == null) {
mUsm = (UsageStatsManager) getSystemService(Context.USAGE_STATS_SERVICE);
diff --git a/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java b/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java
index 188ba9e..96250db 100644
--- a/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java
+++ b/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java
@@ -20,6 +20,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import android.os.Binder;
import android.os.Handler;
@@ -44,6 +45,7 @@
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
@@ -493,7 +495,9 @@
bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE, WORKSOURCE_UID);
PrintWriter pw = new PrintWriter(new StringWriter());
- bcs.dump(pw, new AppIdToPackageMap(new HashMap<>()), true);
+ bcs.dump(pw, new AppIdToPackageMap(new HashMap<>()), Process.INVALID_UID, true);
+
+ bcs.dump(pw, new AppIdToPackageMap(new HashMap<>()), WORKSOURCE_UID, true);
}
@Test
@@ -606,8 +610,8 @@
assertEquals("-1", callStats.methodName);
assertEquals("com.android.internal.os.BinderCallsStats$OverflowBinder",
callStats.className);
- assertEquals(false , callStats.screenInteractive);
- assertEquals(-1 , callStats.callingUid);
+ assertEquals(false, callStats.screenInteractive);
+ assertEquals(-1, callStats.callingUid);
}
@Test
@@ -785,7 +789,7 @@
bcs.time += 30;
bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE, WORKSOURCE_UID);
- for (Runnable runnable: mHandler.mRunnables) {
+ for (Runnable runnable : mHandler.mRunnables) {
// Execute all pending runnables. Ignore the delay.
runnable.run();
}
@@ -839,6 +843,53 @@
assertEquals(3, tids[2]);
}
+ @Test
+ public void testTrackingSpecificWorksourceUid() {
+ mDeviceState.setCharging(true);
+
+ Binder binder = new Binder();
+
+ TestBinderCallsStats bcs = new TestBinderCallsStats();
+ bcs.recordAllCallsForWorkSourceUid(WORKSOURCE_UID);
+
+ int[] transactions = {41, 42, 43, 42, 43, 43};
+ int[] durationsMs = {100, 200, 300, 400, 500, 600};
+
+ for (int i = 0; i < transactions.length; i++) {
+ CallSession callSession = bcs.callStarted(binder, transactions[i], WORKSOURCE_UID);
+ bcs.time += durationsMs[i];
+ bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE, WORKSOURCE_UID);
+ }
+
+ BinderCallsStats.UidEntry uidEntry = bcs.getUidEntries().get(WORKSOURCE_UID);
+ Assert.assertNotNull(uidEntry);
+ assertEquals(6, uidEntry.callCount);
+
+ Collection<BinderCallsStats.CallStat> callStatsList = uidEntry.getCallStatsList();
+ assertEquals(3, callStatsList.size());
+ for (BinderCallsStats.CallStat callStat : callStatsList) {
+ switch (callStat.transactionCode) {
+ case 41:
+ assertEquals(1, callStat.callCount);
+ assertEquals(1, callStat.incrementalCallCount);
+ assertEquals(100, callStat.cpuTimeMicros);
+ break;
+ case 42:
+ assertEquals(2, callStat.callCount);
+ assertEquals(2, callStat.incrementalCallCount);
+ assertEquals(200 + 400, callStat.cpuTimeMicros);
+ break;
+ case 43:
+ assertEquals(3, callStat.callCount);
+ assertEquals(3, callStat.incrementalCallCount);
+ assertEquals(300 + 500 + 600, callStat.cpuTimeMicros);
+ break;
+ default:
+ fail("Unexpected transaction code: " + callStat.transactionCode);
+ }
+ }
+ }
+
private static class TestHandler extends Handler {
ArrayList<Runnable> mRunnables = new ArrayList<>();
diff --git a/data/keyboards/Generic.kl b/data/keyboards/Generic.kl
index 5711f98..bd2d4af 100644
--- a/data/keyboards/Generic.kl
+++ b/data/keyboards/Generic.kl
@@ -345,10 +345,10 @@
# key 395 "KEY_LIST"
# key 396 "KEY_MEMO"
key 397 CALENDAR
-# key 398 "KEY_RED"
-# key 399 "KEY_GREEN"
-# key 400 "KEY_YELLOW"
-# key 401 "KEY_BLUE"
+key 398 PROG_RED
+key 399 PROG_GREEN
+key 400 PROG_YELLOW
+key 401 PROG_BLUE
key 402 CHANNEL_UP
key 403 CHANNEL_DOWN
# key 404 "KEY_FIRST"
diff --git a/framework-jarjar-rules.txt b/framework-jarjar-rules.txt
index d8af726..70dedb8 100644
--- a/framework-jarjar-rules.txt
+++ b/framework-jarjar-rules.txt
@@ -1,2 +1,6 @@
rule android.hidl.** android.internal.hidl.@1
rule android.net.wifi.WifiAnnotations* android.internal.wifi.WifiAnnotations@1
+
+# Hide media mainline module implementation classes to avoid collisions with
+# app-bundled ExoPlayer classes.
+rule com.google.android.exoplayer2.** android.media.internal.exo.@1
diff --git a/graphics/java/android/graphics/HardwareRenderer.java b/graphics/java/android/graphics/HardwareRenderer.java
index b3103fd5..0452933 100644
--- a/graphics/java/android/graphics/HardwareRenderer.java
+++ b/graphics/java/android/graphics/HardwareRenderer.java
@@ -634,6 +634,19 @@
}
/**
+ * Sets the colormode with the desired SDR white point.
+ *
+ * The white point only applies if the color mode is an HDR mode
+ *
+ * @hide
+ */
+ public void setColorMode(@ActivityInfo.ColorMode int colorMode, float whitePoint) {
+ nSetSdrWhitePoint(mNativeProxy, whitePoint);
+ mColorMode = colorMode;
+ nSetColorMode(mNativeProxy, colorMode);
+ }
+
+ /**
* Blocks until all previously queued work has completed.
*
* TODO: Only used for draw finished listeners, but the FrameCompleteCallback does that
@@ -1227,6 +1240,8 @@
private static native void nSetColorMode(long nativeProxy, int colorMode);
+ private static native void nSetSdrWhitePoint(long nativeProxy, float whitePoint);
+
private static native int nSyncAndDrawFrame(long nativeProxy, long[] frameInfo, int size);
private static native void nDestroy(long nativeProxy, long rootRenderNode);
diff --git a/libs/hwui/OWNERS b/libs/hwui/OWNERS
index 936ba5c..c232d13 100644
--- a/libs/hwui/OWNERS
+++ b/libs/hwui/OWNERS
@@ -1,6 +1,7 @@
+alecmouri@google.com
+djsollen@google.com
jreck@google.com
njawad@google.com
-djsollen@google.com
-stani@google.com
-scroggo@google.com
reed@google.com
+scroggo@google.com
+stani@google.com
diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp
index 446e81e..ba44d05 100644
--- a/libs/hwui/Properties.cpp
+++ b/libs/hwui/Properties.cpp
@@ -78,6 +78,7 @@
int Properties::contextPriority = 0;
int Properties::defaultRenderAhead = -1;
+float Properties::defaultSdrWhitePoint = 200.f;
bool Properties::load() {
bool prevDebugLayersUpdates = debugLayersUpdates;
diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h
index c8f6b3b..85a0f4a 100644
--- a/libs/hwui/Properties.h
+++ b/libs/hwui/Properties.h
@@ -249,6 +249,8 @@
static int defaultRenderAhead;
+ static float defaultSdrWhitePoint;
+
private:
static ProfileType sProfileType;
static bool sDisableProfileBars;
diff --git a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
index 7d6875f..fc594da 100644
--- a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
+++ b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
@@ -223,6 +223,11 @@
proxy->setColorMode(static_cast<ColorMode>(colorMode));
}
+static void android_view_ThreadedRenderer_setSdrWhitePoint(JNIEnv* env, jobject clazz,
+ jlong proxyPtr, jfloat sdrWhitePoint) {
+ Properties::defaultSdrWhitePoint = sdrWhitePoint;
+}
+
static int android_view_ThreadedRenderer_syncAndDrawFrame(JNIEnv* env, jobject clazz,
jlong proxyPtr, jlongArray frameInfo, jint frameInfoSize) {
LOG_ALWAYS_FATAL_IF(frameInfoSize != UI_THREAD_FRAME_INFO_SIZE,
@@ -671,6 +676,7 @@
{"nSetLightGeometry", "(JFFFF)V", (void*)android_view_ThreadedRenderer_setLightGeometry},
{"nSetOpaque", "(JZ)V", (void*)android_view_ThreadedRenderer_setOpaque},
{"nSetColorMode", "(JI)V", (void*)android_view_ThreadedRenderer_setColorMode},
+ {"nSetSdrWhitePoint", "(JF)V", (void*)android_view_ThreadedRenderer_setSdrWhitePoint},
{"nSyncAndDrawFrame", "(J[JI)I", (void*)android_view_ThreadedRenderer_syncAndDrawFrame},
{"nDestroy", "(JJ)V", (void*)android_view_ThreadedRenderer_destroy},
{"nRegisterAnimatingRenderNode", "(JJ)V",
diff --git a/libs/hwui/service/GraphicsStatsService.cpp b/libs/hwui/service/GraphicsStatsService.cpp
index 644d5fb..e419801 100644
--- a/libs/hwui/service/GraphicsStatsService.cpp
+++ b/libs/hwui/service/GraphicsStatsService.cpp
@@ -559,6 +559,7 @@
AStatsEvent_writeBool(event, !lastFullDay);
AStatsEvent_build(event);
}
+ delete dump;
}
diff --git a/libs/hwui/utils/Color.cpp b/libs/hwui/utils/Color.cpp
index eff34a8..87512f0 100644
--- a/libs/hwui/utils/Color.cpp
+++ b/libs/hwui/utils/Color.cpp
@@ -26,6 +26,7 @@
#include <algorithm>
#include <cmath>
+#include <Properties.h>
namespace android {
namespace uirenderer {
@@ -344,13 +345,9 @@
static_cast<uint8_t>(rgb.b * 255));
}
-// Note that SkColorSpace doesn't have the notion of an unspecified SDR white
-// level.
-static constexpr float kDefaultSDRWhiteLevel = 150.f;
-
skcms_TransferFunction GetPQSkTransferFunction(float sdr_white_level) {
if (sdr_white_level <= 0.f) {
- sdr_white_level = kDefaultSDRWhiteLevel;
+ sdr_white_level = Properties::defaultSdrWhitePoint;
}
// The generic PQ transfer function produces normalized luminance values i.e.
// the range 0-1 represents 0-10000 nits for the reference display, but we
diff --git a/libs/input/Android.bp b/libs/input/Android.bp
index 5252cd0..dca3501 100644
--- a/libs/input/Android.bp
+++ b/libs/input/Android.bp
@@ -16,6 +16,9 @@
name: "libinputservice",
srcs: [
"PointerController.cpp",
+ "PointerControllerContext.cpp",
+ "MouseCursorController.cpp",
+ "TouchSpotController.cpp",
"SpriteController.cpp",
"SpriteIcon.cpp",
],
diff --git a/libs/input/MouseCursorController.cpp b/libs/input/MouseCursorController.cpp
new file mode 100644
index 0000000..80b555b
--- /dev/null
+++ b/libs/input/MouseCursorController.cpp
@@ -0,0 +1,460 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "MouseCursorController"
+//#define LOG_NDEBUG 0
+
+// Log debug messages about pointer updates
+#define DEBUG_MOUSE_CURSOR_UPDATES 0
+
+#include "MouseCursorController.h"
+
+#include <log/log.h>
+
+#include <SkBitmap.h>
+#include <SkBlendMode.h>
+#include <SkCanvas.h>
+#include <SkColor.h>
+#include <SkPaint.h>
+
+namespace {
+// Time to spend fading out the pointer completely.
+const nsecs_t POINTER_FADE_DURATION = 500 * 1000000LL; // 500 ms
+} // namespace
+
+namespace android {
+
+// --- MouseCursorController ---
+
+MouseCursorController::MouseCursorController(PointerControllerContext& context)
+ : mContext(context) {
+ std::scoped_lock lock(mLock);
+
+ mLocked.animationFrameIndex = 0;
+ mLocked.lastFrameUpdatedTime = 0;
+
+ mLocked.pointerFadeDirection = 0;
+ mLocked.pointerX = 0;
+ mLocked.pointerY = 0;
+ mLocked.pointerAlpha = 0.0f; // pointer is initially faded
+ mLocked.pointerSprite = mContext.getSpriteController()->createSprite();
+ mLocked.updatePointerIcon = false;
+ mLocked.requestedPointerType = mContext.getPolicy()->getDefaultPointerIconId();
+
+ mLocked.resourcesLoaded = false;
+
+ mLocked.buttonState = 0;
+}
+
+MouseCursorController::~MouseCursorController() {
+ std::scoped_lock lock(mLock);
+
+ mLocked.pointerSprite.clear();
+}
+
+bool MouseCursorController::getBounds(float* outMinX, float* outMinY, float* outMaxX,
+ float* outMaxY) const {
+ std::scoped_lock lock(mLock);
+
+ return getBoundsLocked(outMinX, outMinY, outMaxX, outMaxY);
+}
+
+bool MouseCursorController::getBoundsLocked(float* outMinX, float* outMinY, float* outMaxX,
+ float* outMaxY) const REQUIRES(mLock) {
+ if (!mLocked.viewport.isValid()) {
+ return false;
+ }
+
+ *outMinX = mLocked.viewport.logicalLeft;
+ *outMinY = mLocked.viewport.logicalTop;
+ *outMaxX = mLocked.viewport.logicalRight - 1;
+ *outMaxY = mLocked.viewport.logicalBottom - 1;
+ return true;
+}
+
+void MouseCursorController::move(float deltaX, float deltaY) {
+#if DEBUG_MOUSE_CURSOR_UPDATES
+ ALOGD("Move pointer by deltaX=%0.3f, deltaY=%0.3f", deltaX, deltaY);
+#endif
+ if (deltaX == 0.0f && deltaY == 0.0f) {
+ return;
+ }
+
+ std::scoped_lock lock(mLock);
+
+ setPositionLocked(mLocked.pointerX + deltaX, mLocked.pointerY + deltaY);
+}
+
+void MouseCursorController::setButtonState(int32_t buttonState) {
+#if DEBUG_MOUSE_CURSOR_UPDATES
+ ALOGD("Set button state 0x%08x", buttonState);
+#endif
+ std::scoped_lock lock(mLock);
+
+ if (mLocked.buttonState != buttonState) {
+ mLocked.buttonState = buttonState;
+ }
+}
+
+int32_t MouseCursorController::getButtonState() const {
+ std::scoped_lock lock(mLock);
+ return mLocked.buttonState;
+}
+
+void MouseCursorController::setPosition(float x, float y) {
+#if DEBUG_MOUSE_CURSOR_UPDATES
+ ALOGD("Set pointer position to x=%0.3f, y=%0.3f", x, y);
+#endif
+ std::scoped_lock lock(mLock);
+ setPositionLocked(x, y);
+}
+
+void MouseCursorController::setPositionLocked(float x, float y) REQUIRES(mLock) {
+ float minX, minY, maxX, maxY;
+ if (getBoundsLocked(&minX, &minY, &maxX, &maxY)) {
+ if (x <= minX) {
+ mLocked.pointerX = minX;
+ } else if (x >= maxX) {
+ mLocked.pointerX = maxX;
+ } else {
+ mLocked.pointerX = x;
+ }
+ if (y <= minY) {
+ mLocked.pointerY = minY;
+ } else if (y >= maxY) {
+ mLocked.pointerY = maxY;
+ } else {
+ mLocked.pointerY = y;
+ }
+ updatePointerLocked();
+ }
+}
+
+void MouseCursorController::getPosition(float* outX, float* outY) const {
+ std::scoped_lock lock(mLock);
+
+ *outX = mLocked.pointerX;
+ *outY = mLocked.pointerY;
+}
+
+int32_t MouseCursorController::getDisplayId() const {
+ std::scoped_lock lock(mLock);
+ return mLocked.viewport.displayId;
+}
+
+void MouseCursorController::fade(PointerControllerInterface::Transition transition) {
+ std::scoped_lock lock(mLock);
+
+ // Remove the inactivity timeout, since we are fading now.
+ mContext.removeInactivityTimeout();
+
+ // Start fading.
+ if (transition == PointerControllerInterface::Transition::IMMEDIATE) {
+ mLocked.pointerFadeDirection = 0;
+ mLocked.pointerAlpha = 0.0f;
+ updatePointerLocked();
+ } else {
+ mLocked.pointerFadeDirection = -1;
+ mContext.startAnimation();
+ }
+}
+
+void MouseCursorController::unfade(PointerControllerInterface::Transition transition) {
+ std::scoped_lock lock(mLock);
+
+ // Always reset the inactivity timer.
+ mContext.resetInactivityTimeout();
+
+ // Start unfading.
+ if (transition == PointerControllerInterface::Transition::IMMEDIATE) {
+ mLocked.pointerFadeDirection = 0;
+ mLocked.pointerAlpha = 1.0f;
+ updatePointerLocked();
+ } else {
+ mLocked.pointerFadeDirection = 1;
+ mContext.startAnimation();
+ }
+}
+
+void MouseCursorController::reloadPointerResources(bool getAdditionalMouseResources) {
+ std::scoped_lock lock(mLock);
+
+ loadResourcesLocked(getAdditionalMouseResources);
+ updatePointerLocked();
+}
+
+/**
+ * The viewport values for deviceHeight and deviceWidth have already been adjusted for rotation,
+ * so here we are getting the dimensions in the original, unrotated orientation (orientation 0).
+ */
+static void getNonRotatedSize(const DisplayViewport& viewport, int32_t& width, int32_t& height) {
+ width = viewport.deviceWidth;
+ height = viewport.deviceHeight;
+
+ if (viewport.orientation == DISPLAY_ORIENTATION_90 ||
+ viewport.orientation == DISPLAY_ORIENTATION_270) {
+ std::swap(width, height);
+ }
+}
+
+void MouseCursorController::setDisplayViewport(const DisplayViewport& viewport,
+ bool getAdditionalMouseResources) {
+ std::scoped_lock lock(mLock);
+
+ if (viewport == mLocked.viewport) {
+ return;
+ }
+
+ const DisplayViewport oldViewport = mLocked.viewport;
+ mLocked.viewport = viewport;
+
+ int32_t oldDisplayWidth, oldDisplayHeight;
+ getNonRotatedSize(oldViewport, oldDisplayWidth, oldDisplayHeight);
+ int32_t newDisplayWidth, newDisplayHeight;
+ getNonRotatedSize(viewport, newDisplayWidth, newDisplayHeight);
+
+ // Reset cursor position to center if size or display changed.
+ if (oldViewport.displayId != viewport.displayId || oldDisplayWidth != newDisplayWidth ||
+ oldDisplayHeight != newDisplayHeight) {
+ float minX, minY, maxX, maxY;
+ if (getBoundsLocked(&minX, &minY, &maxX, &maxY)) {
+ mLocked.pointerX = (minX + maxX) * 0.5f;
+ mLocked.pointerY = (minY + maxY) * 0.5f;
+ // Reload icon resources for density may be changed.
+ loadResourcesLocked(getAdditionalMouseResources);
+ } else {
+ mLocked.pointerX = 0;
+ mLocked.pointerY = 0;
+ }
+ } else if (oldViewport.orientation != viewport.orientation) {
+ // Apply offsets to convert from the pixel top-left corner position to the pixel center.
+ // This creates an invariant frame of reference that we can easily rotate when
+ // taking into account that the pointer may be located at fractional pixel offsets.
+ float x = mLocked.pointerX + 0.5f;
+ float y = mLocked.pointerY + 0.5f;
+ float temp;
+
+ // Undo the previous rotation.
+ switch (oldViewport.orientation) {
+ case DISPLAY_ORIENTATION_90:
+ temp = x;
+ x = oldViewport.deviceHeight - y;
+ y = temp;
+ break;
+ case DISPLAY_ORIENTATION_180:
+ x = oldViewport.deviceWidth - x;
+ y = oldViewport.deviceHeight - y;
+ break;
+ case DISPLAY_ORIENTATION_270:
+ temp = x;
+ x = y;
+ y = oldViewport.deviceWidth - temp;
+ break;
+ }
+
+ // Perform the new rotation.
+ switch (viewport.orientation) {
+ case DISPLAY_ORIENTATION_90:
+ temp = x;
+ x = y;
+ y = viewport.deviceHeight - temp;
+ break;
+ case DISPLAY_ORIENTATION_180:
+ x = viewport.deviceWidth - x;
+ y = viewport.deviceHeight - y;
+ break;
+ case DISPLAY_ORIENTATION_270:
+ temp = x;
+ x = viewport.deviceWidth - y;
+ y = temp;
+ break;
+ }
+
+ // Apply offsets to convert from the pixel center to the pixel top-left corner position
+ // and save the results.
+ mLocked.pointerX = x - 0.5f;
+ mLocked.pointerY = y - 0.5f;
+ }
+
+ updatePointerLocked();
+}
+
+void MouseCursorController::updatePointerIcon(int32_t iconId) {
+ std::scoped_lock lock(mLock);
+
+ if (mLocked.requestedPointerType != iconId) {
+ mLocked.requestedPointerType = iconId;
+ mLocked.updatePointerIcon = true;
+ updatePointerLocked();
+ }
+}
+
+void MouseCursorController::setCustomPointerIcon(const SpriteIcon& icon) {
+ std::scoped_lock lock(mLock);
+
+ const int32_t iconId = mContext.getPolicy()->getCustomPointerIconId();
+ mLocked.additionalMouseResources[iconId] = icon;
+ mLocked.requestedPointerType = iconId;
+ mLocked.updatePointerIcon = true;
+ updatePointerLocked();
+}
+
+bool MouseCursorController::doFadingAnimation(nsecs_t timestamp, bool keepAnimating) {
+ nsecs_t frameDelay = timestamp - mContext.getAnimationTime();
+
+ std::scoped_lock lock(mLock);
+
+ // Animate pointer fade.
+ if (mLocked.pointerFadeDirection < 0) {
+ mLocked.pointerAlpha -= float(frameDelay) / POINTER_FADE_DURATION;
+ if (mLocked.pointerAlpha <= 0.0f) {
+ mLocked.pointerAlpha = 0.0f;
+ mLocked.pointerFadeDirection = 0;
+ } else {
+ keepAnimating = true;
+ }
+ updatePointerLocked();
+ } else if (mLocked.pointerFadeDirection > 0) {
+ mLocked.pointerAlpha += float(frameDelay) / POINTER_FADE_DURATION;
+ if (mLocked.pointerAlpha >= 1.0f) {
+ mLocked.pointerAlpha = 1.0f;
+ mLocked.pointerFadeDirection = 0;
+ } else {
+ keepAnimating = true;
+ }
+ updatePointerLocked();
+ }
+
+ return keepAnimating;
+}
+
+bool MouseCursorController::doBitmapAnimation(nsecs_t timestamp) {
+ std::scoped_lock lock(mLock);
+
+ std::map<int32_t, PointerAnimation>::const_iterator iter =
+ mLocked.animationResources.find(mLocked.requestedPointerType);
+ if (iter == mLocked.animationResources.end()) {
+ return false;
+ }
+
+ if (timestamp - mLocked.lastFrameUpdatedTime > iter->second.durationPerFrame) {
+ sp<SpriteController> spriteController = mContext.getSpriteController();
+ spriteController->openTransaction();
+
+ int incr = (timestamp - mLocked.lastFrameUpdatedTime) / iter->second.durationPerFrame;
+ mLocked.animationFrameIndex += incr;
+ mLocked.lastFrameUpdatedTime += iter->second.durationPerFrame * incr;
+ while (mLocked.animationFrameIndex >= iter->second.animationFrames.size()) {
+ mLocked.animationFrameIndex -= iter->second.animationFrames.size();
+ }
+ mLocked.pointerSprite->setIcon(iter->second.animationFrames[mLocked.animationFrameIndex]);
+
+ spriteController->closeTransaction();
+ }
+
+ // Keep animating.
+ return true;
+}
+
+void MouseCursorController::updatePointerLocked() REQUIRES(mLock) {
+ if (!mLocked.viewport.isValid()) {
+ return;
+ }
+ sp<SpriteController> spriteController = mContext.getSpriteController();
+ spriteController->openTransaction();
+
+ mLocked.pointerSprite->setLayer(Sprite::BASE_LAYER_POINTER);
+ mLocked.pointerSprite->setPosition(mLocked.pointerX, mLocked.pointerY);
+ mLocked.pointerSprite->setDisplayId(mLocked.viewport.displayId);
+
+ if (mLocked.pointerAlpha > 0) {
+ mLocked.pointerSprite->setAlpha(mLocked.pointerAlpha);
+ mLocked.pointerSprite->setVisible(true);
+ } else {
+ mLocked.pointerSprite->setVisible(false);
+ }
+
+ if (mLocked.updatePointerIcon) {
+ if (mLocked.requestedPointerType == mContext.getPolicy()->getDefaultPointerIconId()) {
+ mLocked.pointerSprite->setIcon(mLocked.pointerIcon);
+ } else {
+ std::map<int32_t, SpriteIcon>::const_iterator iter =
+ mLocked.additionalMouseResources.find(mLocked.requestedPointerType);
+ if (iter != mLocked.additionalMouseResources.end()) {
+ std::map<int32_t, PointerAnimation>::const_iterator anim_iter =
+ mLocked.animationResources.find(mLocked.requestedPointerType);
+ if (anim_iter != mLocked.animationResources.end()) {
+ mLocked.animationFrameIndex = 0;
+ mLocked.lastFrameUpdatedTime = systemTime(SYSTEM_TIME_MONOTONIC);
+ mContext.startAnimation();
+ }
+ mLocked.pointerSprite->setIcon(iter->second);
+ } else {
+ ALOGW("Can't find the resource for icon id %d", mLocked.requestedPointerType);
+ mLocked.pointerSprite->setIcon(mLocked.pointerIcon);
+ }
+ }
+ mLocked.updatePointerIcon = false;
+ }
+
+ spriteController->closeTransaction();
+}
+
+void MouseCursorController::loadResourcesLocked(bool getAdditionalMouseResources) REQUIRES(mLock) {
+ if (!mLocked.viewport.isValid()) {
+ return;
+ }
+
+ if (!mLocked.resourcesLoaded) mLocked.resourcesLoaded = true;
+
+ sp<PointerControllerPolicyInterface> policy = mContext.getPolicy();
+ policy->loadPointerResources(&mResources, mLocked.viewport.displayId);
+ policy->loadPointerIcon(&mLocked.pointerIcon, mLocked.viewport.displayId);
+
+ mLocked.additionalMouseResources.clear();
+ mLocked.animationResources.clear();
+ if (getAdditionalMouseResources) {
+ policy->loadAdditionalMouseResources(&mLocked.additionalMouseResources,
+ &mLocked.animationResources,
+ mLocked.viewport.displayId);
+ }
+
+ mLocked.updatePointerIcon = true;
+}
+
+bool MouseCursorController::isViewportValid() {
+ std::scoped_lock lock(mLock);
+ return mLocked.viewport.isValid();
+}
+
+void MouseCursorController::getAdditionalMouseResources() {
+ std::scoped_lock lock(mLock);
+
+ if (mLocked.additionalMouseResources.empty()) {
+ mContext.getPolicy()->loadAdditionalMouseResources(&mLocked.additionalMouseResources,
+ &mLocked.animationResources,
+ mLocked.viewport.displayId);
+ }
+ mLocked.updatePointerIcon = true;
+ updatePointerLocked();
+}
+
+bool MouseCursorController::resourcesLoaded() {
+ std::scoped_lock lock(mLock);
+ return mLocked.resourcesLoaded;
+}
+
+} // namespace android
diff --git a/libs/input/MouseCursorController.h b/libs/input/MouseCursorController.h
new file mode 100644
index 0000000..448165b
--- /dev/null
+++ b/libs/input/MouseCursorController.h
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+#ifndef _UI_MOUSE_CURSOR_CONTROLLER_H
+#define _UI_MOUSE_CURSOR_CONTROLLER_H
+
+#include <gui/DisplayEventReceiver.h>
+#include <input/DisplayViewport.h>
+#include <input/Input.h>
+#include <ui/DisplayInfo.h>
+#include <utils/BitSet.h>
+#include <utils/Looper.h>
+#include <utils/RefBase.h>
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include "PointerControllerContext.h"
+#include "SpriteController.h"
+
+namespace android {
+
+/*
+ * Helper class for PointerController that specifically handles
+ * mouse cursor resources and actions.
+ */
+class MouseCursorController {
+public:
+ MouseCursorController(PointerControllerContext& context);
+ ~MouseCursorController();
+
+ bool getBounds(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const;
+ void move(float deltaX, float deltaY);
+ void setButtonState(int32_t buttonState);
+ int32_t getButtonState() const;
+ void setPosition(float x, float y);
+ void getPosition(float* outX, float* outY) const;
+ int32_t getDisplayId() const;
+ void fade(PointerControllerInterface::Transition transition);
+ void unfade(PointerControllerInterface::Transition transition);
+ void setDisplayViewport(const DisplayViewport& viewport, bool getAdditionalMouseResources);
+
+ void updatePointerIcon(int32_t iconId);
+ void setCustomPointerIcon(const SpriteIcon& icon);
+ void reloadPointerResources(bool getAdditionalMouseResources);
+
+ void getAdditionalMouseResources();
+ bool isViewportValid();
+
+ bool doBitmapAnimation(nsecs_t timestamp);
+ bool doFadingAnimation(nsecs_t timestamp, bool keepAnimating);
+
+ bool resourcesLoaded();
+
+private:
+ mutable std::mutex mLock;
+
+ PointerResources mResources;
+
+ PointerControllerContext& mContext;
+
+ struct Locked {
+ DisplayViewport viewport;
+
+ size_t animationFrameIndex;
+ nsecs_t lastFrameUpdatedTime;
+
+ int32_t pointerFadeDirection;
+ float pointerX;
+ float pointerY;
+ float pointerAlpha;
+ sp<Sprite> pointerSprite;
+ SpriteIcon pointerIcon;
+ bool updatePointerIcon;
+
+ bool resourcesLoaded;
+
+ std::map<int32_t, SpriteIcon> additionalMouseResources;
+ std::map<int32_t, PointerAnimation> animationResources;
+
+ int32_t requestedPointerType;
+
+ int32_t buttonState;
+
+ } mLocked GUARDED_BY(mLock);
+
+ bool getBoundsLocked(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const;
+ void setPositionLocked(float x, float y);
+
+ void updatePointerLocked();
+
+ void loadResourcesLocked(bool getAdditionalMouseResources);
+};
+
+} // namespace android
+
+#endif // _UI_MOUSE_CURSOR_CONTROLLER_H
diff --git a/libs/input/PointerController.cpp b/libs/input/PointerController.cpp
index 5e480a6..14c96ce 100644
--- a/libs/input/PointerController.cpp
+++ b/libs/input/PointerController.cpp
@@ -21,31 +21,26 @@
#define DEBUG_POINTER_UPDATES 0
#include "PointerController.h"
+#include "MouseCursorController.h"
+#include "PointerControllerContext.h"
+#include "TouchSpotController.h"
#include <log/log.h>
-#include <memory>
+#include <SkBitmap.h>
+#include <SkBlendMode.h>
+#include <SkCanvas.h>
+#include <SkColor.h>
+#include <SkPaint.h>
namespace android {
// --- PointerController ---
-// Time to wait before starting the fade when the pointer is inactive.
-static const nsecs_t INACTIVITY_TIMEOUT_DELAY_TIME_NORMAL = 15 * 1000 * 1000000LL; // 15 seconds
-static const nsecs_t INACTIVITY_TIMEOUT_DELAY_TIME_SHORT = 3 * 1000 * 1000000LL; // 3 seconds
-
-// Time to spend fading out the spot completely.
-static const nsecs_t SPOT_FADE_DURATION = 200 * 1000000LL; // 200 ms
-
-// Time to spend fading out the pointer completely.
-static const nsecs_t POINTER_FADE_DURATION = 500 * 1000000LL; // 500 ms
-
-// The number of events to be read at once for DisplayEventReceiver.
-static const int EVENT_BUFFER_SIZE = 100;
-
std::shared_ptr<PointerController> PointerController::create(
const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper,
const sp<SpriteController>& spriteController) {
+ // using 'new' to access non-public constructor
std::shared_ptr<PointerController> controller = std::shared_ptr<PointerController>(
new PointerController(policy, looper, spriteController));
@@ -60,758 +55,175 @@
* weak_ptr's which themselves cannot be constructed until there's at least one shared_ptr.
*/
- controller->mHandler->pointerController = controller;
- controller->mCallback->pointerController = controller;
- if (controller->mDisplayEventReceiver.initCheck() == NO_ERROR) {
- controller->mLooper->addFd(controller->mDisplayEventReceiver.getFd(), Looper::POLL_CALLBACK,
- Looper::EVENT_INPUT, controller->mCallback, nullptr);
- } else {
- ALOGE("Failed to initialize DisplayEventReceiver.");
- }
+ controller->mContext.setHandlerController(controller);
+ controller->mContext.setCallbackController(controller);
+ controller->mContext.initializeDisplayEventReceiver();
return controller;
}
PointerController::PointerController(const sp<PointerControllerPolicyInterface>& policy,
const sp<Looper>& looper,
const sp<SpriteController>& spriteController)
- : mPolicy(policy),
- mLooper(looper),
- mSpriteController(spriteController),
- mHandler(new MessageHandler()),
- mCallback(new LooperCallback()) {
- AutoMutex _l(mLock);
-
- mLocked.animationPending = false;
-
- mLocked.presentation = Presentation::POINTER;
- mLocked.presentationChanged = false;
-
- mLocked.inactivityTimeout = InactivityTimeout::NORMAL;
-
- mLocked.pointerFadeDirection = 0;
- mLocked.pointerX = 0;
- mLocked.pointerY = 0;
- mLocked.pointerAlpha = 0.0f; // pointer is initially faded
- mLocked.pointerSprite = mSpriteController->createSprite();
- mLocked.pointerIconChanged = false;
- mLocked.requestedPointerType = mPolicy->getDefaultPointerIconId();
-
- mLocked.animationFrameIndex = 0;
- mLocked.lastFrameUpdatedTime = 0;
-
- mLocked.buttonState = 0;
+ : mContext(policy, looper, spriteController, *this), mCursorController(mContext) {
+ std::scoped_lock lock(mLock);
+ mLocked.presentation = Presentation::SPOT;
}
-PointerController::~PointerController() {
- mLooper->removeMessages(mHandler);
-
- AutoMutex _l(mLock);
-
- mLocked.pointerSprite.clear();
-
- for (auto& it : mLocked.spotsByDisplay) {
- const std::vector<Spot*>& spots = it.second;
- size_t numSpots = spots.size();
- for (size_t i = 0; i < numSpots; i++) {
- delete spots[i];
- }
- }
- mLocked.spotsByDisplay.clear();
- mLocked.recycledSprites.clear();
-}
-
-bool PointerController::getBounds(float* outMinX, float* outMinY,
- float* outMaxX, float* outMaxY) const {
- AutoMutex _l(mLock);
-
- return getBoundsLocked(outMinX, outMinY, outMaxX, outMaxY);
-}
-
-bool PointerController::getBoundsLocked(float* outMinX, float* outMinY,
- float* outMaxX, float* outMaxY) const {
-
- if (!mLocked.viewport.isValid()) {
- return false;
- }
-
- *outMinX = mLocked.viewport.logicalLeft;
- *outMinY = mLocked.viewport.logicalTop;
- *outMaxX = mLocked.viewport.logicalRight - 1;
- *outMaxY = mLocked.viewport.logicalBottom - 1;
- return true;
+bool PointerController::getBounds(float* outMinX, float* outMinY, float* outMaxX,
+ float* outMaxY) const {
+ return mCursorController.getBounds(outMinX, outMinY, outMaxX, outMaxY);
}
void PointerController::move(float deltaX, float deltaY) {
-#if DEBUG_POINTER_UPDATES
- ALOGD("Move pointer by deltaX=%0.3f, deltaY=%0.3f", deltaX, deltaY);
-#endif
- if (deltaX == 0.0f && deltaY == 0.0f) {
- return;
- }
-
- AutoMutex _l(mLock);
-
- setPositionLocked(mLocked.pointerX + deltaX, mLocked.pointerY + deltaY);
+ mCursorController.move(deltaX, deltaY);
}
void PointerController::setButtonState(int32_t buttonState) {
-#if DEBUG_POINTER_UPDATES
- ALOGD("Set button state 0x%08x", buttonState);
-#endif
- AutoMutex _l(mLock);
-
- if (mLocked.buttonState != buttonState) {
- mLocked.buttonState = buttonState;
- }
+ mCursorController.setButtonState(buttonState);
}
int32_t PointerController::getButtonState() const {
- AutoMutex _l(mLock);
-
- return mLocked.buttonState;
+ return mCursorController.getButtonState();
}
void PointerController::setPosition(float x, float y) {
-#if DEBUG_POINTER_UPDATES
- ALOGD("Set pointer position to x=%0.3f, y=%0.3f", x, y);
-#endif
- AutoMutex _l(mLock);
-
- setPositionLocked(x, y);
-}
-
-void PointerController::setPositionLocked(float x, float y) {
- float minX, minY, maxX, maxY;
- if (getBoundsLocked(&minX, &minY, &maxX, &maxY)) {
- if (x <= minX) {
- mLocked.pointerX = minX;
- } else if (x >= maxX) {
- mLocked.pointerX = maxX;
- } else {
- mLocked.pointerX = x;
- }
- if (y <= minY) {
- mLocked.pointerY = minY;
- } else if (y >= maxY) {
- mLocked.pointerY = maxY;
- } else {
- mLocked.pointerY = y;
- }
- updatePointerLocked();
- }
+ std::scoped_lock lock(mLock);
+ mCursorController.setPosition(x, y);
}
void PointerController::getPosition(float* outX, float* outY) const {
- AutoMutex _l(mLock);
-
- *outX = mLocked.pointerX;
- *outY = mLocked.pointerY;
+ mCursorController.getPosition(outX, outY);
}
int32_t PointerController::getDisplayId() const {
- AutoMutex _l(mLock);
-
- return mLocked.viewport.displayId;
+ return mCursorController.getDisplayId();
}
void PointerController::fade(Transition transition) {
- AutoMutex _l(mLock);
-
- // Remove the inactivity timeout, since we are fading now.
- removeInactivityTimeoutLocked();
-
- // Start fading.
- if (transition == Transition::IMMEDIATE) {
- mLocked.pointerFadeDirection = 0;
- mLocked.pointerAlpha = 0.0f;
- updatePointerLocked();
- } else {
- mLocked.pointerFadeDirection = -1;
- startAnimationLocked();
- }
+ std::scoped_lock lock(mLock);
+ mCursorController.fade(transition);
}
void PointerController::unfade(Transition transition) {
- AutoMutex _l(mLock);
-
- // Always reset the inactivity timer.
- resetInactivityTimeoutLocked();
-
- // Start unfading.
- if (transition == Transition::IMMEDIATE) {
- mLocked.pointerFadeDirection = 0;
- mLocked.pointerAlpha = 1.0f;
- updatePointerLocked();
- } else {
- mLocked.pointerFadeDirection = 1;
- startAnimationLocked();
- }
+ std::scoped_lock lock(mLock);
+ mCursorController.unfade(transition);
}
void PointerController::setPresentation(Presentation presentation) {
- AutoMutex _l(mLock);
+ std::scoped_lock lock(mLock);
if (mLocked.presentation == presentation) {
return;
}
mLocked.presentation = presentation;
- mLocked.presentationChanged = true;
- if (!mLocked.viewport.isValid()) {
+ if (!mCursorController.isViewportValid()) {
return;
}
if (presentation == Presentation::POINTER) {
- if (mLocked.additionalMouseResources.empty()) {
- mPolicy->loadAdditionalMouseResources(&mLocked.additionalMouseResources,
- &mLocked.animationResources,
- mLocked.viewport.displayId);
- }
- fadeOutAndReleaseAllSpotsLocked();
- updatePointerLocked();
+ mCursorController.getAdditionalMouseResources();
+ clearSpotsLocked();
}
}
-void PointerController::setSpots(const PointerCoords* spotCoords,
- const uint32_t* spotIdToIndex, BitSet32 spotIdBits, int32_t displayId) {
-#if DEBUG_POINTER_UPDATES
- ALOGD("setSpots: idBits=%08x", spotIdBits.value);
- for (BitSet32 idBits(spotIdBits); !idBits.isEmpty(); ) {
- uint32_t id = idBits.firstMarkedBit();
- idBits.clearBit(id);
- const PointerCoords& c = spotCoords[spotIdToIndex[id]];
- ALOGD(" spot %d: position=(%0.3f, %0.3f), pressure=%0.3f, displayId=%" PRId32 ".", id,
- c.getAxisValue(AMOTION_EVENT_AXIS_X),
- c.getAxisValue(AMOTION_EVENT_AXIS_Y),
- c.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
- displayId);
+void PointerController::setSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex,
+ BitSet32 spotIdBits, int32_t displayId) {
+ std::scoped_lock lock(mLock);
+ auto it = mLocked.spotControllers.find(displayId);
+ if (it == mLocked.spotControllers.end()) {
+ mLocked.spotControllers.try_emplace(displayId, displayId, mContext);
}
-#endif
-
- AutoMutex _l(mLock);
- if (!mLocked.viewport.isValid()) {
- return;
- }
-
- std::vector<Spot*> newSpots;
- std::map<int32_t, std::vector<Spot*>>::const_iterator iter =
- mLocked.spotsByDisplay.find(displayId);
- if (iter != mLocked.spotsByDisplay.end()) {
- newSpots = iter->second;
- }
-
- mSpriteController->openTransaction();
-
- // Add or move spots for fingers that are down.
- for (BitSet32 idBits(spotIdBits); !idBits.isEmpty(); ) {
- uint32_t id = idBits.clearFirstMarkedBit();
- const PointerCoords& c = spotCoords[spotIdToIndex[id]];
- const SpriteIcon& icon = c.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE) > 0
- ? mResources.spotTouch : mResources.spotHover;
- float x = c.getAxisValue(AMOTION_EVENT_AXIS_X);
- float y = c.getAxisValue(AMOTION_EVENT_AXIS_Y);
-
- Spot* spot = getSpot(id, newSpots);
- if (!spot) {
- spot = createAndAddSpotLocked(id, newSpots);
- }
-
- spot->updateSprite(&icon, x, y, displayId);
- }
-
- // Remove spots for fingers that went up.
- for (size_t i = 0; i < newSpots.size(); i++) {
- Spot* spot = newSpots[i];
- if (spot->id != Spot::INVALID_ID
- && !spotIdBits.hasBit(spot->id)) {
- fadeOutAndReleaseSpotLocked(spot);
- }
- }
-
- mSpriteController->closeTransaction();
- mLocked.spotsByDisplay[displayId] = newSpots;
+ mLocked.spotControllers.at(displayId).setSpots(spotCoords, spotIdToIndex, spotIdBits);
}
void PointerController::clearSpots() {
-#if DEBUG_POINTER_UPDATES
- ALOGD("clearSpots");
-#endif
+ std::scoped_lock lock(mLock);
+ clearSpotsLocked();
+}
- AutoMutex _l(mLock);
- if (!mLocked.viewport.isValid()) {
- return;
+void PointerController::clearSpotsLocked() REQUIRES(mLock) {
+ for (auto& [displayID, spotController] : mLocked.spotControllers) {
+ spotController.clearSpots();
}
-
- fadeOutAndReleaseAllSpotsLocked();
}
void PointerController::setInactivityTimeout(InactivityTimeout inactivityTimeout) {
- AutoMutex _l(mLock);
-
- if (mLocked.inactivityTimeout != inactivityTimeout) {
- mLocked.inactivityTimeout = inactivityTimeout;
- resetInactivityTimeoutLocked();
- }
+ mContext.setInactivityTimeout(inactivityTimeout);
}
void PointerController::reloadPointerResources() {
- AutoMutex _l(mLock);
+ std::scoped_lock lock(mLock);
- loadResourcesLocked();
- updatePointerLocked();
-}
+ for (auto& [displayID, spotController] : mLocked.spotControllers) {
+ spotController.reloadSpotResources();
+ }
-/**
- * The viewport values for deviceHeight and deviceWidth have already been adjusted for rotation,
- * so here we are getting the dimensions in the original, unrotated orientation (orientation 0).
- */
-static void getNonRotatedSize(const DisplayViewport& viewport, int32_t& width, int32_t& height) {
- width = viewport.deviceWidth;
- height = viewport.deviceHeight;
-
- if (viewport.orientation == DISPLAY_ORIENTATION_90
- || viewport.orientation == DISPLAY_ORIENTATION_270) {
- std::swap(width, height);
+ if (mCursorController.resourcesLoaded()) {
+ bool getAdditionalMouseResources = false;
+ if (mLocked.presentation == PointerController::Presentation::POINTER) {
+ getAdditionalMouseResources = true;
+ }
+ mCursorController.reloadPointerResources(getAdditionalMouseResources);
}
}
void PointerController::setDisplayViewport(const DisplayViewport& viewport) {
- AutoMutex _l(mLock);
- if (viewport == mLocked.viewport) {
- return;
+ std::scoped_lock lock(mLock);
+
+ bool getAdditionalMouseResources = false;
+ if (mLocked.presentation == PointerController::Presentation::POINTER) {
+ getAdditionalMouseResources = true;
}
-
- const DisplayViewport oldViewport = mLocked.viewport;
- mLocked.viewport = viewport;
-
- int32_t oldDisplayWidth, oldDisplayHeight;
- getNonRotatedSize(oldViewport, oldDisplayWidth, oldDisplayHeight);
- int32_t newDisplayWidth, newDisplayHeight;
- getNonRotatedSize(viewport, newDisplayWidth, newDisplayHeight);
-
- // Reset cursor position to center if size or display changed.
- if (oldViewport.displayId != viewport.displayId
- || oldDisplayWidth != newDisplayWidth
- || oldDisplayHeight != newDisplayHeight) {
-
- float minX, minY, maxX, maxY;
- if (getBoundsLocked(&minX, &minY, &maxX, &maxY)) {
- mLocked.pointerX = (minX + maxX) * 0.5f;
- mLocked.pointerY = (minY + maxY) * 0.5f;
- // Reload icon resources for density may be changed.
- loadResourcesLocked();
- } else {
- mLocked.pointerX = 0;
- mLocked.pointerY = 0;
- }
-
- fadeOutAndReleaseAllSpotsLocked();
- } else if (oldViewport.orientation != viewport.orientation) {
- // Apply offsets to convert from the pixel top-left corner position to the pixel center.
- // This creates an invariant frame of reference that we can easily rotate when
- // taking into account that the pointer may be located at fractional pixel offsets.
- float x = mLocked.pointerX + 0.5f;
- float y = mLocked.pointerY + 0.5f;
- float temp;
-
- // Undo the previous rotation.
- switch (oldViewport.orientation) {
- case DISPLAY_ORIENTATION_90:
- temp = x;
- x = oldViewport.deviceHeight - y;
- y = temp;
- break;
- case DISPLAY_ORIENTATION_180:
- x = oldViewport.deviceWidth - x;
- y = oldViewport.deviceHeight - y;
- break;
- case DISPLAY_ORIENTATION_270:
- temp = x;
- x = y;
- y = oldViewport.deviceWidth - temp;
- break;
- }
-
- // Perform the new rotation.
- switch (viewport.orientation) {
- case DISPLAY_ORIENTATION_90:
- temp = x;
- x = y;
- y = viewport.deviceHeight - temp;
- break;
- case DISPLAY_ORIENTATION_180:
- x = viewport.deviceWidth - x;
- y = viewport.deviceHeight - y;
- break;
- case DISPLAY_ORIENTATION_270:
- temp = x;
- x = viewport.deviceWidth - y;
- y = temp;
- break;
- }
-
- // Apply offsets to convert from the pixel center to the pixel top-left corner position
- // and save the results.
- mLocked.pointerX = x - 0.5f;
- mLocked.pointerY = y - 0.5f;
- }
-
- updatePointerLocked();
+ mCursorController.setDisplayViewport(viewport, getAdditionalMouseResources);
}
void PointerController::updatePointerIcon(int32_t iconId) {
- AutoMutex _l(mLock);
- if (mLocked.requestedPointerType != iconId) {
- mLocked.requestedPointerType = iconId;
- mLocked.presentationChanged = true;
- updatePointerLocked();
- }
+ std::scoped_lock lock(mLock);
+ mCursorController.updatePointerIcon(iconId);
}
void PointerController::setCustomPointerIcon(const SpriteIcon& icon) {
- AutoMutex _l(mLock);
-
- const int32_t iconId = mPolicy->getCustomPointerIconId();
- mLocked.additionalMouseResources[iconId] = icon;
- mLocked.requestedPointerType = iconId;
- mLocked.presentationChanged = true;
-
- updatePointerLocked();
-}
-
-void PointerController::MessageHandler::handleMessage(const Message& message) {
- std::shared_ptr<PointerController> controller = pointerController.lock();
-
- if (controller == nullptr) {
- ALOGE("PointerController instance was released before processing message: what=%d",
- message.what);
- return;
- }
- switch (message.what) {
- case MSG_INACTIVITY_TIMEOUT:
- controller->doInactivityTimeout();
- break;
- }
-}
-
-int PointerController::LooperCallback::handleEvent(int /* fd */, int events, void* /* data */) {
- std::shared_ptr<PointerController> controller = pointerController.lock();
- if (controller == nullptr) {
- ALOGW("PointerController instance was released with pending callbacks. events=0x%x",
- events);
- return 0; // Remove the callback, the PointerController is gone anyways
- }
- if (events & (Looper::EVENT_ERROR | Looper::EVENT_HANGUP)) {
- ALOGE("Display event receiver pipe was closed or an error occurred. events=0x%x", events);
- return 0; // remove the callback
- }
-
- if (!(events & Looper::EVENT_INPUT)) {
- ALOGW("Received spurious callback for unhandled poll event. events=0x%x", events);
- return 1; // keep the callback
- }
-
- bool gotVsync = false;
- ssize_t n;
- nsecs_t timestamp;
- DisplayEventReceiver::Event buf[EVENT_BUFFER_SIZE];
- while ((n = controller->mDisplayEventReceiver.getEvents(buf, EVENT_BUFFER_SIZE)) > 0) {
- for (size_t i = 0; i < static_cast<size_t>(n); ++i) {
- if (buf[i].header.type == DisplayEventReceiver::DISPLAY_EVENT_VSYNC) {
- timestamp = buf[i].header.timestamp;
- gotVsync = true;
- }
- }
- }
- if (gotVsync) {
- controller->doAnimate(timestamp);
- }
- return 1; // keep the callback
+ std::scoped_lock lock(mLock);
+ mCursorController.setCustomPointerIcon(icon);
}
void PointerController::doAnimate(nsecs_t timestamp) {
- AutoMutex _l(mLock);
+ std::scoped_lock lock(mLock);
- mLocked.animationPending = false;
+ mContext.setAnimationPending(false);
- bool keepFading = doFadingAnimationLocked(timestamp);
- bool keepBitmapFlipping = doBitmapAnimationLocked(timestamp);
+ bool keepFading = false;
+ keepFading = mCursorController.doFadingAnimation(timestamp, keepFading);
+
+ for (auto& [displayID, spotController] : mLocked.spotControllers) {
+ keepFading = spotController.doFadingAnimation(timestamp, keepFading);
+ }
+
+ bool keepBitmapFlipping = mCursorController.doBitmapAnimation(timestamp);
if (keepFading || keepBitmapFlipping) {
- startAnimationLocked();
+ mContext.startAnimation();
}
}
-bool PointerController::doFadingAnimationLocked(nsecs_t timestamp) {
- bool keepAnimating = false;
- nsecs_t frameDelay = timestamp - mLocked.animationTime;
-
- // Animate pointer fade.
- if (mLocked.pointerFadeDirection < 0) {
- mLocked.pointerAlpha -= float(frameDelay) / POINTER_FADE_DURATION;
- if (mLocked.pointerAlpha <= 0.0f) {
- mLocked.pointerAlpha = 0.0f;
- mLocked.pointerFadeDirection = 0;
- } else {
- keepAnimating = true;
- }
- updatePointerLocked();
- } else if (mLocked.pointerFadeDirection > 0) {
- mLocked.pointerAlpha += float(frameDelay) / POINTER_FADE_DURATION;
- if (mLocked.pointerAlpha >= 1.0f) {
- mLocked.pointerAlpha = 1.0f;
- mLocked.pointerFadeDirection = 0;
- } else {
- keepAnimating = true;
- }
- updatePointerLocked();
- }
-
- // Animate spots that are fading out and being removed.
- for(auto it = mLocked.spotsByDisplay.begin(); it != mLocked.spotsByDisplay.end();) {
- std::vector<Spot*>& spots = it->second;
- size_t numSpots = spots.size();
- for (size_t i = 0; i < numSpots;) {
- Spot* spot = spots[i];
- if (spot->id == Spot::INVALID_ID) {
- spot->alpha -= float(frameDelay) / SPOT_FADE_DURATION;
- if (spot->alpha <= 0) {
- spots.erase(spots.begin() + i);
- releaseSpotLocked(spot);
- numSpots--;
- continue;
- } else {
- spot->sprite->setAlpha(spot->alpha);
- keepAnimating = true;
- }
- }
- ++i;
- }
-
- if (spots.size() == 0) {
- it = mLocked.spotsByDisplay.erase(it);
- } else {
- ++it;
- }
- }
-
- return keepAnimating;
-}
-
-bool PointerController::doBitmapAnimationLocked(nsecs_t timestamp) {
- std::map<int32_t, PointerAnimation>::const_iterator iter = mLocked.animationResources.find(
- mLocked.requestedPointerType);
- if (iter == mLocked.animationResources.end()) {
- return false;
- }
-
- if (timestamp - mLocked.lastFrameUpdatedTime > iter->second.durationPerFrame) {
- mSpriteController->openTransaction();
-
- int incr = (timestamp - mLocked.lastFrameUpdatedTime) / iter->second.durationPerFrame;
- mLocked.animationFrameIndex += incr;
- mLocked.lastFrameUpdatedTime += iter->second.durationPerFrame * incr;
- while (mLocked.animationFrameIndex >= iter->second.animationFrames.size()) {
- mLocked.animationFrameIndex -= iter->second.animationFrames.size();
- }
- mLocked.pointerSprite->setIcon(iter->second.animationFrames[mLocked.animationFrameIndex]);
-
- mSpriteController->closeTransaction();
- }
-
- // Keep animating.
- return true;
-}
-
void PointerController::doInactivityTimeout() {
fade(Transition::GRADUAL);
}
-void PointerController::startAnimationLocked() {
- if (!mLocked.animationPending) {
- mLocked.animationPending = true;
- mLocked.animationTime = systemTime(SYSTEM_TIME_MONOTONIC);
- mDisplayEventReceiver.requestNextVsync();
- }
-}
-
-void PointerController::resetInactivityTimeoutLocked() {
- mLooper->removeMessages(mHandler, MSG_INACTIVITY_TIMEOUT);
-
- nsecs_t timeout = mLocked.inactivityTimeout == InactivityTimeout::SHORT
- ? INACTIVITY_TIMEOUT_DELAY_TIME_SHORT
- : INACTIVITY_TIMEOUT_DELAY_TIME_NORMAL;
- mLooper->sendMessageDelayed(timeout, mHandler, MSG_INACTIVITY_TIMEOUT);
-}
-
-void PointerController::removeInactivityTimeoutLocked() {
- mLooper->removeMessages(mHandler, MSG_INACTIVITY_TIMEOUT);
-}
-
-void PointerController::updatePointerLocked() REQUIRES(mLock) {
- if (!mLocked.viewport.isValid()) {
- return;
+void PointerController::onDisplayViewportsUpdated(std::vector<DisplayViewport>& viewports) {
+ std::unordered_set<int32_t> displayIdSet;
+ for (DisplayViewport viewport : viewports) {
+ displayIdSet.insert(viewport.displayId);
}
- mSpriteController->openTransaction();
-
- mLocked.pointerSprite->setLayer(Sprite::BASE_LAYER_POINTER);
- mLocked.pointerSprite->setPosition(mLocked.pointerX, mLocked.pointerY);
- mLocked.pointerSprite->setDisplayId(mLocked.viewport.displayId);
-
- if (mLocked.pointerAlpha > 0) {
- mLocked.pointerSprite->setAlpha(mLocked.pointerAlpha);
- mLocked.pointerSprite->setVisible(true);
- } else {
- mLocked.pointerSprite->setVisible(false);
- }
-
- if (mLocked.pointerIconChanged || mLocked.presentationChanged) {
- if (mLocked.presentation == Presentation::POINTER) {
- if (mLocked.requestedPointerType == mPolicy->getDefaultPointerIconId()) {
- mLocked.pointerSprite->setIcon(mLocked.pointerIcon);
- } else {
- std::map<int32_t, SpriteIcon>::const_iterator iter =
- mLocked.additionalMouseResources.find(mLocked.requestedPointerType);
- if (iter != mLocked.additionalMouseResources.end()) {
- std::map<int32_t, PointerAnimation>::const_iterator anim_iter =
- mLocked.animationResources.find(mLocked.requestedPointerType);
- if (anim_iter != mLocked.animationResources.end()) {
- mLocked.animationFrameIndex = 0;
- mLocked.lastFrameUpdatedTime = systemTime(SYSTEM_TIME_MONOTONIC);
- startAnimationLocked();
- }
- mLocked.pointerSprite->setIcon(iter->second);
- } else {
- ALOGW("Can't find the resource for icon id %d", mLocked.requestedPointerType);
- mLocked.pointerSprite->setIcon(mLocked.pointerIcon);
- }
- }
+ std::scoped_lock lock(mLock);
+ for (auto it = mLocked.spotControllers.begin(); it != mLocked.spotControllers.end();) {
+ int32_t displayID = it->first;
+ if (!displayIdSet.count(displayID)) {
+ it = mLocked.spotControllers.erase(it);
} else {
- mLocked.pointerSprite->setIcon(mResources.spotAnchor);
- }
- mLocked.pointerIconChanged = false;
- mLocked.presentationChanged = false;
- }
-
- mSpriteController->closeTransaction();
-}
-
-PointerController::Spot* PointerController::getSpot(uint32_t id, const std::vector<Spot*>& spots) {
- for (size_t i = 0; i < spots.size(); i++) {
- Spot* spot = spots[i];
- if (spot->id == id) {
- return spot;
- }
- }
-
- return nullptr;
-}
-
-PointerController::Spot* PointerController::createAndAddSpotLocked(uint32_t id,
- std::vector<Spot*>& spots) {
- // Remove spots until we have fewer than MAX_SPOTS remaining.
- while (spots.size() >= MAX_SPOTS) {
- Spot* spot = removeFirstFadingSpotLocked(spots);
- if (!spot) {
- spot = spots[0];
- spots.erase(spots.begin());
- }
- releaseSpotLocked(spot);
- }
-
- // Obtain a sprite from the recycled pool.
- sp<Sprite> sprite;
- if (! mLocked.recycledSprites.empty()) {
- sprite = mLocked.recycledSprites.back();
- mLocked.recycledSprites.pop_back();
- } else {
- sprite = mSpriteController->createSprite();
- }
-
- // Return the new spot.
- Spot* spot = new Spot(id, sprite);
- spots.push_back(spot);
- return spot;
-}
-
-PointerController::Spot* PointerController::removeFirstFadingSpotLocked(std::vector<Spot*>& spots) {
- for (size_t i = 0; i < spots.size(); i++) {
- Spot* spot = spots[i];
- if (spot->id == Spot::INVALID_ID) {
- spots.erase(spots.begin() + i);
- return spot;
- }
- }
- return nullptr;
-}
-
-void PointerController::releaseSpotLocked(Spot* spot) {
- spot->sprite->clearIcon();
-
- if (mLocked.recycledSprites.size() < MAX_RECYCLED_SPRITES) {
- mLocked.recycledSprites.push_back(spot->sprite);
- }
-
- delete spot;
-}
-
-void PointerController::fadeOutAndReleaseSpotLocked(Spot* spot) {
- if (spot->id != Spot::INVALID_ID) {
- spot->id = Spot::INVALID_ID;
- startAnimationLocked();
- }
-}
-
-void PointerController::fadeOutAndReleaseAllSpotsLocked() {
- for (auto& it : mLocked.spotsByDisplay) {
- const std::vector<Spot*>& spots = it.second;
- size_t numSpots = spots.size();
- for (size_t i = 0; i < numSpots; i++) {
- Spot* spot = spots[i];
- fadeOutAndReleaseSpotLocked(spot);
- }
- }
-}
-
-void PointerController::loadResourcesLocked() REQUIRES(mLock) {
- if (!mLocked.viewport.isValid()) {
- return;
- }
-
- mPolicy->loadPointerResources(&mResources, mLocked.viewport.displayId);
- mPolicy->loadPointerIcon(&mLocked.pointerIcon, mLocked.viewport.displayId);
-
- mLocked.additionalMouseResources.clear();
- mLocked.animationResources.clear();
- if (mLocked.presentation == Presentation::POINTER) {
- mPolicy->loadAdditionalMouseResources(&mLocked.additionalMouseResources,
- &mLocked.animationResources, mLocked.viewport.displayId);
- }
-
- mLocked.pointerIconChanged = true;
-}
-
-
-// --- PointerController::Spot ---
-
-void PointerController::Spot::updateSprite(const SpriteIcon* icon, float x, float y,
- int32_t displayId) {
- sprite->setLayer(Sprite::BASE_LAYER_SPOT + id);
- sprite->setAlpha(alpha);
- sprite->setTransformationMatrix(SpriteTransformationMatrix(scale, 0.0f, 0.0f, scale));
- sprite->setPosition(x, y);
- sprite->setDisplayId(displayId);
- this->x = x;
- this->y = y;
-
- if (icon != lastIcon) {
- lastIcon = icon;
- if (icon) {
- sprite->setIcon(*icon);
- sprite->setVisible(true);
- } else {
- sprite->setVisible(false);
+ ++it;
}
}
}
diff --git a/libs/input/PointerController.h b/libs/input/PointerController.h
index 14c0679..1f561da 100644
--- a/libs/input/PointerController.h
+++ b/libs/input/PointerController.h
@@ -30,48 +30,14 @@
#include <memory>
#include <vector>
+#include "MouseCursorController.h"
+#include "PointerControllerContext.h"
#include "SpriteController.h"
+#include "TouchSpotController.h"
namespace android {
/*
- * Pointer resources.
- */
-struct PointerResources {
- SpriteIcon spotHover;
- SpriteIcon spotTouch;
- SpriteIcon spotAnchor;
-};
-
-struct PointerAnimation {
- std::vector<SpriteIcon> animationFrames;
- nsecs_t durationPerFrame;
-};
-
-/*
- * Pointer controller policy interface.
- *
- * The pointer controller policy is used by the pointer controller to interact with
- * the Window Manager and other system components.
- *
- * The actual implementation is partially supported by callbacks into the DVM
- * via JNI. This interface is also mocked in the unit tests.
- */
-class PointerControllerPolicyInterface : public virtual RefBase {
-protected:
- PointerControllerPolicyInterface() { }
- virtual ~PointerControllerPolicyInterface() { }
-
-public:
- virtual void loadPointerIcon(SpriteIcon* icon, int32_t displayId) = 0;
- virtual void loadPointerResources(PointerResources* outResources, int32_t displayId) = 0;
- virtual void loadAdditionalMouseResources(std::map<int32_t, SpriteIcon>* outResources,
- std::map<int32_t, PointerAnimation>* outAnimationResources, int32_t displayId) = 0;
- virtual int32_t getDefaultPointerIconId() = 0;
- virtual int32_t getCustomPointerIconId() = 0;
-};
-
-/*
* Tracks pointer movements and draws the pointer sprite to a surface.
*
* Handles pointer acceleration and animation.
@@ -81,15 +47,10 @@
static std::shared_ptr<PointerController> create(
const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper,
const sp<SpriteController>& spriteController);
- enum class InactivityTimeout {
- NORMAL = 0,
- SHORT = 1,
- };
- virtual ~PointerController();
+ virtual ~PointerController() = default;
- virtual bool getBounds(float* outMinX, float* outMinY,
- float* outMaxX, float* outMaxY) const;
+ virtual bool getBounds(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const;
virtual void move(float deltaX, float deltaY);
virtual void setButtonState(int32_t buttonState);
virtual int32_t getButtonState() const;
@@ -101,129 +62,37 @@
virtual void setDisplayViewport(const DisplayViewport& viewport);
virtual void setPresentation(Presentation presentation);
- virtual void setSpots(const PointerCoords* spotCoords,
- const uint32_t* spotIdToIndex, BitSet32 spotIdBits, int32_t displayId);
+ virtual void setSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex,
+ BitSet32 spotIdBits, int32_t displayId);
virtual void clearSpots();
void updatePointerIcon(int32_t iconId);
void setCustomPointerIcon(const SpriteIcon& icon);
void setInactivityTimeout(InactivityTimeout inactivityTimeout);
+ void doInactivityTimeout();
+ void doAnimate(nsecs_t timestamp);
void reloadPointerResources();
+ void onDisplayViewportsUpdated(std::vector<DisplayViewport>& viewports);
private:
- static constexpr size_t MAX_RECYCLED_SPRITES = 12;
- static constexpr size_t MAX_SPOTS = 12;
+ friend PointerControllerContext::LooperCallback;
+ friend PointerControllerContext::MessageHandler;
- enum {
- MSG_INACTIVITY_TIMEOUT,
- };
+ mutable std::mutex mLock;
- struct Spot {
- static const uint32_t INVALID_ID = 0xffffffff;
+ PointerControllerContext mContext;
- uint32_t id;
- sp<Sprite> sprite;
- float alpha;
- float scale;
- float x, y;
-
- inline Spot(uint32_t id, const sp<Sprite>& sprite)
- : id(id),
- sprite(sprite),
- alpha(1.0f),
- scale(1.0f),
- x(0.0f),
- y(0.0f),
- lastIcon(nullptr) {}
-
- void updateSprite(const SpriteIcon* icon, float x, float y, int32_t displayId);
-
- private:
- const SpriteIcon* lastIcon;
- };
-
- class MessageHandler : public virtual android::MessageHandler {
- public:
- void handleMessage(const Message& message) override;
- std::weak_ptr<PointerController> pointerController;
- };
-
- class LooperCallback : public virtual android::LooperCallback {
- public:
- int handleEvent(int fd, int events, void* data) override;
- std::weak_ptr<PointerController> pointerController;
- };
-
- mutable Mutex mLock;
-
- sp<PointerControllerPolicyInterface> mPolicy;
- sp<Looper> mLooper;
- sp<SpriteController> mSpriteController;
- sp<MessageHandler> mHandler;
- sp<LooperCallback> mCallback;
-
- DisplayEventReceiver mDisplayEventReceiver;
-
- PointerResources mResources;
+ MouseCursorController mCursorController;
struct Locked {
- bool animationPending;
- nsecs_t animationTime;
-
- size_t animationFrameIndex;
- nsecs_t lastFrameUpdatedTime;
-
- DisplayViewport viewport;
-
- InactivityTimeout inactivityTimeout;
-
Presentation presentation;
- bool presentationChanged;
- int32_t pointerFadeDirection;
- float pointerX;
- float pointerY;
- float pointerAlpha;
- sp<Sprite> pointerSprite;
- SpriteIcon pointerIcon;
- bool pointerIconChanged;
-
- std::map<int32_t, SpriteIcon> additionalMouseResources;
- std::map<int32_t, PointerAnimation> animationResources;
-
- int32_t requestedPointerType;
-
- int32_t buttonState;
-
- std::map<int32_t /* displayId */, std::vector<Spot*>> spotsByDisplay;
- std::vector<sp<Sprite>> recycledSprites;
+ std::unordered_map<int32_t /* displayId */, TouchSpotController> spotControllers;
} mLocked GUARDED_BY(mLock);
PointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper,
const sp<SpriteController>& spriteController);
-
- bool getBoundsLocked(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const;
- void setPositionLocked(float x, float y);
-
- void doAnimate(nsecs_t timestamp);
- bool doFadingAnimationLocked(nsecs_t timestamp);
- bool doBitmapAnimationLocked(nsecs_t timestamp);
- void doInactivityTimeout();
-
- void startAnimationLocked();
-
- void resetInactivityTimeoutLocked();
- void removeInactivityTimeoutLocked();
- void updatePointerLocked();
-
- Spot* getSpot(uint32_t id, const std::vector<Spot*>& spots);
- Spot* createAndAddSpotLocked(uint32_t id, std::vector<Spot*>& spots);
- Spot* removeFirstFadingSpotLocked(std::vector<Spot*>& spots);
- void releaseSpotLocked(Spot* spot);
- void fadeOutAndReleaseSpotLocked(Spot* spot);
- void fadeOutAndReleaseAllSpotsLocked();
-
- void loadResourcesLocked();
+ void clearSpotsLocked();
};
} // namespace android
diff --git a/libs/input/PointerControllerContext.cpp b/libs/input/PointerControllerContext.cpp
new file mode 100644
index 0000000..2d7e22b
--- /dev/null
+++ b/libs/input/PointerControllerContext.cpp
@@ -0,0 +1,179 @@
+/*
+ * 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.
+ */
+
+#include "PointerControllerContext.h"
+#include "PointerController.h"
+
+namespace {
+// Time to wait before starting the fade when the pointer is inactive.
+const nsecs_t INACTIVITY_TIMEOUT_DELAY_TIME_NORMAL = 15 * 1000 * 1000000LL; // 15 seconds
+const nsecs_t INACTIVITY_TIMEOUT_DELAY_TIME_SHORT = 3 * 1000 * 1000000LL; // 3 seconds
+
+// The number of events to be read at once for DisplayEventReceiver.
+const int EVENT_BUFFER_SIZE = 100;
+} // namespace
+
+namespace android {
+
+// --- PointerControllerContext ---
+
+PointerControllerContext::PointerControllerContext(
+ const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper,
+ const sp<SpriteController>& spriteController, PointerController& controller)
+ : mPolicy(policy),
+ mLooper(looper),
+ mSpriteController(spriteController),
+ mHandler(new MessageHandler()),
+ mCallback(new LooperCallback()),
+ mController(controller) {
+ std::scoped_lock lock(mLock);
+ mLocked.inactivityTimeout = InactivityTimeout::NORMAL;
+ mLocked.animationPending = false;
+}
+
+PointerControllerContext::~PointerControllerContext() {
+ mLooper->removeMessages(mHandler);
+}
+
+void PointerControllerContext::setInactivityTimeout(InactivityTimeout inactivityTimeout) {
+ std::scoped_lock lock(mLock);
+
+ if (mLocked.inactivityTimeout != inactivityTimeout) {
+ mLocked.inactivityTimeout = inactivityTimeout;
+ resetInactivityTimeoutLocked();
+ }
+}
+
+void PointerControllerContext::startAnimation() {
+ std::scoped_lock lock(mLock);
+ if (!mLocked.animationPending) {
+ mLocked.animationPending = true;
+ mLocked.animationTime = systemTime(SYSTEM_TIME_MONOTONIC);
+ mDisplayEventReceiver.requestNextVsync();
+ }
+}
+
+void PointerControllerContext::resetInactivityTimeout() {
+ std::scoped_lock lock(mLock);
+ resetInactivityTimeoutLocked();
+}
+
+void PointerControllerContext::resetInactivityTimeoutLocked() REQUIRES(mLock) {
+ mLooper->removeMessages(mHandler, MessageHandler::MSG_INACTIVITY_TIMEOUT);
+
+ nsecs_t timeout = mLocked.inactivityTimeout == InactivityTimeout::SHORT
+ ? INACTIVITY_TIMEOUT_DELAY_TIME_SHORT
+ : INACTIVITY_TIMEOUT_DELAY_TIME_NORMAL;
+ mLooper->sendMessageDelayed(timeout, mHandler, MessageHandler::MSG_INACTIVITY_TIMEOUT);
+}
+
+void PointerControllerContext::removeInactivityTimeout() {
+ std::scoped_lock lock(mLock);
+ mLooper->removeMessages(mHandler, MessageHandler::MSG_INACTIVITY_TIMEOUT);
+}
+
+void PointerControllerContext::setAnimationPending(bool animationPending) {
+ std::scoped_lock lock(mLock);
+ mLocked.animationPending = animationPending;
+}
+
+nsecs_t PointerControllerContext::getAnimationTime() {
+ std::scoped_lock lock(mLock);
+ return mLocked.animationTime;
+}
+
+void PointerControllerContext::setHandlerController(std::shared_ptr<PointerController> controller) {
+ mHandler->pointerController = controller;
+}
+
+void PointerControllerContext::setCallbackController(
+ std::shared_ptr<PointerController> controller) {
+ mCallback->pointerController = controller;
+}
+
+sp<PointerControllerPolicyInterface> PointerControllerContext::getPolicy() {
+ return mPolicy;
+}
+
+sp<SpriteController> PointerControllerContext::getSpriteController() {
+ return mSpriteController;
+}
+
+void PointerControllerContext::initializeDisplayEventReceiver() {
+ if (mDisplayEventReceiver.initCheck() == NO_ERROR) {
+ mLooper->addFd(mDisplayEventReceiver.getFd(), Looper::POLL_CALLBACK, Looper::EVENT_INPUT,
+ mCallback, nullptr);
+ } else {
+ ALOGE("Failed to initialize DisplayEventReceiver.");
+ }
+}
+
+void PointerControllerContext::handleDisplayEvents() {
+ bool gotVsync = false;
+ ssize_t n;
+ nsecs_t timestamp;
+ DisplayEventReceiver::Event buf[EVENT_BUFFER_SIZE];
+ while ((n = mDisplayEventReceiver.getEvents(buf, EVENT_BUFFER_SIZE)) > 0) {
+ for (size_t i = 0; i < static_cast<size_t>(n); ++i) {
+ if (buf[i].header.type == DisplayEventReceiver::DISPLAY_EVENT_VSYNC) {
+ timestamp = buf[i].header.timestamp;
+ gotVsync = true;
+ }
+ }
+ }
+ if (gotVsync) {
+ mController.doAnimate(timestamp);
+ }
+}
+
+void PointerControllerContext::MessageHandler::handleMessage(const Message& message) {
+ std::shared_ptr<PointerController> controller = pointerController.lock();
+
+ if (controller == nullptr) {
+ ALOGE("PointerController instance was released before processing message: what=%d",
+ message.what);
+ return;
+ }
+ switch (message.what) {
+ case MSG_INACTIVITY_TIMEOUT:
+ controller->doInactivityTimeout();
+ break;
+ }
+}
+
+int PointerControllerContext::LooperCallback::handleEvent(int /* fd */, int events,
+ void* /* data */) {
+ std::shared_ptr<PointerController> controller = pointerController.lock();
+ if (controller == nullptr) {
+ ALOGW("PointerController instance was released with pending callbacks. events=0x%x",
+ events);
+ return 0; // Remove the callback, the PointerController is gone anyways
+ }
+ if (events & (Looper::EVENT_ERROR | Looper::EVENT_HANGUP)) {
+ ALOGE("Display event receiver pipe was closed or an error occurred. events=0x%x", events);
+ return 0; // remove the callback
+ }
+
+ if (!(events & Looper::EVENT_INPUT)) {
+ ALOGW("Received spurious callback for unhandled poll event. events=0x%x", events);
+ return 1; // keep the callback
+ }
+
+ controller->mContext.handleDisplayEvents();
+ return 1; // keep the callback
+}
+
+} // namespace android
diff --git a/libs/input/PointerControllerContext.h b/libs/input/PointerControllerContext.h
new file mode 100644
index 0000000..92e1bda
--- /dev/null
+++ b/libs/input/PointerControllerContext.h
@@ -0,0 +1,154 @@
+/*
+ * 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.
+ */
+
+#ifndef _UI_POINTER_CONTROLLER_CONTEXT_H
+#define _UI_POINTER_CONTROLLER_CONTEXT_H
+
+#include <PointerControllerInterface.h>
+#include <gui/DisplayEventReceiver.h>
+#include <input/DisplayViewport.h>
+#include <input/Input.h>
+#include <ui/DisplayInfo.h>
+#include <utils/BitSet.h>
+#include <utils/Looper.h>
+#include <utils/RefBase.h>
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include "SpriteController.h"
+
+namespace android {
+
+class PointerController;
+
+/*
+ * Pointer resources.
+ */
+struct PointerResources {
+ SpriteIcon spotHover;
+ SpriteIcon spotTouch;
+ SpriteIcon spotAnchor;
+};
+
+struct PointerAnimation {
+ std::vector<SpriteIcon> animationFrames;
+ nsecs_t durationPerFrame;
+};
+
+enum class InactivityTimeout {
+ NORMAL = 0,
+ SHORT = 1,
+};
+
+/*
+ * Pointer controller policy interface.
+ *
+ * The pointer controller policy is used by the pointer controller to interact with
+ * the Window Manager and other system components.
+ *
+ * The actual implementation is partially supported by callbacks into the DVM
+ * via JNI. This interface is also mocked in the unit tests.
+ */
+class PointerControllerPolicyInterface : public virtual RefBase {
+protected:
+ PointerControllerPolicyInterface() {}
+ virtual ~PointerControllerPolicyInterface() {}
+
+public:
+ virtual void loadPointerIcon(SpriteIcon* icon, int32_t displayId) = 0;
+ virtual void loadPointerResources(PointerResources* outResources, int32_t displayId) = 0;
+ virtual void loadAdditionalMouseResources(
+ std::map<int32_t, SpriteIcon>* outResources,
+ std::map<int32_t, PointerAnimation>* outAnimationResources, int32_t displayId) = 0;
+ virtual int32_t getDefaultPointerIconId() = 0;
+ virtual int32_t getCustomPointerIconId() = 0;
+};
+
+/*
+ * Contains logic and resources shared among PointerController,
+ * MouseCursorController, and TouchSpotController.
+ */
+
+class PointerControllerContext {
+public:
+ PointerControllerContext(const sp<PointerControllerPolicyInterface>& policy,
+ const sp<Looper>& looper, const sp<SpriteController>& spriteController,
+ PointerController& controller);
+ ~PointerControllerContext();
+
+ void removeInactivityTimeout();
+ void resetInactivityTimeout();
+ void startAnimation();
+ void setInactivityTimeout(InactivityTimeout inactivityTimeout);
+
+ void setAnimationPending(bool animationPending);
+ nsecs_t getAnimationTime();
+
+ void clearSpotsByDisplay(int32_t displayId);
+
+ void setHandlerController(std::shared_ptr<PointerController> controller);
+ void setCallbackController(std::shared_ptr<PointerController> controller);
+
+ sp<PointerControllerPolicyInterface> getPolicy();
+ sp<SpriteController> getSpriteController();
+
+ void initializeDisplayEventReceiver();
+ void handleDisplayEvents();
+
+ class MessageHandler : public virtual android::MessageHandler {
+ public:
+ enum {
+ MSG_INACTIVITY_TIMEOUT,
+ };
+
+ void handleMessage(const Message& message) override;
+ std::weak_ptr<PointerController> pointerController;
+ };
+
+ class LooperCallback : public virtual android::LooperCallback {
+ public:
+ int handleEvent(int fd, int events, void* data) override;
+ std::weak_ptr<PointerController> pointerController;
+ };
+
+private:
+ sp<PointerControllerPolicyInterface> mPolicy;
+ sp<Looper> mLooper;
+ sp<SpriteController> mSpriteController;
+ sp<MessageHandler> mHandler;
+ sp<LooperCallback> mCallback;
+
+ DisplayEventReceiver mDisplayEventReceiver;
+
+ PointerController& mController;
+
+ mutable std::mutex mLock;
+
+ struct Locked {
+ bool animationPending;
+ nsecs_t animationTime;
+
+ InactivityTimeout inactivityTimeout;
+ } mLocked GUARDED_BY(mLock);
+
+ void resetInactivityTimeoutLocked();
+};
+
+} // namespace android
+
+#endif // _UI_POINTER_CONTROLLER_CONTEXT_H
diff --git a/libs/input/TouchSpotController.cpp b/libs/input/TouchSpotController.cpp
new file mode 100644
index 0000000..c7430ce
--- /dev/null
+++ b/libs/input/TouchSpotController.cpp
@@ -0,0 +1,236 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "TouchSpotController"
+
+// Log debug messages about pointer updates
+#define DEBUG_SPOT_UPDATES 0
+
+#include "TouchSpotController.h"
+
+#include <log/log.h>
+
+#include <SkBitmap.h>
+#include <SkBlendMode.h>
+#include <SkCanvas.h>
+#include <SkColor.h>
+#include <SkPaint.h>
+
+namespace {
+// Time to spend fading out the spot completely.
+const nsecs_t SPOT_FADE_DURATION = 200 * 1000000LL; // 200 ms
+} // namespace
+
+namespace android {
+
+// --- Spot ---
+
+void TouchSpotController::Spot::updateSprite(const SpriteIcon* icon, float x, float y,
+ int32_t displayId) {
+ sprite->setLayer(Sprite::BASE_LAYER_SPOT + id);
+ sprite->setAlpha(alpha);
+ sprite->setTransformationMatrix(SpriteTransformationMatrix(scale, 0.0f, 0.0f, scale));
+ sprite->setPosition(x, y);
+ sprite->setDisplayId(displayId);
+ this->x = x;
+ this->y = y;
+
+ if (icon != mLastIcon) {
+ mLastIcon = icon;
+ if (icon) {
+ sprite->setIcon(*icon);
+ sprite->setVisible(true);
+ } else {
+ sprite->setVisible(false);
+ }
+ }
+}
+
+// --- TouchSpotController ---
+
+TouchSpotController::TouchSpotController(int32_t displayId, PointerControllerContext& context)
+ : mDisplayId(displayId), mContext(context) {
+ mContext.getPolicy()->loadPointerResources(&mResources, mDisplayId);
+}
+
+TouchSpotController::~TouchSpotController() {
+ std::scoped_lock lock(mLock);
+
+ size_t numSpots = mLocked.displaySpots.size();
+ for (size_t i = 0; i < numSpots; i++) {
+ delete mLocked.displaySpots[i];
+ }
+ mLocked.displaySpots.clear();
+}
+
+void TouchSpotController::setSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex,
+ BitSet32 spotIdBits) {
+#if DEBUG_SPOT_UPDATES
+ ALOGD("setSpots: idBits=%08x", spotIdBits.value);
+ for (BitSet32 idBits(spotIdBits); !idBits.isEmpty();) {
+ uint32_t id = idBits.firstMarkedBit();
+ idBits.clearBit(id);
+ const PointerCoords& c = spotCoords[spotIdToIndex[id]];
+ ALOGD(" spot %d: position=(%0.3f, %0.3f), pressure=%0.3f, displayId=%" PRId32 ".", id,
+ c.getAxisValue(AMOTION_EVENT_AXIS_X), c.getAxisValue(AMOTION_EVENT_AXIS_Y),
+ c.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE), displayId);
+ }
+#endif
+
+ std::scoped_lock lock(mLock);
+ sp<SpriteController> spriteController = mContext.getSpriteController();
+ spriteController->openTransaction();
+
+ // Add or move spots for fingers that are down.
+ for (BitSet32 idBits(spotIdBits); !idBits.isEmpty();) {
+ uint32_t id = idBits.clearFirstMarkedBit();
+ const PointerCoords& c = spotCoords[spotIdToIndex[id]];
+ const SpriteIcon& icon = c.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE) > 0
+ ? mResources.spotTouch
+ : mResources.spotHover;
+ float x = c.getAxisValue(AMOTION_EVENT_AXIS_X);
+ float y = c.getAxisValue(AMOTION_EVENT_AXIS_Y);
+
+ Spot* spot = getSpot(id, mLocked.displaySpots);
+ if (!spot) {
+ spot = createAndAddSpotLocked(id, mLocked.displaySpots);
+ }
+
+ spot->updateSprite(&icon, x, y, mDisplayId);
+ }
+
+ for (Spot* spot : mLocked.displaySpots) {
+ if (spot->id != Spot::INVALID_ID && !spotIdBits.hasBit(spot->id)) {
+ fadeOutAndReleaseSpotLocked(spot);
+ }
+ }
+
+ spriteController->closeTransaction();
+}
+
+void TouchSpotController::clearSpots() {
+#if DEBUG_SPOT_UPDATES
+ ALOGD("clearSpots");
+#endif
+
+ std::scoped_lock lock(mLock);
+ fadeOutAndReleaseAllSpotsLocked();
+}
+
+TouchSpotController::Spot* TouchSpotController::getSpot(uint32_t id,
+ const std::vector<Spot*>& spots) {
+ for (size_t i = 0; i < spots.size(); i++) {
+ Spot* spot = spots[i];
+ if (spot->id == id) {
+ return spot;
+ }
+ }
+ return nullptr;
+}
+
+TouchSpotController::Spot* TouchSpotController::createAndAddSpotLocked(uint32_t id,
+ std::vector<Spot*>& spots) {
+ // Remove spots until we have fewer than MAX_SPOTS remaining.
+ while (spots.size() >= MAX_SPOTS) {
+ Spot* spot = removeFirstFadingSpotLocked(spots);
+ if (!spot) {
+ spot = spots[0];
+ spots.erase(spots.begin());
+ }
+ releaseSpotLocked(spot);
+ }
+
+ // Obtain a sprite from the recycled pool.
+ sp<Sprite> sprite;
+ if (!mLocked.recycledSprites.empty()) {
+ sprite = mLocked.recycledSprites.back();
+ mLocked.recycledSprites.pop_back();
+ } else {
+ sprite = mContext.getSpriteController()->createSprite();
+ }
+
+ // Return the new spot.
+ Spot* spot = new Spot(id, sprite);
+ spots.push_back(spot);
+ return spot;
+}
+
+TouchSpotController::Spot* TouchSpotController::removeFirstFadingSpotLocked(
+ std::vector<Spot*>& spots) REQUIRES(mLock) {
+ for (size_t i = 0; i < spots.size(); i++) {
+ Spot* spot = spots[i];
+ if (spot->id == Spot::INVALID_ID) {
+ spots.erase(spots.begin() + i);
+ return spot;
+ }
+ }
+ return NULL;
+}
+
+void TouchSpotController::releaseSpotLocked(Spot* spot) REQUIRES(mLock) {
+ spot->sprite->clearIcon();
+
+ if (mLocked.recycledSprites.size() < MAX_RECYCLED_SPRITES) {
+ mLocked.recycledSprites.push_back(spot->sprite);
+ }
+
+ delete spot;
+}
+
+void TouchSpotController::fadeOutAndReleaseSpotLocked(Spot* spot) REQUIRES(mLock) {
+ if (spot->id != Spot::INVALID_ID) {
+ spot->id = Spot::INVALID_ID;
+ mContext.startAnimation();
+ }
+}
+
+void TouchSpotController::fadeOutAndReleaseAllSpotsLocked() REQUIRES(mLock) {
+ size_t numSpots = mLocked.displaySpots.size();
+ for (size_t i = 0; i < numSpots; i++) {
+ Spot* spot = mLocked.displaySpots[i];
+ fadeOutAndReleaseSpotLocked(spot);
+ }
+}
+
+void TouchSpotController::reloadSpotResources() {
+ mContext.getPolicy()->loadPointerResources(&mResources, mDisplayId);
+}
+
+bool TouchSpotController::doFadingAnimation(nsecs_t timestamp, bool keepAnimating) {
+ std::scoped_lock lock(mLock);
+ nsecs_t animationTime = mContext.getAnimationTime();
+ nsecs_t frameDelay = timestamp - animationTime;
+ size_t numSpots = mLocked.displaySpots.size();
+ for (size_t i = 0; i < numSpots;) {
+ Spot* spot = mLocked.displaySpots[i];
+ if (spot->id == Spot::INVALID_ID) {
+ spot->alpha -= float(frameDelay) / SPOT_FADE_DURATION;
+ if (spot->alpha <= 0) {
+ mLocked.displaySpots.erase(mLocked.displaySpots.begin() + i);
+ releaseSpotLocked(spot);
+ numSpots--;
+ continue;
+ } else {
+ spot->sprite->setAlpha(spot->alpha);
+ keepAnimating = true;
+ }
+ }
+ ++i;
+ }
+ return keepAnimating;
+}
+
+} // namespace android
diff --git a/libs/input/TouchSpotController.h b/libs/input/TouchSpotController.h
new file mode 100644
index 0000000..f3b3550
--- /dev/null
+++ b/libs/input/TouchSpotController.h
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+
+#ifndef _UI_TOUCH_SPOT_CONTROLLER_H
+#define _UI_TOUCH_SPOT_CONTROLLER_H
+
+#include "PointerControllerContext.h"
+
+namespace android {
+
+/*
+ * Helper class for PointerController that specifically handles
+ * touch spot resources and actions for a single display.
+ */
+class TouchSpotController {
+public:
+ TouchSpotController(int32_t displayId, PointerControllerContext& context);
+ ~TouchSpotController();
+ void setSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex,
+ BitSet32 spotIdBits);
+ void clearSpots();
+
+ void reloadSpotResources();
+ bool doFadingAnimation(nsecs_t timestamp, bool keepAnimating);
+
+private:
+ struct Spot {
+ static const uint32_t INVALID_ID = 0xffffffff;
+
+ uint32_t id;
+ sp<Sprite> sprite;
+ float alpha;
+ float scale;
+ float x, y;
+
+ inline Spot(uint32_t id, const sp<Sprite>& sprite)
+ : id(id),
+ sprite(sprite),
+ alpha(1.0f),
+ scale(1.0f),
+ x(0.0f),
+ y(0.0f),
+ mLastIcon(nullptr) {}
+
+ void updateSprite(const SpriteIcon* icon, float x, float y, int32_t displayId);
+
+ private:
+ const SpriteIcon* mLastIcon;
+ };
+
+ int32_t mDisplayId;
+
+ mutable std::mutex mLock;
+
+ PointerResources mResources;
+
+ PointerControllerContext& mContext;
+
+ static constexpr size_t MAX_RECYCLED_SPRITES = 12;
+ static constexpr size_t MAX_SPOTS = 12;
+
+ struct Locked {
+ std::vector<Spot*> displaySpots;
+ std::vector<sp<Sprite>> recycledSprites;
+
+ } mLocked GUARDED_BY(mLock);
+
+ Spot* getSpot(uint32_t id, const std::vector<Spot*>& spots);
+ Spot* createAndAddSpotLocked(uint32_t id, std::vector<Spot*>& spots);
+ Spot* removeFirstFadingSpotLocked(std::vector<Spot*>& spots);
+ void releaseSpotLocked(Spot* spot);
+ void fadeOutAndReleaseSpotLocked(Spot* spot);
+ void fadeOutAndReleaseAllSpotsLocked();
+};
+
+} // namespace android
+
+#endif // _UI_TOUCH_SPOT_CONTROLLER_H
diff --git a/libs/input/tests/PointerController_test.cpp b/libs/input/tests/PointerController_test.cpp
index 6e129a0..b67088a 100644
--- a/libs/input/tests/PointerController_test.cpp
+++ b/libs/input/tests/PointerController_test.cpp
@@ -178,9 +178,6 @@
viewport.deviceWidth = 400;
viewport.deviceHeight = 300;
mPointerController->setDisplayViewport(viewport);
-
- // The first call to setDisplayViewport should trigger the loading of the necessary resources.
- EXPECT_TRUE(mPolicy->allResourcesAreLoaded());
}
void PointerControllerTest::loopThread() {
@@ -208,6 +205,7 @@
TEST_F(PointerControllerTest, updatePointerIcon) {
ensureDisplayViewportIsSet();
+ mPointerController->setPresentation(PointerController::Presentation::POINTER);
mPointerController->unfade(PointerController::Transition::IMMEDIATE);
int32_t type = CURSOR_TYPE_ADDITIONAL;
@@ -247,8 +245,6 @@
TEST_F(PointerControllerTest, doesNotGetResourcesBeforeSettingViewport) {
mPointerController->setPresentation(PointerController::Presentation::POINTER);
- mPointerController->setSpots(nullptr, nullptr, BitSet32(), -1);
- mPointerController->clearSpots();
mPointerController->setPosition(1.0f, 1.0f);
mPointerController->move(1.0f, 1.0f);
mPointerController->unfade(PointerController::Transition::IMMEDIATE);
diff --git a/media/java/android/media/AudioDeviceInfo.java b/media/java/android/media/AudioDeviceInfo.java
index 6e3fb19..d4fb1be 100644
--- a/media/java/android/media/AudioDeviceInfo.java
+++ b/media/java/android/media/AudioDeviceInfo.java
@@ -147,6 +147,19 @@
// {@link android.media.audiopolicy.AudioMix#ROUTE_FLAG_LOOP_BACK} flag.
public static final int TYPE_REMOTE_SUBMIX = 25;
+ /**
+ * A device type describing a Bluetooth Low Energy (BLE) audio headset or headphones.
+ * Headphones are grouped with headsets when the device is a sink:
+ * the features of headsets and headphones with regard to playback are the same.
+ */
+ public static final int TYPE_BLE_HEADSET = 26;
+
+ /**
+ * A device type describing a Bluetooth Low Energy (BLE) audio speaker.
+ */
+ public static final int TYPE_BLE_SPEAKER = 27;
+
+
/** @hide */
@IntDef(flag = false, prefix = "TYPE", value = {
TYPE_BUILTIN_EARPIECE,
@@ -171,7 +184,9 @@
TYPE_HEARING_AID,
TYPE_BUILTIN_MIC,
TYPE_FM_TUNER,
- TYPE_TV_TUNER }
+ TYPE_TV_TUNER,
+ TYPE_BLE_HEADSET,
+ TYPE_BLE_SPEAKER}
)
@Retention(RetentionPolicy.SOURCE)
public @interface AudioDeviceType {}
@@ -193,7 +208,8 @@
TYPE_LINE_ANALOG,
TYPE_LINE_DIGITAL,
TYPE_IP,
- TYPE_BUS }
+ TYPE_BUS,
+ TYPE_BLE_HEADSET}
)
@Retention(RetentionPolicy.SOURCE)
public @interface AudioDeviceTypeIn {}
@@ -219,7 +235,9 @@
TYPE_AUX_LINE,
TYPE_IP,
TYPE_BUS,
- TYPE_HEARING_AID }
+ TYPE_HEARING_AID,
+ TYPE_BLE_HEADSET,
+ TYPE_BLE_SPEAKER}
)
@Retention(RetentionPolicy.SOURCE)
public @interface AudioDeviceTypeOut {}
@@ -248,7 +266,8 @@
case TYPE_BUS:
case TYPE_HEARING_AID:
case TYPE_BUILTIN_SPEAKER_SAFE:
- case TYPE_REMOTE_SUBMIX:
+ case TYPE_BLE_HEADSET:
+ case TYPE_BLE_SPEAKER:
return true;
default:
return false;
@@ -275,6 +294,7 @@
case TYPE_IP:
case TYPE_BUS:
case TYPE_REMOTE_SUBMIX:
+ case TYPE_BLE_HEADSET:
return true;
default:
return false;
@@ -527,6 +547,8 @@
INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_SPEAKER_SAFE,
TYPE_BUILTIN_SPEAKER_SAFE);
INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_REMOTE_SUBMIX, TYPE_REMOTE_SUBMIX);
+ INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLE_HEADSET, TYPE_BLE_HEADSET);
+ INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLE_SPEAKER, TYPE_BLE_SPEAKER);
INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BUILTIN_MIC, TYPE_BUILTIN_MIC);
INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BLUETOOTH_SCO_HEADSET, TYPE_BLUETOOTH_SCO);
@@ -547,6 +569,7 @@
INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_IP, TYPE_IP);
INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BUS, TYPE_BUS);
INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_REMOTE_SUBMIX, TYPE_REMOTE_SUBMIX);
+ INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BLE_HEADSET, TYPE_BLE_HEADSET);
// privileges mapping to output device
EXT_TO_INT_DEVICE_MAPPING = new SparseIntArray();
@@ -576,6 +599,8 @@
EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BUILTIN_SPEAKER_SAFE,
AudioSystem.DEVICE_OUT_SPEAKER_SAFE);
EXT_TO_INT_DEVICE_MAPPING.put(TYPE_REMOTE_SUBMIX, AudioSystem.DEVICE_OUT_REMOTE_SUBMIX);
+ EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BLE_HEADSET, AudioSystem.DEVICE_OUT_BLE_HEADSET);
+ EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BLE_SPEAKER, AudioSystem.DEVICE_OUT_BLE_SPEAKER);
}
}
diff --git a/media/java/android/media/AudioDevicePort.java b/media/java/android/media/AudioDevicePort.java
index 42d0f0c..f6b0454 100644
--- a/media/java/android/media/AudioDevicePort.java
+++ b/media/java/android/media/AudioDevicePort.java
@@ -70,7 +70,9 @@
* {@link AudioManager#DEVICE_IN_USB_DEVICE}) use an address composed of the ALSA card number
* and device number: "card=2;device=1"
* - Bluetooth devices ({@link AudioManager#DEVICE_OUT_BLUETOOTH_SCO},
- * {@link AudioManager#DEVICE_OUT_BLUETOOTH_SCO}, {@link AudioManager#DEVICE_OUT_BLUETOOTH_A2DP})
+ * {@link AudioManager#DEVICE_OUT_BLUETOOTH_SCO},
+ * {@link AudioManager#DEVICE_OUT_BLUETOOTH_A2DP}),
+ * {@link AudioManager#DEVICE_OUT_BLE_HEADSET}, {@link AudioManager#DEVICE_OUT_BLE_SPEAKER})
* use the MAC address of the bluetooth device in the form "00:11:22:AA:BB:CC" as reported by
* {@link BluetoothDevice#getAddress()}.
* - Deivces that do not have an address will indicate an empty string "".
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 408f34b..b2e0538 100755
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -4413,6 +4413,18 @@
*/
public static final int DEVICE_OUT_FM = AudioSystem.DEVICE_OUT_FM;
/** @hide
+ * The audio output device code for echo reference injection point.
+ */
+ public static final int DEVICE_OUT_ECHO_CANCELLER = AudioSystem.DEVICE_OUT_ECHO_CANCELLER;
+ /** @hide
+ * The audio output device code for a BLE audio headset.
+ */
+ public static final int DEVICE_OUT_BLE_HEADSET = AudioSystem.DEVICE_OUT_BLE_HEADSET;
+ /** @hide
+ * The audio output device code for a BLE audio speaker.
+ */
+ public static final int DEVICE_OUT_BLE_SPEAKER = AudioSystem.DEVICE_OUT_BLE_SPEAKER;
+ /** @hide
* This is not used as a returned value from {@link #getDevicesForStream}, but could be
* used in the future in a set method to select whatever default device is chosen by the
* platform-specific implementation.
@@ -4496,6 +4508,14 @@
* The audio input device code for audio loopback
*/
public static final int DEVICE_IN_LOOPBACK = AudioSystem.DEVICE_IN_LOOPBACK;
+ /** @hide
+ * The audio input device code for an echo reference capture point.
+ */
+ public static final int DEVICE_IN_ECHO_REFERENCE = AudioSystem.DEVICE_IN_ECHO_REFERENCE;
+ /** @hide
+ * The audio input device code for a BLE audio headset.
+ */
+ public static final int DEVICE_IN_BLE_HEADSET = AudioSystem.DEVICE_IN_BLE_HEADSET;
/**
* Return true if the device code corresponds to an output device.
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index da52cfe..5fe5c05 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -866,6 +866,12 @@
public static final int DEVICE_OUT_USB_HEADSET = 0x4000000;
/** @hide */
public static final int DEVICE_OUT_HEARING_AID = 0x8000000;
+ /** @hide */
+ public static final int DEVICE_OUT_ECHO_CANCELLER = 0x10000000;
+ /** @hide */
+ public static final int DEVICE_OUT_BLE_HEADSET = 0x20000000;
+ /** @hide */
+ public static final int DEVICE_OUT_BLE_SPEAKER = 0x20000001;
/** @hide */
public static final int DEVICE_OUT_DEFAULT = DEVICE_BIT_DEFAULT;
@@ -890,6 +896,8 @@
public static final Set<Integer> DEVICE_OUT_ALL_HDMI_SYSTEM_AUDIO_SET;
/** @hide */
public static final Set<Integer> DEVICE_ALL_HDMI_SYSTEM_AUDIO_AND_SPEAKER_SET;
+ /** @hide */
+ public static final Set<Integer> DEVICE_OUT_ALL_BLE_SET;
static {
DEVICE_OUT_ALL_SET = new HashSet<>();
DEVICE_OUT_ALL_SET.add(DEVICE_OUT_EARPIECE);
@@ -920,6 +928,9 @@
DEVICE_OUT_ALL_SET.add(DEVICE_OUT_PROXY);
DEVICE_OUT_ALL_SET.add(DEVICE_OUT_USB_HEADSET);
DEVICE_OUT_ALL_SET.add(DEVICE_OUT_HEARING_AID);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_ECHO_CANCELLER);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_BLE_HEADSET);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_BLE_SPEAKER);
DEVICE_OUT_ALL_SET.add(DEVICE_OUT_DEFAULT);
DEVICE_OUT_ALL_A2DP_SET = new HashSet<>();
@@ -945,6 +956,10 @@
DEVICE_ALL_HDMI_SYSTEM_AUDIO_AND_SPEAKER_SET = new HashSet<>();
DEVICE_ALL_HDMI_SYSTEM_AUDIO_AND_SPEAKER_SET.addAll(DEVICE_OUT_ALL_HDMI_SYSTEM_AUDIO_SET);
DEVICE_ALL_HDMI_SYSTEM_AUDIO_AND_SPEAKER_SET.add(DEVICE_OUT_SPEAKER);
+
+ DEVICE_OUT_ALL_BLE_SET = new HashSet<>();
+ DEVICE_OUT_ALL_BLE_SET.add(DEVICE_OUT_BLE_HEADSET);
+ DEVICE_OUT_ALL_BLE_SET.add(DEVICE_OUT_BLE_SPEAKER);
}
// input devices
@@ -1019,6 +1034,8 @@
/** @hide */
public static final int DEVICE_IN_ECHO_REFERENCE = DEVICE_BIT_IN | 0x10000000;
/** @hide */
+ public static final int DEVICE_IN_BLE_HEADSET = DEVICE_BIT_IN | 0x20000000;
+ /** @hide */
@UnsupportedAppUsage
public static final int DEVICE_IN_DEFAULT = DEVICE_BIT_IN | DEVICE_BIT_DEFAULT;
@@ -1056,6 +1073,7 @@
DEVICE_IN_ALL_SET.add(DEVICE_IN_BLUETOOTH_BLE);
DEVICE_IN_ALL_SET.add(DEVICE_IN_HDMI_ARC);
DEVICE_IN_ALL_SET.add(DEVICE_IN_ECHO_REFERENCE);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_BLE_HEADSET);
DEVICE_IN_ALL_SET.add(DEVICE_IN_DEFAULT);
DEVICE_IN_ALL_SCO_SET = new HashSet<>();
@@ -1118,6 +1136,9 @@
/** @hide */ public static final String DEVICE_OUT_PROXY_NAME = "proxy";
/** @hide */ public static final String DEVICE_OUT_USB_HEADSET_NAME = "usb_headset";
/** @hide */ public static final String DEVICE_OUT_HEARING_AID_NAME = "hearing_aid_out";
+ /** @hide */ public static final String DEVICE_OUT_ECHO_CANCELLER_NAME = "echo_canceller";
+ /** @hide */ public static final String DEVICE_OUT_BLE_HEADSET_NAME = "ble_headset";
+ /** @hide */ public static final String DEVICE_OUT_BLE_SPEAKER_NAME = "ble_speaker";
/** @hide */ public static final String DEVICE_IN_COMMUNICATION_NAME = "communication";
/** @hide */ public static final String DEVICE_IN_AMBIENT_NAME = "ambient";
@@ -1145,6 +1166,7 @@
/** @hide */ public static final String DEVICE_IN_BLUETOOTH_BLE_NAME = "bt_ble";
/** @hide */ public static final String DEVICE_IN_ECHO_REFERENCE_NAME = "echo_reference";
/** @hide */ public static final String DEVICE_IN_HDMI_ARC_NAME = "hdmi_arc";
+ /** @hide */ public static final String DEVICE_IN_BLE_HEADSET_NAME = "ble_headset";
/** @hide */
@UnsupportedAppUsage
@@ -1207,6 +1229,12 @@
return DEVICE_OUT_USB_HEADSET_NAME;
case DEVICE_OUT_HEARING_AID:
return DEVICE_OUT_HEARING_AID_NAME;
+ case DEVICE_OUT_ECHO_CANCELLER:
+ return DEVICE_OUT_ECHO_CANCELLER_NAME;
+ case DEVICE_OUT_BLE_HEADSET:
+ return DEVICE_OUT_BLE_HEADSET_NAME;
+ case DEVICE_OUT_BLE_SPEAKER:
+ return DEVICE_OUT_BLE_SPEAKER_NAME;
case DEVICE_OUT_DEFAULT:
default:
return Integer.toString(device);
@@ -1269,6 +1297,8 @@
return DEVICE_IN_ECHO_REFERENCE_NAME;
case DEVICE_IN_HDMI_ARC:
return DEVICE_IN_HDMI_ARC_NAME;
+ case DEVICE_IN_BLE_HEADSET:
+ return DEVICE_IN_BLE_HEADSET_NAME;
case DEVICE_IN_DEFAULT:
default:
return Integer.toString(device);
diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java
index 6fa3787..2b3f420c 100644
--- a/media/java/android/media/MediaRouter.java
+++ b/media/java/android/media/MediaRouter.java
@@ -1616,9 +1616,9 @@
Drawable mIcon;
// playback information
int mPlaybackType = PLAYBACK_TYPE_LOCAL;
- int mVolumeMax = RemoteControlClient.DEFAULT_PLAYBACK_VOLUME;
- int mVolume = RemoteControlClient.DEFAULT_PLAYBACK_VOLUME;
- int mVolumeHandling = RemoteControlClient.DEFAULT_PLAYBACK_VOLUME_HANDLING;
+ int mVolumeMax = DEFAULT_PLAYBACK_MAX_VOLUME;
+ int mVolume = DEFAULT_PLAYBACK_VOLUME;
+ int mVolumeHandling = PLAYBACK_VOLUME_VARIABLE;
int mPlaybackStream = AudioManager.STREAM_MUSIC;
VolumeCallbackInfo mVcb;
Display mPresentationDisplay;
@@ -1722,6 +1722,21 @@
*/
public final static int PLAYBACK_VOLUME_VARIABLE = 1;
+ /**
+ * Default playback max volume if not set.
+ * Hard-coded to the same number of steps as AudioService.MAX_STREAM_VOLUME[STREAM_MUSIC]
+ *
+ * @see #getVolumeMax()
+ */
+ private static final int DEFAULT_PLAYBACK_MAX_VOLUME = 15;
+
+ /**
+ * Default playback volume if not set.
+ *
+ * @see #getVolume()
+ */
+ private static final int DEFAULT_PLAYBACK_VOLUME = DEFAULT_PLAYBACK_MAX_VOLUME;
+
RouteInfo(RouteCategory category) {
mCategory = category;
mDeviceType = DEVICE_TYPE_UNKNOWN;
@@ -2430,13 +2445,13 @@
}
return;
}
- if (mPlaybackType == RemoteControlClient.PLAYBACK_TYPE_REMOTE) {
+ if (mPlaybackType == PLAYBACK_TYPE_REMOTE) {
int volumeControl = VolumeProvider.VOLUME_CONTROL_FIXED;
switch (mVolumeHandling) {
- case RemoteControlClient.PLAYBACK_VOLUME_VARIABLE:
+ case PLAYBACK_VOLUME_VARIABLE:
volumeControl = VolumeProvider.VOLUME_CONTROL_ABSOLUTE;
break;
- case RemoteControlClient.PLAYBACK_VOLUME_FIXED:
+ case PLAYBACK_VOLUME_FIXED:
default:
break;
}
diff --git a/media/java/android/media/MediaTranscodeManager.java b/media/java/android/media/MediaTranscodeManager.java
index e959e8e..e1bff03 100644
--- a/media/java/android/media/MediaTranscodeManager.java
+++ b/media/java/android/media/MediaTranscodeManager.java
@@ -225,13 +225,50 @@
job.updateStatusAndResult(TranscodingJob.STATUS_FINISHED,
TranscodingJob.RESULT_ERROR);
- // Notifies client the job is done.
+ // Notifies client the job failed.
if (job.mListener != null && job.mListenerExecutor != null) {
job.mListenerExecutor.execute(() -> job.mListener.onTranscodingFinished(job));
}
}
}
+ private void handleTranscodingProgressUpdate(int jobId, int newProgress) {
+ synchronized (mPendingTranscodingJobs) {
+ // Gets the job associated with the jobId.
+ final TranscodingJob job = mPendingTranscodingJobs.get(jobId);
+
+ if (job == null) {
+ // This should not happen in reality.
+ Log.e(TAG, "Job " + jobId + " is not in PendingJobs");
+ return;
+ }
+
+ // Updates the job progress.
+ job.updateProgress(newProgress);
+
+ // Notifies client the progress update.
+ if (job.mProgressUpdateExecutor != null && job.mProgressUpdateListener != null) {
+ job.mProgressUpdateExecutor.execute(
+ () -> job.mProgressUpdateListener.onProgressUpdate(newProgress));
+ }
+ }
+ }
+
+ private void updateStatus(int jobId, int status) {
+ synchronized (mPendingTranscodingJobs) {
+ final TranscodingJob job = mPendingTranscodingJobs.get(jobId);
+
+ if (job == null) {
+ // This should not happen in reality.
+ Log.e(TAG, "Job " + jobId + " is not in PendingJobs");
+ return;
+ }
+
+ // Updates the job status.
+ job.updateStatus(status);
+ }
+ }
+
// Just forwards all the events to the event handler.
private ITranscodingClientCallback mTranscodingClientCallback =
new ITranscodingClientCallback.Stub() {
@@ -263,17 +300,17 @@
@Override
public void onTranscodingStarted(int jobId) throws RemoteException {
-
+ updateStatus(jobId, TranscodingJob.STATUS_RUNNING);
}
@Override
public void onTranscodingPaused(int jobId) throws RemoteException {
-
+ updateStatus(jobId, TranscodingJob.STATUS_PAUSED);
}
@Override
public void onTranscodingResumed(int jobId) throws RemoteException {
-
+ updateStatus(jobId, TranscodingJob.STATUS_RUNNING);
}
@Override
@@ -294,8 +331,8 @@
}
@Override
- public void onProgressUpdate(int jobId, int progress) throws RemoteException {
- //TODO(hkuang): Implement this.
+ public void onProgressUpdate(int jobId, int newProgress) throws RemoteException {
+ handleTranscodingProgressUpdate(jobId, newProgress);
}
};
@@ -661,11 +698,14 @@
public static final int STATUS_RUNNING = 2;
/** The job is finished. */
public static final int STATUS_FINISHED = 3;
+ /** The job is paused. */
+ public static final int STATUS_PAUSED = 4;
@IntDef(prefix = { "STATUS_" }, value = {
STATUS_PENDING,
STATUS_RUNNING,
STATUS_FINISHED,
+ STATUS_PAUSED,
})
@Retention(RetentionPolicy.SOURCE)
public @interface Status {}
@@ -821,17 +861,12 @@
return mResult;
}
- private void setJobProgress(int newProgress) {
- synchronized (this) {
- mProgress = newProgress;
- }
+ private synchronized void updateProgress(int newProgress) {
+ mProgress = newProgress;
+ }
- // Notify listener.
- OnProgressUpdateListener onProgressUpdateListener = mProgressUpdateListener;
- if (mProgressUpdateListener != null) {
- mProgressUpdateExecutor.execute(
- () -> onProgressUpdateListener.onProgressUpdate(mProgress));
- }
+ private synchronized void updateStatus(int newStatus) {
+ mStatus = newStatus;
}
}
diff --git a/media/java/android/media/audiopolicy/AudioPolicyConfig.java b/media/java/android/media/audiopolicy/AudioPolicyConfig.java
index 561a884..697d80c 100644
--- a/media/java/android/media/audiopolicy/AudioPolicyConfig.java
+++ b/media/java/android/media/audiopolicy/AudioPolicyConfig.java
@@ -220,6 +220,34 @@
return textDump;
}
+ /**
+ * Very short dump of configuration
+ * @return a condensed dump of configuration, uniquely identifies a policy in a log
+ */
+ public String toCompactLogString() {
+ String compactDump = "reg:" + mRegistrationId;
+ int mixNum = 0;
+ for (AudioMix mix : mMixes) {
+ compactDump += " Mix:" + mixNum + "-Typ:" + mixTypePrefix(mix.getMixType())
+ + "-Rul:" + mix.getRule().getCriteria().size();
+ mixNum++;
+ }
+ return compactDump;
+ }
+
+ private static String mixTypePrefix(int mixType) {
+ switch (mixType) {
+ case AudioMix.MIX_TYPE_PLAYERS:
+ return "p";
+ case AudioMix.MIX_TYPE_RECORDERS:
+ return "r";
+ case AudioMix.MIX_TYPE_INVALID:
+ default:
+ return "#";
+
+ }
+ }
+
protected void reset() {
mMixCounter = 0;
}
diff --git a/media/java/android/media/session/MediaSession.java b/media/java/android/media/session/MediaSession.java
index 8bf462c..70bd160 100644
--- a/media/java/android/media/session/MediaSession.java
+++ b/media/java/android/media/session/MediaSession.java
@@ -19,6 +19,7 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.app.Activity;
import android.app.PendingIntent;
import android.compat.annotation.UnsupportedAppUsage;
@@ -105,6 +106,7 @@
*
* @hide
*/
+ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
public static final int FLAG_EXCLUSIVE_GLOBAL_PRIORITY = 1 << 16;
/**
diff --git a/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaTranscodeManagerTest.java b/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaTranscodeManagerTest.java
index 3a5e692..8fe1088 100644
--- a/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaTranscodeManagerTest.java
+++ b/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaTranscodeManagerTest.java
@@ -33,10 +33,12 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
/*
* Functional tests for MediaTranscodeManager in the media framework.
@@ -230,5 +232,73 @@
30, TimeUnit.MILLISECONDS);
assertTrue("Fails to cancel transcoding", finishedOnTime);
}
+
+
+ @Test
+ public void testTranscodingProgressUpdate() throws Exception {
+ Log.d(TAG, "Starting: testMediaTranscodeManager");
+
+ Semaphore transcodeCompleteSemaphore = new Semaphore(0);
+ final CountDownLatch statusLatch = new CountDownLatch(1);
+
+ // Create a file Uri: file:///data/user/0/com.android.mediatranscodingtest/cache/temp.mp4
+ // The full path of this file is:
+ // /data/user/0/com.android.mediatranscodingtest/cache/temp.mp4
+ Uri destinationUri = Uri.parse(ContentResolver.SCHEME_FILE + "://"
+ + mContext.getCacheDir().getAbsolutePath() + "/HevcTranscode.mp4");
+
+ TranscodingRequest request =
+ new TranscodingRequest.Builder()
+ .setSourceUri(mSourceHEVCVideoUri)
+ .setDestinationUri(destinationUri)
+ .setType(MediaTranscodeManager.TRANSCODING_TYPE_VIDEO)
+ .setPriority(MediaTranscodeManager.PRIORITY_REALTIME)
+ .setVideoTrackFormat(createMediaFormat())
+ .build();
+ Executor listenerExecutor = Executors.newSingleThreadExecutor();
+
+ Log.i(TAG, "transcoding to " + createMediaFormat());
+
+ TranscodingJob job = mMediaTranscodeManager.enqueueRequest(request, listenerExecutor,
+ transcodingJob -> {
+ Log.d(TAG, "Transcoding completed with result: " + transcodingJob.getResult());
+ assertEquals(transcodingJob.getResult(), TranscodingJob.RESULT_SUCCESS);
+ transcodeCompleteSemaphore.release();
+ });
+ assertNotNull(job);
+
+ AtomicInteger progressUpdateCount = new AtomicInteger(0);
+
+ // Set progress update executor and use the same executor as result listener.
+ job.setOnProgressUpdateListener(listenerExecutor,
+ new TranscodingJob.OnProgressUpdateListener() {
+ int mPreviousProgress = 0;
+
+ @Override
+ public void onProgressUpdate(int newProgress) {
+ assertTrue("Invalid proress update", newProgress > mPreviousProgress);
+ assertTrue("Invalid proress update", newProgress <= 100);
+ if (newProgress > 0) {
+ statusLatch.countDown();
+ }
+ mPreviousProgress = newProgress;
+ progressUpdateCount.getAndIncrement();
+ Log.i(TAG, "Get progress update " + newProgress);
+ }
+ });
+
+ try {
+ statusLatch.await();
+ // The transcoding should not be finished yet as the clip is long.
+ assertTrue("Invalid status", job.getStatus() == TranscodingJob.STATUS_RUNNING);
+ } catch (InterruptedException e) { }
+
+ Log.d(TAG, "testMediaTranscodeManager - Waiting for transcode to cancel.");
+ boolean finishedOnTime = transcodeCompleteSemaphore.tryAcquire(
+ TRANSCODE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+ assertTrue("Transcode failed to complete in time.", finishedOnTime);
+ assertTrue("Failed to receive at least 10 progress updates",
+ progressUpdateCount.get() > 10);
+ }
}
diff --git a/non-updatable-api/current.txt b/non-updatable-api/current.txt
index 70ef69d..51e7287 100644
--- a/non-updatable-api/current.txt
+++ b/non-updatable-api/current.txt
@@ -5596,6 +5596,7 @@
method public android.graphics.drawable.Icon getIcon();
method public android.app.RemoteInput[] getRemoteInputs();
method public int getSemanticAction();
+ method public boolean isAuthenticationRequired();
method public boolean isContextual();
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.app.Notification.Action> CREATOR;
@@ -5625,6 +5626,7 @@
method @NonNull public android.app.Notification.Action.Builder extend(android.app.Notification.Action.Extender);
method @NonNull public android.os.Bundle getExtras();
method @NonNull public android.app.Notification.Action.Builder setAllowGeneratedReplies(boolean);
+ method @NonNull public android.app.Notification.Action.Builder setAuthenticationRequired(boolean);
method @NonNull public android.app.Notification.Action.Builder setContextual(boolean);
method @NonNull public android.app.Notification.Action.Builder setSemanticAction(int);
}
@@ -24047,6 +24049,8 @@
method public boolean isSink();
method public boolean isSource();
field public static final int TYPE_AUX_LINE = 19; // 0x13
+ field public static final int TYPE_BLE_HEADSET = 26; // 0x1a
+ field public static final int TYPE_BLE_SPEAKER = 27; // 0x1b
field public static final int TYPE_BLUETOOTH_A2DP = 8; // 0x8
field public static final int TYPE_BLUETOOTH_SCO = 7; // 0x7
field public static final int TYPE_BUILTIN_EARPIECE = 1; // 0x1
diff --git a/non-updatable-api/module-lib-current.txt b/non-updatable-api/module-lib-current.txt
index 3c0b955..35b483b 100644
--- a/non-updatable-api/module-lib-current.txt
+++ b/non-updatable-api/module-lib-current.txt
@@ -39,6 +39,14 @@
}
+package android.media.session {
+
+ public final class MediaSession {
+ field public static final int FLAG_EXCLUSIVE_GLOBAL_PRIORITY = 65536; // 0x10000
+ }
+
+}
+
package android.os {
public class Binder implements android.os.IBinder {
@@ -46,6 +54,7 @@
}
public interface Parcelable {
+ method public default int getStability();
field public static final int PARCELABLE_STABILITY_LOCAL = 0; // 0x0
field public static final int PARCELABLE_STABILITY_VINTF = 1; // 0x1
}
diff --git a/non-updatable-api/system-current.txt b/non-updatable-api/system-current.txt
index 10887fa..cf792b6 100644
--- a/non-updatable-api/system-current.txt
+++ b/non-updatable-api/system-current.txt
@@ -301,6 +301,7 @@
field public static final int config_helpIntentNameKey = 17039390; // 0x104001e
field public static final int config_helpPackageNameKey = 17039387; // 0x104001b
field public static final int config_helpPackageNameValue = 17039388; // 0x104001c
+ field public static final int config_systemAutomotiveCluster = 17039400; // 0x1040028
field public static final int config_systemGallery = 17039399; // 0x1040027
}
@@ -9357,7 +9358,7 @@
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getCurrentTtyMode();
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getDefaultDialerPackage(@NonNull android.os.UserHandle);
method @Deprecated public android.content.ComponentName getDefaultPhoneApp();
- method public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsForPackage();
+ method @Deprecated public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsForPackage();
method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsSupportingScheme(String);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean isInEmergencyCall();
method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isRinging();
diff --git a/packages/CarSystemUI/samples/sample1/rro/Android.bp b/packages/CarSystemUI/samples/sample1/rro/Android.bp
new file mode 100644
index 0000000..5b0347f
--- /dev/null
+++ b/packages/CarSystemUI/samples/sample1/rro/Android.bp
@@ -0,0 +1,27 @@
+//
+// 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.
+//
+
+android_app {
+ name: "CarSystemUISampleOneRRO",
+ resource_dirs: ["res"],
+ certificate: "platform",
+ platform_apis: true,
+ manifest: "AndroidManifest.xml",
+ aaptflags: [
+ "--no-resource-deduping",
+ "--no-resource-removal",
+ ]
+}
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/tv_circle_dark.xml b/packages/CarSystemUI/samples/sample1/rro/AndroidManifest.xml
similarity index 62%
copy from packages/SystemUI/res/drawable/tv_circle_dark.xml
copy to packages/CarSystemUI/samples/sample1/rro/AndroidManifest.xml
index d1ba8e7..5c25056 100644
--- a/packages/SystemUI/res/drawable/tv_circle_dark.xml
+++ b/packages/CarSystemUI/samples/sample1/rro/AndroidManifest.xml
@@ -1,6 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?>
<!--
- ~ Copyright (C) 2019 The Android Open Source Project
+ ~ 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.
@@ -15,10 +14,11 @@
~ limitations under the License.
-->
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
-
- <solid
- android:color="@color/tv_audio_recording_indicator_background" />
-
-</shape>
\ No newline at end of file
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.systemui.rro">
+ <overlay
+ android:targetPackage="com.android.systemui"
+ android:isStatic="false"
+ android:resourcesMap="@xml/car_sysui_overlays"
+ />
+</manifest>
\ No newline at end of file
diff --git a/packages/CarSystemUI/samples/sample1/rro/res/values/config.xml b/packages/CarSystemUI/samples/sample1/rro/res/values/config.xml
new file mode 100644
index 0000000..854ab7d
--- /dev/null
+++ b/packages/CarSystemUI/samples/sample1/rro/res/values/config.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources>
+ <!-- Configure which system bars should be displayed. -->
+ <bool name="config_enableTopNavigationBar">true</bool>
+ <bool name="config_enableLeftNavigationBar">true</bool>
+ <bool name="config_enableRightNavigationBar">true</bool>
+ <bool name="config_enableBottomNavigationBar">true</bool>
+
+ <!-- Configure the type of each system bar. Each system bar must have a unique type. -->
+ <!-- STATUS_BAR = 0-->
+ <!-- NAVIGATION_BAR = 1-->
+ <!-- STATUS_BAR_EXTRA = 2-->
+ <!-- NAVIGATION_BAR_EXTRA = 3-->
+ <integer name="config_topSystemBarType">0</integer>
+ <integer name="config_leftSystemBarType">2</integer>
+ <integer name="config_rightSystemBarType">3</integer>
+ <integer name="config_bottomSystemBarType">1</integer>
+
+ <!-- Configure the relative z-order among the system bars. When two system bars overlap (e.g.
+ if both top bar and left bar are enabled, it creates an overlapping space in the upper left
+ corner), the system bar with the higher z-order takes the overlapping space and padding is
+ applied to the other bar.-->
+ <!-- NOTE: If two overlapping system bars have the same z-order, SystemBarConfigs will throw a
+ RuntimeException, since their placing order cannot be determined. Bars that do not overlap
+ are allowed to have the same z-order. -->
+ <!-- NOTE: If the z-order of a bar is 10 or above, it will also appear on top of HUN's. -->
+ <integer name="config_topSystemBarZOrder">1</integer>
+ <integer name="config_leftSystemBarZOrder">0</integer>
+ <integer name="config_rightSystemBarZOrder">0</integer>
+ <integer name="config_bottomSystemBarZOrder">10</integer>
+</resources>
\ No newline at end of file
diff --git a/packages/CarSystemUI/samples/sample1/rro/res/xml/car_sysui_overlays.xml b/packages/CarSystemUI/samples/sample1/rro/res/xml/car_sysui_overlays.xml
new file mode 100644
index 0000000..7bcb8e1
--- /dev/null
+++ b/packages/CarSystemUI/samples/sample1/rro/res/xml/car_sysui_overlays.xml
@@ -0,0 +1,33 @@
+
+<!--
+ ~ 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.
+ -->
+
+<overlay>
+ <item target="bool/config_enableTopNavigationBar" value="@bool/config_enableTopNavigationBar"/>
+ <item target="bool/config_enableLeftNavigationBar" value="@bool/config_enableLeftNavigationBar"/>
+ <item target="bool/config_enableRightNavigationBar" value="@bool/config_enableRightNavigationBar"/>
+ <item target="bool/config_enableBottomNavigationBar" value="@bool/config_enableBottomNavigationBar"/>
+
+ <item target="integer/config_topSystemBarType" value="@integer/config_topSystemBarType"/>
+ <item target="integer/config_leftSystemBarType" value="@integer/config_leftSystemBarType"/>
+ <item target="integer/config_rightSystemBarType" value="@integer/config_rightSystemBarType"/>
+ <item target="integer/config_bottomSystemBarType" value="@integer/config_bottomSystemBarType"/>
+
+ <item target="integer/config_topSystemBarZOrder" value="@integer/config_topSystemBarZOrder"/>
+ <item target="integer/config_leftSystemBarZOrder" value="@integer/config_leftSystemBarZOrder"/>
+ <item target="integer/config_rightSystemBarZOrder" value="@integer/config_rightSystemBarZOrder"/>
+ <item target="integer/config_bottomSystemBarZOrder" value="@integer/config_bottomSystemBarZOrder"/>
+</overlay>
\ No newline at end of file
diff --git a/packages/FusedLocation/test/src/com/android/location/fused/tests/FusedLocationServiceTest.java b/packages/FusedLocation/test/src/com/android/location/fused/tests/FusedLocationServiceTest.java
index 8efbad6..2c4545e 100644
--- a/packages/FusedLocation/test/src/com/android/location/fused/tests/FusedLocationServiceTest.java
+++ b/packages/FusedLocation/test/src/com/android/location/fused/tests/FusedLocationServiceTest.java
@@ -155,41 +155,6 @@
assertThat(mManager.getNextLocation(TIMEOUT_MS)).isEqualTo(location);
}
- @Test
- public void testBypassRequest() throws Exception {
- LocationRequest request = LocationRequest.createFromDeprecatedProvider(FUSED_PROVIDER, 1000,
- 0, false).setQuality(LocationRequest.POWER_HIGH).setLocationSettingsIgnored(true);
-
- mProvider.setRequest(
- new ProviderRequest.Builder()
- .setInterval(1000)
- .setLocationSettingsIgnored(true)
- .setLocationRequests(Collections.singletonList(request))
- .build(),
- new WorkSource());
-
- boolean containsNetworkBypass = false;
- for (LocationRequest iRequest : mLocationManager.getTestProviderCurrentRequests(
- NETWORK_PROVIDER)) {
- if (iRequest.isLocationSettingsIgnored()) {
- containsNetworkBypass = true;
- break;
- }
- }
-
- boolean containsGpsBypass = false;
- for (LocationRequest iRequest : mLocationManager.getTestProviderCurrentRequests(
- GPS_PROVIDER)) {
- if (iRequest.isLocationSettingsIgnored()) {
- containsGpsBypass = true;
- break;
- }
- }
-
- assertThat(containsNetworkBypass).isTrue();
- assertThat(containsGpsBypass).isTrue();
- }
-
private static class LocationProviderManagerCapture extends ILocationProviderManager.Stub {
private final LinkedBlockingQueue<Location> mLocations;
diff --git a/packages/SettingsLib/Tile/src/com/android/settingslib/drawer/Tile.java b/packages/SettingsLib/Tile/src/com/android/settingslib/drawer/Tile.java
index 1e4c7ca..52d2b3c 100644
--- a/packages/SettingsLib/Tile/src/com/android/settingslib/drawer/Tile.java
+++ b/packages/SettingsLib/Tile/src/com/android/settingslib/drawer/Tile.java
@@ -376,8 +376,12 @@
* Check whether tile only has primary profile.
*/
public boolean isPrimaryProfileOnly() {
- String profile = mMetaData != null
- ? mMetaData.getString(META_DATA_KEY_PROFILE) : PROFILE_ALL;
+ return isPrimaryProfileOnly(mMetaData);
+ }
+
+ static boolean isPrimaryProfileOnly(Bundle metaData) {
+ String profile = metaData != null
+ ? metaData.getString(META_DATA_KEY_PROFILE) : PROFILE_ALL;
profile = (profile != null ? profile : PROFILE_ALL);
return TextUtils.equals(profile, PROFILE_PRIMARY);
}
diff --git a/packages/SettingsLib/Tile/src/com/android/settingslib/drawer/TileUtils.java b/packages/SettingsLib/Tile/src/com/android/settingslib/drawer/TileUtils.java
index ace50f3..49f6bd8 100644
--- a/packages/SettingsLib/Tile/src/com/android/settingslib/drawer/TileUtils.java
+++ b/packages/SettingsLib/Tile/src/com/android/settingslib/drawer/TileUtils.java
@@ -339,6 +339,16 @@
private static void loadTile(UserHandle user, Map<Pair<String, String>, Tile> addedCache,
String defaultCategory, List<Tile> outTiles, Intent intent, Bundle metaData,
ComponentInfo componentInfo) {
+ // Skip loading tile if the component is tagged primary_profile_only but not running on
+ // the current user.
+ if (user.getIdentifier() != ActivityManager.getCurrentUser()
+ && Tile.isPrimaryProfileOnly(componentInfo.metaData)) {
+ Log.w(LOG_TAG, "Found " + componentInfo.name + " for intent "
+ + intent + " is primary profile only, skip loading tile for uid "
+ + user.getIdentifier());
+ return;
+ }
+
String categoryKey = defaultCategory;
// Load category
if ((metaData == null || !metaData.containsKey(EXTRA_CATEGORY_KEY))
diff --git a/packages/SettingsLib/res/values-fr/strings.xml b/packages/SettingsLib/res/values-fr/strings.xml
index ddf2bc0..5f5be97 100644
--- a/packages/SettingsLib/res/values-fr/strings.xml
+++ b/packages/SettingsLib/res/values-fr/strings.xml
@@ -165,7 +165,7 @@
<string name="tts_lang_not_selected" msgid="7927823081096056147">"Langue non sélectionnée"</string>
<string name="tts_default_lang_summary" msgid="9042620014800063470">"Définir la langue utilisée par la synthèse vocale"</string>
<string name="tts_play_example_title" msgid="1599468547216481684">"Écouter un échantillon"</string>
- <string name="tts_play_example_summary" msgid="634044730710636383">"Lire une courte démonstration de la synthèse vocale"</string>
+ <string name="tts_play_example_summary" msgid="634044730710636383">"Écoutez une courte démonstration de la synthèse vocale"</string>
<string name="tts_install_data_title" msgid="1829942496472751703">"Installer les données vocales"</string>
<string name="tts_install_data_summary" msgid="3608874324992243851">"Installer les données nécessaires à la synthèse vocale"</string>
<string name="tts_engine_security_warning" msgid="3372432853837988146">"Ce moteur de synthèse vocale est susceptible de collecter tout ce qui sera lu, y compris les données personnelles comme les mots de passe et les numéros de carte de paiement. Il provient du moteur <xliff:g id="TTS_PLUGIN_ENGINE_NAME">%s</xliff:g>. Voulez-vous activer son utilisation ?"</string>
@@ -189,8 +189,8 @@
<item msgid="1158955023692670059">"Rapide"</item>
<item msgid="5664310435707146591">"Plus rapide"</item>
<item msgid="5491266922147715962">"Très rapide"</item>
- <item msgid="7659240015901486196">"Rapide"</item>
- <item msgid="7147051179282410945">"Très rapide"</item>
+ <item msgid="7659240015901486196">"Beaucoup plus rapide"</item>
+ <item msgid="7147051179282410945">"Extrêmement rapide"</item>
<item msgid="581904787661470707">"La plus rapide"</item>
</string-array>
<string name="choose_profile" msgid="343803890897657450">"Sélectionner un profil"</string>
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/TestAccessPointBuilder.java b/packages/SettingsLib/src/com/android/settingslib/wifi/TestAccessPointBuilder.java
index 2fb2481..df98b17 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/TestAccessPointBuilder.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/TestAccessPointBuilder.java
@@ -108,8 +108,8 @@
public TestAccessPointBuilder setActive(boolean active) {
if (active) {
mNetworkInfo = new NetworkInfo(
- ConnectivityManager.TYPE_DUMMY,
- ConnectivityManager.TYPE_DUMMY,
+ ConnectivityManager.TYPE_WIFI,
+ ConnectivityManager.TYPE_WIFI,
"TestNetwork",
"TestNetwork");
} else {
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileUtilsTest.java
index 9b4b97e..1769053 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileUtilsTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileUtilsTest.java
@@ -17,11 +17,14 @@
package com.android.settingslib.drawer;
import static com.android.settingslib.drawer.TileUtils.IA_SETTINGS_ACTION;
+import static com.android.settingslib.drawer.TileUtils.META_DATA_KEY_PROFILE;
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_ICON;
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_ICON_URI;
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_KEYHINT;
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SUMMARY;
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SUMMARY_URI;
+import static com.android.settingslib.drawer.TileUtils.PROFILE_ALL;
+import static com.android.settingslib.drawer.TileUtils.PROFILE_PRIMARY;
import static com.google.common.truth.Truth.assertThat;
@@ -189,7 +192,7 @@
List<Tile> outTiles = new ArrayList<>();
List<ResolveInfo> info = new ArrayList<>();
ResolveInfo resolveInfo = newInfo(true, null /* category */, null, URI_GET_ICON,
- URI_GET_SUMMARY, "my title", 0);
+ URI_GET_SUMMARY, "my title", 0, PROFILE_ALL);
info.add(resolveInfo);
when(mPackageManager.queryIntentActivitiesAsUser(any(Intent.class), anyInt(), anyInt()))
@@ -211,7 +214,7 @@
List<Tile> outTiles = new ArrayList<>();
List<ResolveInfo> info = new ArrayList<>();
ResolveInfo resolveInfo = newInfo(true, null /* category */, null, URI_GET_ICON,
- URI_GET_SUMMARY, null, 123);
+ URI_GET_SUMMARY, null, 123, PROFILE_ALL);
info.add(resolveInfo);
when(mPackageManager.queryIntentActivitiesAsUser(any(Intent.class), anyInt(), anyInt()))
@@ -235,7 +238,7 @@
List<Tile> outTiles = new ArrayList<>();
List<ResolveInfo> info = new ArrayList<>();
ResolveInfo resolveInfo = newInfo(true, null /* category */, null, URI_GET_ICON,
- URI_GET_SUMMARY, null, 123);
+ URI_GET_SUMMARY, null, 123, PROFILE_ALL);
resolveInfo.activityInfo.packageName = "com.android.settings";
resolveInfo.activityInfo.applicationInfo.packageName = "com.android.settings";
info.add(resolveInfo);
@@ -258,7 +261,7 @@
final List<Tile> outTiles = new ArrayList<>();
final List<ResolveInfo> info = new ArrayList<>();
final ResolveInfo resolveInfo = newInfo(true, null /* category */, null, URI_GET_ICON,
- URI_GET_SUMMARY, null, 123);
+ URI_GET_SUMMARY, null, 123, PROFILE_ALL);
resolveInfo.activityInfo.packageName = "com.android.settings";
resolveInfo.activityInfo.applicationInfo.packageName = "com.android.settings";
info.add(resolveInfo);
@@ -290,7 +293,7 @@
List<Tile> outTiles = new ArrayList<>();
List<ResolveInfo> info = new ArrayList<>();
ResolveInfo resolveInfo = newInfo(true, null /* category */, null, URI_GET_ICON,
- URI_GET_SUMMARY, null, 123);
+ URI_GET_SUMMARY, null, 123, PROFILE_ALL);
resolveInfo.activityInfo.metaData
.putBoolean(TileUtils.META_DATA_PREFERENCE_ICON_TINTABLE, true);
info.add(resolveInfo);
@@ -327,6 +330,26 @@
assertThat(outTiles).hasSize(2);
}
+ @Test
+ public void loadTilesForAction_isPrimaryProfileOnly_shouldSkipNonPrimaryUserTiles() {
+ Map<Pair<String, String>, Tile> addedCache = new ArrayMap<>();
+ List<Tile> outTiles = new ArrayList<>();
+ List<ResolveInfo> info = new ArrayList<>();
+ ResolveInfo resolveInfo = newInfo(true, null /* category */, null, URI_GET_ICON,
+ URI_GET_SUMMARY, null, 123, PROFILE_PRIMARY);
+ info.add(resolveInfo);
+
+ when(mPackageManager.queryIntentActivitiesAsUser(any(Intent.class), anyInt(), anyInt()))
+ .thenReturn(info);
+ when(mPackageManager.queryIntentContentProvidersAsUser(any(Intent.class), anyInt(),
+ anyInt())).thenReturn(info);
+
+ TileUtils.loadTilesForAction(mContext, new UserHandle(10), IA_SETTINGS_ACTION,
+ addedCache, null /* defaultCategory */, outTiles, false /* requiresSettings */);
+
+ assertThat(outTiles).isEmpty();
+ }
+
public static ResolveInfo newInfo(boolean systemApp, String category) {
return newInfo(systemApp, category, null);
}
@@ -337,14 +360,14 @@
private static ResolveInfo newInfo(boolean systemApp, String category, String keyHint,
String iconUri, String summaryUri) {
- return newInfo(systemApp, category, keyHint, iconUri, summaryUri, null, 0);
+ return newInfo(systemApp, category, keyHint, iconUri, summaryUri, null, 0, PROFILE_ALL);
}
private static ResolveInfo newInfo(boolean systemApp, String category, String keyHint,
- String iconUri, String summaryUri, String title, int titleResId) {
+ String iconUri, String summaryUri, String title, int titleResId, String profile) {
final Bundle metaData = newMetaData(category, keyHint, iconUri, summaryUri, title,
- titleResId);
+ titleResId, profile);
final ResolveInfo info = new ResolveInfo();
info.system = systemApp;
@@ -358,6 +381,7 @@
info.providerInfo.packageName = "abc";
info.providerInfo.name = "456";
info.providerInfo.authority = "auth";
+ info.providerInfo.metaData = metaData;
ShadowTileUtils.setMetaData(metaData);
info.providerInfo.applicationInfo = new ApplicationInfo();
@@ -369,7 +393,7 @@
}
private static Bundle newMetaData(String category, String keyHint, String iconUri,
- String summaryUri, String title, int titleResId) {
+ String summaryUri, String title, int titleResId, String profile) {
final Bundle metaData = new Bundle();
metaData.putString("com.android.settings.category", category);
metaData.putInt(META_DATA_PREFERENCE_ICON, 314159);
@@ -388,6 +412,9 @@
} else if (title != null) {
metaData.putString(TileUtils.META_DATA_PREFERENCE_TITLE, title);
}
+ if (profile != null) {
+ metaData.putString(META_DATA_KEY_PROFILE, profile);
+ }
return metaData;
}
diff --git a/packages/Shell/src/com/android/shell/Screenshooter.java b/packages/Shell/src/com/android/shell/Screenshooter.java
index 8e01619..85f2552 100644
--- a/packages/Shell/src/com/android/shell/Screenshooter.java
+++ b/packages/Shell/src/com/android/shell/Screenshooter.java
@@ -17,11 +17,8 @@
package com.android.shell;
import android.graphics.Bitmap;
-import android.graphics.Point;
-import android.graphics.Rect;
-import android.hardware.display.DisplayManagerGlobal;
+import android.os.IBinder;
import android.util.Log;
-import android.view.Display;
import android.view.SurfaceControl;
/**
@@ -40,22 +37,17 @@
* @return The screenshot bitmap on success, null otherwise.
*/
static Bitmap takeScreenshot() {
- Display display = DisplayManagerGlobal.getInstance()
- .getRealDisplay(Display.DEFAULT_DISPLAY);
- Point displaySize = new Point();
- display.getRealSize(displaySize);
- final int displayWidth = displaySize.x;
- final int displayHeight = displaySize.y;
-
- int rotation = display.getRotation();
- Rect crop = new Rect(0, 0, displayWidth, displayHeight);
- Log.d(TAG, "Taking screenshot of dimensions " + displayWidth + " x " + displayHeight);
+ Log.d(TAG, "Taking fullscreen screenshot");
// Take the screenshot
- Bitmap screenShot =
- SurfaceControl.screenshot(crop, displayWidth, displayHeight, rotation);
+ final IBinder displayToken = SurfaceControl.getInternalDisplayToken();
+ final SurfaceControl.DisplayCaptureArgs captureArgs =
+ new SurfaceControl.DisplayCaptureArgs.Builder(displayToken)
+ .build();
+ final SurfaceControl.ScreenshotHardwareBuffer screenshotBuffer =
+ SurfaceControl.captureDisplay(captureArgs);
+ final Bitmap screenShot = screenshotBuffer == null ? null : screenshotBuffer.asBitmap();
if (screenShot == null) {
- Log.e(TAG, "Failed to take screenshot of dimensions " + displayWidth + " x "
- + displayHeight);
+ Log.e(TAG, "Failed to take fullscreen screenshot");
return null;
}
diff --git a/packages/SystemUI/res-keyguard/values/styles.xml b/packages/SystemUI/res-keyguard/values/styles.xml
index 53eb234..401f3e3 100644
--- a/packages/SystemUI/res-keyguard/values/styles.xml
+++ b/packages/SystemUI/res-keyguard/values/styles.xml
@@ -27,6 +27,7 @@
<item name="android:textColor">?attr/wallpaperTextColorSecondary</item>
<item name="android:textSize">14dp</item>
<item name="android:background">@drawable/kg_emergency_button_background</item>
+ <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
<item name="android:paddingLeft">12dp</item>
<item name="android:paddingRight">12dp</item>
</style>
diff --git a/packages/SystemUI/res/drawable-television/ic_volume_media.xml b/packages/SystemUI/res/drawable-television/ic_volume_media.xml
new file mode 100644
index 0000000..e43c4b4
--- /dev/null
+++ b/packages/SystemUI/res/drawable-television/ic_volume_media.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="@color/tv_volume_dialog_accent"
+ android:pathData="M3,9v6h4l5,5L12,4L7,9L3,9zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14,3.23v2.06c2.89,0.86 5,3.54 5,6.71s-2.11,5.85 -5,6.71v2.06c4.01,-0.91 7,-4.49 7,-8.77s-2.99,-7.86 -7,-8.77z"/>
+</vector>
diff --git a/packages/SystemUI/res/drawable-television/ic_volume_media_low.xml b/packages/SystemUI/res/drawable-television/ic_volume_media_low.xml
new file mode 100644
index 0000000..0f6dc95
--- /dev/null
+++ b/packages/SystemUI/res/drawable-television/ic_volume_media_low.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="@color/tv_volume_dialog_accent"
+ android:pathData="M3,15V9H7L12,4V20L7,15H3ZM14,7.97C15.48,8.71 16.5,10.23 16.5,12C16.5,13.77 15.48,15.29 14,16.02V7.97Z"/>
+</vector>
diff --git a/packages/SystemUI/res/drawable-television/ic_volume_media_mute.xml b/packages/SystemUI/res/drawable-television/ic_volume_media_mute.xml
new file mode 100644
index 0000000..4b59e13
--- /dev/null
+++ b/packages/SystemUI/res/drawable-television/ic_volume_media_mute.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="@color/tv_volume_dialog_accent"
+ android:pathData="M16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v2.21l2.45,2.45c0.03,-0.2 0.05,-0.41 0.05,-0.63zM19,12c0,0.94 -0.2,1.82 -0.54,2.64l1.51,1.51C20.63,14.91 21,13.5 21,12c0,-4.28 -2.99,-7.86 -7,-8.77v2.06c2.89,0.86 5,3.54 5,6.71zM4.27,3L3,4.27 7.73,9L3,9v6h4l5,5v-6.73l4.25,4.25c-0.67,0.52 -1.42,0.93 -2.25,1.18v2.06c1.38,-0.31 2.63,-0.95 3.69,-1.81L19.73,21 21,19.73l-9,-9L4.27,3zM12,4L9.91,6.09 12,8.18L12,4z"/>
+</vector>
+
diff --git a/packages/SystemUI/res/drawable/ic_volume_media_low.xml b/packages/SystemUI/res/drawable/ic_volume_media_low.xml
new file mode 100644
index 0000000..87591de
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_volume_media_low.xml
@@ -0,0 +1,18 @@
+<!--
+ 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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:drawable="@drawable/ic_volume_media" />
+</selector>
diff --git a/packages/SystemUI/res/drawable/tv_circle_dark.xml b/packages/SystemUI/res/drawable/tv_rect_shadow_rounded.xml
similarity index 75%
copy from packages/SystemUI/res/drawable/tv_circle_dark.xml
copy to packages/SystemUI/res/drawable/tv_rect_shadow_rounded.xml
index d1ba8e7..93f8724 100644
--- a/packages/SystemUI/res/drawable/tv_circle_dark.xml
+++ b/packages/SystemUI/res/drawable/tv_rect_shadow_rounded.xml
@@ -16,9 +16,10 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ android:shape="rectangle">
- <solid
- android:color="@color/tv_audio_recording_indicator_background" />
+ <corners android:radius="20dp"/>
+ <solid android:color="@color/tv_audio_recording_indicator_icon_background"/>
+ <stroke android:width="1dp" android:color="@color/tv_audio_recording_indicator_stroke"/>
</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/tv_ring_white.xml b/packages/SystemUI/res/drawable/tv_ring_white.xml
deleted file mode 100644
index 0f7cc10..0000000
--- a/packages/SystemUI/res/drawable/tv_ring_white.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2019 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.
- -->
-
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
-
- <stroke
- android:width="1dp"
- android:color="@android:color/white" />
-
-</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/tv_circle_dark.xml b/packages/SystemUI/res/drawable/tv_volume_dialog_background.xml
similarity index 75%
rename from packages/SystemUI/res/drawable/tv_circle_dark.xml
rename to packages/SystemUI/res/drawable/tv_volume_dialog_background.xml
index d1ba8e7..fee6e57 100644
--- a/packages/SystemUI/res/drawable/tv_circle_dark.xml
+++ b/packages/SystemUI/res/drawable/tv_volume_dialog_background.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- ~ Copyright (C) 2019 The Android Open Source Project
+ ~ 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.
@@ -16,9 +16,9 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ android:shape="rectangle">
- <solid
- android:color="@color/tv_audio_recording_indicator_background" />
+ <solid android:color="@color/tv_volume_dialog_background" />
+ <corners android:radius="@dimen/tv_volume_dialog_corner_radius"/>
-</shape>
\ No newline at end of file
+</shape>
diff --git a/packages/SystemUI/res/drawable/tv_circle_white_translucent.xml b/packages/SystemUI/res/drawable/tv_volume_dialog_circle.xml
similarity index 84%
rename from packages/SystemUI/res/drawable/tv_circle_white_translucent.xml
rename to packages/SystemUI/res/drawable/tv_volume_dialog_circle.xml
index 55d21de..3c4fc05 100644
--- a/packages/SystemUI/res/drawable/tv_circle_white_translucent.xml
+++ b/packages/SystemUI/res/drawable/tv_volume_dialog_circle.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- ~ Copyright (C) 2019 The Android Open Source Project
+ ~ 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.
@@ -17,8 +17,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
+ <solid android:color="@color/tv_volume_dialog_circle" />
- <solid
- android:color="@color/tv_audio_recording_indicator_pulse" />
-
-</shape>
\ No newline at end of file
+</shape>
diff --git a/packages/SystemUI/res/layout-land-television/volume_dialog.xml b/packages/SystemUI/res/layout-land-television/volume_dialog.xml
index e0d158d..56d847c 100644
--- a/packages/SystemUI/res/layout-land-television/volume_dialog.xml
+++ b/packages/SystemUI/res/layout-land-television/volume_dialog.xml
@@ -20,7 +20,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
- android:theme="@style/qs_theme">
+ android:theme="@style/volume_dialog_theme">
<FrameLayout
android:id="@+id/volume_dialog"
@@ -46,7 +46,7 @@
android:translationZ="@dimen/volume_dialog_elevation"
android:clipChildren="false"
android:clipToPadding="false"
- android:background="@drawable/rounded_bg_full">
+ android:background="@drawable/tv_volume_dialog_background">
<LinearLayout
android:id="@+id/volume_dialog_rows"
@@ -54,9 +54,7 @@
android:layout_height="wrap_content"
android:minWidth="@dimen/volume_dialog_panel_width"
android:gravity="center"
- android:orientation="horizontal"
- android:paddingRight="@dimen/volume_dialog_stream_padding"
- android:paddingLeft="@dimen/volume_dialog_stream_padding">
+ android:orientation="horizontal">
<!-- volume rows added and removed here! :-) -->
</LinearLayout>
@@ -98,4 +96,4 @@
</FrameLayout>
-</FrameLayout>
\ No newline at end of file
+</FrameLayout>
diff --git a/packages/SystemUI/res/layout-land-television/volume_dialog_row.xml b/packages/SystemUI/res/layout-land-television/volume_dialog_row.xml
index 08209ab..c0f0aa8 100644
--- a/packages/SystemUI/res/layout-land-television/volume_dialog_row.xml
+++ b/packages/SystemUI/res/layout-land-television/volume_dialog_row.xml
@@ -21,11 +21,12 @@
android:background="@android:color/transparent"
android:clipChildren="false"
android:clipToPadding="false"
- android:theme="@style/qs_theme">
+ android:theme="@style/volume_dialog_theme">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
+ android:padding="@dimen/tv_volume_dialog_row_padding"
android:background="@android:color/transparent"
android:gravity="center"
android:layout_gravity="center"
@@ -33,9 +34,9 @@
<com.android.keyguard.AlphaOptimizedImageButton
android:id="@+id/volume_row_icon"
style="@style/VolumeButtons"
- android:layout_width="@dimen/volume_dialog_tap_target_size"
- android:layout_height="@dimen/volume_dialog_tap_target_size"
- android:background="@drawable/ripple_drawable_20dp"
+ android:layout_width="@dimen/tv_volume_dialog_bubble_size"
+ android:layout_height="@dimen/tv_volume_dialog_bubble_size"
+ android:background="@drawable/tv_volume_dialog_circle"
android:tint="@color/accent_tint_color_selector"
android:soundEffectsEnabled="false" />
<TextView
@@ -62,6 +63,15 @@
android:layout_gravity="center"
android:rotation="0" />
</FrameLayout>
+ <TextView
+ android:id="@+id/volume_number"
+ android:layout_width="@dimen/tv_volume_dialog_bubble_size"
+ android:layout_height="@dimen/tv_volume_dialog_bubble_size"
+ android:maxLength="2"
+ android:gravity="center"
+ android:background="@drawable/tv_volume_dialog_circle"
+ android:textSize="@dimen/tv_volume_number_text_size"
+ android:textColor="@color/accent_tint_color_selector"/>
</LinearLayout>
<include layout="@layout/volume_dnd_icon"/>
diff --git a/packages/SystemUI/res/layout-land/volume_dialog.xml b/packages/SystemUI/res/layout-land/volume_dialog.xml
index 5da7819..c420117 100644
--- a/packages/SystemUI/res/layout-land/volume_dialog.xml
+++ b/packages/SystemUI/res/layout-land/volume_dialog.xml
@@ -22,7 +22,7 @@
android:gravity="right"
android:layout_gravity="right"
android:background="@android:color/transparent"
- android:theme="@style/qs_theme">
+ android:theme="@style/volume_dialog_theme">
<FrameLayout
android:id="@+id/volume_dialog"
diff --git a/packages/SystemUI/res/layout/tv_audio_recording_indicator.xml b/packages/SystemUI/res/layout/tv_audio_recording_indicator.xml
index 1d2340d..f9336a54 100644
--- a/packages/SystemUI/res/layout/tv_audio_recording_indicator.xml
+++ b/packages/SystemUI/res/layout/tv_audio_recording_indicator.xml
@@ -19,7 +19,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
- android:padding="32dp">
+ android:padding="12dp">
<FrameLayout
android:layout_width="wrap_content"
@@ -32,45 +32,25 @@
android:orientation="horizontal">
<FrameLayout
- android:layout_width="45dp"
- android:layout_height="47dp">
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent">
<View
android:id="@+id/icon_container_bg"
- android:layout_width="match_parent"
+ android:layout_width="50dp"
android:layout_height="match_parent"
android:background="@drawable/tv_rect_dark_left_rounded"/>
<FrameLayout
android:id="@+id/icon_mic"
- android:layout_width="35dp"
- android:layout_height="35dp"
- android:layout_marginStart="6dp"
- android:layout_marginTop="6dp"
- android:layout_marginBottom="6dp">
-
- <View
- android:layout_width="27dp"
- android:layout_height="27dp"
- android:layout_gravity="center"
- android:background="@drawable/tv_circle_dark"/>
+ android:layout_width="34dp"
+ android:layout_height="24dp"
+ android:layout_gravity="center"
+ android:background="@drawable/tv_rect_shadow_rounded">
<ImageView
- android:id="@+id/pulsating_circle"
- android:layout_width="27dp"
- android:layout_height="27dp"
- android:layout_gravity="center"
- android:background="@drawable/tv_circle_white_translucent"/>
-
- <ImageView
- android:layout_width="27dp"
- android:layout_height="27dp"
- android:layout_gravity="center"
- android:src="@drawable/tv_ring_white"/>
-
- <ImageView
- android:layout_width="16dp"
- android:layout_height="16dp"
+ android:layout_width="13dp"
+ android:layout_height="13dp"
android:layout_gravity="center"
android:background="@drawable/tv_ic_mic_white"/>
</FrameLayout>
diff --git a/packages/SystemUI/res/layout/volume_dialog.xml b/packages/SystemUI/res/layout/volume_dialog.xml
index 7d6547b..a90b1eb 100644
--- a/packages/SystemUI/res/layout/volume_dialog.xml
+++ b/packages/SystemUI/res/layout/volume_dialog.xml
@@ -22,7 +22,7 @@
android:gravity="right"
android:layout_gravity="right"
android:background="@android:color/transparent"
- android:theme="@style/qs_theme">
+ android:theme="@style/volume_dialog_theme">
<!-- right-aligned to be physically near volume button -->
<LinearLayout
diff --git a/packages/SystemUI/res/layout/volume_dialog_row.xml b/packages/SystemUI/res/layout/volume_dialog_row.xml
index 6128da8..b9efc5b 100644
--- a/packages/SystemUI/res/layout/volume_dialog_row.xml
+++ b/packages/SystemUI/res/layout/volume_dialog_row.xml
@@ -20,7 +20,7 @@
android:layout_width="@dimen/volume_dialog_panel_width"
android:clipChildren="false"
android:clipToPadding="false"
- android:theme="@style/qs_theme">
+ android:theme="@style/volume_dialog_theme">
<LinearLayout
android:layout_height="wrap_content"
diff --git a/packages/SystemUI/res/values-af/strings.xml b/packages/SystemUI/res/values-af/strings.xml
index ee87002..bac915d 100644
--- a/packages/SystemUI/res/values-af/strings.xml
+++ b/packages/SystemUI/res/values-af/strings.xml
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Laai tans aanbevelings"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Versteek die huidige sessie."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Versteek"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"Maak toe"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"Hervat"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Instellings"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Onaktief, gaan program na"</string>
diff --git a/packages/SystemUI/res/values-am/strings.xml b/packages/SystemUI/res/values-am/strings.xml
index 03eb396..aedbded 100644
--- a/packages/SystemUI/res/values-am/strings.xml
+++ b/packages/SystemUI/res/values-am/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"ምክሮችን በመጫን ላይ"</string>
<string name="controls_media_title" msgid="1746947284862928133">"ሚዲያ"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"የአሁኑን ክፍለ-ጊዜ ደብቅ።"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"ደብቅ"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"ከቆመበት ቀጥል"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"ቅንብሮች"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"ንቁ ያልኾነ፣ መተግበሪያን ይፈትሹ"</string>
diff --git a/packages/SystemUI/res/values-ar/strings.xml b/packages/SystemUI/res/values-ar/strings.xml
index 95d54a2..fee86ca 100644
--- a/packages/SystemUI/res/values-ar/strings.xml
+++ b/packages/SystemUI/res/values-ar/strings.xml
@@ -1093,7 +1093,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"جارٍ تحميل الاقتراحات"</string>
<string name="controls_media_title" msgid="1746947284862928133">"الوسائط"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"إخفاء الجلسة الحالية"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"إخفاء"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"استئناف التشغيل"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"الإعدادات"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"غير نشط، تحقّق من التطبيق."</string>
diff --git a/packages/SystemUI/res/values-as/strings.xml b/packages/SystemUI/res/values-as/strings.xml
index 3023a27..3778df8 100644
--- a/packages/SystemUI/res/values-as/strings.xml
+++ b/packages/SystemUI/res/values-as/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"চুপাৰিছসমূহ ল’ড কৰি থকা হৈছে"</string>
<string name="controls_media_title" msgid="1746947284862928133">"মিডিয়া"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"বৰ্তমানৰ ছেশ্বনটো লুকুৱাওক।"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"লুকুৱাওক"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"পুনৰ আৰম্ভ কৰক"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"ছেটিংসমূহ"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"সক্ৰিয় নহয়, এপ্টো পৰীক্ষা কৰক"</string>
diff --git a/packages/SystemUI/res/values-az/strings.xml b/packages/SystemUI/res/values-az/strings.xml
index 3c8e04b..874bf74 100644
--- a/packages/SystemUI/res/values-az/strings.xml
+++ b/packages/SystemUI/res/values-az/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Tövsiyələr yüklənir"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Cari sessiyanı gizlədin."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Gizlədin"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Davam edin"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Ayarlar"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Aktiv deyil, tətbiqi yoxlayın"</string>
diff --git a/packages/SystemUI/res/values-b+sr+Latn/strings.xml b/packages/SystemUI/res/values-b+sr+Latn/strings.xml
index 4b400eb..2a120c5 100644
--- a/packages/SystemUI/res/values-b+sr+Latn/strings.xml
+++ b/packages/SystemUI/res/values-b+sr+Latn/strings.xml
@@ -1075,7 +1075,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Učitavaju se preporuke"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Mediji"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Sakrijte aktuelnu sesiju."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Sakrij"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Nastavi"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Podešavanja"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Neaktivno. Vidite aplikaciju"</string>
diff --git a/packages/SystemUI/res/values-be/strings.xml b/packages/SystemUI/res/values-be/strings.xml
index f1064fb..e4bb67a 100644
--- a/packages/SystemUI/res/values-be/strings.xml
+++ b/packages/SystemUI/res/values-be/strings.xml
@@ -1081,7 +1081,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Загружаюцца рэкамендацыі"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Мультымедыя"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Схаваць цяперашні сеанс."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Схаваць"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Узнавіць"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Налады"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Неактыўна, праверце праграму"</string>
diff --git a/packages/SystemUI/res/values-bg/strings.xml b/packages/SystemUI/res/values-bg/strings.xml
index 8ba2a1e..c51e58c 100644
--- a/packages/SystemUI/res/values-bg/strings.xml
+++ b/packages/SystemUI/res/values-bg/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Препоръките се зареждат"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Мултимедия"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Скриване на текущата сесия."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Скриване"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Възобновяване"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Настройки"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Неактивно, проверете прилож."</string>
diff --git a/packages/SystemUI/res/values-bn/strings.xml b/packages/SystemUI/res/values-bn/strings.xml
index 5861c44..3d00ca8 100644
--- a/packages/SystemUI/res/values-bn/strings.xml
+++ b/packages/SystemUI/res/values-bn/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"সাজেশন লোড করা হচ্ছে"</string>
<string name="controls_media_title" msgid="1746947284862928133">"মিডিয়া"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"বর্তমান সেশন লুকান।"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"লুকান"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"আবার চালু করুন"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"সেটিংস"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"বন্ধ আছে, অ্যাপ চেক করুন"</string>
@@ -1084,8 +1085,6 @@
<string name="controls_added_tooltip" msgid="4842812921719153085">"নতুন কন্ট্রোল দেখতে পাওয়ার বোতাম টিপে ধরে থাকুন"</string>
<string name="controls_menu_add" msgid="4447246119229920050">"কন্ট্রোল যোগ করুন"</string>
<string name="controls_menu_edit" msgid="890623986951347062">"কন্ট্রোল এডিট করুন"</string>
- <!-- no translation found for one_handed_tutorial_title (6312198435090726656) -->
- <skip />
- <!-- no translation found for one_handed_tutorial_description (7674850272340517174) -->
- <skip />
+ <string name="one_handed_tutorial_title" msgid="6312198435090726656">"\'এক হাতে ব্যবহার করার মোড\'-এর ব্যবহার"</string>
+ <string name="one_handed_tutorial_description" msgid="7674850272340517174">"বেরিয়ে আসার জন্য, স্ক্রিনের নিচ থেকে উপরের দিকে সোয়াইপ করুন অথবা অ্যাপের আইকনের উপরে যেকোনও জায়গায় ট্যাপ করুন"</string>
</resources>
diff --git a/packages/SystemUI/res/values-bs/strings.xml b/packages/SystemUI/res/values-bs/strings.xml
index 984cbeb..1425984 100644
--- a/packages/SystemUI/res/values-bs/strings.xml
+++ b/packages/SystemUI/res/values-bs/strings.xml
@@ -1075,7 +1075,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Učitavanje preporuka"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Mediji"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Sakrijte trenutnu sesiju."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Sakrij"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Nastavi"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Postavke"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Neaktivno, vidite aplikaciju"</string>
diff --git a/packages/SystemUI/res/values-ca/strings.xml b/packages/SystemUI/res/values-ca/strings.xml
index b8c41ef..b150155 100644
--- a/packages/SystemUI/res/values-ca/strings.xml
+++ b/packages/SystemUI/res/values-ca/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Carregant les recomanacions"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Multimèdia"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Amaga la sessió actual."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Amaga"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Reprèn"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Configuració"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inactiu; comprova l\'aplicació"</string>
diff --git a/packages/SystemUI/res/values-cs/strings.xml b/packages/SystemUI/res/values-cs/strings.xml
index f946cc4..ae6cc13 100644
--- a/packages/SystemUI/res/values-cs/strings.xml
+++ b/packages/SystemUI/res/values-cs/strings.xml
@@ -1081,7 +1081,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Načítání doporučení"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Média"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Skrýt aktuální relaci."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Skrýt"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Pokračovat"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Nastavení"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Neaktivní, zkontrolujte aplikaci"</string>
diff --git a/packages/SystemUI/res/values-da/strings.xml b/packages/SystemUI/res/values-da/strings.xml
index a6de8a6..09f7f1a 100644
--- a/packages/SystemUI/res/values-da/strings.xml
+++ b/packages/SystemUI/res/values-da/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Indlæser anbefalinger"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Medie"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Skjul den aktuelle session."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Skjul"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Genoptag"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Indstillinger"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inaktiv. Tjek appen"</string>
diff --git a/packages/SystemUI/res/values-de/strings.xml b/packages/SystemUI/res/values-de/strings.xml
index 372cc11..2410e47 100644
--- a/packages/SystemUI/res/values-de/strings.xml
+++ b/packages/SystemUI/res/values-de/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Empfehlungen werden geladen"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Medien"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Du kannst die aktuelle Sitzung ausblenden."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Ausblenden"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Fortsetzen"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Einstellungen"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inaktiv – sieh in der App nach"</string>
@@ -1084,8 +1085,6 @@
<string name="controls_added_tooltip" msgid="4842812921719153085">"Zum Anzeigen der Karten für neue Geräte Ein-/Aus-Taste gedrückt halten"</string>
<string name="controls_menu_add" msgid="4447246119229920050">"Steuerelemente hinzufügen"</string>
<string name="controls_menu_edit" msgid="890623986951347062">"Steuerelemente bearbeiten"</string>
- <!-- no translation found for one_handed_tutorial_title (6312198435090726656) -->
- <skip />
- <!-- no translation found for one_handed_tutorial_description (7674850272340517174) -->
- <skip />
+ <string name="one_handed_tutorial_title" msgid="6312198435090726656">"Einhandmodus verwenden"</string>
+ <string name="one_handed_tutorial_description" msgid="7674850272340517174">"Wenn du die App schließen möchtest, wische vom unteren Rand des Displays nach oben oder tippe auf eine beliebige Stelle oberhalb der App"</string>
</resources>
diff --git a/packages/SystemUI/res/values-el/strings.xml b/packages/SystemUI/res/values-el/strings.xml
index b467347..f66c5a8 100644
--- a/packages/SystemUI/res/values-el/strings.xml
+++ b/packages/SystemUI/res/values-el/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Φόρτωση προτάσεων"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Μέσα"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Απόκρυψη της τρέχουσας περιόδου λειτουργίας."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Απόκρυψη"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Συνέχιση"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Ρυθμίσεις"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Ανενεργό, έλεγχος εφαρμογής"</string>
diff --git a/packages/SystemUI/res/values-en-rAU/strings.xml b/packages/SystemUI/res/values-en-rAU/strings.xml
index 7fa7f83..0e22b58 100644
--- a/packages/SystemUI/res/values-en-rAU/strings.xml
+++ b/packages/SystemUI/res/values-en-rAU/strings.xml
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Loading recommendations"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Hide the current session."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Hide"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"Dismiss"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"Resume"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Settings"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inactive, check app"</string>
diff --git a/packages/SystemUI/res/values-en-rCA/strings.xml b/packages/SystemUI/res/values-en-rCA/strings.xml
index f73dad3..acf087d 100644
--- a/packages/SystemUI/res/values-en-rCA/strings.xml
+++ b/packages/SystemUI/res/values-en-rCA/strings.xml
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Loading recommendations"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Hide the current session."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Hide"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"Dismiss"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"Resume"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Settings"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inactive, check app"</string>
diff --git a/packages/SystemUI/res/values-en-rGB/strings.xml b/packages/SystemUI/res/values-en-rGB/strings.xml
index 7fa7f83..0e22b58 100644
--- a/packages/SystemUI/res/values-en-rGB/strings.xml
+++ b/packages/SystemUI/res/values-en-rGB/strings.xml
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Loading recommendations"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Hide the current session."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Hide"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"Dismiss"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"Resume"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Settings"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inactive, check app"</string>
diff --git a/packages/SystemUI/res/values-en-rIN/strings.xml b/packages/SystemUI/res/values-en-rIN/strings.xml
index 7fa7f83..0e22b58 100644
--- a/packages/SystemUI/res/values-en-rIN/strings.xml
+++ b/packages/SystemUI/res/values-en-rIN/strings.xml
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Loading recommendations"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Hide the current session."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Hide"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"Dismiss"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"Resume"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Settings"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inactive, check app"</string>
diff --git a/packages/SystemUI/res/values-en-rXC/strings.xml b/packages/SystemUI/res/values-en-rXC/strings.xml
index 6140bf1..4f4238a 100644
--- a/packages/SystemUI/res/values-en-rXC/strings.xml
+++ b/packages/SystemUI/res/values-en-rXC/strings.xml
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Loading recommendations"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Hide the current session."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Hide"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"Dismiss"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"Resume"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Settings"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inactive, check app"</string>
diff --git a/packages/SystemUI/res/values-es-rUS/strings.xml b/packages/SystemUI/res/values-es-rUS/strings.xml
index 6818116..45e0724 100644
--- a/packages/SystemUI/res/values-es-rUS/strings.xml
+++ b/packages/SystemUI/res/values-es-rUS/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Cargando recomendaciones"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Contenido multimedia"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Oculta la sesión actual."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Ocultar"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Reanudar"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Configuración"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inactivo. Verifica la app"</string>
diff --git a/packages/SystemUI/res/values-es/strings.xml b/packages/SystemUI/res/values-es/strings.xml
index f09a0d2..f7ebbd0 100644
--- a/packages/SystemUI/res/values-es/strings.xml
+++ b/packages/SystemUI/res/values-es/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Cargando recomendaciones"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Multimedia"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Ocultar la sesión."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Ocultar"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Reanudar"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Ajustes"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inactivo, comprobar aplicación"</string>
diff --git a/packages/SystemUI/res/values-et/strings.xml b/packages/SystemUI/res/values-et/strings.xml
index 6236f25..1e5e49e 100644
--- a/packages/SystemUI/res/values-et/strings.xml
+++ b/packages/SystemUI/res/values-et/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Soovituste laadimine"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Meedia"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Peidetakse praegune seanss."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Peida"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Jätka"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Seaded"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Passiivne, vaadake rakendust"</string>
diff --git a/packages/SystemUI/res/values-eu/strings.xml b/packages/SystemUI/res/values-eu/strings.xml
index 167a09c..38b2103d 100644
--- a/packages/SystemUI/res/values-eu/strings.xml
+++ b/packages/SystemUI/res/values-eu/strings.xml
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Gomendioak kargatzen"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Multimedia-edukia"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Ezkutatu uneko saioa."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Ezkutatu"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"Baztertu"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"Berrekin"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Ezarpenak"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inaktibo; egiaztatu aplikazioa"</string>
@@ -1085,5 +1085,5 @@
<string name="controls_menu_add" msgid="4447246119229920050">"Gehitu aukerak"</string>
<string name="controls_menu_edit" msgid="890623986951347062">"Editatu aukerak"</string>
<string name="one_handed_tutorial_title" msgid="6312198435090726656">"Esku bakarreko modua erabiltzea"</string>
- <string name="one_handed_tutorial_description" msgid="7674850272340517174">"Ateratzeko, pasatu hatza pantailaren behealdetik gora edo sakatu aplikazioaren gainean, edonon"</string>
+ <string name="one_handed_tutorial_description" msgid="7674850272340517174">"Ateratzeko, pasatu hatza pantailaren behealdetik gora edo sakatu aplikazioaren gainaldea"</string>
</resources>
diff --git a/packages/SystemUI/res/values-fa/strings.xml b/packages/SystemUI/res/values-fa/strings.xml
index 0555052..d39d0c3 100644
--- a/packages/SystemUI/res/values-fa/strings.xml
+++ b/packages/SystemUI/res/values-fa/strings.xml
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"درحال بار کردن توصیهها"</string>
<string name="controls_media_title" msgid="1746947284862928133">"رسانه"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"جلسه فعلی پنهان شود."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"پنهان کردن"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"رد کردن"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"ازسرگیری"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"تنظیمات"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"غیرفعال، برنامه را بررسی کنید"</string>
diff --git a/packages/SystemUI/res/values-fi/strings.xml b/packages/SystemUI/res/values-fi/strings.xml
index ec9bbc4..fa076c4 100644
--- a/packages/SystemUI/res/values-fi/strings.xml
+++ b/packages/SystemUI/res/values-fi/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Ladataan suosituksia"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Piilota nykyinen käyttökerta."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Piilota"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Jatka"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Asetukset"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Epäaktiivinen, tarkista sovellus"</string>
diff --git a/packages/SystemUI/res/values-fr-rCA/strings.xml b/packages/SystemUI/res/values-fr-rCA/strings.xml
index 6c5387f..9c418f7 100644
--- a/packages/SystemUI/res/values-fr-rCA/strings.xml
+++ b/packages/SystemUI/res/values-fr-rCA/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Chargement des recommandations…"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Commandes multimédias"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Masquer la session en cours."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Masquer"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Reprendre"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Paramètres"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Délai expiré, vérifiez l\'appli"</string>
diff --git a/packages/SystemUI/res/values-fr/strings.xml b/packages/SystemUI/res/values-fr/strings.xml
index 3a2ae07..3e2f5fd 100644
--- a/packages/SystemUI/res/values-fr/strings.xml
+++ b/packages/SystemUI/res/values-fr/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Chargement des recommandations"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Multimédia"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Masquer la session en cours."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Masquer"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Reprendre"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Paramètres"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Délai expiré, vérifier l\'appli"</string>
diff --git a/packages/SystemUI/res/values-gl/strings.xml b/packages/SystemUI/res/values-gl/strings.xml
index 25c7b4b..9ecd75e 100644
--- a/packages/SystemUI/res/values-gl/strings.xml
+++ b/packages/SystemUI/res/values-gl/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Cargando recomendacións"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Contido multimedia"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Oculta a sesión actual."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Ocultar"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Retomar"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Configuración"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inactivo. Comproba a app"</string>
diff --git a/packages/SystemUI/res/values-gu/strings.xml b/packages/SystemUI/res/values-gu/strings.xml
index 17cc5a4..6e05a54 100644
--- a/packages/SystemUI/res/values-gu/strings.xml
+++ b/packages/SystemUI/res/values-gu/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"સુઝાવ લોડ કરી રહ્યાં છીએ"</string>
<string name="controls_media_title" msgid="1746947284862928133">"મીડિયા"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"હાલનું સત્ર છુપાવો."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"છુપાવો"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"ફરી શરૂ કરો"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"સેટિંગ"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"નિષ્ક્રિય, ઍપને ચેક કરો"</string>
@@ -1084,8 +1085,6 @@
<string name="controls_added_tooltip" msgid="4842812921719153085">"નવા નિયંત્રણ જોવા માટે પાવર બટનને દબાવી રાખો"</string>
<string name="controls_menu_add" msgid="4447246119229920050">"નિયંત્રણો ઉમેરો"</string>
<string name="controls_menu_edit" msgid="890623986951347062">"નિયંત્રણોમાં ફેરફાર કરો"</string>
- <!-- no translation found for one_handed_tutorial_title (6312198435090726656) -->
- <skip />
- <!-- no translation found for one_handed_tutorial_description (7674850272340517174) -->
- <skip />
+ <string name="one_handed_tutorial_title" msgid="6312198435090726656">"એક-હાથે વાપરો મોડનો ઉપયોગ કરી રહ્યાં છીએ"</string>
+ <string name="one_handed_tutorial_description" msgid="7674850272340517174">"બહાર નીકળવા માટે, સ્ક્રીનની નીચેના ભાગથી ઉપરની તરફ સ્વાઇપ કરો અથવા ઍપના આઇકન પર ગમે ત્યાં ટૅપ કરો"</string>
</resources>
diff --git a/packages/SystemUI/res/values-hi/strings.xml b/packages/SystemUI/res/values-hi/strings.xml
index 97ae7b6..de4fc48 100644
--- a/packages/SystemUI/res/values-hi/strings.xml
+++ b/packages/SystemUI/res/values-hi/strings.xml
@@ -1071,7 +1071,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"सुझाव लोड हो रहे हैं"</string>
<string name="controls_media_title" msgid="1746947284862928133">"मीडिया"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"इस मीडिया सेशन को छिपाएं."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"छिपाएं"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"खारिज करें"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"फिर से शुरू करें"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"सेटिंग"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"काम नहीं कर रहा, ऐप जांचें"</string>
@@ -1086,6 +1086,6 @@
<string name="controls_added_tooltip" msgid="4842812921719153085">"नए कंट्रोल देखने के लिए पावर बटन दबाकर रखें"</string>
<string name="controls_menu_add" msgid="4447246119229920050">"कंट्राेल जोड़ें"</string>
<string name="controls_menu_edit" msgid="890623986951347062">"कंट्रोल मेन्यू में बदलाव करें"</string>
- <string name="one_handed_tutorial_title" msgid="6312198435090726656">"वन-हैंडेड मोड का इस्तेमाल करें"</string>
+ <string name="one_handed_tutorial_title" msgid="6312198435090726656">"वन-हैंडेड मोड का इस्तेमाल करना"</string>
<string name="one_handed_tutorial_description" msgid="7674850272340517174">"इसे बंद करने के लिए, स्क्रीन के सबसे निचले हिस्से से ऊपर की ओर स्वाइप करें या ऐप्लिकेशन के आइकॉन के ऊपर कहीं भी टैप करें"</string>
</resources>
diff --git a/packages/SystemUI/res/values-hr/strings.xml b/packages/SystemUI/res/values-hr/strings.xml
index 9e17735..4bebe79 100644
--- a/packages/SystemUI/res/values-hr/strings.xml
+++ b/packages/SystemUI/res/values-hr/strings.xml
@@ -1075,7 +1075,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Učitavanje preporuka"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Mediji"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Sakrij trenutačnu sesiju."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Sakrij"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Nastavi"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Postavke"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Neaktivno, provjerite aplik."</string>
diff --git a/packages/SystemUI/res/values-hu/strings.xml b/packages/SystemUI/res/values-hu/strings.xml
index 804587f..42e251f 100644
--- a/packages/SystemUI/res/values-hu/strings.xml
+++ b/packages/SystemUI/res/values-hu/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Javaslatok betöltése…"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Média"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Jelenlegi munkamenet elrejtése."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Elrejtés"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Folytatás"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Beállítások"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inaktív, ellenőrizze az appot"</string>
diff --git a/packages/SystemUI/res/values-hy/strings.xml b/packages/SystemUI/res/values-hy/strings.xml
index 08ef489..e6b7139 100644
--- a/packages/SystemUI/res/values-hy/strings.xml
+++ b/packages/SystemUI/res/values-hy/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Բեռնման խորհուրդներ"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Մեդիա"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Թաքցրեք ընթացիկ աշխատաշրջանը"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Թաքցնել"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Շարունակել"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Կարգավորումներ"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Ակտիվ չէ, ստուգեք հավելվածը"</string>
diff --git a/packages/SystemUI/res/values-in/strings.xml b/packages/SystemUI/res/values-in/strings.xml
index ba9eca3..fec4205 100644
--- a/packages/SystemUI/res/values-in/strings.xml
+++ b/packages/SystemUI/res/values-in/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Memuat rekomendasi"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Menyembunyikan sesi saat ini."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Sembunyikan"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Lanjutkan"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Setelan"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Nonaktif, periksa aplikasi"</string>
diff --git a/packages/SystemUI/res/values-is/strings.xml b/packages/SystemUI/res/values-is/strings.xml
index 6295813..3a9e63b 100644
--- a/packages/SystemUI/res/values-is/strings.xml
+++ b/packages/SystemUI/res/values-is/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Hleður tillögum"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Margmiðlunarefni"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Fela núverandi lotu."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Fela"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Halda áfram"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Stillingar"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Óvirkt, athugaðu forrit"</string>
diff --git a/packages/SystemUI/res/values-it/strings.xml b/packages/SystemUI/res/values-it/strings.xml
index ef862cb..3eca501 100644
--- a/packages/SystemUI/res/values-it/strings.xml
+++ b/packages/SystemUI/res/values-it/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Caricamento dei consigli"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Contenuti multimediali"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Nascondi la sessione attuale."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Nascondi"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Riprendi"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Impostazioni"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inattivo, controlla l\'app"</string>
diff --git a/packages/SystemUI/res/values-iw/strings.xml b/packages/SystemUI/res/values-iw/strings.xml
index 358946d..e88c951 100644
--- a/packages/SystemUI/res/values-iw/strings.xml
+++ b/packages/SystemUI/res/values-iw/strings.xml
@@ -1081,7 +1081,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"בטעינת המלצות"</string>
<string name="controls_media_title" msgid="1746947284862928133">"מדיה"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"הסתרת הסשן הנוכחי."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"הסתרה"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"המשך"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"הגדרות"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"לא פעיל, יש לבדוק את האפליקציה"</string>
diff --git a/packages/SystemUI/res/values-ja/strings.xml b/packages/SystemUI/res/values-ja/strings.xml
index 9cb872bf..130f682 100644
--- a/packages/SystemUI/res/values-ja/strings.xml
+++ b/packages/SystemUI/res/values-ja/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"候補を読み込んでいます"</string>
<string name="controls_media_title" msgid="1746947284862928133">"メディア"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"現在のセッションを非表示にします。"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"非表示"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"再開"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"設定"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"無効: アプリをご確認ください"</string>
diff --git a/packages/SystemUI/res/values-ka/strings.xml b/packages/SystemUI/res/values-ka/strings.xml
index ef6ff128..d050875 100644
--- a/packages/SystemUI/res/values-ka/strings.xml
+++ b/packages/SystemUI/res/values-ka/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"მიმდინარეობს რეკომენდაციების ჩატვირთვა"</string>
<string name="controls_media_title" msgid="1746947284862928133">"მედია"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"დაიმალოს მიმდინარე სესია"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"დამალვა"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"გაგრძელება"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"პარამეტრები"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"არააქტიურია, გადაამოწმეთ აპი"</string>
diff --git a/packages/SystemUI/res/values-kk/strings.xml b/packages/SystemUI/res/values-kk/strings.xml
index 08b1f62..36c726e 100644
--- a/packages/SystemUI/res/values-kk/strings.xml
+++ b/packages/SystemUI/res/values-kk/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Жүктеуге қатысты ұсыныстар"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Мультимедиа"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Ағымдағы сеансты жасыру"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Жасыру"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Жалғастыру"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Параметрлер"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Өшірулі. Қолданба тексеріңіз."</string>
diff --git a/packages/SystemUI/res/values-km/strings.xml b/packages/SystemUI/res/values-km/strings.xml
index 6d80ee4..9d87c58 100644
--- a/packages/SystemUI/res/values-km/strings.xml
+++ b/packages/SystemUI/res/values-km/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"កំពុងផ្ទុកការណែនាំ"</string>
<string name="controls_media_title" msgid="1746947284862928133">"មេឌៀ"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"លាក់វគ្គបច្ចុប្បន្ន។"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"លាក់"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"បន្ត"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"ការកំណត់"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"អសកម្ម ពិនិត្យមើលកម្មវិធី"</string>
diff --git a/packages/SystemUI/res/values-kn/strings.xml b/packages/SystemUI/res/values-kn/strings.xml
index db20864..901f024 100644
--- a/packages/SystemUI/res/values-kn/strings.xml
+++ b/packages/SystemUI/res/values-kn/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"ಶಿಫಾರಸುಗಳು ಲೋಡ್ ಆಗುತ್ತಿವೆ"</string>
<string name="controls_media_title" msgid="1746947284862928133">"ಮಾಧ್ಯಮ"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"ಪ್ರಸ್ತುತ ಸೆಶನ್ ಅನ್ನು ಮರೆಮಾಡಿ."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"ಮರೆಮಾಡಿ"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"ಪುನರಾರಂಭಿಸಿ"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"ಸೆಟ್ಟಿಂಗ್ಗಳು"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"ನಿಷ್ಕ್ರಿಯ, ಆ್ಯಪ್ ಪರಿಶೀಲಿಸಿ"</string>
diff --git a/packages/SystemUI/res/values-ko/strings.xml b/packages/SystemUI/res/values-ko/strings.xml
index b43eb41..8a64155 100644
--- a/packages/SystemUI/res/values-ko/strings.xml
+++ b/packages/SystemUI/res/values-ko/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"추천 제어 기능 로드 중"</string>
<string name="controls_media_title" msgid="1746947284862928133">"미디어"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"현재 세션을 숨깁니다."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"숨기기"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"다시 시작"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"설정"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"비활성. 앱을 확인하세요."</string>
diff --git a/packages/SystemUI/res/values-ky/strings.xml b/packages/SystemUI/res/values-ky/strings.xml
index 02e468a..3cf4126 100644
--- a/packages/SystemUI/res/values-ky/strings.xml
+++ b/packages/SystemUI/res/values-ky/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Сунуштар жүктөлүүдө"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Медиа"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Учурдагы сеансты жашыруу."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Жашыруу"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Улантуу"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Жөндөөлөр"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Жигерсиз. Колдонмону текшериңиз"</string>
diff --git a/packages/SystemUI/res/values-land-television/dimens.xml b/packages/SystemUI/res/values-land-television/dimens.xml
index 499341c..90fc652 100644
--- a/packages/SystemUI/res/values-land-television/dimens.xml
+++ b/packages/SystemUI/res/values-land-television/dimens.xml
@@ -17,5 +17,8 @@
<resources>
<!-- Width of volume bar -->
<dimen name="volume_dialog_row_width">252dp</dimen>
- <dimen name="volume_dialog_tap_target_size">36dp</dimen>
+ <dimen name="tv_volume_dialog_bubble_size">36dp</dimen>
+ <dimen name="tv_volume_dialog_corner_radius">40dp</dimen>
+ <dimen name="tv_volume_dialog_row_padding">5dp</dimen>
+ <dimen name="tv_volume_number_text_size">16dp</dimen>
</resources>
diff --git a/packages/SystemUI/res/values-lo/strings.xml b/packages/SystemUI/res/values-lo/strings.xml
index 030bdc1..b1c5a5c 100644
--- a/packages/SystemUI/res/values-lo/strings.xml
+++ b/packages/SystemUI/res/values-lo/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"ກຳລັງໂຫຼດຄຳແນະນຳ"</string>
<string name="controls_media_title" msgid="1746947284862928133">"ມີເດຍ"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"ເຊື່ອງເຊດຊັນປັດຈຸບັນ."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"ເຊື່ອງ"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"ສືບຕໍ່"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"ການຕັ້ງຄ່າ"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"ບໍ່ເຮັດວຽກ, ກະລຸນາກວດສອບແອັບ"</string>
diff --git a/packages/SystemUI/res/values-lt/strings.xml b/packages/SystemUI/res/values-lt/strings.xml
index 6f48741..4e9b802 100644
--- a/packages/SystemUI/res/values-lt/strings.xml
+++ b/packages/SystemUI/res/values-lt/strings.xml
@@ -1081,7 +1081,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Įkeliamos rekomendacijos"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Medija"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Slėpti dabartinį seansą."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Slėpti"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Tęsti"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Nustatymai"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Neaktyvu, patikrinkite progr."</string>
diff --git a/packages/SystemUI/res/values-lv/strings.xml b/packages/SystemUI/res/values-lv/strings.xml
index bdea26a..a4c4666 100644
--- a/packages/SystemUI/res/values-lv/strings.xml
+++ b/packages/SystemUI/res/values-lv/strings.xml
@@ -1075,7 +1075,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Notiek ieteikumu ielāde"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Multivide"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Paslēpiet pašreizējo sesiju."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Paslēpt"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Atsākt"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Iestatījumi"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Neaktīva, pārbaudiet lietotni"</string>
diff --git a/packages/SystemUI/res/values-mk/strings.xml b/packages/SystemUI/res/values-mk/strings.xml
index c9f3777..7e623ad 100644
--- a/packages/SystemUI/res/values-mk/strings.xml
+++ b/packages/SystemUI/res/values-mk/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Се вчитуваат препораки"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Аудиовизуелни содржини"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Сокриј ја тековнава сесија."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Сокриј"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Продолжи"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Поставки"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Неактивна, провери апликација"</string>
diff --git a/packages/SystemUI/res/values-ml/strings.xml b/packages/SystemUI/res/values-ml/strings.xml
index c968c28..35e6427 100644
--- a/packages/SystemUI/res/values-ml/strings.xml
+++ b/packages/SystemUI/res/values-ml/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"നിർദ്ദേശങ്ങൾ ലോഡ് ചെയ്യുന്നു"</string>
<string name="controls_media_title" msgid="1746947284862928133">"മീഡിയ"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"നിലവിലെ സെഷൻ മറയ്ക്കുക."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"മറയ്ക്കുക"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"പുനരാരംഭിക്കുക"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"ക്രമീകരണം"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"നിഷ്ക്രിയം, ആപ്പ് പരിശോധിക്കൂ"</string>
diff --git a/packages/SystemUI/res/values-mn/strings.xml b/packages/SystemUI/res/values-mn/strings.xml
index 9ce6779..b4690d4 100644
--- a/packages/SystemUI/res/values-mn/strings.xml
+++ b/packages/SystemUI/res/values-mn/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Зөвлөмжүүдийг ачаалж байна"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Медиа"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Одоогийн харилцан үйлдлийг нуугаарай."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Нуух"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Үргэлжлүүлэх"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Тохиргоо"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Идэвхгүй байна, аппыг шалгана уу"</string>
diff --git a/packages/SystemUI/res/values-mr/strings.xml b/packages/SystemUI/res/values-mr/strings.xml
index d712679..4ea965a 100644
--- a/packages/SystemUI/res/values-mr/strings.xml
+++ b/packages/SystemUI/res/values-mr/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"शिफारशी लोड करत आहे"</string>
<string name="controls_media_title" msgid="1746947284862928133">"मीडिया"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"सध्याचे सेशन लपवा."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"लपवा"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"पुन्हा सुरू करा"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"सेटिंग्ज"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"निष्क्रिय, ॲप तपासा"</string>
diff --git a/packages/SystemUI/res/values-ms/strings.xml b/packages/SystemUI/res/values-ms/strings.xml
index 01e918a..38ee25c 100644
--- a/packages/SystemUI/res/values-ms/strings.xml
+++ b/packages/SystemUI/res/values-ms/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Memuatkan cadangan"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Sembunyikan sesi semasa."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Sembunyikan"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Sambung semula"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Tetapan"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Tidak aktif, semak apl"</string>
diff --git a/packages/SystemUI/res/values-my/strings.xml b/packages/SystemUI/res/values-my/strings.xml
index 23b0a06..150ed94e 100644
--- a/packages/SystemUI/res/values-my/strings.xml
+++ b/packages/SystemUI/res/values-my/strings.xml
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"အကြံပြုချက်များ ဖွင့်နေသည်"</string>
<string name="controls_media_title" msgid="1746947284862928133">"မီဒီယာ"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"လက်ရှိ စက်ရှင်ကို ဖျောက်ထားမည်။"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"ဖျောက်ထားမည်"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"ပယ်ရန်"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"ဆက်လုပ်ရန်"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"ဆက်တင်များ"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"ရပ်နေသည်၊ အက်ပ်ကို စစ်ဆေးပါ"</string>
diff --git a/packages/SystemUI/res/values-nb/strings.xml b/packages/SystemUI/res/values-nb/strings.xml
index b0a593f..d872a89 100644
--- a/packages/SystemUI/res/values-nb/strings.xml
+++ b/packages/SystemUI/res/values-nb/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Laster inn anbefalinger"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Medier"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Skjul den nåværende økten."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Skjul"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Gjenoppta"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Innstillinger"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inaktiv. Sjekk appen"</string>
diff --git a/packages/SystemUI/res/values-ne/strings.xml b/packages/SystemUI/res/values-ne/strings.xml
index 09462cf..1974e80 100644
--- a/packages/SystemUI/res/values-ne/strings.xml
+++ b/packages/SystemUI/res/values-ne/strings.xml
@@ -731,11 +731,11 @@
<string name="see_more_title" msgid="7409317011708185729">"थप हेर्नुहोस्"</string>
<string name="appops_camera" msgid="5215967620896725715">"यो अनुप्रयोगले क्यामेराको प्रयोग गर्दै छ।"</string>
<string name="appops_microphone" msgid="8805468338613070149">"यो अनुप्रयोगले माइक्रोफोनको प्रयोग गर्दै छ।"</string>
- <string name="appops_overlay" msgid="4822261562576558490">"यो अनुप्रयोगले तपाईंको स्क्रिनका अन्य अनुप्रयोगहरूमाथि प्रदर्शन गर्दै छ।"</string>
+ <string name="appops_overlay" msgid="4822261562576558490">"यो अनुप्रयोगले तपाईंको स्क्रिनका अन्य एपमाथि प्रदर्शन गर्दै छ।"</string>
<string name="appops_camera_mic" msgid="7032239823944420431">"यो अनुप्रयोगले माइक्रोफोन र क्यामेराको प्रयोग गर्दै छ।"</string>
- <string name="appops_camera_overlay" msgid="6466845606058816484">"यो अनुप्रयोगले तपाईंको स्क्रिनका अन्य अनुप्रयोगहरूमाथि प्रदर्शन गर्नुका साथै क्यामेराको प्रयोग गर्दै छ।"</string>
- <string name="appops_mic_overlay" msgid="4609326508944233061">"यो अनुप्रयोगले तपाईंको स्क्रिनका अन्य अनुप्रयोगहरूमाथि प्रदर्शन गर्नुका साथै माइक्रोफोनको प्रयोग गर्दै छ।"</string>
- <string name="appops_camera_mic_overlay" msgid="5584311236445644095">"यो अनुप्रयोगले तपाईंको स्क्रिनका अन्य अनुप्रयोगहरूमाथि प्रदर्शन गर्नुका साथै माइक्रोफोन र क्यामेराको प्रयोग गर्दै छ।"</string>
+ <string name="appops_camera_overlay" msgid="6466845606058816484">"यो अनुप्रयोगले तपाईंको स्क्रिनका अन्य एपमाथि प्रदर्शन गर्नुका साथै क्यामेराको प्रयोग गर्दै छ।"</string>
+ <string name="appops_mic_overlay" msgid="4609326508944233061">"यो अनुप्रयोगले तपाईंको स्क्रिनका अन्य एपमाथि प्रदर्शन गर्नुका साथै माइक्रोफोनको प्रयोग गर्दै छ।"</string>
+ <string name="appops_camera_mic_overlay" msgid="5584311236445644095">"यो अनुप्रयोगले तपाईंको स्क्रिनका अन्य एपमाथि प्रदर्शन गर्नुका साथै माइक्रोफोन र क्यामेराको प्रयोग गर्दै छ।"</string>
<string name="notification_appops_settings" msgid="5208974858340445174">"सेटिङहरू"</string>
<string name="notification_appops_ok" msgid="2177609375872784124">"ठिक छ"</string>
<string name="feedback_silenced" msgid="5382212321253328247">"सिस्टमले यो सूचना आउँदा बज्ने ध्वनि बन्द गरेको छ।"</string>
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"सिफारिसहरू लोड गर्दै"</string>
<string name="controls_media_title" msgid="1746947284862928133">"मिडिया"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"हालको सत्र लुकाउनुहोस्।"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"लुकाउनुहोस्"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"सुचारु गर्नुहोस्"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"सेटिङ"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"निष्क्रिय छ, एप जाँच गर्नु…"</string>
@@ -1084,8 +1085,6 @@
<string name="controls_added_tooltip" msgid="4842812921719153085">"नयाँ नियन्त्रण सुविधाहरू हेर्न पावर बटन थिचिराख्नुहोस्"</string>
<string name="controls_menu_add" msgid="4447246119229920050">"नियन्त्रण सुविधाहरू थप्नुहोस्"</string>
<string name="controls_menu_edit" msgid="890623986951347062">"नियन्त्रण सुविधाहरू सम्पादन गर्नु…"</string>
- <!-- no translation found for one_handed_tutorial_title (6312198435090726656) -->
- <skip />
- <!-- no translation found for one_handed_tutorial_description (7674850272340517174) -->
- <skip />
+ <string name="one_handed_tutorial_title" msgid="6312198435090726656">"एक हाते मोड प्रयोग गरिँदै छ"</string>
+ <string name="one_handed_tutorial_description" msgid="7674850272340517174">"बाहिर निस्कन, स्क्रिनको पुछारबाट माथितिर स्वाइप गर्नुहोस् वा एपभन्दा माथि जुनसुकै ठाउँमा ट्याप गर्नुहोस्"</string>
</resources>
diff --git a/packages/SystemUI/res/values-nl/strings.xml b/packages/SystemUI/res/values-nl/strings.xml
index 2385017..9da8afa 100644
--- a/packages/SystemUI/res/values-nl/strings.xml
+++ b/packages/SystemUI/res/values-nl/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Aanbevelingen laden"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"De huidige sessie verbergen."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Verbergen"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Hervatten"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Instellingen"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inactief, check de app"</string>
diff --git a/packages/SystemUI/res/values-or/strings.xml b/packages/SystemUI/res/values-or/strings.xml
index d5c077b..5b5cbc6 100644
--- a/packages/SystemUI/res/values-or/strings.xml
+++ b/packages/SystemUI/res/values-or/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"ସୁପାରିଶଗୁଡ଼ିକ ଲୋଡ୍ କରାଯାଉଛି"</string>
<string name="controls_media_title" msgid="1746947284862928133">"ମିଡିଆ"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"ବର୍ତ୍ତମାନର ସେସନ୍ ଲୁଚାନ୍ତୁ।"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"ଲୁଚାନ୍ତୁ"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"ପୁଣି ଆରମ୍ଭ କରନ୍ତୁ"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"ସେଟିଂସ୍"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"ନିଷ୍କ୍ରିୟ ଅଛି, ଆପ ଯାଞ୍ଚ କରନ୍ତୁ"</string>
@@ -1084,8 +1085,6 @@
<string name="controls_added_tooltip" msgid="4842812921719153085">"ନୂଆ ନିୟନ୍ତ୍ରଣଗୁଡ଼ିକୁ ଦେଖିବା ପାଇଁ ପାୱାର ବଟନକୁ ଧରି ରଖନ୍ତୁ"</string>
<string name="controls_menu_add" msgid="4447246119229920050">"ନିୟନ୍ତ୍ରଣଗୁଡ଼ିକ ଯୋଗ କରନ୍ତୁ"</string>
<string name="controls_menu_edit" msgid="890623986951347062">"ନିୟନ୍ତ୍ରଣଗୁଡ଼ିକ ସମ୍ପାଦନ କରନ୍ତୁ"</string>
- <!-- no translation found for one_handed_tutorial_title (6312198435090726656) -->
- <skip />
- <!-- no translation found for one_handed_tutorial_description (7674850272340517174) -->
- <skip />
+ <string name="one_handed_tutorial_title" msgid="6312198435090726656">"ଏକ-ହାତ ମୋଡ୍ ବ୍ୟବହାର କରି"</string>
+ <string name="one_handed_tutorial_description" msgid="7674850272340517174">"ବାହାରି ଯିବା ପାଇଁ, ତଳୁ ଉପରକୁ ସ୍ୱାଇପ୍ କରନ୍ତୁ କିମ୍ବା ଆପ୍ ଆଇକନର ଉପରେ ଯେ କୌଣସି ସ୍ଥାନରେ ଟାପ୍ କରନ୍ତୁ"</string>
</resources>
diff --git a/packages/SystemUI/res/values-pa/strings.xml b/packages/SystemUI/res/values-pa/strings.xml
index 1156782..5c31ce7 100644
--- a/packages/SystemUI/res/values-pa/strings.xml
+++ b/packages/SystemUI/res/values-pa/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"ਸਿਫ਼ਾਰਸ਼ਾਂ ਲੋਡ ਹੋ ਰਹੀਆਂ ਹਨ"</string>
<string name="controls_media_title" msgid="1746947284862928133">"ਮੀਡੀਆ"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"ਮੌਜੂਦਾ ਸੈਸ਼ਨ ਨੂੰ ਲੁਕਾਓ।"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"ਲੁਕਾਓ"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"ਮੁੜ-ਚਾਲੂ ਕਰੋ"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"ਸੈਟਿੰਗਾਂ"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"ਅਕਿਰਿਆਸ਼ੀਲ, ਐਪ ਦੀ ਜਾਂਚ ਕਰੋ"</string>
@@ -1084,8 +1085,6 @@
<string name="controls_added_tooltip" msgid="4842812921719153085">"ਨਵੇਂ ਕੰਟਰੋਲ ਦੇਖਣ ਲਈ ਪਾਵਰ ਬਟਨ ਦਬਾਈ ਰੱਖੋ"</string>
<string name="controls_menu_add" msgid="4447246119229920050">"ਕੰਟਰੋਲ ਸ਼ਾਮਲ ਕਰੋ"</string>
<string name="controls_menu_edit" msgid="890623986951347062">"ਕੰਟਰੋਲਾਂ ਦਾ ਸੰਪਾਦਨ ਕਰੋ"</string>
- <!-- no translation found for one_handed_tutorial_title (6312198435090726656) -->
- <skip />
- <!-- no translation found for one_handed_tutorial_description (7674850272340517174) -->
- <skip />
+ <string name="one_handed_tutorial_title" msgid="6312198435090726656">"ਇੱਕ ਹੱਥ ਮੋਡ ਵਰਤਣਾ"</string>
+ <string name="one_handed_tutorial_description" msgid="7674850272340517174">"ਬਾਹਰ ਜਾਣ ਲਈ, ਸਕ੍ਰੀਨ ਦੇ ਹੇਠਾਂ ਤੋਂ ਉੱਪਰ ਵੱਲ ਸਵਾਈਪ ਕਰੋ ਜਾਂ ਐਪ \'ਤੇ ਕਿਤੇ ਵੀ ਟੈਪ ਕਰੋ"</string>
</resources>
diff --git a/packages/SystemUI/res/values-pl/strings.xml b/packages/SystemUI/res/values-pl/strings.xml
index 1f6effe..b7ee750 100644
--- a/packages/SystemUI/res/values-pl/strings.xml
+++ b/packages/SystemUI/res/values-pl/strings.xml
@@ -1081,7 +1081,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Wczytuję rekomendacje"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Multimedia"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Ukryj bieżącą sesję."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Ukryj"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Wznów"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Ustawienia"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Nieaktywny, sprawdź aplikację"</string>
diff --git a/packages/SystemUI/res/values-pt-rBR/strings.xml b/packages/SystemUI/res/values-pt-rBR/strings.xml
index 14d7a84..715b0e4 100644
--- a/packages/SystemUI/res/values-pt-rBR/strings.xml
+++ b/packages/SystemUI/res/values-pt-rBR/strings.xml
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Carregando recomendações"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Mídia"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Ocultar a sessão atual."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Ocultar"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"Dispensar"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"Retomar"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Configurações"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inativo, verifique o app"</string>
diff --git a/packages/SystemUI/res/values-pt-rPT/strings.xml b/packages/SystemUI/res/values-pt-rPT/strings.xml
index a6f7f00..1a59de4 100644
--- a/packages/SystemUI/res/values-pt-rPT/strings.xml
+++ b/packages/SystemUI/res/values-pt-rPT/strings.xml
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"A carregar recomendações…"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Multimédia"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Oculte a sessão atual."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Ocultar"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"Ignorar"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"Retomar"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Definições"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inativa. Consulte a app."</string>
diff --git a/packages/SystemUI/res/values-pt/strings.xml b/packages/SystemUI/res/values-pt/strings.xml
index 14d7a84..715b0e4 100644
--- a/packages/SystemUI/res/values-pt/strings.xml
+++ b/packages/SystemUI/res/values-pt/strings.xml
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Carregando recomendações"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Mídia"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Ocultar a sessão atual."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Ocultar"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"Dispensar"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"Retomar"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Configurações"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inativo, verifique o app"</string>
diff --git a/packages/SystemUI/res/values-ro/strings.xml b/packages/SystemUI/res/values-ro/strings.xml
index 0f15cfc..49c3ba0 100644
--- a/packages/SystemUI/res/values-ro/strings.xml
+++ b/packages/SystemUI/res/values-ro/strings.xml
@@ -1075,7 +1075,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Se încarcă recomandările"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Ascunde sesiunea actuală."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Ascunde"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Reia"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Setări"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inactiv, verificați aplicația"</string>
diff --git a/packages/SystemUI/res/values-ru/strings.xml b/packages/SystemUI/res/values-ru/strings.xml
index 6196f88..7fb456d 100644
--- a/packages/SystemUI/res/values-ru/strings.xml
+++ b/packages/SystemUI/res/values-ru/strings.xml
@@ -1081,7 +1081,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Загрузка рекомендаций…"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Медиа"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Скрыть текущий сеанс?"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Скрыть"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Возобновить"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Настройки"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Нет ответа. Проверьте приложение."</string>
diff --git a/packages/SystemUI/res/values-si/strings.xml b/packages/SystemUI/res/values-si/strings.xml
index 8aca9f4..1cd1ceb 100644
--- a/packages/SystemUI/res/values-si/strings.xml
+++ b/packages/SystemUI/res/values-si/strings.xml
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"නිර්දේශ පූරණය කරමින්"</string>
<string name="controls_media_title" msgid="1746947284862928133">"මාධ්ය"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"වත්මන් සැසිය සඟවන්න."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"සඟවන්න"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"ඉවත ලන්න"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"නැවත පටන් ගන්න"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"සැකසීම්"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"අක්රියයි, යෙදුම පරීක්ෂා කරන්න"</string>
diff --git a/packages/SystemUI/res/values-sk/strings.xml b/packages/SystemUI/res/values-sk/strings.xml
index 45ee562..9d7e7d1 100644
--- a/packages/SystemUI/res/values-sk/strings.xml
+++ b/packages/SystemUI/res/values-sk/strings.xml
@@ -1081,7 +1081,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Načítavajú sa odporúčania"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Médiá"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Skryť aktuálnu reláciu."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Skryť"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Pokračovať"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Nastavenia"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Neaktívne, preverte aplikáciu"</string>
diff --git a/packages/SystemUI/res/values-sl/strings.xml b/packages/SystemUI/res/values-sl/strings.xml
index c7ad8ab..ecbf1d9 100644
--- a/packages/SystemUI/res/values-sl/strings.xml
+++ b/packages/SystemUI/res/values-sl/strings.xml
@@ -1081,7 +1081,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Nalaganje priporočil"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Predstavnost"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Skrije trenutno sejo."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Skrij"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Nadaljuj"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Nastavitve"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Neaktivno, poglejte aplikacijo"</string>
diff --git a/packages/SystemUI/res/values-sq/strings.xml b/packages/SystemUI/res/values-sq/strings.xml
index 3e0aecc..70245b8 100644
--- a/packages/SystemUI/res/values-sq/strings.xml
+++ b/packages/SystemUI/res/values-sq/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Po ngarkon rekomandimet"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Fshih sesionin aktual."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Fshih"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Vazhdo"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Cilësimet"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Joaktive, kontrollo aplikacionin"</string>
diff --git a/packages/SystemUI/res/values-sr/strings.xml b/packages/SystemUI/res/values-sr/strings.xml
index 985041b..1d02ca6 100644
--- a/packages/SystemUI/res/values-sr/strings.xml
+++ b/packages/SystemUI/res/values-sr/strings.xml
@@ -1075,7 +1075,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Учитавају се препоруке"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Медији"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Сакријте актуелну сесију."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Сакриј"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Настави"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Подешавања"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Неактивно. Видите апликацију"</string>
diff --git a/packages/SystemUI/res/values-sv/strings.xml b/packages/SystemUI/res/values-sv/strings.xml
index 2018a38..7a7448b 100644
--- a/packages/SystemUI/res/values-sv/strings.xml
+++ b/packages/SystemUI/res/values-sv/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Rekommendationer läses in"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Dölj den aktuella sessionen."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Dölj"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Återuppta"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Inställningar"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Inaktiv, kolla appen"</string>
diff --git a/packages/SystemUI/res/values-sw/strings.xml b/packages/SystemUI/res/values-sw/strings.xml
index 6eecc0e..b8d95fc 100644
--- a/packages/SystemUI/res/values-sw/strings.xml
+++ b/packages/SystemUI/res/values-sw/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Inapakia mapendekezo"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Maudhui"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Ficha kipindi cha sasa."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Ficha"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Endelea"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Mipangilio"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Haitumiki, angalia programu"</string>
diff --git a/packages/SystemUI/res/values-ta/strings.xml b/packages/SystemUI/res/values-ta/strings.xml
index a05e0e7..60c1cf9 100644
--- a/packages/SystemUI/res/values-ta/strings.xml
+++ b/packages/SystemUI/res/values-ta/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"பரிந்துரைகளை ஏற்றுகிறது"</string>
<string name="controls_media_title" msgid="1746947284862928133">"மீடியா"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"இந்த அமர்வை மறையுங்கள்."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"மறை"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"தொடர்க"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"அமைப்புகள்"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"செயலில் இல்லை , சரிபார்க்கவும்"</string>
diff --git a/packages/SystemUI/res/values-te/strings.xml b/packages/SystemUI/res/values-te/strings.xml
index 7d76abd..6cfe03d 100644
--- a/packages/SystemUI/res/values-te/strings.xml
+++ b/packages/SystemUI/res/values-te/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"సిఫార్సులు లోడ్ అవుతున్నాయి"</string>
<string name="controls_media_title" msgid="1746947284862928133">"మీడియా"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"ప్రస్తుత సెషన్ను దాచు."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"దాచు"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"కొనసాగించండి"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"సెట్టింగ్లు"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"ఇన్యాక్టివ్, యాప్ చెక్ చేయండి"</string>
diff --git a/packages/SystemUI/res/values-television/config.xml b/packages/SystemUI/res/values-television/config.xml
index 1696aab..7b1479a 100644
--- a/packages/SystemUI/res/values-television/config.xml
+++ b/packages/SystemUI/res/values-television/config.xml
@@ -43,4 +43,7 @@
<item>com.android.systemui.toast.ToastUI</item>
<item>com.android.systemui.onehanded.OneHandedUI</item>
</string-array>
+
+ <!-- Show a separate icon for low and high volume on the volume dialog -->
+ <bool name="config_showLowMediaVolumeIcon">true</bool>
</resources>
diff --git a/packages/SystemUI/res/values-television/styles.xml b/packages/SystemUI/res/values-television/styles.xml
index b01c5d8..4cf7034a 100644
--- a/packages/SystemUI/res/values-television/styles.xml
+++ b/packages/SystemUI/res/values-television/styles.xml
@@ -22,4 +22,8 @@
<item name="android:windowEnterAnimation">@null</item>
<item name="android:windowExitAnimation">@null</item>
</style>
+
+ <style name="volume_dialog_theme" parent="qs_theme">
+ <item name="android:colorAccent">@color/tv_volume_dialog_accent</item>
+ </style>
</resources>
diff --git a/packages/SystemUI/res/values-th/strings.xml b/packages/SystemUI/res/values-th/strings.xml
index 765c224..a2c1127 100644
--- a/packages/SystemUI/res/values-th/strings.xml
+++ b/packages/SystemUI/res/values-th/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"กำลังโหลดคำแนะนำ"</string>
<string name="controls_media_title" msgid="1746947284862928133">"สื่อ"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"ซ่อนเซสชันปัจจุบัน"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"ซ่อน"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"เล่นต่อ"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"การตั้งค่า"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"ไม่มีการใช้งาน โปรดตรวจสอบแอป"</string>
diff --git a/packages/SystemUI/res/values-tl/strings.xml b/packages/SystemUI/res/values-tl/strings.xml
index c2cae90..e5f0532 100644
--- a/packages/SystemUI/res/values-tl/strings.xml
+++ b/packages/SystemUI/res/values-tl/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Nilo-load ang rekomendasyon"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Itago ang kasalukuyang session."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Itago"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Ituloy"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Mga Setting"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Hindi aktibo, tingnan ang app"</string>
diff --git a/packages/SystemUI/res/values-tr/strings.xml b/packages/SystemUI/res/values-tr/strings.xml
index 74b44f2..4943e2d 100644
--- a/packages/SystemUI/res/values-tr/strings.xml
+++ b/packages/SystemUI/res/values-tr/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Öneriler yükleniyor"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Medya"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Mevcut oturumu gizle."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Gizle"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Devam ettir"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Ayarlar"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Devre dışı, uygulamaya bakın"</string>
diff --git a/packages/SystemUI/res/values-uk/strings.xml b/packages/SystemUI/res/values-uk/strings.xml
index 38c331a..447912e 100644
--- a/packages/SystemUI/res/values-uk/strings.xml
+++ b/packages/SystemUI/res/values-uk/strings.xml
@@ -1081,7 +1081,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Завантаження рекомендацій"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Медіа"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Приховати поточний сеанс."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Приховати"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Відновити"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Налаштування"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Неактивно, перейдіть у додаток"</string>
diff --git a/packages/SystemUI/res/values-ur/strings.xml b/packages/SystemUI/res/values-ur/strings.xml
index 69ddabb..20b5518 100644
--- a/packages/SystemUI/res/values-ur/strings.xml
+++ b/packages/SystemUI/res/values-ur/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"تجاویز لوڈ ہو رہی ہیں"</string>
<string name="controls_media_title" msgid="1746947284862928133">"میڈیا"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"موجودہ سیشن چھپائیں۔"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"چھپائیں"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"دوبارہ شروع کریں"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"ترتیبات"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"غیر فعال، ایپ چیک کریں"</string>
diff --git a/packages/SystemUI/res/values-uz/strings.xml b/packages/SystemUI/res/values-uz/strings.xml
index ed704b0..cf1da75 100644
--- a/packages/SystemUI/res/values-uz/strings.xml
+++ b/packages/SystemUI/res/values-uz/strings.xml
@@ -227,7 +227,7 @@
<string name="data_connection_roaming" msgid="375650836665414797">"Rouming"</string>
<string name="data_connection_edge" msgid="6316755666481405762">"EDGE"</string>
<string name="accessibility_data_connection_wifi" msgid="4422160347472742434">"Wi-Fi"</string>
- <string name="accessibility_no_sim" msgid="1140839832913084973">"SIM karta solinmagan."</string>
+ <string name="accessibility_no_sim" msgid="1140839832913084973">"SIM kartasiz."</string>
<string name="accessibility_cell_data" msgid="172950885786007392">"Mobil internet"</string>
<string name="accessibility_cell_data_on" msgid="691666434519443162">"Mobil internet yoniq"</string>
<string name="cell_data_off_content_description" msgid="9165555931499878044">"Mobil internet yoqilmagan"</string>
@@ -1069,7 +1069,7 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Tavsiyalar yuklanmoqda"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Media"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Joriy seans berkitilsin."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Berkitish"</string>
+ <string name="controls_media_dismiss_button" msgid="9081375542265132213">"Yopish"</string>
<string name="controls_media_resume" msgid="1933520684481586053">"Davom etish"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Sozlamalar"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Nofaol. Ilovani tekshiring"</string>
diff --git a/packages/SystemUI/res/values-vi/strings.xml b/packages/SystemUI/res/values-vi/strings.xml
index 5cc2099..a12a08d 100644
--- a/packages/SystemUI/res/values-vi/strings.xml
+++ b/packages/SystemUI/res/values-vi/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Đang tải các đề xuất"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Nội dung nghe nhìn"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Ẩn phiên hiện tại."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Ẩn"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Tiếp tục"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Cài đặt"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Không hoạt động, hãy kiểm tra ứng dụng"</string>
diff --git a/packages/SystemUI/res/values-zh-rCN/strings.xml b/packages/SystemUI/res/values-zh-rCN/strings.xml
index f670bf6..3382365 100644
--- a/packages/SystemUI/res/values-zh-rCN/strings.xml
+++ b/packages/SystemUI/res/values-zh-rCN/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"正在加载推荐内容"</string>
<string name="controls_media_title" msgid="1746947284862928133">"媒体"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"隐藏当前会话。"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"隐藏"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"继续播放"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"设置"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"无效,请检查应用"</string>
diff --git a/packages/SystemUI/res/values-zh-rHK/strings.xml b/packages/SystemUI/res/values-zh-rHK/strings.xml
index 2e26d61..1d55ca2 100644
--- a/packages/SystemUI/res/values-zh-rHK/strings.xml
+++ b/packages/SystemUI/res/values-zh-rHK/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"正在載入建議"</string>
<string name="controls_media_title" msgid="1746947284862928133">"媒體"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"隱藏目前的工作階段。"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"隱藏"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"繼續播放"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"設定"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"已停用,請檢查應用程式"</string>
diff --git a/packages/SystemUI/res/values-zh-rTW/strings.xml b/packages/SystemUI/res/values-zh-rTW/strings.xml
index 0049d2e..e62c164 100644
--- a/packages/SystemUI/res/values-zh-rTW/strings.xml
+++ b/packages/SystemUI/res/values-zh-rTW/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"正在載入建議控制項"</string>
<string name="controls_media_title" msgid="1746947284862928133">"媒體"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"隱藏目前的工作階段。"</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"隱藏"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"繼續播放"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"設定"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"無效,請查看應用程式"</string>
diff --git a/packages/SystemUI/res/values-zu/strings.xml b/packages/SystemUI/res/values-zu/strings.xml
index c8c99b1..bd73912 100644
--- a/packages/SystemUI/res/values-zu/strings.xml
+++ b/packages/SystemUI/res/values-zu/strings.xml
@@ -1069,7 +1069,8 @@
<string name="controls_seeding_in_progress" msgid="3033855341410264148">"Ilayisha izincomo"</string>
<string name="controls_media_title" msgid="1746947284862928133">"Imidiya"</string>
<string name="controls_media_close_session" msgid="3957093425905475065">"Fihla iseshini yamanje."</string>
- <string name="controls_media_dismiss_button" msgid="4485675693008031646">"Fihla"</string>
+ <!-- no translation found for controls_media_dismiss_button (9081375542265132213) -->
+ <skip />
<string name="controls_media_resume" msgid="1933520684481586053">"Qalisa kabusha"</string>
<string name="controls_media_settings_button" msgid="5815790345117172504">"Izilungiselelo"</string>
<string name="controls_error_timeout" msgid="794197289772728958">"Akusebenzi, hlola uhlelo lokusebenza"</string>
diff --git a/packages/SystemUI/res/values/colors_tv.xml b/packages/SystemUI/res/values/colors_tv.xml
index 53cd971..cb49918 100644
--- a/packages/SystemUI/res/values/colors_tv.xml
+++ b/packages/SystemUI/res/values/colors_tv.xml
@@ -24,7 +24,11 @@
<!-- Background color for audio recording indicator (G800) -->
<color name="tv_audio_recording_indicator_background">#FF3C4043</color>
- <color name="tv_audio_recording_indicator_pulse">#4DFFFFFF</color>
+ <color name="tv_audio_recording_indicator_icon_background">#CC000000</color>
+ <color name="tv_audio_recording_indicator_stroke">#33FFFFFF</color>
<color name="red">#FFCC0000</color>
+ <color name="tv_volume_dialog_background">#E61F232B</color>
+ <color name="tv_volume_dialog_circle">#08FFFFFF</color>
+ <color name="tv_volume_dialog_accent">#FFDADCE0</color>
</resources>
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index fba43a6..17ba7c9 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -574,4 +574,6 @@
<!-- Animation duration for translating of one handed when trigger / dismiss. -->
<integer name="config_one_handed_translate_animation_duration">150</integer>
+ <!-- Show a separate icon for low and high volume on the volume dialog -->
+ <bool name="config_showLowMediaVolumeIcon">false</bool>
</resources>
diff --git a/packages/SystemUI/res/values/donottranslate.xml b/packages/SystemUI/res/values/donottranslate.xml
index 67293c5..f05be06 100644
--- a/packages/SystemUI/res/values/donottranslate.xml
+++ b/packages/SystemUI/res/values/donottranslate.xml
@@ -21,5 +21,5 @@
<string name="system_ui_date_pattern" translatable="false">@*android:string/system_ui_date_pattern</string>
<!-- Date format for the always on display. -->
- <item type="string" name="system_ui_aod_date_pattern" translatable="false">eeeMMMd</item>
+ <item type="string" name="system_ui_aod_date_pattern" translatable="false">EEEMMMd</item>
</resources>
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index 9e5b94e..ee07e61 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -387,6 +387,9 @@
<item name="android:homeAsUpIndicator">@drawable/ic_arrow_back</item>
</style>
+ <!-- Overridden by values-television/styles.xml with tv-specific settings -->
+ <style name="volume_dialog_theme" parent="qs_theme"/>
+
<style name="systemui_theme_remote_input" parent="@android:style/Theme.DeviceDefault.Light">
<item name="android:colorAccent">@color/remote_input_accent</item>
</style>
diff --git a/services/core/java/com/android/server/protolog/common/BitmaskConversionException.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ContextUtils.java
similarity index 61%
copy from services/core/java/com/android/server/protolog/common/BitmaskConversionException.java
copy to packages/SystemUI/shared/src/com/android/systemui/shared/system/ContextUtils.java
index 7bb27b2..1de740a 100644
--- a/services/core/java/com/android/server/protolog/common/BitmaskConversionException.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ContextUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 The Android Open Source Project
+ * 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.
@@ -14,13 +14,15 @@
* limitations under the License.
*/
-package com.android.server.protolog.common;
+package com.android.systemui.shared.system;
-/**
- * Error while converting a bitmask representing a list of LogDataTypes.
- */
-public class BitmaskConversionException extends RuntimeException {
- BitmaskConversionException(String msg) {
- super(msg);
+import android.annotation.UserIdInt;
+import android.content.Context;
+
+public class ContextUtils {
+
+ /** Get the user associated with this context */
+ public static @UserIdInt int getUserId(Context context) {
+ return context.getUserId();
}
}
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WallpaperEngineCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WallpaperEngineCompat.java
index 4d968f1..73dc60d 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WallpaperEngineCompat.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WallpaperEngineCompat.java
@@ -26,6 +26,17 @@
private static final String TAG = "WallpaperEngineCompat";
+ /**
+ * Returns true if {@link IWallpaperEngine#scalePreview(Rect)} is available.
+ */
+ public static boolean supportsScalePreview() {
+ try {
+ return IWallpaperEngine.class.getMethod("scalePreview", Rect.class) != null;
+ } catch (NoSuchMethodException | SecurityException e) {
+ return false;
+ }
+ }
+
private final IWallpaperEngine mWrappedEngine;
public WallpaperEngineCompat(IWallpaperEngine wrappedEngine) {
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnification.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnification.java
index 816bcf8..d5f74a8 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnification.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnification.java
@@ -53,8 +53,8 @@
ActivityInfo.CONFIG_DENSITY | ActivityInfo.CONFIG_ORIENTATION;
@VisibleForTesting
- protected WindowMagnificationController mWindowMagnificationController;
- protected final ModeSwitchesController mModeSwitchesController;
+ protected WindowMagnificationAnimationController mWindowMagnificationAnimationController;
+ private final ModeSwitchesController mModeSwitchesController;
private final Handler mHandler;
private final AccessibilityManager mAccessibilityManager;
private final CommandQueue mCommandQueue;
@@ -72,6 +72,11 @@
Context.ACCESSIBILITY_SERVICE);
mCommandQueue = commandQueue;
mModeSwitchesController = modeSwitchesController;
+ final WindowMagnificationController controller = new WindowMagnificationController(mContext,
+ mHandler, new SfVsyncFrameCallbackProvider(), null,
+ new SurfaceControl.Transaction(), this);
+ mWindowMagnificationAnimationController = new WindowMagnificationAnimationController(
+ mContext, controller);
}
@Override
@@ -81,9 +86,7 @@
return;
}
mLastConfiguration.setTo(newConfig);
- if (mWindowMagnificationController != null) {
- mWindowMagnificationController.onConfigurationChanged(configDiff);
- }
+ mWindowMagnificationAnimationController.onConfigurationChanged(configDiff);
if (mModeSwitchesController != null) {
mModeSwitchesController.onConfigurationChanged(configDiff);
}
@@ -97,39 +100,25 @@
@MainThread
void enableWindowMagnification(int displayId, float scale, float centerX, float centerY) {
//TODO: b/144080869 support multi-display.
- if (mWindowMagnificationController == null) {
- mWindowMagnificationController = new WindowMagnificationController(mContext,
- mHandler,
- new SfVsyncFrameCallbackProvider(),
- null, new SurfaceControl.Transaction(),
- this);
- }
- mWindowMagnificationController.enableWindowMagnification(scale, centerX, centerY);
+ mWindowMagnificationAnimationController.enableWindowMagnification(scale, centerX, centerY);
}
@MainThread
void setScale(int displayId, float scale) {
//TODO: b/144080869 support multi-display.
- if (mWindowMagnificationController != null) {
- mWindowMagnificationController.setScale(scale);
- }
+ mWindowMagnificationAnimationController.setScale(scale);
}
@MainThread
void moveWindowMagnifier(int displayId, float offsetX, float offsetY) {
//TODO: b/144080869 support multi-display.
- if (mWindowMagnificationController != null) {
- mWindowMagnificationController.moveWindowMagnifier(offsetX, offsetY);
- }
+ mWindowMagnificationAnimationController.moveWindowMagnifier(offsetX, offsetY);
}
@MainThread
void disableWindowMagnification(int displayId) {
//TODO: b/144080869 support multi-display.
- if (mWindowMagnificationController != null) {
- mWindowMagnificationController.deleteWindowMagnification();
- }
- mWindowMagnificationController = null;
+ mWindowMagnificationAnimationController.deleteWindowMagnification();
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationAnimationController.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationAnimationController.java
new file mode 100644
index 0000000..ae51623
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationAnimationController.java
@@ -0,0 +1,272 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui.accessibility;
+
+import android.animation.Animator;
+import android.animation.ValueAnimator;
+import android.annotation.IntDef;
+import android.content.Context;
+import android.content.res.Resources;
+import android.util.Log;
+import android.view.animation.AccelerateInterpolator;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.systemui.R;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Provides same functionality of {@link WindowMagnificationController}. Some methods run with
+ * the animation.
+ */
+class WindowMagnificationAnimationController implements ValueAnimator.AnimatorUpdateListener,
+ Animator.AnimatorListener {
+
+ private static final String TAG = "WindowMagnificationBridge";
+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({STATE_DISABLED, STATE_ENABLED, STATE_DISABLING, STATE_ENABLING})
+ @interface MagnificationState {}
+
+ //The window magnification is disabled.
+ private static final int STATE_DISABLED = 0;
+ //The window magnification is enabled.
+ private static final int STATE_ENABLED = 1;
+ //The window magnification is going to be disabled when the animation is end.
+ private static final int STATE_DISABLING = 2;
+ //The animation is running for enabling the window magnification.
+ private static final int STATE_ENABLING = 3;
+
+ private final WindowMagnificationController mController;
+ private final ValueAnimator mValueAnimator;
+ private final AnimationSpec mStartSpec = new AnimationSpec();
+ private final AnimationSpec mEndSpec = new AnimationSpec();
+ private final Context mContext;
+
+ @MagnificationState
+ private int mState = STATE_DISABLED;
+
+ WindowMagnificationAnimationController(
+ Context context, WindowMagnificationController controller) {
+ this(context, controller, newValueAnimator(context.getResources()));
+ }
+
+ @VisibleForTesting
+ WindowMagnificationAnimationController(Context context,
+ WindowMagnificationController controller, ValueAnimator valueAnimator) {
+ mContext = context;
+ mController = controller;
+ mValueAnimator = valueAnimator;
+ mValueAnimator.addUpdateListener(this);
+ mValueAnimator.addListener(this);
+ }
+
+ /**
+ * Wraps {@link WindowMagnificationController#enableWindowMagnification(float, float, float)}
+ * with transition animation. If the window magnification is not enabled, the scale will start
+ * from 1.0 and the center won't be changed during the animation. If {@link #mState} is
+ * {@code STATE_DISABLING}, the animation runs in reverse.
+ *
+ * @param scale the target scale, or {@link Float#NaN} to leave unchanged.
+ * @param centerX the screen-relative X coordinate around which to center,
+ * or {@link Float#NaN} to leave unchanged.
+ * @param centerY the screen-relative Y coordinate around which to center,
+ * or {@link Float#NaN} to leave unchanged.
+ *
+ * @see #onAnimationUpdate(ValueAnimator)
+ */
+ void enableWindowMagnification(float scale, float centerX, float centerY) {
+ if (mState == STATE_ENABLING) {
+ mValueAnimator.cancel();
+ }
+ setupEnableAnimationSpecs(scale, centerX, centerY);
+
+ if (mEndSpec.equals(mStartSpec)) {
+ setState(STATE_ENABLED);
+ } else {
+ if (mState == STATE_DISABLING) {
+ mValueAnimator.reverse();
+ } else {
+ mValueAnimator.start();
+ }
+ setState(STATE_ENABLING);
+ }
+ }
+
+ private void setupEnableAnimationSpecs(float scale, float centerX, float centerY) {
+ final float currentScale = mController.getScale();
+ final float currentCenterX = mController.getCenterX();
+ final float currentCenterY = mController.getCenterY();
+
+ if (mState == STATE_DISABLED) {
+ //We don't need to offset the center during the animation.
+ mStartSpec.set(/* scale*/ 1.0f, centerX, centerY);
+ mEndSpec.set(Float.isNaN(scale) ? mContext.getResources().getInteger(
+ R.integer.magnification_default_scale) : scale, centerX, centerY);
+ } else {
+ mStartSpec.set(currentScale, currentCenterX, currentCenterY);
+ mEndSpec.set(Float.isNaN(scale) ? currentScale : scale,
+ Float.isNaN(centerX) ? currentCenterX : centerX,
+ Float.isNaN(centerY) ? currentCenterY : centerY);
+ }
+ if (DEBUG) {
+ Log.d(TAG, "SetupEnableAnimationSpecs : mStartSpec = " + mStartSpec + ", endSpec = "
+ + mEndSpec);
+ }
+ }
+
+ /**
+ * Wraps {@link WindowMagnificationController#setScale(float)}. If the animation is
+ * running, it has no effect.
+ */
+ void setScale(float scale) {
+ if (mValueAnimator.isRunning()) {
+ return;
+ }
+ mController.setScale(scale);
+ }
+
+ /**
+ * Wraps {@link WindowMagnificationController#deleteWindowMagnification()}} with transition
+ * animation. If the window magnification is enabling, it runs the animation in reverse.
+ */
+ void deleteWindowMagnification() {
+ if (mState == STATE_DISABLED || mState == STATE_DISABLING) {
+ return;
+ }
+ mStartSpec.set(/* scale*/ 1.0f, Float.NaN, Float.NaN);
+ mEndSpec.set(/* scale*/ mController.getScale(), Float.NaN, Float.NaN);
+
+ mValueAnimator.reverse();
+ setState(STATE_DISABLING);
+ }
+
+ /**
+ * Wraps {@link WindowMagnificationController#moveWindowMagnifier(float, float)}. If the
+ * animation is running, it has no effect.
+ * @param offsetX the amount in pixels to offset the window magnifier in the X direction, in
+ * current screen pixels.
+ * @param offsetY the amount in pixels to offset the window magnifier in the Y direction, in
+ * current screen pixels.
+ */
+ void moveWindowMagnifier(float offsetX, float offsetY) {
+ if (mValueAnimator.isRunning()) {
+ return;
+ }
+ mController.moveWindowMagnifier(offsetX, offsetY);
+ }
+
+ void onConfigurationChanged(int configDiff) {
+ mController.onConfigurationChanged(configDiff);
+ }
+
+ private void setState(@MagnificationState int state) {
+ if (DEBUG) {
+ Log.d(TAG, "setState from " + mState + " to " + state);
+ }
+ mState = state;
+ }
+
+ @Override
+ public void onAnimationStart(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ if (mState == STATE_DISABLING) {
+ mController.deleteWindowMagnification();
+ setState(STATE_DISABLED);
+ } else if (mState == STATE_ENABLING) {
+ setState(STATE_ENABLED);
+ } else {
+ Log.w(TAG, "onAnimationEnd unexpected state:" + mState);
+ }
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ final float fract = animation.getAnimatedFraction();
+ final float sentScale = mStartSpec.mScale + (mEndSpec.mScale - mStartSpec.mScale) * fract;
+ final float centerX =
+ mStartSpec.mCenterX + (mEndSpec.mCenterX - mStartSpec.mCenterX) * fract;
+ final float centerY =
+ mStartSpec.mCenterY + (mEndSpec.mCenterY - mStartSpec.mCenterY) * fract;
+ mController.enableWindowMagnification(sentScale, centerX, centerY);
+ }
+
+ private static ValueAnimator newValueAnimator(Resources resources) {
+ final ValueAnimator valueAnimator = new ValueAnimator();
+ valueAnimator.setDuration(
+ resources.getInteger(com.android.internal.R.integer.config_longAnimTime));
+ valueAnimator.setInterpolator(new AccelerateInterpolator(2.5f));
+ valueAnimator.setFloatValues(0.0f, 1.0f);
+ return valueAnimator;
+ }
+
+ private static class AnimationSpec {
+ private float mScale = Float.NaN;
+ private float mCenterX = Float.NaN;
+ private float mCenterY = Float.NaN;
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (other == null || getClass() != other.getClass()) {
+ return false;
+ }
+
+ final AnimationSpec s = (AnimationSpec) other;
+ return mScale == s.mScale && mCenterX == s.mCenterX && mCenterY == s.mCenterY;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = (mScale != +0.0f ? Float.floatToIntBits(mScale) : 0);
+ result = 31 * result + (mCenterX != +0.0f ? Float.floatToIntBits(mCenterX) : 0);
+ result = 31 * result + (mCenterY != +0.0f ? Float.floatToIntBits(mCenterY) : 0);
+ return result;
+ }
+
+ void set(float scale, float centerX, float centerY) {
+ mScale = scale;
+ mCenterX = centerX;
+ mCenterY = centerY;
+ }
+
+ @Override
+ public String toString() {
+ return "AnimationSpec{"
+ + "mScale=" + mScale
+ + ", mCenterX=" + mCenterX
+ + ", mCenterY=" + mCenterY
+ + '}';
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java
index 798b751..494a0f64 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java
@@ -150,7 +150,7 @@
mMirrorViewGeometryVsyncCallback =
l -> {
- if (mMirrorView != null && mMirrorSurface != null) {
+ if (isWindowVisible() && mMirrorSurface != null) {
calculateSourceBounds(mMagnificationFrame, mScale);
// The final destination for the magnification surface should be at 0,0
// since the ViewRootImpl's position will change
@@ -203,13 +203,13 @@
* @param configDiff a bit mask of the differences between the configurations
*/
void onConfigurationChanged(int configDiff) {
+ if (!isWindowVisible()) {
+ return;
+ }
if ((configDiff & ActivityInfo.CONFIG_DENSITY) != 0) {
updateDimensions();
- // TODO(b/145780606): update toggle button UI.
- if (mMirrorView != null) {
- mWm.removeView(mMirrorView);
- createMirrorWindow();
- }
+ mWm.removeView(mMirrorView);
+ createMirrorWindow();
} else if ((configDiff & ActivityInfo.CONFIG_ORIENTATION) != 0) {
onRotate();
}
@@ -502,7 +502,7 @@
/**
* Enables window magnification with specified parameters.
*
- * @param scale the target scale
+ * @param scale the target scale, or {@link Float#NaN} to leave unchanged
* @param centerX the screen-relative X coordinate around which to center,
* or {@link Float#NaN} to leave unchanged.
* @param centerY the screen-relative Y coordinate around which to center,
@@ -513,10 +513,10 @@
: centerX - mMagnificationFrame.exactCenterX();
final float offsetY = Float.isNaN(centerY) ? 0
: centerY - mMagnificationFrame.exactCenterY();
- mScale = scale;
+ mScale = Float.isNaN(scale) ? mScale : scale;
setMagnificationFrameBoundary();
updateMagnificationFramePosition((int) offsetX, (int) offsetY);
- if (mMirrorView == null) {
+ if (!isWindowVisible()) {
createMirrorWindow();
showControls();
} else {
@@ -527,10 +527,10 @@
/**
* Sets the scale of the magnified region if it's visible.
*
- * @param scale the target scale
+ * @param scale the target scale, or {@link Float#NaN} to leave unchanged
*/
void setScale(float scale) {
- if (mMirrorView == null || mScale == scale) {
+ if (!isWindowVisible() || mScale == scale) {
return;
}
enableWindowMagnification(scale, Float.NaN, Float.NaN);
@@ -552,4 +552,35 @@
modifyWindowMagnification(mTransaction);
}
}
+
+ /**
+ * Gets the scale.
+ * @return {@link Float#NaN} if the window is invisible.
+ */
+ float getScale() {
+ return isWindowVisible() ? mScale : Float.NaN;
+ }
+
+ /**
+ * Returns the screen-relative X coordinate of the center of the magnified bounds.
+ *
+ * @return the X coordinate. {@link Float#NaN} if the window is invisible.
+ */
+ float getCenterX() {
+ return isWindowVisible() ? mMagnificationFrame.exactCenterX() : Float.NaN;
+ }
+
+ /**
+ * Returns the screen-relative Y coordinate of the center of the magnified bounds.
+ *
+ * @return the Y coordinate. {@link Float#NaN} if the window is invisible.
+ */
+ float getCenterY() {
+ return isWindowVisible() ? mMagnificationFrame.exactCenterY() : Float.NaN;
+ }
+
+ //The window is visible when it is existed.
+ private boolean isWindowVisible() {
+ return mMirrorView != null;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/appops/AppOpItem.java b/packages/SystemUI/src/com/android/systemui/appops/AppOpItem.java
index 7e5b426..93a8df4 100644
--- a/packages/SystemUI/src/com/android/systemui/appops/AppOpItem.java
+++ b/packages/SystemUI/src/com/android/systemui/appops/AppOpItem.java
@@ -25,7 +25,9 @@
private int mUid;
private String mPackageName;
private long mTimeStarted;
- private String mState;
+ private StringBuilder mState;
+ // This is only used for items with mCode == AppOpsManager.OP_RECORD_AUDIO
+ private boolean mSilenced;
public AppOpItem(int code, int uid, String packageName, long timeStarted) {
this.mCode = code;
@@ -36,9 +38,8 @@
.append("AppOpItem(")
.append("Op code=").append(code).append(", ")
.append("UID=").append(uid).append(", ")
- .append("Package name=").append(packageName)
- .append(")")
- .toString();
+ .append("Package name=").append(packageName).append(", ")
+ .append("Paused=");
}
public int getCode() {
@@ -57,8 +58,16 @@
return mTimeStarted;
}
+ public void setSilenced(boolean silenced) {
+ mSilenced = silenced;
+ }
+
+ public boolean isSilenced() {
+ return mSilenced;
+ }
+
@Override
public String toString() {
- return mState;
+ return mState.append(mSilenced).append(")").toString();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/appops/AppOpsControllerImpl.java b/packages/SystemUI/src/com/android/systemui/appops/AppOpsControllerImpl.java
index 6512624..8187a223 100644
--- a/packages/SystemUI/src/com/android/systemui/appops/AppOpsControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/appops/AppOpsControllerImpl.java
@@ -19,6 +19,8 @@
import android.app.AppOpsManager;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.media.AudioManager;
+import android.media.AudioRecordingConfiguration;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
@@ -63,6 +65,7 @@
private static final boolean DEBUG = false;
private final AppOpsManager mAppOps;
+ private final AudioManager mAudioManager;
private H mBGHandler;
private final List<AppOpsController.Callback> mCallbacks = new ArrayList<>();
private final SparseArray<Set<Callback>> mCallbacksByCode = new SparseArray<>();
@@ -73,6 +76,9 @@
private final List<AppOpItem> mActiveItems = new ArrayList<>();
@GuardedBy("mNotedItems")
private final List<AppOpItem> mNotedItems = new ArrayList<>();
+ @GuardedBy("mActiveItems")
+ private final SparseArray<ArrayList<AudioRecordingConfiguration>> mRecordingsByUid =
+ new SparseArray<>();
protected static final int[] OPS = new int[] {
AppOpsManager.OP_MONITOR_HIGH_POWER_LOCATION,
@@ -88,7 +94,8 @@
Context context,
@Background Looper bgLooper,
DumpManager dumpManager,
- PermissionFlagsCache cache
+ PermissionFlagsCache cache,
+ AudioManager audioManager
) {
mAppOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
mFlagsCache = cache;
@@ -97,6 +104,7 @@
for (int i = 0; i < numOps; i++) {
mCallbacksByCode.put(OPS[i], new ArraySet<>());
}
+ mAudioManager = audioManager;
dumpManager.registerDumpable(TAG, this);
}
@@ -111,12 +119,19 @@
if (listening) {
mAppOps.startWatchingActive(OPS, this);
mAppOps.startWatchingNoted(OPS, this);
+ mAudioManager.registerAudioRecordingCallback(mAudioRecordingCallback, mBGHandler);
+ mBGHandler.post(() -> mAudioRecordingCallback.onRecordingConfigChanged(
+ mAudioManager.getActiveRecordingConfigurations()));
+
} else {
mAppOps.stopWatchingActive(this);
mAppOps.stopWatchingNoted(this);
+ mAudioManager.unregisterAudioRecordingCallback(mAudioRecordingCallback);
+
mBGHandler.removeCallbacksAndMessages(null); // null removes all
synchronized (mActiveItems) {
mActiveItems.clear();
+ mRecordingsByUid.clear();
}
synchronized (mNotedItems) {
mNotedItems.clear();
@@ -189,9 +204,12 @@
AppOpItem item = getAppOpItemLocked(mActiveItems, code, uid, packageName);
if (item == null && active) {
item = new AppOpItem(code, uid, packageName, System.currentTimeMillis());
+ if (code == AppOpsManager.OP_RECORD_AUDIO) {
+ item.setSilenced(isAnyRecordingPausedLocked(uid));
+ }
mActiveItems.add(item);
if (DEBUG) Log.w(TAG, "Added item: " + item.toString());
- return true;
+ return !item.isSilenced();
} else if (item != null && !active) {
mActiveItems.remove(item);
if (DEBUG) Log.w(TAG, "Removed item: " + item.toString());
@@ -215,7 +233,7 @@
active = getAppOpItemLocked(mActiveItems, code, uid, packageName) != null;
}
if (!active) {
- notifySuscribers(code, uid, packageName, false);
+ notifySuscribersWorker(code, uid, packageName, false);
}
}
@@ -324,7 +342,7 @@
AppOpItem item = mActiveItems.get(i);
if ((userId == UserHandle.USER_ALL
|| UserHandle.getUserId(item.getUid()) == userId)
- && isUserVisible(item)) {
+ && isUserVisible(item) && !item.isSilenced()) {
list.add(item);
}
}
@@ -343,6 +361,10 @@
return list;
}
+ private void notifySuscribers(int code, int uid, String packageName, boolean active) {
+ mBGHandler.post(() -> notifySuscribersWorker(code, uid, packageName, active));
+ }
+
@Override
public void onOpActiveChanged(int code, int uid, String packageName, boolean active) {
if (DEBUG) {
@@ -360,7 +382,7 @@
// If active is false, we only send the update if the op is not actively noted (prevent
// early removal)
if (!alsoNoted) {
- mBGHandler.post(() -> notifySuscribers(code, uid, packageName, active));
+ notifySuscribers(code, uid, packageName, active);
}
}
@@ -378,11 +400,11 @@
alsoActive = getAppOpItemLocked(mActiveItems, code, uid, packageName) != null;
}
if (!alsoActive) {
- mBGHandler.post(() -> notifySuscribers(code, uid, packageName, true));
+ notifySuscribers(code, uid, packageName, true);
}
}
- private void notifySuscribers(int code, int uid, String packageName, boolean active) {
+ private void notifySuscribersWorker(int code, int uid, String packageName, boolean active) {
if (mCallbacksByCode.contains(code) && isUserVisible(code, uid, packageName)) {
if (DEBUG) Log.d(TAG, "Notifying of change in package " + packageName);
for (Callback cb: mCallbacksByCode.get(code)) {
@@ -408,6 +430,61 @@
}
+ private boolean isAnyRecordingPausedLocked(int uid) {
+ List<AudioRecordingConfiguration> configs = mRecordingsByUid.get(uid);
+ if (configs == null) return false;
+ int configsNum = configs.size();
+ for (int i = 0; i < configsNum; i++) {
+ AudioRecordingConfiguration config = configs.get(i);
+ if (config.isClientSilenced()) return true;
+ }
+ return false;
+ }
+
+ private void updateRecordingPausedStatus() {
+ synchronized (mActiveItems) {
+ int size = mActiveItems.size();
+ for (int i = 0; i < size; i++) {
+ AppOpItem item = mActiveItems.get(i);
+ if (item.getCode() == AppOpsManager.OP_RECORD_AUDIO) {
+ boolean paused = isAnyRecordingPausedLocked(item.getUid());
+ if (item.isSilenced() != paused) {
+ item.setSilenced(paused);
+ notifySuscribers(
+ item.getCode(),
+ item.getUid(),
+ item.getPackageName(),
+ !item.isSilenced()
+ );
+ }
+ }
+ }
+ }
+ }
+
+ private AudioManager.AudioRecordingCallback mAudioRecordingCallback =
+ new AudioManager.AudioRecordingCallback() {
+ @Override
+ public void onRecordingConfigChanged(List<AudioRecordingConfiguration> configs) {
+ synchronized (mActiveItems) {
+ mRecordingsByUid.clear();
+ final int recordingsCount = configs.size();
+ for (int i = 0; i < recordingsCount; i++) {
+ AudioRecordingConfiguration recording = configs.get(i);
+
+ ArrayList<AudioRecordingConfiguration> recordings = mRecordingsByUid.get(
+ recording.getClientUid());
+ if (recordings == null) {
+ recordings = new ArrayList<>();
+ mRecordingsByUid.put(recording.getClientUid(), recordings);
+ }
+ recordings.add(recording);
+ }
+ }
+ updateRecordingPausedStatus();
+ }
+ };
+
protected class H extends Handler {
H(Looper looper) {
super(looper);
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistantSessionEvent.kt b/packages/SystemUI/src/com/android/systemui/assist/AssistantSessionEvent.kt
index 8b953fa..be089b1 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistantSessionEvent.kt
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistantSessionEvent.kt
@@ -21,7 +21,7 @@
enum class AssistantSessionEvent(private val id: Int) : UiEventLogger.UiEventEnum {
@UiEvent(doc = "Unknown assistant session event")
- ASSISTANT_SESSION_UNKNOWN(523),
+ ASSISTANT_SESSION_UNKNOWN(0),
@UiEvent(doc = "Assistant session dismissed due to timeout")
ASSISTANT_SESSION_TIMEOUT_DISMISS(524),
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPasswordView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPasswordView.java
index 95bbea1..d4e6506b 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPasswordView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPasswordView.java
@@ -16,6 +16,7 @@
package com.android.systemui.biometrics;
+import android.annotation.NonNull;
import android.content.Context;
import android.os.UserHandle;
import android.text.InputType;
@@ -27,7 +28,9 @@
import android.widget.TextView;
import com.android.internal.widget.LockPatternChecker;
+import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockscreenCredential;
+import com.android.internal.widget.VerifyCredentialResponse;
import com.android.systemui.R;
/**
@@ -104,18 +107,21 @@
return;
}
+ // Request LockSettingsService to return the Gatekeeper Password in the
+ // VerifyCredentialResponse so that we can request a Gatekeeper HAT with the
+ // Gatekeeper Password and operationId.
mPendingLockCheck = LockPatternChecker.verifyCredential(mLockPatternUtils,
- password, mOperationId, mEffectiveUserId, this::onCredentialVerified);
+ password, mEffectiveUserId, LockPatternUtils.VERIFY_FLAG_RETURN_GK_PW,
+ this::onCredentialVerified);
}
}
@Override
- protected void onCredentialVerified(byte[] attestation, int timeoutMs) {
- super.onCredentialVerified(attestation, timeoutMs);
+ protected void onCredentialVerified(@NonNull VerifyCredentialResponse response,
+ int timeoutMs) {
+ super.onCredentialVerified(response, timeoutMs);
- final boolean matched = attestation != null;
-
- if (matched) {
+ if (response.isMatched()) {
mImm.hideSoftInputFromWindow(getWindowToken(), 0 /* flags */);
} else {
mPasswordField.setText("");
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPatternView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPatternView.java
index 6d16f43..ad89ae8 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPatternView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPatternView.java
@@ -16,6 +16,7 @@
package com.android.systemui.biometrics;
+import android.annotation.NonNull;
import android.content.Context;
import android.util.AttributeSet;
@@ -23,6 +24,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView;
import com.android.internal.widget.LockscreenCredential;
+import com.android.internal.widget.VerifyCredentialResponse;
import com.android.systemui.R;
import java.util.List;
@@ -61,22 +63,25 @@
if (pattern.size() < LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
// Pattern size is less than the minimum, do not count it as a failed attempt.
- onPatternVerified(null /* attestation */, 0 /* timeoutMs */);
+ onPatternVerified(VerifyCredentialResponse.ERROR, 0 /* timeoutMs */);
return;
}
try (LockscreenCredential credential = LockscreenCredential.createPattern(pattern)) {
+ // Request LockSettingsService to return the Gatekeeper Password in the
+ // VerifyCredentialResponse so that we can request a Gatekeeper HAT with the
+ // Gatekeeper Password and operationId.
mPendingLockCheck = LockPatternChecker.verifyCredential(
mLockPatternUtils,
credential,
- mOperationId,
mEffectiveUserId,
+ LockPatternUtils.VERIFY_FLAG_RETURN_GK_PW,
this::onPatternVerified);
}
}
- private void onPatternVerified(byte[] attestation, int timeoutMs) {
- AuthCredentialPatternView.this.onCredentialVerified(attestation, timeoutMs);
+ private void onPatternVerified(@NonNull VerifyCredentialResponse response, int timeoutMs) {
+ AuthCredentialPatternView.this.onCredentialVerified(response, timeoutMs);
if (timeoutMs > 0) {
mLockPatternView.setEnabled(false);
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java
index 2695c69..a8f6f85 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java
@@ -16,6 +16,9 @@
package com.android.systemui.biometrics;
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -38,12 +41,10 @@
import android.widget.LinearLayout;
import android.widget.TextView;
-import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.VerifyCredentialResponse;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
@@ -283,14 +284,18 @@
protected void onErrorTimeoutFinish() {}
- protected void onCredentialVerified(byte[] attestation, int timeoutMs) {
-
- final boolean matched = attestation != null;
-
- if (matched) {
+ protected void onCredentialVerified(@NonNull VerifyCredentialResponse response, int timeoutMs) {
+ if (response.isMatched()) {
mClearErrorRunnable.run();
mLockPatternUtils.userPresent(mEffectiveUserId);
- mCallback.onCredentialMatched(attestation);
+
+ // The response passed into this method contains the Gatekeeper Password. We still
+ // have to request Gatekeeper to create a Hardware Auth Token with the
+ // Gatekeeper Password and Challenge (keystore operationId in this case)
+ final VerifyCredentialResponse gkResponse = mLockPatternUtils.verifyGatekeeperPassword(
+ response.getGatekeeperPw(), mOperationId, mEffectiveUserId);
+
+ mCallback.onCredentialMatched(gkResponse.getGatekeeperHAT());
} else {
if (timeoutMs > 0) {
mHandler.removeCallbacks(mClearErrorRunnable);
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
index fce545b..f774358 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
@@ -38,6 +38,7 @@
import com.android.systemui.statusbar.notification.people.PeopleHubModule;
import com.android.systemui.statusbar.notification.row.dagger.ExpandableNotificationRowComponent;
import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent;
+import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent;
import com.android.systemui.statusbar.phone.KeyguardLiftController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
@@ -72,7 +73,8 @@
subcomponents = {StatusBarComponent.class,
NotificationRowComponent.class,
DozeComponent.class,
- ExpandableNotificationRowComponent.class})
+ ExpandableNotificationRowComponent.class,
+ NotificationShelfComponent.class})
public abstract class SystemUIModule {
@Binds
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt
index 8a51c85..e77e499 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt
@@ -44,6 +44,7 @@
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dump.DumpManager
+import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.statusbar.notification.MediaNotificationProcessor
import com.android.systemui.statusbar.notification.row.HybridGroupManager
import com.android.systemui.util.Assert
@@ -97,6 +98,7 @@
dumpManager: DumpManager,
mediaTimeoutListener: MediaTimeoutListener,
mediaResumeListener: MediaResumeListener,
+ private val activityStarter: ActivityStarter,
private var useMediaResumption: Boolean,
private val useQsMediaPlayer: Boolean
) : Dumpable {
@@ -113,10 +115,11 @@
dumpManager: DumpManager,
broadcastDispatcher: BroadcastDispatcher,
mediaTimeoutListener: MediaTimeoutListener,
- mediaResumeListener: MediaResumeListener
+ mediaResumeListener: MediaResumeListener,
+ activityStarter: ActivityStarter
) : this(context, backgroundExecutor, foregroundExecutor, mediaControllerFactory,
broadcastDispatcher, dumpManager, mediaTimeoutListener, mediaResumeListener,
- Utils.useMediaResumption(context), Utils.useQsMediaPlayer(context))
+ activityStarter, Utils.useMediaResumption(context), Utils.useQsMediaPlayer(context))
private val appChangeReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
@@ -403,10 +406,13 @@
}
val runnable = if (action.actionIntent != null) {
Runnable {
- try {
- action.actionIntent.send()
- } catch (e: PendingIntent.CanceledException) {
- Log.d(TAG, "Intent canceled", e)
+ if (action.isAuthenticationRequired()) {
+ activityStarter.dismissKeyguardThenExecute ({
+ var result = sendPendingIntent(action.actionIntent)
+ result
+ }, {}, true)
+ } else {
+ sendPendingIntent(action.actionIntent)
}
}
} else {
@@ -449,6 +455,15 @@
return null
}
+ private fun sendPendingIntent(intent: PendingIntent): Boolean {
+ return try {
+ intent.send()
+ true
+ } catch (e: PendingIntent.CanceledException) {
+ Log.d(TAG, "Intent canceled", e)
+ false
+ }
+ }
/**
* Load a bitmap from a URI
* @param uri the uri to load
diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedGestureHandler.java b/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedGestureHandler.java
index ded3861..563684a 100644
--- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedGestureHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedGestureHandler.java
@@ -159,7 +159,7 @@
} else {
float distance = (float) Math.hypot(mLastPos.x - mDownPos.x,
mLastPos.y - mDownPos.y);
- if (distance > mDragDistThreshold && mPassedSlop) {
+ if (distance > mDragDistThreshold) {
mGestureEventCallback.onStop();
}
}
@@ -273,13 +273,13 @@
*/
public interface OneHandedGestureEventCallback {
/**
- * Handle the start event event, and return whether the event was consumed.
+ * Handles the start gesture.
*/
- boolean onStart();
+ void onStart();
/**
- * Handle the exit event event, and return whether the event was consumed.
+ * Handles the exit gesture.
*/
- boolean onStop();
+ void onStop();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedManagerImpl.java b/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedManagerImpl.java
index 51e5875..a3921ee 100644
--- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedManagerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedManagerImpl.java
@@ -24,6 +24,7 @@
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
+import android.view.KeyEvent;
import androidx.annotation.NonNull;
@@ -33,6 +34,7 @@
import com.android.systemui.model.SysUiState;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.TaskStackChangeListener;
+import com.android.systemui.statusbar.CommandQueue;
import com.android.wm.shell.common.DisplayChangeController;
import com.android.wm.shell.common.DisplayController;
@@ -50,9 +52,11 @@
private static final String TAG = "OneHandedManager";
private boolean mIsOneHandedEnabled;
+ private boolean mIsSwipeToNotificationEnabled;
private boolean mTaskChangeToExit;
private float mOffSetFraction;
+ private final CommandQueue mCommandQueue;
private final DisplayController mDisplayController;
private final OneHandedGestureHandler mGestureHandler;
private final OneHandedTimeoutHandler mTimeoutHandler;
@@ -60,11 +64,7 @@
private final OneHandedTutorialHandler mTutorialHandler;
private final SysUiState mSysUiFlagContainer;
- private Context mContext;
private OneHandedDisplayAreaOrganizer mDisplayAreaOrganizer;
- private OneHandedGestureHandler.OneHandedGestureEventCallback mGestureEventCallback;
- private OneHandedTouchHandler.OneHandedTouchEventCallback mTouchEventCallback;
- private OneHandedTransitionCallback mTransitionCallback;
/**
* Handler for system task stack changes, exit when user lunch new task or bring task to front
@@ -105,13 +105,14 @@
*/
@Inject
public OneHandedManagerImpl(Context context,
+ CommandQueue commandQueue,
DisplayController displayController,
OneHandedDisplayAreaOrganizer displayAreaOrganizer,
OneHandedTouchHandler touchHandler,
OneHandedTutorialHandler tutorialHandler,
OneHandedGestureHandler gestureHandler,
SysUiState sysUiState) {
- mContext = context;
+ mCommandQueue = commandQueue;
mDisplayAreaOrganizer = displayAreaOrganizer;
mDisplayController = displayController;
mDisplayController.addDisplayChangingController(mRotationController);
@@ -120,6 +121,8 @@
context.getResources().getFraction(R.fraction.config_one_handed_offset, 1, 1);
mIsOneHandedEnabled = OneHandedSettingsUtil.getSettingsOneHandedModeEnabled(
context.getContentResolver());
+ mIsSwipeToNotificationEnabled = OneHandedSettingsUtil.getSettingsSwipeToNotificationEnabled(
+ context.getContentResolver());
mTimeoutHandler = OneHandedTimeoutHandler.get();
mTouchHandler = touchHandler;
mTutorialHandler = tutorialHandler;
@@ -148,11 +151,19 @@
}
/**
- * Start one handed mode
+ * Sets whether to enable swipe bottom to notification gesture when user update settings.
+ */
+ public void setSwipeToNotificationEnabled(boolean enabled) {
+ mIsSwipeToNotificationEnabled = enabled;
+ updateOneHandedEnabled();
+ }
+
+ /**
+ * Enters one handed mode.
*/
@Override
public void startOneHanded() {
- if (!mDisplayAreaOrganizer.isInOneHanded() && mIsOneHandedEnabled) {
+ if (!mDisplayAreaOrganizer.isInOneHanded()) {
final int yOffSet = Math.round(getDisplaySize().y * mOffSetFraction);
mDisplayAreaOrganizer.scheduleOffset(0, yOffSet);
mTimeoutHandler.resetTimer();
@@ -160,7 +171,7 @@
}
/**
- * Stop one handed mode
+ * Exits one handed mode.
*/
@Override
public void stopOneHanded() {
@@ -171,53 +182,45 @@
}
private void setupGestures() {
- mTouchEventCallback = new OneHandedTouchHandler.OneHandedTouchEventCallback() {
- @Override
- public boolean onStart() {
- boolean result = false;
- if (!mDisplayAreaOrganizer.isInOneHanded()) {
- startOneHanded();
- result = true;
- }
- return result;
- }
+ mTouchHandler.registerTouchEventListener(
+ new OneHandedTouchHandler.OneHandedTouchEventCallback() {
+ @Override
+ public void onStart() {
+ if (mIsOneHandedEnabled) {
+ startOneHanded();
+ }
+ }
- @Override
- public boolean onStop() {
- boolean result = false;
- if (mDisplayAreaOrganizer.isInOneHanded()) {
- stopOneHanded();
- result = true;
- }
- return result;
- }
- };
- mTouchHandler.registerTouchEventListener(mTouchEventCallback);
+ @Override
+ public void onStop() {
+ if (mIsOneHandedEnabled) {
+ stopOneHanded();
+ }
+ }
+ });
- mGestureEventCallback = new OneHandedGestureHandler.OneHandedGestureEventCallback() {
- @Override
- public boolean onStart() {
- boolean result = false;
- if (!mDisplayAreaOrganizer.isInOneHanded()) {
- startOneHanded();
- result = true;
- }
- return result;
- }
+ mGestureHandler.setGestureEventListener(
+ new OneHandedGestureHandler.OneHandedGestureEventCallback() {
+ @Override
+ public void onStart() {
+ if (mIsOneHandedEnabled) {
+ startOneHanded();
+ } else if (mIsSwipeToNotificationEnabled) {
+ mCommandQueue.handleSystemKey(KeyEvent.KEYCODE_SYSTEM_NAVIGATION_DOWN);
+ }
+ }
- @Override
- public boolean onStop() {
- boolean result = false;
- if (mDisplayAreaOrganizer.isInOneHanded()) {
- stopOneHanded();
- result = true;
- }
- return result;
- }
- };
- mGestureHandler.setGestureEventListener(mGestureEventCallback);
+ @Override
+ public void onStop() {
+ if (mIsOneHandedEnabled) {
+ stopOneHanded();
+ } else if (mIsSwipeToNotificationEnabled) {
+ mCommandQueue.handleSystemKey(KeyEvent.KEYCODE_SYSTEM_NAVIGATION_UP);
+ }
+ }
+ });
- mTransitionCallback = new OneHandedTransitionCallback() {
+ mDisplayAreaOrganizer.registerTransitionCallback(new OneHandedTransitionCallback() {
@Override
public void onStartFinished(Rect bounds) {
mSysUiFlagContainer.setFlag(SYSUI_STATE_ONE_HANDED_ACTIVE,
@@ -229,8 +232,8 @@
mSysUiFlagContainer.setFlag(SYSUI_STATE_ONE_HANDED_ACTIVE,
false).commitUpdate(DEFAULT_DISPLAY);
}
- };
- mDisplayAreaOrganizer.registerTransitionCallback(mTransitionCallback);
+ });
+
mDisplayAreaOrganizer.registerTransitionCallback(mTouchHandler);
mDisplayAreaOrganizer.registerTransitionCallback(mGestureHandler);
mDisplayAreaOrganizer.registerTransitionCallback(mTutorialHandler);
@@ -264,7 +267,7 @@
ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener);
}
mTouchHandler.onOneHandedEnabled(mIsOneHandedEnabled);
- mGestureHandler.onOneHandedEnabled(mIsOneHandedEnabled);
+ mGestureHandler.onOneHandedEnabled(mIsOneHandedEnabled || mIsSwipeToNotificationEnabled);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedSettingsUtil.java b/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedSettingsUtil.java
index 9b232cd..1b6ec04 100644
--- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedSettingsUtil.java
+++ b/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedSettingsUtil.java
@@ -132,6 +132,14 @@
Settings.Secure.ONE_HANDED_MODE_TIMEOUT, ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS);
}
+ /**
+ * Returns whether swipe bottom to notification gesture enabled or not.
+ */
+ public static boolean getSettingsSwipeToNotificationEnabled(ContentResolver resolver) {
+ return Settings.Secure.getInt(resolver,
+ Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 0) == 1;
+ }
+
protected static void dump(PrintWriter pw, String prefix, ContentResolver resolver) {
final String innerPrefix = prefix + " ";
pw.println(prefix + TAG);
diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedTouchHandler.java b/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedTouchHandler.java
index d616a3a..1446e5a 100644
--- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedTouchHandler.java
@@ -175,13 +175,13 @@
*/
public interface OneHandedTouchEventCallback {
/**
- * Handle the start event event, and return whether the event was consumed.
+ * Handle the start event.
*/
- boolean onStart();
+ void onStart();
/**
- * Handle the exit event event, and return whether the event was consumed.
+ * Handle the exit event.
*/
- boolean onStop();
+ void onStop();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedUI.java b/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedUI.java
index 9239435..0903c0e 100644
--- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedUI.java
+++ b/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedUI.java
@@ -40,7 +40,6 @@
import com.android.systemui.Dependency;
import com.android.systemui.Dumpable;
import com.android.systemui.SystemUI;
-import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.statusbar.CommandQueue;
@@ -80,7 +79,10 @@
mOneHandedManager.setOneHandedEnabled(enabled);
}
- setEnabledGesturalOverlay(enabled);
+ // Also checks swipe to notification settings since they all need gesture overlay.
+ setEnabledGesturalOverlay(
+ enabled || OneHandedSettingsUtil.getSettingsSwipeToNotificationEnabled(
+ mContext.getContentResolver()));
}
};
@@ -130,11 +132,28 @@
}
};
+ private final ContentObserver mSwipeToNotificationEnabledObserver =
+ new ContentObserver(mMainHandler) {
+ @Override
+ public void onChange(boolean selfChange) {
+ final boolean enabled =
+ OneHandedSettingsUtil.getSettingsSwipeToNotificationEnabled(
+ mContext.getContentResolver());
+ if (mOneHandedManager != null) {
+ mOneHandedManager.setSwipeToNotificationEnabled(enabled);
+ }
+
+ // Also checks one handed mode settings since they all need gesture overlay.
+ setEnabledGesturalOverlay(
+ enabled || OneHandedSettingsUtil.getSettingsOneHandedModeEnabled(
+ mContext.getContentResolver()));
+ }
+ };
+
@Inject
public OneHandedUI(Context context,
CommandQueue commandQueue,
OneHandedManagerImpl oneHandedManager,
- DumpManager dumpManager,
OneHandedSettingsUtil settingsUtil,
ScreenLifecycle screenLifecycle) {
super(context);
@@ -239,6 +258,9 @@
mContext.getContentResolver(), mTimeoutObserver);
mSettingUtil.registerSettingsKeyObserver(Settings.Secure.TAPS_APP_TO_EXIT,
mContext.getContentResolver(), mTaskChangeExitObserver);
+ mSettingUtil.registerSettingsKeyObserver(
+ Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED,
+ mContext.getContentResolver(), mSwipeToNotificationEnabledObserver);
}
private void updateSettings() {
@@ -248,6 +270,8 @@
mSettingUtil.getSettingsOneHandedModeTimeout(mContext.getContentResolver()));
mOneHandedManager.setTaskChangeToExit(
mSettingUtil.getSettingsTapsAppToExit(mContext.getContentResolver()));
+ mOneHandedManager.setSwipeToNotificationEnabled(
+ mSettingUtil.getSettingsSwipeToNotificationEnabled(mContext.getContentResolver()));
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
index 0167028..f1c8b0c 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
@@ -186,20 +186,23 @@
private class PipManagerPinnedStackListener extends PinnedStackListener {
@Override
public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {
- if (mState == STATE_PIP) {
- if (mImeVisible != imeVisible) {
- if (imeVisible) {
- // Save the IME height adjustment, and offset to not occlude the IME
- mPipBounds.offset(0, -imeHeight);
- mImeHeightAdjustment = imeHeight;
- } else {
- // Apply the inverse adjustment when the IME is hidden
- mPipBounds.offset(0, mImeHeightAdjustment);
+ mHandler.post(() -> {
+ mPipBoundsHandler.onImeVisibilityChanged(imeVisible, imeHeight);
+ if (mState == STATE_PIP) {
+ if (mImeVisible != imeVisible) {
+ if (imeVisible) {
+ // Save the IME height adjustment, and offset to not occlude the IME
+ mPipBounds.offset(0, -imeHeight);
+ mImeHeightAdjustment = imeHeight;
+ } else {
+ // Apply the inverse adjustment when the IME is hidden
+ mPipBounds.offset(0, mImeHeightAdjustment);
+ }
+ mImeVisible = imeVisible;
+ resizePinnedStack(STATE_PIP);
}
- mImeVisible = imeVisible;
- resizePinnedStack(STATE_PIP);
}
- }
+ });
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PageIndicator.java b/packages/SystemUI/src/com/android/systemui/qs/PageIndicator.java
index f8655cc..52a2cec 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/PageIndicator.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/PageIndicator.java
@@ -3,7 +3,9 @@
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
+import android.graphics.drawable.Animatable2;
import android.graphics.drawable.AnimatedVectorDrawable;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
@@ -44,6 +46,24 @@
private int mPosition = -1;
private boolean mAnimating;
+ private final Animatable2.AnimationCallback mAnimationCallback =
+ new Animatable2.AnimationCallback() {
+
+ @Override
+ public void onAnimationEnd(Drawable drawable) {
+ super.onAnimationEnd(drawable);
+ if (DEBUG) Log.d(TAG, "onAnimationEnd - queued: " + mQueuedPositions.size());
+ if (drawable instanceof AnimatedVectorDrawable) {
+ ((AnimatedVectorDrawable) drawable).unregisterAnimationCallback(
+ mAnimationCallback);
+ }
+ mAnimating = false;
+ if (mQueuedPositions.size() != 0) {
+ setPosition(mQueuedPositions.remove(0));
+ }
+ }
+ };
+
public PageIndicator(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -197,10 +217,8 @@
final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getContext().getDrawable(res);
imageView.setImageDrawable(avd);
avd.forceAnimationOnUI();
+ avd.registerAnimationCallback(mAnimationCallback);
avd.start();
- // TODO: Figure out how to user an AVD animation callback instead, which doesn't
- // seem to be working right now...
- postDelayed(mAnimationDone, ANIMATION_DURATION);
}
private int getTransition(boolean fromB, boolean isMajorAState, boolean isMajor) {
@@ -264,15 +282,4 @@
getChildAt(i).layout(left, 0, mPageIndicatorWidth + left, mPageIndicatorHeight);
}
}
-
- private final Runnable mAnimationDone = new Runnable() {
- @Override
- public void run() {
- if (DEBUG) Log.d(TAG, "onAnimationEnd - queued: " + mQueuedPositions.size());
- mAnimating = false;
- if (mQueuedPositions.size() != 0) {
- setPosition(mQueuedPositions.remove(0));
- }
- }
- };
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java
index d2aaaede..255513a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java
@@ -14,6 +14,7 @@
package com.android.systemui.qs.tileimpl;
+import static androidx.lifecycle.Lifecycle.State.CREATED;
import static androidx.lifecycle.Lifecycle.State.DESTROYED;
import static androidx.lifecycle.Lifecycle.State.RESUMED;
import static androidx.lifecycle.Lifecycle.State.STARTED;
@@ -173,6 +174,7 @@
mState = newTileState();
mTmpState = newTileState();
+ mUiHandler.post(() -> mLifecycle.setCurrentState(CREATED));
}
protected final void resetStates() {
@@ -453,6 +455,9 @@
if (DEBUG) Log.d(TAG, "handleSetListening true");
handleSetListening(listening);
mUiHandler.post(() -> {
+ // This tile has been destroyed, the state should not change anymore and we
+ // should not refresh it anymore.
+ if (mLifecycle.getCurrentState().equals(DESTROYED)) return;
mLifecycle.setCurrentState(RESUMED);
refreshState(); // Ensure we get at least one refresh after listening.
});
@@ -461,7 +466,11 @@
if (mListeners.remove(listener) && mListeners.size() == 0) {
if (DEBUG) Log.d(TAG, "handleSetListening false");
handleSetListening(listening);
- mUiHandler.post(() -> mLifecycle.setCurrentState(STARTED));
+ mUiHandler.post(() -> {
+ // This tile has been destroyed, the state should not change anymore.
+ if (mLifecycle.getCurrentState().equals(DESTROYED)) return;
+ mLifecycle.setCurrentState(STARTED);
+ });
}
}
updateIsFullQs();
@@ -488,11 +497,14 @@
mQSLogger.logTileDestroyed(mTileSpec, "Handle destroy");
if (mListeners.size() != 0) {
handleSetListening(false);
+ mListeners.clear();
}
mCallbacks.clear();
mHandler.removeCallbacksAndMessages(null);
// This will force it to be removed from all controllers that may have it registered.
- mLifecycle.setCurrentState(DESTROYED);
+ mUiHandler.post(() -> {
+ mLifecycle.setCurrentState(DESTROYED);
+ });
}
protected void checkIfRestrictionEnforcedByAdminOnly(State state, String userRestriction) {
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index c535230..6747281 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -50,6 +50,7 @@
import android.media.MediaActionSound;
import android.net.Uri;
import android.os.Handler;
+import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
@@ -556,11 +557,18 @@
private void takeScreenshotInternal(Consumer<Uri> finisher, Rect crop) {
// copy the input Rect, since SurfaceControl.screenshot can mutate it
Rect screenRect = new Rect(crop);
- int rot = mDisplay.getRotation();
int width = crop.width();
int height = crop.height();
- saveScreenshot(SurfaceControl.screenshot(crop, width, height, rot), finisher, screenRect,
- Insets.NONE, true);
+ final IBinder displayToken = SurfaceControl.getInternalDisplayToken();
+ final SurfaceControl.DisplayCaptureArgs captureArgs =
+ new SurfaceControl.DisplayCaptureArgs.Builder(displayToken)
+ .setSourceCrop(crop)
+ .setSize(width, height)
+ .build();
+ final SurfaceControl.ScreenshotHardwareBuffer screenshotBuffer =
+ SurfaceControl.captureDisplay(captureArgs);
+ final Bitmap screenshot = screenshotBuffer == null ? null : screenshotBuffer.asBitmap();
+ saveScreenshot(screenshot, finisher, screenRect, Insets.NONE, true);
}
private void saveScreenshot(Bitmap screenshot, Consumer<Uri> finisher, Rect screenRect,
diff --git a/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java b/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
index 71e7883..1bea72a 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
+++ b/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
@@ -385,7 +385,7 @@
if (stopTracking) {
// TODO(brightnessfloat): change to use float value instead.
MetricsLogger.action(mContext, metric,
- BrightnessSynchronizer.brightnessFloatToInt(mContext, valFloat));
+ BrightnessSynchronizer.brightnessFloatToInt(valFloat));
}
setBrightness(valFloat);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java
index 6b023c0..9586795 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java
@@ -161,7 +161,9 @@
ActivityManager.getService().resumeAppSwitches();
} catch (RemoteException e) {
}
- return mCallback.handleRemoteViewClick(view, pendingIntent, () -> {
+ Notification.Action action = getActionFromView(view, entry, pendingIntent);
+ return mCallback.handleRemoteViewClick(view, pendingIntent,
+ action == null ? false : action.isAuthenticationRequired(), () -> {
Pair<Intent, ActivityOptions> options = response.getLaunchOptions(view);
options.second.setLaunchWindowingMode(
WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY);
@@ -170,23 +172,45 @@
});
}
+ private @Nullable Notification.Action getActionFromView(View view,
+ NotificationEntry entry, PendingIntent actionIntent) {
+ Integer actionIndex = (Integer)
+ view.getTag(com.android.internal.R.id.notification_action_index_tag);
+ if (actionIndex == null) {
+ return null;
+ }
+ if (entry == null) {
+ Log.w(TAG, "Couldn't determine notification for click.");
+ return null;
+ }
+
+ // Notification may be updated before this function is executed, and thus play safe
+ // here and verify that the action object is still the one that where the click happens.
+ StatusBarNotification statusBarNotification = entry.getSbn();
+ Notification.Action[] actions = statusBarNotification.getNotification().actions;
+ if (actions == null || actionIndex >= actions.length) {
+ Log.w(TAG, "statusBarNotification.getNotification().actions is null or invalid");
+ return null ;
+ }
+ final Notification.Action action =
+ statusBarNotification.getNotification().actions[actionIndex];
+ if (!Objects.equals(action.actionIntent, actionIntent)) {
+ Log.w(TAG, "actionIntent does not match");
+ return null;
+ }
+ return action;
+ }
+
private void logActionClick(
View view,
NotificationEntry entry,
PendingIntent actionIntent) {
- Integer actionIndex = (Integer)
- view.getTag(com.android.internal.R.id.notification_action_index_tag);
- if (actionIndex == null) {
- // Custom action button, not logging.
+ Notification.Action action = getActionFromView(view, entry, actionIntent);
+ if (action == null) {
return;
}
ViewParent parent = view.getParent();
- if (entry == null) {
- Log.w(TAG, "Couldn't determine notification for click.");
- return;
- }
- StatusBarNotification statusBarNotification = entry.getSbn();
- String key = statusBarNotification.getKey();
+ String key = entry.getSbn().getKey();
int buttonIndex = -1;
// If this is a default template, determine the index of the button.
if (view.getId() == com.android.internal.R.id.action0 &&
@@ -198,19 +222,6 @@
final int rank = mEntryManager
.getActiveNotificationUnfiltered(key).getRanking().getRank();
- // Notification may be updated before this function is executed, and thus play safe
- // here and verify that the action object is still the one that where the click happens.
- Notification.Action[] actions = statusBarNotification.getNotification().actions;
- if (actions == null || actionIndex >= actions.length) {
- Log.w(TAG, "statusBarNotification.getNotification().actions is null or invalid");
- return;
- }
- final Notification.Action action =
- statusBarNotification.getNotification().actions[actionIndex];
- if (!Objects.equals(action.actionIntent, actionIntent)) {
- Log.w(TAG, "actionIntent does not match");
- return;
- }
NotificationVisibility.NotificationLocation location =
NotificationLogger.getNotificationLocation(
mEntryManager.getActiveNotificationUnfiltered(key));
@@ -813,11 +824,12 @@
*
* @param view
* @param pendingIntent
+ * @param appRequestedAuth
* @param defaultHandler
* @return true iff the click was handled
*/
boolean handleRemoteViewClick(View view, PendingIntent pendingIntent,
- ClickHandler defaultHandler);
+ boolean appRequestedAuth, ClickHandler defaultHandler);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
index d798692..8f3033e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
@@ -18,7 +18,6 @@
import static com.android.systemui.Interpolators.FAST_OUT_SLOW_IN_REVERSE;
import static com.android.systemui.statusbar.phone.NotificationIconContainer.IconState.NO_VALUE;
-import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT;
import android.content.Context;
import android.content.res.Configuration;
@@ -26,7 +25,6 @@
import android.graphics.Rect;
import android.os.SystemProperties;
import android.util.AttributeSet;
-import android.util.Log;
import android.util.MathUtils;
import android.view.DisplayCutout;
import android.view.View;
@@ -36,10 +34,8 @@
import android.view.accessibility.AccessibilityNodeInfo;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
-import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
@@ -48,14 +44,10 @@
import com.android.systemui.statusbar.notification.stack.AmbientState;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
-import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
+import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.notification.stack.ViewState;
-import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.NotificationIconContainer;
-import javax.inject.Inject;
-import javax.inject.Named;
-
/**
* A notification shelf view that is placed inside the notification scroller. It manages the
* overflow icons that don't fit into the regular list anymore.
@@ -69,7 +61,6 @@
= SystemProperties.getBoolean("debug.icon_scroll_animations", true);
private static final int TAG_CONTINUOUS_CLIPPING = R.id.continuous_clipping_tag;
private static final String TAG = "NotificationShelf";
- private final KeyguardBypassController mBypassController;
private NotificationIconContainer mShelfIcons;
private int[] mTmp = new int[2];
@@ -77,9 +68,8 @@
private int mIconAppearTopPadding;
private float mHiddenShelfIconSize;
private int mStatusBarHeight;
- private int mStatusBarPaddingStart;
private AmbientState mAmbientState;
- private NotificationStackScrollLayout mHostLayout;
+ private NotificationStackScrollLayoutController mHostLayoutController;
private int mMaxLayoutHeight;
private int mPaddingBetweenElements;
private int mNotGoneIndex;
@@ -88,7 +78,6 @@
private int mScrollFastThreshold;
private int mIconSize;
private int mStatusBarState;
- private float mMaxShelfEnd;
private int mRelativeOffset;
private boolean mInteractive;
private float mOpenedAmount;
@@ -99,13 +88,10 @@
private Rect mClipRect = new Rect();
private int mCutoutHeight;
private int mGapHeight;
+ private NotificationShelfController mController;
- @Inject
- public NotificationShelf(@Named(VIEW_CONTEXT) Context context,
- AttributeSet attrs,
- KeyguardBypassController keyguardBypassController) {
+ public NotificationShelf(Context context, AttributeSet attrs) {
super(context, attrs);
- mBypassController = keyguardBypassController;
}
@Override
@@ -128,29 +114,16 @@
initDimens();
}
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- ((SysuiStatusBarStateController) Dependency.get(StatusBarStateController.class))
- .addCallback(this, SysuiStatusBarStateController.RANK_SHELF);
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- Dependency.get(StatusBarStateController.class).removeCallback(this);
- }
-
- public void bind(AmbientState ambientState, NotificationStackScrollLayout hostLayout) {
+ public void bind(AmbientState ambientState,
+ NotificationStackScrollLayoutController hostLayoutController) {
mAmbientState = ambientState;
- mHostLayout = hostLayout;
+ mHostLayoutController = hostLayoutController;
}
private void initDimens() {
Resources res = getResources();
mIconAppearTopPadding = res.getDimensionPixelSize(R.dimen.notification_icon_appear_padding);
mStatusBarHeight = res.getDimensionPixelOffset(R.dimen.status_bar_height);
- mStatusBarPaddingStart = res.getDimensionPixelOffset(R.dimen.status_bar_padding_start);
mPaddingBetweenElements = res.getDimensionPixelSize(R.dimen.notification_divider_height);
ViewGroup.LayoutParams layoutParams = getLayoutParams();
@@ -276,8 +249,8 @@
float firstElementRoundness = 0.0f;
ActivatableNotificationView previousAnv = null;
- for (int i = 0; i < mHostLayout.getChildCount(); i++) {
- ExpandableView child = (ExpandableView) mHostLayout.getChildAt(i);
+ for (int i = 0; i < mHostLayoutController.getChildCount(); i++) {
+ ExpandableView child = (ExpandableView) mHostLayoutController.getChildAt(i);
if (!child.needsClippingToShelf() || child.getVisibility() == GONE) {
continue;
@@ -315,9 +288,7 @@
transitionAmount = inShelfAmount;
}
// We don't want to modify the color if the notification is hun'd
- boolean canModifyColor = mAmbientState.isShadeExpanded()
- && !(mAmbientState.isOnKeyguard() && mBypassController.getBypassEnabled());
- if (isLastChild && canModifyColor) {
+ if (isLastChild && mController.canModifyColorOfNotifications()) {
if (colorOfViewBeforeLast == NO_COLOR) {
colorOfViewBeforeLast = ownColorUntinted;
}
@@ -384,8 +355,8 @@
mShelfIcons.setSpeedBumpIndex(mAmbientState.getSpeedBumpIndex());
mShelfIcons.calculateIconTranslations();
mShelfIcons.applyIconStates();
- for (int i = 0; i < mHostLayout.getChildCount(); i++) {
- View child = mHostLayout.getChildAt(i);
+ for (int i = 0; i < mHostLayoutController.getChildCount(); i++) {
+ View child = mHostLayoutController.getChildAt(i);
if (!(child instanceof ExpandableNotificationRow)
|| child.getVisibility() == GONE) {
continue;
@@ -408,8 +379,8 @@
* swipes quickly.
*/
private void clipTransientViews() {
- for (int i = 0; i < mHostLayout.getTransientViewCount(); i++) {
- View transientView = mHostLayout.getTransientView(i);
+ for (int i = 0; i < mHostLayoutController.getTransientViewCount(); i++) {
+ View transientView = mHostLayoutController.getTransientView(i);
if (transientView instanceof ExpandableView) {
ExpandableView transientExpandableView = (ExpandableView) transientView;
updateNotificationClipHeight(transientExpandableView, getTranslationY(), -1);
@@ -648,7 +619,7 @@
// We need to persist this, since after the expansion, the behavior should still be the
// same.
float position = mAmbientState.getIntrinsicPadding()
- + mHostLayout.getPositionInLinearLayout(view);
+ + mHostLayoutController.getPositionInLinearLayout(view);
int maxShelfStart = mMaxLayoutHeight - getIntrinsicHeight();
if (position < maxShelfStart && position + view.getIntrinsicHeight() >= maxShelfStart
&& view.getTranslationY() < position) {
@@ -999,10 +970,6 @@
return mInteractive;
}
- public void setMaxShelfEnd(float maxShelfEnd) {
- mMaxShelfEnd = maxShelfEnd;
- }
-
public void setAnimationsEnabled(boolean enabled) {
mAnimationsEnabled = enabled;
if (!enabled) {
@@ -1044,6 +1011,10 @@
updateBackgroundColors();
}
+ public void setController(NotificationShelfController notificationShelfController) {
+ mController = notificationShelfController;
+ }
+
private class ShelfState extends ExpandableViewState {
private float openedAmount;
private boolean hasItemsInStableShelf;
@@ -1056,7 +1027,6 @@
}
super.applyToView(view);
- setMaxShelfEnd(maxShelfEnd);
setOpenedAmount(openedAmount);
updateAppearance();
setHasItemsInStableShelf(hasItemsInStableShelf);
@@ -1070,7 +1040,6 @@
}
super.animateTo(child, properties);
- setMaxShelfEnd(maxShelfEnd);
setOpenedAmount(openedAmount);
updateAppearance();
setHasItemsInStableShelf(hasItemsInStableShelf);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelfController.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelfController.java
new file mode 100644
index 0000000..77abcfa
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelfController.java
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui.statusbar;
+
+import android.view.View;
+
+import com.android.systemui.statusbar.notification.row.ActivatableNotificationViewController;
+import com.android.systemui.statusbar.notification.row.dagger.NotificationRowScope;
+import com.android.systemui.statusbar.notification.stack.AmbientState;
+import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
+import com.android.systemui.statusbar.phone.KeyguardBypassController;
+import com.android.systemui.statusbar.phone.NotificationIconContainer;
+import com.android.systemui.statusbar.phone.StatusBarNotificationPresenter;
+
+import javax.inject.Inject;
+
+/**
+ * Controller class for {@link NotificationShelf}.
+ */
+@NotificationRowScope
+public class NotificationShelfController {
+ private final NotificationShelf mView;
+ private final ActivatableNotificationViewController mActivatableNotificationViewController;
+ private final KeyguardBypassController mKeyguardBypassController;
+ private final SysuiStatusBarStateController mStatusBarStateController;
+ private final View.OnAttachStateChangeListener mOnAttachStateChangeListener;
+ private AmbientState mAmbientState;
+
+ @Inject
+ public NotificationShelfController(NotificationShelf notificationShelf,
+ ActivatableNotificationViewController activatableNotificationViewController,
+ KeyguardBypassController keyguardBypassController,
+ SysuiStatusBarStateController statusBarStateController) {
+ mView = notificationShelf;
+ mActivatableNotificationViewController = activatableNotificationViewController;
+ mKeyguardBypassController = keyguardBypassController;
+ mStatusBarStateController = statusBarStateController;
+ mOnAttachStateChangeListener = new View.OnAttachStateChangeListener() {
+ @Override
+ public void onViewAttachedToWindow(View v) {
+ mStatusBarStateController.addCallback(
+ mView, SysuiStatusBarStateController.RANK_SHELF);
+ }
+
+ @Override
+ public void onViewDetachedFromWindow(View v) {
+ mStatusBarStateController.removeCallback(mView);
+ }
+ };
+ }
+
+ public void init() {
+ mActivatableNotificationViewController.init();
+ mView.setController(this);
+ mView.addOnAttachStateChangeListener(mOnAttachStateChangeListener);
+ if (mView.isAttachedToWindow()) {
+ mOnAttachStateChangeListener.onViewAttachedToWindow(mView);
+ }
+ }
+
+ public NotificationShelf getView() {
+ return mView;
+ }
+
+ public boolean canModifyColorOfNotifications() {
+ return mAmbientState.isShadeExpanded()
+ && !(mAmbientState.isOnKeyguard() && mKeyguardBypassController.getBypassEnabled());
+ }
+
+ public NotificationIconContainer getShelfIcons() {
+ return mView.getShelfIcons();
+ }
+
+ public void setCollapsedIcons(NotificationIconContainer notificationIcons) {
+ mView.setCollapsedIcons(notificationIcons);
+ }
+
+ public void bind(AmbientState ambientState,
+ NotificationStackScrollLayoutController notificationStackScrollLayoutController) {
+ mView.bind(ambientState, notificationStackScrollLayoutController);
+ mAmbientState = ambientState;
+ }
+
+ public int getHeight() {
+ return mView.getHeight();
+ }
+
+ public void updateState(AmbientState ambientState) {
+ mAmbientState = ambientState;
+ mView.updateState(ambientState);
+ }
+
+ public int getIntrinsicHeight() {
+ return mView.getIntrinsicHeight();
+ }
+
+ public void setOnActivatedListener(StatusBarNotificationPresenter presenter) {
+ mView.setOnActivatedListener(presenter);
+ }
+
+ public void setOnClickListener(View.OnClickListener onClickListener) {
+ mView.setOnClickListener(onClickListener);
+ }
+
+ public int getNotGoneIndex() {
+ return mView.getNotGoneIndex();
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt
index 7b25853..ff13c4e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt
@@ -36,7 +36,7 @@
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView
import com.android.systemui.statusbar.notification.stack.NotificationRoundnessManager
-import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
+import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone
import com.android.systemui.statusbar.phone.KeyguardBypassController
import com.android.systemui.statusbar.phone.ShadeController
@@ -93,7 +93,7 @@
private set
private val mTouchSlop: Float
private lateinit var expansionCallback: ExpansionCallback
- private lateinit var stackScroller: NotificationStackScrollLayout
+ private lateinit var stackScrollerController: NotificationStackScrollLayoutController
private val mTemp2 = IntArray(2)
private var mDraggedFarEnough: Boolean = false
private var mStartingChild: ExpandableView? = null
@@ -315,23 +315,23 @@
private fun findView(x: Float, y: Float): ExpandableView? {
var totalX = x
var totalY = y
- stackScroller.getLocationOnScreen(mTemp2)
+ stackScrollerController.getLocationOnScreen(mTemp2)
totalX += mTemp2[0].toFloat()
totalY += mTemp2[1].toFloat()
- val childAtRawPosition = stackScroller.getChildAtRawPosition(totalX, totalY)
+ val childAtRawPosition = stackScrollerController.getChildAtRawPosition(totalX, totalY)
return if (childAtRawPosition != null && childAtRawPosition.isContentExpandable) {
childAtRawPosition
} else null
}
fun setUp(
- stackScroller: NotificationStackScrollLayout,
+ stackScrollerController: NotificationStackScrollLayoutController,
expansionCallback: ExpansionCallback,
shadeController: ShadeController
) {
this.expansionCallback = expansionCallback
this.shadeController = shadeController
- this.stackScroller = stackScroller
+ this.stackScrollerController = stackScrollerController
}
fun setPulsing(pulsing: Boolean) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java b/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java
index 7cda235..27e4ade 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java
@@ -21,7 +21,7 @@
import android.view.ViewGroup;
import com.android.systemui.R;
-import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent;
+import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent;
import com.android.systemui.statusbar.phone.LockIcon;
import com.android.systemui.statusbar.phone.LockscreenLockIconController;
import com.android.systemui.statusbar.phone.NotificationPanelView;
@@ -41,22 +41,22 @@
private final Context mContext;
private final InjectionInflationController mInjectionInflationController;
- private final NotificationRowComponent.Builder mNotificationRowComponentBuilder;
private final LockscreenLockIconController mLockIconController;
+ private final NotificationShelfComponent.Builder mNotificationShelfComponentBuilder;
private NotificationShadeWindowView mNotificationShadeWindowView;
private StatusBarWindowView mStatusBarWindowView;
- private NotificationShelf mNotificationShelf;
+ private NotificationShelfController mNotificationShelfController;
@Inject
public SuperStatusBarViewFactory(Context context,
InjectionInflationController injectionInflationController,
- NotificationRowComponent.Builder notificationRowComponentBuilder,
+ NotificationShelfComponent.Builder notificationShelfComponentBuilder,
LockscreenLockIconController lockIconController) {
mContext = context;
mInjectionInflationController = injectionInflationController;
- mNotificationRowComponentBuilder = notificationRowComponentBuilder;
mLockIconController = lockIconController;
+ mNotificationShelfComponentBuilder = notificationShelfComponentBuilder;
}
/**
@@ -114,25 +114,27 @@
* isn't immediately attached, but the layout params of this view is used
* during inflation.
*/
- public NotificationShelf getNotificationShelf(ViewGroup container) {
- if (mNotificationShelf != null) {
- return mNotificationShelf;
+ public NotificationShelfController getNotificationShelfController(ViewGroup container) {
+ if (mNotificationShelfController != null) {
+ return mNotificationShelfController;
}
- mNotificationShelf = (NotificationShelf) mInjectionInflationController.injectable(
- LayoutInflater.from(mContext)).inflate(R.layout.status_bar_notification_shelf,
- container, /* attachToRoot= */ false);
+ NotificationShelf view = (NotificationShelf) LayoutInflater.from(mContext)
+ .inflate(R.layout.status_bar_notification_shelf, container, /* attachToRoot= */
+ false);
- NotificationRowComponent component = mNotificationRowComponentBuilder
- .activatableNotificationView(mNotificationShelf)
- .build();
- component.getActivatableNotificationViewController().init();
-
- if (mNotificationShelf == null) {
+ if (view == null) {
throw new IllegalStateException(
"R.layout.status_bar_notification_shelf could not be properly inflated");
}
- return mNotificationShelf;
+
+ NotificationShelfComponent component = mNotificationShelfComponentBuilder
+ .notificationShelf(view)
+ .build();
+ mNotificationShelfController = component.getNotificationShelfController();
+ mNotificationShelfController.init();
+
+ return mNotificationShelfController;
}
public NotificationPanelView getNotificationPanelView() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt
index f982cf0..0469176 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt
@@ -22,7 +22,7 @@
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.notification.collection.NotificationEntry
-import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
+import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.notification.stack.StackStateAnimator
import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.phone.KeyguardBypassController
@@ -33,6 +33,7 @@
import javax.inject.Inject
import javax.inject.Singleton
+import kotlin.math.min
@Singleton
class NotificationWakeUpCoordinator @Inject constructor(
@@ -53,7 +54,7 @@
return coordinator.mLinearVisibilityAmount
}
}
- private lateinit var mStackScroller: NotificationStackScrollLayout
+ private lateinit var mStackScrollerController: NotificationStackScrollLayoutController
private var mVisibilityInterpolator = Interpolators.FAST_OUT_SLOW_IN_REVERSE
private var mLinearDozeAmount: Float = 0.0f
@@ -79,7 +80,7 @@
if (mNotificationsVisible && !mNotificationsVisibleForExpansion &&
!bypassController.bypassEnabled) {
// We're waking up while pulsing, let's make sure the animation looks nice
- mStackScroller.wakeUpFromPulse()
+ mStackScrollerController.wakeUpFromPulse()
}
if (bypassController.bypassEnabled && !mNotificationsVisible) {
// Let's make sure our huns become visible once we are waking up in case
@@ -156,10 +157,10 @@
})
}
- fun setStackScroller(stackScroller: NotificationStackScrollLayout) {
- mStackScroller = stackScroller
- pulseExpanding = stackScroller.isPulseExpanding
- stackScroller.setOnPulseHeightChangedListener {
+ fun setStackScroller(stackScrollerController: NotificationStackScrollLayoutController) {
+ mStackScrollerController = stackScrollerController
+ pulseExpanding = stackScrollerController.isPulseExpanding
+ stackScrollerController.setOnPulseHeightChangedListener {
val nowExpanding = isPulseExpanding()
val changed = nowExpanding != pulseExpanding
pulseExpanding = nowExpanding
@@ -169,7 +170,7 @@
}
}
- fun isPulseExpanding(): Boolean = mStackScroller.isPulseExpanding
+ fun isPulseExpanding(): Boolean = mStackScrollerController.isPulseExpanding
/**
* @param visible should notifications be visible
@@ -249,7 +250,7 @@
val changed = linear != mLinearDozeAmount
mLinearDozeAmount = linear
mDozeAmount = eased
- mStackScroller.setDozeAmount(mDozeAmount)
+ mStackScrollerController.setDozeAmount(mDozeAmount)
updateHideAmount()
if (changed && linear == 0.0f) {
setNotificationsVisible(visible = false, animate = false, increaseSpeed = false)
@@ -330,18 +331,18 @@
}
fun getWakeUpHeight(): Float {
- return mStackScroller.wakeUpHeight
+ return mStackScrollerController.wakeUpHeight
}
private fun updateHideAmount() {
- val linearAmount = Math.min(1.0f - mLinearVisibilityAmount, mLinearDozeAmount)
- val amount = Math.min(1.0f - mVisibilityAmount, mDozeAmount)
- mStackScroller.setHideAmount(linearAmount, amount)
+ val linearAmount = min(1.0f - mLinearVisibilityAmount, mLinearDozeAmount)
+ val amount = min(1.0f - mVisibilityAmount, mDozeAmount)
+ mStackScrollerController.setHideAmount(linearAmount, amount)
notificationsFullyHidden = linearAmount == 1.0f
}
private fun notifyAnimationStart(awake: Boolean) {
- mStackScroller.notifyHideAnimationStart(!awake)
+ mStackScrollerController.notifyHideAnimationStart(!awake)
}
override fun onDozingChanged(isDozing: Boolean) {
@@ -355,7 +356,7 @@
* from a pulse and determines how much the notifications are expanded.
*/
fun setPulseHeight(height: Float): Float {
- val overflow = mStackScroller.setPulseHeight(height)
+ val overflow = mStackScrollerController.setPulseHeight(height)
// no overflow for the bypass experience
return if (bypassController.bypassEnabled) 0.0f else overflow
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/NotificationShelfComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/NotificationShelfComponent.java
new file mode 100644
index 0000000..af8d6ec
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/NotificationShelfComponent.java
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui.statusbar.notification.row.dagger;
+
+import com.android.systemui.statusbar.NotificationShelf;
+import com.android.systemui.statusbar.NotificationShelfController;
+import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
+
+import dagger.Binds;
+import dagger.BindsInstance;
+import dagger.Module;
+import dagger.Subcomponent;
+
+/**
+ * Dagger subcomponent for NotificationShelf.
+ */
+@Subcomponent(modules = {ActivatableNotificationViewModule.class,
+ NotificationShelfComponent.NotificationShelfModule.class})
+@NotificationRowScope
+public interface NotificationShelfComponent {
+ /**
+ * Builder for {@link NotificationShelfComponent}.
+ */
+ @Subcomponent.Builder
+ interface Builder {
+ @BindsInstance
+ Builder notificationShelf(NotificationShelf view);
+ NotificationShelfComponent build();
+ }
+
+ /**
+ * Creates a NotificationShelfController.
+ */
+ @NotificationRowScope
+ NotificationShelfController getNotificationShelfController();
+ /**
+ * Dagger Module that extracts interesting properties from a NotificationShelf.
+ */
+ @Module
+ abstract class NotificationShelfModule {
+
+ /** NotificationShelf is provided as an instance of ActivatableNotificationView. */
+ @Binds
+ abstract ActivatableNotificationView bindNotificationShelf(NotificationShelf view);
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index 66a541a..2ff67ab 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -19,7 +19,6 @@
import static android.service.notification.NotificationStats.DISMISSAL_SHADE;
import static android.service.notification.NotificationStats.DISMISS_SENTIMENT_NEUTRAL;
-import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator.ExpandAnimationParameters;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManagerKt.BUCKET_SILENT;
import static com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.ANCHOR_SCROLLING;
@@ -113,6 +112,7 @@
import com.android.systemui.statusbar.NotificationLockscreenUserManager.UserChangedListener;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationShelf;
+import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
@@ -209,7 +209,6 @@
private final Paint mBackgroundPaint = new Paint();
private final boolean mShouldDrawNotificationBackground;
private boolean mHighPriorityBeforeSpeedBump;
- private final boolean mAllowLongPress;
private boolean mDismissRtl;
private float mExpandedHeight;
@@ -538,6 +537,7 @@
private int mGapHeight;
private int mWaterfallTopInset;
+ private NotificationStackScrollLayoutController mController;
private SysuiColorExtractor.OnColorsChangedListener mOnColorsChangedListener =
(colorExtractor, which) -> {
@@ -549,7 +549,6 @@
public NotificationStackScrollLayout(
@Named(VIEW_CONTEXT) Context context,
AttributeSet attrs,
- @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowLongPress,
NotificationRoundnessManager notificationRoundnessManager,
DynamicPrivacyController dynamicPrivacyController,
SysuiStatusBarStateController statusBarStateController,
@@ -572,8 +571,6 @@
super(context, attrs, 0, 0);
Resources res = getResources();
- mAllowLongPress = allowLongPress;
-
mRoundnessManager = notificationRoundnessManager;
mLockscreenUserManager = notificationLockscreenUserManager;
@@ -714,9 +711,6 @@
inflateEmptyShadeView();
inflateFooterView();
mVisualStabilityManager.setVisibilityLocationProvider(this::isInVisibleLocation);
- if (mAllowLongPress) {
- setLongPressListener(mNotificationGutsManager::openGuts);
- }
}
/**
@@ -5419,28 +5413,23 @@
}
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
- public void setShelf(NotificationShelf shelf) {
+ public void setShelfController(NotificationShelfController notificationShelfController) {
int index = -1;
if (mShelf != null) {
index = indexOfChild(mShelf);
removeView(mShelf);
}
- mShelf = shelf;
+ mShelf = notificationShelfController.getView();
addView(mShelf, index);
- mAmbientState.setShelf(shelf);
- mStateAnimator.setShelf(shelf);
- shelf.bind(mAmbientState, this);
+ mAmbientState.setShelf(mShelf);
+ mStateAnimator.setShelf(mShelf);
+ notificationShelfController.bind(mAmbientState, mController);
if (ANCHOR_SCROLLING) {
mScrollAnchorView = mShelf;
}
}
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
- public NotificationShelf getNotificationShelf() {
- return mShelf;
- }
-
- @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void setMaxDisplayedNotifications(int maxDisplayedNotifications) {
if (mMaxDisplayedNotifications != maxDisplayedNotifications) {
mMaxDisplayedNotifications = maxDisplayedNotifications;
@@ -5908,6 +5897,15 @@
return MathUtils.smoothStep(0, totalDistance, dragDownAmount);
}
+ public void setController(
+ NotificationStackScrollLayoutController notificationStackScrollLayoutController) {
+ mController = notificationStackScrollLayoutController;
+ }
+
+ public NotificationStackScrollLayoutController getController() {
+ return mController;
+ }
+
/**
* A listener that is notified when the empty space below the notifications is clicked on
*/
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
new file mode 100644
index 0000000..8150593
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
@@ -0,0 +1,540 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui.statusbar.notification.stack;
+
+import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
+
+import android.graphics.PointF;
+import android.view.Display;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowInsets;
+import android.widget.FrameLayout;
+
+import com.android.systemui.statusbar.NotificationShelfController;
+import com.android.systemui.statusbar.RemoteInputController;
+import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
+import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
+import com.android.systemui.statusbar.notification.row.ExpandableView;
+import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
+import com.android.systemui.statusbar.phone.HeadsUpAppearanceController;
+import com.android.systemui.statusbar.phone.HeadsUpTouchHelper;
+import com.android.systemui.statusbar.phone.NotificationGroupManager;
+import com.android.systemui.statusbar.phone.NotificationIconAreaController;
+import com.android.systemui.statusbar.phone.NotificationPanelViewController;
+import com.android.systemui.statusbar.phone.ScrimController;
+import com.android.systemui.statusbar.phone.StatusBar;
+import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
+
+import java.util.function.BiConsumer;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ * Controller for {@link NotificationStackScrollLayout}.
+ */
+@StatusBarComponent.StatusBarScope
+public class NotificationStackScrollLayoutController {
+ private final boolean mAllowLongPress;
+ private final NotificationGutsManager mNotificationGutsManager;
+ private NotificationStackScrollLayout mView;
+
+ @Inject
+ public NotificationStackScrollLayoutController(
+ @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowLongPress,
+ NotificationGutsManager notificationGutsManager) {
+ mAllowLongPress = allowLongPress;
+ mNotificationGutsManager = notificationGutsManager;
+ }
+
+ public void attach(NotificationStackScrollLayout view) {
+ mView = view;
+ mView.setController(this);
+
+ if (mAllowLongPress) {
+ mView.setLongPressListener(mNotificationGutsManager::openGuts);
+ }
+ }
+
+ public void addOnExpandedHeightChangedListener(BiConsumer<Float, Float> listener) {
+ mView.addOnExpandedHeightChangedListener(listener);
+ }
+
+ public void removeOnExpandedHeightChangedListener(BiConsumer<Float, Float> listener) {
+ mView.removeOnExpandedHeightChangedListener(listener);
+ }
+
+ public void addOnLayoutChangeListener(View.OnLayoutChangeListener listener) {
+ mView.addOnLayoutChangeListener(listener);
+ }
+
+ public void removeOnLayoutChangeListener(View.OnLayoutChangeListener listener) {
+ mView.removeOnLayoutChangeListener(listener);
+ }
+
+ public void setHeadsUpAppearanceController(HeadsUpAppearanceController controller) {
+ mView.setHeadsUpAppearanceController(controller);
+ }
+
+ public void requestLayout() {
+ mView.requestLayout();
+ }
+
+ public Display getDisplay() {
+ return mView.getDisplay();
+ }
+
+ public WindowInsets getRootWindowInsets() {
+ return mView.getRootWindowInsets();
+ }
+
+ public int getRight() {
+ return mView.getRight();
+ }
+
+ public boolean isLayoutRtl() {
+ return mView.isLayoutRtl();
+ }
+
+ public float getLeft() {
+ return mView.getLeft();
+ }
+
+ public float getTranslationX() {
+ return mView.getTranslationX();
+ }
+
+ public void setOnHeightChangedListener(
+ ExpandableView.OnHeightChangedListener listener) {
+ mView.setOnHeightChangedListener(listener);
+ }
+
+ public void setOverscrollTopChangedListener(
+ NotificationStackScrollLayout.OnOverscrollTopChangedListener listener) {
+ mView.setOverscrollTopChangedListener(listener);
+ }
+
+ public void setOnEmptySpaceClickListener(
+ NotificationStackScrollLayout.OnEmptySpaceClickListener listener) {
+ mView.setOnEmptySpaceClickListener(listener);
+ }
+
+ public void setTrackingHeadsUp(ExpandableNotificationRow expandableNotificationRow) {
+ mView.setTrackingHeadsUp(expandableNotificationRow);
+ }
+
+ public void wakeUpFromPulse() {
+ mView.wakeUpFromPulse();
+ }
+
+ public boolean isPulseExpanding() {
+ return mView.isPulseExpanding();
+ }
+
+ public void setOnPulseHeightChangedListener(Runnable listener) {
+ mView.setOnPulseHeightChangedListener(listener);
+ }
+
+ public void setDozeAmount(float amount) {
+ mView.setDozeAmount(amount);
+ }
+
+ public float getWakeUpHeight() {
+ return mView.getWakeUpHeight();
+ }
+
+ public void setHideAmount(float linearAmount, float amount) {
+ mView.setHideAmount(linearAmount, amount);
+ }
+
+ public void notifyHideAnimationStart(boolean hide) {
+ mView.notifyHideAnimationStart(hide);
+ }
+
+ public float setPulseHeight(float height) {
+ return mView.setPulseHeight(height);
+ }
+
+ public void getLocationOnScreen(int[] outLocation) {
+ mView.getLocationOnScreen(outLocation);
+ }
+
+ public ExpandableView getChildAtRawPosition(float x, float y) {
+ return mView.getChildAtRawPosition(x, y);
+ }
+
+ public FrameLayout.LayoutParams getLayoutParams() {
+ return (FrameLayout.LayoutParams) mView.getLayoutParams();
+ }
+
+ public void setLayoutParams(FrameLayout.LayoutParams lp) {
+ mView.setLayoutParams(lp);
+ }
+
+ public void setIsFullWidth(boolean isFullWidth) {
+ mView.setIsFullWidth(isFullWidth);
+ }
+
+ public boolean isAddOrRemoveAnimationPending() {
+ return mView.isAddOrRemoveAnimationPending();
+ }
+
+ public int getVisibleNotificationCount() {
+ return mView.getVisibleNotificationCount();
+ }
+
+ public int getIntrinsicContentHeight() {
+ return mView.getIntrinsicContentHeight();
+ }
+
+ public void setIntrinsicPadding(int intrinsicPadding) {
+ mView.setIntrinsicPadding(intrinsicPadding);
+ }
+
+ public int getHeight() {
+ return mView.getHeight();
+ }
+
+ public int getChildCount() {
+ return mView.getChildCount();
+ }
+
+ public ExpandableView getChildAt(int i) {
+ return (ExpandableView) mView.getChildAt(i);
+ }
+
+ public void goToFullShade(long delay) {
+ mView.goToFullShade(delay);
+ }
+
+ public void setOverScrollAmount(float amount, boolean onTop, boolean animate,
+ boolean cancelAnimators) {
+ mView.setOverScrollAmount(amount, onTop, animate, cancelAnimators);
+ }
+
+ public void setOverScrollAmount(float amount, boolean onTop, boolean animate) {
+ mView.setOverScrollAmount(amount, onTop, animate);
+ }
+
+ public void setOverScrolledPixels(float numPixels, boolean onTop, boolean animate) {
+ mView.setOverScrolledPixels(numPixels, onTop, animate);
+ }
+
+ public void resetScrollPosition() {
+ mView.resetScrollPosition();
+ }
+
+ public void setShouldShowShelfOnly(boolean shouldShowShelfOnly) {
+ mView.setShouldShowShelfOnly(shouldShowShelfOnly);
+ }
+
+ public void cancelLongPress() {
+ mView.cancelLongPress();
+ }
+
+ public float getX() {
+ return mView.getX();
+ }
+
+ public boolean isBelowLastNotification(float x, float y) {
+ return mView.isBelowLastNotification(x, y);
+ }
+
+ public float getWidth() {
+ return mView.getWidth();
+ }
+
+ public float getOpeningHeight() {
+ return mView.getOpeningHeight();
+ }
+
+ public float getBottomMostNotificationBottom() {
+ return mView.getBottomMostNotificationBottom();
+ }
+
+ public void checkSnoozeLeavebehind() {
+ mView.checkSnoozeLeavebehind();
+ }
+
+ public void setQsExpanded(boolean expanded) {
+ mView.setQsExpanded(expanded);
+ }
+
+ public void setScrollingEnabled(boolean enabled) {
+ mView.setScrollingEnabled(enabled);
+ }
+
+ public void setQsExpansionFraction(float expansionFraction) {
+ mView.setQsExpansionFraction(expansionFraction);
+ }
+
+ public float calculateAppearFractionBypass() {
+ return mView.calculateAppearFractionBypass();
+ }
+
+ public void updateTopPadding(float qsHeight, boolean animate) {
+ mView.updateTopPadding(qsHeight, animate);
+ }
+
+ public void resetCheckSnoozeLeavebehind() {
+ mView.resetCheckSnoozeLeavebehind();
+ }
+
+ public boolean isScrolledToBottom() {
+ return mView.isScrolledToBottom();
+ }
+
+ public int getNotGoneChildCount() {
+ return mView.getNotGoneChildCount();
+ }
+
+ public float getIntrinsicPadding() {
+ return mView.getIntrinsicPadding();
+ }
+
+ public float getLayoutMinHeight() {
+ return mView.getLayoutMinHeight();
+ }
+
+ public int getEmptyBottomMargin() {
+ return mView.getEmptyBottomMargin();
+ }
+
+ public float getTopPaddingOverflow() {
+ return mView.getTopPaddingOverflow();
+ }
+
+ public int getTopPadding() {
+ return mView.getTopPadding();
+ }
+
+ public float getEmptyShadeViewHeight() {
+ return mView.getEmptyShadeViewHeight();
+ }
+
+ public void setAlpha(float alpha) {
+ mView.setAlpha(alpha);
+ }
+
+ public float getCurrentOverScrollAmount(boolean top) {
+ return mView.getCurrentOverScrollAmount(top);
+ }
+
+ public float getCurrentOverScrolledPixels(boolean top) {
+ return mView.getCurrentOverScrolledPixels(top);
+ }
+
+ public float calculateAppearFraction(float height) {
+ return mView.calculateAppearFraction(height);
+ }
+
+ public void onExpansionStarted() {
+ mView.onExpansionStarted();
+ }
+
+ public void onExpansionStopped() {
+ mView.onExpansionStopped();
+ }
+
+ public void onPanelTrackingStarted() {
+ mView.onPanelTrackingStarted();
+ }
+
+ public void onPanelTrackingStopped() {
+ mView.onPanelTrackingStopped();
+ }
+
+ public void setHeadsUpBoundaries(int height, int bottomBarHeight) {
+ mView.setHeadsUpBoundaries(height, bottomBarHeight);
+ }
+
+ public void setUnlockHintRunning(boolean running) {
+ mView.setUnlockHintRunning(running);
+ }
+
+ public float getPeekHeight() {
+ return mView.getPeekHeight();
+ }
+
+ public boolean isFooterViewNotGone() {
+ return mView.isFooterViewNotGone();
+ }
+
+ public boolean isFooterViewContentVisible() {
+ return mView.isFooterViewContentVisible();
+ }
+
+ public int getFooterViewHeightWithPadding() {
+ return mView.getFooterViewHeightWithPadding();
+ }
+
+ public void updateEmptyShadeView(boolean visible) {
+ mView.updateEmptyShadeView(visible);
+ }
+
+ public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
+ mView.setHeadsUpAnimatingAway(headsUpAnimatingAway);
+ }
+
+ public HeadsUpTouchHelper.Callback getHeadsUpCallback() {
+ return mView.getHeadsUpCallback();
+ }
+
+ public void forceNoOverlappingRendering(boolean force) {
+ mView.forceNoOverlappingRendering(force);
+ }
+
+ public void setTranslationX(float translation) {
+ mView.setTranslationX(translation);
+ }
+
+ public void setExpandingVelocity(float velocity) {
+ mView.setExpandingVelocity(velocity);
+ }
+
+ public void setExpandedHeight(float expandedHeight) {
+ mView.setExpandedHeight(expandedHeight);
+ }
+
+ public void setQsContainer(ViewGroup view) {
+ mView.setQsContainer(view);
+ }
+
+ public void setAnimationsEnabled(boolean enabled) {
+ mView.setAnimationsEnabled(enabled);
+ }
+
+ public void setDozing(boolean dozing, boolean animate, PointF wakeUpTouchLocation) {
+ mView.setDozing(dozing, animate, wakeUpTouchLocation);
+ }
+
+ public void setPulsing(boolean pulsing, boolean animatePulse) {
+ mView.setPulsing(pulsing, animatePulse);
+ }
+
+ public boolean hasActiveClearableNotifications(
+ @NotificationStackScrollLayout.SelectedRows int selection) {
+ return mView.hasActiveClearableNotifications(selection);
+ }
+
+ public RemoteInputController.Delegate createDelegate() {
+ return mView.createDelegate();
+ }
+
+ public void updateSectionBoundaries(String reason) {
+ mView.updateSectionBoundaries(reason);
+ }
+
+ public void updateSpeedBumpIndex() {
+ mView.updateSpeedBumpIndex();
+ }
+
+ public void updateFooter() {
+ mView.updateFooter();
+ }
+
+ public void updateIconAreaViews() {
+ mView.updateIconAreaViews();
+ }
+
+ public void onUpdateRowStates() {
+ mView.onUpdateRowStates();
+ }
+
+ public boolean hasPulsingNotifications() {
+ return mView.hasPulsingNotifications();
+ }
+
+ public ActivatableNotificationView getActivatedChild() {
+ return mView.getActivatedChild();
+ }
+
+ public void setActivatedChild(ActivatableNotificationView view) {
+ mView.setActivatedChild(view);
+ }
+
+ public void runAfterAnimationFinished(Runnable r) {
+ mView.runAfterAnimationFinished(r);
+ }
+
+ public void setNotificationPanelController(
+ NotificationPanelViewController notificationPanelViewController) {
+ mView.setNotificationPanelController(notificationPanelViewController);
+ }
+
+ public void setIconAreaController(NotificationIconAreaController controller) {
+ mView.setIconAreaController(controller);
+ }
+
+ public void setStatusBar(StatusBar statusBar) {
+ mView.setStatusBar(statusBar);
+ }
+
+ public void setGroupManager(NotificationGroupManager groupManager) {
+ mView.setGroupManager(groupManager);
+ }
+
+ public void setShelfController(NotificationShelfController notificationShelfController) {
+ mView.setShelfController(notificationShelfController);
+ }
+
+ public void setScrimController(ScrimController scrimController) {
+ mView.setScrimController(scrimController);
+ }
+
+ public ExpandableView getFirstChildNotGone() {
+ return mView.getFirstChildNotGone();
+ }
+
+ public void setInHeadsUpPinnedMode(boolean inPinnedMode) {
+ mView.setInHeadsUpPinnedMode(inPinnedMode);
+ }
+
+ public void generateHeadsUpAnimation(NotificationEntry entry, boolean isHeadsUp) {
+ mView.generateHeadsUpAnimation(entry, isHeadsUp);
+ }
+
+ public void generateHeadsUpAnimation(ExpandableNotificationRow row, boolean isHeadsUp) {
+ mView.generateHeadsUpAnimation(row, isHeadsUp);
+ }
+
+ public void setMaxTopPadding(int padding) {
+ mView.setMaxTopPadding(padding);
+ }
+
+ public int getTransientViewCount() {
+ return mView.getTransientViewCount();
+ }
+
+ public View getTransientView(int i) {
+ return mView.getTransientView(i);
+ }
+
+ public int getPositionInLinearLayout(ExpandableView row) {
+ return mView.getPositionInLinearLayout(row);
+ }
+
+ public NotificationStackScrollLayout getView() {
+ return mView;
+ }
+
+ public float calculateGapHeight(ExpandableView previousView, ExpandableView child, int count) {
+ return mView.calculateGapHeight(previousView, child, count);
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FloatingRotationButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FloatingRotationButton.java
index 687f5f1..8a85f7d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FloatingRotationButton.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FloatingRotationButton.java
@@ -30,6 +30,8 @@
import com.android.systemui.statusbar.policy.KeyButtonDrawable;
import com.android.systemui.statusbar.policy.KeyButtonView;
+import java.util.function.Consumer;
+
/** Containing logic for the rotation button on the physical left bottom corner of the screen. */
public class FloatingRotationButton implements RotationButton {
@@ -45,6 +47,7 @@
private boolean mCanShow = true;
private RotationButtonController mRotationButtonController;
+ private Consumer<Boolean> mVisibilityChangedCallback;
FloatingRotationButton(Context context) {
mContext = context;
@@ -67,6 +70,11 @@
}
@Override
+ public void setVisibilityChangedCallback(Consumer<Boolean> visibilityChangedCallback) {
+ mVisibilityChangedCallback = visibilityChangedCallback;
+ }
+
+ @Override
public View getCurrentView() {
return mKeyButtonView;
}
@@ -105,6 +113,16 @@
mKeyButtonDrawable.resetAnimation();
mKeyButtonDrawable.startAnimation();
}
+ mKeyButtonView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5,
+ int i6, int i7) {
+ if (mIsShowing && mVisibilityChangedCallback != null) {
+ mVisibilityChangedCallback.accept(true);
+ }
+ mKeyButtonView.removeOnLayoutChangeListener(this);
+ }
+ });
return true;
}
@@ -115,6 +133,9 @@
}
mWindowManager.removeViewImmediate(mKeyButtonView);
mIsShowing = false;
+ if (mVisibilityChangedCallback != null) {
+ mVisibilityChangedCallback.accept(false);
+ }
return true;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java
index 51c02c9..8cdaa63 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java
@@ -36,7 +36,7 @@
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
-import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
+import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
@@ -52,7 +52,7 @@
public static final int CONTENT_FADE_DELAY = 100;
private final NotificationIconAreaController mNotificationIconAreaController;
private final HeadsUpManagerPhone mHeadsUpManager;
- private final NotificationStackScrollLayout mStackScroller;
+ private final NotificationStackScrollLayoutController mStackScrollerController;
private final HeadsUpStatusBarView mHeadsUpStatusBarView;
private final View mCenteredIconView;
private final View mClockView;
@@ -93,7 +93,7 @@
public HeadsUpAppearanceController(
NotificationIconAreaController notificationIconAreaController,
HeadsUpManagerPhone headsUpManager,
- View notificationShadeView,
+ NotificationStackScrollLayoutController notificationStackScrollLayoutController,
SysuiStatusBarStateController statusBarStateController,
KeyguardBypassController keyguardBypassController,
KeyguardStateController keyguardStateController,
@@ -101,10 +101,9 @@
NotificationPanelViewController notificationPanelViewController, View statusBarView) {
this(notificationIconAreaController, headsUpManager, statusBarStateController,
keyguardBypassController, wakeUpCoordinator, keyguardStateController,
- commandQueue,
- statusBarView.findViewById(R.id.heads_up_status_bar_view),
- notificationShadeView.findViewById(R.id.notification_stack_scroller),
+ commandQueue, notificationStackScrollLayoutController,
notificationPanelViewController,
+ statusBarView.findViewById(R.id.heads_up_status_bar_view),
statusBarView.findViewById(R.id.clock),
statusBarView.findViewById(R.id.operator_name_frame),
statusBarView.findViewById(R.id.centered_icon_area));
@@ -119,9 +118,9 @@
NotificationWakeUpCoordinator wakeUpCoordinator,
KeyguardStateController keyguardStateController,
CommandQueue commandQueue,
- HeadsUpStatusBarView headsUpStatusBarView,
- NotificationStackScrollLayout stackScroller,
+ NotificationStackScrollLayoutController stackScrollerController,
NotificationPanelViewController notificationPanelViewController,
+ HeadsUpStatusBarView headsUpStatusBarView,
View clockView,
View operatorNameView,
View centeredIconView) {
@@ -132,14 +131,14 @@
mCenteredIconView = centeredIconView;
headsUpStatusBarView.setOnDrawingRectChangedListener(
() -> updateIsolatedIconLocation(true /* requireUpdate */));
- mStackScroller = stackScroller;
+ mStackScrollerController = stackScrollerController;
mNotificationPanelViewController = notificationPanelViewController;
notificationPanelViewController.addTrackingHeadsUpListener(mSetTrackingHeadsUp);
notificationPanelViewController.addVerticalTranslationListener(mUpdatePanelTranslation);
notificationPanelViewController.setHeadsUpAppearanceController(this);
- mStackScroller.addOnExpandedHeightChangedListener(mSetExpandedHeight);
- mStackScroller.addOnLayoutChangeListener(mStackScrollLayoutChangeListener);
- mStackScroller.setHeadsUpAppearanceController(this);
+ mStackScrollerController.addOnExpandedHeightChangedListener(mSetExpandedHeight);
+ mStackScrollerController.addOnLayoutChangeListener(mStackScrollLayoutChangeListener);
+ mStackScrollerController.setHeadsUpAppearanceController(this);
mClockView = clockView;
mOperatorNameView = operatorNameView;
mDarkIconDispatcher = Dependency.get(DarkIconDispatcher.class);
@@ -153,7 +152,7 @@
updateTopEntry();
// trigger scroller to notify the latest panel translation
- mStackScroller.requestLayout();
+ mStackScrollerController.requestLayout();
}
mHeadsUpStatusBarView.removeOnLayoutChangeListener(this);
}
@@ -174,8 +173,8 @@
mNotificationPanelViewController.removeTrackingHeadsUpListener(mSetTrackingHeadsUp);
mNotificationPanelViewController.removeVerticalTranslationListener(mUpdatePanelTranslation);
mNotificationPanelViewController.setHeadsUpAppearanceController(null);
- mStackScroller.removeOnExpandedHeightChangedListener(mSetExpandedHeight);
- mStackScroller.removeOnLayoutChangeListener(mStackScrollLayoutChangeListener);
+ mStackScrollerController.removeOnExpandedHeightChangedListener(mSetExpandedHeight);
+ mStackScrollerController.removeOnLayoutChangeListener(mStackScrollLayoutChangeListener);
mDarkIconDispatcher.removeDarkReceiver(this);
}
@@ -219,12 +218,12 @@
}
int realDisplaySize = 0;
- if (mStackScroller.getDisplay() != null) {
- mStackScroller.getDisplay().getRealSize(mPoint);
+ if (mStackScrollerController.getDisplay() != null) {
+ mStackScrollerController.getDisplay().getRealSize(mPoint);
realDisplaySize = mPoint.x;
}
- WindowInsets windowInset = mStackScroller.getRootWindowInsets();
+ WindowInsets windowInset = mStackScrollerController.getRootWindowInsets();
DisplayCutout cutout = (windowInset != null) ? windowInset.getDisplayCutout() : null;
int sysWinLeft = (windowInset != null) ? windowInset.getStableInsetLeft() : 0;
int sysWinRight = (windowInset != null) ? windowInset.getStableInsetRight() : 0;
@@ -233,17 +232,17 @@
int leftInset = Math.max(sysWinLeft, cutoutLeft);
int rightInset = Math.max(sysWinRight, cutoutRight);
- return leftInset + mStackScroller.getRight() + rightInset - realDisplaySize;
+ return leftInset + mStackScrollerController.getRight() + rightInset - realDisplaySize;
}
public void updatePanelTranslation() {
float newTranslation;
- if (mStackScroller.isLayoutRtl()) {
+ if (mStackScrollerController.isLayoutRtl()) {
newTranslation = getRtlTranslation();
} else {
- newTranslation = mStackScroller.getLeft();
+ newTranslation = mStackScrollerController.getLeft();
}
- newTranslation += mStackScroller.getTranslationX();
+ newTranslation += mStackScrollerController.getTranslationX();
mHeadsUpStatusBarView.setPanelTranslation(newTranslation);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
index 8c5e2ce..fd653b4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
@@ -120,7 +120,6 @@
import com.android.systemui.statusbar.AutoHideUiElement;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.CommandQueue.Callbacks;
-import com.android.systemui.statusbar.NavigationBarController;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
@@ -132,7 +131,6 @@
import java.io.FileDescriptor;
import java.io.PrintWriter;
-import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
@@ -194,6 +192,7 @@
private int mLayoutDirection;
private boolean mForceNavBarHandleOpaque;
+ private boolean mIsCurrentUserSetup;
/** @see android.view.WindowInsetsController#setSystemBarsAppearance(int) */
private @Appearance int mAppearance;
@@ -313,6 +312,10 @@
@Override
public void onNavBarButtonAlphaChanged(float alpha, boolean animate) {
+ if (!mIsCurrentUserSetup) {
+ // If the current user is not yet setup, then don't update any button alphas
+ return;
+ }
ButtonDispatcher buttonDispatcher = null;
boolean forceVisible = false;
if (QuickStepContract.isSwipeUpMode(mNavBarMode)) {
@@ -351,15 +354,6 @@
}
};
- private final ContextButtonListener mRotationButtonListener = (button, visible) -> {
- if (visible) {
- // If the button will actually become visible and the navbar is about to hide,
- // tell the statusbar to keep it around for longer
- mAutoHideController.touchAutoHide();
- mNavigationBarView.notifyActiveTouchRegions();
- }
- };
-
private final Runnable mAutoDim = () -> getBarTransitions().setAutoDim(true);
private final ContentObserver mAssistContentObserver = new ContentObserver(
@@ -414,6 +408,14 @@
}
};
+ private final DeviceProvisionedController.DeviceProvisionedListener mUserSetupListener =
+ new DeviceProvisionedController.DeviceProvisionedListener() {
+ @Override
+ public void onUserSetupChanged() {
+ mIsCurrentUserSetup = mDeviceProvisionedController.isCurrentUserSetup();
+ }
+ };
+
@Inject
public NavigationBarFragment(AccessibilityManagerWrapper accessibilityManagerWrapper,
DeviceProvisionedController deviceProvisionedController, MetricsLogger metricsLogger,
@@ -481,6 +483,9 @@
/* defaultValue = */ true);
DeviceConfig.addOnPropertiesChangedListener(
DeviceConfig.NAMESPACE_SYSTEMUI, mHandler::post, mOnPropertiesChangedListener);
+
+ mIsCurrentUserSetup = mDeviceProvisionedController.isCurrentUserSetup();
+ mDeviceProvisionedController.addCallback(mUserSetupListener);
}
@Override
@@ -489,6 +494,7 @@
mNavigationModeController.removeListener(this);
mAccessibilityManagerWrapper.removeCallback(mAccessibilityListener);
mContentResolver.unregisterContentObserver(mAssistContentObserver);
+ mDeviceProvisionedController.removeCallback(mUserSetupListener);
DeviceConfig.removeOnPropertiesChangedListener(mOnPropertiesChangedListener);
}
@@ -535,8 +541,6 @@
// Currently there is no accelerometer sensor on non-default display.
if (mIsOnDefaultDisplay) {
- mNavigationBarView.getRotateSuggestionButton().setListener(mRotationButtonListener);
-
final RotationButtonController rotationButtonController =
mNavigationBarView.getRotationButtonController();
rotationButtonController.addRotationCallback(mRotationWatcher);
@@ -1340,6 +1344,7 @@
if (mAutoHideController != null) {
mAutoHideController.setNavigationBar(mAutoHideUiElement);
}
+ mNavigationBarView.setAutoHideController(autoHideController);
}
private boolean isTransientShown() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 0b4a2b6..e3cb105 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -131,6 +131,7 @@
private boolean mDeadZoneConsuming = false;
private final NavigationBarTransitions mBarTransitions;
private final OverviewProxyService mOverviewProxyService;
+ private AutoHideController mAutoHideController;
// performs manual animation in sync with layout transitions
private final NavTransitionListener mTransitionListener = new NavTransitionListener();
@@ -276,6 +277,15 @@
info.touchableRegion.setEmpty();
};
+ private final Consumer<Boolean> mRotationButtonListener = (visible) -> {
+ if (visible) {
+ // If the button will actually become visible and the navbar is about to hide,
+ // tell the statusbar to keep it around for longer
+ mAutoHideController.touchAutoHide();
+ }
+ notifyActiveTouchRegions();
+ };
+
public NavigationBarView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -313,7 +323,8 @@
mFloatingRotationButton = new FloatingRotationButton(context);
mRotationButtonController = new RotationButtonController(mLightContext,
mLightIconColor, mDarkIconColor,
- isGesturalMode ? mFloatingRotationButton : rotateSuggestionButton);
+ isGesturalMode ? mFloatingRotationButton : rotateSuggestionButton,
+ mRotationButtonListener);
mConfiguration = new Configuration();
mTmpLastConfiguration = new Configuration();
@@ -361,6 +372,10 @@
});
}
+ public void setAutoHideController(AutoHideController autoHideController) {
+ mAutoHideController = autoHideController;
+ }
+
public NavigationBarTransitions getBarTransitions() {
return mBarTransitions;
}
@@ -939,7 +954,15 @@
updateButtonLocation(getBackButton());
updateButtonLocation(getHomeButton());
updateButtonLocation(getRecentsButton());
- updateButtonLocation(getRotateSuggestionButton());
+ updateButtonLocation(getImeSwitchButton());
+ updateButtonLocation(getAccessibilityButton());
+ if (mFloatingRotationButton.isVisible()) {
+ View floatingRotationView = mFloatingRotationButton.getCurrentView();
+ floatingRotationView.getBoundsOnScreen(mTmpBounds);
+ mActiveRegion.op(mTmpBounds, Op.UNION);
+ } else {
+ updateButtonLocation(getRotateSuggestionButton());
+ }
mOverviewProxyService.onActiveNavBarRegionChanges(mActiveRegion);
}
@@ -1211,6 +1234,7 @@
dumpButton(pw, "rcnt", getRecentsButton());
dumpButton(pw, "rota", getRotateSuggestionButton());
dumpButton(pw, "a11y", getAccessibilityButton());
+ dumpButton(pw, "ime", getImeSwitchButton());
pw.println(" }");
pw.println(" mScreenOn: " + mScreenOn);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
index 9d3e915..7bbe1c9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
@@ -26,7 +26,7 @@
import com.android.systemui.statusbar.CrossFadeHelper;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationMediaManager;
-import com.android.systemui.statusbar.NotificationShelf;
+import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.StatusBarIconView;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.NotificationUtils;
@@ -160,9 +160,9 @@
}
}
- public void setupShelf(NotificationShelf shelf) {
- mShelfIcons = shelf.getShelfIcons();
- shelf.setCollapsedIcons(mNotificationIcons);
+ public void setupShelf(NotificationShelfController notificationShelfController) {
+ mShelfIcons = notificationShelfController.getShelfIcons();
+ notificationShelfController.setCollapsedIcons(mNotificationIcons);
}
public void onDensityOrFontScaleChanged(Context context) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
index a87311a..70fb71a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -86,6 +86,7 @@
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationShelf;
+import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.PulseExpansionHandler;
import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.StatusBarState;
@@ -105,6 +106,7 @@
import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
+import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.phone.LockscreenGestureLogger.LockscreenUiEvent;
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
@@ -174,6 +176,7 @@
private final ZenModeController mZenModeController;
private final ConfigurationController mConfigurationController;
private final FlingAnimationUtils.Builder mFlingAnimationUtilsBuilder;
+ private final NotificationStackScrollLayoutController mNotificationStackScrollLayoutController;
// Cap and total height of Roboto font. Needs to be adjusted when font for the big clock is
// changed.
@@ -264,7 +267,6 @@
private KeyguardStatusView mKeyguardStatusView;
private View mQsNavbarScrim;
private NotificationsQuickSettingsContainer mNotificationContainerParent;
- private NotificationStackScrollLayout mNotificationStackScroller;
private boolean mAnimateNextPositionUpdate;
private int mTrackingPointer;
@@ -454,6 +456,7 @@
private boolean mAnimatingQS;
private int mOldLayoutDirection;
+ private NotificationShelfController mNotificationShelfController;
private View.AccessibilityDelegate mAccessibilityDelegate = new View.AccessibilityDelegate() {
@Override
@@ -498,7 +501,8 @@
MediaHierarchyManager mediaHierarchyManager,
BiometricUnlockController biometricUnlockController,
StatusBarKeyguardViewManager statusBarKeyguardViewManager,
- Provider<KeyguardClockSwitchController> keyguardClockSwitchControllerProvider) {
+ Provider<KeyguardClockSwitchController> keyguardClockSwitchControllerProvider,
+ NotificationStackScrollLayoutController notificationStackScrollLayoutController) {
super(view, falsingManager, dozeLog, keyguardStateController,
(SysuiStatusBarStateController) statusBarStateController, vibratorHelper,
latencyTracker, flingAnimationUtilsBuilder, statusBarTouchableRegionManager);
@@ -511,6 +515,7 @@
mMediaHierarchyManager = mediaHierarchyManager;
mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
mKeyguardClockSwitchControllerProvider = keyguardClockSwitchControllerProvider;
+ mNotificationStackScrollLayoutController = notificationStackScrollLayoutController;
mView.setWillNotDraw(!DEBUG);
mInjectionInflationController = injectionInflationController;
mFalsingManager = falsingManager;
@@ -590,21 +595,26 @@
keyguardClockSwitchController.setBigClockContainer(mBigClockContainer);
mNotificationContainerParent = mView.findViewById(R.id.notification_container_parent);
- mNotificationStackScroller = mView.findViewById(R.id.notification_stack_scroller);
- mNotificationStackScroller.setOnHeightChangedListener(mOnHeightChangedListener);
- mNotificationStackScroller.setOverscrollTopChangedListener(mOnOverscrollTopChangedListener);
- mNotificationStackScroller.setOnEmptySpaceClickListener(mOnEmptySpaceClickListener);
- addTrackingHeadsUpListener(mNotificationStackScroller::setTrackingHeadsUp);
+ NotificationStackScrollLayout stackScrollLayout = mView.findViewById(
+ R.id.notification_stack_scroller);
+ mNotificationStackScrollLayoutController.attach(stackScrollLayout);
+ mNotificationStackScrollLayoutController.setOnHeightChangedListener(
+ mOnHeightChangedListener);
+ mNotificationStackScrollLayoutController.setOverscrollTopChangedListener(
+ mOnOverscrollTopChangedListener);
+ mNotificationStackScrollLayoutController.setOnEmptySpaceClickListener(
+ mOnEmptySpaceClickListener);
+ addTrackingHeadsUpListener(mNotificationStackScrollLayoutController::setTrackingHeadsUp);
mKeyguardBottomArea = mView.findViewById(R.id.keyguard_bottom_area);
mQsNavbarScrim = mView.findViewById(R.id.qs_navbar_scrim);
mLastOrientation = mResources.getConfiguration().orientation;
initBottomArea();
- mWakeUpCoordinator.setStackScroller(mNotificationStackScroller);
+ mWakeUpCoordinator.setStackScroller(mNotificationStackScrollLayoutController);
mQsFrame = mView.findViewById(R.id.qs_frame);
mPulseExpansionHandler.setUp(
- mNotificationStackScroller, mExpansionCallback, mShadeController);
+ mNotificationStackScrollLayoutController, mExpansionCallback, mShadeController);
mWakeUpCoordinator.addListener(new NotificationWakeUpCoordinator.WakeUpListener() {
@Override
public void onFullyHiddenChanged(boolean isFullyHidden) {
@@ -688,11 +698,11 @@
}
int panelWidth = mResources.getDimensionPixelSize(R.dimen.notification_panel_width);
- lp = (FrameLayout.LayoutParams) mNotificationStackScroller.getLayoutParams();
+ lp = mNotificationStackScrollLayoutController.getLayoutParams();
if (lp.width != panelWidth || lp.gravity != panelGravity) {
lp.width = panelWidth;
lp.gravity = panelGravity;
- mNotificationStackScroller.setLayoutParams(lp);
+ mNotificationStackScrollLayoutController.setLayoutParams(lp);
}
}
@@ -770,7 +780,7 @@
private void setIsFullWidth(boolean isFullWidth) {
mIsFullWidth = isFullWidth;
- mNotificationStackScroller.setIsFullWidth(isFullWidth);
+ mNotificationStackScrollLayoutController.setIsFullWidth(isFullWidth);
}
private void startQsSizeChangeAnimation(int oldHeight, final int newHeight) {
@@ -804,7 +814,7 @@
* showing.
*/
private void positionClockAndNotifications() {
- boolean animate = mNotificationStackScroller.isAddOrRemoveAnimationPending();
+ boolean animate = mNotificationStackScrollLayoutController.isAddOrRemoveAnimationPending();
boolean animateClock = animate || mAnimateNextPositionUpdate;
int stackScrollerPadding;
if (mBarState != StatusBarState.KEYGUARD) {
@@ -814,12 +824,12 @@
int bottomPadding = Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding);
int clockPreferredY = mKeyguardStatusView.getClockPreferredY(totalHeight);
boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled();
- final boolean
- hasVisibleNotifications =
- !bypassEnabled && mNotificationStackScroller.getVisibleNotificationCount() != 0;
+ final boolean hasVisibleNotifications = !bypassEnabled
+ && mNotificationStackScrollLayoutController.getVisibleNotificationCount() != 0;
mKeyguardStatusView.setHasVisibleNotifications(hasVisibleNotifications);
mClockPositionAlgorithm.setup(mStatusBarMinHeight, totalHeight - bottomPadding,
- mNotificationStackScroller.getIntrinsicContentHeight(), getExpandedFraction(),
+ mNotificationStackScrollLayoutController.getIntrinsicContentHeight(),
+ getExpandedFraction(),
totalHeight, (int) (mKeyguardStatusView.getHeight() - mShelfHeight / 2.0f
- mDarkIconSize / 2.0f), clockPreferredY, hasCustomClock(),
hasVisibleNotifications, mInterpolatedDarkAmount, mEmptyDragAmount,
@@ -833,7 +843,7 @@
updateClock();
stackScrollerPadding = mClockPositionResult.stackScrollerPaddingExpanded;
}
- mNotificationStackScroller.setIntrinsicPadding(stackScrollerPadding);
+ mNotificationStackScrollLayoutController.setIntrinsicPadding(stackScrollerPadding);
mKeyguardBottomArea.setAntiBurnInOffsetX(mClockPositionResult.clockX);
mStackScrollerMeasuringPass++;
@@ -858,36 +868,51 @@
float minPadding = mClockPositionAlgorithm.getMinStackScrollerPadding();
int notificationPadding = Math.max(
1, mResources.getDimensionPixelSize(R.dimen.notification_divider_height));
- NotificationShelf shelf = mNotificationStackScroller.getNotificationShelf();
+ NotificationShelf shelf = mNotificationShelfController.getView();
float
shelfSize =
shelf.getVisibility() == View.GONE ? 0
: shelf.getIntrinsicHeight() + notificationPadding;
float
availableSpace =
- mNotificationStackScroller.getHeight() - minPadding - shelfSize - Math.max(
- mIndicationBottomPadding, mAmbientIndicationBottomPadding)
+ mNotificationStackScrollLayoutController.getHeight() - minPadding - shelfSize
+ - Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding)
- mKeyguardStatusView.getLogoutButtonHeight();
int count = 0;
ExpandableView previousView = null;
- for (int i = 0; i < mNotificationStackScroller.getChildCount(); i++) {
- ExpandableView child = (ExpandableView) mNotificationStackScroller.getChildAt(i);
+ for (int i = 0; i < mNotificationStackScrollLayoutController.getChildCount(); i++) {
+ ExpandableView child = mNotificationStackScrollLayoutController.getChildAt(i);
+ if (!(child instanceof ExpandableNotificationRow)) {
+ continue;
+ }
+ ExpandableNotificationRow row = (ExpandableNotificationRow) child;
+ boolean
+ suppressedSummary =
+ mGroupManager != null && mGroupManager.isSummaryOfSuppressedGroup(
+ row.getEntry().getSbn());
+ if (suppressedSummary) {
+ continue;
+ }
if (!canShowViewOnLockscreen(child)) {
continue;
}
+ if (row.isRemoved()) {
+ continue;
+ }
availableSpace -= child.getMinHeight(true /* ignoreTemporaryStates */);
availableSpace -= count == 0 ? 0 : notificationPadding;
- availableSpace -= mNotificationStackScroller.calculateGapHeight(previousView, child,
- count);
+ availableSpace -= mNotificationStackScrollLayoutController
+ .calculateGapHeight(previousView, child, count);
previousView = child;
if (availableSpace >= 0 && count < maximum) {
count++;
} else if (availableSpace > -shelfSize) {
// if we are exactly the last view, then we can show us still!
- for (int j = i + 1; j < mNotificationStackScroller.getChildCount(); j++) {
- ExpandableView view = (ExpandableView) mNotificationStackScroller.getChildAt(j);
- if (view instanceof ExpandableNotificationRow &&
- canShowViewOnLockscreen(view)) {
+ int childCount = mNotificationStackScrollLayoutController.getChildCount();
+ for (int j = i + 1; j < childCount; j++) {
+ ExpandableView view = mNotificationStackScrollLayoutController.getChildAt(j);
+ if (view instanceof ExpandableNotificationRow
+ && canShowViewOnLockscreen(view)) {
return count;
}
}
@@ -952,7 +977,7 @@
}
public void animateToFullShade(long delay) {
- mNotificationStackScroller.goToFullShade(delay);
+ mNotificationStackScrollLayoutController.goToFullShade(delay);
mView.requestLayout();
mAnimateNextPositionUpdate = true;
}
@@ -978,9 +1003,9 @@
} else {
closeQs();
}
- mNotificationStackScroller.setOverScrollAmount(0f, true /* onTop */, animate,
+ mNotificationStackScrollLayoutController.setOverScrollAmount(0f, true /* onTop */, animate,
!animate /* cancelAnimators */);
- mNotificationStackScroller.resetScrollPosition();
+ mNotificationStackScrollLayoutController.resetScrollPosition();
}
@Override
@@ -991,7 +1016,7 @@
if (mQsExpanded) {
mQsExpandImmediate = true;
- mNotificationStackScroller.setShouldShowShelfOnly(true);
+ mNotificationStackScrollLayoutController.setShouldShowShelfOnly(true);
}
super.collapse(delayed, speedUpFactor);
}
@@ -1027,7 +1052,7 @@
public void expandWithQs() {
if (mQsExpansionEnabled) {
mQsExpandImmediate = true;
- mNotificationStackScroller.setShouldShowShelfOnly(true);
+ mNotificationStackScrollLayoutController.setShouldShowShelfOnly(true);
}
if (isFullyCollapsed()) {
expand(true /* animate */);
@@ -1088,7 +1113,7 @@
onQsExpansionStarted();
mInitialHeightOnTouch = mQsExpansionHeight;
mQsTracking = true;
- mNotificationStackScroller.cancelLongPress();
+ mNotificationStackScrollLayoutController.cancelLongPress();
}
break;
case MotionEvent.ACTION_POINTER_UP:
@@ -1124,7 +1149,7 @@
mInitialHeightOnTouch = mQsExpansionHeight;
mInitialTouchY = y;
mInitialTouchX = x;
- mNotificationStackScroller.cancelLongPress();
+ mNotificationStackScrollLayoutController.cancelLongPress();
return true;
}
break;
@@ -1144,9 +1169,11 @@
@Override
protected boolean isInContentBounds(float x, float y) {
- float stackScrollerX = mNotificationStackScroller.getX();
- return !mNotificationStackScroller.isBelowLastNotification(x - stackScrollerX, y)
- && stackScrollerX < x && x < stackScrollerX + mNotificationStackScroller.getWidth();
+ float stackScrollerX = mNotificationStackScrollLayoutController.getX();
+ return !mNotificationStackScrollLayoutController
+ .isBelowLastNotification(x - stackScrollerX, y)
+ && stackScrollerX < x
+ && x < stackScrollerX + mNotificationStackScrollLayoutController.getWidth();
}
private void initDownStates(MotionEvent event) {
@@ -1254,7 +1281,7 @@
@Override
protected float getOpeningHeight() {
- return mNotificationStackScroller.getOpeningHeight();
+ return mNotificationStackScrollLayoutController.getOpeningHeight();
}
@@ -1290,7 +1317,7 @@
< mStatusBarMinHeight) {
mMetricsLogger.count(COUNTER_PANEL_OPEN_QS, 1);
mQsExpandImmediate = true;
- mNotificationStackScroller.setShouldShowShelfOnly(true);
+ mNotificationStackScrollLayoutController.setShouldShowShelfOnly(true);
requestPanelHeightUpdate();
// Normally, we start listening when the panel is expanded, but here we need to start
@@ -1302,7 +1329,7 @@
private boolean isInQsArea(float x, float y) {
return (x >= mQsFrame.getX() && x <= mQsFrame.getX() + mQsFrame.getWidth()) && (
- y <= mNotificationStackScroller.getBottomMostNotificationBottom()
+ y <= mNotificationStackScrollLayoutController.getBottomMostNotificationBottom()
|| y <= mQs.getView().getY() + mQs.getView().getHeight());
}
@@ -1492,7 +1519,7 @@
float height = mQsExpansionHeight - overscrollAmount;
setQsExpansion(height);
requestPanelHeightUpdate();
- mNotificationStackScroller.checkSnoozeLeavebehind();
+ mNotificationStackScrollLayoutController.checkSnoozeLeavebehind();
// When expanding QS, let's authenticate the user if possible,
// this will speed up notification actions.
@@ -1665,8 +1692,8 @@
}
private void updateQsState() {
- mNotificationStackScroller.setQsExpanded(mQsExpanded);
- mNotificationStackScroller.setScrollingEnabled(
+ mNotificationStackScrollLayoutController.setQsExpanded(mQsExpanded);
+ mNotificationStackScrollLayoutController.setScrollingEnabled(
mBarState != StatusBarState.KEYGUARD && (!mQsExpanded
|| mQsExpansionFromOverscroll));
updateEmptyShadeView();
@@ -1726,7 +1753,7 @@
float qsExpansionFraction = getQsExpansionFraction();
mQs.setQsExpansion(qsExpansionFraction, getHeaderTranslation());
mMediaHierarchyManager.setQsExpansion(qsExpansionFraction);
- mNotificationStackScroller.setQsExpansionFraction(qsExpansionFraction);
+ mNotificationStackScrollLayoutController.setQsExpansionFraction(qsExpansionFraction);
}
private String determineAccessibilityPaneTitle() {
@@ -1785,18 +1812,18 @@
return mClockPositionResult.stackScrollerPadding;
}
int collapsedPosition = mHeadsUpInset;
- if (!mNotificationStackScroller.isPulseExpanding()) {
+ if (!mNotificationStackScrollLayoutController.isPulseExpanding()) {
return collapsedPosition;
} else {
int expandedPosition = mClockPositionResult.stackScrollerPadding;
return (int) MathUtils.lerp(collapsedPosition, expandedPosition,
- mNotificationStackScroller.calculateAppearFractionBypass());
+ mNotificationStackScrollLayoutController.calculateAppearFractionBypass());
}
}
protected void requestScrollerTopPaddingUpdate(boolean animate) {
- mNotificationStackScroller.updateTopPadding(calculateQsTopPadding(), animate);
+ mNotificationStackScrollLayoutController.updateTopPadding(calculateQsTopPadding(), animate);
if (mKeyguardShowing && mKeyguardBypassController.getBypassEnabled()) {
// update the position of the header
updateQsExpansion();
@@ -1808,7 +1835,7 @@
if (mQs != null) {
mQs.setShowCollapsedOnKeyguard(
mKeyguardShowing && mKeyguardBypassController.getBypassEnabled()
- && mNotificationStackScroller.isPulseExpanding());
+ && mNotificationStackScrollLayoutController.isPulseExpanding());
}
}
@@ -1904,7 +1931,7 @@
public void onAnimationEnd(Animator animation) {
mAnimatingQS = false;
notifyExpandingFinished();
- mNotificationStackScroller.resetCheckSnoozeLeavebehind();
+ mNotificationStackScrollLayoutController.resetCheckSnoozeLeavebehind();
mQsExpansionAnimator = null;
if (onFinishRunnable != null) {
onFinishRunnable.run();
@@ -1943,8 +1970,8 @@
protected boolean canCollapsePanelOnTouch() {
if (!isInSettings()) {
return mBarState == StatusBarState.KEYGUARD
- || mNotificationStackScroller.isScrolledToBottom()
- || mIsPanelCollapseOnQQS;
+ || mIsPanelCollapseOnQQS
+ || mNotificationStackScrollLayoutController.isScrolledToBottom();
} else {
return true;
}
@@ -1962,7 +1989,7 @@
private int getMaxPanelHeightNonBypass() {
int min = mStatusBarMinHeight;
if (!(mBarState == StatusBarState.KEYGUARD)
- && mNotificationStackScroller.getNotGoneChildCount() == 0) {
+ && mNotificationStackScrollLayoutController.getNotGoneChildCount() == 0) {
int minHeight = (int) (mQsMinExpansionHeight + getOverExpansionAmount());
min = Math.max(min, minHeight);
}
@@ -1988,7 +2015,7 @@
int position =
mClockPositionAlgorithm.getExpandedClockPosition()
+ mKeyguardStatusView.getHeight();
- if (mNotificationStackScroller.getVisibleNotificationCount() != 0) {
+ if (mNotificationStackScrollLayoutController.getVisibleNotificationCount() != 0) {
position += mShelfHeight / 2.0f + mDarkIconSize / 2.0f;
}
return position;
@@ -2027,8 +2054,8 @@
// minimum QS expansion + minStackHeight
float
panelHeightQsCollapsed =
- mNotificationStackScroller.getIntrinsicPadding()
- + mNotificationStackScroller.getLayoutMinHeight();
+ mNotificationStackScrollLayoutController.getIntrinsicPadding()
+ + mNotificationStackScrollLayoutController.getLayoutMinHeight();
float panelHeightQsExpanded = calculatePanelHeightQsExpanded();
t =
(expandedHeight - panelHeightQsCollapsed) / (panelHeightQsExpanded
@@ -2060,16 +2087,16 @@
}
private int calculatePanelHeightShade() {
- int emptyBottomMargin = mNotificationStackScroller.getEmptyBottomMargin();
- int maxHeight = mNotificationStackScroller.getHeight() - emptyBottomMargin;
- maxHeight += mNotificationStackScroller.getTopPaddingOverflow();
+ int emptyBottomMargin = mNotificationStackScrollLayoutController.getEmptyBottomMargin();
+ int maxHeight = mNotificationStackScrollLayoutController.getHeight() - emptyBottomMargin;
+ maxHeight += mNotificationStackScrollLayoutController.getTopPaddingOverflow();
if (mBarState == StatusBarState.KEYGUARD) {
int
minKeyguardPanelBottom =
mClockPositionAlgorithm.getExpandedClockPosition()
+ mKeyguardStatusView.getHeight()
- + mNotificationStackScroller.getIntrinsicContentHeight();
+ + mNotificationStackScrollLayoutController.getIntrinsicContentHeight();
return Math.max(maxHeight, minKeyguardPanelBottom);
} else {
return maxHeight;
@@ -2079,15 +2106,16 @@
private int calculatePanelHeightQsExpanded() {
float
notificationHeight =
- mNotificationStackScroller.getHeight()
- - mNotificationStackScroller.getEmptyBottomMargin()
- - mNotificationStackScroller.getTopPadding();
+ mNotificationStackScrollLayoutController.getHeight()
+ - mNotificationStackScrollLayoutController.getEmptyBottomMargin()
+ - mNotificationStackScrollLayoutController.getTopPadding();
// When only empty shade view is visible in QS collapsed state, simulate that we would have
// it in expanded QS state as well so we don't run into troubles when fading the view in/out
// and expanding/collapsing the whole panel from/to quick settings.
- if (mNotificationStackScroller.getNotGoneChildCount() == 0 && mShowEmptyShadeView) {
- notificationHeight = mNotificationStackScroller.getEmptyShadeViewHeight();
+ if (mNotificationStackScrollLayoutController.getNotGoneChildCount() == 0
+ && mShowEmptyShadeView) {
+ notificationHeight = mNotificationStackScrollLayoutController.getEmptyShadeViewHeight();
}
int maxQsHeight = mQsMaxExpansionHeight;
@@ -2102,12 +2130,13 @@
float totalHeight = Math.max(maxQsHeight,
mBarState == StatusBarState.KEYGUARD ? mClockPositionResult.stackScrollerPadding
: 0) + notificationHeight
- + mNotificationStackScroller.getTopPaddingOverflow();
- if (totalHeight > mNotificationStackScroller.getHeight()) {
+ + mNotificationStackScrollLayoutController.getTopPaddingOverflow();
+ if (totalHeight > mNotificationStackScrollLayoutController.getHeight()) {
float
fullyCollapsedHeight =
- maxQsHeight + mNotificationStackScroller.getLayoutMinHeight();
- totalHeight = Math.max(fullyCollapsedHeight, mNotificationStackScroller.getHeight());
+ maxQsHeight + mNotificationStackScrollLayoutController.getLayoutMinHeight();
+ totalHeight = Math.max(fullyCollapsedHeight,
+ mNotificationStackScrollLayoutController.getHeight());
}
return (int) totalHeight;
}
@@ -2122,7 +2151,7 @@
&& !mKeyguardBypassController.getBypassEnabled()) {
alpha *= mClockPositionResult.clockAlpha;
}
- mNotificationStackScroller.setAlpha(alpha);
+ mNotificationStackScrollLayoutController.setAlpha(alpha);
}
private float getFadeoutAlpha() {
@@ -2138,7 +2167,8 @@
@Override
protected float getOverExpansionAmount() {
- float result = mNotificationStackScroller.getCurrentOverScrollAmount(true /* top */);
+ float result = mNotificationStackScrollLayoutController
+ .getCurrentOverScrollAmount(true /* top */);
if (isNaN(result)) {
Log.wtf(TAG, "OverExpansionAmount is NaN!");
}
@@ -2148,7 +2178,8 @@
@Override
protected float getOverExpansionPixels() {
- return mNotificationStackScroller.getCurrentOverScrolledPixels(true /* top */);
+ return mNotificationStackScrollLayoutController
+ .getCurrentOverScrolledPixels(true /* top */);
}
/**
@@ -2165,17 +2196,19 @@
if (mBarState == StatusBarState.KEYGUARD && !mKeyguardBypassController.getBypassEnabled()) {
return -mQs.getQsMinExpansionHeight();
}
- float appearAmount = mNotificationStackScroller.calculateAppearFraction(mExpandedHeight);
+ float appearAmount = mNotificationStackScrollLayoutController
+ .calculateAppearFraction(mExpandedHeight);
float startHeight = -mQsExpansionHeight;
if (mKeyguardBypassController.getBypassEnabled() && isOnKeyguard()
- && mNotificationStackScroller.isPulseExpanding()) {
+ && mNotificationStackScrollLayoutController.isPulseExpanding()) {
if (!mPulseExpansionHandler.isExpanding()
&& !mPulseExpansionHandler.getLeavingLockscreen()) {
// If we aborted the expansion we need to make sure the header doesn't reappear
// again after the header has animated away
appearAmount = 0;
} else {
- appearAmount = mNotificationStackScroller.calculateAppearFractionBypass();
+ appearAmount = mNotificationStackScrollLayoutController
+ .calculateAppearFractionBypass();
}
startHeight = -mQs.getQsMinExpansionHeight();
}
@@ -2264,7 +2297,7 @@
@Override
protected void onExpandingStarted() {
super.onExpandingStarted();
- mNotificationStackScroller.onExpansionStarted();
+ mNotificationStackScrollLayoutController.onExpansionStarted();
mIsExpanding = true;
mQsExpandedWhenExpandingStarted = mQsFullyExpanded;
mMediaHierarchyManager.setCollapsingShadeFromQS(mQsExpandedWhenExpandingStarted &&
@@ -2282,7 +2315,7 @@
@Override
protected void onExpandingFinished() {
super.onExpandingFinished();
- mNotificationStackScroller.onExpansionStopped();
+ mNotificationStackScrollLayoutController.onExpansionStopped();
mHeadsUpManager.onExpandingFinished();
mConversationNotificationManager.onNotificationPanelExpandStateChanged(isFullyCollapsed());
mIsExpanding = false;
@@ -2308,7 +2341,7 @@
setListening(true);
}
mQsExpandImmediate = false;
- mNotificationStackScroller.setShouldShowShelfOnly(false);
+ mNotificationStackScrollLayoutController.setShouldShowShelfOnly(false);
mTwoFingerQsExpandPossible = false;
notifyListenersTrackingHeadsUp(null);
mExpandingFromHeadsUp = false;
@@ -2340,15 +2373,16 @@
return;
}
if (mBarState != StatusBarState.KEYGUARD) {
- mNotificationStackScroller.setOnHeightChangedListener(null);
+ mNotificationStackScrollLayoutController.setOnHeightChangedListener(null);
if (isPixels) {
- mNotificationStackScroller.setOverScrolledPixels(overExpansion, true /* onTop */,
- false /* animate */);
+ mNotificationStackScrollLayoutController.setOverScrolledPixels(
+ overExpansion, true /* onTop */, false /* animate */);
} else {
- mNotificationStackScroller.setOverScrollAmount(overExpansion, true /* onTop */,
- false /* animate */);
+ mNotificationStackScrollLayoutController.setOverScrollAmount(
+ overExpansion, true /* onTop */, false /* animate */);
}
- mNotificationStackScroller.setOnHeightChangedListener(mOnHeightChangedListener);
+ mNotificationStackScrollLayoutController
+ .setOnHeightChangedListener(mOnHeightChangedListener);
}
}
@@ -2358,12 +2392,12 @@
super.onTrackingStarted();
if (mQsFullyExpanded) {
mQsExpandImmediate = true;
- mNotificationStackScroller.setShouldShowShelfOnly(true);
+ mNotificationStackScrollLayoutController.setShouldShowShelfOnly(true);
}
if (mBarState == StatusBarState.KEYGUARD || mBarState == StatusBarState.SHADE_LOCKED) {
mAffordanceHelper.animateHideLeftRightIcon();
}
- mNotificationStackScroller.onPanelTrackingStarted();
+ mNotificationStackScrollLayoutController.onPanelTrackingStarted();
}
@Override
@@ -2371,10 +2405,10 @@
mFalsingManager.onTrackingStopped();
super.onTrackingStopped(expand);
if (expand) {
- mNotificationStackScroller.setOverScrolledPixels(0.0f, true /* onTop */,
+ mNotificationStackScrollLayoutController.setOverScrolledPixels(0.0f, true /* onTop */,
true /* animate */);
}
- mNotificationStackScroller.onPanelTrackingStopped();
+ mNotificationStackScrollLayoutController.onPanelTrackingStopped();
if (expand && (mBarState == StatusBarState.KEYGUARD
|| mBarState == StatusBarState.SHADE_LOCKED)) {
if (!mHintAnimationRunning) {
@@ -2384,7 +2418,8 @@
}
private void updateMaxHeadsUpTranslation() {
- mNotificationStackScroller.setHeadsUpBoundaries(getHeight(), mNavigationBarBottomHeight);
+ mNotificationStackScrollLayoutController.setHeadsUpBoundaries(
+ getHeight(), mNavigationBarBottomHeight);
}
@Override
@@ -2400,19 +2435,19 @@
@Override
protected void onUnlockHintFinished() {
super.onUnlockHintFinished();
- mNotificationStackScroller.setUnlockHintRunning(false);
+ mNotificationStackScrollLayoutController.setUnlockHintRunning(false);
}
@Override
protected void onUnlockHintStarted() {
super.onUnlockHintStarted();
- mNotificationStackScroller.setUnlockHintRunning(true);
+ mNotificationStackScrollLayoutController.setUnlockHintRunning(true);
}
@Override
protected float getPeekHeight() {
- if (mNotificationStackScroller.getNotGoneChildCount() > 0) {
- return mNotificationStackScroller.getPeekHeight();
+ if (mNotificationStackScrollLayoutController.getNotGoneChildCount() > 0) {
+ return mNotificationStackScrollLayoutController.getPeekHeight();
} else {
return mQsMinExpansionHeight;
}
@@ -2426,7 +2461,8 @@
}
// Let's make sure we're not appearing but the animation will end below the appear.
// Otherwise quick settings would jump at the end of the animation.
- float fraction = mNotificationStackScroller.calculateAppearFraction(targetHeight);
+ float fraction = mNotificationStackScrollLayoutController
+ .calculateAppearFraction(targetHeight);
return fraction >= 1.0f;
}
@@ -2438,18 +2474,19 @@
@Override
protected boolean fullyExpandedClearAllVisible() {
- return mNotificationStackScroller.isFooterViewNotGone()
- && mNotificationStackScroller.isScrolledToBottom() && !mQsExpandImmediate;
+ return mNotificationStackScrollLayoutController.isFooterViewNotGone()
+ && mNotificationStackScrollLayoutController.isScrolledToBottom()
+ && !mQsExpandImmediate;
}
@Override
protected boolean isClearAllVisible() {
- return mNotificationStackScroller.isFooterViewContentVisible();
+ return mNotificationStackScrollLayoutController.isFooterViewContentVisible();
}
@Override
protected int getClearAllHeightWithPadding() {
- return mNotificationStackScroller.getFooterViewHeightWithPadding();
+ return mNotificationStackScrollLayoutController.getFooterViewHeightWithPadding();
}
@Override
@@ -2500,7 +2537,8 @@
private void updateEmptyShadeView() {
// Hide "No notifications" in QS.
- mNotificationStackScroller.updateEmptyShadeView(mShowEmptyShadeView && !mQsExpanded);
+ mNotificationStackScrollLayoutController.updateEmptyShadeView(
+ mShowEmptyShadeView && !mQsExpanded);
}
public void setQsScrimEnabled(boolean qsScrimEnabled) {
@@ -2591,7 +2629,7 @@
public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
mHeadsUpAnimatingAway = headsUpAnimatingAway;
- mNotificationStackScroller.setHeadsUpAnimatingAway(headsUpAnimatingAway);
+ mNotificationStackScrollLayoutController.setHeadsUpAnimatingAway(headsUpAnimatingAway);
updateHeadsUpVisibility();
}
@@ -2603,7 +2641,7 @@
public void setHeadsUpManager(HeadsUpManagerPhone headsUpManager) {
super.setHeadsUpManager(headsUpManager);
mHeadsUpTouchHelper = new HeadsUpTouchHelper(headsUpManager,
- mNotificationStackScroller.getHeadsUpCallback(),
+ mNotificationStackScrollLayoutController.getHeadsUpCallback(),
NotificationPanelViewController.this);
}
@@ -2625,7 +2663,7 @@
private void setClosingWithAlphaFadeout(boolean closing) {
mClosingWithAlphaFadeOut = closing;
- mNotificationStackScroller.forceNoOverlappingRendering(closing);
+ mNotificationStackScrollLayoutController.forceNoOverlappingRendering(closing);
}
/**
@@ -2635,22 +2673,24 @@
* @param x the x-coordinate the touch event
*/
protected void updateVerticalPanelPosition(float x) {
- if (mNotificationStackScroller.getWidth() * 1.75f > mView.getWidth()) {
+ if (mNotificationStackScrollLayoutController.getWidth() * 1.75f > mView.getWidth()) {
resetHorizontalPanelPosition();
return;
}
- float leftMost = mPositionMinSideMargin + mNotificationStackScroller.getWidth() / 2;
+ float leftMost = mPositionMinSideMargin
+ + mNotificationStackScrollLayoutController.getWidth() / 2;
float
rightMost =
mView.getWidth() - mPositionMinSideMargin
- - mNotificationStackScroller.getWidth() / 2;
- if (Math.abs(x - mView.getWidth() / 2) < mNotificationStackScroller.getWidth() / 4) {
+ - mNotificationStackScrollLayoutController.getWidth() / 2;
+ if (Math.abs(x - mView.getWidth() / 2)
+ < mNotificationStackScrollLayoutController.getWidth() / 4) {
x = mView.getWidth() / 2;
}
x = Math.min(rightMost, Math.max(leftMost, x));
float
- center =
- mNotificationStackScroller.getLeft() + mNotificationStackScroller.getWidth() / 2;
+ center = mNotificationStackScrollLayoutController.getLeft()
+ + mNotificationStackScrollLayoutController.getWidth() / 2;
setHorizontalPanelTranslation(x - center);
}
@@ -2659,7 +2699,7 @@
}
protected void setHorizontalPanelTranslation(float translation) {
- mNotificationStackScroller.setTranslationX(translation);
+ mNotificationStackScrollLayoutController.setTranslationX(translation);
mQsFrame.setTranslationX(translation);
int size = mVerticalTranslationListener.size();
for (int i = 0; i < size; i++) {
@@ -2669,13 +2709,14 @@
protected void updateExpandedHeight(float expandedHeight) {
if (mTracking) {
- mNotificationStackScroller.setExpandingVelocity(getCurrentExpandVelocity());
+ mNotificationStackScrollLayoutController
+ .setExpandingVelocity(getCurrentExpandVelocity());
}
if (mKeyguardBypassController.getBypassEnabled() && isOnKeyguard()) {
// The expandedHeight is always the full panel Height when bypassing
expandedHeight = getMaxPanelHeightNonBypass();
}
- mNotificationStackScroller.setExpandedHeight(expandedHeight);
+ mNotificationStackScrollLayoutController.setExpandedHeight(expandedHeight);
updateKeyguardBottomAreaAlpha();
updateBigClockAlpha();
updateStatusBarIcons();
@@ -2835,7 +2876,7 @@
mHeightListener.onQsHeightChanged();
}
});
- mNotificationStackScroller.setQsContainer((ViewGroup) mQs.getView());
+ mNotificationStackScrollLayoutController.setQsContainer((ViewGroup) mQs.getView());
if (mQs instanceof QSFragment) {
mKeyguardStatusBar.setQSPanel(((QSFragment) mQs).getQsPanel());
}
@@ -2859,7 +2900,7 @@
if (disabled && mAffordanceHelper.isSwipingInProgress() && !mIsLaunchTransitionRunning) {
mAffordanceHelper.reset(false /* animate */);
}
- mNotificationStackScroller.setAnimationsEnabled(!disabled);
+ mNotificationStackScrollLayoutController.setAnimationsEnabled(!disabled);
}
/**
@@ -2873,7 +2914,7 @@
if (dozing == mDozing) return;
mView.setDozing(dozing);
mDozing = dozing;
- mNotificationStackScroller.setDozing(mDozing, animate, wakeUpTouchLocation);
+ mNotificationStackScrollLayoutController.setDozing(mDozing, animate, wakeUpTouchLocation);
mKeyguardBottomArea.setDozing(mDozing, animate);
if (dozing) {
@@ -2901,7 +2942,7 @@
if (!mPulsing && !mDozing) {
mAnimateNextPositionUpdate = false;
}
- mNotificationStackScroller.setPulsing(pulsing, animatePulse);
+ mNotificationStackScrollLayoutController.setPulsing(pulsing, animatePulse);
mKeyguardStatusView.setPulsing(pulsing);
}
@@ -3006,7 +3047,7 @@
}
public boolean hasActiveClearableNotifications() {
- return mNotificationStackScroller.hasActiveClearableNotifications(ROWS_ALL);
+ return mNotificationStackScrollLayoutController.hasActiveClearableNotifications(ROWS_ALL);
}
private void updateShowEmptyShadeView() {
@@ -3017,54 +3058,56 @@
}
public RemoteInputController.Delegate createRemoteInputDelegate() {
- return mNotificationStackScroller.createDelegate();
+ return mNotificationStackScrollLayoutController.createDelegate();
}
void updateNotificationViews(String reason) {
- mNotificationStackScroller.updateSectionBoundaries(reason);
- mNotificationStackScroller.updateSpeedBumpIndex();
- mNotificationStackScroller.updateFooter();
+ mNotificationStackScrollLayoutController.updateSectionBoundaries(reason);
+ mNotificationStackScrollLayoutController.updateSpeedBumpIndex();
+ mNotificationStackScrollLayoutController.updateFooter();
updateShowEmptyShadeView();
- mNotificationStackScroller.updateIconAreaViews();
+ mNotificationStackScrollLayoutController.updateIconAreaViews();
}
public void onUpdateRowStates() {
- mNotificationStackScroller.onUpdateRowStates();
+ mNotificationStackScrollLayoutController.onUpdateRowStates();
}
public boolean hasPulsingNotifications() {
- return mNotificationStackScroller.hasPulsingNotifications();
+ return mNotificationStackScrollLayoutController.hasPulsingNotifications();
}
public ActivatableNotificationView getActivatedChild() {
- return mNotificationStackScroller.getActivatedChild();
+ return mNotificationStackScrollLayoutController.getActivatedChild();
}
public void setActivatedChild(ActivatableNotificationView o) {
- mNotificationStackScroller.setActivatedChild(o);
+ mNotificationStackScrollLayoutController.setActivatedChild(o);
}
public void runAfterAnimationFinished(Runnable r) {
- mNotificationStackScroller.runAfterAnimationFinished(r);
+ mNotificationStackScrollLayoutController.runAfterAnimationFinished(r);
}
public void setScrollingEnabled(boolean b) {
- mNotificationStackScroller.setScrollingEnabled(b);
+ mNotificationStackScrollLayoutController.setScrollingEnabled(b);
}
public void initDependencies(StatusBar statusBar, NotificationGroupManager groupManager,
- NotificationShelf notificationShelf,
+ NotificationShelfController notificationShelfController,
NotificationIconAreaController notificationIconAreaController,
ScrimController scrimController) {
setStatusBar(statusBar);
setGroupManager(mGroupManager);
- mNotificationStackScroller.setNotificationPanelController(this);
- mNotificationStackScroller.setIconAreaController(notificationIconAreaController);
- mNotificationStackScroller.setStatusBar(statusBar);
- mNotificationStackScroller.setGroupManager(groupManager);
- mNotificationStackScroller.setShelf(notificationShelf);
- mNotificationStackScroller.setScrimController(scrimController);
+ mNotificationStackScrollLayoutController.setNotificationPanelController(this);
+ mNotificationStackScrollLayoutController
+ .setIconAreaController(notificationIconAreaController);
+ mNotificationStackScrollLayoutController.setStatusBar(statusBar);
+ mNotificationStackScrollLayoutController.setGroupManager(groupManager);
+ mNotificationStackScrollLayoutController.setShelfController(notificationShelfController);
+ mNotificationStackScrollLayoutController.setScrimController(scrimController);
updateShowEmptyShadeView();
+ mNotificationShelfController = notificationShelfController;
}
public void showTransientIndication(int id) {
@@ -3228,7 +3271,8 @@
if (needsAnimation && mInterpolatedDarkAmount == 0) {
mAnimateNextPositionUpdate = true;
}
- ExpandableView firstChildNotGone = mNotificationStackScroller.getFirstChildNotGone();
+ ExpandableView firstChildNotGone =
+ mNotificationStackScrollLayoutController.getFirstChildNotGone();
ExpandableNotificationRow
firstRow =
firstChildNotGone instanceof ExpandableNotificationRow
@@ -3454,13 +3498,13 @@
private class MyOnHeadsUpChangedListener implements OnHeadsUpChangedListener {
@Override
public void onHeadsUpPinnedModeChanged(final boolean inPinnedMode) {
- mNotificationStackScroller.setInHeadsUpPinnedMode(inPinnedMode);
+ mNotificationStackScrollLayoutController.setInHeadsUpPinnedMode(inPinnedMode);
if (inPinnedMode) {
mHeadsUpExistenceChangedRunnable.run();
updateNotificationTranslucency();
} else {
setHeadsUpAnimatingAway(true);
- mNotificationStackScroller.runAfterAnimationFinished(
+ mNotificationStackScrollLayoutController.runAfterAnimationFinished(
mHeadsUpExistenceChangedRunnable);
}
updateGestureExclusionRect();
@@ -3472,8 +3516,8 @@
@Override
public void onHeadsUpPinned(NotificationEntry entry) {
if (!isOnKeyguard()) {
- mNotificationStackScroller.generateHeadsUpAnimation(entry.getHeadsUpAnimationView(),
- true);
+ mNotificationStackScrollLayoutController.generateHeadsUpAnimation(
+ entry.getHeadsUpAnimationView(), true);
}
}
@@ -3485,7 +3529,7 @@
// notification
// will stick to the top without any interaction.
if (isFullyCollapsed() && entry.isRowHeadsUp() && !isOnKeyguard()) {
- mNotificationStackScroller.generateHeadsUpAnimation(
+ mNotificationStackScrollLayoutController.generateHeadsUpAnimation(
entry.getHeadsUpAnimationView(), false);
entry.setHeadsUpIsVisible();
}
@@ -3493,7 +3537,7 @@
@Override
public void onHeadsUpStateChanged(NotificationEntry entry, boolean isHeadsUp) {
- mNotificationStackScroller.generateHeadsUpAnimation(entry, isHeadsUp);
+ mNotificationStackScrollLayoutController.generateHeadsUpAnimation(entry, isHeadsUp);
}
}
@@ -3508,7 +3552,7 @@
if (mAccessibilityManager.isEnabled()) {
mView.setAccessibilityPaneTitle(determineAccessibilityPaneTitle());
}
- mNotificationStackScroller.setMaxTopPadding(
+ mNotificationStackScrollLayoutController.setMaxTopPadding(
mQsMaxExpansionHeight + mQsNotificationTopPadding);
}
}
@@ -3570,7 +3614,7 @@
} else if (oldState == StatusBarState.SHADE_LOCKED
&& statusBarState == StatusBarState.KEYGUARD) {
animateKeyguardStatusBarIn(StackStateAnimator.ANIMATION_DURATION_STANDARD);
- mNotificationStackScroller.resetScrollPosition();
+ mNotificationStackScrollLayoutController.resetScrollPosition();
// Only animate header if the header is visible. If not, it will partially
// animate out
// the top of QS
@@ -3646,7 +3690,7 @@
int oldTop, int oldRight, int oldBottom) {
DejankUtils.startDetectingBlockingIpcs("NVP#onLayout");
super.onLayoutChange(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom);
- setIsFullWidth(mNotificationStackScroller.getWidth() == mView.getWidth());
+ setIsFullWidth(mNotificationStackScrollLayoutController.getWidth() == mView.getWidth());
// Update Clock Pivot
mKeyguardStatusView.setPivotX(mView.getWidth() / 2);
@@ -3662,7 +3706,7 @@
mQsExpansionHeight = mQsMinExpansionHeight;
}
mQsMaxExpansionHeight = mQs.getDesiredHeight();
- mNotificationStackScroller.setMaxTopPadding(
+ mNotificationStackScrollLayoutController.setMaxTopPadding(
mQsMaxExpansionHeight + mQsNotificationTopPadding);
}
positionClockAndNotifications();
@@ -3724,7 +3768,7 @@
0, calculateQsTopPadding(), mView.getWidth(), calculateQsTopPadding(), p);
p.setColor(Color.CYAN);
canvas.drawLine(0, mClockPositionResult.stackScrollerPadding, mView.getWidth(),
- mNotificationStackScroller.getTopPadding(), p);
+ mNotificationStackScrollLayoutController.getTopPadding(), p);
p.setColor(Color.GRAY);
canvas.drawLine(0, mClockPositionResult.clockY, mView.getWidth(),
mClockPositionResult.clockY, p);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
index 8cb54ee..e42c3dc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -284,13 +284,22 @@
mResources.getString(R.string.accessibility_data_saver_on));
mIconController.setIconVisibility(mSlotDataSaver, false);
+
// privacy items
+ String microphoneString = mResources.getString(PrivacyType.TYPE_MICROPHONE.getNameId());
+ String microphoneDesc = mResources.getString(
+ R.string.ongoing_privacy_chip_content_multiple_apps, microphoneString);
mIconController.setIcon(mSlotMicrophone, PrivacyType.TYPE_MICROPHONE.getIconId(),
- mResources.getString(PrivacyType.TYPE_MICROPHONE.getNameId()));
+ microphoneDesc);
mIconController.setIconVisibility(mSlotMicrophone, false);
+
+ String cameraString = mResources.getString(PrivacyType.TYPE_CAMERA.getNameId());
+ String cameraDesc = mResources.getString(
+ R.string.ongoing_privacy_chip_content_multiple_apps, cameraString);
mIconController.setIcon(mSlotCamera, PrivacyType.TYPE_CAMERA.getIconId(),
- mResources.getString(PrivacyType.TYPE_CAMERA.getNameId()));
+ cameraDesc);
mIconController.setIconVisibility(mSlotCamera, false);
+
mIconController.setIcon(mSlotLocation, LOCATION_STATUS_ICON_ID,
mResources.getString(R.string.accessibility_location_active));
mIconController.setIconVisibility(mSlotLocation, false);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButton.java
index 687efd3..74d4eb1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButton.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButton.java
@@ -20,9 +20,12 @@
import com.android.systemui.statusbar.policy.KeyButtonDrawable;
+import java.util.function.Consumer;
+
/** Interface of a rotation button that interacts {@link RotationButtonController}. */
interface RotationButton {
void setRotationButtonController(RotationButtonController rotationButtonController);
+ void setVisibilityChangedCallback(Consumer<Boolean> visibilityChangedCallback);
View getCurrentView();
boolean show();
boolean hide();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButtonController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButtonController.java
index b0630a6..2f2e1f9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButtonController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButtonController.java
@@ -124,7 +124,8 @@
}
RotationButtonController(Context context, @ColorInt int lightIconColor,
- @ColorInt int darkIconColor, RotationButton rotationButton) {
+ @ColorInt int darkIconColor, RotationButton rotationButton,
+ Consumer<Boolean> visibilityChangedCallback) {
mContext = context;
mLightIconColor = lightIconColor;
mDarkIconColor = darkIconColor;
@@ -139,6 +140,7 @@
mTaskStackListener = new TaskStackListenerImpl();
mRotationButton.setOnClickListener(this::onRotateSuggestionClick);
mRotationButton.setOnHoverListener(this::onRotateSuggestionHover);
+ mRotationButton.setVisibilityChangedCallback(visibilityChangedCallback);
}
void registerListeners() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationContextButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationContextButton.java
index 08aeb04..d63d445 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationContextButton.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationContextButton.java
@@ -23,6 +23,8 @@
import com.android.systemui.statusbar.policy.KeyButtonDrawable;
+import java.util.function.Consumer;
+
/** Containing logic for the rotation button in nav bar. */
public class RotationContextButton extends ContextualButton implements RotationButton {
public static final boolean DEBUG_ROTATION = false;
@@ -43,6 +45,18 @@
}
@Override
+ public void setVisibilityChangedCallback(Consumer<Boolean> visibilityChangedCallback) {
+ setListener(new ContextButtonListener() {
+ @Override
+ public void onVisibilityChanged(ContextualButton button, boolean visible) {
+ if (visibilityChangedCallback != null) {
+ visibilityChangedCallback.accept(visible);
+ }
+ }
+ });
+ }
+
+ @Override
public void setVisibility(int visibility) {
super.setVisibility(visibility);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index eb62628..6cd33c6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -179,7 +179,6 @@
import com.android.systemui.statusbar.BackDropView;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.CrossFadeHelper;
-import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.KeyboardShortcuts;
import com.android.systemui.statusbar.KeyguardIndicationController;
@@ -189,7 +188,7 @@
import com.android.systemui.statusbar.NotificationPresenter;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationShadeDepthController;
-import com.android.systemui.statusbar.NotificationShelf;
+import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.NotificationViewHierarchyManager;
import com.android.systemui.statusbar.PulseExpansionHandler;
import com.android.systemui.statusbar.ScrimView;
@@ -210,6 +209,7 @@
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
+import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule;
import com.android.systemui.statusbar.policy.BatteryController;
@@ -1029,7 +1029,7 @@
mStatusBarStateController);
mWakeUpCoordinator.setIconAreaController(mNotificationIconAreaController);
inflateShelf();
- mNotificationIconAreaController.setupShelf(mNotificationShelf);
+ mNotificationIconAreaController.setupShelf(mNotificationShelfController);
mNotificationPanelViewController.setOnReinflationListener(
mNotificationIconAreaController::initAodIcons);
mNotificationPanelViewController.addExpansionListener(mWakeUpCoordinator);
@@ -1076,7 +1076,7 @@
// TODO (b/136993073) Separate notification shade and status bar
mHeadsUpAppearanceController = new HeadsUpAppearanceController(
mNotificationIconAreaController, mHeadsUpManager,
- mNotificationShadeWindowView,
+ mStackScroller.getController(),
mStatusBarStateController, mKeyguardBypassController,
mKeyguardStateController, mWakeUpCoordinator, mCommandQueue,
mNotificationPanelViewController, mStatusBarView);
@@ -1147,7 +1147,8 @@
});
mScrimController.attachViews(scrimBehind, scrimInFront, scrimForBubble);
- mNotificationPanelViewController.initDependencies(this, mGroupManager, mNotificationShelf,
+ mNotificationPanelViewController.initDependencies(this, mGroupManager,
+ mNotificationShelfController,
mNotificationIconAreaController, mScrimController);
BackDropView backdrop = mNotificationShadeWindowView.findViewById(R.id.backdrop);
@@ -1310,7 +1311,7 @@
this /* statusBar */, mShadeController, mCommandQueue, mInitController,
mNotificationInterruptStateProvider);
- mNotificationShelf.setOnActivatedListener(mPresenter);
+ mNotificationShelfController.setOnActivatedListener(mPresenter);
mRemoteInputManager.getController().addCallback(mNotificationShadeWindowController);
mNotificationActivityStarter =
@@ -1386,8 +1387,9 @@
}
private void inflateShelf() {
- mNotificationShelf = mSuperStatusBarViewFactory.getNotificationShelf(mStackScroller);
- mNotificationShelf.setOnClickListener(mGoToLockedShadeListener);
+ mNotificationShelfController = mSuperStatusBarViewFactory
+ .getNotificationShelfController(mStackScroller);
+ mNotificationShelfController.setOnClickListener(mGoToLockedShadeListener);
}
@Override
@@ -4049,7 +4051,7 @@
protected IStatusBarService mBarService;
// all notifications
- protected ViewGroup mStackScroller;
+ protected NotificationStackScrollLayout mStackScroller;
private final NotificationGroupManager mGroupManager;
@@ -4085,8 +4087,7 @@
private final Optional<Recents> mRecentsOptional;
- protected NotificationShelf mNotificationShelf;
- protected EmptyShadeView mEmptyShadeView;
+ protected NotificationShelfController mNotificationShelfController;
private final Lazy<AssistManager> mAssistManagerLazy;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallback.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallback.java
index 72395e6..ac69d9c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallback.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallback.java
@@ -244,9 +244,10 @@
@Override
public boolean handleRemoteViewClick(View view, PendingIntent pendingIntent,
+ boolean appRequestedAuth,
NotificationRemoteInputManager.ClickHandler defaultHandler) {
final boolean isActivity = pendingIntent.isActivity();
- if (isActivity) {
+ if (isActivity || appRequestedAuth) {
mActionClickLogger.logWaitingToCloseKeyguard(pendingIntent);
final boolean afterKeyguardGone = mActivityIntentHelper.wouldLaunchResolverActivity(
pendingIntent.getIntent(), mLockscreenUserManager.getCurrentUserId());
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/AudioActivityObserver.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/AudioActivityObserver.java
index 87b3956..bbab625 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/AudioActivityObserver.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/AudioActivityObserver.java
@@ -40,5 +40,9 @@
mListener = listener;
}
+ abstract void start();
+
+ abstract void stop();
+
abstract Set<String> getActivePackages();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/AudioRecordingDisclosureBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/AudioRecordingDisclosureBar.java
index 8e4e123..e3eed35 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/AudioRecordingDisclosureBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/AudioRecordingDisclosureBar.java
@@ -22,12 +22,12 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
-import android.animation.PropertyValuesHolder;
import android.annotation.IntDef;
import android.annotation.UiThread;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.database.ContentObserver;
import android.graphics.PixelFormat;
import android.provider.Settings;
import android.text.TextUtils;
@@ -65,11 +65,13 @@
// CtsSystemUiHostTestCases:TvMicrophoneCaptureIndicatorTest
private static final String LAYOUT_PARAMS_TITLE = "MicrophoneCaptureIndicator";
+ private static final String ENABLE_FLAG = "sysui_mic_disclosure_enable";
private static final String EXEMPT_PACKAGES_LIST = "sysui_mic_disclosure_exempt";
private static final String FORCED_PACKAGES_LIST = "sysui_mic_disclosure_forced";
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"STATE_"}, value = {
+ STATE_STOPPED,
STATE_NOT_SHOWN,
STATE_APPEARING,
STATE_SHOWN,
@@ -80,6 +82,7 @@
})
public @interface State {}
+ private static final int STATE_STOPPED = -1;
private static final int STATE_NOT_SHOWN = 0;
private static final int STATE_APPEARING = 1;
private static final int STATE_SHOWN = 2;
@@ -90,10 +93,9 @@
private static final int ANIMATION_DURATION = 600;
private static final int MAXIMIZED_DURATION = 3000;
- private static final int PULSE_BIT_DURATION = 1000;
- private static final float PULSE_SCALE = 1.25f;
private final Context mContext;
+ private boolean mIsEnabledInSettings;
private View mIndicatorView;
private View mIconTextsContainer;
@@ -104,13 +106,13 @@
private TextView mTextView;
private boolean mIsLtr;
- @State private int mState = STATE_NOT_SHOWN;
+ @State private int mState = STATE_STOPPED;
/**
* Array of the observers that monitor different aspects of the system, such as AppOps and
* microphone foreground services
*/
- private final AudioActivityObserver[] mAudioActivityObservers;
+ private AudioActivityObserver[] mAudioActivityObservers;
/**
* Whether the indicator should expand and show the recording application's label.
* If disabled ({@code false}) the "minimized" ({@link #STATE_MINIMIZED}) indicator would appear
@@ -144,6 +146,7 @@
public AudioRecordingDisclosureBar(Context context) {
mContext = context;
+ // Loading configs
mRevealRecordingPackages = mContext.getResources().getBoolean(
R.bool.audio_recording_disclosure_reveal_packages);
mExemptPackages = new ArraySet<>(
@@ -152,10 +155,52 @@
mExemptPackages.addAll(Arrays.asList(getGlobalStringArray(EXEMPT_PACKAGES_LIST)));
mExemptPackages.removeAll(Arrays.asList(getGlobalStringArray(FORCED_PACKAGES_LIST)));
- mAudioActivityObservers = new AudioActivityObserver[]{
- new RecordAudioAppOpObserver(mContext, this),
- new MicrophoneForegroundServicesObserver(mContext, this),
- };
+ // Check setting, and start if enabled
+ mIsEnabledInSettings = checkIfEnabledInSettings();
+ registerSettingsObserver();
+ if (mIsEnabledInSettings) {
+ start();
+ }
+ }
+
+ @UiThread
+ private void start() {
+ if (mState != STATE_STOPPED) {
+ return;
+ }
+ mState = STATE_NOT_SHOWN;
+
+ if (mAudioActivityObservers == null) {
+ mAudioActivityObservers = new AudioActivityObserver[]{
+ new RecordAudioAppOpObserver(mContext, this),
+ new MicrophoneForegroundServicesObserver(mContext, this),
+ };
+ }
+
+ for (int i = mAudioActivityObservers.length - 1; i >= 0; i--) {
+ mAudioActivityObservers[i].start();
+ }
+ }
+
+ @UiThread
+ private void stop() {
+ if (mState == STATE_STOPPED) {
+ return;
+ }
+ mState = STATE_STOPPED;
+
+ for (int i = mAudioActivityObservers.length - 1; i >= 0; i--) {
+ mAudioActivityObservers[i].stop();
+ }
+
+ // Remove the view if shown.
+ if (mState != STATE_NOT_SHOWN) {
+ removeIndicatorView();
+ }
+
+ // Clean up the state.
+ mSessionNotifiedPackages.clear();
+ mPendingNotificationPackages.clear();
}
@UiThread
@@ -213,7 +258,6 @@
@UiThread
private void hideIndicatorIfNeeded() {
- if (DEBUG) Log.d(TAG, "hideIndicatorIfNeeded");
// If not MINIMIZED, will check whether the indicator should be hidden when the indicator
// comes to the STATE_MINIMIZED eventually.
if (mState != STATE_MINIMIZED) return;
@@ -222,7 +266,6 @@
for (int index = mAudioActivityObservers.length - 1; index >= 0; index--) {
for (String activePackage : mAudioActivityObservers[index].getActivePackages()) {
if (mExemptPackages.contains(activePackage)) continue;
- if (DEBUG) Log.d(TAG, " - there are still ongoing activities");
return;
}
}
@@ -235,7 +278,7 @@
@UiThread
private void show(String packageName) {
if (DEBUG) {
- Log.d(TAG, "Showing indicator for " + packageName);
+ Log.d(TAG, "Showing indicator");
}
mIsLtr = mContext.getResources().getConfiguration().getLayoutDirection()
@@ -286,6 +329,10 @@
new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
+ if (mState == STATE_STOPPED) {
+ return;
+ }
+
// Remove the observer
mIndicatorView.getViewTreeObserver().removeOnGlobalLayoutListener(
this);
@@ -306,13 +353,16 @@
@Override
public void onAnimationStart(Animator animation,
boolean isReverse) {
+ if (mState == STATE_STOPPED) {
+ return;
+ }
+
// Indicator is INVISIBLE at the moment, change it.
mIndicatorView.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
- startPulsatingAnimation();
if (mRevealRecordingPackages) {
onExpanded();
} else {
@@ -345,9 +395,6 @@
assertRevealingRecordingPackages();
final String label = getApplicationLabel(packageName);
- if (DEBUG) {
- Log.d(TAG, "Expanding for " + packageName + " (" + label + ")...");
- }
mTextView.setText(mContext.getString(R.string.app_accessed_mic, label));
final AnimatorSet set = new AnimatorSet();
@@ -373,7 +420,6 @@
private void minimize() {
assertRevealingRecordingPackages();
- if (DEBUG) Log.d(TAG, "Minimizing...");
final int targetOffset = (mIsLtr ? 1 : -1) * mTextsContainers.getWidth();
final AnimatorSet set = new AnimatorSet();
set.playTogether(
@@ -396,7 +442,9 @@
@UiThread
private void hide() {
- if (DEBUG) Log.d(TAG, "Hiding...");
+ if (DEBUG) {
+ Log.d(TAG, "Hide indicator");
+ }
final int targetOffset = (mIsLtr ? 1 : -1) * (mIndicatorView.getWidth()
- (int) mIconTextsContainer.getTranslationX());
final AnimatorSet set = new AnimatorSet();
@@ -418,9 +466,12 @@
@UiThread
private void onExpanded() {
+ if (mState == STATE_STOPPED) {
+ return;
+ }
+
assertRevealingRecordingPackages();
- if (DEBUG) Log.d(TAG, "Expanded");
mState = STATE_SHOWN;
mIndicatorView.postDelayed(this::minimize, MAXIMIZED_DURATION);
@@ -428,7 +479,10 @@
@UiThread
private void onMinimized() {
- if (DEBUG) Log.d(TAG, "Minimized");
+ if (mState == STATE_STOPPED) {
+ return;
+ }
+
mState = STATE_MINIMIZED;
if (mRevealRecordingPackages) {
@@ -443,8 +497,21 @@
@UiThread
private void onHidden() {
- if (DEBUG) Log.d(TAG, "Hidden");
+ if (mState == STATE_STOPPED) {
+ return;
+ }
+ removeIndicatorView();
+ mState = STATE_NOT_SHOWN;
+
+ // Check if anybody started recording while we were in STATE_DISAPPEARING
+ if (!mPendingNotificationPackages.isEmpty()) {
+ // There is a new application that started recording, tell the user about it.
+ show(mPendingNotificationPackages.poll());
+ }
+ }
+
+ private void removeIndicatorView() {
final WindowManager windowManager = (WindowManager) mContext.getSystemService(
Context.WINDOW_SERVICE);
windowManager.removeView(mIndicatorView);
@@ -456,28 +523,6 @@
mTextsContainers = null;
mTextView = null;
mBgEnd = null;
-
- mState = STATE_NOT_SHOWN;
-
- // Check if anybody started recording while we were in STATE_DISAPPEARING
- if (!mPendingNotificationPackages.isEmpty()) {
- // There is a new application that started recording, tell the user about it.
- show(mPendingNotificationPackages.poll());
- }
- }
-
- @UiThread
- private void startPulsatingAnimation() {
- final View pulsatingView = mIconTextsContainer.findViewById(R.id.pulsating_circle);
- final ObjectAnimator animator =
- ObjectAnimator.ofPropertyValuesHolder(
- pulsatingView,
- PropertyValuesHolder.ofFloat(View.SCALE_X, PULSE_SCALE),
- PropertyValuesHolder.ofFloat(View.SCALE_Y, PULSE_SCALE));
- animator.setDuration(PULSE_BIT_DURATION);
- animator.setRepeatCount(ObjectAnimator.INFINITE);
- animator.setRepeatMode(ObjectAnimator.REVERSE);
- animator.start();
}
private String[] getGlobalStringArray(String setting) {
@@ -504,4 +549,33 @@
DEBUG ? new RuntimeException("Should not be called") : null);
}
}
+
+ private boolean checkIfEnabledInSettings() {
+ // 0 = disabled, everything else = enabled. Enabled by default.
+ return Settings.Global.getInt(mContext.getContentResolver(),
+ ENABLE_FLAG, 1) != 0;
+ }
+
+ private void registerSettingsObserver() {
+ final ContentObserver contentObserver = new ContentObserver(
+ mContext.getMainThreadHandler()) {
+ @Override
+ public void onChange(boolean selfChange) {
+ if (mIsEnabledInSettings == checkIfEnabledInSettings()) {
+ // Nothing changed as we know it - ignore.
+ return;
+ }
+
+ // Things changed: flip the flag.
+ mIsEnabledInSettings = !mIsEnabledInSettings;
+ if (mIsEnabledInSettings) {
+ start();
+ } else {
+ stop();
+ }
+ }
+ };
+ mContext.getContentResolver().registerContentObserver(
+ Settings.Global.getUriFor(ENABLE_FLAG), false, contentObserver);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/MicrophoneForegroundServicesObserver.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/MicrophoneForegroundServicesObserver.java
index 1ede88a..8caf95f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/MicrophoneForegroundServicesObserver.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/MicrophoneForegroundServicesObserver.java
@@ -30,7 +30,6 @@
import android.util.Log;
import android.util.SparseArray;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -41,9 +40,8 @@
*/
class MicrophoneForegroundServicesObserver extends AudioActivityObserver {
private static final String TAG = "MicrophoneForegroundServicesObserver";
- private static final boolean ENABLED = true;
- private final IActivityManager mActivityManager;
+ private IActivityManager mActivityManager;
/**
* A dictionary that maps PIDs to the package names. We only keep track of the PIDs that are
* "active" (those that are running FGS with FOREGROUND_SERVICE_TYPE_MICROPHONE flag).
@@ -60,7 +58,10 @@
MicrophoneForegroundServicesObserver(Context context,
OnAudioActivityStateChangeListener listener) {
super(context, listener);
+ }
+ @Override
+ void start() {
mActivityManager = ActivityManager.getService();
try {
mActivityManager.registerProcessObserver(mProcessObserver);
@@ -70,8 +71,19 @@
}
@Override
+ void stop() {
+ try {
+ mActivityManager.unregisterProcessObserver(mProcessObserver);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Couldn't unregister process observer", e);
+ }
+ mActivityManager = null;
+ mPackageToProcessCount.clear();
+ }
+
+ @Override
Set<String> getActivePackages() {
- return ENABLED ? mPackageToProcessCount.keySet() : Collections.emptySet();
+ return mPackageToProcessCount.keySet();
}
@UiThread
@@ -141,13 +153,12 @@
@UiThread
private void notifyPackageStateChanged(String packageName, boolean active) {
- if (active) {
- if (DEBUG) Log.d(TAG, "New microphone fgs detected, package=" + packageName);
- } else {
- if (DEBUG) Log.d(TAG, "Microphone fgs is gone, package=" + packageName);
+ if (DEBUG) {
+ Log.d(TAG, (active ? "New microphone fgs detected" : "Microphone fgs is gone")
+ + ", package=" + packageName);
}
- if (ENABLED) mListener.onAudioActivityStateChange(active, packageName);
+ mListener.onAudioActivityStateChange(active, packageName);
}
@UiThread
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/RecordAudioAppOpObserver.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/RecordAudioAppOpObserver.java
index b5b1c2b..9a2b4a9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/RecordAudioAppOpObserver.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/RecordAudioAppOpObserver.java
@@ -42,14 +42,33 @@
RecordAudioAppOpObserver(Context context, OnAudioActivityStateChangeListener listener) {
super(context, listener);
+ }
+
+ @Override
+ void start() {
+ if (DEBUG) {
+ Log.d(TAG, "Start");
+ }
// Register AppOpsManager callback
- final AppOpsManager appOpsManager = (AppOpsManager) mContext.getSystemService(
- Context.APP_OPS_SERVICE);
- appOpsManager.startWatchingActive(
- new String[]{AppOpsManager.OPSTR_RECORD_AUDIO},
- mContext.getMainExecutor(),
- this);
+ mContext.getSystemService(AppOpsManager.class)
+ .startWatchingActive(
+ new String[]{AppOpsManager.OPSTR_RECORD_AUDIO},
+ mContext.getMainExecutor(),
+ this);
+ }
+
+ @Override
+ void stop() {
+ if (DEBUG) {
+ Log.d(TAG, "Stop");
+ }
+
+ // Unregister AppOpsManager callback
+ mContext.getSystemService(AppOpsManager.class).stopWatchingActive(this);
+
+ // Clean up state
+ mActiveAudioRecordingPackages.clear();
}
@UiThread
diff --git a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java
index 551b7b4..d16bedc 100644
--- a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java
+++ b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java
@@ -23,6 +23,7 @@
import android.view.LayoutInflater;
import android.view.View;
+import com.android.keyguard.KeyguardClockSwitch;
import com.android.keyguard.KeyguardMessageArea;
import com.android.keyguard.KeyguardSliceView;
import com.android.systemui.dagger.SystemUIRootComponent;
@@ -126,11 +127,6 @@
NotificationStackScrollLayout createNotificationStackScrollLayout();
/**
- * Creates the Shelf.
- */
- NotificationShelf creatNotificationShelf();
-
- /**
* Creates the KeyguardSliceView.
*/
KeyguardSliceView createKeyguardSliceView();
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
index 3455ff4..4b119dd 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
@@ -150,6 +150,8 @@
private boolean mShowing;
private boolean mShowA11yStream;
+ private final boolean mShowLowMediaVolumeIcon;
+
private int mActiveStream;
private int mPrevActiveStream;
private boolean mAutomute = VolumePrefs.DEFAULT_ENABLE_AUTOMUTE;
@@ -166,7 +168,7 @@
public VolumeDialogImpl(Context context) {
mContext =
- new ContextThemeWrapper(context, R.style.qs_theme);
+ new ContextThemeWrapper(context, R.style.volume_dialog_theme);
mController = Dependency.get(VolumeDialogController.class);
mKeyguard = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
@@ -175,6 +177,8 @@
mShowActiveStreamOnly = showActiveStreamOnly();
mHasSeenODICaptionsTooltip =
Prefs.getBoolean(context, Prefs.Key.HAS_SEEN_ODI_CAPTIONS_TOOLTIP, false);
+ mShowLowMediaVolumeIcon =
+ mContext.getResources().getBoolean(R.bool.config_showLowMediaVolumeIcon);
}
@Override
@@ -421,6 +425,7 @@
row.dndIcon = row.view.findViewById(R.id.dnd_icon);
row.slider = row.view.findViewById(R.id.volume_row_slider);
row.slider.setOnSeekBarChangeListener(new VolumeSeekBarChangeListener(row));
+ row.number = row.view.findViewById(R.id.volume_number);
row.anim = null;
@@ -1024,19 +1029,28 @@
final boolean iconEnabled = (mAutomute || ss.muteSupported) && !zenMuted;
row.icon.setEnabled(iconEnabled);
row.icon.setAlpha(iconEnabled ? 1 : 0.5f);
- final int iconRes =
- isRingVibrate ? R.drawable.ic_volume_ringer_vibrate
- : isRingSilent || zenMuted ? row.iconMuteRes
- : ss.routedToBluetooth
- ? isStreamMuted(ss) ? R.drawable.ic_volume_media_bt_mute
- : R.drawable.ic_volume_media_bt
- : isStreamMuted(ss) ? row.iconMuteRes : row.iconRes;
+ final int iconRes;
+ if (isRingVibrate) {
+ iconRes = R.drawable.ic_volume_ringer_vibrate;
+ } else if (isRingSilent || zenMuted) {
+ iconRes = row.iconMuteRes;
+ } else if (ss.routedToBluetooth) {
+ iconRes = isStreamMuted(ss) ? R.drawable.ic_volume_media_bt_mute
+ : R.drawable.ic_volume_media_bt;
+ } else if (isStreamMuted(ss)) {
+ iconRes = row.iconMuteRes;
+ } else {
+ iconRes = mShowLowMediaVolumeIcon && ss.level * 2 < (ss.levelMax + ss.levelMin)
+ ? R.drawable.ic_volume_media_low : row.iconRes;
+ }
+
row.icon.setImageResource(iconRes);
row.iconState =
iconRes == R.drawable.ic_volume_ringer_vibrate ? Events.ICON_STATE_VIBRATE
: (iconRes == R.drawable.ic_volume_media_bt_mute || iconRes == row.iconMuteRes)
? Events.ICON_STATE_MUTE
- : (iconRes == R.drawable.ic_volume_media_bt || iconRes == row.iconRes)
+ : (iconRes == R.drawable.ic_volume_media_bt || iconRes == row.iconRes
+ || iconRes == R.drawable.ic_volume_media_low)
? Events.ICON_STATE_UNMUTE
: Events.ICON_STATE_UNKNOWN;
if (iconEnabled) {
@@ -1090,6 +1104,7 @@
final int vlevel = row.ss.muted && (!isRingStream && !zenMuted) ? 0
: row.ss.level;
updateVolumeRowSliderH(row, enableSlider, vlevel);
+ if (row.number != null) row.number.setText(Integer.toString(vlevel));
}
private boolean isStreamMuted(final StreamState streamState) {
@@ -1115,6 +1130,10 @@
row.icon.setImageTintList(tint);
row.icon.setImageAlpha(alpha);
row.cachedTint = tint;
+ if (row.number != null) {
+ row.number.setTextColor(tint);
+ row.number.setAlpha(alpha);
+ }
}
private void updateVolumeRowSliderH(VolumeRow row, boolean enable, int vlevel) {
@@ -1346,7 +1365,7 @@
private final class CustomDialog extends Dialog implements DialogInterface {
public CustomDialog(Context context) {
- super(context, R.style.qs_theme);
+ super(context, R.style.volume_dialog_theme);
}
@Override
@@ -1458,6 +1477,7 @@
private TextView header;
private ImageButton icon;
private SeekBar slider;
+ private TextView number;
private int stream;
private StreamState ss;
private long userAttempt; // last user-driven slider change
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/IWindowMagnificationConnectionTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/IWindowMagnificationConnectionTest.java
index fbc8e9d..ac567e0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/IWindowMagnificationConnectionTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/IWindowMagnificationConnectionTest.java
@@ -25,6 +25,7 @@
import android.os.RemoteException;
import android.provider.Settings;
import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
import android.view.Display;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.IWindowMagnificationConnection;
@@ -47,6 +48,7 @@
*/
@SmallTest
@RunWith(AndroidTestingRunner.class)
+@TestableLooper.RunWithLooper
public class IWindowMagnificationConnectionTest extends SysuiTestCase {
private static final int TEST_DISPLAY = Display.DEFAULT_DISPLAY;
@@ -57,7 +59,7 @@
@Mock
private IWindowMagnificationConnectionCallback mConnectionCallback;
@Mock
- private WindowMagnificationController mWindowMagnificationController;
+ private WindowMagnificationAnimationController mWindowMagnificationAnimationController;
@Mock
private ModeSwitchesController mModeSwitchesController;
private IWindowMagnificationConnection mIWindowMagnificationConnection;
@@ -74,7 +76,8 @@
any(IWindowMagnificationConnection.class));
mWindowMagnification = new WindowMagnification(getContext(),
getContext().getMainThreadHandler(), mCommandQueue, mModeSwitchesController);
- mWindowMagnification.mWindowMagnificationController = mWindowMagnificationController;
+ mWindowMagnification.mWindowMagnificationAnimationController =
+ mWindowMagnificationAnimationController;
mWindowMagnification.requestWindowMagnificationConnection(true);
assertNotNull(mIWindowMagnificationConnection);
mIWindowMagnificationConnection.setConnectionCallback(mConnectionCallback);
@@ -86,7 +89,7 @@
Float.NaN);
waitForIdleSync();
- verify(mWindowMagnificationController).enableWindowMagnification(3.0f, Float.NaN,
+ verify(mWindowMagnificationAnimationController).enableWindowMagnification(3.0f, Float.NaN,
Float.NaN);
}
@@ -99,7 +102,7 @@
mIWindowMagnificationConnection.disableWindowMagnification(TEST_DISPLAY);
waitForIdleSync();
- verify(mWindowMagnificationController).deleteWindowMagnification();
+ verify(mWindowMagnificationAnimationController).deleteWindowMagnification();
}
@Test
@@ -107,7 +110,7 @@
mIWindowMagnificationConnection.setScale(TEST_DISPLAY, 3.0f);
waitForIdleSync();
- verify(mWindowMagnificationController).setScale(3.0f);
+ verify(mWindowMagnificationAnimationController).setScale(3.0f);
}
@Test
@@ -115,7 +118,7 @@
mIWindowMagnificationConnection.moveWindowMagnifier(TEST_DISPLAY, 100f, 200f);
waitForIdleSync();
- verify(mWindowMagnificationController).moveWindowMagnifier(100f, 200f);
+ verify(mWindowMagnificationAnimationController).moveWindowMagnifier(100f, 200f);
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java
new file mode 100644
index 0000000..b7c198e
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java
@@ -0,0 +1,363 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui.accessibility;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyFloat;
+import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
+import android.animation.ValueAnimator;
+import android.app.Instrumentation;
+import android.content.Context;
+import android.os.Handler;
+import android.os.SystemClock;
+import android.testing.AndroidTestingRunner;
+import android.view.SurfaceControl;
+import android.view.animation.AccelerateInterpolator;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.MediumTest;
+
+import com.android.internal.graphics.SfVsyncFrameCallbackProvider;
+import com.android.systemui.SysuiTestCase;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+
+@MediumTest
+@RunWith(AndroidTestingRunner.class)
+public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
+
+ private static final float DEFAULT_SCALE = 3.0f;
+ private static final float DEFAULT_CENTER_X = 400.0f;
+ private static final float DEFAULT_CENTER_Y = 500.0f;
+ // The duration couldn't too short, otherwise the ValueAnimator won't work in expectation.
+ private static final long ANIMATION_DURATION_MS = 200;
+
+ private AtomicReference<Float> mCurrentScale = new AtomicReference<>((float) 0);
+ private AtomicReference<Float> mCurrentCenterX = new AtomicReference<>((float) 0);
+ private AtomicReference<Float> mCurrentCenterY = new AtomicReference<>((float) 0);
+ private ArgumentCaptor<Float> mScaleCaptor = ArgumentCaptor.forClass(Float.class);
+ private ArgumentCaptor<Float> mCenterXCaptor = ArgumentCaptor.forClass(Float.class);
+ private ArgumentCaptor<Float> mCenterYCaptor = ArgumentCaptor.forClass(Float.class);
+
+ @Mock
+ Handler mHandler;
+ @Mock
+ SfVsyncFrameCallbackProvider mSfVsyncFrameProvider;
+ @Mock
+ WindowMagnifierCallback mWindowMagnifierCallback;
+
+ private SpyWindowMagnificationController mController;
+ private WindowMagnificationController mSpyController;
+ private WindowMagnificationAnimationController mWindowMagnificationAnimationController;
+ private Instrumentation mInstrumentation;
+ private long mWaitingAnimationPeriod;
+ private long mWaitIntermediateAnimationPeriod;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ mWaitingAnimationPeriod = ANIMATION_DURATION_MS + 50;
+ mWaitIntermediateAnimationPeriod = ANIMATION_DURATION_MS / 2;
+ mController = new SpyWindowMagnificationController(mContext, mHandler,
+ mSfVsyncFrameProvider, null, new SurfaceControl.Transaction(),
+ mWindowMagnifierCallback);
+ mSpyController = mController.getSpyController();
+ mWindowMagnificationAnimationController = new WindowMagnificationAnimationController(
+ mContext, mController, newValueAnimator());
+ }
+
+ @Test
+ public void enableWindowMagnification_disabled_expectedStartAndEndValues() {
+ enableWindowMagnificationAndWaitAnimating(mWaitingAnimationPeriod);
+
+ verify(mSpyController, atLeast(2)).enableWindowMagnification(
+ mScaleCaptor.capture(),
+ mCenterXCaptor.capture(), mCenterYCaptor.capture());
+ verifyStartValue(mScaleCaptor, 1.0f);
+ verifyStartValue(mCenterXCaptor, DEFAULT_CENTER_X);
+ verifyStartValue(mCenterYCaptor, DEFAULT_CENTER_Y);
+ verifyFinalSpec(DEFAULT_SCALE, DEFAULT_CENTER_X, DEFAULT_CENTER_Y);
+ }
+
+ @Test
+ public void enableWindowMagnification_enabling_expectedStartAndEndValues() {
+ enableWindowMagnificationAndWaitAnimating(mWaitIntermediateAnimationPeriod);
+ final float targetScale = DEFAULT_SCALE + 1.0f;
+ final float targetCenterX = DEFAULT_CENTER_X + 100;
+ final float targetCenterY = DEFAULT_CENTER_Y + 100;
+
+ mInstrumentation.runOnMainSync(() -> {
+ Mockito.reset(mSpyController);
+ mWindowMagnificationAnimationController.enableWindowMagnification(targetScale,
+ targetCenterX, targetCenterY);
+ mCurrentScale.set(mController.getScale());
+ mCurrentCenterX.set(mController.getCenterX());
+ mCurrentCenterY.set(mController.getCenterY());
+ });
+
+ SystemClock.sleep(mWaitingAnimationPeriod);
+
+ verify(mSpyController, atLeast(2)).enableWindowMagnification(mScaleCaptor.capture(),
+ mCenterXCaptor.capture(), mCenterYCaptor.capture());
+ verifyStartValue(mScaleCaptor, mCurrentScale.get());
+ verifyStartValue(mCenterXCaptor, mCurrentCenterX.get());
+ verifyStartValue(mCenterYCaptor, mCurrentCenterY.get());
+ verifyFinalSpec(targetScale, targetCenterX, targetCenterY);
+ }
+
+ @Test
+ public void enableWindowMagnification_disabling_expectedStartAndEndValues() {
+ enableWindowMagnificationAndWaitAnimating(mWaitingAnimationPeriod);
+ deleteWindowMagnificationAndWaitAnimating(mWaitIntermediateAnimationPeriod);
+ final float targetScale = DEFAULT_SCALE + 1.0f;
+ final float targetCenterX = DEFAULT_CENTER_X + 100;
+ final float targetCenterY = DEFAULT_CENTER_Y + 100;
+
+ mInstrumentation.runOnMainSync(
+ () -> {
+ Mockito.reset(mSpyController);
+ mWindowMagnificationAnimationController.enableWindowMagnification(targetScale,
+ targetCenterX, targetCenterY);
+ mCurrentScale.set(mController.getScale());
+ mCurrentCenterX.set(mController.getCenterX());
+ mCurrentCenterY.set(mController.getCenterY());
+ });
+ SystemClock.sleep(mWaitingAnimationPeriod);
+
+ verify(mSpyController, atLeast(2)).enableWindowMagnification(
+ mScaleCaptor.capture(),
+ mCenterXCaptor.capture(), mCenterYCaptor.capture());
+ //Animating in reverse, so we only check if the start values are greater than current.
+ assertTrue(mScaleCaptor.getAllValues().get(0) > mCurrentScale.get());
+ assertEquals(targetScale, mScaleCaptor.getValue(), 0f);
+ assertTrue(mCenterXCaptor.getAllValues().get(0) > mCurrentCenterX.get());
+ assertEquals(targetCenterX, mCenterXCaptor.getValue(), 0f);
+ assertTrue(mCenterYCaptor.getAllValues().get(0) > mCurrentCenterY.get());
+ assertEquals(targetCenterY, mCenterYCaptor.getValue(), 0f);
+ verifyFinalSpec(targetScale, targetCenterX, targetCenterY);
+ }
+
+ @Test
+ public void enableWindowMagnificationWithSameScale_doNothing() {
+ enableWindowMagnificationAndWaitAnimating(mWaitingAnimationPeriod);
+
+ enableWindowMagnificationAndWaitAnimating(mWaitingAnimationPeriod);
+
+ verify(mSpyController, never()).enableWindowMagnification(anyFloat(), anyFloat(),
+ anyFloat());
+ }
+
+ @Test
+ public void setScale_enabled_expectedScale() {
+ enableWindowMagnificationAndWaitAnimating(mWaitingAnimationPeriod);
+
+ mInstrumentation.runOnMainSync(
+ () -> mWindowMagnificationAnimationController.setScale(DEFAULT_SCALE + 1));
+
+ verify(mSpyController).setScale(DEFAULT_SCALE + 1);
+ verifyFinalSpec(DEFAULT_SCALE + 1, DEFAULT_CENTER_X, DEFAULT_CENTER_Y);
+ }
+
+ @Test
+ public void deleteWindowMagnification_enabled_expectedStartAndEndValues() {
+ enableWindowMagnificationAndWaitAnimating(mWaitingAnimationPeriod);
+
+ deleteWindowMagnificationAndWaitAnimating(mWaitingAnimationPeriod);
+
+ verify(mSpyController, atLeast(2)).enableWindowMagnification(mScaleCaptor.capture(),
+ mCenterXCaptor.capture(), mCenterYCaptor.capture());
+ verify(mSpyController).deleteWindowMagnification();
+ verifyStartValue(mScaleCaptor, DEFAULT_SCALE);
+ verifyStartValue(mCenterXCaptor, Float.NaN);
+ verifyStartValue(mCenterYCaptor, Float.NaN);
+ verifyFinalSpec(Float.NaN, Float.NaN, Float.NaN);
+ }
+
+ @Test
+ public void deleteWindowMagnification_disabled_doNothing() {
+ deleteWindowMagnificationAndWaitAnimating(mWaitingAnimationPeriod);
+
+ Mockito.verifyNoMoreInteractions(mSpyController);
+ }
+
+ @Test
+ public void deleteWindowMagnification_enabling_checkStartAndEndValues() {
+ enableWindowMagnificationAndWaitAnimating(mWaitIntermediateAnimationPeriod);
+
+ //It just reverse the animation, so we don't need to wait the whole duration.
+ mInstrumentation.runOnMainSync(
+ () -> {
+ Mockito.reset(mSpyController);
+ mWindowMagnificationAnimationController.deleteWindowMagnification();
+ mCurrentScale.set(mController.getScale());
+ mCurrentCenterX.set(mController.getCenterX());
+ mCurrentCenterY.set(mController.getCenterY());
+ });
+ SystemClock.sleep(mWaitingAnimationPeriod);
+
+ verify(mSpyController, atLeast(2)).enableWindowMagnification(mScaleCaptor.capture(),
+ mCenterXCaptor.capture(), mCenterYCaptor.capture());
+ verify(mSpyController).deleteWindowMagnification();
+
+ //The animation is in verse, so we only check the start values should no be greater than
+ // the current one.
+ assertTrue(mScaleCaptor.getAllValues().get(0) <= mCurrentScale.get());
+ assertEquals(1.0f, mScaleCaptor.getValue(), 0f);
+ verifyStartValue(mCenterXCaptor, Float.NaN);
+ verifyStartValue(mCenterYCaptor, Float.NaN);
+ verifyFinalSpec(Float.NaN, Float.NaN, Float.NaN);
+ }
+
+ @Test
+ public void deleteWindowMagnification_disabling_checkStartAndValues() {
+ enableWindowMagnificationAndWaitAnimating(mWaitingAnimationPeriod);
+ deleteWindowMagnificationAndWaitAnimating(mWaitIntermediateAnimationPeriod);
+
+ deleteWindowMagnificationAndWaitAnimating(mWaitingAnimationPeriod);
+
+ verify(mSpyController, atLeast(2)).enableWindowMagnification(mScaleCaptor.capture(),
+ mCenterXCaptor.capture(), mCenterYCaptor.capture());
+ verify(mSpyController).deleteWindowMagnification();
+ assertEquals(1.0f, mScaleCaptor.getValue(), 0f);
+ verifyFinalSpec(Float.NaN, Float.NaN, Float.NaN);
+ }
+
+ @Test
+ public void moveWindowMagnifier_enabled() {
+ enableWindowMagnificationAndWaitAnimating(mWaitingAnimationPeriod);
+
+ mInstrumentation.runOnMainSync(
+ () -> mWindowMagnificationAnimationController.moveWindowMagnifier(100f, 200f));
+
+ verify(mSpyController).moveWindowMagnifier(100f, 200f);
+ verifyFinalSpec(DEFAULT_SCALE, DEFAULT_CENTER_X + 100f, DEFAULT_CENTER_Y + 100f);
+ }
+
+ @Test
+ public void onConfigurationChanged_passThrough() {
+ mWindowMagnificationAnimationController.onConfigurationChanged(100);
+
+ verify(mSpyController).onConfigurationChanged(100);
+ }
+ private void verifyFinalSpec(float expectedScale, float expectedCenterX,
+ float expectedCenterY) {
+ assertEquals(expectedScale, mController.getScale(), 0f);
+ assertEquals(expectedCenterX, mController.getCenterX(), 0f);
+ assertEquals(expectedCenterY, mController.getCenterY(), 0f);
+ }
+
+ private void enableWindowMagnificationAndWaitAnimating(long duration) {
+ mInstrumentation.runOnMainSync(
+ () -> {
+ Mockito.reset(mSpyController);
+ mWindowMagnificationAnimationController.enableWindowMagnification(DEFAULT_SCALE,
+ DEFAULT_CENTER_X, DEFAULT_CENTER_Y);
+ });
+ SystemClock.sleep(duration);
+ }
+
+ private void deleteWindowMagnificationAndWaitAnimating(long duration) {
+ mInstrumentation.runOnMainSync(
+ () -> {
+ resetMockObjects();
+ mWindowMagnificationAnimationController.deleteWindowMagnification();
+ });
+ SystemClock.sleep(duration);
+ }
+
+ private void verifyStartValue(ArgumentCaptor<Float> captor, float startValue) {
+ assertEquals(startValue, captor.getAllValues().get(0), 0f);
+ }
+
+ private void resetMockObjects() {
+ Mockito.reset(mSpyController);
+ }
+
+ /**
+ * It observes the methods in {@link WindowMagnificationController} since we couldn't spy it
+ * directly.
+ */
+ private static class SpyWindowMagnificationController extends WindowMagnificationController {
+ private WindowMagnificationController mSpyController;
+
+ SpyWindowMagnificationController(Context context, Handler handler,
+ SfVsyncFrameCallbackProvider sfVsyncFrameProvider,
+ MirrorWindowControl mirrorWindowControl, SurfaceControl.Transaction transaction,
+ WindowMagnifierCallback callback) {
+ super(context, handler, sfVsyncFrameProvider, mirrorWindowControl, transaction,
+ callback);
+ mSpyController = Mockito.mock(WindowMagnificationController.class);
+ }
+
+ WindowMagnificationController getSpyController() {
+ return mSpyController;
+ }
+
+ @Override
+ void enableWindowMagnification(float scale, float centerX, float centerY) {
+ super.enableWindowMagnification(scale, centerX, centerY);
+ mSpyController.enableWindowMagnification(scale, centerX, centerY);
+ }
+
+ @Override
+ void deleteWindowMagnification() {
+ super.deleteWindowMagnification();
+ mSpyController.deleteWindowMagnification();
+ }
+
+ @Override
+ void moveWindowMagnifier(float offsetX, float offsetY) {
+ super.moveWindowMagnifier(offsetX, offsetX);
+ mSpyController.moveWindowMagnifier(offsetX, offsetY);
+ }
+
+ @Override
+ void setScale(float scale) {
+ super.setScale(scale);
+ mSpyController.setScale(scale);
+ }
+
+ @Override
+ void onConfigurationChanged(int configDiff) {
+ super.onConfigurationChanged(configDiff);
+ mSpyController.onConfigurationChanged(configDiff);
+ }
+
+ }
+
+ private static ValueAnimator newValueAnimator() {
+ final ValueAnimator valueAnimator = new ValueAnimator();
+ valueAnimator.setDuration(ANIMATION_DURATION_MS);
+ valueAnimator.setInterpolator(new AccelerateInterpolator(2.5f));
+ valueAnimator.setFloatValues(0.0f, 1.0f);
+ return valueAnimator;
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java
index 2007fbb..f1f394e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java
@@ -18,6 +18,7 @@
import static android.view.Choreographer.FrameCallback;
+import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.atLeastOnce;
@@ -26,8 +27,12 @@
import static org.mockito.Mockito.when;
import android.app.Instrumentation;
+import android.content.Context;
+import android.content.pm.ActivityInfo;
import android.os.Handler;
import android.testing.AndroidTestingRunner;
+import android.view.Display;
+import android.view.Surface;
import android.view.SurfaceControl;
import androidx.test.InstrumentationRegistry;
@@ -41,6 +46,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@SmallTest
@@ -57,12 +63,14 @@
WindowMagnifierCallback mWindowMagnifierCallback;
@Mock
SurfaceControl.Transaction mTransaction;
+ private Context mContext;
private WindowMagnificationController mWindowMagnificationController;
private Instrumentation mInstrumentation;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ mContext = Mockito.spy(getContext());
mInstrumentation = InstrumentationRegistry.getInstrumentation();
doAnswer(invocation -> {
FrameCallback callback = invocation.getArgument(0);
@@ -73,8 +81,7 @@
when(mTransaction.remove(any())).thenReturn(mTransaction);
when(mTransaction.setGeometry(any(), any(), any(),
anyInt())).thenReturn(mTransaction);
-
- mWindowMagnificationController = new WindowMagnificationController(getContext(),
+ mWindowMagnificationController = new WindowMagnificationController(mContext,
mHandler, mSfVsyncFrameProvider,
mMirrorWindowControl, mTransaction, mWindowMagnifierCallback);
verify(mMirrorWindowControl).setWindowDelegate(
@@ -83,9 +90,8 @@
@After
public void tearDown() {
- mInstrumentation.runOnMainSync(() -> {
- mWindowMagnificationController.deleteWindowMagnification();
- });
+ mInstrumentation.runOnMainSync(
+ () -> mWindowMagnificationController.deleteWindowMagnification());
}
@Test
@@ -121,4 +127,27 @@
verify(mSfVsyncFrameProvider, atLeastOnce()).postFrameCallback(any());
}
+
+ @Test
+ public void setScale_enabled_expectedValue() {
+ mInstrumentation.runOnMainSync(
+ () -> mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
+ Float.NaN));
+
+ mInstrumentation.runOnMainSync(() -> mWindowMagnificationController.setScale(3.0f));
+
+ assertEquals(3.0f, mWindowMagnificationController.getScale(), 0);
+ }
+
+ @Test
+ public void onConfigurationChanged_disabled_withoutException() {
+ Display display = Mockito.spy(mContext.getDisplay());
+ when(display.getRotation()).thenReturn(Surface.ROTATION_90);
+ when(mContext.getDisplay()).thenReturn(display);
+
+ mInstrumentation.runOnMainSync(() -> {
+ mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_DENSITY);
+ mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_ORIENTATION);
+ });
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationTest.java
index 4136013..936558b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationTest.java
@@ -26,6 +26,7 @@
import android.graphics.Rect;
import android.os.RemoteException;
import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
import android.view.Display;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.IWindowMagnificationConnection;
@@ -45,6 +46,7 @@
@SmallTest
@RunWith(AndroidTestingRunner.class)
+@TestableLooper.RunWithLooper
public class WindowMagnificationTest extends SysuiTestCase {
@Mock
diff --git a/packages/SystemUI/tests/src/com/android/systemui/appops/AppOpsControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/appops/AppOpsControllerTest.java
index 4fdc06e..8f082c1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/appops/AppOpsControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/appops/AppOpsControllerTest.java
@@ -27,6 +27,9 @@
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -34,6 +37,8 @@
import android.app.AppOpsManager;
import android.content.pm.PackageManager;
+import android.media.AudioManager;
+import android.media.AudioRecordingConfiguration;
import android.os.Looper;
import android.os.UserHandle;
import android.testing.AndroidTestingRunner;
@@ -47,9 +52,11 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.util.Collections;
import java.util.List;
@SmallTest
@@ -73,6 +80,12 @@
private PermissionFlagsCache mFlagsCache;
@Mock
private PackageManager mPackageManager;
+ @Mock(stubOnly = true)
+ private AudioManager mAudioManager;
+ @Mock(stubOnly = true)
+ private AudioManager.AudioRecordingCallback mRecordingCallback;
+ @Mock(stubOnly = true)
+ private AudioRecordingConfiguration mPausedMockRecording;
private AppOpsControllerImpl mController;
private TestableLooper mTestableLooper;
@@ -94,11 +107,20 @@
when(mFlagsCache.getPermissionFlags(anyString(), anyString(),
eq(TEST_UID_NON_USER_SENSITIVE))).thenReturn(0);
+ doAnswer((invocation) -> mRecordingCallback = invocation.getArgument(0))
+ .when(mAudioManager).registerAudioRecordingCallback(any(), any());
+ when(mPausedMockRecording.getClientUid()).thenReturn(TEST_UID);
+ when(mPausedMockRecording.isClientSilenced()).thenReturn(true);
+
+ when(mAudioManager.getActiveRecordingConfigurations())
+ .thenReturn(List.of(mPausedMockRecording));
+
mController = new AppOpsControllerImpl(
mContext,
mTestableLooper.getLooper(),
mDumpManager,
- mFlagsCache
+ mFlagsCache,
+ mAudioManager
);
}
@@ -363,6 +385,89 @@
AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME, true);
}
+ @Test
+ public void testPausedRecordingIsRetrievedOnCreation() {
+ mController.addCallback(new int[]{AppOpsManager.OP_RECORD_AUDIO}, mCallback);
+ mTestableLooper.processAllMessages();
+
+ mController.onOpActiveChanged(
+ AppOpsManager.OP_RECORD_AUDIO, TEST_UID, TEST_PACKAGE_NAME, true);
+ mTestableLooper.processAllMessages();
+
+ verify(mCallback, never())
+ .onActiveStateChanged(anyInt(), anyInt(), anyString(), anyBoolean());
+ }
+
+ @Test
+ public void testPausedRecordingFilteredOut() {
+ mController.addCallback(new int[]{AppOpsManager.OP_RECORD_AUDIO}, mCallback);
+ mTestableLooper.processAllMessages();
+
+ mController.onOpActiveChanged(
+ AppOpsManager.OP_RECORD_AUDIO, TEST_UID, TEST_PACKAGE_NAME, true);
+ mTestableLooper.processAllMessages();
+
+ assertTrue(mController.getActiveAppOps().isEmpty());
+ }
+
+ @Test
+ public void testOnlyRecordAudioPaused() {
+ mController.addCallback(new int[]{
+ AppOpsManager.OP_RECORD_AUDIO,
+ AppOpsManager.OP_CAMERA
+ }, mCallback);
+ mTestableLooper.processAllMessages();
+
+ mController.onOpActiveChanged(
+ AppOpsManager.OP_CAMERA, TEST_UID, TEST_PACKAGE_NAME, true);
+ mTestableLooper.processAllMessages();
+
+ verify(mCallback).onActiveStateChanged(
+ AppOpsManager.OP_CAMERA, TEST_UID, TEST_PACKAGE_NAME, true);
+ List<AppOpItem> list = mController.getActiveAppOps();
+
+ assertEquals(1, list.size());
+ assertEquals(AppOpsManager.OP_CAMERA, list.get(0).getCode());
+ }
+
+ @Test
+ public void testUnpausedRecordingSentActive() {
+ mController.addCallback(new int[]{AppOpsManager.OP_RECORD_AUDIO}, mCallback);
+ mTestableLooper.processAllMessages();
+ mController.onOpActiveChanged(
+ AppOpsManager.OP_RECORD_AUDIO, TEST_UID, TEST_PACKAGE_NAME, true);
+
+ mTestableLooper.processAllMessages();
+ mRecordingCallback.onRecordingConfigChanged(Collections.emptyList());
+
+ mTestableLooper.processAllMessages();
+
+ verify(mCallback).onActiveStateChanged(
+ AppOpsManager.OP_RECORD_AUDIO, TEST_UID, TEST_PACKAGE_NAME, true);
+ }
+
+ @Test
+ public void testAudioPausedSentInactive() {
+ mController.addCallback(new int[]{AppOpsManager.OP_RECORD_AUDIO}, mCallback);
+ mTestableLooper.processAllMessages();
+ mController.onOpActiveChanged(
+ AppOpsManager.OP_RECORD_AUDIO, TEST_UID_OTHER, TEST_PACKAGE_NAME, true);
+ mTestableLooper.processAllMessages();
+
+ AudioRecordingConfiguration mockARC = mock(AudioRecordingConfiguration.class);
+ when(mockARC.getClientUid()).thenReturn(TEST_UID_OTHER);
+ when(mockARC.isClientSilenced()).thenReturn(true);
+
+ mRecordingCallback.onRecordingConfigChanged(List.of(mockARC));
+ mTestableLooper.processAllMessages();
+
+ InOrder inOrder = inOrder(mCallback);
+ inOrder.verify(mCallback).onActiveStateChanged(
+ AppOpsManager.OP_RECORD_AUDIO, TEST_UID_OTHER, TEST_PACKAGE_NAME, true);
+ inOrder.verify(mCallback).onActiveStateChanged(
+ AppOpsManager.OP_RECORD_AUDIO, TEST_UID_OTHER, TEST_PACKAGE_NAME, false);
+ }
+
private class TestHandler extends AppOpsControllerImpl.H {
TestHandler(Looper looper) {
mController.super(looper);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
index b758953..1538a32 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
@@ -60,6 +60,7 @@
import com.android.internal.colorextraction.ColorExtractor;
import com.android.internal.statusbar.IStatusBarService;
+import com.android.systemui.SystemUIFactory;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dump.DumpManager;
@@ -70,7 +71,9 @@
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationRemoveInterceptor;
+import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.RankingBuilder;
+import com.android.systemui.statusbar.SuperStatusBarViewFactory;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
@@ -79,8 +82,10 @@
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
+import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
+import com.android.systemui.statusbar.phone.LockscreenLockIconController;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.NotificationShadeWindowController;
import com.android.systemui.statusbar.phone.NotificationShadeWindowView;
@@ -90,6 +95,7 @@
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.util.FloatingContentCoordinator;
+import com.android.systemui.util.InjectionInflationController;
import com.google.common.collect.ImmutableList;
@@ -174,6 +180,8 @@
@Mock
private ShadeController mShadeController;
@Mock
+ private NotificationShelfComponent mNotificationShelfComponent;
+ @Mock
private NotifPipeline mNotifPipeline;
@Mock
private FeatureFlags mFeatureFlagsOldPipeline;
@@ -185,11 +193,14 @@
private IStatusBarService mStatusBarService;
@Mock
private LauncherApps mLauncherApps;
+ @Mock private LockscreenLockIconController mLockIconController;
private BubbleData mBubbleData;
private TestableLooper mTestableLooper;
+ private SuperStatusBarViewFactory mSuperStatusBarViewFactory;
+
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
@@ -199,6 +210,23 @@
mContext.addMockSystemService(FaceManager.class, mFaceManager);
when(mColorExtractor.getNeutralColors()).thenReturn(mGradientColors);
+ mSuperStatusBarViewFactory = new SuperStatusBarViewFactory(mContext,
+ new InjectionInflationController(SystemUIFactory.getInstance().getRootComponent()),
+ new NotificationShelfComponent.Builder() {
+ @Override
+ public NotificationShelfComponent.Builder notificationShelf(
+ NotificationShelf view) {
+ return this;
+ }
+
+ @Override
+ public NotificationShelfComponent build() {
+ return mNotificationShelfComponent;
+ }
+ },
+ mLockIconController);
+
+ // Bubbles get added to status bar window view
mNotificationShadeWindowController = new NotificationShadeWindowController(mContext,
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
mConfigurationController, mKeyguardViewMediator, mKeyguardBypassController,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java
index 43bf191..0e7cb79 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java
@@ -58,6 +58,7 @@
import com.android.internal.colorextraction.ColorExtractor;
import com.android.internal.statusbar.IStatusBarService;
+import com.android.systemui.SystemUIFactory;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dump.DumpManager;
@@ -66,7 +67,9 @@
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
+import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.RankingBuilder;
+import com.android.systemui.statusbar.SuperStatusBarViewFactory;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationFilter;
@@ -75,7 +78,7 @@
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
-import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent;
+import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.LockscreenLockIconController;
@@ -88,6 +91,7 @@
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.util.FloatingContentCoordinator;
+import com.android.systemui.util.InjectionInflationController;
import org.junit.Before;
import org.junit.Ignore;
@@ -168,7 +172,7 @@
@Mock
private ShadeController mShadeController;
@Mock
- private NotificationRowComponent mNotificationRowComponent;
+ private NotificationShelfComponent mNotificationShelfComponent;
@Mock
private NotifPipeline mNotifPipeline;
@Mock
@@ -185,6 +189,7 @@
private BubbleData mBubbleData;
private TestableLooper mTestableLooper;
+ private SuperStatusBarViewFactory mSuperStatusBarViewFactory;
@Before
public void setUp() throws Exception {
@@ -195,6 +200,22 @@
mContext.addMockSystemService(FaceManager.class, mFaceManager);
when(mColorExtractor.getNeutralColors()).thenReturn(mGradientColors);
+ mSuperStatusBarViewFactory = new SuperStatusBarViewFactory(mContext,
+ new InjectionInflationController(SystemUIFactory.getInstance().getRootComponent()),
+ new NotificationShelfComponent.Builder() {
+ @Override
+ public NotificationShelfComponent.Builder notificationShelf(
+ NotificationShelf view) {
+ return this;
+ }
+
+ @Override
+ public NotificationShelfComponent build() {
+ return mNotificationShelfComponent;
+ }
+ },
+ mLockIconController);
+
// Bubbles get added to status bar window view
mNotificationShadeWindowController = new NotificationShadeWindowController(mContext,
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/MediaDataManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/MediaDataManagerTest.kt
index 3789e6e..a4ebe1f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/MediaDataManagerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/MediaDataManagerTest.kt
@@ -13,6 +13,7 @@
import com.android.systemui.SysuiTestCase
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.dump.DumpManager
+import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.statusbar.SbnBuilder
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.mockito.eq
@@ -58,6 +59,7 @@
@Mock lateinit var mediaTimeoutListener: MediaTimeoutListener
@Mock lateinit var mediaResumeListener: MediaResumeListener
@Mock lateinit var pendingIntent: PendingIntent
+ @Mock lateinit var activityStarter: ActivityStarter
@JvmField @Rule val mockito = MockitoJUnit.rule()
lateinit var mediaDataManager: MediaDataManager
lateinit var mediaNotification: StatusBarNotification
@@ -68,8 +70,8 @@
backgroundExecutor = FakeExecutor(FakeSystemClock())
mediaDataManager = MediaDataManager(context, backgroundExecutor, foregroundExecutor,
mediaControllerFactory, broadcastDispatcher, dumpManager,
- mediaTimeoutListener, mediaResumeListener, useMediaResumption = true,
- useQsMediaPlayer = true)
+ mediaTimeoutListener, mediaResumeListener, activityStarter,
+ useMediaResumption = true, useQsMediaPlayer = true)
session = MediaSession(context, "MediaDataManagerTestSession")
mediaNotification = SbnBuilder().run {
setPkg(PACKAGE_NAME)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedGestureHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedGestureHandlerTest.java
index 694f51b..f4c0700 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedGestureHandlerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedGestureHandlerTest.java
@@ -24,14 +24,13 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import android.app.Instrumentation;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import androidx.test.filters.SmallTest;
-import androidx.test.platform.app.InstrumentationRegistry;
import com.android.systemui.model.SysUiState;
+import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.NavigationModeController;
import com.android.wm.shell.common.DisplayController;
@@ -46,12 +45,13 @@
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
public class OneHandedGestureHandlerTest extends OneHandedTestCase {
- Instrumentation mInstrumentation;
OneHandedTouchHandler mTouchHandler;
OneHandedTutorialHandler mTutorialHandler;
OneHandedGestureHandler mGestureHandler;
OneHandedManagerImpl mOneHandedManagerImpl;
@Mock
+ CommandQueue mCommandQueue;
+ @Mock
DisplayController mMockDisplayController;
@Mock
OneHandedDisplayAreaOrganizer mMockDisplayAreaOrganizer;
@@ -62,12 +62,13 @@
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- mInstrumentation = InstrumentationRegistry.getInstrumentation();
mTouchHandler = new OneHandedTouchHandler();
mTutorialHandler = new OneHandedTutorialHandler(mContext);
mGestureHandler = Mockito.spy(new OneHandedGestureHandler(
mContext, mMockDisplayController, mMockNavigationModeController));
- mOneHandedManagerImpl = new OneHandedManagerImpl(mInstrumentation.getContext(),
+ mOneHandedManagerImpl = new OneHandedManagerImpl(
+ getContext(),
+ mCommandQueue,
mMockDisplayController,
mMockDisplayAreaOrganizer,
mTouchHandler,
@@ -100,6 +101,7 @@
@Test
public void testOneHandedDisabled_shouldDisposeInputChannel() {
mOneHandedManagerImpl.setOneHandedEnabled(false);
+ mOneHandedManagerImpl.setSwipeToNotificationEnabled(false);
assertThat(mGestureHandler.mInputMonitor).isNull();
assertThat(mGestureHandler.mInputEventReceiver).isNull();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedManagerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedManagerImplTest.java
index 3418ebf..763f6e4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedManagerImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedManagerImplTest.java
@@ -33,6 +33,7 @@
import androidx.test.filters.SmallTest;
import com.android.systemui.model.SysUiState;
+import com.android.systemui.statusbar.CommandQueue;
import com.android.wm.shell.common.DisplayController;
import org.junit.Before;
@@ -51,6 +52,8 @@
OneHandedTimeoutHandler mTimeoutHandler;
@Mock
+ CommandQueue mCommandQueue;
+ @Mock
DisplayController mMockDisplayController;
@Mock
OneHandedDisplayAreaOrganizer mMockDisplayAreaOrganizer;
@@ -67,7 +70,9 @@
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mDisplay = mContext.getDisplay();
- mOneHandedManagerImpl = new OneHandedManagerImpl(getContext(),
+ mOneHandedManagerImpl = new OneHandedManagerImpl(
+ getContext(),
+ mCommandQueue,
mMockDisplayController,
mMockDisplayAreaOrganizer,
mMockTouchHandler,
@@ -94,14 +99,14 @@
@Test
public void testRegisterOrganizer() {
- verify(mMockDisplayAreaOrganizer, times(1)).registerOrganizer(anyInt());
+ verify(mMockDisplayAreaOrganizer).registerOrganizer(anyInt());
}
@Test
public void testStartOneHanded() {
mOneHandedManagerImpl.startOneHanded();
- verify(mMockDisplayAreaOrganizer, times(1)).scheduleOffset(anyInt(), anyInt());
+ verify(mMockDisplayAreaOrganizer).scheduleOffset(anyInt(), anyInt());
}
@Test
@@ -121,7 +126,7 @@
public void testStopOneHanded_shouldRemoveTimer() {
mOneHandedManagerImpl.stopOneHanded();
- verify(mTimeoutHandler, times(1)).removeTimer();
+ verify(mTimeoutHandler).removeTimer();
}
@Test
@@ -129,7 +134,14 @@
final boolean enabled = true;
mOneHandedManagerImpl.setOneHandedEnabled(enabled);
- verify(mMockTouchHandler, atLeastOnce()).onOneHandedEnabled(enabled);
+ verify(mMockTouchHandler, times(2)).onOneHandedEnabled(enabled);
}
+ @Test
+ public void testUpdateSwipeToNotificationIsEnabled() {
+ final boolean enabled = true;
+ mOneHandedManagerImpl.setSwipeToNotificationEnabled(enabled);
+
+ verify(mMockTouchHandler, times(2)).onOneHandedEnabled(enabled);
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedSettingsUtilTest.java b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedSettingsUtilTest.java
index c157ae6..f81d047 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedSettingsUtilTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedSettingsUtilTest.java
@@ -104,4 +104,10 @@
ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS,
ONE_HANDED_TIMEOUT_LONG_IN_SECONDS);
}
+
+ @Test
+ public void testGetSettingsSwipeToNotificationEnabled() {
+ assertThat(mOneHandedSettingsUtil.getSettingsSwipeToNotificationEnabled(
+ mContentResolver)).isAnyOf(true, false);
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTestCase.java b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTestCase.java
index befa42a..04ebf25 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTestCase.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTestCase.java
@@ -32,6 +32,7 @@
static boolean sOrigEnabled;
static boolean sOrigTapsAppToExitEnabled;
static int sOrigTimeout;
+ static boolean sOrigSwipeToNotification;
@Before
public void setupSettings() {
@@ -41,12 +42,16 @@
getContext().getContentResolver());
sOrigTapsAppToExitEnabled = OneHandedSettingsUtil.getSettingsTapsAppToExit(
getContext().getContentResolver());
+ sOrigSwipeToNotification = OneHandedSettingsUtil.getSettingsSwipeToNotificationEnabled(
+ getContext().getContentResolver());
Settings.Secure.putInt(getContext().getContentResolver(),
Settings.Secure.ONE_HANDED_MODE_ENABLED, 1);
Settings.Secure.putInt(getContext().getContentResolver(),
Settings.Secure.ONE_HANDED_MODE_TIMEOUT, ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS);
Settings.Secure.putInt(getContext().getContentResolver(),
Settings.Secure.TAPS_APP_TO_EXIT, 1);
+ Settings.Secure.putInt(getContext().getContentResolver(),
+ Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 1);
}
@After
@@ -57,6 +62,9 @@
Settings.Secure.ONE_HANDED_MODE_TIMEOUT, sOrigTimeout);
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.TAPS_APP_TO_EXIT, sOrigTapsAppToExitEnabled ? 1 : 0);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED,
+ sOrigSwipeToNotification ? 1 : 0);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTouchHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTouchHandlerTest.java
index fdb28d3..15881a2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTouchHandlerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTouchHandlerTest.java
@@ -22,14 +22,13 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import android.app.Instrumentation;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import androidx.test.filters.SmallTest;
-import androidx.test.platform.app.InstrumentationRegistry;
import com.android.systemui.model.SysUiState;
+import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.NavigationModeController;
import com.android.wm.shell.common.DisplayController;
@@ -44,12 +43,13 @@
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
public class OneHandedTouchHandlerTest extends OneHandedTestCase {
- Instrumentation mInstrumentation;
OneHandedTouchHandler mTouchHandler;
OneHandedTutorialHandler mTutorialHandler;
OneHandedGestureHandler mGestureHandler;
OneHandedManagerImpl mOneHandedManagerImpl;
@Mock
+ CommandQueue mCommandQueue;
+ @Mock
DisplayController mMockDisplayController;
@Mock
NavigationModeController mMockNavigationModeController;
@@ -61,11 +61,12 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mInstrumentation = InstrumentationRegistry.getInstrumentation();
mTouchHandler = Mockito.spy(new OneHandedTouchHandler());
mGestureHandler = new OneHandedGestureHandler(mContext, mMockDisplayController,
mMockNavigationModeController);
- mOneHandedManagerImpl = new OneHandedManagerImpl(mInstrumentation.getContext(),
+ mOneHandedManagerImpl = new OneHandedManagerImpl(
+ getContext(),
+ mCommandQueue,
mMockDisplayController,
mMockDisplayAreaOrganizer,
mTouchHandler,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTutorialHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTutorialHandlerTest.java
index f4aa00e..f2b77a0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTutorialHandlerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTutorialHandlerTest.java
@@ -19,14 +19,13 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import android.app.Instrumentation;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import androidx.test.filters.SmallTest;
-import androidx.test.platform.app.InstrumentationRegistry;
import com.android.systemui.model.SysUiState;
+import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.NavigationModeController;
import com.android.wm.shell.common.DisplayController;
@@ -41,12 +40,13 @@
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
public class OneHandedTutorialHandlerTest extends OneHandedTestCase {
- Instrumentation mInstrumentation;
OneHandedTouchHandler mTouchHandler;
OneHandedTutorialHandler mTutorialHandler;
OneHandedGestureHandler mGestureHandler;
OneHandedManagerImpl mOneHandedManagerImpl;
@Mock
+ CommandQueue mCommandQueue;
+ @Mock
DisplayController mMockDisplayController;
@Mock
NavigationModeController mMockNavigationModeController;
@@ -58,12 +58,13 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mInstrumentation = InstrumentationRegistry.getInstrumentation();
mTouchHandler = new OneHandedTouchHandler();
mTutorialHandler = Mockito.spy(new OneHandedTutorialHandler(mContext));
mGestureHandler = new OneHandedGestureHandler(mContext, mMockDisplayController,
mMockNavigationModeController);
- mOneHandedManagerImpl = new OneHandedManagerImpl(mInstrumentation.getContext(),
+ mOneHandedManagerImpl = new OneHandedManagerImpl(
+ getContext(),
+ mCommandQueue,
mMockDisplayController,
mMockDisplayAreaOrganizer,
mTouchHandler,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedUITest.java b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedUITest.java
index ffedb07..6db2679 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedUITest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedUITest.java
@@ -28,7 +28,6 @@
import androidx.test.filters.SmallTest;
import com.android.keyguard.KeyguardUpdateMonitor;
-import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.statusbar.CommandQueue;
@@ -53,8 +52,6 @@
@Mock
OneHandedManagerImpl mMockOneHandedManagerImpl;
@Mock
- DumpManager mMockDumpManager;
- @Mock
OneHandedSettingsUtil mMockSettingsUtil;
@Mock
OneHandedTimeoutHandler mMockTimeoutHandler;
@@ -68,7 +65,6 @@
mOneHandedUI = new OneHandedUI(mContext,
mCommandQueue,
mMockOneHandedManagerImpl,
- mMockDumpManager,
mMockSettingsUtil,
mScreenLifecycle);
mOneHandedUI.start();
@@ -168,6 +164,18 @@
OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS);
}
+ @Test
+ public void tesSettingsObserver_updateSwipeToNotification() {
+ // Bypass test if device not support one-handed mode
+ if (!mIsSupportOneHandedMode) {
+ return;
+ }
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 1);
+
+ verify(mMockOneHandedManagerImpl).setSwipeToNotificationEnabled(true);
+ }
+
@Ignore("Clarifying do not receive callback")
@Test
public void testKeyguardBouncerShowing_shouldStopOneHanded() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java
index 548da8e..3562032 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java
@@ -384,7 +384,7 @@
mPowerUI.mSevereWarningShownThisChargeCycle = false;
BatteryStateSnapshotWrapper state = new BatteryStateSnapshotWrapper();
- // sanity check to make sure we can show for a valid config
+ // readiness check to make sure we can show for a valid config
state.mBatteryLevel = 10;
state.mTimeRemainingMillis = Duration.ofHours(2).toMillis();
boolean shouldShow = mPowerUI.shouldShowHybridWarning(state.get());
@@ -449,7 +449,7 @@
mPowerUI.mSevereWarningShownThisChargeCycle = false;
BatteryStateSnapshotWrapper state = new BatteryStateSnapshotWrapper();
- // sanity check to make sure we can show for a valid config
+ // readiness check to make sure we can show for a valid config
state.mBatteryLevel = 1;
state.mTimeRemainingMillis = Duration.ofMinutes(1).toMillis();
boolean shouldShow = mPowerUI.shouldShowHybridWarning(state.get());
@@ -572,7 +572,7 @@
state.mIsHybrid = false;
BatteryStateSnapshot lastState = state.get();
- // sanity check to make sure we can show for a valid config
+ // readiness check to make sure we can show for a valid config
state.mBatteryLevel = 10;
state.mBucket = -1;
boolean shouldShow = mPowerUI.shouldShowLowBatteryWarning(state.get(), lastState);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
index bdb7166..c8e1a74 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
@@ -78,7 +78,7 @@
@RunWith(AndroidTestingRunner.class)
@SmallTest
-@RunWithLooper
+@RunWithLooper(setAsMainLooper = true)
public class QSTileHostTest extends SysuiTestCase {
private static String MOCK_STATE_STRING = "MockState";
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt
index c2579dd..3aa40de 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt
@@ -53,7 +53,7 @@
@SmallTest
@RunWith(AndroidTestingRunner::class)
-@TestableLooper.RunWithLooper
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
class CustomTileTest : SysuiTestCase() {
companion object {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java
index cccb65d..61a0d6c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java
@@ -244,6 +244,8 @@
assertNotEquals(DESTROYED, mTile.getLifecycle().getCurrentState());
mTile.handleDestroy();
+ mTestableLooper.processAllMessages();
+
assertEquals(DESTROYED, mTile.getLifecycle().getCurrentState());
}
@@ -298,6 +300,25 @@
assertNotEquals(DESTROYED, mTile.getLifecycle().getCurrentState());
}
+ @Test
+ public void testRefreshStateAfterDestroyedDoesNotCrash() {
+ mTile.destroy();
+ mTile.refreshState();
+
+ mTestableLooper.processAllMessages();
+ }
+
+ @Test
+ public void testSetListeningAfterDestroyedDoesNotCrash() {
+ Object o = new Object();
+ mTile.destroy();
+
+ mTile.setListening(o, true);
+ mTile.setListening(o, false);
+
+ mTestableLooper.processAllMessages();
+ }
+
private void assertEvent(UiEventLogger.UiEventEnum eventType,
UiEventLoggerFake.FakeUiEvent fakeEvent) {
assertEquals(eventType.getId(), fakeEvent.eventId);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/BatterySaverTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/BatterySaverTileTest.kt
index f70106a..2006a75 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/BatterySaverTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/BatterySaverTileTest.kt
@@ -38,7 +38,7 @@
import org.mockito.MockitoAnnotations
@RunWith(AndroidTestingRunner::class)
-@RunWithLooper
+@RunWithLooper(setAsMainLooper = true)
@SmallTest
class BatterySaverTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/CastTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/CastTileTest.java
index 8ece622..5d14898 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/CastTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/CastTileTest.java
@@ -58,7 +58,7 @@
@RunWith(AndroidTestingRunner.class)
-@TestableLooper.RunWithLooper
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class CastTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
index ddac2ec..fec4677 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
@@ -64,6 +64,7 @@
import com.android.systemui.statusbar.NotificationPresenter;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationShelf;
+import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
@@ -197,7 +198,10 @@
mEntryManager.setUpWithPresenter(mock(NotificationPresenter.class));
when(mFeatureFlags.isNewNotifPipelineRenderingEnabled()).thenReturn(false);
+ NotificationShelfController notificationShelfController =
+ mock(NotificationShelfController.class);
NotificationShelf notificationShelf = mock(NotificationShelf.class);
+ when(notificationShelfController.getView()).thenReturn(notificationShelf);
when(mNotificationSectionsManager.createSectionsForBuckets()).thenReturn(
new NotificationSection[]{
mNotificationSection
@@ -208,7 +212,7 @@
// holds a copy of the CUT's instances of these KeyguardBypassController, so they still
// refer to the CUT's member variables, not the spy's member variables.
mStackScrollerInternal = new NotificationStackScrollLayout(getContext(), null,
- true /* allowLongPress */, mNotificationRoundnessManager,
+ mNotificationRoundnessManager,
mock(DynamicPrivacyController.class),
mock(SysuiStatusBarStateController.class),
mHeadsUpManager,
@@ -230,7 +234,7 @@
verify(mLockscreenUserManager).addUserChangedListener(userChangedCaptor.capture());
mUserChangedListener = userChangedCaptor.getValue();
mStackScroller = spy(mStackScrollerInternal);
- mStackScroller.setShelf(notificationShelf);
+ mStackScroller.setShelfController(notificationShelfController);
mStackScroller.setStatusBar(mBar);
mStackScroller.setScrimController(mock(ScrimController.class));
mStackScroller.setGroupManager(mGroupManager);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
index e546dff..8dea84c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
@@ -38,7 +38,7 @@
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
-import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
+import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import org.junit.Assert;
@@ -51,8 +51,8 @@
@RunWithLooper
public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
- private final NotificationStackScrollLayout mStackScroller =
- mock(NotificationStackScrollLayout.class);
+ private final NotificationStackScrollLayoutController mStackScrollerController =
+ mock(NotificationStackScrollLayoutController.class);
private final NotificationPanelViewController mPanelView =
mock(NotificationPanelViewController.class);
private final DarkIconDispatcher mDarkIconDispatcher = mock(DarkIconDispatcher.class);
@@ -93,9 +93,9 @@
mWakeUpCoordinator,
mKeyguardStateController,
mCommandQueue,
- mHeadsUpStatusBarView,
- mStackScroller,
+ mStackScrollerController,
mPanelView,
+ mHeadsUpStatusBarView,
new View(mContext),
mOperatorNameView,
new View(mContext));
@@ -172,9 +172,9 @@
mWakeUpCoordinator,
mKeyguardStateController,
mCommandQueue,
- mHeadsUpStatusBarView,
- mStackScroller,
+ mStackScrollerController,
mPanelView,
+ mHeadsUpStatusBarView,
new View(mContext),
new View(mContext),
new View(mContext));
@@ -193,14 +193,14 @@
reset(mHeadsUpManager);
reset(mDarkIconDispatcher);
reset(mPanelView);
- reset(mStackScroller);
+ reset(mStackScrollerController);
mHeadsUpAppearanceController.destroy();
verify(mHeadsUpManager).removeListener(any());
verify(mDarkIconDispatcher).removeDarkReceiver((DarkIconDispatcher.DarkReceiver) any());
verify(mPanelView).removeVerticalTranslationListener(any());
verify(mPanelView).removeTrackingHeadsUpListener(any());
verify(mPanelView).setHeadsUpAppearanceController(any());
- verify(mStackScroller).removeOnExpandedHeightChangedListener(any());
- verify(mStackScroller).removeOnLayoutChangeListener(any());
+ verify(mStackScrollerController).removeOnExpandedHeightChangedListener(any());
+ verify(mStackScrollerController).removeOnLayoutChangeListener(any());
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarRotationContextTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarRotationContextTest.java
index f21235c..f665241 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarRotationContextTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarRotationContextTest.java
@@ -60,7 +60,7 @@
final View view = new View(mContext);
mRotationButton = mock(RotationButton.class);
mRotationButtonController = spy(new RotationButtonController(mContext, 0, 0,
- mRotationButton));
+ mRotationButton, (visibility) -> {}));
final KeyButtonDrawable kbd = mock(KeyButtonDrawable.class);
doReturn(view).when(mRotationButton).getCurrentView();
doReturn(true).when(mRotationButton).acceptRotationProposal();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
index c7434f6..f66fd56 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
@@ -63,7 +63,7 @@
import com.android.systemui.statusbar.FlingAnimationUtils;
import com.android.systemui.statusbar.KeyguardAffordanceView;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
-import com.android.systemui.statusbar.NotificationShelf;
+import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.PulseExpansionHandler;
import com.android.systemui.statusbar.StatusBarStateControllerImpl;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
@@ -72,8 +72,10 @@
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
+import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.stack.NotificationRoundnessManager;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
+import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.ZenModeController;
@@ -115,7 +117,7 @@
@Mock
private HeadsUpManagerPhone mHeadsUpManager;
@Mock
- private NotificationShelf mNotificationShelf;
+ private NotificationShelfController mNotificationShelfController;
@Mock
private NotificationGroupManager mGroupManager;
@Mock
@@ -186,8 +188,6 @@
private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
@Mock
private KeyguardClockSwitchController mKeyguardClockSwitchController;
- private FlingAnimationUtils.Builder mFlingAnimationUtilsBuilder;
-
private NotificationPanelViewController mNotificationPanelViewController;
private View.AccessibilityDelegate mAccessibiltyDelegate;
@@ -212,7 +212,8 @@
when(mKeyguardBottomArea.getRightView()).thenReturn(mock(KeyguardAffordanceView.class));
when(mView.findViewById(R.id.big_clock_container)).thenReturn(mBigClockContainer);
when(mView.findViewById(R.id.qs_frame)).thenReturn(mQsFrame);
- mFlingAnimationUtilsBuilder = new FlingAnimationUtils.Builder(mDisplayMetrics);
+ FlingAnimationUtils.Builder flingAnimationUtilsBuilder = new FlingAnimationUtils.Builder(
+ mDisplayMetrics);
doAnswer((Answer<Void>) invocation -> {
mTouchHandler = invocation.getArgument(0);
@@ -232,6 +233,11 @@
mock(NotificationRoundnessManager.class),
mStatusBarStateController,
new FalsingManagerFake());
+ NotificationStackScrollLayoutController notificationStackScrollLayoutController =
+ new NotificationStackScrollLayoutController(
+ true /* allowLongPress */,
+ mock(NotificationGutsManager.class)
+ );
mNotificationPanelViewController = new NotificationPanelViewController(mView,
mInjectionInflationController,
coordinator, expansionHandler, mDynamicPrivacyController, mKeyguardBypassController,
@@ -241,19 +247,19 @@
mDozeParameters, mCommandQueue, mVibratorHelper,
mLatencyTracker, mPowerManager, mAccessibilityManager, 0, mUpdateMonitor,
mMetricsLogger, mActivityManager, mZenModeController, mConfigurationController,
- mFlingAnimationUtilsBuilder, mStatusBarTouchableRegionManager,
+ flingAnimationUtilsBuilder, mStatusBarTouchableRegionManager,
mConversationNotificationManager, mMediaHiearchyManager,
mBiometricUnlockController, mStatusBarKeyguardViewManager,
- () -> mKeyguardClockSwitchController);
+ () -> mKeyguardClockSwitchController,
+ notificationStackScrollLayoutController);
mNotificationPanelViewController.initDependencies(mStatusBar, mGroupManager,
- mNotificationShelf, mNotificationAreaController, mScrimController);
+ mNotificationShelfController, mNotificationAreaController, mScrimController);
mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager);
mNotificationPanelViewController.setBar(mPanelBar);
ArgumentCaptor<View.AccessibilityDelegate> accessibilityDelegateArgumentCaptor =
ArgumentCaptor.forClass(View.AccessibilityDelegate.class);
- verify(mView)
- .setAccessibilityDelegate(accessibilityDelegateArgumentCaptor.capture());
+ verify(mView).setAccessibilityDelegate(accessibilityDelegateArgumentCaptor.capture());
mAccessibiltyDelegate = accessibilityDelegateArgumentCaptor.getValue();
}
diff --git a/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringNotificationUpdaterTest.kt b/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringNotificationUpdaterTest.kt
index 4b6bbac..75c819b 100644
--- a/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringNotificationUpdaterTest.kt
+++ b/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringNotificationUpdaterTest.kt
@@ -18,33 +18,40 @@
import android.app.Notification
import android.app.NotificationManager
+import android.app.PendingIntent
+import android.app.PendingIntent.FLAG_IMMUTABLE
import android.content.Context
+import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.content.res.Resources
import android.net.ConnectivityManager.TETHERING_WIFI
+import android.net.NetworkCapabilities
+import android.net.NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING
import android.os.Handler
import android.os.HandlerThread
import android.os.Looper
-import android.net.NetworkCapabilities
-import android.net.NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING
import android.os.UserHandle
+import android.provider.Settings
import android.telephony.TelephonyManager
import androidx.test.filters.SmallTest
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.runner.AndroidJUnit4
import com.android.internal.util.test.BroadcastInterceptingContext
+import com.android.networkstack.tethering.TetheringNotificationUpdater.ACTION_DISABLE_TETHERING
import com.android.networkstack.tethering.TetheringNotificationUpdater.DOWNSTREAM_NONE
import com.android.networkstack.tethering.TetheringNotificationUpdater.EVENT_SHOW_NO_UPSTREAM
import com.android.networkstack.tethering.TetheringNotificationUpdater.NO_UPSTREAM_NOTIFICATION_ID
import com.android.networkstack.tethering.TetheringNotificationUpdater.RESTRICTED_NOTIFICATION_ID
import com.android.networkstack.tethering.TetheringNotificationUpdater.ROAMING_NOTIFICATION_ID
import com.android.networkstack.tethering.TetheringNotificationUpdater.VERIZON_CARRIER_ID
+import com.android.networkstack.tethering.TetheringNotificationUpdater.getSettingsPackageName
import com.android.testutils.waitForIdle
import org.junit.After
import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNotNull
import org.junit.Assert.fail
import org.junit.Before
import org.junit.Test
@@ -87,12 +94,17 @@
// every test but should always be initialized before use (or the test should crash).
private lateinit var context: TestContext
private lateinit var notificationUpdater: TetheringNotificationUpdater
+
+ // Initializing the following members depends on initializing some of the mocks and
+ // is more logically done in setup().
private lateinit var fakeTetheringThread: HandlerThread
private val ROAMING_CAPABILITIES = NetworkCapabilities()
private val HOME_CAPABILITIES = NetworkCapabilities().addCapability(NET_CAPABILITY_NOT_ROAMING)
private val NOTIFICATION_ICON_ID = R.drawable.stat_sys_tether_general
private val TIMEOUT_MS = 500L
+ private val ACTIVITY_PENDING_INTENT = 0
+ private val BROADCAST_PENDING_INTENT = 1
private inner class TestContext(c: Context) : BroadcastInterceptingContext(c) {
override fun createContextAsUser(user: UserHandle, flags: Int) =
@@ -146,10 +158,43 @@
fakeTetheringThread.quitSafely()
}
+ private fun verifyActivityPendingIntent(intent: Intent, flags: Int) {
+ // Use FLAG_NO_CREATE to verify whether PendingIntent has FLAG_IMMUTABLE flag(forcefully add
+ // the flag in creating arguments). If the described PendingIntent does not already exist,
+ // getActivity() will return null instead of PendingIntent object.
+ val pi = PendingIntent.getActivity(
+ context.createContextAsUser(UserHandle.CURRENT, 0 /* flags */),
+ 0 /* requestCode */,
+ intent,
+ flags or FLAG_IMMUTABLE or PendingIntent.FLAG_NO_CREATE,
+ null /* options */)
+ assertNotNull("Activity PendingIntent with FLAG_IMMUTABLE does not exist.", pi)
+ }
+
+ private fun verifyBroadcastPendingIntent(intent: Intent, flags: Int) {
+ // Use FLAG_NO_CREATE to verify whether PendingIntent has FLAG_IMMUTABLE flag(forcefully add
+ // the flag in creating arguments). If the described PendingIntent does not already exist,
+ // getBroadcast() will return null instead of PendingIntent object.
+ val pi = PendingIntent.getBroadcast(
+ context.createContextAsUser(UserHandle.CURRENT, 0 /* flags */),
+ 0 /* requestCode */,
+ intent,
+ flags or FLAG_IMMUTABLE or PendingIntent.FLAG_NO_CREATE)
+ assertNotNull("Broadcast PendingIntent with FLAG_IMMUTABLE does not exist.", pi)
+ }
+
private fun Notification.title() = this.extras.getString(Notification.EXTRA_TITLE)
private fun Notification.text() = this.extras.getString(Notification.EXTRA_TEXT)
- private fun verifyNotification(iconId: Int, title: String, text: String, id: Int) {
+ private fun verifyNotification(
+ iconId: Int,
+ title: String,
+ text: String,
+ id: Int,
+ intentSenderType: Int,
+ intent: Intent,
+ flags: Int
+ ) {
verify(notificationManager, never()).cancel(any(), eq(id))
val notificationCaptor = ArgumentCaptor.forClass(Notification::class.java)
@@ -161,6 +206,11 @@
assertEquals(title, notification.title())
assertEquals(text, notification.text())
+ when (intentSenderType) {
+ ACTIVITY_PENDING_INTENT -> verifyActivityPendingIntent(intent, flags)
+ BROADCAST_PENDING_INTENT -> verifyBroadcastPendingIntent(intent, flags)
+ }
+
reset(notificationManager)
}
@@ -176,6 +226,10 @@
@Test
fun testRestrictedNotification() {
+ val settingsIntent = Intent(Settings.ACTION_TETHER_SETTINGS)
+ .setPackage(getSettingsPackageName(context.packageManager))
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+
// Set test sub id.
notificationUpdater.onActiveDataSubscriptionIdChanged(TEST_SUBID)
verifyNotificationCancelled(listOf(NO_UPSTREAM_NOTIFICATION_ID, ROAMING_NOTIFICATION_ID))
@@ -183,7 +237,7 @@
// User restrictions on. Show restricted notification.
notificationUpdater.notifyTetheringDisabledByRestriction()
verifyNotification(NOTIFICATION_ICON_ID, TEST_DISALLOW_TITLE, TEST_DISALLOW_MESSAGE,
- RESTRICTED_NOTIFICATION_ID)
+ RESTRICTED_NOTIFICATION_ID, ACTIVITY_PENDING_INTENT, settingsIntent, FLAG_IMMUTABLE)
// User restrictions off. Clear notification.
notificationUpdater.tetheringRestrictionLifted()
@@ -196,7 +250,7 @@
// User restrictions on again. Show restricted notification.
notificationUpdater.notifyTetheringDisabledByRestriction()
verifyNotification(NOTIFICATION_ICON_ID, TEST_DISALLOW_TITLE, TEST_DISALLOW_MESSAGE,
- RESTRICTED_NOTIFICATION_ID)
+ RESTRICTED_NOTIFICATION_ID, ACTIVITY_PENDING_INTENT, settingsIntent, FLAG_IMMUTABLE)
}
val MAX_BACKOFF_MS = 200L
@@ -234,6 +288,8 @@
@Test
fun testNoUpstreamNotification() {
+ val disableIntent = Intent(ACTION_DISABLE_TETHERING).setPackage(context.packageName)
+
// Set test sub id.
notificationUpdater.onActiveDataSubscriptionIdChanged(TEST_SUBID)
verifyNotificationCancelled(listOf(NO_UPSTREAM_NOTIFICATION_ID, ROAMING_NOTIFICATION_ID))
@@ -246,7 +302,8 @@
notificationUpdater.onUpstreamCapabilitiesChanged(null)
notificationUpdater.handler.waitForDelayedMessage(EVENT_SHOW_NO_UPSTREAM, TIMEOUT_MS)
verifyNotification(NOTIFICATION_ICON_ID, TEST_NO_UPSTREAM_TITLE, TEST_NO_UPSTREAM_MESSAGE,
- NO_UPSTREAM_NOTIFICATION_ID)
+ NO_UPSTREAM_NOTIFICATION_ID, BROADCAST_PENDING_INTENT, disableIntent,
+ FLAG_IMMUTABLE)
// Same capabilities changed. Nothing happened.
notificationUpdater.onUpstreamCapabilitiesChanged(null)
@@ -260,7 +317,8 @@
notificationUpdater.onUpstreamCapabilitiesChanged(null)
notificationUpdater.handler.waitForDelayedMessage(EVENT_SHOW_NO_UPSTREAM, TIMEOUT_MS)
verifyNotification(NOTIFICATION_ICON_ID, TEST_NO_UPSTREAM_TITLE, TEST_NO_UPSTREAM_MESSAGE,
- NO_UPSTREAM_NOTIFICATION_ID)
+ NO_UPSTREAM_NOTIFICATION_ID, BROADCAST_PENDING_INTENT, disableIntent,
+ FLAG_IMMUTABLE)
// No downstream.
notificationUpdater.onDownstreamChanged(DOWNSTREAM_NONE)
@@ -305,6 +363,11 @@
@Test
fun testRoamingNotification() {
+ val disableIntent = Intent(ACTION_DISABLE_TETHERING).setPackage(context.packageName)
+ val settingsIntent = Intent(Settings.ACTION_TETHER_SETTINGS)
+ .setPackage(getSettingsPackageName(context.packageManager))
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+
// Set test sub id.
notificationUpdater.onActiveDataSubscriptionIdChanged(TEST_SUBID)
verifyNotificationCancelled(listOf(NO_UPSTREAM_NOTIFICATION_ID, ROAMING_NOTIFICATION_ID))
@@ -316,7 +379,7 @@
// Upstream capabilities changed to roaming state. Show roaming notification.
notificationUpdater.onUpstreamCapabilitiesChanged(ROAMING_CAPABILITIES)
verifyNotification(NOTIFICATION_ICON_ID, TEST_ROAMING_TITLE, TEST_ROAMING_MESSAGE,
- ROAMING_NOTIFICATION_ID)
+ ROAMING_NOTIFICATION_ID, ACTIVITY_PENDING_INTENT, settingsIntent, FLAG_IMMUTABLE)
// Same capabilities change. Nothing happened.
notificationUpdater.onUpstreamCapabilitiesChanged(ROAMING_CAPABILITIES)
@@ -329,14 +392,15 @@
// Upstream capabilities changed to roaming state again. Show roaming notification.
notificationUpdater.onUpstreamCapabilitiesChanged(ROAMING_CAPABILITIES)
verifyNotification(NOTIFICATION_ICON_ID, TEST_ROAMING_TITLE, TEST_ROAMING_MESSAGE,
- ROAMING_NOTIFICATION_ID)
+ ROAMING_NOTIFICATION_ID, ACTIVITY_PENDING_INTENT, settingsIntent, FLAG_IMMUTABLE)
// No upstream. Clear roaming notification and show no upstream notification.
notificationUpdater.onUpstreamCapabilitiesChanged(null)
notificationUpdater.handler.waitForDelayedMessage(EVENT_SHOW_NO_UPSTREAM, TIMEOUT_MS)
verifyNotificationCancelled(listOf(ROAMING_NOTIFICATION_ID), false)
verifyNotification(NOTIFICATION_ICON_ID, TEST_NO_UPSTREAM_TITLE, TEST_NO_UPSTREAM_MESSAGE,
- NO_UPSTREAM_NOTIFICATION_ID)
+ NO_UPSTREAM_NOTIFICATION_ID, BROADCAST_PENDING_INTENT, disableIntent,
+ FLAG_IMMUTABLE)
// No downstream.
notificationUpdater.onDownstreamChanged(DOWNSTREAM_NONE)
@@ -347,7 +411,8 @@
notificationUpdater.handler.waitForDelayedMessage(EVENT_SHOW_NO_UPSTREAM, TIMEOUT_MS)
verifyNotificationCancelled(listOf(ROAMING_NOTIFICATION_ID), false)
verifyNotification(NOTIFICATION_ICON_ID, TEST_NO_UPSTREAM_TITLE, TEST_NO_UPSTREAM_MESSAGE,
- NO_UPSTREAM_NOTIFICATION_ID)
+ NO_UPSTREAM_NOTIFICATION_ID, BROADCAST_PENDING_INTENT, disableIntent,
+ FLAG_IMMUTABLE)
// Set R.bool.config_upstream_roaming_notification to false and change upstream
// network to roaming state again. No roaming notification.
@@ -363,8 +428,7 @@
val testSettingsPackageName = "com.android.test.settings"
val pm = mock(PackageManager::class.java)
doReturn(null).`when`(pm).resolveActivity(any(), anyInt())
- assertEquals(defaultSettingsPackageName,
- TetheringNotificationUpdater.getSettingsPackageName(pm))
+ assertEquals(defaultSettingsPackageName, getSettingsPackageName(pm))
val resolveInfo = ResolveInfo().apply {
activityInfo = ActivityInfo().apply {
@@ -375,7 +439,6 @@
}
}
doReturn(resolveInfo).`when`(pm).resolveActivity(any(), anyInt())
- assertEquals(testSettingsPackageName,
- TetheringNotificationUpdater.getSettingsPackageName(pm))
+ assertEquals(testSettingsPackageName, getSettingsPackageName(pm))
}
}
diff --git a/services/Android.bp b/services/Android.bp
index ef52c2a..b348b91 100644
--- a/services/Android.bp
+++ b/services/Android.bp
@@ -156,14 +156,10 @@
java_library {
name: "android_system_server_stubs_current",
- defaults: ["android_stubs_dists_default"],
srcs: [":services-stubs.sources"],
installable: false,
static_libs: ["android_module_lib_stubs_current"],
sdk_version: "none",
system_modules: "none",
java_version: "1.8",
- dist: {
- dir: "apistubs/android/system-server",
- },
}
diff --git a/services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java b/services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java
index 9ad808a..a167ab1 100644
--- a/services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java
+++ b/services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java
@@ -148,6 +148,8 @@
private boolean mRequestMultiFingerGestures;
+ private boolean mRequestTwoFingerPassthrough;
+
boolean mRequestFilterKeyEvents;
boolean mRetrieveInteractiveWindows;
@@ -325,8 +327,10 @@
& AccessibilityServiceInfo.FLAG_SERVICE_HANDLES_DOUBLE_TAP) != 0;
mRequestMultiFingerGestures = (info.flags
& AccessibilityServiceInfo.FLAG_REQUEST_MULTI_FINGER_GESTURES) != 0;
- mRequestFilterKeyEvents = (info.flags
- & AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS) != 0;
+ mRequestTwoFingerPassthrough =
+ (info.flags & AccessibilityServiceInfo.FLAG_REQUEST_2_FINGER_PASSTHROUGH) != 0;
+ mRequestFilterKeyEvents =
+ (info.flags & AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS) != 0;
mRetrieveInteractiveWindows = (info.flags
& AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS) != 0;
mCaptureFingerprintGestures = (info.flags
@@ -1772,6 +1776,10 @@
return mRequestMultiFingerGestures;
}
+ public boolean isTwoFingerPassthroughEnabled() {
+ return mRequestTwoFingerPassthrough;
+ }
+
@Override
public void setGestureDetectionPassthroughRegion(int displayId, Region region) {
mSystemSupport.setGestureDetectionPassthroughRegion(displayId, region);
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java
index 8b40f61..cd9ab8d 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java
@@ -118,6 +118,13 @@
*/
static final int FLAG_REQUEST_MULTI_FINGER_GESTURES = 0x00000100;
+ /**
+ * Flag for enabling multi-finger gestures.
+ *
+ * @see #setUserAndEnabledFeatures(int, int)
+ */
+ static final int FLAG_REQUEST_2_FINGER_PASSTHROUGH = 0x00000200;
+
static final int FEATURES_AFFECTING_MOTION_EVENTS =
FLAG_FEATURE_INJECT_MOTION_EVENTS
| FLAG_FEATURE_AUTOCLICK
@@ -125,7 +132,8 @@
| FLAG_FEATURE_SCREEN_MAGNIFIER
| FLAG_FEATURE_TRIGGERED_SCREEN_MAGNIFIER
| FLAG_SERVICE_HANDLES_DOUBLE_TAP
- | FLAG_REQUEST_MULTI_FINGER_GESTURES;
+ | FLAG_REQUEST_MULTI_FINGER_GESTURES
+ | FLAG_REQUEST_2_FINGER_PASSTHROUGH;
private final Context mContext;
@@ -421,6 +429,9 @@
if ((mEnabledFeatures & FLAG_REQUEST_MULTI_FINGER_GESTURES) != 0) {
explorer.setMultiFingerGesturesEnabled(true);
}
+ if ((mEnabledFeatures & FLAG_REQUEST_2_FINGER_PASSTHROUGH) != 0) {
+ explorer.setTwoFingerPassthroughEnabled(true);
+ }
addFirstEventHandler(displayId, explorer);
mTouchExplorer.put(displayId, explorer);
}
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index b134022..833aeec 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -1837,6 +1837,9 @@
if (userState.isMultiFingerGesturesEnabledLocked()) {
flags |= AccessibilityInputFilter.FLAG_REQUEST_MULTI_FINGER_GESTURES;
}
+ if (userState.isTwoFingerPassthroughEnabledLocked()) {
+ flags |= AccessibilityInputFilter.FLAG_REQUEST_2_FINGER_PASSTHROUGH;
+ }
}
if (userState.isFilterKeyEventsEnabledLocked()) {
flags |= AccessibilityInputFilter.FLAG_FEATURE_FILTER_KEY_EVENTS;
@@ -2120,6 +2123,7 @@
boolean touchExplorationEnabled = mUiAutomationManager.isTouchExplorationEnabledLocked();
boolean serviceHandlesDoubleTapEnabled = false;
boolean requestMultiFingerGestures = false;
+ boolean requestTwoFingerPassthrough = false;
final int serviceCount = userState.mBoundServices.size();
for (int i = 0; i < serviceCount; i++) {
AccessibilityServiceConnection service = userState.mBoundServices.get(i);
@@ -2127,6 +2131,7 @@
touchExplorationEnabled = true;
serviceHandlesDoubleTapEnabled = service.isServiceHandlesDoubleTapEnabled();
requestMultiFingerGestures = service.isMultiFingerGesturesEnabled();
+ requestTwoFingerPassthrough = service.isTwoFingerPassthroughEnabled();
break;
}
}
@@ -2143,6 +2148,7 @@
}
userState.setServiceHandlesDoubleTapLocked(serviceHandlesDoubleTapEnabled);
userState.setMultiFingerGesturesLocked(requestMultiFingerGestures);
+ userState.setTwoFingerPassthroughLocked(requestTwoFingerPassthrough);
}
private boolean readAccessibilityShortcutKeySettingLocked(AccessibilityUserState userState) {
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java
index f865aa7..4c9e444 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java
@@ -110,6 +110,7 @@
private boolean mIsTouchExplorationEnabled;
private boolean mServiceHandlesDoubleTap;
private boolean mRequestMultiFingerGestures;
+ private boolean mRequestTwoFingerPassthrough;
private int mUserInteractiveUiTimeout;
private int mUserNonInteractiveUiTimeout;
private int mNonInteractiveUiTimeout = 0;
@@ -169,6 +170,7 @@
mIsTouchExplorationEnabled = false;
mServiceHandlesDoubleTap = false;
mRequestMultiFingerGestures = false;
+ mRequestTwoFingerPassthrough = false;
mIsDisplayMagnificationEnabled = false;
mIsAutoclickEnabled = false;
mUserNonInteractiveUiTimeout = 0;
@@ -456,6 +458,8 @@
.append(String.valueOf(mServiceHandlesDoubleTap));
pw.append(", requestMultiFingerGestures=")
.append(String.valueOf(mRequestMultiFingerGestures));
+ pw.append(", requestTwoFingerPassthrough=")
+ .append(String.valueOf(mRequestTwoFingerPassthrough));
pw.append(", displayMagnificationEnabled=").append(String.valueOf(
mIsDisplayMagnificationEnabled));
pw.append(", autoclickEnabled=").append(String.valueOf(mIsAutoclickEnabled));
@@ -790,6 +794,14 @@
public void setMultiFingerGesturesLocked(boolean enabled) {
mRequestMultiFingerGestures = enabled;
}
+ public boolean isTwoFingerPassthroughEnabledLocked() {
+ return mRequestTwoFingerPassthrough;
+ }
+
+ public void setTwoFingerPassthroughLocked(boolean enabled) {
+ mRequestTwoFingerPassthrough = enabled;
+ }
+
public int getUserInteractiveUiTimeoutLocked() {
return mUserInteractiveUiTimeout;
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/GestureManifold.java b/services/accessibility/java/com/android/server/accessibility/gestures/GestureManifold.java
index e9c70c6..8604fe7 100644
--- a/services/accessibility/java/com/android/server/accessibility/gestures/GestureManifold.java
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/GestureManifold.java
@@ -94,8 +94,13 @@
private boolean mServiceHandlesDoubleTap = false;
// Whether multi-finger gestures are enabled.
boolean mMultiFingerGesturesEnabled;
+ // Whether the two-finger passthrough is enabled when multi-finger gestures are enabled.
+ private boolean mTwoFingerPassthroughEnabled;
// A list of all the multi-finger gestures, for easy adding and removal.
private final List<GestureMatcher> mMultiFingerGestures = new ArrayList<>();
+ // A list of two-finger swipes, for easy adding and removal when turning on or off two-finger
+ // passthrough.
+ private final List<GestureMatcher> mTwoFingerSwipes = new ArrayList<>();
// Shared state information.
private TouchState mState;
@@ -105,6 +110,7 @@
mListener = listener;
mState = state;
mMultiFingerGesturesEnabled = false;
+ mTwoFingerPassthroughEnabled = false;
// Set up gestures.
// Start with double tap.
mGestures.add(new MultiTap(context, 2, GESTURE_DOUBLE_TAP, this));
@@ -161,14 +167,14 @@
mMultiFingerGestures.add(
new MultiFingerMultiTap(mContext, 4, 3, GESTURE_4_FINGER_TRIPLE_TAP, this));
// Two-finger swipes.
- mMultiFingerGestures.add(
+ mTwoFingerSwipes.add(
new MultiFingerSwipe(context, 2, DOWN, GESTURE_2_FINGER_SWIPE_DOWN, this));
- mMultiFingerGestures.add(
+ mTwoFingerSwipes.add(
new MultiFingerSwipe(context, 2, LEFT, GESTURE_2_FINGER_SWIPE_LEFT, this));
- mMultiFingerGestures.add(
+ mTwoFingerSwipes.add(
new MultiFingerSwipe(context, 2, RIGHT, GESTURE_2_FINGER_SWIPE_RIGHT, this));
- mMultiFingerGestures.add(
- new MultiFingerSwipe(context, 2, UP, GESTURE_2_FINGER_SWIPE_UP, this));
+ mTwoFingerSwipes.add(new MultiFingerSwipe(context, 2, UP, GESTURE_2_FINGER_SWIPE_UP, this));
+ mMultiFingerGestures.addAll(mTwoFingerSwipes);
// Three-finger swipes.
mMultiFingerGestures.add(
new MultiFingerSwipe(context, 3, DOWN, GESTURE_3_FINGER_SWIPE_DOWN, this));
@@ -360,6 +366,25 @@
}
}
+ public boolean isTwoFingerPassthroughEnabled() {
+ return mTwoFingerPassthroughEnabled;
+ }
+
+ public void setTwoFingerPassthroughEnabled(boolean mode) {
+ if (mTwoFingerPassthroughEnabled != mode) {
+ mTwoFingerPassthroughEnabled = mode;
+ if (!mode) {
+ mMultiFingerGestures.addAll(mTwoFingerSwipes);
+ if (mMultiFingerGesturesEnabled) {
+ mGestures.addAll(mTwoFingerSwipes);
+ }
+ } else {
+ mMultiFingerGestures.removeAll(mTwoFingerSwipes);
+ mGestures.removeAll(mTwoFingerSwipes);
+ }
+ }
+ }
+
public void setServiceHandlesDoubleTap(boolean mode) {
mServiceHandlesDoubleTap = mode;
}
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java b/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
index 696702f..c45da86 100644
--- a/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
@@ -41,6 +41,7 @@
import android.content.Context;
import android.graphics.Region;
import android.os.Handler;
+import android.util.DisplayMetrics;
import android.util.Slog;
import android.view.InputDevice;
import android.view.MotionEvent;
@@ -91,12 +92,21 @@
// The timeout after which we are no longer trying to detect a gesture.
private static final int EXIT_GESTURE_DETECTION_TIMEOUT = 2000;
+ // The height of the top and bottom edges for edge-swipes.
+ // For now this is only used to allow three-finger edge-swipes from the bottom.
+ private static final float EDGE_SWIPE_HEIGHT_CM = 0.25f;
+
+ // The calculated edge height for the top and bottom edges.
+ private final float mEdgeSwipeHeightPixels;
// Timeout before trying to decide what the user is trying to do.
private final int mDetermineUserIntentTimeout;
// Slop between the first and second tap to be a double tap.
private final int mDoubleTapSlop;
+ // Slop to move before being considered a move rather than a tap.
+ private final int mTouchSlop;
+
// The current state of the touch explorer.
private TouchState mState;
@@ -174,6 +184,9 @@
mDispatcher = new EventDispatcher(context, mAms, super.getNext(), mState);
mDetermineUserIntentTimeout = ViewConfiguration.getDoubleTapTimeout();
mDoubleTapSlop = ViewConfiguration.get(context).getScaledDoubleTapSlop();
+ mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
+ DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
+ mEdgeSwipeHeightPixels = metrics.ydpi / GestureUtils.CM_PER_INCH * EDGE_SWIPE_HEIGHT_CM;
mHandler = mainHandler;
mExitGestureDetectionModeDelayed = new ExitGestureDetectionModeDelayed();
mSendHoverEnterAndMoveDelayed = new SendHoverEnterAndMoveDelayed();
@@ -219,16 +232,10 @@
if (mState.isTouchExploring()) {
// If a touch exploration gesture is in progress send events for its end.
sendHoverExitAndTouchExplorationGestureEndIfNeeded(policyFlags);
- } else if (mState.isDragging()) {
- mDraggingPointerId = INVALID_POINTER_ID;
- // Send exit to all pointers that we have delivered.
- mDispatcher.sendUpForInjectedDownPointers(event, policyFlags);
- } else if (mState.isDelegating()) {
- // Send exit to all pointers that we have delivered.
- mDispatcher.sendUpForInjectedDownPointers(event, policyFlags);
- } else if (mState.isGestureDetecting()) {
- // No state specific cleanup required.
}
+ mDraggingPointerId = INVALID_POINTER_ID;
+ // Send exit to any pointers that we have delivered as part of delegating or dragging.
+ mDispatcher.sendUpForInjectedDownPointers(event, policyFlags);
// Remove all pending callbacks.
mSendHoverEnterAndMoveDelayed.cancel();
mSendHoverExitDelayed.cancel();
@@ -554,7 +561,26 @@
// stream consistent.
sendHoverExitAndTouchExplorationGestureEndIfNeeded(policyFlags);
}
+ if (mGestureDetector.isMultiFingerGesturesEnabled()
+ && mGestureDetector.isTwoFingerPassthroughEnabled()) {
+ if (event.getPointerCount() == 3) {
+ boolean isOnBottomEdge = false;
+ // If three fingers go down on the bottom edge of the screen, delegate immediately.
+ final long screenHeight = mContext.getResources().getDisplayMetrics().heightPixels;
+ for (int i = 0; i < TouchState.MAX_POINTER_COUNT; ++i) {
+ if (mReceivedPointerTracker.getReceivedPointerDownY(i)
+ > (screenHeight - mEdgeSwipeHeightPixels)) {
+ isOnBottomEdge = true;
+ }
+ }
+ if (isOnBottomEdge) {
+ mState.startDelegating();
+ mDispatcher.sendDownForAllNotInjectedPointers(event, policyFlags);
+ }
+ }
+ }
}
+
/**
* Handles ACTION_MOVE while in the touch interacting state. This is where transitions to
* delegating and dragging states are handled.
@@ -563,7 +589,7 @@
MotionEvent event, MotionEvent rawEvent, int policyFlags) {
final int pointerId = mReceivedPointerTracker.getPrimaryPointerId();
final int pointerIndex = event.findPointerIndex(pointerId);
- final int pointerIdBits = (1 << pointerId);
+ int pointerIdBits = (1 << pointerId);
switch (event.getPointerCount()) {
case 1:
// We have not started sending events since we try to
@@ -574,12 +600,29 @@
}
break;
case 2:
- if (mGestureDetector.isMultiFingerGesturesEnabled()) {
+ if (mGestureDetector.isMultiFingerGesturesEnabled()
+ && !mGestureDetector.isTwoFingerPassthroughEnabled()) {
return;
}
// Make sure we don't have any pending transitions to touch exploration
mSendHoverEnterAndMoveDelayed.cancel();
mSendHoverExitDelayed.cancel();
+ if (mGestureDetector.isMultiFingerGesturesEnabled()
+ && mGestureDetector.isTwoFingerPassthroughEnabled()) {
+ if (pointerIndex < 0) {
+ return;
+ }
+ final float deltaX =
+ mReceivedPointerTracker.getReceivedPointerDownX(pointerId)
+ - rawEvent.getX(pointerIndex);
+ final float deltaY =
+ mReceivedPointerTracker.getReceivedPointerDownY(pointerId)
+ - rawEvent.getY(pointerIndex);
+ final double moveDelta = Math.hypot(deltaX, deltaY);
+ if (moveDelta < mTouchSlop) {
+ return;
+ }
+ }
// More than one pointer so the user is not touch exploring
// and now we have to decide whether to delegate or drag.
// Remove move history before send injected non-move events
@@ -588,8 +631,8 @@
// Two pointers moving in the same direction within
// a given distance perform a drag.
mState.startDragging();
- mDraggingPointerId = pointerId;
adjustEventLocationForDrag(event);
+ pointerIdBits = 1 << mDraggingPointerId;
event.setEdgeFlags(mReceivedPointerTracker.getLastReceivedDownEdgeFlags());
mDispatcher.sendMotionEvent(
event, ACTION_DOWN, rawEvent, pointerIdBits, policyFlags);
@@ -648,7 +691,8 @@
event, ACTION_HOVER_MOVE, rawEvent, pointerIdBits, policyFlags);
break;
case 2:
- if (mGestureDetector.isMultiFingerGesturesEnabled()) {
+ if (mGestureDetector.isMultiFingerGesturesEnabled()
+ && !mGestureDetector.isTwoFingerPassthroughEnabled()) {
return;
}
if (mSendHoverEnterAndMoveDelayed.isPending()) {
@@ -703,7 +747,8 @@
*/
private void handleMotionEventStateDragging(
MotionEvent event, MotionEvent rawEvent, int policyFlags) {
- if (mGestureDetector.isMultiFingerGesturesEnabled()) {
+ if (mGestureDetector.isMultiFingerGesturesEnabled()
+ && !mGestureDetector.isTwoFingerPassthroughEnabled()) {
// Multi-finger gestures conflict with this functionality.
return;
}
@@ -756,6 +801,7 @@
// The two pointers are moving either in different directions or
// no close enough => delegate the gesture to the view hierarchy.
mState.startDelegating();
+ mDraggingPointerId = INVALID_POINTER_ID;
// Remove move history before send injected non-move events
event = MotionEvent.obtainNoHistory(event);
// Send an event to the end of the drag gesture.
@@ -767,6 +813,7 @@
break;
default:
mState.startDelegating();
+ mDraggingPointerId = INVALID_POINTER_ID;
event = MotionEvent.obtainNoHistory(event);
// Send an event to the end of the drag gesture.
mDispatcher.sendMotionEvent(
@@ -784,15 +831,16 @@
}
break;
case ACTION_UP:
- mAms.onTouchInteractionEnd();
- // Announce the end of a new touch interaction.
- mDispatcher.sendAccessibilityEvent(TYPE_TOUCH_INTERACTION_END);
if (event.getPointerId(GestureUtils.getActionIndex(event)) == mDraggingPointerId) {
mDraggingPointerId = INVALID_POINTER_ID;
// Send an event to the end of the drag gesture.
mDispatcher.sendMotionEvent(
event, ACTION_UP, rawEvent, pointerIdBits, policyFlags);
}
+ mAms.onTouchInteractionEnd();
+ // Announce the end of a new touch interaction.
+ mDispatcher.sendAccessibilityEvent(TYPE_TOUCH_INTERACTION_END);
+
break;
}
}
@@ -911,21 +959,62 @@
}
/**
- * Adjust the location of an injected event when performing a drag The new location will be in
- * between the two fingers touching the screen.
+ * Adjust the location of an injected event when performing a drag. The location will be the
+ * location of the finger closest to an edge of the screen.
*/
private void adjustEventLocationForDrag(MotionEvent event) {
-
final float firstPtrX = event.getX(0);
final float firstPtrY = event.getY(0);
+ final int firstPtrId = event.getPointerId(0);
final float secondPtrX = event.getX(1);
final float secondPtrY = event.getY(1);
- final int pointerIndex = event.findPointerIndex(mDraggingPointerId);
- final float deltaX =
- (pointerIndex == 0) ? (secondPtrX - firstPtrX) : (firstPtrX - secondPtrX);
- final float deltaY =
- (pointerIndex == 0) ? (secondPtrY - firstPtrY) : (firstPtrY - secondPtrY);
- event.offsetLocation(deltaX / 2, deltaY / 2);
+ final int secondPtrId = event.getPointerId(1);
+ float draggingX = firstPtrX;
+ float draggingY = firstPtrY;
+ if (mDraggingPointerId != INVALID_POINTER_ID) {
+ // Just use the coordinates of the dragging pointer.
+ int pointerIndex = event.findPointerIndex(mDraggingPointerId);
+ if (pointerIndex >= 0) {
+ draggingX = event.getX(pointerIndex);
+ draggingY = event.getY(pointerIndex);
+ } else {
+ // We've lost track of the dragging pointer. Try to recover by invalidating it.
+ // We'll the drop into the code below to choose a new one.
+ mDraggingPointerId = INVALID_POINTER_ID;
+ }
+ }
+ // Not quite an else, since the above code can invalidate the pointer
+ if (mDraggingPointerId == INVALID_POINTER_ID) {
+ // The goal is to use the coordinates of the finger that is closest to its closest edge.
+ if (getDistanceToClosestEdge(firstPtrX, firstPtrY)
+ < getDistanceToClosestEdge(secondPtrX, secondPtrY)) {
+ // X and Y initialized to firstPtrX and Y was right
+ mDraggingPointerId = firstPtrId;
+ } else {
+ draggingX = secondPtrX;
+ draggingY = secondPtrY;
+ mDraggingPointerId = secondPtrId;
+ }
+ }
+ event.setLocation(draggingX, draggingY);
+ }
+
+ private float getDistanceToClosestEdge(float x, float y) {
+ final long width = mContext.getResources().getDisplayMetrics().widthPixels;
+ final long height = mContext.getResources().getDisplayMetrics().heightPixels;
+ float distance = Float.MAX_VALUE;
+ if (x < (width - x)) {
+ distance = x;
+ } else {
+ distance = width - x;
+ }
+ if (distance > y) {
+ distance = y;
+ }
+ if (distance > (height - y)) {
+ distance = (height - y);
+ }
+ return distance;
}
public TouchState getState() {
@@ -954,6 +1043,13 @@
mGestureDetector.setMultiFingerGesturesEnabled(enabled);
}
+ /**
+ * This function turns on and off two-finger passthrough gestures such as drag and pinch when
+ * multi-finger gestures are enabled.
+ */
+ public void setTwoFingerPassthroughEnabled(boolean enabled) {
+ mGestureDetector.setTwoFingerPassthroughEnabled(enabled);
+ }
public void setGestureDetectionPassthroughRegion(Region region) {
mGestureDetectionPassthroughRegion = region;
}
diff --git a/services/accessibility/java/com/android/server/accessibility/magnification/WindowMagnificationGestureHandler.java b/services/accessibility/java/com/android/server/accessibility/magnification/WindowMagnificationGestureHandler.java
index bd25f2b..3ee5b28 100644
--- a/services/accessibility/java/com/android/server/accessibility/magnification/WindowMagnificationGestureHandler.java
+++ b/services/accessibility/java/com/android/server/accessibility/magnification/WindowMagnificationGestureHandler.java
@@ -25,10 +25,12 @@
import android.annotation.Nullable;
import android.content.Context;
+import android.graphics.Point;
import android.provider.Settings;
import android.util.Log;
import android.util.MathUtils;
import android.util.Slog;
+import android.view.Display;
import android.view.MotionEvent;
import com.android.internal.annotations.VisibleForTesting;
@@ -90,6 +92,8 @@
private MotionEventDispatcherDelegate mMotionEventDispatcherDelegate;
private final int mDisplayId;
+ private final Context mContext;
+ private final Point mTempPoint = new Point();
private final Queue<MotionEvent> mDebugOutputEventHistory;
@@ -107,7 +111,7 @@
Slog.i(LOG_TAG,
"WindowMagnificationGestureHandler() , displayId = " + displayId + ")");
}
-
+ mContext = context;
mWindowMagnificationMgr = windowMagnificationMgr;
mDetectShortcutTrigger = detectShortcutTrigger;
mDisplayId = displayId;
@@ -184,7 +188,14 @@
if (!mDetectShortcutTrigger) {
return;
}
- toggleMagnification(Float.NaN, Float.NaN);
+ final Point screenSize = mTempPoint;
+ getScreenSize(mTempPoint);
+ toggleMagnification(screenSize.x / 2.0f, screenSize.y / 2.0f);
+ }
+
+ private void getScreenSize(Point outSize) {
+ final Display display = mContext.getDisplay();
+ display.getRealSize(outSize);
}
@Override
diff --git a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java
index 1c31166..a92d334 100644
--- a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java
+++ b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java
@@ -27,6 +27,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
+import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
@@ -214,7 +215,13 @@
return componentName;
}
intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
- return intent.resolveActivity(packageManager);
+ final ActivityInfo ai =
+ intent.resolveActivityInfo(packageManager, PackageManager.MATCH_INSTANT);
+ if (ai != null) {
+ return new ComponentName(ai.applicationInfo.packageName, ai.name);
+ }
+
+ return null;
}
};
final LayoutInflater inflater = LayoutInflater.from(context);
diff --git a/services/backup/java/com/android/server/backup/KeyValueAdbBackupEngine.java b/services/backup/java/com/android/server/backup/KeyValueAdbBackupEngine.java
index c9b09e3..0855b9d 100644
--- a/services/backup/java/com/android/server/backup/KeyValueAdbBackupEngine.java
+++ b/services/backup/java/com/android/server/backup/KeyValueAdbBackupEngine.java
@@ -10,6 +10,7 @@
import android.app.ApplicationThreadConstants;
import android.app.IBackupAgent;
+import android.app.backup.BackupManager;
import android.app.backup.FullBackup;
import android.app.backup.FullBackupDataOutput;
import android.app.backup.IBackupCallback;
@@ -146,7 +147,8 @@
private IBackupAgent bindToAgent(ApplicationInfo targetApp) {
try {
return mBackupManagerService.bindToAgentSynchronous(targetApp,
- ApplicationThreadConstants.BACKUP_MODE_INCREMENTAL);
+ ApplicationThreadConstants.BACKUP_MODE_INCREMENTAL,
+ BackupManager.OperationType.BACKUP);
} catch (SecurityException e) {
Slog.e(TAG, "error in binding to agent for package " + targetApp.packageName
+ ". " + e);
diff --git a/services/backup/java/com/android/server/backup/UserBackupManagerService.java b/services/backup/java/com/android/server/backup/UserBackupManagerService.java
index 27a280a..29235dd 100644
--- a/services/backup/java/com/android/server/backup/UserBackupManagerService.java
+++ b/services/backup/java/com/android/server/backup/UserBackupManagerService.java
@@ -1651,13 +1651,15 @@
/** Fires off a backup agent, blocking until it attaches or times out. */
@Nullable
- public IBackupAgent bindToAgentSynchronous(ApplicationInfo app, int mode) {
+ public IBackupAgent bindToAgentSynchronous(ApplicationInfo app, int mode,
+ @OperationType int operationType) {
IBackupAgent agent = null;
synchronized (mAgentConnectLock) {
mConnecting = true;
mConnectedAgent = null;
try {
- if (mActivityManager.bindBackupAgent(app.packageName, mode, mUserId)) {
+ if (mActivityManager.bindBackupAgent(app.packageName, mode, mUserId,
+ operationType)) {
Slog.d(TAG, addUserIdToLogMessage(mUserId, "awaiting agent for " + app));
// success; wait for the agent to arrive
diff --git a/services/backup/java/com/android/server/backup/fullbackup/FullBackupEngine.java b/services/backup/java/com/android/server/backup/fullbackup/FullBackupEngine.java
index 846c6a2..fe5497f 100644
--- a/services/backup/java/com/android/server/backup/fullbackup/FullBackupEngine.java
+++ b/services/backup/java/com/android/server/backup/fullbackup/FullBackupEngine.java
@@ -41,6 +41,7 @@
import com.android.server.backup.BackupRestoreTask;
import com.android.server.backup.UserBackupManagerService;
import com.android.server.backup.remote.RemoteCall;
+import com.android.server.backup.utils.BackupEligibilityRules;
import com.android.server.backup.utils.FullBackupUtils;
import java.io.File;
@@ -64,6 +65,7 @@
private final int mOpToken;
private final int mTransportFlags;
private final BackupAgentTimeoutParameters mAgentTimeoutParameters;
+ private final BackupEligibilityRules mBackupEligibilityRules;
class FullBackupRunner implements Runnable {
private final @UserIdInt int mUserId;
@@ -190,7 +192,8 @@
BackupRestoreTask timeoutMonitor,
long quota,
int opToken,
- int transportFlags) {
+ int transportFlags,
+ BackupEligibilityRules backupEligibilityRules) {
this.backupManagerService = backupManagerService;
mOutput = output;
mPreflightHook = preflightHook;
@@ -204,6 +207,7 @@
Objects.requireNonNull(
backupManagerService.getAgentTimeoutParameters(),
"Timeout parameters cannot be null");
+ mBackupEligibilityRules = backupEligibilityRules;
}
public int preflightCheck() throws RemoteException {
@@ -302,7 +306,8 @@
}
mAgent =
backupManagerService.bindToAgentSynchronous(
- mPkg.applicationInfo, ApplicationThreadConstants.BACKUP_MODE_FULL);
+ mPkg.applicationInfo, ApplicationThreadConstants.BACKUP_MODE_FULL,
+ mBackupEligibilityRules.getOperationType());
}
return mAgent != null;
}
diff --git a/services/backup/java/com/android/server/backup/fullbackup/PerformAdbBackupTask.java b/services/backup/java/com/android/server/backup/fullbackup/PerformAdbBackupTask.java
index 0a11774..448e086 100644
--- a/services/backup/java/com/android/server/backup/fullbackup/PerformAdbBackupTask.java
+++ b/services/backup/java/com/android/server/backup/fullbackup/PerformAdbBackupTask.java
@@ -421,7 +421,8 @@
this,
Long.MAX_VALUE,
mCurrentOpToken,
- /*transportFlags=*/ 0);
+ /*transportFlags=*/ 0,
+ mBackupEligibilityRules);
sendOnBackupPackage(isSharedStorage ? "Shared storage" : pkg.packageName);
// Don't need to check preflight result as there is no preflight hook.
diff --git a/services/backup/java/com/android/server/backup/fullbackup/PerformFullTransportBackupTask.java b/services/backup/java/com/android/server/backup/fullbackup/PerformFullTransportBackupTask.java
index 1fa8892..a4d47d4 100644
--- a/services/backup/java/com/android/server/backup/fullbackup/PerformFullTransportBackupTask.java
+++ b/services/backup/java/com/android/server/backup/fullbackup/PerformFullTransportBackupTask.java
@@ -860,7 +860,8 @@
this,
mQuota,
mCurrentOpToken,
- mTransportFlags);
+ mTransportFlags,
+ mBackupEligibilityRules);
try {
try {
if (!mIsCancelled) {
diff --git a/services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupTask.java b/services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupTask.java
index 6124171..7267cdf 100644
--- a/services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupTask.java
+++ b/services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupTask.java
@@ -731,7 +731,8 @@
try {
agent =
mBackupManagerService.bindToAgentSynchronous(
- packageInfo.applicationInfo, BACKUP_MODE_INCREMENTAL);
+ packageInfo.applicationInfo, BACKUP_MODE_INCREMENTAL,
+ mBackupEligibilityRules.getOperationType());
if (agent == null) {
mReporter.onAgentError(packageName);
throw AgentException.transitory();
diff --git a/services/backup/java/com/android/server/backup/restore/FullRestoreEngine.java b/services/backup/java/com/android/server/backup/restore/FullRestoreEngine.java
index e42d3bd..6220679 100644
--- a/services/backup/java/com/android/server/backup/restore/FullRestoreEngine.java
+++ b/services/backup/java/com/android/server/backup/restore/FullRestoreEngine.java
@@ -49,6 +49,7 @@
import com.android.server.backup.KeyValueAdbRestoreEngine;
import com.android.server.backup.UserBackupManagerService;
import com.android.server.backup.fullbackup.FullBackupObbConnection;
+import com.android.server.backup.utils.BackupEligibilityRules;
import com.android.server.backup.utils.BytesReadListener;
import com.android.server.backup.utils.FullBackupRestoreObserverUtils;
import com.android.server.backup.utils.RestoreUtils;
@@ -129,11 +130,13 @@
private final boolean mIsAdbRestore;
@GuardedBy("mPipesLock")
private boolean mPipesClosed;
+ private final BackupEligibilityRules mBackupEligibilityRules;
public FullRestoreEngine(UserBackupManagerService backupManagerService,
BackupRestoreTask monitorTask, IFullBackupRestoreObserver observer,
IBackupManagerMonitor monitor, PackageInfo onlyPackage, boolean allowApks,
- int ephemeralOpToken, boolean isAdbRestore) {
+ int ephemeralOpToken, boolean isAdbRestore,
+ BackupEligibilityRules backupEligibilityRules) {
mBackupManagerService = backupManagerService;
mEphemeralOpToken = ephemeralOpToken;
mMonitorTask = monitorTask;
@@ -147,6 +150,7 @@
"Timeout parameters cannot be null");
mIsAdbRestore = isAdbRestore;
mUserId = backupManagerService.getUserId();
+ mBackupEligibilityRules = backupEligibilityRules;
}
public IBackupAgent getAgent() {
@@ -365,7 +369,8 @@
mAgent = mBackupManagerService.bindToAgentSynchronous(mTargetApp,
FullBackup.KEY_VALUE_DATA_TOKEN.equals(info.domain)
? ApplicationThreadConstants.BACKUP_MODE_INCREMENTAL
- : ApplicationThreadConstants.BACKUP_MODE_RESTORE_FULL);
+ : ApplicationThreadConstants.BACKUP_MODE_RESTORE_FULL,
+ mBackupEligibilityRules.getOperationType());
mAgentPackage = pkg;
} catch (IOException | NameNotFoundException e) {
// fall through to error handling
diff --git a/services/backup/java/com/android/server/backup/restore/PerformAdbRestoreTask.java b/services/backup/java/com/android/server/backup/restore/PerformAdbRestoreTask.java
index 923bb08..c94286f 100644
--- a/services/backup/java/com/android/server/backup/restore/PerformAdbRestoreTask.java
+++ b/services/backup/java/com/android/server/backup/restore/PerformAdbRestoreTask.java
@@ -25,12 +25,15 @@
import static com.android.server.backup.UserBackupManagerService.BACKUP_FILE_VERSION;
import android.app.backup.IFullBackupRestoreObserver;
+import android.content.pm.PackageManagerInternal;
import android.os.ParcelFileDescriptor;
import android.util.Slog;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.server.LocalServices;
import com.android.server.backup.UserBackupManagerService;
import com.android.server.backup.fullbackup.FullBackupObbConnection;
+import com.android.server.backup.utils.BackupEligibilityRules;
import com.android.server.backup.utils.FullBackupRestoreObserverUtils;
import com.android.server.backup.utils.PasswordUtils;
@@ -102,7 +105,10 @@
}
FullRestoreEngine mEngine = new FullRestoreEngine(mBackupManagerService, null,
- mObserver, null, null, true, 0 /*unused*/, true);
+ mObserver, null, null, true, 0 /*unused*/, true,
+ BackupEligibilityRules.forBackup(mBackupManagerService.getPackageManager(),
+ LocalServices.getService(PackageManagerInternal.class),
+ mBackupManagerService.getUserId()));
FullRestoreEngineThread mEngineThread = new FullRestoreEngineThread(mEngine,
tarInputStream);
mEngineThread.run();
diff --git a/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java b/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java
index a7e3604..7baf559 100644
--- a/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java
+++ b/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java
@@ -162,6 +162,7 @@
private final int mEphemeralOpToken;
private final BackupAgentTimeoutParameters mAgentTimeoutParameters;
+ private final BackupEligibilityRules mBackupEligibilityRules;
@VisibleForTesting
PerformUnifiedRestoreTask(UserBackupManagerService backupManagerService) {
@@ -171,6 +172,7 @@
mTransportManager = null;
mEphemeralOpToken = 0;
mUserId = 0;
+ mBackupEligibilityRules = null;
this.backupManagerService = backupManagerService;
}
@@ -208,6 +210,7 @@
mAgentTimeoutParameters = Objects.requireNonNull(
backupManagerService.getAgentTimeoutParameters(),
"Timeout parameters cannot be null");
+ mBackupEligibilityRules = backupEligibilityRules;
if (targetPackage != null) {
// Single package restore
@@ -656,7 +659,8 @@
// Good to go! Set up and bind the agent...
mAgent = backupManagerService.bindToAgentSynchronous(
mCurrentPackage.applicationInfo,
- ApplicationThreadConstants.BACKUP_MODE_INCREMENTAL);
+ ApplicationThreadConstants.BACKUP_MODE_INCREMENTAL,
+ mBackupEligibilityRules.getOperationType());
if (mAgent == null) {
Slog.w(TAG, "Can't find backup agent for " + packageName);
mMonitor = BackupManagerMonitorUtils.monitorEvent(mMonitor,
@@ -913,7 +917,8 @@
mCurrentPackage.packageName);
mEngine = new FullRestoreEngine(backupManagerService, this, null,
- mMonitor, mCurrentPackage, false, mEphemeralOpToken, false);
+ mMonitor, mCurrentPackage, false, mEphemeralOpToken, false,
+ mBackupEligibilityRules);
mEngineThread = new FullRestoreEngineThread(mEngine, mEnginePipes[0]);
ParcelFileDescriptor eWriteEnd = mEnginePipes[1];
diff --git a/services/backup/java/com/android/server/backup/utils/BackupEligibilityRules.java b/services/backup/java/com/android/server/backup/utils/BackupEligibilityRules.java
index ee05c2b..d659897 100644
--- a/services/backup/java/com/android/server/backup/utils/BackupEligibilityRules.java
+++ b/services/backup/java/com/android/server/backup/utils/BackupEligibilityRules.java
@@ -318,4 +318,8 @@
return true;
}
}
+
+ public int getOperationType() {
+ return mOperationType;
+ }
}
diff --git a/services/core/Android.bp b/services/core/Android.bp
index e76ec74..addaa65 100644
--- a/services/core/Android.bp
+++ b/services/core/Android.bp
@@ -2,38 +2,25 @@
name: "services.core-sources",
srcs: ["java/**/*.java"],
path: "java",
- visibility: ["//frameworks/base/services"],
-}
-
-java_library {
- name: "protolog-common",
- srcs: [
- "java/com/android/server/protolog/common/**/*.java",
+ visibility: [
+ "//frameworks/base/services",
+ "//frameworks/base/core/java/com/android/internal/protolog",
],
- host_supported: true,
-}
-
-java_library {
- name: "services.core.wm.protologgroups",
- srcs: [
- "java/com/android/server/wm/ProtoLogGroup.java",
- ],
- static_libs: ["protolog-common"],
}
genrule {
name: "services.core.protologsrc",
srcs: [
- ":services.core.wm.protologgroups",
+ ":protolog-groups",
":services.core-sources",
],
tools: ["protologtool"],
cmd: "$(location protologtool) transform-protolog-calls " +
- "--protolog-class com.android.server.protolog.common.ProtoLog " +
- "--protolog-impl-class com.android.server.protolog.ProtoLogImpl " +
- "--protolog-cache-class 'com.android.server.protolog.ProtoLog$$Cache' " +
- "--loggroups-class com.android.server.wm.ProtoLogGroup " +
- "--loggroups-jar $(location :services.core.wm.protologgroups) " +
+ "--protolog-class com.android.internal.protolog.common.ProtoLog " +
+ "--protolog-impl-class com.android.internal.protolog.ProtoLogImpl " +
+ "--protolog-cache-class 'com.android.server.wm.ProtoLogCache' " +
+ "--loggroups-class com.android.internal.protolog.ProtoLogGroup " +
+ "--loggroups-jar $(location :protolog-groups) " +
"--output-srcjar $(out) " +
"$(locations :services.core-sources)",
out: ["services.core.protolog.srcjar"],
@@ -42,14 +29,14 @@
genrule {
name: "generate-protolog.json",
srcs: [
- ":services.core.wm.protologgroups",
+ ":protolog-groups",
":services.core-sources",
],
tools: ["protologtool"],
cmd: "$(location protologtool) generate-viewer-config " +
- "--protolog-class com.android.server.protolog.common.ProtoLog " +
- "--loggroups-class com.android.server.wm.ProtoLogGroup " +
- "--loggroups-jar $(location :services.core.wm.protologgroups) " +
+ "--protolog-class com.android.internal.protolog.common.ProtoLog " +
+ "--loggroups-class com.android.internal.protolog.ProtoLogGroup " +
+ "--loggroups-jar $(location :protolog-groups) " +
"--viewer-conf $(out) " +
"$(locations :services.core-sources)",
out: ["services.core.protolog.json"],
@@ -109,6 +96,7 @@
],
static_libs: [
+ "protolog-lib",
"time_zone_distro",
"time_zone_distro_installer",
"android.hardware.authsecret-V1.0-java",
diff --git a/services/core/java/com/android/server/BinderCallsStatsService.java b/services/core/java/com/android/server/BinderCallsStatsService.java
index a3c04be..c951359 100644
--- a/services/core/java/com/android/server/BinderCallsStatsService.java
+++ b/services/core/java/com/android/server/BinderCallsStatsService.java
@@ -28,7 +28,9 @@
import android.net.Uri;
import android.os.BatteryStatsInternal;
import android.os.Binder;
+import android.os.ParcelFileDescriptor;
import android.os.Process;
+import android.os.ShellCommand;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
@@ -308,50 +310,134 @@
}
boolean verbose = false;
+ int worksourceUid = Process.INVALID_UID;
if (args != null) {
- for (final String arg : args) {
+ for (int i = 0; i < args.length; i++) {
+ String arg = args[i];
if ("-a".equals(arg)) {
verbose = true;
- } else if ("--reset".equals(arg)) {
- reset();
- pw.println("binder_calls_stats reset.");
- return;
- } else if ("--enable".equals(arg)) {
- Binder.setObserver(mBinderCallsStats);
- return;
- } else if ("--disable".equals(arg)) {
- Binder.setObserver(null);
- return;
- } else if ("--no-sampling".equals(arg)) {
- mBinderCallsStats.setSamplingInterval(1);
- return;
- } else if ("--enable-detailed-tracking".equals(arg)) {
- SystemProperties.set(PERSIST_SYS_BINDER_CALLS_DETAILED_TRACKING, "1");
- mBinderCallsStats.setDetailedTracking(true);
- pw.println("Detailed tracking enabled");
- return;
- } else if ("--disable-detailed-tracking".equals(arg)) {
- SystemProperties.set(PERSIST_SYS_BINDER_CALLS_DETAILED_TRACKING, "");
- mBinderCallsStats.setDetailedTracking(false);
- pw.println("Detailed tracking disabled");
- return;
- } else if ("--dump-worksource-provider".equals(arg)) {
- mWorkSourceProvider.dump(pw, AppIdToPackageMap.getSnapshot());
- return;
} else if ("-h".equals(arg)) {
- pw.println("binder_calls_stats commands:");
- pw.println(" --reset: Reset stats");
- pw.println(" --enable: Enable tracking binder calls");
- pw.println(" --disable: Disables tracking binder calls");
- pw.println(" --no-sampling: Tracks all calls");
- pw.println(" --enable-detailed-tracking: Enables detailed tracking");
- pw.println(" --disable-detailed-tracking: Disables detailed tracking");
+ pw.println("dumpsys binder_calls_stats options:");
+ pw.println(" -a: Verbose");
+ pw.println(" --work-source-uid <UID>: Dump binder calls from the UID");
return;
- } else {
- pw.println("Unknown option: " + arg);
+ } else if ("--work-source-uid".equals(arg)) {
+ i++;
+ if (i >= args.length) {
+ throw new IllegalArgumentException(
+ "Argument expected after \"" + arg + "\"");
+ }
+ String uidArg = args[i];
+ try {
+ worksourceUid = Integer.parseInt(uidArg);
+ } catch (NumberFormatException e) {
+ pw.println("Invalid UID: " + uidArg);
+ return;
+ }
+ }
+ }
+
+ if (args.length > 0 && worksourceUid == Process.INVALID_UID) {
+ // For compatibility, support "cmd"-style commands when passed to "dumpsys".
+ BinderCallsStatsShellCommand command = new BinderCallsStatsShellCommand(pw);
+ int status = command.exec(this, null, FileDescriptor.out, FileDescriptor.err, args);
+ if (status == 0) {
+ return;
}
}
}
- mBinderCallsStats.dump(pw, AppIdToPackageMap.getSnapshot(), verbose);
+ mBinderCallsStats.dump(pw, AppIdToPackageMap.getSnapshot(), worksourceUid, verbose);
+ }
+
+ @Override
+ public int handleShellCommand(ParcelFileDescriptor in, ParcelFileDescriptor out,
+ ParcelFileDescriptor err, String[] args) {
+ ShellCommand command = new BinderCallsStatsShellCommand(null);
+ int status = command.exec(this, in.getFileDescriptor(), out.getFileDescriptor(),
+ err.getFileDescriptor(), args);
+ if (status != 0) {
+ command.onHelp();
+ }
+ return status;
+ }
+
+ private class BinderCallsStatsShellCommand extends ShellCommand {
+ private final PrintWriter mPrintWriter;
+
+ BinderCallsStatsShellCommand(PrintWriter printWriter) {
+ mPrintWriter = printWriter;
+ }
+
+ @Override
+ public PrintWriter getOutPrintWriter() {
+ if (mPrintWriter != null) {
+ return mPrintWriter;
+ }
+ return super.getOutPrintWriter();
+ }
+
+ @Override
+ public int onCommand(String cmd) {
+ PrintWriter pw = getOutPrintWriter();
+ if (cmd == null) {
+ return -1;
+ }
+
+ switch (cmd) {
+ case "--reset":
+ reset();
+ pw.println("binder_calls_stats reset.");
+ break;
+ case "--enable":
+ Binder.setObserver(mBinderCallsStats);
+ break;
+ case "--disable":
+ Binder.setObserver(null);
+ break;
+ case "--no-sampling":
+ mBinderCallsStats.setSamplingInterval(1);
+ break;
+ case "--enable-detailed-tracking":
+ SystemProperties.set(PERSIST_SYS_BINDER_CALLS_DETAILED_TRACKING, "1");
+ mBinderCallsStats.setDetailedTracking(true);
+ pw.println("Detailed tracking enabled");
+ break;
+ case "--disable-detailed-tracking":
+ SystemProperties.set(PERSIST_SYS_BINDER_CALLS_DETAILED_TRACKING, "");
+ mBinderCallsStats.setDetailedTracking(false);
+ pw.println("Detailed tracking disabled");
+ break;
+ case "--dump-worksource-provider":
+ mBinderCallsStats.setDetailedTracking(true);
+ mWorkSourceProvider.dump(pw, AppIdToPackageMap.getSnapshot());
+ break;
+ case "--work-source-uid":
+ String uidArg = getNextArgRequired();
+ try {
+ int uid = Integer.parseInt(uidArg);
+ mBinderCallsStats.recordAllCallsForWorkSourceUid(uid);
+ } catch (NumberFormatException e) {
+ pw.println("Invalid UID: " + uidArg);
+ return -1;
+ }
+ break;
+ default:
+ return handleDefaultCommands(cmd);
+ }
+ return 0;
+ }
+
+ @Override
+ public void onHelp() {
+ PrintWriter pw = getOutPrintWriter();
+ pw.println("binder_calls_stats commands:");
+ pw.println(" --reset: Reset stats");
+ pw.println(" --enable: Enable tracking binder calls");
+ pw.println(" --disable: Disables tracking binder calls");
+ pw.println(" --no-sampling: Tracks all calls");
+ pw.println(" --enable-detailed-tracking: Enables detailed tracking");
+ pw.println(" --disable-detailed-tracking: Disables detailed tracking");
+ pw.println(" --work-source-uid <UID>: Track all binder calls from the UID");
+ }
}
}
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 02c08cc..ef62a99 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -220,6 +220,8 @@
import com.google.android.collect.Lists;
+import libcore.io.IoUtils;
+
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -7513,18 +7515,34 @@
public void startNattKeepaliveWithFd(Network network, FileDescriptor fd, int resourceId,
int intervalSeconds, ISocketKeepaliveCallback cb, String srcAddr,
String dstAddr) {
- mKeepaliveTracker.startNattKeepalive(
- getNetworkAgentInfoForNetwork(network), fd, resourceId,
- intervalSeconds, cb,
- srcAddr, dstAddr, NattSocketKeepalive.NATT_PORT);
+ try {
+ mKeepaliveTracker.startNattKeepalive(
+ getNetworkAgentInfoForNetwork(network), fd, resourceId,
+ intervalSeconds, cb,
+ srcAddr, dstAddr, NattSocketKeepalive.NATT_PORT);
+ } finally {
+ // FileDescriptors coming from AIDL calls must be manually closed to prevent leaks.
+ // startNattKeepalive calls Os.dup(fd) before returning, so we can close immediately.
+ if (fd != null && Binder.getCallingPid() != Process.myPid()) {
+ IoUtils.closeQuietly(fd);
+ }
+ }
}
@Override
public void startTcpKeepalive(Network network, FileDescriptor fd, int intervalSeconds,
ISocketKeepaliveCallback cb) {
- enforceKeepalivePermission();
- mKeepaliveTracker.startTcpKeepalive(
- getNetworkAgentInfoForNetwork(network), fd, intervalSeconds, cb);
+ try {
+ enforceKeepalivePermission();
+ mKeepaliveTracker.startTcpKeepalive(
+ getNetworkAgentInfoForNetwork(network), fd, intervalSeconds, cb);
+ } finally {
+ // FileDescriptors coming from AIDL calls must be manually closed to prevent leaks.
+ // startTcpKeepalive calls Os.dup(fd) before returning, so we can close immediately.
+ if (fd != null && Binder.getCallingPid() != Process.myPid()) {
+ IoUtils.closeQuietly(fd);
+ }
+ }
}
@Override
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java
index 0ddfa1c..97f3b37 100644
--- a/services/core/java/com/android/server/NetworkManagementService.java
+++ b/services/core/java/com/android/server/NetworkManagementService.java
@@ -185,10 +185,10 @@
/** Set of interfaces with active alerts. */
@GuardedBy("mQuotaLock")
private HashMap<String, Long> mActiveAlerts = Maps.newHashMap();
- /** Set of UIDs blacklisted on metered networks. */
+ /** Set of UIDs denylisted on metered networks. */
@GuardedBy("mRulesLock")
private SparseBooleanArray mUidRejectOnMetered = new SparseBooleanArray();
- /** Set of UIDs whitelisted on metered networks. */
+ /** Set of UIDs allowlisted on metered networks. */
@GuardedBy("mRulesLock")
private SparseBooleanArray mUidAllowOnMetered = new SparseBooleanArray();
/** Set of UIDs with cleartext penalties. */
@@ -561,27 +561,27 @@
synchronized (mRulesLock) {
size = mUidRejectOnMetered.size();
if (size > 0) {
- if (DBG) Slog.d(TAG, "Pushing " + size + " UIDs to metered blacklist rules");
+ if (DBG) Slog.d(TAG, "Pushing " + size + " UIDs to metered denylist rules");
uidRejectOnQuota = mUidRejectOnMetered;
mUidRejectOnMetered = new SparseBooleanArray();
}
size = mUidAllowOnMetered.size();
if (size > 0) {
- if (DBG) Slog.d(TAG, "Pushing " + size + " UIDs to metered whitelist rules");
+ if (DBG) Slog.d(TAG, "Pushing " + size + " UIDs to metered allowlist rules");
uidAcceptOnQuota = mUidAllowOnMetered;
mUidAllowOnMetered = new SparseBooleanArray();
}
}
if (uidRejectOnQuota != null) {
for (int i = 0; i < uidRejectOnQuota.size(); i++) {
- setUidMeteredNetworkBlacklist(uidRejectOnQuota.keyAt(i),
+ setUidMeteredNetworkDenylist(uidRejectOnQuota.keyAt(i),
uidRejectOnQuota.valueAt(i));
}
}
if (uidAcceptOnQuota != null) {
for (int i = 0; i < uidAcceptOnQuota.size(); i++) {
- setUidMeteredNetworkWhitelist(uidAcceptOnQuota.keyAt(i),
+ setUidMeteredNetworkAllowlist(uidAcceptOnQuota.keyAt(i),
uidAcceptOnQuota.valueAt(i));
}
}
@@ -1307,14 +1307,14 @@
}
}
- private void setUidOnMeteredNetworkList(int uid, boolean blacklist, boolean enable) {
+ private void setUidOnMeteredNetworkList(int uid, boolean denylist, boolean enable) {
NetworkStack.checkNetworkStackPermission(mContext);
synchronized (mQuotaLock) {
boolean oldEnable;
SparseBooleanArray quotaList;
synchronized (mRulesLock) {
- quotaList = blacklist ? mUidRejectOnMetered : mUidAllowOnMetered;
+ quotaList = denylist ? mUidRejectOnMetered : mUidAllowOnMetered;
oldEnable = quotaList.get(uid, false);
}
if (oldEnable == enable) {
@@ -1324,7 +1324,7 @@
Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "inetd bandwidth");
try {
- if (blacklist) {
+ if (denylist) {
if (enable) {
mNetdService.bandwidthAddNaughtyApp(uid);
} else {
@@ -1353,12 +1353,12 @@
}
@Override
- public void setUidMeteredNetworkBlacklist(int uid, boolean enable) {
+ public void setUidMeteredNetworkDenylist(int uid, boolean enable) {
setUidOnMeteredNetworkList(uid, true, enable);
}
@Override
- public void setUidMeteredNetworkWhitelist(int uid, boolean enable) {
+ public void setUidMeteredNetworkAllowlist(int uid, boolean enable) {
setUidOnMeteredNetworkList(uid, false, enable);
}
@@ -1626,7 +1626,7 @@
}
}
}
- // Normally, whitelist chains only contain deny rules, so numUids == exemptUids.length.
+ // Normally, allowlist chains only contain deny rules, so numUids == exemptUids.length.
// But the code does not guarantee this in any way, and at least in one case - if we add
// a UID rule to the firewall, and then disable the firewall - the chains can contain
// the wrong type of rule. In this case, don't close connections that we shouldn't.
@@ -1691,7 +1691,7 @@
// Close any sockets that were opened by the affected UIDs. This has to be done after
// disabling network connectivity, in case they react to the socket close by reopening
// the connection and race with the iptables commands that enable the firewall. All
- // whitelist and blacklist chains allow RSTs through.
+ // allowlist and denylist chains allow RSTs through.
if (enable) {
closeSocketsForFirewallChainLocked(chain, chainName);
}
@@ -1828,7 +1828,7 @@
} else {
ruleName = "deny";
}
- } else { // Blacklist mode
+ } else { // Denylist mode
if (rule == FIREWALL_RULE_DENY) {
ruleName = "deny";
} else {
@@ -1913,8 +1913,8 @@
pw.print("Active alert ifaces: "); pw.println(mActiveAlerts.toString());
pw.print("Data saver mode: "); pw.println(mDataSaverMode);
synchronized (mRulesLock) {
- dumpUidRuleOnQuotaLocked(pw, "blacklist", mUidRejectOnMetered);
- dumpUidRuleOnQuotaLocked(pw, "whitelist", mUidAllowOnMetered);
+ dumpUidRuleOnQuotaLocked(pw, "denylist", mUidRejectOnMetered);
+ dumpUidRuleOnQuotaLocked(pw, "allowlist", mUidAllowOnMetered);
}
}
@@ -2179,9 +2179,9 @@
}
}
- void setUidOnMeteredNetworkList(boolean blacklist, int uid, boolean enable) {
+ void setUidOnMeteredNetworkList(boolean denylist, int uid, boolean enable) {
synchronized (mRulesLock) {
- if (blacklist) {
+ if (denylist) {
mUidRejectOnMetered.put(uid, enable);
} else {
mUidAllowOnMetered.put(uid, enable);
diff --git a/services/core/java/com/android/server/PackageWatchdog.java b/services/core/java/com/android/server/PackageWatchdog.java
index 1689656..e675d8d 100644
--- a/services/core/java/com/android/server/PackageWatchdog.java
+++ b/services/core/java/com/android/server/PackageWatchdog.java
@@ -1453,8 +1453,11 @@
} else {
mHealthCheckState = HealthCheckState.ACTIVE;
}
- Slog.i(TAG, "Updated health check state for package " + getName() + ": "
- + toString(oldState) + " -> " + toString(mHealthCheckState));
+
+ if (oldState != mHealthCheckState) {
+ Slog.i(TAG, "Updated health check state for package " + getName() + ": "
+ + toString(oldState) + " -> " + toString(mHealthCheckState));
+ }
return mHealthCheckState;
}
diff --git a/services/core/java/com/android/server/VibratorService.java b/services/core/java/com/android/server/VibratorService.java
index 2534a53..32d02fb 100644
--- a/services/core/java/com/android/server/VibratorService.java
+++ b/services/core/java/com/android/server/VibratorService.java
@@ -114,9 +114,6 @@
private static final VibrationAttributes DEFAULT_ATTRIBUTES =
new VibrationAttributes.Builder().build();
- // If HAL supports callbacks set the timeout to ASYNC_TIMEOUT_MULTIPLIER * duration.
- private static final long ASYNC_TIMEOUT_MULTIPLIER = 2;
-
// A mapping from the intensity adjustment to the scaling to apply, where the intensity
// adjustment is defined as the delta between the default intensity level and the user selected
// intensity level. It's important that we apply the scaling on the delta between the two so
@@ -167,7 +164,7 @@
private boolean mIsVibrating;
@GuardedBy("mLock")
private final RemoteCallbackList<IVibratorStateListener> mVibratorStateListeners =
- new RemoteCallbackList<>();
+ new RemoteCallbackList<>();
private int mHapticFeedbackIntensity;
private int mNotificationIntensity;
private int mRingIntensity;
@@ -176,16 +173,25 @@
static native long vibratorInit();
static native long vibratorGetFinalizer();
+
static native boolean vibratorExists(long controllerPtr);
- static native void vibratorOn(long milliseconds);
+
+ static native void vibratorOn(long controllerPtr, long milliseconds, Vibration vibration);
+
static native void vibratorOff(long controllerPtr);
+
static native void vibratorSetAmplitude(long controllerPtr, int amplitude);
+
static native int[] vibratorGetSupportedEffects(long controllerPtr);
- static native long vibratorPerformEffect(long effect, long strength, Vibration vibration,
- boolean withCallback);
- static native void vibratorPerformComposedEffect(
+
+ static native long vibratorPerformEffect(
+ long controllerPtr, long effect, long strength, Vibration vibration);
+
+ static native void vibratorPerformComposedEffect(long controllerPtr,
VibrationEffect.Composition.PrimitiveEffect[] effect, Vibration vibration);
+
static native void vibratorSetExternalControl(long controllerPtr, boolean enabled);
+
static native long vibratorGetCapabilities(long controllerPtr);
static native void vibratorAlwaysOnEnable(long controllerPtr, long id, long effect,
long strength);
@@ -231,8 +237,7 @@
// The actual effect to be played.
public VibrationEffect effect;
- // The original effect that was requested. This is non-null only when the original effect
- // differs from the effect that's being played. Typically these two things differ because
+ // The original effect that was requested. Typically these two things differ because
// the effect was scaled based on the users vibration intensity settings.
public VibrationEffect originalEffect;
@@ -248,9 +253,13 @@
this.reason = reason;
}
+ @Override
public void binderDied() {
synchronized (mLock) {
if (this == mCurrentVibration) {
+ if (DEBUG) {
+ Slog.d(TAG, "Vibration finished because binder died, cleaning up");
+ }
doCancelVibrateLocked();
}
}
@@ -261,6 +270,9 @@
public void onComplete() {
synchronized (mLock) {
if (this == mCurrentVibration) {
+ if (DEBUG) {
+ Slog.d(TAG, "Vibration finished by callback, cleaning up");
+ }
doCancelVibrateLocked();
}
}
@@ -883,19 +895,11 @@
}
}
- private final Runnable mVibrationEndRunnable = new Runnable() {
- @Override
- public void run() {
- onVibrationFinished();
- }
- };
-
@GuardedBy("mLock")
private void doCancelVibrateLocked() {
Trace.asyncTraceEnd(Trace.TRACE_TAG_VIBRATOR, "vibration", 0);
Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "doCancelVibrateLocked");
try {
- mH.removeCallbacks(mVibrationEndRunnable);
if (mThread != null) {
mThread.cancel();
mThread = null;
@@ -915,7 +919,7 @@
// Callback for whenever the current vibration has finished played out
public void onVibrationFinished() {
if (DEBUG) {
- Slog.e(TAG, "Vibration finished, cleaning up");
+ Slog.d(TAG, "Vibration finished, cleaning up");
}
synchronized (mLock) {
// Make sure the vibration is really done. This also reports that the vibration is
@@ -947,29 +951,19 @@
if (vib.effect instanceof VibrationEffect.OneShot) {
Trace.asyncTraceBegin(Trace.TRACE_TAG_VIBRATOR, "vibration", 0);
VibrationEffect.OneShot oneShot = (VibrationEffect.OneShot) vib.effect;
- doVibratorOn(oneShot.getDuration(), oneShot.getAmplitude(), vib.uid, vib.attrs);
- mH.postDelayed(mVibrationEndRunnable, oneShot.getDuration());
+ doVibratorOn(oneShot.getDuration(), oneShot.getAmplitude(), vib);
} else if (vib.effect instanceof VibrationEffect.Waveform) {
// mThread better be null here. doCancelVibrate should always be
// called before startNextVibrationLocked or startVibrationLocked.
- Trace.asyncTraceBegin(Trace.TRACE_TAG_VIBRATOR, "vibration", 0);
VibrationEffect.Waveform waveform = (VibrationEffect.Waveform) vib.effect;
mThread = new VibrateThread(waveform, vib.uid, vib.attrs);
mThread.start();
} else if (vib.effect instanceof VibrationEffect.Prebaked) {
Trace.asyncTraceBegin(Trace.TRACE_TAG_VIBRATOR, "vibration", 0);
- long timeout = doVibratorPrebakedEffectLocked(vib);
- if (timeout > 0) {
- mH.postDelayed(mVibrationEndRunnable, timeout);
- }
+ doVibratorPrebakedEffectLocked(vib);
} else if (vib.effect instanceof VibrationEffect.Composed) {
Trace.asyncTraceBegin(Trace.TRACE_TAG_VIBRATOR, "vibration", 0);
doVibratorComposedEffectLocked(vib);
- // FIXME: We rely on the completion callback here, but I don't think we require that
- // devices which support composition also support the completion callback. If we
- // ever get a device that supports the former but not the latter, then we have no
- // real way of knowing how long a given effect should last.
- mH.postDelayed(mVibrationEndRunnable, 10000);
} else {
Slog.e(TAG, "Unknown vibration type, ignoring");
}
@@ -1062,18 +1056,18 @@
return attrs.isFlagSet(VibrationAttributes.FLAG_BYPASS_INTERRUPTION_POLICY);
}
- private int getAppOpMode(Vibration vib) {
+ private int getAppOpMode(int uid, String packageName, VibrationAttributes attrs) {
int mode = mAppOps.checkAudioOpNoThrow(AppOpsManager.OP_VIBRATE,
- vib.attrs.getAudioAttributes().getUsage(), vib.uid, vib.opPkg);
+ attrs.getAudioAttributes().getUsage(), uid, packageName);
if (mode == AppOpsManager.MODE_ALLOWED) {
- mode = mAppOps.startOpNoThrow(AppOpsManager.OP_VIBRATE, vib.uid, vib.opPkg);
+ mode = mAppOps.startOpNoThrow(AppOpsManager.OP_VIBRATE, uid, packageName);
}
- if (mode == AppOpsManager.MODE_IGNORED && shouldBypassDnd(vib.attrs)) {
+ if (mode == AppOpsManager.MODE_IGNORED && shouldBypassDnd(attrs)) {
// If we're just ignoring the vibration op then this is set by DND and we should ignore
// if we're asked to bypass. AppOps won't be able to record this operation, so make
// sure we at least note it in the logs for debugging.
- Slog.d(TAG, "Bypassing DND for vibration: " + vib);
+ Slog.d(TAG, "Bypassing DND for vibrate from uid " + uid);
mode = AppOpsManager.MODE_ALLOWED;
}
return mode;
@@ -1095,7 +1089,7 @@
return false;
}
- final int mode = getAppOpMode(vib);
+ final int mode = getAppOpMode(vib.uid, vib.opPkg, vib.attrs);
if (mode != AppOpsManager.MODE_ALLOWED) {
if (mode == AppOpsManager.MODE_ERRORED) {
// We might be getting calls from within system_server, so we don't actually
@@ -1265,7 +1259,18 @@
return mNativeWrapper.vibratorExists();
}
+ /** Vibrates with native callback trigger for {@link Vibration#onComplete()}. */
+ private void doVibratorOn(long millis, int amplitude, Vibration vib) {
+ doVibratorOn(millis, amplitude, vib.uid, vib.attrs, vib);
+ }
+
+ /** Vibrates without native callback. */
private void doVibratorOn(long millis, int amplitude, int uid, VibrationAttributes attrs) {
+ doVibratorOn(millis, amplitude, uid, attrs, /* vib= */ null);
+ }
+
+ private void doVibratorOn(long millis, int amplitude, int uid, VibrationAttributes attrs,
+ @Nullable Vibration vib) {
Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "doVibratorOn");
try {
synchronized (mInputDeviceVibrators) {
@@ -1280,13 +1285,14 @@
final int vibratorCount = mInputDeviceVibrators.size();
if (vibratorCount != 0) {
for (int i = 0; i < vibratorCount; i++) {
- mInputDeviceVibrators.get(i).vibrate(millis, attrs.getAudioAttributes());
+ Vibrator inputDeviceVibrator = mInputDeviceVibrators.get(i);
+ inputDeviceVibrator.vibrate(millis, attrs.getAudioAttributes());
}
} else {
// Note: ordering is important here! Many haptic drivers will reset their
// amplitude when enabled, so we always have to enable first, then set the
// amplitude.
- mNativeWrapper.vibratorOn(millis);
+ mNativeWrapper.vibratorOn(millis, vib);
doVibratorSetAmplitude(amplitude);
}
}
@@ -1324,7 +1330,7 @@
}
@GuardedBy("mLock")
- private long doVibratorPrebakedEffectLocked(Vibration vib) {
+ private void doVibratorPrebakedEffectLocked(Vibration vib) {
Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "doVibratorPrebakedEffectLocked");
try {
final VibrationEffect.Prebaked prebaked = (VibrationEffect.Prebaked) vib.effect;
@@ -1334,25 +1340,20 @@
}
// Input devices don't support prebaked effect, so skip trying it with them.
if (!usingInputDeviceVibrators) {
- long duration = mNativeWrapper.vibratorPerformEffect(prebaked.getId(),
- prebaked.getEffectStrength(), vib,
- hasCapability(IVibrator.CAP_PERFORM_CALLBACK));
- long timeout = duration;
- if (hasCapability(IVibrator.CAP_PERFORM_CALLBACK)) {
- timeout *= ASYNC_TIMEOUT_MULTIPLIER;
- }
- if (timeout > 0) {
+ long duration = mNativeWrapper.vibratorPerformEffect(
+ prebaked.getId(), prebaked.getEffectStrength(), vib);
+ if (duration > 0) {
noteVibratorOnLocked(vib.uid, duration);
- return timeout;
+ return;
}
}
if (!prebaked.shouldFallback()) {
- return 0;
+ return;
}
VibrationEffect effect = getFallbackEffect(prebaked.getId());
if (effect == null) {
Slog.w(TAG, "Failed to play prebaked effect, no fallback");
- return 0;
+ return;
}
Vibration fallbackVib = new Vibration(vib.token, effect, vib.attrs, vib.uid,
vib.opPkg, vib.reason + " (fallback)");
@@ -1360,7 +1361,7 @@
linkVibration(fallbackVib);
applyVibrationIntensityScalingLocked(fallbackVib, intensity);
startVibrationInnerLocked(fallbackVib);
- return 0;
+ return;
} finally {
Trace.traceEnd(Trace.TRACE_TAG_VIBRATOR);
}
@@ -1570,6 +1571,7 @@
proto.flush();
}
+ /** Thread that plays a single {@link VibrationEffect.Waveform}. */
private class VibrateThread extends Thread {
private final VibrationEffect.Waveform mWaveform;
private final int mUid;
@@ -1738,8 +1740,8 @@
}
/** Turns vibrator on for given time. */
- public void vibratorOn(long milliseconds) {
- VibratorService.vibratorOn(milliseconds);
+ public void vibratorOn(long milliseconds, @Nullable Vibration vibration) {
+ VibratorService.vibratorOn(mNativeControllerPtr, milliseconds, vibration);
}
/** Turns vibrator off. */
@@ -1758,15 +1760,15 @@
}
/** Turns vibrator on to perform one of the supported effects. */
- public long vibratorPerformEffect(long effect, long strength, Vibration vibration,
- boolean withCallback) {
- return VibratorService.vibratorPerformEffect(effect, strength, vibration, withCallback);
+ public long vibratorPerformEffect(long effect, long strength, Vibration vibration) {
+ return VibratorService.vibratorPerformEffect(
+ mNativeControllerPtr, effect, strength, vibration);
}
/** Turns vibrator on to perform one of the supported composed effects. */
public void vibratorPerformComposedEffect(
VibrationEffect.Composition.PrimitiveEffect[] effect, Vibration vibration) {
- VibratorService.vibratorPerformComposedEffect(effect, vibration);
+ VibratorService.vibratorPerformComposedEffect(mNativeControllerPtr, effect, vibration);
}
/** Enabled the device vibrator to be controlled by another service. */
@@ -1865,7 +1867,7 @@
return SCALE_MUTE;
}
if (ActivityManager.checkComponentPermission(android.Manifest.permission.VIBRATE,
- vib.getUid(), -1 /*owningUid*/, true /*exported*/)
+ vib.getUid(), -1 /*owningUid*/, true /*exported*/)
!= PackageManager.PERMISSION_GRANTED) {
Slog.w(TAG, "pkg=" + vib.getPackage() + ", uid=" + vib.getUid()
+ " tried to play externally controlled vibration"
@@ -1873,6 +1875,14 @@
return SCALE_MUTE;
}
+ int mode = getAppOpMode(vib.getUid(), vib.getPackage(), vib.getVibrationAttributes());
+ if (mode != AppOpsManager.MODE_ALLOWED) {
+ if (mode == AppOpsManager.MODE_ERRORED) {
+ Slog.w(TAG, "Would be an error: external vibrate from uid " + vib.getUid());
+ }
+ return SCALE_MUTE;
+ }
+
final int scaleLevel;
synchronized (mLock) {
if (!vib.equals(mCurrentExternalVibration)) {
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index 33a92e6..b83aa4f 100644
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -694,12 +694,8 @@
}
ComponentName cmp = startServiceInnerLocked(smap, service, r, callerFg, addToStarting);
- if (!r.mAllowWhileInUsePermissionInFgs) {
- r.mAllowWhileInUsePermissionInFgs =
- shouldAllowWhileInUsePermissionInFgsLocked(callingPackage, callingPid,
- callingUid, service, r, allowBackgroundActivityStarts);
- }
-
+ setFgsRestrictionLocked(callingPackage, callingPid,
+ callingUid, service, r, allowBackgroundActivityStarts);
return cmp;
}
@@ -1369,6 +1365,7 @@
+ r.shortInstanceName);
}
}
+
boolean alreadyStartedOp = false;
boolean stopProcStatsOp = false;
if (r.fgRequired) {
@@ -1415,6 +1412,24 @@
ignoreForeground = true;
}
+ if (!ignoreForeground) {
+ if (!r.mAllowStartForeground) {
+ if (!r.mLoggedInfoAllowStartForeground) {
+ Slog.wtf(TAG, "Background started FGS "
+ + r.mInfoAllowStartForeground);
+ r.mLoggedInfoAllowStartForeground = true;
+ }
+ if (mAm.mConstants.mFlagFgsStartRestrictionEnabled) {
+ Slog.w(TAG,
+ "Service.startForeground() not allowed due to "
+ + " mAllowStartForeground false: service "
+ + r.shortInstanceName);
+ updateServiceForegroundLocked(r.app, true);
+ ignoreForeground = true;
+ }
+ }
+ }
+
// Apps under strict background restrictions simply don't get to have foreground
// services, so now that we've enforced the startForegroundService() contract
// we only do the machinery of making the service foreground when the app
@@ -1836,11 +1851,13 @@
if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "bindService: " + service
+ " type=" + resolvedType + " conn=" + connection.asBinder()
+ " flags=0x" + Integer.toHexString(flags));
+ final int callingPid = Binder.getCallingPid();
+ final int callingUid = Binder.getCallingUid();
final ProcessRecord callerApp = mAm.getRecordForAppLocked(caller);
if (callerApp == null) {
throw new SecurityException(
"Unable to find app for caller " + caller
- + " (pid=" + Binder.getCallingPid()
+ + " (pid=" + callingPid
+ ") when binding service " + service);
}
@@ -1880,19 +1897,19 @@
}
if ((flags & Context.BIND_SCHEDULE_LIKE_TOP_APP) != 0 && !isCallerSystem) {
- throw new SecurityException("Non-system caller (pid=" + Binder.getCallingPid()
+ throw new SecurityException("Non-system caller (pid=" + callingPid
+ ") set BIND_SCHEDULE_LIKE_TOP_APP when binding service " + service);
}
if ((flags & Context.BIND_ALLOW_WHITELIST_MANAGEMENT) != 0 && !isCallerSystem) {
throw new SecurityException(
- "Non-system caller " + caller + " (pid=" + Binder.getCallingPid()
+ "Non-system caller " + caller + " (pid=" + callingPid
+ ") set BIND_ALLOW_WHITELIST_MANAGEMENT when binding service " + service);
}
if ((flags & Context.BIND_ALLOW_INSTANT) != 0 && !isCallerSystem) {
throw new SecurityException(
- "Non-system caller " + caller + " (pid=" + Binder.getCallingPid()
+ "Non-system caller " + caller + " (pid=" + callingPid
+ ") set BIND_ALLOW_INSTANT when binding service " + service);
}
@@ -1908,7 +1925,7 @@
ServiceLookupResult res =
retrieveServiceLocked(service, instanceName, resolvedType, callingPackage,
- Binder.getCallingPid(), Binder.getCallingUid(), userId, true,
+ callingPid, callingUid, userId, true,
callerFg, isBindExternal, allowInstant);
if (res == null) {
return 0;
@@ -2065,12 +2082,7 @@
}
}
- if (!s.mAllowWhileInUsePermissionInFgs) {
- s.mAllowWhileInUsePermissionInFgs =
- shouldAllowWhileInUsePermissionInFgsLocked(callingPackage,
- Binder.getCallingPid(), Binder.getCallingUid(),
- service, s, false);
- }
+ setFgsRestrictionLocked(callingPackage, callingPid, callingUid, service, s, false);
if (s.app != null) {
if ((flags&Context.BIND_TREAT_LIKE_ACTIVITY) != 0) {
@@ -4838,21 +4850,48 @@
}
/**
- * Should allow while-in-use permissions in foreground service or not.
- * while-in-use permissions in FGS started from background might be restricted.
+ * There are two FGS restrictions:
+ * In R, mAllowWhileInUsePermissionInFgs is to allow while-in-use permissions in foreground
+ * service or not. while-in-use permissions in FGS started from background might be restricted.
+ * In S, mAllowStartForeground is to allow FGS to startForeground or not. Service started
+ * from background may not become a FGS.
* @param callingPackage caller app's package name.
* @param callingUid caller app's uid.
* @param intent intent to start/bind service.
* @param r the service to start.
* @return true if allow, false otherwise.
*/
- private boolean shouldAllowWhileInUsePermissionInFgsLocked(String callingPackage,
+ private void setFgsRestrictionLocked(String callingPackage,
int callingPid, int callingUid, Intent intent, ServiceRecord r,
boolean allowBackgroundActivityStarts) {
- // Is the background FGS start restriction turned on?
+ // Check DeviceConfig flag.
if (!mAm.mConstants.mFlagBackgroundFgsStartRestrictionEnabled) {
- return true;
+ r.mAllowWhileInUsePermissionInFgs = true;
}
+
+ if (!r.mAllowWhileInUsePermissionInFgs || !r.mAllowStartForeground) {
+ final boolean temp = shouldAllowFgsFeatureLocked(callingPackage, callingPid,
+ callingUid, intent, r, allowBackgroundActivityStarts);
+ if (!r.mAllowWhileInUsePermissionInFgs) {
+ r.mAllowWhileInUsePermissionInFgs = temp;
+ }
+ if (!r.mAllowStartForeground) {
+ r.mAllowStartForeground = temp;
+ }
+ }
+ }
+
+ /**
+ * Should allow FGS feature or not.
+ * @param callingPackage caller app's package name.
+ * @param callingUid caller app's uid.
+ * @param intent intent to start/bind service.
+ * @param r the service to start.
+ * @return true if allow, false otherwise.
+ */
+ private boolean shouldAllowFgsFeatureLocked(String callingPackage,
+ int callingPid, int callingUid, Intent intent, ServiceRecord r,
+ boolean allowBackgroundActivityStarts) {
// Is the allow activity background start flag on?
if (allowBackgroundActivityStarts) {
return true;
@@ -4892,10 +4931,11 @@
}
// Is the calling UID at PROCESS_STATE_TOP or above?
- final boolean isCallingUidTopApp = appIsTopLocked(callingUid);
- if (isCallingUidTopApp) {
+ final int uidState = mAm.getUidState(callingUid);
+ if (uidState <= ActivityManager.PROCESS_STATE_TOP) {
return true;
}
+
// Does the calling UID have any visible activity?
final boolean isCallingUidVisible = mAm.mAtmInternal.isUidForeground(callingUid);
if (isCallingUidVisible) {
@@ -4913,6 +4953,19 @@
if (isDeviceOwner) {
return true;
}
+
+ final String info =
+ "[callingPackage: " + callingPackage
+ + "; callingUid: " + callingUid
+ + "; uidState: " + ProcessList.makeProcStateString(uidState)
+ + "; intent: " + intent
+ + "; targetSdkVersion:" + r.appInfo.targetSdkVersion
+ + "]";
+ if (!info.equals(r.mInfoAllowStartForeground)) {
+ r.mLoggedInfoAllowStartForeground = false;
+ r.mInfoAllowStartForeground = info;
+ }
+
return false;
}
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerConstants.java b/services/core/java/com/android/server/am/ActivityManagerConstants.java
index 775119c..e9539be 100644
--- a/services/core/java/com/android/server/am/ActivityManagerConstants.java
+++ b/services/core/java/com/android/server/am/ActivityManagerConstants.java
@@ -144,6 +144,13 @@
private static final String KEY_DEFAULT_BACKGROUND_FGS_STARTS_RESTRICTION_ENABLED =
"default_background_fgs_starts_restriction_enabled";
+ /**
+ * Default value for mFlagFgsStartRestrictionEnabled if not explicitly set in
+ * Settings.Global.
+ */
+ private static final String KEY_DEFAULT_FGS_STARTS_RESTRICTION_ENABLED =
+ "default_fgs_starts_restriction_enabled";
+
// Maximum number of cached processes we will allow.
public int MAX_CACHED_PROCESSES = DEFAULT_MAX_CACHED_PROCESSES;
@@ -293,6 +300,11 @@
// started, the restriction is on while-in-use permissions.)
volatile boolean mFlagBackgroundFgsStartRestrictionEnabled = true;
+ // Indicates whether the foreground service background start restriction is enabled.
+ // When the restriction is enabled, service is not allowed to startForeground from background
+ // at all.
+ volatile boolean mFlagFgsStartRestrictionEnabled = false;
+
private final ActivityManagerService mService;
private ContentResolver mResolver;
private final KeyValueListParser mParser = new KeyValueListParser(',');
@@ -436,6 +448,9 @@
case KEY_DEFAULT_BACKGROUND_FGS_STARTS_RESTRICTION_ENABLED:
updateBackgroundFgsStartsRestriction();
break;
+ case KEY_DEFAULT_FGS_STARTS_RESTRICTION_ENABLED:
+ updateFgsStartsRestriction();
+ break;
case KEY_OOMADJ_UPDATE_POLICY:
updateOomAdjUpdatePolicy();
break;
@@ -659,6 +674,7 @@
mFlagForegroundServiceStartsLoggingEnabled = Settings.Global.getInt(mResolver,
Settings.Global.FOREGROUND_SERVICE_STARTS_LOGGING_ENABLED, 1) == 1;
}
+
private void updateBackgroundFgsStartsRestriction() {
mFlagBackgroundFgsStartRestrictionEnabled = DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
@@ -666,6 +682,13 @@
/*defaultValue*/ true);
}
+ private void updateFgsStartsRestriction() {
+ mFlagFgsStartRestrictionEnabled = DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
+ KEY_DEFAULT_FGS_STARTS_RESTRICTION_ENABLED,
+ /*defaultValue*/ false);
+ }
+
private void updateOomAdjUpdatePolicy() {
OOMADJ_UPDATE_QUICK = DeviceConfig.getInt(
DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 5555650..f250647 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -176,6 +176,8 @@
import android.app.ProcessMemoryState;
import android.app.ProfilerInfo;
import android.app.WaitResult;
+import android.app.backup.BackupManager;
+import android.app.backup.BackupManager.OperationType;
import android.app.backup.IBackupManager;
import android.app.usage.UsageEvents;
import android.app.usage.UsageEvents.Event;
@@ -5380,7 +5382,7 @@
try {
thread.scheduleCreateBackupAgent(backupTarget.appInfo,
compatibilityInfoForPackage(backupTarget.appInfo),
- backupTarget.backupMode, backupTarget.userId);
+ backupTarget.backupMode, backupTarget.userId, backupTarget.operationType);
} catch (Exception e) {
Slog.wtf(TAG, "Exception thrown creating backup agent in " + app, e);
badApp = true;
@@ -13782,7 +13784,8 @@
// Cause the target app to be launched if necessary and its backup agent
// instantiated. The backup agent will invoke backupAgentCreated() on the
// activity manager to announce its creation.
- public boolean bindBackupAgent(String packageName, int backupMode, int targetUserId) {
+ public boolean bindBackupAgent(String packageName, int backupMode, int targetUserId,
+ @OperationType int operationType) {
if (DEBUG_BACKUP) {
Slog.v(TAG, "bindBackupAgent: app=" + packageName + " mode=" + backupMode
+ " targetUserId=" + targetUserId + " callingUid = " + Binder.getCallingUid()
@@ -13825,7 +13828,7 @@
+ app.packageName + ": " + e);
}
- BackupRecord r = new BackupRecord(app, backupMode, targetUserId);
+ BackupRecord r = new BackupRecord(app, backupMode, targetUserId, operationType);
ComponentName hostingName =
(backupMode == ApplicationThreadConstants.BACKUP_MODE_INCREMENTAL)
? new ComponentName(app.packageName, app.backupAgentName)
@@ -13864,7 +13867,8 @@
if (DEBUG_BACKUP) Slog.v(TAG_BACKUP, "Agent proc already running: " + proc);
try {
proc.thread.scheduleCreateBackupAgent(app,
- compatibilityInfoForPackage(app), backupMode, targetUserId);
+ compatibilityInfoForPackage(app), backupMode, targetUserId,
+ operationType);
} catch (RemoteException e) {
// Will time out on the backup manager side
}
@@ -14057,13 +14061,13 @@
public Intent registerReceiver(IApplicationThread caller, String callerPackage,
IIntentReceiver receiver, IntentFilter filter, String permission, int userId,
int flags) {
- return registerReceiverWithFeature(caller, callerPackage, null, receiver, filter,
- permission, userId, flags);
+ return registerReceiverWithFeature(caller, callerPackage, null, null,
+ receiver, filter, permission, userId, flags);
}
public Intent registerReceiverWithFeature(IApplicationThread caller, String callerPackage,
- String callerFeatureId, IIntentReceiver receiver, IntentFilter filter,
- String permission, int userId, int flags) {
+ String callerFeatureId, String receiverId, IIntentReceiver receiver,
+ IntentFilter filter, String permission, int userId, int flags) {
enforceNotIsolatedCaller("registerReceiver");
ArrayList<Intent> stickyIntents = null;
ProcessRecord callerApp = null;
@@ -14200,7 +14204,7 @@
+ " callerPackage is " + callerPackage);
}
BroadcastFilter bf = new BroadcastFilter(filter, rl, callerPackage, callerFeatureId,
- permission, callingUid, userId, instantApp, visibleToInstantApps);
+ receiverId, permission, callingUid, userId, instantApp, visibleToInstantApps);
if (rl.containsFilter(filter)) {
Slog.w(TAG, "Receiver with filter " + filter
+ " already registered for pid " + rl.pid
@@ -14472,7 +14476,7 @@
resolvedType, resultTo, resultCode, resultData, resultExtras, requiredPermissions,
appOp, bOptions, ordered, sticky, callingPid, callingUid, realCallingUid,
realCallingPid, userId, false /* allowBackgroundActivityStarts */,
- null /* tokenNeededForBackgroundActivityStarts */, null /* broadcastWhitelist */);
+ null /* tokenNeededForBackgroundActivityStarts */, null /* broadcastAllowList */);
}
@GuardedBy("this")
@@ -15316,7 +15320,7 @@
OP_NONE, bOptions, serialized, sticky, -1, uid, realCallingUid,
realCallingPid, userId, allowBackgroundActivityStarts,
backgroundActivityStartsToken,
- null /*broadcastWhitelist*/);
+ null /* broadcastAllowList */);
} finally {
Binder.restoreCallingIdentity(origId);
}
diff --git a/services/core/java/com/android/server/am/BackupRecord.java b/services/core/java/com/android/server/am/BackupRecord.java
index 37b4be4..d419856 100644
--- a/services/core/java/com/android/server/am/BackupRecord.java
+++ b/services/core/java/com/android/server/am/BackupRecord.java
@@ -16,6 +16,8 @@
package com.android.server.am;
+import android.app.backup.BackupManager;
+import android.app.backup.BackupManager.OperationType;
import android.content.pm.ApplicationInfo;
/** @hide */
@@ -30,14 +32,16 @@
final ApplicationInfo appInfo; // information about BackupAgent's app
final int userId; // user for which backup is performed
final int backupMode; // full backup / incremental / restore
+ @OperationType final int operationType; // see BackupManager#OperationType
ProcessRecord app; // where this agent is running or null
// ----- Implementation -----
- BackupRecord(ApplicationInfo _appInfo, int _backupMode, int _userId) {
+ BackupRecord(ApplicationInfo _appInfo, int _backupMode, int _userId, int _operationType) {
appInfo = _appInfo;
backupMode = _backupMode;
userId = _userId;
+ operationType = _operationType;
}
public String toString() {
diff --git a/services/core/java/com/android/server/am/BroadcastFilter.java b/services/core/java/com/android/server/am/BroadcastFilter.java
index 578db6f..50e06c3 100644
--- a/services/core/java/com/android/server/am/BroadcastFilter.java
+++ b/services/core/java/com/android/server/am/BroadcastFilter.java
@@ -28,6 +28,7 @@
final ReceiverList receiverList;
final String packageName;
final String featureId;
+ final String receiverId;
final String requiredPermission;
final int owningUid;
final int owningUserId;
@@ -35,12 +36,13 @@
final boolean visibleToInstantApp;
BroadcastFilter(IntentFilter _filter, ReceiverList _receiverList,
- String _packageName, String _featureId, String _requiredPermission, int _owningUid, int _userId,
- boolean _instantApp, boolean _visibleToInstantApp) {
+ String _packageName, String _featureId, String _receiverId, String _requiredPermission,
+ int _owningUid, int _userId, boolean _instantApp, boolean _visibleToInstantApp) {
super(_filter);
receiverList = _receiverList;
packageName = _packageName;
featureId = _featureId;
+ receiverId = _receiverId;
requiredPermission = _requiredPermission;
owningUid = _owningUid;
owningUserId = _userId;
diff --git a/services/core/java/com/android/server/am/BroadcastQueue.java b/services/core/java/com/android/server/am/BroadcastQueue.java
index 12937b9..960d26b 100644
--- a/services/core/java/com/android/server/am/BroadcastQueue.java
+++ b/services/core/java/com/android/server/am/BroadcastQueue.java
@@ -639,7 +639,7 @@
final int opCode = AppOpsManager.permissionToOpCode(filter.requiredPermission);
if (opCode != AppOpsManager.OP_NONE
&& mService.getAppOpsManager().noteOpNoThrow(opCode, r.callingUid,
- r.callerPackage, r.callerFeatureId, "")
+ r.callerPackage, r.callerFeatureId, "Broadcast sent to protected receiver")
!= AppOpsManager.MODE_ALLOWED) {
Slog.w(TAG, "Appop Denial: broadcasting "
+ r.intent.toString()
@@ -672,7 +672,8 @@
int appOp = AppOpsManager.permissionToOpCode(requiredPermission);
if (appOp != AppOpsManager.OP_NONE && appOp != r.appOp
&& mService.getAppOpsManager().noteOpNoThrow(appOp,
- filter.receiverList.uid, filter.packageName, filter.featureId, "")
+ filter.receiverList.uid, filter.packageName, filter.featureId,
+ "Broadcast delivered to registered receiver " + filter.receiverId)
!= AppOpsManager.MODE_ALLOWED) {
Slog.w(TAG, "Appop Denial: receiving "
+ r.intent.toString()
@@ -704,7 +705,8 @@
}
if (!skip && r.appOp != AppOpsManager.OP_NONE
&& mService.getAppOpsManager().noteOpNoThrow(r.appOp,
- filter.receiverList.uid, filter.packageName, filter.featureId, "")
+ filter.receiverList.uid, filter.packageName, filter.featureId,
+ "Broadcast delivered to registered receiver " + filter.receiverId)
!= AppOpsManager.MODE_ALLOWED) {
Slog.w(TAG, "Appop Denial: receiving "
+ r.intent.toString()
@@ -1366,9 +1368,10 @@
skip = true;
} else if (!skip && info.activityInfo.permission != null) {
final int opCode = AppOpsManager.permissionToOpCode(info.activityInfo.permission);
- if (opCode != AppOpsManager.OP_NONE
- && mService.getAppOpsManager().noteOpNoThrow(opCode, r.callingUid, r.callerPackage,
- r.callerFeatureId, "") != AppOpsManager.MODE_ALLOWED) {
+ if (opCode != AppOpsManager.OP_NONE && mService.getAppOpsManager().noteOpNoThrow(opCode,
+ r.callingUid, r.callerPackage, r.callerFeatureId,
+ "Broadcast delivered to " + info.activityInfo.name)
+ != AppOpsManager.MODE_ALLOWED) {
Slog.w(TAG, "Appop Denial: broadcasting "
+ r.intent.toString()
+ " from " + r.callerPackage + " (pid="
@@ -1407,7 +1410,8 @@
if (appOp != AppOpsManager.OP_NONE && appOp != r.appOp
&& mService.getAppOpsManager().noteOpNoThrow(appOp,
info.activityInfo.applicationInfo.uid, info.activityInfo.packageName,
- null /* default featureId */, "")
+ null /* default featureId */,
+ "Broadcast delivered to " + info.activityInfo.name)
!= AppOpsManager.MODE_ALLOWED) {
Slog.w(TAG, "Appop Denial: receiving "
+ r.intent + " to "
@@ -1424,7 +1428,7 @@
if (!skip && r.appOp != AppOpsManager.OP_NONE
&& mService.getAppOpsManager().noteOpNoThrow(r.appOp,
info.activityInfo.applicationInfo.uid, info.activityInfo.packageName,
- null /* default featureId */, "")
+ null /* default featureId */, "Broadcast delivered to " + info.activityInfo.name)
!= AppOpsManager.MODE_ALLOWED) {
Slog.w(TAG, "Appop Denial: receiving "
+ r.intent + " to "
diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java
index 4a27030..66677b67 100644
--- a/services/core/java/com/android/server/am/ServiceRecord.java
+++ b/services/core/java/com/android/server/am/ServiceRecord.java
@@ -146,6 +146,12 @@
// the most recent package that start/bind this service.
String mRecentCallingPackage;
+ // allow the service becomes foreground service? Service started from background may not be
+ // allowed to become a foreground service.
+ boolean mAllowStartForeground;
+ String mInfoAllowStartForeground;
+ boolean mLoggedInfoAllowStartForeground;
+
String stringName; // caching of toString
private int lastStartId; // identifier of most recent start request.
@@ -408,6 +414,10 @@
pw.println(mAllowWhileInUsePermissionInFgs);
pw.print(prefix); pw.print("recentCallingPackage=");
pw.println(mRecentCallingPackage);
+ pw.print(prefix); pw.print("allowStartForeground=");
+ pw.println(mAllowStartForeground);
+ pw.print(prefix); pw.print("infoAllowStartForeground=");
+ pw.println(mInfoAllowStartForeground);
if (delayed) {
pw.print(prefix); pw.print("delayed="); pw.println(delayed);
}
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index 0658e81..7420e0a 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -1630,7 +1630,7 @@
UserInfo currentUserInfo = getUserInfo(currentUserId);
Pair<UserInfo, UserInfo> userNames = new Pair<>(currentUserInfo, targetUserInfo);
mUiHandler.removeMessages(START_USER_SWITCH_UI_MSG);
- mUiHandler.sendMessage(mHandler.obtainMessage(
+ mUiHandler.sendMessage(mUiHandler.obtainMessage(
START_USER_SWITCH_UI_MSG, userNames));
} else {
mHandler.removeMessages(START_USER_SWITCH_FG_MSG);
@@ -2887,13 +2887,18 @@
void showUserSwitchingDialog(UserInfo fromUser, UserInfo toUser,
String switchingFromSystemUserMessage, String switchingToSystemUserMessage) {
- if (!mService.mContext.getPackageManager()
+ if (mService.mContext.getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
- final Dialog d = new UserSwitchingDialog(mService, mService.mContext, fromUser,
- toUser, true /* above system */, switchingFromSystemUserMessage,
- switchingToSystemUserMessage);
- d.show();
+ // config_customUserSwitchUi is set to true on Automotive as CarSystemUI is
+ // responsible to show the UI; OEMs should not change that, but if they do, we
+ // should at least warn the user...
+ Slog.w(TAG, "Showing user switch dialog on UserController, it could cause a race "
+ + "condition if it's shown by CarSystemUI as well");
}
+ final Dialog d = new UserSwitchingDialog(mService, mService.mContext, fromUser,
+ toUser, true /* above system */, switchingFromSystemUserMessage,
+ switchingToSystemUserMessage);
+ d.show();
}
void reportGlobalUsageEventLocked(int event) {
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 366f303..23b0929 100755
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -7903,9 +7903,6 @@
return null;
}
- mDynPolicyLogger.log((new AudioEventLogger.StringEvent("registerAudioPolicy for "
- + pcb.asBinder() + " with config:" + policyConfig)).printLog(TAG));
-
String regId = null;
synchronized (mAudioPolicies) {
if (mAudioPolicies.containsKey(pcb.asBinder())) {
@@ -7916,6 +7913,13 @@
AudioPolicyProxy app = new AudioPolicyProxy(policyConfig, pcb, hasFocusListener,
isFocusPolicy, isTestFocusPolicy, isVolumeController, projection);
pcb.asBinder().linkToDeath(app, 0/*flags*/);
+
+ // logging after registration so we have the registration id
+ mDynPolicyLogger.log((new AudioEventLogger.StringEvent("registerAudioPolicy for "
+ + pcb.asBinder() + " u/pid:" + Binder.getCallingUid() + "/"
+ + Binder.getCallingPid() + " with config:" + app.toCompactLogString()))
+ .printLog(TAG));
+
regId = app.getRegistrationId();
mAudioPolicies.put(pcb.asBinder(), app);
} catch (RemoteException e) {
@@ -8079,7 +8083,10 @@
* @param pcb nullable because on service interface
*/
public void unregisterAudioPolicyAsync(@Nullable IAudioPolicyCallback pcb) {
- unregisterAudioPolicy(pcb);
+ if (pcb == null) {
+ return;
+ }
+ unregisterAudioPolicyInt(pcb, "unregisterAudioPolicyAsync");
}
/**
@@ -8090,12 +8097,12 @@
if (pcb == null) {
return;
}
- unregisterAudioPolicyInt(pcb);
+ unregisterAudioPolicyInt(pcb, "unregisterAudioPolicy");
}
- private void unregisterAudioPolicyInt(@NonNull IAudioPolicyCallback pcb) {
- mDynPolicyLogger.log((new AudioEventLogger.StringEvent("unregisterAudioPolicyAsync for "
+ private void unregisterAudioPolicyInt(@NonNull IAudioPolicyCallback pcb, String operationName) {
+ mDynPolicyLogger.log((new AudioEventLogger.StringEvent(operationName + " for "
+ pcb.asBinder()).printLog(TAG)));
synchronized (mAudioPolicies) {
AudioPolicyProxy app = mAudioPolicies.remove(pcb.asBinder());
@@ -8570,7 +8577,8 @@
}
public void binderDied() {
- Log.i(TAG, "audio policy " + mPolicyCallback + " died");
+ mDynPolicyLogger.log((new AudioEventLogger.StringEvent("AudioPolicy "
+ + mPolicyCallback.asBinder() + " died").printLog(TAG)));
release();
}
diff --git a/services/core/java/com/android/server/backup/SystemBackupAgent.java b/services/core/java/com/android/server/backup/SystemBackupAgent.java
index 0a30b76..d98298c 100644
--- a/services/core/java/com/android/server/backup/SystemBackupAgent.java
+++ b/services/core/java/com/android/server/backup/SystemBackupAgent.java
@@ -20,6 +20,7 @@
import android.app.backup.BackupAgentHelper;
import android.app.backup.BackupDataInput;
import android.app.backup.BackupHelper;
+import android.app.backup.BackupManager;
import android.app.backup.FullBackup;
import android.app.backup.FullBackupDataOutput;
import android.app.backup.WallpaperBackupHelper;
@@ -87,8 +88,8 @@
private int mUserId = UserHandle.USER_SYSTEM;
@Override
- public void onCreate(UserHandle user) {
- super.onCreate(user);
+ public void onCreate(UserHandle user, @BackupManager.OperationType int operationType) {
+ super.onCreate(user, operationType);
mUserId = user.getIdentifier();
diff --git a/services/core/java/com/android/server/display/BrightnessMappingStrategy.java b/services/core/java/com/android/server/display/BrightnessMappingStrategy.java
index 6f12155..b8e579d 100644
--- a/services/core/java/com/android/server/display/BrightnessMappingStrategy.java
+++ b/services/core/java/com/android/server/display/BrightnessMappingStrategy.java
@@ -349,9 +349,7 @@
// Normalize entire brightness range to 0 - 1.
protected static float normalizeAbsoluteBrightness(int brightness) {
- return BrightnessSynchronizer.brightnessIntToFloat(brightness,
- PowerManager.BRIGHTNESS_OFF + 1, PowerManager.BRIGHTNESS_ON,
- PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX);
+ return BrightnessSynchronizer.brightnessIntToFloat(brightness);
}
private Pair<float[], float[]> insertControlPoint(
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java
index 0979ad6..dab8c7f 100644
--- a/services/core/java/com/android/server/display/DisplayManagerService.java
+++ b/services/core/java/com/android/server/display/DisplayManagerService.java
@@ -30,8 +30,6 @@
import static android.hardware.display.DisplayViewport.VIEWPORT_EXTERNAL;
import static android.hardware.display.DisplayViewport.VIEWPORT_INTERNAL;
import static android.hardware.display.DisplayViewport.VIEWPORT_VIRTUAL;
-import static android.view.Surface.ROTATION_270;
-import static android.view.Surface.ROTATION_90;
import android.Manifest;
import android.annotation.NonNull;
@@ -46,7 +44,6 @@
import android.database.ContentObserver;
import android.graphics.ColorSpace;
import android.graphics.Point;
-import android.graphics.Rect;
import android.hardware.SensorManager;
import android.hardware.display.AmbientBrightnessDayStats;
import android.hardware.display.BrightnessChangeEvent;
@@ -104,7 +101,6 @@
import com.android.server.DisplayThread;
import com.android.server.LocalServices;
import com.android.server.SystemService;
-import com.android.server.SystemService.TargetUser;
import com.android.server.UiThread;
import com.android.server.wm.SurfaceAnimationThread;
import com.android.server.wm.WindowManagerInternal;
@@ -1394,9 +1390,13 @@
}
final DisplayInfo displayInfo = logicalDisplay.getDisplayInfoLocked();
- return SurfaceControl.screenshotToBufferWithSecureLayersUnsafe(token, new Rect(),
- displayInfo.getNaturalWidth(), displayInfo.getNaturalHeight(),
- false /* useIdentityTransform */, 0 /* rotation */);
+ final SurfaceControl.DisplayCaptureArgs captureArgs =
+ new SurfaceControl.DisplayCaptureArgs.Builder(token)
+ .setSize(displayInfo.getNaturalWidth(), displayInfo.getNaturalHeight())
+ .setUseIdentityTransform(true)
+ .setCaptureSecureLayers(true)
+ .build();
+ return SurfaceControl.captureDisplay(captureArgs);
}
}
@@ -1406,30 +1406,11 @@
if (token == null) {
return null;
}
- final LogicalDisplay logicalDisplay = mLogicalDisplays.get(displayId);
- if (logicalDisplay == null) {
- return null;
- }
- final DisplayInfo displayInfo = logicalDisplay.getDisplayInfoLocked();
- // Takes screenshot based on current device orientation.
- final Display display = DisplayManagerGlobal.getInstance()
- .getRealDisplay(displayId);
- if (display == null) {
- return null;
- }
- final Point displaySize = new Point();
- display.getRealSize(displaySize);
-
- int rotation = displayInfo.rotation;
- // TODO (b/153382624) : This workaround solution would be removed after
- // SurfaceFlinger fixes the inconsistency with rotation direction issue.
- if (rotation == ROTATION_90 || rotation == ROTATION_270) {
- rotation = (rotation == ROTATION_90) ? ROTATION_270 : ROTATION_90;
- }
-
- return SurfaceControl.screenshotToBuffer(token, new Rect(), displaySize.x,
- displaySize.y, false /* useIdentityTransform */, rotation /* rotation */);
+ final SurfaceControl.DisplayCaptureArgs captureArgs =
+ new SurfaceControl.DisplayCaptureArgs.Builder(token)
+ .build();
+ return SurfaceControl.captureDisplay(captureArgs);
}
}
@@ -2550,8 +2531,7 @@
public boolean requestPowerState(DisplayPowerRequest request,
boolean waitForNegativeProximity) {
synchronized (mSyncRoot) {
- return mDisplayPowerController.requestPowerState(request,
- waitForNegativeProximity);
+ return mDisplayPowerController.requestPowerState(request, waitForNegativeProximity);
}
}
@@ -2679,6 +2659,10 @@
return getDisplayedContentSampleInternal(displayId, maxFrames, timestamp);
}
+ @Override
+ public void ignoreProximitySensorUntilChanged() {
+ mDisplayPowerController.ignoreProximitySensorUntilChanged();
+ }
}
class DesiredDisplayModeSpecsObserver
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 9411c562..58ef9d1 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -117,6 +117,7 @@
private static final int MSG_CONFIGURE_BRIGHTNESS = 5;
private static final int MSG_SET_TEMPORARY_BRIGHTNESS = 6;
private static final int MSG_SET_TEMPORARY_AUTO_BRIGHTNESS_ADJUSTMENT = 7;
+ private static final int MSG_IGNORE_PROXIMITY = 8;
private static final int PROXIMITY_UNKNOWN = -1;
private static final int PROXIMITY_NEGATIVE = 0;
@@ -263,6 +264,11 @@
// go to sleep by the user. While true, the screen remains off.
private boolean mWaitingForNegativeProximity;
+ // True if the device should not take into account the proximity sensor
+ // until either the proximity sensor state changes, or there is no longer a
+ // request to listen to proximity sensor.
+ private boolean mIgnoreProximityUntilChanged;
+
// The actual proximity sensor threshold value.
private float mProximityThreshold;
@@ -699,13 +705,13 @@
// Initialize screen state for battery stats.
try {
mBatteryStats.noteScreenState(mPowerState.getScreenState());
- mBatteryStats.noteScreenBrightness(BrightnessSynchronizer.brightnessFloatToInt(mContext,
+ mBatteryStats.noteScreenBrightness(BrightnessSynchronizer.brightnessFloatToInt(
mPowerState.getScreenBrightness()));
} catch (RemoteException ex) {
// same process
}
// Initialize all of the brightness tracking state
- final float brightness = convertToNits(BrightnessSynchronizer.brightnessFloatToInt(mContext,
+ final float brightness = convertToNits(BrightnessSynchronizer.brightnessFloatToInt(
mPowerState.getScreenBrightness()));
if (brightness >= 0.0f) {
mBrightnessTracker.start(brightness);
@@ -760,8 +766,7 @@
if (mPowerRequest == null) {
mPowerRequest = new DisplayPowerRequest(mPendingRequestLocked);
- mWaitingForNegativeProximity = mPendingWaitForNegativeProximityLocked;
- mPendingWaitForNegativeProximityLocked = false;
+ updatePendingProximityRequestsLocked();
mPendingRequestChangedLocked = false;
mustInitialize = true;
// Assume we're on and bright until told otherwise, since that's the state we turn
@@ -770,8 +775,7 @@
} else if (mPendingRequestChangedLocked) {
previousPolicy = mPowerRequest.policy;
mPowerRequest.copyFrom(mPendingRequestLocked);
- mWaitingForNegativeProximity |= mPendingWaitForNegativeProximityLocked;
- mPendingWaitForNegativeProximityLocked = false;
+ updatePendingProximityRequestsLocked();
mPendingRequestChangedLocked = false;
mDisplayReadyLocked = false;
} else {
@@ -822,9 +826,16 @@
// Apply the proximity sensor.
if (mProximitySensor != null) {
if (mPowerRequest.useProximitySensor && state != Display.STATE_OFF) {
+ // At this point the policy says that the screen should be on, but we've been
+ // asked to listen to the prox sensor to adjust the display state, so lets make
+ // sure the sensor is on.
setProximitySensorEnabled(true);
if (!mScreenOffBecauseOfProximity
- && mProximity == PROXIMITY_POSITIVE) {
+ && mProximity == PROXIMITY_POSITIVE
+ && !mIgnoreProximityUntilChanged) {
+ // Prox sensor already reporting "near" so we should turn off the screen.
+ // Also checked that we aren't currently set to ignore the proximity sensor
+ // temporarily.
mScreenOffBecauseOfProximity = true;
sendOnProximityPositiveWithWakelock();
}
@@ -832,18 +843,28 @@
&& mScreenOffBecauseOfProximity
&& mProximity == PROXIMITY_POSITIVE
&& state != Display.STATE_OFF) {
+ // The policy says that we should have the screen on, but it's off due to the prox
+ // and we've been asked to wait until the screen is far from the user to turn it
+ // back on. Let keep the prox sensor on so we can tell when it's far again.
setProximitySensorEnabled(true);
} else {
+ // We haven't been asked to use the prox sensor and we're not waiting on the screen
+ // to turn back on...so lets shut down the prox sensor.
setProximitySensorEnabled(false);
mWaitingForNegativeProximity = false;
}
+
if (mScreenOffBecauseOfProximity
- && mProximity != PROXIMITY_POSITIVE) {
+ && (mProximity != PROXIMITY_POSITIVE || mIgnoreProximityUntilChanged)) {
+ // The screen *was* off due to prox being near, but now it's "far" so lets turn
+ // the screen back on. Also turn it back on if we've been asked to ignore the
+ // prox sensor temporarily.
mScreenOffBecauseOfProximity = false;
sendOnProximityNegativeWithWakelock();
}
} else {
mWaitingForNegativeProximity = false;
+ mIgnoreProximityUntilChanged = false;
}
if (mScreenOffBecauseOfProximity) {
state = Display.STATE_OFF;
@@ -1093,7 +1114,7 @@
userInitiatedChange = false;
}
notifyBrightnessChanged(
- BrightnessSynchronizer.brightnessFloatToInt(mContext, brightnessState),
+ BrightnessSynchronizer.brightnessFloatToInt(brightnessState),
userInitiatedChange, hadUserBrightnessPoint);
}
@@ -1181,6 +1202,14 @@
sendUpdatePowerState();
}
+ /**
+ * Ignores the proximity sensor until the sensor state changes, but only if the sensor is
+ * currently enabled and forcing the screen to be dark.
+ */
+ public void ignoreProximitySensorUntilChanged() {
+ mHandler.sendEmptyMessage(MSG_IGNORE_PROXIMITY);
+ }
+
public void setBrightnessConfiguration(BrightnessConfiguration c) {
Message msg = mHandler.obtainMessage(MSG_CONFIGURE_BRIGHTNESS, c);
msg.sendToTarget();
@@ -1341,8 +1370,7 @@
try {
// TODO(brightnessfloat): change BatteryStats to use float
mBatteryStats.noteScreenBrightness(
- BrightnessSynchronizer.brightnessFloatToInt(
- mContext, target));
+ BrightnessSynchronizer.brightnessFloatToInt(target));
} catch (RemoteException ex) {
// same process
}
@@ -1529,6 +1557,7 @@
// Register the listener.
// Proximity sensor state already cleared initially.
mProximitySensorEnabled = true;
+ mIgnoreProximityUntilChanged = false;
mSensorManager.registerListener(mProximitySensorListener, mProximitySensor,
SensorManager.SENSOR_DELAY_NORMAL, mHandler);
}
@@ -1538,6 +1567,7 @@
// Clear the proximity sensor state for next time.
mProximitySensorEnabled = false;
mProximity = PROXIMITY_UNKNOWN;
+ mIgnoreProximityUntilChanged = false;
mPendingProximity = PROXIMITY_UNKNOWN;
mHandler.removeMessages(MSG_PROXIMITY_SENSOR_DEBOUNCED);
mSensorManager.unregisterListener(mProximitySensorListener);
@@ -1580,6 +1610,11 @@
&& mPendingProximityDebounceTime >= 0) {
final long now = SystemClock.uptimeMillis();
if (mPendingProximityDebounceTime <= now) {
+ if (mProximity != mPendingProximity) {
+ // if the status of the sensor changed, stop ignoring.
+ mIgnoreProximityUntilChanged = false;
+ Slog.i(TAG, "No longer ignoring proximity [" + mPendingProximity + "]");
+ }
// Sensor reading accepted. Apply the change then release the wake lock.
mProximity = mPendingProximity;
updatePowerState();
@@ -1723,6 +1758,27 @@
}
}
+ private void updatePendingProximityRequestsLocked() {
+ mWaitingForNegativeProximity |= mPendingWaitForNegativeProximityLocked;
+ mPendingWaitForNegativeProximityLocked = false;
+
+ if (mIgnoreProximityUntilChanged) {
+ // Also, lets stop waiting for negative proximity if we're ignoring it.
+ mWaitingForNegativeProximity = false;
+ }
+ }
+
+ private void ignoreProximitySensorUntilChangedInternal() {
+ if (!mIgnoreProximityUntilChanged
+ && mPowerRequest.useProximitySensor
+ && mProximity == PROXIMITY_POSITIVE) {
+ // Only ignore if it is still reporting positive (near)
+ mIgnoreProximityUntilChanged = true;
+ Slog.i(TAG, "Ignoring proximity");
+ updatePowerState();
+ }
+ }
+
private final Runnable mOnStateChangedRunnable = new Runnable() {
@Override
public void run() {
@@ -1961,6 +2017,10 @@
mTemporaryAutoBrightnessAdjustment = Float.intBitsToFloat(msg.arg1);
updatePowerState();
break;
+
+ case MSG_IGNORE_PROXIMITY:
+ ignoreProximitySensorUntilChangedInternal();
+ break;
}
}
}
diff --git a/services/core/java/com/android/server/display/LocalDisplayAdapter.java b/services/core/java/com/android/server/display/LocalDisplayAdapter.java
index 48fa1bf..0be428b 100644
--- a/services/core/java/com/android/server/display/LocalDisplayAdapter.java
+++ b/services/core/java/com/android/server/display/LocalDisplayAdapter.java
@@ -728,16 +728,14 @@
try {
if (isHalBrightnessRangeSpecified()) {
brightness = displayBrightnessToHalBrightness(
- BrightnessSynchronizer.brightnessFloatToIntRange(
- getContext(), brightness));
+ BrightnessSynchronizer.brightnessFloatToIntRange(brightness));
}
if (mBacklight != null) {
mBacklight.setBrightness(brightness);
}
Trace.traceCounter(Trace.TRACE_TAG_POWER,
"ScreenBrightness",
- BrightnessSynchronizer.brightnessFloatToInt(
- getContext(), brightness));
+ BrightnessSynchronizer.brightnessFloatToInt(brightness));
} finally {
Trace.traceEnd(Trace.TRACE_TAG_POWER);
}
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java
index 596c1ec..d675b81 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java
@@ -232,11 +232,12 @@
mAutoTvOff = enabled;
}
+ @Override
@ServiceThreadOnly
@VisibleForTesting
void setIsActiveSource(boolean on) {
assertRunOnServiceThread();
- mIsActiveSource = on;
+ super.setIsActiveSource(on);
if (on) {
getWakeLock().acquire();
} else {
@@ -274,19 +275,15 @@
@Override
@ServiceThreadOnly
- protected boolean handleActiveSource(HdmiCecMessage message) {
- super.handleActiveSource(message);
- if (mIsActiveSource) {
- return true;
- }
+ protected void onActiveSourceLost() {
+ assertRunOnServiceThread();
switch (mPowerStateChangeOnActiveSourceLost) {
case STANDBY_NOW:
mService.standby();
- return true;
+ return;
case NONE:
- return true;
+ return;
}
- return true;
}
@ServiceThreadOnly
@@ -398,9 +395,12 @@
}
@Override
+ @ServiceThreadOnly
protected void handleRoutingChangeAndInformation(int physicalAddress, HdmiCecMessage message) {
+ assertRunOnServiceThread();
if (physicalAddress != mService.getPhysicalAddress()) {
- return; // Do nothing.
+ setActiveSource(physicalAddress);
+ return;
}
switch (mPlaybackDeviceActionOnRoutingControl) {
case WAKE_UP_AND_SEND_ACTIVE_SOURCE:
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java
index 1c67718..44ad8ee 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java
@@ -114,6 +114,19 @@
}
@ServiceThreadOnly
+ protected void onActiveSourceLost() {
+ // Nothing to do.
+ }
+
+ @ServiceThreadOnly
+ protected void setActiveSource(int physicalAddress) {
+ assertRunOnServiceThread();
+ // Invalidate the internal active source record. This will also update mIsActiveSource.
+ ActiveSource activeSource = ActiveSource.of(Constants.ADDR_INVALID, physicalAddress);
+ setActiveSource(activeSource);
+ }
+
+ @ServiceThreadOnly
protected boolean handleActiveSource(HdmiCecMessage message) {
assertRunOnServiceThread();
int logicalAddress = message.getSource();
@@ -148,6 +161,9 @@
if (physicalAddress == mService.getPhysicalAddress() && mService.isPlaybackDevice()) {
setAndBroadcastActiveSource(message, physicalAddress);
}
+ if (physicalAddress != mService.getPhysicalAddress()) {
+ setActiveSource(physicalAddress);
+ }
switchInputOnReceivingNewActivePath(physicalAddress);
return true;
}
@@ -156,18 +172,21 @@
@ServiceThreadOnly
protected boolean handleRoutingChange(HdmiCecMessage message) {
assertRunOnServiceThread();
+ int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams(), 2);
+ if (physicalAddress != mService.getPhysicalAddress()) {
+ setActiveSource(physicalAddress);
+ }
if (!isRoutingControlFeatureEnabled()) {
mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED);
return true;
}
- int newPath = HdmiUtils.twoBytesToInt(message.getParams(), 2);
// if the current device is a pure playback device
if (!mIsSwitchDevice
- && newPath == mService.getPhysicalAddress()
+ && physicalAddress == mService.getPhysicalAddress()
&& mService.isPlaybackDevice()) {
- setAndBroadcastActiveSource(message, newPath);
+ setAndBroadcastActiveSource(message, physicalAddress);
}
- handleRoutingChangeAndInformation(newPath, message);
+ handleRoutingChangeAndInformation(physicalAddress, message);
return true;
}
@@ -175,11 +194,14 @@
@ServiceThreadOnly
protected boolean handleRoutingInformation(HdmiCecMessage message) {
assertRunOnServiceThread();
+ int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams());
+ if (physicalAddress != mService.getPhysicalAddress()) {
+ setActiveSource(physicalAddress);
+ }
if (!isRoutingControlFeatureEnabled()) {
mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED);
return true;
}
- int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams());
// if the current device is a pure playback device
if (!mIsSwitchDevice
&& physicalAddress == mService.getPhysicalAddress()
@@ -222,7 +244,11 @@
@ServiceThreadOnly
void setIsActiveSource(boolean on) {
assertRunOnServiceThread();
+ boolean wasActiveSource = mIsActiveSource;
mIsActiveSource = on;
+ if (wasActiveSource && !mIsActiveSource) {
+ onActiveSourceLost();
+ }
}
protected void wakeUpIfActiveSource() {
diff --git a/services/core/java/com/android/server/infra/AbstractMasterSystemService.java b/services/core/java/com/android/server/infra/AbstractMasterSystemService.java
index 7bbcdaa..6672daa 100644
--- a/services/core/java/com/android/server/infra/AbstractMasterSystemService.java
+++ b/services/core/java/com/android/server/infra/AbstractMasterSystemService.java
@@ -949,7 +949,7 @@
if (debug) {
Slog.d(mTag, "Eagerly recreating service for user " + userId);
}
- getServiceForUserLocked(userId);
+ updateCachedServiceLocked(userId);
}
}
onServicePackageRestartedLocked(userId);
diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
index c4f8441..ac9b7ea 100644
--- a/services/core/java/com/android/server/lights/LightsService.java
+++ b/services/core/java/com/android/server/lights/LightsService.java
@@ -318,8 +318,7 @@
SurfaceControl.setDisplayBrightness(mDisplayToken, brightness);
} else {
// Old system
- int brightnessInt = BrightnessSynchronizer.brightnessFloatToInt(
- getContext(), brightness);
+ int brightnessInt = BrightnessSynchronizer.brightnessFloatToInt(brightness);
int color = brightnessInt & 0x000000ff;
color = 0xff000000 | (color << 16) | (color << 8) | color;
setLightLocked(color, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
diff --git a/services/core/java/com/android/server/location/LocationProviderManager.java b/services/core/java/com/android/server/location/LocationProviderManager.java
index d4f8c7e..c3532a8 100644
--- a/services/core/java/com/android/server/location/LocationProviderManager.java
+++ b/services/core/java/com/android/server/location/LocationProviderManager.java
@@ -1615,7 +1615,7 @@
case LOCATION_MODE_THROTTLE_REQUESTS_WHEN_SCREEN_OFF:
// fall through
case LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF:
- updateService();
+ updateRegistrations(registration -> true);
break;
default:
break;
diff --git a/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java b/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java
index 8004ec7..850cf7f 100644
--- a/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java
+++ b/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java
@@ -49,8 +49,6 @@
import android.os.Message;
import android.os.PersistableBundle;
import android.os.PowerManager;
-import android.os.PowerManager.ServiceType;
-import android.os.PowerSaveState;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
@@ -486,10 +484,6 @@
deviceIdleService.unregisterStationaryListener(
mDeviceIdleStationaryListener);
}
- // Intentional fall-through.
- case PowerManager.ACTION_POWER_SAVE_MODE_CHANGED:
- case Intent.ACTION_SCREEN_OFF:
- case Intent.ACTION_SCREEN_ON:
// Call updateLowPowerMode on handler thread so it's always called from the
// same thread.
mHandler.sendEmptyMessage(UPDATE_LOW_POWER_MODE);
@@ -554,15 +548,6 @@
private void updateLowPowerMode() {
// Disable GPS if we are in device idle mode and the device is stationary.
boolean disableGpsForPowerManager = mPowerManager.isDeviceIdleMode() && mIsDeviceStationary;
- final PowerSaveState result = mPowerManager.getPowerSaveState(ServiceType.LOCATION);
- switch (result.locationMode) {
- case PowerManager.LOCATION_MODE_GPS_DISABLED_WHEN_SCREEN_OFF:
- case PowerManager.LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF:
- // If we are in battery saver mode and the screen is off, disable GPS.
- disableGpsForPowerManager |=
- result.batterySaverEnabled && !mPowerManager.isInteractive();
- break;
- }
if (disableGpsForPowerManager != mDisableGpsForPowerManager) {
mDisableGpsForPowerManager = disableGpsForPowerManager;
updateEnabled();
@@ -1959,10 +1944,7 @@
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ALARM_WAKEUP);
intentFilter.addAction(ALARM_TIMEOUT);
- intentFilter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
intentFilter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
- intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
- intentFilter.addAction(Intent.ACTION_SCREEN_ON);
intentFilter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
intentFilter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
mContext.registerReceiver(mBroadcastReceiver, intentFilter, null, this);
diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java
index f1b89c7..d6e37bac 100644
--- a/services/core/java/com/android/server/locksettings/LockSettingsService.java
+++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java
@@ -33,6 +33,7 @@
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_FOR_UNATTENDED_UPDATE;
import static com.android.internal.widget.LockPatternUtils.USER_FRP;
+import static com.android.internal.widget.LockPatternUtils.VERIFY_FLAG_RETURN_GK_PW;
import static com.android.internal.widget.LockPatternUtils.frpCredentialEnabled;
import static com.android.internal.widget.LockPatternUtils.userOwnsFrpCredential;
@@ -186,6 +187,9 @@
private static final String SYNTHETIC_PASSWORD_UPDATE_TIME_KEY = "sp-handle-ts";
private static final String USER_SERIAL_NUMBER_KEY = "serial-number";
+ // TODO (b/145978626) LockSettingsService no longer accepts challenges in the verifyCredential
+ // paths. These are temporarily left around to ensure that resetLockout works. It will be
+ // removed once resetLockout is compartmentalized.
// No challenge provided
private static final int CHALLENGE_NONE = 0;
// Challenge was provided from the external caller (non-LockSettingsService)
@@ -1308,7 +1312,7 @@
try {
doVerifyCredential(getDecryptedPasswordForTiedProfile(profileHandle),
challengeType, challenge, profileHandle, null /* progressCallback */,
- resetLockouts);
+ resetLockouts, 0 /* flags */);
} catch (UnrecoverableKeyException | InvalidKeyException | KeyStoreException
| NoSuchAlgorithmException | NoSuchPaddingException
| InvalidAlgorithmParameterException | IllegalBlockSizeException
@@ -1608,8 +1612,8 @@
// Verify the parent credential again, to make sure we have a fresh enough
// auth token such that getDecryptedPasswordForTiedProfile() inside
// setLockCredentialInternal() can function correctly.
- verifyCredential(savedCredential, /* challenge */ 0,
- mUserManager.getProfileParent(userId).id);
+ verifyCredential(savedCredential, mUserManager.getProfileParent(userId).id,
+ 0 /* flags */);
savedCredential.zeroize();
savedCredential = LockscreenCredential.createNone();
}
@@ -1724,7 +1728,7 @@
fixateNewestUserKeyAuth(userId);
// Refresh the auth token
doVerifyCredential(credential, CHALLENGE_FROM_CALLER, 0, userId,
- null /* progressCallback */);
+ null /* progressCallback */, 0 /* flags */);
synchronizeUnifiedWorkChallengeForProfiles(userId, null);
sendCredentialsOnChangeIfRequired(credential, userId, isLockTiedToParent);
return true;
@@ -1835,7 +1839,7 @@
throw new IllegalArgumentException("Non-OK response verifying a credential we just set "
+ vcr.getResponseCode());
}
- byte[] token = vcr.getPayload();
+ byte[] token = vcr.getGatekeeperHAT();
if (token == null) {
throw new IllegalArgumentException("Empty payload verifying a credential we just set");
}
@@ -1968,35 +1972,56 @@
ICheckCredentialProgressCallback progressCallback) {
checkPasswordReadPermission(userId);
try {
- return doVerifyCredential(credential, CHALLENGE_NONE, 0, userId, progressCallback);
+ return doVerifyCredential(credential, CHALLENGE_NONE, 0L, userId, progressCallback,
+ 0 /* flags */);
} finally {
scheduleGc();
}
}
@Override
+ @Nullable
public VerifyCredentialResponse verifyCredential(LockscreenCredential credential,
- long challenge, int userId) {
+ int userId, int flags) {
checkPasswordReadPermission(userId);
- @ChallengeType int challengeType = CHALLENGE_FROM_CALLER;
- if (challenge == 0) {
- Slog.w(TAG, "VerifyCredential called with challenge=0");
- challengeType = CHALLENGE_NONE;
- }
try {
- return doVerifyCredential(credential, challengeType, challenge, userId,
- null /* progressCallback */);
+ return doVerifyCredential(credential, CHALLENGE_NONE, 0L, userId,
+ null /* progressCallback */, flags);
} finally {
scheduleGc();
}
}
+ @Override
+ public VerifyCredentialResponse verifyGatekeeperPassword(byte[] gatekeeperPassword,
+ long challenge, int userId) {
+ checkPasswordReadPermission(userId);
+
+ VerifyCredentialResponse response;
+ synchronized (mSpManager) {
+ response = mSpManager.verifyChallengeInternal(getGateKeeperService(),
+ gatekeeperPassword, challenge, userId);
+ }
+ return response;
+ }
+
+ /**
+ * @param credential User's lockscreen credential
+ * @param challengeType Owner of the challenge
+ * @param challenge Challenge to be wrapped within Gatekeeper's HAT, if the credential is
+ * verified
+ * @param userId User to verify the credential for
+ * @param progressCallback Receive progress callbacks
+ * @param flags See {@link LockPatternUtils.VerifyFlag}
+ * @return See {@link VerifyCredentialResponse}
+ */
private VerifyCredentialResponse doVerifyCredential(LockscreenCredential credential,
@ChallengeType int challengeType, long challenge, int userId,
- ICheckCredentialProgressCallback progressCallback) {
+ ICheckCredentialProgressCallback progressCallback,
+ @LockPatternUtils.VerifyFlag int flags) {
return doVerifyCredential(credential, challengeType, challenge, userId,
- progressCallback, null /* resetLockouts */);
+ progressCallback, null /* resetLockouts */, flags);
}
/**
@@ -2006,7 +2031,8 @@
private VerifyCredentialResponse doVerifyCredential(LockscreenCredential credential,
@ChallengeType int challengeType, long challenge, int userId,
ICheckCredentialProgressCallback progressCallback,
- @Nullable ArrayList<PendingResetLockout> resetLockouts) {
+ @Nullable ArrayList<PendingResetLockout> resetLockouts,
+ @LockPatternUtils.VerifyFlag int flags) {
if (credential == null || credential.isNone()) {
throw new IllegalArgumentException("Credential can't be null or empty");
}
@@ -2017,7 +2043,7 @@
}
VerifyCredentialResponse response = null;
response = spBasedDoVerifyCredential(credential, challengeType, challenge,
- userId, progressCallback, resetLockouts);
+ userId, progressCallback, resetLockouts, flags);
// The user employs synthetic password based credential.
if (response != null) {
if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK) {
@@ -2050,7 +2076,7 @@
@Override
public VerifyCredentialResponse verifyTiedProfileChallenge(LockscreenCredential credential,
- long challenge, int userId) {
+ int userId, @LockPatternUtils.VerifyFlag int flags) {
checkPasswordReadPermission(userId);
if (!isManagedProfileWithUnifiedLock(userId)) {
throw new IllegalArgumentException("User id must be managed profile with unified lock");
@@ -2059,10 +2085,11 @@
// Unlock parent by using parent's challenge
final VerifyCredentialResponse parentResponse = doVerifyCredential(
credential,
- CHALLENGE_FROM_CALLER,
- challenge,
+ CHALLENGE_NONE,
+ 0L,
parentProfileId,
- null /* progressCallback */);
+ null /* progressCallback */,
+ flags);
if (parentResponse.getResponseCode() != VerifyCredentialResponse.RESPONSE_OK) {
// Failed, just return parent's response
return parentResponse;
@@ -2071,9 +2098,10 @@
try {
// Unlock work profile, and work profile with unified lock must use password only
return doVerifyCredential(getDecryptedPasswordForTiedProfile(userId),
- CHALLENGE_FROM_CALLER,
- challenge,
- userId, null /* progressCallback */);
+ CHALLENGE_NONE,
+ 0L,
+ userId, null /* progressCallback */,
+ flags);
} catch (UnrecoverableKeyException | InvalidKeyException | KeyStoreException
| NoSuchAlgorithmException | NoSuchPaddingException
| InvalidAlgorithmParameterException | IllegalBlockSizeException
@@ -2132,8 +2160,8 @@
unlockKeystore(credential.getCredential(), userId);
Slog.i(TAG, "Unlocking user " + userId + " with token length "
- + response.getPayload().length);
- unlockUser(userId, response.getPayload(), secretFromCredential(credential));
+ + response.getGatekeeperHAT().length);
+ unlockUser(userId, response.getGatekeeperHAT(), secretFromCredential(credential));
if (isManagedProfileWithSeparatedLock(userId)) {
setDeviceUnlockedForUser(userId);
@@ -2684,7 +2712,8 @@
private VerifyCredentialResponse spBasedDoVerifyCredential(LockscreenCredential userCredential,
@ChallengeType int challengeType, long challenge,
int userId, ICheckCredentialProgressCallback progressCallback,
- @Nullable ArrayList<PendingResetLockout> resetLockouts) {
+ @Nullable ArrayList<PendingResetLockout> resetLockouts,
+ @LockPatternUtils.VerifyFlag int flags) {
final boolean hasEnrolledBiometrics = mInjector.hasEnrolledBiometrics(userId);
@@ -2705,6 +2734,8 @@
final AuthenticationResult authResult;
VerifyCredentialResponse response;
+ final boolean returnGkPw = (flags & VERIFY_FLAG_RETURN_GK_PW) != 0;
+
synchronized (mSpManager) {
if (!isSyntheticPasswordBasedCredentialLocked(userId)) {
return null;
@@ -2717,8 +2748,8 @@
long handle = getSyntheticPasswordHandleLocked(userId);
authResult = mSpManager.unwrapPasswordBasedSyntheticPassword(
getGateKeeperService(), handle, userCredential, userId, progressCallback);
-
response = authResult.gkResponse;
+
// credential has matched
if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK) {
// perform verifyChallenge with synthetic password which generates the real GK auth
@@ -2739,7 +2770,7 @@
if (resetLockouts == null) {
resetLockouts = new ArrayList<>();
}
- resetLockouts.add(new PendingResetLockout(userId, response.getPayload()));
+ resetLockouts.add(new PendingResetLockout(userId, response.getGatekeeperHAT()));
}
onCredentialVerified(authResult.authToken, challengeType, challenge, resetLockouts,
@@ -2750,7 +2781,12 @@
}
}
- return response;
+ if (response.isMatched() && returnGkPw) {
+ return new VerifyCredentialResponse.Builder()
+ .setGatekeeperPassword(authResult.authToken.deriveGkPassword()).build();
+ } else {
+ return response;
+ }
}
private void onCredentialVerified(AuthenticationToken authToken,
@@ -3172,7 +3208,8 @@
if (cred == null) {
return false;
}
- return doVerifyCredential(cred, CHALLENGE_NONE, 0, userId, null /* progressCallback */)
+ return doVerifyCredential(cred, CHALLENGE_NONE, 0, userId,
+ null /* progressCallback */, 0 /* flags */)
.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK;
}
}
diff --git a/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java b/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java
index d644b1d..e31bf3d 100644
--- a/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java
+++ b/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java
@@ -482,11 +482,12 @@
(int status, WeaverReadResponse readResponse) -> {
switch (status) {
case WeaverReadStatus.OK:
- response[0] = new VerifyCredentialResponse(
- fromByteArrayList(readResponse.value));
+ response[0] = new VerifyCredentialResponse.Builder().setGatekeeperHAT(
+ fromByteArrayList(readResponse.value)).build();
break;
case WeaverReadStatus.THROTTLE:
- response[0] = new VerifyCredentialResponse(readResponse.timeout);
+ response[0] = VerifyCredentialResponse
+ .fromTimeout(readResponse.timeout);
Slog.e(TAG, "weaver read failed (THROTTLE), slot: " + slot);
break;
case WeaverReadStatus.INCORRECT_KEY:
@@ -494,7 +495,8 @@
response[0] = VerifyCredentialResponse.ERROR;
Slog.e(TAG, "weaver read failed (INCORRECT_KEY), slot: " + slot);
} else {
- response[0] = new VerifyCredentialResponse(readResponse.timeout);
+ response[0] = VerifyCredentialResponse
+ .fromTimeout(readResponse.timeout);
Slog.e(TAG, "weaver read failed (INCORRECT_KEY/THROTTLE), slot: "
+ slot);
}
@@ -1007,7 +1009,8 @@
return result;
}
sid = GateKeeper.INVALID_SECURE_USER_ID;
- applicationId = transformUnderWeaverSecret(pwdToken, result.gkResponse.getPayload());
+ applicationId = transformUnderWeaverSecret(pwdToken,
+ result.gkResponse.getGatekeeperHAT());
} else {
byte[] gkPwdToken = passwordTokenToGkInput(pwdToken);
GateKeeperResponse response;
@@ -1045,7 +1048,7 @@
}
}
} else if (responseCode == GateKeeperResponse.RESPONSE_RETRY) {
- result.gkResponse = new VerifyCredentialResponse(response.getTimeout());
+ result.gkResponse = VerifyCredentialResponse.fromTimeout(response.getTimeout());
return result;
} else {
result.gkResponse = VerifyCredentialResponse.ERROR;
@@ -1096,12 +1099,12 @@
}
VerifyCredentialResponse response = weaverVerify(slotId, null);
if (response.getResponseCode() != VerifyCredentialResponse.RESPONSE_OK ||
- response.getPayload() == null) {
+ response.getGatekeeperHAT() == null) {
Slog.e(TAG, "Failed to retrieve weaver secret when unwrapping token");
result.gkResponse = VerifyCredentialResponse.ERROR;
return result;
}
- secdiscardable = SyntheticPasswordCrypto.decrypt(response.getPayload(),
+ secdiscardable = SyntheticPasswordCrypto.decrypt(response.getGatekeeperHAT(),
PERSONALISATION_WEAVER_TOKEN, secdiscardable);
}
byte[] applicationId = transformUnderSecdiscardable(token, secdiscardable);
@@ -1174,6 +1177,12 @@
*/
public @Nullable VerifyCredentialResponse verifyChallenge(IGateKeeperService gatekeeper,
@NonNull AuthenticationToken auth, long challenge, int userId) {
+ return verifyChallengeInternal(gatekeeper, auth.deriveGkPassword(), challenge, userId);
+ }
+
+ protected @Nullable VerifyCredentialResponse verifyChallengeInternal(
+ IGateKeeperService gatekeeper, @NonNull byte[] gatekeeperPassword, long challenge,
+ int userId) {
byte[] spHandle = loadSyntheticPasswordHandle(userId);
if (spHandle == null) {
// There is no password handle associated with the given user, i.e. the user is not
@@ -1183,18 +1192,19 @@
GateKeeperResponse response;
try {
response = gatekeeper.verifyChallenge(userId, challenge,
- spHandle, auth.deriveGkPassword());
+ spHandle, gatekeeperPassword);
} catch (RemoteException e) {
Slog.e(TAG, "Fail to verify with gatekeeper " + userId, e);
return VerifyCredentialResponse.ERROR;
}
int responseCode = response.getResponseCode();
if (responseCode == GateKeeperResponse.RESPONSE_OK) {
- VerifyCredentialResponse result = new VerifyCredentialResponse(response.getPayload());
+ VerifyCredentialResponse result = new VerifyCredentialResponse.Builder()
+ .setGatekeeperHAT(response.getPayload()).build();
if (response.getShouldReEnroll()) {
try {
response = gatekeeper.enroll(userId, spHandle, spHandle,
- auth.deriveGkPassword());
+ gatekeeperPassword);
} catch (RemoteException e) {
Slog.e(TAG, "Failed to invoke gatekeeper.enroll", e);
response = GateKeeperResponse.ERROR;
@@ -1203,7 +1213,8 @@
spHandle = response.getPayload();
saveSyntheticPasswordHandle(spHandle, userId);
// Call self again to re-verify with updated handle
- return verifyChallenge(gatekeeper, auth, challenge, userId);
+ return verifyChallengeInternal(gatekeeper, gatekeeperPassword, challenge,
+ userId);
} else {
// Fall through, return result from the previous verification attempt.
Slog.w(TAG, "Fail to re-enroll SP handle for user " + userId);
@@ -1211,7 +1222,7 @@
}
return result;
} else if (responseCode == GateKeeperResponse.RESPONSE_RETRY) {
- return new VerifyCredentialResponse(response.getTimeout());
+ return VerifyCredentialResponse.fromTimeout(response.getTimeout());
} else {
return VerifyCredentialResponse.ERROR;
}
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index e2f70e3..eb4ab1c 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -1937,7 +1937,8 @@
// Context#getPackageName() for getting package name that matches with the PID/UID,
// but it doesn't tell which package has created the MediaController, so useless.
return hasMediaControlPermission(controllerPid, controllerUid)
- || hasEnabledNotificationListener(userId, controllerPackageName, uid);
+ || hasEnabledNotificationListener(
+ userId, controllerPackageName, controllerUid);
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -2001,21 +2002,21 @@
return resolvedUserId;
}
- private boolean hasEnabledNotificationListener(int resolvedUserId, String packageName,
- int uid) {
- // TODO: revisit this checking code
- // You may not access another user's content as an enabled listener.
- final int userId = UserHandle.getUserHandleForUid(resolvedUserId).getIdentifier();
- if (resolvedUserId != userId) {
+ private boolean hasEnabledNotificationListener(int callingUserId,
+ String controllerPackageName, int controllerUid) {
+ int controllerUserId = UserHandle.getUserHandleForUid(controllerUid).getIdentifier();
+ if (callingUserId != controllerUserId) {
+ // Enabled notification listener only works within the same user.
return false;
}
- if (mNotificationManager.hasEnabledNotificationListener(packageName,
- UserHandle.getUserHandleForUid(uid))) {
+
+ if (mNotificationManager.hasEnabledNotificationListener(controllerPackageName,
+ UserHandle.getUserHandleForUid(controllerUid))) {
return true;
}
if (DEBUG) {
- Log.d(TAG, packageName + " (uid=" + uid + ") doesn't have an enabled "
- + "notification listener");
+ Log.d(TAG, controllerPackageName + " (uid=" + controllerUid
+ + ") doesn't have an enabled notification listener");
}
return false;
}
diff --git a/services/core/java/com/android/server/net/NetworkPolicyLogger.java b/services/core/java/com/android/server/net/NetworkPolicyLogger.java
index 3bd18f9..006d78e 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyLogger.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyLogger.java
@@ -70,9 +70,9 @@
static final int NTWK_BLOCKED_POWER = 0;
static final int NTWK_ALLOWED_NON_METERED = 1;
- static final int NTWK_BLOCKED_BLACKLIST = 2;
- static final int NTWK_ALLOWED_WHITELIST = 3;
- static final int NTWK_ALLOWED_TMP_WHITELIST = 4;
+ static final int NTWK_BLOCKED_DENYLIST = 2;
+ static final int NTWK_ALLOWED_ALLOWLIST = 3;
+ static final int NTWK_ALLOWED_TMP_ALLOWLIST = 4;
static final int NTWK_BLOCKED_BG_RESTRICT = 5;
static final int NTWK_ALLOWED_DEFAULT = 6;
static final int NTWK_ALLOWED_SYSTEM = 7;
@@ -269,12 +269,12 @@
return "blocked by power restrictions";
case NTWK_ALLOWED_NON_METERED:
return "allowed on unmetered network";
- case NTWK_BLOCKED_BLACKLIST:
- return "blacklisted on metered network";
- case NTWK_ALLOWED_WHITELIST:
- return "whitelisted on metered network";
- case NTWK_ALLOWED_TMP_WHITELIST:
- return "temporary whitelisted on metered network";
+ case NTWK_BLOCKED_DENYLIST:
+ return "denylisted on metered network";
+ case NTWK_ALLOWED_ALLOWLIST:
+ return "allowlisted on metered network";
+ case NTWK_ALLOWED_TMP_ALLOWLIST:
+ return "temporary allowlisted on metered network";
case NTWK_BLOCKED_BG_RESTRICT:
return "blocked when background is restricted";
case NTWK_ALLOWED_DEFAULT:
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index d6557f6..295143e 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -101,13 +101,13 @@
import static com.android.internal.util.XmlUtils.writeLongAttribute;
import static com.android.internal.util.XmlUtils.writeStringAttribute;
import static com.android.server.NetworkManagementService.LIMIT_GLOBAL_ALERT;
+import static com.android.server.net.NetworkPolicyLogger.NTWK_ALLOWED_ALLOWLIST;
import static com.android.server.net.NetworkPolicyLogger.NTWK_ALLOWED_DEFAULT;
import static com.android.server.net.NetworkPolicyLogger.NTWK_ALLOWED_NON_METERED;
import static com.android.server.net.NetworkPolicyLogger.NTWK_ALLOWED_SYSTEM;
-import static com.android.server.net.NetworkPolicyLogger.NTWK_ALLOWED_TMP_WHITELIST;
-import static com.android.server.net.NetworkPolicyLogger.NTWK_ALLOWED_WHITELIST;
+import static com.android.server.net.NetworkPolicyLogger.NTWK_ALLOWED_TMP_ALLOWLIST;
import static com.android.server.net.NetworkPolicyLogger.NTWK_BLOCKED_BG_RESTRICT;
-import static com.android.server.net.NetworkPolicyLogger.NTWK_BLOCKED_BLACKLIST;
+import static com.android.server.net.NetworkPolicyLogger.NTWK_BLOCKED_DENYLIST;
import static com.android.server.net.NetworkPolicyLogger.NTWK_BLOCKED_POWER;
import static com.android.server.net.NetworkStatsService.ACTION_NETWORK_STATS_UPDATED;
@@ -507,7 +507,7 @@
* UIDs that have been initially white-listed by system to avoid restricted background.
*/
@GuardedBy("mUidRulesFirstLock")
- private final SparseBooleanArray mDefaultRestrictBackgroundWhitelistUids =
+ private final SparseBooleanArray mDefaultRestrictBackgroundAllowlistUids =
new SparseBooleanArray();
/**
@@ -515,7 +515,7 @@
* but later revoked by user.
*/
@GuardedBy("mUidRulesFirstLock")
- private final SparseBooleanArray mRestrictBackgroundWhitelistRevokedUids =
+ private final SparseBooleanArray mRestrictBackgroundAllowlistRevokedUids =
new SparseBooleanArray();
/** Set of ifaces that are metered. */
@@ -582,7 +582,7 @@
@GuardedBy("mUidRulesFirstLock")
private final SparseBooleanArray mInternetPermissionMap = new SparseBooleanArray();
- // TODO: keep whitelist of system-critical services that should never have
+ // TODO: keep allowlist of system-critical services that should never have
// rules enforced, such as system, phone, and radio UIDs.
// TODO: migrate notifications to SystemUI
@@ -668,26 +668,26 @@
}
/**
- * Whitelists pre-defined apps for restrict background, but only if the user didn't already
- * revoke the whitelist.
+ * Allows pre-defined apps for restrict background, but only if the user didn't already
+ * revoked them.
*
- * @return whether any uid has been whitelisted.
+ * @return whether any uid has been allowlisted.
*/
@GuardedBy("mUidRulesFirstLock")
- boolean addDefaultRestrictBackgroundWhitelistUidsUL() {
+ boolean addDefaultRestrictBackgroundAllowlistUidsUL() {
final List<UserInfo> users = mUserManager.getUsers();
final int numberUsers = users.size();
boolean changed = false;
for (int i = 0; i < numberUsers; i++) {
final UserInfo user = users.get(i);
- changed = addDefaultRestrictBackgroundWhitelistUidsUL(user.id) || changed;
+ changed = addDefaultRestrictBackgroundAllowlistUidsUL(user.id) || changed;
}
return changed;
}
@GuardedBy("mUidRulesFirstLock")
- private boolean addDefaultRestrictBackgroundWhitelistUidsUL(int userId) {
+ private boolean addDefaultRestrictBackgroundAllowlistUidsUL(int userId) {
final SystemConfig sysConfig = SystemConfig.getInstance();
final PackageManager pm = mContext.getPackageManager();
final ArraySet<String> allowDataUsage = sysConfig.getAllowInDataUsageSave();
@@ -695,7 +695,7 @@
for (int i = 0; i < allowDataUsage.size(); i++) {
final String pkg = allowDataUsage.valueAt(i);
if (LOGD)
- Slog.d(TAG, "checking restricted background whitelisting for package " + pkg
+ Slog.d(TAG, "checking restricted background allowlisting for package " + pkg
+ " and user " + userId);
final ApplicationInfo app;
try {
@@ -706,20 +706,20 @@
continue;
}
if (!app.isPrivilegedApp()) {
- Slog.e(TAG, "addDefaultRestrictBackgroundWhitelistUidsUL(): "
+ Slog.e(TAG, "addDefaultRestrictBackgroundAllowlistUidsUL(): "
+ "skipping non-privileged app " + pkg);
continue;
}
final int uid = UserHandle.getUid(userId, app.uid);
- mDefaultRestrictBackgroundWhitelistUids.append(uid, true);
+ mDefaultRestrictBackgroundAllowlistUids.append(uid, true);
if (LOGD)
Slog.d(TAG, "Adding uid " + uid + " (user " + userId + ") to default restricted "
- + "background whitelist. Revoked status: "
- + mRestrictBackgroundWhitelistRevokedUids.get(uid));
- if (!mRestrictBackgroundWhitelistRevokedUids.get(uid)) {
+ + "background allowlist. Revoked status: "
+ + mRestrictBackgroundAllowlistRevokedUids.get(uid));
+ if (!mRestrictBackgroundAllowlistRevokedUids.get(uid)) {
if (LOGD)
Slog.d(TAG, "adding default package " + pkg + " (uid " + uid + " for user "
- + userId + ") to restrict background whitelist");
+ + userId + ") to restrict background allowlist");
setUidPolicyUncheckedUL(uid, POLICY_ALLOW_METERED_BACKGROUND, false);
changed = true;
}
@@ -799,7 +799,7 @@
}
});
- if (addDefaultRestrictBackgroundWhitelistUidsUL()) {
+ if (addDefaultRestrictBackgroundAllowlistUidsUL()) {
writePolicyAL();
}
@@ -1005,14 +1005,14 @@
case ACTION_USER_ADDED:
synchronized (mUidRulesFirstLock) {
// Remove any persistable state for the given user; both cleaning up after a
- // USER_REMOVED, and one last sanity check during USER_ADDED
+ // USER_REMOVED, and one last check during USER_ADDED
removeUserStateUL(userId, true, false);
// Removing outside removeUserStateUL since that can also be called when
// user resets app preferences.
mMeteredRestrictedUids.remove(userId);
if (action == ACTION_USER_ADDED) {
- // Add apps that are whitelisted by default.
- addDefaultRestrictBackgroundWhitelistUidsUL(userId);
+ // Add apps that are allowlisted by default.
+ addDefaultRestrictBackgroundAllowlistUidsUL(userId);
}
// Update global restrict for that user
synchronized (mNetworkPoliciesSecondLock) {
@@ -2196,12 +2196,12 @@
in.setInput(fis, StandardCharsets.UTF_8.name());
// Must save the <restrict-background> tags and convert them to <uid-policy> later,
- // to skip UIDs that were explicitly blacklisted.
- final SparseBooleanArray whitelistedRestrictBackground = new SparseBooleanArray();
+ // to skip UIDs that were explicitly denylisted.
+ final SparseBooleanArray allowlistedRestrictBackground = new SparseBooleanArray();
int type;
int version = VERSION_INIT;
- boolean insideWhitelist = false;
+ boolean insideAllowlist = false;
while ((type = in.next()) != END_DOCUMENT) {
final String tag = in.getName();
if (type == START_TAG) {
@@ -2340,28 +2340,28 @@
Slog.w(TAG, "unable to apply policy to UID " + uid + "; ignoring");
}
} else if (TAG_WHITELIST.equals(tag)) {
- insideWhitelist = true;
- } else if (TAG_RESTRICT_BACKGROUND.equals(tag) && insideWhitelist) {
+ insideAllowlist = true;
+ } else if (TAG_RESTRICT_BACKGROUND.equals(tag) && insideAllowlist) {
final int uid = readIntAttribute(in, ATTR_UID);
- whitelistedRestrictBackground.append(uid, true);
- } else if (TAG_REVOKED_RESTRICT_BACKGROUND.equals(tag) && insideWhitelist) {
+ allowlistedRestrictBackground.append(uid, true);
+ } else if (TAG_REVOKED_RESTRICT_BACKGROUND.equals(tag) && insideAllowlist) {
final int uid = readIntAttribute(in, ATTR_UID);
- mRestrictBackgroundWhitelistRevokedUids.put(uid, true);
+ mRestrictBackgroundAllowlistRevokedUids.put(uid, true);
}
} else if (type == END_TAG) {
if (TAG_WHITELIST.equals(tag)) {
- insideWhitelist = false;
+ insideAllowlist = false;
}
}
}
- final int size = whitelistedRestrictBackground.size();
+ final int size = allowlistedRestrictBackground.size();
for (int i = 0; i < size; i++) {
- final int uid = whitelistedRestrictBackground.keyAt(i);
+ final int uid = allowlistedRestrictBackground.keyAt(i);
final int policy = mUidPolicy.get(uid, POLICY_NONE);
if ((policy & POLICY_REJECT_METERED_BACKGROUND) != 0) {
- Slog.w(TAG, "ignoring restrict-background-whitelist for " + uid
+ Slog.w(TAG, "ignoring restrict-background-allowlist for " + uid
+ " because its policy is " + uidPoliciesToString(policy));
continue;
}
@@ -2533,13 +2533,13 @@
out.endTag(null, TAG_POLICY_LIST);
- // write all whitelists
+ // write all allowlists
out.startTag(null, TAG_WHITELIST);
- // revoked restrict background whitelist
- int size = mRestrictBackgroundWhitelistRevokedUids.size();
+ // revoked restrict background allowlist
+ int size = mRestrictBackgroundAllowlistRevokedUids.size();
for (int i = 0; i < size; i++) {
- final int uid = mRestrictBackgroundWhitelistRevokedUids.keyAt(i);
+ final int uid = mRestrictBackgroundAllowlistRevokedUids.keyAt(i);
out.startTag(null, TAG_REVOKED_RESTRICT_BACKGROUND);
writeIntAttribute(out, ATTR_UID, uid);
out.endTag(null, TAG_REVOKED_RESTRICT_BACKGROUND);
@@ -2619,21 +2619,21 @@
setUidPolicyUncheckedUL(uid, policy, false);
final boolean notifyApp;
- if (!isUidValidForWhitelistRulesUL(uid)) {
+ if (!isUidValidForAllowlistRulesUL(uid)) {
notifyApp = false;
} else {
- final boolean wasBlacklisted = oldPolicy == POLICY_REJECT_METERED_BACKGROUND;
- final boolean isBlacklisted = policy == POLICY_REJECT_METERED_BACKGROUND;
- final boolean wasWhitelisted = oldPolicy == POLICY_ALLOW_METERED_BACKGROUND;
- final boolean isWhitelisted = policy == POLICY_ALLOW_METERED_BACKGROUND;
- final boolean wasBlocked = wasBlacklisted || (mRestrictBackground && !wasWhitelisted);
- final boolean isBlocked = isBlacklisted || (mRestrictBackground && !isWhitelisted);
- if ((wasWhitelisted && (!isWhitelisted || isBlacklisted))
- && mDefaultRestrictBackgroundWhitelistUids.get(uid)
- && !mRestrictBackgroundWhitelistRevokedUids.get(uid)) {
+ final boolean wasDenylisted = oldPolicy == POLICY_REJECT_METERED_BACKGROUND;
+ final boolean isDenylisted = policy == POLICY_REJECT_METERED_BACKGROUND;
+ final boolean wasAllowlisted = oldPolicy == POLICY_ALLOW_METERED_BACKGROUND;
+ final boolean isAllowlisted = policy == POLICY_ALLOW_METERED_BACKGROUND;
+ final boolean wasBlocked = wasDenylisted || (mRestrictBackground && !wasAllowlisted);
+ final boolean isBlocked = isDenylisted || (mRestrictBackground && !isAllowlisted);
+ if ((wasAllowlisted && (!isAllowlisted || isDenylisted))
+ && mDefaultRestrictBackgroundAllowlistUids.get(uid)
+ && !mRestrictBackgroundAllowlistRevokedUids.get(uid)) {
if (LOGD)
- Slog.d(TAG, "Adding uid " + uid + " to revoked restrict background whitelist");
- mRestrictBackgroundWhitelistRevokedUids.append(uid, true);
+ Slog.d(TAG, "Adding uid " + uid + " to revoked restrict background allowlist");
+ mRestrictBackgroundAllowlistRevokedUids.append(uid, true);
}
notifyApp = wasBlocked != isBlocked;
}
@@ -2700,11 +2700,11 @@
mLogger.removingUserState(userId);
boolean changed = false;
- // Remove entries from revoked default restricted background UID whitelist
- for (int i = mRestrictBackgroundWhitelistRevokedUids.size() - 1; i >= 0; i--) {
- final int uid = mRestrictBackgroundWhitelistRevokedUids.keyAt(i);
+ // Remove entries from revoked default restricted background UID allowlist
+ for (int i = mRestrictBackgroundAllowlistRevokedUids.size() - 1; i >= 0; i--) {
+ final int uid = mRestrictBackgroundAllowlistRevokedUids.keyAt(i);
if (UserHandle.getUserId(uid) == userId) {
- mRestrictBackgroundWhitelistRevokedUids.removeAt(i);
+ mRestrictBackgroundAllowlistRevokedUids.removeAt(i);
changed = true;
}
}
@@ -2913,7 +2913,7 @@
Slog.d(TAG, "setRestrictBackgroundUL(): " + restrictBackground + "; reason: " + reason);
final boolean oldRestrictBackground = mRestrictBackground;
mRestrictBackground = restrictBackground;
- // Must whitelist foreground apps before turning data saver mode on.
+ // Must allowlist foreground apps before turning data saver mode on.
// TODO: there is no need to iterate through all apps here, just those in the foreground,
// so it could call AM to get the UIDs of such apps, and iterate through them instead.
updateRulesForRestrictBackgroundUL();
@@ -2966,7 +2966,7 @@
Binder.restoreCallingIdentity(token);
}
if (policy == POLICY_REJECT_METERED_BACKGROUND) {
- // App is blacklisted.
+ // App is denylisted.
return RESTRICT_BACKGROUND_STATUS_ENABLED;
}
if (!mRestrictBackground) {
@@ -3543,25 +3543,25 @@
fout.decreaseIndent();
}
- size = mDefaultRestrictBackgroundWhitelistUids.size();
+ size = mDefaultRestrictBackgroundAllowlistUids.size();
if (size > 0) {
- fout.println("Default restrict background whitelist uids:");
+ fout.println("Default restrict background allowlist uids:");
fout.increaseIndent();
for (int i = 0; i < size; i++) {
fout.print("UID=");
- fout.print(mDefaultRestrictBackgroundWhitelistUids.keyAt(i));
+ fout.print(mDefaultRestrictBackgroundAllowlistUids.keyAt(i));
fout.println();
}
fout.decreaseIndent();
}
- size = mRestrictBackgroundWhitelistRevokedUids.size();
+ size = mRestrictBackgroundAllowlistRevokedUids.size();
if (size > 0) {
- fout.println("Default restrict background whitelist uids revoked by users:");
+ fout.println("Default restrict background allowlist uids revoked by users:");
fout.increaseIndent();
for (int i = 0; i < size; i++) {
fout.print("UID=");
- fout.print(mRestrictBackgroundWhitelistRevokedUids.keyAt(i));
+ fout.print(mRestrictBackgroundAllowlistRevokedUids.keyAt(i));
fout.println();
}
fout.decreaseIndent();
@@ -3882,7 +3882,7 @@
@GuardedBy("mUidRulesFirstLock")
void updateRuleForAppIdleUL(int uid) {
- if (!isUidValidForBlacklistRulesUL(uid)) return;
+ if (!isUidValidForDenylistRulesUL(uid)) return;
if (Trace.isTagEnabled(Trace.TRACE_TAG_NETWORK)) {
Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "updateRuleForAppIdleUL: " + uid );
@@ -3915,13 +3915,13 @@
final SparseIntArray blockedUids = new SparseIntArray();
for (int i = 0; i < ruleCount; i++) {
final int uid = mUidFirewallStandbyRules.keyAt(i);
- if (!isUidValidForBlacklistRulesUL(uid)) {
+ if (!isUidValidForDenylistRulesUL(uid)) {
continue;
}
int oldRules = mUidRules.get(uid);
if (enableChain) {
// Chain wasn't enabled before and the other power-related
- // chains are whitelists, so we can clear the
+ // chains are allowlists, so we can clear the
// MASK_ALL_NETWORKS part of the rules and re-inform listeners if
// the effective rules result in blocking network access.
oldRules &= MASK_METERED_NETWORKS;
@@ -4079,10 +4079,10 @@
// TODO: the MEDIA / DRM restriction might not be needed anymore, in which case both
// methods below could be merged into a isUidValidForRules() method.
@GuardedBy("mUidRulesFirstLock")
- private boolean isUidValidForBlacklistRulesUL(int uid) {
+ private boolean isUidValidForDenylistRulesUL(int uid) {
// allow rules on specific system services, and any apps
if (uid == android.os.Process.MEDIA_UID || uid == android.os.Process.DRM_UID
- || isUidValidForWhitelistRulesUL(uid)) {
+ || isUidValidForAllowlistRulesUL(uid)) {
return true;
}
@@ -4090,7 +4090,7 @@
}
@GuardedBy("mUidRulesFirstLock")
- private boolean isUidValidForWhitelistRulesUL(int uid) {
+ private boolean isUidValidForAllowlistRulesUL(int uid) {
return UserHandle.isApp(uid) && hasInternetPermissionUL(uid);
}
@@ -4235,23 +4235,23 @@
/**
* Applies network rules to bandwidth controllers based on process state and user-defined
- * restrictions (blacklist / whitelist).
+ * restrictions (allowlist / denylist).
*
* <p>
* {@code netd} defines 3 firewall chains that govern whether an app has access to metered
* networks:
* <ul>
- * <li>@{code bw_penalty_box}: UIDs added to this chain do not have access (blacklist).
- * <li>@{code bw_happy_box}: UIDs added to this chain have access (whitelist), unless they're
- * also blacklisted.
+ * <li>@{code bw_penalty_box}: UIDs added to this chain do not have access (denylist).
+ * <li>@{code bw_happy_box}: UIDs added to this chain have access (allowlist), unless they're
+ * also denylisted.
* <li>@{code bw_data_saver}: when enabled (through {@link #setRestrictBackground(boolean)}),
- * no UIDs other than those whitelisted will have access.
+ * no UIDs other than those allowlisted will have access.
* <ul>
*
* <p>The @{code bw_penalty_box} and @{code bw_happy_box} are primarily managed through the
- * {@link #setUidPolicy(int, int)} and {@link #addRestrictBackgroundWhitelistedUid(int)} /
- * {@link #removeRestrictBackgroundWhitelistedUid(int)} methods (for blacklist and whitelist
- * respectively): these methods set the proper internal state (blacklist / whitelist), then call
+ * {@link #setUidPolicy(int, int)} and {@link #addRestrictBackgroundAllowlistedUid(int)} /
+ * {@link #removeRestrictBackgroundDenylistedUid(int)} methods (for denylist and allowlist
+ * respectively): these methods set the proper internal state (denylist / allowlist), then call
* this ({@link #updateRulesForDataUsageRestrictionsUL(int)}) to propagate the rules to
* {@link INetworkManagementService}, but this method should also be called in events (like
* Data Saver Mode flips or UID state changes) that might affect the foreground app, since the
@@ -4260,7 +4260,7 @@
* <ul>
* <li>When Data Saver mode is on, the foreground app should be temporarily added to
* {@code bw_happy_box} before the @{code bw_data_saver} chain is enabled.
- * <li>If the foreground app is blacklisted by the user, it should be temporarily removed from
+ * <li>If the foreground app is denylisted by the user, it should be temporarily removed from
* {@code bw_penalty_box}.
* <li>When the app leaves foreground state, the temporary changes above should be reverted.
* </ul>
@@ -4285,7 +4285,7 @@
}
private void updateRulesForDataUsageRestrictionsULInner(int uid) {
- if (!isUidValidForWhitelistRulesUL(uid)) {
+ if (!isUidValidForAllowlistRulesUL(uid)) {
if (LOGD) Slog.d(TAG, "no need to update restrict data rules for uid " + uid);
return;
}
@@ -4295,8 +4295,8 @@
final boolean isForeground = isUidForegroundOnRestrictBackgroundUL(uid);
final boolean isRestrictedByAdmin = isRestrictedByAdminUL(uid);
- final boolean isBlacklisted = (uidPolicy & POLICY_REJECT_METERED_BACKGROUND) != 0;
- final boolean isWhitelisted = (uidPolicy & POLICY_ALLOW_METERED_BACKGROUND) != 0;
+ final boolean isDenylisted = (uidPolicy & POLICY_REJECT_METERED_BACKGROUND) != 0;
+ final boolean isAllowlisted = (uidPolicy & POLICY_ALLOW_METERED_BACKGROUND) != 0;
final int oldRule = oldUidRules & MASK_METERED_NETWORKS;
int newRule = RULE_NONE;
@@ -4304,15 +4304,15 @@
if (isRestrictedByAdmin) {
newRule = RULE_REJECT_METERED;
} else if (isForeground) {
- if (isBlacklisted || (mRestrictBackground && !isWhitelisted)) {
+ if (isDenylisted || (mRestrictBackground && !isAllowlisted)) {
newRule = RULE_TEMPORARY_ALLOW_METERED;
- } else if (isWhitelisted) {
+ } else if (isAllowlisted) {
newRule = RULE_ALLOW_METERED;
}
} else {
- if (isBlacklisted) {
+ if (isDenylisted) {
newRule = RULE_REJECT_METERED;
- } else if (mRestrictBackground && isWhitelisted) {
+ } else if (mRestrictBackground && isAllowlisted) {
newRule = RULE_ALLOW_METERED;
}
}
@@ -4321,8 +4321,8 @@
if (LOGV) {
Log.v(TAG, "updateRuleForRestrictBackgroundUL(" + uid + ")"
+ ": isForeground=" +isForeground
- + ", isBlacklisted=" + isBlacklisted
- + ", isWhitelisted=" + isWhitelisted
+ + ", isDenylisted=" + isDenylisted
+ + ", isAllowlisted=" + isAllowlisted
+ ", isRestrictedByAdmin=" + isRestrictedByAdmin
+ ", oldRule=" + uidRulesToString(oldRule)
+ ", newRule=" + uidRulesToString(newRule)
@@ -4339,49 +4339,49 @@
// Second step: apply bw changes based on change of state.
if (newRule != oldRule) {
if (hasRule(newRule, RULE_TEMPORARY_ALLOW_METERED)) {
- // Temporarily whitelist foreground app, removing from blacklist if necessary
+ // Temporarily allowlist foreground app, removing from denylist if necessary
// (since bw_penalty_box prevails over bw_happy_box).
- setMeteredNetworkWhitelist(uid, true);
+ setMeteredNetworkAllowlist(uid, true);
// TODO: if statement below is used to avoid an unnecessary call to netd / iptables,
// but ideally it should be just:
- // setMeteredNetworkBlacklist(uid, isBlacklisted);
- if (isBlacklisted) {
- setMeteredNetworkBlacklist(uid, false);
+ // setMeteredNetworkDenylist(uid, isDenylisted);
+ if (isDenylisted) {
+ setMeteredNetworkDenylist(uid, false);
}
} else if (hasRule(oldRule, RULE_TEMPORARY_ALLOW_METERED)) {
- // Remove temporary whitelist from app that is not on foreground anymore.
+ // Remove temporary allowlist from app that is not on foreground anymore.
// TODO: if statements below are used to avoid unnecessary calls to netd / iptables,
// but ideally they should be just:
- // setMeteredNetworkWhitelist(uid, isWhitelisted);
- // setMeteredNetworkBlacklist(uid, isBlacklisted);
- if (!isWhitelisted) {
- setMeteredNetworkWhitelist(uid, false);
+ // setMeteredNetworkAllowlist(uid, isAllowlisted);
+ // setMeteredNetworkDenylist(uid, isDenylisted);
+ if (!isAllowlisted) {
+ setMeteredNetworkAllowlist(uid, false);
}
- if (isBlacklisted || isRestrictedByAdmin) {
- setMeteredNetworkBlacklist(uid, true);
+ if (isDenylisted || isRestrictedByAdmin) {
+ setMeteredNetworkDenylist(uid, true);
}
} else if (hasRule(newRule, RULE_REJECT_METERED)
|| hasRule(oldRule, RULE_REJECT_METERED)) {
- // Flip state because app was explicitly added or removed to blacklist.
- setMeteredNetworkBlacklist(uid, (isBlacklisted || isRestrictedByAdmin));
- if (hasRule(oldRule, RULE_REJECT_METERED) && isWhitelisted) {
- // Since blacklist prevails over whitelist, we need to handle the special case
- // where app is whitelisted and blacklisted at the same time (although such
- // scenario should be blocked by the UI), then blacklist is removed.
- setMeteredNetworkWhitelist(uid, isWhitelisted);
+ // Flip state because app was explicitly added or removed to denylist.
+ setMeteredNetworkDenylist(uid, (isDenylisted || isRestrictedByAdmin));
+ if (hasRule(oldRule, RULE_REJECT_METERED) && isAllowlisted) {
+ // Since dneylist prevails over allowlist, we need to handle the special case
+ // where app is allowlisted and denylisted at the same time (although such
+ // scenario should be blocked by the UI), then denylist is removed.
+ setMeteredNetworkAllowlist(uid, isAllowlisted);
}
} else if (hasRule(newRule, RULE_ALLOW_METERED)
|| hasRule(oldRule, RULE_ALLOW_METERED)) {
- // Flip state because app was explicitly added or removed to whitelist.
- setMeteredNetworkWhitelist(uid, isWhitelisted);
+ // Flip state because app was explicitly added or removed to allowlist.
+ setMeteredNetworkAllowlist(uid, isAllowlisted);
} else {
// All scenarios should have been covered above.
Log.wtf(TAG, "Unexpected change of metered UID state for " + uid
+ ": foreground=" + isForeground
- + ", whitelisted=" + isWhitelisted
- + ", blacklisted=" + isBlacklisted
+ + ", allowlisted=" + isAllowlisted
+ + ", denylisted=" + isDenylisted
+ ", isRestrictedByAdmin=" + isRestrictedByAdmin
+ ", newRule=" + uidRulesToString(newUidRules)
+ ", oldRule=" + uidRulesToString(oldUidRules));
@@ -4397,7 +4397,7 @@
* listeners in case of change.
* <p>
* There are 3 power-related rules that affects whether an app has background access on
- * non-metered networks, and when the condition applies and the UID is not whitelisted for power
+ * non-metered networks, and when the condition applies and the UID is not allowlisted for power
* restriction, it's added to the equivalent firewall chain:
* <ul>
* <li>App is idle: {@code fw_standby} firewall chain.
@@ -4406,7 +4406,7 @@
* </ul>
* <p>
* This method updates the power-related part of the {@link #mUidRules} for a given uid based on
- * these modes, the UID process state (foreground or not), and the UIDwhitelist state.
+ * these modes, the UID process state (foreground or not), and the UID allowlist state.
* <p>
* <strong>NOTE: </strong>This method does not update the firewall rules on {@code netd}.
*/
@@ -4450,7 +4450,7 @@
@GuardedBy("mUidRulesFirstLock")
private int updateRulesForPowerRestrictionsULInner(int uid, int oldUidRules,
boolean isUidIdle) {
- if (!isUidValidForBlacklistRulesUL(uid)) {
+ if (!isUidValidForDenylistRulesUL(uid)) {
if (LOGD) Slog.d(TAG, "no need to update restrict power rules for uid " + uid);
return RULE_NONE;
}
@@ -4859,23 +4859,23 @@
}
}
- private void setMeteredNetworkBlacklist(int uid, boolean enable) {
- if (LOGV) Slog.v(TAG, "setMeteredNetworkBlacklist " + uid + ": " + enable);
+ private void setMeteredNetworkDenylist(int uid, boolean enable) {
+ if (LOGV) Slog.v(TAG, "setMeteredNetworkDenylist " + uid + ": " + enable);
try {
- mNetworkManager.setUidMeteredNetworkBlacklist(uid, enable);
+ mNetworkManager.setUidMeteredNetworkDenylist(uid, enable);
} catch (IllegalStateException e) {
- Log.wtf(TAG, "problem setting blacklist (" + enable + ") rules for " + uid, e);
+ Log.wtf(TAG, "problem setting denylist (" + enable + ") rules for " + uid, e);
} catch (RemoteException e) {
// ignored; service lives in system_server
}
}
- private void setMeteredNetworkWhitelist(int uid, boolean enable) {
- if (LOGV) Slog.v(TAG, "setMeteredNetworkWhitelist " + uid + ": " + enable);
+ private void setMeteredNetworkAllowlist(int uid, boolean enable) {
+ if (LOGV) Slog.v(TAG, "setMeteredNetworkAllowlist " + uid + ": " + enable);
try {
- mNetworkManager.setUidMeteredNetworkWhitelist(uid, enable);
+ mNetworkManager.setUidMeteredNetworkAllowlist(uid, enable);
} catch (IllegalStateException e) {
- Log.wtf(TAG, "problem setting whitelist (" + enable + ") rules for " + uid, e);
+ Log.wtf(TAG, "problem setting allowlist (" + enable + ") rules for " + uid, e);
} catch (RemoteException e) {
// ignored; service lives in system_server
}
@@ -4936,7 +4936,7 @@
}
/**
- * Add or remove a uid to the firewall blacklist for all network ifaces.
+ * Add or remove a uid to the firewall denylist for all network ifaces.
*/
private void setUidFirewallRule(int chain, int uid, int rule) {
if (Trace.isTagEnabled(Trace.TRACE_TAG_NETWORK)) {
@@ -4966,7 +4966,7 @@
}
/**
- * Add or remove a uid to the firewall blacklist for all network ifaces.
+ * Add or remove a uid to the firewall denylist for all network ifaces.
*/
@GuardedBy("mUidRulesFirstLock")
private void enableFirewallChainUL(int chain, boolean enable) {
@@ -4995,8 +4995,8 @@
mNetworkManager.setFirewallUidRule(FIREWALL_CHAIN_STANDBY, uid, FIREWALL_RULE_DEFAULT);
mNetworkManager
.setFirewallUidRule(FIREWALL_CHAIN_POWERSAVE, uid, FIREWALL_RULE_DEFAULT);
- mNetworkManager.setUidMeteredNetworkWhitelist(uid, false);
- mNetworkManager.setUidMeteredNetworkBlacklist(uid, false);
+ mNetworkManager.setUidMeteredNetworkAllowlist(uid, false);
+ mNetworkManager.setUidMeteredNetworkDenylist(uid, false);
} catch (IllegalStateException e) {
Log.wtf(TAG, "problem resetting firewall uid rules for " + uid, e);
} catch (RemoteException e) {
@@ -5189,13 +5189,13 @@
reason = NTWK_ALLOWED_NON_METERED;
}
else if (hasRule(uidRules, RULE_REJECT_METERED)) {
- reason = NTWK_BLOCKED_BLACKLIST;
+ reason = NTWK_BLOCKED_DENYLIST;
}
else if (hasRule(uidRules, RULE_ALLOW_METERED)) {
- reason = NTWK_ALLOWED_WHITELIST;
+ reason = NTWK_ALLOWED_ALLOWLIST;
}
else if (hasRule(uidRules, RULE_TEMPORARY_ALLOW_METERED)) {
- reason = NTWK_ALLOWED_TMP_WHITELIST;
+ reason = NTWK_ALLOWED_TMP_ALLOWLIST;
}
else if (isBackgroundRestricted) {
reason = NTWK_BLOCKED_BG_RESTRICT;
@@ -5208,13 +5208,13 @@
switch(reason) {
case NTWK_ALLOWED_DEFAULT:
case NTWK_ALLOWED_NON_METERED:
- case NTWK_ALLOWED_TMP_WHITELIST:
- case NTWK_ALLOWED_WHITELIST:
+ case NTWK_ALLOWED_TMP_ALLOWLIST:
+ case NTWK_ALLOWED_ALLOWLIST:
case NTWK_ALLOWED_SYSTEM:
blocked = false;
break;
case NTWK_BLOCKED_POWER:
- case NTWK_BLOCKED_BLACKLIST:
+ case NTWK_BLOCKED_DENYLIST:
case NTWK_BLOCKED_BG_RESTRICT:
blocked = true;
break;
@@ -5234,7 +5234,7 @@
public void resetUserState(int userId) {
synchronized (mUidRulesFirstLock) {
boolean changed = removeUserStateUL(userId, false, true);
- changed = addDefaultRestrictBackgroundWhitelistUidsUL(userId) || changed;
+ changed = addDefaultRestrictBackgroundAllowlistUidsUL(userId) || changed;
if (changed) {
synchronized (mNetworkPoliciesSecondLock) {
writePolicyAL();
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index d71c33e..2d052da 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -7288,12 +7288,12 @@
@GuardedBy("mToastQueue")
private void keepProcessAliveForToastIfNeededLocked(int pid) {
- int toastCount = 0; // toasts from this pid
+ int toastCount = 0; // toasts from this pid, rendered by the app
ArrayList<ToastRecord> list = mToastQueue;
int n = list.size();
for (int i = 0; i < n; i++) {
ToastRecord r = list.get(i);
- if (r.pid == pid) {
+ if (r.pid == pid && r.keepProcessAlive()) {
toastCount++;
}
}
diff --git a/services/core/java/com/android/server/notification/toast/CustomToastRecord.java b/services/core/java/com/android/server/notification/toast/CustomToastRecord.java
index 2b91a00..17e0b39 100644
--- a/services/core/java/com/android/server/notification/toast/CustomToastRecord.java
+++ b/services/core/java/com/android/server/notification/toast/CustomToastRecord.java
@@ -71,6 +71,13 @@
}
@Override
+ public boolean keepProcessAlive() {
+ // As custom toasts are rendered by the app, we need to keep the app alive for it to show
+ // the toast.
+ return true;
+ }
+
+ @Override
public String toString() {
return "CustomToastRecord{"
+ Integer.toHexString(System.identityHashCode(this))
diff --git a/services/core/java/com/android/server/notification/toast/ToastRecord.java b/services/core/java/com/android/server/notification/toast/ToastRecord.java
index 7915f70..33906cc 100644
--- a/services/core/java/com/android/server/notification/toast/ToastRecord.java
+++ b/services/core/java/com/android/server/notification/toast/ToastRecord.java
@@ -85,4 +85,14 @@
}
pw.println(prefix + this);
}
+
+ /**
+ * Returns whether it's necessary to bump the process state to keep it alive in order to show
+ * the toast.
+ */
+ public boolean keepProcessAlive() {
+ // By default we assume the toast is rendered by the systemUI. Any toast rendered by the app
+ // should override this method.
+ return false;
+ }
}
diff --git a/services/core/java/com/android/server/pm/PackageInstallerService.java b/services/core/java/com/android/server/pm/PackageInstallerService.java
index 55e7ca8..840645e 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerService.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerService.java
@@ -442,7 +442,7 @@
// After reboot housekeeping.
for (int i = 0; i < mSessions.size(); ++i) {
PackageInstallerSession session = mSessions.valueAt(i);
- session.onAfterSessionRead();
+ session.onAfterSessionRead(mSessions);
}
}
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java
index 05026a0..ff9edd5 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerSession.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -122,7 +122,7 @@
import android.util.ExceptionUtils;
import android.util.MathUtils;
import android.util.Slog;
-import android.util.SparseIntArray;
+import android.util.SparseArray;
import android.util.apk.ApkSignatureVerifier;
import com.android.internal.R;
@@ -336,7 +336,7 @@
@GuardedBy("mLock")
private PackageParser.SigningDetails mSigningDetails;
@GuardedBy("mLock")
- private SparseIntArray mChildSessionIds = new SparseIntArray();
+ private SparseArray<PackageInstallerSession> mChildSessions = new SparseArray<>();
@GuardedBy("mLock")
private int mParentSessionId;
@@ -589,7 +589,9 @@
this.mShouldBeSealed = sealed;
if (childSessionIds != null) {
for (int childSessionId : childSessionIds) {
- mChildSessionIds.put(childSessionId, 0);
+ // Null values will be resolved to actual object references in
+ // #onAfterSessionRead later.
+ mChildSessions.put(childSessionId, null);
}
}
this.mParentSessionId = parentSessionId;
@@ -708,10 +710,7 @@
info.isStaged = params.isStaged;
info.rollbackDataPolicy = params.rollbackDataPolicy;
info.parentSessionId = mParentSessionId;
- info.childSessionIds = mChildSessionIds.copyKeys();
- if (info.childSessionIds == null) {
- info.childSessionIds = EMPTY_CHILD_SESSION_ARRAY;
- }
+ info.childSessionIds = getChildSessionIdsLocked();
info.isStagedSessionApplied = mStagedSessionApplied;
info.isStagedSessionReady = mStagedSessionReady;
info.isStagedSessionFailed = mStagedSessionFailed;
@@ -1159,27 +1158,22 @@
return;
}
if (isMultiPackage()) {
- final SparseIntArray remainingSessions;
- final int[] childSessionIds;
synchronized (mLock) {
- remainingSessions = mChildSessionIds.clone();
- childSessionIds = mChildSessionIds.copyKeys();
- }
- final IntentSender childIntentSender =
- new ChildStatusIntentReceiver(remainingSessions, statusReceiver)
- .getIntentSender();
- boolean sealFailed = false;
- for (int i = childSessionIds.length - 1; i >= 0; --i) {
- final int childSessionId = childSessionIds[i];
- // seal all children, regardless if any of them fail; we'll throw/return
- // as appropriate once all children have been processed
- if (!mSessionProvider.getSession(childSessionId)
- .markAsSealed(childIntentSender, forTransfer)) {
- sealFailed = true;
+ final IntentSender childIntentSender =
+ new ChildStatusIntentReceiver(mChildSessions.clone(), statusReceiver)
+ .getIntentSender();
+ boolean sealFailed = false;
+ for (int i = mChildSessions.size() - 1; i >= 0; --i) {
+ // seal all children, regardless if any of them fail; we'll throw/return
+ // as appropriate once all children have been processed
+ if (!mChildSessions.valueAt(i)
+ .markAsSealed(childIntentSender, forTransfer)) {
+ sealFailed = true;
+ }
}
- }
- if (sealFailed) {
- return;
+ if (sealFailed) {
+ return;
+ }
}
}
@@ -1218,21 +1212,20 @@
}
if (isMultiPackage()) {
- final int[] childSessionIds;
+ final List<PackageInstallerSession> childSessions;
synchronized (mLock) {
- childSessionIds = mChildSessionIds.copyKeys();
+ childSessions = getChildSessionsLocked();
}
- int childCount = childSessionIds.length;
+ int childCount = childSessions.size();
// This will contain all child sessions that do not encounter an unrecoverable failure
ArrayList<PackageInstallerSession> nonFailingSessions = new ArrayList<>(childCount);
for (int i = childCount - 1; i >= 0; --i) {
- final int childSessionId = childSessionIds[i];
// commit all children, regardless if any of them fail; we'll throw/return
// as appropriate once all children have been processed
try {
- PackageInstallerSession session = mSessionProvider.getSession(childSessionId);
+ PackageInstallerSession session = childSessions.get(i);
allSessionsReady &= session.streamValidateAndCommit();
nonFailingSessions.add(session);
} catch (PackageManagerException e) {
@@ -1293,7 +1286,7 @@
}
private class ChildStatusIntentReceiver {
- private final SparseIntArray mChildSessionsRemaining;
+ private final SparseArray<PackageInstallerSession> mChildSessionsRemaining;
private final IntentSender mStatusReceiver;
private final IIntentSender.Stub mLocalSender = new IIntentSender.Stub() {
@Override
@@ -1303,7 +1296,7 @@
}
};
- private ChildStatusIntentReceiver(SparseIntArray remainingSessions,
+ private ChildStatusIntentReceiver(SparseArray<PackageInstallerSession> remainingSessions,
IntentSender statusReceiver) {
this.mChildSessionsRemaining = remainingSessions;
this.mStatusReceiver = statusReceiver;
@@ -1413,8 +1406,6 @@
private boolean markAsSealed(@NonNull IntentSender statusReceiver, boolean forTransfer) {
Objects.requireNonNull(statusReceiver);
- List<PackageInstallerSession> childSessions = getChildSessionsNotLocked();
-
synchronized (mLock) {
assertCallerIsOwnerOrRootLocked();
assertPreparedAndNotDestroyedLocked("commit");
@@ -1446,7 +1437,7 @@
}
try {
- sealLocked(childSessions);
+ sealLocked();
} catch (PackageManagerException e) {
return false;
}
@@ -1487,21 +1478,14 @@
return true;
}
- /** Return a list of child sessions or null if the session is not multipackage
- *
- * <p> This method is handy to prevent potential deadlocks (b/123391593)
- */
- private @Nullable List<PackageInstallerSession> getChildSessionsNotLocked() {
- if (Thread.holdsLock(mLock)) {
- Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName()
- + " is holding mLock", new Throwable());
- }
+ @GuardedBy("mLock")
+ private @Nullable List<PackageInstallerSession> getChildSessionsLocked() {
List<PackageInstallerSession> childSessions = null;
if (isMultiPackage()) {
- final int[] childSessionIds = getChildSessionIds();
- childSessions = new ArrayList<>(childSessionIds.length);
- for (int childSessionId : childSessionIds) {
- childSessions.add(mSessionProvider.getSession(childSessionId));
+ int size = mChildSessions.size();
+ childSessions = new ArrayList<>(size);
+ for (int i = 0; i < size; ++i) {
+ childSessions.add(mChildSessions.valueAt(i));
}
}
return childSessions;
@@ -1563,14 +1547,14 @@
* session was sealed this is the only possible exception.
*/
@GuardedBy("mLock")
- private void sealLocked(List<PackageInstallerSession> childSessions)
+ private void sealLocked()
throws PackageManagerException {
try {
assertNoWriteFileTransfersOpenLocked();
assertPreparedAndNotDestroyedLocked("sealing of session");
mSealed = true;
-
+ List<PackageInstallerSession> childSessions = getChildSessionsLocked();
if (childSessions != null) {
assertMultiPackageConsistencyLocked(childSessions);
}
@@ -1657,17 +1641,30 @@
*
* <p> This is meant to be called after all of the sessions are loaded and added to
* PackageInstallerService
+ *
+ * @param allSessions All sessions loaded by PackageInstallerService, guaranteed to be
+ * immutable by the caller during the method call. Used to resolve child
+ * sessions Ids to actual object reference.
*/
- void onAfterSessionRead() {
+ void onAfterSessionRead(SparseArray<PackageInstallerSession> allSessions) {
synchronized (mLock) {
+ // Resolve null values to actual object references
+ for (int i = mChildSessions.size() - 1; i >= 0; --i) {
+ int childSessionId = mChildSessions.keyAt(i);
+ PackageInstallerSession childSession = allSessions.get(childSessionId);
+ if (childSession != null) {
+ mChildSessions.setValueAt(i, childSession);
+ } else {
+ Slog.e(TAG, "Child session not existed: " + childSessionId);
+ mChildSessions.removeAt(i);
+ }
+ }
+
if (!mShouldBeSealed || isStagedAndInTerminalState()) {
return;
}
- }
- List<PackageInstallerSession> childSessions = getChildSessionsNotLocked();
- synchronized (mLock) {
try {
- sealLocked(childSessions);
+ sealLocked();
if (isApexInstallation()) {
// APEX installations rely on certain fields to be populated after reboot.
@@ -1708,14 +1705,12 @@
throw new SecurityException("Can only transfer sessions that use public options");
}
- List<PackageInstallerSession> childSessions = getChildSessionsNotLocked();
-
synchronized (mLock) {
assertCallerIsOwnerOrRootLocked();
assertPreparedAndNotSealedLocked("transfer");
try {
- sealLocked(childSessions);
+ sealLocked();
} catch (PackageManagerException e) {
throw new IllegalArgumentException("Package is not valid", e);
}
@@ -1746,14 +1741,8 @@
return;
}
- // For a multiPackage session, read the child sessions
- // outside of the lock, because reading the child
- // sessions with the lock held could lead to deadlock
- // (b/123391593).
- List<PackageInstallerSession> childSessions = getChildSessionsNotLocked();
-
try {
- verifyNonStaged(childSessions);
+ verifyNonStaged();
} catch (PackageManagerException e) {
final String completeMsg = ExceptionUtils.getCompleteMessage(e);
Slog.e(TAG, "Commit of session " + sessionId + " failed: " + completeMsg);
@@ -1762,7 +1751,7 @@
}
}
- private void verifyNonStaged(List<PackageInstallerSession> childSessions)
+ private void verifyNonStaged()
throws PackageManagerException {
final PackageManagerService.VerificationParams verifyingSession =
makeVerificationParams();
@@ -1770,6 +1759,10 @@
return;
}
if (isMultiPackage()) {
+ final List<PackageInstallerSession> childSessions;
+ synchronized (mLock) {
+ childSessions = getChildSessionsLocked();
+ }
List<PackageManagerService.VerificationParams> verifyingChildSessions =
new ArrayList<>(childSessions.size());
boolean success = true;
@@ -1803,7 +1796,7 @@
}
}
- private void installNonStaged(List<PackageInstallerSession> childSessions)
+ private void installNonStaged()
throws PackageManagerException {
final PackageManagerService.InstallParams installingSession =
makeInstallParams();
@@ -1811,6 +1804,10 @@
return;
}
if (isMultiPackage()) {
+ final List<PackageInstallerSession> childSessions;
+ synchronized (mLock) {
+ childSessions = getChildSessionsLocked();
+ }
List<PackageManagerService.InstallParams> installingChildSessions =
new ArrayList<>(childSessions.size());
boolean success = true;
@@ -2004,9 +2001,8 @@
return;
}
- List<PackageInstallerSession> childSessions = getChildSessionsNotLocked();
try {
- installNonStaged(childSessions);
+ installNonStaged();
} catch (PackageManagerException e) {
final String completeMsg = ExceptionUtils.getCompleteMessage(e);
Slog.e(TAG, "Commit of session " + sessionId + " failed: " + completeMsg);
@@ -2741,15 +2737,6 @@
}
}
- /**
- * Adds a child session ID without any safety / sanity checks. This should only be used to
- * build a session from XML or similar.
- */
- @GuardedBy("mLock")
- void addChildSessionIdLocked(int sessionId) {
- mChildSessionIds.put(sessionId, 0);
- }
-
public void open() throws IOException {
if (mActiveCount.getAndIncrement() == 0) {
mCallback.onSessionActiveChanged(this, true);
@@ -2804,7 +2791,6 @@
+ getParentSessionId() + " and may not be abandoned directly.");
}
- List<PackageInstallerSession> childSessions = getChildSessionsNotLocked();
synchronized (mLock) {
if (params.isStaged && mDestroyed) {
// If a user abandons staged session in an unsafe state, then system will try to
@@ -2828,7 +2814,7 @@
mCallback.onStagedSessionChanged(this);
return;
}
- cleanStageDir(childSessions);
+ cleanStageDir(getChildSessionsLocked());
}
if (mRelinquished) {
@@ -3149,8 +3135,15 @@
@GuardedBy("mLock")
private int[] getChildSessionIdsLocked() {
- final int[] childSessionIds = mChildSessionIds.copyKeys();
- return childSessionIds != null ? childSessionIds : EMPTY_CHILD_SESSION_ARRAY;
+ int size = mChildSessions.size();
+ if (size == 0) {
+ return EMPTY_CHILD_SESSION_ARRAY;
+ }
+ final int[] childSessionIds = new int[size];
+ for (int i = 0; i < size; ++i) {
+ childSessionIds[i] = mChildSessions.keyAt(i);
+ }
+ return childSessionIds;
}
@Override
@@ -3205,12 +3198,12 @@
assertCallerIsOwnerOrRootLocked();
assertPreparedAndNotSealedLocked("addChildSessionId");
- final int indexOfSession = mChildSessionIds.indexOfKey(childSessionId);
+ final int indexOfSession = mChildSessions.indexOfKey(childSessionId);
if (indexOfSession >= 0) {
return;
}
childSession.setParentSessionId(this.sessionId);
- addChildSessionIdLocked(childSessionId);
+ mChildSessions.put(childSessionId, childSession);
}
} finally {
releaseTransactionLock();
@@ -3220,30 +3213,23 @@
@Override
public void removeChildSessionId(int sessionId) {
- final PackageInstallerSession session = mSessionProvider.getSession(sessionId);
- try {
- acquireTransactionLock();
- if (session != null) {
+ synchronized (mLock) {
+ assertCallerIsOwnerOrRootLocked();
+ assertPreparedAndNotSealedLocked("removeChildSessionId");
+
+ final int indexOfSession = mChildSessions.indexOfKey(sessionId);
+ if (indexOfSession < 0) {
+ // not added in the first place; no-op
+ return;
+ }
+ PackageInstallerSession session = mChildSessions.valueAt(indexOfSession);
+ try {
+ acquireTransactionLock();
session.acquireTransactionLock();
- }
-
- synchronized (mLock) {
- assertCallerIsOwnerOrRootLocked();
- assertPreparedAndNotSealedLocked("removeChildSessionId");
-
- final int indexOfSession = mChildSessionIds.indexOfKey(sessionId);
- if (indexOfSession < 0) {
- // not added in the first place; no-op
- return;
- }
- if (session != null) {
- session.setParentSessionId(SessionInfo.INVALID_ID);
- }
- mChildSessionIds.removeAt(indexOfSession);
- }
- } finally {
- releaseTransactionLock();
- if (session != null) {
+ session.setParentSessionId(SessionInfo.INVALID_ID);
+ mChildSessions.removeAt(indexOfSession);
+ } finally {
+ releaseTransactionLock();
session.releaseTransactionLock();
}
}
@@ -3334,6 +3320,7 @@
/** {@hide} */
void setStagedSessionFailed(@StagedSessionErrorCode int errorCode, String errorMessage) {
+ List<PackageInstallerSession> childSessions;
synchronized (mLock) {
// Do not allow destroyed/failed staged session to change state
if (mDestroyed || mStagedSessionFailed) return;
@@ -3343,13 +3330,15 @@
mStagedSessionErrorCode = errorCode;
mStagedSessionErrorMessage = errorMessage;
Slog.d(TAG, "Marking session " + sessionId + " as failed: " + errorMessage);
+ childSessions = getChildSessionsLocked();
}
- cleanStageDirNotLocked();
+ cleanStageDir(childSessions);
mCallback.onStagedSessionChanged(this);
}
/** {@hide} */
void setStagedSessionApplied() {
+ List<PackageInstallerSession> childSessions;
synchronized (mLock) {
// Do not allow destroyed/failed staged session to change state
if (mDestroyed || mStagedSessionFailed) return;
@@ -3359,8 +3348,9 @@
mStagedSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR;
mStagedSessionErrorMessage = "";
Slog.d(TAG, "Marking session " + sessionId + " as applied");
+ childSessions = getChildSessionsLocked();
}
- cleanStageDirNotLocked();
+ cleanStageDir(childSessions);
mCallback.onStagedSessionChanged(this);
}
@@ -3428,23 +3418,10 @@
}
}
- /**
- * <b>must not hold {@link #mLock}</b>
- */
- private void cleanStageDirNotLocked() {
- if (Thread.holdsLock(mLock)) {
- Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName()
- + " is holding mLock", new Throwable());
- }
- cleanStageDir(getChildSessionsNotLocked());
- }
-
private void cleanStageDir(List<PackageInstallerSession> childSessions) {
if (childSessions != null) {
for (PackageInstallerSession childSession : childSessions) {
- if (childSession != null) {
- childSession.cleanStageDir();
- }
+ childSession.cleanStageDir();
}
} else {
cleanStageDir();
@@ -3504,7 +3481,7 @@
pw.printPair("params.isMultiPackage", params.isMultiPackage);
pw.printPair("params.isStaged", params.isStaged);
pw.printPair("mParentSessionId", mParentSessionId);
- pw.printPair("mChildSessionIds", mChildSessionIds);
+ pw.printPair("mChildSessionIds", getChildSessionIdsLocked());
pw.printPair("mStagedSessionApplied", mStagedSessionApplied);
pw.printPair("mStagedSessionFailed", mStagedSessionFailed);
pw.printPair("mStagedSessionReady", mStagedSessionReady);
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 997c7e3..0d1c00d 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -2232,7 +2232,7 @@
sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName,
extras, 0 /*flags*/,
installerPackageName, null /*finishedReceiver*/,
- updateUserIds, instantUserIds, null /* broadcastWhitelist */);
+ updateUserIds, instantUserIds, null /* broadcastAllowList */);
}
// if the required verifier is defined, but, is not the installer of record
// for the package, it gets notified
@@ -2242,7 +2242,7 @@
sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName,
extras, 0 /*flags*/,
mRequiredVerifierPackage, null /*finishedReceiver*/,
- updateUserIds, instantUserIds, null /* broadcastWhitelist */);
+ updateUserIds, instantUserIds, null /* broadcastAllowList */);
}
// If package installer is defined, notify package installer about new
// app installed
@@ -2250,7 +2250,7 @@
sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName,
extras, Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND /*flags*/,
mRequiredInstallerPackage, null /*finishedReceiver*/,
- firstUserIds, instantUserIds, null /* broadcastWhitelist */);
+ firstUserIds, instantUserIds, null /* broadcastAllowList */);
}
// Send replaced for users that don't see the package for the first time
@@ -2263,19 +2263,19 @@
sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, packageName,
extras, 0 /*flags*/,
installerPackageName, null /*finishedReceiver*/,
- updateUserIds, instantUserIds, null /*broadcastWhitelist*/);
+ updateUserIds, instantUserIds, null /*broadcastAllowList*/);
}
if (notifyVerifier) {
sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, packageName,
extras, 0 /*flags*/,
mRequiredVerifierPackage, null /*finishedReceiver*/,
- updateUserIds, instantUserIds, null /*broadcastWhitelist*/);
+ updateUserIds, instantUserIds, null /*broadcastAllowList*/);
}
sendPackageBroadcast(Intent.ACTION_MY_PACKAGE_REPLACED,
null /*package*/, null /*extras*/, 0 /*flags*/,
packageName /*targetPackage*/,
null /*finishedReceiver*/, updateUserIds, instantUserIds,
- null /*broadcastWhitelist*/);
+ null /*broadcastAllowList*/);
} else if (launchedForRestore && !res.pkg.isSystem()) {
// First-install and we did a restore, so we're responsible for the
// first-launch broadcast.
@@ -10351,6 +10351,7 @@
mInstaller.rmPackageDir(codePath.getAbsolutePath());
if (codePathParent.getName().startsWith(RANDOM_DIR_PREFIX)) {
mInstaller.rmPackageDir(codePathParent.getAbsolutePath());
+ removeCachedResult(codePathParent);
}
} catch (InstallerException e) {
Slog.w(TAG, "Failed to remove code path", e);
@@ -10360,6 +10361,16 @@
}
}
+ private void removeCachedResult(@NonNull File codePath) {
+ if (mCacheDir == null) {
+ return;
+ }
+
+ final PackageCacher cacher = new PackageCacher(mCacheDir);
+ // Find and delete the cached result belong to the given codePath.
+ cacher.cleanCachedResult(codePath);
+ }
+
private int[] resolveUserIds(int userId) {
return (userId == UserHandle.USER_ALL) ? mUserManager.getUserIds() : new int[] { userId };
}
@@ -14616,7 +14627,7 @@
private void sendFirstLaunchBroadcast(String pkgName, String installerPkg,
int[] userIds, int[] instantUserIds) {
sendPackageBroadcast(Intent.ACTION_PACKAGE_FIRST_LAUNCH, pkgName, null, 0,
- installerPkg, null, userIds, instantUserIds, null /* broadcastWhitelist */);
+ installerPkg, null, userIds, instantUserIds, null /* broadcastAllowList */);
}
private abstract class HandlerParams {
@@ -18719,14 +18730,14 @@
packageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, removedPackage,
extras, 0, null /*targetPackage*/, null, null, null, broadcastAllowList);
packageSender.sendPackageBroadcast(Intent.ACTION_MY_PACKAGE_REPLACED, null, null, 0,
- removedPackage, null, null, null, null /* broadcastWhitelist */);
+ removedPackage, null, null, null, null /* broadcastAllowList */);
if (installerPackageName != null) {
packageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED,
removedPackage, extras, 0 /*flags*/,
- installerPackageName, null, null, null, null /* broadcastWhitelist */);
+ installerPackageName, null, null, null, null /* broadcastAllowList */);
packageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED,
removedPackage, extras, 0 /*flags*/,
- installerPackageName, null, null, null, null /* broadcastWhitelist */);
+ installerPackageName, null, null, null, null /* broadcastAllowList */);
}
}
@@ -25401,18 +25412,7 @@
int mode = mInjector.getAppOpsManager().checkOpNoThrow(
AppOpsManager.OP_AUTO_REVOKE_PERMISSIONS_IF_UNUSED,
Binder.getCallingUid(), packageName);
- if (mode == MODE_ALLOWED) {
- return false;
- } else if (mode == MODE_IGNORED) {
- return true;
- } else {
- synchronized (mLock) {
- boolean manifestWhitelisted =
- mPackages.get(packageName).getAutoRevokePermissions()
- == ApplicationInfo.AUTO_REVOKE_DISALLOWED;
- return manifestWhitelisted;
- }
- }
+ return mode == MODE_IGNORED;
}
@Override
@@ -25700,9 +25700,9 @@
* @param instantUserIds User IDs where the action occurred on an instant application
*/
void sendPackageBroadcast(final String action, final String pkg,
- final Bundle extras, final int flags, final String targetPkg,
- final IIntentReceiver finishedReceiver, final int[] userIds, int[] instantUserIds,
- @Nullable SparseArray<int[]> broadcastWhitelist);
+ final Bundle extras, final int flags, final String targetPkg,
+ final IIntentReceiver finishedReceiver, final int[] userIds, int[] instantUserIds,
+ @Nullable SparseArray<int[]> broadcastAllowList);
void sendPackageAddedForNewUsers(String packageName, boolean sendBootCompleted,
boolean includeStopped, int appId, int[] userIds, int[] instantUserIds,
int dataLoaderType);
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index bf9506a..f66b4ee 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -87,6 +87,7 @@
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.AtomicFile;
+import android.util.IndentingPrintWriter;
import android.util.IntArray;
import android.util.Slog;
import android.util.SparseArray;
@@ -103,7 +104,6 @@
import com.android.internal.util.DumpUtils;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.FrameworkStatsLog;
-import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.Preconditions;
import com.android.internal.util.XmlUtils;
import com.android.internal.widget.LockPatternUtils;
@@ -141,6 +141,7 @@
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* Service for {@link UserManager}.
@@ -443,6 +444,11 @@
}
};
+ // TODO(b/161915546): remove once userWithName() is fixed / removed
+ // Use to debug / dump when user 0 is allocated at userWithName()
+ public static final boolean DBG_ALLOCATION = false; // DO NOT SUBMIT WITH TRUE
+ public final AtomicInteger mUser0Allocations;
+
/**
* Start an {@link IntentSender} when user is unlocked after disabling quiet mode.
*
@@ -629,6 +635,7 @@
LocalServices.addService(UserManagerInternal.class, mLocalService);
mLockPatternUtils = new LockPatternUtils(mContext);
mUserStates.put(UserHandle.USER_SYSTEM, UserState.STATE_BOOTING);
+ mUser0Allocations = DBG_ALLOCATION ? new AtomicInteger() : null;
}
void systemReady() {
@@ -1310,6 +1317,10 @@
*/
private UserInfo userWithName(UserInfo orig) {
if (orig != null && orig.name == null && orig.id == UserHandle.USER_SYSTEM) {
+ if (DBG_ALLOCATION) {
+ final int number = mUser0Allocations.incrementAndGet();
+ Slog.w(LOG_TAG, "System user instantiated at least " + number + " times");
+ }
UserInfo withName = new UserInfo(orig);
withName.name = getOwnerName();
return withName;
@@ -4786,6 +4797,7 @@
}
}
+ pw.println();
pw.println("Device properties:");
pw.println(" Device owner id:" + mDeviceOwnerUserId);
pw.println();
@@ -4814,12 +4826,9 @@
}
pw.println(']');
}
-
synchronized (mUsersLock) {
- pw.println();
- pw.print("Cached user IDs: ");
+ pw.print(" Cached user IDs: ");
pw.println(Arrays.toString(mUserIds));
- pw.println();
}
} // synchronized (mPackagesLock)
@@ -4835,6 +4844,10 @@
pw.println(" Is split-system user: " + UserManager.isSplitSystemUser());
pw.println(" Is headless-system mode: " + UserManager.isHeadlessSystemUserMode());
pw.println(" User version: " + mUserVersion);
+ pw.println(" Owner name: " + getOwnerName());
+ if (DBG_ALLOCATION) {
+ pw.println(" System user allocations: " + mUser0Allocations.get());
+ }
// Dump UserTypes
pw.println();
@@ -4844,9 +4857,17 @@
mUserTypes.valueAt(i).dump(pw, " ");
}
- // Dump package whitelist
- pw.println();
- mSystemPackageInstaller.dump(pw);
+ // TODO: create IndentingPrintWriter at the beginning of dump() and use the proper
+ // indentation methods instead of explicit printing " "
+ try (IndentingPrintWriter ipw = new IndentingPrintWriter(pw)) {
+
+ // Dump SystemPackageInstaller info
+ ipw.println();
+ mSystemPackageInstaller.dump(ipw);
+
+ // NOTE: pw's not available after this point as it's auto-closed by ipw, so new dump
+ // statements should use ipw below
+ }
}
private static void dumpTimeAgo(PrintWriter pw, StringBuilder sb, long nowTime, long time) {
diff --git a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
index 3c1d189..f7e9e34 100644
--- a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
+++ b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
@@ -139,6 +139,11 @@
UserManager.DISALLOW_CONFIG_PRIVATE_DNS
});
+ public static final Set<String> DEPRECATED_USER_RESTRICTIONS = Sets.newArraySet(
+ UserManager.DISALLOW_ADD_MANAGED_PROFILE,
+ UserManager.DISALLOW_REMOVE_MANAGED_PROFILE
+ );
+
/**
* Set of user restriction which we don't want to persist.
*/
diff --git a/services/core/java/com/android/server/pm/UserSystemPackageInstaller.java b/services/core/java/com/android/server/pm/UserSystemPackageInstaller.java
index 492b84a..b95404f 100644
--- a/services/core/java/com/android/server/pm/UserSystemPackageInstaller.java
+++ b/services/core/java/com/android/server/pm/UserSystemPackageInstaller.java
@@ -28,15 +28,14 @@
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.DebugUtils;
+import android.util.IndentingPrintWriter;
import android.util.Slog;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.util.IndentingPrintWriter;
import com.android.server.LocalServices;
import com.android.server.SystemConfig;
import com.android.server.pm.parsing.pkg.AndroidPackage;
-import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -723,13 +722,7 @@
return userTypeList;
}
- void dump(PrintWriter pw) {
- try (IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ")) {
- dumpIndented(ipw);
- }
- }
-
- private void dumpIndented(IndentingPrintWriter pw) {
+ void dump(IndentingPrintWriter pw) {
final int mode = getWhitelistMode();
pw.println("Whitelisted packages per user type");
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
index 03771be..63aa80e 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
@@ -83,6 +83,7 @@
import android.content.pm.ParceledListSlice;
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
+import android.content.pm.UserInfo;
import android.content.pm.parsing.component.ParsedPermission;
import android.content.pm.parsing.component.ParsedPermissionGroup;
import android.content.pm.permission.SplitPermissionInfoParcelable;
@@ -120,6 +121,7 @@
import android.util.Slog;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
+import android.util.TimingsTraceLog;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
@@ -2521,12 +2523,12 @@
final PermissionsState permissionsState = ps.getPermissionsState();
- final int[] currentUserIds = UserManagerService.getInstance().getUserIds();
+ final int[] userIds = getAllUserIds();
boolean runtimePermissionsRevoked = false;
int[] updatedUserIds = EMPTY_INT_ARRAY;
- for (int userId : currentUserIds) {
+ for (int userId : userIds) {
if (permissionsState.isMissing(userId)) {
Collection<String> requestedPermissions;
int targetSdkVersion;
@@ -2592,7 +2594,7 @@
// runtime and revocation of a runtime from a shared user.
synchronized (mLock) {
updatedUserIds = revokeUnusedSharedUserPermissionsLocked(ps.getSharedUser(),
- currentUserIds);
+ userIds);
if (!ArrayUtils.isEmpty(updatedUserIds)) {
runtimePermissionsRevoked = true;
}
@@ -2747,7 +2749,7 @@
// a runtime permission being downgraded to an install one.
// Also in permission review mode we keep dangerous permissions
// for legacy apps
- for (int userId : currentUserIds) {
+ for (int userId : userIds) {
if (origPermissions.getRuntimePermissionState(
perm, userId) != null) {
// Revoke the runtime permission and clear the flags.
@@ -2770,7 +2772,7 @@
boolean hardRestricted = bp.isHardRestricted();
boolean softRestricted = bp.isSoftRestricted();
- for (int userId : currentUserIds) {
+ for (int userId : userIds) {
// If permission policy is not ready we don't deal with restricted
// permissions as the policy may whitelist some permissions. Once
// the policy is initialized we would re-evaluate permissions.
@@ -2909,7 +2911,7 @@
boolean hardRestricted = bp.isHardRestricted();
boolean softRestricted = bp.isSoftRestricted();
- for (int userId : currentUserIds) {
+ for (int userId : userIds) {
// If permission policy is not ready we don't deal with restricted
// permissions as the policy may whitelist some permissions. Once
// the policy is initialized we would re-evaluate permissions.
@@ -3061,10 +3063,10 @@
synchronized (mLock) {
updatedUserIds = revokePermissionsNoLongerImplicitLocked(permissionsState, pkg,
- currentUserIds, updatedUserIds);
+ userIds, updatedUserIds);
updatedUserIds = setInitialGrantForNewImplicitPermissionsLocked(origPermissions,
- permissionsState, pkg, newImplicitPermissions, currentUserIds, updatedUserIds);
- updatedUserIds = checkIfLegacyStorageOpsNeedToBeUpdated(pkg, replace, currentUserIds,
+ permissionsState, pkg, newImplicitPermissions, userIds, updatedUserIds);
+ updatedUserIds = checkIfLegacyStorageOpsNeedToBeUpdated(pkg, replace, userIds,
updatedUserIds);
}
@@ -3081,6 +3083,25 @@
}
/**
+ * Returns all relevant user ids. This list include the current set of created user ids as well
+ * as pre-created user ids.
+ * @return user ids for created users and pre-created users
+ */
+ private int[] getAllUserIds() {
+ final TimingsTraceLog t = new TimingsTraceLog(TAG, Trace.TRACE_TAG_SYSTEM_SERVER);
+ t.traceBegin("getAllUserIds");
+ List<UserInfo> users = UserManagerService.getInstance().getUsers(
+ /*excludePartial=*/ true, /*excludeDying=*/ true, /*excludePreCreated=*/ false);
+ int size = users.size();
+ final int[] userIds = new int[size];
+ for (int i = 0; i < size; i++) {
+ userIds[i] = users.get(i).id;
+ }
+ t.traceEnd();
+ return userIds;
+ }
+
+ /**
* Revoke permissions that are not implicit anymore and that have
* {@link PackageManager#FLAG_PERMISSION_REVOKE_WHEN_REQUESTED} set.
*
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 03868e9..548cd70 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -450,7 +450,6 @@
volatile int mPendingWakeKey = PENDING_KEY_NULL;
int mRecentAppsHeldModifiers;
- boolean mLanguageSwitchKeyPressed;
int mCameraLensCoverState = CAMERA_LENS_COVER_ABSENT;
boolean mHaveBuiltInKeyboard;
@@ -933,6 +932,8 @@
}
}
+ final boolean handledByPowerManager = mPowerManagerInternal.interceptPowerKeyDown(event);
+
GestureLauncherService gestureService = LocalServices.getService(
GestureLauncherService.class);
boolean gesturedServiceIntercepted = false;
@@ -952,7 +953,8 @@
// If the power key has still not yet been handled, then detect short
// press, long press, or multi press and decide what to do.
mPowerKeyHandled = hungUp || mScreenshotChordVolumeDownKeyTriggered
- || mA11yShortcutChordVolumeUpKeyTriggered || gesturedServiceIntercepted;
+ || mA11yShortcutChordVolumeUpKeyTriggered || gesturedServiceIntercepted
+ || handledByPowerManager;
if (!mPowerKeyHandled) {
if (interactive) {
// When interactive, we're already awake.
@@ -2935,12 +2937,6 @@
mWindowManagerFuncs.switchKeyboardLayout(event.getDeviceId(), direction);
return -1;
}
- if (mLanguageSwitchKeyPressed && !down
- && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH
- || keyCode == KeyEvent.KEYCODE_SPACE)) {
- mLanguageSwitchKeyPressed = false;
- return -1;
- }
if (isValidGlobalKey(keyCode)
&& mGlobalKeyManager.handleGlobalKey(mContext, keyCode, event)) {
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index f9a49c9..882ed1b 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -86,6 +86,7 @@
import android.util.TimeUtils;
import android.util.proto.ProtoOutputStream;
import android.view.Display;
+import android.view.KeyEvent;
import com.android.internal.BrightnessSynchronizer;
import com.android.internal.annotations.VisibleForTesting;
@@ -892,19 +893,13 @@
|| def == INVALID_BRIGHTNESS_IN_CONFIG) {
mScreenBrightnessMinimum = BrightnessSynchronizer.brightnessIntToFloat(
mContext.getResources().getInteger(com.android.internal.R.integer
- .config_screenBrightnessSettingMinimum),
- PowerManager.BRIGHTNESS_OFF + 1, PowerManager.BRIGHTNESS_ON,
- PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX);
+ .config_screenBrightnessSettingMinimum));
mScreenBrightnessMaximum = BrightnessSynchronizer.brightnessIntToFloat(
mContext.getResources().getInteger(com.android.internal.R.integer
- .config_screenBrightnessSettingMaximum),
- PowerManager.BRIGHTNESS_OFF + 1, PowerManager.BRIGHTNESS_ON,
- PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX);
+ .config_screenBrightnessSettingMaximum));
mScreenBrightnessDefault = BrightnessSynchronizer.brightnessIntToFloat(
mContext.getResources().getInteger(com.android.internal.R.integer
- .config_screenBrightnessSettingDefault),
- PowerManager.BRIGHTNESS_OFF + 1, PowerManager.BRIGHTNESS_ON,
- PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX);
+ .config_screenBrightnessSettingDefault));
} else {
mScreenBrightnessMinimum = min;
mScreenBrightnessMaximum = max;
@@ -913,18 +908,14 @@
if (doze == INVALID_BRIGHTNESS_IN_CONFIG) {
mScreenBrightnessDoze = BrightnessSynchronizer.brightnessIntToFloat(
mContext.getResources().getInteger(com.android.internal.R.integer
- .config_screenBrightnessDoze), PowerManager.BRIGHTNESS_OFF + 1,
- PowerManager.BRIGHTNESS_ON, PowerManager.BRIGHTNESS_MIN,
- PowerManager.BRIGHTNESS_MAX);
+ .config_screenBrightnessDoze));
} else {
mScreenBrightnessDoze = doze;
}
if (dim == INVALID_BRIGHTNESS_IN_CONFIG) {
mScreenBrightnessDim = BrightnessSynchronizer.brightnessIntToFloat(
mContext.getResources().getInteger(com.android.internal.R.integer
- .config_screenBrightnessDim), PowerManager.BRIGHTNESS_OFF + 1,
- PowerManager.BRIGHTNESS_ON, PowerManager.BRIGHTNESS_MIN,
- PowerManager.BRIGHTNESS_MAX);
+ .config_screenBrightnessDim));
} else {
mScreenBrightnessDim = dim;
}
@@ -939,19 +930,13 @@
|| vrDef == INVALID_BRIGHTNESS_IN_CONFIG) {
mScreenBrightnessMinimumVr = BrightnessSynchronizer.brightnessIntToFloat(
mContext.getResources().getInteger(com.android.internal.R.integer
- .config_screenBrightnessForVrSettingMinimum),
- PowerManager.BRIGHTNESS_OFF + 1, PowerManager.BRIGHTNESS_ON,
- PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX);
+ .config_screenBrightnessForVrSettingMinimum));
mScreenBrightnessMaximumVr = BrightnessSynchronizer.brightnessIntToFloat(
mContext.getResources().getInteger(com.android.internal.R.integer
- .config_screenBrightnessForVrSettingMaximum),
- PowerManager.BRIGHTNESS_OFF + 1, PowerManager.BRIGHTNESS_ON,
- PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX);
+ .config_screenBrightnessForVrSettingMaximum));
mScreenBrightnessDefaultVr = BrightnessSynchronizer.brightnessIntToFloat(
mContext.getResources().getInteger(com.android.internal.R.integer
- .config_screenBrightnessForVrSettingDefault),
- PowerManager.BRIGHTNESS_OFF + 1, PowerManager.BRIGHTNESS_ON,
- PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX);
+ .config_screenBrightnessForVrSettingDefault));
} else {
mScreenBrightnessMinimumVr = vrMin;
mScreenBrightnessMaximumVr = vrMax;
@@ -3590,8 +3575,7 @@
mDozeScreenStateOverrideFromDreamManager = screenState;
mDozeScreenBrightnessOverrideFromDreamManager = screenBrightness;
mDozeScreenBrightnessOverrideFromDreamManagerFloat =
- BrightnessSynchronizer.brightnessIntToFloat(mContext,
- mDozeScreenBrightnessOverrideFromDreamManager);
+ BrightnessSynchronizer.brightnessIntToFloat(mDozeScreenBrightnessOverrideFromDreamManager);
mDirty |= DIRTY_SETTINGS;
updatePowerStateLocked();
}
@@ -5393,6 +5377,29 @@
}
}
+ /**
+ * If the user presses power while the proximity sensor is enabled and keeping
+ * the screen off, then turn the screen back on by telling display manager to
+ * ignore the proximity sensor. We don't turn off the proximity sensor because
+ * we still want it to be reenabled if it's state changes.
+ *
+ * @return True if the proximity sensor was successfully ignored and we should
+ * consume the key event.
+ */
+ private boolean interceptPowerKeyDownInternal(KeyEvent event) {
+ synchronized (mLock) {
+ // DisplayPowerController only reports proximity positive (near) if it's
+ // positive and the proximity wasn't already being ignored. So it reliably
+ // also tells us that we're not already ignoring the proximity sensor.
+ if (mDisplayPowerRequest.useProximitySensor && mProximityPositive) {
+ mDisplayManagerInternal.ignoreProximitySensorUntilChanged();
+ return true;
+ }
+ }
+
+ return false;
+ }
+
@VisibleForTesting
final class LocalService extends PowerManagerInternal {
@Override
@@ -5525,5 +5532,10 @@
public WakeData getLastWakeup() {
return getLastWakeupInternal();
}
+
+ @Override
+ public boolean interceptPowerKeyDown(KeyEvent event) {
+ return interceptPowerKeyDownInternal(event);
+ }
}
}
diff --git a/services/core/java/com/android/server/slice/SliceManagerService.java b/services/core/java/com/android/server/slice/SliceManagerService.java
index 4349ca4..5aedfc1 100644
--- a/services/core/java/com/android/server/slice/SliceManagerService.java
+++ b/services/core/java/com/android/server/slice/SliceManagerService.java
@@ -39,9 +39,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
-import android.content.pm.PackageManagerInternal;
import android.content.pm.ProviderInfo;
-import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Binder;
import android.os.Handler;
@@ -63,7 +61,6 @@
import com.android.server.LocalServices;
import com.android.server.ServiceThread;
import com.android.server.SystemService;
-import com.android.server.SystemService.TargetUser;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -75,9 +72,7 @@
import java.io.FileDescriptor;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.List;
import java.util.Objects;
-import java.util.function.Supplier;
public class SliceManagerService extends ISliceManager.Stub {
@@ -85,16 +80,13 @@
private final Object mLock = new Object();
private final Context mContext;
- private final PackageManagerInternal mPackageManagerInternal;
private final AppOpsManager mAppOps;
private final AssistUtils mAssistUtils;
@GuardedBy("mLock")
private final ArrayMap<Uri, PinnedSliceState> mPinnedSlicesByUri = new ArrayMap<>();
@GuardedBy("mLock")
- private final SparseArray<PackageMatchingCache> mAssistantLookup = new SparseArray<>();
- @GuardedBy("mLock")
- private final SparseArray<PackageMatchingCache> mHomeLookup = new SparseArray<>();
+ private final SparseArray<String> mLastAssistantPackage = new SparseArray<>();
private final Handler mHandler;
private final SlicePermissionManager mPermissions;
@@ -107,8 +99,6 @@
@VisibleForTesting
SliceManagerService(Context context, Looper looper) {
mContext = context;
- mPackageManagerInternal = Objects.requireNonNull(
- LocalServices.getService(PackageManagerInternal.class));
mAppOps = context.getSystemService(AppOpsManager.class);
mAssistUtils = new AssistUtils(context);
mHandler = new Handler(looper);
@@ -170,8 +160,7 @@
mHandler.post(() -> {
if (slicePkg != null && !Objects.equals(pkg, slicePkg)) {
mAppUsageStats.reportEvent(slicePkg, user,
- isAssistant(pkg, user) || isDefaultHomeApp(pkg, user)
- ? SLICE_PINNED_PRIV : SLICE_PINNED);
+ isAssistant(pkg, user) ? SLICE_PINNED_PRIV : SLICE_PINNED);
}
});
}
@@ -436,38 +425,19 @@
private boolean hasFullSliceAccess(String pkg, int userId) {
long ident = Binder.clearCallingIdentity();
try {
- boolean ret = isDefaultHomeApp(pkg, userId) || isAssistant(pkg, userId)
- || isGrantedFullAccess(pkg, userId);
- return ret;
+ return isAssistant(pkg, userId) || isGrantedFullAccess(pkg, userId);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
private boolean isAssistant(String pkg, int userId) {
- return getAssistantMatcher(userId).matches(pkg);
- }
-
- private boolean isDefaultHomeApp(String pkg, int userId) {
- return getHomeMatcher(userId).matches(pkg);
- }
-
- private PackageMatchingCache getAssistantMatcher(int userId) {
- PackageMatchingCache matcher = mAssistantLookup.get(userId);
- if (matcher == null) {
- matcher = new PackageMatchingCache(() -> getAssistant(userId));
- mAssistantLookup.put(userId, matcher);
+ if (pkg == null) return false;
+ if (!pkg.equals(mLastAssistantPackage.get(userId))) {
+ // Failed on cached value, try updating.
+ mLastAssistantPackage.put(userId, getAssistant(userId));
}
- return matcher;
- }
-
- private PackageMatchingCache getHomeMatcher(int userId) {
- PackageMatchingCache matcher = mHomeLookup.get(userId);
- if (matcher == null) {
- matcher = new PackageMatchingCache(() -> getDefaultHome(userId));
- mHomeLookup.put(userId, matcher);
- }
- return matcher;
+ return pkg.equals(mLastAssistantPackage.get(userId));
}
private String getAssistant(int userId) {
@@ -478,51 +448,6 @@
return cn.getPackageName();
}
- // Based on getDefaultHome in ShortcutService.
- // TODO: Unify if possible
- @VisibleForTesting
- protected String getDefaultHome(int userId) {
- final long token = Binder.clearCallingIdentity();
- try {
- final List<ResolveInfo> allHomeCandidates = new ArrayList<>();
-
- // Default launcher from package manager.
- final ComponentName defaultLauncher = mPackageManagerInternal
- .getHomeActivitiesAsUser(allHomeCandidates, userId);
-
- ComponentName detected = null;
- if (defaultLauncher != null) {
- detected = defaultLauncher;
- }
-
- if (detected == null) {
- // If we reach here, that means it's the first check since the user was created,
- // and there's already multiple launchers and there's no default set.
- // Find the system one with the highest priority.
- // (We need to check the priority too because of FallbackHome in Settings.)
- // If there's no system launcher yet, then no one can access slices, until
- // the user explicitly sets one.
- final int size = allHomeCandidates.size();
-
- int lastPriority = Integer.MIN_VALUE;
- for (int i = 0; i < size; i++) {
- final ResolveInfo ri = allHomeCandidates.get(i);
- if (!ri.activityInfo.applicationInfo.isSystemApp()) {
- continue;
- }
- if (ri.priority < lastPriority) {
- continue;
- }
- detected = ri.activityInfo.getComponentName();
- lastPriority = ri.priority;
- }
- }
- return detected != null ? detected.getPackageName() : null;
- } finally {
- Binder.restoreCallingIdentity(token);
- }
- }
-
private boolean isGrantedFullAccess(String pkg, int userId) {
return mPermissions.hasFullAccess(pkg, userId);
}
@@ -571,30 +496,6 @@
return mPermissions.getAllPackagesGranted(pkg);
}
- /**
- * Holder that caches a package that has access to a slice.
- */
- static class PackageMatchingCache {
-
- private final Supplier<String> mPkgSource;
- private String mCurrentPkg;
-
- public PackageMatchingCache(Supplier<String> pkgSource) {
- mPkgSource = pkgSource;
- }
-
- public boolean matches(String pkgCandidate) {
- if (pkgCandidate == null) return false;
-
- if (Objects.equals(pkgCandidate, mCurrentPkg)) {
- return true;
- }
- // Failed on cached value, try updating.
- mCurrentPkg = mPkgSource.get();
- return Objects.equals(pkgCandidate, mCurrentPkg);
- }
- }
-
public static class Lifecycle extends SystemService {
private SliceManagerService mService;
diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorCallbackImpl.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorCallbackImpl.java
index c2b0d106..0ca36e0 100644
--- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorCallbackImpl.java
+++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorCallbackImpl.java
@@ -72,6 +72,10 @@
builder.setConfigureAutoDetectionEnabled(CAPABILITY_POSSESSED);
}
+ // TODO(b/149014708) Replace this with real logic when the settings storage is fully
+ // implemented.
+ builder.setConfigureGeoDetectionEnabled(CAPABILITY_NOT_SUPPORTED);
+
// The ability to make manual time zone suggestions can also be restricted by policy. With
// the current logic above, this could lead to a situation where a device hardware does not
// support auto detection, the device has been forced into "auto" mode by an admin and the
@@ -90,6 +94,7 @@
public TimeZoneConfiguration getConfiguration(@UserIdInt int userId) {
return new TimeZoneConfiguration.Builder()
.setAutoDetectionEnabled(isAutoDetectionEnabled())
+ .setGeoDetectionEnabled(isGeoDetectionEnabled())
.build();
}
@@ -105,8 +110,11 @@
// detection: if we wrote it down then we'd set the default explicitly. That might influence
// what happens on later releases that do support auto detection on the same hardware.
if (isAutoDetectionSupported()) {
- final int value = configuration.isAutoDetectionEnabled() ? 1 : 0;
- Settings.Global.putInt(mCr, Settings.Global.AUTO_TIME_ZONE, value);
+ final int autoEnabledValue = configuration.isAutoDetectionEnabled() ? 1 : 0;
+ Settings.Global.putInt(mCr, Settings.Global.AUTO_TIME_ZONE, autoEnabledValue);
+
+ final boolean geoTzDetectionEnabledValue = configuration.isGeoDetectionEnabled();
+ // TODO(b/149014708) Write this down to user-scoped settings once implemented.
}
}
@@ -126,6 +134,14 @@
}
@Override
+ public boolean isGeoDetectionEnabled() {
+ // TODO(b/149014708) Read this from user-scoped settings once implemented. The user's
+ // location toggle will act as an override for this setting, i.e. so that the setting will
+ // return false if the location toggle is disabled.
+ return false;
+ }
+
+ @Override
public boolean isDeviceTimeZoneInitialized() {
// timezone.equals("GMT") will be true and only true if the time zone was
// set to a default value by the system server (when starting, system server
diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorInternal.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorInternal.java
index 3d9ec64..fb7a73d 100644
--- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorInternal.java
+++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorInternal.java
@@ -22,6 +22,7 @@
* The internal (in-process) system server API for the {@link
* com.android.server.timezonedetector.TimeZoneDetectorService}.
*
+ * <p>The methods on this class can be called from any thread.
* @hide
*/
public interface TimeZoneDetectorInternal extends Dumpable.Container {
@@ -29,7 +30,7 @@
/**
* Suggests the current time zone, determined using geolocation, to the detector. The
* detector may ignore the signal based on system settings, whether better information is
- * available, and so on.
+ * available, and so on. This method may be implemented asynchronously.
*/
void suggestGeolocationTimeZone(@NonNull GeolocationTimeZoneSuggestion timeZoneSuggestion);
}
diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorInternalImpl.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorInternalImpl.java
index 4464f7d..15412a0 100644
--- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorInternalImpl.java
+++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorInternalImpl.java
@@ -58,6 +58,7 @@
@NonNull GeolocationTimeZoneSuggestion timeZoneSuggestion) {
Objects.requireNonNull(timeZoneSuggestion);
+ // All strategy calls must take place on the mHandler thread.
mHandler.post(
() -> mTimeZoneDetectorStrategy.suggestGeolocationTimeZone(timeZoneSuggestion));
}
diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java
index 7467439..d81f949 100644
--- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java
+++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java
@@ -130,6 +130,10 @@
service.handleAutoTimeZoneConfigChanged();
}
});
+ // TODO(b/149014708) Listen for changes to geolocation time zone detection enabled config.
+ // This should also include listening to the current user and the current user's location
+ // toggle since the config is user-scoped and the location toggle overrides the geolocation
+ // time zone enabled setting.
return service;
}
@@ -280,7 +284,7 @@
void handleConfigurationChanged() {
// Note: we could trigger an async time zone detection operation here via a call to
- // handleAutoTimeZoneDetectionChanged(), but that is triggered in response to the underlying
+ // handleAutoTimeZoneConfigChanged(), but that is triggered in response to the underlying
// setting value changing so it is currently unnecessary. If we get to a point where all
// configuration changes are guaranteed to happen in response to an updateConfiguration()
// call, then we can remove that path and call it here instead.
@@ -288,7 +292,6 @@
// Configuration has changed, but each user may have a different view of the configuration.
// It's possible that this will cause unnecessary notifications but that shouldn't be a
// problem.
-
synchronized (mConfigurationListeners) {
final int userCount = mConfigurationListeners.size();
for (int userIndex = 0; userIndex < userCount; userIndex++) {
diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategy.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategy.java
index f947a655..c5b7e39 100644
--- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategy.java
+++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategy.java
@@ -30,9 +30,9 @@
* <p>The strategy uses suggestions to decide whether to modify the device's time zone setting
* and what to set it to.
*
- * <p>Most calls will be handled by a single thread but that is not true for all calls. For example
- * {@link #dump(IndentingPrintWriter, String[])}) may be called on a different thread so
- * implementations mustvhandle thread safety.
+ * <p>Most calls will be handled by a single thread, but that is not true for all calls. For example
+ * {@link #dump(IndentingPrintWriter, String[])}) may be called on a different thread concurrently
+ * with other operations so implementations must still handle thread safety.
*
* @hide
*/
diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategyImpl.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategyImpl.java
index 9c36c39..d1369a2 100644
--- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategyImpl.java
+++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategyImpl.java
@@ -23,6 +23,7 @@
import static android.app.timezonedetector.TimeZoneCapabilities.CAPABILITY_NOT_APPLICABLE;
import static android.app.timezonedetector.TimeZoneCapabilities.CAPABILITY_POSSESSED;
import static android.app.timezonedetector.TimeZoneConfiguration.PROPERTY_AUTO_DETECTION_ENABLED;
+import static android.app.timezonedetector.TimeZoneConfiguration.PROPERTY_GEO_DETECTION_ENABLED;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -98,6 +99,12 @@
boolean isAutoDetectionEnabled();
/**
+ * Returns whether geolocation can be used for time zone detection when {@link
+ * #isAutoDetectionEnabled()} returns {@code true}.
+ */
+ boolean isGeoDetectionEnabled();
+
+ /**
* Returns true if the device has had an explicit time zone set.
*/
boolean isDeviceTimeZoneInitialized();
@@ -200,7 +207,15 @@
*/
@GuardedBy("this")
private ArrayMapWithHistory<Integer, QualifiedTelephonyTimeZoneSuggestion>
- mSuggestionBySlotIndex = new ArrayMapWithHistory<>(KEEP_SUGGESTION_HISTORY_SIZE);
+ mTelephonySuggestionsBySlotIndex =
+ new ArrayMapWithHistory<>(KEEP_SUGGESTION_HISTORY_SIZE);
+
+ /**
+ * The latest geolocation suggestion received.
+ */
+ @GuardedBy("this")
+ private ReferenceWithHistory<GeolocationTimeZoneSuggestion> mLatestGeoLocationSuggestion =
+ new ReferenceWithHistory<>(KEEP_SUGGESTION_HISTORY_SIZE);
@GuardedBy("this")
private final List<Dumpable> mDumpables = new ArrayList<>();
@@ -284,17 +299,26 @@
private static boolean containsAutoTimeDetectionProperties(
@NonNull TimeZoneConfiguration configuration) {
- return configuration.hasProperty(PROPERTY_AUTO_DETECTION_ENABLED);
+ return configuration.hasProperty(PROPERTY_AUTO_DETECTION_ENABLED)
+ || configuration.hasProperty(PROPERTY_GEO_DETECTION_ENABLED);
}
@Override
public synchronized void suggestGeolocationTimeZone(
@NonNull GeolocationTimeZoneSuggestion suggestion) {
- Objects.requireNonNull(suggestion);
+ if (DBG) {
+ Slog.d(LOG_TAG, "Geolocation suggestion received. newSuggestion=" + suggestion);
+ }
- // TODO Implement this.
- throw new UnsupportedOperationException(
- "Geo-location time zone detection is not currently implemented");
+ Objects.requireNonNull(suggestion);
+ mLatestGeoLocationSuggestion.set(suggestion);
+
+ // Now perform auto time zone detection. The new suggestion may be used to modify the time
+ // zone setting.
+ if (mCallback.isGeoDetectionEnabled()) {
+ String reason = "New geolocation time zone suggested. suggestion=" + suggestion;
+ doAutoTimeZoneDetection(reason);
+ }
}
@Override
@@ -332,12 +356,14 @@
new QualifiedTelephonyTimeZoneSuggestion(suggestion, score);
// Store the suggestion against the correct slotIndex.
- mSuggestionBySlotIndex.put(suggestion.getSlotIndex(), scoredSuggestion);
+ mTelephonySuggestionsBySlotIndex.put(suggestion.getSlotIndex(), scoredSuggestion);
// Now perform auto time zone detection. The new suggestion may be used to modify the time
// zone setting.
- String reason = "New telephony time suggested. suggestion=" + suggestion;
- doAutoTimeZoneDetection(reason);
+ if (!mCallback.isGeoDetectionEnabled()) {
+ String reason = "New telephony time zone suggested. suggestion=" + suggestion;
+ doAutoTimeZoneDetection(reason);
+ }
}
private static int scoreTelephonySuggestion(@NonNull TelephonyTimeZoneSuggestion suggestion) {
@@ -363,9 +389,7 @@
}
/**
- * Finds the best available time zone suggestion from all slotIndexes. If it is high-enough
- * quality and automatic time zone detection is enabled then it will be set on the device. The
- * outcome can be that this strategy becomes / remains un-opinionated and nothing is set.
+ * Performs automatic time zone detection.
*/
@GuardedBy("this")
private void doAutoTimeZoneDetection(@NonNull String detectionReason) {
@@ -374,6 +398,62 @@
return;
}
+ // Use the right suggestions based on the current configuration. This check is potentially
+ // race-prone until this value is set via a call to TimeZoneDetectorStrategy.
+ if (mCallback.isGeoDetectionEnabled()) {
+ doGeolocationTimeZoneDetection(detectionReason);
+ } else {
+ doTelephonyTimeZoneDetection(detectionReason);
+ }
+ }
+
+ /**
+ * Detects the time zone using the latest available geolocation time zone suggestion, if one is
+ * available. The outcome can be that this strategy becomes / remains un-opinionated and nothing
+ * is set.
+ */
+ @GuardedBy("this")
+ private void doGeolocationTimeZoneDetection(@NonNull String detectionReason) {
+ GeolocationTimeZoneSuggestion latestGeolocationSuggestion =
+ mLatestGeoLocationSuggestion.get();
+ if (latestGeolocationSuggestion == null) {
+ return;
+ }
+
+ List<String> zoneIds = latestGeolocationSuggestion.getZoneIds();
+ if (zoneIds == null || zoneIds.isEmpty()) {
+ // This means the client has become uncertain about the time zone or it is certain there
+ // is no known zone. In either case we must leave the existing time zone setting as it
+ // is.
+ return;
+ }
+
+ // GeolocationTimeZoneSuggestion has no measure of quality. We assume all suggestions are
+ // reliable.
+ String zoneId;
+
+ // Introduce bias towards the device's current zone when there are multiple zone suggested.
+ String deviceTimeZone = mCallback.getDeviceTimeZone();
+ if (zoneIds.contains(deviceTimeZone)) {
+ if (DBG) {
+ Slog.d(LOG_TAG,
+ "Geo tz suggestion contains current device time zone. Applying bias.");
+ }
+ zoneId = deviceTimeZone;
+ } else {
+ zoneId = zoneIds.get(0);
+ }
+ setDeviceTimeZoneIfRequired(zoneId, detectionReason);
+ }
+
+ /**
+ * Detects the time zone using the latest available telephony time zone suggestions.
+ * Finds the best available time zone suggestion from all slotIndexes. If it is high-enough
+ * quality and automatic time zone detection is enabled then it will be set on the device. The
+ * outcome can be that this strategy becomes / remains un-opinionated and nothing is set.
+ */
+ @GuardedBy("this")
+ private void doTelephonyTimeZoneDetection(@NonNull String detectionReason) {
QualifiedTelephonyTimeZoneSuggestion bestTelephonySuggestion =
findBestTelephonySuggestion();
@@ -468,9 +548,9 @@
// slotIndex and find the best. Note that we deliberately do not look at age: the caller can
// rate-limit so age is not a strong indicator of confidence. Instead, the callers are
// expected to withdraw suggestions they no longer have confidence in.
- for (int i = 0; i < mSuggestionBySlotIndex.size(); i++) {
+ for (int i = 0; i < mTelephonySuggestionsBySlotIndex.size(); i++) {
QualifiedTelephonyTimeZoneSuggestion candidateSuggestion =
- mSuggestionBySlotIndex.valueAt(i);
+ mTelephonySuggestionsBySlotIndex.valueAt(i);
if (candidateSuggestion == null) {
// Unexpected
continue;
@@ -505,14 +585,10 @@
@Override
public synchronized void handleAutoTimeZoneConfigChanged() {
if (DBG) {
- Slog.d(LOG_TAG, "handleTimeZoneDetectionChange() called");
+ Slog.d(LOG_TAG, "handleAutoTimeZoneConfigChanged()");
}
- if (mCallback.isAutoDetectionEnabled()) {
- // When the user enabled time zone detection, run the time zone detection and change the
- // device time zone if possible.
- String reason = "Auto time zone detection setting enabled.";
- doAutoTimeZoneDetection(reason);
- }
+
+ doAutoTimeZoneDetection("handleAutoTimeZoneConfigChanged()");
}
@Override
@@ -532,15 +608,21 @@
ipw.println("mCallback.isDeviceTimeZoneInitialized()="
+ mCallback.isDeviceTimeZoneInitialized());
ipw.println("mCallback.getDeviceTimeZone()=" + mCallback.getDeviceTimeZone());
+ ipw.println("mCallback.isGeoDetectionEnabled()=" + mCallback.isGeoDetectionEnabled());
ipw.println("Time zone change log:");
ipw.increaseIndent(); // level 2
mTimeZoneChangesLog.dump(ipw);
ipw.decreaseIndent(); // level 2
+ ipw.println("Geolocation suggestion history:");
+ ipw.increaseIndent(); // level 2
+ mLatestGeoLocationSuggestion.dump(ipw);
+ ipw.decreaseIndent(); // level 2
+
ipw.println("Telephony suggestion history:");
ipw.increaseIndent(); // level 2
- mSuggestionBySlotIndex.dump(ipw);
+ mTelephonySuggestionsBySlotIndex.dump(ipw);
ipw.decreaseIndent(); // level 2
ipw.decreaseIndent(); // level 1
@@ -555,7 +637,15 @@
@VisibleForTesting
public synchronized QualifiedTelephonyTimeZoneSuggestion getLatestTelephonySuggestion(
int slotIndex) {
- return mSuggestionBySlotIndex.get(slotIndex);
+ return mTelephonySuggestionsBySlotIndex.get(slotIndex);
+ }
+
+ /**
+ * A method used to inspect strategy state during tests. Not intended for general use.
+ */
+ @VisibleForTesting
+ public GeolocationTimeZoneSuggestion getLatestGeolocationSuggestion() {
+ return mLatestGeoLocationSuggestion.get();
}
/**
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index 2f695c6..202a3dc 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -3070,7 +3070,7 @@
mLockWallpaperMap.put(userId, wallpaper);
ensureSaneWallpaperData(wallpaper);
} else {
- // sanity fallback: we're in bad shape, but establishing a known
+ // rationality fallback: we're in bad shape, but establishing a known
// valid system+lock WallpaperData will keep us from dying.
Slog.wtf(TAG, "Didn't find wallpaper in non-lock case!");
wallpaper = new WallpaperData(userId, getWallpaperDir(userId),
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java
index ecba3f9..1536473 100644
--- a/services/core/java/com/android/server/wm/AccessibilityController.java
+++ b/services/core/java/com/android/server/wm/AccessibilityController.java
@@ -177,7 +177,7 @@
public void performComputeChangedWindowsNotLocked(int displayId, boolean forceSend) {
WindowsForAccessibilityObserver observer = null;
- synchronized (mService) {
+ synchronized (mService.mGlobalLock) {
final WindowsForAccessibilityObserver windowsForA11yObserver =
mWindowsForAccessibilityObserver.get(displayId);
if (windowsForA11yObserver != null) {
@@ -266,7 +266,7 @@
// Not relevant for the display magnifier.
WindowsForAccessibilityObserver observer = null;
- synchronized (mService) {
+ synchronized (mService.mGlobalLock) {
final WindowsForAccessibilityObserver windowsForA11yObserver =
mWindowsForAccessibilityObserver.get(displayId);
if (windowsForA11yObserver != null) {
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 1b4fac6..5b80787 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -107,6 +107,12 @@
import static android.view.WindowManager.TRANSIT_TASK_OPEN_BEHIND;
import static android.view.WindowManager.TRANSIT_UNSET;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS_ANIM;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_STARTING_WINDOW;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
import static com.android.server.wm.ActivityRecordProto.ALL_DRAWN;
@@ -172,12 +178,6 @@
import static com.android.server.wm.IdentifierProto.HASH_CODE;
import static com.android.server.wm.IdentifierProto.TITLE;
import static com.android.server.wm.IdentifierProto.USER_ID;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS_ANIM;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_STARTING_WINDOW;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION;
import static com.android.server.wm.Task.ActivityState.DESTROYED;
@@ -294,6 +294,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.ResolverActivity;
import com.android.internal.content.ReferrerIntent;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.ToBooleanFunction;
import com.android.internal.util.XmlUtils;
import com.android.internal.util.function.pooled.PooledConsumer;
@@ -305,7 +306,6 @@
import com.android.server.am.PendingIntentRecord;
import com.android.server.display.color.ColorDisplayService;
import com.android.server.policy.WindowManagerPolicy;
-import com.android.server.protolog.common.ProtoLog;
import com.android.server.uri.NeededUriGrants;
import com.android.server.uri.UriPermissionOwner;
import com.android.server.wm.ActivityMetricsLogger.TransitionInfoSnapshot;
@@ -1675,7 +1675,8 @@
static int getLockTaskLaunchMode(ActivityInfo aInfo, @Nullable ActivityOptions options) {
int lockTaskLaunchMode = aInfo.lockTaskLaunchMode;
- if (aInfo.applicationInfo.isPrivilegedApp()
+ // Non-priv apps are not allowed to use always or never, fall back to default
+ if (!aInfo.applicationInfo.isPrivilegedApp()
&& (lockTaskLaunchMode == LOCK_TASK_LAUNCH_MODE_ALWAYS
|| lockTaskLaunchMode == LOCK_TASK_LAUNCH_MODE_NEVER)) {
lockTaskLaunchMode = LOCK_TASK_LAUNCH_MODE_DEFAULT;
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 627361d..31a9c5d 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -2999,13 +2999,7 @@
@Override
public void stopLockTaskModeByToken(IBinder token) {
- synchronized (mGlobalLock) {
- final ActivityRecord r = ActivityRecord.forTokenLocked(token);
- if (r == null) {
- return;
- }
- stopLockTaskModeInternal(r.getTask(), false /* isSystemCaller */);
- }
+ stopLockTaskModeInternal(token, false /* isSystemCaller */);
}
/**
@@ -3047,11 +3041,19 @@
}
}
- private void stopLockTaskModeInternal(@Nullable Task task, boolean isSystemCaller) {
+ private void stopLockTaskModeInternal(@Nullable IBinder token, boolean isSystemCaller) {
final int callingUid = Binder.getCallingUid();
long ident = Binder.clearCallingIdentity();
try {
synchronized (mGlobalLock) {
+ Task task = null;
+ if (token != null) {
+ final ActivityRecord r = ActivityRecord.forTokenLocked(token);
+ if (r == null) {
+ return;
+ }
+ task = r.getTask();
+ }
getLockTaskController().stopLockTaskMode(task, isSystemCaller, callingUid);
}
// Launch in-call UI if a call is ongoing. This is necessary to allow stopping the lock
diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java
index 11a468b..f76108f 100644
--- a/services/core/java/com/android/server/wm/AppTransition.java
+++ b/services/core/java/com/android/server/wm/AppTransition.java
@@ -67,10 +67,10 @@
import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation;
import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation;
import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS_ANIM;
import static com.android.server.wm.AppTransitionProto.APP_TRANSITION_STATE;
import static com.android.server.wm.AppTransitionProto.LAST_USED_APP_TRANSITION;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -127,11 +127,11 @@
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.DumpUtils.Dump;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.internal.util.function.pooled.PooledPredicate;
import com.android.server.AttributeCache;
-import com.android.server.protolog.common.ProtoLog;
import com.android.server.wm.animation.ClipRectLRAnimation;
import com.android.server.wm.animation.ClipRectTBAnimation;
import com.android.server.wm.animation.CurvedTranslateAnimation;
diff --git a/services/core/java/com/android/server/wm/AppTransitionController.java b/services/core/java/com/android/server/wm/AppTransitionController.java
index 5720e9b..57d51c5 100644
--- a/services/core/java/com/android/server/wm/AppTransitionController.java
+++ b/services/core/java/com/android/server/wm/AppTransitionController.java
@@ -41,14 +41,14 @@
import static android.view.WindowManager.TRANSIT_WALLPAPER_INTRA_OPEN;
import static android.view.WindowManager.TRANSIT_WALLPAPER_OPEN;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS_ANIM;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
import static com.android.server.wm.ActivityTaskManagerInternal.APP_TRANSITION_SNAPSHOT;
import static com.android.server.wm.ActivityTaskManagerInternal.APP_TRANSITION_SPLASH_SCREEN;
import static com.android.server.wm.ActivityTaskManagerInternal.APP_TRANSITION_WINDOWS_DRAWN;
import static com.android.server.wm.AppTransition.isKeyguardGoingAwayTransit;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS_ANIM;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS;
@@ -69,7 +69,7 @@
import android.view.animation.Animation;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.server.protolog.common.ProtoLog;
+import com.android.internal.protolog.common.ProtoLog;
import java.util.ArrayList;
import java.util.LinkedList;
diff --git a/services/core/java/com/android/server/wm/BlackFrame.java b/services/core/java/com/android/server/wm/BlackFrame.java
index f563e57..0b2c851 100644
--- a/services/core/java/com/android/server/wm/BlackFrame.java
+++ b/services/core/java/com/android/server/wm/BlackFrame.java
@@ -16,13 +16,13 @@
package com.android.server.wm;
-import static com.android.server.wm.ProtoLogGroup.WM_SHOW_SURFACE_ALLOC;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_SURFACE_ALLOC;
import android.graphics.Rect;
import android.view.Surface.OutOfResourcesException;
import android.view.SurfaceControl;
-import com.android.server.protolog.common.ProtoLog;
+import com.android.internal.protolog.common.ProtoLog;
import java.io.PrintWriter;
import java.util.function.Supplier;
diff --git a/services/core/java/com/android/server/wm/DisplayArea.java b/services/core/java/com/android/server/wm/DisplayArea.java
index 6ffb482..8bd42f0 100644
--- a/services/core/java/com/android/server/wm/DisplayArea.java
+++ b/services/core/java/com/android/server/wm/DisplayArea.java
@@ -24,11 +24,11 @@
import static android.window.DisplayAreaOrganizer.FEATURE_UNDEFINED;
import static android.window.DisplayAreaOrganizer.FEATURE_WINDOW_TOKENS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.internal.util.Preconditions.checkState;
import static com.android.server.wm.DisplayAreaProto.IS_TASK_DISPLAY_AREA;
import static com.android.server.wm.DisplayAreaProto.NAME;
import static com.android.server.wm.DisplayAreaProto.WINDOW_CONTAINER;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.server.wm.WindowContainerChildProto.DISPLAY_AREA;
import android.annotation.Nullable;
@@ -38,8 +38,8 @@
import android.window.DisplayAreaInfo;
import android.window.IDisplayAreaOrganizer;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.server.policy.WindowManagerPolicy;
-import com.android.server.protolog.common.ProtoLog;
import java.util.Comparator;
import java.util.function.BiFunction;
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index fc17053..ba5a382 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -74,6 +74,14 @@
import static android.window.DisplayAreaOrganizer.FEATURE_ROOT;
import static android.window.DisplayAreaOrganizer.FEATURE_WINDOWED_MAGNIFICATION;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_BOOT;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_IME;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_SCREEN_ON;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
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;
@@ -94,14 +102,6 @@
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.SINGLE_TASK_INSTANCE;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_BOOT;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_IME;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_SCREEN_ON;
-import static com.android.server.wm.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
import static com.android.server.wm.Task.ActivityState.RESUMED;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION;
@@ -203,6 +203,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.ToBooleanFunction;
import com.android.internal.util.function.TriConsumer;
import com.android.internal.util.function.pooled.PooledConsumer;
@@ -211,7 +212,6 @@
import com.android.internal.util.function.pooled.PooledPredicate;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.policy.WindowManagerPolicy;
-import com.android.server.protolog.common.ProtoLog;
import com.android.server.wm.utils.DisplayRotationUtil;
import com.android.server.wm.utils.RotationCache;
import com.android.server.wm.utils.WmDisplayCutout;
@@ -4063,9 +4063,14 @@
if (DEBUG_SCREENSHOT && inRotation) Slog.v(TAG_WM, "Taking screenshot while rotating");
// Send invalid rect and no width and height since it will screenshot the entire display.
- Rect frame = new Rect(0, 0, -1, -1);
- final Bitmap bitmap = SurfaceControl.screenshot(frame, 0, 0, inRotation,
- mDisplay.getRotation());
+ final IBinder displayToken = SurfaceControl.getInternalDisplayToken();
+ final SurfaceControl.DisplayCaptureArgs captureArgs =
+ new SurfaceControl.DisplayCaptureArgs.Builder(displayToken)
+ .setUseIdentityTransform(inRotation)
+ .build();
+ final SurfaceControl.ScreenshotHardwareBuffer screenshotBuffer =
+ SurfaceControl.captureDisplay(captureArgs);
+ final Bitmap bitmap = screenshotBuffer == null ? null : screenshotBuffer.asBitmap();
if (bitmap == null) {
Slog.w(TAG_WM, "Failed to take screenshot");
return null;
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index 4f6f75d..2e03cb8 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -112,6 +112,7 @@
import static android.view.WindowManagerPolicyConstants.NAV_BAR_LEFT;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_RIGHT;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_SCREEN_ON;
import static com.android.server.policy.PhoneWindowManager.TOAST_WINDOW_TIMEOUT;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
import static com.android.server.policy.WindowManagerPolicy.TRANSIT_ENTER;
@@ -120,7 +121,6 @@
import static com.android.server.policy.WindowManagerPolicy.TRANSIT_PREVIEW_DONE;
import static com.android.server.policy.WindowManagerPolicy.TRANSIT_SHOW;
import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_SCREEN_ON;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
@@ -187,6 +187,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.policy.GestureNavigationSettingsObserver;
import com.android.internal.policy.ScreenDecorationsUtils;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.ScreenshotHelper;
import com.android.internal.util.function.TriConsumer;
import com.android.internal.view.AppearanceRegion;
@@ -199,7 +200,6 @@
import com.android.server.policy.WindowManagerPolicy.ScreenOnListener;
import com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs;
import com.android.server.policy.WindowOrientationListener;
-import com.android.server.protolog.common.ProtoLog;
import com.android.server.statusbar.StatusBarManagerInternal;
import com.android.server.wallpaper.WallpaperManagerInternal;
import com.android.server.wm.utils.InsetUtils;
diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java
index c63128c..0206787 100644
--- a/services/core/java/com/android/server/wm/DisplayRotation.java
+++ b/services/core/java/com/android/server/wm/DisplayRotation.java
@@ -22,8 +22,8 @@
import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_ROTATE;
import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -58,12 +58,12 @@
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.server.LocalServices;
import com.android.server.UiThread;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.policy.WindowOrientationListener;
-import com.android.server.protolog.common.ProtoLog;
import com.android.server.statusbar.StatusBarManagerInternal;
import java.io.PrintWriter;
diff --git a/services/core/java/com/android/server/wm/DragState.java b/services/core/java/com/android/server/wm/DragState.java
index 22dd1d3..133b111 100644
--- a/services/core/java/com/android/server/wm/DragState.java
+++ b/services/core/java/com/android/server/wm/DragState.java
@@ -18,11 +18,11 @@
import static android.os.IInputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
import static com.android.server.wm.DragDropController.MSG_ANIMATION_END;
import static com.android.server.wm.DragDropController.MSG_DRAG_END_TIMEOUT;
import static com.android.server.wm.DragDropController.MSG_TEAR_DOWN_DRAG_AND_DROP_INPUT;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
-import static com.android.server.wm.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DRAG;
import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -58,9 +58,9 @@
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.view.IDragAndDropPermissions;
import com.android.server.LocalServices;
-import com.android.server.protolog.common.ProtoLog;
import java.util.ArrayList;
diff --git a/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java b/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java
index e7fbc334..86e2698 100644
--- a/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java
+++ b/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java
@@ -16,13 +16,13 @@
package com.android.server.wm;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_IME;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_IME;
import android.view.InsetsSource;
import android.view.WindowInsets;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.server.protolog.common.ProtoLog;
+import com.android.internal.protolog.common.ProtoLog;
import java.io.PrintWriter;
diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java
index 791f471..0fe9735 100644
--- a/services/core/java/com/android/server/wm/InputMonitor.java
+++ b/services/core/java/com/android/server/wm/InputMonitor.java
@@ -41,7 +41,7 @@
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_INPUT;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -60,8 +60,8 @@
import android.view.InputWindowHandle;
import android.view.SurfaceControl;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.server.policy.WindowManagerPolicy;
-import com.android.server.protolog.common.ProtoLog;
import java.io.PrintWriter;
import java.util.Set;
diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java
index f64149c..d1eb795 100644
--- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java
+++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java
@@ -24,7 +24,7 @@
import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
import static android.view.ViewRootImpl.sNewInsetsMode;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_IME;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_IME;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_INSETS_CONTROL;
import static com.android.server.wm.WindowManagerService.H.LAYOUT_AND_ASSIGN_WINDOW_LAYERS_IF_NEEDED;
@@ -40,8 +40,8 @@
import android.view.SurfaceControl.Transaction;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.function.TriConsumer;
-import com.android.server.protolog.common.ProtoLog;
import com.android.server.wm.SurfaceAnimator.AnimationType;
import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
diff --git a/services/core/java/com/android/server/wm/InsetsStateController.java b/services/core/java/com/android/server/wm/InsetsStateController.java
index 9c978fd..ab1074e 100644
--- a/services/core/java/com/android/server/wm/InsetsStateController.java
+++ b/services/core/java/com/android/server/wm/InsetsStateController.java
@@ -30,7 +30,7 @@
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_IME;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_IME;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -45,8 +45,8 @@
import android.view.InsetsState.InternalInsetsType;
import android.view.WindowManager;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.server.inputmethod.InputMethodManagerInternal;
-import com.android.server.protolog.common.ProtoLog;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -105,6 +105,10 @@
* @return The state stripped of the necessary information.
*/
InsetsState getInsetsForDispatch(@NonNull WindowState target) {
+ final InsetsState rotatedState = target.mToken.getFixedRotationTransformInsetsState();
+ if (rotatedState != null) {
+ return rotatedState;
+ }
final InsetsSourceProvider provider = target.getControllableInsetProvider();
final @InternalInsetsType int type = provider != null
? provider.getSource().getType() : ITYPE_INVALID;
diff --git a/services/core/java/com/android/server/wm/RecentsAnimation.java b/services/core/java/com/android/server/wm/RecentsAnimation.java
index d7b43bc..6c41683 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimation.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimation.java
@@ -25,8 +25,8 @@
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.WindowManager.TRANSIT_NONE;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_RECENTS_ANIMATIONS;
import static com.android.server.wm.ActivityStackSupervisor.PRESERVE_WINDOWS;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_RECENTS_ANIMATIONS;
import static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_IN_PLACE;
import static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_TO_ORIGINAL_POSITION;
import static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_TO_TOP;
@@ -41,9 +41,9 @@
import android.util.Slog;
import android.view.IRecentsAnimationRunner;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.internal.util.function.pooled.PooledPredicate;
-import com.android.server.protolog.common.ProtoLog;
import com.android.server.wm.ActivityMetricsLogger.LaunchingState;
import com.android.server.wm.RecentsAnimationController.RecentsAnimationCallbacks;
diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java
index 6b3a5d6..143fbb0 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimationController.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java
@@ -23,10 +23,10 @@
import static android.view.WindowManager.INPUT_CONSUMER_RECENTS_ANIMATION;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_RECENTS_ANIMATIONS;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
import static com.android.server.wm.ActivityTaskManagerInternal.APP_TRANSITION_RECENTS_ANIM;
import static com.android.server.wm.AnimationAdapterProto.REMOTE;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_RECENTS_ANIMATIONS;
import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_RECENTS;
import static com.android.server.wm.WindowManagerInternal.AppTransitionListener;
@@ -56,12 +56,12 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.inputmethod.SoftInputShowHideReason;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.function.pooled.PooledConsumer;
import com.android.internal.util.function.pooled.PooledFunction;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.server.LocalServices;
import com.android.server.inputmethod.InputMethodManagerInternal;
-import com.android.server.protolog.common.ProtoLog;
import com.android.server.statusbar.StatusBarManagerInternal;
import com.android.server.wm.SurfaceAnimator.AnimationType;
import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
diff --git a/services/core/java/com/android/server/wm/RemoteAnimationController.java b/services/core/java/com/android/server/wm/RemoteAnimationController.java
index c255a18..e7461e7 100644
--- a/services/core/java/com/android/server/wm/RemoteAnimationController.java
+++ b/services/core/java/com/android/server/wm/RemoteAnimationController.java
@@ -16,8 +16,8 @@
package com.android.server.wm;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_REMOTE_ANIMATIONS;
import static com.android.server.wm.AnimationAdapterProto.REMOTE;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_REMOTE_ANIMATIONS;
import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -37,9 +37,9 @@
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
+import com.android.internal.protolog.ProtoLogImpl;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.FastPrintWriter;
-import com.android.server.protolog.ProtoLogImpl;
-import com.android.server.protolog.common.ProtoLog;
import com.android.server.wm.SurfaceAnimator.AnimationType;
import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java
index 1cb483c..b3a3ed7 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -41,6 +41,11 @@
import static android.view.WindowManager.TRANSIT_SHOW_SINGLE_TASK_DISPLAY;
import static android.view.WindowManager.TRANSIT_TASK_TO_BACK;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_KEEP_SCREEN_ON;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_SURFACE_ALLOC;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
import static com.android.server.policy.PhoneWindowManager.SYSTEM_DIALOG_REASON_ASSIST;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
@@ -59,11 +64,6 @@
import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_TASKS;
import static com.android.server.wm.ActivityTaskManagerService.ANIMATE;
import static com.android.server.wm.ActivityTaskManagerService.TAG_SWITCH;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_KEEP_SCREEN_ON;
-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.RecentsAnimationController.REORDER_KEEP_IN_PLACE;
import static com.android.server.wm.RootWindowContainerProto.IS_HOME_RECENTS_COMPONENT;
import static com.android.server.wm.RootWindowContainerProto.KEYGUARD_CONTROLLER;
@@ -146,6 +146,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.ResolverActivity;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.function.pooled.PooledConsumer;
import com.android.internal.util.function.pooled.PooledFunction;
import com.android.internal.util.function.pooled.PooledLambda;
@@ -155,7 +156,6 @@
import com.android.server.am.AppTimeTracker;
import com.android.server.am.UserState;
import com.android.server.policy.WindowManagerPolicy;
-import com.android.server.protolog.common.ProtoLog;
import java.io.FileDescriptor;
import java.io.PrintWriter;
diff --git a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java
index d7b8fb0..3c8036d 100644
--- a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java
+++ b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java
@@ -18,9 +18,9 @@
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_SURFACE_ALLOC;
import static com.android.server.wm.AnimationSpecProto.ROTATE;
-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.RotationAnimationSpecProto.DURATION_MS;
import static com.android.server.wm.RotationAnimationSpecProto.END_LUMA;
import static com.android.server.wm.RotationAnimationSpecProto.START_LUMA;
@@ -50,7 +50,7 @@
import android.view.animation.Transformation;
import com.android.internal.R;
-import com.android.server.protolog.common.ProtoLog;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.server.wm.SurfaceAnimator.AnimationType;
import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
import com.android.server.wm.utils.RotationAnimationUtils;
diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java
index 86cbf3e..3b32a9d76 100644
--- a/services/core/java/com/android/server/wm/Session.java
+++ b/services/core/java/com/android/server/wm/Session.java
@@ -24,7 +24,7 @@
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static android.view.WindowManager.LayoutParams.isSystemAlertWindowType;
-import static com.android.server.wm.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_POSITIONING;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -58,7 +58,7 @@
import android.view.WindowManager;
import com.android.internal.os.logging.MetricsLoggerWrapper;
-import com.android.server.protolog.common.ProtoLog;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.server.wm.WindowManagerService.H;
import java.io.PrintWriter;
diff --git a/services/core/java/com/android/server/wm/SurfaceFreezer.java b/services/core/java/com/android/server/wm/SurfaceFreezer.java
index 1c97430..d9365c5 100644
--- a/services/core/java/com/android/server/wm/SurfaceFreezer.java
+++ b/services/core/java/com/android/server/wm/SurfaceFreezer.java
@@ -16,7 +16,7 @@
package com.android.server.wm;
-import static com.android.server.wm.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_SCREEN_ROTATION;
@@ -28,7 +28,7 @@
import android.view.Surface;
import android.view.SurfaceControl;
-import com.android.server.protolog.common.ProtoLog;
+import com.android.internal.protolog.common.ProtoLog;
import java.util.function.Supplier;
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index be0815b0..ec7b1ee 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -78,6 +78,8 @@
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.internal.protolog.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_RECENTS_ANIMATIONS;
import static com.android.server.wm.ActivityRecord.STARTING_WINDOW_SHOWN;
import static com.android.server.wm.ActivityStackSupervisor.DEFER_RESUME;
import static com.android.server.wm.ActivityStackSupervisor.ON_TOP;
@@ -116,8 +118,6 @@
import static com.android.server.wm.IdentifierProto.HASH_CODE;
import static com.android.server.wm.IdentifierProto.TITLE;
import static com.android.server.wm.IdentifierProto.USER_ID;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_RECENTS_ANIMATIONS;
import static com.android.server.wm.Task.ActivityState.PAUSED;
import static com.android.server.wm.Task.ActivityState.PAUSING;
import static com.android.server.wm.Task.ActivityState.RESUMED;
@@ -210,6 +210,7 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.IVoiceInteractor;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.XmlUtils;
import com.android.internal.util.function.pooled.PooledConsumer;
import com.android.internal.util.function.pooled.PooledFunction;
@@ -218,7 +219,6 @@
import com.android.server.Watchdog;
import com.android.server.am.ActivityManagerService;
import com.android.server.am.AppTimeTracker;
-import com.android.server.protolog.common.ProtoLog;
import com.android.server.uri.NeededUriGrants;
import org.xmlpull.v1.XmlPullParser;
@@ -7056,17 +7056,21 @@
/**
* Reset local parameters because an app's activity died.
* @param app The app of the activity that died.
+ * @return {@code true} if the process of the pausing activity is died.
*/
- void handleAppDied(WindowProcessController app) {
+ boolean handleAppDied(WindowProcessController app) {
+ boolean isPausingDied = false;
if (mPausingActivity != null && mPausingActivity.app == app) {
if (DEBUG_PAUSE || DEBUG_CLEANUP) Slog.v(TAG_PAUSE,
"App died while pausing: " + mPausingActivity);
mPausingActivity = null;
+ isPausingDied = true;
}
if (mLastPausedActivity != null && mLastPausedActivity.app == app) {
mLastPausedActivity = null;
mLastNoHistoryActivity = null;
}
+ return isPausingDied;
}
boolean dump(FileDescriptor fd, PrintWriter pw, boolean dumpAll, boolean dumpClient,
diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java
index a847744..3251110 100644
--- a/services/core/java/com/android/server/wm/TaskDisplayArea.java
+++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java
@@ -32,13 +32,13 @@
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.server.wm.ActivityStackSupervisor.TAG_TASKS;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_STATES;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_TASKS;
import static com.android.server.wm.ActivityTaskManagerService.TAG_STACK;
import static com.android.server.wm.DisplayContent.alwaysCreateStack;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.server.wm.RootWindowContainer.TAG_STATES;
import static com.android.server.wm.Task.ActivityState.RESUMED;
import static com.android.server.wm.Task.STACK_VISIBILITY_VISIBLE;
@@ -58,10 +58,10 @@
import android.window.WindowContainerTransaction;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.ToBooleanFunction;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.internal.util.function.pooled.PooledPredicate;
-import com.android.server.protolog.common.ProtoLog;
import java.io.PrintWriter;
import java.util.ArrayList;
diff --git a/services/core/java/com/android/server/wm/TaskPositioner.java b/services/core/java/com/android/server/wm/TaskPositioner.java
index 3fbc037..a66cd84 100644
--- a/services/core/java/com/android/server/wm/TaskPositioner.java
+++ b/services/core/java/com/android/server/wm/TaskPositioner.java
@@ -26,8 +26,8 @@
import static com.android.internal.policy.TaskResizingAlgorithm.CTRL_NONE;
import static com.android.internal.policy.TaskResizingAlgorithm.CTRL_RIGHT;
import static com.android.internal.policy.TaskResizingAlgorithm.CTRL_TOP;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.server.wm.DragResizeMode.DRAG_RESIZE_MODE_FREEFORM;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_POSITIONING;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -59,7 +59,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.policy.TaskResizingAlgorithm;
import com.android.internal.policy.TaskResizingAlgorithm.CtrlType;
-import com.android.server.protolog.common.ProtoLog;
+import com.android.internal.protolog.common.ProtoLog;
class TaskPositioner implements IBinder.DeathRecipient {
private static final boolean DEBUG_ORIENTATION_VIOLATIONS = false;
diff --git a/services/core/java/com/android/server/wm/TaskScreenshotAnimatable.java b/services/core/java/com/android/server/wm/TaskScreenshotAnimatable.java
index 1103bf1..3def091 100644
--- a/services/core/java/com/android/server/wm/TaskScreenshotAnimatable.java
+++ b/services/core/java/com/android/server/wm/TaskScreenshotAnimatable.java
@@ -15,14 +15,14 @@
*/
package com.android.server.wm;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_RECENTS_ANIMATIONS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_RECENTS_ANIMATIONS;
import android.hardware.HardwareBuffer;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
-import com.android.server.protolog.common.ProtoLog;
+import com.android.internal.protolog.common.ProtoLog;
import java.util.function.Function;
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
index 9b18ac8..e9ada6b 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
@@ -41,7 +41,7 @@
import static com.android.internal.policy.DecorView.NAVIGATION_BAR_COLOR_VIEW_ATTRIBUTES;
import static com.android.internal.policy.DecorView.STATUS_BAR_COLOR_VIEW_ATTRIBUTES;
import static com.android.internal.policy.DecorView.getNavigationBarRect;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_STARTING_WINDOW;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_STARTING_WINDOW;
import static com.android.server.wm.TaskSnapshotController.getSystemBarInsets;
import static com.android.server.wm.TaskSnapshotController.mergeInsetsSources;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
@@ -83,9 +83,9 @@
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.policy.DecorView;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.view.BaseIWindow;
import com.android.server.policy.WindowManagerPolicy.StartingSurface;
-import com.android.server.protolog.common.ProtoLog;
/**
* This class represents a starting window that shows a snapshot.
diff --git a/services/core/java/com/android/server/wm/WallpaperAnimationAdapter.java b/services/core/java/com/android/server/wm/WallpaperAnimationAdapter.java
index f467015..38bff9e 100644
--- a/services/core/java/com/android/server/wm/WallpaperAnimationAdapter.java
+++ b/services/core/java/com/android/server/wm/WallpaperAnimationAdapter.java
@@ -15,8 +15,8 @@
*/
package com.android.server.wm;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_REMOTE_ANIMATIONS;
import static com.android.server.wm.AnimationAdapterProto.REMOTE;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_REMOTE_ANIMATIONS;
import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION;
@@ -26,7 +26,7 @@
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl;
-import com.android.server.protolog.common.ProtoLog;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.server.wm.SurfaceAnimator.AnimationType;
import java.io.PrintWriter;
diff --git a/services/core/java/com/android/server/wm/WindowAnimator.java b/services/core/java/com/android/server/wm/WindowAnimator.java
index 6377a21..5c6266a 100644
--- a/services/core/java/com/android/server/wm/WindowAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowAnimator.java
@@ -16,7 +16,7 @@
package com.android.server.wm;
-import static com.android.server.wm.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_ALL;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_RECENTS;
@@ -36,8 +36,8 @@
import android.view.Choreographer;
import android.view.SurfaceControl;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.server.policy.WindowManagerPolicy;
-import com.android.server.protolog.common.ProtoLog;
import java.io.PrintWriter;
import java.util.ArrayList;
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index e24d185..8a5e70f 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -28,14 +28,14 @@
import static android.os.UserHandle.USER_NULL;
import static android.view.SurfaceControl.Transaction;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS_ANIM;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
import static com.android.server.wm.AppTransition.MAX_APP_TRANSITION_DURATION;
import static com.android.server.wm.IdentifierProto.HASH_CODE;
import static com.android.server.wm.IdentifierProto.TITLE;
import static com.android.server.wm.IdentifierProto.USER_ID;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS_ANIM;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_ALL;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
import static com.android.server.wm.WindowContainer.AnimationFlags.CHILDREN;
@@ -82,8 +82,8 @@
import android.window.WindowContainerToken;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.ToBooleanFunction;
-import com.android.server.protolog.common.ProtoLog;
import com.android.server.wm.SurfaceAnimator.Animatable;
import com.android.server.wm.SurfaceAnimator.AnimationType;
import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
diff --git a/services/core/java/com/android/server/wm/WindowContainerThumbnail.java b/services/core/java/com/android/server/wm/WindowContainerThumbnail.java
index b75f886..b9f67a5 100644
--- a/services/core/java/com/android/server/wm/WindowContainerThumbnail.java
+++ b/services/core/java/com/android/server/wm/WindowContainerThumbnail.java
@@ -19,7 +19,7 @@
import static android.view.SurfaceControl.METADATA_OWNER_UID;
import static android.view.SurfaceControl.METADATA_WINDOW_TYPE;
-import static com.android.server.wm.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_RECENTS;
import static com.android.server.wm.WindowContainerThumbnailProto.HEIGHT;
import static com.android.server.wm.WindowContainerThumbnailProto.SURFACE_ANIMATOR;
@@ -39,7 +39,7 @@
import android.view.SurfaceControl.Transaction;
import android.view.animation.Animation;
-import com.android.server.protolog.common.ProtoLog;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.server.wm.SurfaceAnimator.Animatable;
import com.android.server.wm.SurfaceAnimator.AnimationType;
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 0b1d6bc..b33a8e9 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -84,22 +84,22 @@
import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_INVALID;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_BOOT;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_IME;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_KEEP_SCREEN_ON;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_SCREEN_ON;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_STARTING_WINDOW;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_WINDOW_MOVEMENT;
+import static com.android.internal.protolog.ProtoLogGroup.WM_ERROR;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
import static com.android.internal.util.LatencyTracker.ACTION_ROTATE_SCREEN;
import static com.android.server.LockGuard.INDEX_WINDOW;
import static com.android.server.LockGuard.installLock;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_BOOT;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_IME;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_KEEP_SCREEN_ON;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_SCREEN_ON;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_STARTING_WINDOW;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_WINDOW_MOVEMENT;
-import static com.android.server.wm.ProtoLogGroup.WM_ERROR;
-import static com.android.server.wm.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
import static com.android.server.wm.WindowContainer.AnimationFlags.CHILDREN;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION;
@@ -265,6 +265,8 @@
import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.internal.policy.IShortcutService;
import com.android.internal.policy.KeyInterceptionInfo;
+import com.android.internal.protolog.ProtoLogImpl;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.LatencyTracker;
@@ -281,8 +283,6 @@
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.policy.WindowManagerPolicy.ScreenOffListener;
import com.android.server.power.ShutdownThread;
-import com.android.server.protolog.ProtoLogImpl;
-import com.android.server.protolog.common.ProtoLog;
import com.android.server.utils.PriorityDump;
import com.android.server.wm.utils.DeviceConfigInterface;
diff --git a/services/core/java/com/android/server/wm/WindowManagerShellCommand.java b/services/core/java/com/android/server/wm/WindowManagerShellCommand.java
index bdecb8d..271d2b1 100644
--- a/services/core/java/com/android/server/wm/WindowManagerShellCommand.java
+++ b/services/core/java/com/android/server/wm/WindowManagerShellCommand.java
@@ -31,7 +31,7 @@
import android.view.ViewDebug;
import com.android.internal.os.ByteTransferPipe;
-import com.android.server.protolog.ProtoLogImpl;
+import com.android.internal.protolog.ProtoLogImpl;
import java.io.IOException;
import java.io.PrintWriter;
diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java
index a58c564..ab6e35b 100644
--- a/services/core/java/com/android/server/wm/WindowProcessController.java
+++ b/services/core/java/com/android/server/wm/WindowProcessController.java
@@ -1177,12 +1177,19 @@
boolean handleAppDied() {
mAtm.mStackSupervisor.removeHistoryRecords(this);
- final boolean isRemoved = isRemoved();
boolean hasVisibleActivities = false;
if (mInactiveActivities != null && !mInactiveActivities.isEmpty()) {
// Make sure that all activities in this process are handled.
mActivities.addAll(mInactiveActivities);
}
+ if (isRemoved()) {
+ // The package of the died process should be force-stopped, so make its activities as
+ // finishing to prevent the process from being started again if the next top (or being
+ // visible) activity also resides in the same process. This must be done before removal.
+ for (int i = mActivities.size() - 1; i >= 0; i--) {
+ mActivities.get(i).makeFinishingLocked();
+ }
+ }
for (int i = mActivities.size() - 1; i >= 0; i--) {
final ActivityRecord r = mActivities.get(i);
if (r.mVisibleRequested || r.isVisible()) {
@@ -1191,16 +1198,13 @@
// is not yet committed, so isVisible()=true.
hasVisibleActivities = true;
}
- if (isRemoved) {
- // The package of the died process should be force-stopped, so make its activities
- // as finishing to prevent the process from being started again if the next top (or
- // being visible) activity also resides in the same process.
- r.makeFinishingLocked();
- }
final Task rootTask = r.getRootTask();
if (rootTask != null) {
- rootTask.handleAppDied(this);
+ // There may be a pausing activity that hasn't shown any window and was requested
+ // to be hidden. But pausing is also a visible state, it should be regarded as
+ // visible, so the caller can know the next activity should be resumed.
+ hasVisibleActivities |= rootTask.handleAppDied(this);
}
r.handleAppDied();
}
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index ab78e74..ebbd74a 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -101,6 +101,14 @@
import static android.view.WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_IME;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_RESIZE;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_STARTING_WINDOW;
import static com.android.server.am.ActivityManagerService.MY_PID;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
import static com.android.server.policy.WindowManagerPolicy.TRANSIT_ENTER;
@@ -116,14 +124,6 @@
import static com.android.server.wm.MoveAnimationSpecProto.DURATION_MS;
import static com.android.server.wm.MoveAnimationSpecProto.FROM;
import static com.android.server.wm.MoveAnimationSpecProto.TO;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_IME;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_RESIZE;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_STARTING_WINDOW;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION;
@@ -236,10 +236,10 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.policy.KeyInterceptionInfo;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.FrameworkStatsLog;
import com.android.internal.util.ToBooleanFunction;
import com.android.server.policy.WindowManagerPolicy;
-import com.android.server.protolog.common.ProtoLog;
import com.android.server.wm.LocalAnimationAdapter.AnimationSpec;
import com.android.server.wm.SurfaceAnimator.AnimationType;
import com.android.server.wm.utils.WmDisplayCutout;
@@ -1535,10 +1535,6 @@
}
InsetsState getInsetsState() {
- final InsetsState insetsState = mToken.getFixedRotationTransformInsetsState();
- if (insetsState != null) {
- return insetsState;
- }
return getDisplayContent().getInsetsPolicy().getInsetsForDispatch(this);
}
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index d0101ad..16edb55 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -31,13 +31,13 @@
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static android.view.WindowManager.TRANSIT_NONE;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_DRAW;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_STARTING_WINDOW;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_SURFACE_ALLOC;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_DRAW;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_STARTING_WINDOW;
-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.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG;
@@ -76,8 +76,8 @@
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.server.policy.WindowManagerPolicy;
-import com.android.server.protolog.common.ProtoLog;
import java.io.PrintWriter;
diff --git a/services/core/java/com/android/server/wm/WindowSurfaceController.java b/services/core/java/com/android/server/wm/WindowSurfaceController.java
index b89cdd3..9b40822 100644
--- a/services/core/java/com/android/server/wm/WindowSurfaceController.java
+++ b/services/core/java/com/android/server/wm/WindowSurfaceController.java
@@ -21,8 +21,8 @@
import static android.view.SurfaceControl.METADATA_OWNER_UID;
import static android.view.SurfaceControl.METADATA_WINDOW_TYPE;
-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.internal.protolog.ProtoLogGroup.WM_SHOW_SURFACE_ALLOC;
+import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
@@ -40,7 +40,7 @@
import android.view.WindowContentFrameStats;
import android.view.WindowManager;
-import com.android.server.protolog.common.ProtoLog;
+import com.android.internal.protolog.common.ProtoLog;
import java.io.PrintWriter;
diff --git a/services/core/java/com/android/server/wm/WindowToken.java b/services/core/java/com/android/server/wm/WindowToken.java
index 2c1bb3e..f7cd37f 100644
--- a/services/core/java/com/android/server/wm/WindowToken.java
+++ b/services/core/java/com/android/server/wm/WindowToken.java
@@ -23,10 +23,10 @@
import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_WINDOW_MOVEMENT;
-import static com.android.server.wm.ProtoLogGroup.WM_ERROR;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_WINDOW_MOVEMENT;
+import static com.android.internal.protolog.ProtoLogGroup.WM_ERROR;
import static com.android.server.wm.WindowContainer.AnimationFlags.CHILDREN;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION;
@@ -59,8 +59,8 @@
import android.view.WindowManager;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.protolog.common.ProtoLog;
import com.android.server.policy.WindowManagerPolicy;
-import com.android.server.protolog.common.ProtoLog;
import java.io.PrintWriter;
import java.util.ArrayList;
diff --git a/services/core/java/com/android/server/wm/WindowTracing.java b/services/core/java/com/android/server/wm/WindowTracing.java
index ba3dc60..e8b8bfc 100644
--- a/services/core/java/com/android/server/wm/WindowTracing.java
+++ b/services/core/java/com/android/server/wm/WindowTracing.java
@@ -34,7 +34,7 @@
import android.util.proto.ProtoOutputStream;
import android.view.Choreographer;
-import com.android.server.protolog.ProtoLogImpl;
+import com.android.internal.protolog.ProtoLogImpl;
import com.android.internal.util.TraceBuffer;
import java.io.File;
diff --git a/services/core/jni/com_android_server_VibratorService.cpp b/services/core/jni/com_android_server_VibratorService.cpp
index 74e2328..529fb88 100644
--- a/services/core/jni/com_android_server_VibratorService.cpp
+++ b/services/core/jni/com_android_server_VibratorService.cpp
@@ -17,9 +17,7 @@
#define LOG_TAG "VibratorService"
#include <android/hardware/vibrator/1.3/IVibrator.h>
-#include <android/hardware/vibrator/BnVibratorCallback.h>
#include <android/hardware/vibrator/IVibrator.h>
-#include <binder/IServiceManager.h>
#include "jni.h"
#include <nativehelper/JNIHelp.h>
@@ -28,19 +26,11 @@
#include <utils/misc.h>
#include <utils/Log.h>
-#include <hardware/vibrator.h>
#include <inttypes.h>
-#include <stdio.h>
#include <vibratorservice/VibratorHalController.h>
-using android::hardware::Return;
-using android::hardware::Void;
-using android::hardware::vibrator::V1_0::EffectStrength;
-using android::hardware::vibrator::V1_0::Status;
-using android::hardware::vibrator::V1_1::Effect_1_1;
-
namespace V1_0 = android::hardware::vibrator::V1_0;
namespace V1_1 = android::hardware::vibrator::V1_1;
namespace V1_2 = android::hardware::vibrator::V1_2;
@@ -49,6 +39,8 @@
namespace android {
+static JavaVM* sJvm = nullptr;
+
static jmethodID sMethodIdOnComplete;
static struct {
@@ -85,147 +77,13 @@
static_assert(static_cast<uint8_t>(V1_3::Effect::TEXTURE_TICK) ==
static_cast<uint8_t>(aidl::Effect::TEXTURE_TICK));
-class VibratorCallback {
- public:
- VibratorCallback(JNIEnv *env, jobject vibration) :
- mVibration(MakeGlobalRefOrDie(env, vibration)) {}
-
- ~VibratorCallback() {
- JNIEnv *env = AndroidRuntime::getJNIEnv();
- env->DeleteGlobalRef(mVibration);
- }
-
- void onComplete() {
- auto env = AndroidRuntime::getJNIEnv();
- env->CallVoidMethod(mVibration, sMethodIdOnComplete);
- }
-
- private:
- jobject mVibration;
-};
-
-class AidlVibratorCallback : public aidl::BnVibratorCallback {
- public:
- AidlVibratorCallback(JNIEnv *env, jobject vibration) :
- mCb(env, vibration) {}
-
- binder::Status onComplete() override {
- mCb.onComplete();
- return binder::Status::ok(); // oneway, local call
+static inline void callVibrationOnComplete(jobject vibration) {
+ if (vibration == nullptr) {
+ return;
}
-
- private:
- VibratorCallback mCb;
-};
-
-static constexpr int NUM_TRIES = 2;
-
-template<class R>
-inline R NoneStatus() {
- using ::android::hardware::Status;
- return Status::fromExceptionCode(Status::EX_NONE);
-}
-
-template<>
-inline binder::Status NoneStatus() {
- using binder::Status;
- return Status::fromExceptionCode(Status::EX_NONE);
-}
-
-// Creates a Return<R> with STATUS::EX_NULL_POINTER.
-template<class R>
-inline R NullptrStatus() {
- using ::android::hardware::Status;
- return Status::fromExceptionCode(Status::EX_NULL_POINTER);
-}
-
-template<>
-inline binder::Status NullptrStatus() {
- using binder::Status;
- return Status::fromExceptionCode(Status::EX_NULL_POINTER);
-}
-
-template <typename I>
-sp<I> getService() {
- return I::getService();
-}
-
-template <>
-sp<aidl::IVibrator> getService() {
- return waitForVintfService<aidl::IVibrator>();
-}
-
-template <typename I>
-sp<I> tryGetService() {
- return I::tryGetService();
-}
-
-template <>
-sp<aidl::IVibrator> tryGetService() {
- return checkVintfService<aidl::IVibrator>();
-}
-
-template <typename I>
-class HalWrapper {
- public:
- static std::unique_ptr<HalWrapper> Create() {
- // Assume that if getService returns a nullptr, HAL is not available on the
- // device.
- auto hal = getService<I>();
- return hal ? std::unique_ptr<HalWrapper>(new HalWrapper(std::move(hal))) : nullptr;
- }
-
- // Helper used to transparently deal with the vibrator HAL becoming unavailable.
- template<class R, class... Args0, class... Args1>
- R call(R (I::* fn)(Args0...), Args1&&... args1) {
- // Return<R> doesn't have a default constructor, so make a Return<R> with
- // STATUS::EX_NONE.
- R ret{NoneStatus<R>()};
-
- // Note that ret is guaranteed to be changed after this loop.
- for (int i = 0; i < NUM_TRIES; ++i) {
- ret = (mHal == nullptr) ? NullptrStatus<R>()
- : (*mHal.*fn)(std::forward<Args1>(args1)...);
-
- if (ret.isOk()) {
- break;
- }
-
- ALOGE("Failed to issue command to vibrator HAL. Retrying.");
-
- // Restoring connection to the HAL.
- mHal = tryGetService<I>();
- }
- return ret;
- }
-
- private:
- HalWrapper(sp<I> &&hal) : mHal(std::move(hal)) {}
-
- private:
- sp<I> mHal;
-};
-
-template <typename I>
-static auto getHal() {
- static auto sHalWrapper = HalWrapper<I>::Create();
- return sHalWrapper.get();
-}
-
-template<class R, class I, class... Args0, class... Args1>
-R halCall(R (I::* fn)(Args0...), Args1&&... args1) {
- auto hal = getHal<I>();
- return hal ? hal->call(fn, std::forward<Args1>(args1)...) : NullptrStatus<R>();
-}
-
-template<class R>
-bool isValidEffect(jlong effect) {
- if (effect < 0) {
- return false;
- }
- R val = static_cast<R>(effect);
- auto iter = hardware::hidl_enum_range<R>();
- return val >= *iter.begin() && val <= *std::prev(iter.end());
+ auto jniEnv = GetOrAttachJNIEnvironment(sJvm);
+ jniEnv->CallVoidMethod(vibration, sMethodIdOnComplete);
+ jniEnv->DeleteGlobalRef(vibration);
}
static aidl::CompositeEffect effectFromJavaPrimitive(JNIEnv* env, jobject primitive) {
@@ -246,14 +104,6 @@
}
static jlong vibratorInit(JNIEnv* /* env */, jclass /* clazz */) {
- if (auto hal = getHal<aidl::IVibrator>()) {
- // IBinder::pingBinder isn't accessible as a pointer function
- // but getCapabilities can serve the same purpose
- int32_t cap;
- hal->call(&aidl::IVibrator::getCapabilities, &cap).isOk();
- } else {
- halCall(&V1_0::IVibrator::ping).isOk();
- }
std::unique_ptr<vibrator::HalController> controller =
std::make_unique<vibrator::HalController>();
controller->init();
@@ -273,18 +123,16 @@
return controller->ping().isOk() ? JNI_TRUE : JNI_FALSE;
}
-static void vibratorOn(JNIEnv* /* env */, jclass /* clazz */, jlong timeout_ms) {
- if (auto hal = getHal<aidl::IVibrator>()) {
- auto status = hal->call(&aidl::IVibrator::on, timeout_ms, nullptr);
- if (!status.isOk()) {
- ALOGE("vibratorOn command failed: %s", status.toString8().string());
- }
- } else {
- Status retStatus = halCall(&V1_0::IVibrator::on, timeout_ms).withDefault(Status::UNKNOWN_ERROR);
- if (retStatus != Status::OK) {
- ALOGE("vibratorOn command failed (%" PRIu32 ").", static_cast<uint32_t>(retStatus));
- }
+static void vibratorOn(JNIEnv* env, jclass /* clazz */, jlong controllerPtr, jlong timeoutMs,
+ jobject vibration) {
+ vibrator::HalController* controller = reinterpret_cast<vibrator::HalController*>(controllerPtr);
+ if (controller == nullptr) {
+ ALOGE("vibratorOn failed because controller was not initialized");
+ return;
}
+ jobject vibrationRef = vibration == nullptr ? vibration : MakeGlobalRefOrDie(env, vibration);
+ auto callback = [vibrationRef]() { callVibrationOnComplete(vibrationRef); };
+ controller->on(std::chrono::milliseconds(timeoutMs), callback);
}
static void vibratorOff(JNIEnv* env, jclass /* clazz */, jlong controllerPtr) {
@@ -333,76 +181,26 @@
return effects;
}
-static jlong vibratorPerformEffect(JNIEnv* env, jclass /* clazz */, jlong effect, jlong strength,
- jobject vibration, jboolean withCallback) {
- if (auto hal = getHal<aidl::IVibrator>()) {
- int32_t lengthMs;
- sp<AidlVibratorCallback> effectCallback =
- (withCallback != JNI_FALSE ? new AidlVibratorCallback(env, vibration) : nullptr);
- aidl::Effect effectType(static_cast<aidl::Effect>(effect));
- aidl::EffectStrength effectStrength(static_cast<aidl::EffectStrength>(strength));
-
- auto status = hal->call(&aidl::IVibrator::perform, effectType, effectStrength, effectCallback, &lengthMs);
- if (!status.isOk()) {
- if (status.exceptionCode() != binder::Status::EX_UNSUPPORTED_OPERATION) {
- ALOGE("Failed to perform haptic effect: effect=%" PRId64 ", strength=%" PRId32
- ": %s", static_cast<int64_t>(effect), static_cast<int32_t>(strength), status.toString8().string());
- }
- return -1;
- }
- return lengthMs;
- } else {
- Status status;
- uint32_t lengthMs;
- auto callback = [&status, &lengthMs](Status retStatus, uint32_t retLengthMs) {
- status = retStatus;
- lengthMs = retLengthMs;
- };
- EffectStrength effectStrength(static_cast<EffectStrength>(strength));
-
- Return<void> ret;
- if (isValidEffect<V1_0::Effect>(effect)) {
- ret = halCall(&V1_0::IVibrator::perform, static_cast<V1_0::Effect>(effect),
- effectStrength, callback);
- } else if (isValidEffect<Effect_1_1>(effect)) {
- ret = halCall(&V1_1::IVibrator::perform_1_1, static_cast<Effect_1_1>(effect),
- effectStrength, callback);
- } else if (isValidEffect<V1_2::Effect>(effect)) {
- ret = halCall(&V1_2::IVibrator::perform_1_2, static_cast<V1_2::Effect>(effect),
- effectStrength, callback);
- } else if (isValidEffect<V1_3::Effect>(effect)) {
- ret = halCall(&V1_3::IVibrator::perform_1_3, static_cast<V1_3::Effect>(effect),
- effectStrength, callback);
- } else {
- ALOGW("Unable to perform haptic effect, invalid effect ID (%" PRId32 ")",
- static_cast<int32_t>(effect));
- return -1;
- }
-
- if (!ret.isOk()) {
- ALOGW("Failed to perform effect (%" PRId32 ")", static_cast<int32_t>(effect));
- return -1;
- }
-
- if (status == Status::OK) {
- return lengthMs;
- } else if (status != Status::UNSUPPORTED_OPERATION) {
- // Don't warn on UNSUPPORTED_OPERATION, that's a normal event and just means the motor
- // doesn't have a pre-defined waveform to perform for it, so we should just give the
- // opportunity to fall back to the framework waveforms.
- ALOGE("Failed to perform haptic effect: effect=%" PRId64 ", strength=%" PRId32
- ", error=%" PRIu32 ").", static_cast<int64_t>(effect),
- static_cast<int32_t>(strength), static_cast<uint32_t>(status));
- }
+static jlong vibratorPerformEffect(JNIEnv* env, jclass /* clazz */, jlong controllerPtr,
+ jlong effect, jlong strength, jobject vibration) {
+ vibrator::HalController* controller = reinterpret_cast<vibrator::HalController*>(controllerPtr);
+ if (controller == nullptr) {
+ ALOGE("vibratorPerformEffect failed because controller was not initialized");
+ return -1;
}
-
- return -1;
+ aidl::Effect effectType = static_cast<aidl::Effect>(effect);
+ aidl::EffectStrength effectStrength = static_cast<aidl::EffectStrength>(strength);
+ jobject vibrationRef = vibration == nullptr ? vibration : MakeGlobalRefOrDie(env, vibration);
+ auto callback = [vibrationRef]() { callVibrationOnComplete(vibrationRef); };
+ auto result = controller->performEffect(effectType, effectStrength, callback);
+ return result.isOk() ? result.value().count() : -1;
}
-static void vibratorPerformComposedEffect(JNIEnv* env, jclass /* clazz */, jobjectArray composition,
- jobject vibration) {
- auto hal = getHal<aidl::IVibrator>();
- if (!hal) {
+static void vibratorPerformComposedEffect(JNIEnv* env, jclass /* clazz */, jlong controllerPtr,
+ jobjectArray composition, jobject vibration) {
+ vibrator::HalController* controller = reinterpret_cast<vibrator::HalController*>(controllerPtr);
+ if (controller == nullptr) {
+ ALOGE("vibratorPerformComposedEffect failed because controller was not initialized");
return;
}
size_t size = env->GetArrayLength(composition);
@@ -411,14 +209,9 @@
jobject element = env->GetObjectArrayElement(composition, i);
effects.push_back(effectFromJavaPrimitive(env, element));
}
- sp<AidlVibratorCallback> effectCallback = new AidlVibratorCallback(env, vibration);
-
- auto status = hal->call(&aidl::IVibrator::compose, effects, effectCallback);
- if (!status.isOk()) {
- if (status.exceptionCode() != binder::Status::EX_UNSUPPORTED_OPERATION) {
- ALOGE("Failed to play haptic effect composition");
- }
- }
+ jobject vibrationRef = vibration == nullptr ? vibration : MakeGlobalRefOrDie(env, vibration);
+ auto callback = [vibrationRef]() { callVibrationOnComplete(vibrationRef); };
+ controller->performComposedEffect(effects, callback);
}
static jlong vibratorGetCapabilities(JNIEnv* env, jclass /* clazz */, jlong controllerPtr) {
@@ -456,13 +249,13 @@
{"vibratorInit", "()J", (void*)vibratorInit},
{"vibratorGetFinalizer", "()J", (void*)vibratorGetFinalizer},
{"vibratorExists", "(J)Z", (void*)vibratorExists},
- {"vibratorOn", "(J)V", (void*)vibratorOn},
+ {"vibratorOn", "(JJLcom/android/server/VibratorService$Vibration;)V", (void*)vibratorOn},
{"vibratorOff", "(J)V", (void*)vibratorOff},
{"vibratorSetAmplitude", "(JI)V", (void*)vibratorSetAmplitude},
- {"vibratorPerformEffect", "(JJLcom/android/server/VibratorService$Vibration;Z)J",
+ {"vibratorPerformEffect", "(JJJLcom/android/server/VibratorService$Vibration;)J",
(void*)vibratorPerformEffect},
{"vibratorPerformComposedEffect",
- "([Landroid/os/VibrationEffect$Composition$PrimitiveEffect;Lcom/android/server/"
+ "(J[Landroid/os/VibrationEffect$Composition$PrimitiveEffect;Lcom/android/server/"
"VibratorService$Vibration;)V",
(void*)vibratorPerformComposedEffect},
{"vibratorGetSupportedEffects", "(J)[I", (void*)vibratorGetSupportedEffects},
@@ -472,7 +265,8 @@
{"vibratorAlwaysOnDisable", "(JJ)V", (void*)vibratorAlwaysOnDisable},
};
-int register_android_server_VibratorService(JNIEnv *env) {
+int register_android_server_VibratorService(JavaVM* vm, JNIEnv* env) {
+ sJvm = vm;
sMethodIdOnComplete =
GetMethodIDOrDie(env,
FindClassOrDie(env, "com/android/server/VibratorService$Vibration"),
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index 935dffe..9751c46 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -421,6 +421,10 @@
AutoMutex _l(mLock);
mLocked.viewports = viewports;
mLocked.pointerDisplayId = pointerDisplayId;
+ std::shared_ptr<PointerController> controller = mLocked.pointerController.lock();
+ if (controller != nullptr) {
+ controller->onDisplayViewportsUpdated(mLocked.viewports);
+ }
} // release lock
mInputManager->getReader()->requestRefreshConfiguration(
@@ -818,8 +822,8 @@
}
bool lightsOut = mLocked.systemUiVisibility & ASYSTEM_UI_VISIBILITY_STATUS_BAR_HIDDEN;
- controller->setInactivityTimeout(lightsOut ? PointerController::InactivityTimeout::SHORT
- : PointerController::InactivityTimeout::NORMAL);
+ controller->setInactivityTimeout(lightsOut ? InactivityTimeout::SHORT
+ : InactivityTimeout::NORMAL);
}
void NativeInputManager::setPointerSpeed(int32_t speed) {
diff --git a/services/core/jni/com_android_server_pm_PackageManagerShellCommandDataLoader.cpp b/services/core/jni/com_android_server_pm_PackageManagerShellCommandDataLoader.cpp
index e904645..9e2bb45 100644
--- a/services/core/jni/com_android_server_pm_PackageManagerShellCommandDataLoader.cpp
+++ b/services/core/jni/com_android_server_pm_PackageManagerShellCommandDataLoader.cpp
@@ -314,31 +314,6 @@
return result;
}
-static inline JNIEnv* GetJNIEnvironment(JavaVM* vm) {
- JNIEnv* env;
- if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
- return 0;
- }
- return env;
-}
-
-static inline JNIEnv* GetOrAttachJNIEnvironment(JavaVM* jvm) {
- JNIEnv* env = GetJNIEnvironment(jvm);
- if (!env) {
- int result = jvm->AttachCurrentThread(&env, nullptr);
- CHECK_EQ(result, JNI_OK) << "thread attach failed";
- struct VmDetacher {
- VmDetacher(JavaVM* vm) : mVm(vm) {}
- ~VmDetacher() { mVm->DetachCurrentThread(); }
-
- private:
- JavaVM* const mVm;
- };
- static thread_local VmDetacher detacher(jvm);
- }
- return env;
-}
-
class PMSCDataLoader;
struct OnTraceChanged {
@@ -415,7 +390,7 @@
bool onPrepareImage(dataloader::DataLoaderInstallationFiles addedFiles) final {
ALOGE("onPrepareImage: start.");
- JNIEnv* env = GetOrAttachJNIEnvironment(mJvm);
+ JNIEnv* env = GetOrAttachJNIEnvironment(mJvm, JNI_VERSION_1_6);
const auto& jni = jniIds(env);
jobject shellCommand = env->CallStaticObjectMethod(jni.packageManagerShellCommandDataLoader,
diff --git a/services/core/jni/onload.cpp b/services/core/jni/onload.cpp
index 6f24e3b..5df1ada 100644
--- a/services/core/jni/onload.cpp
+++ b/services/core/jni/onload.cpp
@@ -37,7 +37,7 @@
int register_android_server_UsbMidiDevice(JNIEnv* env);
int register_android_server_UsbHostManager(JNIEnv* env);
int register_android_server_vr_VrManagerService(JNIEnv* env);
-int register_android_server_VibratorService(JNIEnv* env);
+int register_android_server_VibratorService(JavaVM* vm, JNIEnv* env);
int register_android_server_location_GnssLocationProvider(JNIEnv* env);
int register_android_server_connectivity_Vpn(JNIEnv* env);
int register_android_server_TestNetworkService(JNIEnv* env);
@@ -90,7 +90,7 @@
register_android_server_UsbAlsaJackDetector(env);
register_android_server_UsbHostManager(env);
register_android_server_vr_VrManagerService(env);
- register_android_server_VibratorService(env);
+ register_android_server_VibratorService(vm, env);
register_android_server_SystemServer(env);
register_android_server_location_GnssLocationProvider(env);
register_android_server_connectivity_Vpn(env);
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/ActiveAdmin.java b/services/devicepolicy/java/com/android/server/devicepolicy/ActiveAdmin.java
new file mode 100644
index 0000000..6fea2aa
--- /dev/null
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/ActiveAdmin.java
@@ -0,0 +1,1116 @@
+/*
+ * 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.
+ */
+
+package com.android.server.devicepolicy;
+
+import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
+
+import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
+import static org.xmlpull.v1.XmlPullParser.END_TAG;
+import static org.xmlpull.v1.XmlPullParser.TEXT;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.app.admin.DeviceAdminInfo;
+import android.app.admin.DevicePolicyManager;
+import android.app.admin.FactoryResetProtectionPolicy;
+import android.app.admin.PasswordPolicy;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.PersistableBundle;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.text.TextUtils;
+import android.util.ArrayMap;
+import android.util.ArraySet;
+import android.util.Log;
+import android.util.Slog;
+
+import com.android.internal.util.IndentingPrintWriter;
+import com.android.internal.util.Preconditions;
+import com.android.internal.util.XmlUtils;
+import com.android.server.pm.UserRestrictionsUtils;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlSerializer;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Predicate;
+
+class ActiveAdmin {
+ private static final String TAG_DISABLE_KEYGUARD_FEATURES = "disable-keyguard-features";
+ private static final String TAG_TEST_ONLY_ADMIN = "test-only-admin";
+ private static final String TAG_DISABLE_CAMERA = "disable-camera";
+ private static final String TAG_DISABLE_CALLER_ID = "disable-caller-id";
+ private static final String TAG_DISABLE_CONTACTS_SEARCH = "disable-contacts-search";
+ private static final String TAG_DISABLE_BLUETOOTH_CONTACT_SHARING =
+ "disable-bt-contacts-sharing";
+ private static final String TAG_DISABLE_SCREEN_CAPTURE = "disable-screen-capture";
+ private static final String TAG_DISABLE_ACCOUNT_MANAGEMENT = "disable-account-management";
+ private static final String TAG_REQUIRE_AUTO_TIME = "require_auto_time";
+ private static final String TAG_FORCE_EPHEMERAL_USERS = "force_ephemeral_users";
+ private static final String TAG_IS_NETWORK_LOGGING_ENABLED = "is_network_logging_enabled";
+ private static final String TAG_ACCOUNT_TYPE = "account-type";
+ private static final String TAG_PERMITTED_ACCESSIBILITY_SERVICES =
+ "permitted-accessiblity-services";
+ private static final String TAG_ENCRYPTION_REQUESTED = "encryption-requested";
+ private static final String TAG_MANAGE_TRUST_AGENT_FEATURES = "manage-trust-agent-features";
+ private static final String TAG_TRUST_AGENT_COMPONENT_OPTIONS = "trust-agent-component-options";
+ private static final String TAG_TRUST_AGENT_COMPONENT = "component";
+ private static final String TAG_PASSWORD_EXPIRATION_DATE = "password-expiration-date";
+ private static final String TAG_PASSWORD_EXPIRATION_TIMEOUT = "password-expiration-timeout";
+ private static final String TAG_GLOBAL_PROXY_EXCLUSION_LIST = "global-proxy-exclusion-list";
+ private static final String TAG_GLOBAL_PROXY_SPEC = "global-proxy-spec";
+ private static final String TAG_SPECIFIES_GLOBAL_PROXY = "specifies-global-proxy";
+ private static final String TAG_PERMITTED_IMES = "permitted-imes";
+ private static final String TAG_PERMITTED_NOTIFICATION_LISTENERS =
+ "permitted-notification-listeners";
+ private static final String TAG_MAX_FAILED_PASSWORD_WIPE = "max-failed-password-wipe";
+ private static final String TAG_MAX_TIME_TO_UNLOCK = "max-time-to-unlock";
+ private static final String TAG_STRONG_AUTH_UNLOCK_TIMEOUT = "strong-auth-unlock-timeout";
+ private static final String TAG_MIN_PASSWORD_NONLETTER = "min-password-nonletter";
+ private static final String TAG_MIN_PASSWORD_SYMBOLS = "min-password-symbols";
+ private static final String TAG_MIN_PASSWORD_NUMERIC = "min-password-numeric";
+ private static final String TAG_MIN_PASSWORD_LETTERS = "min-password-letters";
+ private static final String TAG_MIN_PASSWORD_LOWERCASE = "min-password-lowercase";
+ private static final String TAG_MIN_PASSWORD_UPPERCASE = "min-password-uppercase";
+ private static final String TAG_PASSWORD_HISTORY_LENGTH = "password-history-length";
+ private static final String TAG_MIN_PASSWORD_LENGTH = "min-password-length";
+ private static final String TAG_PASSWORD_QUALITY = "password-quality";
+ private static final String TAG_POLICIES = "policies";
+ private static final String TAG_CROSS_PROFILE_WIDGET_PROVIDERS =
+ "cross-profile-widget-providers";
+ private static final String TAG_PROVIDER = "provider";
+ private static final String TAG_PACKAGE_LIST_ITEM = "item";
+ private static final String TAG_KEEP_UNINSTALLED_PACKAGES = "keep-uninstalled-packages";
+ private static final String TAG_USER_RESTRICTIONS = "user-restrictions";
+ private static final String TAG_DEFAULT_ENABLED_USER_RESTRICTIONS =
+ "default-enabled-user-restrictions";
+ private static final String TAG_RESTRICTION = "restriction";
+ private static final String TAG_SHORT_SUPPORT_MESSAGE = "short-support-message";
+ private static final String TAG_LONG_SUPPORT_MESSAGE = "long-support-message";
+ private static final String TAG_PARENT_ADMIN = "parent-admin";
+ private static final String TAG_ORGANIZATION_COLOR = "organization-color";
+ private static final String TAG_ORGANIZATION_NAME = "organization-name";
+ private static final String TAG_IS_LOGOUT_ENABLED = "is_logout_enabled";
+ private static final String TAG_START_USER_SESSION_MESSAGE = "start_user_session_message";
+ private static final String TAG_END_USER_SESSION_MESSAGE = "end_user_session_message";
+ private static final String TAG_METERED_DATA_DISABLED_PACKAGES =
+ "metered_data_disabled_packages";
+ private static final String TAG_CROSS_PROFILE_CALENDAR_PACKAGES =
+ "cross-profile-calendar-packages";
+ private static final String TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL =
+ "cross-profile-calendar-packages-null";
+ private static final String TAG_CROSS_PROFILE_PACKAGES = "cross-profile-packages";
+ private static final String TAG_FACTORY_RESET_PROTECTION_POLICY =
+ "factory_reset_protection_policy";
+ private static final String TAG_SUSPEND_PERSONAL_APPS = "suspend-personal-apps";
+ private static final String TAG_PROFILE_MAXIMUM_TIME_OFF = "profile-max-time-off";
+ private static final String TAG_PROFILE_OFF_DEADLINE = "profile-off-deadline";
+ private static final String TAG_ALWAYS_ON_VPN_PACKAGE = "vpn-package";
+ private static final String TAG_ALWAYS_ON_VPN_LOCKDOWN = "vpn-lockdown";
+ private static final String TAG_COMMON_CRITERIA_MODE = "common-criteria-mode";
+ private static final String ATTR_VALUE = "value";
+ private static final String ATTR_LAST_NETWORK_LOGGING_NOTIFICATION = "last-notification";
+ private static final String ATTR_NUM_NETWORK_LOGGING_NOTIFICATIONS = "num-notifications";
+
+ DeviceAdminInfo info;
+
+ static final int DEF_PASSWORD_HISTORY_LENGTH = 0;
+ int passwordHistoryLength = DEF_PASSWORD_HISTORY_LENGTH;
+
+ @NonNull
+ PasswordPolicy mPasswordPolicy = new PasswordPolicy();
+
+ @Nullable
+ FactoryResetProtectionPolicy mFactoryResetProtectionPolicy = null;
+
+ static final long DEF_MAXIMUM_TIME_TO_UNLOCK = 0;
+ long maximumTimeToUnlock = DEF_MAXIMUM_TIME_TO_UNLOCK;
+
+ long strongAuthUnlockTimeout = 0; // admin doesn't participate by default
+
+ static final int DEF_MAXIMUM_FAILED_PASSWORDS_FOR_WIPE = 0;
+ int maximumFailedPasswordsForWipe = DEF_MAXIMUM_FAILED_PASSWORDS_FOR_WIPE;
+
+ static final long DEF_PASSWORD_EXPIRATION_TIMEOUT = 0;
+ long passwordExpirationTimeout = DEF_PASSWORD_EXPIRATION_TIMEOUT;
+
+ static final long DEF_PASSWORD_EXPIRATION_DATE = 0;
+ long passwordExpirationDate = DEF_PASSWORD_EXPIRATION_DATE;
+
+ static final int DEF_KEYGUARD_FEATURES_DISABLED = 0; // none
+
+ int disabledKeyguardFeatures = DEF_KEYGUARD_FEATURES_DISABLED;
+
+ boolean encryptionRequested = false;
+ boolean testOnlyAdmin = false;
+ boolean disableCamera = false;
+ boolean disableCallerId = false;
+ boolean disableContactsSearch = false;
+ boolean disableBluetoothContactSharing = true;
+ boolean disableScreenCapture = false;
+ boolean requireAutoTime = false;
+ boolean forceEphemeralUsers = false;
+ boolean isNetworkLoggingEnabled = false;
+ boolean isLogoutEnabled = false;
+
+ // one notification after enabling + one more after reboots
+ static final int DEF_MAXIMUM_NETWORK_LOGGING_NOTIFICATIONS_SHOWN = 2;
+ int numNetworkLoggingNotifications = 0;
+ long lastNetworkLoggingNotificationTimeMs = 0; // Time in milliseconds since epoch
+
+ ActiveAdmin parentAdmin;
+ final boolean isParent;
+
+ static class TrustAgentInfo {
+ public PersistableBundle options;
+ TrustAgentInfo(PersistableBundle bundle) {
+ options = bundle;
+ }
+ }
+
+ // The list of packages which are not allowed to use metered data.
+ List<String> meteredDisabledPackages;
+
+ final Set<String> accountTypesWithManagementDisabled = new ArraySet<>();
+
+ // The list of permitted accessibility services package namesas set by a profile
+ // or device owner. Null means all accessibility services are allowed, empty means
+ // none except system services are allowed.
+ List<String> permittedAccessiblityServices;
+
+ // The list of permitted input methods package names as set by a profile or device owner.
+ // Null means all input methods are allowed, empty means none except system imes are
+ // allowed.
+ List<String> permittedInputMethods;
+
+ // The list of packages allowed to use a NotificationListenerService to receive events for
+ // notifications from this user. Null means that all packages are allowed. Empty list means
+ // that only packages from the system are allowed.
+ List<String> permittedNotificationListeners;
+
+ // List of package names to keep cached.
+ List<String> keepUninstalledPackages;
+
+ // TODO: review implementation decisions with frameworks team
+ boolean specifiesGlobalProxy = false;
+ String globalProxySpec = null;
+ String globalProxyExclusionList = null;
+
+ @NonNull
+ ArrayMap<String, TrustAgentInfo> trustAgentInfos = new ArrayMap<>();
+
+ List<String> crossProfileWidgetProviders;
+
+ Bundle userRestrictions;
+
+ // User restrictions that have already been enabled by default for this admin (either when
+ // setting the device or profile owner, or during a system update if one of those "enabled
+ // by default" restrictions is newly added).
+ final Set<String> defaultEnabledRestrictionsAlreadySet = new ArraySet<>();
+
+ // Support text provided by the admin to display to the user.
+ CharSequence shortSupportMessage = null;
+ CharSequence longSupportMessage = null;
+
+ // Background color of confirm credentials screen. Default: teal.
+ static final int DEF_ORGANIZATION_COLOR = Color.parseColor("#00796B");
+ int organizationColor = DEF_ORGANIZATION_COLOR;
+
+ // Default title of confirm credentials screen
+ String organizationName = null;
+
+ // Message for user switcher
+ String startUserSessionMessage = null;
+ String endUserSessionMessage = null;
+
+ // The allow list of packages that can access cross profile calendar APIs.
+ // This allow list should be in default an empty list, which indicates that no package
+ // is allow listed.
+ List<String> mCrossProfileCalendarPackages = Collections.emptyList();
+
+ // The allow list of packages that the admin has enabled to be able to request consent from
+ // the user to communicate cross-profile. By default, no packages are allowed, which is
+ // represented as an empty list.
+ List<String> mCrossProfilePackages = Collections.emptyList();
+
+ // Whether the admin explicitly requires personal apps to be suspended
+ boolean mSuspendPersonalApps = false;
+ // Maximum time the profile owned by this admin can be off.
+ long mProfileMaximumTimeOffMillis = 0;
+ // Time by which the profile should be turned on according to System.currentTimeMillis().
+ long mProfileOffDeadline = 0;
+
+ public String mAlwaysOnVpnPackage;
+ public boolean mAlwaysOnVpnLockdown;
+ boolean mCommonCriteriaMode;
+
+ ActiveAdmin(DeviceAdminInfo info, boolean isParent) {
+ this.info = info;
+ this.isParent = isParent;
+ }
+
+ ActiveAdmin getParentActiveAdmin() {
+ Preconditions.checkState(!isParent);
+
+ if (parentAdmin == null) {
+ parentAdmin = new ActiveAdmin(info, /* parent */ true);
+ }
+ return parentAdmin;
+ }
+
+ boolean hasParentActiveAdmin() {
+ return parentAdmin != null;
+ }
+
+ int getUid() {
+ return info.getActivityInfo().applicationInfo.uid;
+ }
+
+ public UserHandle getUserHandle() {
+ return UserHandle.of(UserHandle.getUserId(info.getActivityInfo().applicationInfo.uid));
+ }
+
+ void writeToXml(XmlSerializer out)
+ throws IllegalArgumentException, IllegalStateException, IOException {
+ out.startTag(null, TAG_POLICIES);
+ info.writePoliciesToXml(out);
+ out.endTag(null, TAG_POLICIES);
+ if (mPasswordPolicy.quality != PASSWORD_QUALITY_UNSPECIFIED) {
+ writeAttributeValueToXml(
+ out, TAG_PASSWORD_QUALITY, mPasswordPolicy.quality);
+ if (mPasswordPolicy.length != PasswordPolicy.DEF_MINIMUM_LENGTH) {
+ writeAttributeValueToXml(
+ out, TAG_MIN_PASSWORD_LENGTH, mPasswordPolicy.length);
+ }
+ if (mPasswordPolicy.upperCase != PasswordPolicy.DEF_MINIMUM_UPPER_CASE) {
+ writeAttributeValueToXml(
+ out, TAG_MIN_PASSWORD_UPPERCASE, mPasswordPolicy.upperCase);
+ }
+ if (mPasswordPolicy.lowerCase != PasswordPolicy.DEF_MINIMUM_LOWER_CASE) {
+ writeAttributeValueToXml(
+ out, TAG_MIN_PASSWORD_LOWERCASE, mPasswordPolicy.lowerCase);
+ }
+ if (mPasswordPolicy.letters != PasswordPolicy.DEF_MINIMUM_LETTERS) {
+ writeAttributeValueToXml(
+ out, TAG_MIN_PASSWORD_LETTERS, mPasswordPolicy.letters);
+ }
+ if (mPasswordPolicy.numeric != PasswordPolicy.DEF_MINIMUM_NUMERIC) {
+ writeAttributeValueToXml(
+ out, TAG_MIN_PASSWORD_NUMERIC, mPasswordPolicy.numeric);
+ }
+ if (mPasswordPolicy.symbols != PasswordPolicy.DEF_MINIMUM_SYMBOLS) {
+ writeAttributeValueToXml(
+ out, TAG_MIN_PASSWORD_SYMBOLS, mPasswordPolicy.symbols);
+ }
+ if (mPasswordPolicy.nonLetter > PasswordPolicy.DEF_MINIMUM_NON_LETTER) {
+ writeAttributeValueToXml(
+ out, TAG_MIN_PASSWORD_NONLETTER, mPasswordPolicy.nonLetter);
+ }
+ }
+ if (passwordHistoryLength != DEF_PASSWORD_HISTORY_LENGTH) {
+ writeAttributeValueToXml(
+ out, TAG_PASSWORD_HISTORY_LENGTH, passwordHistoryLength);
+ }
+ if (maximumTimeToUnlock != DEF_MAXIMUM_TIME_TO_UNLOCK) {
+ writeAttributeValueToXml(
+ out, TAG_MAX_TIME_TO_UNLOCK, maximumTimeToUnlock);
+ }
+ if (strongAuthUnlockTimeout != DevicePolicyManager.DEFAULT_STRONG_AUTH_TIMEOUT_MS) {
+ writeAttributeValueToXml(
+ out, TAG_STRONG_AUTH_UNLOCK_TIMEOUT, strongAuthUnlockTimeout);
+ }
+ if (maximumFailedPasswordsForWipe != DEF_MAXIMUM_FAILED_PASSWORDS_FOR_WIPE) {
+ writeAttributeValueToXml(
+ out, TAG_MAX_FAILED_PASSWORD_WIPE, maximumFailedPasswordsForWipe);
+ }
+ if (specifiesGlobalProxy) {
+ writeAttributeValueToXml(
+ out, TAG_SPECIFIES_GLOBAL_PROXY, specifiesGlobalProxy);
+ if (globalProxySpec != null) {
+ writeAttributeValueToXml(out, TAG_GLOBAL_PROXY_SPEC, globalProxySpec);
+ }
+ if (globalProxyExclusionList != null) {
+ writeAttributeValueToXml(
+ out, TAG_GLOBAL_PROXY_EXCLUSION_LIST, globalProxyExclusionList);
+ }
+ }
+ if (passwordExpirationTimeout != DEF_PASSWORD_EXPIRATION_TIMEOUT) {
+ writeAttributeValueToXml(
+ out, TAG_PASSWORD_EXPIRATION_TIMEOUT, passwordExpirationTimeout);
+ }
+ if (passwordExpirationDate != DEF_PASSWORD_EXPIRATION_DATE) {
+ writeAttributeValueToXml(
+ out, TAG_PASSWORD_EXPIRATION_DATE, passwordExpirationDate);
+ }
+ if (encryptionRequested) {
+ writeAttributeValueToXml(
+ out, TAG_ENCRYPTION_REQUESTED, encryptionRequested);
+ }
+ if (testOnlyAdmin) {
+ writeAttributeValueToXml(
+ out, TAG_TEST_ONLY_ADMIN, testOnlyAdmin);
+ }
+ if (disableCamera) {
+ writeAttributeValueToXml(
+ out, TAG_DISABLE_CAMERA, disableCamera);
+ }
+ if (disableCallerId) {
+ writeAttributeValueToXml(
+ out, TAG_DISABLE_CALLER_ID, disableCallerId);
+ }
+ if (disableContactsSearch) {
+ writeAttributeValueToXml(
+ out, TAG_DISABLE_CONTACTS_SEARCH, disableContactsSearch);
+ }
+ if (!disableBluetoothContactSharing) {
+ writeAttributeValueToXml(
+ out, TAG_DISABLE_BLUETOOTH_CONTACT_SHARING, disableBluetoothContactSharing);
+ }
+ if (disableScreenCapture) {
+ writeAttributeValueToXml(
+ out, TAG_DISABLE_SCREEN_CAPTURE, disableScreenCapture);
+ }
+ if (requireAutoTime) {
+ writeAttributeValueToXml(
+ out, TAG_REQUIRE_AUTO_TIME, requireAutoTime);
+ }
+ if (forceEphemeralUsers) {
+ writeAttributeValueToXml(
+ out, TAG_FORCE_EPHEMERAL_USERS, forceEphemeralUsers);
+ }
+ if (isNetworkLoggingEnabled) {
+ out.startTag(null, TAG_IS_NETWORK_LOGGING_ENABLED);
+ out.attribute(null, ATTR_VALUE, Boolean.toString(isNetworkLoggingEnabled));
+ out.attribute(null, ATTR_NUM_NETWORK_LOGGING_NOTIFICATIONS,
+ Integer.toString(numNetworkLoggingNotifications));
+ out.attribute(null, ATTR_LAST_NETWORK_LOGGING_NOTIFICATION,
+ Long.toString(lastNetworkLoggingNotificationTimeMs));
+ out.endTag(null, TAG_IS_NETWORK_LOGGING_ENABLED);
+ }
+ if (disabledKeyguardFeatures != DEF_KEYGUARD_FEATURES_DISABLED) {
+ writeAttributeValueToXml(
+ out, TAG_DISABLE_KEYGUARD_FEATURES, disabledKeyguardFeatures);
+ }
+ if (!accountTypesWithManagementDisabled.isEmpty()) {
+ writeAttributeValuesToXml(
+ out, TAG_DISABLE_ACCOUNT_MANAGEMENT, TAG_ACCOUNT_TYPE,
+ accountTypesWithManagementDisabled);
+ }
+ if (!trustAgentInfos.isEmpty()) {
+ Set<Map.Entry<String, TrustAgentInfo>> set = trustAgentInfos.entrySet();
+ out.startTag(null, TAG_MANAGE_TRUST_AGENT_FEATURES);
+ for (Map.Entry<String, TrustAgentInfo> entry : set) {
+ TrustAgentInfo trustAgentInfo = entry.getValue();
+ out.startTag(null, TAG_TRUST_AGENT_COMPONENT);
+ out.attribute(null, ATTR_VALUE, entry.getKey());
+ if (trustAgentInfo.options != null) {
+ out.startTag(null, TAG_TRUST_AGENT_COMPONENT_OPTIONS);
+ try {
+ trustAgentInfo.options.saveToXml(out);
+ } catch (XmlPullParserException e) {
+ Log.e(DevicePolicyManagerService.LOG_TAG,
+ "Failed to save TrustAgent options", e);
+ }
+ out.endTag(null, TAG_TRUST_AGENT_COMPONENT_OPTIONS);
+ }
+ out.endTag(null, TAG_TRUST_AGENT_COMPONENT);
+ }
+ out.endTag(null, TAG_MANAGE_TRUST_AGENT_FEATURES);
+ }
+ if (crossProfileWidgetProviders != null && !crossProfileWidgetProviders.isEmpty()) {
+ writeAttributeValuesToXml(
+ out, TAG_CROSS_PROFILE_WIDGET_PROVIDERS, TAG_PROVIDER,
+ crossProfileWidgetProviders);
+ }
+ writePackageListToXml(out, TAG_PERMITTED_ACCESSIBILITY_SERVICES,
+ permittedAccessiblityServices);
+ writePackageListToXml(out, TAG_PERMITTED_IMES, permittedInputMethods);
+ writePackageListToXml(out, TAG_PERMITTED_NOTIFICATION_LISTENERS,
+ permittedNotificationListeners);
+ writePackageListToXml(out, TAG_KEEP_UNINSTALLED_PACKAGES, keepUninstalledPackages);
+ writePackageListToXml(out, TAG_METERED_DATA_DISABLED_PACKAGES, meteredDisabledPackages);
+ if (hasUserRestrictions()) {
+ UserRestrictionsUtils.writeRestrictions(
+ out, userRestrictions, TAG_USER_RESTRICTIONS);
+ }
+ if (!defaultEnabledRestrictionsAlreadySet.isEmpty()) {
+ writeAttributeValuesToXml(out, TAG_DEFAULT_ENABLED_USER_RESTRICTIONS,
+ TAG_RESTRICTION,
+ defaultEnabledRestrictionsAlreadySet);
+ }
+ if (!TextUtils.isEmpty(shortSupportMessage)) {
+ writeTextToXml(out, TAG_SHORT_SUPPORT_MESSAGE, shortSupportMessage.toString());
+ }
+ if (!TextUtils.isEmpty(longSupportMessage)) {
+ writeTextToXml(out, TAG_LONG_SUPPORT_MESSAGE, longSupportMessage.toString());
+ }
+ if (parentAdmin != null) {
+ out.startTag(null, TAG_PARENT_ADMIN);
+ parentAdmin.writeToXml(out);
+ out.endTag(null, TAG_PARENT_ADMIN);
+ }
+ if (organizationColor != DEF_ORGANIZATION_COLOR) {
+ writeAttributeValueToXml(out, TAG_ORGANIZATION_COLOR, organizationColor);
+ }
+ if (organizationName != null) {
+ writeTextToXml(out, TAG_ORGANIZATION_NAME, organizationName);
+ }
+ if (isLogoutEnabled) {
+ writeAttributeValueToXml(out, TAG_IS_LOGOUT_ENABLED, isLogoutEnabled);
+ }
+ if (startUserSessionMessage != null) {
+ writeTextToXml(out, TAG_START_USER_SESSION_MESSAGE, startUserSessionMessage);
+ }
+ if (endUserSessionMessage != null) {
+ writeTextToXml(out, TAG_END_USER_SESSION_MESSAGE, endUserSessionMessage);
+ }
+ if (mCrossProfileCalendarPackages == null) {
+ out.startTag(null, TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL);
+ out.endTag(null, TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL);
+ } else {
+ writePackageListToXml(out, TAG_CROSS_PROFILE_CALENDAR_PACKAGES,
+ mCrossProfileCalendarPackages);
+ }
+ writePackageListToXml(out, TAG_CROSS_PROFILE_PACKAGES, mCrossProfilePackages);
+ if (mFactoryResetProtectionPolicy != null) {
+ out.startTag(null, TAG_FACTORY_RESET_PROTECTION_POLICY);
+ mFactoryResetProtectionPolicy.writeToXml(out);
+ out.endTag(null, TAG_FACTORY_RESET_PROTECTION_POLICY);
+ }
+ if (mSuspendPersonalApps) {
+ writeAttributeValueToXml(out, TAG_SUSPEND_PERSONAL_APPS, mSuspendPersonalApps);
+ }
+ if (mProfileMaximumTimeOffMillis != 0) {
+ writeAttributeValueToXml(out, TAG_PROFILE_MAXIMUM_TIME_OFF,
+ mProfileMaximumTimeOffMillis);
+ }
+ if (mProfileMaximumTimeOffMillis != 0) {
+ writeAttributeValueToXml(out, TAG_PROFILE_OFF_DEADLINE, mProfileOffDeadline);
+ }
+ if (!TextUtils.isEmpty(mAlwaysOnVpnPackage)) {
+ writeAttributeValueToXml(out, TAG_ALWAYS_ON_VPN_PACKAGE, mAlwaysOnVpnPackage);
+ }
+ if (mAlwaysOnVpnLockdown) {
+ writeAttributeValueToXml(out, TAG_ALWAYS_ON_VPN_LOCKDOWN, mAlwaysOnVpnLockdown);
+ }
+ if (mCommonCriteriaMode) {
+ writeAttributeValueToXml(out, TAG_COMMON_CRITERIA_MODE, mCommonCriteriaMode);
+ }
+ }
+
+ void writeTextToXml(XmlSerializer out, String tag, String text) throws IOException {
+ out.startTag(null, tag);
+ out.text(text);
+ out.endTag(null, tag);
+ }
+
+ void writePackageListToXml(XmlSerializer out, String outerTag,
+ List<String> packageList)
+ throws IllegalArgumentException, IllegalStateException, IOException {
+ if (packageList == null) {
+ return;
+ }
+ writeAttributeValuesToXml(out, outerTag, TAG_PACKAGE_LIST_ITEM, packageList);
+ }
+
+ void writeAttributeValueToXml(XmlSerializer out, String tag, String value)
+ throws IOException {
+ out.startTag(null, tag);
+ out.attribute(null, ATTR_VALUE, value);
+ out.endTag(null, tag);
+ }
+
+ void writeAttributeValueToXml(XmlSerializer out, String tag, int value)
+ throws IOException {
+ out.startTag(null, tag);
+ out.attribute(null, ATTR_VALUE, Integer.toString(value));
+ out.endTag(null, tag);
+ }
+
+ void writeAttributeValueToXml(XmlSerializer out, String tag, long value)
+ throws IOException {
+ out.startTag(null, tag);
+ out.attribute(null, ATTR_VALUE, Long.toString(value));
+ out.endTag(null, tag);
+ }
+
+ void writeAttributeValueToXml(XmlSerializer out, String tag, boolean value)
+ throws IOException {
+ out.startTag(null, tag);
+ out.attribute(null, ATTR_VALUE, Boolean.toString(value));
+ out.endTag(null, tag);
+ }
+
+ void writeAttributeValuesToXml(XmlSerializer out, String outerTag, String innerTag,
+ @NonNull Collection<String> values) throws IOException {
+ out.startTag(null, outerTag);
+ for (String value : values) {
+ out.startTag(null, innerTag);
+ out.attribute(null, ATTR_VALUE, value);
+ out.endTag(null, innerTag);
+ }
+ out.endTag(null, outerTag);
+ }
+
+ void readFromXml(XmlPullParser parser, boolean shouldOverridePolicies)
+ throws XmlPullParserException, IOException {
+ int outerDepth = parser.getDepth();
+ int type;
+ while ((type = parser.next()) != END_DOCUMENT
+ && (type != END_TAG || parser.getDepth() > outerDepth)) {
+ if (type == END_TAG || type == TEXT) {
+ continue;
+ }
+ String tag = parser.getName();
+ if (TAG_POLICIES.equals(tag)) {
+ if (shouldOverridePolicies) {
+ Log.d(DevicePolicyManagerService.LOG_TAG,
+ "Overriding device admin policies from XML.");
+ info.readPoliciesFromXml(parser);
+ }
+ } else if (TAG_PASSWORD_QUALITY.equals(tag)) {
+ mPasswordPolicy.quality = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_MIN_PASSWORD_LENGTH.equals(tag)) {
+ mPasswordPolicy.length = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_PASSWORD_HISTORY_LENGTH.equals(tag)) {
+ passwordHistoryLength = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_MIN_PASSWORD_UPPERCASE.equals(tag)) {
+ mPasswordPolicy.upperCase = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_MIN_PASSWORD_LOWERCASE.equals(tag)) {
+ mPasswordPolicy.lowerCase = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_MIN_PASSWORD_LETTERS.equals(tag)) {
+ mPasswordPolicy.letters = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_MIN_PASSWORD_NUMERIC.equals(tag)) {
+ mPasswordPolicy.numeric = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_MIN_PASSWORD_SYMBOLS.equals(tag)) {
+ mPasswordPolicy.symbols = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_MIN_PASSWORD_NONLETTER.equals(tag)) {
+ mPasswordPolicy.nonLetter = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_MAX_TIME_TO_UNLOCK.equals(tag)) {
+ maximumTimeToUnlock = Long.parseLong(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_STRONG_AUTH_UNLOCK_TIMEOUT.equals(tag)) {
+ strongAuthUnlockTimeout = Long.parseLong(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_MAX_FAILED_PASSWORD_WIPE.equals(tag)) {
+ maximumFailedPasswordsForWipe = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_SPECIFIES_GLOBAL_PROXY.equals(tag)) {
+ specifiesGlobalProxy = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_GLOBAL_PROXY_SPEC.equals(tag)) {
+ globalProxySpec =
+ parser.getAttributeValue(null, ATTR_VALUE);
+ } else if (TAG_GLOBAL_PROXY_EXCLUSION_LIST.equals(tag)) {
+ globalProxyExclusionList =
+ parser.getAttributeValue(null, ATTR_VALUE);
+ } else if (TAG_PASSWORD_EXPIRATION_TIMEOUT.equals(tag)) {
+ passwordExpirationTimeout = Long.parseLong(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_PASSWORD_EXPIRATION_DATE.equals(tag)) {
+ passwordExpirationDate = Long.parseLong(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_ENCRYPTION_REQUESTED.equals(tag)) {
+ encryptionRequested = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_TEST_ONLY_ADMIN.equals(tag)) {
+ testOnlyAdmin = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_DISABLE_CAMERA.equals(tag)) {
+ disableCamera = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_DISABLE_CALLER_ID.equals(tag)) {
+ disableCallerId = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_DISABLE_CONTACTS_SEARCH.equals(tag)) {
+ disableContactsSearch = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_DISABLE_BLUETOOTH_CONTACT_SHARING.equals(tag)) {
+ disableBluetoothContactSharing = Boolean.parseBoolean(parser
+ .getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_DISABLE_SCREEN_CAPTURE.equals(tag)) {
+ disableScreenCapture = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_REQUIRE_AUTO_TIME.equals(tag)) {
+ requireAutoTime = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_FORCE_EPHEMERAL_USERS.equals(tag)) {
+ forceEphemeralUsers = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_IS_NETWORK_LOGGING_ENABLED.equals(tag)) {
+ isNetworkLoggingEnabled = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ lastNetworkLoggingNotificationTimeMs = Long.parseLong(
+ parser.getAttributeValue(null, ATTR_LAST_NETWORK_LOGGING_NOTIFICATION));
+ numNetworkLoggingNotifications = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_NUM_NETWORK_LOGGING_NOTIFICATIONS));
+ } else if (TAG_DISABLE_KEYGUARD_FEATURES.equals(tag)) {
+ disabledKeyguardFeatures = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_DISABLE_ACCOUNT_MANAGEMENT.equals(tag)) {
+ readAttributeValues(
+ parser, TAG_ACCOUNT_TYPE, accountTypesWithManagementDisabled);
+ } else if (TAG_MANAGE_TRUST_AGENT_FEATURES.equals(tag)) {
+ trustAgentInfos = getAllTrustAgentInfos(parser, tag);
+ } else if (TAG_CROSS_PROFILE_WIDGET_PROVIDERS.equals(tag)) {
+ crossProfileWidgetProviders = new ArrayList<>();
+ readAttributeValues(parser, TAG_PROVIDER, crossProfileWidgetProviders);
+ } else if (TAG_PERMITTED_ACCESSIBILITY_SERVICES.equals(tag)) {
+ permittedAccessiblityServices = readPackageList(parser, tag);
+ } else if (TAG_PERMITTED_IMES.equals(tag)) {
+ permittedInputMethods = readPackageList(parser, tag);
+ } else if (TAG_PERMITTED_NOTIFICATION_LISTENERS.equals(tag)) {
+ permittedNotificationListeners = readPackageList(parser, tag);
+ } else if (TAG_KEEP_UNINSTALLED_PACKAGES.equals(tag)) {
+ keepUninstalledPackages = readPackageList(parser, tag);
+ } else if (TAG_METERED_DATA_DISABLED_PACKAGES.equals(tag)) {
+ meteredDisabledPackages = readPackageList(parser, tag);
+ } else if (TAG_USER_RESTRICTIONS.equals(tag)) {
+ userRestrictions = UserRestrictionsUtils.readRestrictions(parser);
+ } else if (TAG_DEFAULT_ENABLED_USER_RESTRICTIONS.equals(tag)) {
+ readAttributeValues(
+ parser, TAG_RESTRICTION, defaultEnabledRestrictionsAlreadySet);
+ } else if (TAG_SHORT_SUPPORT_MESSAGE.equals(tag)) {
+ type = parser.next();
+ if (type == XmlPullParser.TEXT) {
+ shortSupportMessage = parser.getText();
+ } else {
+ Log.w(DevicePolicyManagerService.LOG_TAG,
+ "Missing text when loading short support message");
+ }
+ } else if (TAG_LONG_SUPPORT_MESSAGE.equals(tag)) {
+ type = parser.next();
+ if (type == XmlPullParser.TEXT) {
+ longSupportMessage = parser.getText();
+ } else {
+ Log.w(DevicePolicyManagerService.LOG_TAG,
+ "Missing text when loading long support message");
+ }
+ } else if (TAG_PARENT_ADMIN.equals(tag)) {
+ Preconditions.checkState(!isParent);
+ parentAdmin = new ActiveAdmin(info, /* parent */ true);
+ parentAdmin.readFromXml(parser, shouldOverridePolicies);
+ } else if (TAG_ORGANIZATION_COLOR.equals(tag)) {
+ organizationColor = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_ORGANIZATION_NAME.equals(tag)) {
+ type = parser.next();
+ if (type == XmlPullParser.TEXT) {
+ organizationName = parser.getText();
+ } else {
+ Log.w(DevicePolicyManagerService.LOG_TAG,
+ "Missing text when loading organization name");
+ }
+ } else if (TAG_IS_LOGOUT_ENABLED.equals(tag)) {
+ isLogoutEnabled = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_START_USER_SESSION_MESSAGE.equals(tag)) {
+ type = parser.next();
+ if (type == XmlPullParser.TEXT) {
+ startUserSessionMessage = parser.getText();
+ } else {
+ Log.w(DevicePolicyManagerService.LOG_TAG,
+ "Missing text when loading start session message");
+ }
+ } else if (TAG_END_USER_SESSION_MESSAGE.equals(tag)) {
+ type = parser.next();
+ if (type == XmlPullParser.TEXT) {
+ endUserSessionMessage = parser.getText();
+ } else {
+ Log.w(DevicePolicyManagerService.LOG_TAG,
+ "Missing text when loading end session message");
+ }
+ } else if (TAG_CROSS_PROFILE_CALENDAR_PACKAGES.equals(tag)) {
+ mCrossProfileCalendarPackages = readPackageList(parser, tag);
+ } else if (TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL.equals(tag)) {
+ mCrossProfileCalendarPackages = null;
+ } else if (TAG_CROSS_PROFILE_PACKAGES.equals(tag)) {
+ mCrossProfilePackages = readPackageList(parser, tag);
+ } else if (TAG_FACTORY_RESET_PROTECTION_POLICY.equals(tag)) {
+ mFactoryResetProtectionPolicy = FactoryResetProtectionPolicy.readFromXml(
+ parser);
+ } else if (TAG_SUSPEND_PERSONAL_APPS.equals(tag)) {
+ mSuspendPersonalApps = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_PROFILE_MAXIMUM_TIME_OFF.equals(tag)) {
+ mProfileMaximumTimeOffMillis =
+ Long.parseLong(parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_PROFILE_OFF_DEADLINE.equals(tag)) {
+ mProfileOffDeadline =
+ Long.parseLong(parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_ALWAYS_ON_VPN_PACKAGE.equals(tag)) {
+ mAlwaysOnVpnPackage = parser.getAttributeValue(null, ATTR_VALUE);
+ } else if (TAG_ALWAYS_ON_VPN_LOCKDOWN.equals(tag)) {
+ mAlwaysOnVpnLockdown = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_COMMON_CRITERIA_MODE.equals(tag)) {
+ mCommonCriteriaMode = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else {
+ Slog.w(DevicePolicyManagerService.LOG_TAG, "Unknown admin tag: " + tag);
+ XmlUtils.skipCurrentTag(parser);
+ }
+ }
+ }
+
+ private List<String> readPackageList(XmlPullParser parser,
+ String tag) throws XmlPullParserException, IOException {
+ List<String> result = new ArrayList<String>();
+ int outerDepth = parser.getDepth();
+ int outerType;
+ while ((outerType = parser.next()) != XmlPullParser.END_DOCUMENT
+ && (outerType != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
+ if (outerType == XmlPullParser.END_TAG || outerType == XmlPullParser.TEXT) {
+ continue;
+ }
+ String outerTag = parser.getName();
+ if (TAG_PACKAGE_LIST_ITEM.equals(outerTag)) {
+ String packageName = parser.getAttributeValue(null, ATTR_VALUE);
+ if (packageName != null) {
+ result.add(packageName);
+ } else {
+ Slog.w(DevicePolicyManagerService.LOG_TAG,
+ "Package name missing under " + outerTag);
+ }
+ } else {
+ Slog.w(DevicePolicyManagerService.LOG_TAG,
+ "Unknown tag under " + tag + ": " + outerTag);
+ }
+ }
+ return result;
+ }
+
+ private void readAttributeValues(
+ XmlPullParser parser, String tag, Collection<String> result)
+ throws XmlPullParserException, IOException {
+ result.clear();
+ int outerDepthDAM = parser.getDepth();
+ int typeDAM;
+ while ((typeDAM = parser.next()) != END_DOCUMENT
+ && (typeDAM != END_TAG || parser.getDepth() > outerDepthDAM)) {
+ if (typeDAM == END_TAG || typeDAM == TEXT) {
+ continue;
+ }
+ String tagDAM = parser.getName();
+ if (tag.equals(tagDAM)) {
+ result.add(parser.getAttributeValue(null, ATTR_VALUE));
+ } else {
+ Slog.e(DevicePolicyManagerService.LOG_TAG,
+ "Expected tag " + tag + " but found " + tagDAM);
+ }
+ }
+ }
+
+ @NonNull
+ private ArrayMap<String, TrustAgentInfo> getAllTrustAgentInfos(
+ XmlPullParser parser, String tag) throws XmlPullParserException, IOException {
+ int outerDepthDAM = parser.getDepth();
+ int typeDAM;
+ final ArrayMap<String, TrustAgentInfo> result = new ArrayMap<>();
+ while ((typeDAM = parser.next()) != END_DOCUMENT
+ && (typeDAM != END_TAG || parser.getDepth() > outerDepthDAM)) {
+ if (typeDAM == END_TAG || typeDAM == TEXT) {
+ continue;
+ }
+ String tagDAM = parser.getName();
+ if (TAG_TRUST_AGENT_COMPONENT.equals(tagDAM)) {
+ final String component = parser.getAttributeValue(null, ATTR_VALUE);
+ final TrustAgentInfo trustAgentInfo = getTrustAgentInfo(parser, tag);
+ result.put(component, trustAgentInfo);
+ } else {
+ Slog.w(DevicePolicyManagerService.LOG_TAG,
+ "Unknown tag under " + tag + ": " + tagDAM);
+ }
+ }
+ return result;
+ }
+
+ private TrustAgentInfo getTrustAgentInfo(XmlPullParser parser, String tag)
+ throws XmlPullParserException, IOException {
+ int outerDepthDAM = parser.getDepth();
+ int typeDAM;
+ TrustAgentInfo result = new TrustAgentInfo(null);
+ while ((typeDAM = parser.next()) != END_DOCUMENT
+ && (typeDAM != END_TAG || parser.getDepth() > outerDepthDAM)) {
+ if (typeDAM == END_TAG || typeDAM == TEXT) {
+ continue;
+ }
+ String tagDAM = parser.getName();
+ if (TAG_TRUST_AGENT_COMPONENT_OPTIONS.equals(tagDAM)) {
+ result.options = PersistableBundle.restoreFromXml(parser);
+ } else {
+ Slog.w(DevicePolicyManagerService.LOG_TAG,
+ "Unknown tag under " + tag + ": " + tagDAM);
+ }
+ }
+ return result;
+ }
+
+ boolean hasUserRestrictions() {
+ return userRestrictions != null && userRestrictions.size() > 0;
+ }
+
+ Bundle ensureUserRestrictions() {
+ if (userRestrictions == null) {
+ userRestrictions = new Bundle();
+ }
+ return userRestrictions;
+ }
+
+ public void transfer(DeviceAdminInfo deviceAdminInfo) {
+ if (hasParentActiveAdmin()) {
+ parentAdmin.info = deviceAdminInfo;
+ }
+ info = deviceAdminInfo;
+ }
+
+ Bundle addSyntheticRestrictions(Bundle restrictions) {
+ if (disableCamera) {
+ restrictions.putBoolean(UserManager.DISALLOW_CAMERA, true);
+ }
+ if (requireAutoTime) {
+ restrictions.putBoolean(UserManager.DISALLOW_CONFIG_DATE_TIME, true);
+ }
+ return restrictions;
+ }
+
+ static Bundle removeDeprecatedRestrictions(Bundle restrictions) {
+ for (String deprecatedRestriction: UserRestrictionsUtils.DEPRECATED_USER_RESTRICTIONS) {
+ restrictions.remove(deprecatedRestriction);
+ }
+ return restrictions;
+ }
+
+ static Bundle filterRestrictions(Bundle restrictions, Predicate<String> filter) {
+ Bundle result = new Bundle();
+ for (String key : restrictions.keySet()) {
+ if (!restrictions.getBoolean(key)) {
+ continue;
+ }
+ if (filter.test(key)) {
+ result.putBoolean(key, true);
+ }
+ }
+ return result;
+ }
+
+ Bundle getEffectiveRestrictions() {
+ return addSyntheticRestrictions(
+ removeDeprecatedRestrictions(new Bundle(ensureUserRestrictions())));
+ }
+
+ Bundle getLocalUserRestrictions(int adminType) {
+ return filterRestrictions(getEffectiveRestrictions(),
+ key -> UserRestrictionsUtils.isLocal(adminType, key));
+ }
+
+ Bundle getGlobalUserRestrictions(int adminType) {
+ return filterRestrictions(getEffectiveRestrictions(),
+ key -> UserRestrictionsUtils.isGlobal(adminType, key));
+ }
+
+ void dump(IndentingPrintWriter pw) {
+ pw.print("uid=");
+ pw.println(getUid());
+
+ pw.print("testOnlyAdmin=");
+ pw.println(testOnlyAdmin);
+
+ pw.println("policies:");
+ ArrayList<DeviceAdminInfo.PolicyInfo> pols = info.getUsedPolicies();
+ if (pols != null) {
+ pw.increaseIndent();
+ for (int i = 0; i < pols.size(); i++) {
+ pw.println(pols.get(i).tag);
+ }
+ pw.decreaseIndent();
+ }
+
+ pw.print("passwordQuality=0x");
+ pw.println(Integer.toHexString(mPasswordPolicy.quality));
+
+ pw.print("minimumPasswordLength=");
+ pw.println(mPasswordPolicy.length);
+
+ pw.print("passwordHistoryLength=");
+ pw.println(passwordHistoryLength);
+
+ pw.print("minimumPasswordUpperCase=");
+ pw.println(mPasswordPolicy.upperCase);
+
+ pw.print("minimumPasswordLowerCase=");
+ pw.println(mPasswordPolicy.lowerCase);
+
+ pw.print("minimumPasswordLetters=");
+ pw.println(mPasswordPolicy.letters);
+
+ pw.print("minimumPasswordNumeric=");
+ pw.println(mPasswordPolicy.numeric);
+
+ pw.print("minimumPasswordSymbols=");
+ pw.println(mPasswordPolicy.symbols);
+
+ pw.print("minimumPasswordNonLetter=");
+ pw.println(mPasswordPolicy.nonLetter);
+
+ pw.print("maximumTimeToUnlock=");
+ pw.println(maximumTimeToUnlock);
+
+ pw.print("strongAuthUnlockTimeout=");
+ pw.println(strongAuthUnlockTimeout);
+
+ pw.print("maximumFailedPasswordsForWipe=");
+ pw.println(maximumFailedPasswordsForWipe);
+
+ pw.print("specifiesGlobalProxy=");
+ pw.println(specifiesGlobalProxy);
+
+ pw.print("passwordExpirationTimeout=");
+ pw.println(passwordExpirationTimeout);
+
+ pw.print("passwordExpirationDate=");
+ pw.println(passwordExpirationDate);
+
+ if (globalProxySpec != null) {
+ pw.print("globalProxySpec=");
+ pw.println(globalProxySpec);
+ }
+ if (globalProxyExclusionList != null) {
+ pw.print("globalProxyEclusionList=");
+ pw.println(globalProxyExclusionList);
+ }
+ pw.print("encryptionRequested=");
+ pw.println(encryptionRequested);
+
+ pw.print("disableCamera=");
+ pw.println(disableCamera);
+
+ pw.print("disableCallerId=");
+ pw.println(disableCallerId);
+
+ pw.print("disableContactsSearch=");
+ pw.println(disableContactsSearch);
+
+ pw.print("disableBluetoothContactSharing=");
+ pw.println(disableBluetoothContactSharing);
+
+ pw.print("disableScreenCapture=");
+ pw.println(disableScreenCapture);
+
+ pw.print("requireAutoTime=");
+ pw.println(requireAutoTime);
+
+ pw.print("forceEphemeralUsers=");
+ pw.println(forceEphemeralUsers);
+
+ pw.print("isNetworkLoggingEnabled=");
+ pw.println(isNetworkLoggingEnabled);
+
+ pw.print("disabledKeyguardFeatures=");
+ pw.println(disabledKeyguardFeatures);
+
+ pw.print("crossProfileWidgetProviders=");
+ pw.println(crossProfileWidgetProviders);
+
+ if (permittedAccessiblityServices != null) {
+ pw.print("permittedAccessibilityServices=");
+ pw.println(permittedAccessiblityServices);
+ }
+
+ if (permittedInputMethods != null) {
+ pw.print("permittedInputMethods=");
+ pw.println(permittedInputMethods);
+ }
+
+ if (permittedNotificationListeners != null) {
+ pw.print("permittedNotificationListeners=");
+ pw.println(permittedNotificationListeners);
+ }
+
+ if (keepUninstalledPackages != null) {
+ pw.print("keepUninstalledPackages=");
+ pw.println(keepUninstalledPackages);
+ }
+
+ pw.print("organizationColor=");
+ pw.println(organizationColor);
+
+ if (organizationName != null) {
+ pw.print("organizationName=");
+ pw.println(organizationName);
+ }
+
+ pw.println("userRestrictions:");
+ UserRestrictionsUtils.dumpRestrictions(pw, " ", userRestrictions);
+
+ pw.print("defaultEnabledRestrictionsAlreadySet=");
+ pw.println(defaultEnabledRestrictionsAlreadySet);
+
+ pw.print("isParent=");
+ pw.println(isParent);
+
+ if (parentAdmin != null) {
+ pw.println("parentAdmin:");
+ pw.increaseIndent();
+ parentAdmin.dump(pw);
+ pw.decreaseIndent();
+ }
+
+ if (mCrossProfileCalendarPackages != null) {
+ pw.print("mCrossProfileCalendarPackages=");
+ pw.println(mCrossProfileCalendarPackages);
+ }
+
+ pw.print("mCrossProfilePackages=");
+ pw.println(mCrossProfilePackages);
+
+ pw.print("mSuspendPersonalApps=");
+ pw.println(mSuspendPersonalApps);
+
+ pw.print("mProfileMaximumTimeOffMillis=");
+ pw.println(mProfileMaximumTimeOffMillis);
+
+ pw.print("mProfileOffDeadline=");
+ pw.println(mProfileOffDeadline);
+
+ pw.print("mAlwaysOnVpnPackage=");
+ pw.println(mAlwaysOnVpnPackage);
+
+ pw.print("mAlwaysOnVpnLockdown=");
+ pw.println(mAlwaysOnVpnLockdown);
+
+ pw.print("mCommonCriteriaMode=");
+ pw.println(mCommonCriteriaMode);
+ }
+}
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyData.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyData.java
new file mode 100644
index 0000000..130cfd5
--- /dev/null
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyData.java
@@ -0,0 +1,566 @@
+/*
+ * 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.
+ */
+
+package com.android.server.devicepolicy;
+
+import android.app.admin.DeviceAdminInfo;
+import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
+import android.os.FileUtils;
+import android.os.PersistableBundle;
+import android.text.TextUtils;
+import android.util.ArrayMap;
+import android.util.ArraySet;
+import android.util.Slog;
+import android.util.Xml;
+
+import com.android.internal.util.FastXmlSerializer;
+import com.android.internal.util.JournaledFile;
+import com.android.internal.util.XmlUtils;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlSerializer;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.function.Function;
+
+class DevicePolicyData {
+ private static final String TAG_ACCEPTED_CA_CERTIFICATES = "accepted-ca-certificate";
+ private static final String TAG_LOCK_TASK_COMPONENTS = "lock-task-component";
+ private static final String TAG_LOCK_TASK_FEATURES = "lock-task-features";
+ private static final String TAG_STATUS_BAR = "statusbar";
+ private static final String TAG_APPS_SUSPENDED = "apps-suspended";
+ private static final String TAG_SECONDARY_LOCK_SCREEN = "secondary-lock-screen";
+ private static final String TAG_DO_NOT_ASK_CREDENTIALS_ON_BOOT =
+ "do-not-ask-credentials-on-boot";
+ private static final String TAG_AFFILIATION_ID = "affiliation-id";
+ private static final String TAG_LAST_SECURITY_LOG_RETRIEVAL = "last-security-log-retrieval";
+ private static final String TAG_LAST_BUG_REPORT_REQUEST = "last-bug-report-request";
+ private static final String TAG_LAST_NETWORK_LOG_RETRIEVAL = "last-network-log-retrieval";
+ private static final String TAG_ADMIN_BROADCAST_PENDING = "admin-broadcast-pending";
+ private static final String TAG_CURRENT_INPUT_METHOD_SET = "current-ime-set";
+ private static final String TAG_OWNER_INSTALLED_CA_CERT = "owner-installed-ca-cert";
+ private static final String TAG_INITIALIZATION_BUNDLE = "initialization-bundle";
+ private static final String TAG_PASSWORD_VALIDITY = "password-validity";
+ private static final String TAG_PASSWORD_TOKEN_HANDLE = "password-token";
+ private static final String TAG_PROTECTED_PACKAGES = "protected-packages";
+ private static final String ATTR_VALUE = "value";
+ private static final String ATTR_ALIAS = "alias";
+ private static final String ATTR_ID = "id";
+ private static final String ATTR_PERMISSION_PROVIDER = "permission-provider";
+ private static final String ATTR_NAME = "name";
+ private static final String ATTR_DISABLED = "disabled";
+ private static final String ATTR_SETUP_COMPLETE = "setup-complete";
+ private static final String ATTR_PROVISIONING_STATE = "provisioning-state";
+ private static final String ATTR_PERMISSION_POLICY = "permission-policy";
+ private static final String ATTR_DEVICE_PROVISIONING_CONFIG_APPLIED =
+ "device-provisioning-config-applied";
+ private static final String ATTR_DEVICE_PAIRED = "device-paired";
+
+ int mFailedPasswordAttempts = 0;
+ boolean mPasswordValidAtLastCheckpoint = true;
+
+ int mUserHandle;
+ int mPasswordOwner = -1;
+ long mLastMaximumTimeToLock = -1;
+ boolean mUserSetupComplete = false;
+ boolean mPaired = false;
+ int mUserProvisioningState;
+ int mPermissionPolicy;
+
+ boolean mDeviceProvisioningConfigApplied = false;
+
+ final ArrayMap<ComponentName, ActiveAdmin> mAdminMap = new ArrayMap<>();
+ final ArrayList<ActiveAdmin> mAdminList = new ArrayList<>();
+ final ArrayList<ComponentName> mRemovingAdmins = new ArrayList<>();
+
+ // TODO(b/35385311): Keep track of metadata in TrustedCertificateStore instead.
+ final ArraySet<String> mAcceptedCaCertificates = new ArraySet<>();
+
+ // This is the list of component allowed to start lock task mode.
+ List<String> mLockTaskPackages = new ArrayList<>();
+
+ // List of packages protected by device owner
+ List<String> mUserControlDisabledPackages = new ArrayList<>();
+
+ // Bitfield of feature flags to be enabled during LockTask mode.
+ // We default on the power button menu, in order to be consistent with pre-P behaviour.
+ int mLockTaskFeatures = DevicePolicyManager.LOCK_TASK_FEATURE_GLOBAL_ACTIONS;
+
+ boolean mStatusBarDisabled = false;
+
+ ComponentName mRestrictionsProvider;
+
+ // Map of delegate package to delegation scopes
+ final ArrayMap<String, List<String>> mDelegationMap = new ArrayMap<>();
+
+ boolean mDoNotAskCredentialsOnBoot = false;
+
+ Set<String> mAffiliationIds = new ArraySet<>();
+
+ long mLastSecurityLogRetrievalTime = -1;
+
+ long mLastBugReportRequestTime = -1;
+
+ long mLastNetworkLogsRetrievalTime = -1;
+
+ boolean mCurrentInputMethodSet = false;
+
+ boolean mSecondaryLockscreenEnabled = false;
+
+ // TODO(b/35385311): Keep track of metadata in TrustedCertificateStore instead.
+ Set<String> mOwnerInstalledCaCerts = new ArraySet<>();
+
+ // Used for initialization of users created by createAndManageUser.
+ boolean mAdminBroadcastPending = false;
+ PersistableBundle mInitBundle = null;
+
+ long mPasswordTokenHandle = 0;
+
+ // Whether user's apps are suspended. This flag should only be written AFTER all the needed
+ // apps were suspended or unsuspended.
+ boolean mAppsSuspended = false;
+
+ DevicePolicyData(int userHandle) {
+ mUserHandle = userHandle;
+ }
+
+ /**
+ * Serializes DevicePolicyData object as XML.
+ */
+ static boolean store(DevicePolicyData policyData, JournaledFile file, boolean isFdeDevice) {
+ FileOutputStream stream = null;
+ try {
+ stream = new FileOutputStream(file.chooseForWrite(), false);
+ XmlSerializer out = new FastXmlSerializer();
+ out.setOutput(stream, StandardCharsets.UTF_8.name());
+ out.startDocument(null, true);
+
+ out.startTag(null, "policies");
+ if (policyData.mRestrictionsProvider != null) {
+ out.attribute(null, ATTR_PERMISSION_PROVIDER,
+ policyData.mRestrictionsProvider.flattenToString());
+ }
+ if (policyData.mUserSetupComplete) {
+ out.attribute(null, ATTR_SETUP_COMPLETE,
+ Boolean.toString(true));
+ }
+ if (policyData.mPaired) {
+ out.attribute(null, ATTR_DEVICE_PAIRED,
+ Boolean.toString(true));
+ }
+ if (policyData.mDeviceProvisioningConfigApplied) {
+ out.attribute(null, ATTR_DEVICE_PROVISIONING_CONFIG_APPLIED,
+ Boolean.toString(true));
+ }
+ if (policyData.mUserProvisioningState != DevicePolicyManager.STATE_USER_UNMANAGED) {
+ out.attribute(null, ATTR_PROVISIONING_STATE,
+ Integer.toString(policyData.mUserProvisioningState));
+ }
+ if (policyData.mPermissionPolicy != DevicePolicyManager.PERMISSION_POLICY_PROMPT) {
+ out.attribute(null, ATTR_PERMISSION_POLICY,
+ Integer.toString(policyData.mPermissionPolicy));
+ }
+
+ // Serialize delegations.
+ for (int i = 0; i < policyData.mDelegationMap.size(); ++i) {
+ final String delegatePackage = policyData.mDelegationMap.keyAt(i);
+ final List<String> scopes = policyData.mDelegationMap.valueAt(i);
+
+ // Every "delegation" tag serializes the information of one delegate-scope pair.
+ for (String scope : scopes) {
+ out.startTag(null, "delegation");
+ out.attribute(null, "delegatePackage", delegatePackage);
+ out.attribute(null, "scope", scope);
+ out.endTag(null, "delegation");
+ }
+ }
+
+ final int n = policyData.mAdminList.size();
+ for (int i = 0; i < n; i++) {
+ ActiveAdmin ap = policyData.mAdminList.get(i);
+ if (ap != null) {
+ out.startTag(null, "admin");
+ out.attribute(null, "name", ap.info.getComponent().flattenToString());
+ ap.writeToXml(out);
+ out.endTag(null, "admin");
+ }
+ }
+
+ if (policyData.mPasswordOwner >= 0) {
+ out.startTag(null, "password-owner");
+ out.attribute(null, "value", Integer.toString(policyData.mPasswordOwner));
+ out.endTag(null, "password-owner");
+ }
+
+ if (policyData.mFailedPasswordAttempts != 0) {
+ out.startTag(null, "failed-password-attempts");
+ out.attribute(null, "value", Integer.toString(policyData.mFailedPasswordAttempts));
+ out.endTag(null, "failed-password-attempts");
+ }
+
+ // For FDE devices only, we save this flag so we can report on password sufficiency
+ // before the user enters their password for the first time after a reboot. For
+ // security reasons, we don't want to store the full set of active password metrics.
+ if (isFdeDevice) {
+ out.startTag(null, TAG_PASSWORD_VALIDITY);
+ out.attribute(null, ATTR_VALUE,
+ Boolean.toString(policyData.mPasswordValidAtLastCheckpoint));
+ out.endTag(null, TAG_PASSWORD_VALIDITY);
+ }
+
+ for (int i = 0; i < policyData.mAcceptedCaCertificates.size(); i++) {
+ out.startTag(null, TAG_ACCEPTED_CA_CERTIFICATES);
+ out.attribute(null, ATTR_NAME, policyData.mAcceptedCaCertificates.valueAt(i));
+ out.endTag(null, TAG_ACCEPTED_CA_CERTIFICATES);
+ }
+
+ for (int i = 0; i < policyData.mLockTaskPackages.size(); i++) {
+ String component = policyData.mLockTaskPackages.get(i);
+ out.startTag(null, TAG_LOCK_TASK_COMPONENTS);
+ out.attribute(null, "name", component);
+ out.endTag(null, TAG_LOCK_TASK_COMPONENTS);
+ }
+
+ if (policyData.mLockTaskFeatures != DevicePolicyManager.LOCK_TASK_FEATURE_NONE) {
+ out.startTag(null, TAG_LOCK_TASK_FEATURES);
+ out.attribute(null, ATTR_VALUE, Integer.toString(policyData.mLockTaskFeatures));
+ out.endTag(null, TAG_LOCK_TASK_FEATURES);
+ }
+
+ if (policyData.mSecondaryLockscreenEnabled) {
+ out.startTag(null, TAG_SECONDARY_LOCK_SCREEN);
+ out.attribute(null, ATTR_VALUE, Boolean.toString(true));
+ out.endTag(null, TAG_SECONDARY_LOCK_SCREEN);
+ }
+
+ if (policyData.mStatusBarDisabled) {
+ out.startTag(null, TAG_STATUS_BAR);
+ out.attribute(null, ATTR_DISABLED, Boolean.toString(policyData.mStatusBarDisabled));
+ out.endTag(null, TAG_STATUS_BAR);
+ }
+
+ if (policyData.mDoNotAskCredentialsOnBoot) {
+ out.startTag(null, TAG_DO_NOT_ASK_CREDENTIALS_ON_BOOT);
+ out.endTag(null, TAG_DO_NOT_ASK_CREDENTIALS_ON_BOOT);
+ }
+
+ for (String id : policyData.mAffiliationIds) {
+ out.startTag(null, TAG_AFFILIATION_ID);
+ out.attribute(null, ATTR_ID, id);
+ out.endTag(null, TAG_AFFILIATION_ID);
+ }
+
+ if (policyData.mLastSecurityLogRetrievalTime >= 0) {
+ out.startTag(null, TAG_LAST_SECURITY_LOG_RETRIEVAL);
+ out.attribute(null, ATTR_VALUE,
+ Long.toString(policyData.mLastSecurityLogRetrievalTime));
+ out.endTag(null, TAG_LAST_SECURITY_LOG_RETRIEVAL);
+ }
+
+ if (policyData.mLastBugReportRequestTime >= 0) {
+ out.startTag(null, TAG_LAST_BUG_REPORT_REQUEST);
+ out.attribute(null, ATTR_VALUE,
+ Long.toString(policyData.mLastBugReportRequestTime));
+ out.endTag(null, TAG_LAST_BUG_REPORT_REQUEST);
+ }
+
+ if (policyData.mLastNetworkLogsRetrievalTime >= 0) {
+ out.startTag(null, TAG_LAST_NETWORK_LOG_RETRIEVAL);
+ out.attribute(null, ATTR_VALUE,
+ Long.toString(policyData.mLastNetworkLogsRetrievalTime));
+ out.endTag(null, TAG_LAST_NETWORK_LOG_RETRIEVAL);
+ }
+
+ if (policyData.mAdminBroadcastPending) {
+ out.startTag(null, TAG_ADMIN_BROADCAST_PENDING);
+ out.attribute(null, ATTR_VALUE,
+ Boolean.toString(policyData.mAdminBroadcastPending));
+ out.endTag(null, TAG_ADMIN_BROADCAST_PENDING);
+ }
+
+ if (policyData.mInitBundle != null) {
+ out.startTag(null, TAG_INITIALIZATION_BUNDLE);
+ policyData.mInitBundle.saveToXml(out);
+ out.endTag(null, TAG_INITIALIZATION_BUNDLE);
+ }
+
+ if (policyData.mPasswordTokenHandle != 0) {
+ out.startTag(null, TAG_PASSWORD_TOKEN_HANDLE);
+ out.attribute(null, ATTR_VALUE,
+ Long.toString(policyData.mPasswordTokenHandle));
+ out.endTag(null, TAG_PASSWORD_TOKEN_HANDLE);
+ }
+
+ if (policyData.mCurrentInputMethodSet) {
+ out.startTag(null, TAG_CURRENT_INPUT_METHOD_SET);
+ out.endTag(null, TAG_CURRENT_INPUT_METHOD_SET);
+ }
+
+ for (final String cert : policyData.mOwnerInstalledCaCerts) {
+ out.startTag(null, TAG_OWNER_INSTALLED_CA_CERT);
+ out.attribute(null, ATTR_ALIAS, cert);
+ out.endTag(null, TAG_OWNER_INSTALLED_CA_CERT);
+ }
+
+ for (int i = 0, size = policyData.mUserControlDisabledPackages.size(); i < size; i++) {
+ String packageName = policyData.mUserControlDisabledPackages.get(i);
+ out.startTag(null, TAG_PROTECTED_PACKAGES);
+ out.attribute(null, ATTR_NAME, packageName);
+ out.endTag(null, TAG_PROTECTED_PACKAGES);
+ }
+
+ if (policyData.mAppsSuspended) {
+ out.startTag(null, TAG_APPS_SUSPENDED);
+ out.attribute(null, ATTR_VALUE, Boolean.toString(policyData.mAppsSuspended));
+ out.endTag(null, TAG_APPS_SUSPENDED);
+ }
+
+ out.endTag(null, "policies");
+
+ out.endDocument();
+ stream.flush();
+ FileUtils.sync(stream);
+ stream.close();
+ file.commit();
+ return true;
+ } catch (XmlPullParserException | IOException e) {
+ Slog.w(DevicePolicyManagerService.LOG_TAG, "failed writing file", e);
+ try {
+ if (stream != null) {
+ stream.close();
+ }
+ } catch (IOException ex) {
+ // Ignore
+ }
+ file.rollback();
+ return false;
+ }
+ }
+
+ /**
+ * @param adminInfoSupplier function that queries DeviceAdminInfo from PackageManager
+ * @param ownerComponent device or profile owner component if any.
+ */
+ static boolean load(DevicePolicyData policy, boolean isFdeDevice, JournaledFile journaledFile,
+ Function<ComponentName, DeviceAdminInfo> adminInfoSupplier,
+ ComponentName ownerComponent) {
+ FileInputStream stream = null;
+ File file = journaledFile.chooseForRead();
+ boolean needsRewrite = false;
+ try {
+ stream = new FileInputStream(file);
+ XmlPullParser parser = Xml.newPullParser();
+ parser.setInput(stream, StandardCharsets.UTF_8.name());
+
+ int type;
+ while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+ && type != XmlPullParser.START_TAG) {
+ }
+ String tag = parser.getName();
+ if (!"policies".equals(tag)) {
+ throw new XmlPullParserException(
+ "Settings do not start with policies tag: found " + tag);
+ }
+
+ // Extract the permission provider component name if available
+ String permissionProvider = parser.getAttributeValue(null, ATTR_PERMISSION_PROVIDER);
+ if (permissionProvider != null) {
+ policy.mRestrictionsProvider =
+ ComponentName.unflattenFromString(permissionProvider);
+ }
+ String userSetupComplete = parser.getAttributeValue(null, ATTR_SETUP_COMPLETE);
+ if (Boolean.toString(true).equals(userSetupComplete)) {
+ policy.mUserSetupComplete = true;
+ }
+ String paired = parser.getAttributeValue(null, ATTR_DEVICE_PAIRED);
+ if (Boolean.toString(true).equals(paired)) {
+ policy.mPaired = true;
+ }
+ String deviceProvisioningConfigApplied = parser.getAttributeValue(null,
+ ATTR_DEVICE_PROVISIONING_CONFIG_APPLIED);
+ if (Boolean.toString(true).equals(deviceProvisioningConfigApplied)) {
+ policy.mDeviceProvisioningConfigApplied = true;
+ }
+ String provisioningState = parser.getAttributeValue(null, ATTR_PROVISIONING_STATE);
+ if (!TextUtils.isEmpty(provisioningState)) {
+ policy.mUserProvisioningState = Integer.parseInt(provisioningState);
+ }
+ String permissionPolicy = parser.getAttributeValue(null, ATTR_PERMISSION_POLICY);
+ if (!TextUtils.isEmpty(permissionPolicy)) {
+ policy.mPermissionPolicy = Integer.parseInt(permissionPolicy);
+ }
+
+ parser.next();
+ int outerDepth = parser.getDepth();
+ policy.mLockTaskPackages.clear();
+ policy.mAdminList.clear();
+ policy.mAdminMap.clear();
+ policy.mAffiliationIds.clear();
+ policy.mOwnerInstalledCaCerts.clear();
+ policy.mUserControlDisabledPackages.clear();
+ while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+ && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
+ if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
+ continue;
+ }
+ tag = parser.getName();
+ if ("admin".equals(tag)) {
+ String name = parser.getAttributeValue(null, "name");
+ try {
+ DeviceAdminInfo dai = adminInfoSupplier.apply(
+ ComponentName.unflattenFromString(name));
+
+ if (dai != null) {
+ // b/123415062: If DA, overwrite with the stored policies that were
+ // agreed by the user to prevent apps from sneaking additional policies
+ // into updates.
+ boolean overwritePolicies = !dai.getComponent().equals(ownerComponent);
+ ActiveAdmin ap = new ActiveAdmin(dai, /* parent */ false);
+ ap.readFromXml(parser, overwritePolicies);
+ policy.mAdminMap.put(ap.info.getComponent(), ap);
+ }
+ } catch (RuntimeException e) {
+ Slog.w(DevicePolicyManagerService.LOG_TAG,
+ "Failed loading admin " + name, e);
+ }
+ } else if ("delegation".equals(tag)) {
+ // Parse delegation info.
+ final String delegatePackage = parser.getAttributeValue(null,
+ "delegatePackage");
+ final String scope = parser.getAttributeValue(null, "scope");
+
+ // Get a reference to the scopes list for the delegatePackage.
+ List<String> scopes = policy.mDelegationMap.get(delegatePackage);
+ // Or make a new list if none was found.
+ if (scopes == null) {
+ scopes = new ArrayList<>();
+ policy.mDelegationMap.put(delegatePackage, scopes);
+ }
+ // Add the new scope to the list of delegatePackage if it's not already there.
+ if (!scopes.contains(scope)) {
+ scopes.add(scope);
+ }
+ } else if ("failed-password-attempts".equals(tag)) {
+ policy.mFailedPasswordAttempts = Integer.parseInt(
+ parser.getAttributeValue(null, "value"));
+ } else if ("password-owner".equals(tag)) {
+ policy.mPasswordOwner = Integer.parseInt(
+ parser.getAttributeValue(null, "value"));
+ } else if (TAG_ACCEPTED_CA_CERTIFICATES.equals(tag)) {
+ policy.mAcceptedCaCertificates.add(parser.getAttributeValue(null, ATTR_NAME));
+ } else if (TAG_LOCK_TASK_COMPONENTS.equals(tag)) {
+ policy.mLockTaskPackages.add(parser.getAttributeValue(null, "name"));
+ } else if (TAG_LOCK_TASK_FEATURES.equals(tag)) {
+ policy.mLockTaskFeatures = Integer.parseInt(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_SECONDARY_LOCK_SCREEN.equals(tag)) {
+ policy.mSecondaryLockscreenEnabled = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_STATUS_BAR.equals(tag)) {
+ policy.mStatusBarDisabled = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_DISABLED));
+ } else if (TAG_DO_NOT_ASK_CREDENTIALS_ON_BOOT.equals(tag)) {
+ policy.mDoNotAskCredentialsOnBoot = true;
+ } else if (TAG_AFFILIATION_ID.equals(tag)) {
+ policy.mAffiliationIds.add(parser.getAttributeValue(null, ATTR_ID));
+ } else if (TAG_LAST_SECURITY_LOG_RETRIEVAL.equals(tag)) {
+ policy.mLastSecurityLogRetrievalTime = Long.parseLong(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_LAST_BUG_REPORT_REQUEST.equals(tag)) {
+ policy.mLastBugReportRequestTime = Long.parseLong(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_LAST_NETWORK_LOG_RETRIEVAL.equals(tag)) {
+ policy.mLastNetworkLogsRetrievalTime = Long.parseLong(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_ADMIN_BROADCAST_PENDING.equals(tag)) {
+ String pending = parser.getAttributeValue(null, ATTR_VALUE);
+ policy.mAdminBroadcastPending = Boolean.toString(true).equals(pending);
+ } else if (TAG_INITIALIZATION_BUNDLE.equals(tag)) {
+ policy.mInitBundle = PersistableBundle.restoreFromXml(parser);
+ } else if ("active-password".equals(tag)) {
+ // Remove password metrics from saved settings, as we no longer wish to store
+ // these on disk
+ needsRewrite = true;
+ } else if (TAG_PASSWORD_VALIDITY.equals(tag)) {
+ if (isFdeDevice) {
+ // This flag is only used for FDE devices
+ policy.mPasswordValidAtLastCheckpoint = Boolean.parseBoolean(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ }
+ } else if (TAG_PASSWORD_TOKEN_HANDLE.equals(tag)) {
+ policy.mPasswordTokenHandle = Long.parseLong(
+ parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_CURRENT_INPUT_METHOD_SET.equals(tag)) {
+ policy.mCurrentInputMethodSet = true;
+ } else if (TAG_OWNER_INSTALLED_CA_CERT.equals(tag)) {
+ policy.mOwnerInstalledCaCerts.add(parser.getAttributeValue(null, ATTR_ALIAS));
+ } else if (TAG_PROTECTED_PACKAGES.equals(tag)) {
+ policy.mUserControlDisabledPackages.add(
+ parser.getAttributeValue(null, ATTR_NAME));
+ } else if (TAG_APPS_SUSPENDED.equals(tag)) {
+ policy.mAppsSuspended =
+ Boolean.parseBoolean(parser.getAttributeValue(null, ATTR_VALUE));
+ } else {
+ Slog.w(DevicePolicyManagerService.LOG_TAG, "Unknown tag: " + tag);
+ XmlUtils.skipCurrentTag(parser);
+ }
+ }
+ } catch (FileNotFoundException e) {
+ // Don't be noisy, this is normal if we haven't defined any policies.
+ } catch (NullPointerException | NumberFormatException | XmlPullParserException | IOException
+ | IndexOutOfBoundsException e) {
+ Slog.w(DevicePolicyManagerService.LOG_TAG, "failed parsing " + file, e);
+ }
+ try {
+ if (stream != null) {
+ stream.close();
+ }
+ } catch (IOException e) {
+ // Ignore
+ }
+
+ // Generate a list of admins from the admin map
+ policy.mAdminList.addAll(policy.mAdminMap.values());
+ return needsRewrite;
+ }
+
+ void validatePasswordOwner() {
+ if (mPasswordOwner >= 0) {
+ boolean haveOwner = false;
+ for (int i = mAdminList.size() - 1; i >= 0; i--) {
+ if (mAdminList.get(i).getUid() == mPasswordOwner) {
+ haveOwner = true;
+ break;
+ }
+ }
+ if (!haveOwner) {
+ Slog.w(DevicePolicyManagerService.LOG_TAG, "Previous password owner "
+ + mPasswordOwner + " no longer active; disabling");
+ mPasswordOwner = -1;
+ }
+ }
+ }
+}
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 9a2bef8..cafd56e 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -106,10 +106,6 @@
import static com.android.server.devicepolicy.TransferOwnershipMetadataManager.ADMIN_TYPE_PROFILE_OWNER;
import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
-import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
-import static org.xmlpull.v1.XmlPullParser.END_TAG;
-import static org.xmlpull.v1.XmlPullParser.TEXT;
-
import android.Manifest.permission;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.accounts.Account;
@@ -189,7 +185,6 @@
import android.database.ContentObserver;
import android.database.Cursor;
import android.graphics.Bitmap;
-import android.graphics.Color;
import android.location.LocationManager;
import android.media.AudioManager;
import android.media.IAudioService;
@@ -204,7 +199,6 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
-import android.os.FileUtils;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
@@ -248,7 +242,6 @@
import android.telephony.data.ApnSetting;
import android.text.TextUtils;
import android.text.format.DateUtils;
-import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.AtomicFile;
import android.util.Log;
@@ -280,7 +273,6 @@
import com.android.internal.util.JournaledFile;
import com.android.internal.util.Preconditions;
import com.android.internal.util.StatLogger;
-import com.android.internal.util.XmlUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockSettingsInternal;
import com.android.internal.widget.LockscreenCredential;
@@ -290,8 +282,7 @@
import com.android.server.PersistentDataBlockManagerInternal;
import com.android.server.SystemServerInitThreadPool;
import com.android.server.SystemService;
-import com.android.server.SystemService.TargetUser;
-import com.android.server.devicepolicy.DevicePolicyManagerService.ActiveAdmin.TrustAgentInfo;
+import com.android.server.devicepolicy.ActiveAdmin.TrustAgentInfo;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.net.NetworkPolicyManagerInternal;
import com.android.server.pm.RestrictionsSet;
@@ -328,7 +319,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -350,55 +340,8 @@
private static final String TRANSFER_OWNERSHIP_PARAMETERS_XML =
"transfer-ownership-parameters.xml";
- private static final String TAG_ACCEPTED_CA_CERTIFICATES = "accepted-ca-certificate";
-
- private static final String TAG_LOCK_TASK_COMPONENTS = "lock-task-component";
-
- private static final String TAG_LOCK_TASK_FEATURES = "lock-task-features";
-
- private static final String TAG_STATUS_BAR = "statusbar";
-
- private static final String ATTR_DISABLED = "disabled";
-
- private static final String ATTR_NAME = "name";
-
- private static final String DO_NOT_ASK_CREDENTIALS_ON_BOOT_XML =
- "do-not-ask-credentials-on-boot";
-
- private static final String TAG_AFFILIATION_ID = "affiliation-id";
-
- private static final String TAG_LAST_SECURITY_LOG_RETRIEVAL = "last-security-log-retrieval";
-
- private static final String TAG_LAST_BUG_REPORT_REQUEST = "last-bug-report-request";
-
- private static final String TAG_LAST_NETWORK_LOG_RETRIEVAL = "last-network-log-retrieval";
-
- private static final String TAG_ADMIN_BROADCAST_PENDING = "admin-broadcast-pending";
-
- private static final String TAG_CURRENT_INPUT_METHOD_SET = "current-ime-set";
-
- private static final String TAG_OWNER_INSTALLED_CA_CERT = "owner-installed-ca-cert";
-
- private static final String ATTR_ID = "id";
-
- private static final String ATTR_VALUE = "value";
-
- private static final String ATTR_ALIAS = "alias";
-
- private static final String TAG_INITIALIZATION_BUNDLE = "initialization-bundle";
-
- private static final String TAG_PASSWORD_TOKEN_HANDLE = "password-token";
-
- private static final String TAG_PASSWORD_VALIDITY = "password-validity";
-
private static final String TAG_TRANSFER_OWNERSHIP_BUNDLE = "transfer-ownership-bundle";
- private static final String TAG_PROTECTED_PACKAGES = "protected-packages";
-
- private static final String TAG_SECONDARY_LOCK_SCREEN = "secondary-lock-screen";
-
- private static final String TAG_APPS_SUSPENDED = "apps-suspended";
-
private static final int REQUEST_EXPIRE_PASSWORD = 5571;
private static final int REQUEST_PROFILE_OFF_DEADLINE = 5572;
@@ -423,17 +366,6 @@
static final String ACTION_PROFILE_OFF_DEADLINE =
"com.android.server.ACTION_PROFILE_OFF_DEADLINE";
- private static final String ATTR_PERMISSION_PROVIDER = "permission-provider";
- private static final String ATTR_SETUP_COMPLETE = "setup-complete";
- private static final String ATTR_PROVISIONING_STATE = "provisioning-state";
- private static final String ATTR_PERMISSION_POLICY = "permission-policy";
- private static final String ATTR_DEVICE_PROVISIONING_CONFIG_APPLIED =
- "device-provisioning-config-applied";
- private static final String ATTR_DEVICE_PAIRED = "device-paired";
- private static final String ATTR_DELEGATED_CERT_INSTALLER = "delegated-cert-installer";
- private static final String ATTR_APPLICATION_RESTRICTIONS_MANAGER
- = "application-restrictions-manager";
-
private static final String CALLED_FROM_PARENT = "calledFromParent";
private static final String NOT_CALLED_FROM_PARENT = "notCalledFromParent";
@@ -488,7 +420,6 @@
private static final Set<String> SYSTEM_SETTINGS_WHITELIST;
private static final Set<Integer> DA_DISALLOWED_POLICIES;
// A collection of user restrictions that are deprecated and should simply be ignored.
- private static final Set<String> DEPRECATED_USER_RESTRICTIONS;
private static final String AB_DEVICE_KEY = "ro.build.ab_update";
static {
@@ -532,10 +463,6 @@
DA_DISALLOWED_POLICIES.add(DeviceAdminInfo.USES_POLICY_DISABLE_KEYGUARD_FEATURES);
DA_DISALLOWED_POLICIES.add(DeviceAdminInfo.USES_POLICY_EXPIRE_PASSWORD);
DA_DISALLOWED_POLICIES.add(DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD);
-
- DEPRECATED_USER_RESTRICTIONS = Sets.newHashSet(
- UserManager.DISALLOW_ADD_MANAGED_PROFILE,
- UserManager.DISALLOW_REMOVE_MANAGED_PROFILE);
}
/**
@@ -791,76 +718,6 @@
}
}
- public static class DevicePolicyData {
- int mFailedPasswordAttempts = 0;
- boolean mPasswordValidAtLastCheckpoint = true;
-
- int mUserHandle;
- int mPasswordOwner = -1;
- long mLastMaximumTimeToLock = -1;
- boolean mUserSetupComplete = false;
- boolean mPaired = false;
- int mUserProvisioningState;
- int mPermissionPolicy;
-
- boolean mDeviceProvisioningConfigApplied = false;
-
- final ArrayMap<ComponentName, ActiveAdmin> mAdminMap = new ArrayMap<>();
- final ArrayList<ActiveAdmin> mAdminList = new ArrayList<>();
- final ArrayList<ComponentName> mRemovingAdmins = new ArrayList<>();
-
- // TODO(b/35385311): Keep track of metadata in TrustedCertificateStore instead.
- final ArraySet<String> mAcceptedCaCertificates = new ArraySet<>();
-
- // This is the list of component allowed to start lock task mode.
- List<String> mLockTaskPackages = new ArrayList<>();
-
- // List of packages protected by device owner
- List<String> mUserControlDisabledPackages = new ArrayList<>();
-
- // Bitfield of feature flags to be enabled during LockTask mode.
- // We default on the power button menu, in order to be consistent with pre-P behaviour.
- int mLockTaskFeatures = DevicePolicyManager.LOCK_TASK_FEATURE_GLOBAL_ACTIONS;
-
- boolean mStatusBarDisabled = false;
-
- ComponentName mRestrictionsProvider;
-
- // Map of delegate package to delegation scopes
- final ArrayMap<String, List<String>> mDelegationMap = new ArrayMap<>();
-
- boolean doNotAskCredentialsOnBoot = false;
-
- Set<String> mAffiliationIds = new ArraySet<>();
-
- long mLastSecurityLogRetrievalTime = -1;
-
- long mLastBugReportRequestTime = -1;
-
- long mLastNetworkLogsRetrievalTime = -1;
-
- boolean mCurrentInputMethodSet = false;
-
- boolean mSecondaryLockscreenEnabled = false;
-
- // TODO(b/35385311): Keep track of metadata in TrustedCertificateStore instead.
- Set<String> mOwnerInstalledCaCerts = new ArraySet<>();
-
- // Used for initialization of users created by createAndManageUser.
- boolean mAdminBroadcastPending = false;
- PersistableBundle mInitBundle = null;
-
- long mPasswordTokenHandle = 0;
-
- // Whether user's apps are suspended. This flag should only be written AFTER all the needed
- // apps were suspended or unsuspended.
- boolean mAppsSuspended = false;
-
- public DevicePolicyData(int userHandle) {
- mUserHandle = userHandle;
- }
- }
-
@GuardedBy("getLockObject()")
final SparseArray<DevicePolicyData> mUserData = new SparseArray<>();
@@ -1045,1002 +902,6 @@
}
}
- static class ActiveAdmin {
- private static final String TAG_DISABLE_KEYGUARD_FEATURES = "disable-keyguard-features";
- private static final String TAG_TEST_ONLY_ADMIN = "test-only-admin";
- private static final String TAG_DISABLE_CAMERA = "disable-camera";
- private static final String TAG_DISABLE_CALLER_ID = "disable-caller-id";
- private static final String TAG_DISABLE_CONTACTS_SEARCH = "disable-contacts-search";
- private static final String TAG_DISABLE_BLUETOOTH_CONTACT_SHARING
- = "disable-bt-contacts-sharing";
- private static final String TAG_DISABLE_SCREEN_CAPTURE = "disable-screen-capture";
- private static final String TAG_DISABLE_ACCOUNT_MANAGEMENT = "disable-account-management";
- private static final String TAG_REQUIRE_AUTO_TIME = "require_auto_time";
- private static final String TAG_FORCE_EPHEMERAL_USERS = "force_ephemeral_users";
- private static final String TAG_IS_NETWORK_LOGGING_ENABLED = "is_network_logging_enabled";
- private static final String TAG_ACCOUNT_TYPE = "account-type";
- private static final String TAG_PERMITTED_ACCESSIBILITY_SERVICES
- = "permitted-accessiblity-services";
- private static final String TAG_ENCRYPTION_REQUESTED = "encryption-requested";
- private static final String TAG_MANAGE_TRUST_AGENT_FEATURES = "manage-trust-agent-features";
- private static final String TAG_TRUST_AGENT_COMPONENT_OPTIONS = "trust-agent-component-options";
- private static final String TAG_TRUST_AGENT_COMPONENT = "component";
- private static final String TAG_PASSWORD_EXPIRATION_DATE = "password-expiration-date";
- private static final String TAG_PASSWORD_EXPIRATION_TIMEOUT = "password-expiration-timeout";
- private static final String TAG_GLOBAL_PROXY_EXCLUSION_LIST = "global-proxy-exclusion-list";
- private static final String TAG_GLOBAL_PROXY_SPEC = "global-proxy-spec";
- private static final String TAG_SPECIFIES_GLOBAL_PROXY = "specifies-global-proxy";
- private static final String TAG_PERMITTED_IMES = "permitted-imes";
- private static final String TAG_PERMITTED_NOTIFICATION_LISTENERS =
- "permitted-notification-listeners";
- private static final String TAG_MAX_FAILED_PASSWORD_WIPE = "max-failed-password-wipe";
- private static final String TAG_MAX_TIME_TO_UNLOCK = "max-time-to-unlock";
- private static final String TAG_STRONG_AUTH_UNLOCK_TIMEOUT = "strong-auth-unlock-timeout";
- private static final String TAG_MIN_PASSWORD_NONLETTER = "min-password-nonletter";
- private static final String TAG_MIN_PASSWORD_SYMBOLS = "min-password-symbols";
- private static final String TAG_MIN_PASSWORD_NUMERIC = "min-password-numeric";
- private static final String TAG_MIN_PASSWORD_LETTERS = "min-password-letters";
- private static final String TAG_MIN_PASSWORD_LOWERCASE = "min-password-lowercase";
- private static final String TAG_MIN_PASSWORD_UPPERCASE = "min-password-uppercase";
- private static final String TAG_PASSWORD_HISTORY_LENGTH = "password-history-length";
- private static final String TAG_MIN_PASSWORD_LENGTH = "min-password-length";
- private static final String ATTR_VALUE = "value";
- private static final String TAG_PASSWORD_QUALITY = "password-quality";
- private static final String TAG_POLICIES = "policies";
- private static final String TAG_CROSS_PROFILE_WIDGET_PROVIDERS =
- "cross-profile-widget-providers";
- private static final String TAG_PROVIDER = "provider";
- private static final String TAG_PACKAGE_LIST_ITEM = "item";
- private static final String TAG_KEEP_UNINSTALLED_PACKAGES = "keep-uninstalled-packages";
- private static final String TAG_USER_RESTRICTIONS = "user-restrictions";
- private static final String TAG_DEFAULT_ENABLED_USER_RESTRICTIONS =
- "default-enabled-user-restrictions";
- private static final String TAG_RESTRICTION = "restriction";
- private static final String TAG_SHORT_SUPPORT_MESSAGE = "short-support-message";
- private static final String TAG_LONG_SUPPORT_MESSAGE = "long-support-message";
- private static final String TAG_PARENT_ADMIN = "parent-admin";
- private static final String TAG_ORGANIZATION_COLOR = "organization-color";
- private static final String TAG_ORGANIZATION_NAME = "organization-name";
- private static final String ATTR_LAST_NETWORK_LOGGING_NOTIFICATION = "last-notification";
- private static final String ATTR_NUM_NETWORK_LOGGING_NOTIFICATIONS = "num-notifications";
- private static final String TAG_IS_LOGOUT_ENABLED = "is_logout_enabled";
- private static final String TAG_START_USER_SESSION_MESSAGE = "start_user_session_message";
- private static final String TAG_END_USER_SESSION_MESSAGE = "end_user_session_message";
- private static final String TAG_METERED_DATA_DISABLED_PACKAGES =
- "metered_data_disabled_packages";
- private static final String TAG_CROSS_PROFILE_CALENDAR_PACKAGES =
- "cross-profile-calendar-packages";
- private static final String TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL =
- "cross-profile-calendar-packages-null";
- private static final String TAG_CROSS_PROFILE_PACKAGES = "cross-profile-packages";
- private static final String TAG_FACTORY_RESET_PROTECTION_POLICY =
- "factory_reset_protection_policy";
- private static final String TAG_SUSPEND_PERSONAL_APPS = "suspend-personal-apps";
- private static final String TAG_PROFILE_MAXIMUM_TIME_OFF = "profile-max-time-off";
- private static final String TAG_PROFILE_OFF_DEADLINE = "profile-off-deadline";
- private static final String TAG_ALWAYS_ON_VPN_PACKAGE = "vpn-package";
- private static final String TAG_ALWAYS_ON_VPN_LOCKDOWN = "vpn-lockdown";
- private static final String TAG_COMMON_CRITERIA_MODE = "common-criteria-mode";
- DeviceAdminInfo info;
-
-
- static final int DEF_PASSWORD_HISTORY_LENGTH = 0;
- int passwordHistoryLength = DEF_PASSWORD_HISTORY_LENGTH;
-
- @NonNull
- PasswordPolicy mPasswordPolicy = new PasswordPolicy();
-
- @Nullable
- FactoryResetProtectionPolicy mFactoryResetProtectionPolicy = null;
-
- static final long DEF_MAXIMUM_TIME_TO_UNLOCK = 0;
- long maximumTimeToUnlock = DEF_MAXIMUM_TIME_TO_UNLOCK;
-
- long strongAuthUnlockTimeout = 0; // admin doesn't participate by default
-
- static final int DEF_MAXIMUM_FAILED_PASSWORDS_FOR_WIPE = 0;
- int maximumFailedPasswordsForWipe = DEF_MAXIMUM_FAILED_PASSWORDS_FOR_WIPE;
-
- static final long DEF_PASSWORD_EXPIRATION_TIMEOUT = 0;
- long passwordExpirationTimeout = DEF_PASSWORD_EXPIRATION_TIMEOUT;
-
- static final long DEF_PASSWORD_EXPIRATION_DATE = 0;
- long passwordExpirationDate = DEF_PASSWORD_EXPIRATION_DATE;
-
- static final int DEF_KEYGUARD_FEATURES_DISABLED = 0; // none
-
- int disabledKeyguardFeatures = DEF_KEYGUARD_FEATURES_DISABLED;
-
- boolean encryptionRequested = false;
- boolean testOnlyAdmin = false;
- boolean disableCamera = false;
- boolean disableCallerId = false;
- boolean disableContactsSearch = false;
- boolean disableBluetoothContactSharing = true;
- boolean disableScreenCapture = false; // Can only be set by a device/profile owner.
- boolean requireAutoTime = false; // Can only be set by a device owner.
- boolean forceEphemeralUsers = false; // Can only be set by a device owner.
- boolean isNetworkLoggingEnabled = false; // Can only be set by a device owner.
- boolean isLogoutEnabled = false; // Can only be set by a device owner.
-
- // one notification after enabling + one more after reboots
- static final int DEF_MAXIMUM_NETWORK_LOGGING_NOTIFICATIONS_SHOWN = 2;
- int numNetworkLoggingNotifications = 0;
- long lastNetworkLoggingNotificationTimeMs = 0; // Time in milliseconds since epoch
-
- ActiveAdmin parentAdmin;
- final boolean isParent;
-
- static class TrustAgentInfo {
- public PersistableBundle options;
- TrustAgentInfo(PersistableBundle bundle) {
- options = bundle;
- }
- }
-
- // The list of packages which are not allowed to use metered data.
- List<String> meteredDisabledPackages;
-
- final Set<String> accountTypesWithManagementDisabled = new ArraySet<>();
-
- // The list of permitted accessibility services package namesas set by a profile
- // or device owner. Null means all accessibility services are allowed, empty means
- // none except system services are allowed.
- List<String> permittedAccessiblityServices;
-
- // The list of permitted input methods package names as set by a profile or device owner.
- // Null means all input methods are allowed, empty means none except system imes are
- // allowed.
- List<String> permittedInputMethods;
-
- // The list of packages allowed to use a NotificationListenerService to receive events for
- // notifications from this user. Null means that all packages are allowed. Empty list means
- // that only packages from the system are allowed.
- List<String> permittedNotificationListeners;
-
- // List of package names to keep cached.
- List<String> keepUninstalledPackages;
-
- // TODO: review implementation decisions with frameworks team
- boolean specifiesGlobalProxy = false;
- String globalProxySpec = null;
- String globalProxyExclusionList = null;
-
- @NonNull ArrayMap<String, TrustAgentInfo> trustAgentInfos = new ArrayMap<>();
-
- List<String> crossProfileWidgetProviders;
-
- Bundle userRestrictions;
-
- // User restrictions that have already been enabled by default for this admin (either when
- // setting the device or profile owner, or during a system update if one of those "enabled
- // by default" restrictions is newly added).
- final Set<String> defaultEnabledRestrictionsAlreadySet = new ArraySet<>();
-
- // Support text provided by the admin to display to the user.
- CharSequence shortSupportMessage = null;
- CharSequence longSupportMessage = null;
-
- // Background color of confirm credentials screen. Default: teal.
- static final int DEF_ORGANIZATION_COLOR = Color.parseColor("#00796B");
- int organizationColor = DEF_ORGANIZATION_COLOR;
-
- // Default title of confirm credentials screen
- String organizationName = null;
-
- // Message for user switcher
- String startUserSessionMessage = null;
- String endUserSessionMessage = null;
-
- // The whitelist of packages that can access cross profile calendar APIs.
- // This whitelist should be in default an empty list, which indicates that no package
- // is whitelisted.
- List<String> mCrossProfileCalendarPackages = Collections.emptyList();
-
- // The whitelist of packages that the admin has enabled to be able to request consent from
- // the user to communicate cross-profile. By default, no packages are whitelisted, which is
- // represented as an empty list.
- List<String> mCrossProfilePackages = Collections.emptyList();
-
- // Whether the admin explicitly requires personal apps to be suspended
- boolean mSuspendPersonalApps = false;
- // Maximum time the profile owned by this admin can be off.
- long mProfileMaximumTimeOffMillis = 0;
- // Time by which the profile should be turned on according to System.currentTimeMillis().
- long mProfileOffDeadline = 0;
-
- public String mAlwaysOnVpnPackage;
- public boolean mAlwaysOnVpnLockdown;
- boolean mCommonCriteriaMode;
-
- ActiveAdmin(DeviceAdminInfo _info, boolean parent) {
- info = _info;
- isParent = parent;
- }
-
- ActiveAdmin getParentActiveAdmin() {
- Preconditions.checkState(!isParent);
-
- if (parentAdmin == null) {
- parentAdmin = new ActiveAdmin(info, /* parent */ true);
- }
- return parentAdmin;
- }
-
- boolean hasParentActiveAdmin() {
- return parentAdmin != null;
- }
-
- int getUid() { return info.getActivityInfo().applicationInfo.uid; }
-
- public UserHandle getUserHandle() {
- return UserHandle.of(UserHandle.getUserId(info.getActivityInfo().applicationInfo.uid));
- }
-
- void writeToXml(XmlSerializer out)
- throws IllegalArgumentException, IllegalStateException, IOException {
- out.startTag(null, TAG_POLICIES);
- info.writePoliciesToXml(out);
- out.endTag(null, TAG_POLICIES);
- if (mPasswordPolicy.quality != PASSWORD_QUALITY_UNSPECIFIED) {
- writeAttributeValueToXml(
- out, TAG_PASSWORD_QUALITY, mPasswordPolicy.quality);
- if (mPasswordPolicy.length != PasswordPolicy.DEF_MINIMUM_LENGTH) {
- writeAttributeValueToXml(
- out, TAG_MIN_PASSWORD_LENGTH, mPasswordPolicy.length);
- }
- if (mPasswordPolicy.upperCase != PasswordPolicy.DEF_MINIMUM_UPPER_CASE) {
- writeAttributeValueToXml(
- out, TAG_MIN_PASSWORD_UPPERCASE, mPasswordPolicy.upperCase);
- }
- if (mPasswordPolicy.lowerCase != PasswordPolicy.DEF_MINIMUM_LOWER_CASE) {
- writeAttributeValueToXml(
- out, TAG_MIN_PASSWORD_LOWERCASE, mPasswordPolicy.lowerCase);
- }
- if (mPasswordPolicy.letters != PasswordPolicy.DEF_MINIMUM_LETTERS) {
- writeAttributeValueToXml(
- out, TAG_MIN_PASSWORD_LETTERS, mPasswordPolicy.letters);
- }
- if (mPasswordPolicy.numeric != PasswordPolicy.DEF_MINIMUM_NUMERIC) {
- writeAttributeValueToXml(
- out, TAG_MIN_PASSWORD_NUMERIC, mPasswordPolicy.numeric);
- }
- if (mPasswordPolicy.symbols != PasswordPolicy.DEF_MINIMUM_SYMBOLS) {
- writeAttributeValueToXml(
- out, TAG_MIN_PASSWORD_SYMBOLS, mPasswordPolicy.symbols);
- }
- if (mPasswordPolicy.nonLetter > PasswordPolicy.DEF_MINIMUM_NON_LETTER) {
- writeAttributeValueToXml(
- out, TAG_MIN_PASSWORD_NONLETTER, mPasswordPolicy.nonLetter);
- }
- }
- if (passwordHistoryLength != DEF_PASSWORD_HISTORY_LENGTH) {
- writeAttributeValueToXml(
- out, TAG_PASSWORD_HISTORY_LENGTH, passwordHistoryLength);
- }
- if (maximumTimeToUnlock != DEF_MAXIMUM_TIME_TO_UNLOCK) {
- writeAttributeValueToXml(
- out, TAG_MAX_TIME_TO_UNLOCK, maximumTimeToUnlock);
- }
- if (strongAuthUnlockTimeout != DevicePolicyManager.DEFAULT_STRONG_AUTH_TIMEOUT_MS) {
- writeAttributeValueToXml(
- out, TAG_STRONG_AUTH_UNLOCK_TIMEOUT, strongAuthUnlockTimeout);
- }
- if (maximumFailedPasswordsForWipe != DEF_MAXIMUM_FAILED_PASSWORDS_FOR_WIPE) {
- writeAttributeValueToXml(
- out, TAG_MAX_FAILED_PASSWORD_WIPE, maximumFailedPasswordsForWipe);
- }
- if (specifiesGlobalProxy) {
- writeAttributeValueToXml(
- out, TAG_SPECIFIES_GLOBAL_PROXY, specifiesGlobalProxy);
- if (globalProxySpec != null) {
- writeAttributeValueToXml(out, TAG_GLOBAL_PROXY_SPEC, globalProxySpec);
- }
- if (globalProxyExclusionList != null) {
- writeAttributeValueToXml(
- out, TAG_GLOBAL_PROXY_EXCLUSION_LIST, globalProxyExclusionList);
- }
- }
- if (passwordExpirationTimeout != DEF_PASSWORD_EXPIRATION_TIMEOUT) {
- writeAttributeValueToXml(
- out, TAG_PASSWORD_EXPIRATION_TIMEOUT, passwordExpirationTimeout);
- }
- if (passwordExpirationDate != DEF_PASSWORD_EXPIRATION_DATE) {
- writeAttributeValueToXml(
- out, TAG_PASSWORD_EXPIRATION_DATE, passwordExpirationDate);
- }
- if (encryptionRequested) {
- writeAttributeValueToXml(
- out, TAG_ENCRYPTION_REQUESTED, encryptionRequested);
- }
- if (testOnlyAdmin) {
- writeAttributeValueToXml(
- out, TAG_TEST_ONLY_ADMIN, testOnlyAdmin);
- }
- if (disableCamera) {
- writeAttributeValueToXml(
- out, TAG_DISABLE_CAMERA, disableCamera);
- }
- if (disableCallerId) {
- writeAttributeValueToXml(
- out, TAG_DISABLE_CALLER_ID, disableCallerId);
- }
- if (disableContactsSearch) {
- writeAttributeValueToXml(
- out, TAG_DISABLE_CONTACTS_SEARCH, disableContactsSearch);
- }
- if (!disableBluetoothContactSharing) {
- writeAttributeValueToXml(
- out, TAG_DISABLE_BLUETOOTH_CONTACT_SHARING, disableBluetoothContactSharing);
- }
- if (disableScreenCapture) {
- writeAttributeValueToXml(
- out, TAG_DISABLE_SCREEN_CAPTURE, disableScreenCapture);
- }
- if (requireAutoTime) {
- writeAttributeValueToXml(
- out, TAG_REQUIRE_AUTO_TIME, requireAutoTime);
- }
- if (forceEphemeralUsers) {
- writeAttributeValueToXml(
- out, TAG_FORCE_EPHEMERAL_USERS, forceEphemeralUsers);
- }
- if (isNetworkLoggingEnabled) {
- out.startTag(null, TAG_IS_NETWORK_LOGGING_ENABLED);
- out.attribute(null, ATTR_VALUE, Boolean.toString(isNetworkLoggingEnabled));
- out.attribute(null, ATTR_NUM_NETWORK_LOGGING_NOTIFICATIONS,
- Integer.toString(numNetworkLoggingNotifications));
- out.attribute(null, ATTR_LAST_NETWORK_LOGGING_NOTIFICATION,
- Long.toString(lastNetworkLoggingNotificationTimeMs));
- out.endTag(null, TAG_IS_NETWORK_LOGGING_ENABLED);
- }
- if (disabledKeyguardFeatures != DEF_KEYGUARD_FEATURES_DISABLED) {
- writeAttributeValueToXml(
- out, TAG_DISABLE_KEYGUARD_FEATURES, disabledKeyguardFeatures);
- }
- if (!accountTypesWithManagementDisabled.isEmpty()) {
- writeAttributeValuesToXml(
- out, TAG_DISABLE_ACCOUNT_MANAGEMENT, TAG_ACCOUNT_TYPE,
- accountTypesWithManagementDisabled);
- }
- if (!trustAgentInfos.isEmpty()) {
- Set<Entry<String, TrustAgentInfo>> set = trustAgentInfos.entrySet();
- out.startTag(null, TAG_MANAGE_TRUST_AGENT_FEATURES);
- for (Entry<String, TrustAgentInfo> entry : set) {
- TrustAgentInfo trustAgentInfo = entry.getValue();
- out.startTag(null, TAG_TRUST_AGENT_COMPONENT);
- out.attribute(null, ATTR_VALUE, entry.getKey());
- if (trustAgentInfo.options != null) {
- out.startTag(null, TAG_TRUST_AGENT_COMPONENT_OPTIONS);
- try {
- trustAgentInfo.options.saveToXml(out);
- } catch (XmlPullParserException e) {
- Log.e(LOG_TAG, "Failed to save TrustAgent options", e);
- }
- out.endTag(null, TAG_TRUST_AGENT_COMPONENT_OPTIONS);
- }
- out.endTag(null, TAG_TRUST_AGENT_COMPONENT);
- }
- out.endTag(null, TAG_MANAGE_TRUST_AGENT_FEATURES);
- }
- if (crossProfileWidgetProviders != null && !crossProfileWidgetProviders.isEmpty()) {
- writeAttributeValuesToXml(
- out, TAG_CROSS_PROFILE_WIDGET_PROVIDERS, TAG_PROVIDER,
- crossProfileWidgetProviders);
- }
- writePackageListToXml(out, TAG_PERMITTED_ACCESSIBILITY_SERVICES,
- permittedAccessiblityServices);
- writePackageListToXml(out, TAG_PERMITTED_IMES, permittedInputMethods);
- writePackageListToXml(out, TAG_PERMITTED_NOTIFICATION_LISTENERS,
- permittedNotificationListeners);
- writePackageListToXml(out, TAG_KEEP_UNINSTALLED_PACKAGES, keepUninstalledPackages);
- writePackageListToXml(out, TAG_METERED_DATA_DISABLED_PACKAGES, meteredDisabledPackages);
- if (hasUserRestrictions()) {
- UserRestrictionsUtils.writeRestrictions(
- out, userRestrictions, TAG_USER_RESTRICTIONS);
- }
- if (!defaultEnabledRestrictionsAlreadySet.isEmpty()) {
- writeAttributeValuesToXml(out, TAG_DEFAULT_ENABLED_USER_RESTRICTIONS,
- TAG_RESTRICTION,
- defaultEnabledRestrictionsAlreadySet);
- }
- if (!TextUtils.isEmpty(shortSupportMessage)) {
- writeTextToXml(out, TAG_SHORT_SUPPORT_MESSAGE, shortSupportMessage.toString());
- }
- if (!TextUtils.isEmpty(longSupportMessage)) {
- writeTextToXml(out, TAG_LONG_SUPPORT_MESSAGE, longSupportMessage.toString());
- }
- if (parentAdmin != null) {
- out.startTag(null, TAG_PARENT_ADMIN);
- parentAdmin.writeToXml(out);
- out.endTag(null, TAG_PARENT_ADMIN);
- }
- if (organizationColor != DEF_ORGANIZATION_COLOR) {
- writeAttributeValueToXml(out, TAG_ORGANIZATION_COLOR, organizationColor);
- }
- if (organizationName != null) {
- writeTextToXml(out, TAG_ORGANIZATION_NAME, organizationName);
- }
- if (isLogoutEnabled) {
- writeAttributeValueToXml(out, TAG_IS_LOGOUT_ENABLED, isLogoutEnabled);
- }
- if (startUserSessionMessage != null) {
- writeTextToXml(out, TAG_START_USER_SESSION_MESSAGE, startUserSessionMessage);
- }
- if (endUserSessionMessage != null) {
- writeTextToXml(out, TAG_END_USER_SESSION_MESSAGE, endUserSessionMessage);
- }
- if (mCrossProfileCalendarPackages == null) {
- out.startTag(null, TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL);
- out.endTag(null, TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL);
- } else {
- writePackageListToXml(out, TAG_CROSS_PROFILE_CALENDAR_PACKAGES,
- mCrossProfileCalendarPackages);
- }
- writePackageListToXml(out, TAG_CROSS_PROFILE_PACKAGES, mCrossProfilePackages);
- if (mFactoryResetProtectionPolicy != null) {
- out.startTag(null, TAG_FACTORY_RESET_PROTECTION_POLICY);
- mFactoryResetProtectionPolicy.writeToXml(out);
- out.endTag(null, TAG_FACTORY_RESET_PROTECTION_POLICY);
- }
- if (mSuspendPersonalApps) {
- writeAttributeValueToXml(out, TAG_SUSPEND_PERSONAL_APPS, mSuspendPersonalApps);
- }
- if (mProfileMaximumTimeOffMillis != 0) {
- writeAttributeValueToXml(out, TAG_PROFILE_MAXIMUM_TIME_OFF,
- mProfileMaximumTimeOffMillis);
- }
- if (mProfileMaximumTimeOffMillis != 0) {
- writeAttributeValueToXml(out, TAG_PROFILE_OFF_DEADLINE, mProfileOffDeadline);
- }
- if (!TextUtils.isEmpty(mAlwaysOnVpnPackage)) {
- writeAttributeValueToXml(out, TAG_ALWAYS_ON_VPN_PACKAGE, mAlwaysOnVpnPackage);
- }
- if (mAlwaysOnVpnLockdown) {
- writeAttributeValueToXml(out, TAG_ALWAYS_ON_VPN_LOCKDOWN, mAlwaysOnVpnLockdown);
- }
- if (mCommonCriteriaMode) {
- writeAttributeValueToXml(out, TAG_COMMON_CRITERIA_MODE, mCommonCriteriaMode);
- }
- }
-
- void writeTextToXml(XmlSerializer out, String tag, String text) throws IOException {
- out.startTag(null, tag);
- out.text(text);
- out.endTag(null, tag);
- }
-
- void writePackageListToXml(XmlSerializer out, String outerTag,
- List<String> packageList)
- throws IllegalArgumentException, IllegalStateException, IOException {
- if (packageList == null) {
- return;
- }
- writeAttributeValuesToXml(out, outerTag, TAG_PACKAGE_LIST_ITEM, packageList);
- }
-
- void writeAttributeValueToXml(XmlSerializer out, String tag, String value)
- throws IOException {
- out.startTag(null, tag);
- out.attribute(null, ATTR_VALUE, value);
- out.endTag(null, tag);
- }
-
- void writeAttributeValueToXml(XmlSerializer out, String tag, int value)
- throws IOException {
- out.startTag(null, tag);
- out.attribute(null, ATTR_VALUE, Integer.toString(value));
- out.endTag(null, tag);
- }
-
- void writeAttributeValueToXml(XmlSerializer out, String tag, long value)
- throws IOException {
- out.startTag(null, tag);
- out.attribute(null, ATTR_VALUE, Long.toString(value));
- out.endTag(null, tag);
- }
-
- void writeAttributeValueToXml(XmlSerializer out, String tag, boolean value)
- throws IOException {
- out.startTag(null, tag);
- out.attribute(null, ATTR_VALUE, Boolean.toString(value));
- out.endTag(null, tag);
- }
-
- void writeAttributeValuesToXml(XmlSerializer out, String outerTag, String innerTag,
- @NonNull Collection<String> values) throws IOException {
- out.startTag(null, outerTag);
- for (String value : values) {
- out.startTag(null, innerTag);
- out.attribute(null, ATTR_VALUE, value);
- out.endTag(null, innerTag);
- }
- out.endTag(null, outerTag);
- }
-
- void readFromXml(XmlPullParser parser, boolean shouldOverridePolicies)
- throws XmlPullParserException, IOException {
- int outerDepth = parser.getDepth();
- int type;
- while ((type=parser.next()) != END_DOCUMENT
- && (type != END_TAG || parser.getDepth() > outerDepth)) {
- if (type == END_TAG || type == TEXT) {
- continue;
- }
- String tag = parser.getName();
- if (TAG_POLICIES.equals(tag)) {
- if (shouldOverridePolicies) {
- Log.d(LOG_TAG, "Overriding device admin policies from XML.");
- info.readPoliciesFromXml(parser);
- }
- } else if (TAG_PASSWORD_QUALITY.equals(tag)) {
- mPasswordPolicy.quality = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_MIN_PASSWORD_LENGTH.equals(tag)) {
- mPasswordPolicy.length = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_PASSWORD_HISTORY_LENGTH.equals(tag)) {
- passwordHistoryLength = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_MIN_PASSWORD_UPPERCASE.equals(tag)) {
- mPasswordPolicy.upperCase = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_MIN_PASSWORD_LOWERCASE.equals(tag)) {
- mPasswordPolicy.lowerCase = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_MIN_PASSWORD_LETTERS.equals(tag)) {
- mPasswordPolicy.letters = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_MIN_PASSWORD_NUMERIC.equals(tag)) {
- mPasswordPolicy.numeric = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_MIN_PASSWORD_SYMBOLS.equals(tag)) {
- mPasswordPolicy.symbols = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_MIN_PASSWORD_NONLETTER.equals(tag)) {
- mPasswordPolicy.nonLetter = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_VALUE));
- }else if (TAG_MAX_TIME_TO_UNLOCK.equals(tag)) {
- maximumTimeToUnlock = Long.parseLong(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_STRONG_AUTH_UNLOCK_TIMEOUT.equals(tag)) {
- strongAuthUnlockTimeout = Long.parseLong(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_MAX_FAILED_PASSWORD_WIPE.equals(tag)) {
- maximumFailedPasswordsForWipe = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_SPECIFIES_GLOBAL_PROXY.equals(tag)) {
- specifiesGlobalProxy = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_GLOBAL_PROXY_SPEC.equals(tag)) {
- globalProxySpec =
- parser.getAttributeValue(null, ATTR_VALUE);
- } else if (TAG_GLOBAL_PROXY_EXCLUSION_LIST.equals(tag)) {
- globalProxyExclusionList =
- parser.getAttributeValue(null, ATTR_VALUE);
- } else if (TAG_PASSWORD_EXPIRATION_TIMEOUT.equals(tag)) {
- passwordExpirationTimeout = Long.parseLong(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_PASSWORD_EXPIRATION_DATE.equals(tag)) {
- passwordExpirationDate = Long.parseLong(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_ENCRYPTION_REQUESTED.equals(tag)) {
- encryptionRequested = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_TEST_ONLY_ADMIN.equals(tag)) {
- testOnlyAdmin = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_DISABLE_CAMERA.equals(tag)) {
- disableCamera = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_DISABLE_CALLER_ID.equals(tag)) {
- disableCallerId = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_DISABLE_CONTACTS_SEARCH.equals(tag)) {
- disableContactsSearch = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_DISABLE_BLUETOOTH_CONTACT_SHARING.equals(tag)) {
- disableBluetoothContactSharing = Boolean.parseBoolean(parser
- .getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_DISABLE_SCREEN_CAPTURE.equals(tag)) {
- disableScreenCapture = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_REQUIRE_AUTO_TIME.equals(tag)) {
- requireAutoTime = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_FORCE_EPHEMERAL_USERS.equals(tag)) {
- forceEphemeralUsers = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_IS_NETWORK_LOGGING_ENABLED.equals(tag)) {
- isNetworkLoggingEnabled = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- lastNetworkLoggingNotificationTimeMs = Long.parseLong(
- parser.getAttributeValue(null, ATTR_LAST_NETWORK_LOGGING_NOTIFICATION));
- numNetworkLoggingNotifications = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_NUM_NETWORK_LOGGING_NOTIFICATIONS));
- } else if (TAG_DISABLE_KEYGUARD_FEATURES.equals(tag)) {
- disabledKeyguardFeatures = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_DISABLE_ACCOUNT_MANAGEMENT.equals(tag)) {
- readAttributeValues(
- parser, TAG_ACCOUNT_TYPE, accountTypesWithManagementDisabled);
- } else if (TAG_MANAGE_TRUST_AGENT_FEATURES.equals(tag)) {
- trustAgentInfos = getAllTrustAgentInfos(parser, tag);
- } else if (TAG_CROSS_PROFILE_WIDGET_PROVIDERS.equals(tag)) {
- crossProfileWidgetProviders = new ArrayList<>();
- readAttributeValues(parser, TAG_PROVIDER, crossProfileWidgetProviders);
- } else if (TAG_PERMITTED_ACCESSIBILITY_SERVICES.equals(tag)) {
- permittedAccessiblityServices = readPackageList(parser, tag);
- } else if (TAG_PERMITTED_IMES.equals(tag)) {
- permittedInputMethods = readPackageList(parser, tag);
- } else if (TAG_PERMITTED_NOTIFICATION_LISTENERS.equals(tag)) {
- permittedNotificationListeners = readPackageList(parser, tag);
- } else if (TAG_KEEP_UNINSTALLED_PACKAGES.equals(tag)) {
- keepUninstalledPackages = readPackageList(parser, tag);
- } else if (TAG_METERED_DATA_DISABLED_PACKAGES.equals(tag)) {
- meteredDisabledPackages = readPackageList(parser, tag);
- } else if (TAG_USER_RESTRICTIONS.equals(tag)) {
- userRestrictions = UserRestrictionsUtils.readRestrictions(parser);
- } else if (TAG_DEFAULT_ENABLED_USER_RESTRICTIONS.equals(tag)) {
- readAttributeValues(
- parser, TAG_RESTRICTION, defaultEnabledRestrictionsAlreadySet);
- } else if (TAG_SHORT_SUPPORT_MESSAGE.equals(tag)) {
- type = parser.next();
- if (type == XmlPullParser.TEXT) {
- shortSupportMessage = parser.getText();
- } else {
- Log.w(LOG_TAG, "Missing text when loading short support message");
- }
- } else if (TAG_LONG_SUPPORT_MESSAGE.equals(tag)) {
- type = parser.next();
- if (type == XmlPullParser.TEXT) {
- longSupportMessage = parser.getText();
- } else {
- Log.w(LOG_TAG, "Missing text when loading long support message");
- }
- } else if (TAG_PARENT_ADMIN.equals(tag)) {
- Preconditions.checkState(!isParent);
- parentAdmin = new ActiveAdmin(info, /* parent */ true);
- parentAdmin.readFromXml(parser, shouldOverridePolicies);
- } else if (TAG_ORGANIZATION_COLOR.equals(tag)) {
- organizationColor = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_ORGANIZATION_NAME.equals(tag)) {
- type = parser.next();
- if (type == XmlPullParser.TEXT) {
- organizationName = parser.getText();
- } else {
- Log.w(LOG_TAG, "Missing text when loading organization name");
- }
- } else if (TAG_IS_LOGOUT_ENABLED.equals(tag)) {
- isLogoutEnabled = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_START_USER_SESSION_MESSAGE.equals(tag)) {
- type = parser.next();
- if (type == XmlPullParser.TEXT) {
- startUserSessionMessage = parser.getText();
- } else {
- Log.w(LOG_TAG, "Missing text when loading start session message");
- }
- } else if (TAG_END_USER_SESSION_MESSAGE.equals(tag)) {
- type = parser.next();
- if (type == XmlPullParser.TEXT) {
- endUserSessionMessage = parser.getText();
- } else {
- Log.w(LOG_TAG, "Missing text when loading end session message");
- }
- } else if (TAG_CROSS_PROFILE_CALENDAR_PACKAGES.equals(tag)) {
- mCrossProfileCalendarPackages = readPackageList(parser, tag);
- } else if (TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL.equals(tag)) {
- mCrossProfileCalendarPackages = null;
- } else if (TAG_CROSS_PROFILE_PACKAGES.equals(tag)) {
- mCrossProfilePackages = readPackageList(parser, tag);
- } else if (TAG_FACTORY_RESET_PROTECTION_POLICY.equals(tag)) {
- mFactoryResetProtectionPolicy = FactoryResetProtectionPolicy.readFromXml(
- parser);
- } else if (TAG_SUSPEND_PERSONAL_APPS.equals(tag)) {
- mSuspendPersonalApps = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_PROFILE_MAXIMUM_TIME_OFF.equals(tag)) {
- mProfileMaximumTimeOffMillis =
- Long.parseLong(parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_PROFILE_OFF_DEADLINE.equals(tag)) {
- mProfileOffDeadline =
- Long.parseLong(parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_ALWAYS_ON_VPN_PACKAGE.equals(tag)) {
- mAlwaysOnVpnPackage = parser.getAttributeValue(null, ATTR_VALUE);
- } else if (TAG_ALWAYS_ON_VPN_LOCKDOWN.equals(tag)) {
- mAlwaysOnVpnLockdown = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_COMMON_CRITERIA_MODE.equals(tag)) {
- mCommonCriteriaMode = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else {
- Slog.w(LOG_TAG, "Unknown admin tag: " + tag);
- XmlUtils.skipCurrentTag(parser);
- }
- }
- }
-
- private List<String> readPackageList(XmlPullParser parser,
- String tag) throws XmlPullParserException, IOException {
- List<String> result = new ArrayList<String>();
- int outerDepth = parser.getDepth();
- int outerType;
- while ((outerType=parser.next()) != XmlPullParser.END_DOCUMENT
- && (outerType != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
- if (outerType == XmlPullParser.END_TAG || outerType == XmlPullParser.TEXT) {
- continue;
- }
- String outerTag = parser.getName();
- if (TAG_PACKAGE_LIST_ITEM.equals(outerTag)) {
- String packageName = parser.getAttributeValue(null, ATTR_VALUE);
- if (packageName != null) {
- result.add(packageName);
- } else {
- Slog.w(LOG_TAG, "Package name missing under " + outerTag);
- }
- } else {
- Slog.w(LOG_TAG, "Unknown tag under " + tag + ": " + outerTag);
- }
- }
- return result;
- }
-
- private void readAttributeValues(
- XmlPullParser parser, String tag, Collection<String> result)
- throws XmlPullParserException, IOException {
- result.clear();
- int outerDepthDAM = parser.getDepth();
- int typeDAM;
- while ((typeDAM=parser.next()) != END_DOCUMENT
- && (typeDAM != END_TAG || parser.getDepth() > outerDepthDAM)) {
- if (typeDAM == END_TAG || typeDAM == TEXT) {
- continue;
- }
- String tagDAM = parser.getName();
- if (tag.equals(tagDAM)) {
- result.add(parser.getAttributeValue(null, ATTR_VALUE));
- } else {
- Slog.e(LOG_TAG, "Expected tag " + tag + " but found " + tagDAM);
- }
- }
- }
-
- @NonNull
- private ArrayMap<String, TrustAgentInfo> getAllTrustAgentInfos(
- XmlPullParser parser, String tag) throws XmlPullParserException, IOException {
- int outerDepthDAM = parser.getDepth();
- int typeDAM;
- final ArrayMap<String, TrustAgentInfo> result = new ArrayMap<>();
- while ((typeDAM=parser.next()) != END_DOCUMENT
- && (typeDAM != END_TAG || parser.getDepth() > outerDepthDAM)) {
- if (typeDAM == END_TAG || typeDAM == TEXT) {
- continue;
- }
- String tagDAM = parser.getName();
- if (TAG_TRUST_AGENT_COMPONENT.equals(tagDAM)) {
- final String component = parser.getAttributeValue(null, ATTR_VALUE);
- final TrustAgentInfo trustAgentInfo = getTrustAgentInfo(parser, tag);
- result.put(component, trustAgentInfo);
- } else {
- Slog.w(LOG_TAG, "Unknown tag under " + tag + ": " + tagDAM);
- }
- }
- return result;
- }
-
- private TrustAgentInfo getTrustAgentInfo(XmlPullParser parser, String tag)
- throws XmlPullParserException, IOException {
- int outerDepthDAM = parser.getDepth();
- int typeDAM;
- TrustAgentInfo result = new TrustAgentInfo(null);
- while ((typeDAM=parser.next()) != END_DOCUMENT
- && (typeDAM != END_TAG || parser.getDepth() > outerDepthDAM)) {
- if (typeDAM == END_TAG || typeDAM == TEXT) {
- continue;
- }
- String tagDAM = parser.getName();
- if (TAG_TRUST_AGENT_COMPONENT_OPTIONS.equals(tagDAM)) {
- result.options = PersistableBundle.restoreFromXml(parser);
- } else {
- Slog.w(LOG_TAG, "Unknown tag under " + tag + ": " + tagDAM);
- }
- }
- return result;
- }
-
- boolean hasUserRestrictions() {
- return userRestrictions != null && userRestrictions.size() > 0;
- }
-
- Bundle ensureUserRestrictions() {
- if (userRestrictions == null) {
- userRestrictions = new Bundle();
- }
- return userRestrictions;
- }
-
- public void transfer(DeviceAdminInfo deviceAdminInfo) {
- if (hasParentActiveAdmin()) {
- parentAdmin.info = deviceAdminInfo;
- }
- info = deviceAdminInfo;
- }
-
- Bundle addSyntheticRestrictions(Bundle restrictions) {
- if (disableCamera) {
- restrictions.putBoolean(UserManager.DISALLOW_CAMERA, true);
- }
- if (requireAutoTime) {
- restrictions.putBoolean(UserManager.DISALLOW_CONFIG_DATE_TIME, true);
- }
- return restrictions;
- }
-
- static Bundle removeDeprecatedRestrictions(Bundle restrictions) {
- for (String deprecatedRestriction: DEPRECATED_USER_RESTRICTIONS) {
- restrictions.remove(deprecatedRestriction);
- }
- return restrictions;
- }
-
- static Bundle filterRestrictions(Bundle restrictions, Predicate<String> filter) {
- Bundle result = new Bundle();
- for (String key : restrictions.keySet()) {
- if (!restrictions.getBoolean(key)) {
- continue;
- }
- if (filter.test(key)) {
- result.putBoolean(key, true);
- }
- }
- return result;
- }
-
- Bundle getEffectiveRestrictions() {
- return addSyntheticRestrictions(
- removeDeprecatedRestrictions(new Bundle(ensureUserRestrictions())));
- }
-
- Bundle getLocalUserRestrictions(int adminType) {
- return filterRestrictions(getEffectiveRestrictions(),
- key -> UserRestrictionsUtils.isLocal(adminType, key));
- }
-
- Bundle getGlobalUserRestrictions(int adminType) {
- return filterRestrictions(getEffectiveRestrictions(),
- key -> UserRestrictionsUtils.isGlobal(adminType, key));
- }
-
- void dump(IndentingPrintWriter pw) {
- pw.print("uid="); pw.println(getUid());
- pw.print("testOnlyAdmin=");
- pw.println(testOnlyAdmin);
- pw.println("policies:");
- ArrayList<DeviceAdminInfo.PolicyInfo> pols = info.getUsedPolicies();
- if (pols != null) {
- pw.increaseIndent();
- for (int i=0; i<pols.size(); i++) {
- pw.println(pols.get(i).tag);
- }
- pw.decreaseIndent();
- }
- pw.print("passwordQuality=0x");
- pw.println(Integer.toHexString(mPasswordPolicy.quality));
- pw.print("minimumPasswordLength=");
- pw.println(mPasswordPolicy.length);
- pw.print("passwordHistoryLength=");
- pw.println(passwordHistoryLength);
- pw.print("minimumPasswordUpperCase=");
- pw.println(mPasswordPolicy.upperCase);
- pw.print("minimumPasswordLowerCase=");
- pw.println(mPasswordPolicy.lowerCase);
- pw.print("minimumPasswordLetters=");
- pw.println(mPasswordPolicy.letters);
- pw.print("minimumPasswordNumeric=");
- pw.println(mPasswordPolicy.numeric);
- pw.print("minimumPasswordSymbols=");
- pw.println(mPasswordPolicy.symbols);
- pw.print("minimumPasswordNonLetter=");
- pw.println(mPasswordPolicy.nonLetter);
- pw.print("maximumTimeToUnlock=");
- pw.println(maximumTimeToUnlock);
- pw.print("strongAuthUnlockTimeout=");
- pw.println(strongAuthUnlockTimeout);
- pw.print("maximumFailedPasswordsForWipe=");
- pw.println(maximumFailedPasswordsForWipe);
- pw.print("specifiesGlobalProxy=");
- pw.println(specifiesGlobalProxy);
- pw.print("passwordExpirationTimeout=");
- pw.println(passwordExpirationTimeout);
- pw.print("passwordExpirationDate=");
- pw.println(passwordExpirationDate);
- if (globalProxySpec != null) {
- pw.print("globalProxySpec=");
- pw.println(globalProxySpec);
- }
- if (globalProxyExclusionList != null) {
- pw.print("globalProxyEclusionList=");
- pw.println(globalProxyExclusionList);
- }
- pw.print("encryptionRequested=");
- pw.println(encryptionRequested);
- pw.print("disableCamera=");
- pw.println(disableCamera);
- pw.print("disableCallerId=");
- pw.println(disableCallerId);
- pw.print("disableContactsSearch=");
- pw.println(disableContactsSearch);
- pw.print("disableBluetoothContactSharing=");
- pw.println(disableBluetoothContactSharing);
- pw.print("disableScreenCapture=");
- pw.println(disableScreenCapture);
- pw.print("requireAutoTime=");
- pw.println(requireAutoTime);
- pw.print("forceEphemeralUsers=");
- pw.println(forceEphemeralUsers);
- pw.print("isNetworkLoggingEnabled=");
- pw.println(isNetworkLoggingEnabled);
- pw.print("disabledKeyguardFeatures=");
- pw.println(disabledKeyguardFeatures);
- pw.print("crossProfileWidgetProviders=");
- pw.println(crossProfileWidgetProviders);
- if (permittedAccessiblityServices != null) {
- pw.print("permittedAccessibilityServices=");
- pw.println(permittedAccessiblityServices);
- }
- if (permittedInputMethods != null) {
- pw.print("permittedInputMethods=");
- pw.println(permittedInputMethods);
- }
- if (permittedNotificationListeners != null) {
- pw.print("permittedNotificationListeners=");
- pw.println(permittedNotificationListeners);
- }
- if (keepUninstalledPackages != null) {
- pw.print("keepUninstalledPackages=");
- pw.println(keepUninstalledPackages);
- }
- pw.print("organizationColor=");
- pw.println(organizationColor);
- if (organizationName != null) {
- pw.print("organizationName=");
- pw.println(organizationName);
- }
- pw.println("userRestrictions:");
- UserRestrictionsUtils.dumpRestrictions(pw, " ", userRestrictions);
- pw.print("defaultEnabledRestrictionsAlreadySet=");
- pw.println(defaultEnabledRestrictionsAlreadySet);
- pw.print("isParent=");
- pw.println(isParent);
- if (parentAdmin != null) {
- pw.println("parentAdmin:");
- pw.increaseIndent();
- parentAdmin.dump(pw);
- pw.decreaseIndent();
- }
- if (mCrossProfileCalendarPackages != null) {
- pw.print("mCrossProfileCalendarPackages=");
- pw.println(mCrossProfileCalendarPackages);
- }
- pw.print("mCrossProfilePackages=");
- pw.println(mCrossProfilePackages);
- pw.print("mSuspendPersonalApps=");
- pw.println(mSuspendPersonalApps);
- pw.print("mProfileMaximumTimeOffMillis=");
- pw.println(mProfileMaximumTimeOffMillis);
- pw.print("mProfileOffDeadline=");
- pw.println(mProfileOffDeadline);
- pw.print("mAlwaysOnVpnPackage=");
- pw.println(mAlwaysOnVpnPackage);
- pw.print("mAlwaysOnVpnLockdown=");
- pw.println(mAlwaysOnVpnLockdown);
- pw.print("mCommonCriteriaMode=");
- pw.println(mCommonCriteriaMode);
- }
- }
-
private void handlePackagesChanged(@Nullable String packageName, int userHandle) {
boolean removedAdmin = false;
if (VERBOSE_LOG) {
@@ -2073,7 +934,7 @@
}
}
if (removedAdmin) {
- validatePasswordOwnerLocked(policy);
+ policy.validatePasswordOwner();
}
boolean removedDelegate = false;
@@ -3514,13 +2375,8 @@
}
}
-
- public DeviceAdminInfo findAdmin(final ComponentName adminName, final int userHandle,
+ private DeviceAdminInfo findAdmin(final ComponentName adminName, final int userHandle,
boolean throwForMissingPermission) {
- if (!mHasFeature) {
- return null;
- }
- enforceFullCrossUsersPermission(userHandle);
final ActivityInfo ai = mInjector.binderWithCleanCallingIdentity(() -> {
try {
return mIPackageManager.getReceiverInfo(adminName,
@@ -3583,213 +2439,11 @@
}
private void saveSettingsLocked(int userHandle) {
- DevicePolicyData policy = getUserData(userHandle);
- JournaledFile journal = makeJournaledFile(userHandle);
- FileOutputStream stream = null;
- try {
- stream = new FileOutputStream(journal.chooseForWrite(), false);
- XmlSerializer out = new FastXmlSerializer();
- out.setOutput(stream, StandardCharsets.UTF_8.name());
- out.startDocument(null, true);
-
- out.startTag(null, "policies");
- if (policy.mRestrictionsProvider != null) {
- out.attribute(null, ATTR_PERMISSION_PROVIDER,
- policy.mRestrictionsProvider.flattenToString());
- }
- if (policy.mUserSetupComplete) {
- out.attribute(null, ATTR_SETUP_COMPLETE,
- Boolean.toString(true));
- }
- if (policy.mPaired) {
- out.attribute(null, ATTR_DEVICE_PAIRED,
- Boolean.toString(true));
- }
- if (policy.mDeviceProvisioningConfigApplied) {
- out.attribute(null, ATTR_DEVICE_PROVISIONING_CONFIG_APPLIED,
- Boolean.toString(true));
- }
- if (policy.mUserProvisioningState != DevicePolicyManager.STATE_USER_UNMANAGED) {
- out.attribute(null, ATTR_PROVISIONING_STATE,
- Integer.toString(policy.mUserProvisioningState));
- }
- if (policy.mPermissionPolicy != DevicePolicyManager.PERMISSION_POLICY_PROMPT) {
- out.attribute(null, ATTR_PERMISSION_POLICY,
- Integer.toString(policy.mPermissionPolicy));
- }
-
- // Serialize delegations.
- for (int i = 0; i < policy.mDelegationMap.size(); ++i) {
- final String delegatePackage = policy.mDelegationMap.keyAt(i);
- final List<String> scopes = policy.mDelegationMap.valueAt(i);
-
- // Every "delegation" tag serializes the information of one delegate-scope pair.
- for (String scope : scopes) {
- out.startTag(null, "delegation");
- out.attribute(null, "delegatePackage", delegatePackage);
- out.attribute(null, "scope", scope);
- out.endTag(null, "delegation");
- }
- }
-
- final int N = policy.mAdminList.size();
- for (int i=0; i<N; i++) {
- ActiveAdmin ap = policy.mAdminList.get(i);
- if (ap != null) {
- out.startTag(null, "admin");
- out.attribute(null, "name", ap.info.getComponent().flattenToString());
- ap.writeToXml(out);
- out.endTag(null, "admin");
- }
- }
-
- if (policy.mPasswordOwner >= 0) {
- out.startTag(null, "password-owner");
- out.attribute(null, "value", Integer.toString(policy.mPasswordOwner));
- out.endTag(null, "password-owner");
- }
-
- if (policy.mFailedPasswordAttempts != 0) {
- out.startTag(null, "failed-password-attempts");
- out.attribute(null, "value", Integer.toString(policy.mFailedPasswordAttempts));
- out.endTag(null, "failed-password-attempts");
- }
-
- // For FDE devices only, we save this flag so we can report on password sufficiency
- // before the user enters their password for the first time after a reboot. For
- // security reasons, we don't want to store the full set of active password metrics.
- if (!mInjector.storageManagerIsFileBasedEncryptionEnabled()) {
- out.startTag(null, TAG_PASSWORD_VALIDITY);
- out.attribute(null, ATTR_VALUE,
- Boolean.toString(policy.mPasswordValidAtLastCheckpoint));
- out.endTag(null, TAG_PASSWORD_VALIDITY);
- }
-
- for (int i = 0; i < policy.mAcceptedCaCertificates.size(); i++) {
- out.startTag(null, TAG_ACCEPTED_CA_CERTIFICATES);
- out.attribute(null, ATTR_NAME, policy.mAcceptedCaCertificates.valueAt(i));
- out.endTag(null, TAG_ACCEPTED_CA_CERTIFICATES);
- }
-
- for (int i=0; i<policy.mLockTaskPackages.size(); i++) {
- String component = policy.mLockTaskPackages.get(i);
- out.startTag(null, TAG_LOCK_TASK_COMPONENTS);
- out.attribute(null, "name", component);
- out.endTag(null, TAG_LOCK_TASK_COMPONENTS);
- }
-
- if (policy.mLockTaskFeatures != DevicePolicyManager.LOCK_TASK_FEATURE_NONE) {
- out.startTag(null, TAG_LOCK_TASK_FEATURES);
- out.attribute(null, ATTR_VALUE, Integer.toString(policy.mLockTaskFeatures));
- out.endTag(null, TAG_LOCK_TASK_FEATURES);
- }
-
- if (policy.mSecondaryLockscreenEnabled) {
- out.startTag(null, TAG_SECONDARY_LOCK_SCREEN);
- out.attribute(null, ATTR_VALUE, Boolean.toString(true));
- out.endTag(null, TAG_SECONDARY_LOCK_SCREEN);
- }
-
- if (policy.mStatusBarDisabled) {
- out.startTag(null, TAG_STATUS_BAR);
- out.attribute(null, ATTR_DISABLED, Boolean.toString(policy.mStatusBarDisabled));
- out.endTag(null, TAG_STATUS_BAR);
- }
-
- if (policy.doNotAskCredentialsOnBoot) {
- out.startTag(null, DO_NOT_ASK_CREDENTIALS_ON_BOOT_XML);
- out.endTag(null, DO_NOT_ASK_CREDENTIALS_ON_BOOT_XML);
- }
-
- for (String id : policy.mAffiliationIds) {
- out.startTag(null, TAG_AFFILIATION_ID);
- out.attribute(null, ATTR_ID, id);
- out.endTag(null, TAG_AFFILIATION_ID);
- }
-
- if (policy.mLastSecurityLogRetrievalTime >= 0) {
- out.startTag(null, TAG_LAST_SECURITY_LOG_RETRIEVAL);
- out.attribute(null, ATTR_VALUE,
- Long.toString(policy.mLastSecurityLogRetrievalTime));
- out.endTag(null, TAG_LAST_SECURITY_LOG_RETRIEVAL);
- }
-
- if (policy.mLastBugReportRequestTime >= 0) {
- out.startTag(null, TAG_LAST_BUG_REPORT_REQUEST);
- out.attribute(null, ATTR_VALUE,
- Long.toString(policy.mLastBugReportRequestTime));
- out.endTag(null, TAG_LAST_BUG_REPORT_REQUEST);
- }
-
- if (policy.mLastNetworkLogsRetrievalTime >= 0) {
- out.startTag(null, TAG_LAST_NETWORK_LOG_RETRIEVAL);
- out.attribute(null, ATTR_VALUE,
- Long.toString(policy.mLastNetworkLogsRetrievalTime));
- out.endTag(null, TAG_LAST_NETWORK_LOG_RETRIEVAL);
- }
-
- if (policy.mAdminBroadcastPending) {
- out.startTag(null, TAG_ADMIN_BROADCAST_PENDING);
- out.attribute(null, ATTR_VALUE,
- Boolean.toString(policy.mAdminBroadcastPending));
- out.endTag(null, TAG_ADMIN_BROADCAST_PENDING);
- }
-
- if (policy.mInitBundle != null) {
- out.startTag(null, TAG_INITIALIZATION_BUNDLE);
- policy.mInitBundle.saveToXml(out);
- out.endTag(null, TAG_INITIALIZATION_BUNDLE);
- }
-
- if (policy.mPasswordTokenHandle != 0) {
- out.startTag(null, TAG_PASSWORD_TOKEN_HANDLE);
- out.attribute(null, ATTR_VALUE,
- Long.toString(policy.mPasswordTokenHandle));
- out.endTag(null, TAG_PASSWORD_TOKEN_HANDLE);
- }
-
- if (policy.mCurrentInputMethodSet) {
- out.startTag(null, TAG_CURRENT_INPUT_METHOD_SET);
- out.endTag(null, TAG_CURRENT_INPUT_METHOD_SET);
- }
-
- for (final String cert : policy.mOwnerInstalledCaCerts) {
- out.startTag(null, TAG_OWNER_INSTALLED_CA_CERT);
- out.attribute(null, ATTR_ALIAS, cert);
- out.endTag(null, TAG_OWNER_INSTALLED_CA_CERT);
- }
-
- for (int i = 0, size = policy.mUserControlDisabledPackages.size(); i < size; i++) {
- String packageName = policy.mUserControlDisabledPackages.get(i);
- out.startTag(null, TAG_PROTECTED_PACKAGES);
- out.attribute(null, ATTR_NAME, packageName);
- out.endTag(null, TAG_PROTECTED_PACKAGES);
- }
-
- if (policy.mAppsSuspended) {
- out.startTag(null, TAG_APPS_SUSPENDED);
- out.attribute(null, ATTR_VALUE, Boolean.toString(policy.mAppsSuspended));
- out.endTag(null, TAG_APPS_SUSPENDED);
- }
-
- out.endTag(null, "policies");
-
- out.endDocument();
- stream.flush();
- FileUtils.sync(stream);
- stream.close();
- journal.commit();
+ if (DevicePolicyData.store(
+ getUserData(userHandle),
+ makeJournaledFile(userHandle),
+ !mInjector.storageManagerIsFileBasedEncryptionEnabled())) {
sendChangedNotification(userHandle);
- } catch (XmlPullParserException | IOException e) {
- Slog.w(LOG_TAG, "failed writing file", e);
- try {
- if (stream != null) {
- stream.close();
- }
- } catch (IOException ex) {
- // Ignore
- }
- journal.rollback();
}
}
@@ -3801,225 +2455,19 @@
}
private void loadSettingsLocked(DevicePolicyData policy, int userHandle) {
- JournaledFile journal = makeJournaledFile(userHandle);
- FileInputStream stream = null;
- File file = journal.chooseForRead();
- boolean needsRewrite = false;
- try {
- stream = new FileInputStream(file);
- XmlPullParser parser = Xml.newPullParser();
- parser.setInput(stream, StandardCharsets.UTF_8.name());
-
- int type;
- while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
- && type != XmlPullParser.START_TAG) {
- }
- String tag = parser.getName();
- if (!"policies".equals(tag)) {
- throw new XmlPullParserException(
- "Settings do not start with policies tag: found " + tag);
- }
-
- // Extract the permission provider component name if available
- String permissionProvider = parser.getAttributeValue(null, ATTR_PERMISSION_PROVIDER);
- if (permissionProvider != null) {
- policy.mRestrictionsProvider = ComponentName.unflattenFromString(permissionProvider);
- }
- String userSetupComplete = parser.getAttributeValue(null, ATTR_SETUP_COMPLETE);
- if (userSetupComplete != null && Boolean.toString(true).equals(userSetupComplete)) {
- policy.mUserSetupComplete = true;
- }
- String paired = parser.getAttributeValue(null, ATTR_DEVICE_PAIRED);
- if (paired != null && Boolean.toString(true).equals(paired)) {
- policy.mPaired = true;
- }
- String deviceProvisioningConfigApplied = parser.getAttributeValue(null,
- ATTR_DEVICE_PROVISIONING_CONFIG_APPLIED);
- if (deviceProvisioningConfigApplied != null
- && Boolean.toString(true).equals(deviceProvisioningConfigApplied)) {
- policy.mDeviceProvisioningConfigApplied = true;
- }
- String provisioningState = parser.getAttributeValue(null, ATTR_PROVISIONING_STATE);
- if (!TextUtils.isEmpty(provisioningState)) {
- policy.mUserProvisioningState = Integer.parseInt(provisioningState);
- }
- String permissionPolicy = parser.getAttributeValue(null, ATTR_PERMISSION_POLICY);
- if (!TextUtils.isEmpty(permissionPolicy)) {
- policy.mPermissionPolicy = Integer.parseInt(permissionPolicy);
- }
- // Check for delegation compatibility with pre-O.
- // TODO(edmanp) remove in P.
- {
- final String certDelegate = parser.getAttributeValue(null,
- ATTR_DELEGATED_CERT_INSTALLER);
- if (certDelegate != null) {
- List<String> scopes = policy.mDelegationMap.get(certDelegate);
- if (scopes == null) {
- scopes = new ArrayList<>();
- policy.mDelegationMap.put(certDelegate, scopes);
- }
- if (!scopes.contains(DELEGATION_CERT_INSTALL)) {
- scopes.add(DELEGATION_CERT_INSTALL);
- needsRewrite = true;
- }
- }
- final String appRestrictionsDelegate = parser.getAttributeValue(null,
- ATTR_APPLICATION_RESTRICTIONS_MANAGER);
- if (appRestrictionsDelegate != null) {
- List<String> scopes = policy.mDelegationMap.get(appRestrictionsDelegate);
- if (scopes == null) {
- scopes = new ArrayList<>();
- policy.mDelegationMap.put(appRestrictionsDelegate, scopes);
- }
- if (!scopes.contains(DELEGATION_APP_RESTRICTIONS)) {
- scopes.add(DELEGATION_APP_RESTRICTIONS);
- needsRewrite = true;
- }
- }
- }
-
- type = parser.next();
- int outerDepth = parser.getDepth();
- policy.mLockTaskPackages.clear();
- policy.mAdminList.clear();
- policy.mAdminMap.clear();
- policy.mAffiliationIds.clear();
- policy.mOwnerInstalledCaCerts.clear();
- policy.mUserControlDisabledPackages.clear();
- while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
- && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
- if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
- continue;
- }
- tag = parser.getName();
- if ("admin".equals(tag)) {
- String name = parser.getAttributeValue(null, "name");
- try {
- DeviceAdminInfo dai = findAdmin(
- ComponentName.unflattenFromString(name), userHandle,
- /* throwForMissingPermission= */ false);
- if (VERBOSE_LOG
- && (UserHandle.getUserId(dai.getActivityInfo().applicationInfo.uid)
- != userHandle)) {
- Slog.w(LOG_TAG, "findAdmin returned an incorrect uid "
- + dai.getActivityInfo().applicationInfo.uid + " for user "
- + userHandle);
- }
- if (dai != null) {
- boolean shouldOverwritePolicies =
- shouldOverwritePoliciesFromXml(dai.getComponent(), userHandle);
- ActiveAdmin ap = new ActiveAdmin(dai, /* parent */ false);
- ap.readFromXml(parser, shouldOverwritePolicies);
- policy.mAdminMap.put(ap.info.getComponent(), ap);
- }
- } catch (RuntimeException e) {
- Slog.w(LOG_TAG, "Failed loading admin " + name, e);
- }
- } else if ("delegation".equals(tag)) {
- // Parse delegation info.
- final String delegatePackage = parser.getAttributeValue(null,
- "delegatePackage");
- final String scope = parser.getAttributeValue(null, "scope");
-
- // Get a reference to the scopes list for the delegatePackage.
- List<String> scopes = policy.mDelegationMap.get(delegatePackage);
- // Or make a new list if none was found.
- if (scopes == null) {
- scopes = new ArrayList<>();
- policy.mDelegationMap.put(delegatePackage, scopes);
- }
- // Add the new scope to the list of delegatePackage if it's not already there.
- if (!scopes.contains(scope)) {
- scopes.add(scope);
- }
- } else if ("failed-password-attempts".equals(tag)) {
- policy.mFailedPasswordAttempts = Integer.parseInt(
- parser.getAttributeValue(null, "value"));
- } else if ("password-owner".equals(tag)) {
- policy.mPasswordOwner = Integer.parseInt(
- parser.getAttributeValue(null, "value"));
- } else if (TAG_ACCEPTED_CA_CERTIFICATES.equals(tag)) {
- policy.mAcceptedCaCertificates.add(parser.getAttributeValue(null, ATTR_NAME));
- } else if (TAG_LOCK_TASK_COMPONENTS.equals(tag)) {
- policy.mLockTaskPackages.add(parser.getAttributeValue(null, "name"));
- } else if (TAG_LOCK_TASK_FEATURES.equals(tag)) {
- policy.mLockTaskFeatures = Integer.parseInt(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_SECONDARY_LOCK_SCREEN.equals(tag)) {
- policy.mSecondaryLockscreenEnabled = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_STATUS_BAR.equals(tag)) {
- policy.mStatusBarDisabled = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_DISABLED));
- } else if (DO_NOT_ASK_CREDENTIALS_ON_BOOT_XML.equals(tag)) {
- policy.doNotAskCredentialsOnBoot = true;
- } else if (TAG_AFFILIATION_ID.equals(tag)) {
- policy.mAffiliationIds.add(parser.getAttributeValue(null, ATTR_ID));
- } else if (TAG_LAST_SECURITY_LOG_RETRIEVAL.equals(tag)) {
- policy.mLastSecurityLogRetrievalTime = Long.parseLong(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_LAST_BUG_REPORT_REQUEST.equals(tag)) {
- policy.mLastBugReportRequestTime = Long.parseLong(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_LAST_NETWORK_LOG_RETRIEVAL.equals(tag)) {
- policy.mLastNetworkLogsRetrievalTime = Long.parseLong(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_ADMIN_BROADCAST_PENDING.equals(tag)) {
- String pending = parser.getAttributeValue(null, ATTR_VALUE);
- policy.mAdminBroadcastPending = Boolean.toString(true).equals(pending);
- } else if (TAG_INITIALIZATION_BUNDLE.equals(tag)) {
- policy.mInitBundle = PersistableBundle.restoreFromXml(parser);
- } else if ("active-password".equals(tag)) {
- // Remove password metrics from saved settings, as we no longer wish to store
- // these on disk
- needsRewrite = true;
- } else if (TAG_PASSWORD_VALIDITY.equals(tag)) {
- if (!mInjector.storageManagerIsFileBasedEncryptionEnabled()) {
- // This flag is only used for FDE devices
- policy.mPasswordValidAtLastCheckpoint = Boolean.parseBoolean(
- parser.getAttributeValue(null, ATTR_VALUE));
- }
- } else if (TAG_PASSWORD_TOKEN_HANDLE.equals(tag)) {
- policy.mPasswordTokenHandle = Long.parseLong(
- parser.getAttributeValue(null, ATTR_VALUE));
- } else if (TAG_CURRENT_INPUT_METHOD_SET.equals(tag)) {
- policy.mCurrentInputMethodSet = true;
- } else if (TAG_OWNER_INSTALLED_CA_CERT.equals(tag)) {
- policy.mOwnerInstalledCaCerts.add(parser.getAttributeValue(null, ATTR_ALIAS));
- } else if (TAG_PROTECTED_PACKAGES.equals(tag)) {
- policy.mUserControlDisabledPackages.add(
- parser.getAttributeValue(null, ATTR_NAME));
- } else if (TAG_APPS_SUSPENDED.equals(tag)) {
- policy.mAppsSuspended =
- Boolean.parseBoolean(parser.getAttributeValue(null, ATTR_VALUE));
- } else {
- Slog.w(LOG_TAG, "Unknown tag: " + tag);
- XmlUtils.skipCurrentTag(parser);
- }
- }
- } catch (FileNotFoundException e) {
- // Don't be noisy, this is normal if we haven't defined any policies.
- } catch (NullPointerException | NumberFormatException | XmlPullParserException | IOException
- | IndexOutOfBoundsException e) {
- Slog.w(LOG_TAG, "failed parsing " + file, e);
- }
- try {
- if (stream != null) {
- stream.close();
- }
- } catch (IOException e) {
- // Ignore
- }
-
- // Generate a list of admins from the admin map
- policy.mAdminList.addAll(policy.mAdminMap.values());
+ boolean needsRewrite = DevicePolicyData.load(policy,
+ !mInjector.storageManagerIsFileBasedEncryptionEnabled(),
+ makeJournaledFile(userHandle),
+ component -> findAdmin(
+ component, userHandle, /* throwForMissingPermission= */ false),
+ getOwnerComponent(userHandle));
// Might need to upgrade the file by rewriting it
if (needsRewrite) {
saveSettingsLocked(userHandle);
}
- validatePasswordOwnerLocked(policy);
+ policy.validatePasswordOwner();
updateMaximumTimeToLockLocked(userHandle);
updateLockTaskPackagesLocked(policy.mLockTaskPackages, userHandle);
updateLockTaskFeaturesLocked(policy.mLockTaskFeatures, userHandle);
@@ -4029,14 +2477,6 @@
}
}
- private boolean shouldOverwritePoliciesFromXml(
- ComponentName deviceAdminComponent, int userHandle) {
- // http://b/123415062: If DA, overwrite with the stored policies that were agreed by the
- // user to prevent apps from sneaking additional policies into updates.
- return !isProfileOwner(deviceAdminComponent, userHandle)
- && !isDeviceOwner(deviceAdminComponent, userHandle);
- }
-
private void updateLockTaskPackagesLocked(List<String> packages, int userId) {
long ident = mInjector.binderClearCallingIdentity();
try {
@@ -4098,23 +2538,6 @@
+ Integer.toHexString(quality));
}
- void validatePasswordOwnerLocked(DevicePolicyData policy) {
- if (policy.mPasswordOwner >= 0) {
- boolean haveOwner = false;
- for (int i = policy.mAdminList.size() - 1; i >= 0; i--) {
- if (policy.mAdminList.get(i).getUid() == policy.mPasswordOwner) {
- haveOwner = true;
- break;
- }
- }
- if (!haveOwner) {
- Slog.w(LOG_TAG, "Previous password owner " + policy.mPasswordOwner
- + " no longer active; disabling");
- policy.mPasswordOwner = -1;
- }
- }
- }
-
@VisibleForTesting
@Override
void systemReady(int phase) {
@@ -5842,8 +4265,8 @@
private void setDoNotAskCredentialsOnBoot() {
synchronized (getLockObject()) {
DevicePolicyData policyData = getUserData(UserHandle.USER_SYSTEM);
- if (!policyData.doNotAskCredentialsOnBoot) {
- policyData.doNotAskCredentialsOnBoot = true;
+ if (!policyData.mDoNotAskCredentialsOnBoot) {
+ policyData.mDoNotAskCredentialsOnBoot = true;
saveSettingsLocked(UserHandle.USER_SYSTEM);
}
}
@@ -5855,7 +4278,7 @@
android.Manifest.permission.QUERY_DO_NOT_ASK_CREDENTIALS_ON_BOOT, null);
synchronized (getLockObject()) {
DevicePolicyData policyData = getUserData(UserHandle.USER_SYSTEM);
- return policyData.doNotAskCredentialsOnBoot;
+ return policyData.mDoNotAskCredentialsOnBoot;
}
}
@@ -14363,7 +12786,7 @@
DeviceAdminInfo.USES_POLICY_SETS_GLOBAL_PROXY);
policy.mAdminList.remove(admin);
policy.mAdminMap.remove(adminReceiver);
- validatePasswordOwnerLocked(policy);
+ policy.validatePasswordOwner();
if (doProxyCleanup) {
resetGlobalProxyLocked(policy);
}
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp
index a5f0d04..f7082a9 100644
--- a/services/incremental/IncrementalService.cpp
+++ b/services/incremental/IncrementalService.cpp
@@ -23,7 +23,6 @@
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <binder/AppOpsManager.h>
-#include <binder/Nullable.h>
#include <binder/Status.h>
#include <sys/stat.h>
#include <uuid/uuid.h>
@@ -1404,7 +1403,7 @@
}
FileSystemControlParcel fsControlParcel;
- fsControlParcel.incremental = aidl::make_nullable<IncrementalFileSystemControlParcel>();
+ fsControlParcel.incremental = std::make_optional<IncrementalFileSystemControlParcel>();
fsControlParcel.incremental->cmd.reset(dup(ifs.control.cmd()));
fsControlParcel.incremental->pendingReads.reset(dup(ifs.control.pendingReads()));
fsControlParcel.incremental->log.reset(dup(ifs.control.logs()));
diff --git a/services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java b/services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java
index 6184c4e..09e3bfe 100644
--- a/services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java
+++ b/services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java
@@ -794,7 +794,7 @@
setUpAgent(PACKAGE_1);
doThrow(SecurityException.class)
.when(mBackupManagerService)
- .bindToAgentSynchronous(argThat(applicationInfo(PACKAGE_1)), anyInt());
+ .bindToAgentSynchronous(argThat(applicationInfo(PACKAGE_1)), anyInt(), anyInt());
KeyValueBackupTask task = createKeyValueBackupTask(transportMock, PACKAGE_1);
runTask(task);
@@ -812,7 +812,7 @@
setUpAgent(PACKAGE_1);
doThrow(SecurityException.class)
.when(mBackupManagerService)
- .bindToAgentSynchronous(argThat(applicationInfo(PACKAGE_1)), anyInt());
+ .bindToAgentSynchronous(argThat(applicationInfo(PACKAGE_1)), anyInt(), anyInt());
KeyValueBackupTask task = createKeyValueBackupTask(transportMock, true, PACKAGE_1);
runTask(task);
@@ -2593,11 +2593,13 @@
if (packageData.available) {
doReturn(backupAgentBinder)
.when(mBackupManagerService)
- .bindToAgentSynchronous(argThat(applicationInfo(packageData)), anyInt());
+ .bindToAgentSynchronous(argThat(applicationInfo(packageData)), anyInt(),
+ anyInt());
} else {
doReturn(null)
.when(mBackupManagerService)
- .bindToAgentSynchronous(argThat(applicationInfo(packageData)), anyInt());
+ .bindToAgentSynchronous(argThat(applicationInfo(packageData)), anyInt(),
+ anyInt());
}
return new AgentMock(backupAgentBinder, backupAgent);
} catch (RemoteException e) {
diff --git a/services/systemcaptions/java/com/android/server/systemcaptions/SystemCaptionsManagerService.java b/services/systemcaptions/java/com/android/server/systemcaptions/SystemCaptionsManagerService.java
index 27a116c..1586a33 100644
--- a/services/systemcaptions/java/com/android/server/systemcaptions/SystemCaptionsManagerService.java
+++ b/services/systemcaptions/java/com/android/server/systemcaptions/SystemCaptionsManagerService.java
@@ -34,7 +34,8 @@
context,
com.android.internal.R.string.config_defaultSystemCaptionsManagerService),
/*disallowProperty=*/ null,
- /*packageUpdatePolicy=*/ PACKAGE_UPDATE_POLICY_REFRESH_EAGER);
+ /*packageUpdatePolicy=*/ PACKAGE_UPDATE_POLICY_REFRESH_EAGER
+ | PACKAGE_RESTART_POLICY_REFRESH_EAGER);
}
@Override
diff --git a/services/tests/PackageManagerServiceTests/host/Android.bp b/services/tests/PackageManagerServiceTests/host/Android.bp
index cffcdd8..e4e7e22 100644
--- a/services/tests/PackageManagerServiceTests/host/Android.bp
+++ b/services/tests/PackageManagerServiceTests/host/Android.bp
@@ -32,6 +32,7 @@
":PackageManagerTestAppVersion3Invalid",
":PackageManagerTestAppVersion4",
":PackageManagerTestAppOriginalOverride",
+ ":PackageManagerServiceDeviceSideTests",
],
}
diff --git a/services/tests/PackageManagerServiceTests/host/src/com/android/server/pm/test/FactoryPackageTest.kt b/services/tests/PackageManagerServiceTests/host/src/com/android/server/pm/test/FactoryPackageTest.kt
new file mode 100644
index 0000000..3847658
--- /dev/null
+++ b/services/tests/PackageManagerServiceTests/host/src/com/android/server/pm/test/FactoryPackageTest.kt
@@ -0,0 +1,71 @@
+package com.android.server.pm.test
+
+import com.android.internal.util.test.SystemPreparer
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner
+import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test
+import com.google.common.truth.Truth.assertThat
+import org.junit.After
+import org.junit.Before
+import org.junit.ClassRule
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.RuleChain
+import org.junit.rules.TemporaryFolder
+import org.junit.runner.RunWith
+
+@RunWith(DeviceJUnit4ClassRunner::class)
+class FactoryPackageTest : BaseHostJUnit4Test() {
+
+ companion object {
+ private const val TEST_PKG_NAME = "com.android.server.pm.test.test_app"
+
+ private const val VERSION_ONE = "PackageManagerTestAppVersion1.apk"
+ private const val VERSION_TWO = "PackageManagerTestAppVersion2.apk"
+ private const val DEVICE_SIDE = "PackageManagerServiceDeviceSideTests.apk"
+
+ @get:ClassRule
+ val deviceRebootRule = SystemPreparer.TestRuleDelegate(true)
+ }
+
+ private val tempFolder = TemporaryFolder()
+ private val preparer: SystemPreparer = SystemPreparer(tempFolder,
+ SystemPreparer.RebootStrategy.FULL, deviceRebootRule) { this.device }
+
+ @get:Rule
+ val rules = RuleChain.outerRule(tempFolder).around(preparer)!!
+ private val filePath =
+ HostUtils.makePathForApk("PackageManagerTestApp.apk", Partition.SYSTEM)
+
+ @Before
+ @After
+ fun removeApk() {
+ device.uninstallPackage(TEST_PKG_NAME)
+ device.deleteFile(filePath.parent.toString())
+ device.reboot()
+ }
+
+ @Test
+ fun testGetInstalledPackagesFactoryOnlyFlag() {
+ // First, push a system app to the device and then update it so there's a data variant
+ preparer.pushResourceFile(VERSION_ONE, filePath.toString())
+ .reboot()
+
+ val versionTwoFile = HostUtils.copyResourceToHostFile(VERSION_TWO, tempFolder.newFile())
+
+ assertThat(device.installPackage(versionTwoFile, true)).isNull()
+
+ runDeviceTest("testGetInstalledPackagesWithFactoryOnly")
+ }
+
+ /**
+ * Run a device side test from com.android.server.pm.test.deviceside.DeviceSide
+ *
+ * @param method the method to run
+ */
+ fun runDeviceTest(method: String) {
+ val deviceSideFile = HostUtils.copyResourceToHostFile(DEVICE_SIDE, tempFolder.newFile())
+ assertThat(device.installPackage(deviceSideFile, true)).isNull()
+ runDeviceTests(device, "com.android.server.pm.test.deviceside",
+ "com.android.server.pm.test.deviceside.DeviceSide", method)
+ }
+}
diff --git a/services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/Android.bp b/services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/Android.bp
new file mode 100644
index 0000000..af0ac77
--- /dev/null
+++ b/services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/Android.bp
@@ -0,0 +1,33 @@
+//
+// Copyright (C) 2019 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.
+//
+
+android_test_helper_app {
+ name: "PackageManagerServiceDeviceSideTests",
+ sdk_version: "test_current",
+ srcs: ["src/**/*.kt"],
+ libs: [
+ "android.test.base",
+ ],
+ static_libs: [
+ "androidx.annotation_annotation",
+ "junit",
+ "junit-params",
+ "androidx.test.ext.junit",
+ "androidx.test.rules",
+ "truth-prebuilt",
+ ],
+ platform_apis: true,
+}
diff --git a/services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/AndroidManifest.xml b/services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/AndroidManifest.xml
new file mode 100644
index 0000000..286ad56
--- /dev/null
+++ b/services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/AndroidManifest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2019 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.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.server.pm.test.deviceside">
+
+ <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
+
+ <instrumentation
+ android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.server.pm.test.deviceside" />
+</manifest>
+
diff --git a/services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/src/com/android/server/pm/cts/test/deviceside/DeviceSide.kt b/services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/src/com/android/server/pm/cts/test/deviceside/DeviceSide.kt
new file mode 100644
index 0000000..d140662
--- /dev/null
+++ b/services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/src/com/android/server/pm/cts/test/deviceside/DeviceSide.kt
@@ -0,0 +1,42 @@
+package com.android.server.pm.test.deviceside
+
+import android.content.pm.PackageManager.MATCH_FACTORY_ONLY
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.platform.app.InstrumentationRegistry
+import com.google.common.truth.Truth
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class DeviceSide {
+ companion object {
+ private const val TEST_PKG_NAME = "com.android.server.pm.test.test_app"
+ }
+
+ @Test
+ fun testGetInstalledPackagesWithFactoryOnly() {
+ val instrumentation = InstrumentationRegistry.getInstrumentation()
+ val uiAutomation = instrumentation.uiAutomation
+ val ctx = instrumentation.context
+
+ uiAutomation.adoptShellPermissionIdentity()
+ try {
+ val packages1 = ctx.packageManager.getInstalledPackages(0)
+ .filter { it.packageName == TEST_PKG_NAME }
+ val packages2 = ctx.packageManager.getInstalledPackages(MATCH_FACTORY_ONLY)
+ .filter { it.packageName == TEST_PKG_NAME }
+
+ Truth.assertWithMessage("Incorrect number of packages found")
+ .that(packages1.size).isEqualTo(1)
+ Truth.assertWithMessage("Incorrect number of packages found")
+ .that(packages2.size).isEqualTo(1)
+
+ Truth.assertWithMessage("Incorrect version code for updated package")
+ .that(packages1[0].longVersionCode).isEqualTo(2)
+ Truth.assertWithMessage("Incorrect version code for factory package")
+ .that(packages2[0].longVersionCode).isEqualTo(1)
+ } finally {
+ uiAutomation.dropShellPermissionIdentity()
+ }
+ }
+}
diff --git a/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java b/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java
index 1b2711d..82726c7 100644
--- a/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java
+++ b/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java
@@ -501,7 +501,7 @@
public void testUpdateOomAdj_DoOne_Backup() {
ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID,
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, true));
- BackupRecord backupTarget = new BackupRecord(null, 0, 0);
+ BackupRecord backupTarget = new BackupRecord(null, 0, 0, 0);
backupTarget.app = app;
doReturn(backupTarget).when(sService.mBackupTargets).get(anyInt());
sService.mWakefulness = PowerManagerInternal.WAKEFULNESS_AWAKE;
@@ -803,7 +803,7 @@
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
bindService(app, client, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class));
- BackupRecord backupTarget = new BackupRecord(null, 0, 0);
+ BackupRecord backupTarget = new BackupRecord(null, 0, 0, 0);
backupTarget.app = client;
doReturn(backupTarget).when(sService.mBackupTargets).get(anyInt());
sService.mWakefulness = PowerManagerInternal.WAKEFULNESS_AWAKE;
diff --git a/services/tests/mockingservicestests/src/com/android/server/location/LocationProviderManagerTest.java b/services/tests/mockingservicestests/src/com/android/server/location/LocationProviderManagerTest.java
index 1cb004a..fdcadf3 100644
--- a/services/tests/mockingservicestests/src/com/android/server/location/LocationProviderManagerTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/location/LocationProviderManagerTest.java
@@ -25,6 +25,7 @@
import static android.location.Criteria.ACCURACY_FINE;
import static android.location.Criteria.POWER_HIGH;
import static android.location.LocationManager.PASSIVE_PROVIDER;
+import static android.os.PowerManager.LOCATION_MODE_THROTTLE_REQUESTS_WHEN_SCREEN_OFF;
import static androidx.test.ext.truth.location.LocationSubject.assertThat;
@@ -907,6 +908,21 @@
assertThat(mProvider.getRequest().interval).isEqualTo(5);
}
+ @Test
+ public void testProviderRequest_BatterySaver_ScreenOnOff() {
+ mInjector.getLocationPowerSaveModeHelper().setLocationPowerSaveMode(
+ LOCATION_MODE_THROTTLE_REQUESTS_WHEN_SCREEN_OFF);
+
+ ILocationListener listener = createMockLocationListener();
+ LocationRequest request = LocationRequest.createFromDeprecatedProvider(NAME, 5, 0, false);
+ mManager.registerLocationRequest(request, IDENTITY, PERMISSION_FINE, listener);
+
+ assertThat(mProvider.getRequest().reportLocation).isTrue();
+
+ mInjector.getScreenInteractiveHelper().setScreenInteractive(false);
+ assertThat(mProvider.getRequest().reportLocation).isFalse();
+ }
+
private ILocationListener createMockLocationListener() {
return spy(new ILocationListener.Stub() {
@Override
diff --git a/services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/restrict-background-lists-whitelist-format.xml b/services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/restrict-background-lists-allowlist-format.xml
similarity index 100%
rename from services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/restrict-background-lists-whitelist-format.xml
rename to services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/restrict-background-lists-allowlist-format.xml
diff --git a/services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-whitelisted-restrict-background-off.xml b/services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-allowlisted-restrict-background-off.xml
similarity index 100%
rename from services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-whitelisted-restrict-background-off.xml
rename to services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-allowlisted-restrict-background-off.xml
diff --git a/services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-whitelisted-restrict-background-on.xml b/services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-allowlisted-restrict-background-on.xml
similarity index 100%
rename from services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-whitelisted-restrict-background-on.xml
rename to services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-allowlisted-restrict-background-on.xml
diff --git a/services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-blacklisted-restrict-background-off.xml b/services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-denylisted-restrict-background-off.xml
similarity index 100%
rename from services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-blacklisted-restrict-background-off.xml
rename to services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-denylisted-restrict-background-off.xml
diff --git a/services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-blacklisted-restrict-background-on.xml b/services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-denylisted-restrict-background-on.xml
similarity index 100%
rename from services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-blacklisted-restrict-background-on.xml
rename to services/tests/servicestests/assets/NetworkPolicyManagerServiceTest/netpolicy/uidA-denylisted-restrict-background-on.xml
diff --git a/services/tests/servicestests/src/com/android/server/VibratorServiceTest.java b/services/tests/servicestests/src/com/android/server/VibratorServiceTest.java
index 1b6ac3c..02d10e3 100644
--- a/services/tests/servicestests/src/com/android/server/VibratorServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/VibratorServiceTest.java
@@ -21,12 +21,13 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.intThat;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
@@ -65,6 +66,7 @@
import org.junit.Rule;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnit;
@@ -277,7 +279,7 @@
assertTrue(service.isVibrating());
verify(mNativeWrapperMock).vibratorOff();
- verify(mNativeWrapperMock).vibratorOn(eq(100L));
+ verify(mNativeWrapperMock).vibratorOn(eq(100L), any(VibratorService.Vibration.class));
verify(mNativeWrapperMock).vibratorSetAmplitude(eq(128));
}
@@ -290,7 +292,7 @@
assertTrue(service.isVibrating());
verify(mNativeWrapperMock).vibratorOff();
- verify(mNativeWrapperMock).vibratorOn(eq(100L));
+ verify(mNativeWrapperMock).vibratorOn(eq(100L), any(VibratorService.Vibration.class));
verify(mNativeWrapperMock, never()).vibratorSetAmplitude(anyInt());
}
@@ -307,7 +309,7 @@
verify(mNativeWrapperMock).vibratorPerformEffect(
eq((long) VibrationEffect.EFFECT_CLICK),
eq((long) VibrationEffect.EFFECT_STRENGTH_STRONG),
- any(VibratorService.Vibration.class), eq(false));
+ any(VibratorService.Vibration.class));
}
@Test
@@ -344,76 +346,138 @@
Mockito.clearInvocations(mNativeWrapperMock);
VibrationEffect effect = VibrationEffect.createWaveform(
- new long[] { 10, 10, 10 }, new int[] { 100, 200, 50 }, -1);
+ new long[]{10, 10, 10}, new int[]{100, 200, 50}, -1);
vibrate(service, effect);
verify(mNativeWrapperMock).vibratorOff();
+ // Wait for VibrateThread to turn vibrator ON with total timing and no callback.
Thread.sleep(5);
- verify(mNativeWrapperMock).vibratorOn(eq(30L));
+ verify(mNativeWrapperMock).vibratorOn(eq(30L), isNull());
+
+ // First amplitude set right away.
verify(mNativeWrapperMock).vibratorSetAmplitude(eq(100));
+ // Second amplitude set after first timing is finished.
Thread.sleep(10);
verify(mNativeWrapperMock).vibratorSetAmplitude(eq(200));
+ // Third amplitude set after second timing is finished.
Thread.sleep(10);
verify(mNativeWrapperMock).vibratorSetAmplitude(eq(50));
}
@Test
- public void vibrate_withCallback_finishesVibrationWhenCallbackTriggered() {
- mockVibratorCapabilities(IVibrator.CAP_COMPOSE_EFFECTS);
+ public void vibrate_withOneShotAndNativeCallbackTriggered_finishesVibration() {
+ doAnswer(invocation -> {
+ ((VibratorService.Vibration) invocation.getArgument(1)).onComplete();
+ return null;
+ }).when(mNativeWrapperMock).vibratorOn(anyLong(), any(VibratorService.Vibration.class));
VibratorService service = createService();
Mockito.clearInvocations(mNativeWrapperMock);
+ vibrate(service, VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE));
+
+ InOrder inOrderVerifier = inOrder(mNativeWrapperMock);
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorOff();
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorOn(eq(100L),
+ any(VibratorService.Vibration.class));
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorOff();
+ }
+
+ @Test
+ public void vibrate_withPrebakedAndNativeCallbackTriggered_finishesVibration() {
+ when(mNativeWrapperMock.vibratorGetSupportedEffects())
+ .thenReturn(new int[]{VibrationEffect.EFFECT_CLICK});
+ doAnswer(invocation -> {
+ ((VibratorService.Vibration) invocation.getArgument(2)).onComplete();
+ return 10_000L; // 10s
+ }).when(mNativeWrapperMock).vibratorPerformEffect(
+ anyLong(), anyLong(), any(VibratorService.Vibration.class));
+ VibratorService service = createService();
+ Mockito.clearInvocations(mNativeWrapperMock);
+
+ vibrate(service, VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK));
+
+ InOrder inOrderVerifier = inOrder(mNativeWrapperMock);
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorOff();
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorPerformEffect(
+ eq((long) VibrationEffect.EFFECT_CLICK),
+ eq((long) VibrationEffect.EFFECT_STRENGTH_STRONG),
+ any(VibratorService.Vibration.class));
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorOff();
+ }
+
+ @Test
+ public void vibrate_withWaveformAndNativeCallback_callbackCannotBeTriggeredByNative()
+ throws Exception {
+ VibratorService service = createService();
+ Mockito.clearInvocations(mNativeWrapperMock);
+
+ VibrationEffect effect = VibrationEffect.createWaveform(new long[]{1, 3, 1, 2}, -1);
+ vibrate(service, effect);
+
+ // Wait for VibrateThread to finish: 1ms OFF, 3ms ON, 1ms OFF, 2ms ON.
+ Thread.sleep(15);
+ InOrder inOrderVerifier = inOrder(mNativeWrapperMock);
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorOff();
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorOn(eq(3L), isNull());
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorOn(eq(2L), isNull());
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorOff();
+ }
+
+ @Test
+ public void vibrate_withComposedAndNativeCallbackTriggered_finishesVibration() {
+ mockVibratorCapabilities(IVibrator.CAP_COMPOSE_EFFECTS);
doAnswer(invocation -> {
((VibratorService.Vibration) invocation.getArgument(1)).onComplete();
return null;
}).when(mNativeWrapperMock).vibratorPerformComposedEffect(
any(), any(VibratorService.Vibration.class));
+ VibratorService service = createService();
+ Mockito.clearInvocations(mNativeWrapperMock);
- // Use vibration with delay so there is time for the callback to be triggered.
VibrationEffect effect = VibrationEffect.startComposition()
.addPrimitive(VibrationEffect.Composition.PRIMITIVE_CLICK, 1f, 10)
.compose();
vibrate(service, effect);
- // Vibration canceled once before perform and once by native callback.
- verify(mNativeWrapperMock, times(2)).vibratorOff();
- verify(mNativeWrapperMock).vibratorPerformComposedEffect(
+ InOrder inOrderVerifier = inOrder(mNativeWrapperMock);
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorOff();
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorPerformComposedEffect(
any(VibrationEffect.Composition.PrimitiveEffect[].class),
any(VibratorService.Vibration.class));
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorOff();
}
@Test
public void vibrate_whenBinderDies_cancelsVibration() {
mockVibratorCapabilities(IVibrator.CAP_COMPOSE_EFFECTS);
- VibratorService service = createService();
- Mockito.clearInvocations(mNativeWrapperMock);
-
doAnswer(invocation -> {
((VibratorService.Vibration) invocation.getArgument(1)).binderDied();
return null;
}).when(mNativeWrapperMock).vibratorPerformComposedEffect(
any(), any(VibratorService.Vibration.class));
+ VibratorService service = createService();
+ Mockito.clearInvocations(mNativeWrapperMock);
- // Use vibration with delay so there is time for the callback to be triggered.
VibrationEffect effect = VibrationEffect.startComposition()
.addPrimitive(VibrationEffect.Composition.PRIMITIVE_CLICK, 1f, 10)
.compose();
vibrate(service, effect);
- // Vibration canceled once before perform and once by native binder death.
- verify(mNativeWrapperMock, times(2)).vibratorOff();
- verify(mNativeWrapperMock).vibratorPerformComposedEffect(
+ InOrder inOrderVerifier = inOrder(mNativeWrapperMock);
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorOff();
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorPerformComposedEffect(
any(VibrationEffect.Composition.PrimitiveEffect[].class),
any(VibratorService.Vibration.class));
+ inOrderVerifier.verify(mNativeWrapperMock).vibratorOff();
}
@Test
public void cancelVibrate_withDeviceVibrating_callsVibratorOff() {
VibratorService service = createService();
- vibrate(service, VibrationEffect.createOneShot(100, 128));
+ vibrate(service, VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE));
assertTrue(service.isVibrating());
Mockito.clearInvocations(mNativeWrapperMock);
@@ -434,18 +498,20 @@
@Test
public void registerVibratorStateListener_callbacksAreTriggered() throws Exception {
+ doAnswer(invocation -> {
+ ((VibratorService.Vibration) invocation.getArgument(1)).onComplete();
+ return null;
+ }).when(mNativeWrapperMock).vibratorOn(anyLong(), any(VibratorService.Vibration.class));
VibratorService service = createService();
service.registerVibratorStateListener(mVibratorStateListenerMock);
verify(mVibratorStateListenerMock).onVibrating(false);
+ Mockito.clearInvocations(mVibratorStateListenerMock);
vibrate(service, VibrationEffect.createOneShot(10, VibrationEffect.DEFAULT_AMPLITUDE));
- verify(mVibratorStateListenerMock).onVibrating(true);
-
- // Run the scheduled callback to finish one-shot vibration.
- mTestLooper.moveTimeForward(10);
- mTestLooper.dispatchAll();
- verify(mVibratorStateListenerMock, times(2)).onVibrating(false);
+ InOrder inOrderVerifier = inOrder(mVibratorStateListenerMock);
+ inOrderVerifier.verify(mVibratorStateListenerMock).onVibrating(eq(true));
+ inOrderVerifier.verify(mVibratorStateListenerMock).onVibrating(eq(false));
}
@Test
@@ -488,15 +554,15 @@
verify(mNativeWrapperMock).vibratorPerformEffect(
eq((long) VibrationEffect.EFFECT_CLICK),
- eq((long) VibrationEffect.EFFECT_STRENGTH_STRONG), any(), anyBoolean());
+ eq((long) VibrationEffect.EFFECT_STRENGTH_STRONG), any());
verify(mNativeWrapperMock).vibratorPerformEffect(
eq((long) VibrationEffect.EFFECT_TICK),
- eq((long) VibrationEffect.EFFECT_STRENGTH_MEDIUM), any(), anyBoolean());
+ eq((long) VibrationEffect.EFFECT_STRENGTH_MEDIUM), any());
verify(mNativeWrapperMock).vibratorPerformEffect(
eq((long) VibrationEffect.EFFECT_DOUBLE_CLICK),
- eq((long) VibrationEffect.EFFECT_STRENGTH_LIGHT), any(), anyBoolean());
+ eq((long) VibrationEffect.EFFECT_STRENGTH_LIGHT), any());
verify(mNativeWrapperMock, never()).vibratorPerformEffect(
- eq((long) VibrationEffect.EFFECT_HEAVY_CLICK), anyLong(), any(), anyBoolean());
+ eq((long) VibrationEffect.EFFECT_HEAVY_CLICK), anyLong(), any());
}
@Test
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 6450a0f..763654d 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
@@ -42,6 +42,7 @@
import android.testing.DexmakerShareClassLoaderRule;
import android.view.InputDevice;
import android.view.MotionEvent;
+import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
import androidx.test.InstrumentationRegistry;
@@ -87,6 +88,8 @@
private MotionEvent mLastEvent;
private TestHandler mHandler;
private TouchExplorer mTouchExplorer;
+ private Context mContext;
+ private int mTouchSlop;
private long mLastDownTime = Integer.MIN_VALUE;
// mock package-private GestureManifold class
@@ -121,12 +124,13 @@
if (Looper.myLooper() == null) {
Looper.prepare();
}
- Context context = InstrumentationRegistry.getContext();
- AccessibilityManagerService ams = new AccessibilityManagerService(context);
+ mContext = InstrumentationRegistry.getContext();
+ mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop();
+ AccessibilityManagerService ams = new AccessibilityManagerService(mContext);
GestureManifold detector = mock(GestureManifold.class);
mCaptor = new EventCaptor();
mHandler = new TestHandler();
- mTouchExplorer = new TouchExplorer(context, ams, detector, mHandler);
+ mTouchExplorer = new TouchExplorer(mContext, ams, detector, mHandler);
mTouchExplorer.setNext(mCaptor);
}
@@ -354,12 +358,12 @@
break;
case STATE_DRAGGING_2FINGERS:
goFromStateClearTo(STATE_TOUCH_EXPLORING_2FINGER);
- moveEachPointers(mLastEvent, p(10, 0), p(10, 0));
+ moveEachPointers(mLastEvent, p(mTouchSlop, 0), p(mTouchSlop, 0));
send(mLastEvent);
break;
case STATE_PINCH_2FINGERS:
goFromStateClearTo(STATE_DRAGGING_2FINGERS);
- moveEachPointers(mLastEvent, p(10, 0), p(-10, 1));
+ moveEachPointers(mLastEvent, p(mTouchSlop, 0), p(-mTouchSlop, 1));
send(mLastEvent);
break;
case STATE_MOVING_3FINGERS:
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
index 9a465a91..8fc2287 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -1604,7 +1604,7 @@
dpm.setApplicationRestrictionsManagingPackage(admin1, RESTRICTIONS_DELEGATE);
// DPMS correctly stores and retrieves the delegates
- DevicePolicyManagerService.DevicePolicyData policy = dpms.mUserData.get(userHandle);
+ DevicePolicyData policy = dpms.mUserData.get(userHandle);
assertEquals(2, policy.mDelegationMap.size());
MoreAsserts.assertContentsInAnyOrder(policy.mDelegationMap.get(CERT_DELEGATE),
DELEGATION_CERT_INSTALL);
@@ -1846,11 +1846,11 @@
reset(getServices().userManagerInternal);
}
- private DevicePolicyManagerService.ActiveAdmin getDeviceOwner() {
+ private ActiveAdmin getDeviceOwner() {
ComponentName component = dpms.mOwners.getDeviceOwnerComponent();
- DevicePolicyManagerService.DevicePolicyData policy =
+ DevicePolicyData policy =
dpms.getUserData(dpms.mOwners.getDeviceOwnerUserId());
- for (DevicePolicyManagerService.ActiveAdmin admin : policy.mAdminList) {
+ for (ActiveAdmin admin : policy.mAdminList) {
if (component.equals(admin.info.getComponent())) {
return admin;
}
@@ -3745,8 +3745,7 @@
setUserSetupCompleteForUser(false, userId);
// GIVEN userComplete is true in DPM
- DevicePolicyManagerService.DevicePolicyData userData =
- new DevicePolicyManagerService.DevicePolicyData(userId);
+ DevicePolicyData userData = new DevicePolicyData(userId);
userData.mUserSetupComplete = true;
dpms.mUserData.put(UserHandle.USER_SYSTEM, userData);
@@ -3770,8 +3769,7 @@
setUserSetupCompleteForUser(false, userId);
// GIVEN userComplete is true in DPM
- DevicePolicyManagerService.DevicePolicyData userData =
- new DevicePolicyManagerService.DevicePolicyData(userId);
+ DevicePolicyData userData = new DevicePolicyData(userId);
userData.mUserSetupComplete = true;
dpms.mUserData.put(UserHandle.USER_SYSTEM, userData);
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDevicePlaybackTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDevicePlaybackTest.java
index 960a7ab..ef2365e 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDevicePlaybackTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDevicePlaybackTest.java
@@ -16,7 +16,6 @@
package com.android.server.hdmi;
import static com.android.server.hdmi.Constants.ADDR_BROADCAST;
-import static com.android.server.hdmi.Constants.ADDR_PLAYBACK_1;
import static com.android.server.hdmi.Constants.ADDR_TV;
import static com.android.server.hdmi.HdmiControlService.INITIATED_BY_ENABLE_CEC;
@@ -62,6 +61,7 @@
private TestLooper mTestLooper = new TestLooper();
private ArrayList<HdmiCecLocalDevice> mLocalDevices = new ArrayList<>();
private int mPlaybackPhysicalAddress;
+ private int mPlaybackLogicalAddress;
private boolean mWokenUp;
private boolean mStandby;
@@ -129,6 +129,7 @@
mPlaybackPhysicalAddress = 0x2000;
mNativeWrapper.setPhysicalAddress(mPlaybackPhysicalAddress);
mTestLooper.dispatchAll();
+ mPlaybackLogicalAddress = mHdmiCecLocalDevicePlayback.getDeviceInfo().getLogicalAddress();
mNativeWrapper.clearResultMessages();
}
@@ -144,7 +145,7 @@
mPlaybackPhysicalAddress);
HdmiCecMessage expectedMessage =
- HdmiCecMessageBuilder.buildActiveSource(ADDR_PLAYBACK_1,
+ HdmiCecMessageBuilder.buildActiveSource(mPlaybackLogicalAddress,
mPlaybackPhysicalAddress);
assertThat(mHdmiCecLocalDevicePlayback.handleRoutingChange(message)).isTrue();
@@ -165,7 +166,7 @@
mPlaybackPhysicalAddress);
HdmiCecMessage expectedMessage =
- HdmiCecMessageBuilder.buildActiveSource(ADDR_PLAYBACK_1,
+ HdmiCecMessageBuilder.buildActiveSource(mPlaybackLogicalAddress,
mPlaybackPhysicalAddress);
assertThat(mHdmiCecLocalDevicePlayback.handleRoutingInformation(message)).isTrue();
@@ -186,7 +187,7 @@
mPlaybackPhysicalAddress);
HdmiCecMessage expectedMessage =
- HdmiCecMessageBuilder.buildActiveSource(ADDR_PLAYBACK_1,
+ HdmiCecMessageBuilder.buildActiveSource(mPlaybackLogicalAddress,
mPlaybackPhysicalAddress);
assertThat(mHdmiCecLocalDevicePlayback.handleRoutingChange(message)).isTrue();
@@ -207,7 +208,7 @@
mPlaybackPhysicalAddress);
HdmiCecMessage expectedMessage =
- HdmiCecMessageBuilder.buildActiveSource(ADDR_PLAYBACK_1,
+ HdmiCecMessageBuilder.buildActiveSource(mPlaybackLogicalAddress,
mPlaybackPhysicalAddress);
assertThat(mHdmiCecLocalDevicePlayback.handleRoutingInformation(message)).isTrue();
@@ -230,7 +231,7 @@
mPlaybackPhysicalAddress);
HdmiCecMessage expectedMessage =
- HdmiCecMessageBuilder.buildActiveSource(ADDR_PLAYBACK_1,
+ HdmiCecMessageBuilder.buildActiveSource(mPlaybackLogicalAddress,
mPlaybackPhysicalAddress);
assertThat(mHdmiCecLocalDevicePlayback.handleRoutingChange(message)).isTrue();
@@ -253,7 +254,7 @@
mPlaybackPhysicalAddress);
HdmiCecMessage expectedMessage =
- HdmiCecMessageBuilder.buildActiveSource(ADDR_PLAYBACK_1,
+ HdmiCecMessageBuilder.buildActiveSource(mPlaybackLogicalAddress,
mPlaybackPhysicalAddress);
assertThat(mHdmiCecLocalDevicePlayback.handleRoutingInformation(message)).isTrue();
@@ -262,6 +263,112 @@
assertThat(mNativeWrapper.getResultMessages()).contains(expectedMessage);
}
+ @Test
+ public void handleRoutingChange_otherDevice_None() {
+ mHdmiCecLocalDevicePlayback.mPowerStateChangeOnActiveSourceLost =
+ HdmiProperties.power_state_change_on_active_source_lost_values.NONE;
+ mHdmiCecLocalDevicePlayback.setIsActiveSource(true);
+ mStandby = false;
+ HdmiCecMessage message =
+ HdmiCecMessageBuilder.buildRoutingChange(ADDR_TV, 0x0000, 0x5000);
+ assertThat(mHdmiCecLocalDevicePlayback.handleRoutingChange(message)).isTrue();
+ assertThat(mHdmiCecLocalDevicePlayback.mIsActiveSource).isFalse();
+ assertThat(mStandby).isFalse();
+ }
+
+ @Test
+ public void handleRoutingChange_otherDevice_StandbyNow() {
+ mHdmiCecLocalDevicePlayback.mPowerStateChangeOnActiveSourceLost =
+ HdmiProperties.power_state_change_on_active_source_lost_values.STANDBY_NOW;
+ mHdmiCecLocalDevicePlayback.setIsActiveSource(true);
+ mStandby = false;
+ HdmiCecMessage message =
+ HdmiCecMessageBuilder.buildRoutingChange(ADDR_TV, 0x0000, 0x5000);
+ assertThat(mHdmiCecLocalDevicePlayback.handleRoutingChange(message)).isTrue();
+ assertThat(mHdmiCecLocalDevicePlayback.mIsActiveSource).isFalse();
+ assertThat(mStandby).isTrue();
+ }
+
+ @Test
+ public void handleRoutingChange_otherDevice_StandbyNow_InactiveSource() {
+ mHdmiCecLocalDevicePlayback.mPowerStateChangeOnActiveSourceLost =
+ HdmiProperties.power_state_change_on_active_source_lost_values.STANDBY_NOW;
+ mHdmiCecLocalDevicePlayback.setIsActiveSource(false);
+ mStandby = false;
+ HdmiCecMessage message =
+ HdmiCecMessageBuilder.buildRoutingChange(ADDR_TV, 0x0000, 0x5000);
+ assertThat(mHdmiCecLocalDevicePlayback.handleRoutingChange(message)).isTrue();
+ assertThat(mHdmiCecLocalDevicePlayback.mIsActiveSource).isFalse();
+ assertThat(mStandby).isFalse();
+ }
+
+ @Test
+ public void handleRoutingChange_sameDevice_StandbyNow_ActiveSource() {
+ mHdmiCecLocalDevicePlayback.mPowerStateChangeOnActiveSourceLost =
+ HdmiProperties.power_state_change_on_active_source_lost_values.STANDBY_NOW;
+ mHdmiCecLocalDevicePlayback.setIsActiveSource(true);
+ mStandby = false;
+ HdmiCecMessage message =
+ HdmiCecMessageBuilder.buildRoutingChange(ADDR_TV, 0x0000,
+ mPlaybackPhysicalAddress);
+ assertThat(mHdmiCecLocalDevicePlayback.handleRoutingChange(message)).isTrue();
+ assertThat(mHdmiCecLocalDevicePlayback.mIsActiveSource).isTrue();
+ assertThat(mStandby).isFalse();
+ }
+
+ @Test
+ public void handleRoutingInformation_otherDevice_None() {
+ mHdmiCecLocalDevicePlayback.mPowerStateChangeOnActiveSourceLost =
+ HdmiProperties.power_state_change_on_active_source_lost_values.NONE;
+ mHdmiCecLocalDevicePlayback.setIsActiveSource(true);
+ mStandby = false;
+ HdmiCecMessage message =
+ HdmiCecMessageBuilder.buildRoutingInformation(ADDR_TV, 0x5000);
+ assertThat(mHdmiCecLocalDevicePlayback.handleRoutingInformation(message)).isTrue();
+ assertThat(mHdmiCecLocalDevicePlayback.mIsActiveSource).isFalse();
+ assertThat(mStandby).isFalse();
+ }
+
+ @Test
+ public void handleRoutingInformation_otherDevice_StandbyNow() {
+ mHdmiCecLocalDevicePlayback.mPowerStateChangeOnActiveSourceLost =
+ HdmiProperties.power_state_change_on_active_source_lost_values.STANDBY_NOW;
+ mHdmiCecLocalDevicePlayback.setIsActiveSource(true);
+ mStandby = false;
+ HdmiCecMessage message =
+ HdmiCecMessageBuilder.buildRoutingInformation(ADDR_TV, 0x5000);
+ assertThat(mHdmiCecLocalDevicePlayback.handleRoutingInformation(message)).isTrue();
+ assertThat(mHdmiCecLocalDevicePlayback.mIsActiveSource).isFalse();
+ assertThat(mStandby).isTrue();
+ }
+
+ @Test
+ public void handleRoutingInformation_otherDevice_StandbyNow_InactiveSource() {
+ mHdmiCecLocalDevicePlayback.mPowerStateChangeOnActiveSourceLost =
+ HdmiProperties.power_state_change_on_active_source_lost_values.STANDBY_NOW;
+ mHdmiCecLocalDevicePlayback.setIsActiveSource(false);
+ mStandby = false;
+ HdmiCecMessage message =
+ HdmiCecMessageBuilder.buildRoutingInformation(ADDR_TV, 0x5000);
+ assertThat(mHdmiCecLocalDevicePlayback.handleRoutingInformation(message)).isTrue();
+ assertThat(mHdmiCecLocalDevicePlayback.mIsActiveSource).isFalse();
+ assertThat(mStandby).isFalse();
+ }
+
+ @Test
+ public void handleRoutingInformation_sameDevice_StandbyNow_ActiveSource() {
+ mHdmiCecLocalDevicePlayback.mPowerStateChangeOnActiveSourceLost =
+ HdmiProperties.power_state_change_on_active_source_lost_values.STANDBY_NOW;
+ mHdmiCecLocalDevicePlayback.setIsActiveSource(true);
+ mStandby = false;
+ HdmiCecMessage message =
+ HdmiCecMessageBuilder.buildRoutingInformation(ADDR_TV,
+ mPlaybackPhysicalAddress);
+ assertThat(mHdmiCecLocalDevicePlayback.handleRoutingInformation(message)).isTrue();
+ assertThat(mHdmiCecLocalDevicePlayback.mIsActiveSource).isTrue();
+ assertThat(mStandby).isFalse();
+ }
+
// Playback device does not handle routing control related feature right now
@Ignore("b/120845532")
@Test
@@ -442,7 +549,7 @@
mHdmiCecLocalDevicePlayback.mPowerStateChangeOnActiveSourceLost =
HdmiProperties.power_state_change_on_active_source_lost_values.NONE;
mStandby = false;
- HdmiCecMessage message = HdmiCecMessageBuilder.buildActiveSource(ADDR_PLAYBACK_1,
+ HdmiCecMessage message = HdmiCecMessageBuilder.buildActiveSource(mPlaybackLogicalAddress,
mPlaybackPhysicalAddress);
assertThat(mHdmiCecLocalDevicePlayback.handleActiveSource(message)).isTrue();
mTestLooper.dispatchAll();
@@ -465,7 +572,7 @@
mHdmiCecLocalDevicePlayback.mPowerStateChangeOnActiveSourceLost =
HdmiProperties.power_state_change_on_active_source_lost_values.STANDBY_NOW;
mStandby = false;
- HdmiCecMessage message = HdmiCecMessageBuilder.buildActiveSource(ADDR_PLAYBACK_1,
+ HdmiCecMessage message = HdmiCecMessageBuilder.buildActiveSource(mPlaybackLogicalAddress,
mPlaybackPhysicalAddress);
assertThat(mHdmiCecLocalDevicePlayback.handleActiveSource(message)).isTrue();
mTestLooper.dispatchAll();
@@ -629,4 +736,43 @@
mHdmiCecLocalDevicePlayback.getDeviceInfo().getLogicalAddress());
assertThat(mHdmiCecLocalDevicePlayback.mIsActiveSource).isTrue();
}
+
+ @Test
+ public void handleSetStreamPath_otherDevice_None() {
+ mHdmiCecLocalDevicePlayback.mPowerStateChangeOnActiveSourceLost =
+ HdmiProperties.power_state_change_on_active_source_lost_values.NONE;
+ mHdmiCecLocalDevicePlayback.setIsActiveSource(true);
+ mStandby = false;
+ HdmiCecMessage message =
+ HdmiCecMessageBuilder.buildSetStreamPath(ADDR_TV, 0x5000);
+ assertThat(mHdmiCecLocalDevicePlayback.handleSetStreamPath(message)).isTrue();
+ assertThat(mHdmiCecLocalDevicePlayback.mIsActiveSource).isFalse();
+ assertThat(mStandby).isFalse();
+ }
+
+ @Test
+ public void handleSetStreamPath_otherDevice_StandbyNow() {
+ mHdmiCecLocalDevicePlayback.mPowerStateChangeOnActiveSourceLost =
+ HdmiProperties.power_state_change_on_active_source_lost_values.STANDBY_NOW;
+ mHdmiCecLocalDevicePlayback.setIsActiveSource(true);
+ mStandby = false;
+ HdmiCecMessage message =
+ HdmiCecMessageBuilder.buildSetStreamPath(ADDR_TV, 0x5000);
+ assertThat(mHdmiCecLocalDevicePlayback.handleSetStreamPath(message)).isTrue();
+ assertThat(mHdmiCecLocalDevicePlayback.mIsActiveSource).isFalse();
+ assertThat(mStandby).isTrue();
+ }
+
+ @Test
+ public void handleSetStreamPath_otherDevice_StandbyNow_InactiveSource() {
+ mHdmiCecLocalDevicePlayback.mPowerStateChangeOnActiveSourceLost =
+ HdmiProperties.power_state_change_on_active_source_lost_values.STANDBY_NOW;
+ mHdmiCecLocalDevicePlayback.setIsActiveSource(false);
+ mStandby = false;
+ HdmiCecMessage message =
+ HdmiCecMessageBuilder.buildSetStreamPath(ADDR_TV, 0x5000);
+ assertThat(mHdmiCecLocalDevicePlayback.handleSetStreamPath(message)).isTrue();
+ assertThat(mHdmiCecLocalDevicePlayback.mIsActiveSource).isFalse();
+ assertThat(mStandby).isFalse();
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsServiceTests.java b/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsServiceTests.java
index 12b144f..1f66c7c 100644
--- a/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsServiceTests.java
+++ b/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsServiceTests.java
@@ -129,7 +129,7 @@
mGateKeeperService.clearAuthToken(TURNED_OFF_PROFILE_USER_ID);
// verify credential
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- firstUnifiedPassword, 0, PRIMARY_USER_ID)
+ firstUnifiedPassword, PRIMARY_USER_ID, 0 /* flags */)
.getResponseCode());
// Verify that we have a new auth token for the profile
@@ -186,13 +186,13 @@
mGateKeeperService.clearAuthToken(MANAGED_PROFILE_USER_ID);
// verify primary credential
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- primaryPassword, 0, PRIMARY_USER_ID)
+ primaryPassword, PRIMARY_USER_ID, 0 /* flags */)
.getResponseCode());
assertNull(mGateKeeperService.getAuthToken(MANAGED_PROFILE_USER_ID));
// verify profile credential
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- profilePassword, 0, MANAGED_PROFILE_USER_ID)
+ profilePassword, MANAGED_PROFILE_USER_ID, 0 /* flags */)
.getResponseCode());
assertNotNull(mGateKeeperService.getAuthToken(MANAGED_PROFILE_USER_ID));
assertEquals(profileSid, mGateKeeperService.getSecureUserId(MANAGED_PROFILE_USER_ID));
@@ -203,7 +203,7 @@
newPassword("pwd"), primaryPassword, PRIMARY_USER_ID));
mStorageManager.setIgnoreBadUnlock(false);
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- profilePassword, 0, MANAGED_PROFILE_USER_ID)
+ profilePassword, MANAGED_PROFILE_USER_ID, 0 /* flags */)
.getResponseCode());
assertEquals(profileSid, mGateKeeperService.getSecureUserId(MANAGED_PROFILE_USER_ID));
}
@@ -389,7 +389,7 @@
initializeStorageWithCredential(PRIMARY_USER_ID, password, 1234);
reset(mRecoverableKeyStoreManager);
- mService.verifyCredential(password, 1, PRIMARY_USER_ID);
+ mService.verifyCredential(password, PRIMARY_USER_ID, 0 /* flags */);
verify(mRecoverableKeyStoreManager)
.lockScreenSecretAvailable(
@@ -406,7 +406,7 @@
MANAGED_PROFILE_USER_ID));
reset(mRecoverableKeyStoreManager);
- mService.verifyCredential(pattern, 1, MANAGED_PROFILE_USER_ID);
+ mService.verifyCredential(pattern, MANAGED_PROFILE_USER_ID, 0 /* flags */);
verify(mRecoverableKeyStoreManager)
.lockScreenSecretAvailable(
@@ -421,7 +421,7 @@
mService.setSeparateProfileChallengeEnabled(MANAGED_PROFILE_USER_ID, false, null);
reset(mRecoverableKeyStoreManager);
- mService.verifyCredential(pattern, 1, PRIMARY_USER_ID);
+ mService.verifyCredential(pattern, PRIMARY_USER_ID, 0 /* flags */);
// Parent sends its credentials for both the parent and profile.
verify(mRecoverableKeyStoreManager)
@@ -484,9 +484,8 @@
private void assertVerifyCredentials(int userId, LockscreenCredential credential, long sid)
throws RemoteException{
- final long challenge = 54321;
- VerifyCredentialResponse response = mService.verifyCredential(credential,
- challenge, userId);
+ VerifyCredentialResponse response = mService.verifyCredential(credential, userId,
+ 0 /* flags */);
assertEquals(GateKeeperResponse.RESPONSE_OK, response.getResponseCode());
if (sid != -1) assertEquals(sid, mGateKeeperService.getSecureUserId(userId));
@@ -508,7 +507,7 @@
badCredential = LockscreenCredential.createPin("0");
}
assertEquals(GateKeeperResponse.RESPONSE_ERROR, mService.verifyCredential(
- badCredential, challenge, userId).getResponseCode());
+ badCredential, userId, 0 /* flags */).getResponseCode());
}
private void initializeStorageWithCredential(int userId, LockscreenCredential credential,
diff --git a/services/tests/servicestests/src/com/android/server/locksettings/LockscreenFrpTest.java b/services/tests/servicestests/src/com/android/server/locksettings/LockscreenFrpTest.java
index 4b3f7b5..9c0239b 100644
--- a/services/tests/servicestests/src/com/android/server/locksettings/LockscreenFrpTest.java
+++ b/services/tests/servicestests/src/com/android/server/locksettings/LockscreenFrpTest.java
@@ -52,7 +52,8 @@
assertEquals(CREDENTIAL_TYPE_PIN, mService.getCredentialType(USER_FRP));
assertEquals(VerifyCredentialResponse.RESPONSE_OK,
- mService.verifyCredential(newPin("1234"), 0, USER_FRP).getResponseCode());
+ mService.verifyCredential(newPin("1234"), USER_FRP, 0 /* flags */)
+ .getResponseCode());
}
@Test
@@ -61,7 +62,8 @@
assertEquals(CREDENTIAL_TYPE_PATTERN, mService.getCredentialType(USER_FRP));
assertEquals(VerifyCredentialResponse.RESPONSE_OK,
- mService.verifyCredential(newPattern("4321"), 0, USER_FRP).getResponseCode());
+ mService.verifyCredential(newPattern("4321"), USER_FRP, 0 /* flags */)
+ .getResponseCode());
}
@Test
@@ -70,7 +72,8 @@
assertEquals(CREDENTIAL_TYPE_PASSWORD, mService.getCredentialType(USER_FRP));
assertEquals(VerifyCredentialResponse.RESPONSE_OK,
- mService.verifyCredential(newPassword("4321"), 0, USER_FRP).getResponseCode());
+ mService.verifyCredential(newPassword("4321"), USER_FRP, 0 /* flags */)
+ .getResponseCode());
}
@Test
@@ -80,7 +83,8 @@
assertEquals(CREDENTIAL_TYPE_PATTERN, mService.getCredentialType(USER_FRP));
assertEquals(VerifyCredentialResponse.RESPONSE_OK,
- mService.verifyCredential(newPattern("5678"), 0, USER_FRP).getResponseCode());
+ mService.verifyCredential(newPattern("5678"), USER_FRP, 0 /* flags */)
+ .getResponseCode());
}
@Test
@@ -98,7 +102,8 @@
mSettings.setDeviceProvisioned(true);
assertEquals(VerifyCredentialResponse.RESPONSE_ERROR,
- mService.verifyCredential(newPin("1234"), 0, USER_FRP).getResponseCode());
+ mService.verifyCredential(newPin("1234"), USER_FRP, 0 /* flags */)
+ .getResponseCode());
}
@Test
@@ -113,7 +118,8 @@
assertEquals(CREDENTIAL_TYPE_PIN, mService.getCredentialType(USER_FRP));
assertEquals(VerifyCredentialResponse.RESPONSE_OK,
- mService.verifyCredential(newPin("1234"), 0, USER_FRP).getResponseCode());
+ mService.verifyCredential(newPin("1234"), USER_FRP, 0 /* flags */)
+ .getResponseCode());
}
@@ -129,6 +135,7 @@
assertEquals(CREDENTIAL_TYPE_PASSWORD, mService.getCredentialType(USER_FRP));
assertEquals(VerifyCredentialResponse.RESPONSE_OK,
- mService.verifyCredential(newPin("1234"), 0, USER_FRP).getResponseCode());
+ mService.verifyCredential(newPin("1234"), USER_FRP, 0 /* flags */)
+ .getResponseCode());
}
}
diff --git a/services/tests/servicestests/src/com/android/server/locksettings/SyntheticPasswordTests.java b/services/tests/servicestests/src/com/android/server/locksettings/SyntheticPasswordTests.java
index ba85199..2bd0e55 100644
--- a/services/tests/servicestests/src/com/android/server/locksettings/SyntheticPasswordTests.java
+++ b/services/tests/servicestests/src/com/android/server/locksettings/SyntheticPasswordTests.java
@@ -119,8 +119,7 @@
long sid = mGateKeeperService.getSecureUserId(PRIMARY_USER_ID);
mService.setLockCredential(newPassword, password, PRIMARY_USER_ID);
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- newPassword, 0, PRIMARY_USER_ID)
- .getResponseCode());
+ newPassword, PRIMARY_USER_ID, 0 /* flags */).getResponseCode());
assertEquals(sid, mGateKeeperService.getSecureUserId(PRIMARY_USER_ID));
}
@@ -131,12 +130,10 @@
initializeCredentialUnderSP(password, PRIMARY_USER_ID);
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- password, 0, PRIMARY_USER_ID)
- .getResponseCode());
+ password, PRIMARY_USER_ID, 0 /* flags */).getResponseCode());
assertEquals(VerifyCredentialResponse.RESPONSE_ERROR, mService.verifyCredential(
- badPassword, 0, PRIMARY_USER_ID)
- .getResponseCode());
+ badPassword, PRIMARY_USER_ID, 0 /* flags */).getResponseCode());
}
@Test
@@ -153,8 +150,7 @@
// set a new password
mService.setLockCredential(badPassword, nonePassword(), PRIMARY_USER_ID);
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- badPassword, 0, PRIMARY_USER_ID)
- .getResponseCode());
+ badPassword, PRIMARY_USER_ID, 0 /* flags */).getResponseCode());
assertNotEquals(sid, mGateKeeperService.getSecureUserId(PRIMARY_USER_ID));
}
@@ -166,8 +162,7 @@
initializeCredentialUnderSP(password, PRIMARY_USER_ID);
mService.setLockCredential(badPassword, password, PRIMARY_USER_ID);
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- badPassword, 0, PRIMARY_USER_ID)
- .getResponseCode());
+ badPassword, PRIMARY_USER_ID, 0 /* flags */).getResponseCode());
// Check the same secret was passed each time
ArgumentCaptor<ArrayList<Byte>> secret = ArgumentCaptor.forClass(ArrayList.class);
@@ -183,8 +178,7 @@
initializeCredentialUnderSP(password, PRIMARY_USER_ID);
reset(mAuthSecretService);
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- password, 0, PRIMARY_USER_ID)
- .getResponseCode());
+ password, PRIMARY_USER_ID, 0 /* flags */).getResponseCode());
verify(mAuthSecretService).primaryUserCredential(any(ArrayList.class));
}
@@ -194,8 +188,7 @@
initializeCredentialUnderSP(password, SECONDARY_USER_ID);
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- password, 0, SECONDARY_USER_ID)
- .getResponseCode());
+ password, SECONDARY_USER_ID, 0 /* flags */).getResponseCode());
verify(mAuthSecretService, never()).primaryUserCredential(any(ArrayList.class));
}
@@ -246,7 +239,8 @@
assertFalse(mLocalService.isEscrowTokenActive(handle, PRIMARY_USER_ID));
assertTrue(mService.hasPendingEscrowToken(PRIMARY_USER_ID));
- mService.verifyCredential(password, 0, PRIMARY_USER_ID).getResponseCode();
+ mService.verifyCredential(password, PRIMARY_USER_ID, 0 /* flags */)
+ .getResponseCode();
assertTrue(mLocalService.isEscrowTokenActive(handle, PRIMARY_USER_ID));
assertFalse(mService.hasPendingEscrowToken(PRIMARY_USER_ID));
@@ -259,8 +253,7 @@
verify(mDevicePolicyManager).reportPasswordChanged(PRIMARY_USER_ID);
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- pattern, 0, PRIMARY_USER_ID)
- .getResponseCode());
+ pattern, PRIMARY_USER_ID, 0 /* flags */).getResponseCode());
assertArrayEquals(storageKey, mStorageManager.getUserUnlockToken(PRIMARY_USER_ID));
}
@@ -275,7 +268,8 @@
long handle = mLocalService.addEscrowToken(token, PRIMARY_USER_ID, null);
assertFalse(mLocalService.isEscrowTokenActive(handle, PRIMARY_USER_ID));
- mService.verifyCredential(password, 0, PRIMARY_USER_ID).getResponseCode();
+ mService.verifyCredential(password, PRIMARY_USER_ID, 0 /* flags */)
+ .getResponseCode();
assertTrue(mLocalService.isEscrowTokenActive(handle, PRIMARY_USER_ID));
mLocalService.setLockCredentialWithToken(nonePassword(), handle, token, PRIMARY_USER_ID);
@@ -284,8 +278,7 @@
PRIMARY_USER_ID);
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- pattern, 0, PRIMARY_USER_ID)
- .getResponseCode());
+ pattern, PRIMARY_USER_ID, 0 /* flags */).getResponseCode());
assertArrayEquals(storageKey, mStorageManager.getUserUnlockToken(PRIMARY_USER_ID));
}
@@ -301,7 +294,8 @@
long handle = mLocalService.addEscrowToken(token, PRIMARY_USER_ID, null);
assertFalse(mLocalService.isEscrowTokenActive(handle, PRIMARY_USER_ID));
- mService.verifyCredential(password, 0, PRIMARY_USER_ID).getResponseCode();
+ mService.verifyCredential(password, PRIMARY_USER_ID, 0 /* flags */)
+ .getResponseCode();
assertTrue(mLocalService.isEscrowTokenActive(handle, PRIMARY_USER_ID));
mService.setLockCredential(pattern, password, PRIMARY_USER_ID);
@@ -309,8 +303,7 @@
mLocalService.setLockCredentialWithToken(newPassword, handle, token, PRIMARY_USER_ID);
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- newPassword, 0, PRIMARY_USER_ID)
- .getResponseCode());
+ newPassword, PRIMARY_USER_ID, 0 /* flags */).getResponseCode());
assertArrayEquals(storageKey, mStorageManager.getUserUnlockToken(PRIMARY_USER_ID));
}
@@ -357,8 +350,7 @@
assertFalse(mLocalService.isEscrowTokenActive(handle, PRIMARY_USER_ID));
// Activate token (password gets migrated to SP at the same time)
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- password, 0, PRIMARY_USER_ID)
- .getResponseCode());
+ password, PRIMARY_USER_ID, 0 /* flags */).getResponseCode());
// Verify token is activated
assertTrue(mLocalService.isEscrowTokenActive(handle, PRIMARY_USER_ID));
}
@@ -488,8 +480,7 @@
initializeCredentialUnderSP(password, PRIMARY_USER_ID);
assertEquals(VerifyCredentialResponse.RESPONSE_OK, mService.verifyCredential(
- password, 0, PRIMARY_USER_ID)
- .getResponseCode());
+ password, PRIMARY_USER_ID, 0 /* flags */).getResponseCode());
verify(mAuthSecretService, never()).primaryUserCredential(any(ArrayList.class));
}
@@ -503,7 +494,8 @@
reset(mDevicePolicyManager);
long handle = mLocalService.addEscrowToken(token, PRIMARY_USER_ID, null);
- mService.verifyCredential(password, 0, PRIMARY_USER_ID).getResponseCode();
+ mService.verifyCredential(password, PRIMARY_USER_ID, 0 /* flags */)
+ .getResponseCode();
assertTrue(mLocalService.isEscrowTokenActive(handle, PRIMARY_USER_ID));
mService.onCleanupUser(PRIMARY_USER_ID);
diff --git a/services/tests/servicestests/src/com/android/server/net/NetworkPolicyManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/net/NetworkPolicyManagerServiceTest.java
index 128177b..58b71d4 100644
--- a/services/tests/servicestests/src/com/android/server/net/NetworkPolicyManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/net/NetworkPolicyManagerServiceTest.java
@@ -462,7 +462,7 @@
@Test
public void testTurnRestrictBackgroundOn() throws Exception {
- assertRestrictBackgroundOff(); // Sanity check.
+ assertRestrictBackgroundOff();
final FutureIntent futureIntent = newRestrictBackgroundChangedFuture();
setRestrictBackground(true);
assertRestrictBackgroundChangedReceived(futureIntent, null);
@@ -471,7 +471,7 @@
@Test
@NetPolicyXml("restrict-background-on.xml")
public void testTurnRestrictBackgroundOff() throws Exception {
- assertRestrictBackgroundOn(); // Sanity check.
+ assertRestrictBackgroundOn();
assertRestrictBackgroundChangedReceived(mFutureIntent, null);
final FutureIntent futureIntent = newRestrictBackgroundChangedFuture();
setRestrictBackground(false);
@@ -479,28 +479,27 @@
}
/**
- * Adds whitelist when restrict background is on - app should receive an intent.
+ * Adds allowlist when restrict background is on - app should receive an intent.
*/
@Test
@NetPolicyXml("restrict-background-on.xml")
- public void testAddRestrictBackgroundWhitelist_restrictBackgroundOn() throws Exception {
- assertRestrictBackgroundOn(); // Sanity check.
+ public void testAddRestrictBackgroundAllowlist_restrictBackgroundOn() throws Exception {
+ assertRestrictBackgroundOn();
assertRestrictBackgroundChangedReceived(mFutureIntent, null);
- addRestrictBackgroundWhitelist(true);
+ addRestrictBackgroundAllowlist(true);
}
/**
- * Adds whitelist when restrict background is off - app should not receive an intent.
+ * Adds allowlist when restrict background is off - app should not receive an intent.
*/
@Test
- public void testAddRestrictBackgroundWhitelist_restrictBackgroundOff() throws Exception {
- assertRestrictBackgroundOff(); // Sanity check.
- addRestrictBackgroundWhitelist(false);
+ public void testAddRestrictBackgroundAllowlist_restrictBackgroundOff() throws Exception {
+ assertRestrictBackgroundOff();
+ addRestrictBackgroundAllowlist(false);
}
- private void addRestrictBackgroundWhitelist(boolean expectIntent) throws Exception {
- // Sanity checks.
- assertWhitelistUids();
+ private void addRestrictBackgroundAllowlist(boolean expectIntent) throws Exception {
+ assertAllowlistUids();
assertUidPolicy(UID_A, POLICY_NONE);
final FutureIntent futureIntent = newRestrictBackgroundChangedFuture();
@@ -508,7 +507,7 @@
mService.setUidPolicy(UID_A, POLICY_ALLOW_METERED_BACKGROUND);
- assertWhitelistUids(UID_A);
+ assertAllowlistUids(UID_A);
assertUidPolicy(UID_A, POLICY_ALLOW_METERED_BACKGROUND);
mPolicyListener.waitAndVerify()
.onUidPoliciesChanged(APP_ID_A, POLICY_ALLOW_METERED_BACKGROUND);
@@ -520,24 +519,24 @@
}
/**
- * Removes whitelist when restrict background is on - app should receive an intent.
+ * Removes allowlist when restrict background is on - app should receive an intent.
*/
@Test
- @NetPolicyXml("uidA-whitelisted-restrict-background-on.xml")
- public void testRemoveRestrictBackgroundWhitelist_restrictBackgroundOn() throws Exception {
- assertRestrictBackgroundOn(); // Sanity check.
+ @NetPolicyXml("uidA-allowlisted-restrict-background-on.xml")
+ public void testRemoveRestrictBackgroundAllowlist_restrictBackgroundOn() throws Exception {
+ assertRestrictBackgroundOn();
assertRestrictBackgroundChangedReceived(mFutureIntent, null);
- removeRestrictBackgroundWhitelist(true);
+ removeRestrictBackgroundAllowlist(true);
}
/**
- * Removes whitelist when restrict background is off - app should not receive an intent.
+ * Removes allowlist when restrict background is off - app should not receive an intent.
*/
@Test
- @NetPolicyXml("uidA-whitelisted-restrict-background-off.xml")
- public void testRemoveRestrictBackgroundWhitelist_restrictBackgroundOff() throws Exception {
- assertRestrictBackgroundOff(); // Sanity check.
- removeRestrictBackgroundWhitelist(false);
+ @NetPolicyXml("uidA-allowlisted-restrict-background-off.xml")
+ public void testRemoveRestrictBackgroundAllowlist_restrictBackgroundOff() throws Exception {
+ assertRestrictBackgroundOff();
+ removeRestrictBackgroundAllowlist(false);
}
@Test
@@ -688,9 +687,8 @@
assertFalse(mService.getRestrictBackground());
}
- private void removeRestrictBackgroundWhitelist(boolean expectIntent) throws Exception {
- // Sanity checks.
- assertWhitelistUids(UID_A);
+ private void removeRestrictBackgroundAllowlist(boolean expectIntent) throws Exception {
+ assertAllowlistUids(UID_A);
assertUidPolicy(UID_A, POLICY_ALLOW_METERED_BACKGROUND);
final FutureIntent futureIntent = newRestrictBackgroundChangedFuture();
@@ -698,7 +696,7 @@
mService.setUidPolicy(UID_A, POLICY_NONE);
- assertWhitelistUids();
+ assertAllowlistUids();
assertUidPolicy(UID_A, POLICY_NONE);
mPolicyListener.waitAndVerify().onUidPoliciesChanged(APP_ID_A, POLICY_NONE);
if (expectIntent) {
@@ -709,27 +707,27 @@
}
/**
- * Adds blacklist when restrict background is on - app should not receive an intent.
+ * Adds denylist when restrict background is on - app should not receive an intent.
*/
@Test
@NetPolicyXml("restrict-background-on.xml")
- public void testAddRestrictBackgroundBlacklist_restrictBackgroundOn() throws Exception {
- assertRestrictBackgroundOn(); // Sanity check.
+ public void testAddRestrictBackgroundDenylist_restrictBackgroundOn() throws Exception {
+ assertRestrictBackgroundOn();
assertRestrictBackgroundChangedReceived(mFutureIntent, null);
- addRestrictBackgroundBlacklist(false);
+ addRestrictBackgroundDenylist(false);
}
/**
- * Adds blacklist when restrict background is off - app should receive an intent.
+ * Adds denylist when restrict background is off - app should receive an intent.
*/
@Test
- public void testAddRestrictBackgroundBlacklist_restrictBackgroundOff() throws Exception {
- assertRestrictBackgroundOff(); // Sanity check.
- addRestrictBackgroundBlacklist(true);
+ public void testAddRestrictBackgroundDenylist_restrictBackgroundOff() throws Exception {
+ assertRestrictBackgroundOff();
+ addRestrictBackgroundDenylist(true);
}
- private void addRestrictBackgroundBlacklist(boolean expectIntent) throws Exception {
- assertUidPolicy(UID_A, POLICY_NONE); // Sanity check.
+ private void addRestrictBackgroundDenylist(boolean expectIntent) throws Exception {
+ assertUidPolicy(UID_A, POLICY_NONE);
final FutureIntent futureIntent = newRestrictBackgroundChangedFuture();
mPolicyListener.expect().onUidPoliciesChanged(anyInt(), anyInt());
@@ -746,28 +744,28 @@
}
/**
- * Removes blacklist when restrict background is on - app should not receive an intent.
+ * Removes denylist when restrict background is on - app should not receive an intent.
*/
@Test
- @NetPolicyXml("uidA-blacklisted-restrict-background-on.xml")
- public void testRemoveRestrictBackgroundBlacklist_restrictBackgroundOn() throws Exception {
- assertRestrictBackgroundOn(); // Sanity check.
+ @NetPolicyXml("uidA-denylisted-restrict-background-on.xml")
+ public void testRemoveRestrictBackgroundDenylist_restrictBackgroundOn() throws Exception {
+ assertRestrictBackgroundOn();
assertRestrictBackgroundChangedReceived(mFutureIntent, null);
- removeRestrictBackgroundBlacklist(false);
+ removeRestrictBackgroundDenylist(false);
}
/**
- * Removes blacklist when restrict background is off - app should receive an intent.
+ * Removes denylist when restrict background is off - app should receive an intent.
*/
@Test
- @NetPolicyXml("uidA-blacklisted-restrict-background-off.xml")
- public void testRemoveRestrictBackgroundBlacklist_restrictBackgroundOff() throws Exception {
- assertRestrictBackgroundOff(); // Sanity check.
- removeRestrictBackgroundBlacklist(true);
+ @NetPolicyXml("uidA-denylisted-restrict-background-off.xml")
+ public void testRemoveRestrictBackgroundDenylist_restrictBackgroundOff() throws Exception {
+ assertRestrictBackgroundOff();
+ removeRestrictBackgroundDenylist(true);
}
- private void removeRestrictBackgroundBlacklist(boolean expectIntent) throws Exception {
- assertUidPolicy(UID_A, POLICY_REJECT_METERED_BACKGROUND); // Sanity check.
+ private void removeRestrictBackgroundDenylist(boolean expectIntent) throws Exception {
+ assertUidPolicy(UID_A, POLICY_REJECT_METERED_BACKGROUND);
final FutureIntent futureIntent = newRestrictBackgroundChangedFuture();
mPolicyListener.expect().onUidPoliciesChanged(anyInt(), anyInt());
@@ -784,9 +782,8 @@
}
@Test
- @NetPolicyXml("uidA-blacklisted-restrict-background-on.xml")
- public void testBlacklistedAppIsNotNotifiedWhenRestrictBackgroundIsOn() throws Exception {
- // Sanity checks.
+ @NetPolicyXml("uidA-denylisted-restrict-background-on.xml")
+ public void testDenylistedAppIsNotNotifiedWhenRestrictBackgroundIsOn() throws Exception {
assertRestrictBackgroundOn();
assertRestrictBackgroundChangedReceived(mFutureIntent, null);
assertUidPolicy(UID_A, POLICY_REJECT_METERED_BACKGROUND);
@@ -797,12 +794,11 @@
}
@Test
- @NetPolicyXml("uidA-whitelisted-restrict-background-on.xml")
- public void testWhitelistedAppIsNotNotifiedWhenRestrictBackgroundIsOn() throws Exception {
- // Sanity checks.
+ @NetPolicyXml("uidA-allowlisted-restrict-background-on.xml")
+ public void testAllowlistedAppIsNotNotifiedWhenRestrictBackgroundIsOn() throws Exception {
assertRestrictBackgroundOn();
assertRestrictBackgroundChangedReceived(mFutureIntent, null);
- assertWhitelistUids(UID_A);
+ assertAllowlistUids(UID_A);
final FutureIntent futureIntent = newRestrictBackgroundChangedFuture();
setRestrictBackground(true);
@@ -810,12 +806,11 @@
}
@Test
- @NetPolicyXml("uidA-whitelisted-restrict-background-on.xml")
- public void testWhitelistedAppIsNotifiedWhenBlacklisted() throws Exception {
- // Sanity checks.
+ @NetPolicyXml("uidA-allowlisted-restrict-background-on.xml")
+ public void testAllowlistedAppIsNotifiedWhenDenylisted() throws Exception {
assertRestrictBackgroundOn();
assertRestrictBackgroundChangedReceived(mFutureIntent, null);
- assertWhitelistUids(UID_A);
+ assertAllowlistUids(UID_A);
final FutureIntent futureIntent = newRestrictBackgroundChangedFuture();
mService.setUidPolicy(UID_A, POLICY_REJECT_METERED_BACKGROUND);
@@ -823,8 +818,8 @@
}
@Test
- @NetPolicyXml("restrict-background-lists-whitelist-format.xml")
- public void testRestrictBackgroundLists_whitelistFormat() throws Exception {
+ @NetPolicyXml("restrict-background-lists-allowlist-format.xml")
+ public void testRestrictBackgroundLists_allowlistFormat() throws Exception {
restrictBackgroundListsTest();
}
@@ -835,33 +830,33 @@
}
private void restrictBackgroundListsTest() throws Exception {
- // UIds that are whitelisted.
- assertWhitelistUids(UID_A, UID_B, UID_C);
+ // UIds that are allowlisted.
+ assertAllowlistUids(UID_A, UID_B, UID_C);
assertUidPolicy(UID_A, POLICY_ALLOW_METERED_BACKGROUND);
assertUidPolicy(UID_B, POLICY_ALLOW_METERED_BACKGROUND);
assertUidPolicy(UID_C, POLICY_ALLOW_METERED_BACKGROUND);
- // UIDs that are blacklisted.
+ // UIDs that are denylisted.
assertUidPolicy(UID_D, POLICY_NONE);
assertUidPolicy(UID_E, POLICY_REJECT_METERED_BACKGROUND);
// UIDS that have legacy policies.
assertUidPolicy(UID_F, 2); // POLICY_ALLOW_BACKGROUND_BATTERY_SAVE
- // Remove whitelist.
+ // Remove allowlist.
mService.setUidPolicy(UID_A, POLICY_NONE);
assertUidPolicy(UID_A, POLICY_NONE);
- assertWhitelistUids(UID_B, UID_C);
+ assertAllowlistUids(UID_B, UID_C);
- // Add whitelist when blacklisted.
+ // Add allowlist when denylisted.
mService.setUidPolicy(UID_E, POLICY_ALLOW_METERED_BACKGROUND);
assertUidPolicy(UID_E, POLICY_ALLOW_METERED_BACKGROUND);
- assertWhitelistUids(UID_B, UID_C, UID_E);
+ assertAllowlistUids(UID_B, UID_C, UID_E);
- // Add blacklist when whitelisted.
+ // Add denylist when allowlisted.
mService.setUidPolicy(UID_B, POLICY_REJECT_METERED_BACKGROUND);
assertUidPolicy(UID_B, POLICY_REJECT_METERED_BACKGROUND);
- assertWhitelistUids(UID_C, UID_E);
+ assertAllowlistUids(UID_C, UID_E);
}
/**
@@ -870,9 +865,9 @@
@Test
@NetPolicyXml("restrict-background-lists-mixed-format.xml")
public void testRestrictBackgroundLists_mixedFormat() throws Exception {
- assertWhitelistUids(UID_A, UID_C, UID_D);
+ assertAllowlistUids(UID_A, UID_C, UID_D);
assertUidPolicy(UID_A, POLICY_ALLOW_METERED_BACKGROUND);
- assertUidPolicy(UID_B, POLICY_REJECT_METERED_BACKGROUND); // Blacklist prevails.
+ assertUidPolicy(UID_B, POLICY_REJECT_METERED_BACKGROUND); // Denylist prevails.
assertUidPolicy(UID_C, (POLICY_ALLOW_METERED_BACKGROUND | 2));
assertUidPolicy(UID_D, POLICY_ALLOW_METERED_BACKGROUND);
}
@@ -2045,7 +2040,7 @@
}
}
- private void assertWhitelistUids(int... uids) {
+ private void assertAllowlistUids(int... uids) {
assertContainsInAnyOrder(mService.getUidsWithPolicy(POLICY_ALLOW_METERED_BACKGROUND), uids);
}
@@ -2133,7 +2128,6 @@
private void setRestrictBackground(boolean flag) throws Exception {
mService.setRestrictBackground(flag);
- // Sanity check.
assertEquals("restrictBackground not set", flag, mService.getRestrictBackground());
}
diff --git a/services/tests/servicestests/src/com/android/server/pm/PackageManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/pm/PackageManagerServiceTest.java
index 80f145b..35d6f47 100644
--- a/services/tests/servicestests/src/com/android/server/pm/PackageManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/PackageManagerServiceTest.java
@@ -48,7 +48,7 @@
public void sendPackageBroadcast(final String action, final String pkg,
final Bundle extras, final int flags, final String targetPkg,
final IIntentReceiver finishedReceiver, final int[] userIds,
- int[] instantUserIds, SparseArray<int[]> broadcastWhitelist) {
+ int[] instantUserIds, SparseArray<int[]> broadcastAllowList) {
}
public void sendPackageAddedForNewUsers(String packageName,
diff --git a/services/tests/servicestests/src/com/android/server/pm/parsing/AndroidPackageParsingEquivalenceTest.kt b/services/tests/servicestests/src/com/android/server/pm/parsing/AndroidPackageParsingEquivalenceTest.kt
index 9f9ec31..f96ebda 100644
--- a/services/tests/servicestests/src/com/android/server/pm/parsing/AndroidPackageParsingEquivalenceTest.kt
+++ b/services/tests/servicestests/src/com/android/server/pm/parsing/AndroidPackageParsingEquivalenceTest.kt
@@ -23,6 +23,8 @@
import org.junit.Rule
import org.junit.Test
+import org.junit.rules.Timeout
+import java.util.concurrent.TimeUnit
/**
* Collects APKs from the device and verifies that the new parsing behavior outputs
@@ -32,6 +34,9 @@
class AndroidPackageParsingEquivalenceTest : AndroidPackageParsingTestBase() {
@get:Rule
+ val timeout = Timeout(4, TimeUnit.MINUTES)
+
+ @get:Rule
val expect = Expect.create()
@Test
diff --git a/services/tests/servicestests/src/com/android/server/timezonedetector/FakeTimeZoneDetectorStrategy.java b/services/tests/servicestests/src/com/android/server/timezonedetector/FakeTimeZoneDetectorStrategy.java
index dcf3190..e5e9311 100644
--- a/services/tests/servicestests/src/com/android/server/timezonedetector/FakeTimeZoneDetectorStrategy.java
+++ b/services/tests/servicestests/src/com/android/server/timezonedetector/FakeTimeZoneDetectorStrategy.java
@@ -27,6 +27,9 @@
import android.app.timezonedetector.TimeZoneConfiguration;
import android.util.IndentingPrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
class FakeTimeZoneDetectorStrategy implements TimeZoneDetectorStrategy {
private StrategyListener mListener;
@@ -41,6 +44,7 @@
private TelephonyTimeZoneSuggestion mLastTelephonySuggestion;
private boolean mHandleAutoTimeZoneConfigChangedCalled;
private boolean mDumpCalled;
+ private final List<Dumpable> mDumpables = new ArrayList<>();
@Override
public void setStrategyListener(@NonNull StrategyListener listener) {
@@ -105,7 +109,7 @@
@Override
public void addDumpable(Dumpable dumpable) {
- // Stubbed
+ mDumpables.add(dumpable);
}
@Override
@@ -149,4 +153,8 @@
void verifyDumpCalled() {
assertTrue(mDumpCalled);
}
+
+ void verifyHasDumpable(Dumpable expected) {
+ assertTrue(mDumpables.contains(expected));
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorInternalImplTest.java b/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorInternalImplTest.java
index 0e2c227..e9d57e5 100644
--- a/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorInternalImplTest.java
+++ b/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorInternalImplTest.java
@@ -75,6 +75,16 @@
mFakeTimeZoneDetectorStrategy.verifySuggestGeolocationTimeZoneCalled(timeZoneSuggestion);
}
+ @Test
+ public void testAddDumpable() throws Exception {
+ Dumpable stubbedDumpable = mock(Dumpable.class);
+
+ mTimeZoneDetectorInternal.addDumpable(stubbedDumpable);
+ mTestHandler.assertTotalMessagesEnqueued(0);
+
+ mFakeTimeZoneDetectorStrategy.verifyHasDumpable(stubbedDumpable);
+ }
+
private static GeolocationTimeZoneSuggestion createGeolocationTimeZoneSuggestion() {
return new GeolocationTimeZoneSuggestion(ARBITRARY_ZONE_IDS);
}
diff --git a/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorServiceTest.java b/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorServiceTest.java
index 8034cac..3a1ec4f 100644
--- a/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorServiceTest.java
@@ -52,6 +52,7 @@
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.util.Arrays;
@RunWith(AndroidJUnit4.class)
public class TimeZoneDetectorServiceTest {
@@ -253,6 +254,39 @@
}
@Test(expected = SecurityException.class)
+ public void testSuggestGeolocationTimeZone_withoutPermission() {
+ doThrow(new SecurityException("Mock"))
+ .when(mMockContext).enforceCallingOrSelfPermission(anyString(), any());
+ GeolocationTimeZoneSuggestion timeZoneSuggestion = createGeolocationTimeZoneSuggestion();
+
+ try {
+ mTimeZoneDetectorService.suggestGeolocationTimeZone(timeZoneSuggestion);
+ fail();
+ } finally {
+ verify(mMockContext).enforceCallingOrSelfPermission(
+ eq(android.Manifest.permission.SET_TIME_ZONE),
+ anyString());
+ }
+ }
+
+ @Test
+ public void testSuggestGeolocationTimeZone() throws Exception {
+ doNothing().when(mMockContext).enforceCallingOrSelfPermission(anyString(), any());
+
+ GeolocationTimeZoneSuggestion timeZoneSuggestion = createGeolocationTimeZoneSuggestion();
+
+ mTimeZoneDetectorService.suggestGeolocationTimeZone(timeZoneSuggestion);
+ mTestHandler.assertTotalMessagesEnqueued(1);
+
+ verify(mMockContext).enforceCallingOrSelfPermission(
+ eq(android.Manifest.permission.SET_TIME_ZONE),
+ anyString());
+
+ mTestHandler.waitForMessagesToBeProcessed();
+ mFakeTimeZoneDetectorStrategy.verifySuggestGeolocationTimeZoneCalled(timeZoneSuggestion);
+ }
+
+ @Test(expected = SecurityException.class)
public void testSuggestManualTimeZone_withoutPermission() {
doThrow(new SecurityException("Mock"))
.when(mMockContext).enforceCallingOrSelfPermission(anyString(), any());
@@ -346,7 +380,7 @@
}
@Test
- public void testAutoTimeZoneDetectionChanged() throws Exception {
+ public void testHandleAutoTimeZoneConfigChanged() throws Exception {
mTimeZoneDetectorService.handleAutoTimeZoneConfigChanged();
mTestHandler.assertTotalMessagesEnqueued(1);
mTestHandler.waitForMessagesToBeProcessed();
@@ -370,10 +404,15 @@
private static TimeZoneCapabilities createTimeZoneCapabilities() {
return new TimeZoneCapabilities.Builder(ARBITRARY_USER_ID)
.setConfigureAutoDetectionEnabled(CAPABILITY_POSSESSED)
+ .setConfigureGeoDetectionEnabled(CAPABILITY_POSSESSED)
.setSuggestManualTimeZone(CAPABILITY_POSSESSED)
.build();
}
+ private static GeolocationTimeZoneSuggestion createGeolocationTimeZoneSuggestion() {
+ return new GeolocationTimeZoneSuggestion(Arrays.asList("TestZoneId"));
+ }
+
private static ManualTimeZoneSuggestion createManualTimeZoneSuggestion() {
return new ManualTimeZoneSuggestion("TestZoneId");
}
diff --git a/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorStrategyImplTest.java b/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorStrategyImplTest.java
index 6855445..a6caa42 100644
--- a/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorStrategyImplTest.java
+++ b/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorStrategyImplTest.java
@@ -41,6 +41,7 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.timezonedetector.ManualTimeZoneSuggestion;
import android.app.timezonedetector.TelephonyTimeZoneSuggestion;
@@ -56,10 +57,10 @@
import org.junit.Test;
import java.io.StringWriter;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
+import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -93,16 +94,26 @@
TELEPHONY_SCORE_HIGHEST),
};
- private static final TimeZoneConfiguration CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED =
+ private static final TimeZoneConfiguration CONFIG_AUTO_ENABLED =
new TimeZoneConfiguration.Builder()
.setAutoDetectionEnabled(true)
.build();
- private static final TimeZoneConfiguration CONFIG_AUTO_TIME_ZONE_DETECTION_DISABLED =
+ private static final TimeZoneConfiguration CONFIG_AUTO_DISABLED =
new TimeZoneConfiguration.Builder()
.setAutoDetectionEnabled(false)
.build();
+ private static final TimeZoneConfiguration CONFIG_GEO_DETECTION_DISABLED =
+ new TimeZoneConfiguration.Builder()
+ .setGeoDetectionEnabled(false)
+ .build();
+
+ private static final TimeZoneConfiguration CONFIG_GEO_DETECTION_ENABLED =
+ new TimeZoneConfiguration.Builder()
+ .setGeoDetectionEnabled(true)
+ .build();
+
private TimeZoneDetectorStrategyImpl mTimeZoneDetectorStrategy;
private FakeCallback mFakeCallback;
private MockStrategyListener mMockStrategyListener;
@@ -120,7 +131,7 @@
public void testGetCapabilities() {
new Script()
.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED));
TimeZoneCapabilities expectedCapabilities = mFakeCallback.getCapabilities(USER_ID);
assertEquals(expectedCapabilities, mTimeZoneDetectorStrategy.getCapabilities(USER_ID));
}
@@ -129,7 +140,7 @@
public void testGetConfiguration() {
new Script()
.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED));
TimeZoneConfiguration expectedConfiguration = mFakeCallback.getConfiguration(USER_ID);
assertTrue(expectedConfiguration.isComplete());
assertEquals(expectedConfiguration, mTimeZoneDetectorStrategy.getConfiguration(USER_ID));
@@ -140,20 +151,22 @@
Script script = new Script();
script.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED));
{
// Check the fake test infra is doing what is expected.
TimeZoneCapabilities capabilities = mFakeCallback.getCapabilities(USER_ID);
assertEquals(CAPABILITY_POSSESSED, capabilities.getConfigureAutoDetectionEnabled());
+ assertEquals(CAPABILITY_POSSESSED, capabilities.getConfigureGeoDetectionEnabled());
assertEquals(CAPABILITY_NOT_APPLICABLE, capabilities.getSuggestManualTimeZone());
}
script.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_DISABLED);
+ CONFIG_AUTO_DISABLED.with(CONFIG_GEO_DETECTION_DISABLED));
{
// Check the fake test infra is doing what is expected.
TimeZoneCapabilities capabilities = mFakeCallback.getCapabilities(USER_ID);
assertEquals(CAPABILITY_POSSESSED, capabilities.getConfigureAutoDetectionEnabled());
+ assertEquals(CAPABILITY_POSSESSED, capabilities.getConfigureGeoDetectionEnabled());
assertEquals(CAPABILITY_POSSESSED, capabilities.getSuggestManualTimeZone());
}
}
@@ -163,20 +176,22 @@
Script script = new Script();
script.initializeUser(USER_ID, UserCase.RESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED));
{
// Check the fake test infra is doing what is expected.
TimeZoneCapabilities capabilities = mFakeCallback.getCapabilities(USER_ID);
assertEquals(CAPABILITY_NOT_ALLOWED, capabilities.getConfigureAutoDetectionEnabled());
+ assertEquals(CAPABILITY_NOT_ALLOWED, capabilities.getConfigureGeoDetectionEnabled());
assertEquals(CAPABILITY_NOT_ALLOWED, capabilities.getSuggestManualTimeZone());
}
script.initializeUser(USER_ID, UserCase.RESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_DISABLED);
+ CONFIG_AUTO_DISABLED.with(CONFIG_GEO_DETECTION_DISABLED));
{
// Check the fake test infra is doing what is expected.
TimeZoneCapabilities capabilities = mFakeCallback.getCapabilities(USER_ID);
assertEquals(CAPABILITY_NOT_ALLOWED, capabilities.getConfigureAutoDetectionEnabled());
+ assertEquals(CAPABILITY_NOT_ALLOWED, capabilities.getConfigureGeoDetectionEnabled());
assertEquals(CAPABILITY_NOT_ALLOWED, capabilities.getSuggestManualTimeZone());
}
}
@@ -186,20 +201,22 @@
Script script = new Script();
script.initializeUser(USER_ID, UserCase.AUTO_DETECT_NOT_SUPPORTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED));
{
// Check the fake test infra is doing what is expected.
TimeZoneCapabilities capabilities = mFakeCallback.getCapabilities(USER_ID);
assertEquals(CAPABILITY_NOT_SUPPORTED, capabilities.getConfigureAutoDetectionEnabled());
+ assertEquals(CAPABILITY_NOT_SUPPORTED, capabilities.getConfigureGeoDetectionEnabled());
assertEquals(CAPABILITY_POSSESSED, capabilities.getSuggestManualTimeZone());
}
script.initializeUser(USER_ID, UserCase.AUTO_DETECT_NOT_SUPPORTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_DISABLED);
+ CONFIG_AUTO_DISABLED.with(CONFIG_GEO_DETECTION_DISABLED));
{
// Check the fake test infra is doing what is expected.
TimeZoneCapabilities capabilities = mFakeCallback.getCapabilities(USER_ID);
assertEquals(CAPABILITY_NOT_SUPPORTED, capabilities.getConfigureAutoDetectionEnabled());
+ assertEquals(CAPABILITY_NOT_SUPPORTED, capabilities.getConfigureGeoDetectionEnabled());
assertEquals(CAPABILITY_POSSESSED, capabilities.getSuggestManualTimeZone());
}
}
@@ -208,42 +225,61 @@
public void testUpdateConfiguration_unrestricted() {
Script script = new Script()
.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED));
// Set the configuration with auto detection enabled.
- script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_ENABLED, true /* expectedResult */);
// Nothing should have happened: it was initialized in this state.
script.verifyConfigurationNotChanged();
// Update the configuration with auto detection disabled.
- script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_TIME_ZONE_DETECTION_DISABLED);
+ script.simulateUpdateConfiguration(
+ USER_ID, CONFIG_AUTO_DISABLED, true /* expectedResult */);
// The settings should have been changed and the StrategyListener onChange() called.
- script.verifyConfigurationChangedAndReset(
- USER_ID, CONFIG_AUTO_TIME_ZONE_DETECTION_DISABLED);
+ script.verifyConfigurationChangedAndReset(USER_ID,
+ CONFIG_AUTO_DISABLED.with(CONFIG_GEO_DETECTION_DISABLED));
// Update the configuration with auto detection enabled.
- script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_ENABLED, true /* expectedResult */);
// The settings should have been changed and the StrategyListener onChange() called.
- script.verifyConfigurationChangedAndReset(USER_ID, CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ script.verifyConfigurationChangedAndReset(USER_ID,
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED));
+
+ // Update the configuration to enable geolocation time zone detection.
+ script.simulateUpdateConfiguration(
+ USER_ID, CONFIG_GEO_DETECTION_ENABLED, true /* expectedResult */);
+
+ // The settings should have been changed and the StrategyListener onChange() called.
+ script.verifyConfigurationChangedAndReset(USER_ID,
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_ENABLED));
}
@Test
public void testUpdateConfiguration_restricted() {
Script script = new Script()
.initializeUser(USER_ID, UserCase.RESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED));
// Try to update the configuration with auto detection disabled.
- script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_TIME_ZONE_DETECTION_DISABLED);
+ script.simulateUpdateConfiguration(
+ USER_ID, CONFIG_AUTO_DISABLED, false /* expectedResult */);
// The settings should not have been changed: user shouldn't have the capabilities.
script.verifyConfigurationNotChanged();
// Update the configuration with auto detection enabled.
- script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ script.simulateUpdateConfiguration(
+ USER_ID, CONFIG_AUTO_ENABLED, false /* expectedResult */);
+
+ // The settings should not have been changed: user shouldn't have the capabilities.
+ script.verifyConfigurationNotChanged();
+
+ // Update the configuration to enable geolocation time zone detection.
+ script.simulateUpdateConfiguration(
+ USER_ID, CONFIG_GEO_DETECTION_ENABLED, false /* expectedResult */);
// The settings should not have been changed: user shouldn't have the capabilities.
script.verifyConfigurationNotChanged();
@@ -253,16 +289,18 @@
public void testUpdateConfiguration_autoDetectNotSupported() {
Script script = new Script()
.initializeUser(USER_ID, UserCase.AUTO_DETECT_NOT_SUPPORTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED));
// Try to update the configuration with auto detection disabled.
- script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_TIME_ZONE_DETECTION_DISABLED);
+ script.simulateUpdateConfiguration(
+ USER_ID, CONFIG_AUTO_DISABLED, false /* expectedResult */);
// The settings should not have been changed: user shouldn't have the capabilities.
script.verifyConfigurationNotChanged();
// Update the configuration with auto detection enabled.
- script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ script.simulateUpdateConfiguration(
+ USER_ID, CONFIG_AUTO_ENABLED, false /* expectedResult */);
// The settings should not have been changed: user shouldn't have the capabilities.
script.verifyConfigurationNotChanged();
@@ -276,7 +314,7 @@
createEmptySlotIndex2Suggestion();
Script script = new Script()
.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED)
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED))
.initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
script.simulateTelephonyTimeZoneSuggestion(slotIndex1TimeZoneSuggestion)
@@ -308,6 +346,10 @@
mTimeZoneDetectorStrategy.findBestTelephonySuggestionForTests());
}
+ /**
+ * Telephony suggestions have quality metadata. Ordinarily, low scoring suggestions are not
+ * used, but this is not true if the device's time zone setting is uninitialized.
+ */
@Test
public void testTelephonySuggestionsWhenTimeZoneUninitialized() {
assertTrue(TELEPHONY_SCORE_LOW < TELEPHONY_SCORE_USAGE_THRESHOLD);
@@ -319,7 +361,7 @@
Script script = new Script()
.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED));
// A low quality suggestions will not be taken: The device time zone setting is left
// uninitialized.
@@ -376,16 +418,16 @@
/**
* Confirms that toggling the auto time zone detection setting has the expected behavior when
- * the strategy is "opinionated".
+ * the strategy is "opinionated" when using telephony auto detection.
*/
@Test
- public void testTogglingAutoTimeZoneDetection() {
+ public void testTogglingAutoDetection_autoTelephony() {
Script script = new Script();
for (TelephonyTestCase testCase : TELEPHONY_TEST_CASES) {
// Start with the device in a known state.
script.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_DISABLED)
+ CONFIG_AUTO_DISABLED.with(CONFIG_GEO_DETECTION_DISABLED))
.initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
TelephonyTimeZoneSuggestion suggestion =
@@ -405,7 +447,8 @@
mTimeZoneDetectorStrategy.findBestTelephonySuggestionForTests());
// Toggling the time zone setting on should cause the device setting to be set.
- script.simulateAutoTimeZoneDetectionEnabled(USER_ID, true);
+ script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_ENABLED,
+ true /* expectedResult */);
// When time zone detection is already enabled the suggestion (if it scores highly
// enough) should be set immediately.
@@ -422,7 +465,8 @@
mTimeZoneDetectorStrategy.findBestTelephonySuggestionForTests());
// Toggling the time zone setting should off should do nothing.
- script.simulateAutoTimeZoneDetectionEnabled(USER_ID, false)
+ script.simulateUpdateConfiguration(
+ USER_ID, CONFIG_AUTO_DISABLED, true /* expectedResult */)
.verifyTimeZoneNotChanged();
// Assert internal service state.
@@ -437,7 +481,7 @@
public void testTelephonySuggestionsSingleSlotId() {
Script script = new Script()
.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED)
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED))
.initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
for (TelephonyTestCase testCase : TELEPHONY_TEST_CASES) {
@@ -451,8 +495,7 @@
*/
// Each test case will have the same or lower score than the last.
- ArrayList<TelephonyTestCase> descendingCasesByScore =
- new ArrayList<>(Arrays.asList(TELEPHONY_TEST_CASES));
+ List<TelephonyTestCase> descendingCasesByScore = list(TELEPHONY_TEST_CASES);
Collections.reverse(descendingCasesByScore);
for (TelephonyTestCase testCase : descendingCasesByScore) {
@@ -504,7 +547,7 @@
Script script = new Script()
.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED)
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED))
.initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID)
// Initialize the latest suggestions as empty so we don't need to worry about nulls
// below for the first loop.
@@ -583,15 +626,15 @@
}
/**
- * The {@link TimeZoneDetectorStrategyImpl.Callback} is left to detect whether changing
- * the time zone is actually necessary. This test proves that the service doesn't assume it
- * knows the current setting.
+ * The {@link TimeZoneDetectorStrategyImpl.Callback} is left to detect whether changing the time
+ * zone is actually necessary. This test proves that the strategy doesn't assume it knows the
+ * current settings.
*/
@Test
- public void testTelephonySuggestionTimeZoneDetectorStrategyDoesNotAssumeCurrentSetting() {
+ public void testTelephonySuggestionStrategyDoesNotAssumeCurrentSetting_autoTelephony() {
Script script = new Script()
.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED);
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED));
TelephonyTestCase testCase = newTelephonyTestCase(
MATCH_TYPE_NETWORK_COUNTRY_AND_OFFSET, QUALITY_SINGLE_ZONE, TELEPHONY_SCORE_HIGH);
@@ -609,26 +652,40 @@
// Toggling time zone detection should set the device time zone only if the current setting
// value is different from the most recent telephony suggestion.
- script.simulateAutoTimeZoneDetectionEnabled(USER_ID, false)
+ script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_DISABLED, true /* expectedResult */)
.verifyTimeZoneNotChanged()
- .simulateAutoTimeZoneDetectionEnabled(USER_ID, true)
+ .simulateUpdateConfiguration(
+ USER_ID, CONFIG_AUTO_ENABLED, true /* expectedResult */)
.verifyTimeZoneNotChanged();
// Simulate a user turning auto detection off, a new suggestion being made while auto
// detection is off, and the user turning it on again.
- script.simulateAutoTimeZoneDetectionEnabled(USER_ID, false)
+ script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_DISABLED, true /* expectedResult */)
.simulateTelephonyTimeZoneSuggestion(newYorkSuggestion)
.verifyTimeZoneNotChanged();
// Latest suggestion should be used.
- script.simulateAutoTimeZoneDetectionEnabled(USER_ID, true)
+ script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_ENABLED, true /* expectedResult */)
.verifyTimeZoneChangedAndReset(newYorkSuggestion);
}
@Test
- public void testManualSuggestion_unrestricted_simulateAutoTimeZoneEnabled() {
+ public void testManualSuggestion_autoDetectionEnabled_autoTelephony() {
+ checkManualSuggestion_autoDetectionEnabled(false /* geoDetectionEnabled */);
+ }
+
+ @Test
+ public void testManualSuggestion_autoDetectionEnabled_autoGeo() {
+ checkManualSuggestion_autoDetectionEnabled(true /* geoDetectionEnabled */);
+ }
+
+ private void checkManualSuggestion_autoDetectionEnabled(boolean geoDetectionEnabled) {
+ TimeZoneConfiguration geoTzEnabledConfig =
+ new TimeZoneConfiguration.Builder()
+ .setGeoDetectionEnabled(geoDetectionEnabled)
+ .build();
Script script = new Script()
.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED)
+ CONFIG_AUTO_ENABLED.with(geoTzEnabledConfig))
.initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
// Auto time zone detection is enabled so the manual suggestion should be ignored.
@@ -641,7 +698,7 @@
public void testManualSuggestion_restricted_simulateAutoTimeZoneEnabled() {
Script script = new Script()
.initializeUser(USER_ID, UserCase.RESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED)
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED))
.initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
// Auto time zone detection is enabled so the manual suggestion should be ignored.
@@ -654,7 +711,7 @@
public void testManualSuggestion_autoDetectNotSupported_simulateAutoTimeZoneEnabled() {
Script script = new Script()
.initializeUser(USER_ID, UserCase.AUTO_DETECT_NOT_SUPPORTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_ENABLED)
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_DISABLED))
.initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
// Auto time zone detection is enabled so the manual suggestion should be ignored.
@@ -668,7 +725,7 @@
public void testManualSuggestion_unrestricted_autoTimeZoneDetectionDisabled() {
Script script = new Script()
.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_DISABLED)
+ CONFIG_AUTO_DISABLED.with(CONFIG_GEO_DETECTION_DISABLED))
.initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
// Auto time zone detection is disabled so the manual suggestion should be used.
@@ -682,7 +739,7 @@
public void testManualSuggestion_restricted_autoTimeZoneDetectionDisabled() {
Script script = new Script()
.initializeUser(USER_ID, UserCase.RESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_DISABLED)
+ CONFIG_AUTO_DISABLED.with(CONFIG_GEO_DETECTION_DISABLED))
.initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
// Restricted users do not have the capability.
@@ -696,7 +753,7 @@
public void testManualSuggestion_autoDetectNotSupported_autoTimeZoneDetectionDisabled() {
Script script = new Script()
.initializeUser(USER_ID, UserCase.AUTO_DETECT_NOT_SUPPORTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_DISABLED)
+ CONFIG_AUTO_DISABLED.with(CONFIG_GEO_DETECTION_DISABLED))
.initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
// Unrestricted users have the capability.
@@ -707,10 +764,261 @@
}
@Test
+ public void testGeoSuggestion_uncertain() {
+ Script script = new Script()
+ .initializeUser(USER_ID, UserCase.UNRESTRICTED,
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_ENABLED))
+ .initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
+
+ GeolocationTimeZoneSuggestion uncertainSuggestion = createUncertainGeoLocationSuggestion();
+
+ script.simulateGeolocationTimeZoneSuggestion(uncertainSuggestion)
+ .verifyTimeZoneNotChanged();
+
+ // Assert internal service state.
+ assertEquals(uncertainSuggestion,
+ mTimeZoneDetectorStrategy.getLatestGeolocationSuggestion());
+ }
+
+ @Test
+ public void testGeoSuggestion_noZones() {
+ Script script = new Script()
+ .initializeUser(USER_ID, UserCase.UNRESTRICTED,
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_ENABLED))
+ .initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
+
+ GeolocationTimeZoneSuggestion noZonesSuggestion = createGeoLocationSuggestion(list());
+
+ script.simulateGeolocationTimeZoneSuggestion(noZonesSuggestion)
+ .verifyTimeZoneNotChanged();
+
+ // Assert internal service state.
+ assertEquals(noZonesSuggestion, mTimeZoneDetectorStrategy.getLatestGeolocationSuggestion());
+ }
+
+ @Test
+ public void testGeoSuggestion_oneZone() {
+ GeolocationTimeZoneSuggestion suggestion =
+ createGeoLocationSuggestion(list("Europe/London"));
+
+ Script script = new Script()
+ .initializeUser(USER_ID, UserCase.UNRESTRICTED,
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_ENABLED))
+ .initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
+
+ script.simulateGeolocationTimeZoneSuggestion(suggestion)
+ .verifyTimeZoneChangedAndReset("Europe/London");
+
+ // Assert internal service state.
+ assertEquals(suggestion, mTimeZoneDetectorStrategy.getLatestGeolocationSuggestion());
+ }
+
+ /**
+ * In the current implementation, the first zone ID is always used unless the device is set to
+ * one of the other options. This is "stickiness" - the device favors the zone it is currently
+ * set to until that unambiguously can't be correct.
+ */
+ @Test
+ public void testGeoSuggestion_multiZone() {
+ GeolocationTimeZoneSuggestion londonOnlySuggestion =
+ createGeoLocationSuggestion(list("Europe/London"));
+ GeolocationTimeZoneSuggestion londonOrParisSuggestion =
+ createGeoLocationSuggestion(list("Europe/Paris", "Europe/London"));
+ GeolocationTimeZoneSuggestion parisOnlySuggestion =
+ createGeoLocationSuggestion(list("Europe/Paris"));
+
+ Script script = new Script()
+ .initializeUser(USER_ID, UserCase.UNRESTRICTED,
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_ENABLED))
+ .initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
+
+ script.simulateGeolocationTimeZoneSuggestion(londonOnlySuggestion)
+ .verifyTimeZoneChangedAndReset("Europe/London");
+ assertEquals(londonOnlySuggestion,
+ mTimeZoneDetectorStrategy.getLatestGeolocationSuggestion());
+
+ // Confirm bias towards the current device zone when there's multiple zones to choose from.
+ script.simulateGeolocationTimeZoneSuggestion(londonOrParisSuggestion)
+ .verifyTimeZoneNotChanged();
+ assertEquals(londonOrParisSuggestion,
+ mTimeZoneDetectorStrategy.getLatestGeolocationSuggestion());
+
+ script.simulateGeolocationTimeZoneSuggestion(parisOnlySuggestion)
+ .verifyTimeZoneChangedAndReset("Europe/Paris");
+ assertEquals(parisOnlySuggestion,
+ mTimeZoneDetectorStrategy.getLatestGeolocationSuggestion());
+
+ // Now the suggestion that previously left the device on Europe/London will leave the device
+ // on Europe/Paris.
+ script.simulateGeolocationTimeZoneSuggestion(londonOrParisSuggestion)
+ .verifyTimeZoneNotChanged();
+ assertEquals(londonOrParisSuggestion,
+ mTimeZoneDetectorStrategy.getLatestGeolocationSuggestion());
+ }
+
+ /**
+ * Confirms that toggling the auto time zone detection enabled setting has the expected behavior
+ * when the strategy is "opinionated" and "un-opinionated" when in geolocation detection is
+ * enabled.
+ */
+ @Test
+ public void testTogglingAutoDetectionEnabled_autoGeo() {
+ GeolocationTimeZoneSuggestion geolocationSuggestion =
+ createGeoLocationSuggestion(list("Europe/London"));
+ GeolocationTimeZoneSuggestion uncertainGeolocationSuggestion =
+ createUncertainGeoLocationSuggestion();
+ ManualTimeZoneSuggestion manualSuggestion = createManualSuggestion("Europe/Paris");
+
+ Script script = new Script()
+ .initializeUser(USER_ID, UserCase.UNRESTRICTED,
+ CONFIG_AUTO_DISABLED.with(CONFIG_GEO_DETECTION_ENABLED))
+ .initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
+
+ script.simulateGeolocationTimeZoneSuggestion(geolocationSuggestion);
+
+ // When time zone detection is not enabled, the time zone suggestion will not be set.
+ script.verifyTimeZoneNotChanged();
+
+ // Assert internal service state.
+ assertEquals(geolocationSuggestion,
+ mTimeZoneDetectorStrategy.getLatestGeolocationSuggestion());
+
+ // Toggling the time zone setting on should cause the device setting to be set.
+ script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_ENABLED, true /* expectedResult */)
+ .verifyTimeZoneChangedAndReset("Europe/London");
+
+ // Toggling the time zone setting should off should do nothing because the device is now
+ // set to that time zone.
+ script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_DISABLED, true /* expectedResult */)
+ .verifyTimeZoneNotChanged()
+ .simulateUpdateConfiguration(
+ USER_ID, CONFIG_AUTO_ENABLED, true /* expectedResult */)
+ .verifyTimeZoneNotChanged();
+
+ // Now toggle auto time zone setting, and confirm it is opinionated.
+ script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_DISABLED, true /* expectedResult */)
+ .simulateManualTimeZoneSuggestion(
+ USER_ID, manualSuggestion, true /* expectedResult */)
+ .verifyTimeZoneChangedAndReset(manualSuggestion)
+ .simulateUpdateConfiguration(
+ USER_ID, CONFIG_AUTO_ENABLED, true /* expectedResult */)
+ .verifyTimeZoneChangedAndReset("Europe/London");
+
+ // Now withdraw the geolocation suggestion, and assert the strategy is no longer
+ // opinionated.
+ /* expectedResult */
+ script.simulateGeolocationTimeZoneSuggestion(uncertainGeolocationSuggestion)
+ .verifyTimeZoneNotChanged()
+ .simulateUpdateConfiguration(
+ USER_ID, CONFIG_AUTO_DISABLED, true /* expectedResult */)
+ .verifyTimeZoneNotChanged()
+ .simulateManualTimeZoneSuggestion(
+ USER_ID, manualSuggestion, true /* expectedResult */)
+ .verifyTimeZoneChangedAndReset(manualSuggestion)
+ .simulateUpdateConfiguration(
+ USER_ID, CONFIG_AUTO_ENABLED, true /* expectedResult */)
+ .verifyTimeZoneNotChanged();
+
+ // Assert internal service state.
+ assertEquals(uncertainGeolocationSuggestion,
+ mTimeZoneDetectorStrategy.getLatestGeolocationSuggestion());
+ }
+
+ /**
+ * Confirms that changing the geolocation time zone detection enabled setting has the expected
+ * behavior, i.e. immediately recompute the detected time zone using different signals.
+ */
+ @Test
+ public void testChangingGeoDetectionEnabled() {
+ GeolocationTimeZoneSuggestion geolocationSuggestion =
+ createGeoLocationSuggestion(list("Europe/London"));
+ TelephonyTimeZoneSuggestion telephonySuggestion = createTelephonySuggestion(
+ SLOT_INDEX1, MATCH_TYPE_NETWORK_COUNTRY_AND_OFFSET, QUALITY_SINGLE_ZONE,
+ "Europe/Paris");
+
+ Script script = new Script()
+ .initializeUser(USER_ID, UserCase.UNRESTRICTED,
+ CONFIG_AUTO_DISABLED.with(CONFIG_GEO_DETECTION_DISABLED))
+ .initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
+
+ // Add suggestions. Nothing should happen as time zone detection is disabled.
+ script.simulateGeolocationTimeZoneSuggestion(geolocationSuggestion)
+ .verifyTimeZoneNotChanged();
+ script.simulateTelephonyTimeZoneSuggestion(telephonySuggestion)
+ .verifyTimeZoneNotChanged();
+
+ // Assert internal service state.
+ assertEquals(geolocationSuggestion,
+ mTimeZoneDetectorStrategy.getLatestGeolocationSuggestion());
+ assertEquals(telephonySuggestion,
+ mTimeZoneDetectorStrategy.getLatestTelephonySuggestion(SLOT_INDEX1).suggestion);
+
+ // Toggling the time zone detection enabled setting on should cause the device setting to be
+ // set from the telephony signal, as we've started with geolocation time zone detection
+ // disabled.
+ script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_ENABLED, true /* expectedResult */)
+ .verifyTimeZoneChangedAndReset(telephonySuggestion);
+
+ // Changing the detection to enable geo detection should cause the device tz setting to
+ // change to the geo suggestion.
+ script.simulateUpdateConfiguration(
+ USER_ID, CONFIG_GEO_DETECTION_ENABLED, true /* expectedResult */)
+ .verifyTimeZoneChangedAndReset(geolocationSuggestion.getZoneIds().get(0));
+
+ // Changing the detection to disable geo detection should cause the device tz setting to
+ // change to the telephony suggestion.
+ script.simulateUpdateConfiguration(
+ USER_ID, CONFIG_GEO_DETECTION_DISABLED, true /* expectedResult */)
+ .verifyTimeZoneChangedAndReset(telephonySuggestion);
+ }
+
+ /**
+ * The {@link TimeZoneDetectorStrategyImpl.Callback} is left to detect whether changing the time
+ * zone is actually necessary. This test proves that the strategy doesn't assume it knows the
+ * current setting.
+ */
+ @Test
+ public void testTimeZoneDetectorStrategyDoesNotAssumeCurrentSetting_autoGeo() {
+ GeolocationTimeZoneSuggestion losAngelesSuggestion =
+ createGeoLocationSuggestion(list("America/Los_Angeles"));
+ GeolocationTimeZoneSuggestion newYorkSuggestion =
+ createGeoLocationSuggestion(list("America/New_York"));
+
+ Script script = new Script()
+ .initializeUser(USER_ID, UserCase.UNRESTRICTED,
+ CONFIG_AUTO_ENABLED.with(CONFIG_GEO_DETECTION_ENABLED));
+
+ // Initialization.
+ script.simulateGeolocationTimeZoneSuggestion(losAngelesSuggestion)
+ .verifyTimeZoneChangedAndReset("America/Los_Angeles");
+ // Suggest it again - it should not be set because it is already set.
+ script.simulateGeolocationTimeZoneSuggestion(losAngelesSuggestion)
+ .verifyTimeZoneNotChanged();
+
+ // Toggling time zone detection should set the device time zone only if the current setting
+ // value is different from the most recent telephony suggestion.
+ /* expectedResult */
+ script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_DISABLED, true /* expectedResult */)
+ .verifyTimeZoneNotChanged()
+ .simulateUpdateConfiguration(
+ USER_ID, CONFIG_AUTO_ENABLED, true /* expectedResult */)
+ .verifyTimeZoneNotChanged();
+
+ // Simulate a user turning auto detection off, a new suggestion being made while auto
+ // detection is off, and the user turning it on again.
+ script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_DISABLED, true /* expectedResult */)
+ .simulateGeolocationTimeZoneSuggestion(newYorkSuggestion)
+ .verifyTimeZoneNotChanged();
+ // Latest suggestion should be used.
+ script.simulateUpdateConfiguration(USER_ID, CONFIG_AUTO_ENABLED, true /* expectedResult */)
+ .verifyTimeZoneChangedAndReset("America/New_York");
+ }
+
+ @Test
public void testAddDumpable() {
new Script()
.initializeUser(USER_ID, UserCase.UNRESTRICTED,
- CONFIG_AUTO_TIME_ZONE_DETECTION_DISABLED)
+ CONFIG_AUTO_DISABLED.with(CONFIG_GEO_DETECTION_DISABLED))
.initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID);
AtomicBoolean dumpCalled = new AtomicBoolean(false);
@@ -733,6 +1041,15 @@
return new ManualTimeZoneSuggestion(zoneId);
}
+ private static TelephonyTimeZoneSuggestion createTelephonySuggestion(
+ int slotIndex, @MatchType int matchType, @Quality int quality, String zoneId) {
+ return new TelephonyTimeZoneSuggestion.Builder(slotIndex)
+ .setMatchType(matchType)
+ .setQuality(quality)
+ .setZoneId(zoneId)
+ .build();
+ }
+
private static TelephonyTimeZoneSuggestion createEmptySlotIndex1Suggestion() {
return new TelephonyTimeZoneSuggestion.Builder(SLOT_INDEX1).build();
}
@@ -741,6 +1058,17 @@
return new TelephonyTimeZoneSuggestion.Builder(SLOT_INDEX2).build();
}
+ private static GeolocationTimeZoneSuggestion createUncertainGeoLocationSuggestion() {
+ return createGeoLocationSuggestion(null);
+ }
+
+ private static GeolocationTimeZoneSuggestion createGeoLocationSuggestion(
+ @Nullable List<String> zoneIds) {
+ GeolocationTimeZoneSuggestion suggestion = new GeolocationTimeZoneSuggestion(zoneIds);
+ suggestion.addDebugInfo("Test suggestion");
+ return suggestion;
+ }
+
static class FakeCallback implements TimeZoneDetectorStrategyImpl.Callback {
private TimeZoneCapabilities mCapabilities;
@@ -757,7 +1085,8 @@
TimeZoneConfiguration configuration) {
assertEquals(userId, capabilities.getUserId());
mCapabilities = capabilities;
- assertTrue(configuration.isComplete());
+ assertTrue("Configuration must be complete when initializing, config=" + configuration,
+ configuration.isComplete());
mConfiguration.init(new UserConfiguration(userId, configuration));
}
@@ -790,11 +1119,8 @@
mConfiguration.set(new UserConfiguration(userId, newConfig));
if (!newConfig.equals(oldConfig)) {
- if (oldConfig.isAutoDetectionEnabled() != newConfig.isAutoDetectionEnabled()) {
- // Simulate what happens when the auto detection enabled configuration is
- // changed.
- mStrategy.handleAutoTimeZoneConfigChanged();
- }
+ // Simulate what happens when the auto detection configuration is changed.
+ mStrategy.handleAutoTimeZoneConfigChanged();
}
}
@@ -804,6 +1130,11 @@
}
@Override
+ public boolean isGeoDetectionEnabled() {
+ return mConfiguration.getLatest().configuration.isGeoDetectionEnabled();
+ }
+
+ @Override
public boolean isDeviceTimeZoneInitialized() {
return mTimeZoneId.getLatest() != null;
}
@@ -942,32 +1273,33 @@
* supplied configuration.
*/
private static TimeZoneCapabilities createCapabilities(
- int userId, UserCase userRole, TimeZoneConfiguration configuration) {
- switch (userRole) {
+ int userId, UserCase userCase, TimeZoneConfiguration configuration) {
+ switch (userCase) {
case UNRESTRICTED: {
int suggestManualTimeZoneCapability = configuration.isAutoDetectionEnabled()
? CAPABILITY_NOT_APPLICABLE : CAPABILITY_POSSESSED;
return new TimeZoneCapabilities.Builder(userId)
.setConfigureAutoDetectionEnabled(CAPABILITY_POSSESSED)
+ .setConfigureGeoDetectionEnabled(CAPABILITY_POSSESSED)
.setSuggestManualTimeZone(suggestManualTimeZoneCapability)
.build();
}
case RESTRICTED: {
return new TimeZoneCapabilities.Builder(userId)
.setConfigureAutoDetectionEnabled(CAPABILITY_NOT_ALLOWED)
+ .setConfigureGeoDetectionEnabled(CAPABILITY_NOT_ALLOWED)
.setSuggestManualTimeZone(CAPABILITY_NOT_ALLOWED)
.build();
-
}
case AUTO_DETECT_NOT_SUPPORTED: {
return new TimeZoneCapabilities.Builder(userId)
.setConfigureAutoDetectionEnabled(CAPABILITY_NOT_SUPPORTED)
+ .setConfigureGeoDetectionEnabled(CAPABILITY_NOT_SUPPORTED)
.setSuggestManualTimeZone(CAPABILITY_POSSESSED)
.build();
-
}
default:
- throw new AssertionError(userRole + " not recognized");
+ throw new AssertionError(userCase + " not recognized");
}
}
@@ -978,8 +1310,8 @@
private class Script {
Script initializeUser(
- @UserIdInt int userId, UserCase userRole, TimeZoneConfiguration configuration) {
- TimeZoneCapabilities capabilities = createCapabilities(userId, userRole, configuration);
+ @UserIdInt int userId, UserCase userCase, TimeZoneConfiguration configuration) {
+ TimeZoneCapabilities capabilities = createCapabilities(userId, userCase, configuration);
mFakeCallback.initializeUser(userId, capabilities, configuration);
return this;
}
@@ -989,27 +1321,24 @@
return this;
}
- Script simulateAutoTimeZoneDetectionEnabled(@UserIdInt int userId, boolean enabled) {
- TimeZoneConfiguration configuration = new TimeZoneConfiguration.Builder()
- .setAutoDetectionEnabled(enabled)
- .build();
- return simulateUpdateConfiguration(userId, configuration);
- }
-
/**
- * Simulates the time zone detection strategy receiving an updated configuration.
+ * Simulates the time zone detection strategy receiving an updated configuration and checks
+ * the return value.
*/
Script simulateUpdateConfiguration(
- @UserIdInt int userId, TimeZoneConfiguration configuration) {
- mTimeZoneDetectorStrategy.updateConfiguration(userId, configuration);
+ @UserIdInt int userId, TimeZoneConfiguration configuration,
+ boolean expectedResult) {
+ assertEquals(expectedResult,
+ mTimeZoneDetectorStrategy.updateConfiguration(userId, configuration));
return this;
}
/**
- * Simulates the time zone detection strategy receiving a telephony-originated suggestion.
+ * Simulates the time zone detection strategy receiving a geolocation-originated
+ * suggestion.
*/
- Script simulateTelephonyTimeZoneSuggestion(TelephonyTimeZoneSuggestion timeZoneSuggestion) {
- mTimeZoneDetectorStrategy.suggestTelephonyTimeZone(timeZoneSuggestion);
+ Script simulateGeolocationTimeZoneSuggestion(GeolocationTimeZoneSuggestion suggestion) {
+ mTimeZoneDetectorStrategy.suggestGeolocationTimeZone(suggestion);
return this;
}
@@ -1024,13 +1353,26 @@
return this;
}
+ /**
+ * Simulates the time zone detection strategy receiving a telephony-originated suggestion.
+ */
+ Script simulateTelephonyTimeZoneSuggestion(TelephonyTimeZoneSuggestion timeZoneSuggestion) {
+ mTimeZoneDetectorStrategy.suggestTelephonyTimeZone(timeZoneSuggestion);
+ return this;
+ }
+
+ /**
+ * Confirms that the device's time zone has not been set by previous actions since the test
+ * state was last reset.
+ */
Script verifyTimeZoneNotChanged() {
mFakeCallback.assertTimeZoneNotChanged();
return this;
}
- Script verifyTimeZoneChangedAndReset(TelephonyTimeZoneSuggestion suggestion) {
- mFakeCallback.assertTimeZoneChangedTo(suggestion.getZoneId());
+ /** Verifies the device's time zone has been set and clears change tracking history. */
+ Script verifyTimeZoneChangedAndReset(String zoneId) {
+ mFakeCallback.assertTimeZoneChangedTo(zoneId);
mFakeCallback.commitAllChanges();
return this;
}
@@ -1041,6 +1383,12 @@
return this;
}
+ Script verifyTimeZoneChangedAndReset(TelephonyTimeZoneSuggestion suggestion) {
+ mFakeCallback.assertTimeZoneChangedTo(suggestion.getZoneId());
+ mFakeCallback.commitAllChanges();
+ return this;
+ }
+
/**
* Verifies that the configuration has been changed to the expected value.
*/
@@ -1120,4 +1468,8 @@
mOnConfigurationChangedCalled = false;
}
}
+
+ private static <T> List<T> list(T... values) {
+ return Arrays.asList(values);
+ }
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index 980772b..5b2d738 100755
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -4856,6 +4856,70 @@
}
@Test
+ public void backgroundSystemCustomToast_callsSetProcessImportantAsForegroundForToast() throws
+ Exception {
+ final String testPackage = "testPackageName";
+ assertEquals(0, mService.mToastQueue.size());
+ mService.isSystemUid = true;
+
+ // package is not suspended
+ when(mPackageManager.isPackageSuspendedForUser(testPackage, UserHandle.getUserId(mUid)))
+ .thenReturn(false);
+
+ // notifications from this package are blocked by the user
+ mService.setPreferencesHelper(mPreferencesHelper);
+ when(mPreferencesHelper.getImportance(testPackage, mUid)).thenReturn(IMPORTANCE_NONE);
+
+ setAppInForegroundForToasts(mUid, false);
+
+ // enqueue toast -> toast should still enqueue
+ ((INotificationManager) mService.mService).enqueueToast(testPackage, new Binder(),
+ new TestableToastCallback(), 2000, 0);
+ assertEquals(1, mService.mToastQueue.size());
+ verify(mAm).setProcessImportant(any(), anyInt(), eq(true), any());
+ }
+
+ @Test
+ public void foregroundTextToast_callsSetProcessImportantAsNotForegroundForToast() throws
+ Exception {
+ final String testPackage = "testPackageName";
+ assertEquals(0, mService.mToastQueue.size());
+ mService.isSystemUid = false;
+
+ // package is not suspended
+ when(mPackageManager.isPackageSuspendedForUser(testPackage, UserHandle.getUserId(mUid)))
+ .thenReturn(false);
+
+ setAppInForegroundForToasts(mUid, true);
+
+ // enqueue toast -> toast should still enqueue
+ ((INotificationManager) mService.mService).enqueueTextToast(testPackage, new Binder(),
+ "Text", 2000, 0, null);
+ assertEquals(1, mService.mToastQueue.size());
+ verify(mAm).setProcessImportant(any(), anyInt(), eq(false), any());
+ }
+
+ @Test
+ public void backgroundTextToast_callsSetProcessImportantAsNotForegroundForToast() throws
+ Exception {
+ final String testPackage = "testPackageName";
+ assertEquals(0, mService.mToastQueue.size());
+ mService.isSystemUid = false;
+
+ // package is not suspended
+ when(mPackageManager.isPackageSuspendedForUser(testPackage, UserHandle.getUserId(mUid)))
+ .thenReturn(false);
+
+ setAppInForegroundForToasts(mUid, false);
+
+ // enqueue toast -> toast should still enqueue
+ ((INotificationManager) mService.mService).enqueueTextToast(testPackage, new Binder(),
+ "Text", 2000, 0, null);
+ assertEquals(1, mService.mToastQueue.size());
+ verify(mAm).setProcessImportant(any(), anyInt(), eq(false), any());
+ }
+
+ @Test
public void testTextToastsCallStatusBar() throws Exception {
final String testPackage = "testPackageName";
assertEquals(0, mService.mToastQueue.size());
diff --git a/services/tests/uiservicestests/src/com/android/server/slice/PackageMatchingCacheTest.java b/services/tests/uiservicestests/src/com/android/server/slice/PackageMatchingCacheTest.java
deleted file mode 100644
index f6c854e..0000000
--- a/services/tests/uiservicestests/src/com/android/server/slice/PackageMatchingCacheTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.server.slice;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.testing.AndroidTestingRunner;
-import android.testing.TestableLooper.RunWithLooper;
-
-import androidx.test.filters.SmallTest;
-
-import com.android.server.UiServiceTestCase;
-import com.android.server.slice.SliceManagerService.PackageMatchingCache;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.function.Supplier;
-
-@SmallTest
-@RunWith(AndroidTestingRunner.class)
-@RunWithLooper
-public class PackageMatchingCacheTest extends UiServiceTestCase {
-
- private final Supplier<String> supplier = mock(Supplier.class);
- private final PackageMatchingCache cache = new PackageMatchingCache(supplier);
-
- @Test
- public void testNulls() {
- // Doesn't get for a null input
- cache.matches(null);
- verify(supplier, never()).get();
-
- // Gets once valid input in sent.
- cache.matches("");
- verify(supplier).get();
- }
-
- @Test
- public void testCaching() {
- when(supplier.get()).thenReturn("ret.pkg");
-
- assertTrue(cache.matches("ret.pkg"));
- assertTrue(cache.matches("ret.pkg"));
- assertTrue(cache.matches("ret.pkg"));
-
- verify(supplier, times(1)).get();
- }
-
- @Test
- public void testGetOnFailure() {
- when(supplier.get()).thenReturn("ret.pkg");
- assertTrue(cache.matches("ret.pkg"));
-
- when(supplier.get()).thenReturn("other.pkg");
- assertTrue(cache.matches("other.pkg"));
- verify(supplier, times(2)).get();
- }
-}
diff --git a/services/tests/uiservicestests/src/com/android/server/slice/SliceManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/slice/SliceManagerServiceTest.java
index a443695..cf1c36c 100644
--- a/services/tests/uiservicestests/src/com/android/server/slice/SliceManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/slice/SliceManagerServiceTest.java
@@ -90,8 +90,6 @@
@Test
public void testAddPinCreatesPinned() throws RemoteException {
- doReturn("pkg").when(mService).getDefaultHome(anyInt());
-
mService.pinSlice("pkg", TEST_URI, EMPTY_SPECS, mToken);
mService.pinSlice("pkg", TEST_URI, EMPTY_SPECS, mToken);
verify(mService, times(1)).createPinnedSlice(eq(maybeAddUserId(TEST_URI, 0)), anyString());
@@ -99,8 +97,6 @@
@Test
public void testRemovePinDestroysPinned() throws RemoteException {
- doReturn("pkg").when(mService).getDefaultHome(anyInt());
-
mService.pinSlice("pkg", TEST_URI, EMPTY_SPECS, mToken);
when(mCreatedSliceState.unpin(eq("pkg"), eq(mToken))).thenReturn(false);
diff --git a/services/tests/wmtests/Android.bp b/services/tests/wmtests/Android.bp
index b3d75d3..4ca5b9e 100644
--- a/services/tests/wmtests/Android.bp
+++ b/services/tests/wmtests/Android.bp
@@ -2,15 +2,37 @@
// Build WmTests package
//########################################################################
+// Include all test java files.
+filegroup {
+ name: "wmtests-sources",
+ srcs: [
+ "src/**/*.java",
+ ],
+}
+
+genrule {
+ name: "wmtests.protologsrc",
+ srcs: [
+ ":protolog-groups",
+ ":wmtests-sources",
+ ],
+ tools: ["protologtool"],
+ cmd: "$(location protologtool) transform-protolog-calls " +
+ "--protolog-class com.android.internal.protolog.common.ProtoLog " +
+ "--protolog-impl-class com.android.internal.protolog.ProtoLogImpl " +
+ "--protolog-cache-class 'com.android.server.wm.ProtoLogCache' " +
+ "--loggroups-class com.android.internal.protolog.ProtoLogGroup " +
+ "--loggroups-jar $(location :protolog-groups) " +
+ "--output-srcjar $(out) " +
+ "$(locations :wmtests-sources)",
+ out: ["wmtests.protolog.srcjar"],
+}
+
android_test {
name: "WmTests",
// We only want this apk build for tests.
-
- // Include all test java files.
- srcs: [
- "src/**/*.java",
- ],
+ srcs: [":wmtests.protologsrc"],
static_libs: [
"frameworks-base-testutils",
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index e3830f6..f860e17 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -22,6 +22,10 @@
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION;
import static android.content.pm.ActivityInfo.CONFIG_SCREEN_LAYOUT;
+import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_ALWAYS;
+import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_DEFAULT;
+import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED;
+import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_NEVER;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
@@ -69,10 +73,8 @@
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.clearInvocations;
-import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import android.app.ActivityManager.TaskSnapshot;
@@ -84,6 +86,7 @@
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
@@ -1503,7 +1506,7 @@
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
params.width = params.height = WindowManager.LayoutParams.MATCH_PARENT;
- final WindowTestUtils.TestWindowState w = new WindowTestUtils.TestWindowState(
+ final TestWindowState w = new TestWindowState(
mAtm.mWindowManager, mock(Session.class), new TestIWindow(), params, mActivity);
mActivity.addWindow(w);
@@ -1685,6 +1688,32 @@
assertFalse(mActivity.canTurnScreenOn());
}
+ @Test
+ public void testGetLockTaskLaunchMode() {
+ final ActivityOptions options = ActivityOptions.makeBasic().setLockTaskEnabled(true);
+ mActivity.info.lockTaskLaunchMode = LOCK_TASK_LAUNCH_MODE_DEFAULT;
+ assertEquals(LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED,
+ ActivityRecord.getLockTaskLaunchMode(mActivity.info, options));
+
+ mActivity.info.lockTaskLaunchMode = LOCK_TASK_LAUNCH_MODE_ALWAYS;
+ assertEquals(LOCK_TASK_LAUNCH_MODE_DEFAULT,
+ ActivityRecord.getLockTaskLaunchMode(mActivity.info, null /*options*/));
+
+ mActivity.info.lockTaskLaunchMode = LOCK_TASK_LAUNCH_MODE_NEVER;
+ assertEquals(LOCK_TASK_LAUNCH_MODE_DEFAULT,
+ ActivityRecord.getLockTaskLaunchMode(mActivity.info, null /*options*/));
+
+ mActivity.info.applicationInfo.privateFlags |= ApplicationInfo.PRIVATE_FLAG_PRIVILEGED;
+ mActivity.info.lockTaskLaunchMode = LOCK_TASK_LAUNCH_MODE_ALWAYS;
+ assertEquals(LOCK_TASK_LAUNCH_MODE_ALWAYS,
+ ActivityRecord.getLockTaskLaunchMode(mActivity.info, null /*options*/));
+
+ mActivity.info.lockTaskLaunchMode = LOCK_TASK_LAUNCH_MODE_NEVER;
+ assertEquals(LOCK_TASK_LAUNCH_MODE_NEVER,
+ ActivityRecord.getLockTaskLaunchMode(mActivity.info, null /*options*/));
+
+ }
+
/**
* Creates an activity on display. For non-default display request it will also create a new
* display with custom DisplayInfo.
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
index 2e988af..5676100 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
@@ -225,5 +225,27 @@
mockSession.finishMocking();
}
+
+ @Test
+ public void testResumeNextActivityOnCrashedAppDied() {
+ mSupervisor.beginDeferResume();
+ final ActivityRecord homeActivity = new ActivityBuilder(mAtm)
+ .setTask(mRootWindowContainer.getDefaultTaskDisplayArea().getOrCreateRootHomeTask())
+ .build();
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build();
+ mSupervisor.endDeferResume();
+ // Assume the activity is finishing and hidden because it was crashed.
+ activity.finishing = true;
+ activity.mVisibleRequested = false;
+ activity.setVisible(false);
+ activity.getRootTask().mPausingActivity = activity;
+ homeActivity.setState(Task.ActivityState.PAUSED, "test");
+
+ // Even the visibility states are invisible, the next activity should be resumed because
+ // the crashed activity was pausing.
+ mAtm.mInternal.handleAppDied(activity.app, false /* restarting */,
+ null /* finishInstrumentationCallback */);
+ assertEquals(Task.ActivityState.RESUMED, homeActivity.getState());
+ }
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java
index 7adcead..1b21920 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java
@@ -133,10 +133,10 @@
// [DisplayContent] -+- [TaskStack1] - [Task1] - [ActivityRecord1] (opening, visible)
// +- [TaskStack2] - [Task2] - [ActivityRecord2] (closing, invisible)
final Task stack1 = createTaskStackOnDisplay(mDisplayContent);
- final ActivityRecord activity1 = WindowTestUtils.createTestActivityRecord(stack1);
+ final ActivityRecord activity1 = createTestActivityRecord(stack1);
final Task stack2 = createTaskStackOnDisplay(mDisplayContent);
- final ActivityRecord activity2 = WindowTestUtils.createTestActivityRecord(stack2);
+ final ActivityRecord activity2 = createTestActivityRecord(stack2);
activity2.setVisible(false);
activity2.mVisibleRequested = false;
@@ -162,13 +162,13 @@
// [DisplayContent] -+- [TaskStack1] - [Task1] - [ActivityRecord1] (closing, invisible)
// +- [TaskStack2] - [Task2] - [ActivityRecord2] (opening, visible)
final Task stack1 = createTaskStackOnDisplay(mDisplayContent);
- final ActivityRecord activity1 = WindowTestUtils.createTestActivityRecord(stack1);
+ final ActivityRecord activity1 = createTestActivityRecord(stack1);
activity1.setVisible(true);
activity1.mVisibleRequested = true;
activity1.mRequestForceTransition = true;
final Task stack2 = createTaskStackOnDisplay(mDisplayContent);
- final ActivityRecord activity2 = WindowTestUtils.createTestActivityRecord(stack2);
+ final ActivityRecord activity2 = createTestActivityRecord(stack2);
activity2.setVisible(false);
activity2.mVisibleRequested = false;
activity2.mRequestForceTransition = true;
@@ -193,10 +193,10 @@
@Test
public void testGetAnimationTargets_exitingBeforeTransition() {
// Create another non-empty task so the animation target won't promote to task display area.
- WindowTestUtils.createTestActivityRecord(
+ createTestActivityRecord(
mDisplayContent.getDefaultTaskDisplayArea().getOrCreateRootHomeTask());
final Task stack = createTaskStackOnDisplay(mDisplayContent);
- final ActivityRecord activity = WindowTestUtils.createTestActivityRecord(stack);
+ final ActivityRecord activity = createTestActivityRecord(stack);
activity.setVisible(false);
activity.mIsExiting = true;
@@ -218,20 +218,20 @@
// +- [TaskStack2] - [Task2] - [ActivityRecord2] (closing, invisible)
// +- [AppWindow2] (being-replaced)
final Task stack1 = createTaskStackOnDisplay(mDisplayContent);
- final ActivityRecord activity1 = WindowTestUtils.createTestActivityRecord(stack1);
+ final ActivityRecord activity1 = createTestActivityRecord(stack1);
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(
TYPE_BASE_APPLICATION);
attrs.setTitle("AppWindow1");
- final WindowTestUtils.TestWindowState appWindow1 = createWindowState(attrs, activity1);
+ final TestWindowState appWindow1 = createWindowState(attrs, activity1);
appWindow1.mWillReplaceWindow = true;
activity1.addWindow(appWindow1);
final Task stack2 = createTaskStackOnDisplay(mDisplayContent);
- final ActivityRecord activity2 = WindowTestUtils.createTestActivityRecord(stack2);
+ final ActivityRecord activity2 = createTestActivityRecord(stack2);
activity2.setVisible(false);
activity2.mVisibleRequested = false;
attrs.setTitle("AppWindow2");
- final WindowTestUtils.TestWindowState appWindow2 = createWindowState(attrs, activity2);
+ final TestWindowState appWindow2 = createWindowState(attrs, activity2);
appWindow2.mWillReplaceWindow = true;
activity2.addWindow(appWindow2);
@@ -262,21 +262,17 @@
// +- [ActivityRecord4] (invisible)
final Task stack1 = createTaskStackOnDisplay(mDisplayContent);
final Task task1 = createTaskInStack(stack1, 0 /* userId */);
- final ActivityRecord activity1 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task1);
+ final ActivityRecord activity1 = createActivityRecordInTask(mDisplayContent, task1);
activity1.setVisible(false);
activity1.mVisibleRequested = true;
- final ActivityRecord activity2 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task1);
+ final ActivityRecord activity2 = createActivityRecordInTask(mDisplayContent, task1);
activity2.setVisible(false);
activity2.mVisibleRequested = false;
final Task stack2 = createTaskStackOnDisplay(mDisplayContent);
final Task task2 = createTaskInStack(stack2, 0 /* userId */);
- final ActivityRecord activity3 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task2);
- final ActivityRecord activity4 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task2);
+ final ActivityRecord activity3 = createActivityRecordInTask(mDisplayContent, task2);
+ final ActivityRecord activity4 = createActivityRecordInTask(mDisplayContent, task2);
activity4.setVisible(false);
activity4.mVisibleRequested = false;
@@ -303,12 +299,10 @@
// +- [ActivityRecord2] (closing, visible)
final Task stack = createTaskStackOnDisplay(mDisplayContent);
final Task task = createTaskInStack(stack, 0 /* userId */);
- final ActivityRecord activity1 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task);
+ final ActivityRecord activity1 = createActivityRecordInTask(mDisplayContent, task);
activity1.setVisible(false);
activity1.mVisibleRequested = true;
- final ActivityRecord activity2 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task);
+ final ActivityRecord activity2 = createActivityRecordInTask(mDisplayContent, task);
final ArraySet<ActivityRecord> opening = new ArraySet<>();
opening.add(activity1);
@@ -337,22 +331,18 @@
final Task stack1 = createTaskStackOnDisplay(mDisplayContent);
final Task task1 = createTaskInStack(stack1, 0 /* userId */);
- final ActivityRecord activity1 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task1);
+ final ActivityRecord activity1 = createActivityRecordInTask(mDisplayContent, task1);
activity1.setVisible(false);
activity1.mVisibleRequested = true;
activity1.setOccludesParent(false);
- final ActivityRecord activity2 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task1);
+ final ActivityRecord activity2 = createActivityRecordInTask(mDisplayContent, task1);
final Task stack2 = createTaskStackOnDisplay(mDisplayContent);
final Task task2 = createTaskInStack(stack2, 0 /* userId */);
- final ActivityRecord activity3 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task2);
+ final ActivityRecord activity3 = createActivityRecordInTask(mDisplayContent, task2);
activity3.setOccludesParent(false);
- final ActivityRecord activity4 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task2);
+ final ActivityRecord activity4 = createActivityRecordInTask(mDisplayContent, task2);
final ArraySet<ActivityRecord> opening = new ArraySet<>();
opening.add(activity1);
@@ -381,24 +371,20 @@
final Task stack1 = createTaskStackOnDisplay(mDisplayContent);
final Task task1 = createTaskInStack(stack1, 0 /* userId */);
- final ActivityRecord activity1 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task1);
+ final ActivityRecord activity1 = createActivityRecordInTask(mDisplayContent, task1);
activity1.setVisible(false);
activity1.mVisibleRequested = true;
activity1.setOccludesParent(false);
- final ActivityRecord activity2 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task1);
+ final ActivityRecord activity2 = createActivityRecordInTask(mDisplayContent, task1);
activity2.setVisible(false);
activity2.mVisibleRequested = true;
final Task stack2 = createTaskStackOnDisplay(mDisplayContent);
final Task task2 = createTaskInStack(stack2, 0 /* userId */);
- final ActivityRecord activity3 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task2);
+ final ActivityRecord activity3 = createActivityRecordInTask(mDisplayContent, task2);
activity3.setOccludesParent(false);
- final ActivityRecord activity4 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task2);
+ final ActivityRecord activity4 = createActivityRecordInTask(mDisplayContent, task2);
final ArraySet<ActivityRecord> opening = new ArraySet<>();
opening.add(activity1);
@@ -425,13 +411,11 @@
// +- [Task2] - [ActivityRecord2] (closing, visible)
final Task stack = createTaskStackOnDisplay(mDisplayContent);
final Task task1 = createTaskInStack(stack, 0 /* userId */);
- final ActivityRecord activity1 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task1);
+ final ActivityRecord activity1 = createActivityRecordInTask(mDisplayContent, task1);
activity1.setVisible(false);
activity1.mVisibleRequested = true;
final Task task2 = createTaskInStack(stack, 0 /* userId */);
- final ActivityRecord activity2 = WindowTestUtils.createActivityRecordInTask(
- mDisplayContent, task2);
+ final ActivityRecord activity2 = createActivityRecordInTask(mDisplayContent, task2);
final ArraySet<ActivityRecord> opening = new ArraySet<>();
opening.add(activity1);
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java
index 17914e7..ee030af 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java
@@ -151,8 +151,7 @@
final Task stack1 = createTaskStackOnDisplay(dc1);
final Task task1 = createTaskInStack(stack1, 0 /* userId */);
- final ActivityRecord activity1 =
- WindowTestUtils.createTestActivityRecord(dc1);
+ final ActivityRecord activity1 = createTestActivityRecord(dc1);
task1.addChild(activity1, 0);
// Simulate same app is during opening / closing transition set stage.
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
index 888935e..085b8de 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
@@ -92,7 +92,7 @@
public void setUp() throws Exception {
mStack = createTaskStackOnDisplay(mDisplayContent);
mTask = createTaskInStack(mStack, 0 /* userId */);
- mActivity = WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ mActivity = createTestActivityRecord(mDisplayContent);
mTask.addChild(mActivity, 0);
}
@@ -165,7 +165,7 @@
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(
TYPE_BASE_APPLICATION);
attrs.setTitle("AppWindow");
- final WindowTestUtils.TestWindowState appWindow = createWindowState(attrs, mActivity);
+ final TestWindowState appWindow = createWindowState(attrs, mActivity);
mActivity.addWindow(appWindow);
// Set initial orientation and update.
@@ -198,7 +198,7 @@
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(
TYPE_BASE_APPLICATION);
attrs.setTitle("RotationByPolicy");
- final WindowTestUtils.TestWindowState appWindow = createWindowState(attrs, mActivity);
+ final TestWindowState appWindow = createWindowState(attrs, mActivity);
mActivity.addWindow(appWindow);
// Set initial orientation and update.
@@ -244,7 +244,7 @@
TYPE_BASE_APPLICATION);
attrs.flags |= FLAG_SHOW_WHEN_LOCKED | FLAG_DISMISS_KEYGUARD;
attrs.setTitle("AppWindow");
- final WindowTestUtils.TestWindowState appWindow = createWindowState(attrs, mActivity);
+ final TestWindowState appWindow = createWindowState(attrs, mActivity);
// Add window with show when locked flag
mActivity.addWindow(appWindow);
@@ -307,7 +307,7 @@
assertEquals(Configuration.ORIENTATION_PORTRAIT, displayConfig.orientation);
assertEquals(Configuration.ORIENTATION_PORTRAIT, activityConfig.orientation);
- final ActivityRecord topActivity = WindowTestUtils.createTestActivityRecord(mStack);
+ final ActivityRecord topActivity = createTestActivityRecord(mStack);
topActivity.setOrientation(SCREEN_ORIENTATION_LANDSCAPE);
assertEquals(Configuration.ORIENTATION_LANDSCAPE, displayConfig.orientation);
@@ -490,8 +490,7 @@
}
private ActivityRecord createTestActivityRecordForGivenTask(Task task) {
- final ActivityRecord activity =
- WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ final ActivityRecord activity = createTestActivityRecord(mDisplayContent);
task.addChild(activity, 0);
waitUntilHandlersIdle();
return activity;
@@ -562,7 +561,7 @@
public void testHasStartingWindow() {
final WindowManager.LayoutParams attrs =
new WindowManager.LayoutParams(TYPE_APPLICATION_STARTING);
- final WindowTestUtils.TestWindowState startingWindow = createWindowState(attrs, mActivity);
+ final TestWindowState startingWindow = createWindowState(attrs, mActivity);
mActivity.startingDisplayed = true;
mActivity.addWindow(startingWindow);
assertTrue("Starting window should be present", mActivity.hasStartingWindow());
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
index 0cc6159..d54b4a0 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -326,7 +326,7 @@
assertEquals(dc, stack.getDisplayContent());
final Task task = createTaskInStack(stack, 0 /* userId */);
- final ActivityRecord activity = WindowTestUtils.createTestActivityRecord(dc);
+ final ActivityRecord activity = createTestActivityRecord(dc);
task.addChild(activity, 0);
assertEquals(dc, task.getDisplayContent());
assertEquals(dc, activity.getDisplayContent());
@@ -397,16 +397,14 @@
// Add stack with activity.
final Task stack0 = createTaskStackOnDisplay(dc0);
final Task task0 = createTaskInStack(stack0, 0 /* userId */);
- final ActivityRecord activity =
- WindowTestUtils.createTestActivityRecord(dc0);
+ final ActivityRecord activity = createTestActivityRecord(dc0);
task0.addChild(activity, 0);
dc0.configureDisplayPolicy();
assertNotNull(dc0.mTapDetector);
final Task stack1 = createTaskStackOnDisplay(dc1);
final Task task1 = createTaskInStack(stack1, 0 /* userId */);
- final ActivityRecord activity1 =
- WindowTestUtils.createTestActivityRecord(dc0);
+ final ActivityRecord activity1 = createTestActivityRecord(dc0);
task1.addChild(activity1, 0);
dc1.configureDisplayPolicy();
assertNotNull(dc1.mTapDetector);
@@ -1296,7 +1294,7 @@
final ActivityRecord pinnedActivity = createActivityRecord(displayContent,
WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD);
final Task pinnedTask = pinnedActivity.getRootTask();
- final ActivityRecord homeActivity = WindowTestUtils.createTestActivityRecord(
+ final ActivityRecord homeActivity = createTestActivityRecord(
displayContent.getDefaultTaskDisplayArea().getOrCreateRootHomeTask());
if (displayConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
homeActivity.setOrientation(SCREEN_ORIENTATION_PORTRAIT);
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 4ea5b97..0675c6d 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java
@@ -48,12 +48,14 @@
import static android.view.WindowManagerPolicyConstants.ALT_BAR_RIGHT;
import static android.view.WindowManagerPolicyConstants.ALT_BAR_TOP;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThat;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
@@ -874,6 +876,19 @@
}
@Test
+ public void testFixedRotationInsetsSourceFrame() {
+ mDisplayPolicy.beginLayoutLw(mFrames, mDisplayContent.getConfiguration().uiMode);
+ doReturn((mDisplayContent.getRotation() + 1) % 4).when(mDisplayContent)
+ .rotationForActivityInDifferentOrientation(eq(mWindow.mActivityRecord));
+ final Rect frame = mWindow.getInsetsState().getSource(ITYPE_STATUS_BAR).getFrame();
+ mDisplayContent.rotateInDifferentOrientationIfNeeded(mWindow.mActivityRecord);
+ final Rect rotatedFrame = mWindow.getInsetsState().getSource(ITYPE_STATUS_BAR).getFrame();
+
+ assertEquals(DISPLAY_WIDTH, frame.width());
+ assertEquals(DISPLAY_HEIGHT, rotatedFrame.width());
+ }
+
+ @Test
public void testScreenDecorWindows() {
final WindowState decorWindow = spy(
createWindow(null, TYPE_APPLICATION_OVERLAY, "decorWindow"));
diff --git a/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java
index e18d93d..4536997 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java
@@ -95,8 +95,7 @@
* Creates a window state which can be used as a drop target.
*/
private WindowState createDropTargetWindow(String name, int ownerId) {
- final ActivityRecord activity = WindowTestUtils.createTestActivityRecord(
- mDisplayContent);
+ final ActivityRecord activity = createTestActivityRecord(mDisplayContent);
final Task stack = createTaskStackOnDisplay(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, mDisplayContent);
final Task task = createTaskInStack(stack, ownerId);
diff --git a/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java
index 5e83e66..085230d 100644
--- a/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java
@@ -28,6 +28,9 @@
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -40,6 +43,7 @@
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
+import android.util.IntArray;
import android.view.InsetsSourceControl;
import android.view.InsetsState;
import android.view.test.InsetsModeSession;
@@ -328,6 +332,27 @@
assertNull(getController().getControlsForDispatch(app));
}
+ @Test
+ public void testTransientVisibilityOfFixedRotationState() {
+ final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
+ final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
+ final InsetsSourceProvider provider = getController().getSourceProvider(ITYPE_STATUS_BAR);
+ provider.setWindow(statusBar, null, null);
+
+ final InsetsState rotatedState = new InsetsState(app.getInsetsState(),
+ true /* copySources */);
+ spyOn(app.mToken);
+ doReturn(rotatedState).when(app.mToken).getFixedRotationTransformInsetsState();
+ assertTrue(rotatedState.getSource(ITYPE_STATUS_BAR).isVisible());
+
+ provider.getSource().setVisible(false);
+ mDisplayContent.getInsetsPolicy().showTransient(
+ IntArray.wrap(new int[] { ITYPE_STATUS_BAR }));
+
+ assertTrue(mDisplayContent.getInsetsPolicy().isTransient(ITYPE_STATUS_BAR));
+ assertFalse(app.getInsetsState().getSource(ITYPE_STATUS_BAR).isVisible());
+ }
+
private InsetsStateController getController() {
return mDisplayContent.getInsetsStateController();
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/ProtoLogIntegrationTest.java b/services/tests/wmtests/src/com/android/server/wm/ProtoLogIntegrationTest.java
index d1510cf..82230242 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ProtoLogIntegrationTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ProtoLogIntegrationTest.java
@@ -25,9 +25,12 @@
import androidx.test.filters.SmallTest;
-import com.android.server.protolog.ProtoLogImpl;
+import com.android.internal.protolog.ProtoLogGroup;
+import com.android.internal.protolog.ProtoLogImpl;
+import com.android.internal.protolog.common.ProtoLog;
import org.junit.After;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -35,6 +38,7 @@
*/
@SmallTest
@Presubmit
+@Ignore("b/163095037")
public class ProtoLogIntegrationTest {
@After
public void tearDown() {
@@ -44,17 +48,21 @@
@Test
public void testProtoLogToolIntegration() {
ProtoLogImpl mockedProtoLog = mock(ProtoLogImpl.class);
- runWith(mockedProtoLog, () -> {
- ProtoLogGroup.testProtoLog();
- });
+ runWith(mockedProtoLog, this::testProtoLog);
verify(mockedProtoLog).log(eq(ProtoLogImpl.LogLevel.ERROR), eq(ProtoLogGroup.TEST_GROUP),
anyInt(), eq(0b0010101001010111),
- eq(ProtoLogGroup.TEST_GROUP.isLogToLogcat()
+ eq(com.android.internal.protolog.ProtoLogGroup.TEST_GROUP.isLogToLogcat()
? "Test completed successfully: %b %d %o %x %e %g %f %% %s"
: null),
eq(new Object[]{true, 1L, 2L, 3L, 0.4, 0.5, 0.6, "ok"}));
}
+ private void testProtoLog() {
+ ProtoLog.e(ProtoLogGroup.TEST_GROUP,
+ "Test completed successfully: %b %d %o %x %e %g %f %% %s.",
+ true, 1, 2, 3, 0.4, 0.5, 0.6, "ok");
+ }
+
/**
* Starts protolog for the duration of {@code runnable}, with a ProtoLogImpl instance installed.
*/
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index 0e1d4dc..982e469 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -568,7 +568,9 @@
private static WindowState addWindowToActivity(ActivityRecord activity) {
final WindowManager.LayoutParams params = new WindowManager.LayoutParams();
params.type = WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
- final WindowTestUtils.TestWindowState w = new WindowTestUtils.TestWindowState(
+ params.setFitInsetsSides(0);
+ params.setFitInsetsTypes(0);
+ final TestWindowState w = new TestWindowState(
activity.mWmService, mock(Session.class), new TestIWindow(), params, activity);
WindowTestsBase.makeWindowVisible(w);
w.mWinAnimator.mDrawState = WindowStateAnimator.HAS_DRAWN;
@@ -581,7 +583,7 @@
doReturn(true).when(displayPolicy).hasStatusBar();
displayPolicy.onConfigurationChanged();
- final WindowTestUtils.TestWindowToken token = WindowTestUtils.createTestWindowToken(
+ final TestWindowToken token = createTestWindowToken(
WindowManager.LayoutParams.TYPE_STATUS_BAR, displayContent);
final WindowManager.LayoutParams attrs =
new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_STATUS_BAR);
@@ -589,7 +591,7 @@
attrs.layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
attrs.setFitInsetsTypes(0 /* types */);
- final WindowTestUtils.TestWindowState statusBar = new WindowTestUtils.TestWindowState(
+ final TestWindowState statusBar = new TestWindowState(
displayContent.mWmService, mock(Session.class), new TestIWindow(), attrs, token);
token.addWindow(statusBar);
statusBar.setRequestedSize(displayContent.mBaseDisplayWidth,
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java
index 3492556..260f1e9 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java
@@ -76,8 +76,7 @@
// Stack should contain visible app window to be considered visible.
final Task pinnedTask = createTaskInStack(mPinnedStack, 0 /* userId */);
assertFalse(mPinnedStack.isVisible());
- final ActivityRecord pinnedApp =
- WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ final ActivityRecord pinnedApp = createTestActivityRecord(mDisplayContent);
pinnedTask.addChild(pinnedApp, 0 /* addPos */);
assertTrue(mPinnedStack.isVisible());
}
@@ -92,7 +91,7 @@
final Task stack = createTaskStackOnDisplay(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, mDisplayContent);
final Task task = createTaskInStack(stack, 0 /* userId */);
- final ActivityRecord activity = WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ final ActivityRecord activity = createTestActivityRecord(mDisplayContent);
task.addChild(activity, 0 /* addPos */);
final TaskDisplayArea taskDisplayArea = activity.getDisplayArea();
activity.mNeedsAnimationBoundsLayer = true;
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java
index 205b842..7cf30c0 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java
@@ -85,14 +85,12 @@
public void testClosingAppDifferentStackOrientation() {
final Task stack = createTaskStackOnDisplay(mDisplayContent);
final Task task1 = createTaskInStack(stack, 0 /* userId */);
- ActivityRecord activity1 =
- WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ ActivityRecord activity1 = createTestActivityRecord(mDisplayContent);
task1.addChild(activity1, 0);
activity1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE);
final Task task2 = createTaskInStack(stack, 1 /* userId */);
- ActivityRecord activity2=
- WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ ActivityRecord activity2 = createTestActivityRecord(mDisplayContent);
task2.addChild(activity2, 0);
activity2.setOrientation(SCREEN_ORIENTATION_PORTRAIT);
@@ -105,14 +103,12 @@
public void testMoveTaskToBackDifferentStackOrientation() {
final Task stack = createTaskStackOnDisplay(mDisplayContent);
final Task task1 = createTaskInStack(stack, 0 /* userId */);
- ActivityRecord activity1 =
- WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ ActivityRecord activity1 = createTestActivityRecord(mDisplayContent);
task1.addChild(activity1, 0);
activity1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE);
final Task task2 = createTaskInStack(stack, 1 /* userId */);
- ActivityRecord activity2 =
- WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ ActivityRecord activity2 = createTestActivityRecord(mDisplayContent);
task2.addChild(activity2, 0);
activity2.setOrientation(SCREEN_ORIENTATION_PORTRAIT);
assertEquals(SCREEN_ORIENTATION_PORTRAIT, stack.getOrientation());
@@ -221,7 +217,7 @@
public void testActivityAndTaskGetsProperType() {
final Task stack = createTaskStackOnDisplay(mDisplayContent);
final Task task1 = createTaskInStack(stack, 0 /* userId */);
- ActivityRecord activity1 = WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ ActivityRecord activity1 = createTestActivityRecord(mDisplayContent);
// First activity should become standard
task1.addChild(activity1, 0);
@@ -229,7 +225,7 @@
assertEquals(WindowConfiguration.ACTIVITY_TYPE_STANDARD, task1.getActivityType());
// Second activity should also become standard
- ActivityRecord activity2 = WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ ActivityRecord activity2 = createTestActivityRecord(mDisplayContent);
task1.addChild(activity2, WindowContainer.POSITION_TOP);
assertEquals(WindowConfiguration.ACTIVITY_TYPE_STANDARD, activity2.getActivityType());
assertEquals(WindowConfiguration.ACTIVITY_TYPE_STANDARD, task1.getActivityType());
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
index 92b6e6e..ace0400 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
@@ -56,8 +56,7 @@
public void testRemoveContainer() {
final Task stackController1 = createTaskStackOnDisplay(mDisplayContent);
final Task task = createTaskInStack(stackController1, 0 /* userId */);
- final ActivityRecord activity =
- WindowTestUtils.createActivityRecordInTask(mDisplayContent, task);
+ final ActivityRecord activity = createActivityRecordInTask(mDisplayContent, task);
task.removeIfPossible();
// Assert that the container was removed.
@@ -70,8 +69,7 @@
public void testRemoveContainer_deferRemoval() {
final Task stackController1 = createTaskStackOnDisplay(mDisplayContent);
final Task task = createTaskInStack(stackController1, 0 /* userId */);
- final ActivityRecord activity =
- WindowTestUtils.createActivityRecordInTask(mDisplayContent, task);
+ final ActivityRecord activity = createActivityRecordInTask(mDisplayContent, task);
doReturn(true).when(task).shouldDeferRemoval();
@@ -153,10 +151,8 @@
public void testIsInStack() {
final Task task1 = createTaskStackOnDisplay(mDisplayContent);
final Task task2 = createTaskStackOnDisplay(mDisplayContent);
- final ActivityRecord activity1 =
- WindowTestUtils.createActivityRecordInTask(mDisplayContent, task1);
- final ActivityRecord activity2 =
- WindowTestUtils.createActivityRecordInTask(mDisplayContent, task2);
+ final ActivityRecord activity1 = createActivityRecordInTask(mDisplayContent, task1);
+ final ActivityRecord activity2 = createActivityRecordInTask(mDisplayContent, task2);
assertEquals(activity1, task1.isInTask(activity1));
assertNull(task1.isInTask(activity2));
}
@@ -165,12 +161,9 @@
public void testRemoveChildForOverlayTask() {
final Task task = createTaskStackOnDisplay(mDisplayContent);
final int taskId = task.mTaskId;
- final ActivityRecord activity1 =
- WindowTestUtils.createActivityRecordInTask(mDisplayContent, task);
- final ActivityRecord activity2 =
- WindowTestUtils.createActivityRecordInTask(mDisplayContent, task);
- final ActivityRecord activity3 =
- WindowTestUtils.createActivityRecordInTask(mDisplayContent, task);
+ final ActivityRecord activity1 = createActivityRecordInTask(mDisplayContent, task);
+ final ActivityRecord activity2 = createActivityRecordInTask(mDisplayContent, task);
+ final ActivityRecord activity3 = createActivityRecordInTask(mDisplayContent, task);
activity1.setTaskOverlay(true);
activity2.setTaskOverlay(true);
activity3.setTaskOverlay(true);
diff --git a/services/tests/wmtests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java
index 75ed928..6ed7622 100644
--- a/services/tests/wmtests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java
@@ -44,7 +44,7 @@
@Test
public void testFlow() {
- final ActivityRecord activity = WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ final ActivityRecord activity = createTestActivityRecord(mDisplayContent);
mDisplayContent.mUnknownAppVisibilityController.notifyLaunched(activity);
mDisplayContent.mUnknownAppVisibilityController.notifyAppResumedFinished(activity);
mDisplayContent.mUnknownAppVisibilityController.notifyRelayouted(activity);
@@ -56,8 +56,8 @@
@Test
public void testMultiple() {
- final ActivityRecord activity1 = WindowTestUtils.createTestActivityRecord(mDisplayContent);
- final ActivityRecord activity2 = WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ final ActivityRecord activity1 = createTestActivityRecord(mDisplayContent);
+ final ActivityRecord activity2 = createTestActivityRecord(mDisplayContent);
mDisplayContent.mUnknownAppVisibilityController.notifyLaunched(activity1);
mDisplayContent.mUnknownAppVisibilityController.notifyAppResumedFinished(activity1);
mDisplayContent.mUnknownAppVisibilityController.notifyLaunched(activity2);
@@ -72,7 +72,7 @@
@Test
public void testClear() {
- final ActivityRecord activity = WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ final ActivityRecord activity = createTestActivityRecord(mDisplayContent);
mDisplayContent.mUnknownAppVisibilityController.notifyLaunched(activity);
mDisplayContent.mUnknownAppVisibilityController.clear();
assertTrue(mDisplayContent.mUnknownAppVisibilityController.allResolved());
@@ -80,7 +80,7 @@
@Test
public void testRemoveFinishingInvisibleActivityFromUnknown() {
- final ActivityRecord activity = WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ final ActivityRecord activity = createTestActivityRecord(mDisplayContent);
mDisplayContent.mUnknownAppVisibilityController.notifyLaunched(activity);
activity.finishing = true;
activity.mVisibleRequested = true;
@@ -90,7 +90,7 @@
@Test
public void testAppRemoved() {
- final ActivityRecord activity = WindowTestUtils.createTestActivityRecord(mDisplayContent);
+ final ActivityRecord activity = createTestActivityRecord(mDisplayContent);
mDisplayContent.mUnknownAppVisibilityController.notifyLaunched(activity);
mDisplayContent.mUnknownAppVisibilityController.appRemovedOrHidden(activity);
assertTrue(mDisplayContent.mUnknownAppVisibilityController.allResolved());
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
index 8ac44f2..4163a9a 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
@@ -810,8 +810,7 @@
public void testOnDisplayChanged() {
final Task stack = createTaskStackOnDisplay(mDisplayContent);
final Task task = createTaskInStack(stack, 0 /* userId */);
- final ActivityRecord activity =
- WindowTestUtils.createActivityRecordInTask(mDisplayContent, task);
+ final ActivityRecord activity = createActivityRecordInTask(mDisplayContent, task);
final DisplayContent newDc = createNewDisplay();
stack.getDisplayArea().removeStack(stack);
@@ -854,19 +853,17 @@
public void testTaskCanApplyAnimation() {
final Task stack = createTaskStackOnDisplay(mDisplayContent);
final Task task = createTaskInStack(stack, 0 /* userId */);
- final ActivityRecord activity2 =
- WindowTestUtils.createActivityRecordInTask(mDisplayContent, task);
- final ActivityRecord activity1 =
- WindowTestUtils.createActivityRecordInTask(mDisplayContent, task);
+ final ActivityRecord activity2 = createActivityRecordInTask(mDisplayContent, task);
+ final ActivityRecord activity1 = createActivityRecordInTask(mDisplayContent, task);
verifyWindowContainerApplyAnimation(task, activity1, activity2);
}
@Test
public void testStackCanApplyAnimation() {
final Task stack = createTaskStackOnDisplay(mDisplayContent);
- final ActivityRecord activity2 = WindowTestUtils.createActivityRecordInTask(mDisplayContent,
+ final ActivityRecord activity2 = createActivityRecordInTask(mDisplayContent,
createTaskInStack(stack, 0 /* userId */));
- final ActivityRecord activity1 = WindowTestUtils.createActivityRecordInTask(mDisplayContent,
+ final ActivityRecord activity1 = createActivityRecordInTask(mDisplayContent,
createTaskInStack(stack, 0 /* userId */));
verifyWindowContainerApplyAnimation(stack, activity1, activity2);
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
index 8cfa4f0..9135297 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
@@ -931,8 +931,7 @@
final Task stack = createStack();
final Task task = createTask(stack);
- final ActivityRecord record = WindowTestUtils.createActivityRecordInTask(
- stack.mDisplayContent, task);
+ final ActivityRecord record = createActivityRecordInTask(stack.mDisplayContent, task);
stack.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
record.setTaskDescription(new ActivityManager.TaskDescription("TestDescription"));
@@ -966,8 +965,7 @@
public void testInterceptBackPressedOnTaskRoot() throws RemoteException {
final Task stack = createStack();
final Task task = createTask(stack);
- final ActivityRecord activity = WindowTestUtils.createActivityRecordInTask(
- stack.mDisplayContent, task);
+ final ActivityRecord activity = createActivityRecordInTask(stack.mDisplayContent, task);
final ITaskOrganizer organizer = registerMockOrganizer(WINDOWING_MODE_MULTI_WINDOW);
// Setup the task to be controlled by the MW mode organizer
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
index 3894a2e..f095fd4 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
@@ -357,8 +357,7 @@
// Call prepareWindowToDisplayDuringRelayout for a windows that are not children of an
// activity. Both windows have the FLAG_TURNS_SCREEN_ON so both should call wakeup
- final WindowToken windowToken = WindowTestUtils.createTestWindowToken(FIRST_SUB_WINDOW,
- mDisplayContent);
+ final WindowToken windowToken = createTestWindowToken(FIRST_SUB_WINDOW, mDisplayContent);
final WindowState firstWindow = createWindow(null, TYPE_APPLICATION, windowToken,
"firstWindow");
final WindowState secondWindow = createWindow(null, TYPE_APPLICATION, windowToken,
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java
deleted file mode 100644
index 0180d87..0000000
--- a/services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.server.wm;
-
-import static android.app.AppOpsManager.OP_NONE;
-
-import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
-import static com.android.server.wm.WindowContainer.POSITION_TOP;
-
-import android.os.IBinder;
-import android.view.IWindow;
-import android.view.WindowManager;
-
-import com.android.server.wm.WindowTestsBase.ActivityBuilder;
-
-/**
- * A collection of static functions that provide access to WindowManager related test functionality.
- */
-class WindowTestUtils {
-
- /** Creates a {@link Task} and adds it to the specified {@link Task}. */
- static Task createTaskInStack(WindowManagerService service, Task stack, int userId) {
- final Task task = new WindowTestsBase.TaskBuilder(stack.mStackSupervisor)
- .setUserId(userId)
- .setStack(stack)
- .build();
- return task;
- }
-
- /** Creates an {@link ActivityRecord} and adds it to the specified {@link Task}. */
- static ActivityRecord createActivityRecordInTask(DisplayContent dc, Task task) {
- final ActivityRecord activity = createTestActivityRecord(dc);
- task.addChild(activity, POSITION_TOP);
- return activity;
- }
-
- static ActivityRecord createTestActivityRecord(Task stack) {
- final ActivityRecord activity = new ActivityBuilder(stack.mAtmService)
- .setStack(stack)
- .setCreateTask(true)
- .build();
- postCreateActivitySetup(activity, stack.getDisplayContent());
- return activity;
- }
-
- static ActivityRecord createTestActivityRecord(DisplayContent dc) {
- final ActivityRecord activity = new ActivityBuilder(dc.mWmService.mAtmService).build();
- postCreateActivitySetup(activity, dc);
- return activity;
- }
-
- private static void postCreateActivitySetup(ActivityRecord activity, DisplayContent dc) {
- activity.onDisplayChanged(dc);
- activity.setOccludesParent(true);
- activity.setVisible(true);
- activity.mVisibleRequested = true;
- }
-
- static TestWindowToken createTestWindowToken(int type, DisplayContent dc) {
- return createTestWindowToken(type, dc, false /* persistOnEmpty */);
- }
-
- static TestWindowToken createTestWindowToken(int type, DisplayContent dc,
- boolean persistOnEmpty) {
- SystemServicesTestRule.checkHoldsLock(dc.mWmService.mGlobalLock);
-
- return new TestWindowToken(type, dc, persistOnEmpty);
- }
-
- /* Used so we can gain access to some protected members of the {@link WindowToken} class */
- static class TestWindowToken extends WindowToken {
-
- private TestWindowToken(int type, DisplayContent dc, boolean persistOnEmpty) {
- super(dc.mWmService, mock(IBinder.class), type, persistOnEmpty, dc,
- false /* ownerCanManageAppTokens */);
- }
-
- int getWindowsCount() {
- return mChildren.size();
- }
-
- boolean hasWindow(WindowState w) {
- return mChildren.contains(w);
- }
- }
-
- /** Used to track resize reports. */
- static class TestWindowState extends WindowState {
- boolean mResizeReported;
-
- TestWindowState(WindowManagerService service, Session session, IWindow window,
- WindowManager.LayoutParams attrs, WindowToken token) {
- super(service, session, window, token, null, OP_NONE, 0, attrs, 0, 0, 0,
- false /* ownerCanAddInternalSystemWindow */);
- }
-
- @Override
- void reportResized() {
- super.reportResized();
- mResizeReported = true;
- }
-
- @Override
- public boolean isGoneForLayoutLw() {
- return false;
- }
-
- @Override
- void updateResizingWindowIfNeeded() {
- // Used in AppWindowTokenTests#testLandscapeSeascapeRotationRelayout to deceive
- // the system that it can actually update the window.
- boolean hadSurface = mHasSurface;
- mHasSurface = true;
-
- super.updateResizingWindowIfNeeded();
-
- mHasSurface = hadSurface;
- }
- }
-}
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
index ec19a58..5ce61b4 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
@@ -47,6 +47,7 @@
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.server.wm.WindowContainer.POSITION_BOTTOM;
+import static com.android.server.wm.WindowContainer.POSITION_TOP;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -66,6 +67,7 @@
import android.hardware.display.DisplayManager;
import android.os.Build;
import android.os.Bundle;
+import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.service.voice.IVoiceInteractionSession;
@@ -239,7 +241,7 @@
private WindowToken createWindowToken(
DisplayContent dc, int windowingMode, int activityType, int type) {
if (type < FIRST_APPLICATION_WINDOW || type > LAST_APPLICATION_WINDOW) {
- return WindowTestUtils.createTestWindowToken(type, dc);
+ return createTestWindowToken(type, dc);
}
return createActivityRecord(dc, windowingMode, activityType);
@@ -249,10 +251,39 @@
return createTestActivityRecord(dc, windowingMode, activityType);
}
- ActivityRecord createTestActivityRecord(DisplayContent dc, int
- windowingMode, int activityType) {
+ ActivityRecord createTestActivityRecord(DisplayContent dc, int windowingMode,
+ int activityType) {
final Task stack = createTaskStackOnDisplay(windowingMode, activityType, dc);
- return WindowTestUtils.createTestActivityRecord(stack);
+ return createTestActivityRecord(stack);
+ }
+
+ /** Creates an {@link ActivityRecord} and adds it to the specified {@link Task}. */
+ static ActivityRecord createActivityRecordInTask(DisplayContent dc, Task task) {
+ final ActivityRecord activity = createTestActivityRecord(dc);
+ task.addChild(activity, POSITION_TOP);
+ return activity;
+ }
+
+ static ActivityRecord createTestActivityRecord(DisplayContent dc) {
+ final ActivityRecord activity = new ActivityBuilder(dc.mWmService.mAtmService).build();
+ postCreateActivitySetup(activity, dc);
+ return activity;
+ }
+
+ static ActivityRecord createTestActivityRecord(Task stack) {
+ final ActivityRecord activity = new ActivityBuilder(stack.mAtmService)
+ .setStack(stack)
+ .setCreateTask(true)
+ .build();
+ postCreateActivitySetup(activity, stack.getDisplayContent());
+ return activity;
+ }
+
+ private static void postCreateActivitySetup(ActivityRecord activity, DisplayContent dc) {
+ activity.onDisplayChanged(dc);
+ activity.setOccludesParent(true);
+ activity.setVisible(true);
+ activity.mVisibleRequested = true;
}
WindowState createWindow(WindowState parent, int type, String name) {
@@ -274,8 +305,7 @@
}
WindowState createAppWindow(Task task, int type, String name) {
- final ActivityRecord activity =
- WindowTestUtils.createTestActivityRecord(task.getDisplayContent());
+ final ActivityRecord activity = createTestActivityRecord(task.getDisplayContent());
task.addChild(activity, 0);
return createWindow(null, type, activity, name);
}
@@ -390,7 +420,11 @@
/** Creates a {@link Task} and adds it to the specified {@link Task}. */
Task createTaskInStack(Task stack, int userId) {
- return WindowTestUtils.createTaskInStack(mWm, stack, userId);
+ final Task task = new TaskBuilder(stack.mStackSupervisor)
+ .setUserId(userId)
+ .setStack(stack)
+ .build();
+ return task;
}
/** Creates a {@link DisplayContent} that supports IME and adds it to the system. */
@@ -432,12 +466,11 @@
return createNewDisplay(displayInfo, true /* supportIme */);
}
- /** Creates a {@link com.android.server.wm.WindowTestUtils.TestWindowState} */
- WindowTestUtils.TestWindowState createWindowState(WindowManager.LayoutParams attrs,
- WindowToken token) {
+ /** Creates a {@link TestWindowState} */
+ TestWindowState createWindowState(WindowManager.LayoutParams attrs, WindowToken token) {
SystemServicesTestRule.checkHoldsLock(mWm.mGlobalLock);
- return new WindowTestUtils.TestWindowState(mWm, mMockSession, mIWindow, attrs, token);
+ return new TestWindowState(mWm, mMockSession, mIWindow, attrs, token);
}
/** Creates a {@link DisplayContent} as parts of simulate display info for test. */
@@ -1055,4 +1088,66 @@
public void onBackPressedOnTaskRoot(ActivityManager.RunningTaskInfo taskInfo) {
}
}
+
+ static TestWindowToken createTestWindowToken(int type, DisplayContent dc) {
+ return createTestWindowToken(type, dc, false /* persistOnEmpty */);
+ }
+
+ static TestWindowToken createTestWindowToken(int type, DisplayContent dc,
+ boolean persistOnEmpty) {
+ SystemServicesTestRule.checkHoldsLock(dc.mWmService.mGlobalLock);
+
+ return new TestWindowToken(type, dc, persistOnEmpty);
+ }
+
+ /** Used so we can gain access to some protected members of the {@link WindowToken} class */
+ static class TestWindowToken extends WindowToken {
+
+ private TestWindowToken(int type, DisplayContent dc, boolean persistOnEmpty) {
+ super(dc.mWmService, mock(IBinder.class), type, persistOnEmpty, dc,
+ false /* ownerCanManageAppTokens */);
+ }
+
+ int getWindowsCount() {
+ return mChildren.size();
+ }
+
+ boolean hasWindow(WindowState w) {
+ return mChildren.contains(w);
+ }
+ }
+
+ /** Used to track resize reports. */
+ static class TestWindowState extends WindowState {
+ boolean mResizeReported;
+
+ TestWindowState(WindowManagerService service, Session session, IWindow window,
+ WindowManager.LayoutParams attrs, WindowToken token) {
+ super(service, session, window, token, null, OP_NONE, 0, attrs, 0, 0, 0,
+ false /* ownerCanAddInternalSystemWindow */);
+ }
+
+ @Override
+ void reportResized() {
+ super.reportResized();
+ mResizeReported = true;
+ }
+
+ @Override
+ public boolean isGoneForLayoutLw() {
+ return false;
+ }
+
+ @Override
+ void updateResizingWindowIfNeeded() {
+ // Used in AppWindowTokenTests#testLandscapeSeascapeRotationRelayout to deceive
+ // the system that it can actually update the window.
+ boolean hadSurface = mHasSurface;
+ mHasSurface = true;
+
+ super.updateResizingWindowIfNeeded();
+
+ mHasSurface = hadSurface;
+ }
+ }
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java
index f185da3..d9c48fc 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java
@@ -58,8 +58,7 @@
@Test
public void testAddWindow() {
- final WindowTestUtils.TestWindowToken token =
- WindowTestUtils.createTestWindowToken(0, mDisplayContent);
+ final TestWindowToken token = createTestWindowToken(0, mDisplayContent);
assertEquals(0, token.getWindowsCount());
@@ -93,7 +92,7 @@
@Test
public void testChildRemoval() {
final DisplayContent dc = mDisplayContent;
- final WindowTestUtils.TestWindowToken token = WindowTestUtils.createTestWindowToken(0, dc);
+ final TestWindowToken token = createTestWindowToken(0, dc);
assertEquals(token, dc.getWindowToken(token.token));
@@ -116,7 +115,7 @@
*/
@Test
public void testTokenRemovalProcess() {
- final WindowTestUtils.TestWindowToken token = WindowTestUtils.createTestWindowToken(
+ final TestWindowToken token = createTestWindowToken(
TYPE_TOAST, mDisplayContent, true /* persistOnEmpty */);
// Verify that the token is on the display
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java
index 2fd6c42..78556ef 100644
--- a/services/usage/java/com/android/server/usage/UsageStatsService.java
+++ b/services/usage/java/com/android/server/usage/UsageStatsService.java
@@ -763,11 +763,12 @@
return;
}
- final LinkedList<Event> events = mReportedEvents.get(userId, new LinkedList<>());
- events.add(event);
- if (mReportedEvents.get(userId) == null) {
+ LinkedList<Event> events = mReportedEvents.get(userId);
+ if (events == null) {
+ events = new LinkedList<>();
mReportedEvents.put(userId, events);
}
+ events.add(event);
if (events.size() == 1) {
// Every time a file is persisted to disk, mReportedEvents is cleared for this user
// so trigger a flush to disk every time the first event has been added.
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index bcb1736..464f318 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -1209,11 +1209,14 @@
/**
* Returns a list of all {@link PhoneAccount}s registered for the calling package.
*
+ * @deprecated Use {@link #getSelfManagedPhoneAccounts()} instead to get only self-managed
+ * {@link PhoneAccountHandle} for the calling package.
* @return A list of {@code PhoneAccountHandle} objects.
* @hide
*/
@SystemApi
@SuppressLint("Doclava125")
+ @Deprecated
public List<PhoneAccountHandle> getPhoneAccountsForPackage() {
try {
if (isServiceConnected()) {
diff --git a/tests/Internal/Android.bp b/tests/Internal/Android.bp
index e233fed..9da17db 100644
--- a/tests/Internal/Android.bp
+++ b/tests/Internal/Android.bp
@@ -11,6 +11,7 @@
"androidx.test.rules",
"mockito-target-minus-junit4",
"truth-prebuilt",
+ "platform-test-annotations",
],
java_resource_dirs: ["res"],
certificate: "platform",
diff --git a/services/tests/servicestests/src/com/android/server/protolog/ProtoLogImplTest.java b/tests/Internal/src/com/android/internal/protolog/ProtoLogImplTest.java
similarity index 98%
rename from services/tests/servicestests/src/com/android/server/protolog/ProtoLogImplTest.java
rename to tests/Internal/src/com/android/internal/protolog/ProtoLogImplTest.java
index 3e9f625..3db0116 100644
--- a/services/tests/servicestests/src/com/android/server/protolog/ProtoLogImplTest.java
+++ b/tests/Internal/src/com/android/internal/protolog/ProtoLogImplTest.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package com.android.server.protolog;
+package com.android.internal.protolog;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
-import static com.android.server.protolog.ProtoLogImpl.PROTOLOG_VERSION;
+import static com.android.internal.protolog.ProtoLogImpl.PROTOLOG_VERSION;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -42,7 +42,7 @@
import androidx.test.filters.SmallTest;
-import com.android.server.protolog.common.IProtoLogGroup;
+import com.android.internal.protolog.common.IProtoLogGroup;
import org.junit.After;
import org.junit.Before;
diff --git a/services/tests/servicestests/src/com/android/server/protolog/ProtoLogViewerConfigReaderTest.java b/tests/Internal/src/com/android/internal/protolog/ProtoLogViewerConfigReaderTest.java
similarity index 98%
rename from services/tests/servicestests/src/com/android/server/protolog/ProtoLogViewerConfigReaderTest.java
rename to tests/Internal/src/com/android/internal/protolog/ProtoLogViewerConfigReaderTest.java
index 0254055..ae50216 100644
--- a/services/tests/servicestests/src/com/android/server/protolog/ProtoLogViewerConfigReaderTest.java
+++ b/tests/Internal/src/com/android/internal/protolog/ProtoLogViewerConfigReaderTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server.protolog;
+package com.android.internal.protolog;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
diff --git a/services/tests/servicestests/src/com/android/server/protolog/common/LogDataTypeTest.java b/tests/Internal/src/com/android/internal/protolog/common/LogDataTypeTest.java
similarity index 97%
rename from services/tests/servicestests/src/com/android/server/protolog/common/LogDataTypeTest.java
rename to tests/Internal/src/com/android/internal/protolog/common/LogDataTypeTest.java
index 4c7f5fd..e20ca3d 100644
--- a/services/tests/servicestests/src/com/android/server/protolog/common/LogDataTypeTest.java
+++ b/tests/Internal/src/com/android/internal/protolog/common/LogDataTypeTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server.protolog.common;
+package com.android.internal.protolog.common;
import static org.junit.Assert.assertEquals;
diff --git a/tests/SilkFX/src/com/android/test/silkfx/common/ColorModeControls.kt b/tests/SilkFX/src/com/android/test/silkfx/common/ColorModeControls.kt
index c3d689c..9b15b04 100644
--- a/tests/SilkFX/src/com/android/test/silkfx/common/ColorModeControls.kt
+++ b/tests/SilkFX/src/com/android/test/silkfx/common/ColorModeControls.kt
@@ -26,10 +26,10 @@
import android.widget.TextView
import com.android.test.silkfx.R
import com.android.test.silkfx.app.WindowObserver
-import java.lang.Exception
class ColorModeControls : LinearLayout, WindowObserver {
private val COLOR_MODE_HDR10 = 3
+ private val SDR_WHITE_POINTS = floatArrayOf(200f, 250f, 300f, 350f, 400f, 100f, 150f)
constructor(context: Context) : this(context, null)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
@@ -37,14 +37,17 @@
}
private var window: Window? = null
- private var currentMode: TextView? = null
+ private var currentModeDisplay: TextView? = null
private val displayManager: DisplayManager
+ private var targetSdrWhitePointIndex = 0
+
+ private val whitePoint get() = SDR_WHITE_POINTS[targetSdrWhitePointIndex]
override fun onFinishInflate() {
super.onFinishInflate()
val window = window ?: throw IllegalStateException("Failed to attach window")
- currentMode = findViewById(R.id.current_mode)!!
+ currentModeDisplay = findViewById(R.id.current_mode)!!
setColorMode(window.colorMode)
findViewById<Button>(R.id.mode_default)!!.setOnClickListener {
@@ -63,21 +66,30 @@
private fun setColorMode(newMode: Int) {
val window = window!!
+ var sdrWhitepointChanged = false
// Need to do this before setting the colorMode, as setting the colorMode will
// trigger the attribute change listener
if (newMode == ActivityInfo.COLOR_MODE_HDR ||
newMode == COLOR_MODE_HDR10) {
+ if (window.colorMode == newMode) {
+ targetSdrWhitePointIndex = (targetSdrWhitePointIndex + 1) % SDR_WHITE_POINTS.size
+ sdrWhitepointChanged = true
+ }
setBrightness(1.0f)
} else {
setBrightness(.4f)
}
window.colorMode = newMode
- currentMode?.run {
+ if (sdrWhitepointChanged) {
+ threadedRenderer?.setColorMode(newMode, whitePoint)
+ }
+ val whitePoint = whitePoint.toInt()
+ currentModeDisplay?.run {
text = "Current Mode: " + when (newMode) {
ActivityInfo.COLOR_MODE_DEFAULT -> "Default/SRGB"
ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT -> "Wide Gamut"
- ActivityInfo.COLOR_MODE_HDR -> "HDR (sdr white point 150)"
- COLOR_MODE_HDR10 -> "HDR10 (sdr white point 150)"
+ ActivityInfo.COLOR_MODE_HDR -> "HDR (sdr white point $whitePoint)"
+ COLOR_MODE_HDR10 -> "HDR10 (sdr white point $whitePoint)"
else -> "Unknown"
}
}
@@ -101,4 +113,10 @@
}
}
}
+
+ override fun onAttachedToWindow() {
+ super.onAttachedToWindow()
+
+ threadedRenderer?.setColorMode(window!!.colorMode, whitePoint)
+ }
}
\ No newline at end of file
diff --git a/tests/SilkFX/src/com/android/test/silkfx/hdr/BlingyNotification.kt b/tests/SilkFX/src/com/android/test/silkfx/hdr/BlingyNotification.kt
index e517c3c..4ad21fa 100644
--- a/tests/SilkFX/src/com/android/test/silkfx/hdr/BlingyNotification.kt
+++ b/tests/SilkFX/src/com/android/test/silkfx/hdr/BlingyNotification.kt
@@ -71,9 +71,9 @@
paint.shader = LinearGradient(0f, 0f, w.toFloat(), 0f,
longArrayOf(
color(1f, 1f, 1f, 0f),
- color(1f, 1f, 1f, .4f),
- color(2f, 2f, 2f, .8f),
- color(1f, 1f, 1f, .4f),
+ color(1f, 1f, 1f, .1f),
+ color(2f, 2f, 2f, .3f),
+ color(1f, 1f, 1f, .2f),
color(1f, 1f, 1f, 0f)
),
floatArrayOf(.2f, .4f, .5f, .6f, .8f),
diff --git a/tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java b/tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java
index 5285b04..55def49 100644
--- a/tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java
+++ b/tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java
@@ -22,7 +22,8 @@
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
-import com.android.cts.install.lib.host.InstallUtilsHost;
+import android.cts.install.lib.host.InstallUtilsHost;
+
import com.android.ddmlib.Log;
import com.android.tests.rollback.host.AbandonSessionsRule;
import com.android.tests.util.ModuleTestUtils;
diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp
index f9c54f6..d84ca3d 100644
--- a/tools/aapt2/cmd/Link.cpp
+++ b/tools/aapt2/cmd/Link.cpp
@@ -78,6 +78,8 @@
namespace aapt {
+constexpr uint8_t kAndroidPackageId = 0x01;
+
class LinkContext : public IAaptContext {
public:
explicit LinkContext(IDiagnostics* diagnostics)
@@ -1805,7 +1807,7 @@
// Override the package ID when it is "android".
if (context_->GetCompilationPackage() == "android") {
- context_->SetPackageId(0x01);
+ context_->SetPackageId(kAndroidPackageId);
// Verify we're building a regular app.
if (context_->GetPackageType() != PackageType::kApp) {
@@ -1862,7 +1864,8 @@
if (context_->GetPackageType() != PackageType::kStaticLib) {
PrivateAttributeMover mover;
- if (!mover.Consume(context_, &final_table_)) {
+ if (context_->GetPackageId() == kAndroidPackageId &&
+ !mover.Consume(context_, &final_table_)) {
context_->GetDiagnostics()->Error(DiagMessage() << "failed moving private attributes");
return 1;
}
diff --git a/tools/protologtool/Android.bp b/tools/protologtool/Android.bp
index ce551bd..0be80d3 100644
--- a/tools/protologtool/Android.bp
+++ b/tools/protologtool/Android.bp
@@ -2,9 +2,9 @@
name: "protologtool-lib",
srcs: [
"src/com/android/protolog/tool/**/*.kt",
+ ":protolog-common-src",
],
static_libs: [
- "protolog-common",
"javaparser",
"platformprotos",
"jsonlib",
diff --git a/tools/protologtool/src/com/android/protolog/tool/LogParser.kt b/tools/protologtool/src/com/android/protolog/tool/LogParser.kt
index a59038f..645c567 100644
--- a/tools/protologtool/src/com/android/protolog/tool/LogParser.kt
+++ b/tools/protologtool/src/com/android/protolog/tool/LogParser.kt
@@ -16,16 +16,15 @@
package com.android.protolog.tool
+import com.android.internal.protolog.ProtoLogFileProto
+import com.android.internal.protolog.ProtoLogMessage
+import com.android.internal.protolog.common.InvalidFormatStringException
+import com.android.internal.protolog.common.LogDataType
import com.android.json.stream.JsonReader
-import com.android.server.protolog.common.InvalidFormatStringException
-import com.android.server.protolog.common.LogDataType
-import com.android.server.protolog.ProtoLogMessage
-import com.android.server.protolog.ProtoLogFileProto
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintStream
-import java.lang.Exception
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
diff --git a/tools/protologtool/src/com/android/protolog/tool/ProtoLogGroupReader.kt b/tools/protologtool/src/com/android/protolog/tool/ProtoLogGroupReader.kt
index 75493b6..42b628b 100644
--- a/tools/protologtool/src/com/android/protolog/tool/ProtoLogGroupReader.kt
+++ b/tools/protologtool/src/com/android/protolog/tool/ProtoLogGroupReader.kt
@@ -17,7 +17,7 @@
package com.android.protolog.tool
import com.android.protolog.tool.Constants.ENUM_VALUES_METHOD
-import com.android.server.protolog.common.IProtoLogGroup
+import com.android.internal.protolog.common.IProtoLogGroup
import java.io.File
import java.net.URLClassLoader
diff --git a/tools/protologtool/src/com/android/protolog/tool/SourceTransformer.kt b/tools/protologtool/src/com/android/protolog/tool/SourceTransformer.kt
index 36ea411..27e61a1 100644
--- a/tools/protologtool/src/com/android/protolog/tool/SourceTransformer.kt
+++ b/tools/protologtool/src/com/android/protolog/tool/SourceTransformer.kt
@@ -16,7 +16,7 @@
package com.android.protolog.tool
-import com.android.server.protolog.common.LogDataType
+import com.android.internal.protolog.common.LogDataType
import com.github.javaparser.StaticJavaParser
import com.github.javaparser.ast.CompilationUnit
import com.github.javaparser.ast.NodeList
@@ -89,7 +89,7 @@
// Out: ProtoLog.e(GROUP, 1234, 0, null, arg)
newCall.arguments.add(2, IntegerLiteralExpr(typeMask))
// Replace call to a stub method with an actual implementation.
- // Out: com.android.server.protolog.ProtoLogImpl.e(GROUP, 1234, null, arg)
+ // Out: ProtoLogImpl.e(GROUP, 1234, null, arg)
newCall.setScope(protoLogImplClassNode)
// Create a call to ProtoLog$Cache.GROUP_enabled
// Out: com.android.server.protolog.ProtoLog$Cache.GROUP_enabled
@@ -119,9 +119,9 @@
}
blockStmt.addStatement(ExpressionStmt(newCall))
// Create an IF-statement with the previously created condition.
- // Out: if (com.android.server.protolog.ProtoLogImpl.isEnabled(GROUP)) {
+ // Out: if (ProtoLogImpl.isEnabled(GROUP)) {
// long protoLogParam0 = arg;
- // com.android.server.protolog.ProtoLogImpl.e(GROUP, 1234, 0, null, protoLogParam0);
+ // ProtoLogImpl.e(GROUP, 1234, 0, null, protoLogParam0);
// }
ifStmt = IfStmt(isLogEnabled, blockStmt, null)
} else {
diff --git a/tools/protologtool/tests/com/android/protolog/tool/CommandOptionsTest.kt b/tools/protologtool/tests/com/android/protolog/tool/CommandOptionsTest.kt
index cf36651c..3cfbb43 100644
--- a/tools/protologtool/tests/com/android/protolog/tool/CommandOptionsTest.kt
+++ b/tools/protologtool/tests/com/android/protolog/tool/CommandOptionsTest.kt
@@ -31,7 +31,7 @@
private const val TEST_PROTOLOG_CLASS = "com.android.server.wm.ProtoLog"
private const val TEST_PROTOLOGIMPL_CLASS = "com.android.server.wm.ProtoLogImpl"
private const val TEST_PROTOLOGCACHE_CLASS = "com.android.server.wm.ProtoLog\$Cache"
- private const val TEST_PROTOLOGGROUP_CLASS = "com.android.server.wm.ProtoLogGroup"
+ private const val TEST_PROTOLOGGROUP_CLASS = "com.android.internal.protolog.ProtoLogGroup"
private const val TEST_PROTOLOGGROUP_JAR = "out/soong/.intermediates/frameworks/base/" +
"services/core/services.core.wm.protologgroups/android_common/javac/" +
"services.core.wm.protologgroups.jar"
diff --git a/tools/protologtool/tests/com/android/protolog/tool/EndToEndTest.kt b/tools/protologtool/tests/com/android/protolog/tool/EndToEndTest.kt
index dd8a0b1..0d2b91d 100644
--- a/tools/protologtool/tests/com/android/protolog/tool/EndToEndTest.kt
+++ b/tools/protologtool/tests/com/android/protolog/tool/EndToEndTest.kt
@@ -33,8 +33,8 @@
val output = run(
src = "frameworks/base/org/example/Example.java" to """
package org.example;
- import com.android.server.protolog.common.ProtoLog;
- import static com.android.server.wm.ProtoLogGroup.GROUP;
+ import com.android.internal.protolog.common.ProtoLog;
+ import static com.android.internal.protolog.ProtoLogGroup.GROUP;
class Example {
void method() {
@@ -46,11 +46,11 @@
""".trimIndent(),
logGroup = LogGroup("GROUP", true, false, "TAG_GROUP"),
commandOptions = CommandOptions(arrayOf("transform-protolog-calls",
- "--protolog-class", "com.android.server.protolog.common.ProtoLog",
- "--protolog-impl-class", "com.android.server.protolog.ProtoLogImpl",
+ "--protolog-class", "com.android.internal.protolog.common.ProtoLog",
+ "--protolog-impl-class", "com.android.internal.protolog.ProtoLogImpl",
"--protolog-cache-class",
- "com.android.server.protolog.ProtoLog${"\$\$"}Cache",
- "--loggroups-class", "com.android.server.wm.ProtoLogGroup",
+ "com.android.server.wm.ProtoLogCache",
+ "--loggroups-class", "com.android.internal.protolog.ProtoLogGroup",
"--loggroups-jar", "not_required.jar",
"--output-srcjar", "out.srcjar",
"frameworks/base/org/example/Example.java"))
@@ -64,8 +64,8 @@
val output = run(
src = "frameworks/base/org/example/Example.java" to """
package org.example;
- import com.android.server.protolog.common.ProtoLog;
- import static com.android.server.wm.ProtoLogGroup.GROUP;
+ import com.android.internal.protolog.common.ProtoLog;
+ import static com.android.internal.protolog.ProtoLogGroup.GROUP;
class Example {
void method() {
@@ -77,8 +77,8 @@
""".trimIndent(),
logGroup = LogGroup("GROUP", true, false, "TAG_GROUP"),
commandOptions = CommandOptions(arrayOf("generate-viewer-config",
- "--protolog-class", "com.android.server.protolog.common.ProtoLog",
- "--loggroups-class", "com.android.server.wm.ProtoLogGroup",
+ "--protolog-class", "com.android.internal.protolog.common.ProtoLog",
+ "--loggroups-class", "com.android.internal.protolog.ProtoLogGroup",
"--loggroups-jar", "not_required.jar",
"--viewer-conf", "out.json",
"frameworks/base/org/example/Example.java"))
diff --git a/tools/protologtool/tests/com/android/protolog/tool/LogParserTest.kt b/tools/protologtool/tests/com/android/protolog/tool/LogParserTest.kt
index 04a3bfa..67a31da 100644
--- a/tools/protologtool/tests/com/android/protolog/tool/LogParserTest.kt
+++ b/tools/protologtool/tests/com/android/protolog/tool/LogParserTest.kt
@@ -17,8 +17,8 @@
package com.android.protolog.tool
import com.android.json.stream.JsonReader
-import com.android.server.protolog.ProtoLogMessage
-import com.android.server.protolog.ProtoLogFileProto
+import com.android.internal.protolog.ProtoLogMessage
+import com.android.internal.protolog.ProtoLogFileProto
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
diff --git a/wifi/api/system-current.txt b/wifi/api/system-current.txt
index 53c69c4..eff64a3 100644
--- a/wifi/api/system-current.txt
+++ b/wifi/api/system-current.txt
@@ -326,6 +326,8 @@
field @Deprecated public static final int METERED_OVERRIDE_METERED = 1; // 0x1
field @Deprecated public static final int METERED_OVERRIDE_NONE = 0; // 0x0
field @Deprecated public static final int METERED_OVERRIDE_NOT_METERED = 2; // 0x2
+ field @Deprecated public static final int RANDOMIZATION_AUTO = 3; // 0x3
+ field @Deprecated public static final int RANDOMIZATION_ENHANCED = 2; // 0x2
field @Deprecated public static final int RANDOMIZATION_NONE = 0; // 0x0
field @Deprecated public static final int RANDOMIZATION_PERSISTENT = 1; // 0x1
field @Deprecated public static final int RECENT_FAILURE_AP_UNABLE_TO_HANDLE_NEW_STA = 17; // 0x11
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java
index 71f0ab8..1588bf7 100644
--- a/wifi/java/android/net/wifi/WifiConfiguration.java
+++ b/wifi/java/android/net/wifi/WifiConfiguration.java
@@ -1130,7 +1130,9 @@
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"RANDOMIZATION_"}, value = {
RANDOMIZATION_NONE,
- RANDOMIZATION_PERSISTENT})
+ RANDOMIZATION_PERSISTENT,
+ RANDOMIZATION_ENHANCED,
+ RANDOMIZATION_AUTO})
public @interface MacRandomizationSetting {}
/**
@@ -1147,14 +1149,30 @@
public static final int RANDOMIZATION_PERSISTENT = 1;
/**
+ * Use a randomly generated MAC address for connections to this network.
+ * This option does not persist the randomized MAC address.
+ * @hide
+ */
+ @SystemApi
+ public static final int RANDOMIZATION_ENHANCED = 2;
+
+ /**
+ * Let the wifi framework automatically decide the MAC randomization strategy.
+ * @hide
+ */
+ @SystemApi
+ public static final int RANDOMIZATION_AUTO = 3;
+
+ /**
* Level of MAC randomization for this network.
- * One of {@link #RANDOMIZATION_NONE} or {@link #RANDOMIZATION_PERSISTENT}.
- * By default this field is set to {@link #RANDOMIZATION_PERSISTENT}.
+ * One of {@link #RANDOMIZATION_NONE}, {@link #RANDOMIZATION_AUTO},
+ * {@link #RANDOMIZATION_PERSISTENT} or {@link #RANDOMIZATION_ENHANCED}.
+ * By default this field is set to {@link #RANDOMIZATION_AUTO}.
* @hide
*/
@SystemApi
@MacRandomizationSetting
- public int macRandomizationSetting = RANDOMIZATION_PERSISTENT;
+ public int macRandomizationSetting = RANDOMIZATION_AUTO;
/**
* @hide