Merge "DO NOT MERGE Create a key value settings observer for backup parameters" into pi-dev
diff --git a/apct-tests/perftests/core/src/android/widget/TextViewPrecomputedTextPerfTest.java b/apct-tests/perftests/core/src/android/widget/TextViewPrecomputedTextPerfTest.java
index 55b97e7..dc34b7f 100644
--- a/apct-tests/perftests/core/src/android/widget/TextViewPrecomputedTextPerfTest.java
+++ b/apct-tests/perftests/core/src/android/widget/TextViewPrecomputedTextPerfTest.java
@@ -117,6 +117,26 @@
}
@Test
+ public void testNewLayout_RandomText_Selectable() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ BoringLayout.Metrics metrics = new BoringLayout.Metrics();
+ while (state.keepRunning()) {
+ state.pauseTiming();
+ final CharSequence text = mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT);
+ final TextView textView = new TextView(getContext());
+ textView.setTextIsSelectable(true);
+ textView.setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED);
+ textView.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL);
+ textView.setText(text);
+ Canvas.freeTextLayoutCaches();
+ state.resumeTiming();
+
+ textView.makeNewLayout(TEXT_WIDTH, TEXT_WIDTH, UNKNOWN_BORING, UNKNOWN_BORING,
+ TEXT_WIDTH, false);
+ }
+ }
+
+ @Test
public void testNewLayout_PrecomputedText() {
final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
BoringLayout.Metrics metrics = new BoringLayout.Metrics();
@@ -179,6 +199,24 @@
}
@Test
+ public void testSetText_RandomText_Selectable() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ BoringLayout.Metrics metrics = new BoringLayout.Metrics();
+ while (state.keepRunning()) {
+ state.pauseTiming();
+ final CharSequence text = mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT);
+ final TextView textView = new TextView(getContext());
+ textView.setTextIsSelectable(true);
+ textView.setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED);
+ textView.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL);
+ Canvas.freeTextLayoutCaches();
+ state.resumeTiming();
+
+ textView.setText(text);
+ }
+ }
+
+ @Test
public void testSetText_PrecomputedText() {
final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
BoringLayout.Metrics metrics = new BoringLayout.Metrics();
@@ -222,8 +260,8 @@
@Test
public void testOnMeasure_RandomText() {
final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
- int width = MeasureSpec.makeMeasureSpec(MeasureSpec.AT_MOST, TEXT_WIDTH);
- int height = MeasureSpec.makeMeasureSpec(MeasureSpec.UNSPECIFIED, 0);
+ int width = MeasureSpec.makeMeasureSpec(TEXT_WIDTH, MeasureSpec.AT_MOST);
+ int height = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
while (state.keepRunning()) {
state.pauseTiming();
final CharSequence text = mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT);
@@ -240,10 +278,31 @@
}
@Test
+ public void testOnMeasure_RandomText_Selectable() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ int width = MeasureSpec.makeMeasureSpec(TEXT_WIDTH, MeasureSpec.AT_MOST);
+ int height = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+ while (state.keepRunning()) {
+ state.pauseTiming();
+ final CharSequence text = mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT);
+ final TestableTextView textView = new TestableTextView(getContext());
+ textView.setTextIsSelectable(true);
+ textView.setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED);
+ textView.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL);
+ textView.setText(text);
+ textView.nullLayouts();
+ Canvas.freeTextLayoutCaches();
+ state.resumeTiming();
+
+ textView.onMeasure(width, height);
+ }
+ }
+
+ @Test
public void testOnMeasure_PrecomputedText() {
final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
- int width = MeasureSpec.makeMeasureSpec(MeasureSpec.AT_MOST, TEXT_WIDTH);
- int height = MeasureSpec.makeMeasureSpec(MeasureSpec.UNSPECIFIED, 0);
+ int width = MeasureSpec.makeMeasureSpec(TEXT_WIDTH, MeasureSpec.AT_MOST);
+ int height = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
while (state.keepRunning()) {
state.pauseTiming();
final PrecomputedText.Params params = new PrecomputedText.Params.Builder(PAINT)
@@ -265,8 +324,8 @@
@Test
public void testOnMeasure_PrecomputedText_Selectable() {
final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
- int width = MeasureSpec.makeMeasureSpec(MeasureSpec.AT_MOST, TEXT_WIDTH);
- int height = MeasureSpec.makeMeasureSpec(MeasureSpec.UNSPECIFIED, 0);
+ int width = MeasureSpec.makeMeasureSpec(TEXT_WIDTH, MeasureSpec.AT_MOST);
+ int height = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
while (state.keepRunning()) {
state.pauseTiming();
final PrecomputedText.Params params = new PrecomputedText.Params.Builder(PAINT)
@@ -289,8 +348,8 @@
@Test
public void testOnDraw_RandomText() {
final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
- int width = MeasureSpec.makeMeasureSpec(MeasureSpec.AT_MOST, TEXT_WIDTH);
- int height = MeasureSpec.makeMeasureSpec(MeasureSpec.UNSPECIFIED, 0);
+ int width = MeasureSpec.makeMeasureSpec(TEXT_WIDTH, MeasureSpec.AT_MOST);
+ int height = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
final RenderNode node = RenderNode.create("benchmark", null);
while (state.keepRunning()) {
state.pauseTiming();
@@ -299,8 +358,34 @@
textView.setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED);
textView.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL);
textView.setText(text);
+ textView.measure(width, height);
+ textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
+ final DisplayListCanvas c = node.start(
+ textView.getMeasuredWidth(), textView.getMeasuredHeight());
textView.nullLayouts();
- textView.onMeasure(width, height);
+ Canvas.freeTextLayoutCaches();
+ state.resumeTiming();
+
+ textView.onDraw(c);
+ }
+ }
+
+ @Test
+ public void testOnDraw_RandomText_Selectable() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ int width = MeasureSpec.makeMeasureSpec(TEXT_WIDTH, MeasureSpec.AT_MOST);
+ int height = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+ final RenderNode node = RenderNode.create("benchmark", null);
+ while (state.keepRunning()) {
+ state.pauseTiming();
+ final CharSequence text = mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT);
+ final TestableTextView textView = new TestableTextView(getContext());
+ textView.setTextIsSelectable(true);
+ textView.setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED);
+ textView.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL);
+ textView.setText(text);
+ textView.measure(width, height);
+ textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
final DisplayListCanvas c = node.start(
textView.getMeasuredWidth(), textView.getMeasuredHeight());
textView.nullLayouts();
@@ -314,8 +399,8 @@
@Test
public void testOnDraw_PrecomputedText() {
final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
- int width = MeasureSpec.makeMeasureSpec(MeasureSpec.AT_MOST, TEXT_WIDTH);
- int height = MeasureSpec.makeMeasureSpec(MeasureSpec.UNSPECIFIED, 0);
+ int width = MeasureSpec.makeMeasureSpec(TEXT_WIDTH, MeasureSpec.AT_MOST);
+ int height = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
final RenderNode node = RenderNode.create("benchmark", null);
while (state.keepRunning()) {
state.pauseTiming();
@@ -327,8 +412,8 @@
final TestableTextView textView = new TestableTextView(getContext());
textView.setTextMetricsParams(params);
textView.setText(text);
- textView.nullLayouts();
- textView.onMeasure(width, height);
+ textView.measure(width, height);
+ textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
final DisplayListCanvas c = node.start(
textView.getMeasuredWidth(), textView.getMeasuredHeight());
textView.nullLayouts();
@@ -356,8 +441,8 @@
textView.setTextIsSelectable(true);
textView.setTextMetricsParams(params);
textView.setText(text);
- textView.nullLayouts();
- textView.onMeasure(width, height);
+ textView.measure(width, height);
+ textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
final DisplayListCanvas c = node.start(
textView.getMeasuredWidth(), textView.getMeasuredHeight());
textView.nullLayouts();
diff --git a/api/current.txt b/api/current.txt
index 4021ffb..b3be727 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -7278,7 +7278,6 @@
public abstract class SliceProvider extends android.content.ContentProvider {
ctor public SliceProvider();
method public final int delete(android.net.Uri, java.lang.String, java.lang.String[]);
- method public final java.lang.String getBindingPackage();
method public final java.lang.String getType(android.net.Uri);
method public final android.net.Uri insert(android.net.Uri, android.content.ContentValues);
method public android.app.slice.Slice onBindSlice(android.net.Uri, java.util.List<android.app.slice.SliceSpec>);
@@ -14437,6 +14436,7 @@
method public static android.graphics.Typeface createFromFile(java.lang.String);
method public static android.graphics.Typeface defaultFromStyle(int);
method public int getStyle();
+ method public int getWeight();
method public final boolean isBold();
method public final boolean isItalic();
field public static final int BOLD = 1; // 0x1
@@ -16435,8 +16435,8 @@
}
public final class SessionConfiguration {
- ctor public SessionConfiguration(int, java.util.List<android.hardware.camera2.params.OutputConfiguration>, java.util.concurrent.Executor, android.hardware.camera2.CameraCaptureSession.StateCallback);
- method public java.util.concurrent.Executor getExecutor();
+ ctor public SessionConfiguration(int, java.util.List<android.hardware.camera2.params.OutputConfiguration>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler);
+ method public android.os.Handler getHandler();
method public android.hardware.camera2.params.InputConfiguration getInputConfiguration();
method public java.util.List<android.hardware.camera2.params.OutputConfiguration> getOutputConfigurations();
method public android.hardware.camera2.CaptureRequest getSessionParameters();
diff --git a/api/system-current.txt b/api/system-current.txt
index 43425cb..5ec84fe 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -261,6 +261,7 @@
public class AppOpsManager {
method public static java.lang.String[] getOpStrs();
+ method public void setMode(java.lang.String, int, java.lang.String, int);
method public void setUidMode(java.lang.String, int, int);
field public static final java.lang.String OPSTR_ACCEPT_HANDOVER = "android:accept_handover";
field public static final java.lang.String OPSTR_ACCESS_NOTIFICATIONS = "android:access_notifications";
@@ -5261,12 +5262,13 @@
}
public class UiccSlotInfo implements android.os.Parcelable {
- ctor public UiccSlotInfo(boolean, boolean, java.lang.String, int, int);
+ ctor public UiccSlotInfo(boolean, boolean, java.lang.String, int, int, boolean);
method public int describeContents();
method public java.lang.String getCardId();
method public int getCardStateInfo();
method public boolean getIsActive();
method public boolean getIsEuicc();
+ method public boolean getIsExtendedApduSupported();
method public int getLogicalSlotIdx();
method public void writeToParcel(android.os.Parcel, int);
field public static final int CARD_STATE_INFO_ABSENT = 1; // 0x1
@@ -6127,19 +6129,24 @@
}
public final class ImsFeatureConfiguration implements android.os.Parcelable {
- ctor public ImsFeatureConfiguration();
method public int describeContents();
- method public int[] getServiceFeatures();
+ method public java.util.Set<android.telephony.ims.stub.ImsFeatureConfiguration.FeatureSlotPair> getServiceFeatures();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.telephony.ims.stub.ImsFeatureConfiguration> CREATOR;
}
public static class ImsFeatureConfiguration.Builder {
ctor public ImsFeatureConfiguration.Builder();
- method public android.telephony.ims.stub.ImsFeatureConfiguration.Builder addFeature(int);
+ method public android.telephony.ims.stub.ImsFeatureConfiguration.Builder addFeature(int, int);
method public android.telephony.ims.stub.ImsFeatureConfiguration build();
}
+ public static final class ImsFeatureConfiguration.FeatureSlotPair {
+ ctor public ImsFeatureConfiguration.FeatureSlotPair(int, int);
+ field public final int featureType;
+ field public final int slotId;
+ }
+
public class ImsMultiEndpointImplBase {
ctor public ImsMultiEndpointImplBase();
method public final void onImsExternalCallStateUpdate(java.util.List<android.telephony.ims.ImsExternalCallState>);
diff --git a/api/test-current.txt b/api/test-current.txt
index 9d67f4c..54ddd5d 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -1,3 +1,12 @@
+package android {
+
+ public static final class Manifest.permission {
+ field public static final java.lang.String BRIGHTNESS_SLIDER_USAGE = "android.permission.BRIGHTNESS_SLIDER_USAGE";
+ field public static final java.lang.String CONFIGURE_DISPLAY_BRIGHTNESS = "android.permission.CONFIGURE_DISPLAY_BRIGHTNESS";
+ }
+
+}
+
package android.animation {
public class ValueAnimator extends android.animation.Animator {
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 8ba35b7..298f494 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -110,6 +110,11 @@
BluetoothEnabledStateChanged bluetooth_enabled_state_changed = 67;
BluetoothConnectionStateChanged bluetooth_connection_state_changed = 68;
BluetoothA2dpAudioStateChanged bluetooth_a2dp_audio_state_changed = 69;
+ UsbConnectorStateChanged usb_connector_changed = 70;
+ SpeakerImpedanceReported speaker_impedance_reported = 71;
+ HardwareFailed hardware_failed = 72;
+ PhysicalDropDetected physical_drop_detected = 73;
+ ChargeCyclesReported charge_cycles_reported = 74;
// TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
}
@@ -965,6 +970,108 @@
}
/**
+ * Logs when something is plugged into or removed from the USB-C connector.
+ *
+ * Logged from:
+ * Vendor USB HAL.
+ */
+message UsbConnectorStateChanged {
+ enum State {
+ DISCONNECTED = 0;
+ CONNECTED = 1;
+ }
+ optional State state = 1;
+}
+
+/**
+ * Logs the reported speaker impedance.
+ *
+ * Logged from:
+ * Vendor audio implementation.
+ */
+message SpeakerImpedanceReported {
+ optional int32 speaker_location = 1;
+ optional int32 impedance = 2;
+}
+
+/**
+ * Logs the report of a failed hardware.
+ *
+ * Logged from:
+ * Vendor HALs.
+ *
+ */
+message HardwareFailed {
+ enum HardwareType {
+ HARDWARE_FAILED_UNKNOWN = 0;
+ HARDWARE_FAILED_MICROPHONE = 1;
+ HARDWARE_FAILED_CODEC = 2;
+ HARDWARE_FAILED_SPEAKER = 3;
+ HARDWARE_FAILED_FINGERPRINT = 4;
+ }
+ optional HardwareType hardware_type = 1;
+
+ /* hardware_location allows vendors to differentiate between multiple instances of
+ * the same hardware_type. The specific locations are vendor defined integers,
+ * referring to board-specific numbering schemes.
+ */
+ optional int32 hardware_location = 2;
+
+ /* failure_code is specific to the HardwareType of the failed hardware.
+ * It should use the enum values defined below.
+ */
+ enum MicrophoneFailureCode {
+ MICROPHONE_FAILURE_COMPLETE = 0;
+ }
+ enum CodecFailureCode {
+ CODEC_FAILURE_COMPLETE = 0;
+ }
+ enum SpeakerFailureCode {
+ SPEAKER_FAILURE_COMPLETE = 0;
+ SPEAKER_FAILURE_HIGH_Z = 1;
+ SPEAKER_FAILURE_SHORT = 2;
+ }
+ enum FingerprintFailureCode {
+ FINGERPRINT_FAILURE_COMPLETE = 0;
+ FINGERPRINT_SENSOR_BROKEN = 1;
+ FINGERPRINT_TOO_MANY_DEAD_PIXELS = 2;
+ }
+ optional int32 failure_code = 3;
+}
+
+/**
+ * Log an event when the device has been physically dropped.
+ * Reported from the /vendor partition.
+ */
+message PhysicalDropDetected {
+ // Confidence that the event was actually a drop, 0 -> 100
+ optional int32 confidence_pctg = 1;
+ // Peak acceleration of the drop, in 1/1000s of a g.
+ optional int32 accel_peak_thousandths_g = 2;
+}
+
+/**
+ * Log bucketed battery charge cycles.
+ *
+ * Each bucket represents cycles of the battery past
+ * a given charge point. For example, bucket 1 is the
+ * lowest 1/8th of the battery, and bucket 8 is 100%.
+ *
+ * Logged from:
+ * /sys/class/power_supply/bms/cycle_count, via Vendor.
+ */
+message ChargeCyclesReported {
+ optional int32 cycle_bucket_1 = 1;
+ optional int32 cycle_bucket_2 = 2;
+ optional int32 cycle_bucket_3 = 3;
+ optional int32 cycle_bucket_4 = 4;
+ optional int32 cycle_bucket_5 = 5;
+ optional int32 cycle_bucket_6 = 6;
+ optional int32 cycle_bucket_7 = 7;
+ optional int32 cycle_bucket_8 = 8;
+}
+
+/**
* Logs the duration of a davey (jank of >=700ms) when it occurs
*
* Logged from:
diff --git a/cmds/statsd/src/config/ConfigManager.cpp b/cmds/statsd/src/config/ConfigManager.cpp
index d0f55ab..f5310a4 100644
--- a/cmds/statsd/src/config/ConfigManager.cpp
+++ b/cmds/statsd/src/config/ConfigManager.cpp
@@ -68,12 +68,25 @@
{
lock_guard <mutex> lock(mMutex);
+ auto it = mConfigs.find(key);
+
+ const int numBytes = config.ByteSize();
+ vector<uint8_t> buffer(numBytes);
+ config.SerializeToArray(&buffer[0], numBytes);
+
+ const bool isDuplicate =
+ it != mConfigs.end() &&
+ StorageManager::hasIdenticalConfig(key, buffer);
+
+ // Update saved file on disk. We still update timestamp of file when
+ // there exists a duplicate configuration to avoid garbage collection.
+ update_saved_configs_locked(key, buffer, numBytes);
+
+ if (isDuplicate) return;
+
// Add to set
mConfigs.insert(key);
- // Save to disk
- update_saved_configs_locked(key, config);
-
for (sp<ConfigListener> listener : mListeners) {
broadcastList.push_back(listener);
}
@@ -137,7 +150,6 @@
{
lock_guard <mutex> lock(mMutex);
-
for (auto it = mConfigs.begin(); it != mConfigs.end();) {
// Remove from map
if (it->GetUid() == uid) {
@@ -230,16 +242,16 @@
}
}
-void ConfigManager::update_saved_configs_locked(const ConfigKey& key, const StatsdConfig& config) {
+void ConfigManager::update_saved_configs_locked(const ConfigKey& key,
+ const vector<uint8_t>& buffer,
+ const int numBytes) {
// If there is a pre-existing config with same key we should first delete it.
remove_saved_configs(key);
// Then we save the latest config.
- string file_name = StringPrintf("%s/%ld_%d_%lld", STATS_SERVICE_DIR, time(nullptr),
- key.GetUid(), (long long)key.GetId());
- const int numBytes = config.ByteSize();
- vector<uint8_t> buffer(numBytes);
- config.SerializeToArray(&buffer[0], numBytes);
+ string file_name =
+ StringPrintf("%s/%ld_%d_%lld", STATS_SERVICE_DIR, time(nullptr),
+ key.GetUid(), (long long)key.GetId());
StorageManager::writeFile(file_name.c_str(), &buffer[0], numBytes);
}
diff --git a/cmds/statsd/src/config/ConfigManager.h b/cmds/statsd/src/config/ConfigManager.h
index a0c1c1c..9a38188a 100644
--- a/cmds/statsd/src/config/ConfigManager.h
+++ b/cmds/statsd/src/config/ConfigManager.h
@@ -115,7 +115,9 @@
/**
* Save the configs to disk.
*/
- void update_saved_configs_locked(const ConfigKey& key, const StatsdConfig& config);
+ void update_saved_configs_locked(const ConfigKey& key,
+ const std::vector<uint8_t>& buffer,
+ const int numBytes);
/**
* Remove saved configs from disk.
@@ -123,7 +125,7 @@
void remove_saved_configs(const ConfigKey& key);
/**
- * The Configs that have been set. Each config should
+ * Config keys that have been set.
*/
std::set<ConfigKey> mConfigs;
diff --git a/cmds/statsd/src/storage/StorageManager.cpp b/cmds/statsd/src/storage/StorageManager.cpp
index 781eced..77387cb 100644
--- a/cmds/statsd/src/storage/StorageManager.cpp
+++ b/cmds/statsd/src/storage/StorageManager.cpp
@@ -245,6 +245,45 @@
}
}
+bool StorageManager::hasIdenticalConfig(const ConfigKey& key,
+ const vector<uint8_t>& config) {
+ unique_ptr<DIR, decltype(&closedir)> dir(opendir(STATS_SERVICE_DIR),
+ closedir);
+ if (dir == NULL) {
+ VLOG("Directory does not exist: %s", STATS_SERVICE_DIR);
+ return false;
+ }
+
+ const char* suffix =
+ StringPrintf("%d_%lld", key.GetUid(), (long long)key.GetId()).c_str();
+
+ dirent* de;
+ while ((de = readdir(dir.get()))) {
+ char* name = de->d_name;
+ if (name[0] == '.') {
+ continue;
+ }
+ size_t nameLen = strlen(name);
+ size_t suffixLen = strlen(suffix);
+ // There can be at most one file that matches this suffix (config key).
+ if (suffixLen <= nameLen &&
+ strncmp(name + nameLen - suffixLen, suffix, suffixLen) == 0) {
+ int fd = open(StringPrintf("%s/%s", STATS_SERVICE_DIR, name).c_str(),
+ O_RDONLY | O_CLOEXEC);
+ if (fd != -1) {
+ string content;
+ if (android::base::ReadFdToString(fd, &content)) {
+ vector<uint8_t> vec(content.begin(), content.end());
+ if (vec == config) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+
void StorageManager::trimToFit(const char* path) {
unique_ptr<DIR, decltype(&closedir)> dir(opendir(path), closedir);
if (dir == NULL) {
diff --git a/cmds/statsd/src/storage/StorageManager.h b/cmds/statsd/src/storage/StorageManager.h
index 6c8ed0a..13ce5c6 100644
--- a/cmds/statsd/src/storage/StorageManager.h
+++ b/cmds/statsd/src/storage/StorageManager.h
@@ -78,6 +78,12 @@
* files, accumulation of outdated files.
*/
static void trimToFit(const char* dir);
+
+ /**
+ * Returns true if there already exists identical configuration on device.
+ */
+ static bool hasIdenticalConfig(const ConfigKey& key,
+ const vector<uint8_t>& config);
};
} // namespace statsd
diff --git a/config/hiddenapi-light-greylist.txt b/config/hiddenapi-light-greylist.txt
index f134e54..bd2e4cb 100644
--- a/config/hiddenapi-light-greylist.txt
+++ b/config/hiddenapi-light-greylist.txt
@@ -649,6 +649,8 @@
Landroid/hardware/input/IInputManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/hardware/input/IInputManager;
Landroid/hardware/input/IInputManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
Landroid/hardware/input/InputManager;->getInstance()Landroid/hardware/input/InputManager;
+Landroid/hardware/input/InputManager;->injectInputEvent(Landroid/view/InputEvent;I)Z
+Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I
Landroid/hardware/input/InputManager;->mIm:Landroid/hardware/input/IInputManager;
Landroid/hardware/location/IActivityRecognitionHardwareClient$Stub;-><init>()V
Landroid/hardware/SerialPort;->mNativeContext:I
@@ -656,6 +658,7 @@
Landroid/hardware/soundtrigger/SoundTrigger$ConfidenceLevel;-><init>(II)V
Landroid/hardware/soundtrigger/SoundTrigger$ConfidenceLevel;->userId:I
Landroid/hardware/soundtrigger/SoundTrigger$GenericRecognitionEvent;-><init>(IIZIIIZLandroid/media/AudioFormat;[B)V
+Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;-><init>(Ljava/util/UUID;Ljava/util/UUID;[B)V
Landroid/hardware/soundtrigger/SoundTrigger$Keyphrase;->id:I
Landroid/hardware/soundtrigger/SoundTrigger$Keyphrase;->locale:Ljava/lang/String;
Landroid/hardware/soundtrigger/SoundTrigger$KeyphraseRecognitionEvent;-><init>(IIZIIIZLandroid/media/AudioFormat;[B[Landroid/hardware/soundtrigger/SoundTrigger$KeyphraseRecognitionExtra;)V
@@ -674,6 +677,7 @@
Landroid/hardware/soundtrigger/SoundTrigger$ModuleProperties;-><init>(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;IIIIIZIZIZ)V
Landroid/hardware/soundtrigger/SoundTrigger$RecognitionConfig;->captureRequested:Z
Landroid/hardware/soundtrigger/SoundTrigger$RecognitionConfig;->data:[B
+Landroid/hardware/soundtrigger/SoundTrigger$RecognitionConfig;-><init>(ZZ[Landroid/hardware/soundtrigger/SoundTrigger$KeyphraseRecognitionExtra;[B)V
Landroid/hardware/soundtrigger/SoundTrigger$RecognitionConfig;->keyphrases:[Landroid/hardware/soundtrigger/SoundTrigger$KeyphraseRecognitionExtra;
Landroid/hardware/soundtrigger/SoundTrigger$RecognitionEvent;-><init>(IIZIIIZLandroid/media/AudioFormat;[B)V
Landroid/hardware/soundtrigger/SoundTrigger$SoundModel;->data:[B
@@ -890,6 +894,10 @@
Landroid/media/RemoteDisplay;->notifyDisplayError(I)V
Landroid/media/RingtoneManager;->getRingtone(Landroid/content/Context;Landroid/net/Uri;I)Landroid/media/Ringtone;
Landroid/media/session/MediaSessionLegacyHelper;->getHelper(Landroid/content/Context;)Landroid/media/session/MediaSessionLegacyHelper;
+Landroid/media/soundtrigger/SoundTriggerDetector$EventPayload;->getCaptureSession()Ljava/lang/Integer;
+Landroid/media/soundtrigger/SoundTriggerDetector$EventPayload;->getData()[B
+Landroid/media/soundtrigger/SoundTriggerManager;->loadSoundModel(Landroid/hardware/soundtrigger/SoundTrigger$SoundModel;)I
+Landroid/media/soundtrigger/SoundTriggerManager;->startRecognition(Ljava/util/UUID;Landroid/app/PendingIntent;Landroid/hardware/soundtrigger/SoundTrigger$RecognitionConfig;)I
Landroid/media/soundtrigger/SoundTriggerManager;->stopRecognition(Ljava/util/UUID;)I
Landroid/media/soundtrigger/SoundTriggerManager;->unloadSoundModel(Ljava/util/UUID;)I
Landroid/media/SubtitleController;->mHandler:Landroid/os/Handler;
@@ -1556,6 +1564,7 @@
Landroid/service/media/MediaBrowserService$Result;->mFlags:I
Landroid/service/notification/NotificationListenerService;->registerAsSystemService(Landroid/content/Context;Landroid/content/ComponentName;I)V
Landroid/service/notification/NotificationListenerService;->unregisterAsSystemService()V
+Landroid/service/voice/AlwaysOnHotwordDetector$EventPayload;->getCaptureSession()Ljava/lang/Integer;
Landroid/service/voice/VoiceInteractionService;->isKeyphraseAndLocaleSupportedForHotword(Ljava/lang/String;Ljava/util/Locale;)Z
Landroid/service/wallpaper/WallpaperService$Engine;->setFixedSizeAllowed(Z)V
Landroid/speech/tts/TextToSpeech;->getCurrentEngine()Ljava/lang/String;
@@ -1571,6 +1580,7 @@
Landroid/telephony/CellSignalStrengthLte;->mSignalStrength:I
Landroid/telephony/CellSignalStrengthWcdma;->mBitErrorRate:I
Landroid/telephony/CellSignalStrengthWcdma;->mSignalStrength:I
+Landroid/telephony/PhoneNumberUtils;->isLocalEmergencyNumber(Landroid/content/Context;ILjava/lang/String;)Z
Landroid/telephony/PhoneStateListener;->mSubId:Ljava/lang/Integer;
Landroid/telephony/ServiceState;->newFromBundle(Landroid/os/Bundle;)Landroid/telephony/ServiceState;
Landroid/telephony/SignalStrength;->getAsuLevel()I
@@ -1595,6 +1605,7 @@
Landroid/telephony/SignalStrength;->SIGNAL_STRENGTH_POOR:I
Landroid/telephony/SmsMessage;->getSubId()I
Landroid/telephony/SmsMessage;->mWrappedSmsMessage:Lcom/android/internal/telephony/SmsMessageBase;
+Landroid/telephony/SubscriptionManager;->getActiveSubscriptionIdList()[I
Landroid/telephony/SubscriptionManager;->getAllSubscriptionInfoCount()I
Landroid/telephony/SubscriptionManager;->getAllSubscriptionInfoList()Ljava/util/List;
Landroid/telephony/SubscriptionManager;->getDefaultDataSubscriptionInfo()Landroid/telephony/SubscriptionInfo;
@@ -1767,6 +1778,7 @@
Landroid/view/InputDevice;->addMotionRange(IIFFFFF)V
Landroid/view/InputDevice;-><init>(IIILjava/lang/String;IILjava/lang/String;ZIILandroid/view/KeyCharacterMap;ZZZ)V
Landroid/view/InputDevice;->isExternal()Z
+Landroid/view/InputEvent;->getSequenceNumber()I
Landroid/view/InputEventReceiver;->dispatchBatchedInputEventPending()V
Landroid/view/InputEventReceiver;->dispatchInputEvent(ILandroid/view/InputEvent;I)V
Landroid/view/InputEventSender;->dispatchInputEventFinished(IZ)V
@@ -1885,6 +1897,7 @@
Landroid/view/View;->clearAccessibilityFocus()V
Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z
Landroid/view/View;->computeOpaqueFlags()V
+Landroid/view/ViewConfiguration;->getDoubleTapMinTime()I
Landroid/view/ViewConfiguration;->mFadingMarqueeEnabled:Z
Landroid/view/ViewConfiguration;->sHasPermanentMenuKeySet:Z
Landroid/view/ViewConfiguration;->sHasPermanentMenuKey:Z
@@ -2280,6 +2293,7 @@
Lcom/android/ims/internal/uce/presence/PresTupleInfo;->setContactUri(Ljava/lang/String;)V
Lcom/android/ims/internal/uce/presence/PresTupleInfo;->setFeatureTag(Ljava/lang/String;)V
Lcom/android/ims/internal/uce/presence/PresTupleInfo;->setTimestamp(Ljava/lang/String;)V
+Lcom/android/internal/app/AlertController$RecycleListView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
Lcom/android/internal/app/IAppOpsService$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/app/IAppOpsService;
Lcom/android/internal/app/IAppOpsService$Stub$Proxy;->checkOperation(IILjava/lang/String;)I
Lcom/android/internal/app/IAppOpsService$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index 05a9861..14edd31 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -1609,6 +1609,7 @@
* @param mode The app op mode to set.
* @hide
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES)
public void setUidMode(int code, int uid, int mode) {
try {
mService.setUidMode(code, uid, mode);
@@ -1628,7 +1629,7 @@
* @hide
*/
@SystemApi
- @RequiresPermission(android.Manifest.permission.UPDATE_APP_OPS_STATS)
+ @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES)
public void setUidMode(String appOp, int uid, int mode) {
try {
mService.setUidMode(AppOpsManager.strOpToOp(appOp), uid, mode);
@@ -1660,6 +1661,7 @@
/** @hide */
@TestApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES)
public void setMode(int code, int uid, String packageName, int mode) {
try {
mService.setMode(code, uid, packageName, mode);
@@ -1669,6 +1671,27 @@
}
/**
+ * Change the operating mode for the given op in the given app package. You must pass
+ * in both the uid and name of the application whose mode is being modified; if these
+ * do not match, the modification will not be applied.
+ *
+ * @param op The operation to modify. One of the OPSTR_* constants.
+ * @param uid The user id of the application whose mode will be changed.
+ * @param packageName The name of the application package name whose mode will
+ * be changed.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES)
+ public void setMode(String op, int uid, String packageName, int mode) {
+ try {
+ mService.setMode(strOpToOp(op), uid, packageName, mode);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Set a non-persisted restriction on an audio operation at a stream-level.
* Restrictions are temporary additional constraints imposed on top of the persisted rules
* defined by {@link #setMode}.
@@ -1679,6 +1702,7 @@
* @param exceptionPackages Optional list of packages to exclude from the restriction.
* @hide
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES)
public void setRestriction(int code, @AttributeUsage int usage, int mode,
String[] exceptionPackages) {
try {
@@ -1690,6 +1714,7 @@
}
/** @hide */
+ @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES)
public void resetAllModes() {
try {
mService.resetAllModes(mContext.getUserId(), null);
diff --git a/core/java/android/app/servertransaction/TransactionExecutor.java b/core/java/android/app/servertransaction/TransactionExecutor.java
index 9e9a9c5..0d995e8 100644
--- a/core/java/android/app/servertransaction/TransactionExecutor.java
+++ b/core/java/android/app/servertransaction/TransactionExecutor.java
@@ -147,7 +147,10 @@
pw.println("Executor:");
dump(pw, prefix);
- Slog.wtf(TAG, stringWriter.toString());
+ Slog.w(TAG, stringWriter.toString());
+
+ // Ignore requests for non-existent client records for now.
+ return;
}
// Cycle to the state right before the final requested state.
diff --git a/core/java/android/app/slice/SliceProvider.java b/core/java/android/app/slice/SliceProvider.java
index df32fb9..aa2cf46 100644
--- a/core/java/android/app/slice/SliceProvider.java
+++ b/core/java/android/app/slice/SliceProvider.java
@@ -16,7 +16,6 @@
package android.app.slice;
import android.annotation.NonNull;
-import android.annotation.Nullable;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.ContentProvider;
@@ -35,7 +34,6 @@
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Handler;
-import android.os.Looper;
import android.os.Process;
import android.os.StrictMode;
import android.os.StrictMode.ThreadPolicy;
@@ -46,7 +44,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.CountDownLatch;
/**
* A SliceProvider allows an app to provide content to be displayed in system spaces. This content
@@ -163,18 +160,10 @@
private static final boolean DEBUG = false;
- private String mBindingPkg;
- private SliceManager mSliceManager;
+ private static final long SLICE_BIND_ANR = 2000;
- /**
- * Return the package name of the caller that initiated the binding request
- * currently happening. The returned package will have been
- * verified to belong to the calling UID. Returns {@code null} if not
- * currently performing an {@link #onBindSlice(Uri, List)}.
- */
- public final @Nullable String getBindingPackage() {
- return mBindingPkg;
- }
+ private String mCallback;
+ private SliceManager mSliceManager;
@Override
public void attachInfo(Context context, ProviderInfo info) {
@@ -183,12 +172,12 @@
}
/**
- * Implemented to create a slice. Will be called on the main thread.
+ * Implemented to create a slice.
* <p>
* onBindSlice should return as quickly as possible so that the UI tied
* to this slice can be responsive. No network or other IO will be allowed
* during onBindSlice. Any loading that needs to be done should happen
- * off the main thread with a call to {@link ContentResolver#notifyChange(Uri, ContentObserver)}
+ * in the background with a call to {@link ContentResolver#notifyChange(Uri, ContentObserver)}
* when the app is ready to provide the complete data in onBindSlice.
* <p>
* The slice returned should have a spec that is compatible with one of
@@ -381,55 +370,32 @@
}
private Collection<Uri> handleGetDescendants(Uri uri) {
- if (Looper.myLooper() == Looper.getMainLooper()) {
+ mCallback = "onGetSliceDescendants";
+ Handler.getMain().postDelayed(mAnr, SLICE_BIND_ANR);
+ try {
return onGetSliceDescendants(uri);
- } else {
- CountDownLatch latch = new CountDownLatch(1);
- Collection<Uri>[] output = new Collection[1];
- Handler.getMain().post(() -> {
- output[0] = onGetSliceDescendants(uri);
- latch.countDown();
- });
- try {
- latch.await();
- return output[0];
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
+ } finally {
+ Handler.getMain().removeCallbacks(mAnr);
}
}
private void handlePinSlice(Uri sliceUri) {
- if (Looper.myLooper() == Looper.getMainLooper()) {
+ mCallback = "onSlicePinned";
+ Handler.getMain().postDelayed(mAnr, SLICE_BIND_ANR);
+ try {
onSlicePinned(sliceUri);
- } else {
- CountDownLatch latch = new CountDownLatch(1);
- Handler.getMain().post(() -> {
- onSlicePinned(sliceUri);
- latch.countDown();
- });
- try {
- latch.await();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
+ } finally {
+ Handler.getMain().removeCallbacks(mAnr);
}
}
private void handleUnpinSlice(Uri sliceUri) {
- if (Looper.myLooper() == Looper.getMainLooper()) {
+ mCallback = "onSliceUnpinned";
+ Handler.getMain().postDelayed(mAnr, SLICE_BIND_ANR);
+ try {
onSliceUnpinned(sliceUri);
- } else {
- CountDownLatch latch = new CountDownLatch(1);
- Handler.getMain().post(() -> {
- onSliceUnpinned(sliceUri);
- latch.countDown();
- });
- try {
- latch.await();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
+ } finally {
+ Handler.getMain().removeCallbacks(mAnr);
}
}
@@ -447,21 +413,12 @@
return createPermissionSlice(getContext(), sliceUri, pkg);
}
}
- if (Looper.myLooper() == Looper.getMainLooper()) {
- return onBindSliceStrict(sliceUri, supportedSpecs, pkg);
- } else {
- CountDownLatch latch = new CountDownLatch(1);
- Slice[] output = new Slice[1];
- Handler.getMain().post(() -> {
- output[0] = onBindSliceStrict(sliceUri, supportedSpecs, pkg);
- latch.countDown();
- });
- try {
- latch.await();
- return output[0];
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
+ mCallback = "onBindSlice";
+ Handler.getMain().postDelayed(mAnr, SLICE_BIND_ANR);
+ try {
+ return onBindSliceStrict(sliceUri, supportedSpecs);
+ } finally {
+ Handler.getMain().removeCallbacks(mAnr);
}
}
@@ -513,19 +470,21 @@
}
}
- private Slice onBindSliceStrict(Uri sliceUri, List<SliceSpec> supportedSpecs,
- String callingPackage) {
+ private Slice onBindSliceStrict(Uri sliceUri, List<SliceSpec> supportedSpecs) {
ThreadPolicy oldPolicy = StrictMode.getThreadPolicy();
try {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyDeath()
.build());
- mBindingPkg = callingPackage;
return onBindSlice(sliceUri, supportedSpecs);
} finally {
- mBindingPkg = null;
StrictMode.setThreadPolicy(oldPolicy);
}
}
+
+ private final Runnable mAnr = () -> {
+ Process.sendSignal(Process.myPid(), Process.SIGNAL_QUIT);
+ Log.wtf(TAG, "Timed out while handling slice callback " + mCallback);
+ };
}
diff --git a/core/java/android/hardware/camera2/CameraDevice.java b/core/java/android/hardware/camera2/CameraDevice.java
index f47d464..72db33f 100644
--- a/core/java/android/hardware/camera2/CameraDevice.java
+++ b/core/java/android/hardware/camera2/CameraDevice.java
@@ -819,8 +819,7 @@
* @param config A session configuration (see {@link SessionConfiguration}).
*
* @throws IllegalArgumentException In case the session configuration is invalid; or the output
- * configurations are empty; or the session configuration
- * executor is invalid.
+ * configurations are empty.
* @throws CameraAccessException In case the camera device is no longer connected or has
* encountered a fatal error.
* @see #createCaptureSession(List, CameraCaptureSession.StateCallback, Handler)
diff --git a/core/java/android/hardware/camera2/dispatch/ArgumentReplacingDispatcher.java b/core/java/android/hardware/camera2/dispatch/ArgumentReplacingDispatcher.java
new file mode 100644
index 0000000..866f370
--- /dev/null
+++ b/core/java/android/hardware/camera2/dispatch/ArgumentReplacingDispatcher.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2014 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.hardware.camera2.dispatch;
+
+import java.lang.reflect.Method;
+
+import static com.android.internal.util.Preconditions.*;
+
+/**
+ * A dispatcher that replaces one argument with another; replaces any argument at an index
+ * with another argument.
+ *
+ * <p>For example, we can override an {@code void onSomething(int x)} calls to have {@code x} always
+ * equal to 1. Or, if using this with a duck typing dispatcher, we could even overwrite {@code x} to
+ * be something
+ * that's not an {@code int}.</p>
+ *
+ * @param <T>
+ * source dispatch type, whose methods with {@link #dispatch} will be called
+ * @param <TArg>
+ * argument replacement type, args in {@link #dispatch} matching {@code argumentIndex}
+ * will be overriden to objects of this type
+ */
+public class ArgumentReplacingDispatcher<T, TArg> implements Dispatchable<T> {
+
+ private final Dispatchable<T> mTarget;
+ private final int mArgumentIndex;
+ private final TArg mReplaceWith;
+
+ /**
+ * Create a new argument replacing dispatcher; dispatches are forwarded to {@code target}
+ * after the argument is replaced.
+ *
+ * <p>For example, if a method {@code onAction(T1 a, Integer b, T2 c)} is invoked, and we wanted
+ * to replace all occurrences of {@code b} with {@code 0xDEADBEEF}, we would set
+ * {@code argumentIndex = 1} and {@code replaceWith = 0xDEADBEEF}.</p>
+ *
+ * <p>If a method dispatched has less arguments than {@code argumentIndex}, it is
+ * passed through with the arguments unchanged.</p>
+ *
+ * @param target destination dispatch type, methods will be redirected to this dispatcher
+ * @param argumentIndex the numeric index of the argument {@code >= 0}
+ * @param replaceWith arguments matching {@code argumentIndex} will be replaced with this object
+ */
+ public ArgumentReplacingDispatcher(Dispatchable<T> target, int argumentIndex,
+ TArg replaceWith) {
+ mTarget = checkNotNull(target, "target must not be null");
+ mArgumentIndex = checkArgumentNonnegative(argumentIndex,
+ "argumentIndex must not be negative");
+ mReplaceWith = checkNotNull(replaceWith, "replaceWith must not be null");
+ }
+
+ @Override
+ public Object dispatch(Method method, Object[] args) throws Throwable {
+
+ if (args.length > mArgumentIndex) {
+ args = arrayCopy(args); // don't change in-place since it can affect upstream dispatches
+ args[mArgumentIndex] = mReplaceWith;
+ }
+
+ return mTarget.dispatch(method, args);
+ }
+
+ private static Object[] arrayCopy(Object[] array) {
+ int length = array.length;
+ Object[] newArray = new Object[length];
+ for (int i = 0; i < length; ++i) {
+ newArray[i] = array[i];
+ }
+ return newArray;
+ }
+}
diff --git a/core/java/android/hardware/camera2/dispatch/BroadcastDispatcher.java b/core/java/android/hardware/camera2/dispatch/BroadcastDispatcher.java
new file mode 100644
index 0000000..fe575b2
--- /dev/null
+++ b/core/java/android/hardware/camera2/dispatch/BroadcastDispatcher.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2014 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.hardware.camera2.dispatch;
+
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+
+import static com.android.internal.util.Preconditions.*;
+
+/**
+ * Broadcast a single dispatch into multiple other dispatchables.
+ *
+ * <p>Every time {@link #dispatch} is invoked, all the broadcast targets will
+ * see the same dispatch as well. The first target's return value is returned.</p>
+ *
+ * <p>This enables a single listener to be converted into a multi-listener.</p>
+ */
+public class BroadcastDispatcher<T> implements Dispatchable<T> {
+
+ private final List<Dispatchable<T>> mDispatchTargets;
+
+ /**
+ * Create a broadcast dispatcher from the supplied dispatch targets.
+ *
+ * @param dispatchTargets one or more targets to dispatch to
+ */
+ @SafeVarargs
+ public BroadcastDispatcher(Dispatchable<T>... dispatchTargets) {
+ mDispatchTargets = Arrays.asList(
+ checkNotNull(dispatchTargets, "dispatchTargets must not be null"));
+ }
+
+ @Override
+ public Object dispatch(Method method, Object[] args) throws Throwable {
+ Object result = null;
+ boolean gotResult = false;
+
+ for (Dispatchable<T> dispatchTarget : mDispatchTargets) {
+ Object localResult = dispatchTarget.dispatch(method, args);
+
+ if (!gotResult) {
+ gotResult = true;
+ result = localResult;
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/core/java/android/hardware/camera2/dispatch/Dispatchable.java b/core/java/android/hardware/camera2/dispatch/Dispatchable.java
new file mode 100644
index 0000000..753103f
--- /dev/null
+++ b/core/java/android/hardware/camera2/dispatch/Dispatchable.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2014 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.hardware.camera2.dispatch;
+
+import java.lang.reflect.Method;
+
+/**
+ * Dynamically dispatch a method and its argument to some object.
+ *
+ * <p>This can be used to intercept method calls and do work around them, redirect work,
+ * or block calls entirely.</p>
+ */
+public interface Dispatchable<T> {
+ /**
+ * Dispatch the method and arguments to this object.
+ * @param method a method defined in class {@code T}
+ * @param args arguments corresponding to said {@code method}
+ * @return the object returned when invoking {@code method}
+ * @throws Throwable any exception that might have been raised while invoking the method
+ */
+ public Object dispatch(Method method, Object[] args) throws Throwable;
+}
diff --git a/core/java/android/hardware/camera2/dispatch/DuckTypingDispatcher.java b/core/java/android/hardware/camera2/dispatch/DuckTypingDispatcher.java
new file mode 100644
index 0000000..75f97e4
--- /dev/null
+++ b/core/java/android/hardware/camera2/dispatch/DuckTypingDispatcher.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2014 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.hardware.camera2.dispatch;
+
+
+import java.lang.reflect.Method;
+
+import static com.android.internal.util.Preconditions.*;
+
+/**
+ * Duck typing dispatcher; converts dispatch methods calls from one class to another by
+ * looking up equivalently methods at runtime by name.
+ *
+ * <p>For example, if two types have identical method names and arguments, but
+ * are not subclasses/subinterfaces of each other, this dispatcher will allow calls to be
+ * made from one type to the other.</p>
+ *
+ * @param <TFrom> source dispatch type, whose methods with {@link #dispatch} will be called
+ * @param <T> destination dispatch type, methods will be converted to the class of {@code T}
+ */
+public class DuckTypingDispatcher<TFrom, T> implements Dispatchable<TFrom> {
+
+ private final MethodNameInvoker<T> mDuck;
+
+ /**
+ * Create a new duck typing dispatcher.
+ *
+ * @param target destination dispatch type, methods will be redirected to this dispatcher
+ * @param targetClass destination dispatch class, methods will be converted to this class's
+ */
+ public DuckTypingDispatcher(Dispatchable<T> target, Class<T> targetClass) {
+ checkNotNull(targetClass, "targetClass must not be null");
+ checkNotNull(target, "target must not be null");
+
+ mDuck = new MethodNameInvoker<T>(target, targetClass);
+ }
+
+ @Override
+ public Object dispatch(Method method, Object[] args) {
+ return mDuck.invoke(method.getName(), args);
+ }
+}
diff --git a/core/java/android/hardware/camera2/dispatch/HandlerDispatcher.java b/core/java/android/hardware/camera2/dispatch/HandlerDispatcher.java
new file mode 100644
index 0000000..f8e9d49
--- /dev/null
+++ b/core/java/android/hardware/camera2/dispatch/HandlerDispatcher.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2014 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.hardware.camera2.dispatch;
+
+import android.hardware.camera2.utils.UncheckedThrow;
+import android.os.Handler;
+import android.util.Log;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import static com.android.internal.util.Preconditions.*;
+
+/**
+ * Forward all interface calls into a handler by posting it as a {@code Runnable}.
+ *
+ * <p>All calls will return immediately; functions with return values will return a default
+ * value of {@code null}, {@code 0}, or {@code false} where that value is legal.</p>
+ *
+ * <p>Any exceptions thrown on the handler while trying to invoke a method
+ * will be re-thrown. Throwing checked exceptions on a handler which doesn't expect any
+ * checked exceptions to be thrown will result in "undefined" behavior
+ * (although in practice it is usually thrown as normal).</p>
+ */
+public class HandlerDispatcher<T> implements Dispatchable<T> {
+
+ private static final String TAG = "HandlerDispatcher";
+
+ private final Dispatchable<T> mDispatchTarget;
+ private final Handler mHandler;
+
+ /**
+ * Create a dispatcher that forwards it's dispatch calls by posting
+ * them onto the {@code handler} as a {@code Runnable}.
+ *
+ * @param dispatchTarget the destination whose method calls will be redirected into the handler
+ * @param handler all calls into {@code dispatchTarget} will be posted onto this handler
+ * @param <T> the type of the element you want to wrap.
+ * @return a dispatcher that will forward it's dispatch calls to a handler
+ */
+ public HandlerDispatcher(Dispatchable<T> dispatchTarget, Handler handler) {
+ mDispatchTarget = checkNotNull(dispatchTarget, "dispatchTarget must not be null");
+ mHandler = checkNotNull(handler, "handler must not be null");
+ }
+
+ @Override
+ public Object dispatch(final Method method, final Object[] args) throws Throwable {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ mDispatchTarget.dispatch(method, args);
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ // Potential UB. Hopefully 't' is a runtime exception.
+ UncheckedThrow.throwAnyException(t);
+ } catch (IllegalAccessException e) {
+ // Impossible
+ Log.wtf(TAG, "IllegalAccessException while invoking " + method, e);
+ } catch (IllegalArgumentException e) {
+ // Impossible
+ Log.wtf(TAG, "IllegalArgumentException while invoking " + method, e);
+ } catch (Throwable e) {
+ UncheckedThrow.throwAnyException(e);
+ }
+ }
+ });
+
+ // TODO handle primitive return values that would avoid NPE if unboxed
+ return null;
+ }
+}
diff --git a/core/java/android/hardware/camera2/dispatch/InvokeDispatcher.java b/core/java/android/hardware/camera2/dispatch/InvokeDispatcher.java
new file mode 100644
index 0000000..ac5f526
--- /dev/null
+++ b/core/java/android/hardware/camera2/dispatch/InvokeDispatcher.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2014 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.hardware.camera2.dispatch;
+
+import android.hardware.camera2.utils.UncheckedThrow;
+import android.util.Log;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import static com.android.internal.util.Preconditions.*;
+
+
+public class InvokeDispatcher<T> implements Dispatchable<T> {
+
+ private static final String TAG = "InvocationSink";
+ private final T mTarget;
+
+ public InvokeDispatcher(T target) {
+ mTarget = checkNotNull(target, "target must not be null");
+ }
+
+ @Override
+ public Object dispatch(Method method, Object[] args) {
+ try {
+ return method.invoke(mTarget, args);
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ // Potential UB. Hopefully 't' is a runtime exception.
+ UncheckedThrow.throwAnyException(t);
+ } catch (IllegalAccessException e) {
+ // Impossible
+ Log.wtf(TAG, "IllegalAccessException while invoking " + method, e);
+ } catch (IllegalArgumentException e) {
+ // Impossible
+ Log.wtf(TAG, "IllegalArgumentException while invoking " + method, e);
+ }
+
+ // unreachable
+ return null;
+ }
+}
diff --git a/core/java/android/hardware/camera2/dispatch/MethodNameInvoker.java b/core/java/android/hardware/camera2/dispatch/MethodNameInvoker.java
new file mode 100644
index 0000000..8296b7a
--- /dev/null
+++ b/core/java/android/hardware/camera2/dispatch/MethodNameInvoker.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2014 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.hardware.camera2.dispatch;
+
+import static com.android.internal.util.Preconditions.checkNotNull;
+
+import android.hardware.camera2.utils.UncheckedThrow;
+
+import java.lang.reflect.Method;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Invoke a method on a dispatchable by its name (without knowing the {@code Method} ahead of time).
+ *
+ * @param <T> destination dispatch type, methods will be looked up in the class of {@code T}
+ */
+public class MethodNameInvoker<T> {
+
+ private final Dispatchable<T> mTarget;
+ private final Class<T> mTargetClass;
+ private final Method[] mTargetClassMethods;
+ private final ConcurrentHashMap<String, Method> mMethods =
+ new ConcurrentHashMap<>();
+
+ /**
+ * Create a new method name invoker.
+ *
+ * @param target destination dispatch type, invokes will be redirected to this dispatcher
+ * @param targetClass destination dispatch class, the invoked methods will be from this class
+ */
+ public MethodNameInvoker(Dispatchable<T> target, Class<T> targetClass) {
+ mTargetClass = targetClass;
+ mTargetClassMethods = targetClass.getMethods();
+ mTarget = target;
+ }
+
+ /**
+ * Invoke a method by its name.
+ *
+ * <p>If more than one method exists in {@code targetClass}, the first method with the right
+ * number of arguments will be used, and later calls will all use that method.</p>
+ *
+ * @param methodName
+ * The name of the method, which will be matched 1:1 to the destination method
+ * @param params
+ * Variadic parameter list.
+ * @return
+ * The same kind of value that would normally be returned by calling {@code methodName}
+ * statically.
+ *
+ * @throws IllegalArgumentException if {@code methodName} does not exist on the target class
+ * @throws Throwable will rethrow anything that the target method would normally throw
+ */
+ @SuppressWarnings("unchecked")
+ public <K> K invoke(String methodName, Object... params) {
+ checkNotNull(methodName, "methodName must not be null");
+
+ Method targetMethod = mMethods.get(methodName);
+ if (targetMethod == null) {
+ for (Method method : mTargetClassMethods) {
+ // TODO future: match types of params if possible
+ if (method.getName().equals(methodName) &&
+ (params.length == method.getParameterTypes().length) ) {
+ targetMethod = method;
+ mMethods.put(methodName, targetMethod);
+ break;
+ }
+ }
+
+ if (targetMethod == null) {
+ throw new IllegalArgumentException(
+ "Method " + methodName + " does not exist on class " + mTargetClass);
+ }
+ }
+
+ try {
+ return (K) mTarget.dispatch(targetMethod, params);
+ } catch (Throwable e) {
+ UncheckedThrow.throwAnyException(e);
+ // unreachable
+ return null;
+ }
+ }
+}
diff --git a/core/java/android/hardware/camera2/dispatch/NullDispatcher.java b/core/java/android/hardware/camera2/dispatch/NullDispatcher.java
new file mode 100644
index 0000000..fada075
--- /dev/null
+++ b/core/java/android/hardware/camera2/dispatch/NullDispatcher.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2014 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.hardware.camera2.dispatch;
+
+
+import java.lang.reflect.Method;
+
+/**
+ * Do nothing when dispatching; follows the null object pattern.
+ */
+public class NullDispatcher<T> implements Dispatchable<T> {
+ /**
+ * Create a dispatcher that does nothing when dispatched to.
+ */
+ public NullDispatcher() {
+ }
+
+ /**
+ * Do nothing; all parameters are ignored.
+ */
+ @Override
+ public Object dispatch(Method method, Object[] args) {
+ return null;
+ }
+}
diff --git a/core/java/android/hardware/camera2/dispatch/package.html b/core/java/android/hardware/camera2/dispatch/package.html
new file mode 100644
index 0000000..783d0a1
--- /dev/null
+++ b/core/java/android/hardware/camera2/dispatch/package.html
@@ -0,0 +1,3 @@
+<body>
+{@hide}
+</body>
diff --git a/core/java/android/hardware/camera2/impl/CallbackProxies.java b/core/java/android/hardware/camera2/impl/CallbackProxies.java
index 9e4cb80..c9eecf1 100644
--- a/core/java/android/hardware/camera2/impl/CallbackProxies.java
+++ b/core/java/android/hardware/camera2/impl/CallbackProxies.java
@@ -15,17 +15,16 @@
*/
package android.hardware.camera2.impl;
-import android.os.Binder;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CaptureFailure;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.TotalCaptureResult;
+import android.hardware.camera2.dispatch.Dispatchable;
+import android.hardware.camera2.dispatch.MethodNameInvoker;
import android.view.Surface;
-import java.util.concurrent.Executor;
-
import static com.android.internal.util.Preconditions.*;
/**
@@ -35,86 +34,164 @@
* to use our own proxy mechanism.</p>
*/
public class CallbackProxies {
+
+ // TODO: replace with codegen
+
+ public static class DeviceStateCallbackProxy extends CameraDeviceImpl.StateCallbackKK {
+ private final MethodNameInvoker<CameraDeviceImpl.StateCallbackKK> mProxy;
+
+ public DeviceStateCallbackProxy(
+ Dispatchable<CameraDeviceImpl.StateCallbackKK> dispatchTarget) {
+ dispatchTarget = checkNotNull(dispatchTarget, "dispatchTarget must not be null");
+ mProxy = new MethodNameInvoker<>(dispatchTarget, CameraDeviceImpl.StateCallbackKK.class);
+ }
+
+ @Override
+ public void onOpened(CameraDevice camera) {
+ mProxy.invoke("onOpened", camera);
+ }
+
+ @Override
+ public void onDisconnected(CameraDevice camera) {
+ mProxy.invoke("onDisconnected", camera);
+ }
+
+ @Override
+ public void onError(CameraDevice camera, int error) {
+ mProxy.invoke("onError", camera, error);
+ }
+
+ @Override
+ public void onUnconfigured(CameraDevice camera) {
+ mProxy.invoke("onUnconfigured", camera);
+ }
+
+ @Override
+ public void onActive(CameraDevice camera) {
+ mProxy.invoke("onActive", camera);
+ }
+
+ @Override
+ public void onBusy(CameraDevice camera) {
+ mProxy.invoke("onBusy", camera);
+ }
+
+ @Override
+ public void onClosed(CameraDevice camera) {
+ mProxy.invoke("onClosed", camera);
+ }
+
+ @Override
+ public void onIdle(CameraDevice camera) {
+ mProxy.invoke("onIdle", camera);
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ public static class DeviceCaptureCallbackProxy implements CameraDeviceImpl.CaptureCallback {
+ private final MethodNameInvoker<CameraDeviceImpl.CaptureCallback> mProxy;
+
+ public DeviceCaptureCallbackProxy(
+ Dispatchable<CameraDeviceImpl.CaptureCallback> dispatchTarget) {
+ dispatchTarget = checkNotNull(dispatchTarget, "dispatchTarget must not be null");
+ mProxy = new MethodNameInvoker<>(dispatchTarget, CameraDeviceImpl.CaptureCallback.class);
+ }
+
+ @Override
+ public void onCaptureStarted(CameraDevice camera,
+ CaptureRequest request, long timestamp, long frameNumber) {
+ mProxy.invoke("onCaptureStarted", camera, request, timestamp, frameNumber);
+ }
+
+ @Override
+ public void onCapturePartial(CameraDevice camera,
+ CaptureRequest request, CaptureResult result) {
+ mProxy.invoke("onCapturePartial", camera, request, result);
+ }
+
+ @Override
+ public void onCaptureProgressed(CameraDevice camera,
+ CaptureRequest request, CaptureResult partialResult) {
+ mProxy.invoke("onCaptureProgressed", camera, request, partialResult);
+ }
+
+ @Override
+ public void onCaptureCompleted(CameraDevice camera,
+ CaptureRequest request, TotalCaptureResult result) {
+ mProxy.invoke("onCaptureCompleted", camera, request, result);
+ }
+
+ @Override
+ public void onCaptureFailed(CameraDevice camera,
+ CaptureRequest request, CaptureFailure failure) {
+ mProxy.invoke("onCaptureFailed", camera, request, failure);
+ }
+
+ @Override
+ public void onCaptureSequenceCompleted(CameraDevice camera,
+ int sequenceId, long frameNumber) {
+ mProxy.invoke("onCaptureSequenceCompleted", camera, sequenceId, frameNumber);
+ }
+
+ @Override
+ public void onCaptureSequenceAborted(CameraDevice camera,
+ int sequenceId) {
+ mProxy.invoke("onCaptureSequenceAborted", camera, sequenceId);
+ }
+
+ @Override
+ public void onCaptureBufferLost(CameraDevice camera,
+ CaptureRequest request, Surface target, long frameNumber) {
+ mProxy.invoke("onCaptureBufferLost", camera, request, target, frameNumber);
+ }
+
+ }
+
public static class SessionStateCallbackProxy
extends CameraCaptureSession.StateCallback {
- private final Executor mExecutor;
- private final CameraCaptureSession.StateCallback mCallback;
+ private final MethodNameInvoker<CameraCaptureSession.StateCallback> mProxy;
- public SessionStateCallbackProxy(Executor executor,
- CameraCaptureSession.StateCallback callback) {
- mExecutor = checkNotNull(executor, "executor must not be null");
- mCallback = checkNotNull(callback, "callback must not be null");
+ public SessionStateCallbackProxy(
+ Dispatchable<CameraCaptureSession.StateCallback> dispatchTarget) {
+ dispatchTarget = checkNotNull(dispatchTarget, "dispatchTarget must not be null");
+ mProxy = new MethodNameInvoker<>(dispatchTarget,
+ CameraCaptureSession.StateCallback.class);
}
@Override
public void onConfigured(CameraCaptureSession session) {
- final long ident = Binder.clearCallingIdentity();
- try {
- mExecutor.execute(() -> mCallback.onConfigured(session));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ mProxy.invoke("onConfigured", session);
}
@Override
public void onConfigureFailed(CameraCaptureSession session) {
- final long ident = Binder.clearCallingIdentity();
- try {
- mExecutor.execute(() -> mCallback.onConfigureFailed(session));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ mProxy.invoke("onConfigureFailed", session);
}
@Override
public void onReady(CameraCaptureSession session) {
- final long ident = Binder.clearCallingIdentity();
- try {
- mExecutor.execute(() -> mCallback.onReady(session));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ mProxy.invoke("onReady", session);
}
@Override
public void onActive(CameraCaptureSession session) {
- final long ident = Binder.clearCallingIdentity();
- try {
- mExecutor.execute(() -> mCallback.onActive(session));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ mProxy.invoke("onActive", session);
}
@Override
public void onCaptureQueueEmpty(CameraCaptureSession session) {
- final long ident = Binder.clearCallingIdentity();
- try {
- mExecutor.execute(() -> mCallback.onCaptureQueueEmpty(session));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ mProxy.invoke("onCaptureQueueEmpty", session);
}
@Override
public void onClosed(CameraCaptureSession session) {
- final long ident = Binder.clearCallingIdentity();
- try {
- mExecutor.execute(() -> mCallback.onClosed(session));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ mProxy.invoke("onClosed", session);
}
@Override
public void onSurfacePrepared(CameraCaptureSession session, Surface surface) {
- final long ident = Binder.clearCallingIdentity();
- try {
- mExecutor.execute(() -> mCallback.onSurfacePrepared(session, surface));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ mProxy.invoke("onSurfacePrepared", session, surface);
}
}
diff --git a/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java b/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java
index f3f6c84..8b8bbc3 100644
--- a/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java
+++ b/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java
@@ -20,18 +20,20 @@
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.ICameraDeviceUser;
+import android.hardware.camera2.dispatch.ArgumentReplacingDispatcher;
+import android.hardware.camera2.dispatch.BroadcastDispatcher;
+import android.hardware.camera2.dispatch.DuckTypingDispatcher;
+import android.hardware.camera2.dispatch.HandlerDispatcher;
+import android.hardware.camera2.dispatch.InvokeDispatcher;
import android.hardware.camera2.params.OutputConfiguration;
import android.hardware.camera2.utils.TaskDrainer;
import android.hardware.camera2.utils.TaskSingleDrainer;
-import android.os.Binder;
import android.os.Handler;
-import android.os.HandlerExecutor;
import android.util.Log;
import android.view.Surface;
import java.util.Arrays;
import java.util.List;
-import java.util.concurrent.Executor;
import static android.hardware.camera2.impl.CameraDeviceImpl.checkHandler;
import static com.android.internal.util.Preconditions.*;
@@ -49,11 +51,11 @@
private final Surface mInput;
/**
* User-specified state callback, used for outgoing events; calls to this object will be
- * automatically invoked via {@code mStateExecutor}.
+ * automatically {@link Handler#post(Runnable) posted} to {@code mStateHandler}.
*/
private final CameraCaptureSession.StateCallback mStateCallback;
- /** User-specified state executor used for outgoing state callback events */
- private final Executor mStateExecutor;
+ /** User-specified state handler used for outgoing state callback events */
+ private final Handler mStateHandler;
/** Internal camera device; used to translate calls into existing deprecated API */
private final android.hardware.camera2.impl.CameraDeviceImpl mDeviceImpl;
@@ -85,7 +87,7 @@
* (e.g. no pending captures, no repeating requests, no flush).</p>
*/
CameraCaptureSessionImpl(int id, Surface input,
- CameraCaptureSession.StateCallback callback, Executor stateExecutor,
+ CameraCaptureSession.StateCallback callback, Handler stateHandler,
android.hardware.camera2.impl.CameraDeviceImpl deviceImpl,
Handler deviceStateHandler, boolean configureSuccess) {
if (callback == null) {
@@ -96,8 +98,8 @@
mIdString = String.format("Session %d: ", mId);
mInput = input;
- mStateExecutor = checkNotNull(stateExecutor, "stateExecutor must not be null");
- mStateCallback = createUserStateCallbackProxy(mStateExecutor, callback);
+ mStateHandler = checkHandler(stateHandler);
+ mStateCallback = createUserStateCallbackProxy(mStateHandler, callback);
mDeviceHandler = checkNotNull(deviceStateHandler, "deviceStateHandler must not be null");
mDeviceImpl = checkNotNull(deviceImpl, "deviceImpl must not be null");
@@ -108,12 +110,12 @@
* This ensures total ordering between CameraDevice.StateCallback and
* CameraDeviceImpl.CaptureCallback events.
*/
- mSequenceDrainer = new TaskDrainer<>(new HandlerExecutor(mDeviceHandler),
- new SequenceDrainListener(), /*name*/"seq");
- mIdleDrainer = new TaskSingleDrainer(new HandlerExecutor(mDeviceHandler),
- new IdleDrainListener(), /*name*/"idle");
- mAbortDrainer = new TaskSingleDrainer(new HandlerExecutor(mDeviceHandler),
- new AbortDrainListener(), /*name*/"abort");
+ mSequenceDrainer = new TaskDrainer<>(mDeviceHandler, new SequenceDrainListener(),
+ /*name*/"seq");
+ mIdleDrainer = new TaskSingleDrainer(mDeviceHandler, new IdleDrainListener(),
+ /*name*/"idle");
+ mAbortDrainer = new TaskSingleDrainer(mDeviceHandler, new AbortDrainListener(),
+ /*name*/"abort");
// CameraDevice should call configureOutputs and have it finish before constructing us
@@ -444,140 +446,114 @@
}
/**
- * Post calls into a CameraCaptureSession.StateCallback to the user-specified {@code executor}.
+ * Post calls into a CameraCaptureSession.StateCallback to the user-specified {@code handler}.
*/
- private StateCallback createUserStateCallbackProxy(Executor executor, StateCallback callback) {
- return new CallbackProxies.SessionStateCallbackProxy(executor, callback);
+ private StateCallback createUserStateCallbackProxy(Handler handler, StateCallback callback) {
+ InvokeDispatcher<StateCallback> userCallbackSink = new InvokeDispatcher<>(callback);
+ HandlerDispatcher<StateCallback> handlerPassthrough =
+ new HandlerDispatcher<>(userCallbackSink, handler);
+
+ return new CallbackProxies.SessionStateCallbackProxy(handlerPassthrough);
}
/**
* Forward callbacks from
* CameraDeviceImpl.CaptureCallback to the CameraCaptureSession.CaptureCallback.
*
+ * <p>In particular, all calls are automatically split to go both to our own
+ * internal callback, and to the user-specified callback (by transparently posting
+ * to the user-specified handler).</p>
+ *
* <p>When a capture sequence finishes, update the pending checked sequences set.</p>
*/
@SuppressWarnings("deprecation")
private CameraDeviceImpl.CaptureCallback createCaptureCallbackProxy(
Handler handler, CaptureCallback callback) {
- final Executor executor = (callback != null) ? CameraDeviceImpl.checkAndWrapHandler(
- handler) : null;
+ CameraDeviceImpl.CaptureCallback localCallback = new CameraDeviceImpl.CaptureCallback() {
- return new CameraDeviceImpl.CaptureCallback() {
@Override
public void onCaptureStarted(CameraDevice camera,
CaptureRequest request, long timestamp, long frameNumber) {
- if ((callback != null) && (executor != null)) {
- final long ident = Binder.clearCallingIdentity();
- try {
- executor.execute(() -> callback.onCaptureStarted(
- CameraCaptureSessionImpl.this, request, timestamp,
- frameNumber));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
+ // Do nothing
}
@Override
public void onCapturePartial(CameraDevice camera,
CaptureRequest request, android.hardware.camera2.CaptureResult result) {
- if ((callback != null) && (executor != null)) {
- final long ident = Binder.clearCallingIdentity();
- try {
- executor.execute(() -> callback.onCapturePartial(
- CameraCaptureSessionImpl.this, request, result));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
+ // Do nothing
}
@Override
public void onCaptureProgressed(CameraDevice camera,
CaptureRequest request, android.hardware.camera2.CaptureResult partialResult) {
- if ((callback != null) && (executor != null)) {
- final long ident = Binder.clearCallingIdentity();
- try {
- executor.execute(() -> callback.onCaptureProgressed(
- CameraCaptureSessionImpl.this, request, partialResult));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
+ // Do nothing
}
@Override
public void onCaptureCompleted(CameraDevice camera,
CaptureRequest request, android.hardware.camera2.TotalCaptureResult result) {
- if ((callback != null) && (executor != null)) {
- final long ident = Binder.clearCallingIdentity();
- try {
- executor.execute(() -> callback.onCaptureCompleted(
- CameraCaptureSessionImpl.this, request, result));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
+ // Do nothing
}
@Override
public void onCaptureFailed(CameraDevice camera,
CaptureRequest request, android.hardware.camera2.CaptureFailure failure) {
- if ((callback != null) && (executor != null)) {
- final long ident = Binder.clearCallingIdentity();
- try {
- executor.execute(() -> callback.onCaptureFailed(
- CameraCaptureSessionImpl.this, request, failure));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
+ // Do nothing
}
@Override
public void onCaptureSequenceCompleted(CameraDevice camera,
int sequenceId, long frameNumber) {
- if ((callback != null) && (executor != null)) {
- final long ident = Binder.clearCallingIdentity();
- try {
- executor.execute(() -> callback.onCaptureSequenceCompleted(
- CameraCaptureSessionImpl.this, sequenceId, frameNumber));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
finishPendingSequence(sequenceId);
}
@Override
public void onCaptureSequenceAborted(CameraDevice camera,
int sequenceId) {
- if ((callback != null) && (executor != null)) {
- final long ident = Binder.clearCallingIdentity();
- try {
- executor.execute(() -> callback.onCaptureSequenceAborted(
- CameraCaptureSessionImpl.this, sequenceId));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
finishPendingSequence(sequenceId);
}
@Override
public void onCaptureBufferLost(CameraDevice camera,
CaptureRequest request, Surface target, long frameNumber) {
- if ((callback != null) && (executor != null)) {
- final long ident = Binder.clearCallingIdentity();
- try {
- executor.execute(() -> callback.onCaptureBufferLost(
- CameraCaptureSessionImpl.this, request, target, frameNumber));
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
+ // Do nothing
}
+
};
+
+ /*
+ * Split the calls from the device callback into local callback and the following chain:
+ * - replace the first CameraDevice arg with a CameraCaptureSession
+ * - duck type from device callback to session callback
+ * - then forward the call to a handler
+ * - then finally invoke the destination method on the session callback object
+ */
+ if (callback == null) {
+ // OK: API allows the user to not specify a callback, and the handler may
+ // also be null in that case. Collapse whole dispatch chain to only call the local
+ // callback
+ return localCallback;
+ }
+
+ InvokeDispatcher<CameraDeviceImpl.CaptureCallback> localSink =
+ new InvokeDispatcher<>(localCallback);
+
+ InvokeDispatcher<CaptureCallback> userCallbackSink =
+ new InvokeDispatcher<>(callback);
+ HandlerDispatcher<CaptureCallback> handlerPassthrough =
+ new HandlerDispatcher<>(userCallbackSink, handler);
+ DuckTypingDispatcher<CameraDeviceImpl.CaptureCallback, CaptureCallback> duckToSession
+ = new DuckTypingDispatcher<>(handlerPassthrough, CaptureCallback.class);
+ ArgumentReplacingDispatcher<CameraDeviceImpl.CaptureCallback, CameraCaptureSessionImpl>
+ replaceDeviceWithSession = new ArgumentReplacingDispatcher<>(duckToSession,
+ /*argumentIndex*/0, this);
+
+ BroadcastDispatcher<CameraDeviceImpl.CaptureCallback> broadcaster =
+ new BroadcastDispatcher<CameraDeviceImpl.CaptureCallback>(
+ replaceDeviceWithSession,
+ localSink);
+
+ return new CallbackProxies.DeviceCaptureCallbackProxy(broadcaster);
}
/**
diff --git a/core/java/android/hardware/camera2/impl/CameraConstrainedHighSpeedCaptureSessionImpl.java b/core/java/android/hardware/camera2/impl/CameraConstrainedHighSpeedCaptureSessionImpl.java
index 4ee08ba..06c2c25 100644
--- a/core/java/android/hardware/camera2/impl/CameraConstrainedHighSpeedCaptureSessionImpl.java
+++ b/core/java/android/hardware/camera2/impl/CameraConstrainedHighSpeedCaptureSessionImpl.java
@@ -33,7 +33,6 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import java.util.concurrent.Executor;
import static com.android.internal.util.Preconditions.*;
@@ -60,14 +59,14 @@
* (e.g. no pending captures, no repeating requests, no flush).</p>
*/
CameraConstrainedHighSpeedCaptureSessionImpl(int id,
- CameraCaptureSession.StateCallback callback, Executor stateExecutor,
+ CameraCaptureSession.StateCallback callback, Handler stateHandler,
android.hardware.camera2.impl.CameraDeviceImpl deviceImpl,
Handler deviceStateHandler, boolean configureSuccess,
CameraCharacteristics characteristics) {
mCharacteristics = characteristics;
CameraCaptureSession.StateCallback wrapperCallback = new WrapperCallback(callback);
mSessionImpl = new CameraCaptureSessionImpl(id, /*input*/null, wrapperCallback,
- stateExecutor, deviceImpl, deviceStateHandler, configureSuccess);
+ stateHandler, deviceImpl, deviceStateHandler, configureSuccess);
}
@Override
diff --git a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
index b328bb1..511fa43 100644
--- a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
+++ b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
@@ -35,10 +35,8 @@
import android.hardware.camera2.params.StreamConfigurationMap;
import android.hardware.camera2.utils.SubmitInfo;
import android.hardware.camera2.utils.SurfaceUtils;
-import android.os.Binder;
import android.os.Build;
import android.os.Handler;
-import android.os.HandlerExecutor;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
@@ -60,7 +58,6 @@
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.Executor;
/**
* HAL2.1+ implementation of CameraDevice. Use CameraManager#open to instantiate
@@ -504,9 +501,8 @@
for (Surface surface : outputs) {
outConfigurations.add(new OutputConfiguration(surface));
}
- createCaptureSessionInternal(null, outConfigurations, callback,
- checkAndWrapHandler(handler), /*operatingMode*/ICameraDeviceUser.NORMAL_MODE,
- /*sessionParams*/ null);
+ createCaptureSessionInternal(null, outConfigurations, callback, handler,
+ /*operatingMode*/ICameraDeviceUser.NORMAL_MODE, /*sessionParams*/ null);
}
@Override
@@ -521,7 +517,7 @@
// OutputConfiguration objects are immutable, but need to have our own array
List<OutputConfiguration> currentOutputs = new ArrayList<>(outputConfigurations);
- createCaptureSessionInternal(null, currentOutputs, callback, checkAndWrapHandler(handler),
+ createCaptureSessionInternal(null, currentOutputs, callback, handler,
/*operatingMode*/ICameraDeviceUser.NORMAL_MODE, /*sessionParams*/null);
}
@@ -541,9 +537,8 @@
for (Surface surface : outputs) {
outConfigurations.add(new OutputConfiguration(surface));
}
- createCaptureSessionInternal(inputConfig, outConfigurations, callback,
- checkAndWrapHandler(handler), /*operatingMode*/ICameraDeviceUser.NORMAL_MODE,
- /*sessionParams*/ null);
+ createCaptureSessionInternal(inputConfig, outConfigurations, callback, handler,
+ /*operatingMode*/ICameraDeviceUser.NORMAL_MODE, /*sessionParams*/ null);
}
@Override
@@ -571,8 +566,8 @@
currentOutputs.add(new OutputConfiguration(output));
}
createCaptureSessionInternal(inputConfig, currentOutputs,
- callback, checkAndWrapHandler(handler),
- /*operatingMode*/ICameraDeviceUser.NORMAL_MODE, /*sessionParams*/ null);
+ callback, handler, /*operatingMode*/ICameraDeviceUser.NORMAL_MODE,
+ /*sessionParams*/ null);
}
@Override
@@ -587,8 +582,7 @@
for (Surface surface : outputs) {
outConfigurations.add(new OutputConfiguration(surface));
}
- createCaptureSessionInternal(null, outConfigurations, callback,
- checkAndWrapHandler(handler),
+ createCaptureSessionInternal(null, outConfigurations, callback, handler,
/*operatingMode*/ICameraDeviceUser.CONSTRAINED_HIGH_SPEED_MODE,
/*sessionParams*/ null);
}
@@ -603,8 +597,8 @@
for (OutputConfiguration output : outputs) {
currentOutputs.add(new OutputConfiguration(output));
}
- createCaptureSessionInternal(inputConfig, currentOutputs, callback,
- checkAndWrapHandler(handler), operatingMode, /*sessionParams*/ null);
+ createCaptureSessionInternal(inputConfig, currentOutputs, callback, handler, operatingMode,
+ /*sessionParams*/ null);
}
@Override
@@ -618,17 +612,14 @@
if (outputConfigs == null) {
throw new IllegalArgumentException("Invalid output configurations");
}
- if (config.getExecutor() == null) {
- throw new IllegalArgumentException("Invalid executor");
- }
createCaptureSessionInternal(config.getInputConfiguration(), outputConfigs,
- config.getStateCallback(), config.getExecutor(), config.getSessionType(),
+ config.getStateCallback(), config.getHandler(), config.getSessionType(),
config.getSessionParameters());
}
private void createCaptureSessionInternal(InputConfiguration inputConfig,
List<OutputConfiguration> outputConfigurations,
- CameraCaptureSession.StateCallback callback, Executor executor,
+ CameraCaptureSession.StateCallback callback, Handler handler,
int operatingMode, CaptureRequest sessionParams) throws CameraAccessException {
synchronized(mInterfaceLock) {
if (DEBUG) {
@@ -682,11 +673,12 @@
SurfaceUtils.checkConstrainedHighSpeedSurfaces(surfaces, /*fpsRange*/null, config);
newSession = new CameraConstrainedHighSpeedCaptureSessionImpl(mNextSessionId++,
- callback, executor, this, mDeviceHandler, configureSuccess,
+ callback, handler, this, mDeviceHandler, configureSuccess,
mCharacteristics);
} else {
newSession = new CameraCaptureSessionImpl(mNextSessionId++, input,
- callback, executor, this, mDeviceHandler, configureSuccess);
+ callback, handler, this, mDeviceHandler,
+ configureSuccess);
}
// TODO: wait until current session closes, then create the new session
@@ -971,12 +963,7 @@
}
}
};
- final long ident = Binder.clearCallingIdentity();
- try {
- holder.getExecutor().execute(resultDispatch);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ holder.getHandler().post(resultDispatch);
} else {
Log.w(TAG, String.format(
"did not register callback to request %d",
@@ -997,9 +984,9 @@
private int submitCaptureRequest(List<CaptureRequest> requestList, CaptureCallback callback,
Handler handler, boolean repeating) throws CameraAccessException {
- // Need a valid executor, or current thread needs to have a looper, if
+ // Need a valid handler, or current thread needs to have a looper, if
// callback is valid
- Executor executor = getExecutor(handler, callback);
+ handler = checkHandler(handler, callback);
// Make sure that there all requests have at least 1 surface; all surfaces are non-null;
// the surface isn't a physical stream surface for reprocessing request
@@ -1053,7 +1040,7 @@
if (callback != null) {
mCaptureCallbackMap.put(requestInfo.getRequestId(),
new CaptureCallbackHolder(
- callback, requestList, executor, repeating, mNextSessionId - 1));
+ callback, requestList, handler, repeating, mNextSessionId - 1));
} else {
if (DEBUG) {
Log.d(TAG, "Listen for request " + requestInfo.getRequestId() + " is null");
@@ -1367,7 +1354,7 @@
private final boolean mRepeating;
private final CaptureCallback mCallback;
private final List<CaptureRequest> mRequestList;
- private final Executor mExecutor;
+ private final Handler mHandler;
private final int mSessionId;
/**
* <p>Determine if the callback holder is for a constrained high speed request list that
@@ -1379,13 +1366,13 @@
private final boolean mHasBatchedOutputs;
CaptureCallbackHolder(CaptureCallback callback, List<CaptureRequest> requestList,
- Executor executor, boolean repeating, int sessionId) {
- if (callback == null || executor == null) {
+ Handler handler, boolean repeating, int sessionId) {
+ if (callback == null || handler == null) {
throw new UnsupportedOperationException(
"Must have a valid handler and a valid callback");
}
mRepeating = repeating;
- mExecutor = executor;
+ mHandler = handler;
mRequestList = new ArrayList<CaptureRequest>(requestList);
mCallback = callback;
mSessionId = sessionId;
@@ -1438,8 +1425,8 @@
return getRequest(0);
}
- public Executor getExecutor() {
- return mExecutor;
+ public Handler getHandler() {
+ return mHandler;
}
public int getSessionId() {
@@ -1823,12 +1810,7 @@
}
}
};
- final long ident = Binder.clearCallingIdentity();
- try {
- holder.getExecutor().execute(resultDispatch);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ holder.getHandler().post(resultDispatch);
}
}
}
@@ -1879,7 +1861,7 @@
private void scheduleNotifyError(int code) {
mInError = true;
CameraDeviceImpl.this.mDeviceHandler.post(obtainRunnable(
- CameraDeviceCallbacks::notifyError, this, code));
+ CameraDeviceCallbacks::notifyError, this, code));
}
private void notifyError(int code) {
@@ -1947,41 +1929,36 @@
if (isClosed()) return;
// Dispatch capture start notice
- final long ident = Binder.clearCallingIdentity();
- try {
- holder.getExecutor().execute(
- new Runnable() {
- @Override
- public void run() {
- if (!CameraDeviceImpl.this.isClosed()) {
- final int subsequenceId = resultExtras.getSubsequenceId();
- final CaptureRequest request = holder.getRequest(subsequenceId);
+ holder.getHandler().post(
+ new Runnable() {
+ @Override
+ public void run() {
+ if (!CameraDeviceImpl.this.isClosed()) {
+ final int subsequenceId = resultExtras.getSubsequenceId();
+ final CaptureRequest request = holder.getRequest(subsequenceId);
- if (holder.hasBatchedOutputs()) {
- // Send derived onCaptureStarted for requests within the
- // batch
- final Range<Integer> fpsRange =
- request.get(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE);
- for (int i = 0; i < holder.getRequestCount(); i++) {
- holder.getCallback().onCaptureStarted(
- CameraDeviceImpl.this,
- holder.getRequest(i),
- timestamp - (subsequenceId - i) *
- NANO_PER_SECOND/fpsRange.getUpper(),
- frameNumber - (subsequenceId - i));
- }
- } else {
+ if (holder.hasBatchedOutputs()) {
+ // Send derived onCaptureStarted for requests within the batch
+ final Range<Integer> fpsRange =
+ request.get(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE);
+ for (int i = 0; i < holder.getRequestCount(); i++) {
holder.getCallback().onCaptureStarted(
CameraDeviceImpl.this,
- holder.getRequest(resultExtras.getSubsequenceId()),
- timestamp, frameNumber);
+ holder.getRequest(i),
+ timestamp - (subsequenceId - i) *
+ NANO_PER_SECOND/fpsRange.getUpper(),
+ frameNumber - (subsequenceId - i));
}
+ } else {
+ holder.getCallback().onCaptureStarted(
+ CameraDeviceImpl.this,
+ holder.getRequest(resultExtras.getSubsequenceId()),
+ timestamp, frameNumber);
}
}
- });
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ }
+ });
+
}
}
@@ -2134,12 +2111,7 @@
finalResult = resultAsCapture;
}
- final long ident = Binder.clearCallingIdentity();
- try {
- holder.getExecutor().execute(resultDispatch);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ holder.getHandler().post(resultDispatch);
// Collect the partials for a total result; or mark the frame as totally completed
mFrameNumberTracker.updateTracker(frameNumber, finalResult, isPartialResult,
@@ -2235,12 +2207,7 @@
}
};
// Dispatch the failure callback
- final long ident = Binder.clearCallingIdentity();
- try {
- holder.getExecutor().execute(failureDispatch);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ holder.getHandler().post(failureDispatch);
}
} else {
boolean mayHaveBuffers = (errorCode == ERROR_CAMERA_RESULT);
@@ -2280,12 +2247,7 @@
checkAndFireSequenceComplete();
// Dispatch the failure callback
- final long ident = Binder.clearCallingIdentity();
- try {
- holder.getExecutor().execute(failureDispatch);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ holder.getHandler().post(failureDispatch);
}
}
@@ -2293,37 +2255,6 @@
} // public class CameraDeviceCallbacks
/**
- * Instantiate a new Executor.
- *
- * <p>If the callback isn't null, check the handler and instantiate a new executor,
- * otherwise instantiate a new executor in case handler is valid.</p>
- */
- static <T> Executor getExecutor(Handler handler, T callback) {
- if (callback != null) {
- return checkAndWrapHandler(handler);
- }
-
- if (handler != null) {
- return new HandlerExecutor(handler);
- }
-
- return null;
- }
-
- /**
- * Wrap Handler in Executor.
- *
- * <p>
- * If handler is null, get the current thread's
- * Looper to create a Executor with. If no looper exists, throw
- * {@code IllegalArgumentException}.
- * </p>
- */
- static Executor checkAndWrapHandler(Handler handler) {
- return new HandlerExecutor(checkHandler(handler));
- }
-
- /**
* Default handler management.
*
* <p>
diff --git a/core/java/android/hardware/camera2/params/SessionConfiguration.java b/core/java/android/hardware/camera2/params/SessionConfiguration.java
index 7bdb4a2..a79a6c1 100644
--- a/core/java/android/hardware/camera2/params/SessionConfiguration.java
+++ b/core/java/android/hardware/camera2/params/SessionConfiguration.java
@@ -17,10 +17,10 @@
package android.hardware.camera2.params;
-import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.IntDef;
+import android.os.Handler;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
@@ -31,7 +31,6 @@
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
-import java.util.concurrent.Executor;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -79,7 +78,7 @@
private List<OutputConfiguration> mOutputConfigurations;
private CameraCaptureSession.StateCallback mStateCallback;
private int mSessionType;
- private Executor mExecutor = null;
+ private Handler mHandler = null;
private InputConfiguration mInputConfig = null;
private CaptureRequest mSessionParameters = null;
@@ -88,9 +87,10 @@
*
* @param sessionType The session type.
* @param outputs A list of output configurations for the capture session.
- * @param executor The executor which should be used to invoke the callback. In general it is
- * recommended that camera operations are not done on the main (UI) thread.
* @param cb A state callback interface implementation.
+ * @param handler The handler on which the callback will be invoked. If it is
+ * set to null, the callback will be invoked on the current thread's
+ * {@link android.os.Looper looper}.
*
* @see #SESSION_REGULAR
* @see #SESSION_HIGH_SPEED
@@ -101,12 +101,11 @@
*/
public SessionConfiguration(@SessionMode int sessionType,
@NonNull List<OutputConfiguration> outputs,
- @NonNull @CallbackExecutor Executor executor,
- @NonNull CameraCaptureSession.StateCallback cb) {
+ @NonNull CameraCaptureSession.StateCallback cb, @Nullable Handler handler) {
mSessionType = sessionType;
mOutputConfigurations = Collections.unmodifiableList(new ArrayList<>(outputs));
mStateCallback = cb;
- mExecutor = executor;
+ mHandler = handler;
}
/**
@@ -137,12 +136,14 @@
}
/**
- * Retrieve the {@link java.util.concurrent.Executor} for the capture session.
+ * Retrieve the {@link CameraCaptureSession.StateCallback} for the capture session.
*
- * @return The Executor on which the callback will be invoked.
+ * @return The handler on which the callback will be invoked. If it is
+ * set to null, the callback will be invoked on the current thread's
+ * {@link android.os.Looper looper}.
*/
- public Executor getExecutor() {
- return mExecutor;
+ public Handler getHandler() {
+ return mHandler;
}
/**
diff --git a/core/java/android/hardware/camera2/utils/TaskDrainer.java b/core/java/android/hardware/camera2/utils/TaskDrainer.java
index e71f26a..ed30ff3 100644
--- a/core/java/android/hardware/camera2/utils/TaskDrainer.java
+++ b/core/java/android/hardware/camera2/utils/TaskDrainer.java
@@ -15,11 +15,11 @@
*/
package android.hardware.camera2.utils;
+import android.os.Handler;
import android.util.Log;
import java.util.HashSet;
import java.util.Set;
-import java.util.concurrent.Executor;
import static com.android.internal.util.Preconditions.*;
@@ -55,7 +55,7 @@
private static final String TAG = "TaskDrainer";
private final boolean DEBUG = false;
- private final Executor mExecutor;
+ private final Handler mHandler;
private final DrainListener mListener;
private final String mName;
@@ -73,27 +73,28 @@
/**
* Create a new task drainer; {@code onDrained} callbacks will be posted to the listener
- * via the {@code executor}.
+ * via the {@code handler}.
*
- * @param executor a non-{@code null} executor to use for listener execution
+ * @param handler a non-{@code null} handler to use to post runnables to
* @param listener a non-{@code null} listener where {@code onDrained} will be called
*/
- public TaskDrainer(Executor executor, DrainListener listener) {
- mExecutor = checkNotNull(executor, "executor must not be null");
+ public TaskDrainer(Handler handler, DrainListener listener) {
+ mHandler = checkNotNull(handler, "handler must not be null");
mListener = checkNotNull(listener, "listener must not be null");
mName = null;
}
/**
* Create a new task drainer; {@code onDrained} callbacks will be posted to the listener
- * via the {@code executor}.
+ * via the {@code handler}.
*
- * @param executor a non-{@code null} executor to use for listener execution
+ * @param handler a non-{@code null} handler to use to post runnables to
* @param listener a non-{@code null} listener where {@code onDrained} will be called
* @param name an optional name used for debug logging
*/
- public TaskDrainer(Executor executor, DrainListener listener, String name) {
- mExecutor = checkNotNull(executor, "executor must not be null");
+ public TaskDrainer(Handler handler, DrainListener listener, String name) {
+ // XX: Probably don't need a handler at all here
+ mHandler = checkNotNull(handler, "handler must not be null");
mListener = checkNotNull(listener, "listener must not be null");
mName = name;
}
@@ -199,12 +200,15 @@
}
private void postDrained() {
- mExecutor.execute(() -> {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
if (DEBUG) {
Log.v(TAG + "[" + mName + "]", "onDrained");
}
mListener.onDrained();
+ }
});
}
}
diff --git a/core/java/android/hardware/camera2/utils/TaskSingleDrainer.java b/core/java/android/hardware/camera2/utils/TaskSingleDrainer.java
index 9615450..f6272c9 100644
--- a/core/java/android/hardware/camera2/utils/TaskSingleDrainer.java
+++ b/core/java/android/hardware/camera2/utils/TaskSingleDrainer.java
@@ -16,8 +16,7 @@
package android.hardware.camera2.utils;
import android.hardware.camera2.utils.TaskDrainer.DrainListener;
-
-import java.util.concurrent.Executor;
+import android.os.Handler;
/**
* Keep track of a single concurrent task starting and finishing;
@@ -39,25 +38,25 @@
/**
* Create a new task drainer; {@code onDrained} callbacks will be posted to the listener
- * via the {@code executor}.
+ * via the {@code handler}.
*
- * @param executor a non-{@code null} executor to use for listener execution
+ * @param handler a non-{@code null} handler to use to post runnables to
* @param listener a non-{@code null} listener where {@code onDrained} will be called
*/
- public TaskSingleDrainer(Executor executor, DrainListener listener) {
- mTaskDrainer = new TaskDrainer<>(executor, listener);
+ public TaskSingleDrainer(Handler handler, DrainListener listener) {
+ mTaskDrainer = new TaskDrainer<>(handler, listener);
}
/**
* Create a new task drainer; {@code onDrained} callbacks will be posted to the listener
- * via the {@code executor}.
+ * via the {@code handler}.
*
- * @param executor a non-{@code null} executor to use for listener execution
+ * @param handler a non-{@code null} handler to use to post runnables to
* @param listener a non-{@code null} listener where {@code onDrained} will be called
* @param name an optional name used for debug logging
*/
- public TaskSingleDrainer(Executor executor, DrainListener listener, String name) {
- mTaskDrainer = new TaskDrainer<>(executor, listener, name);
+ public TaskSingleDrainer(Handler handler, DrainListener listener, String name) {
+ mTaskDrainer = new TaskDrainer<>(handler, listener, name);
}
/**
diff --git a/core/java/android/net/INetdEventCallback.aidl b/core/java/android/net/INetdEventCallback.aidl
index 1fd9423..1e75bf4 100644
--- a/core/java/android/net/INetdEventCallback.aidl
+++ b/core/java/android/net/INetdEventCallback.aidl
@@ -20,8 +20,9 @@
oneway interface INetdEventCallback {
// Possible addNetdEventCallback callers.
- const int CALLBACK_CALLER_DEVICE_POLICY = 0;
- const int CALLBACK_CALLER_NETWORK_WATCHLIST = 1;
+ const int CALLBACK_CALLER_CONNECTIVITY_SERVICE = 0;
+ const int CALLBACK_CALLER_DEVICE_POLICY = 1;
+ const int CALLBACK_CALLER_NETWORK_WATCHLIST = 2;
/**
* Reports a single DNS lookup function call.
@@ -39,6 +40,18 @@
int uid);
/**
+ * Represents a private DNS validation success or failure.
+ * This method must not block or perform long-running operations.
+ *
+ * @param netId the ID of the network the validation was performed on.
+ * @param ipAddress the IP address for which validation was performed.
+ * @param hostname the hostname for which validation was performed.
+ * @param validated whether or not validation was successful.
+ */
+ void onPrivateDnsValidationEvent(int netId, String ipAddress, String hostname,
+ boolean validated);
+
+ /**
* Reports a single connect library call.
* This method must not block or perform long-running operations.
*
diff --git a/core/java/android/se/omapi/Session.java b/core/java/android/se/omapi/Session.java
index 19a018e..3d8b74b 100644
--- a/core/java/android/se/omapi/Session.java
+++ b/core/java/android/se/omapi/Session.java
@@ -301,12 +301,6 @@
* provide a new logical channel.
*/
public @Nullable Channel openLogicalChannel(byte[] aid, byte p2) throws IOException {
-
- if ((mReader.getName().startsWith("SIM")) && (aid == null)) {
- Log.e(TAG, "NULL AID not supported on " + mReader.getName());
- return null;
- }
-
if (!mService.isConnected()) {
throw new IllegalStateException("service not connected to system");
}
diff --git a/core/java/android/view/RemoteAnimationTarget.java b/core/java/android/view/RemoteAnimationTarget.java
index 75cdd49..5b2cc81 100644
--- a/core/java/android/view/RemoteAnimationTarget.java
+++ b/core/java/android/view/RemoteAnimationTarget.java
@@ -16,13 +16,26 @@
package android.view;
+import static android.app.RemoteAnimationTargetProto.CLIP_RECT;
+import static android.app.RemoteAnimationTargetProto.CONTENT_INSETS;
+import static android.app.RemoteAnimationTargetProto.IS_TRANSLUCENT;
+import static android.app.RemoteAnimationTargetProto.LEASH;
+import static android.app.RemoteAnimationTargetProto.MODE;
+import static android.app.RemoteAnimationTargetProto.POSITION;
+import static android.app.RemoteAnimationTargetProto.PREFIX_ORDER_INDEX;
+import static android.app.RemoteAnimationTargetProto.SOURCE_CONTAINER_BOUNDS;
+import static android.app.RemoteAnimationTargetProto.TASK_ID;
+import static android.app.RemoteAnimationTargetProto.WINDOW_CONFIGURATION;
+
import android.annotation.IntDef;
import android.app.WindowConfiguration;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Parcel;
import android.os.Parcelable;
+import android.util.proto.ProtoOutputStream;
+import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -164,6 +177,35 @@
dest.writeBoolean(isNotInRecents);
}
+ public void dump(PrintWriter pw, String prefix) {
+ pw.print(prefix); pw.print("mode="); pw.print(mode);
+ pw.print(" taskId="); pw.print(taskId);
+ pw.print(" isTranslucent="); pw.print(isTranslucent);
+ pw.print(" clipRect="); clipRect.printShortString(pw);
+ pw.print(" contentInsets="); contentInsets.printShortString(pw);
+ pw.print(" prefixOrderIndex="); pw.print(prefixOrderIndex);
+ pw.print(" position="); position.printShortString(pw);
+ pw.print(" sourceContainerBounds="); sourceContainerBounds.printShortString(pw);
+ pw.println();
+ pw.print(prefix); pw.print("windowConfiguration="); pw.println(windowConfiguration);
+ pw.print(prefix); pw.print("leash="); pw.println(leash);
+ }
+
+ public void writeToProto(ProtoOutputStream proto, long fieldId) {
+ final long token = proto.start(fieldId);
+ proto.write(TASK_ID, taskId);
+ proto.write(MODE, mode);
+ leash.writeToProto(proto, LEASH);
+ proto.write(IS_TRANSLUCENT, isTranslucent);
+ clipRect.writeToProto(proto, CLIP_RECT);
+ contentInsets.writeToProto(proto, CONTENT_INSETS);
+ proto.write(PREFIX_ORDER_INDEX, prefixOrderIndex);
+ position.writeToProto(proto, POSITION);
+ sourceContainerBounds.writeToProto(proto, SOURCE_CONTAINER_BOUNDS);
+ windowConfiguration.writeToProto(proto, WINDOW_CONFIGURATION);
+ proto.end(token);
+ }
+
public static final Creator<RemoteAnimationTarget> CREATOR
= new Creator<RemoteAnimationTarget>() {
public RemoteAnimationTarget createFromParcel(Parcel in) {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index bf0e2eb..b624870 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6546,7 +6546,7 @@
} finally {
// Set it to already called so it's not called twice when called by
// performClickInternal()
- mPrivateFlags |= ~PFLAG_NOTIFY_AUTOFILL_MANAGER_ON_CLICK;
+ mPrivateFlags &= ~PFLAG_NOTIFY_AUTOFILL_MANAGER_ON_CLICK;
}
}
}
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 6fe64a0..f77a6b7 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -291,6 +291,7 @@
* @attr ref android.R.styleable#TextView_drawableTintMode
* @attr ref android.R.styleable#TextView_lineSpacingExtra
* @attr ref android.R.styleable#TextView_lineSpacingMultiplier
+ * @attr ref android.R.styleable#TextView_justificationMode
* @attr ref android.R.styleable#TextView_marqueeRepeatLimit
* @attr ref android.R.styleable#TextView_inputType
* @attr ref android.R.styleable#TextView_imeOptions
diff --git a/core/java/com/android/internal/view/menu/MenuItemImpl.java b/core/java/com/android/internal/view/menu/MenuItemImpl.java
index 9d012de..0c5ea63 100644
--- a/core/java/com/android/internal/view/menu/MenuItemImpl.java
+++ b/core/java/com/android/internal/view/menu/MenuItemImpl.java
@@ -23,6 +23,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
+import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.Log;
@@ -33,6 +34,7 @@
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
+import android.view.ViewConfiguration;
import android.view.ViewDebug;
import android.widget.LinearLayout;
@@ -108,13 +110,6 @@
private CharSequence mContentDescription;
private CharSequence mTooltipText;
- private static String sLanguage;
- private static String sPrependShortcutLabel;
- private static String sEnterShortcutLabel;
- private static String sDeleteShortcutLabel;
- private static String sSpaceShortcutLabel;
-
-
/**
* Instantiates this menu item.
*
@@ -130,20 +125,6 @@
MenuItemImpl(MenuBuilder menu, int group, int id, int categoryOrder, int ordering,
CharSequence title, int showAsAction) {
- String lang = menu.getContext().getResources().getConfiguration().locale.toString();
- if (sPrependShortcutLabel == null || !lang.equals(sLanguage)) {
- sLanguage = lang;
- // This is instantiated from the UI thread, so no chance of sync issues
- sPrependShortcutLabel = menu.getContext().getResources().getString(
- com.android.internal.R.string.prepend_shortcut_label);
- sEnterShortcutLabel = menu.getContext().getResources().getString(
- com.android.internal.R.string.menu_enter_shortcut_label);
- sDeleteShortcutLabel = menu.getContext().getResources().getString(
- com.android.internal.R.string.menu_delete_shortcut_label);
- sSpaceShortcutLabel = menu.getContext().getResources().getString(
- com.android.internal.R.string.menu_space_shortcut_label);
- }
-
mMenu = menu;
mId = id;
mGroup = group;
@@ -353,19 +334,45 @@
return "";
}
- StringBuilder sb = new StringBuilder(sPrependShortcutLabel);
+ final Resources res = mMenu.getContext().getResources();
+
+ StringBuilder sb = new StringBuilder();
+ if (ViewConfiguration.get(mMenu.getContext()).hasPermanentMenuKey()) {
+ // Only prepend "Menu+" if there is a hardware menu key.
+ sb.append(res.getString(
+ com.android.internal.R.string.prepend_shortcut_label));
+ }
+
+ final int modifiers =
+ mMenu.isQwertyMode() ? mShortcutAlphabeticModifiers : mShortcutNumericModifiers;
+ appendModifier(sb, modifiers, KeyEvent.META_META_ON, res.getString(
+ com.android.internal.R.string.menu_meta_shortcut_label));
+ appendModifier(sb, modifiers, KeyEvent.META_CTRL_ON, res.getString(
+ com.android.internal.R.string.menu_ctrl_shortcut_label));
+ appendModifier(sb, modifiers, KeyEvent.META_ALT_ON, res.getString(
+ com.android.internal.R.string.menu_alt_shortcut_label));
+ appendModifier(sb, modifiers, KeyEvent.META_SHIFT_ON, res.getString(
+ com.android.internal.R.string.menu_shift_shortcut_label));
+ appendModifier(sb, modifiers, KeyEvent.META_SYM_ON, res.getString(
+ com.android.internal.R.string.menu_sym_shortcut_label));
+ appendModifier(sb, modifiers, KeyEvent.META_FUNCTION_ON, res.getString(
+ com.android.internal.R.string.menu_function_shortcut_label));
+
switch (shortcut) {
case '\n':
- sb.append(sEnterShortcutLabel);
+ sb.append(res.getString(
+ com.android.internal.R.string.menu_enter_shortcut_label));
break;
case '\b':
- sb.append(sDeleteShortcutLabel);
+ sb.append(res.getString(
+ com.android.internal.R.string.menu_delete_shortcut_label));
break;
case ' ':
- sb.append(sSpaceShortcutLabel);
+ sb.append(res.getString(
+ com.android.internal.R.string.menu_space_shortcut_label));
break;
default:
@@ -376,6 +383,12 @@
return sb.toString();
}
+ private static void appendModifier(StringBuilder sb, int mask, int modifier, String label) {
+ if ((mask & modifier) == modifier) {
+ sb.append(label);
+ }
+ }
+
/**
* @return Whether this menu item should be showing shortcuts (depends on
* whether the menu should show shortcuts and whether this item has
diff --git a/core/java/com/android/server/net/BaseNetdEventCallback.java b/core/java/com/android/server/net/BaseNetdEventCallback.java
index 3d3a3d0..fdba2f3 100644
--- a/core/java/com/android/server/net/BaseNetdEventCallback.java
+++ b/core/java/com/android/server/net/BaseNetdEventCallback.java
@@ -32,6 +32,12 @@
}
@Override
+ public void onPrivateDnsValidationEvent(int netId, String ipAddress,
+ String hostname, boolean validated) {
+ // default no-op
+ }
+
+ @Override
public void onConnectEvent(String ipAddr, int port, long timestamp, int uid) {
// default no-op
}
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index 5498a93..ce4e384 100755
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -921,6 +921,28 @@
SkBitmap skbitmap;
bitmap->getSkBitmap(&skbitmap);
+ if (skbitmap.colorType() == kRGBA_F16_SkColorType) {
+ // Convert to P3 before encoding. This matches SkAndroidCodec::computeOutputColorSpace
+ // for wide gamuts.
+ auto cs = SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
+ SkColorSpace::kDCIP3_D65_Gamut);
+ auto info = skbitmap.info().makeColorType(kRGBA_8888_SkColorType)
+ .makeColorSpace(std::move(cs));
+ SkBitmap p3;
+ if (!p3.tryAllocPixels(info)) {
+ return JNI_FALSE;
+ }
+ auto xform = SkColorSpaceXform::New(skbitmap.colorSpace(), info.colorSpace());
+ if (!xform) {
+ return JNI_FALSE;
+ }
+ if (!xform->apply(SkColorSpaceXform::kRGBA_8888_ColorFormat, p3.getPixels(),
+ SkColorSpaceXform::kRGBA_F16_ColorFormat, skbitmap.getPixels(),
+ info.width() * info.height(), kUnpremul_SkAlphaType)) {
+ return JNI_FALSE;
+ }
+ skbitmap = p3;
+ }
return SkEncodeImage(strm.get(), skbitmap, fm, quality) ? JNI_TRUE : JNI_FALSE;
}
diff --git a/core/proto/android/server/animationadapter.proto b/core/proto/android/server/animationadapter.proto
new file mode 100644
index 0000000..c4ffe8c
--- /dev/null
+++ b/core/proto/android/server/animationadapter.proto
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+syntax = "proto2";
+
+import "frameworks/base/core/proto/android/graphics/point.proto";
+import "frameworks/base/core/proto/android/view/remote_animation_target.proto";
+import "frameworks/base/libs/incident/proto/android/privacy.proto";
+
+package com.android.server.wm.proto;
+option java_multiple_files = true;
+
+message AnimationAdapterProto {
+ option (.android.msg_privacy).dest = DEST_AUTOMATIC;
+
+ optional LocalAnimationAdapterProto local = 1;
+ optional RemoteAnimationAdapterWrapperProto remote = 2;
+}
+
+/* represents RemoteAnimationAdapterWrapper */
+message RemoteAnimationAdapterWrapperProto {
+ option (.android.msg_privacy).dest = DEST_AUTOMATIC;
+
+ optional .android.view.RemoteAnimationTargetProto target = 1;
+}
+
+/* represents LocalAnimationAdapter */
+message LocalAnimationAdapterProto {
+ option (.android.msg_privacy).dest = DEST_AUTOMATIC;
+
+ optional AnimationSpecProto animation_spec = 1;
+}
+
+message AnimationSpecProto {
+ option (.android.msg_privacy).dest = DEST_AUTOMATIC;
+
+ optional WindowAnimationSpecProto window = 1;
+ optional MoveAnimationSpecProto move = 2;
+ optional AlphaAnimationSpecProto alpha = 3;
+}
+
+/* represents WindowAnimationSpec */
+message WindowAnimationSpecProto {
+ option (.android.msg_privacy).dest = DEST_AUTOMATIC;
+
+ optional string animation = 1;
+}
+
+/* represents MoveAnimationSpec*/
+message MoveAnimationSpecProto {
+ option (.android.msg_privacy).dest = DEST_AUTOMATIC;
+
+ optional .android.graphics.PointProto from = 1;
+ optional .android.graphics.PointProto to = 2;
+ optional int64 duration = 3;
+}
+
+/* represents AlphaAnimationSpec */
+message AlphaAnimationSpecProto {
+ option (.android.msg_privacy).dest = DEST_AUTOMATIC;
+
+ optional float from = 1;
+ optional float to = 2;
+ optional int64 duration = 3;
+}
\ No newline at end of file
diff --git a/core/proto/android/server/surfaceanimator.proto b/core/proto/android/server/surfaceanimator.proto
index 7f7839e..dcc2b34 100644
--- a/core/proto/android/server/surfaceanimator.proto
+++ b/core/proto/android/server/surfaceanimator.proto
@@ -16,6 +16,7 @@
syntax = "proto2";
+import "frameworks/base/core/proto/android/server/animationadapter.proto";
import "frameworks/base/core/proto/android/view/surfacecontrol.proto";
import "frameworks/base/libs/incident/proto/android/privacy.proto";
@@ -28,7 +29,8 @@
message SurfaceAnimatorProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
- optional string animation_adapter = 1;
+ reserved 1; // Was string animation_adapter = 1
optional .android.view.SurfaceControlProto leash = 2;
optional bool animation_start_delayed = 3;
+ optional AnimationAdapterProto animation_adapter = 4;
}
\ No newline at end of file
diff --git a/core/proto/android/view/remote_animation_target.proto b/core/proto/android/view/remote_animation_target.proto
new file mode 100644
index 0000000..d5da0a9
--- /dev/null
+++ b/core/proto/android/view/remote_animation_target.proto
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+syntax = "proto2";
+option java_package = "android.app";
+option java_multiple_files = true;
+
+package android.view;
+
+import "frameworks/base/core/proto/android/app/window_configuration.proto";
+import "frameworks/base/core/proto/android/graphics/point.proto";
+import "frameworks/base/core/proto/android/graphics/rect.proto";
+import "frameworks/base/core/proto/android/view/surfacecontrol.proto";
+import "frameworks/base/libs/incident/proto/android/privacy.proto";
+
+/** Proto representation for RemoteAnimationTarget.java class. */
+message RemoteAnimationTargetProto {
+ option (android.msg_privacy).dest = DEST_AUTOMATIC;
+
+ optional int32 task_id = 1;
+ optional int32 mode = 2;
+ optional .android.view.SurfaceControlProto leash = 3;
+ optional bool is_translucent = 4;
+ optional .android.graphics.RectProto clip_rect = 5;
+ optional .android.graphics.RectProto contentInsets = 6;
+ optional int32 prefix_order_index = 7;
+ optional .android.graphics.PointProto position = 8;
+ optional .android.graphics.RectProto source_container_bounds = 9;
+ optional .android.app.WindowConfigurationProto window_configuration = 10;
+}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index f521e4b..9b11a33 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2552,6 +2552,12 @@
<permission android:name="android.permission.MANAGE_APP_OPS_RESTRICTIONS"
android:protectionLevel="signature|installer" />
+ <!-- Allows an application to update the user app op modes.
+ Not for use by third party apps.
+ @hide -->
+ <permission android:name="android.permission.MANAGE_APP_OPS_MODES"
+ android:protectionLevel="signature|installer|verifier" />
+
<!-- @SystemApi Allows an application to open windows that are for use by parts
of the system user interface.
<p>Not for use by third-party applications.
@@ -3089,7 +3095,8 @@
<!-- Allows an application to collect usage infomation about brightness slider changes.
<p>Not for use by third-party applications.</p>
@hide
- @SystemApi -->
+ @SystemApi
+ @TestApi -->
<permission android:name="android.permission.BRIGHTNESS_SLIDER_USAGE"
android:protectionLevel="signature|privileged|development" />
@@ -3102,7 +3109,8 @@
<!-- Allows an application to modify the display brightness configuration
@hide
- @SystemApi -->
+ @SystemApi
+ @TestApi -->
<permission android:name="android.permission.CONFIGURE_DISPLAY_BRIGHTNESS"
android:protectionLevel="signature|privileged|development" />
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index dc937e6..93e765b 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -148,16 +148,16 @@
<string name="CLIRPermanent">You can\'t change the caller ID setting.</string>
<!-- Notification title to tell the user that data service is blocked by access control. -->
- <string name="RestrictedOnDataTitle">No data service</string>
+ <string name="RestrictedOnDataTitle">No mobile data service</string>
<!-- Notification title to tell the user that emergency calling is blocked by access control. -->
- <string name="RestrictedOnEmergencyTitle">No emergency calling</string>
+ <string name="RestrictedOnEmergencyTitle">Emergency calling unavailable</string>
<!-- Notification title to tell the user that normal service is blocked by access control. -->
<string name="RestrictedOnNormalTitle">No voice service</string>
<!-- Notification title to tell the user that all emergency and normal voice services are blocked by access control. -->
- <string name="RestrictedOnAllVoiceTitle">No voice/emergency service</string>
+ <string name="RestrictedOnAllVoiceTitle">No voice service or emergency calling</string>
<!-- Notification content to tell the user that voice/data/emergency service is blocked by access control. -->
- <string name="RestrictedStateContent">Temporarily not offered by the mobile network at your location</string>
+ <string name="RestrictedStateContent">Temporarily turned off by your carrier</string>
<!-- Displayed to tell the user that they should switch their network preference. -->
<string name="NetworkPreferenceSwitchTitle">Can\u2019t reach network</string>
@@ -352,9 +352,6 @@
<!-- Work profile deleted notification--> <skip />
<!-- Shows up in the notification's title when the system deletes the work profile. [CHAR LIMIT=NONE] -->
<string name="work_profile_deleted">Work profile deleted</string>
- <!-- Content text for a notification. The Title of the notification is "Work profile deleted".
- This says that the profile is deleted by the system as a result of the current profile owner gone missing. [CHAR LIMIT=100]-->
- <string name="work_profile_deleted_description">Work profile deleted due to missing admin app</string>
<!-- Content text for an expanded notification. The Title of the notification is "Work profile deleted".
This further explains that the profile is deleted by the system as a result of the current profile admin gone missing. [CHAR LIMIT=NONE]-->
<string name="work_profile_deleted_details">The work profile admin app is either missing or corrupted.
@@ -2447,6 +2444,18 @@
<string name="more_item_label">More</string>
<!-- Prepended to the shortcut for a menu item to indicate that the user should hold the MENU button together with the shortcut to invoke the item. For example, if the shortcut to open a new tab in browser is MENU and B together, then this would be prepended to the letter "B" -->
<string name="prepend_shortcut_label">Menu+</string>
+ <!-- Prepended to the shortcut for a menu item to indicate that the user should hold the META key together with the shortcut to invoke the item. -->
+ <string name="menu_meta_shortcut_label">Meta+</string>
+ <!-- Prepended to the shortcut for a menu item to indicate that the user should hold the CTRL key together with the shortcut to invoke the item. -->
+ <string name="menu_ctrl_shortcut_label">Ctrl+</string>
+ <!-- Prepended to the shortcut for a menu item to indicate that the user should hold the ALT key together with the shortcut to invoke the item. -->
+ <string name="menu_alt_shortcut_label">Alt+</string>
+ <!-- Prepended to the shortcut for a menu item to indicate that the user should hold the SHIFT key together with the shortcut to invoke the item. -->
+ <string name="menu_shift_shortcut_label">Shift+</string>
+ <!-- Prepended to the shortcut for a menu item to indicate that the user should hold the SYM key together with the shortcut to invoke the item. -->
+ <string name="menu_sym_shortcut_label">Sym+</string>
+ <!-- Prepended to the shortcut for a menu item to indicate that the user should hold the FUNCTION key together with the shortcut to invoke the item. -->
+ <string name="menu_function_shortcut_label">Function+</string>
<!-- Displayed in place of the regular shortcut letter when a menu item has Menu+space for the shortcut. -->
<string name="menu_space_shortcut_label">space</string>
<!-- Displayed in place of the regular shortcut letter when a menu item has Menu+enter for the shortcut. -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 97116f5..30193a8 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -528,9 +528,15 @@
<java-symbol type="string" name="delete" />
<java-symbol type="string" name="deleteText" />
<java-symbol type="string" name="grant_permissions_header_text" />
+ <java-symbol type="string" name="menu_alt_shortcut_label" />
+ <java-symbol type="string" name="menu_ctrl_shortcut_label" />
<java-symbol type="string" name="menu_delete_shortcut_label" />
<java-symbol type="string" name="menu_enter_shortcut_label" />
+ <java-symbol type="string" name="menu_function_shortcut_label" />
+ <java-symbol type="string" name="menu_meta_shortcut_label" />
<java-symbol type="string" name="menu_space_shortcut_label" />
+ <java-symbol type="string" name="menu_shift_shortcut_label" />
+ <java-symbol type="string" name="menu_sym_shortcut_label" />
<java-symbol type="string" name="notification_title" />
<java-symbol type="string" name="permission_request_notification_with_subtitle" />
<java-symbol type="string" name="prepend_shortcut_label" />
diff --git a/core/res/res/values/themes_device_defaults.xml b/core/res/res/values/themes_device_defaults.xml
index fdbcd8a..25b053b 100644
--- a/core/res/res/values/themes_device_defaults.xml
+++ b/core/res/res/values/themes_device_defaults.xml
@@ -1318,6 +1318,9 @@
<!-- Progress bar attributes -->
<item name="colorProgressBackgroundNormal">@color/config_progress_background_tint</item>
<item name="progressBarCornerRadius">@dimen/config_progressBarCornerRadius</item>
+
+ <!-- volume background -->
+ <item name="panelColorBackground">@color/primary_material_light</item>
</style>
<style name="Theme.DeviceDefault.QuickSettings.Dialog" parent="Theme.DeviceDefault.Light.Dialog">
diff --git a/core/tests/coretests/AndroidTest.xml b/core/tests/coretests/AndroidTest.xml
index 970a0f0..7b5ad9a 100644
--- a/core/tests/coretests/AndroidTest.xml
+++ b/core/tests/coretests/AndroidTest.xml
@@ -14,15 +14,16 @@
limitations under the License.
-->
<configuration description="Runs Frameworks Core Tests.">
- <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+ <option name="test-suite-tag" value="apct" />
+ <option name="test-suite-tag" value="apct-instrumentation" />
+
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
<option name="test-file-name" value="FrameworksCoreTests.apk" />
<option name="test-file-name" value="BstatsTestApp.apk" />
</target_preparer>
-
- <option name="test-suite-tag" value="apct" />
<option name="test-tag" value="FrameworksCoreTests" />
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="com.android.frameworks.coretests" />
- <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
</test>
</configuration>
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java
index f27c11d..20c22b7 100644
--- a/graphics/java/android/graphics/Typeface.java
+++ b/graphics/java/android/graphics/Typeface.java
@@ -167,10 +167,8 @@
nativeSetDefault(t.native_instance);
}
- // TODO: Make this public API. (b/64852739)
- /** @hide */
- @VisibleForTesting
- public int getWeight() {
+ /** Returns the typeface's weight value */
+ public @IntRange(from = 0, to = 1000) int getWeight() {
return mWeight;
}
@@ -883,6 +881,15 @@
}
/**
+ * This method is used by supportlib-v27.
+ * TODO: Remove private API use in supportlib: http://b/72665240
+ */
+ private static Typeface createFromFamiliesWithDefault(FontFamily[] families, int weight,
+ int italic) {
+ return createFromFamiliesWithDefault(families, DEFAULT_FAMILY, weight, italic);
+ }
+
+ /**
* Create a new typeface from an array of font families, including
* also the font families in the fallback list.
* @param fallbackName the family name. If given families don't support characters, the
diff --git a/media/java/android/media/MediaController2.java b/media/java/android/media/MediaController2.java
index 30b7f70..b51c662 100644
--- a/media/java/android/media/MediaController2.java
+++ b/media/java/android/media/MediaController2.java
@@ -156,17 +156,6 @@
@NonNull List<MediaItem2> playlist) { }
/**
- * Called when the playback state is changed.
- *
- * @param controller the controller for this event
- * @param state latest playback state
- * @hide
- */
- // TODO(jaewan): Remove (b/73971431)
- public void onPlaybackStateChanged(@NonNull MediaController2 controller,
- @NonNull PlaybackState2 state) { }
-
- /**
* Called when the player state is changed.
*
* @param controller the controller for this event
@@ -647,20 +636,6 @@
}
/**
- * Get the lastly cached {@link PlaybackState2} from
- * {@link ControllerCallback#onPlaybackStateChanged(MediaController2, PlaybackState2)}.
- * <p>
- * It may return {@code null} before the first callback or session has sent {@code null}
- * playback state.
- *
- * @return a playback state. Can be {@code null}
- * @hide
- */
- public @Nullable PlaybackState2 getPlaybackState() {
- return mProvider.getPlaybackState_impl();
- }
-
- /**
* Get the lastly cached player state from
* {@link ControllerCallback#onPlayerStateChanged(MediaController2, int)}.
*
diff --git a/media/java/android/media/MediaSession2.java b/media/java/android/media/MediaSession2.java
index ddecb95..91bface 100644
--- a/media/java/android/media/MediaSession2.java
+++ b/media/java/android/media/MediaSession2.java
@@ -16,6 +16,8 @@
package android.media;
+import static android.media.MediaPlayerBase.PLAYER_STATE_IDLE;
+
import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -180,16 +182,6 @@
public static final int COMMAND_CODE_PLAYBACK_ADJUST_VOLUME = 11;
/**
- * Command code for {@link MediaController2#setPlaylistParams(PlaylistParams)}.
- * <p>
- * Command would be sent directly to the player if the session doesn't reject the request
- * through the {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
- * @hide
- */
- // TODO(jaewan): Remove (b/74116823)
- public static final int COMMAND_CODE_PLAYBACK_SET_PLAYLIST_PARAMS = 12;
-
- /**
* Command code for {@link MediaController2#skipToPlaylistItem(MediaItem2)}.
* <p>
* Command would be sent directly to the playlist agent if the session doesn't reject the
@@ -312,6 +304,13 @@
public static final int COMMAND_CODE_PREPARE_FROM_SEARCH = 27;
/**
+ * Command code for {@link MediaController2#setRating(String, Rating2)}.
+ * @hide
+ */
+ // TODO(jaewan): Unhide
+ public static final int COMMAND_CODE_SET_RATING = 29;
+
+ /**
* Command code for {@link MediaBrowser2} specific functions that allows navigation and search
* from the {@link MediaLibraryService2}. This would be ignored for a {@link MediaSession2},
* not {@link android.media.MediaLibraryService2.MediaLibrarySession}.
@@ -323,11 +322,6 @@
/**
* @hide
*/
- public static final int COMMAND_CODE_MAX = 28;
-
- /**
- * @hide
- */
@IntDef({ERROR_CODE_UNKNOWN_ERROR, ERROR_CODE_APP_ERROR, ERROR_CODE_NOT_SUPPORTED,
ERROR_CODE_AUTHENTICATION_EXPIRED, ERROR_CODE_PREMIUM_ACCOUNT_REQUIRED,
ERROR_CODE_CONCURRENT_STREAM_LIMIT, ERROR_CODE_PARENTAL_CONTROL_RESTRICTED,
@@ -450,6 +444,13 @@
.createMediaSession2Command(this, COMMAND_CODE_CUSTOM, action, extras);
}
+ /**
+ * @hide
+ */
+ public CommandProvider getProvider() {
+ return mProvider;
+ }
+
public int getCommandCode() {
return mProvider.getCommandCode_impl();
}
@@ -508,6 +509,13 @@
.createMediaSession2CommandGroup(context, this, others);
}
+ /**
+ * @hide
+ */
+ public CommandGroup(@NonNull CommandGroupProvider provider) {
+ mProvider = provider;
+ }
+
public void addCommand(@NonNull Command command) {
mProvider.addCommand_impl(command);
}
@@ -620,7 +628,6 @@
* @see #COMMAND_CODE_PLAYBACK_REWIND
* @see #COMMAND_CODE_PLAYBACK_SEEK_TO
* @see #COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM
- * @see #COMMAND_CODE_PLAYBACK_SET_PLAYLIST_PARAMS
* @see #COMMAND_CODE_PLAYLIST_ADD_ITEM
* @see #COMMAND_CODE_PLAYLIST_REMOVE_ITEM
* @see #COMMAND_CODE_PLAYLIST_GET_LIST
@@ -1639,13 +1646,36 @@
}
/**
- * Return the {@link PlaybackState2} from the player.
+ * Get the player state.
*
- * @return playback state
+ * @return player state
* @hide
*/
- public PlaybackState2 getPlaybackState() {
- return mProvider.getPlaybackState_impl();
+ public @PlayerState int getPlayerState() {
+ // TODO(jaewan): implement this (b/74578458)
+ return PLAYER_STATE_IDLE;
+ }
+
+ /**
+ * Get the current position.
+ *
+ * @return position
+ * @hide
+ */
+ public long getCurrentPosition() {
+ // TODO(jaewan): implement this (b/74578458)
+ return -1;
+ }
+
+ /**
+ * Get the buffered position.
+ *
+ * @return buffered position
+ * @hide
+ */
+ public long getBufferedPosition() {
+ // TODO(jaewan): implement this (b/74578458)
+ return -1;
}
/**
diff --git a/media/java/android/media/PlaybackState2.java b/media/java/android/media/PlaybackState2.java
deleted file mode 100644
index afc2bfa..0000000
--- a/media/java/android/media/PlaybackState2.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright 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 android.media;
-
-import android.annotation.IntDef;
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.content.Context;
-import android.media.update.ApiLoader;
-import android.media.update.PlaybackState2Provider;
-import android.os.Bundle;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Playback state for a {@link MediaPlayerBase}, to be shared between {@link MediaSession2} and
- * {@link MediaController2}. This includes a playback state {@link #STATE_PLAYING},
- * the current playback position and extra.
- * @hide
- */
-// TODO(jaewan): Remove this (b/73971431)
-public final class PlaybackState2 {
- // Similar to the PlaybackState with following changes
- // - Not implement Parcelable and added from/toBundle()
- // - Removed playback state that doesn't match with the MediaPlayer2
- // Full list should be finalized when the MediaPlayer2 has getter for the playback state.
- // Here's table for the MP2 state and PlaybackState2.State.
- // +----------------------------------------+----------------------------------------+
- // | MediaPlayer2 state | Matching PlaybackState2.State |
- // | (Names are from MP2' Javadoc) | |
- // +----------------------------------------+----------------------------------------+
- // | Idle: Just finished creating MP2 | STATE_NONE |
- // | or reset() is called | |
- // +----------------------------------------+----------------------------------------+
- // | Initialized: setDataSource/Playlist | N/A (Session/Controller don't |
- // | | differentiate with Prepared) |
- // +----------------------------------------+----------------------------------------+
- // | Prepared: Prepared after initialized | STATE_PAUSED |
- // +----------------------------------------+----------------------------------------+
- // | Started: Started playback | STATE_PLAYING |
- // +----------------------------------------+----------------------------------------+
- // | Paused: Paused playback | STATE_PAUSED |
- // +----------------------------------------+----------------------------------------+
- // | PlaybackCompleted: Playback is done | STATE_PAUSED |
- // +----------------------------------------+----------------------------------------+
- // | Stopped: MP2.stop() is called. | STATE_STOPPED |
- // | prepare() is needed to play again | |
- // | (Seemingly the same as initialized | |
- // | because cannot set data source | |
- // | after this) | |
- // +----------------------------------------+----------------------------------------+
- // | Error: an API is called in a state | STATE_ERROR |
- // | that the API isn't supported | |
- // +----------------------------------------+----------------------------------------+
- // | End: MP2.close() is called to release | N/A (MediaSession will be gone) |
- // | MP2. Cannot be reused anymore | |
- // +----------------------------------------+----------------------------------------+
- // | Started, but | STATE_BUFFERING |
- // | EventCallback.onBufferingUpdate() | |
- // +----------------------------------------+----------------------------------------+
- // - Removed actions and custom actions.
- // - Removed error string
- // - Repeat mode / shuffle mode is now in the PlaylistParams
- /**
- * @hide
- */
- @IntDef({STATE_NONE, STATE_STOPPED, STATE_PAUSED, STATE_PLAYING, STATE_BUFFERING, STATE_ERROR})
- @Retention(RetentionPolicy.SOURCE)
- public @interface State {}
-
- /**
- * This is the default playback state and indicates that no media has been
- * added yet, or the performer has been reset and has no content to play.
- */
- public final static int STATE_NONE = 0;
-
- /**
- * State indicating this item is currently stopped.
- */
- public final static int STATE_STOPPED = 1;
-
- /**
- * State indicating this item is currently paused.
- */
- public final static int STATE_PAUSED = 2;
-
- /**
- * State indicating this item is currently playing.
- */
- public final static int STATE_PLAYING = 3;
-
- /**
- * State indicating this item is currently buffering and will begin playing
- * when enough data has buffered.
- */
- public final static int STATE_BUFFERING = 4;
-
- /**
- * State indicating this item is currently in an error state.
- */
- public final static int STATE_ERROR = 5;
-
- /**
- * Use this value for the position to indicate the position is not known.
- */
- public final static long PLAYBACK_POSITION_UNKNOWN = -1;
-
- private final PlaybackState2Provider mProvider;
-
- public PlaybackState2(@NonNull Context context, int state, long position, long updateTime,
- float speed, long bufferedPosition, long activeItemId) {
- mProvider = ApiLoader.getProvider(context).createPlaybackState2(context, this, state,
- position, updateTime, speed, bufferedPosition, activeItemId);
- }
-
- @Override
- public String toString() {
- return mProvider.toString_impl();
- }
-
- /**
- * Get the current state of playback. One of the following:
- * <ul>
- * <li> {@link PlaybackState2#STATE_NONE}</li>
- * <li> {@link PlaybackState2#STATE_STOPPED}</li>
- * <li> {@link PlaybackState2#STATE_PAUSED}</li>
- * <li> {@link PlaybackState2#STATE_PLAYING}</li>
- * <li> {@link PlaybackState2#STATE_BUFFERING}</li>
- * <li> {@link PlaybackState2#STATE_ERROR}</li>
- * </ul>
- */
- @State
- public int getState() {
- return mProvider.getState_impl();
- }
-
- /**
- * Get the current playback position in ms.
- */
- public long getPosition() {
- return mProvider.getPosition_impl();
- }
-
- /**
- * Get the current buffered position in ms. This is the farthest playback
- * point that can be reached from the current position using only buffered
- * content.
- */
- public long getBufferedPosition() {
- return mProvider.getBufferedPosition_impl();
- }
-
- /**
- * Get the current playback speed as a multiple of normal playback. This
- * should be negative when rewinding. A value of 1 means normal playback and
- * 0 means paused.
- *
- * @return The current speed of playback.
- */
- public float getPlaybackSpeed() {
- return mProvider.getPlaybackSpeed_impl();
- }
-
- /**
- * Get the elapsed real time at which position was last updated. If the
- * position has never been set this will return 0;
- *
- * @return The last time the position was updated.
- */
- public long getLastPositionUpdateTime() {
- return mProvider.getLastPositionUpdateTime_impl();
- }
-
- /**
- * Get the id of the currently active item in the playlist.
- *
- * @return The id of the currently active item in the queue
- */
- public long getCurrentPlaylistItemIndex() {
- return mProvider.getCurrentPlaylistItemIndex_impl();
- }
-
- /**
- * Returns this object as a bundle to share between processes.
- */
- public @NonNull Bundle toBundle() {
- return mProvider.toBundle_impl();
- }
-
- /**
- * Creates an instance from a bundle which is previously created by {@link #toBundle()}.
- *
- * @param context context
- * @param bundle A bundle created by {@link #toBundle()}.
- * @return A new {@link PlaybackState2} instance. Returns {@code null} if the given
- * {@param bundle} is null, or if the {@param bundle} has no playback state parameters.
- */
- public @Nullable static PlaybackState2 fromBundle(@NonNull Context context,
- @Nullable Bundle bundle) {
- return ApiLoader.getProvider(context).fromBundle_PlaybackState2(context, bundle);
- }
-}
diff --git a/media/java/android/media/session/MediaSessionManager.java b/media/java/android/media/session/MediaSessionManager.java
index 6b130cc..051321c 100644
--- a/media/java/android/media/session/MediaSessionManager.java
+++ b/media/java/android/media/session/MediaSessionManager.java
@@ -775,8 +775,7 @@
public void run() {
final Context context = mContext;
if (context != null) {
- ArrayList<MediaController> controllers
- = new ArrayList<MediaController>();
+ ArrayList<MediaController> controllers = new ArrayList<>();
int size = tokens.size();
for (int i = 0; i < size; i++) {
controllers.add(new MediaController(context, tokens.get(i)));
@@ -814,10 +813,16 @@
private final ISessionTokensListener.Stub mStub = new ISessionTokensListener.Stub() {
@Override
public void onSessionTokensChanged(final List<Bundle> bundles) {
- mExecutor.execute(() -> {
- List<SessionToken2> tokens = toTokenList(mContext, bundles);
- mListener.onSessionTokensChanged(tokens);
- });
+ final Executor executor = mExecutor;
+ if (executor != null) {
+ executor.execute(() -> {
+ final Context context = mContext;
+ final OnSessionTokensChangedListener listener = mListener;
+ if (context != null && listener != null) {
+ listener.onSessionTokensChanged(toTokenList(context, bundles));
+ }
+ });
+ }
}
};
diff --git a/media/java/android/media/update/MediaController2Provider.java b/media/java/android/media/update/MediaController2Provider.java
index c48f336..55672b6 100644
--- a/media/java/android/media/update/MediaController2Provider.java
+++ b/media/java/android/media/update/MediaController2Provider.java
@@ -16,7 +16,6 @@
package android.media.update;
-import android.annotation.NonNull;
import android.app.PendingIntent;
import android.media.AudioAttributes;
import android.media.MediaController2.PlaybackInfo;
@@ -24,7 +23,6 @@
import android.media.MediaMetadata2;
import android.media.MediaSession2.Command;
import android.media.MediaSession2.PlaylistParams;
-import android.media.PlaybackState2;
import android.media.Rating2;
import android.media.SessionToken2;
import android.net.Uri;
@@ -69,7 +67,6 @@
PlaylistParams getPlaylistParams_impl();
void setPlaylistParams_impl(PlaylistParams params);
- PlaybackState2 getPlaybackState_impl();
int getPlayerState_impl();
long getPosition_impl();
float getPlaybackSpeed_impl();
diff --git a/media/java/android/media/update/MediaSessionService2Provider.java b/media/java/android/media/update/MediaSessionService2Provider.java
index 8697e70..5eb6254 100644
--- a/media/java/android/media/update/MediaSessionService2Provider.java
+++ b/media/java/android/media/update/MediaSessionService2Provider.java
@@ -20,7 +20,6 @@
import android.content.Intent;
import android.media.MediaSession2;
import android.media.MediaSessionService2.MediaNotification;
-import android.media.PlaybackState2;
import android.os.IBinder;
/**
diff --git a/media/java/android/media/update/PlaybackState2Provider.java b/media/java/android/media/update/PlaybackState2Provider.java
deleted file mode 100644
index 66b8fa5..0000000
--- a/media/java/android/media/update/PlaybackState2Provider.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 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 android.media.update;
-
-import android.os.Bundle;
-
-/**
- * @hide
- */
-public interface PlaybackState2Provider {
- String toString_impl();
-
- int getState_impl();
-
- long getPosition_impl();
-
- long getBufferedPosition_impl();
-
- float getPlaybackSpeed_impl();
-
- long getLastPositionUpdateTime_impl();
-
- long getCurrentPlaylistItemIndex_impl();
-
- Bundle toBundle_impl();
-}
diff --git a/media/java/android/media/update/StaticProvider.java b/media/java/android/media/update/StaticProvider.java
index 53ced9c..f78d4a4 100644
--- a/media/java/android/media/update/StaticProvider.java
+++ b/media/java/android/media/update/StaticProvider.java
@@ -19,7 +19,6 @@
import android.annotation.Nullable;
import android.app.Notification;
import android.content.Context;
-import android.media.DataSourceDesc;
import android.media.MediaBrowser2;
import android.media.MediaBrowser2.BrowserCallback;
import android.media.MediaController2;
@@ -32,12 +31,10 @@
import android.media.MediaMetadata2;
import android.media.MediaPlaylistAgent;
import android.media.MediaSession2;
-import android.media.MediaSession2.CommandButton.Builder;
import android.media.MediaSession2.PlaylistParams;
import android.media.MediaSession2.SessionCallback;
import android.media.MediaSessionService2;
import android.media.MediaSessionService2.MediaNotification;
-import android.media.PlaybackState2;
import android.media.Rating2;
import android.media.SessionToken2;
import android.media.VolumeProvider2;
@@ -132,10 +129,6 @@
Rating2 newStarRating_Rating2(Context context, int starRatingStyle, float starRating);
Rating2 newPercentageRating_Rating2(Context context, float percent);
- PlaybackState2Provider createPlaybackState2(Context context, PlaybackState2 instance, int state,
- long position, long updateTime, float speed, long bufferedPosition, long activeItemId);
- PlaybackState2 fromBundle_PlaybackState2(Context context, Bundle bundle);
-
MediaPlaylistAgentProvider createMediaPlaylistAgent(Context context,
MediaPlaylistAgent instance);
}
diff --git a/media/java/android/media/update/TransportControlProvider.java b/media/java/android/media/update/TransportControlProvider.java
index a3fb071..eb03ca7 100644
--- a/media/java/android/media/update/TransportControlProvider.java
+++ b/media/java/android/media/update/TransportControlProvider.java
@@ -17,7 +17,6 @@
package android.media.update;
import android.media.MediaItem2;
-import android.media.PlaybackState2;
/**
* @hide
@@ -34,6 +33,4 @@
void rewind_impl();
void seekTo_impl(long pos);
void skipToPlaylistItem_impl(MediaItem2 item);
-
- PlaybackState2 getPlaybackState_impl();
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
index 2482095..085e112 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
@@ -563,8 +563,7 @@
// If there were no scan results, create an AP for the currently connected network (if
// it exists).
- // TODO(sghuman): Investigate if this works for an ephemeral (auto-connected) network
- // when there are no scan results, as it may not have a valid WifiConfiguration
+ // TODO(b/b/73076869): Add support for passpoint (ephemeral) networks
if (accessPoints.isEmpty() && connectionConfig != null) {
AccessPoint activeAp = new AccessPoint(mContext, connectionConfig);
activeAp.update(connectionConfig, mLastInfo, mLastNetworkInfo);
diff --git a/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/AccessPointTest.java b/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/AccessPointTest.java
index 54c02a2..e435a72 100644
--- a/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/AccessPointTest.java
+++ b/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/AccessPointTest.java
@@ -18,9 +18,11 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -50,6 +52,7 @@
import android.text.style.TtsSpan;
import com.android.settingslib.R;
+import com.android.settingslib.utils.ThreadUtils;
import com.android.settingslib.wifi.AccessPoint.Speed;
import org.junit.Before;
@@ -61,6 +64,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.concurrent.CountDownLatch;
@SmallTest
@RunWith(AndroidJUnit4.class)
@@ -79,6 +83,8 @@
private Context mContext;
@Mock private RssiCurve mockBadgeCurve;
@Mock private WifiNetworkScoreCache mockWifiNetworkScoreCache;
+ public static final int NETWORK_ID = 123;
+ public static final int DEFAULT_RSSI = -55;
private static ScanResult createScanResult(String ssid, String bssid, int rssi) {
ScanResult scanResult = new ScanResult();
@@ -753,16 +759,15 @@
assertThat(ap.update(config, wifiInfo, newInfo)).isFalse();
}
@Test
- public void testUpdateWithConfigChangeOnly_returnsFalseButInvokesListener() {
- int networkId = 123;
- int rssi = -55;
+ public void testUpdateWithConfigChangeOnly_returnsFalseButInvokesListener()
+ throws InterruptedException {
WifiConfiguration config = new WifiConfiguration();
- config.networkId = networkId;
+ config.networkId = NETWORK_ID;
config.numNoInternetAccessReports = 1;
WifiInfo wifiInfo = new WifiInfo();
- wifiInfo.setNetworkId(networkId);
- wifiInfo.setRssi(rssi);
+ wifiInfo.setNetworkId(NETWORK_ID);
+ wifiInfo.setRssi(DEFAULT_RSSI);
NetworkInfo networkInfo =
new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0 /* subtype */, "WIFI", "");
@@ -770,8 +775,8 @@
AccessPoint ap = new TestAccessPointBuilder(mContext)
.setNetworkInfo(networkInfo)
- .setNetworkId(networkId)
- .setRssi(rssi)
+ .setNetworkId(NETWORK_ID)
+ .setRssi(DEFAULT_RSSI)
.setWifiInfo(wifiInfo)
.build();
@@ -781,18 +786,131 @@
config.validatedInternetAccess = true;
assertThat(ap.update(newConfig, wifiInfo, networkInfo)).isFalse();
+
+ // Wait for MainHandler to process callback
+ CountDownLatch latch = new CountDownLatch(1);
+ ThreadUtils.postOnMainThread(latch::countDown);
+
+ latch.await();
verify(mockListener).onAccessPointChanged(ap);
}
@Test
- public void testUpdateWithNullWifiConfiguration_doesNotThrowNPE() {
- int networkId = 123;
- int rssi = -55;
+ public void testConnectionInfo_doesNotThrowNPE_ifListenerIsNulledWhileAwaitingExecution()
+ throws InterruptedException {
WifiConfiguration config = new WifiConfiguration();
- config.networkId = networkId;
+ config.networkId = NETWORK_ID;
+ config.numNoInternetAccessReports = 1;
+
WifiInfo wifiInfo = new WifiInfo();
- wifiInfo.setNetworkId(networkId);
- wifiInfo.setRssi(rssi);
+ wifiInfo.setNetworkId(NETWORK_ID);
+ wifiInfo.setRssi(DEFAULT_RSSI);
+
+ NetworkInfo networkInfo =
+ new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0 /* subtype */, "WIFI", "");
+ networkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, "", "");
+
+ AccessPoint ap = new TestAccessPointBuilder(mContext)
+ .setNetworkInfo(networkInfo)
+ .setNetworkId(NETWORK_ID)
+ .setRssi(DEFAULT_RSSI)
+ .setWifiInfo(wifiInfo)
+ .build();
+
+ WifiConfiguration newConfig = new WifiConfiguration(config);
+ config.validatedInternetAccess = true;
+
+ performGivenUpdateAndThenNullListenerBeforeResumingMainHandlerExecution(
+ ap, () -> assertThat(ap.update(newConfig, wifiInfo, networkInfo)).isFalse());
+
+ }
+
+ private void performGivenUpdateAndThenNullListenerBeforeResumingMainHandlerExecution(
+ AccessPoint ap, Runnable r) {
+ AccessPoint.AccessPointListener mockListener = mock(AccessPoint.AccessPointListener.class);
+ ap.setListener(mockListener);
+
+ // Put a latch on the MainHandler to prevent the callback from being invoked instantly
+ CountDownLatch latch1 = new CountDownLatch(1);
+ ThreadUtils.postOnMainThread(() -> {
+ try{
+ latch1.await();
+ } catch (InterruptedException e) {
+ fail("Interruped Exception thrown while awaiting latch countdown");
+ }
+ });
+
+ r.run();
+
+ ap.setListener(null);
+ latch1.countDown();
+
+ // The second latch ensures the previously posted listener invocation has processed on the
+ // main thread.
+ CountDownLatch latch2 = new CountDownLatch(1);
+ ThreadUtils.postOnMainThread(latch2::countDown);
+
+ try{
+ latch2.await();
+ } catch (InterruptedException e) {
+ fail("Interruped Exception thrown while awaiting latch countdown");
+ }
+ }
+
+ @Test
+ public void testUpdateScanResults_doesNotThrowNPE_ifListenerIsNulledWhileAwaitingExecution()
+ throws InterruptedException {
+ String ssid = "ssid";
+ int newRssi = -80;
+ AccessPoint ap = new TestAccessPointBuilder(mContext).setSsid(ssid).build();
+
+ ScanResult scanResult = new ScanResult();
+ scanResult.SSID = ssid;
+ scanResult.level = newRssi;
+ scanResult.BSSID = "bssid";
+ scanResult.timestamp = SystemClock.elapsedRealtime() * 1000;
+ scanResult.capabilities = "";
+
+ performGivenUpdateAndThenNullListenerBeforeResumingMainHandlerExecution(
+ ap, () -> ap.setScanResults(Collections.singletonList(scanResult)));
+ }
+
+ @Test
+ public void testUpdateConfig_doesNotThrowNPE_ifListenerIsNulledWhileAwaitingExecution()
+ throws InterruptedException {
+ WifiConfiguration config = new WifiConfiguration();
+ config.networkId = NETWORK_ID;
+ config.numNoInternetAccessReports = 1;
+
+ WifiInfo wifiInfo = new WifiInfo();
+ wifiInfo.setNetworkId(NETWORK_ID);
+ wifiInfo.setRssi(DEFAULT_RSSI);
+
+ NetworkInfo networkInfo =
+ new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0 /* subtype */, "WIFI", "");
+ networkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, "", "");
+
+ AccessPoint ap = new TestAccessPointBuilder(mContext)
+ .setNetworkInfo(networkInfo)
+ .setNetworkId(NETWORK_ID)
+ .setRssi(DEFAULT_RSSI)
+ .setWifiInfo(wifiInfo)
+ .build();
+
+ WifiConfiguration newConfig = new WifiConfiguration(config);
+ config.validatedInternetAccess = true;
+
+ performGivenUpdateAndThenNullListenerBeforeResumingMainHandlerExecution(
+ ap, () -> ap.update(newConfig));
+ }
+
+ @Test
+ public void testUpdateWithNullWifiConfiguration_doesNotThrowNPE() {
+ WifiConfiguration config = new WifiConfiguration();
+ config.networkId = NETWORK_ID;
+ WifiInfo wifiInfo = new WifiInfo();
+ wifiInfo.setNetworkId(NETWORK_ID);
+ wifiInfo.setRssi(DEFAULT_RSSI);
NetworkInfo networkInfo =
new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0 /* subtype */, "WIFI", "");
@@ -800,8 +918,8 @@
AccessPoint ap = new TestAccessPointBuilder(mContext)
.setNetworkInfo(networkInfo)
- .setNetworkId(networkId)
- .setRssi(rssi)
+ .setNetworkId(NETWORK_ID)
+ .setRssi(DEFAULT_RSSI)
.setWifiInfo(wifiInfo)
.build();
@@ -847,34 +965,34 @@
.thenReturn(buildScoredNetworkWithGivenBadgeCurve(badgeCurve2));
ap.update(
- mockWifiNetworkScoreCache, true /* scoringUiEnabled */, MAX_SCORE_CACHE_AGE_MILLIS);
+ mockWifiNetworkScoreCache, true /* scoringUiEnabled */, MAX_SCORE_CACHE_AGE_MILLIS);
assertThat(ap.getSpeed()).isEqualTo(speed1);
}
@Test
public void testSpeedLabelFallbackScoreIgnoresNullCurves() {
- int rssi = -55;
String bssid = "00:00:00:00:00:00";
- int networkId = 123;
WifiInfo info = new WifiInfo();
- info.setRssi(rssi);
+ info.setRssi(DEFAULT_RSSI);
info.setSSID(WifiSsid.createFromAsciiEncoded(TEST_SSID));
info.setBSSID(bssid);
- info.setNetworkId(networkId);
+ info.setNetworkId(NETWORK_ID);
ArrayList<ScanResult> scanResults = new ArrayList<>();
- ScanResult scanResultUnconnected = createScanResult(TEST_SSID, "11:11:11:11:11:11", rssi);
+ ScanResult scanResultUnconnected =
+ createScanResult(TEST_SSID, "11:11:11:11:11:11", DEFAULT_RSSI);
scanResults.add(scanResultUnconnected);
- ScanResult scanResultConnected = createScanResult(TEST_SSID, bssid, rssi);
+ ScanResult scanResultConnected =
+ createScanResult(TEST_SSID, bssid, DEFAULT_RSSI);
scanResults.add(scanResultConnected);
AccessPoint ap =
new TestAccessPointBuilder(mContext)
.setActive(true)
- .setNetworkId(networkId)
+ .setNetworkId(NETWORK_ID)
.setSsid(TEST_SSID)
.setScanResults(scanResults)
.setWifiInfo(info)
diff --git a/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/WifiTrackerTest.java b/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/WifiTrackerTest.java
index ca965f3..7fb4dc5 100644
--- a/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/WifiTrackerTest.java
+++ b/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/WifiTrackerTest.java
@@ -721,7 +721,7 @@
// mStaleAccessPoints is true
verify(mockWifiListenerExecutor, never()).onAccessPointsChanged();
- assertThat(tracker.getAccessPoints().size()).isEqualTo(1);
+ assertThat(tracker.getAccessPoints()).hasSize(1);
assertThat(tracker.getAccessPoints().get(0).isActive()).isTrue();
}
diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml
index 937b939..589ae2a 100644
--- a/packages/Shell/AndroidManifest.xml
+++ b/packages/Shell/AndroidManifest.xml
@@ -118,6 +118,7 @@
<uses-permission android:name="android.permission.REGISTER_CONNECTION_MANAGER" />
<uses-permission android:name="android.permission.REGISTER_SIM_SUBSCRIPTION" />
<uses-permission android:name="android.permission.GET_APP_OPS_STATS" />
+ <uses-permission android:name="android.permission.MANAGE_APP_OPS_MODES" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.MANAGE_ACTIVITY_STACKS" />
<uses-permission android:name="android.permission.ACTIVITY_EMBEDDING" />
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavGesture.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavGesture.java
index 6131acc..aa2fb32 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavGesture.java
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavGesture.java
@@ -16,6 +16,7 @@
import android.graphics.Canvas;
import android.view.MotionEvent;
+import android.view.View;
import com.android.systemui.plugins.Plugin;
import com.android.systemui.plugins.annotations.ProvidesInterface;
@@ -42,6 +43,8 @@
public void onLayout(boolean changed, int left, int top, int right, int bottom);
+ public void onNavigationButtonLongPress(View v);
+
public default void destroy() { }
}
diff --git a/packages/SystemUI/res/drawable/rounded_bg_bottom_background.xml b/packages/SystemUI/res/drawable/rounded_bg_bottom_background.xml
index 8d03ce7..622226f 100644
--- a/packages/SystemUI/res/drawable/rounded_bg_bottom_background.xml
+++ b/packages/SystemUI/res/drawable/rounded_bg_bottom_background.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
- <solid android:color="@*android:color/material_grey_200" />
+ <solid android:color="?android:attr/panelColorBackground" />
<corners
android:bottomLeftRadius="@dimen/corner_size"
android:topLeftRadius="0dp"
diff --git a/packages/SystemUI/res/layout/volume_dialog.xml b/packages/SystemUI/res/layout/volume_dialog.xml
index 0063f6a..0a3f4eb 100644
--- a/packages/SystemUI/res/layout/volume_dialog.xml
+++ b/packages/SystemUI/res/layout/volume_dialog.xml
@@ -73,17 +73,19 @@
<!-- volume rows added and removed here! :-) -->
</LinearLayout>
<FrameLayout
- android:layout_height="wrap_content"
+ android:id="@+id/settings_container"
android:layout_width="match_parent"
+ android:layout_height="wrap_content"
android:background="@drawable/rounded_bg_bottom_background">
<com.android.keyguard.AlphaOptimizedImageButton
android:id="@+id/settings"
- android:src="@drawable/ic_settings"
+ android:src="@drawable/ic_settings_16dp"
android:layout_width="@dimen/volume_dialog_tap_target_size"
android:layout_height="@dimen/volume_dialog_tap_target_size"
android:layout_gravity="center"
+ android:contentDescription="@string/accessibility_volume_settings"
android:background="?android:selectableItemBackgroundBorderless"
- android:tint="#8A000000"
+ android:tint="?android:attr/colorControlNormal"
android:soundEffectsEnabled="false" />
</FrameLayout>
</LinearLayout>
diff --git a/packages/SystemUI/res/layout/volume_dialog_row.xml b/packages/SystemUI/res/layout/volume_dialog_row.xml
index def6f6b..bcc3692 100644
--- a/packages/SystemUI/res/layout/volume_dialog_row.xml
+++ b/packages/SystemUI/res/layout/volume_dialog_row.xml
@@ -25,7 +25,6 @@
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
- android:layout_marginTop="@dimen/volume_dialog_slider_margin_top"
android:gravity="center"
android:layout_gravity="center"
android:orientation="vertical" >
@@ -42,6 +41,8 @@
<FrameLayout
android:id="@+id/volume_row_slider_frame"
android:layout_width="match_parent"
+ android:layout_marginTop="@dimen/volume_dialog_slider_margin_top"
+ android:layout_marginBottom="@dimen/volume_dialog_slider_margin_bottom"
android:layoutDirection="rtl"
android:layout_height="@dimen/volume_dialog_slider_height">
<SeekBar
@@ -60,6 +61,7 @@
android:layout_width="@dimen/volume_dialog_tap_target_size"
android:layout_height="@dimen/volume_dialog_tap_target_size"
android:background="?android:selectableItemBackgroundBorderless"
+ android:layout_marginBottom="@dimen/volume_dialog_row_margin_bottom"
android:tint="@color/accent_tint_color_selector"
android:soundEffectsEnabled="false" />
</LinearLayout>
diff --git a/packages/SystemUI/res/values-fr/strings.xml b/packages/SystemUI/res/values-fr/strings.xml
index 12fccd4..4d6509d 100644
--- a/packages/SystemUI/res/values-fr/strings.xml
+++ b/packages/SystemUI/res/values-fr/strings.xml
@@ -401,9 +401,9 @@
<string name="interruption_level_none_twoline" msgid="3957581548190765889">"Aucune\ninterruption"</string>
<string name="interruption_level_priority_twoline" msgid="1564715335217164124">"Priorité\nuniquement"</string>
<string name="interruption_level_alarms_twoline" msgid="3266909566410106146">"Alarmes\nuniquement"</string>
- <string name="keyguard_indication_charging_time" msgid="2056340799276374421">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Rechargement… (rechargé à 100 % dans <xliff:g id="CHARGING_TIME_LEFT">%s</xliff:g>)"</string>
- <string name="keyguard_indication_charging_time_fast" msgid="7767562163577492332">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Rechargement rapide… (à 100 % dans <xliff:g id="CHARGING_TIME_LEFT">%s</xliff:g>)"</string>
- <string name="keyguard_indication_charging_time_slowly" msgid="3769655133567307069">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Rechargement lent… (à 100 % dans <xliff:g id="CHARGING_TIME_LEFT">%s</xliff:g>)"</string>
+ <string name="keyguard_indication_charging_time" msgid="2056340799276374421">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Rechargement… (rechargé à 100 %% dans <xliff:g id="CHARGING_TIME_LEFT">%s</xliff:g>)"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="7767562163577492332">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Rechargement rapide… (à 100 %% dans <xliff:g id="CHARGING_TIME_LEFT">%s</xliff:g>)"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="3769655133567307069">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Rechargement lent… (à 100 %% dans <xliff:g id="CHARGING_TIME_LEFT">%s</xliff:g>)"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="7305948938141024937">"Changer d\'utilisateur"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="8434880595284601601">"Changer d\'utilisateur (utilisateur actuel : <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>)"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="1424081831468083402">"Utilisateur actuel : <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 52b053b..e30b86a 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -270,7 +270,7 @@
<dimen name="volume_dialog_panel_width">64dp</dimen>
- <dimen name="volume_dialog_slider_height">101dp</dimen>
+ <dimen name="volume_dialog_slider_height">108dp</dimen>
<dimen name="volume_dialog_row_height">252dp</dimen>
@@ -280,7 +280,13 @@
<dimen name="volume_dialog_spacer">4dp</dimen>
- <dimen name="volume_dialog_slider_margin_top">13dp</dimen>
+ <dimen name="volume_dialog_slider_margin_top">22dp</dimen>
+
+ <dimen name="volume_dialog_slider_margin_bottom">-2dp</dimen>
+
+ <dimen name="volume_dialog_row_margin_bottom">8dp</dimen>
+
+ <dimen name="volume_dialog_settings_icon_size">16dp</dimen>
<!-- Gravity for the notification panel -->
<integer name="notification_panel_layout_gravity">0x31</integer><!-- center_horizontal|top -->
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index b7c1c55..814b3ef 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -377,6 +377,9 @@
<!-- Content description of the data connection type 3.5G. [CHAR LIMIT=NONE] -->
<string name="data_connection_3_5g">3.5G</string>
+ <!-- Content description of the data connection type 3.5G+. [CHAR LIMIT=NONE] -->
+ <string name="data_connection_3_5g_plus">3.5G+</string>
+
<!-- Content description of the data connection type 4G . [CHAR LIMIT=NONE] -->
<string name="data_connection_4g">4G</string>
@@ -1271,6 +1274,9 @@
<!-- Button label for ending zen mode in the volume dialog -->
<string name="volume_zen_end_now">Turn off now</string>
+ <!-- Content description for accessibility (not shown on the screen): volume dialog settings button. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_volume_settings">Sound settings</string>
+
<!-- Content description for accessibility (not shown on the screen): volume dialog expand button. [CHAR LIMIT=NONE] -->
<string name="accessibility_volume_expand">Expand</string>
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl
index ef36610..8612445 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl
@@ -80,4 +80,17 @@
* Sent when overview is to be hidden.
*/
void onOverviewHidden(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
+
+ /**
+ * Sent when a user swipes up over the navigation bar to launch overview. Swipe up is determined
+ * by passing the touch slop in the direction towards launcher from navigation bar. During and
+ * after this event is sent the caller will continue to send motion events. The motion
+ * {@param event} passed after the touch slop was exceeded will also be passed after by
+ * {@link onMotionEvent}. Since motion events will be sent, motion up or cancel can still be
+ * sent to cancel overview regardless the current state of launcher (eg. if overview is already
+ * visible, this event will still be sent if user swipes up). When this signal is sent,
+ * navigation bar will not handle any gestures such as quick scrub or switch and the home button
+ * will cancel (long) press.
+ */
+ void onQuickStep(in MotionEvent event);
}
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl
index 846aadd..4799f39 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl
@@ -36,11 +36,6 @@
void startScreenPinning(int taskId) = 1;
/**
- * Called when the overview service has started the recents animation.
- */
- void onRecentsAnimationStarted() = 2;
-
- /**
* Specifies the text to be shown for onboarding the new swipe-up gesture to access recents.
*/
void setRecentsOnboardingText(CharSequence text) = 3;
diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java
index cad155c..5fce0a6 100644
--- a/packages/SystemUI/src/com/android/systemui/Dependency.java
+++ b/packages/SystemUI/src/com/android/systemui/Dependency.java
@@ -45,6 +45,7 @@
import com.android.systemui.power.PowerNotificationWarnings;
import com.android.systemui.power.PowerUI;
import com.android.systemui.statusbar.AppOpsListener;
+import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.phone.ConfigurationControllerImpl;
import com.android.systemui.statusbar.phone.DarkIconDispatcherImpl;
import com.android.systemui.statusbar.phone.LightBarController;
@@ -317,6 +318,8 @@
mProviders.put(AppOpsListener.class, () -> new AppOpsListener(mContext));
+ mProviders.put(VibratorHelper.class, () -> new VibratorHelper(mContext));
+
// Put all dependencies above here so the factory can override them if it wants.
SystemUIFactory.getInstance().injectDependencies(mProviders, mContext);
}
diff --git a/packages/SystemUI/src/com/android/systemui/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/OverviewProxyService.java
index 041af0e..a4af6b2 100644
--- a/packages/SystemUI/src/com/android/systemui/OverviewProxyService.java
+++ b/packages/SystemUI/src/com/android/systemui/OverviewProxyService.java
@@ -102,15 +102,6 @@
}
}
- public void onRecentsAnimationStarted() {
- long token = Binder.clearCallingIdentity();
- try {
- mHandler.post(OverviewProxyService.this::notifyRecentsAnimationStarted);
- } finally {
- Binder.restoreCallingIdentity(token);
- }
- }
-
public void onSplitScreenInvoked() {
long token = Binder.clearCallingIdentity();
try {
@@ -283,9 +274,9 @@
}
}
- private void notifyRecentsAnimationStarted() {
+ public void notifyQuickStepStarted() {
for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
- mConnectionCallbacks.get(i).onRecentsAnimationStarted();
+ mConnectionCallbacks.get(i).onQuickStepStarted();
}
}
@@ -300,7 +291,7 @@
public interface OverviewProxyListener {
default void onConnectionChanged(boolean isConnected) {}
- default void onRecentsAnimationStarted() {}
+ default void onQuickStepStarted() {}
default void onInteractionFlagsChanged(@InteractionType int flags) {}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsOnboarding.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsOnboarding.java
index d9359a4..c348187 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsOnboarding.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsOnboarding.java
@@ -189,7 +189,7 @@
}
}
- public void onRecentsAnimationStarted() {
+ public void onQuickStepStarted() {
boolean alreadySeenRecentsOnboarding = Prefs.getBoolean(mContext,
Prefs.Key.HAS_SEEN_RECENTS_ONBOARDING, false);
if (!alreadySeenRecentsOnboarding) {
diff --git a/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java b/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
index 406eef8..f2a7adf 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
+++ b/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
@@ -368,7 +368,9 @@
} else {
final int val = value + mMinimumBacklight;
if (stopTracking) {
- MetricsLogger.action(mContext, MetricsEvent.ACTION_BRIGHTNESS, val);
+ final int metric = mAutomatic ?
+ MetricsEvent.ACTION_BRIGHTNESS_AUTO : MetricsEvent.ACTION_BRIGHTNESS;
+ MetricsLogger.action(mContext, metric, val);
}
setBrightness(val);
if (!tracking) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index ca66e98..0716b37 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -55,6 +55,7 @@
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout;
@@ -912,4 +913,16 @@
return (secure && !canSkipBouncer) ? SECURE_CAMERA_INTENT : INSECURE_CAMERA_INTENT;
}
}
+
+ @Override
+ public WindowInsets onApplyWindowInsets(WindowInsets insets) {
+ int bottom = insets.getDisplayCutout() != null
+ ? insets.getDisplayCutout().getSafeInsetBottom() : 0;
+ if (isPaddingRelative()) {
+ setPaddingRelative(getPaddingStart(), getPaddingTop(), getPaddingEnd(), bottom);
+ } else {
+ setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), bottom);
+ }
+ return insets;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
index 1109955..010b165 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
@@ -157,7 +157,7 @@
public void onFullyHidden() {
if (!mShowingSoon) {
cancelShowRunnable();
- inflateView();
+ mRoot.setVisibility(View.INVISIBLE);
mFalsingManager.onBouncerHidden();
}
}
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 9fa06f7..ce8e746 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
@@ -175,8 +175,8 @@
}
@Override
- public void onRecentsAnimationStarted() {
- mNavigationBarView.setRecentsAnimationStarted(true);
+ public void onQuickStepStarted() {
+ mNavigationBarView.onQuickStepStarted();
// Use navbar dragging as a signal to hide the rotate button
setRotateSuggestionButtonState(false);
@@ -751,6 +751,7 @@
if (shouldDisableNavbarGestures()) {
return false;
}
+ mNavigationBarView.onNavigationButtonLongPress(v);
mMetricsLogger.action(MetricsEvent.ACTION_ASSIST_LONG_PRESS);
mAssistManager.startAssist(new Bundle() /* args */);
mStatusBar.awakenDreams();
@@ -787,10 +788,12 @@
}
private boolean onLongPressBackHome(View v) {
+ mNavigationBarView.onNavigationButtonLongPress(v);
return onLongPressNavigationButtons(v, R.id.back, R.id.home);
}
private boolean onLongPressBackRecents(View v) {
+ mNavigationBarView.onNavigationButtonLongPress(v);
return onLongPressNavigationButtons(v, R.id.back, R.id.recent_apps);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
index 6a1ed51..cd000fe 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
@@ -19,31 +19,22 @@
import static android.view.WindowManager.DOCKED_INVALID;
import static android.view.WindowManager.DOCKED_LEFT;
import static android.view.WindowManager.DOCKED_TOP;
-import static com.android.systemui.OverviewProxyService.DEBUG_OVERVIEW_PROXY;
-import static com.android.systemui.OverviewProxyService.TAG_OPS;
import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
-import android.graphics.Matrix;
import android.graphics.Rect;
-import android.os.RemoteException;
-import android.util.Log;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.policy.DividerSnapAlgorithm.SnapTarget;
import com.android.systemui.Dependency;
-import com.android.systemui.OverviewProxyService;
-import com.android.systemui.OverviewProxyService.OverviewProxyListener;
import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.plugins.statusbar.phone.NavGesture.GestureHelper;
-import com.android.systemui.shared.recents.IOverviewProxy;
-import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.tuner.TunerService;
@@ -75,25 +66,14 @@
private NavigationBarView mNavigationBarView;
private boolean mIsVertical;
- private final QuickScrubController mQuickScrubController;
+ private final QuickStepController mQuickStepController;
private final int mScrollTouchSlop;
- private final Matrix mTransformGlobalMatrix = new Matrix();
- private final Matrix mTransformLocalMatrix = new Matrix();
private final StatusBar mStatusBar;
private int mTouchDownX;
private int mTouchDownY;
private boolean mDownOnRecents;
private VelocityTracker mVelocityTracker;
- private OverviewProxyService mOverviewProxyService = Dependency.get(OverviewProxyService.class);
- private final OverviewProxyListener mOverviewProxyListener = new OverviewProxyListener() {
- @Override
- public void onRecentsAnimationStarted() {
- mRecentsAnimationStarted = true;
- mQuickScrubController.setRecentsAnimationStarted(true /* started */);
- }
- };
- private boolean mRecentsAnimationStarted;
private boolean mDockWindowEnabled;
private boolean mDockWindowTouchSlopExceeded;
private int mDragMode;
@@ -103,14 +83,12 @@
mStatusBar = SysUiServiceProvider.getComponent(context, StatusBar.class);
Resources r = context.getResources();
mScrollTouchSlop = r.getDimensionPixelSize(R.dimen.navigation_bar_min_swipe_distance);
- mQuickScrubController = new QuickScrubController(context);
+ mQuickStepController = new QuickStepController(context);
Dependency.get(TunerService.class).addTunable(this, KEY_DOCK_WINDOW_GESTURE);
- mOverviewProxyService.addCallback(mOverviewProxyListener);
}
public void destroy() {
Dependency.get(TunerService.class).removeTunable(this);
- mOverviewProxyService.removeCallback(mOverviewProxyListener);
}
public void setComponents(RecentsComponent recentsComponent, Divider divider,
@@ -118,65 +96,19 @@
mRecentsComponent = recentsComponent;
mDivider = divider;
mNavigationBarView = navigationBarView;
- mQuickScrubController.setComponents(mNavigationBarView);
+ mQuickStepController.setComponents(mNavigationBarView);
}
public void setBarState(boolean isVertical, boolean isRTL) {
mIsVertical = isVertical;
- mQuickScrubController.setBarState(isVertical, isRTL);
- }
-
- private boolean proxyMotionEvents(MotionEvent event) {
- final IOverviewProxy overviewProxy = mOverviewProxyService.getProxy();
- if (overviewProxy != null && mNavigationBarView.isQuickStepSwipeUpEnabled()) {
- mNavigationBarView.requestUnbufferedDispatch(event);
- event.transform(mTransformGlobalMatrix);
- try {
- if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
- overviewProxy.onPreMotionEvent(mNavigationBarView.getDownHitTarget());
- }
- overviewProxy.onMotionEvent(event);
- if (DEBUG_OVERVIEW_PROXY) {
- Log.d(TAG_OPS, "Send MotionEvent: " + event.toString());
- }
- return true;
- } catch (RemoteException e) {
- Log.e(TAG, "Callback failed", e);
- } finally {
- event.transform(mTransformLocalMatrix);
- }
- }
- return false;
+ mQuickStepController.setBarState(isVertical, isRTL);
}
public boolean onInterceptTouchEvent(MotionEvent event) {
- if (mNavigationBarView.inScreenPinning() || mStatusBar.isKeyguardShowing()
- || !mStatusBar.isPresenterFullyCollapsed()) {
+ if (!canHandleGestures()) {
return false;
}
-
- int action = event.getActionMasked();
- switch (action) {
- case MotionEvent.ACTION_DOWN: {
- mTouchDownX = (int) event.getX();
- mTouchDownY = (int) event.getY();
- mTransformGlobalMatrix.set(Matrix.IDENTITY_MATRIX);
- mTransformLocalMatrix.set(Matrix.IDENTITY_MATRIX);
- mNavigationBarView.transformMatrixToGlobal(mTransformGlobalMatrix);
- mNavigationBarView.transformMatrixToLocal(mTransformLocalMatrix);
- mRecentsAnimationStarted = false;
- mQuickScrubController.setRecentsAnimationStarted(false /* started */);
- break;
- }
- }
- boolean handledByQuickscrub = mQuickScrubController.onInterceptTouchEvent(event);
- if (!handledByQuickscrub) {
- // Proxy motion events until we start intercepting for quickscrub
- proxyMotionEvents(event);
- }
-
- boolean result = handledByQuickscrub;
- result |= mRecentsAnimationStarted;
+ boolean result = mQuickStepController.onInterceptTouchEvent(event);
if (mDockWindowEnabled) {
result |= interceptDockWindowEvent(event);
}
@@ -184,18 +116,10 @@
}
public boolean onTouchEvent(MotionEvent event) {
- if (mNavigationBarView.inScreenPinning() || mStatusBar.isKeyguardShowing()
- || !mStatusBar.isPresenterFullyCollapsed()) {
+ if (!canHandleGestures()) {
return false;
}
-
- // The same down event was just sent on intercept and therefore can be ignored here
- boolean ignoreProxyDownEvent = event.getAction() == MotionEvent.ACTION_DOWN
- && mOverviewProxyService.getProxy() != null;
- boolean result = mQuickScrubController.onTouchEvent(event)
- || ignoreProxyDownEvent
- || proxyMotionEvents(event);
- result |= mRecentsAnimationStarted;
+ boolean result = mQuickStepController.onTouchEvent(event);
if (mDockWindowEnabled) {
result |= handleDockWindowEvent(event);
}
@@ -203,17 +127,19 @@
}
public void onDraw(Canvas canvas) {
- if (mNavigationBarView.isQuickScrubEnabled()) {
- mQuickScrubController.onDraw(canvas);
- }
+ mQuickStepController.onDraw(canvas);
}
public void onLayout(boolean changed, int left, int top, int right, int bottom) {
- mQuickScrubController.onLayout(changed, left, top, right, bottom);
+ mQuickStepController.onLayout(changed, left, top, right, bottom);
}
public void onDarkIntensityChange(float intensity) {
- mQuickScrubController.onDarkIntensityChange(intensity);
+ mQuickStepController.onDarkIntensityChange(intensity);
+ }
+
+ public void onNavigationButtonLongPress(View v) {
+ mQuickStepController.onNavigationButtonLongPress(v);
}
private boolean interceptDockWindowEvent(MotionEvent event) {
@@ -342,6 +268,11 @@
mVelocityTracker = null;
}
+ private boolean canHandleGestures() {
+ return !mNavigationBarView.inScreenPinning() && !mStatusBar.isKeyguardShowing()
+ && mStatusBar.isPresenterFullyCollapsed();
+ }
+
private int calculateDragMode() {
if (mIsVertical && !mDivider.getView().isHorizontalDivision()) {
return DRAG_MODE_DIVIDER;
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 ca5a350..fcbd37c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -50,6 +50,7 @@
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
@@ -246,7 +247,7 @@
mOverviewProxyService = Dependency.get(OverviewProxyService.class);
mRecentsOnboarding = new RecentsOnboarding(context, mOverviewProxyService);
- mVibratorHelper = new VibratorHelper(context);
+ mVibratorHelper = Dependency.get(VibratorHelper.class);
mConfiguration = new Configuration();
mConfiguration.updateFrom(context.getResources().getConfiguration());
@@ -289,18 +290,12 @@
notifyVerticalChangedListener(mVertical);
}
- public void setRecentsAnimationStarted(boolean started) {
+ public void onQuickStepStarted() {
if (mRecentsOnboarding != null) {
- mRecentsOnboarding.onRecentsAnimationStarted();
+ mRecentsOnboarding.onQuickStepStarted();
}
}
- public void onConnectionChanged(boolean isConnected) {
- updateSlippery();
- updateNavButtonIcons();
- setUpSwipeUpOnboarding(isConnected);
- }
-
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
switch (event.getActionMasked()) {
@@ -674,6 +669,10 @@
}
}
+ public void onNavigationButtonLongPress(View v) {
+ mGestureHelper.onNavigationButtonLongPress(v);
+ }
+
public void onPanelExpandedChange(boolean expanded) {
updateSlippery();
}
@@ -1035,6 +1034,7 @@
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
+ requestApplyInsets();
reorient();
onPluginDisconnected(null); // Create default gesture helper
Dependency.get(PluginManager.class).addPluginListener(this,
@@ -1112,6 +1112,13 @@
pw.println(" }");
}
+ @Override
+ public WindowInsets onApplyWindowInsets(WindowInsets insets) {
+ setPadding(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
+ insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
+ return super.onApplyWindowInsets(insets);
+ }
+
private static void dumpButton(PrintWriter pw, String caption, ButtonDispatcher button) {
pw.print(" " + caption + ": ");
if (button == null) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 3de0a41..7f1e9d0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -38,6 +38,7 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.LatencyTracker;
import com.android.systemui.DejankUtils;
+import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.classifier.FalsingManager;
@@ -207,7 +208,7 @@
mFalsingManager = FalsingManager.getInstance(context);
mNotificationsDragEnabled =
getResources().getBoolean(R.bool.config_enableNotificationShadeDrag);
- mVibratorHelper = new VibratorHelper(context);
+ mVibratorHelper = Dependency.get(VibratorHelper.class);
mVibrateOnOpening = mContext.getResources().getBoolean(
R.bool.config_vibrateOnIconAnimation);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickScrubController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java
similarity index 65%
rename from packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickScrubController.java
rename to packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java
index 00aff53..d79f0a1b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickScrubController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java
@@ -25,6 +25,7 @@
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.graphics.Canvas;
+import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Handler;
@@ -55,10 +56,10 @@
/**
* Class to detect gestures on the navigation bar and implement quick scrub and switch.
*/
-public class QuickScrubController extends GestureDetector.SimpleOnGestureListener implements
+public class QuickStepController extends GestureDetector.SimpleOnGestureListener implements
GestureHelper {
- private static final String TAG = "QuickScrubController";
+ private static final String TAG = "QuickStepController";
private static final int QUICK_SWITCH_FLING_VELOCITY = 0;
private static final int ANIM_DURATION_MS = 200;
private static final long LONG_PRESS_DELAY_MS = 225;
@@ -75,7 +76,8 @@
private boolean mDraggingActive;
private boolean mQuickScrubActive;
private boolean mAllowQuickSwitch;
- private boolean mRecentsAnimationStarted;
+ private boolean mAllowGestureDetection;
+ private boolean mQuickStepStarted;
private float mDownOffset;
private float mTranslation;
private int mTouchDownX;
@@ -101,6 +103,8 @@
private final ValueAnimator mButtonAnimator;
private final AnimatorSet mQuickScrubEndAnimator;
private final Context mContext;
+ private final Matrix mTransformGlobalMatrix = new Matrix();
+ private final Matrix mTransformLocalMatrix = new Matrix();
private final ArgbEvaluator mTrackColorEvaluator = new ArgbEvaluator();
private final AnimatorUpdateListener mTrackAnimatorListener = valueAnimator -> {
@@ -123,7 +127,6 @@
private AnimatorListenerAdapter mQuickScrubEndListener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- mNavigationBarView.getHomeButton().setClickable(true);
mQuickScrubActive = false;
mTranslation = 0;
mQuickScrubEndAnimator.setCurrentPlayTime(mQuickScrubEndAnimator.getDuration());
@@ -165,7 +168,7 @@
}
};
- public QuickScrubController(Context context) {
+ public QuickStepController(Context context) {
mContext = context;
mScrollTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mOverviewEventSender = Dependency.get(OverviewProxyService.class);
@@ -197,31 +200,34 @@
*/
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
- final ButtonDispatcher homeButton = mNavigationBarView.getHomeButton();
- if (!mNavigationBarView.isQuickScrubEnabled()) {
- homeButton.setDelayTouchFeedback(false);
+ if (!mNavigationBarView.isQuickScrubEnabled()
+ && !mNavigationBarView.isQuickStepSwipeUpEnabled()) {
+ mNavigationBarView.getHomeButton().setDelayTouchFeedback(false /* delay */);
return false;
}
-
+ mNavigationBarView.requestUnbufferedDispatch(event);
return handleTouchEvent(event);
}
/**
- * @return true if we want to handle touch events for quick scrub/switch and prevent proxying
- * the event to the overview service.
+ * @return true if we want to handle touch events for quick scrub/switch or if down event (that
+ * will get consumed and ignored). No events will be proxied to the overview service.
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
- return handleTouchEvent(event);
+ // The same down event was just sent on intercept and therefore can be ignored here
+ final boolean ignoreProxyDownEvent = event.getAction() == MotionEvent.ACTION_DOWN
+ && mOverviewEventSender.getProxy() != null;
+ return ignoreProxyDownEvent || handleTouchEvent(event);
}
private boolean handleTouchEvent(MotionEvent event) {
- final IOverviewProxy overviewProxy = mOverviewEventSender.getProxy();
final ButtonDispatcher homeButton = mNavigationBarView.getHomeButton();
if (mGestureDetector.onTouchEvent(event)) {
// If the fling has been handled on UP, then skip proxying the UP
return true;
}
+ final boolean homePressed = mNavigationBarView.getDownHitTarget() == HIT_TARGET_HOME;
int action = event.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN: {
@@ -232,89 +238,99 @@
mQuickScrubEndAnimator.end();
}
mHomeButtonView = homeButton.getCurrentView();
- if (mNavigationBarView.isQuickScrubEnabled()
- && mNavigationBarView.getDownHitTarget() == HIT_TARGET_HOME) {
- mTouchDownX = x;
- mTouchDownY = y;
- homeButton.setDelayTouchFeedback(true);
+ homeButton.setDelayTouchFeedback(true /* delay */);
+ mTouchDownX = x;
+ mTouchDownY = y;
+ if (homePressed) {
mHandler.postDelayed(mLongPressRunnable, LONG_PRESS_DELAY_MS);
- } else {
- homeButton.setDelayTouchFeedback(false);
- mTouchDownX = mTouchDownY = -1;
}
+ mTransformGlobalMatrix.set(Matrix.IDENTITY_MATRIX);
+ mTransformLocalMatrix.set(Matrix.IDENTITY_MATRIX);
+ mNavigationBarView.transformMatrixToGlobal(mTransformGlobalMatrix);
+ mNavigationBarView.transformMatrixToLocal(mTransformLocalMatrix);
+ mQuickStepStarted = false;
mAllowQuickSwitch = true;
+ mAllowGestureDetection = true;
break;
}
case MotionEvent.ACTION_MOVE: {
- if (mTouchDownX != -1) {
- int x = (int) event.getX();
- int y = (int) event.getY();
- int xDiff = Math.abs(x - mTouchDownX);
- int yDiff = Math.abs(y - mTouchDownY);
- boolean exceededTouchSlopX = xDiff > mScrollTouchSlop && xDiff > yDiff;
- boolean exceededTouchSlopY = yDiff > mScrollTouchSlop && yDiff > xDiff;
- boolean exceededTouchSlop, exceededPerpendicularTouchSlop;
- int pos, touchDown, offset, trackSize;
+ if (mQuickStepStarted || !mAllowGestureDetection){
+ break;
+ }
+ int x = (int) event.getX();
+ int y = (int) event.getY();
+ int xDiff = Math.abs(x - mTouchDownX);
+ int yDiff = Math.abs(y - mTouchDownY);
+ boolean exceededTouchSlopX = xDiff > mScrollTouchSlop && xDiff > yDiff;
+ boolean exceededTouchSlopY = yDiff > mScrollTouchSlop && yDiff > xDiff;
+ boolean exceededTouchSlop, exceededPerpendicularTouchSlop;
+ int pos, touchDown, offset, trackSize;
- if (mIsVertical) {
- exceededTouchSlop = exceededTouchSlopY;
- exceededPerpendicularTouchSlop = exceededTouchSlopX;
- pos = y;
- touchDown = mTouchDownY;
- offset = pos - mTrackRect.top;
- trackSize = mTrackRect.height();
- } else {
- exceededTouchSlop = exceededTouchSlopX;
- exceededPerpendicularTouchSlop = exceededTouchSlopY;
- pos = x;
- touchDown = mTouchDownX;
- offset = pos - mTrackRect.left;
- trackSize = mTrackRect.width();
+ if (mIsVertical) {
+ exceededTouchSlop = exceededTouchSlopY;
+ exceededPerpendicularTouchSlop = exceededTouchSlopX;
+ pos = y;
+ touchDown = mTouchDownY;
+ offset = pos - mTrackRect.top;
+ trackSize = mTrackRect.height();
+ } else {
+ exceededTouchSlop = exceededTouchSlopX;
+ exceededPerpendicularTouchSlop = exceededTouchSlopY;
+ pos = x;
+ touchDown = mTouchDownX;
+ offset = pos - mTrackRect.left;
+ trackSize = mTrackRect.width();
+ }
+ // Decide to start quickstep if dragging away from the navigation bar, otherwise in
+ // the parallel direction, decide to start quickscrub. Only one may run.
+ if (!mDraggingActive && !mQuickScrubActive && exceededPerpendicularTouchSlop) {
+ if (mNavigationBarView.isQuickStepSwipeUpEnabled()) {
+ startQuickStep(event);
}
- // Do not start scrubbing when dragging in the perpendicular direction if we
- // haven't already started quickscrub
- if (!mDraggingActive && !mQuickScrubActive && exceededPerpendicularTouchSlop) {
- mHandler.removeCallbacksAndMessages(null);
- return false;
- }
- if (!mDragPositive) {
- offset -= mIsVertical ? mTrackRect.height() : mTrackRect.width();
- }
+ break;
+ }
- // Control the button movement
- if (!mDraggingActive && exceededTouchSlop && !mRecentsAnimationStarted) {
- boolean allowDrag = !mDragPositive
- ? offset < 0 && pos < touchDown : offset >= 0 && pos > touchDown;
- if (allowDrag) {
- mDownOffset = offset;
- homeButton.setClickable(false);
- mDraggingActive = true;
- }
+ // Do not handle quick scrub/switch if disabled or hit target is not home button
+ if (!homePressed || !mNavigationBarView.isQuickScrubEnabled()) {
+ break;
+ }
+
+ if (!mDragPositive) {
+ offset -= mIsVertical ? mTrackRect.height() : mTrackRect.width();
+ }
+
+ // Control the button movement
+ if (!mDraggingActive && exceededTouchSlop) {
+ boolean allowDrag = !mDragPositive
+ ? offset < 0 && pos < touchDown : offset >= 0 && pos > touchDown;
+ if (allowDrag) {
+ mDownOffset = offset;
+ homeButton.abortCurrentGesture();
+ mDraggingActive = true;
}
- if (mDraggingActive && (mDragPositive && offset >= 0
- || !mDragPositive && offset <= 0)) {
- float scrubFraction =
- Utilities.clamp(Math.abs(offset) * 1f / trackSize, 0, 1);
- mTranslation = !mDragPositive
- ? Utilities.clamp(offset - mDownOffset, -trackSize, 0)
- : Utilities.clamp(offset - mDownOffset, 0, trackSize);
- if (mQuickScrubActive) {
- try {
- mOverviewEventSender.getProxy().onQuickScrubProgress(scrubFraction);
- if (DEBUG_OVERVIEW_PROXY) {
- Log.d(TAG_OPS, "Quick Scrub Progress:" + scrubFraction);
- }
- } catch (RemoteException e) {
- Log.e(TAG, "Failed to send progress of quick scrub.", e);
+ }
+ if (mDraggingActive && (mDragPositive && offset >= 0
+ || !mDragPositive && offset <= 0)) {
+ float scrubFraction = Utilities.clamp(Math.abs(offset) * 1f / trackSize, 0, 1);
+ mTranslation = !mDragPositive
+ ? Utilities.clamp(offset - mDownOffset, -trackSize, 0)
+ : Utilities.clamp(offset - mDownOffset, 0, trackSize);
+ if (mQuickScrubActive) {
+ try {
+ mOverviewEventSender.getProxy().onQuickScrubProgress(scrubFraction);
+ if (DEBUG_OVERVIEW_PROXY) {
+ Log.d(TAG_OPS, "Quick Scrub Progress:" + scrubFraction);
}
- } else {
- mTranslation /= SWITCH_STICKINESS;
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to send progress of quick scrub.", e);
}
- if (mIsVertical) {
- mHomeButtonView.setTranslationY(mTranslation);
- } else {
- mHomeButtonView.setTranslationX(mTranslation);
- }
+ } else {
+ mTranslation /= SWITCH_STICKINESS;
+ }
+ if (mIsVertical) {
+ mHomeButtonView.setTranslationY(mTranslation);
+ } else {
+ mHomeButtonView.setTranslationX(mTranslation);
}
}
break;
@@ -324,11 +340,20 @@
endQuickScrub(true /* animate */);
break;
}
- return mDraggingActive || mQuickScrubActive;
+
+ // Proxy motion events to launcher if not handled by quick scrub/switch
+ boolean handled = mDraggingActive || mQuickScrubActive;
+ if (!handled && mAllowGestureDetection) {
+ proxyMotionEvents(event);
+ }
+ return handled || mQuickStepStarted;
}
@Override
public void onDraw(Canvas canvas) {
+ if (mNavigationBarView.isQuickScrubEnabled()) {
+ return;
+ }
int color = (int) mTrackColorEvaluator.evaluate(mDarkIntensity, mLightTrackColor,
mDarkTrackColor);
mTrackPaint.setColor(color);
@@ -381,6 +406,31 @@
}
}
+ @Override
+ public void onNavigationButtonLongPress(View v) {
+ mAllowGestureDetection = false;
+ mHandler.removeCallbacksAndMessages(null);
+ }
+
+ private void startQuickStep(MotionEvent event) {
+ mQuickStepStarted = true;
+ event.transform(mTransformGlobalMatrix);
+ try {
+ mOverviewEventSender.getProxy().onQuickStep(event);
+ if (DEBUG_OVERVIEW_PROXY) {
+ Log.d(TAG_OPS, "Quick Step Start");
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to send quick step started.", e);
+ } finally {
+ event.transform(mTransformLocalMatrix);
+ }
+ mOverviewEventSender.notifyQuickStepStarted();
+ mNavigationBarView.getHomeButton().abortCurrentGesture();
+ cancelQuickSwitch();
+ mHandler.removeCallbacksAndMessages(null);
+ }
+
private void startQuickScrub() {
if (!mQuickScrubActive && mDraggingActive) {
mQuickScrubActive = true;
@@ -396,9 +446,6 @@
} catch (RemoteException e) {
Log.e(TAG, "Failed to send start of quick scrub.", e);
}
- } else {
- // After long press do not allow quick scrub/switch
- mTouchDownX = -1;
}
}
@@ -421,11 +468,24 @@
mDraggingActive = false;
}
- public void setRecentsAnimationStarted(boolean started) {
- mRecentsAnimationStarted = started;
- if (started) {
- cancelQuickSwitch();
+ private boolean proxyMotionEvents(MotionEvent event) {
+ final IOverviewProxy overviewProxy = mOverviewEventSender.getProxy();
+ event.transform(mTransformGlobalMatrix);
+ try {
+ if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ overviewProxy.onPreMotionEvent(mNavigationBarView.getDownHitTarget());
+ }
+ overviewProxy.onMotionEvent(event);
+ if (DEBUG_OVERVIEW_PROXY) {
+ Log.d(TAG_OPS, "Send MotionEvent: " + event.toString());
+ }
+ return true;
+ } catch (RemoteException e) {
+ Log.e(TAG, "Callback failed", e);
+ } finally {
+ event.transform(mTransformLocalMatrix);
}
+ return false;
}
public void cancelQuickSwitch() {
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 5c77524..e4f142a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -4624,8 +4624,9 @@
!= FingerprintUnlockController.MODE_UNLOCK);
if (mBouncerShowing) {
- mScrimController.transitionTo(
- mIsOccluded ? ScrimState.BOUNCER_OCCLUDED : ScrimState.BOUNCER);
+ final boolean qsExpanded = mQSPanel != null && mQSPanel.isExpanded();
+ mScrimController.transitionTo(mIsOccluded || qsExpanded ?
+ ScrimState.BOUNCER_OCCLUDED : ScrimState.BOUNCER);
} else if (mLaunchCameraOnScreenTurningOn || isInLaunchTransition()) {
mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback);
} else if (mBrightnessMirrorVisible) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
index 81641da..e5fefd3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
@@ -126,7 +126,7 @@
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
mRipple = new KeyButtonRipple(context, this);
- mVibratorHelper = new VibratorHelper(context);
+ mVibratorHelper = Dependency.get(VibratorHelper.class);
mOverviewProxyService = Dependency.get(OverviewProxyService.class);
setBackground(mRipple);
}
@@ -224,8 +224,10 @@
case MotionEvent.ACTION_DOWN:
mDownTime = SystemClock.uptimeMillis();
mLongClicked = false;
- mTouchDownX = (int) ev.getX();
- mTouchDownY = (int) ev.getY();
+
+ // Use raw X and Y to detect gestures in case a parent changes the x and y values
+ mTouchDownX = (int) ev.getRawX();
+ mTouchDownY = (int) ev.getRawY();
if (mCode != 0) {
sendEvent(KeyEvent.ACTION_DOWN, 0, mDownTime);
} else {
@@ -241,8 +243,8 @@
postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout());
break;
case MotionEvent.ACTION_MOVE:
- x = (int)ev.getX();
- y = (int)ev.getY();
+ x = (int)ev.getRawX();
+ y = (int)ev.getRawY();
boolean exceededTouchSlopX = Math.abs(x - mTouchDownX) > mTouchSlop;
boolean exceededTouchSlopY = Math.abs(y - mTouchDownY) > mTouchSlop;
if (exceededTouchSlopX || exceededTouchSlopY) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
index 487d1c5..a046675 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
@@ -205,13 +205,15 @@
}
MobileIconGroup hGroup = TelephonyIcons.THREE_G;
+ MobileIconGroup hPlusGroup = TelephonyIcons.THREE_G;
if (mConfig.hspaDataDistinguishable) {
hGroup = TelephonyIcons.H;
+ hPlusGroup = TelephonyIcons.H_PLUS;
}
mNetworkToIconLookup.put(TelephonyManager.NETWORK_TYPE_HSDPA, hGroup);
mNetworkToIconLookup.put(TelephonyManager.NETWORK_TYPE_HSUPA, hGroup);
mNetworkToIconLookup.put(TelephonyManager.NETWORK_TYPE_HSPA, hGroup);
- mNetworkToIconLookup.put(TelephonyManager.NETWORK_TYPE_HSPAP, hGroup);
+ mNetworkToIconLookup.put(TelephonyManager.NETWORK_TYPE_HSPAP, hPlusGroup);
if (mConfig.show4gForLte) {
mNetworkToIconLookup.put(TelephonyManager.NETWORK_TYPE_LTE, TelephonyIcons.FOUR_G);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index 5363742..2258fa2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -884,6 +884,7 @@
datatype.equals("e") ? TelephonyIcons.E :
datatype.equals("g") ? TelephonyIcons.G :
datatype.equals("h") ? TelephonyIcons.H :
+ datatype.equals("h+") ? TelephonyIcons.H_PLUS :
datatype.equals("lte") ? TelephonyIcons.LTE :
datatype.equals("lte+") ? TelephonyIcons.LTE_PLUS :
datatype.equals("dis") ? TelephonyIcons.DATA_DISABLED :
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/TelephonyIcons.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/TelephonyIcons.java
index 986abef..7e6fe02 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/TelephonyIcons.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/TelephonyIcons.java
@@ -28,7 +28,6 @@
static final int ICON_G = R.drawable.ic_g_mobiledata;
static final int ICON_E = R.drawable.ic_e_mobiledata;
static final int ICON_H = R.drawable.ic_h_mobiledata;
- // TODO: add logic to insert H+ icon
static final int ICON_H_PLUS = R.drawable.ic_h_plus_mobiledata;
static final int ICON_3G = R.drawable.ic_3g_mobiledata;
static final int ICON_4G = R.drawable.ic_4g_mobiledata;
@@ -135,6 +134,19 @@
TelephonyIcons.ICON_H,
false);
+ static final MobileIconGroup H_PLUS = new MobileIconGroup(
+ "H+",
+ null,
+ null,
+ AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
+ 0, 0,
+ 0,
+ 0,
+ AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
+ R.string.data_connection_3_5g_plus,
+ TelephonyIcons.ICON_H_PLUS,
+ false);
+
static final MobileIconGroup FOUR_G = new MobileIconGroup(
"4G",
null,
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
index fe21f87..22bf983 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
@@ -23,6 +23,8 @@
import static android.media.AudioManager.RINGER_MODE_SILENT;
import static android.media.AudioManager.RINGER_MODE_VIBRATE;
import static android.media.AudioManager.STREAM_ACCESSIBILITY;
+import static android.view.View.GONE;
+import static android.view.View.VISIBLE;
import static com.android.systemui.volume.Events.DISMISS_REASON_SETTINGS_CLICKED;
@@ -81,6 +83,7 @@
import com.android.systemui.plugins.VolumeDialogController.State;
import com.android.systemui.plugins.VolumeDialogController.StreamState;
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
+import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -102,6 +105,7 @@
private final Context mContext;
private final H mHandler = new H();
private final VolumeDialogController mController;
+ private final DeviceProvisionedController mDeviceProvisionedController;
private Window mWindow;
private CustomDialog mDialog;
@@ -109,6 +113,7 @@
private ViewGroup mDialogRowsView;
private ViewGroup mRinger;
private ImageButton mRingerIcon;
+ private View mSettingsView;
private ImageButton mSettingsIcon;
private ImageView mZenIcon;
private final List<VolumeRow> mRows = new ArrayList<>();
@@ -139,6 +144,7 @@
mAccessibilityMgr = Dependency.get(AccessibilityManagerWrapper.class);
mActiveSliderTint = ColorStateList.valueOf(Utils.getColorAccent(mContext));
mInactiveSliderTint = loadColorStateList(R.color.volume_slider_inactive);
+ mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
}
public void init(int windowType, Callback callback) {
@@ -212,6 +218,7 @@
mRinger = mDialog.findViewById(R.id.ringer);
mRingerIcon = mRinger.findViewById(R.id.ringer_icon);
mZenIcon = mRinger.findViewById(R.id.dnd_icon);
+ mSettingsView = mDialog.findViewById(R.id.settings_container);
mSettingsIcon = mDialog.findViewById(R.id.settings);
if (mRows.isEmpty()) {
@@ -387,6 +394,8 @@
}
public void initSettingsH() {
+ mSettingsView.setVisibility(
+ mDeviceProvisionedController.isDeviceProvisioned() ? VISIBLE : GONE);
mSettingsIcon.setOnClickListener(v -> {
Intent intent = new Intent(Settings.ACTION_SOUND_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -607,7 +616,7 @@
* @param enable whether to enable volume row views and hide dnd icon
*/
private void enableVolumeRowViewsH(VolumeRow row, boolean enable) {
- row.dndIcon.setVisibility(enable ? View.GONE : View.VISIBLE);
+ row.dndIcon.setVisibility(enable ? GONE : VISIBLE);
}
/**
@@ -617,7 +626,7 @@
*/
private void enableRingerViewsH(boolean enable) {
mRingerIcon.setEnabled(enable);
- mZenIcon.setVisibility(enable ? View.GONE : View.VISIBLE);
+ mZenIcon.setVisibility(enable ? GONE : VISIBLE);
}
private void trimObsoleteH() {
@@ -797,7 +806,7 @@
}
final int progress = row.slider.getProgress();
final int level = getImpliedLevel(row.slider, progress);
- final boolean rowVisible = row.view.getVisibility() == View.VISIBLE;
+ final boolean rowVisible = row.view.getVisibility() == VISIBLE;
final boolean inGracePeriod = (SystemClock.uptimeMillis() - row.userAttempt)
< USER_ATTEMPT_GRACE_PERIOD;
mHandler.removeMessages(H.RECHECK, row);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
index 8629799..365a9b2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
@@ -74,6 +74,17 @@
verifyDataIndicators(TelephonyIcons.ICON_H);
}
+
+ @Test
+ public void testHspaPlusDataIcon() {
+ setupDefaultSignal();
+ updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_HSPAP);
+
+ verifyDataIndicators(TelephonyIcons.ICON_H_PLUS);
+ }
+
+
@Test
public void testWfcNoDataIcon() {
setupDefaultSignal();
diff --git a/packages/overlays/DisplayCutoutEmulationDoubleOverlay/Android.mk b/packages/overlays/DisplayCutoutEmulationDoubleOverlay/Android.mk
new file mode 100644
index 0000000..d83b30a
--- /dev/null
+++ b/packages/overlays/DisplayCutoutEmulationDoubleOverlay/Android.mk
@@ -0,0 +1,14 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_RRO_THEME := DisplayCutoutEmulationDouble
+LOCAL_CERTIFICATE := platform
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+
+LOCAL_PACKAGE_NAME := DisplayCutoutEmulationDoubleOverlay
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_RRO_PACKAGE)
diff --git a/packages/overlays/DisplayCutoutEmulationDoubleOverlay/AndroidManifest.xml b/packages/overlays/DisplayCutoutEmulationDoubleOverlay/AndroidManifest.xml
new file mode 100644
index 0000000..5d3385d
--- /dev/null
+++ b/packages/overlays/DisplayCutoutEmulationDoubleOverlay/AndroidManifest.xml
@@ -0,0 +1,26 @@
+<!--
+ ~ 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.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.internal.display.cutout.emulation.double"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <overlay android:targetPackage="android"
+ android:category="com.android.internal.display_cutout_emulation"
+ android:priority="1"/>
+
+ <application android:label="@string/display_cutout_emulation_overlay" android:hasCode="false"/>
+</manifest>
diff --git a/packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values/config.xml b/packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values/config.xml
new file mode 100644
index 0000000..ca261f9
--- /dev/null
+++ b/packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values/config.xml
@@ -0,0 +1,67 @@
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <!-- The bounding path of the cutout region of the main built-in display.
+ Must either be empty if there is no cutout region, or a string that is parsable by
+ {@link android.util.PathParser}.
+
+ The path is assumed to be specified in display coordinates with pixel units and in
+ the display's native orientation, with the origin of the coordinate system at the
+ center top of the display.
+
+ To facilitate writing device-independent emulation overlays, the marker `@dp` can be
+ appended after the path string to interpret coordinates in dp instead of px units.
+ Note that a physical cutout should be configured in pixels for the best results.
+ -->
+ <string translatable="false" name="config_mainBuiltInDisplayCutout">
+ M 0,0
+ L -72, 0
+ L -69.9940446283, 20.0595537175
+ C -69.1582133885, 28.4178661152 -65.2, 32.0 -56.8, 32.0
+ L 56.8, 32.0
+ C 65.2, 32.0 69.1582133885, 28.4178661152 69.9940446283, 20.0595537175
+ L 72, 0
+ Z
+ @bottom
+ M 0,0
+ L -72, 0
+ L -69.9940446283, -20.0595537175
+ C -69.1582133885, -28.4178661152 -65.2, -32.0 -56.8, -32.0
+ L 56.8, -32.0
+ C 65.2, -32.0 69.1582133885, -28.4178661152 69.9940446283, -20.0595537175
+ L 72, 0
+ Z
+ @dp
+ </string>
+
+ <!-- Whether the display cutout region of the main built-in display should be forced to
+ black in software (to avoid aliasing or emulate a cutout that is not physically existent).
+ -->
+ <bool name="config_fillMainBuiltInDisplayCutout">true</bool>
+
+ <!-- Height of the status bar -->
+ <dimen name="status_bar_height_portrait">48dp</dimen>
+ <dimen name="status_bar_height_landscape">28dp</dimen>
+ <!-- Height of area above QQS where battery/time go (equal to status bar height if > 48dp) -->
+ <dimen name="quick_qs_offset_height">48dp</dimen>
+ <!-- Total height of QQS (quick_qs_offset_height + 128) -->
+ <dimen name="quick_qs_total_height">176dp</dimen>
+
+</resources>
+
+
diff --git a/packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values/strings.xml b/packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values/strings.xml
new file mode 100644
index 0000000..68c2dcb
--- /dev/null
+++ b/packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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.
+ -->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="display_cutout_emulation_overlay">Double display cutout</string>
+
+</resources>
+
diff --git a/packages/overlays/SysuiDarkThemeOverlay/res/values/styles.xml b/packages/overlays/SysuiDarkThemeOverlay/res/values/styles.xml
index ddac106..41a2940 100644
--- a/packages/overlays/SysuiDarkThemeOverlay/res/values/styles.xml
+++ b/packages/overlays/SysuiDarkThemeOverlay/res/values/styles.xml
@@ -7,5 +7,6 @@
<item name="android:colorAccent">@*android:color/accent_device_default_dark</item>
<item name="android:colorControlNormal">?android:attr/textColorPrimary</item>
<item name="android:colorBackgroundFloating">@*android:color/material_grey_900</item>
+ <item name="android:panelColorBackground">@*android:color/material_grey_800</item>
</style>
</resources>
\ No newline at end of file
diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
index 07012d8..d89cc96 100644
--- a/proto/src/metrics_constants.proto
+++ b/proto/src/metrics_constants.proto
@@ -5499,6 +5499,10 @@
// OS: P
SETTINGS_ZONE_PICKER_FIXED_OFFSET = 1357;
+ // Action: notification shade > manage notifications
+ // OS: P
+ ACTION_MANAGE_NOTIFICATIONS = 1358;
+
// ---- End P Constants, all P constants go above this line ----
// Add new aosp constants above this line.
// END OF AOSP CONSTANTS
diff --git a/services/backup/java/com/android/server/backup/transport/TransportStats.java b/services/backup/java/com/android/server/backup/transport/TransportStats.java
index 4bef81a..bd84782 100644
--- a/services/backup/java/com/android/server/backup/transport/TransportStats.java
+++ b/services/backup/java/com/android/server/backup/transport/TransportStats.java
@@ -32,9 +32,12 @@
void registerConnectionTime(ComponentName transportComponent, long timeMs) {
synchronized (mStatsLock) {
- mTransportStats
- .computeIfAbsent(transportComponent, name -> new Stats())
- .register(timeMs);
+ Stats stats = mTransportStats.get(transportComponent);
+ if (stats == null) {
+ stats = new Stats();
+ mTransportStats.put(transportComponent, stats);
+ }
+ stats.register(timeMs);
}
}
@@ -71,52 +74,49 @@
private static void dumpStats(PrintWriter pw, String prefix, Stats stats) {
pw.println(
String.format(
- Locale.US, "%sAverage connection time: %.2f ms", prefix, stats.mAverage));
- pw.println(String.format(Locale.US, "%sMax connection time: %d ms", prefix, stats.mMax));
- pw.println(String.format(Locale.US, "%sMin connection time: %d ms", prefix, stats.mMin));
- pw.println(String.format(Locale.US, "%sNumber of connections: %d ", prefix, stats.mN));
+ Locale.US, "%sAverage connection time: %.2f ms", prefix, stats.average));
+ pw.println(String.format(Locale.US, "%sMax connection time: %d ms", prefix, stats.max));
+ pw.println(String.format(Locale.US, "%sMin connection time: %d ms", prefix, stats.min));
+ pw.println(String.format(Locale.US, "%sNumber of connections: %d ", prefix, stats.n));
}
public static final class Stats {
public static Stats merge(Stats a, Stats b) {
return new Stats(
- a.mN + b.mN,
- (a.mAverage * a.mN + b.mAverage * b.mN) / (a.mN + b.mN),
- Math.max(a.mMax, b.mMax),
- Math.min(a.mMin, b.mMin));
+ a.n + b.n,
+ (a.average * a.n + b.average * b.n) / (a.n + b.n),
+ Math.max(a.max, b.max),
+ Math.min(a.min, b.min));
}
- public int mN;
- public double mAverage;
- public long mMax;
- public long mMin;
+ public int n;
+ public double average;
+ public long max;
+ public long min;
public Stats() {
- mN = 0;
- mAverage = 0;
- mMax = 0;
- mMin = Long.MAX_VALUE;
- }
-
- private Stats(Stats original) {
- mN = original.mN;
- mAverage = original.mAverage;
- mMax = original.mMax;
- mMin = original.mMin;
+ n = 0;
+ average = 0;
+ max = 0;
+ min = Long.MAX_VALUE;
}
private Stats(int n, double average, long max, long min) {
- mN = n;
- mAverage = average;
- mMax = max;
- mMin = min;
+ this.n = n;
+ this.average = average;
+ this.max = max;
+ this.min = min;
+ }
+
+ private Stats(Stats original) {
+ this(original.n, original.average, original.max, original.min);
}
private void register(long sample) {
- mAverage = (mAverage * mN + sample) / (mN + 1);
- mN++;
- mMax = Math.max(mMax, sample);
- mMin = Math.min(mMin, sample);
+ average = (average * n + sample) / (n + 1);
+ n++;
+ max = Math.max(max, sample);
+ min = Math.min(min, sample);
}
}
}
diff --git a/services/core/java/com/android/server/AppOpsService.java b/services/core/java/com/android/server/AppOpsService.java
index 15f3a23..ecf80ba 100644
--- a/services/core/java/com/android/server/AppOpsService.java
+++ b/services/core/java/com/android/server/AppOpsService.java
@@ -610,7 +610,7 @@
@Override
public void setUidMode(int code, int uid, int mode) {
if (Binder.getCallingPid() != Process.myPid()) {
- mContext.enforcePermission(android.Manifest.permission.UPDATE_APP_OPS_STATS,
+ mContext.enforcePermission(android.Manifest.permission.MANAGE_APP_OPS_MODES,
Binder.getCallingPid(), Binder.getCallingUid(), null);
}
verifyIncomingOp(code);
@@ -714,7 +714,7 @@
@Override
public void setMode(int code, int uid, String packageName, int mode) {
if (Binder.getCallingPid() != Process.myPid()) {
- mContext.enforcePermission(android.Manifest.permission.UPDATE_APP_OPS_STATS,
+ mContext.enforcePermission(android.Manifest.permission.MANAGE_APP_OPS_MODES,
Binder.getCallingPid(), Binder.getCallingUid(), null);
}
verifyIncomingOp(code);
@@ -832,7 +832,7 @@
public void resetAllModes(int reqUserId, String reqPackageName) {
final int callingPid = Binder.getCallingPid();
final int callingUid = Binder.getCallingUid();
- mContext.enforcePermission(android.Manifest.permission.UPDATE_APP_OPS_STATS,
+ mContext.enforcePermission(android.Manifest.permission.MANAGE_APP_OPS_MODES,
callingPid, callingUid, null);
reqUserId = ActivityManager.handleIncomingUser(callingPid, callingUid, reqUserId,
true, true, "resetAllModes", null);
@@ -1087,6 +1087,8 @@
String[] exceptionPackages) {
verifyIncomingUid(uid);
verifyIncomingOp(code);
+ mContext.enforcePermission(android.Manifest.permission.MANAGE_APP_OPS_MODES,
+ Binder.getCallingPid(), Binder.getCallingUid(), null);
synchronized (this) {
SparseArray<Restriction> usageRestrictions = mAudioRestrictions.get(code);
if (usageRestrictions == null) {
@@ -2330,7 +2332,7 @@
}
case "write-settings": {
shell.mInternal.mContext.enforcePermission(
- android.Manifest.permission.UPDATE_APP_OPS_STATS,
+ android.Manifest.permission.MANAGE_APP_OPS_MODES,
Binder.getCallingPid(), Binder.getCallingUid(), null);
long token = Binder.clearCallingIdentity();
try {
@@ -2346,7 +2348,7 @@
}
case "read-settings": {
shell.mInternal.mContext.enforcePermission(
- android.Manifest.permission.UPDATE_APP_OPS_STATS,
+ android.Manifest.permission.MANAGE_APP_OPS_MODES,
Binder.getCallingPid(), Binder.getCallingUid(), null);
long token = Binder.clearCallingIdentity();
try {
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index c1c68e8..96633da 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -5401,11 +5401,12 @@
final int callingPid = Binder.getCallingPid();
final int callingUid = Binder.getCallingUid();
+ final SafeActivityOptions safeOptions = SafeActivityOptions.fromBundle(bOptions);
final long origId = Binder.clearCallingIdentity();
try {
synchronized (this) {
return mStackSupervisor.startActivityFromRecents(callingPid, callingUid, taskId,
- SafeActivityOptions.fromBundle(bOptions));
+ safeOptions);
}
} finally {
Binder.restoreCallingIdentity(origId);
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index e38be67..8c49472 100644
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -1621,12 +1621,6 @@
return;
}
- if (isState(DESTROYED) || (state != DESTROYED && isState(DESTROYING))) {
- // We cannot move backwards from destroyed and destroying states.
- throw new IllegalArgumentException("cannot move back states once destroying"
- + "current:" + mState + " requested:" + state);
- }
-
final ActivityState prev = mState;
mState = state;
@@ -1641,23 +1635,6 @@
if (parent != null) {
parent.onActivityStateChanged(this, state, reason);
}
-
- if (isState(DESTROYING, DESTROYED)) {
- makeFinishingLocked();
-
- // When moving to the destroyed state, immediately destroy the activity in the
- // associated stack. Most paths for finishing an activity will handle an activity's path
- // to destroy through mechanisms such as ActivityStackSupervisor#mFinishingActivities.
- // However, moving to the destroyed state directly (as in the case of an app dying) and
- // marking it as finished will lead to cleanup steps that will prevent later handling
- // from happening.
- if (isState(DESTROYED)) {
- final ActivityStack stack = getStack();
- if (stack != null) {
- stack.activityDestroyedLocked(this, reason);
- }
- }
- }
}
ActivityState getState() {
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 2d7520e..c00fc6a 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -3811,14 +3811,6 @@
final ActivityState prevState = r.getState();
if (DEBUG_STATES) Slog.v(TAG_STATES, "Moving to FINISHING: " + r);
- // We are already destroying / have already destroyed the activity. Do not continue to
- // modify it. Note that we do not use ActivityRecord#finishing here as finishing is not
- // indicative of destruction (though destruction is indicative of finishing) as finishing
- // can be delayed below.
- if (r.isState(DESTROYING, DESTROYED)) {
- return null;
- }
-
r.setState(FINISHING, "finishCurrentActivityLocked");
final boolean finishingActivityInNonFocusedStack
= r.getStack() != mStackSupervisor.getFocusedStack()
@@ -4037,26 +4029,16 @@
* state to destroy so only the cleanup here is needed.
*
* Note: Call before #removeActivityFromHistoryLocked.
- *
- * @param r The {@link ActivityRecord} to cleanup.
- * @param cleanServices Whether services bound to the {@link ActivityRecord} should also be
- * cleaned up.
- * @param destroy Whether the {@link ActivityRecord} should be destroyed.
- * @param clearProcess Whether the client process should be cleared.
*/
- private void cleanUpActivityLocked(ActivityRecord r, boolean cleanServices, boolean destroy,
- boolean clearProcess) {
+ private void cleanUpActivityLocked(ActivityRecord r, boolean cleanServices, boolean setState) {
onActivityRemovedFromStack(r);
r.deferRelaunchUntilPaused = false;
r.frozenBeforeDestroy = false;
- if (destroy) {
+ if (setState) {
if (DEBUG_STATES) Slog.v(TAG_STATES, "Moving to DESTROYED: " + r + " (cleaning up)");
r.setState(DESTROYED, "cleanupActivityLocked");
- }
-
- if (clearProcess) {
if (DEBUG_APP) Slog.v(TAG_APP, "Clearing app during cleanUp for activity " + r);
r.app = null;
}
@@ -4271,7 +4253,7 @@
+ ", app=" + (r.app != null ? r.app.processName : "(null)"));
if (r.isState(DESTROYING, DESTROYED)) {
- if (DEBUG_STATES) Slog.v(TAG_STATES, "activity " + r + " already finishing."
+ if (DEBUG_STATES) Slog.v(TAG_STATES, "activity " + r + " already destroying."
+ "skipping request with reason:" + reason);
return false;
}
@@ -4282,8 +4264,7 @@
boolean removedFromHistory = false;
- cleanUpActivityLocked(r, false /* cleanServices */, false /* destroy */,
- false /*clearProcess*/);
+ cleanUpActivityLocked(r, false, false);
final boolean hadApp = r.app != null;
@@ -4380,6 +4361,10 @@
}
}
+ /**
+ * This method is to only be called from the client via binder when the activity is destroyed
+ * AND finished.
+ */
final void activityDestroyedLocked(ActivityRecord record, String reason) {
if (record != null) {
mHandler.removeMessages(DESTROY_TIMEOUT_MSG, record);
@@ -4389,8 +4374,7 @@
if (isInStackLocked(record) != null) {
if (record.isState(DESTROYING, DESTROYED)) {
- cleanUpActivityLocked(record, true /* cleanServices */, false /* destroy */,
- false /*clearProcess*/);
+ cleanUpActivityLocked(record, true, false);
removeActivityFromHistoryLocked(record, reason);
}
}
@@ -4499,8 +4483,7 @@
r.icicle = null;
}
}
- cleanUpActivityLocked(r, true /* cleanServices */, remove /* destroy */,
- true /*clearProcess*/);
+ cleanUpActivityLocked(r, true, true);
if (remove) {
removeActivityFromHistoryLocked(r, "appDied");
}
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 185897a..abd24e1 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -3375,7 +3375,8 @@
stack.goToSleepIfPossible(false /* shuttingDown */);
} else {
stack.awakeFromSleepingLocked();
- if (isFocusedStack(stack) && !mKeyguardController.isKeyguardLocked()) {
+ if (isFocusedStack(stack)
+ && !mKeyguardController.isKeyguardShowing(display.mDisplayId)) {
// If the keyguard is unlocked - resume immediately.
// It is possible that the display will not be awake at the time we
// process the keyguard going away, which can happen before the sleep token
diff --git a/services/core/java/com/android/server/am/LockTaskController.java b/services/core/java/com/android/server/am/LockTaskController.java
index af99111..ed39329 100644
--- a/services/core/java/com/android/server/am/LockTaskController.java
+++ b/services/core/java/com/android/server/am/LockTaskController.java
@@ -469,6 +469,7 @@
if (mLockTaskModeState == LOCK_TASK_MODE_PINNED) {
getStatusBarService().showPinningEnterExitToast(false /* entering */);
}
+ mWindowManager.onLockTaskStateChanged(LOCK_TASK_MODE_NONE);
} catch (RemoteException ex) {
throw new RuntimeException(ex);
} finally {
@@ -580,6 +581,7 @@
if (lockTaskModeState == LOCK_TASK_MODE_PINNED) {
getStatusBarService().showPinningEnterExitToast(true /* entering */);
}
+ mWindowManager.onLockTaskStateChanged(lockTaskModeState);
mLockTaskModeState = lockTaskModeState;
setStatusBarState(lockTaskModeState, userId);
setKeyguardState(lockTaskModeState, userId);
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index f577d09..9ef84d2 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -727,6 +727,36 @@
}
}
+ int maxAlarmVolume = SystemProperties.getInt("ro.config.alarm_vol_steps", -1);
+ if (maxAlarmVolume != -1) {
+ MAX_STREAM_VOLUME[AudioSystem.STREAM_ALARM] = maxAlarmVolume;
+ }
+
+ int defaultAlarmVolume = SystemProperties.getInt("ro.config.alarm_vol_default", -1);
+ if (defaultAlarmVolume != -1 &&
+ defaultAlarmVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_ALARM]) {
+ AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_ALARM] = defaultAlarmVolume;
+ } else {
+ // Default is 6 out of 7 (default maximum), so scale accordingly.
+ AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_ALARM] =
+ 6 * MAX_STREAM_VOLUME[AudioSystem.STREAM_ALARM] / 7;
+ }
+
+ int maxSystemVolume = SystemProperties.getInt("ro.config.system_vol_steps", -1);
+ if (maxSystemVolume != -1) {
+ MAX_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM] = maxSystemVolume;
+ }
+
+ int defaultSystemVolume = SystemProperties.getInt("ro.config.system_vol_default", -1);
+ if (defaultSystemVolume != -1 &&
+ defaultSystemVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM]) {
+ AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM] = defaultSystemVolume;
+ } else {
+ // Default is to use maximum.
+ AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM] =
+ MAX_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM];
+ }
+
sSoundEffectVolumeDb = context.getResources().getInteger(
com.android.internal.R.integer.config_soundEffectVolumeDb);
diff --git a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
index f1a806b..4f31e53 100644
--- a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
+++ b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
@@ -102,9 +102,12 @@
/**
- * There are only 2 possible callbacks.
+ * There are only 3 possible callbacks.
*
- * mNetdEventCallbackList[CALLBACK_CALLER_DEVICE_POLICY].
+ * mNetdEventCallbackList[CALLBACK_CALLER_CONNECTIVITY_SERVICE]
+ * Callback registered/unregistered by ConnectivityService.
+ *
+ * mNetdEventCallbackList[CALLBACK_CALLER_DEVICE_POLICY]
* Callback registered/unregistered when logging is being enabled/disabled in DPM
* by the device owner. It's DevicePolicyManager's responsibility to ensure that.
*
@@ -113,6 +116,7 @@
*/
@GuardedBy("this")
private static final int[] ALLOWED_CALLBACK_TYPES = {
+ INetdEventCallback.CALLBACK_CALLER_CONNECTIVITY_SERVICE,
INetdEventCallback.CALLBACK_CALLER_DEVICE_POLICY,
INetdEventCallback.CALLBACK_CALLER_NETWORK_WATCHLIST
};
@@ -212,6 +216,19 @@
@Override
// Called concurrently by multiple binder threads.
// This method must not block or perform long-running operations.
+ public synchronized void onPrivateDnsValidationEvent(int netId,
+ String ipAddress, String hostname, boolean validated)
+ throws RemoteException {
+ for (INetdEventCallback callback : mNetdEventCallbackList) {
+ if (callback != null) {
+ callback.onPrivateDnsValidationEvent(netId, ipAddress, hostname, validated);
+ }
+ }
+ }
+
+ @Override
+ // Called concurrently by multiple binder threads.
+ // This method must not block or perform long-running operations.
public synchronized void onConnectEvent(int netId, int error, int latencyMs, String ipAddr,
int port, int uid) throws RemoteException {
long timestamp = System.currentTimeMillis();
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index aa1f7d95..141b47d 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -874,7 +874,14 @@
} else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_MEDIA) {
applyRestrictions(muteMedia || muteEverything, usage);
} else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_SYSTEM) {
- applyRestrictions(muteSystem || muteEverything, usage);
+ if (usage == AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) {
+ // normally DND will only restrict touch sounds, not haptic feedback/vibrations
+ applyRestrictions(muteSystem || muteEverything, usage,
+ AppOpsManager.OP_PLAY_AUDIO);
+ applyRestrictions(false, usage, AppOpsManager.OP_VIBRATE);
+ } else {
+ applyRestrictions(muteSystem || muteEverything, usage);
+ }
} else {
applyRestrictions(muteEverything, usage);
}
@@ -883,18 +890,31 @@
@VisibleForTesting
- protected void applyRestrictions(boolean mute, int usage) {
+ protected void applyRestrictions(boolean mute, int usage, int code) {
final String[] exceptionPackages = null; // none (for now)
- mAppOps.setRestriction(AppOpsManager.OP_VIBRATE, usage,
- mute ? AppOpsManager.MODE_IGNORED : AppOpsManager.MODE_ALLOWED,
- exceptionPackages);
- mAppOps.setRestriction(AppOpsManager.OP_PLAY_AUDIO, usage,
- mute ? AppOpsManager.MODE_IGNORED : AppOpsManager.MODE_ALLOWED,
- exceptionPackages);
+ // Only do this if we are executing within the system process... otherwise
+ // we are running as test code, so don't have access to the protected call.
+ if (Process.myUid() == Process.SYSTEM_UID) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mAppOps.setRestriction(code, usage,
+ mute ? AppOpsManager.MODE_IGNORED : AppOpsManager.MODE_ALLOWED,
+ exceptionPackages);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
}
@VisibleForTesting
+ protected void applyRestrictions(boolean mute, int usage) {
+ applyRestrictions(mute, usage, AppOpsManager.OP_VIBRATE);
+ applyRestrictions(mute, usage, AppOpsManager.OP_PLAY_AUDIO);
+ }
+
+
+ @VisibleForTesting
protected void applyZenToRingerMode() {
if (mAudioManager == null) return;
// force the ringer mode into compliance
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 707184f..f0922b34 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -2877,7 +2877,8 @@
rescanFlags =
scanFlags
| SCAN_AS_SYSTEM;
- } else if (FileUtils.contains(privilegedVendorAppDir, scanFile)) {
+ } else if (FileUtils.contains(privilegedVendorAppDir, scanFile)
+ || FileUtils.contains(privilegedOdmAppDir, scanFile)) {
reparseFlags =
mDefParseFlags |
PackageParser.PARSE_IS_SYSTEM_DIR;
@@ -2886,7 +2887,8 @@
| SCAN_AS_SYSTEM
| SCAN_AS_VENDOR
| SCAN_AS_PRIVILEGED;
- } else if (FileUtils.contains(vendorAppDir, scanFile)) {
+ } else if (FileUtils.contains(vendorAppDir, scanFile)
+ || FileUtils.contains(odmAppDir, scanFile)) {
reparseFlags =
mDefParseFlags |
PackageParser.PARSE_IS_SYSTEM_DIR;
@@ -11788,6 +11790,8 @@
codeRoot = Environment.getOemDirectory();
} else if (FileUtils.contains(Environment.getVendorDirectory(), codePath)) {
codeRoot = Environment.getVendorDirectory();
+ } else if (FileUtils.contains(Environment.getOdmDirectory(), codePath)) {
+ codeRoot = Environment.getOdmDirectory();
} else if (FileUtils.contains(Environment.getProductDirectory(), codePath)) {
codeRoot = Environment.getProductDirectory();
} else {
@@ -18217,9 +18221,11 @@
try {
final File privilegedAppDir = new File(Environment.getRootDirectory(), "priv-app");
final File privilegedVendorAppDir = new File(Environment.getVendorDirectory(), "priv-app");
+ final File privilegedOdmAppDir = new File(Environment.getOdmDirectory(), "priv-app");
final File privilegedProductAppDir = new File(Environment.getProductDirectory(), "priv-app");
return path.startsWith(privilegedAppDir.getCanonicalPath())
|| path.startsWith(privilegedVendorAppDir.getCanonicalPath())
+ || path.startsWith(privilegedOdmAppDir.getCanonicalPath())
|| path.startsWith(privilegedProductAppDir.getCanonicalPath());
} catch (IOException e) {
Slog.e(TAG, "Unable to access code path " + path);
@@ -18238,7 +18244,8 @@
static boolean locationIsVendor(String path) {
try {
- return path.startsWith(Environment.getVendorDirectory().getCanonicalPath());
+ return path.startsWith(Environment.getVendorDirectory().getCanonicalPath())
+ || path.startsWith(Environment.getOdmDirectory().getCanonicalPath());
} catch (IOException e) {
Slog.e(TAG, "Unable to access code path " + path);
}
diff --git a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
index 4abcce1..bf85f30 100644
--- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
@@ -1240,6 +1240,10 @@
if (dir.isDirectory() && dir.canRead()) {
Collections.addAll(ret, dir.listFiles());
}
+ dir = new File(Environment.getOdmDirectory(), "etc/default-permissions");
+ if (dir.isDirectory() && dir.canRead()) {
+ Collections.addAll(ret, dir.listFiles());
+ }
dir = new File(Environment.getProductDirectory(), "etc/default-permissions");
if (dir.isDirectory() && dir.canRead()) {
Collections.addAll(ret, dir.listFiles());
diff --git a/services/core/java/com/android/server/policy/ImmersiveModeConfirmation.java b/services/core/java/com/android/server/policy/ImmersiveModeConfirmation.java
index c6ec287..4aa2446 100644
--- a/services/core/java/com/android/server/policy/ImmersiveModeConfirmation.java
+++ b/services/core/java/com/android/server/policy/ImmersiveModeConfirmation.java
@@ -16,6 +16,9 @@
package com.android.server.policy;
+import static android.app.ActivityManager.LOCK_TASK_MODE_LOCKED;
+import static android.app.ActivityManager.LOCK_TASK_MODE_NONE;
+
import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.app.ActivityManager;
@@ -78,6 +81,7 @@
// Local copy of vr mode enabled state, to avoid calling into VrManager with
// the lock held.
boolean mVrModeEnabled = false;
+ private int mLockTaskState = LOCK_TASK_MODE_NONE;
public ImmersiveModeConfirmation(Context context) {
mContext = ActivityThread.currentActivityThread().getSystemUiContext();
@@ -148,7 +152,8 @@
&& userSetupComplete
&& !mVrModeEnabled
&& !navBarEmpty
- && !UserManager.isDeviceInDemoMode(mContext)) {
+ && !UserManager.isDeviceInDemoMode(mContext)
+ && (mLockTaskState != LOCK_TASK_MODE_LOCKED)) {
mHandler.sendEmptyMessageDelayed(H.SHOW, mShowDelayMs);
}
} else {
@@ -401,4 +406,8 @@
}
}
};
+
+ void onLockTaskModeChangedLw(int lockTaskState) {
+ mLockTaskState = lockTaskState;
+ }
}
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 938edb0..3cd79e1 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -1456,6 +1456,9 @@
+ "already in the process of turning the screen on.");
return;
}
+ Slog.d(TAG, "powerPress: eventTime=" + eventTime + " interactive=" + interactive
+ + " count=" + count + " beganFromNonInteractive=" + mBeganFromNonInteractive +
+ " mShortPressOnPowerBehavior=" + mShortPressOnPowerBehavior);
if (count == 2) {
powerMultiPressAction(eventTime, interactive, mDoublePressOnPowerBehavior);
@@ -1755,7 +1758,6 @@
}
void showGlobalActionsInternal() {
- sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
if (mGlobalActions == null) {
mGlobalActions = new GlobalActions(mContext, mWindowManagerFuncs);
}
@@ -2680,8 +2682,9 @@
attrs.flags &= ~WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
break;
case TYPE_DREAM:
- // Dreams don't have an app window token and can thus not be letterboxed.
- // Hence always let them extend under the cutout.
+ case TYPE_WALLPAPER:
+ // Dreams and wallpapers don't have an app window token and can thus not be
+ // letterboxed. Hence always let them extend under the cutout.
attrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
break;
case TYPE_STATUS_BAR:
@@ -4757,7 +4760,7 @@
// It's a system nav bar or a portrait screen; nav bar goes on bottom.
final int top = cutoutSafeUnrestricted.bottom
- getNavigationBarHeight(rotation, uiMode);
- mTmpNavigationFrame.set(0, top, displayWidth, cutoutSafeUnrestricted.bottom);
+ mTmpNavigationFrame.set(0, top, displayWidth, displayFrames.mUnrestricted.bottom);
displayFrames.mStable.bottom = displayFrames.mStableFullscreen.bottom = top;
if (transientNavBarShowing) {
mNavigationBarController.setBarShowingLw(true);
@@ -4780,7 +4783,7 @@
// Landscape screen; nav bar goes to the right.
final int left = cutoutSafeUnrestricted.right
- getNavigationBarWidth(rotation, uiMode);
- mTmpNavigationFrame.set(left, 0, cutoutSafeUnrestricted.right, displayHeight);
+ mTmpNavigationFrame.set(left, 0, displayFrames.mUnrestricted.right, displayHeight);
displayFrames.mStable.right = displayFrames.mStableFullscreen.right = left;
if (transientNavBarShowing) {
mNavigationBarController.setBarShowingLw(true);
@@ -4803,7 +4806,7 @@
// Seascape screen; nav bar goes to the left.
final int right = cutoutSafeUnrestricted.left
+ getNavigationBarWidth(rotation, uiMode);
- mTmpNavigationFrame.set(cutoutSafeUnrestricted.left, 0, right, displayHeight);
+ mTmpNavigationFrame.set(displayFrames.mUnrestricted.left, 0, right, displayHeight);
displayFrames.mStable.left = displayFrames.mStableFullscreen.left = right;
if (transientNavBarShowing) {
mNavigationBarController.setBarShowingLw(true);
@@ -4832,8 +4835,9 @@
mStatusBarLayer = mNavigationBar.getSurfaceLayer();
// And compute the final frame.
mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame,
- mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, dcf,
- mTmpNavigationFrame, mTmpNavigationFrame, displayFrames.mDisplayCutout);
+ mTmpNavigationFrame, displayFrames.mDisplayCutoutSafe, mTmpNavigationFrame, dcf,
+ mTmpNavigationFrame, displayFrames.mDisplayCutoutSafe,
+ displayFrames.mDisplayCutout);
if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame);
return mNavigationBarController.checkHiddenLw();
}
@@ -4991,8 +4995,7 @@
df.set(displayFrames.mDock);
pf.set(displayFrames.mDock);
// IM dock windows layout below the nav bar...
- pf.bottom = df.bottom = of.bottom = Math.min(displayFrames.mUnrestricted.bottom,
- displayFrames.mDisplayCutoutSafe.bottom);
+ pf.bottom = df.bottom = of.bottom = displayFrames.mUnrestricted.bottom;
// ...with content insets above the nav bar
cf.bottom = vf.bottom = displayFrames.mStable.bottom;
if (mStatusBar != null && mFocusedWindow == mStatusBar && canReceiveInput(mStatusBar)) {
@@ -5293,27 +5296,48 @@
final int cutoutMode = attrs.layoutInDisplayCutoutMode;
final boolean attachedInParent = attached != null && !layoutInScreen;
+ final boolean requestedHideNavigation =
+ (requestedSysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0;
// Ensure that windows with a DEFAULT or NEVER display cutout mode are laid out in
// the cutout safe zone.
if (cutoutMode != LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS) {
- final Rect displayCutoutSafeExceptMaybeTop = mTmpRect;
- displayCutoutSafeExceptMaybeTop.set(displayFrames.mDisplayCutoutSafe);
+ final Rect displayCutoutSafeExceptMaybeBars = mTmpRect;
+ displayCutoutSafeExceptMaybeBars.set(displayFrames.mDisplayCutoutSafe);
if (layoutInScreen && layoutInsetDecor && !requestedFullscreen
&& cutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT) {
// At the top we have the status bar, so apps that are
// LAYOUT_IN_SCREEN | LAYOUT_INSET_DECOR but not FULLSCREEN
// already expect that there's an inset there and we don't need to exclude
// the window from that area.
- displayCutoutSafeExceptMaybeTop.top = Integer.MIN_VALUE;
+ displayCutoutSafeExceptMaybeBars.top = Integer.MIN_VALUE;
+ }
+ if (layoutInScreen && layoutInsetDecor && !requestedHideNavigation
+ && cutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT) {
+ // Same for the navigation bar.
+ switch (mNavigationBarPosition) {
+ case NAV_BAR_BOTTOM:
+ displayCutoutSafeExceptMaybeBars.bottom = Integer.MAX_VALUE;
+ break;
+ case NAV_BAR_RIGHT:
+ displayCutoutSafeExceptMaybeBars.right = Integer.MAX_VALUE;
+ break;
+ case NAV_BAR_LEFT:
+ displayCutoutSafeExceptMaybeBars.left = Integer.MIN_VALUE;
+ break;
+ }
+ }
+ if (type == TYPE_INPUT_METHOD && mNavigationBarPosition == NAV_BAR_BOTTOM) {
+ // The IME can always extend under the bottom cutout if the navbar is there.
+ displayCutoutSafeExceptMaybeBars.bottom = Integer.MAX_VALUE;
}
// Windows that are attached to a parent and laid out in said parent are already
// avoidingthe cutout according to that parent and don't need to be further constrained.
if (!attachedInParent) {
- pf.intersectUnchecked(displayCutoutSafeExceptMaybeTop);
+ pf.intersectUnchecked(displayCutoutSafeExceptMaybeBars);
}
- // Make sure that NO_LIMITS windows clipped to the display don't extend into the display
- // don't extend under the cutout.
- df.intersectUnchecked(displayCutoutSafeExceptMaybeTop);
+ // Make sure that NO_LIMITS windows clipped to the display don't extend under the
+ // cutout.
+ df.intersectUnchecked(displayCutoutSafeExceptMaybeBars);
}
// Content should never appear in the cutout.
@@ -8787,4 +8811,9 @@
return Integer.toString(behavior);
}
}
+
+ @Override
+ public void onLockTaskStateChangedLw(int lockTaskState) {
+ mImmersiveModeConfirmation.onLockTaskModeChangedLw(lockTaskState);
+ }
}
diff --git a/services/core/java/com/android/server/policy/WindowManagerPolicy.java b/services/core/java/com/android/server/policy/WindowManagerPolicy.java
index 8ec8c5b..b0d5e1a 100644
--- a/services/core/java/com/android/server/policy/WindowManagerPolicy.java
+++ b/services/core/java/com/android/server/policy/WindowManagerPolicy.java
@@ -66,6 +66,7 @@
import android.Manifest;
import android.annotation.IntDef;
import android.annotation.Nullable;
+import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.CompatibilityInfo;
@@ -1731,4 +1732,15 @@
* on the next user activity.
*/
public void requestUserActivityNotification();
+
+ /**
+ * Called when the state of lock task mode changes. This should be used to disable immersive
+ * mode confirmation.
+ *
+ * @param lockTaskState the new lock task mode state. One of
+ * {@link ActivityManager#LOCK_TASK_MODE_NONE},
+ * {@link ActivityManager#LOCK_TASK_MODE_LOCKED},
+ * {@link ActivityManager#LOCK_TASK_MODE_PINNED}.
+ */
+ void onLockTaskStateChangedLw(int lockTaskState);
}
diff --git a/services/core/java/com/android/server/power/Notifier.java b/services/core/java/com/android/server/power/Notifier.java
index b729b6a..285532a 100644
--- a/services/core/java/com/android/server/power/Notifier.java
+++ b/services/core/java/com/android/server/power/Notifier.java
@@ -720,9 +720,12 @@
private void playChargingStartedSound() {
final boolean enabled = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.CHARGING_SOUNDS_ENABLED, 1) != 0;
+ final boolean dndOff = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.ZEN_MODE, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS)
+ == Settings.Global.ZEN_MODE_OFF;
final String soundPath = Settings.Global.getString(mContext.getContentResolver(),
Settings.Global.CHARGING_STARTED_SOUND);
- if (enabled && soundPath != null) {
+ if (enabled && dndOff && soundPath != null) {
final Uri soundUri = Uri.parse("file://" + soundPath);
if (soundUri != null) {
final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri);
diff --git a/services/core/java/com/android/server/wm/AnimationAdapter.java b/services/core/java/com/android/server/wm/AnimationAdapter.java
index 64f77a2..00e3050 100644
--- a/services/core/java/com/android/server/wm/AnimationAdapter.java
+++ b/services/core/java/com/android/server/wm/AnimationAdapter.java
@@ -17,13 +17,15 @@
package com.android.server.wm;
import android.annotation.ColorInt;
-import android.graphics.Point;
+import android.util.proto.ProtoOutputStream;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import android.view.animation.Animation;
import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
+import java.io.PrintWriter;
+
/**
* Interface that describes an animation and bridges the animation start to the component
* responsible for running the animation.
@@ -83,4 +85,14 @@
* @return the desired start time of the status bar transition, in uptime millis
*/
long getStatusBarTransitionsStartTime();
+
+ void dump(PrintWriter pw, String prefix);
+
+ default void writeToProto(ProtoOutputStream proto, long fieldId) {
+ final long token = proto.start(fieldId);
+ writeToProto(proto);
+ proto.end(token);
+ }
+
+ void writeToProto(ProtoOutputStream proto);
}
diff --git a/services/core/java/com/android/server/wm/AppWindowContainerController.java b/services/core/java/com/android/server/wm/AppWindowContainerController.java
index 40f772a..1170148 100644
--- a/services/core/java/com/android/server/wm/AppWindowContainerController.java
+++ b/services/core/java/com/android/server/wm/AppWindowContainerController.java
@@ -379,6 +379,8 @@
if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM, "No longer Stopped: " + wtoken);
wtoken.mAppStopped = false;
+
+ mContainer.transferStartingWindowFromHiddenAboveTokenIfNeeded();
}
// If we are preparing an app transition, then delay changing
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index 2672337..b2f153a 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -187,6 +187,7 @@
StartingSurface startingSurface;
boolean startingDisplayed;
boolean startingMoved;
+
// True if the hidden state of this token was forced to false due to a transferred starting
// window.
private boolean mHiddenSetFromTransferredStartingWindow;
@@ -1136,6 +1137,25 @@
stopFreezingScreen(true, true);
}
+ /**
+ * Tries to transfer the starting window from a token that's above ourselves in the task but
+ * not visible anymore. This is a common scenario apps use: Trampoline activity T start main
+ * activity M in the same task. Now, when reopening the task, T starts on top of M but then
+ * immediately finishes after, so we have to transfer T to M.
+ */
+ void transferStartingWindowFromHiddenAboveTokenIfNeeded() {
+ final Task task = getTask();
+ for (int i = task.mChildren.size() - 1; i >= 0; i--) {
+ final AppWindowToken fromToken = task.mChildren.get(i);
+ if (fromToken == this) {
+ return;
+ }
+ if (fromToken.hiddenRequested && transferStartingWindow(fromToken.token)) {
+ return;
+ }
+ }
+ }
+
boolean transferStartingWindow(IBinder transferFrom) {
final AppWindowToken fromToken = getDisplayContent().getAppWindowToken(transferFrom);
if (fromToken == null) {
diff --git a/services/core/java/com/android/server/wm/Dimmer.java b/services/core/java/com/android/server/wm/Dimmer.java
index a180a3a..5c62987 100644
--- a/services/core/java/com/android/server/wm/Dimmer.java
+++ b/services/core/java/com/android/server/wm/Dimmer.java
@@ -16,11 +16,19 @@
package com.android.server.wm;
-import android.view.SurfaceControl;
+import static com.android.server.wm.proto.AlphaAnimationSpecProto.DURATION;
+import static com.android.server.wm.proto.AlphaAnimationSpecProto.FROM;
+import static com.android.server.wm.proto.AlphaAnimationSpecProto.TO;
+import static com.android.server.wm.proto.AnimationSpecProto.ALPHA;
+
import android.graphics.Rect;
+import android.util.proto.ProtoOutputStream;
+import android.view.SurfaceControl;
import com.android.internal.annotations.VisibleForTesting;
+import java.io.PrintWriter;
+
/**
* Utility class for use by a WindowContainer implementation to add "DimLayer" support, that is
* black layers of varying opacity at various Z-levels which create the effect of a Dim.
@@ -334,5 +342,21 @@
+ mFromAlpha;
t.setAlpha(sc, alpha);
}
+
+ @Override
+ public void dump(PrintWriter pw, String prefix) {
+ pw.print(prefix); pw.print("from="); pw.print(mFromAlpha);
+ pw.print(" to="); pw.print(mToAlpha);
+ pw.print(" duration="); pw.println(mDuration);
+ }
+
+ @Override
+ public void writeToProtoInner(ProtoOutputStream proto) {
+ final long token = proto.start(ALPHA);
+ proto.write(FROM, mFromAlpha);
+ proto.write(TO, mToAlpha);
+ proto.write(DURATION, mDuration);
+ proto.end(token);
+ }
}
}
diff --git a/services/core/java/com/android/server/wm/LocalAnimationAdapter.java b/services/core/java/com/android/server/wm/LocalAnimationAdapter.java
index 1b41cb8..3f1fde9 100644
--- a/services/core/java/com/android/server/wm/LocalAnimationAdapter.java
+++ b/services/core/java/com/android/server/wm/LocalAnimationAdapter.java
@@ -16,12 +16,18 @@
package com.android.server.wm;
+import static com.android.server.wm.proto.AnimationAdapterProto.LOCAL;
+import static com.android.server.wm.proto.LocalAnimationAdapterProto.ANIMATION_SPEC;
+
import android.os.SystemClock;
+import android.util.proto.ProtoOutputStream;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
+import java.io.PrintWriter;
+
/**
* Animation that can be executed without holding the window manager lock. See
* {@link SurfaceAnimationRunner}.
@@ -74,6 +80,18 @@
return mSpec.calculateStatusBarTransitionStartTime();
}
+ @Override
+ public void dump(PrintWriter pw, String prefix) {
+ mSpec.dump(pw, prefix);
+ }
+
+ @Override
+ public void writeToProto(ProtoOutputStream proto) {
+ final long token = proto.start(LOCAL);
+ mSpec.writeToProto(proto, ANIMATION_SPEC);
+ proto.end(token);
+ }
+
/**
* Describes how to apply an animation.
*/
@@ -127,5 +145,15 @@
default boolean canSkipFirstFrame() {
return false;
}
+
+ void dump(PrintWriter pw, String prefix);
+
+ default void writeToProto(ProtoOutputStream proto, long fieldId) {
+ final long token = proto.start(fieldId);
+ writeToProtoInner(proto);
+ proto.end(token);
+ }
+
+ void writeToProtoInner(ProtoOutputStream proto);
}
}
diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java
index 39b886d..7392e80 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimationController.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java
@@ -23,6 +23,8 @@
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
+import static com.android.server.wm.proto.RemoteAnimationAdapterWrapperProto.TARGET;
+import static com.android.server.wm.proto.AnimationAdapterProto.REMOTE;
import android.app.ActivityManager.TaskSnapshot;
import android.app.WindowConfiguration;
@@ -33,18 +35,21 @@
import android.os.SystemClock;
import android.util.ArraySet;
import android.util.Log;
-import android.util.Slog;
+import android.util.Slog;import android.util.proto.ProtoOutputStream;
import android.util.SparseBooleanArray;
+import android.util.proto.ProtoOutputStream;
import android.view.IRecentsAnimationController;
import android.view.IRecentsAnimationRunner;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
-import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
+
import com.google.android.collect.Sets;
+
+import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
+
import java.io.PrintWriter;
import java.util.ArrayList;
-
/**
* Controls a single instance of the remote driven recents animation. In particular, this allows
* the calling SystemUI to animate the visible task windows as a part of the transition. The remote
@@ -235,11 +240,16 @@
return;
}
try {
- final RemoteAnimationTarget[] appAnimations =
- new RemoteAnimationTarget[mPendingAnimations.size()];
+ final ArrayList<RemoteAnimationTarget> appAnimations = new ArrayList<>();
for (int i = mPendingAnimations.size() - 1; i >= 0; i--) {
- appAnimations[i] = mPendingAnimations.get(i).createRemoteAnimationApp();
+ final RemoteAnimationTarget target =
+ mPendingAnimations.get(i).createRemoteAnimationApp();
+ if (target != null) {
+ appAnimations.add(target);
+ }
}
+ final RemoteAnimationTarget[] appTargets = appAnimations.toArray(
+ new RemoteAnimationTarget[appAnimations.size()]);
mPendingStart = false;
final Rect minimizedHomeBounds =
@@ -248,7 +258,7 @@
final Rect contentInsets =
mHomeAppToken != null && mHomeAppToken.findMainWindow() != null
? mHomeAppToken.findMainWindow().mContentInsets : null;
- mRunner.onAnimationStart_New(mController, appAnimations, contentInsets,
+ mRunner.onAnimationStart_New(mController, appTargets, contentInsets,
minimizedHomeBounds);
} catch (RemoteException e) {
Slog.e(TAG, "Failed to start recents animation", e);
@@ -348,6 +358,7 @@
private SurfaceControl mCapturedLeash;
private OnAnimationFinishedCallback mCapturedFinishCallback;
private final boolean mIsRecentTaskInvisible;
+ private RemoteAnimationTarget mTarget;
TaskAnimationAdapter(Task task, boolean isRecentTaskInvisible) {
mTask = task;
@@ -361,10 +372,14 @@
container.getRelativePosition(position);
container.getBounds(bounds);
final WindowState mainWindow = mTask.getTopVisibleAppMainWindow();
- return new RemoteAnimationTarget(mTask.mTaskId, MODE_CLOSING, mCapturedLeash,
+ if (mainWindow == null) {
+ return null;
+ }
+ mTarget = new RemoteAnimationTarget(mTask.mTaskId, MODE_CLOSING, mCapturedLeash,
!mTask.fillsParent(), mainWindow.mWinAnimator.mLastClipRect,
mainWindow.mContentInsets, mTask.getPrefixOrderIndex(), position, bounds,
mTask.getWindowConfiguration(), mIsRecentTaskInvisible);
+ return mTarget;
}
@Override
@@ -403,6 +418,26 @@
public long getStatusBarTransitionsStartTime() {
return SystemClock.uptimeMillis();
}
+
+ @Override
+ public void dump(PrintWriter pw, String prefix) {
+ pw.print(prefix); pw.println("task=" + mTask);
+ if (mTarget != null) {
+ pw.print(prefix); pw.println("Target:");
+ mTarget.dump(pw, prefix + " ");
+ } else {
+ pw.print(prefix); pw.println("Target: null");
+ }
+ }
+
+ @Override
+ public void writeToProto(ProtoOutputStream proto) {
+ final long token = proto.start(REMOTE);
+ if (mTarget != null) {
+ mTarget.writeToProto(proto, TARGET);
+ }
+ proto.end(token);
+ }
}
public void dump(PrintWriter pw, String prefix) {
diff --git a/services/core/java/com/android/server/wm/RemoteAnimationController.java b/services/core/java/com/android/server/wm/RemoteAnimationController.java
index 169d65e..d645110 100644
--- a/services/core/java/com/android/server/wm/RemoteAnimationController.java
+++ b/services/core/java/com/android/server/wm/RemoteAnimationController.java
@@ -16,8 +16,11 @@
package com.android.server.wm;
+import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
+import static com.android.server.wm.proto.AnimationAdapterProto.REMOTE;
+import static com.android.server.wm.proto.RemoteAnimationAdapterWrapperProto.TARGET;
import android.graphics.Point;
import android.graphics.Rect;
@@ -25,16 +28,18 @@
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Slog;
+import android.util.proto.ProtoOutputStream;
import android.view.IRemoteAnimationFinishedCallback;
-import android.view.IRemoteAnimationFinishedCallback.Stub;
import android.view.RemoteAnimationAdapter;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
+import com.android.internal.util.FastPrintWriter;
import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
-import java.lang.ref.WeakReference;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.util.ArrayList;
/**
@@ -104,6 +109,20 @@
}
});
sendRunningRemoteAnimation(true);
+ if (DEBUG_APP_TRANSITIONS) {
+ writeStartDebugStatement();
+ }
+ }
+
+ private void writeStartDebugStatement() {
+ Slog.i(TAG, "Starting remote animation");
+ final StringWriter sw = new StringWriter();
+ final FastPrintWriter pw = new FastPrintWriter(sw);
+ for (int i = mPendingAnimations.size() - 1; i >= 0; i--) {
+ mPendingAnimations.get(i).dump(pw, "");
+ }
+ pw.close();
+ Slog.i(TAG, sw.toString());
}
private RemoteAnimationTarget[] createAnimations() {
@@ -133,6 +152,7 @@
}
}
sendRunningRemoteAnimation(false);
+ if (DEBUG_APP_TRANSITIONS) Slog.i(TAG, "Finishing remote animation");
}
private void invokeAnimationCancelled() {
@@ -193,6 +213,7 @@
private OnAnimationFinishedCallback mCapturedFinishCallback;
private final Point mPosition = new Point();
private final Rect mStackBounds = new Rect();
+ private RemoteAnimationTarget mTarget;
RemoteAnimationAdapterWrapper(AppWindowToken appWindowToken, Point position,
Rect stackBounds) {
@@ -210,11 +231,12 @@
if (mainWindow == null) {
return null;
}
- return new RemoteAnimationTarget(task.mTaskId, getMode(),
+ mTarget = new RemoteAnimationTarget(task.mTaskId, getMode(),
mCapturedLeash, !mAppWindowToken.fillsParent(),
mainWindow.mWinAnimator.mLastClipRect, mainWindow.mContentInsets,
mAppWindowToken.getPrefixOrderIndex(), mPosition, mStackBounds,
task.getWindowConfiguration(), false /*isNotInRecents*/);
+ return mTarget;
}
private int getMode() {
@@ -275,5 +297,25 @@
return SystemClock.uptimeMillis()
+ mRemoteAnimationAdapter.getStatusBarTransitionDelay();
}
+
+ @Override
+ public void dump(PrintWriter pw, String prefix) {
+ pw.print(prefix); pw.print("token="); pw.println(mAppWindowToken);
+ if (mTarget != null) {
+ pw.print(prefix); pw.println("Target:");
+ mTarget.dump(pw, prefix + " ");
+ } else {
+ pw.print(prefix); pw.println("Target: null");
+ }
+ }
+
+ @Override
+ public void writeToProto(ProtoOutputStream proto) {
+ final long token = proto.start(REMOTE);
+ if (mTarget != null) {
+ mTarget.writeToProto(proto, TARGET);
+ }
+ proto.end(token);
+ }
}
}
diff --git a/services/core/java/com/android/server/wm/SurfaceAnimator.java b/services/core/java/com/android/server/wm/SurfaceAnimator.java
index 76f5396..c06caaf 100644
--- a/services/core/java/com/android/server/wm/SurfaceAnimator.java
+++ b/services/core/java/com/android/server/wm/SurfaceAnimator.java
@@ -313,7 +313,9 @@
*/
void writeToProto(ProtoOutputStream proto, long fieldId) {
final long token = proto.start(fieldId);
- proto.write(ANIMATION_ADAPTER, mAnimation != null ? mAnimation.toString() : "null");
+ if (mAnimation != null) {
+ mAnimation.writeToProto(proto, ANIMATION_ADAPTER);
+ }
if (mLeash != null){
mLeash.writeToProto(proto, LEASH);
}
@@ -322,8 +324,18 @@
}
void dump(PrintWriter pw, String prefix) {
- pw.print(prefix); pw.print("mAnimation="); pw.print(mAnimation);
- pw.print(" mLeash="); pw.println(mLeash);
+ pw.print(prefix); pw.print("mLeash="); pw.print(mLeash);
+ if (mAnimationStartDelayed) {
+ pw.print(" mAnimationStartDelayed="); pw.println(mAnimationStartDelayed);
+ } else {
+ pw.println();
+ }
+ pw.print(prefix); pw.println("Animation:");
+ if (mAnimation != null) {
+ mAnimation.dump(pw, prefix + " ");
+ } else {
+ pw.print(prefix); pw.println("null");
+ }
}
/**
diff --git a/services/core/java/com/android/server/wm/WindowAnimationSpec.java b/services/core/java/com/android/server/wm/WindowAnimationSpec.java
index 43fa3d5..a41eba8 100644
--- a/services/core/java/com/android/server/wm/WindowAnimationSpec.java
+++ b/services/core/java/com/android/server/wm/WindowAnimationSpec.java
@@ -19,10 +19,13 @@
import static com.android.server.wm.AnimationAdapter.STATUS_BAR_TRANSITION_DURATION;
import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_AFTER_ANIM;
import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_NONE;
+import static com.android.server.wm.proto.AnimationSpecProto.WINDOW;
+import static com.android.server.wm.proto.WindowAnimationSpecProto.ANIMATION;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.SystemClock;
+import android.util.proto.ProtoOutputStream;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import android.view.animation.Animation;
@@ -33,6 +36,8 @@
import com.android.server.wm.LocalAnimationAdapter.AnimationSpec;
+import java.io.PrintWriter;
+
/**
* Animation spec for regular window animations.
*/
@@ -129,6 +134,18 @@
return mCanSkipFirstFrame;
}
+ @Override
+ public void dump(PrintWriter pw, String prefix) {
+ pw.print(prefix); pw.println(mAnimation);
+ }
+
+ @Override
+ public void writeToProtoInner(ProtoOutputStream proto) {
+ final long token = proto.start(WINDOW);
+ proto.write(ANIMATION, mAnimation.toString());
+ proto.end(token);
+ }
+
/**
* Tries to find a {@link TranslateAnimation} inside the {@code animation}.
*
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 563d792..82fbb51 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -7438,5 +7438,19 @@
mH.obtainMessage(H.SET_RUNNING_REMOTE_ANIMATION, pid, runningRemoteAnimation ? 1 : 0)
.sendToTarget();
}
-}
+ /**
+ * Called when the state of lock task mode changes. This should be used to disable immersive
+ * mode confirmation.
+ *
+ * @param lockTaskState the new lock task mode state. One of
+ * {@link ActivityManager#LOCK_TASK_MODE_NONE},
+ * {@link ActivityManager#LOCK_TASK_MODE_LOCKED},
+ * {@link ActivityManager#LOCK_TASK_MODE_PINNED}.
+ */
+ public void onLockTaskStateChanged(int lockTaskState) {
+ synchronized (mWindowMap) {
+ mPolicy.onLockTaskStateChangedLw(lockTaskState);
+ }
+ }
+}
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index f01dc20..297e067 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -113,6 +113,10 @@
import static com.android.server.wm.proto.IdentifierProto.HASH_CODE;
import static com.android.server.wm.proto.IdentifierProto.TITLE;
import static com.android.server.wm.proto.IdentifierProto.USER_ID;
+import static com.android.server.wm.proto.AnimationSpecProto.MOVE;
+import static com.android.server.wm.proto.MoveAnimationSpecProto.DURATION;
+import static com.android.server.wm.proto.MoveAnimationSpecProto.FROM;
+import static com.android.server.wm.proto.MoveAnimationSpecProto.TO;
import static com.android.server.wm.proto.WindowStateProto.ANIMATING_EXIT;
import static com.android.server.wm.proto.WindowStateProto.ANIMATOR;
import static com.android.server.wm.proto.WindowStateProto.ATTRIBUTES;
@@ -4724,5 +4728,21 @@
t.setPosition(leash, mFrom.x + (mTo.x - mFrom.x) * v,
mFrom.y + (mTo.y - mFrom.y) * v);
}
+
+ @Override
+ public void dump(PrintWriter pw, String prefix) {
+ pw.print(prefix); pw.print("from="); pw.print(mFrom);
+ pw.print(" to="); pw.print(mTo);
+ pw.print(" duration="); pw.println(mDuration);
+ }
+
+ @Override
+ public void writeToProtoInner(ProtoOutputStream proto) {
+ final long token = proto.start(MOVE);
+ mFrom.writeToProto(proto, FROM);
+ mTo.writeToProto(proto, TO);
+ proto.write(DURATION, mDuration);
+ proto.end(token);
+ }
}
}
diff --git a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
index 4179590..40ee552 100644
--- a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
+++ b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
@@ -559,7 +559,8 @@
+ wtoken.allDrawn + " startingDisplayed="
+ wtoken.startingDisplayed + " startingMoved="
+ wtoken.startingMoved + " isRelaunching()="
- + wtoken.isRelaunching());
+ + wtoken.isRelaunching() + " startingWindow="
+ + wtoken.startingWindow);
final boolean allDrawn = wtoken.allDrawn && !wtoken.isRelaunching();
diff --git a/services/robotests/src/com/android/server/backup/transport/TransportStatsTest.java b/services/robotests/src/com/android/server/backup/transport/TransportStatsTest.java
new file mode 100644
index 0000000..322db85
--- /dev/null
+++ b/services/robotests/src/com/android/server/backup/transport/TransportStatsTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.backup.transport;
+
+import static com.android.server.backup.testing.TransportData.backupTransport;
+import static com.android.server.backup.testing.TransportData.d2dTransport;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.ComponentName;
+import android.platform.test.annotations.Presubmit;
+
+import com.android.server.backup.transport.TransportStats.Stats;
+import com.android.server.testing.FrameworkRobolectricTestRunner;
+import com.android.server.testing.SystemLoaderPackages;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
+
+@RunWith(FrameworkRobolectricTestRunner.class)
+@Config(manifest = Config.NONE, sdk = 26)
+@SystemLoaderPackages({"com.android.server.backup"})
+@Presubmit
+public class TransportStatsTest {
+ private static final double TOLERANCE = 0.0001;
+
+ private TransportStats mTransportStats;
+ private ComponentName mTransportComponent1;
+ private ComponentName mTransportComponent2;
+
+ @Before
+ public void setUp() throws Exception {
+ mTransportStats = new TransportStats();
+ mTransportComponent1 = backupTransport().getTransportComponent();
+ mTransportComponent2 = d2dTransport().getTransportComponent();
+ }
+
+ @Test
+ public void testRegisterConnectionTime() {
+ mTransportStats.registerConnectionTime(mTransportComponent1, 50L);
+
+ Stats stats = mTransportStats.getStatsForTransport(mTransportComponent1);
+ assertThat(stats.average).isWithin(TOLERANCE).of(50);
+ assertThat(stats.max).isEqualTo(50L);
+ assertThat(stats.min).isEqualTo(50L);
+ assertThat(stats.n).isEqualTo(1);
+ }
+
+ @Test
+ public void testRegisterConnectionTime_whenHasAlreadyOneSample() {
+ mTransportStats.registerConnectionTime(mTransportComponent1, 50L);
+
+ mTransportStats.registerConnectionTime(mTransportComponent1, 100L);
+
+ Stats stats = mTransportStats.getStatsForTransport(mTransportComponent1);
+ assertThat(stats.average).isWithin(TOLERANCE).of(75);
+ assertThat(stats.max).isEqualTo(100L);
+ assertThat(stats.min).isEqualTo(50L);
+ assertThat(stats.n).isEqualTo(2);
+ }
+
+ @Test
+ public void testGetStatsForTransport() {
+ mTransportStats.registerConnectionTime(mTransportComponent1, 10L);
+ mTransportStats.registerConnectionTime(mTransportComponent2, 20L);
+
+ Stats stats = mTransportStats.getStatsForTransport(mTransportComponent1);
+
+ assertThat(stats.average).isWithin(TOLERANCE).of(10);
+ assertThat(stats.max).isEqualTo(10L);
+ assertThat(stats.min).isEqualTo(10L);
+ assertThat(stats.n).isEqualTo(1);
+ }
+
+ @Test
+ public void testMerge() {
+ mTransportStats.registerConnectionTime(mTransportComponent1, 10L);
+ mTransportStats.registerConnectionTime(mTransportComponent2, 20L);
+ Stats stats1 = mTransportStats.getStatsForTransport(mTransportComponent1);
+ Stats stats2 = mTransportStats.getStatsForTransport(mTransportComponent2);
+
+ Stats stats = Stats.merge(stats1, stats2);
+
+ assertThat(stats.average).isWithin(TOLERANCE).of(15);
+ assertThat(stats.max).isEqualTo(20L);
+ assertThat(stats.min).isEqualTo(10L);
+ assertThat(stats.n).isEqualTo(2);
+ }
+}
diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityRecordTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityRecordTests.java
index ac212dd..03e870a 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityRecordTests.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityRecordTests.java
@@ -222,35 +222,4 @@
verify(mService.mStackSupervisor, times(1)).canPlaceEntityOnDisplay(anyInt(), eq(expected),
anyInt(), anyInt(), eq(record.info));
}
-
- @Test
- public void testFinishingAfterDestroying() throws Exception {
- assertFalse(mActivity.finishing);
- mActivity.setState(DESTROYING, "testFinishingAfterDestroying");
- assertTrue(mActivity.isState(DESTROYING));
- assertTrue(mActivity.finishing);
- }
-
- @Test
- public void testFinishingAfterDestroyed() throws Exception {
- assertFalse(mActivity.finishing);
- mActivity.setState(DESTROYED, "testFinishingAfterDestroyed");
- assertTrue(mActivity.isState(DESTROYED));
- assertTrue(mActivity.finishing);
- }
-
- @Test
- public void testSetInvalidState() throws Exception {
- mActivity.setState(DESTROYED, "testInvalidState");
-
- boolean exceptionEncountered = false;
-
- try {
- mActivity.setState(FINISHING, "testInvalidState");
- } catch (IllegalArgumentException e) {
- exceptionEncountered = true;
- }
-
- assertTrue(exceptionEncountered);
- }
}
diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java
index bda68d1..f17bfa4 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java
@@ -479,28 +479,6 @@
}
@Test
- public void testSuppressMultipleDestroy() throws Exception {
- final ActivityRecord r = new ActivityBuilder(mService).setTask(mTask).build();
- final ClientLifecycleManager lifecycleManager = mock(ClientLifecycleManager.class);
- final ProcessRecord app = r.app;
-
- // The mocked lifecycle manager must be set on the ActivityStackSupervisor's reference to
- // the service rather than mService as mService is a spy and setting the value will not
- // propagate as ActivityManagerService hands its own reference to the
- // ActivityStackSupervisor during construction.
- ((TestActivityManagerService) mSupervisor.mService).setLifecycleManager(lifecycleManager);
-
- mStack.destroyActivityLocked(r, true, "first invocation");
- verify(lifecycleManager, times(1)).scheduleTransaction(eq(app.thread),
- eq(r.appToken), any(DestroyActivityItem.class));
- assertTrue(r.isState(DESTROYED, DESTROYING));
-
- mStack.destroyActivityLocked(r, true, "second invocation");
- verify(lifecycleManager, times(1)).scheduleTransaction(eq(app.thread),
- eq(r.appToken), any(DestroyActivityItem.class));
- }
-
- @Test
public void testFinishDisabledPackageActivities() throws Exception {
final ActivityRecord firstActivity = new ActivityBuilder(mService).setTask(mTask).build();
final ActivityRecord secondActivity = new ActivityBuilder(mService).setTask(mTask).build();
diff --git a/services/tests/servicestests/src/com/android/server/wm/AppWindowContainerControllerTests.java b/services/tests/servicestests/src/com/android/server/wm/AppWindowContainerControllerTests.java
index 76e4e89..e0645b1 100644
--- a/services/tests/servicestests/src/com/android/server/wm/AppWindowContainerControllerTests.java
+++ b/services/tests/servicestests/src/com/android/server/wm/AppWindowContainerControllerTests.java
@@ -20,11 +20,9 @@
import org.junit.Test;
import android.platform.test.annotations.Presubmit;
-import android.platform.test.annotations.SecurityTest;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
-import android.view.WindowManager;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
@@ -36,13 +34,12 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
-import java.util.function.Consumer;
+import com.android.server.wm.WindowTestUtils.TestTaskWindowContainerController;
/**
* Test class for {@link AppWindowContainerController}.
*
- * Build/Install/Run:
- * bit FrameworksServicesTests:com.android.server.wm.AppWindowContainerControllerTests
+ * atest FrameworksServicesTests:com.android.server.wm.AppWindowContainerControllerTests
*/
@SmallTest
@Presubmit
@@ -176,6 +173,33 @@
}
@Test
+ public void testTryTransferStartingWindowFromHiddenAboveToken() throws Exception {
+
+ // Add two tasks on top of each other.
+ TestTaskWindowContainerController taskController =
+ new WindowTestUtils.TestTaskWindowContainerController(this);
+ final WindowTestUtils.TestAppWindowContainerController controllerTop =
+ createAppWindowController(taskController);
+ final WindowTestUtils.TestAppWindowContainerController controllerBottom =
+ createAppWindowController(taskController);
+
+ // Add a starting window.
+ controllerTop.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(),
+ android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true,
+ false, false);
+ waitUntilHandlersIdle();
+
+ // Make the top one invisible, and try transfering the starting window from the top to the
+ // bottom one.
+ controllerTop.setVisibility(false, false);
+ controllerBottom.mContainer.transferStartingWindowFromHiddenAboveTokenIfNeeded();
+
+ // Assert that the bottom window now has the starting window.
+ assertNoStartingWindow(controllerTop.getAppWindowToken(mDisplayContent));
+ assertHasStartingWindow(controllerBottom.getAppWindowToken(mDisplayContent));
+ }
+
+ @Test
public void testReparent() throws Exception {
final StackWindowController stackController =
createStackControllerOnDisplay(mDisplayContent);
diff --git a/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
index 6784e30..6d9167f 100644
--- a/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
+++ b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
@@ -656,4 +656,8 @@
@Override
public void requestUserActivityNotification() {
}
+
+ @Override
+ public void onLockTaskStateChangedLw(int lockTaskState) {
+ }
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
index 9008803..be58fd2 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
@@ -35,6 +35,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.AppOpsManager;
import android.app.NotificationManager;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -160,6 +161,26 @@
}
@Test
+ public void testTotalSilence() {
+ mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
+ mZenModeHelperSpy.applyRestrictions();
+
+ // Total silence will silence alarms, media and system noises (but not vibrations)
+ verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
+ AudioAttributes.USAGE_ALARM);
+ verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
+ AudioAttributes.USAGE_MEDIA);
+ verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
+ AudioAttributes.USAGE_GAME);
+ verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
+ AudioAttributes.USAGE_ASSISTANCE_SONIFICATION, AppOpsManager.OP_PLAY_AUDIO);
+ verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(false,
+ AudioAttributes.USAGE_ASSISTANCE_SONIFICATION, AppOpsManager.OP_VIBRATE);
+ verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
+ AudioAttributes.USAGE_UNKNOWN);
+ }
+
+ @Test
public void testAlarmsOnly_alarmMediaMuteNotApplied() {
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_ALARMS;
mZenModeHelperSpy.mConfig.allowAlarms = false;
@@ -179,9 +200,9 @@
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(false,
AudioAttributes.USAGE_GAME);
- // Alarms only will silence system noises
+ // Alarms only will silence system noises (but not vibrations)
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
- AudioAttributes.USAGE_ASSISTANCE_SONIFICATION);
+ AudioAttributes.USAGE_ASSISTANCE_SONIFICATION, AppOpsManager.OP_PLAY_AUDIO);
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
AudioAttributes.USAGE_UNKNOWN);
}
@@ -228,6 +249,7 @@
@Test
public void testZenAllCannotBypass() {
// Only audio attributes with SUPPRESIBLE_NEVER can bypass
+ // with special case USAGE_ASSISTANCE_SONIFICATION
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
mZenModeHelperSpy.mConfig.allowAlarms = false;
mZenModeHelperSpy.mConfig.allowMedia = false;
@@ -247,9 +269,17 @@
mZenModeHelperSpy.applyRestrictions();
for (int usage : AudioAttributes.SDK_USAGES) {
- boolean shouldMute = AudioAttributes.SUPPRESSIBLE_USAGES.get(usage)
- != AudioAttributes.SUPPRESSIBLE_NEVER;
- verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(shouldMute, usage);
+ if (usage == AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) {
+ // only mute audio, not vibrations
+ verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true, usage,
+ AppOpsManager.OP_PLAY_AUDIO);
+ verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(false, usage,
+ AppOpsManager.OP_VIBRATE);
+ } else {
+ boolean shouldMute = AudioAttributes.SUPPRESSIBLE_USAGES.get(usage)
+ != AudioAttributes.SUPPRESSIBLE_NEVER;
+ verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(shouldMute, usage);
+ }
}
}
diff --git a/telephony/java/android/telephony/MbmsDownloadSession.java b/telephony/java/android/telephony/MbmsDownloadSession.java
index ce1b80c..81a966b 100644
--- a/telephony/java/android/telephony/MbmsDownloadSession.java
+++ b/telephony/java/android/telephony/MbmsDownloadSession.java
@@ -131,6 +131,14 @@
*/
public static final String DEFAULT_TOP_LEVEL_TEMP_DIRECTORY = "androidMbmsTempFileRoot";
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(value = {RESULT_SUCCESSFUL, RESULT_CANCELLED, RESULT_EXPIRED, RESULT_IO_ERROR,
+ RESULT_SERVICE_ID_NOT_DEFINED, RESULT_DOWNLOAD_FAILURE, RESULT_OUT_OF_STORAGE,
+ RESULT_FILE_ROOT_UNREACHABLE}, prefix = { "RESULT_" })
+ public @interface DownloadResultCode{}
+
/**
* Indicates that the download was successful.
*/
diff --git a/telephony/java/android/telephony/NetworkScan.java b/telephony/java/android/telephony/NetworkScan.java
index 7f43ee5..073c313 100644
--- a/telephony/java/android/telephony/NetworkScan.java
+++ b/telephony/java/android/telephony/NetworkScan.java
@@ -115,6 +115,8 @@
telephony.stopNetworkScan(mSubId, mScanId);
} catch (RemoteException ex) {
Rlog.e(TAG, "stopNetworkScan RemoteException", ex);
+ } catch (RuntimeException ex) {
+ Rlog.e(TAG, "stopNetworkScan RuntimeException", ex);
}
}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 22795b1..7add893 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -5351,6 +5351,23 @@
}
/**
+ * @return true if the IMS resolver is busy resolving a binding and should not be considered
+ * available, false if the IMS resolver is idle.
+ * @hide
+ */
+ public boolean isResolvingImsBinding() {
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.isResolvingImsBinding();
+ }
+ } catch (RemoteException e) {
+ Rlog.e(TAG, "isResolvingImsBinding, RemoteException: " + e.getMessage());
+ }
+ return false;
+ }
+
+ /**
* Set IMS registration state
*
* @param Registration state
diff --git a/telephony/java/android/telephony/TelephonyScanManager.java b/telephony/java/android/telephony/TelephonyScanManager.java
index 946cecf..99e2db8 100644
--- a/telephony/java/android/telephony/TelephonyScanManager.java
+++ b/telephony/java/android/telephony/TelephonyScanManager.java
@@ -145,7 +145,8 @@
break;
case CALLBACK_SCAN_ERROR:
try {
- executor.execute(() -> callback.onError(message.arg1));
+ final int errorCode = message.arg1;
+ executor.execute(() -> callback.onError(errorCode));
} catch (Exception e) {
Rlog.e(TAG, "Exception in networkscan callback onError", e);
}
diff --git a/telephony/java/android/telephony/UiccSlotInfo.java b/telephony/java/android/telephony/UiccSlotInfo.java
index 0c17147..125161d 100644
--- a/telephony/java/android/telephony/UiccSlotInfo.java
+++ b/telephony/java/android/telephony/UiccSlotInfo.java
@@ -60,6 +60,7 @@
private final String mCardId;
private final @CardStateInfo int mCardStateInfo;
private final int mLogicalSlotIdx;
+ private final boolean mIsExtendedApduSupported;
public static final Creator<UiccSlotInfo> CREATOR = new Creator<UiccSlotInfo>() {
@Override
@@ -79,6 +80,7 @@
mCardId = in.readString();
mCardStateInfo = in.readInt();
mLogicalSlotIdx = in.readInt();
+ mIsExtendedApduSupported = in.readByte() != 0;
}
@Override
@@ -88,6 +90,7 @@
dest.writeString(mCardId);
dest.writeInt(mCardStateInfo);
dest.writeInt(mLogicalSlotIdx);
+ dest.writeByte((byte) (mIsExtendedApduSupported ? 1 : 0));
}
@Override
@@ -96,12 +99,13 @@
}
public UiccSlotInfo(boolean isActive, boolean isEuicc, String cardId,
- @CardStateInfo int cardStateInfo, int logicalSlotIdx) {
+ @CardStateInfo int cardStateInfo, int logicalSlotIdx, boolean isExtendedApduSupported) {
this.mIsActive = isActive;
this.mIsEuicc = isEuicc;
this.mCardId = cardId;
this.mCardStateInfo = cardStateInfo;
this.mLogicalSlotIdx = logicalSlotIdx;
+ this.mIsExtendedApduSupported = isExtendedApduSupported;
}
public boolean getIsActive() {
@@ -125,6 +129,13 @@
return mLogicalSlotIdx;
}
+ /**
+ * @return {@code true} if this slot supports extended APDU from ATR, {@code false} otherwise.
+ */
+ public boolean getIsExtendedApduSupported() {
+ return mIsExtendedApduSupported;
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -139,7 +150,8 @@
&& (mIsEuicc == that.mIsEuicc)
&& (mCardId == that.mCardId)
&& (mCardStateInfo == that.mCardStateInfo)
- && (mLogicalSlotIdx == that.mLogicalSlotIdx);
+ && (mLogicalSlotIdx == that.mLogicalSlotIdx)
+ && (mIsExtendedApduSupported == that.mIsExtendedApduSupported);
}
@Override
@@ -150,6 +162,7 @@
result = 31 * result + Objects.hashCode(mCardId);
result = 31 * result + mCardStateInfo;
result = 31 * result + mLogicalSlotIdx;
+ result = 31 * result + (mIsExtendedApduSupported ? 1 : 0);
return result;
}
@@ -165,6 +178,8 @@
+ mCardStateInfo
+ ", phoneId="
+ mLogicalSlotIdx
+ + ", mIsExtendedApduSupported="
+ + mIsExtendedApduSupported
+ ")";
}
}
diff --git a/telephony/java/android/telephony/ims/ImsService.java b/telephony/java/android/telephony/ims/ImsService.java
index 2748cb5..c008711 100644
--- a/telephony/java/android/telephony/ims/ImsService.java
+++ b/telephony/java/android/telephony/ims/ImsService.java
@@ -161,11 +161,6 @@
}
@Override
- public void notifyImsFeatureReady(int slotId, int featureType) {
- ImsService.this.notifyImsFeatureReady(slotId, featureType);
- }
-
- @Override
public IImsConfig getConfig(int slotId) {
ImsConfigImplBase c = ImsService.this.getConfig(slotId);
return c != null ? c.getIImsConfig() : null;
@@ -274,25 +269,6 @@
}
}
- private void notifyImsFeatureReady(int slotId, int featureType) {
- synchronized (mFeaturesBySlot) {
- // get ImsFeature associated with the slot/feature
- SparseArray<ImsFeature> features = mFeaturesBySlot.get(slotId);
- if (features == null) {
- Log.w(LOG_TAG, "Can not notify ImsFeature ready. No ImsFeatures exist on " +
- "slot " + slotId);
- return;
- }
- ImsFeature f = features.get(featureType);
- if (f == null) {
- Log.w(LOG_TAG, "Can not notify ImsFeature ready. No feature with type "
- + featureType + " exists on slot " + slotId);
- return;
- }
- f.onFeatureReady();
- }
- }
-
/**
* When called, provide the {@link ImsFeatureConfiguration} that this {@link ImsService}
* currently supports. This will trigger the framework to set up the {@link ImsFeature}s that
diff --git a/telephony/java/android/telephony/ims/aidl/IImsServiceController.aidl b/telephony/java/android/telephony/ims/aidl/IImsServiceController.aidl
index 86f8606..c7da681 100644
--- a/telephony/java/android/telephony/ims/aidl/IImsServiceController.aidl
+++ b/telephony/java/android/telephony/ims/aidl/IImsServiceController.aidl
@@ -36,8 +36,6 @@
ImsFeatureConfiguration querySupportedImsFeatures();
// Synchronous call to ensure the ImsService is ready before continuing with feature creation.
void notifyImsServiceReadyForFeatureCreation();
- // Synchronous call to ensure the new ImsFeature is ready before using the Feature.
- void notifyImsFeatureReady(int slotId, int featureType);
void removeImsFeature(int slotId, int featureType, in IImsFeatureStatusCallback c);
IImsConfig getConfig(int slotId);
IImsRegistration getRegistration(int slotId);
diff --git a/telephony/java/android/telephony/ims/feature/MmTelFeature.java b/telephony/java/android/telephony/ims/feature/MmTelFeature.java
index 2fffd36..c073d1a 100644
--- a/telephony/java/android/telephony/ims/feature/MmTelFeature.java
+++ b/telephony/java/android/telephony/ims/feature/MmTelFeature.java
@@ -575,7 +575,7 @@
*/
public ImsUtImplBase getUt() {
// Base Implementation - Should be overridden
- return null;
+ return new ImsUtImplBase();
}
/**
@@ -584,7 +584,7 @@
*/
public ImsEcbmImplBase getEcbm() {
// Base Implementation - Should be overridden
- return null;
+ return new ImsEcbmImplBase();
}
/**
@@ -593,7 +593,7 @@
*/
public ImsMultiEndpointImplBase getMultiEndpoint() {
// Base Implementation - Should be overridden
- return null;
+ return new ImsMultiEndpointImplBase();
}
/**
diff --git a/telephony/java/android/telephony/ims/stub/ImsFeatureConfiguration.java b/telephony/java/android/telephony/ims/stub/ImsFeatureConfiguration.java
index 98b67c3..2f52c0a 100644
--- a/telephony/java/android/telephony/ims/stub/ImsFeatureConfiguration.java
+++ b/telephony/java/android/telephony/ims/stub/ImsFeatureConfiguration.java
@@ -21,6 +21,7 @@
import android.os.Parcelable;
import android.telephony.ims.feature.ImsFeature;
import android.util.ArraySet;
+import android.util.Pair;
import java.util.Set;
@@ -34,14 +35,57 @@
*/
@SystemApi
public final class ImsFeatureConfiguration implements Parcelable {
+
+ public static final class FeatureSlotPair {
+ /**
+ * SIM slot that this feature is associated with.
+ */
+ public final int slotId;
+ /**
+ * The feature that this slotId supports. Supported values are
+ * {@link ImsFeature#FEATURE_EMERGENCY_MMTEL}, {@link ImsFeature#FEATURE_MMTEL}, and
+ * {@link ImsFeature#FEATURE_RCS}.
+ */
+ public final @ImsFeature.FeatureType int featureType;
+
+ /**
+ * A mapping from slotId to IMS Feature type.
+ * @param slotId the SIM slot ID associated with this feature.
+ * @param featureType The feature that this slotId supports. Supported values are
+ * {@link ImsFeature#FEATURE_EMERGENCY_MMTEL}, {@link ImsFeature#FEATURE_MMTEL}, and
+ * {@link ImsFeature#FEATURE_RCS}.
+ */
+ public FeatureSlotPair(int slotId, @ImsFeature.FeatureType int featureType) {
+ this.slotId = slotId;
+ this.featureType = featureType;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ FeatureSlotPair that = (FeatureSlotPair) o;
+
+ if (slotId != that.slotId) return false;
+ return featureType == that.featureType;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = slotId;
+ result = 31 * result + featureType;
+ return result;
+ }
+ }
+
/**
* Features that this ImsService supports.
*/
- private final Set<Integer> mFeatures;
+ private final Set<FeatureSlotPair> mFeatures;
/**
- * Builder for {@link ImsFeatureConfiguration} that makes adding supported {@link ImsFeature}s
- * easier.
+ * Builder for {@link ImsFeatureConfiguration}.
*/
public static class Builder {
ImsFeatureConfiguration mConfig;
@@ -50,12 +94,15 @@
}
/**
- * @param feature A feature defined in {@link ImsFeature.FeatureType} that this service
- * supports.
+ * Adds an IMS feature associated with a SIM slot ID.
+ * @param slotId The slot ID associated with the IMS feature.
+ * @param featureType The feature that the slot ID supports. Supported values are
+ * {@link ImsFeature#FEATURE_EMERGENCY_MMTEL}, {@link ImsFeature#FEATURE_MMTEL}, and
+ * {@link ImsFeature#FEATURE_RCS}.
* @return a {@link Builder} to continue constructing the ImsFeatureConfiguration.
*/
- public Builder addFeature(@ImsFeature.FeatureType int feature) {
- mConfig.addFeature(feature);
+ public Builder addFeature(int slotId, @ImsFeature.FeatureType int featureType) {
+ mConfig.addFeature(slotId, featureType);
return this;
}
@@ -66,8 +113,7 @@
/**
* Creates with all registration features empty.
- *
- * Consider using the provided {@link Builder} to create this configuration instead.
+ * @hide
*/
public ImsFeatureConfiguration() {
mFeatures = new ArraySet<>();
@@ -76,45 +122,41 @@
/**
* Configuration of the ImsService, which describes which features the ImsService supports
* (for registration).
- * @param features an array of feature integers defined in {@link ImsFeature} that describe
- * which features this ImsService supports. Supported values are
- * {@link ImsFeature#FEATURE_EMERGENCY_MMTEL}, {@link ImsFeature#FEATURE_MMTEL}, and
- * {@link ImsFeature#FEATURE_RCS}.
+ * @param features a set of {@link FeatureSlotPair}s that describe which features this
+ * ImsService supports.
* @hide
*/
- public ImsFeatureConfiguration(int[] features) {
+ public ImsFeatureConfiguration(Set<FeatureSlotPair> features) {
mFeatures = new ArraySet<>();
if (features != null) {
- for (int i : features) {
- mFeatures.add(i);
- }
+ mFeatures.addAll(features);
}
}
/**
- * @return an int[] containing the features that this ImsService supports. Supported values are
- * {@link ImsFeature#FEATURE_EMERGENCY_MMTEL}, {@link ImsFeature#FEATURE_MMTEL}, and
- * {@link ImsFeature#FEATURE_RCS}.
+ * @return a set of supported slot ID to feature type pairs contained within a
+ * {@link FeatureSlotPair}.
*/
- public int[] getServiceFeatures() {
- return mFeatures.stream().mapToInt(i->i).toArray();
+ public Set<FeatureSlotPair> getServiceFeatures() {
+ return new ArraySet<>(mFeatures);
}
- void addFeature(int feature) {
- mFeatures.add(feature);
+ /**
+ * @hide
+ */
+ void addFeature(int slotId, int feature) {
+ mFeatures.add(new FeatureSlotPair(slotId, feature));
}
/** @hide */
protected ImsFeatureConfiguration(Parcel in) {
- int[] features = in.createIntArray();
- if (features != null) {
- mFeatures = new ArraySet<>(features.length);
- for(Integer i : features) {
- mFeatures.add(i);
- }
- } else {
- mFeatures = new ArraySet<>();
+ int featurePairLength = in.readInt();
+ // length
+ mFeatures = new ArraySet<>(featurePairLength);
+ for (int i = 0; i < featurePairLength; i++) {
+ // pair of reads for each entry (slotId->featureType)
+ mFeatures.add(new FeatureSlotPair(in.readInt(), in.readInt()));
}
}
@@ -138,7 +180,15 @@
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeIntArray(mFeatures.stream().mapToInt(i->i).toArray());
+ FeatureSlotPair[] featureSlotPairs = new FeatureSlotPair[mFeatures.size()];
+ mFeatures.toArray(featureSlotPairs);
+ // length of list
+ dest.writeInt(featureSlotPairs.length);
+ // then pairs of integers for each entry (slotId->featureType).
+ for (FeatureSlotPair featureSlotPair : featureSlotPairs) {
+ dest.writeInt(featureSlotPair.slotId);
+ dest.writeInt(featureSlotPair.featureType);
+ }
}
/**
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 4002d3c..afbb947 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -829,6 +829,12 @@
boolean isEmergencyMmTelAvailable(int slotId);
/**
+ * @return true if the IMS resolver is busy resolving a binding and should not be considered
+ * available, false if the IMS resolver is idle.
+ */
+ boolean isResolvingImsBinding();
+
+ /**
* Set the network selection mode to automatic.
*
* @param subId the id of the subscription to update.
diff --git a/wifi/java/android/net/wifi/rtt/RangingResult.java b/wifi/java/android/net/wifi/rtt/RangingResult.java
index 936a1f2..4705e1d 100644
--- a/wifi/java/android/net/wifi/rtt/RangingResult.java
+++ b/wifi/java/android/net/wifi/rtt/RangingResult.java
@@ -189,7 +189,8 @@
}
/**
- * @return The Location Configuration Information (LCI) as self-reported by the peer.
+ * @return The Location Configuration Information (LCI) as self-reported by the peer. The format
+ * is specified in the IEEE 802.11-2016 specifications, section 9.4.2.22.10.
* <p>
* Note: the information is NOT validated - use with caution. Consider validating it with
* other sources of information before using it.
@@ -207,7 +208,8 @@
}
/**
- * @return The Location Civic report (LCR) as self-reported by the peer.
+ * @return The Location Civic report (LCR) as self-reported by the peer. The format
+ * is specified in the IEEE 802.11-2016 specifications, section 9.4.2.22.13.
* <p>
* Note: the information is NOT validated - use with caution. Consider validating it with
* other sources of information before using it.