summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/os/FileUtils.java7
-rw-r--r--services/core/java/com/android/server/AlarmManagerService.java15
-rw-r--r--services/core/jni/com_android_server_AlarmManagerService.cpp6
-rw-r--r--telecomm/java/android/telecom/InCallService.java74
-rw-r--r--telephony/java/com/android/internal/telephony/RILConstants.java54
-rw-r--r--tools/aapt2/AppInfo.h5
-rw-r--r--tools/aapt2/cmd/Link.cpp12
-rw-r--r--tools/aapt2/cmd/Util.cpp38
-rw-r--r--tools/aapt2/cmd/Util.h5
-rw-r--r--tools/aapt2/cmd/Util_test.cpp48
-rw-r--r--tools/aapt2/optimize/MultiApkGenerator.cpp31
-rw-r--r--wifi/java/android/net/wifi/hotspot2/omadm/PpsMoParser.java2
-rw-r--r--wifi/tests/assets/pps/PerProviderSubscription.xml2
13 files changed, 257 insertions, 42 deletions
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java
index 9fccd1ec7b43..3a3d9ea0b44f 100644
--- a/core/java/android/os/FileUtils.java
+++ b/core/java/android/os/FileUtils.java
@@ -93,7 +93,8 @@ public class FileUtils {
private static final File[] EMPTY = new File[0];
- private static final boolean ENABLE_COPY_OPTIMIZATIONS = true;
+ // non-final so it can be toggled by Robolectric's ShadowFileUtils
+ private static boolean sEnableCopyOptimizations = true;
private static final long COPY_CHECKPOINT_BYTES = 524288;
@@ -338,7 +339,7 @@ public class FileUtils {
public static long copy(@NonNull InputStream in, @NonNull OutputStream out,
@Nullable CancellationSignal signal, @Nullable Executor executor,
@Nullable ProgressListener listener) throws IOException {
- if (ENABLE_COPY_OPTIMIZATIONS) {
+ if (sEnableCopyOptimizations) {
if (in instanceof FileInputStream && out instanceof FileOutputStream) {
return copy(((FileInputStream) in).getFD(), ((FileOutputStream) out).getFD(),
signal, executor, listener);
@@ -395,7 +396,7 @@ public class FileUtils {
public static long copy(@NonNull FileDescriptor in, @NonNull FileDescriptor out, long count,
@Nullable CancellationSignal signal, @Nullable Executor executor,
@Nullable ProgressListener listener) throws IOException {
- if (ENABLE_COPY_OPTIMIZATIONS) {
+ if (sEnableCopyOptimizations) {
try {
final StructStat st_in = Os.fstat(in);
final StructStat st_out = Os.fstat(out);
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index 7185f025ba8c..26ef42f2b1e7 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -3518,9 +3518,13 @@ class AlarmManagerService extends SystemService {
private class AlarmThread extends Thread
{
+ private int mFalseWakeups;
+ private int mWtfThreshold;
public AlarmThread()
{
super("AlarmManager");
+ mFalseWakeups = 0;
+ mWtfThreshold = 10;
}
public void run()
@@ -3633,6 +3637,17 @@ class AlarmManagerService extends SystemService {
}
mPendingNonWakeupAlarms.clear();
}
+ if (mLastTimeChangeRealtime != nowELAPSED && triggerList.isEmpty()) {
+ if (++mFalseWakeups >= mWtfThreshold) {
+ Slog.wtf(TAG, "Too many (" + mFalseWakeups
+ + ") false wakeups, nowElapsed=" + nowELAPSED);
+ if (mWtfThreshold < 100_000) {
+ mWtfThreshold *= 10;
+ } else {
+ mFalseWakeups = 0;
+ }
+ }
+ }
final ArraySet<Pair<String, Integer>> triggerPackages =
new ArraySet<>();
for (int i = 0; i < triggerList.size(); i++) {
diff --git a/services/core/jni/com_android_server_AlarmManagerService.cpp b/services/core/jni/com_android_server_AlarmManagerService.cpp
index 921eed98d0a8..e79612fbf3d3 100644
--- a/services/core/jni/com_android_server_AlarmManagerService.cpp
+++ b/services/core/jni/com_android_server_AlarmManagerService.cpp
@@ -194,7 +194,9 @@ int AlarmImpl::waitForAlarm()
uint32_t alarm_idx = events[i].data.u32;
uint64_t unused;
ssize_t err = read(fds[alarm_idx], &unused, sizeof(unused));
- if (err < 0) {
+ // Worth evaluating even if read fails with EAGAIN, since epoll_wait
+ // returned. (see b/78560047#comment34)
+ if (err < 0 && errno != EAGAIN) {
if (alarm_idx == ANDROID_ALARM_TYPE_COUNT && errno == ECANCELED) {
result |= ANDROID_ALARM_TIME_CHANGE_MASK;
} else {
@@ -348,7 +350,7 @@ static jlong android_server_AlarmManagerService_init(JNIEnv*, jobject)
}
for (size_t i = 0; i < fds.size(); i++) {
- fds[i] = timerfd_create(android_alarm_to_clockid[i], 0);
+ fds[i] = timerfd_create(android_alarm_to_clockid[i], TFD_NONBLOCK);
if (fds[i] < 0) {
log_timerfd_create_error(android_alarm_to_clockid[i]);
close(epollfd);
diff --git a/telecomm/java/android/telecom/InCallService.java b/telecomm/java/android/telecom/InCallService.java
index bd25ab2b8eab..1aeeca73c0b9 100644
--- a/telecomm/java/android/telecom/InCallService.java
+++ b/telecomm/java/android/telecom/InCallService.java
@@ -47,13 +47,19 @@ import java.util.List;
* before the telecom service will bind to its {@code InCallService} implementation.
* <p>
* Below is an example manifest registration for an {@code InCallService}. The meta-data
- * ({@link TelecomManager#METADATA_IN_CALL_SERVICE_UI}) indicates that this particular
+ * {@link TelecomManager#METADATA_IN_CALL_SERVICE_UI} indicates that this particular
* {@code InCallService} implementation intends to replace the built-in in-call UI.
+ * The meta-data {@link TelecomManager#METADATA_IN_CALL_SERVICE_RINGING} indicates that this
+ * {@link InCallService} will play the ringtone for incoming calls. See
+ * <a href="#incomingCallNotification">below</a> for more information on showing the incoming call
+ * UI and playing the ringtone in your app.
* <pre>
* {@code
* <service android:name="your.package.YourInCallServiceImplementation"
* android:permission="android.permission.BIND_INCALL_SERVICE">
* <meta-data android:name="android.telecom.IN_CALL_SERVICE_UI" android:value="true" />
+ * <meta-data android:name="android.telecom.IN_CALL_SERVICE_RINGING"
+ * android:value="true" />
* <intent-filter>
* <action android:name="android.telecom.InCallService"/>
* </intent-filter>
@@ -80,6 +86,72 @@ import java.util.List;
* to see if they would like your application to be the new default phone app. See the
* {@link TelecomManager#ACTION_CHANGE_DEFAULT_DIALER} intent documentation for more information on
* how to do this.
+ * <p id="incomingCallNotification">
+ * <h2>Showing the Incoming Call Notification</h2>
+ * When your app receives a new incoming call via {@link InCallService#onCallAdded(Call)}, it is
+ * responsible for displaying an incoming call UI for the incoming call. It should do this using
+ * {@link android.app.NotificationManager} APIs to post a new incoming call notification.
+ * <p>
+ * Where your app declares the meta-data {@link TelecomManager#METADATA_IN_CALL_SERVICE_RINGING}, it
+ * is responsible for playing the ringtone for incoming calls. Your app should create a
+ * {@link android.app.NotificationChannel} which specifies the desired ringtone. For example:
+ * <pre><code>
+ * NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls",
+ * NotificationManager.IMPORTANCE_MAX);
+ * // other channel setup stuff goes here.
+ *
+ * // We'll use the default system ringtone for our incoming call notification channel. You can
+ * // use your own audio resource here.
+ * Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
+ * channel.setSound(ringtoneUri, new AudioAttributes.Builder()
+ * // Setting the AudioAttributes is important as it identifies the purpose of your
+ * // notification sound.
+ * .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
+ * .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
+ * .build());
+ *
+ * NotificationManager mgr = getSystemService(NotificationManager.class);
+ * mgr.createNotificationChannel(channel);
+ * </code></pre>
+ * <p>
+ * When your app receives a new incoming call, it creates a {@link android.app.Notification} for the
+ * incoming call and associates it with your incoming call notification channel. You can specify a
+ * {@link android.app.PendingIntent} on the notification which will launch your full screen
+ * incoming call UI. The notification manager framework will display your notification as a
+ * heads-up notification if the user is actively using the phone. When the user is not using the
+ * phone, your full-screen incoming call UI is used instead.
+ * For example:
+ * <pre><code>
+ * // Create an intent which triggers your fullscreen incoming call user interface.
+ * Intent intent = new Intent(Intent.ACTION_MAIN, null);
+ * intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK);
+ * intent.setClass(context, YourIncomingCallActivity.class);
+ * PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, 0);
+ *
+ * // Build the notification as an ongoing high priority item; this ensures it will show as
+ * // a heads up notification which slides down over top of the current content.
+ * final Notification.Builder builder = new Notification.Builder(context);
+ * builder.setOngoing(true);
+ * builder.setPriority(Notification.PRIORITY_HIGH);
+ *
+ * // Set notification content intent to take user to the fullscreen UI if user taps on the
+ * // notification body.
+ * builder.setContentIntent(pendingIntent);
+ * // Set full screen intent to trigger display of the fullscreen UI when the notification
+ * // manager deems it appropriate.
+ * builder.setFullScreenIntent(pendingIntent, true);
+ *
+ * // Setup notification content.
+ * builder.setSmallIcon( yourIconResourceId );
+ * builder.setContentTitle("Your notification title");
+ * builder.setContentText("Your notification content.");
+ *
+ * // Use builder.addAction(..) to add buttons to answer or reject the call.
+ *
+ * NotificationManager notificationManager = mContext.getSystemService(
+ * NotificationManager.class);
+ * notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, builder.build());
+ * </code></pre>
*/
public abstract class InCallService extends Service {
diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java
index 49fbd8f06b05..3a263504a2ec 100644
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -16,15 +16,6 @@
package com.android.internal.telephony;
-/**
- * TODO: This should probably not be an interface see
- * http://www.javaworld.com/javaworld/javaqa/2001-06/01-qa-0608-constants.html and google with
- * http://www.google.com/search?q=interface+constants&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a
- *
- * Also they should all probably be static final.
- */
-
-import android.os.SystemProperties;
import android.telephony.TelephonyManager;
/**
@@ -231,13 +222,6 @@ public interface RILConstants {
int LCE_STOPPED = 0;
int LCE_ACTIVE = 1;
-/*
-cat include/telephony/ril.h | \
- egrep '^#define' | \
- sed -re 's/^#define +([^ ]+)* +([^ ]+)/ int \1 = \2;/' \
- >>java/android/com.android.internal.telephony/gsm/RILConstants.java
-*/
-
/**
* No restriction at all including voice/SMS/USSD/SS/AV64
* and packet data.
@@ -272,6 +256,18 @@ cat include/telephony/ril.h | \
public static final int DATA_PROFILE_OEM_BASE = 1000;
public static final int DATA_PROFILE_INVALID = 0xFFFFFFFF;
+ /**
+ * The request/response/unsol message IDs below match RIL.h through Android O-MR1.
+ *
+ * RIL.h is at hardware/ril/include/telephony.ril.h; RIL support is deprecated and may
+ * be removed in the future.
+ *
+ * Messages defined after O-MR1 have no corresponding definition in RIL.h.
+ * P-and-later messages start at RIL_REQUEST_HAL_NON_RIL_BASE and
+ * RIL_UNSOL_HAL_NON_RIL_BASE.
+ */
+
+ /* Requests begin */
int RIL_REQUEST_GET_SIM_STATUS = 1;
int RIL_REQUEST_ENTER_SIM_PIN = 2;
int RIL_REQUEST_ENTER_SIM_PUK = 3;
@@ -415,15 +411,20 @@ cat include/telephony/ril.h | \
int RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION = 141;
int RIL_REQUEST_START_NETWORK_SCAN = 142;
int RIL_REQUEST_STOP_NETWORK_SCAN = 143;
- int RIL_REQUEST_GET_SLOT_STATUS = 144;
- int RIL_REQUEST_SET_LOGICAL_TO_PHYSICAL_SLOT_MAPPING = 145;
- int RIL_REQUEST_START_KEEPALIVE = 146;
- int RIL_REQUEST_STOP_KEEPALIVE = 147;
- int RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA = 148;
- int RIL_REQUEST_SET_LINK_CAPACITY_REPORTING_CRITERIA = 149;
+ int RIL_REQUEST_START_KEEPALIVE = 144;
+ int RIL_REQUEST_STOP_KEEPALIVE = 145;
+ /* The following requests are not defined in RIL.h */
+ int RIL_REQUEST_HAL_NON_RIL_BASE = 200;
+ int RIL_REQUEST_GET_SLOT_STATUS = 200;
+ int RIL_REQUEST_SET_LOGICAL_TO_PHYSICAL_SLOT_MAPPING = 201;
+ int RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA = 202;
+ int RIL_REQUEST_SET_LINK_CAPACITY_REPORTING_CRITERIA = 203;
+
+ /* Responses begin */
int RIL_RESPONSE_ACKNOWLEDGEMENT = 800;
+ /* Unsols begin */
int RIL_UNSOL_RESPONSE_BASE = 1000;
int RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED = 1000;
int RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED = 1001;
@@ -475,7 +476,10 @@ cat include/telephony/ril.h | \
int RIL_UNSOL_MODEM_RESTART = 1047;
int RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION = 1048;
int RIL_UNSOL_NETWORK_SCAN_RESULT = 1049;
- int RIL_UNSOL_ICC_SLOT_STATUS = 1050;
- int RIL_UNSOL_KEEPALIVE_STATUS = 1051;
- int RIL_UNSOL_PHYSICAL_CHANNEL_CONFIG = 1052;
+ int RIL_UNSOL_KEEPALIVE_STATUS = 1050;
+
+ /* The following unsols are not defined in RIL.h */
+ int RIL_UNSOL_HAL_NON_RIL_BASE = 1100;
+ int RIL_UNSOL_ICC_SLOT_STATUS = 1100;
+ int RIL_UNSOL_PHYSICAL_CHANNEL_CONFIG = 1101;
}
diff --git a/tools/aapt2/AppInfo.h b/tools/aapt2/AppInfo.h
index d6f599520d71..75123537116f 100644
--- a/tools/aapt2/AppInfo.h
+++ b/tools/aapt2/AppInfo.h
@@ -31,9 +31,12 @@ struct AppInfo {
// The app's minimum SDK version, if it is defined.
Maybe<int> min_sdk_version;
- // The app's version code, if it is defined.
+ // The app's version code (the lower 32 bits of the long version code), if it is defined.
Maybe<uint32_t> version_code;
+ // The app's version code major (the upper 32 bits of the long version code), if it is defined.
+ Maybe<uint32_t> version_code_major;
+
// The app's revision code, if it is defined.
Maybe<uint32_t> revision_code;
diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp
index 26770d1f281c..1d508d91f0fa 100644
--- a/tools/aapt2/cmd/Link.cpp
+++ b/tools/aapt2/cmd/Link.cpp
@@ -908,6 +908,18 @@ class Linker {
app_info.version_code = maybe_code.value();
}
+ if (xml::Attribute* version_code_major_attr =
+ manifest_el->FindAttribute(xml::kSchemaAndroid, "versionCodeMajor")) {
+ Maybe<uint32_t> maybe_code = ResourceUtils::ParseInt(version_code_major_attr->value);
+ if (!maybe_code) {
+ diag->Error(DiagMessage(xml_res->file.source.WithLine(manifest_el->line_number))
+ << "invalid android:versionCodeMajor '"
+ << version_code_major_attr->value << "'");
+ return {};
+ }
+ app_info.version_code_major = maybe_code.value();
+ }
+
if (xml::Attribute* revision_code_attr =
manifest_el->FindAttribute(xml::kSchemaAndroid, "revisionCode")) {
Maybe<uint32_t> maybe_code = ResourceUtils::ParseInt(revision_code_attr->value);
diff --git a/tools/aapt2/cmd/Util.cpp b/tools/aapt2/cmd/Util.cpp
index 4e77e9ae9a45..c6c82b04ff2e 100644
--- a/tools/aapt2/cmd/Util.cpp
+++ b/tools/aapt2/cmd/Util.cpp
@@ -29,6 +29,7 @@
#include "util/Util.h"
using ::android::StringPiece;
+using ::android::base::StringPrintf;
namespace aapt {
@@ -168,6 +169,7 @@ std::string MakePackageSafeName(const std::string &name) {
std::unique_ptr<xml::XmlResource> GenerateSplitManifest(const AppInfo& app_info,
const SplitConstraints& constraints) {
const ResourceId kVersionCode(0x0101021b);
+ const ResourceId kVersionCodeMajor(0x01010576);
const ResourceId kRevisionCode(0x010104d5);
const ResourceId kHasCode(0x0101000c);
@@ -184,6 +186,14 @@ std::unique_ptr<xml::XmlResource> GenerateSplitManifest(const AppInfo& app_info,
util::make_unique<BinaryPrimitive>(android::Res_value::TYPE_INT_DEC, version_code)});
}
+ if (app_info.version_code_major) {
+ const uint32_t version_code_major = app_info.version_code_major.value();
+ manifest_el->attributes.push_back(xml::Attribute{
+ xml::kSchemaAndroid, "versionCodeMajor", std::to_string(version_code_major),
+ CreateAttributeWithId(kVersionCodeMajor),
+ util::make_unique<BinaryPrimitive>(android::Res_value::TYPE_INT_DEC, version_code_major)});
+ }
+
if (app_info.revision_code) {
const uint32_t revision_code = app_info.revision_code.value();
manifest_el->attributes.push_back(xml::Attribute{
@@ -355,6 +365,17 @@ Maybe<AppInfo> ExtractAppInfoFromBinaryManifest(const xml::XmlResource& xml_res,
app_info.version_code = maybe_code.value();
}
+ if (const xml::Attribute* version_code_major_attr =
+ manifest_el->FindAttribute(xml::kSchemaAndroid, "versionCodeMajor")) {
+ Maybe<uint32_t> maybe_code = ExtractCompiledInt(*version_code_major_attr, &error_msg);
+ if (!maybe_code) {
+ diag->Error(DiagMessage(xml_res.file.source.WithLine(manifest_el->line_number))
+ << "invalid android:versionCodeMajor: " << error_msg);
+ return {};
+ }
+ app_info.version_code_major = maybe_code.value();
+ }
+
if (const xml::Attribute* revision_code_attr =
manifest_el->FindAttribute(xml::kSchemaAndroid, "revisionCode")) {
Maybe<uint32_t> maybe_code = ExtractCompiledInt(*revision_code_attr, &error_msg);
@@ -391,4 +412,21 @@ Maybe<AppInfo> ExtractAppInfoFromBinaryManifest(const xml::XmlResource& xml_res,
return app_info;
}
+void SetLongVersionCode(xml::Element* manifest, uint64_t version) {
+ // Write the low bits of the version code to android:versionCode
+ auto version_code = manifest->FindOrCreateAttribute(xml::kSchemaAndroid, "versionCode");
+ version_code->value = StringPrintf("0x%08x", (uint32_t) (version & 0xffffffff));
+ version_code->compiled_value = ResourceUtils::TryParseInt(version_code->value);
+
+ auto version_high = (uint32_t) (version >> 32);
+ if (version_high != 0) {
+ // Write the high bits of the version code to android:versionCodeMajor
+ auto version_major = manifest->FindOrCreateAttribute(xml::kSchemaAndroid, "versionCodeMajor");
+ version_major->value = StringPrintf("0x%08x", version_high);
+ version_major->compiled_value = ResourceUtils::TryParseInt(version_major->value);
+ } else {
+ manifest->RemoveAttribute(xml::kSchemaAndroid, "versionCodeMajor");
+ }
+}
+
} // namespace aapt
diff --git a/tools/aapt2/cmd/Util.h b/tools/aapt2/cmd/Util.h
index fb8753ed2286..cf1443e30e1f 100644
--- a/tools/aapt2/cmd/Util.h
+++ b/tools/aapt2/cmd/Util.h
@@ -67,6 +67,11 @@ Maybe<AppInfo> ExtractAppInfoFromBinaryManifest(const xml::XmlResource& xml_res,
// checks this at runtime.
std::string MakePackageSafeName(const std::string &name);
+// Sets the versionCode and versionCodeMajor attributes to the version code. Attempts to encode the
+// version code using the versionCode attribute only, and encodes using both versionCode and
+// versionCodeMajor if the version code requires more than 32 bits.
+void SetLongVersionCode(xml::Element* manifest, uint64_t version_code);
+
} // namespace aapt
#endif /* AAPT_SPLIT_UTIL_H */
diff --git a/tools/aapt2/cmd/Util_test.cpp b/tools/aapt2/cmd/Util_test.cpp
index 0c527f6a90dc..b9fb5b2868a7 100644
--- a/tools/aapt2/cmd/Util_test.cpp
+++ b/tools/aapt2/cmd/Util_test.cpp
@@ -18,6 +18,7 @@
#include "AppInfo.h"
#include "split/TableSplitter.h"
+#include "test/Builders.h"
#include "test/Test.h"
namespace aapt {
@@ -36,4 +37,51 @@ TEST(UtilTest, SplitNamesAreSanitized) {
EXPECT_EQ(root->FindAttribute("", "targetConfig")->value, "b+sr+Latn,en-rUS-land");
}
+TEST (UtilTest, LongVersionCodeDefined) {
+ auto doc = test::BuildXmlDom(R"(
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.aapt.test" android:versionCode="0x1" android:versionCodeMajor="0x1">
+ </manifest>)");
+ SetLongVersionCode(doc->root.get(), 42);
+
+ auto version_code = doc->root->FindAttribute(xml::kSchemaAndroid, "versionCode");
+ ASSERT_NE(version_code, nullptr);
+ EXPECT_EQ(version_code->value, "0x0000002a");
+
+ ASSERT_NE(version_code->compiled_value, nullptr);
+ auto compiled_version_code = ValueCast<BinaryPrimitive>(version_code->compiled_value.get());
+ ASSERT_NE(compiled_version_code, nullptr);
+ EXPECT_EQ(compiled_version_code->value.data, 42U);
+
+ auto version_code_major = doc->root->FindAttribute(xml::kSchemaAndroid, "versionCodeMajor");
+ EXPECT_EQ(version_code_major, nullptr);
+}
+
+TEST (UtilTest, LongVersionCodeUndefined) {
+ auto doc = test::BuildXmlDom(R"(
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.aapt.test">
+ </manifest>)");
+ SetLongVersionCode(doc->root.get(), 420000000000);
+
+ auto version_code = doc->root->FindAttribute(xml::kSchemaAndroid, "versionCode");
+ ASSERT_NE(version_code, nullptr);
+ EXPECT_EQ(version_code->value, "0xc9f36800");
+
+ ASSERT_NE(version_code->compiled_value, nullptr);
+ auto compiled_version_code = ValueCast<BinaryPrimitive>(version_code->compiled_value.get());
+ ASSERT_NE(compiled_version_code, nullptr);
+ EXPECT_EQ(compiled_version_code->value.data, 0xc9f36800);
+
+ auto version_code_major = doc->root->FindAttribute(xml::kSchemaAndroid, "versionCodeMajor");
+ ASSERT_NE(version_code_major, nullptr);
+ EXPECT_EQ(version_code_major->value, "0x00000061");
+
+ ASSERT_NE(version_code_major->compiled_value, nullptr);
+ auto compiled_version_code_major = ValueCast<BinaryPrimitive>(
+ version_code_major->compiled_value.get());
+ ASSERT_NE(compiled_version_code_major, nullptr);
+ EXPECT_EQ(compiled_version_code_major->value.data, 0x61);
+}
+
} // namespace aapt
diff --git a/tools/aapt2/optimize/MultiApkGenerator.cpp b/tools/aapt2/optimize/MultiApkGenerator.cpp
index 9cfd7300df3d..a931343281bc 100644
--- a/tools/aapt2/optimize/MultiApkGenerator.cpp
+++ b/tools/aapt2/optimize/MultiApkGenerator.cpp
@@ -26,6 +26,7 @@
#include "ResourceUtils.h"
#include "ValueVisitor.h"
#include "configuration/ConfigurationParser.h"
+#include "cmd/Util.h"
#include "filter/AbiFilter.h"
#include "filter/Filter.h"
#include "format/Archive.h"
@@ -269,7 +270,7 @@ bool MultiApkGenerator::UpdateManifest(const OutputArtifact& artifact,
// Make sure the first element is <manifest> with package attribute.
xml::Element* manifest_el = manifest->root.get();
- if (manifest_el == nullptr) {
+ if (!manifest_el) {
return false;
}
@@ -278,21 +279,35 @@ bool MultiApkGenerator::UpdateManifest(const OutputArtifact& artifact,
return false;
}
- // Update the versionCode attribute.
- xml::Attribute* versionCode = manifest_el->FindAttribute(kSchemaAndroid, "versionCode");
- if (versionCode == nullptr) {
+ // Retrieve the versionCode attribute.
+ auto version_code = manifest_el->FindAttribute(kSchemaAndroid, "versionCode");
+ if (!version_code) {
diag->Error(DiagMessage(manifest->file.source) << "manifest must have a versionCode attribute");
return false;
}
- auto* compiled_version = ValueCast<BinaryPrimitive>(versionCode->compiled_value.get());
- if (compiled_version == nullptr) {
+ auto version_code_value = ValueCast<BinaryPrimitive>(version_code->compiled_value.get());
+ if (!version_code_value) {
diag->Error(DiagMessage(manifest->file.source) << "versionCode is invalid");
return false;
}
- int new_version = compiled_version->value.data + artifact.version;
- versionCode->compiled_value = ResourceUtils::TryParseInt(std::to_string(new_version));
+ // Retrieve the versionCodeMajor attribute.
+ auto version_code_major = manifest_el->FindAttribute(kSchemaAndroid, "versionCodeMajor");
+ BinaryPrimitive* version_code_major_value = nullptr;
+ if (version_code_major) {
+ version_code_major_value = ValueCast<BinaryPrimitive>(version_code_major->compiled_value.get());
+ if (!version_code_major_value) {
+ diag->Error(DiagMessage(manifest->file.source) << "versionCodeMajor is invalid");
+ return false;
+ }
+ }
+
+ // Calculate and set the updated version code
+ uint64_t major = (version_code_major_value)
+ ? ((uint64_t) version_code_major_value->value.data) << 32 : 0;
+ uint64_t new_version = (major | version_code_value->value.data) + artifact.version;
+ SetLongVersionCode(manifest_el, new_version);
// Check to see if the minSdkVersion needs to be updated.
if (artifact.android_sdk) {
diff --git a/wifi/java/android/net/wifi/hotspot2/omadm/PpsMoParser.java b/wifi/java/android/net/wifi/hotspot2/omadm/PpsMoParser.java
index f6183fa219a1..984cf7d62aa5 100644
--- a/wifi/java/android/net/wifi/hotspot2/omadm/PpsMoParser.java
+++ b/wifi/java/android/net/wifi/hotspot2/omadm/PpsMoParser.java
@@ -136,7 +136,7 @@ public final class PpsMoParser {
private static final String NODE_UPDATE_IDENTIFIER = "UpdateIdentifier";
private static final String NODE_AAA_SERVER_TRUST_ROOT = "AAAServerTrustRoot";
private static final String NODE_SUBSCRIPTION_UPDATE = "SubscriptionUpdate";
- private static final String NODE_SUBSCRIPTION_PARAMETER = "SubscriptionParameter";
+ private static final String NODE_SUBSCRIPTION_PARAMETER = "SubscriptionParameters";
private static final String NODE_TYPE_OF_SUBSCRIPTION = "TypeOfSubscription";
private static final String NODE_USAGE_LIMITS = "UsageLimits";
private static final String NODE_DATA_LIMIT = "DataLimit";
diff --git a/wifi/tests/assets/pps/PerProviderSubscription.xml b/wifi/tests/assets/pps/PerProviderSubscription.xml
index 1fb83094a002..e4472ce19d51 100644
--- a/wifi/tests/assets/pps/PerProviderSubscription.xml
+++ b/wifi/tests/assets/pps/PerProviderSubscription.xml
@@ -368,7 +368,7 @@
</Node>
</Node>
<Node>
- <NodeName>SubscriptionParameter</NodeName>
+ <NodeName>SubscriptionParameters</NodeName>
<Node>
<NodeName>CreationDate</NodeName>
<Value>2016-02-01T10:00:00Z</Value>