Merge "SubscriptionPlan: move out of telephony"
diff --git a/apex/sdkext/Android.bp b/apex/sdkext/Android.bp
index b8dcb90..40f3c45 100644
--- a/apex/sdkext/Android.bp
+++ b/apex/sdkext/Android.bp
@@ -15,7 +15,13 @@
apex {
name: "com.android.sdkext",
manifest: "manifest.json",
+ binaries: [ "derive_sdk" ],
java_libs: [ "framework-sdkext" ],
+ prebuilts: [
+ "com.android.sdkext.ldconfig",
+ "cur_sdkinfo",
+ "derive_sdk.rc",
+ ],
key: "com.android.sdkext.key",
certificate: ":com.android.sdkext.certificate",
}
@@ -30,3 +36,35 @@
name: "com.android.sdkext.certificate",
certificate: "com.android.sdkext",
}
+
+prebuilt_etc {
+ name: "com.android.sdkext.ldconfig",
+ src: "ld.config.txt",
+ filename: "ld.config.txt",
+ installable: false,
+}
+
+python_binary_host {
+ name: "gen_sdkinfo",
+ srcs: [
+ "derive_sdk/sdk.proto",
+ "gen_sdkinfo.py",
+ ],
+ proto: {
+ canonical_path_from_root: false,
+ },
+}
+
+gensrcs {
+ name: "cur_sdkinfo_src",
+ srcs: [""],
+ tools: [ "gen_sdkinfo" ],
+ cmd: "$(location) -v 0 -o $(out)",
+}
+
+prebuilt_etc {
+ name: "cur_sdkinfo",
+ src: ":cur_sdkinfo_src",
+ filename: "sdkinfo.binarypb",
+ installable: false,
+}
diff --git a/apex/sdkext/TEST_MAPPING b/apex/sdkext/TEST_MAPPING
new file mode 100644
index 0000000..8dc732d
--- /dev/null
+++ b/apex/sdkext/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "presubmit": [
+ {
+ "name": "framework-sdkext-tests"
+ }
+ ]
+}
diff --git a/apex/sdkext/derive_sdk/Android.bp b/apex/sdkext/derive_sdk/Android.bp
new file mode 100644
index 0000000..c4e3c29
--- /dev/null
+++ b/apex/sdkext/derive_sdk/Android.bp
@@ -0,0 +1,37 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_binary {
+ name: "derive_sdk",
+ srcs: [
+ "derive_sdk.cpp",
+ "sdk.proto",
+ ],
+ proto: {
+ type: "lite",
+ },
+ sdk_version: "current",
+ stl: "c++_static",
+ shared_libs: [ "liblog" ],
+ static_libs: [
+ "libbase_ndk",
+ "libprotobuf-cpp-lite-ndk",
+ ],
+}
+
+prebuilt_etc {
+ name: "derive_sdk.rc",
+ src: "derive_sdk.rc",
+ installable: false,
+}
diff --git a/apex/sdkext/derive_sdk/derive_sdk.cpp b/apex/sdkext/derive_sdk/derive_sdk.cpp
new file mode 100644
index 0000000..0aacebe
--- /dev/null
+++ b/apex/sdkext/derive_sdk/derive_sdk.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "derive_sdk"
+
+#include <algorithm>
+#include <dirent.h>
+#include <iostream>
+#include <sys/stat.h>
+#include <vector>
+
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <android-base/properties.h>
+
+#include "frameworks/base/apex/sdkext/derive_sdk/sdk.pb.h"
+
+using com::android::sdkext::proto::SdkVersion;
+
+int main(int, char**) {
+ std::unique_ptr<DIR, decltype(&closedir)> apex(opendir("/apex"), closedir);
+ if (!apex) {
+ LOG(ERROR) << "Could not read /apex";
+ return EXIT_FAILURE;
+ }
+ struct dirent* de;
+ std::vector<std::string> paths;
+ while ((de = readdir(apex.get()))) {
+ std::string name = de->d_name;
+ if (name[0] == '.' || name.find('@') != std::string::npos) {
+ // Skip <name>@<ver> dirs, as they are bind-mounted to <name>
+ continue;
+ }
+ std::string path = "/apex/" + name + "/etc/sdkinfo.binarypb";
+ struct stat statbuf;
+ if (stat(path.c_str(), &statbuf) == 0) {
+ paths.push_back(path);
+ }
+ }
+
+ std::vector<int> versions;
+ for (const auto& path : paths) {
+ std::string contents;
+ if (!android::base::ReadFileToString(path, &contents, true)) {
+ LOG(ERROR) << "failed to read " << path;
+ continue;
+ }
+ SdkVersion sdk_version;
+ if (!sdk_version.ParseFromString(contents)) {
+ LOG(ERROR) << "failed to parse " << path;
+ continue;
+ }
+ versions.push_back(sdk_version.version());
+ }
+ auto itr = std::min_element(versions.begin(), versions.end());
+ std::string prop_value = itr == versions.end() ? "0" : std::to_string(*itr);
+
+ if (!android::base::SetProperty("persist.com.android.sdkext.sdk_info", prop_value)) {
+ LOG(ERROR) << "failed to set sdk_info prop";
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/apex/sdkext/derive_sdk/derive_sdk.rc b/apex/sdkext/derive_sdk/derive_sdk.rc
new file mode 100644
index 0000000..1b66794
--- /dev/null
+++ b/apex/sdkext/derive_sdk/derive_sdk.rc
@@ -0,0 +1,3 @@
+service derive_sdk /apex/com.android.sdkext/bin/derive_sdk
+ oneshot
+ disabled
diff --git a/apex/sdkext/derive_sdk/sdk.proto b/apex/sdkext/derive_sdk/sdk.proto
new file mode 100644
index 0000000..d15b935
--- /dev/null
+++ b/apex/sdkext/derive_sdk/sdk.proto
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto3";
+package com.android.sdkext.proto;
+
+option java_outer_classname = "SdkProto";
+option optimize_for = LITE_RUNTIME;
+
+message SdkVersion {
+ int32 version = 1;
+}
diff --git a/apex/sdkext/framework/tests/Android.bp b/apex/sdkext/framework/tests/Android.bp
index 3d5dbb3..ab63275 100644
--- a/apex/sdkext/framework/tests/Android.bp
+++ b/apex/sdkext/framework/tests/Android.bp
@@ -6,5 +6,6 @@
"android.test.runner",
],
static_libs: [ "framework-sdkext" ],
+ test_suites: [ "general-tests" ],
platform_apis: true,
}
diff --git a/apex/sdkext/framework/tests/src/android/os/ext/SdkExtensionsTest.java b/apex/sdkext/framework/tests/src/android/os/ext/SdkExtensionsTest.java
index 6885110..d7dca90 100644
--- a/apex/sdkext/framework/tests/src/android/os/ext/SdkExtensionsTest.java
+++ b/apex/sdkext/framework/tests/src/android/os/ext/SdkExtensionsTest.java
@@ -29,11 +29,6 @@
SdkExtensions.getExtensionVersion(Build.VERSION_CODES.Q);
fail("expected IllegalArgumentException");
} catch (IllegalArgumentException expected) { }
-
- try {
- SdkExtensions.getExtensionVersion(999999);
- fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) { }
}
@SmallTest
diff --git a/apex/sdkext/gen_sdkinfo.py b/apex/sdkext/gen_sdkinfo.py
new file mode 100644
index 0000000..5af478b
--- /dev/null
+++ b/apex/sdkext/gen_sdkinfo.py
@@ -0,0 +1,19 @@
+import sdk_pb2
+import sys
+
+if __name__ == '__main__':
+ argv = sys.argv[1:]
+ if not len(argv) == 4 or sorted([argv[0], argv[2]]) != ['-o', '-v']:
+ print('usage: gen_sdkinfo -v <version> -o <output-file>')
+ sys.exit(1)
+
+ for i in range(len(argv)):
+ if sys.argv[i] == '-o':
+ filename = sys.argv[i+1]
+ if sys.argv[i] == '-v':
+ version = int(sys.argv[i+1])
+
+ proto = sdk_pb2.SdkVersion()
+ proto.version = version
+ with open(filename, 'wb') as f:
+ f.write(proto.SerializeToString())
diff --git a/apex/sdkext/ld.config.txt b/apex/sdkext/ld.config.txt
new file mode 100644
index 0000000..b447068
--- /dev/null
+++ b/apex/sdkext/ld.config.txt
@@ -0,0 +1,31 @@
+# Copyright (C) 2019 The Android Open Source Project
+#
+# Bionic loader config file for the sdkext apex.
+
+dir.sdkext = /apex/com.android.sdkext/bin/
+
+[sdkext]
+additional.namespaces = platform
+
+namespace.default.isolated = true
+namespace.default.links = platform
+namespace.default.link.platform.allow_all_shared_libs = true
+
+###############################################################################
+# "platform" namespace: used for NDK libraries
+###############################################################################
+namespace.platform.isolated = true
+namespace.platform.search.paths = /system/${LIB}
+namespace.platform.asan.search.paths = /data/asan/system/${LIB}
+
+# /system/lib/libc.so, etc are symlinks to /apex/com.android.lib/lib/bionic/libc.so, etc.
+# Add /apex/... path to the permitted paths because linker uses realpath(3)
+# to check the accessibility of the lib. We could add this to search.paths
+# instead but that makes the resolution of bionic libs be dependent on
+# the order of /system/lib and /apex/... in search.paths. If /apex/...
+# is after /system/lib, then /apex/... is never tried because libc.so
+# is always found in /system/lib but fails to pass the accessibility test
+# because of its realpath. It's better to not depend on the ordering if
+# possible.
+namespace.platform.permitted.paths = /apex/com.android.runtime/${LIB}/bionic
+namespace.platform.asan.permitted.paths = /apex/com.android.runtime/${LIB}/bionic
diff --git a/api/current.txt b/api/current.txt
index d9bb73c..d2e1b5f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -29024,12 +29024,14 @@
method public static long getMobileRxPackets();
method public static long getMobileTxBytes();
method public static long getMobileTxPackets();
+ method public static long getRxPackets(@NonNull String);
method public static int getThreadStatsTag();
method public static int getThreadStatsUid();
method public static long getTotalRxBytes();
method public static long getTotalRxPackets();
method public static long getTotalTxBytes();
method public static long getTotalTxPackets();
+ method public static long getTxPackets(@NonNull String);
method public static long getUidRxBytes(int);
method public static long getUidRxPackets(int);
method @Deprecated public static long getUidTcpRxBytes(int);
@@ -42703,6 +42705,7 @@
field public static final int MS_INVALIDATE;
field public static final int MS_SYNC;
field public static final int NETLINK_INET_DIAG;
+ field public static final int NETLINK_NETFILTER;
field public static final int NETLINK_ROUTE;
field public static final int NI_DGRAM;
field public static final int NI_NAMEREQD;
@@ -43113,6 +43116,7 @@
method public int getCallProperties();
method public String getCallerDisplayName();
method public int getCallerDisplayNamePresentation();
+ method public int getCallerNumberVerificationStatus();
method public final long getConnectTimeMillis();
method public long getCreationTimeMillis();
method public android.telecom.DisconnectCause getDisconnectCause();
@@ -43294,6 +43298,7 @@
method public final android.telecom.CallAudioState getCallAudioState();
method public final String getCallerDisplayName();
method public final int getCallerDisplayNamePresentation();
+ method public int getCallerNumberVerificationStatus();
method public final android.telecom.Conference getConference();
method public final java.util.List<android.telecom.Conferenceable> getConferenceables();
method public final int getConnectionCapabilities();
@@ -43345,6 +43350,7 @@
method public final void setAudioModeIsVoip(boolean);
method public final void setAudioRoute(int);
method public final void setCallerDisplayName(String, int);
+ method public void setCallerNumberVerificationStatus(int);
method public final void setConferenceableConnections(java.util.List<android.telecom.Connection>);
method public final void setConferenceables(java.util.List<android.telecom.Conferenceable>);
method public final void setConnectionCapabilities(int);
@@ -43440,6 +43446,9 @@
field public static final int STATE_NEW = 1; // 0x1
field public static final int STATE_PULLING_CALL = 7; // 0x7
field public static final int STATE_RINGING = 2; // 0x2
+ field public static final int VERIFICATION_STATUS_FAILED = 2; // 0x2
+ field public static final int VERIFICATION_STATUS_NOT_VERIFIED = 0; // 0x0
+ field public static final int VERIFICATION_STATUS_PASSED = 1; // 0x1
}
public static final class Connection.RttModifyStatus {
diff --git a/api/system-current.txt b/api/system-current.txt
index 62fe24e..299048e 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -1319,6 +1319,7 @@
public final class BluetoothHeadset implements android.bluetooth.BluetoothProfile {
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean connect(android.bluetooth.BluetoothDevice);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean disconnect(android.bluetooth.BluetoothDevice);
+ method @Nullable @RequiresPermission(android.Manifest.permission.BLUETOOTH) public android.bluetooth.BluetoothDevice getActiveDevice();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getConnectionPolicy(@NonNull android.bluetooth.BluetoothDevice);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setConnectionPolicy(@NonNull android.bluetooth.BluetoothDevice, int);
method @Deprecated @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setPriority(android.bluetooth.BluetoothDevice, int);
@@ -1353,6 +1354,37 @@
field @Deprecated public static final int PRIORITY_ON = 100; // 0x64
}
+ public final class BluetoothUuid {
+ method public static boolean containsAnyUuid(@Nullable android.os.ParcelUuid[], @Nullable android.os.ParcelUuid[]);
+ method @NonNull public static android.os.ParcelUuid parseUuidFrom(@Nullable byte[]);
+ field @NonNull public static final android.os.ParcelUuid A2DP_SINK;
+ field @NonNull public static final android.os.ParcelUuid A2DP_SOURCE;
+ field @NonNull public static final android.os.ParcelUuid ADV_AUDIO_DIST;
+ field @NonNull public static final android.os.ParcelUuid AVRCP_CONTROLLER;
+ field @NonNull public static final android.os.ParcelUuid AVRCP_TARGET;
+ field @NonNull public static final android.os.ParcelUuid BASE_UUID;
+ field @NonNull public static final android.os.ParcelUuid BNEP;
+ field @NonNull public static final android.os.ParcelUuid HEARING_AID;
+ field @NonNull public static final android.os.ParcelUuid HFP;
+ field @NonNull public static final android.os.ParcelUuid HFP_AG;
+ field @NonNull public static final android.os.ParcelUuid HID;
+ field @NonNull public static final android.os.ParcelUuid HOGP;
+ field @NonNull public static final android.os.ParcelUuid HSP;
+ field @NonNull public static final android.os.ParcelUuid HSP_AG;
+ field @NonNull public static final android.os.ParcelUuid MAP;
+ field @NonNull public static final android.os.ParcelUuid MAS;
+ field @NonNull public static final android.os.ParcelUuid MNS;
+ field @NonNull public static final android.os.ParcelUuid NAP;
+ field @NonNull public static final android.os.ParcelUuid OBEX_OBJECT_PUSH;
+ field @NonNull public static final android.os.ParcelUuid PANU;
+ field @NonNull public static final android.os.ParcelUuid PBAP_PCE;
+ field @NonNull public static final android.os.ParcelUuid PBAP_PSE;
+ field @NonNull public static final android.os.ParcelUuid SAP;
+ field public static final int UUID_BYTES_128_BIT = 16; // 0x10
+ field public static final int UUID_BYTES_16_BIT = 2; // 0x2
+ field public static final int UUID_BYTES_32_BIT = 4; // 0x4
+ }
+
}
package android.bluetooth.le {
diff --git a/cmds/telecom/src/com/android/commands/telecom/Telecom.java b/cmds/telecom/src/com/android/commands/telecom/Telecom.java
index 5ffe2f2..9061ed1 100644
--- a/cmds/telecom/src/com/android/commands/telecom/Telecom.java
+++ b/cmds/telecom/src/com/android/commands/telecom/Telecom.java
@@ -16,10 +16,12 @@
package com.android.commands.telecom;
+import android.app.ActivityThread;
import android.content.ComponentName;
import android.content.Context;
import android.net.Uri;
import android.os.IUserManager;
+import android.os.Looper;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -33,7 +35,6 @@
import com.android.internal.os.BaseCommand;
import com.android.internal.telecom.ITelecomService;
-import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.TelephonyProperties;
import java.io.PrintStream;
@@ -83,7 +84,7 @@
private ComponentName mComponent;
private String mAccountId;
private ITelecomService mTelecomService;
- private ITelephony mTelephonyService;
+ private TelephonyManager mTelephonyManager;
private IUserManager mUserManager;
@Override
@@ -154,9 +155,10 @@
return;
}
- mTelephonyService = ITelephony.Stub.asInterface(
- ServiceManager.getService(Context.TELEPHONY_SERVICE));
- if (mTelephonyService == null) {
+ Looper.prepareMainLooper();
+ Context context = ActivityThread.systemMain().getSystemContext();
+ mTelephonyManager = context.getSystemService(TelephonyManager.class);
+ if (mTelephonyManager == null) {
Log.w(this, "onRun: Can't access telephony service.");
showError("Error: Could not access the Telephony Service. Is the system running?");
return;
@@ -352,7 +354,7 @@
}
int numSims = Integer.parseInt(nextArgRequired());
System.out.println("Setting sim count to " + numSims + ". Device may reboot");
- mTelephonyService.switchMultiSimConfig(numSims);
+ mTelephonyManager.switchMultiSimConfig(numSims);
}
/**
@@ -366,8 +368,7 @@
private void runGetMaxPhones() throws RemoteException {
// This assumes the max number of SIMs is 2, which it currently is
- if (TelephonyManager.MULTISIM_ALLOWED
- == mTelephonyService.isMultiSimSupported("com.android.commands.telecom")) {
+ if (TelephonyManager.MULTISIM_ALLOWED == mTelephonyManager.isMultiSimSupported()) {
System.out.println("2");
} else {
System.out.println("1");
diff --git a/core/java/android/app/timedetector/ManualTimeSuggestion.java b/core/java/android/app/timedetector/ManualTimeSuggestion.java
index e7d619a..471606da 100644
--- a/core/java/android/app/timedetector/ManualTimeSuggestion.java
+++ b/core/java/android/app/timedetector/ManualTimeSuggestion.java
@@ -85,7 +85,8 @@
@NonNull
public List<String> getDebugInfo() {
- return Collections.unmodifiableList(mDebugInfo);
+ return mDebugInfo == null
+ ? Collections.emptyList() : Collections.unmodifiableList(mDebugInfo);
}
/**
diff --git a/core/java/android/app/timedetector/PhoneTimeSuggestion.java b/core/java/android/app/timedetector/PhoneTimeSuggestion.java
index 233dbbc..dd02af7 100644
--- a/core/java/android/app/timedetector/PhoneTimeSuggestion.java
+++ b/core/java/android/app/timedetector/PhoneTimeSuggestion.java
@@ -23,7 +23,6 @@
import android.util.TimestampedValue;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -52,20 +51,25 @@
};
private final int mPhoneId;
- @Nullable private TimestampedValue<Long> mUtcTime;
+ @Nullable private final TimestampedValue<Long> mUtcTime;
@Nullable private ArrayList<String> mDebugInfo;
- public PhoneTimeSuggestion(int phoneId) {
- mPhoneId = phoneId;
+ private PhoneTimeSuggestion(Builder builder) {
+ mPhoneId = builder.mPhoneId;
+ mUtcTime = builder.mUtcTime;
+ mDebugInfo = builder.mDebugInfo != null ? new ArrayList<>(builder.mDebugInfo) : null;
}
private static PhoneTimeSuggestion createFromParcel(Parcel in) {
int phoneId = in.readInt();
- PhoneTimeSuggestion suggestion = new PhoneTimeSuggestion(phoneId);
- suggestion.setUtcTime(in.readParcelable(null /* classLoader */));
+ PhoneTimeSuggestion suggestion = new PhoneTimeSuggestion.Builder(phoneId)
+ .setUtcTime(in.readParcelable(null /* classLoader */))
+ .build();
@SuppressWarnings("unchecked")
ArrayList<String> debugInfo = (ArrayList<String>) in.readArrayList(null /* classLoader */);
- suggestion.mDebugInfo = debugInfo;
+ if (debugInfo != null) {
+ suggestion.addDebugInfo(debugInfo);
+ }
return suggestion;
}
@@ -85,10 +89,6 @@
return mPhoneId;
}
- public void setUtcTime(@Nullable TimestampedValue<Long> utcTime) {
- mUtcTime = utcTime;
- }
-
@Nullable
public TimestampedValue<Long> getUtcTime() {
return mUtcTime;
@@ -96,7 +96,8 @@
@NonNull
public List<String> getDebugInfo() {
- return Collections.unmodifiableList(mDebugInfo);
+ return mDebugInfo == null
+ ? Collections.emptyList() : Collections.unmodifiableList(mDebugInfo);
}
/**
@@ -104,11 +105,23 @@
* information is present in {@link #toString()} but is not considered for
* {@link #equals(Object)} and {@link #hashCode()}.
*/
- public void addDebugInfo(String... debugInfos) {
+ public void addDebugInfo(String debugInfo) {
if (mDebugInfo == null) {
mDebugInfo = new ArrayList<>();
}
- mDebugInfo.addAll(Arrays.asList(debugInfos));
+ mDebugInfo.add(debugInfo);
+ }
+
+ /**
+ * Associates information with the instance that can be useful for debugging / logging. The
+ * information is present in {@link #toString()} but is not considered for
+ * {@link #equals(Object)} and {@link #hashCode()}.
+ */
+ public void addDebugInfo(@NonNull List<String> debugInfo) {
+ if (mDebugInfo == null) {
+ mDebugInfo = new ArrayList<>(debugInfo.size());
+ }
+ mDebugInfo.addAll(debugInfo);
}
@Override
@@ -137,4 +150,39 @@
+ ", mDebugInfo=" + mDebugInfo
+ '}';
}
+
+ /**
+ * Builds {@link PhoneTimeSuggestion} instances.
+ *
+ * @hide
+ */
+ public static class Builder {
+ private final int mPhoneId;
+ private TimestampedValue<Long> mUtcTime;
+ private List<String> mDebugInfo;
+
+ public Builder(int phoneId) {
+ mPhoneId = phoneId;
+ }
+
+ /** Returns the builder for call chaining. */
+ public Builder setUtcTime(TimestampedValue<Long> utcTime) {
+ mUtcTime = utcTime;
+ return this;
+ }
+
+ /** Returns the builder for call chaining. */
+ public Builder addDebugInfo(@NonNull String debugInfo) {
+ if (mDebugInfo == null) {
+ mDebugInfo = new ArrayList<>();
+ }
+ mDebugInfo.add(debugInfo);
+ return this;
+ }
+
+ /** Returns the {@link PhoneTimeSuggestion}. */
+ public PhoneTimeSuggestion build() {
+ return new PhoneTimeSuggestion(this);
+ }
+ }
}
diff --git a/core/java/android/bluetooth/BluetoothA2dp.java b/core/java/android/bluetooth/BluetoothA2dp.java
index accdd8d..8ed61b6 100644
--- a/core/java/android/bluetooth/BluetoothA2dp.java
+++ b/core/java/android/bluetooth/BluetoothA2dp.java
@@ -610,7 +610,7 @@
if (uuids == null) return false;
for (ParcelUuid uuid : uuids) {
- if (BluetoothUuid.isAvrcpTarget(uuid)) {
+ if (uuid.equals(BluetoothUuid.AVRCP_TARGET)) {
return true;
}
}
diff --git a/core/java/android/bluetooth/BluetoothHeadset.java b/core/java/android/bluetooth/BluetoothHeadset.java
index ea3831a..0955b10 100644
--- a/core/java/android/bluetooth/BluetoothHeadset.java
+++ b/core/java/android/bluetooth/BluetoothHeadset.java
@@ -559,7 +559,7 @@
*
* <p> The device should already be paired.
* Priority can be one of {@link BluetoothProfile#PRIORITY_ON} or
- * {@link BluetoothProfile#PRIORITY_OFF},
+ * {@link BluetoothProfile#PRIORITY_OFF}
*
* @param device Paired bluetooth device
* @param priority
@@ -1133,8 +1133,9 @@
* is active.
* @hide
*/
+ @SystemApi
+ @Nullable
@RequiresPermission(android.Manifest.permission.BLUETOOTH)
- @UnsupportedAppUsage
public BluetoothDevice getActiveDevice() {
if (VDBG) {
Log.d(TAG, "getActiveDevice");
diff --git a/core/java/android/bluetooth/BluetoothHeadsetClient.java b/core/java/android/bluetooth/BluetoothHeadsetClient.java
index a8e1fd2..7ee29ff 100644
--- a/core/java/android/bluetooth/BluetoothHeadsetClient.java
+++ b/core/java/android/bluetooth/BluetoothHeadsetClient.java
@@ -557,7 +557,7 @@
* Set priority of the profile
*
* <p> The device should already be paired.
- * Priority can be one of {@link #PRIORITY_ON} or {@link #PRIORITY_OFF},
+ * Priority can be one of {@link #PRIORITY_ON} or {@link #PRIORITY_OFF}
*
* @param device Paired bluetooth device
* @param priority
diff --git a/core/java/android/bluetooth/BluetoothUuid.java b/core/java/android/bluetooth/BluetoothUuid.java
index bc3c9a9..7e96c23 100644
--- a/core/java/android/bluetooth/BluetoothUuid.java
+++ b/core/java/android/bluetooth/BluetoothUuid.java
@@ -16,8 +16,10 @@
package android.bluetooth;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.annotation.UnsupportedAppUsage;
-import android.os.Build;
import android.os.ParcelUuid;
import java.nio.ByteBuffer;
@@ -31,6 +33,7 @@
*
* @hide
*/
+@SystemApi
public final class BluetoothUuid {
/* See Bluetooth Assigned Numbers document - SDP section, to get the values of UUIDs
@@ -39,167 +42,157 @@
* The following 128 bit values are calculated as:
* uuid * 2^96 + BASE_UUID
*/
- @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
- public static final ParcelUuid AudioSink =
+
+ /** @hide */
+ @NonNull
+ @SystemApi
+ public static final ParcelUuid A2DP_SINK =
ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB");
- public static final ParcelUuid AudioSource =
+ /** @hide */
+ @NonNull
+ @SystemApi
+ public static final ParcelUuid A2DP_SOURCE =
ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
- @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
- public static final ParcelUuid AdvAudioDist =
+ /** @hide */
+ @NonNull
+ @SystemApi
+ public static final ParcelUuid ADV_AUDIO_DIST =
ParcelUuid.fromString("0000110D-0000-1000-8000-00805F9B34FB");
- @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
+ /** @hide */
+ @NonNull
+ @SystemApi
public static final ParcelUuid HSP =
ParcelUuid.fromString("00001108-0000-1000-8000-00805F9B34FB");
+ /** @hide */
+ @NonNull
+ @SystemApi
public static final ParcelUuid HSP_AG =
ParcelUuid.fromString("00001112-0000-1000-8000-00805F9B34FB");
- @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
- public static final ParcelUuid Handsfree =
+ /** @hide */
+ @NonNull
+ @SystemApi
+ public static final ParcelUuid HFP =
ParcelUuid.fromString("0000111E-0000-1000-8000-00805F9B34FB");
- public static final ParcelUuid Handsfree_AG =
+ /** @hide */
+ @NonNull
+ @SystemApi
+ public static final ParcelUuid HFP_AG =
ParcelUuid.fromString("0000111F-0000-1000-8000-00805F9B34FB");
- public static final ParcelUuid AvrcpController =
+ /** @hide */
+ @NonNull
+ @SystemApi
+ public static final ParcelUuid AVRCP_CONTROLLER =
ParcelUuid.fromString("0000110E-0000-1000-8000-00805F9B34FB");
- public static final ParcelUuid AvrcpTarget =
+ /** @hide */
+ @NonNull
+ @SystemApi
+ public static final ParcelUuid AVRCP_TARGET =
ParcelUuid.fromString("0000110C-0000-1000-8000-00805F9B34FB");
- @UnsupportedAppUsage
- public static final ParcelUuid ObexObjectPush =
+ /** @hide */
+ @NonNull
+ @SystemApi
+ public static final ParcelUuid OBEX_OBJECT_PUSH =
ParcelUuid.fromString("00001105-0000-1000-8000-00805f9b34fb");
- public static final ParcelUuid Hid =
+ /** @hide */
+ @NonNull
+ @SystemApi
+ public static final ParcelUuid HID =
ParcelUuid.fromString("00001124-0000-1000-8000-00805f9b34fb");
- @UnsupportedAppUsage
- public static final ParcelUuid Hogp =
+ /** @hide */
+ @NonNull
+ @SystemApi
+ public static final ParcelUuid HOGP =
ParcelUuid.fromString("00001812-0000-1000-8000-00805f9b34fb");
+ /** @hide */
+ @NonNull
+ @SystemApi
public static final ParcelUuid PANU =
ParcelUuid.fromString("00001115-0000-1000-8000-00805F9B34FB");
- @UnsupportedAppUsage
+ /** @hide */
+ @NonNull
+ @SystemApi
public static final ParcelUuid NAP =
ParcelUuid.fromString("00001116-0000-1000-8000-00805F9B34FB");
+ /** @hide */
+ @NonNull
+ @SystemApi
public static final ParcelUuid BNEP =
ParcelUuid.fromString("0000000f-0000-1000-8000-00805F9B34FB");
+ /** @hide */
+ @NonNull
+ @SystemApi
public static final ParcelUuid PBAP_PCE =
ParcelUuid.fromString("0000112e-0000-1000-8000-00805F9B34FB");
- @UnsupportedAppUsage
+ /** @hide */
+ @NonNull
+ @SystemApi
public static final ParcelUuid PBAP_PSE =
ParcelUuid.fromString("0000112f-0000-1000-8000-00805F9B34FB");
+ /** @hide */
+ @NonNull
+ @SystemApi
public static final ParcelUuid MAP =
ParcelUuid.fromString("00001134-0000-1000-8000-00805F9B34FB");
+ /** @hide */
+ @NonNull
+ @SystemApi
public static final ParcelUuid MNS =
ParcelUuid.fromString("00001133-0000-1000-8000-00805F9B34FB");
+ /** @hide */
+ @NonNull
+ @SystemApi
public static final ParcelUuid MAS =
ParcelUuid.fromString("00001132-0000-1000-8000-00805F9B34FB");
+ /** @hide */
+ @NonNull
+ @SystemApi
public static final ParcelUuid SAP =
ParcelUuid.fromString("0000112D-0000-1000-8000-00805F9B34FB");
- public static final ParcelUuid HearingAid =
+ /** @hide */
+ @NonNull
+ @SystemApi
+ public static final ParcelUuid HEARING_AID =
ParcelUuid.fromString("0000FDF0-0000-1000-8000-00805f9b34fb");
+ /** @hide */
+ @NonNull
+ @SystemApi
public static final ParcelUuid BASE_UUID =
ParcelUuid.fromString("00000000-0000-1000-8000-00805F9B34FB");
- /** Length of bytes for 16 bit UUID */
- public static final int UUID_BYTES_16_BIT = 2;
- /** Length of bytes for 32 bit UUID */
- public static final int UUID_BYTES_32_BIT = 4;
- /** Length of bytes for 128 bit UUID */
- public static final int UUID_BYTES_128_BIT = 16;
-
- @UnsupportedAppUsage
- public static final ParcelUuid[] RESERVED_UUIDS = {
- AudioSink, AudioSource, AdvAudioDist, HSP, Handsfree, AvrcpController, AvrcpTarget,
- ObexObjectPush, PANU, NAP, MAP, MNS, MAS, SAP};
-
- @UnsupportedAppUsage
- public static boolean isAudioSource(ParcelUuid uuid) {
- return uuid.equals(AudioSource);
- }
-
- public static boolean isAudioSink(ParcelUuid uuid) {
- return uuid.equals(AudioSink);
- }
-
- @UnsupportedAppUsage
- public static boolean isAdvAudioDist(ParcelUuid uuid) {
- return uuid.equals(AdvAudioDist);
- }
-
- public static boolean isHandsfree(ParcelUuid uuid) {
- return uuid.equals(Handsfree);
- }
-
- public static boolean isHeadset(ParcelUuid uuid) {
- return uuid.equals(HSP);
- }
-
- public static boolean isAvrcpController(ParcelUuid uuid) {
- return uuid.equals(AvrcpController);
- }
-
- @UnsupportedAppUsage
- public static boolean isAvrcpTarget(ParcelUuid uuid) {
- return uuid.equals(AvrcpTarget);
- }
-
- public static boolean isInputDevice(ParcelUuid uuid) {
- return uuid.equals(Hid);
- }
-
- public static boolean isPanu(ParcelUuid uuid) {
- return uuid.equals(PANU);
- }
-
- public static boolean isNap(ParcelUuid uuid) {
- return uuid.equals(NAP);
- }
-
- public static boolean isBnep(ParcelUuid uuid) {
- return uuid.equals(BNEP);
- }
-
- public static boolean isMap(ParcelUuid uuid) {
- return uuid.equals(MAP);
- }
-
- public static boolean isMns(ParcelUuid uuid) {
- return uuid.equals(MNS);
- }
-
- public static boolean isMas(ParcelUuid uuid) {
- return uuid.equals(MAS);
- }
-
- public static boolean isSap(ParcelUuid uuid) {
- return uuid.equals(SAP);
- }
-
/**
- * Returns true if ParcelUuid is present in uuidArray
+ * Length of bytes for 16 bit UUID
*
- * @param uuidArray - Array of ParcelUuids
- * @param uuid
+ * @hide
*/
- @UnsupportedAppUsage
- public static boolean isUuidPresent(ParcelUuid[] uuidArray, ParcelUuid uuid) {
- if ((uuidArray == null || uuidArray.length == 0) && uuid == null) {
- return true;
- }
-
- if (uuidArray == null) {
- return false;
- }
-
- for (ParcelUuid element : uuidArray) {
- if (element.equals(uuid)) return true;
- }
- return false;
- }
+ @SystemApi
+ public static final int UUID_BYTES_16_BIT = 2;
+ /**
+ * Length of bytes for 32 bit UUID
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int UUID_BYTES_32_BIT = 4;
+ /**
+ * Length of bytes for 128 bit UUID
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int UUID_BYTES_128_BIT = 16;
/**
* Returns true if there any common ParcelUuids in uuidA and uuidB.
*
* @param uuidA - List of ParcelUuids
* @param uuidB - List of ParcelUuids
+ *
+ * @hide
*/
- @UnsupportedAppUsage
- public static boolean containsAnyUuid(ParcelUuid[] uuidA, ParcelUuid[] uuidB) {
+ @SystemApi
+ public static boolean containsAnyUuid(@Nullable ParcelUuid[] uuidA,
+ @Nullable ParcelUuid[] uuidB) {
if (uuidA == null && uuidB == null) return true;
if (uuidA == null) {
@@ -218,29 +211,6 @@
}
/**
- * Returns true if all the ParcelUuids in ParcelUuidB are present in
- * ParcelUuidA
- *
- * @param uuidA - Array of ParcelUuidsA
- * @param uuidB - Array of ParcelUuidsB
- */
- public static boolean containsAllUuids(ParcelUuid[] uuidA, ParcelUuid[] uuidB) {
- if (uuidA == null && uuidB == null) return true;
-
- if (uuidA == null) {
- return uuidB.length == 0;
- }
-
- if (uuidB == null) return true;
-
- HashSet<ParcelUuid> uuidSet = new HashSet<ParcelUuid>(Arrays.asList(uuidA));
- for (ParcelUuid uuid : uuidB) {
- if (!uuidSet.contains(uuid)) return false;
- }
- return true;
- }
-
- /**
* Extract the Service Identifier or the actual uuid from the Parcel Uuid.
* For example, if 0000110B-0000-1000-8000-00805F9B34FB is the parcel Uuid,
* this function will return 110B
@@ -248,7 +218,7 @@
* @param parcelUuid
* @return the service identifier.
*/
- public static int getServiceIdentifierFromParcelUuid(ParcelUuid parcelUuid) {
+ private static int getServiceIdentifierFromParcelUuid(ParcelUuid parcelUuid) {
UUID uuid = parcelUuid.getUuid();
long value = (uuid.getMostSignificantBits() & 0xFFFFFFFF00000000L) >>> 32;
return (int) value;
@@ -262,8 +232,12 @@
* @param uuidBytes Byte representation of uuid.
* @return {@link ParcelUuid} parsed from bytes.
* @throws IllegalArgumentException If the {@code uuidBytes} cannot be parsed.
+ *
+ * @hide
*/
- public static ParcelUuid parseUuidFrom(byte[] uuidBytes) {
+ @NonNull
+ @SystemApi
+ public static ParcelUuid parseUuidFrom(@Nullable byte[] uuidBytes) {
if (uuidBytes == null) {
throw new IllegalArgumentException("uuidBytes cannot be null");
}
@@ -305,6 +279,8 @@
* @param uuid uuid to parse.
* @return shortest representation of {@code uuid} as bytes.
* @throws IllegalArgumentException If the {@code uuid} is null.
+ *
+ * @hide
*/
public static byte[] uuidToBytes(ParcelUuid uuid) {
if (uuid == null) {
@@ -345,6 +321,8 @@
*
* @param parcelUuid
* @return true if the parcelUuid can be converted to 16 bit uuid, false otherwise.
+ *
+ * @hide
*/
@UnsupportedAppUsage
public static boolean is16BitUuid(ParcelUuid parcelUuid) {
@@ -361,6 +339,8 @@
*
* @param parcelUuid
* @return true if the parcelUuid can be converted to 32 bit uuid, false otherwise.
+ *
+ * @hide
*/
@UnsupportedAppUsage
public static boolean is32BitUuid(ParcelUuid parcelUuid) {
@@ -373,4 +353,6 @@
}
return ((uuid.getMostSignificantBits() & 0xFFFFFFFFL) == 0x1000L);
}
+
+ private BluetoothUuid() {}
}
diff --git a/core/java/android/net/TrafficStats.java b/core/java/android/net/TrafficStats.java
index 1c6a484..bf4884a 100644
--- a/core/java/android/net/TrafficStats.java
+++ b/core/java/android/net/TrafficStats.java
@@ -16,6 +16,7 @@
package android.net;
+import android.annotation.NonNull;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
@@ -595,8 +596,15 @@
return total;
}
- /** {@hide} */
- public static long getTxPackets(String iface) {
+ /**
+ * Return the number of packets transmitted on the specified interface since
+ * device boot. Statistics are measured at the network layer, so both TCP and
+ * UDP usage are included.
+ *
+ * @param iface The name of the interface.
+ * @return The number of transmitted packets.
+ */
+ public static long getTxPackets(@NonNull String iface) {
try {
return getStatsService().getIfaceStats(iface, TYPE_TX_PACKETS);
} catch (RemoteException e) {
@@ -604,8 +612,15 @@
}
}
- /** {@hide} */
- public static long getRxPackets(String iface) {
+ /**
+ * Return the number of packets received on the specified interface since
+ * device boot. Statistics are measured at the network layer, so both TCP
+ * and UDP usage are included.
+ *
+ * @param iface The name of the interface.
+ * @return The number of received packets.
+ */
+ public static long getRxPackets(@NonNull String iface) {
try {
return getStatsService().getIfaceStats(iface, TYPE_RX_PACKETS);
} catch (RemoteException e) {
diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java
index 5c42730..308c8b3 100644
--- a/core/java/android/telephony/TelephonyRegistryManager.java
+++ b/core/java/android/telephony/TelephonyRegistryManager.java
@@ -463,6 +463,19 @@
}
/**
+ * Sim activation type: voice
+ * @see #notifyVoiceActivationStateChanged
+ * @hide
+ */
+ public static final int SIM_ACTIVATION_TYPE_VOICE = 0;
+ /**
+ * Sim activation type: data
+ * @see #notifyDataActivationStateChanged
+ * @hide
+ */
+ public static final int SIM_ACTIVATION_TYPE_DATA = 1;
+
+ /**
* Notify data activation state changed on certain subscription.
* @see TelephonyManager#getDataActivationState()
*
@@ -477,7 +490,7 @@
@SimActivationState int activationState) {
try {
sRegistry.notifySimActivationStateChangedForPhoneId(slotIndex, subId,
- TelephonyManager.SIM_ACTIVATION_TYPE_DATA, activationState);
+ SIM_ACTIVATION_TYPE_DATA, activationState);
} catch (RemoteException ex) {
// system process is dead
}
@@ -498,7 +511,7 @@
@SimActivationState int activationState) {
try {
sRegistry.notifySimActivationStateChangedForPhoneId(slotIndex, subId,
- TelephonyManager.SIM_ACTIVATION_TYPE_VOICE, activationState);
+ SIM_ACTIVATION_TYPE_VOICE, activationState);
} catch (RemoteException ex) {
// system process is dead
}
diff --git a/core/tests/coretests/src/android/app/timedetector/ManualTimeSuggestionTest.java b/core/tests/coretests/src/android/app/timedetector/ManualTimeSuggestionTest.java
new file mode 100644
index 0000000..de6f8f7
--- /dev/null
+++ b/core/tests/coretests/src/android/app/timedetector/ManualTimeSuggestionTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.app.timedetector;
+
+import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
+import static android.app.timezonedetector.ParcelableTestSupport.roundTripParcelable;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import android.util.TimestampedValue;
+
+import org.junit.Test;
+
+public class ManualTimeSuggestionTest {
+
+ private static final TimestampedValue<Long> ARBITRARY_TIME =
+ new TimestampedValue<>(1111L, 2222L);
+
+ @Test
+ public void testEquals() {
+ ManualTimeSuggestion one = new ManualTimeSuggestion(ARBITRARY_TIME);
+ assertEquals(one, one);
+
+ ManualTimeSuggestion two = new ManualTimeSuggestion(ARBITRARY_TIME);
+ assertEquals(one, two);
+ assertEquals(two, one);
+
+ TimestampedValue<Long> differentTime = new TimestampedValue<>(
+ ARBITRARY_TIME.getReferenceTimeMillis() + 1,
+ ARBITRARY_TIME.getValue());
+ ManualTimeSuggestion three = new ManualTimeSuggestion(differentTime);
+ assertNotEquals(one, three);
+ assertNotEquals(three, one);
+
+ // DebugInfo must not be considered in equals().
+ one.addDebugInfo("Debug info 1");
+ two.addDebugInfo("Debug info 2");
+ assertEquals(one, two);
+ }
+
+ @Test
+ public void testParcelable() {
+ ManualTimeSuggestion suggestion = new ManualTimeSuggestion(ARBITRARY_TIME);
+ assertRoundTripParcelable(suggestion);
+
+ // DebugInfo should also be stored (but is not checked by equals()
+ suggestion.addDebugInfo("This is debug info");
+ ManualTimeSuggestion rtSuggestion = roundTripParcelable(suggestion);
+ assertEquals(suggestion.getDebugInfo(), rtSuggestion.getDebugInfo());
+ }
+}
diff --git a/core/tests/coretests/src/android/app/timedetector/PhoneTimeSuggestionTest.java b/core/tests/coretests/src/android/app/timedetector/PhoneTimeSuggestionTest.java
index c9a86dc..bee270e 100644
--- a/core/tests/coretests/src/android/app/timedetector/PhoneTimeSuggestionTest.java
+++ b/core/tests/coretests/src/android/app/timedetector/PhoneTimeSuggestionTest.java
@@ -16,11 +16,12 @@
package android.app.timedetector;
+import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
+import static android.app.timezonedetector.ParcelableTestSupport.roundTripParcelable;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
-import android.os.Parcel;
-import android.os.Parcelable;
import android.util.TimestampedValue;
import org.junit.Test;
@@ -30,53 +31,67 @@
@Test
public void testEquals() {
- PhoneTimeSuggestion one = new PhoneTimeSuggestion(PHONE_ID);
- assertEquals(one, one);
+ PhoneTimeSuggestion.Builder builder1 = new PhoneTimeSuggestion.Builder(PHONE_ID);
+ {
+ PhoneTimeSuggestion one = builder1.build();
+ assertEquals(one, one);
+ }
- PhoneTimeSuggestion two = new PhoneTimeSuggestion(PHONE_ID);
- assertEquals(one, two);
- assertEquals(two, one);
+ PhoneTimeSuggestion.Builder builder2 = new PhoneTimeSuggestion.Builder(PHONE_ID);
+ {
+ PhoneTimeSuggestion one = builder1.build();
+ PhoneTimeSuggestion two = builder2.build();
+ assertEquals(one, two);
+ assertEquals(two, one);
+ }
- one.setUtcTime(new TimestampedValue<>(1111L, 2222L));
- assertEquals(one, one);
+ builder1.setUtcTime(new TimestampedValue<>(1111L, 2222L));
+ {
+ PhoneTimeSuggestion one = builder1.build();
+ assertEquals(one, one);
+ }
- two.setUtcTime(new TimestampedValue<>(1111L, 2222L));
- assertEquals(one, two);
- assertEquals(two, one);
+ builder2.setUtcTime(new TimestampedValue<>(1111L, 2222L));
+ {
+ PhoneTimeSuggestion one = builder1.build();
+ PhoneTimeSuggestion two = builder2.build();
+ assertEquals(one, two);
+ assertEquals(two, one);
+ }
- PhoneTimeSuggestion three = new PhoneTimeSuggestion(PHONE_ID + 1);
- three.setUtcTime(new TimestampedValue<>(1111L, 2222L));
- assertNotEquals(one, three);
- assertNotEquals(three, one);
+ PhoneTimeSuggestion.Builder builder3 = new PhoneTimeSuggestion.Builder(PHONE_ID + 1);
+ builder3.setUtcTime(new TimestampedValue<>(1111L, 2222L));
+ {
+ PhoneTimeSuggestion one = builder1.build();
+ PhoneTimeSuggestion three = builder3.build();
+ assertNotEquals(one, three);
+ assertNotEquals(three, one);
+ }
// DebugInfo must not be considered in equals().
- one.addDebugInfo("Debug info 1");
- two.addDebugInfo("Debug info 2");
- assertEquals(one, two);
+ builder1.addDebugInfo("Debug info 1");
+ builder2.addDebugInfo("Debug info 2");
+ {
+ PhoneTimeSuggestion one = builder1.build();
+ PhoneTimeSuggestion two = builder2.build();
+ assertEquals(one, two);
+ }
}
@Test
public void testParcelable() {
- PhoneTimeSuggestion one = new PhoneTimeSuggestion(PHONE_ID);
- assertEquals(one, roundTripParcelable(one));
+ PhoneTimeSuggestion.Builder builder = new PhoneTimeSuggestion.Builder(PHONE_ID);
+ assertRoundTripParcelable(builder.build());
- one.setUtcTime(new TimestampedValue<>(1111L, 2222L));
- assertEquals(one, roundTripParcelable(one));
+ builder.setUtcTime(new TimestampedValue<>(1111L, 2222L));
+ assertRoundTripParcelable(builder.build());
// DebugInfo should also be stored (but is not checked by equals()
- one.addDebugInfo("This is debug info");
- PhoneTimeSuggestion two = roundTripParcelable(one);
- assertEquals(one.getDebugInfo(), two.getDebugInfo());
- }
-
- @SuppressWarnings("unchecked")
- private static <T extends Parcelable> T roundTripParcelable(T one) {
- Parcel parcel = Parcel.obtain();
- parcel.writeTypedObject(one, 0);
- parcel.setDataPosition(0);
-
- T toReturn = (T) parcel.readTypedObject(PhoneTimeSuggestion.CREATOR);
- parcel.recycle();
- return toReturn;
+ {
+ PhoneTimeSuggestion suggestion1 = builder.build();
+ builder.addDebugInfo("This is debug info");
+ PhoneTimeSuggestion rtSuggestion1 = roundTripParcelable(suggestion1);
+ assertEquals(suggestion1.getDebugInfo(), rtSuggestion1.getDebugInfo());
+ }
}
}
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index 900572d..3455c4f 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -30,7 +30,9 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
/* IF YOU CHANGE ANY OF THE CONSTANTS IN THIS FILE, DO NOT FORGET
* TO UPDATE THE CORRESPONDING NATIVE GLUE AND AudioManager.java.
@@ -541,51 +543,75 @@
public static final int DEVICE_OUT_DEFAULT = DEVICE_BIT_DEFAULT;
- public static final int DEVICE_OUT_ALL = (DEVICE_OUT_EARPIECE |
- DEVICE_OUT_SPEAKER |
- DEVICE_OUT_WIRED_HEADSET |
- DEVICE_OUT_WIRED_HEADPHONE |
- DEVICE_OUT_BLUETOOTH_SCO |
- DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
- DEVICE_OUT_BLUETOOTH_SCO_CARKIT |
- DEVICE_OUT_BLUETOOTH_A2DP |
- DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
- DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER |
- DEVICE_OUT_HDMI |
- DEVICE_OUT_ANLG_DOCK_HEADSET |
- DEVICE_OUT_DGTL_DOCK_HEADSET |
- DEVICE_OUT_USB_ACCESSORY |
- DEVICE_OUT_USB_DEVICE |
- DEVICE_OUT_REMOTE_SUBMIX |
- DEVICE_OUT_TELEPHONY_TX |
- DEVICE_OUT_LINE |
- DEVICE_OUT_HDMI_ARC |
- DEVICE_OUT_SPDIF |
- DEVICE_OUT_FM |
- DEVICE_OUT_AUX_LINE |
- DEVICE_OUT_SPEAKER_SAFE |
- DEVICE_OUT_IP |
- DEVICE_OUT_BUS |
- DEVICE_OUT_PROXY |
- DEVICE_OUT_USB_HEADSET |
- DEVICE_OUT_HEARING_AID |
- DEVICE_OUT_DEFAULT);
- public static final int DEVICE_OUT_ALL_A2DP = (DEVICE_OUT_BLUETOOTH_A2DP |
- DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
- DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER);
- public static final int DEVICE_OUT_ALL_SCO = (DEVICE_OUT_BLUETOOTH_SCO |
- DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
- DEVICE_OUT_BLUETOOTH_SCO_CARKIT);
+ // Deprecated in R because multiple device types are no longer accessed as a bit mask.
+ // Removing this will get lint warning about changing hidden apis.
@UnsupportedAppUsage
public static final int DEVICE_OUT_ALL_USB = (DEVICE_OUT_USB_ACCESSORY |
DEVICE_OUT_USB_DEVICE |
DEVICE_OUT_USB_HEADSET);
- public static final int DEVICE_OUT_ALL_HDMI_SYSTEM_AUDIO = (DEVICE_OUT_AUX_LINE |
- DEVICE_OUT_HDMI_ARC |
- DEVICE_OUT_SPDIF);
- public static final int DEVICE_ALL_HDMI_SYSTEM_AUDIO_AND_SPEAKER =
- (DEVICE_OUT_ALL_HDMI_SYSTEM_AUDIO |
- DEVICE_OUT_SPEAKER);
+
+ public static final Set<Integer> DEVICE_OUT_ALL_SET;
+ public static final Set<Integer> DEVICE_OUT_ALL_A2DP_SET;
+ public static final Set<Integer> DEVICE_OUT_ALL_SCO_SET;
+ public static final Set<Integer> DEVICE_OUT_ALL_USB_SET;
+ public static final Set<Integer> DEVICE_OUT_ALL_HDMI_SYSTEM_AUDIO_SET;
+ public static final Set<Integer> DEVICE_ALL_HDMI_SYSTEM_AUDIO_AND_SPEAKER_SET;
+ static {
+ DEVICE_OUT_ALL_SET = new HashSet<>();
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_EARPIECE);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_SPEAKER);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_WIRED_HEADSET);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_WIRED_HEADPHONE);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_BLUETOOTH_SCO);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_BLUETOOTH_SCO_HEADSET);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_BLUETOOTH_SCO_CARKIT);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_BLUETOOTH_A2DP);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_HDMI);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_ANLG_DOCK_HEADSET);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_DGTL_DOCK_HEADSET);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_USB_ACCESSORY);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_USB_DEVICE);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_REMOTE_SUBMIX);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_TELEPHONY_TX);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_LINE);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_HDMI_ARC);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_SPDIF);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_FM);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_AUX_LINE);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_SPEAKER_SAFE);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_IP);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_BUS);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_PROXY);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_USB_HEADSET);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_HEARING_AID);
+ DEVICE_OUT_ALL_SET.add(DEVICE_OUT_DEFAULT);
+
+ DEVICE_OUT_ALL_A2DP_SET = new HashSet<>();
+ DEVICE_OUT_ALL_A2DP_SET.add(DEVICE_OUT_BLUETOOTH_A2DP);
+ DEVICE_OUT_ALL_A2DP_SET.add(DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES);
+ DEVICE_OUT_ALL_A2DP_SET.add(DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER);
+
+ DEVICE_OUT_ALL_SCO_SET = new HashSet<>();
+ DEVICE_OUT_ALL_SCO_SET.add(DEVICE_OUT_BLUETOOTH_SCO);
+ DEVICE_OUT_ALL_SCO_SET.add(DEVICE_OUT_BLUETOOTH_SCO_HEADSET);
+ DEVICE_OUT_ALL_SCO_SET.add(DEVICE_OUT_BLUETOOTH_SCO_CARKIT);
+
+ DEVICE_OUT_ALL_USB_SET = new HashSet<>();
+ DEVICE_OUT_ALL_USB_SET.add(DEVICE_OUT_USB_ACCESSORY);
+ DEVICE_OUT_ALL_USB_SET.add(DEVICE_OUT_USB_DEVICE);
+ DEVICE_OUT_ALL_USB_SET.add(DEVICE_OUT_USB_HEADSET);
+
+ DEVICE_OUT_ALL_HDMI_SYSTEM_AUDIO_SET = new HashSet<>();
+ DEVICE_OUT_ALL_HDMI_SYSTEM_AUDIO_SET.add(DEVICE_OUT_AUX_LINE);
+ DEVICE_OUT_ALL_HDMI_SYSTEM_AUDIO_SET.add(DEVICE_OUT_HDMI_ARC);
+ DEVICE_OUT_ALL_HDMI_SYSTEM_AUDIO_SET.add(DEVICE_OUT_SPDIF);
+
+ DEVICE_ALL_HDMI_SYSTEM_AUDIO_AND_SPEAKER_SET = new HashSet<>();
+ DEVICE_ALL_HDMI_SYSTEM_AUDIO_AND_SPEAKER_SET.addAll(DEVICE_OUT_ALL_HDMI_SYSTEM_AUDIO_SET);
+ DEVICE_ALL_HDMI_SYSTEM_AUDIO_AND_SPEAKER_SET.add(DEVICE_OUT_SPEAKER);
+ }
// input devices
@UnsupportedAppUsage
@@ -633,37 +659,47 @@
@UnsupportedAppUsage
public static final int DEVICE_IN_DEFAULT = DEVICE_BIT_IN | DEVICE_BIT_DEFAULT;
- public static final int DEVICE_IN_ALL = (DEVICE_IN_COMMUNICATION |
- DEVICE_IN_AMBIENT |
- DEVICE_IN_BUILTIN_MIC |
- DEVICE_IN_BLUETOOTH_SCO_HEADSET |
- DEVICE_IN_WIRED_HEADSET |
- DEVICE_IN_HDMI |
- DEVICE_IN_TELEPHONY_RX |
- DEVICE_IN_BACK_MIC |
- DEVICE_IN_REMOTE_SUBMIX |
- DEVICE_IN_ANLG_DOCK_HEADSET |
- DEVICE_IN_DGTL_DOCK_HEADSET |
- DEVICE_IN_USB_ACCESSORY |
- DEVICE_IN_USB_DEVICE |
- DEVICE_IN_FM_TUNER |
- DEVICE_IN_TV_TUNER |
- DEVICE_IN_LINE |
- DEVICE_IN_SPDIF |
- DEVICE_IN_BLUETOOTH_A2DP |
- DEVICE_IN_LOOPBACK |
- DEVICE_IN_IP |
- DEVICE_IN_BUS |
- DEVICE_IN_PROXY |
- DEVICE_IN_USB_HEADSET |
- DEVICE_IN_BLUETOOTH_BLE |
- DEVICE_IN_HDMI_ARC |
- DEVICE_IN_ECHO_REFERENCE |
- DEVICE_IN_DEFAULT);
- public static final int DEVICE_IN_ALL_SCO = DEVICE_IN_BLUETOOTH_SCO_HEADSET;
- public static final int DEVICE_IN_ALL_USB = (DEVICE_IN_USB_ACCESSORY |
- DEVICE_IN_USB_DEVICE |
- DEVICE_IN_USB_HEADSET);
+ public static final Set<Integer> DEVICE_IN_ALL_SET;
+ public static final Set<Integer> DEVICE_IN_ALL_SCO_SET;
+ public static final Set<Integer> DEVICE_IN_ALL_USB_SET;
+ static {
+ DEVICE_IN_ALL_SET = new HashSet<>();
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_COMMUNICATION);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_AMBIENT);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_BUILTIN_MIC);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_BLUETOOTH_SCO_HEADSET);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_WIRED_HEADSET);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_HDMI);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_TELEPHONY_RX);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_BACK_MIC);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_REMOTE_SUBMIX);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_ANLG_DOCK_HEADSET);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_DGTL_DOCK_HEADSET);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_USB_ACCESSORY);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_USB_DEVICE);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_FM_TUNER);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_TV_TUNER);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_LINE);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_SPDIF);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_BLUETOOTH_A2DP);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_LOOPBACK);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_IP);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_BUS);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_PROXY);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_USB_HEADSET);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_BLUETOOTH_BLE);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_HDMI_ARC);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_ECHO_REFERENCE);
+ DEVICE_IN_ALL_SET.add(DEVICE_IN_DEFAULT);
+
+ DEVICE_IN_ALL_SCO_SET = new HashSet<>();
+ DEVICE_IN_ALL_SCO_SET.add(DEVICE_IN_BLUETOOTH_SCO_HEADSET);
+
+ DEVICE_IN_ALL_USB_SET = new HashSet<>();
+ DEVICE_IN_ALL_USB_SET.add(DEVICE_IN_USB_ACCESSORY);
+ DEVICE_IN_ALL_USB_SET.add(DEVICE_IN_USB_DEVICE);
+ DEVICE_IN_ALL_USB_SET.add(DEVICE_IN_USB_HEADSET);
+ }
// device states, must match AudioSystem::device_connection_state
@UnsupportedAppUsage
@@ -1222,6 +1258,40 @@
return getPlatformType(context) == PLATFORM_TELEVISION || forceSingleVolume;
}
+ /**
+ * Return a set of audio device types from a bit mask audio device type, which may
+ * represent multiple audio device types.
+ * FIXME: Remove this when getting ride of bit mask usage of audio device types.
+ */
+ public static Set<Integer> generateAudioDeviceTypesSet(int types) {
+ Set<Integer> deviceTypes = new HashSet<>();
+ Set<Integer> allDeviceTypes =
+ (types & DEVICE_BIT_IN) == 0 ? DEVICE_OUT_ALL_SET : DEVICE_IN_ALL_SET;
+ for (int deviceType : allDeviceTypes) {
+ if ((types & deviceType) == deviceType) {
+ deviceTypes.add(deviceType);
+ }
+ }
+ return deviceTypes;
+ }
+
+ /**
+ * Return the intersection of two audio device types collections.
+ */
+ public static Set<Integer> intersectionAudioDeviceTypes(
+ @NonNull Set<Integer> a, @NonNull Set<Integer> b) {
+ Set<Integer> intersection = new HashSet<>(a);
+ intersection.retainAll(b);
+ return intersection;
+ }
+
+ /**
+ * Return true if the audio device types collection only contains the given device type.
+ */
+ public static boolean isSingleAudioDeviceType(@NonNull Set<Integer> types, int type) {
+ return types.size() == 1 && types.contains(type);
+ }
+
public static final int DEFAULT_MUTE_STREAMS_AFFECTED =
(1 << STREAM_MUSIC) |
(1 << STREAM_RING) |
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java
index 785dd56..96aee51 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java
@@ -44,8 +44,8 @@
private final CachedBluetoothDeviceManager mDeviceManager;
static final ParcelUuid[] SINK_UUIDS = {
- BluetoothUuid.AudioSink,
- BluetoothUuid.AdvAudioDist,
+ BluetoothUuid.A2DP_SINK,
+ BluetoothUuid.ADV_AUDIO_DIST,
};
static final String NAME = "A2DP";
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java
index 4ce9d3e..55765dd 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java
@@ -40,8 +40,8 @@
private final CachedBluetoothDeviceManager mDeviceManager;
static final ParcelUuid[] SRC_UUIDS = {
- BluetoothUuid.AudioSource,
- BluetoothUuid.AdvAudioDist,
+ BluetoothUuid.A2DP_SOURCE,
+ BluetoothUuid.ADV_AUDIO_DIST,
};
static final String NAME = "A2DPSink";
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothDeviceFilter.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothDeviceFilter.java
index 8dec86a..b8ad321 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothDeviceFilter.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothDeviceFilter.java
@@ -22,6 +22,8 @@
import android.os.ParcelUuid;
import android.util.Log;
+import com.android.internal.util.ArrayUtils;
+
/**
* BluetoothDeviceFilter contains a static method that returns a
* Filter object that returns whether or not the BluetoothDevice
@@ -130,7 +132,7 @@
@Override
boolean matches(ParcelUuid[] uuids, BluetoothClass btClass) {
if (uuids != null) {
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.ObexObjectPush)) {
+ if (ArrayUtils.contains(uuids, BluetoothUuid.OBEX_OBJECT_PUSH)) {
return true;
}
}
@@ -144,7 +146,7 @@
@Override
boolean matches(ParcelUuid[] uuids, BluetoothClass btClass) {
if (uuids != null) {
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.PANU)) {
+ if (ArrayUtils.contains(uuids, BluetoothUuid.PANU)) {
return true;
}
}
@@ -158,7 +160,7 @@
@Override
boolean matches(ParcelUuid[] uuids, BluetoothClass btClass) {
if (uuids != null) {
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.NAP)) {
+ if (ArrayUtils.contains(uuids, BluetoothUuid.NAP)) {
return true;
}
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index 9a16825..56be3bb 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -32,6 +32,7 @@
import androidx.annotation.VisibleForTesting;
+import com.android.internal.util.ArrayUtils;
import com.android.settingslib.R;
import com.android.settingslib.Utils;
@@ -609,9 +610,9 @@
ParcelUuid[] uuids = mDevice.getUuids();
long timeout = MAX_UUID_DELAY_FOR_AUTO_CONNECT;
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Hogp)) {
+ if (ArrayUtils.contains(uuids, BluetoothUuid.HOGP)) {
timeout = MAX_HOGP_DELAY_FOR_AUTO_CONNECT;
- } else if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.HearingAid)) {
+ } else if (ArrayUtils.contains(uuids, BluetoothUuid.HEARING_AID)) {
timeout = MAX_HEARING_AIDS_DELAY_FOR_AUTO_CONNECT;
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HeadsetProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HeadsetProfile.java
index c1933fd..9f7b718 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HeadsetProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HeadsetProfile.java
@@ -45,7 +45,7 @@
static final ParcelUuid[] UUIDS = {
BluetoothUuid.HSP,
- BluetoothUuid.Handsfree,
+ BluetoothUuid.HFP,
};
static final String NAME = "HEADSET";
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java
index 4bdbc31..860b77d 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java
@@ -44,7 +44,7 @@
static final ParcelUuid[] SRC_UUIDS = {
BluetoothUuid.HSP_AG,
- BluetoothUuid.Handsfree_AG,
+ BluetoothUuid.HFP_AG,
};
static final String NAME = "HEADSET_CLIENT";
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java
index 29c6d71..ae2acbe 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java
@@ -30,8 +30,8 @@
import android.bluetooth.BluetoothPan;
import android.bluetooth.BluetoothPbap;
import android.bluetooth.BluetoothPbapClient;
-import android.bluetooth.BluetoothSap;
import android.bluetooth.BluetoothProfile;
+import android.bluetooth.BluetoothSap;
import android.bluetooth.BluetoothUuid;
import android.content.Context;
import android.content.Intent;
@@ -40,6 +40,7 @@
import androidx.annotation.VisibleForTesting;
+import com.android.internal.util.ArrayUtils;
import com.android.internal.util.CollectionUtils;
import java.util.ArrayList;
@@ -471,43 +472,40 @@
}
if (mHeadsetProfile != null) {
- if ((BluetoothUuid.isUuidPresent(localUuids, BluetoothUuid.HSP_AG) &&
- BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.HSP)) ||
- (BluetoothUuid.isUuidPresent(localUuids, BluetoothUuid.Handsfree_AG) &&
- BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Handsfree))) {
+ if ((ArrayUtils.contains(localUuids, BluetoothUuid.HSP_AG)
+ && ArrayUtils.contains(uuids, BluetoothUuid.HSP))
+ || (ArrayUtils.contains(localUuids, BluetoothUuid.HFP_AG)
+ && ArrayUtils.contains(uuids, BluetoothUuid.HFP))) {
profiles.add(mHeadsetProfile);
removedProfiles.remove(mHeadsetProfile);
}
}
if ((mHfpClientProfile != null) &&
- BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Handsfree_AG) &&
- BluetoothUuid.isUuidPresent(localUuids, BluetoothUuid.Handsfree)) {
+ ArrayUtils.contains(uuids, BluetoothUuid.HFP_AG)
+ && ArrayUtils.contains(localUuids, BluetoothUuid.HFP)) {
profiles.add(mHfpClientProfile);
removedProfiles.remove(mHfpClientProfile);
}
- if (BluetoothUuid.containsAnyUuid(uuids, A2dpProfile.SINK_UUIDS) &&
- mA2dpProfile != null) {
+ if (BluetoothUuid.containsAnyUuid(uuids, A2dpProfile.SINK_UUIDS) && mA2dpProfile != null) {
profiles.add(mA2dpProfile);
removedProfiles.remove(mA2dpProfile);
}
- if (BluetoothUuid.containsAnyUuid(uuids, A2dpSinkProfile.SRC_UUIDS) &&
- mA2dpSinkProfile != null) {
+ if (BluetoothUuid.containsAnyUuid(uuids, A2dpSinkProfile.SRC_UUIDS)
+ && mA2dpSinkProfile != null) {
profiles.add(mA2dpSinkProfile);
removedProfiles.remove(mA2dpSinkProfile);
}
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.ObexObjectPush) &&
- mOppProfile != null) {
+ if (ArrayUtils.contains(uuids, BluetoothUuid.OBEX_OBJECT_PUSH) && mOppProfile != null) {
profiles.add(mOppProfile);
removedProfiles.remove(mOppProfile);
}
- if ((BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Hid) ||
- BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Hogp)) &&
- mHidProfile != null) {
+ if ((ArrayUtils.contains(uuids, BluetoothUuid.HID)
+ || ArrayUtils.contains(uuids, BluetoothUuid.HOGP)) && mHidProfile != null) {
profiles.add(mHidProfile);
removedProfiles.remove(mHidProfile);
}
@@ -520,8 +518,8 @@
if(isPanNapConnected)
if(DEBUG) Log.d(TAG, "Valid PAN-NAP connection exists.");
- if ((BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.NAP) &&
- mPanProfile != null) || isPanNapConnected) {
+ if ((ArrayUtils.contains(uuids, BluetoothUuid.NAP) && mPanProfile != null)
+ || isPanNapConnected) {
profiles.add(mPanProfile);
removedProfiles.remove(mPanProfile);
}
@@ -545,20 +543,18 @@
removedProfiles.remove(mMapClientProfile);
}
- if ((mPbapClientProfile != null) &&
- BluetoothUuid.isUuidPresent(localUuids, BluetoothUuid.PBAP_PCE) &&
- BluetoothUuid.containsAnyUuid(uuids, PbapClientProfile.SRC_UUIDS)) {
+ if ((mPbapClientProfile != null) && ArrayUtils.contains(localUuids, BluetoothUuid.PBAP_PCE)
+ && BluetoothUuid.containsAnyUuid(uuids, PbapClientProfile.SRC_UUIDS)) {
profiles.add(mPbapClientProfile);
removedProfiles.remove(mPbapClientProfile);
}
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.HearingAid) &&
- mHearingAidProfile != null) {
+ if (ArrayUtils.contains(uuids, BluetoothUuid.HEARING_AID) && mHearingAidProfile != null) {
profiles.add(mHearingAidProfile);
removedProfiles.remove(mHearingAidProfile);
}
- if (mSapProfile != null && BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.SAP)) {
+ if (mSapProfile != null && ArrayUtils.contains(uuids, BluetoothUuid.SAP)) {
profiles.add(mSapProfile);
removedProfiles.remove(mSapProfile);
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapServerProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapServerProfile.java
index 17104e4..d91226e 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapServerProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapServerProfile.java
@@ -46,7 +46,7 @@
// The UUIDs indicate that remote device might access pbap server
static final ParcelUuid[] PBAB_CLIENT_UUIDS = {
BluetoothUuid.HSP,
- BluetoothUuid.Handsfree,
+ BluetoothUuid.HFP,
BluetoothUuid.PBAP_PCE
};
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerTest.java
index 5d5872e..fd5b053 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerTest.java
@@ -132,7 +132,7 @@
mShadowBluetoothAdapter.setSupportedProfiles(generateList(
new int[] {BluetoothProfile.HID_HOST}));
mProfileManager.updateLocalProfiles();
- ParcelUuid[] uuids = new ParcelUuid[]{BluetoothUuid.Hid};
+ ParcelUuid[] uuids = new ParcelUuid[]{BluetoothUuid.HID};
ParcelUuid[] localUuids = new ParcelUuid[]{};
List<LocalBluetoothProfile> profiles = new ArrayList<>();
List<LocalBluetoothProfile> removedProfiles = new ArrayList<>();
diff --git a/services/core/java/com/android/server/AnyMotionDetector.java b/services/core/java/com/android/server/AnyMotionDetector.java
index 8c5ee7f..316306d 100644
--- a/services/core/java/com/android/server/AnyMotionDetector.java
+++ b/services/core/java/com/android/server/AnyMotionDetector.java
@@ -231,8 +231,8 @@
Slog.d(TAG, "mCurrentGravityVector = " + currentGravityVectorString);
Slog.d(TAG, "mPreviousGravityVector = " + previousGravityVectorString);
}
- mRunningStats.reset();
status = getStationaryStatus();
+ mRunningStats.reset();
if (DEBUG) Slog.d(TAG, "getStationaryStatus() returned " + status);
if (status != RESULT_UNKNOWN) {
if (mWakeLock.isHeld()) {
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index fc34434..8436e38 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -17,6 +17,8 @@
package com.android.server;
import static android.telephony.TelephonyManager.ACTION_MULTI_SIM_CONFIG_CHANGED;
+import static android.telephony.TelephonyRegistryManager.SIM_ACTIVATION_TYPE_DATA;
+import static android.telephony.TelephonyRegistryManager.SIM_ACTIVATION_TYPE_VOICE;
import static java.util.Arrays.copyOf;
@@ -1203,10 +1205,10 @@
synchronized (mRecords) {
if (validatePhoneId(phoneId)) {
switch (activationType) {
- case TelephonyManager.SIM_ACTIVATION_TYPE_VOICE:
+ case SIM_ACTIVATION_TYPE_VOICE:
mVoiceActivationState[phoneId] = activationState;
break;
- case TelephonyManager.SIM_ACTIVATION_TYPE_DATA:
+ case SIM_ACTIVATION_TYPE_DATA:
mDataActivationState[phoneId] = activationState;
break;
default:
@@ -1219,10 +1221,10 @@
+ " state=" + activationState);
}
try {
- if ((activationType == TelephonyManager.SIM_ACTIVATION_TYPE_VOICE) &&
- r.matchPhoneStateListenerEvent(
- PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE) &&
- idMatch(r.subId, subId, phoneId)) {
+ if ((activationType == SIM_ACTIVATION_TYPE_VOICE)
+ && r.matchPhoneStateListenerEvent(
+ PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE)
+ && idMatch(r.subId, subId, phoneId)) {
if (DBG) {
log("notifyVoiceActivationStateForPhoneId: callback.onVASC r=" + r
+ " subId=" + subId + " phoneId=" + phoneId
@@ -1230,10 +1232,10 @@
}
r.callback.onVoiceActivationStateChanged(activationState);
}
- if ((activationType == TelephonyManager.SIM_ACTIVATION_TYPE_DATA) &&
- r.matchPhoneStateListenerEvent(
- PhoneStateListener.LISTEN_DATA_ACTIVATION_STATE) &&
- idMatch(r.subId, subId, phoneId)) {
+ if ((activationType == SIM_ACTIVATION_TYPE_DATA)
+ && r.matchPhoneStateListenerEvent(
+ PhoneStateListener.LISTEN_DATA_ACTIVATION_STATE)
+ && idMatch(r.subId, subId, phoneId)) {
if (DBG) {
log("notifyDataActivationStateForPhoneId: callback.onDASC r=" + r
+ " subId=" + subId + " phoneId=" + phoneId
diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
index 90973a8..a2b3574 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
@@ -44,6 +44,8 @@
import com.android.internal.annotations.VisibleForTesting;
import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
/**
* Class to manage the inventory of all connected devices.
@@ -372,9 +374,14 @@
mDeviceBroker.postObserveDevicesForAllStreams();
}
- private static final int DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG =
- AudioSystem.DEVICE_OUT_WIRED_HEADSET | AudioSystem.DEVICE_OUT_WIRED_HEADPHONE
- | AudioSystem.DEVICE_OUT_LINE | AudioSystem.DEVICE_OUT_ALL_USB;
+ private static final Set<Integer> DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET;
+ static {
+ DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET = new HashSet<>();
+ DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET.add(AudioSystem.DEVICE_OUT_WIRED_HEADSET);
+ DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET.add(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE);
+ DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET.add(AudioSystem.DEVICE_OUT_LINE);
+ DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET.addAll(AudioSystem.DEVICE_OUT_ALL_USB_SET);
+ }
/*package*/ void onSetWiredDeviceConnectionState(
AudioDeviceInventory.WiredDeviceConnectionState wdcs) {
@@ -382,7 +389,7 @@
synchronized (mConnectedDevices) {
if ((wdcs.mState == AudioService.CONNECTION_STATE_DISCONNECTED)
- && ((wdcs.mType & DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG) != 0)) {
+ && DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET.contains(wdcs.mType)) {
mDeviceBroker.setBluetoothA2dpOnInt(true,
"onSetWiredDeviceConnectionState state DISCONNECTED");
}
@@ -393,7 +400,7 @@
return;
}
if (wdcs.mState != AudioService.CONNECTION_STATE_DISCONNECTED) {
- if ((wdcs.mType & DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG) != 0) {
+ if (DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET.contains(wdcs.mType)) {
mDeviceBroker.setBluetoothA2dpOnInt(false,
"onSetWiredDeviceConnectionState state not DISCONNECTED");
}
@@ -764,13 +771,19 @@
// - none of these devices are connected anymore after one is disconnected AND
// - the device being disconnected is actually used for music.
// Access synchronized on mConnectedDevices
- private int mBecomingNoisyIntentDevices =
- AudioSystem.DEVICE_OUT_WIRED_HEADSET | AudioSystem.DEVICE_OUT_WIRED_HEADPHONE
- | AudioSystem.DEVICE_OUT_ALL_A2DP | AudioSystem.DEVICE_OUT_HDMI
- | AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET
- | AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET
- | AudioSystem.DEVICE_OUT_ALL_USB | AudioSystem.DEVICE_OUT_LINE
- | AudioSystem.DEVICE_OUT_HEARING_AID;
+ private static final Set<Integer> BECOMING_NOISY_INTENT_DEVICES_SET;
+ static {
+ BECOMING_NOISY_INTENT_DEVICES_SET = new HashSet<>();
+ BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_WIRED_HEADSET);
+ BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE);
+ BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_HDMI);
+ BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET);
+ BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET);
+ BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_LINE);
+ BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_HEARING_AID);
+ BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_A2DP_SET);
+ BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_USB_SET);
+ }
// must be called before removing the device from mConnectedDevices
// musicDevice argument is used when not AudioSystem.DEVICE_NONE instead of querying
@@ -781,16 +794,16 @@
if (state != AudioService.CONNECTION_STATE_DISCONNECTED) {
return 0;
}
- if ((device & mBecomingNoisyIntentDevices) == 0) {
+ if (!BECOMING_NOISY_INTENT_DEVICES_SET.contains(device)) {
return 0;
}
int delay = 0;
- int devices = 0;
+ Set<Integer> devices = new HashSet<>();
for (int i = 0; i < mConnectedDevices.size(); i++) {
int dev = mConnectedDevices.valueAt(i).mDeviceType;
if (((dev & AudioSystem.DEVICE_BIT_IN) == 0)
- && ((dev & mBecomingNoisyIntentDevices) != 0)) {
- devices |= dev;
+ && BECOMING_NOISY_INTENT_DEVICES_SET.contains(dev)) {
+ devices.add(dev);
}
}
if (musicDevice == AudioSystem.DEVICE_NONE) {
@@ -801,8 +814,9 @@
// because music routing is altered in this case.
// also checks whether media routing if affected by a dynamic policy or mirroring
if (((device == musicDevice) || mDeviceBroker.isInCommunication())
- && (device == devices) && !mDeviceBroker.hasMediaDynamicPolicy()
- && ((musicDevice & AudioSystem.DEVICE_OUT_REMOTE_SUBMIX) == 0)) {
+ && AudioSystem.isSingleAudioDeviceType(devices, device)
+ && !mDeviceBroker.hasMediaDynamicPolicy()
+ && (musicDevice != AudioSystem.DEVICE_OUT_REMOTE_SUBMIX)) {
if (!AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0 /*not looking in past*/)
&& !mDeviceBroker.hasAudioFocusUsers()) {
// no media playback, not a "becoming noisy" situation, otherwise it could cause
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index bae9680..25fdf64 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -147,6 +147,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -501,18 +502,20 @@
private volatile IRingtonePlayer mRingtonePlayer;
// Devices for which the volume is fixed (volume is either max or muted)
- int mFixedVolumeDevices = AudioSystem.DEVICE_OUT_HDMI |
- AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET |
- AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET |
- AudioSystem.DEVICE_OUT_HDMI_ARC |
- AudioSystem.DEVICE_OUT_SPDIF |
- AudioSystem.DEVICE_OUT_AUX_LINE;
+ Set<Integer> mFixedVolumeDevices = new HashSet<>(Arrays.asList(
+ AudioSystem.DEVICE_OUT_HDMI,
+ AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET,
+ AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET,
+ AudioSystem.DEVICE_OUT_HDMI_ARC,
+ AudioSystem.DEVICE_OUT_SPDIF,
+ AudioSystem.DEVICE_OUT_AUX_LINE));
// Devices for which the volume is always max, no volume panel
- int mFullVolumeDevices = 0;
+ Set<Integer> mFullVolumeDevices = new HashSet<>();
// Devices for the which use the "absolute volume" concept (framework sends audio signal
// full scale, and volume control separately) and can be used for multiple use cases reflected
// by the audio mode (e.g. media playback in MODE_NORMAL, and phone calls in MODE_IN_CALL).
- int mAbsVolumeMultiModeCaseDevices = AudioSystem.DEVICE_OUT_HEARING_AID;
+ Set<Integer> mAbsVolumeMultiModeCaseDevices = new HashSet<>(
+ Arrays.asList(AudioSystem.DEVICE_OUT_HEARING_AID));
private final boolean mMonitorRotation;
@@ -863,13 +866,14 @@
}
mHdmiTvClient = mHdmiManager.getTvClient();
if (mHdmiTvClient != null) {
- mFixedVolumeDevices &= ~AudioSystem.DEVICE_ALL_HDMI_SYSTEM_AUDIO_AND_SPEAKER;
+ mFixedVolumeDevices.removeAll(
+ AudioSystem.DEVICE_ALL_HDMI_SYSTEM_AUDIO_AND_SPEAKER_SET);
}
mHdmiPlaybackClient = mHdmiManager.getPlaybackClient();
if (mHdmiPlaybackClient != null) {
// not a television: HDMI output will be always at max
- mFixedVolumeDevices &= ~AudioSystem.DEVICE_OUT_HDMI;
- mFullVolumeDevices |= AudioSystem.DEVICE_OUT_HDMI;
+ mFixedVolumeDevices.remove(AudioSystem.DEVICE_OUT_HDMI);
+ mFullVolumeDevices.add(AudioSystem.DEVICE_OUT_HDMI);
}
mHdmiAudioSystemClient = mHdmiManager.getAudioSystemClient();
}
@@ -1126,7 +1130,7 @@
@AudioService.ConnectionState int state, String caller) {
if (state == AudioService.CONNECTION_STATE_CONNECTED) {
// DEVICE_OUT_HDMI is now connected
- if ((AudioSystem.DEVICE_OUT_HDMI & mSafeMediaVolumeDevices) != 0) {
+ if (mSafeMediaVolumeDevices.contains(AudioSystem.DEVICE_OUT_HDMI)) {
sendMsg(mAudioHandler,
MSG_CHECK_MUSIC_ACTIVE,
SENDMSG_REPLACE,
@@ -1757,8 +1761,8 @@
// skip a2dp absolute volume control request when the device
// is not an a2dp device
- if ((device & AudioSystem.DEVICE_OUT_ALL_A2DP) == 0 &&
- (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) != 0) {
+ if (!AudioSystem.DEVICE_OUT_ALL_A2DP_SET.contains(device)
+ && (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) != 0) {
return;
}
@@ -1779,14 +1783,14 @@
flags &= ~AudioManager.FLAG_FIXED_VOLUME;
if ((streamTypeAlias == AudioSystem.STREAM_MUSIC) &&
- ((device & mFixedVolumeDevices) != 0)) {
+ mFixedVolumeDevices.contains(device)) {
flags |= AudioManager.FLAG_FIXED_VOLUME;
// Always toggle between max safe volume and 0 for fixed volume devices where safe
// volume is enforced, and max and 0 for the others.
// This is simulated by stepping by the full allowed volume range
if (mSafeMediaVolumeState == SAFE_MEDIA_VOLUME_ACTIVE &&
- (device & mSafeMediaVolumeDevices) != 0) {
+ mSafeMediaVolumeDevices.contains(device)) {
step = safeMediaVolumeIndex(device);
} else {
step = streamState.getMaxIndex();
@@ -1856,7 +1860,7 @@
!checkSafeMediaVolume(streamTypeAlias, aliasIndex + step, device)) {
Log.e(TAG, "adjustStreamVolume() safe volume index = " + oldIndex);
mVolumeController.postDisplaySafeVolumeWarning(flags);
- } else if (((device & mFullVolumeDevices) == 0)
+ } else if (!mFullVolumeDevices.contains(device)
&& (streamState.adjustIndex(direction * step, device, caller)
|| streamState.mIsMuted)) {
// Post message to set system volume (it in turn will post a
@@ -1885,9 +1889,9 @@
int newIndex = mStreamStates[streamType].getIndex(device);
// Check if volume update should be send to AVRCP
- if (streamTypeAlias == AudioSystem.STREAM_MUSIC &&
- (device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0 &&
- (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) {
+ if (streamTypeAlias == AudioSystem.STREAM_MUSIC
+ && AudioSystem.DEVICE_OUT_ALL_A2DP_SET.contains(device)
+ && (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) {
if (DEBUG_VOL) {
Log.d(TAG, "adjustSreamVolume: postSetAvrcpAbsoluteVolumeIndex index="
+ newIndex + "stream=" + streamType);
@@ -1896,7 +1900,7 @@
}
// Check if volume update should be send to Hearing Aid
- if ((device & AudioSystem.DEVICE_OUT_HEARING_AID) != 0) {
+ if (device == AudioSystem.DEVICE_OUT_HEARING_AID) {
// only modify the hearing aid attenuation when the stream to modify matches
// the one expected by the hearing aid
if (streamType == getHearingAidStreamType()) {
@@ -1918,7 +1922,7 @@
if (mHdmiCecSink
&& streamTypeAlias == AudioSystem.STREAM_MUSIC
// vol change on a full volume device
- && ((device & mFullVolumeDevices) != 0)) {
+ && mFullVolumeDevices.contains(device)) {
int keyCode = KeyEvent.KEYCODE_UNKNOWN;
switch (direction) {
case AudioManager.ADJUST_RAISE:
@@ -2286,13 +2290,17 @@
int streamType = getHearingAidStreamType(newMode);
- final int device = AudioSystem.getDevicesForStream(streamType);
- if ((device & mAbsVolumeMultiModeCaseDevices) == 0) {
+ final Set<Integer> deviceTypes = AudioSystem.generateAudioDeviceTypesSet(
+ AudioSystem.getDevicesForStream(streamType));
+ final Set<Integer> absVolumeMultiModeCaseDevices = AudioSystem.intersectionAudioDeviceTypes(
+ mAbsVolumeMultiModeCaseDevices, deviceTypes);
+ if (absVolumeMultiModeCaseDevices.isEmpty()) {
return;
}
// handling of specific interfaces goes here:
- if ((device & mAbsVolumeMultiModeCaseDevices) == AudioSystem.DEVICE_OUT_HEARING_AID) {
+ if (AudioSystem.isSingleAudioDeviceType(
+ absVolumeMultiModeCaseDevices, AudioSystem.DEVICE_OUT_HEARING_AID)) {
final int index = getStreamVolume(streamType);
sVolumeLogger.log(new VolumeEvent(VolumeEvent.VOL_MODE_CHANGE_HEARING_AID,
newMode, streamType, index));
@@ -2319,8 +2327,8 @@
// skip a2dp absolute volume control request when the device
// is not an a2dp device
- if ((device & AudioSystem.DEVICE_OUT_ALL_A2DP) == 0 &&
- (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) != 0) {
+ if (!AudioSystem.DEVICE_OUT_ALL_A2DP_SET.contains(device)
+ && (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) != 0) {
return;
}
// If we are being called by the system (e.g. hardware keys) check for current user
@@ -2352,7 +2360,7 @@
index = rescaleIndex(index * 10, streamType, streamTypeAlias);
if (streamTypeAlias == AudioSystem.STREAM_MUSIC
- && (device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0
+ && AudioSystem.DEVICE_OUT_ALL_A2DP_SET.contains(device)
&& (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) {
if (DEBUG_VOL) {
Log.d(TAG, "setStreamVolume postSetAvrcpAbsoluteVolumeIndex index=" + index
@@ -2361,7 +2369,7 @@
mDeviceBroker.postSetAvrcpAbsoluteVolumeIndex(index / 10);
}
- if ((device & AudioSystem.DEVICE_OUT_HEARING_AID) != 0
+ if (device == AudioSystem.DEVICE_OUT_HEARING_AID
&& streamType == getHearingAidStreamType()) {
Log.i(TAG, "setStreamVolume postSetHearingAidVolumeIndex index=" + index
+ " stream=" + streamType);
@@ -2374,13 +2382,13 @@
flags &= ~AudioManager.FLAG_FIXED_VOLUME;
if ((streamTypeAlias == AudioSystem.STREAM_MUSIC) &&
- ((device & mFixedVolumeDevices) != 0)) {
+ mFixedVolumeDevices.contains(device)) {
flags |= AudioManager.FLAG_FIXED_VOLUME;
// volume is either 0 or max allowed for fixed volume devices
if (index != 0) {
if (mSafeMediaVolumeState == SAFE_MEDIA_VOLUME_ACTIVE &&
- (device & mSafeMediaVolumeDevices) != 0) {
+ mSafeMediaVolumeDevices.contains(device)) {
index = safeMediaVolumeIndex(device);
} else {
index = streamState.getMaxIndex();
@@ -2563,7 +2571,7 @@
if (streamType == AudioSystem.STREAM_MUSIC) {
flags = updateFlagsForTvPlatform(flags);
- if ((device & mFullVolumeDevices) != 0) {
+ if (mFullVolumeDevices.contains(device)) {
flags &= ~AudioManager.FLAG_SHOW_UI;
}
}
@@ -2609,7 +2617,7 @@
int device,
boolean force,
String caller) {
- if ((device & mFullVolumeDevices) != 0) {
+ if (mFullVolumeDevices.contains(device)) {
return;
}
VolumeStreamState streamState = mStreamStates[streamType];
@@ -2726,8 +2734,8 @@
if (!hasRmtSbmxFullVolDeathHandlerFor(cb)) {
mRmtSbmxFullVolDeathHandlers.add(new RmtSbmxFullVolDeathHandler(cb));
if (mRmtSbmxFullVolRefCount == 0) {
- mFullVolumeDevices |= AudioSystem.DEVICE_OUT_REMOTE_SUBMIX;
- mFixedVolumeDevices |= AudioSystem.DEVICE_OUT_REMOTE_SUBMIX;
+ mFullVolumeDevices.add(AudioSystem.DEVICE_OUT_REMOTE_SUBMIX);
+ mFixedVolumeDevices.add(AudioSystem.DEVICE_OUT_REMOTE_SUBMIX);
applyRequired = true;
}
mRmtSbmxFullVolRefCount++;
@@ -2736,8 +2744,8 @@
if (discardRmtSbmxFullVolDeathHandlerFor(cb) && (mRmtSbmxFullVolRefCount > 0)) {
mRmtSbmxFullVolRefCount--;
if (mRmtSbmxFullVolRefCount == 0) {
- mFullVolumeDevices &= ~AudioSystem.DEVICE_OUT_REMOTE_SUBMIX;
- mFixedVolumeDevices &= ~AudioSystem.DEVICE_OUT_REMOTE_SUBMIX;
+ mFullVolumeDevices.remove(AudioSystem.DEVICE_OUT_REMOTE_SUBMIX);
+ mFixedVolumeDevices.remove(AudioSystem.DEVICE_OUT_REMOTE_SUBMIX);
applyRequired = true;
}
}
@@ -2822,7 +2830,7 @@
index = 0;
}
if (index != 0 && (mStreamVolumeAlias[streamType] == AudioSystem.STREAM_MUSIC) &&
- (device & mFixedVolumeDevices) != 0) {
+ mFixedVolumeDevices.contains(device)) {
index = mStreamStates[streamType].getMaxIndex();
}
return (index + 5) / 10;
@@ -3680,7 +3688,7 @@
if (mSafeMediaVolumeState == SAFE_MEDIA_VOLUME_INACTIVE) {
int device = getDeviceForStream(AudioSystem.STREAM_MUSIC);
- if ((device & mSafeMediaVolumeDevices) != 0) {
+ if (mSafeMediaVolumeDevices.contains(device)) {
sendMsg(mAudioHandler,
MSG_CHECK_MUSIC_ACTIVE,
SENDMSG_REPLACE,
@@ -4221,6 +4229,8 @@
// retain the device on the A2DP output as the other must not correspond to an active
// selection if not the speaker.
// - HDMI-CEC system audio mode only output: give priority to available item in order.
+ // FIXME: Haven't applied audio device type refactor to this API
+ // as it is going to be deprecated.
if ((device & AudioSystem.DEVICE_OUT_SPEAKER) != 0) {
device = AudioSystem.DEVICE_OUT_SPEAKER;
} else if ((device & AudioSystem.DEVICE_OUT_HDMI_ARC) != 0) {
@@ -4230,7 +4240,11 @@
} else if ((device & AudioSystem.DEVICE_OUT_AUX_LINE) != 0) {
device = AudioSystem.DEVICE_OUT_AUX_LINE;
} else {
- device &= AudioSystem.DEVICE_OUT_ALL_A2DP;
+ for (int deviceType : AudioSystem.DEVICE_OUT_ALL_A2DP_SET) {
+ if ((deviceType & device) == deviceType) {
+ return deviceType;
+ }
+ }
}
}
return device;
@@ -4363,12 +4377,16 @@
mDeviceBroker.postBluetoothA2dpDeviceConfigChange(device);
}
- private static final int DEVICE_MEDIA_UNMUTED_ON_PLUG =
- AudioSystem.DEVICE_OUT_WIRED_HEADSET | AudioSystem.DEVICE_OUT_WIRED_HEADPHONE |
- AudioSystem.DEVICE_OUT_LINE |
- AudioSystem.DEVICE_OUT_ALL_A2DP |
- AudioSystem.DEVICE_OUT_ALL_USB |
- AudioSystem.DEVICE_OUT_HDMI;
+ private static final Set<Integer> DEVICE_MEDIA_UNMUTED_ON_PLUG_SET;
+ static {
+ DEVICE_MEDIA_UNMUTED_ON_PLUG_SET = new HashSet<>();
+ DEVICE_MEDIA_UNMUTED_ON_PLUG_SET.add(AudioSystem.DEVICE_OUT_WIRED_HEADSET);
+ DEVICE_MEDIA_UNMUTED_ON_PLUG_SET.add(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE);
+ DEVICE_MEDIA_UNMUTED_ON_PLUG_SET.add(AudioSystem.DEVICE_OUT_LINE);
+ DEVICE_MEDIA_UNMUTED_ON_PLUG_SET.addAll(AudioSystem.DEVICE_OUT_ALL_A2DP_SET);
+ DEVICE_MEDIA_UNMUTED_ON_PLUG_SET.addAll(AudioSystem.DEVICE_OUT_ALL_USB_SET);
+ DEVICE_MEDIA_UNMUTED_ON_PLUG_SET.add(AudioSystem.DEVICE_OUT_HDMI);
+ }
/** only public for mocking/spying, do not call outside of AudioService */
@VisibleForTesting
@@ -4384,7 +4402,7 @@
}
if (mNm.getZenMode() != Settings.Global.ZEN_MODE_NO_INTERRUPTIONS
- && (newDevice & DEVICE_MEDIA_UNMUTED_ON_PLUG) != 0
+ && DEVICE_MEDIA_UNMUTED_ON_PLUG_SET.contains(newDevice)
&& mStreamStates[AudioSystem.STREAM_MUSIC].mIsMuted
&& mStreamStates[AudioSystem.STREAM_MUSIC].getIndex(newDevice) != 0
&& (newDevice & AudioSystem.getDevicesForStream(AudioSystem.STREAM_MUSIC)) != 0) {
@@ -4513,14 +4531,7 @@
}
}
synchronized (VolumeStreamState.class) {
- int remainingDevices = AudioSystem.DEVICE_OUT_ALL;
-
- for (int i = 0; remainingDevices != 0; i++) {
- int device = (1 << i);
- if ((device & remainingDevices) == 0) {
- continue;
- }
- remainingDevices &= ~device;
+ for (int device : AudioSystem.DEVICE_OUT_ALL_SET) {
// retrieve current volume for device
// if no volume stored for current stream and device, use default volume if default
@@ -4580,11 +4591,12 @@
int index;
if (mIsMuted) {
index = 0;
- } else if ((device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0 && isAvrcpAbsVolSupported) {
+ } else if (AudioSystem.DEVICE_OUT_ALL_A2DP_SET.contains(device)
+ && isAvrcpAbsVolSupported) {
index = getAbsoluteVolumeIndex((getIndex(device) + 5)/10);
- } else if ((device & mFullVolumeDevices) != 0) {
+ } else if (mFullVolumeDevices.contains(device)) {
index = (mIndexMax + 5)/10;
- } else if ((device & AudioSystem.DEVICE_OUT_HEARING_AID) != 0) {
+ } else if (device == AudioSystem.DEVICE_OUT_HEARING_AID) {
index = (mIndexMax + 5)/10;
} else {
index = (getIndex(device) + 5)/10;
@@ -4602,12 +4614,12 @@
if (device != AudioSystem.DEVICE_OUT_DEFAULT) {
if (mIsMuted) {
index = 0;
- } else if ((device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0 &&
- isAvrcpAbsVolSupported) {
+ } else if (AudioSystem.DEVICE_OUT_ALL_A2DP_SET.contains(device)
+ && isAvrcpAbsVolSupported) {
index = getAbsoluteVolumeIndex((getIndex(device) + 5)/10);
- } else if ((device & mFullVolumeDevices) != 0) {
+ } else if (mFullVolumeDevices.contains(device)) {
index = (mIndexMax + 5)/10;
- } else if ((device & AudioSystem.DEVICE_OUT_HEARING_AID) != 0) {
+ } else if (device == AudioSystem.DEVICE_OUT_HEARING_AID) {
index = (mIndexMax + 5)/10;
} else {
index = (mIndexMap.valueAt(i) + 5)/10;
@@ -4668,7 +4680,7 @@
&& device == AudioSystem.DEVICE_OUT_SPEAKER) {
for (int i = 0; i < mIndexMap.size(); i++) {
int otherDevice = mIndexMap.keyAt(i);
- if ((otherDevice & AudioSystem.DEVICE_OUT_ALL_SCO) != 0) {
+ if (AudioSystem.DEVICE_OUT_ALL_SCO_SET.contains(otherDevice)) {
mIndexMap.put(otherDevice, index);
}
}
@@ -4806,8 +4818,8 @@
for (int i = 0; i < mIndexMap.size(); i++) {
int device = mIndexMap.keyAt(i);
int index = mIndexMap.valueAt(i);
- if (((device & mFullVolumeDevices) != 0)
- || (((device & mFixedVolumeDevices) != 0) && index != 0)) {
+ if (mFullVolumeDevices.contains(device)
+ || (mFixedVolumeDevices.contains(device) && index != 0)) {
mIndexMap.put(device, mIndexMax);
}
applyDeviceVolume_syncVSS(device, isAvrcpAbsVolSupported);
@@ -4978,7 +4990,7 @@
// that may have a different device selected
int streamDevice = getDeviceForStream(streamType);
if ((device != streamDevice) && isAvrcpAbsVolSupported
- && ((device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0)) {
+ && AudioSystem.DEVICE_OUT_ALL_A2DP_SET.contains(device)) {
mStreamStates[streamType].applyDeviceVolume_syncVSS(device,
isAvrcpAbsVolSupported);
}
@@ -5307,7 +5319,7 @@
}
/*package*/ void checkMusicActive(int deviceType, String caller) {
- if ((deviceType & mSafeMediaVolumeDevices) != 0) {
+ if (mSafeMediaVolumeDevices.contains(deviceType)) {
sendMsg(mAudioHandler,
MSG_CHECK_MUSIC_ACTIVE,
SENDMSG_REPLACE,
@@ -5753,9 +5765,9 @@
// the headset is compliant to EN 60950 with a max loudness of 100dB SPL.
private int mSafeUsbMediaVolumeIndex;
// mSafeMediaVolumeDevices lists the devices for which safe media volume is enforced,
- /*package*/ final int mSafeMediaVolumeDevices = AudioSystem.DEVICE_OUT_WIRED_HEADSET
- | AudioSystem.DEVICE_OUT_WIRED_HEADPHONE
- | AudioSystem.DEVICE_OUT_USB_HEADSET;
+ /*package*/ final Set<Integer> mSafeMediaVolumeDevices = new HashSet<>(
+ Arrays.asList(AudioSystem.DEVICE_OUT_WIRED_HEADSET,
+ AudioSystem.DEVICE_OUT_WIRED_HEADPHONE, AudioSystem.DEVICE_OUT_USB_HEADSET));
// mMusicActiveMs is the cumulative time of music activity since safe volume was disabled.
// When this time reaches UNSAFE_VOLUME_MUSIC_ACTIVE_MS_MAX, the safe media volume is re-enabled
// automatically. mMusicActiveMs is rounded to a multiple of MUSIC_ACTIVE_POLL_PERIOD_MS.
@@ -5765,7 +5777,7 @@
private static final int SAFE_VOLUME_CONFIGURE_TIMEOUT_MS = 30000; // 30s after boot completed
private int safeMediaVolumeIndex(int device) {
- if ((device & mSafeMediaVolumeDevices) == 0) {
+ if (!mSafeMediaVolumeDevices.contains(device)) {
return MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC];
}
if (device == AudioSystem.DEVICE_OUT_USB_HEADSET) {
@@ -5800,14 +5812,9 @@
private void enforceSafeMediaVolume(String caller) {
VolumeStreamState streamState = mStreamStates[AudioSystem.STREAM_MUSIC];
- int devices = mSafeMediaVolumeDevices;
- int i = 0;
+ Set<Integer> devices = mSafeMediaVolumeDevices;
- while (devices != 0) {
- int device = 1 << i++;
- if ((device & devices) == 0) {
- continue;
- }
+ for (int device : devices) {
int index = streamState.getIndex(device);
if (index > safeMediaVolumeIndex(device)) {
streamState.setIndex(safeMediaVolumeIndex(device), device, caller);
@@ -5819,16 +5826,15 @@
streamState,
0);
}
- devices &= ~device;
}
}
private boolean checkSafeMediaVolume(int streamType, int index, int device) {
synchronized (mSafeMediaVolumeStateLock) {
- if ((mSafeMediaVolumeState == SAFE_MEDIA_VOLUME_ACTIVE) &&
- (mStreamVolumeAlias[streamType] == AudioSystem.STREAM_MUSIC) &&
- ((device & mSafeMediaVolumeDevices) != 0) &&
- (index > safeMediaVolumeIndex(device))) {
+ if ((mSafeMediaVolumeState == SAFE_MEDIA_VOLUME_ACTIVE)
+ && (mStreamVolumeAlias[streamType] == AudioSystem.STREAM_MUSIC)
+ && (mSafeMediaVolumeDevices.contains(device))
+ && (index > safeMediaVolumeIndex(device))) {
return false;
}
return true;
@@ -5869,14 +5875,14 @@
if (DEBUG_VOL) {
Log.d(TAG, "CEC sink: setting HDMI as full vol device");
}
- mFullVolumeDevices |= AudioSystem.DEVICE_OUT_HDMI;
+ mFullVolumeDevices.add(AudioSystem.DEVICE_OUT_HDMI);
} else {
if (DEBUG_VOL) {
Log.d(TAG, "TV, no CEC: setting HDMI as regular vol device");
}
// Android TV devices without CEC service apply software volume on
// HDMI output
- mFullVolumeDevices &= ~AudioSystem.DEVICE_OUT_HDMI;
+ mFullVolumeDevices.remove(AudioSystem.DEVICE_OUT_HDMI);
}
checkAddAllFixedVolumeDevices(AudioSystem.DEVICE_OUT_HDMI,
@@ -6097,6 +6103,19 @@
pw.println();
}
+ private String dumpDeviceTypes(@NonNull Set<Integer> deviceTypes) {
+ Iterator<Integer> it = deviceTypes.iterator();
+ if (!it.hasNext()) {
+ return "";
+ }
+ final StringBuilder sb = new StringBuilder();
+ sb.append("0x" + Integer.toHexString(it.next()));
+ while (it.hasNext()) {
+ sb.append("," + "0x" + Integer.toHexString(it.next()));
+ }
+ return sb.toString();
+ }
+
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
@@ -6133,7 +6152,7 @@
pw.println(mDeviceBroker.isAvrcpAbsoluteVolumeSupported());
pw.print(" mIsSingleVolume="); pw.println(mIsSingleVolume);
pw.print(" mUseFixedVolume="); pw.println(mUseFixedVolume);
- pw.print(" mFixedVolumeDevices=0x"); pw.println(Integer.toHexString(mFixedVolumeDevices));
+ pw.print(" mFixedVolumeDevices="); pw.println(dumpDeviceTypes(mFixedVolumeDevices));
pw.print(" mHdmiCecSink="); pw.println(mHdmiCecSink);
pw.print(" mHdmiAudioSystemClient="); pw.println(mHdmiAudioSystemClient);
pw.print(" mHdmiPlaybackClient="); pw.println(mHdmiPlaybackClient);
diff --git a/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java b/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java
index bc83780..2179518 100644
--- a/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java
+++ b/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java
@@ -31,7 +31,6 @@
import android.net.StringNetworkSpecifier;
import android.net.wifi.WifiInfo;
import android.os.UserHandle;
-import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -105,8 +104,7 @@
return -1;
}
- // TODO: Remove @TransportType or change it to @Transport.
- private static String getTransportName(@TransportType int transportType) {
+ private static String getTransportName(final int transportType) {
Resources r = Resources.getSystem();
String[] networkTypes = r.getStringArray(R.array.network_switch_type_name);
try {
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 204f186..31960e4 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -2257,14 +2257,14 @@
return mContext.getResources().getString(com.android.internal.R.string.owner_name);
}
- private void scheduleWriteUser(UserData UserData) {
+ private void scheduleWriteUser(UserData userData) {
if (DBG) {
debug("scheduleWriteUser");
}
// No need to wrap it within a lock -- worst case, we'll just post the same message
// twice.
- if (!mHandler.hasMessages(WRITE_USER_MSG, UserData)) {
- Message msg = mHandler.obtainMessage(WRITE_USER_MSG, UserData);
+ if (!mHandler.hasMessages(WRITE_USER_MSG, userData)) {
+ Message msg = mHandler.obtainMessage(WRITE_USER_MSG, userData);
mHandler.sendMessageDelayed(msg, WRITE_USER_DELAY);
}
}
diff --git a/services/core/java/com/android/server/timedetector/SimpleTimeDetectorStrategy.java b/services/core/java/com/android/server/timedetector/SimpleTimeDetectorStrategy.java
index 0b970bf..340fe3d 100644
--- a/services/core/java/com/android/server/timedetector/SimpleTimeDetectorStrategy.java
+++ b/services/core/java/com/android/server/timedetector/SimpleTimeDetectorStrategy.java
@@ -150,7 +150,8 @@
if (!mCallback.isAutoTimeDetectionEnabled()) {
if (DBG) {
Slog.d(LOG_TAG, "Auto time detection is not enabled."
- + " time=" + time
+ + " origin=" + origin
+ + ", time=" + time
+ ", cause=" + cause);
}
return;
@@ -159,7 +160,8 @@
if (mCallback.isAutoTimeDetectionEnabled()) {
if (DBG) {
Slog.d(LOG_TAG, "Auto time detection is enabled."
- + " time=" + time
+ + " origin=" + origin
+ + ", time=" + time
+ ", cause=" + cause);
}
return;
@@ -232,16 +234,16 @@
@Override
public synchronized void dump(@NonNull PrintWriter pw, @Nullable String[] args) {
- pw.println("mLastPhoneSuggestion=" + mLastPhoneSuggestion);
- pw.println("mLastAutoSystemClockTimeSet=" + mLastAutoSystemClockTimeSet);
- pw.println("mLastAutoSystemClockTime=" + mLastAutoSystemClockTime);
- pw.println("mLastAutoSystemClockTimeSendNetworkBroadcast="
+ IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
+ ipw.println("TimeDetectorStrategy:");
+ ipw.increaseIndent(); // level 1
+
+ ipw.println("mLastPhoneSuggestion=" + mLastPhoneSuggestion);
+ ipw.println("mLastAutoSystemClockTimeSet=" + mLastAutoSystemClockTimeSet);
+ ipw.println("mLastAutoSystemClockTime=" + mLastAutoSystemClockTime);
+ ipw.println("mLastAutoSystemClockTimeSendNetworkBroadcast="
+ mLastAutoSystemClockTimeSendNetworkBroadcast);
- IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
-
- ipw.println("TimeDetectorStrategyImpl logs:");
- ipw.increaseIndent(); // level 1
ipw.println("Time change log:");
ipw.increaseIndent(); // level 2
@@ -249,6 +251,7 @@
ipw.decreaseIndent(); // level 2
ipw.decreaseIndent(); // level 1
+ ipw.flush();
}
@GuardedBy("this")
diff --git a/services/core/java/com/android/server/timedetector/TimeDetectorStrategy.java b/services/core/java/com/android/server/timedetector/TimeDetectorStrategy.java
index 32cee2d..0a6c2e7 100644
--- a/services/core/java/com/android/server/timedetector/TimeDetectorStrategy.java
+++ b/services/core/java/com/android/server/timedetector/TimeDetectorStrategy.java
@@ -39,6 +39,12 @@
/**
* The interface used by the strategy to interact with the surrounding service.
+ *
+ * <p>Note: Because the system properties-derived value {@link #isAutoTimeDetectionEnabled()}
+ * can be modified independently and from different threads (and processes!). its use is prone
+ * to race conditions. That will be true until the responsibility for setting their values is
+ * moved to {@link TimeDetectorStrategy}. There are similar issues with
+ * {@link #systemClockMillis()} while any process can modify the system clock.
*/
interface Callback {
diff --git a/services/core/jni/com_android_server_VibratorService.cpp b/services/core/jni/com_android_server_VibratorService.cpp
index 612a1e7..dcff5a1 100644
--- a/services/core/jni/com_android_server_VibratorService.cpp
+++ b/services/core/jni/com_android_server_VibratorService.cpp
@@ -338,7 +338,7 @@
if (auto hal = getHal<aidl::IVibrator>()) {
int32_t lengthMs;
sp<AidlVibratorCallback> effectCallback = new AidlVibratorCallback(env, vibration);
- aidl::Effect effectType(static_cast<aidl::Effect>(strength));
+ aidl::Effect effectType(static_cast<aidl::Effect>(effect));
aidl::EffectStrength effectStrength(static_cast<aidl::EffectStrength>(strength));
auto status = hal->call(&aidl::IVibrator::perform, effectType, effectStrength, effectCallback, &lengthMs);
diff --git a/services/tests/servicestests/src/com/android/server/timedetector/SimpleTimeDetectorStrategyTest.java b/services/tests/servicestests/src/com/android/server/timedetector/SimpleTimeDetectorStrategyTest.java
index 8a7edf7..7a0a28d 100644
--- a/services/tests/servicestests/src/com/android/server/timedetector/SimpleTimeDetectorStrategyTest.java
+++ b/services/tests/servicestests/src/com/android/server/timedetector/SimpleTimeDetectorStrategyTest.java
@@ -640,9 +640,9 @@
private static PhoneTimeSuggestion createPhoneTimeSuggestion(int phoneId,
TimestampedValue<Long> utcTime) {
- PhoneTimeSuggestion timeSuggestion = new PhoneTimeSuggestion(phoneId);
- timeSuggestion.setUtcTime(utcTime);
- return timeSuggestion;
+ return new PhoneTimeSuggestion.Builder(phoneId)
+ .setUtcTime(utcTime)
+ .build();
}
private ManualTimeSuggestion createManualTimeSuggestion(long timeMillis) {
diff --git a/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java b/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java
index 9951e85..84b495f 100644
--- a/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java
@@ -140,10 +140,10 @@
private static PhoneTimeSuggestion createPhoneTimeSuggestion() {
int phoneId = 1234;
- PhoneTimeSuggestion suggestion = new PhoneTimeSuggestion(phoneId);
TimestampedValue<Long> timeValue = new TimestampedValue<>(100L, 1_000_000L);
- suggestion.setUtcTime(timeValue);
- return suggestion;
+ return new PhoneTimeSuggestion.Builder(phoneId)
+ .setUtcTime(timeValue)
+ .build();
}
private static ManualTimeSuggestion createManualTimeSuggestion() {
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java
index a0739c4..86ad795 100644
--- a/telecomm/java/android/telecom/Call.java
+++ b/telecomm/java/android/telecom/Call.java
@@ -291,7 +291,6 @@
*/
public static final int DIRECTION_OUTGOING = 1;
-
/** Call can currently be put on hold or unheld. */
public static final int CAPABILITY_HOLD = 0x00000001;
@@ -571,6 +570,7 @@
private final Bundle mIntentExtras;
private final long mCreationTimeMillis;
private final @CallDirection int mCallDirection;
+ private final @Connection.VerificationStatus int mCallerNumberVerificationStatus;
/**
* Whether the supplied capabilities supports the specified capability.
@@ -880,6 +880,15 @@
return mCallDirection;
}
+ /**
+ * Gets the verification status for the phone number of an incoming call as identified in
+ * ATIS-1000082.
+ * @return the verification status.
+ */
+ public @Connection.VerificationStatus int getCallerNumberVerificationStatus() {
+ return mCallerNumberVerificationStatus;
+ }
+
@Override
public boolean equals(Object o) {
if (o instanceof Details) {
@@ -901,7 +910,9 @@
areBundlesEqual(mExtras, d.mExtras) &&
areBundlesEqual(mIntentExtras, d.mIntentExtras) &&
Objects.equals(mCreationTimeMillis, d.mCreationTimeMillis) &&
- Objects.equals(mCallDirection, d.mCallDirection);
+ Objects.equals(mCallDirection, d.mCallDirection) &&
+ Objects.equals(mCallerNumberVerificationStatus,
+ d.mCallerNumberVerificationStatus);
}
return false;
}
@@ -923,7 +934,8 @@
mExtras,
mIntentExtras,
mCreationTimeMillis,
- mCallDirection);
+ mCallDirection,
+ mCallerNumberVerificationStatus);
}
/** {@hide} */
@@ -944,7 +956,8 @@
Bundle extras,
Bundle intentExtras,
long creationTimeMillis,
- int callDirection) {
+ int callDirection,
+ int callerNumberVerificationStatus) {
mTelecomCallId = telecomCallId;
mHandle = handle;
mHandlePresentation = handlePresentation;
@@ -962,6 +975,7 @@
mIntentExtras = intentExtras;
mCreationTimeMillis = creationTimeMillis;
mCallDirection = callDirection;
+ mCallerNumberVerificationStatus = callerNumberVerificationStatus;
}
/** {@hide} */
@@ -983,7 +997,8 @@
parcelableCall.getExtras(),
parcelableCall.getIntentExtras(),
parcelableCall.getCreationTimeMillis(),
- parcelableCall.getCallDirection());
+ parcelableCall.getCallDirection(),
+ parcelableCall.getCallerNumberVerificationStatus());
}
@Override
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index ae20aed..c063279 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -16,6 +16,7 @@
package android.telecom;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
@@ -48,6 +49,8 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.nio.channels.Channels;
import java.util.ArrayList;
import java.util.Arrays;
@@ -151,6 +154,32 @@
public static final int STATE_PULLING_CALL = 7;
/**
+ * Indicates that the network could not perform verification.
+ */
+ public static final int VERIFICATION_STATUS_NOT_VERIFIED = 0;
+
+ /**
+ * Indicates that verification by the network passed. This indicates there is a high likelihood
+ * that the call originated from a valid source.
+ */
+ public static final int VERIFICATION_STATUS_PASSED = 1;
+
+ /**
+ * Indicates that verification by the network failed. This indicates there is a high likelihood
+ * that the call did not originate from a valid source.
+ */
+ public static final int VERIFICATION_STATUS_FAILED = 2;
+
+ /**@hide*/
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = "VERIFICATION_STATUS_", value = {
+ VERIFICATION_STATUS_NOT_VERIFIED,
+ VERIFICATION_STATUS_PASSED,
+ VERIFICATION_STATUS_FAILED
+ })
+ public @interface VerificationStatus {}
+
+ /**
* Connection can currently be put on hold or unheld. This is distinct from
* {@link #CAPABILITY_SUPPORT_HOLD} in that although a connection may support 'hold' most times,
* it does not at the moment support the function. This can be true while the call is in the
@@ -1854,6 +1883,12 @@
private Set<String> mPreviousExtraKeys;
/**
+ * The verification status for an incoming call's phone number.
+ */
+ private @VerificationStatus int mCallerNumberVerificationStatus;
+
+
+ /**
* Create a new Connection.
*/
public Connection() {}
@@ -3355,4 +3390,26 @@
public void setCallDirection(@Call.Details.CallDirection int callDirection) {
mCallDirection = callDirection;
}
+
+ /**
+ * Gets the verification status for the phone number of an incoming call as identified in
+ * ATIS-1000082.
+ * @return the verification status.
+ */
+ public @VerificationStatus int getCallerNumberVerificationStatus() {
+ return mCallerNumberVerificationStatus;
+ }
+
+ /**
+ * Sets the verification status for the phone number of an incoming call as identified in
+ * ATIS-1000082.
+ * <p>
+ * This property can only be set at the time of creation of a {@link Connection} being returned
+ * by
+ * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}.
+ */
+ public void setCallerNumberVerificationStatus(
+ @VerificationStatus int callerNumberVerificationStatus) {
+ mCallerNumberVerificationStatus = callerNumberVerificationStatus;
+ }
}
diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java
index 812b805..3a0494e 100644
--- a/telecomm/java/android/telecom/ConnectionService.java
+++ b/telecomm/java/android/telecom/ConnectionService.java
@@ -1621,7 +1621,8 @@
connection.getStatusHints(),
connection.getDisconnectCause(),
createIdList(connection.getConferenceables()),
- connection.getExtras()));
+ connection.getExtras(),
+ connection.getCallerNumberVerificationStatus()));
if (isIncoming && request.shouldShowIncomingCallUi() && isSelfManaged) {
// Tell ConnectionService to show its incoming call UX.
@@ -2156,7 +2157,8 @@
emptyList,
connection.getExtras(),
conferenceId,
- connection.getCallDirection());
+ connection.getCallDirection(),
+ Connection.VERIFICATION_STATUS_NOT_VERIFIED);
mAdapter.addExistingConnection(id, parcelableConnection);
}
}
diff --git a/telecomm/java/android/telecom/ParcelableCall.java b/telecomm/java/android/telecom/ParcelableCall.java
index fdc3243..a234bb0 100644
--- a/telecomm/java/android/telecom/ParcelableCall.java
+++ b/telecomm/java/android/telecom/ParcelableCall.java
@@ -16,7 +16,6 @@
package android.telecom;
-import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
import android.net.Uri;
import android.os.Build;
@@ -66,6 +65,7 @@
private final Bundle mExtras;
private final long mCreationTimeMillis;
private final int mCallDirection;
+ private final int mCallerNumberVerificationStatus;
public ParcelableCall(
String id,
@@ -94,7 +94,8 @@
Bundle intentExtras,
Bundle extras,
long creationTimeMillis,
- int callDirection) {
+ int callDirection,
+ int callerNumberVerificationStatus) {
mId = id;
mState = state;
mDisconnectCause = disconnectCause;
@@ -122,6 +123,7 @@
mExtras = extras;
mCreationTimeMillis = creationTimeMillis;
mCallDirection = callDirection;
+ mCallerNumberVerificationStatus = callerNumberVerificationStatus;
}
/** The unique ID of the call. */
@@ -322,6 +324,15 @@
return mCallDirection;
}
+ /**
+ * Gets the verification status for the phone number of an incoming call as identified in
+ * ATIS-1000082.
+ * @return the verification status.
+ */
+ public @Connection.VerificationStatus int getCallerNumberVerificationStatus() {
+ return mCallerNumberVerificationStatus;
+ }
+
/** Responsible for creating ParcelableCall objects for deserialized Parcels. */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public static final @android.annotation.NonNull Parcelable.Creator<ParcelableCall> CREATOR =
@@ -360,6 +371,7 @@
ParcelableRttCall rttCall = source.readParcelable(classLoader);
long creationTimeMillis = source.readLong();
int callDirection = source.readInt();
+ int callerNumberVerificationStatus = source.readInt();
return new ParcelableCall(
id,
state,
@@ -387,7 +399,8 @@
intentExtras,
extras,
creationTimeMillis,
- callDirection);
+ callDirection,
+ callerNumberVerificationStatus);
}
@Override
@@ -433,6 +446,7 @@
destination.writeParcelable(mRttCall, 0);
destination.writeLong(mCreationTimeMillis);
destination.writeInt(mCallDirection);
+ destination.writeInt(mCallerNumberVerificationStatus);
}
@Override
diff --git a/telecomm/java/android/telecom/ParcelableConnection.java b/telecomm/java/android/telecom/ParcelableConnection.java
index 4734af6..2b9ce9b 100644
--- a/telecomm/java/android/telecom/ParcelableConnection.java
+++ b/telecomm/java/android/telecom/ParcelableConnection.java
@@ -54,6 +54,7 @@
private final Bundle mExtras;
private String mParentCallId;
private @Call.Details.CallDirection int mCallDirection;
+ private @Connection.VerificationStatus int mCallerNumberVerificationStatus;
/** @hide */
public ParcelableConnection(
@@ -77,12 +78,13 @@
List<String> conferenceableConnectionIds,
Bundle extras,
String parentCallId,
- @Call.Details.CallDirection int callDirection) {
+ @Call.Details.CallDirection int callDirection,
+ @Connection.VerificationStatus int callerNumberVerificationStatus) {
this(phoneAccount, state, capabilities, properties, supportedAudioRoutes, address,
addressPresentation, callerDisplayName, callerDisplayNamePresentation,
videoProvider, videoState, ringbackRequested, isVoipAudioMode, connectTimeMillis,
connectElapsedTimeMillis, statusHints, disconnectCause, conferenceableConnectionIds,
- extras);
+ extras, callerNumberVerificationStatus);
mParentCallId = parentCallId;
mCallDirection = callDirection;
}
@@ -107,7 +109,8 @@
StatusHints statusHints,
DisconnectCause disconnectCause,
List<String> conferenceableConnectionIds,
- Bundle extras) {
+ Bundle extras,
+ @Connection.VerificationStatus int callerNumberVerificationStatus) {
mPhoneAccount = phoneAccount;
mState = state;
mConnectionCapabilities = capabilities;
@@ -129,6 +132,7 @@
mExtras = extras;
mParentCallId = null;
mCallDirection = Call.Details.DIRECTION_UNKNOWN;
+ mCallerNumberVerificationStatus = callerNumberVerificationStatus;
}
public PhoneAccountHandle getPhoneAccount() {
@@ -227,6 +231,10 @@
return mCallDirection;
}
+ public @Connection.VerificationStatus int getCallerNumberVerificationStatus() {
+ return mCallerNumberVerificationStatus;
+ }
+
@Override
public String toString() {
return new StringBuilder()
@@ -276,6 +284,7 @@
String parentCallId = source.readString();
long connectElapsedTimeMillis = source.readLong();
int callDirection = source.readInt();
+ int callerNumberVerificationStatus = source.readInt();
return new ParcelableConnection(
phoneAccount,
@@ -298,7 +307,8 @@
conferenceableConnectionIds,
extras,
parentCallId,
- callDirection);
+ callDirection,
+ callerNumberVerificationStatus);
}
@Override
@@ -338,5 +348,6 @@
destination.writeString(mParentCallId);
destination.writeLong(mConnectElapsedTimeMillis);
destination.writeInt(mCallDirection);
+ destination.writeInt(mCallerNumberVerificationStatus);
}
}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 9f15bb7..2cfc2b7 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -4583,17 +4583,6 @@
}
/**
- * Sim activation type: voice
- * @hide
- */
- public static final int SIM_ACTIVATION_TYPE_VOICE = 0;
- /**
- * Sim activation type: data
- * @hide
- */
- public static final int SIM_ACTIVATION_TYPE_DATA = 1;
-
- /**
* Initial SIM activation state, unknown. Not set by any carrier apps.
* @hide
*/