Merge "Fix test: the event should be from the previous bucket"
diff --git a/cmds/incidentd/Android.bp b/cmds/incidentd/Android.bp
index 3dc1093..40da583 100644
--- a/cmds/incidentd/Android.bp
+++ b/cmds/incidentd/Android.bp
@@ -94,10 +94,8 @@
data: ["testdata/**/*"],
- static_libs: [
- "libgmock",
- "libplatformprotos",
- ],
+ static_libs: ["libgmock"],
+
shared_libs: [
"libbase",
"libbinder",
diff --git a/cmds/incidentd/tests/Reporter_test.cpp b/cmds/incidentd/tests/Reporter_test.cpp
index b5e41d7..f54f738 100644
--- a/cmds/incidentd/tests/Reporter_test.cpp
+++ b/cmds/incidentd/tests/Reporter_test.cpp
@@ -35,16 +35,6 @@
using ::testing::StrEq;
using ::testing::Test;
-namespace {
-void getHeaderData(const IncidentHeaderProto& headerProto, vector<uint8_t>* out) {
- out->clear();
- auto serialized = headerProto.SerializeAsString();
- if (serialized.empty()) return;
- out->resize(serialized.length());
- std::copy(serialized.begin(), serialized.end(), out->begin());
-}
-}
-
class TestListener : public IIncidentReportStatusListener {
public:
int startInvoked;
@@ -153,10 +143,7 @@
args2.addSection(2);
IncidentHeaderProto header;
header.set_alert_id(12);
-
- vector<uint8_t> out;
- getHeaderData(header, &out);
- args2.addHeader(out);
+ args2.addHeader(header);
sp<ReportRequest> r1 = new ReportRequest(args1, l, tf.fd);
sp<ReportRequest> r2 = new ReportRequest(args2, l, tf.fd);
@@ -182,12 +169,8 @@
IncidentHeaderProto header1, header2;
header1.set_alert_id(12);
header2.set_reason("abcd");
-
- vector<uint8_t> out;
- getHeaderData(header1, &out);
- args.addHeader(out);
- getHeaderData(header2, &out);
- args.addHeader(out);
+ args.addHeader(header1);
+ args.addHeader(header2);
sp<ReportRequest> r = new ReportRequest(args, l, -1);
reporter->batch.add(r);
diff --git a/cmds/incidentd/tests/Section_test.cpp b/cmds/incidentd/tests/Section_test.cpp
index 24454ed..9b684a0 100644
--- a/cmds/incidentd/tests/Section_test.cpp
+++ b/cmds/incidentd/tests/Section_test.cpp
@@ -82,16 +82,6 @@
virtual IBinder* onAsBinder() override { return nullptr; };
};
-namespace {
-void getHeaderData(const IncidentHeaderProto& headerProto, vector<uint8_t>* out) {
- out->clear();
- auto serialized = headerProto.SerializeAsString();
- if (serialized.empty()) return;
- out->resize(serialized.length());
- std::copy(serialized.begin(), serialized.end(), out->begin());
-}
-}
-
TEST_F(SectionTest, HeaderSection) {
HeaderSection hs;
@@ -104,15 +94,9 @@
head1.set_reason("axe");
head2.set_reason("pup");
- vector<uint8_t> out;
- getHeaderData(head1, &out);
- args1.addHeader(out);
-
- getHeaderData(head2, &out);
- args1.addHeader(out);
-
- getHeaderData(head2, &out);
- args2.addHeader(out);
+ args1.addHeader(head1);
+ args1.addHeader(head2);
+ args2.addHeader(head2);
requests.add(new ReportRequest(args1, new SimpleListener(), -1));
requests.add(new ReportRequest(args2, new SimpleListener(), tf.fd));
diff --git a/cmds/statsd/src/subscriber/IncidentdReporter.cpp b/cmds/statsd/src/subscriber/IncidentdReporter.cpp
index 42cac0c..6e4b2c8 100644
--- a/cmds/statsd/src/subscriber/IncidentdReporter.cpp
+++ b/cmds/statsd/src/subscriber/IncidentdReporter.cpp
@@ -17,67 +17,32 @@
#include "Log.h"
#include "IncidentdReporter.h"
+#include "frameworks/base/libs/incident/proto/android/os/header.pb.h"
#include <android/os/IIncidentManager.h>
#include <android/os/IncidentReportArgs.h>
-#include <android/util/ProtoOutputStream.h>
#include <binder/IBinder.h>
#include <binder/IServiceManager.h>
-#include <vector>
-
namespace android {
namespace os {
namespace statsd {
-using android::util::ProtoOutputStream;
-using std::vector;
-
-using util::FIELD_TYPE_MESSAGE;
-using util::FIELD_TYPE_INT32;
-using util::FIELD_TYPE_INT64;
-
-// field ids in IncidentHeaderProto
-const int FIELD_ID_ALERT_ID = 1;
-const int FIELD_ID_CONFIG_KEY = 3;
-const int FIELD_ID_CONFIG_KEY_UID = 1;
-const int FIELD_ID_CONFIG_KEY_ID = 2;
-
-namespace {
-void getProtoData(const int64_t& rule_id, const ConfigKey& configKey, vector<uint8_t>* protoData) {
- ProtoOutputStream headerProto;
- headerProto.write(FIELD_TYPE_INT64 | FIELD_ID_ALERT_ID, (long long)rule_id);
- uint64_t token =
- headerProto.start(FIELD_TYPE_MESSAGE | FIELD_ID_CONFIG_KEY);
- headerProto.write(FIELD_TYPE_INT32 | FIELD_ID_CONFIG_KEY_UID, configKey.GetUid());
- headerProto.write(FIELD_TYPE_INT64 | FIELD_ID_CONFIG_KEY_ID, (long long)configKey.GetId());
- headerProto.end(token);
-
- protoData->resize(headerProto.size());
- size_t pos = 0;
- auto iter = headerProto.data();
- while (iter.readBuffer() != NULL) {
- size_t toRead = iter.currentToRead();
- std::memcpy(&((*protoData)[pos]), iter.readBuffer(), toRead);
- pos += toRead;
- iter.rp()->move(toRead);
- }
-}
-} // namespace
-
bool GenerateIncidentReport(const IncidentdDetails& config, const int64_t& rule_id,
const ConfigKey& configKey) {
if (config.section_size() == 0) {
VLOG("The alert %lld contains zero section in config(%d,%lld)", (unsigned long long)rule_id,
- configKey.GetUid(), (long long)configKey.GetId());
+ configKey.GetUid(), (long long) configKey.GetId());
return false;
}
IncidentReportArgs incidentReport;
- vector<uint8_t> protoData;
- getProtoData(rule_id, configKey, &protoData);
- incidentReport.addHeader(protoData);
+ android::os::IncidentHeaderProto header;
+ header.set_alert_id(rule_id);
+ header.mutable_config_key()->set_uid(configKey.GetUid());
+ header.mutable_config_key()->set_id(configKey.GetId());
+ incidentReport.addHeader(header);
for (int i = 0; i < config.section_size(); i++) {
incidentReport.addSection(config.section(i));
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index aee4b1f..8a09788 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -339,7 +339,11 @@
// For scheduling work on the main thread. This also serves as our
// global lock.
- @UnsupportedAppUsage
+ // Remark on @UnsupportedAppUsage: there were context leaks on old versions
+ // of android (b/37043700), so developers used this field to perform manual clean up.
+ // Leaks were fixed, hacks were backported to AppCompatActivity,
+ // so an access to the field is closed.
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
final H mH;
// Our generic input connection if the current target does not have its own.
@@ -375,13 +379,15 @@
* This is the view that should currently be served by an input method,
* regardless of the state of setting that up.
*/
- @UnsupportedAppUsage
+ // See comment to mH field in regard to @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
View mServedView;
/**
* This is then next view that will be served by the input method, when
* we get around to updating things.
*/
- @UnsupportedAppUsage
+ // See comment to mH field in regard to @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
View mNextServedView;
/**
* This is set when we are in the process of connecting, to determine
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index a02103e..542df45 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -442,8 +442,10 @@
/**
* Handles one frame of a fling
+ *
+ * To interrupt a fling early you should use smoothScrollBy(0,0) instead
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
private FlingRunnable mFlingRunnable;
/**
@@ -4679,7 +4681,8 @@
mScroller = new OverScroller(getContext());
}
- @UnsupportedAppUsage
+ // Use AbsListView#fling(int) instead
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
void start(int initialVelocity) {
int initialY = initialVelocity < 0 ? Integer.MAX_VALUE : 0;
mLastFlingY = initialY;
@@ -4757,7 +4760,8 @@
postOnAnimation(this);
}
- @UnsupportedAppUsage
+ // To interrupt a fling early you should use smoothScrollBy(0,0) instead
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
void endFling() {
mTouchMode = TOUCH_MODE_REST;
diff --git a/libs/incident/Android.bp b/libs/incident/Android.bp
index 905e303..0619a9c 100644
--- a/libs/incident/Android.bp
+++ b/libs/incident/Android.bp
@@ -36,6 +36,7 @@
srcs: [
":libincident_aidl",
+ "proto/android/os/header.proto",
"proto/android/os/metadata.proto",
"src/IncidentReportArgs.cpp",
],
@@ -46,4 +47,4 @@
},
export_include_dirs: ["include"],
-}
\ No newline at end of file
+}
diff --git a/libs/incident/include/android/os/IncidentReportArgs.h b/libs/incident/include/android/os/IncidentReportArgs.h
index 5e8eac1..ee1e33c 100644
--- a/libs/incident/include/android/os/IncidentReportArgs.h
+++ b/libs/incident/include/android/os/IncidentReportArgs.h
@@ -24,6 +24,8 @@
#include <set>
#include <vector>
+#include "frameworks/base/libs/incident/proto/android/os/header.pb.h"
+
namespace android {
namespace os {
@@ -47,7 +49,7 @@
void setAll(bool all);
void setDest(int dest);
void addSection(int section);
- void addHeader(const vector<uint8_t>& headerProto);
+ void addHeader(const IncidentHeaderProto& headerProto);
inline bool all() const { return mAll; }
bool containsSection(int section) const;
diff --git a/libs/incident/src/IncidentReportArgs.cpp b/libs/incident/src/IncidentReportArgs.cpp
index 06b7a5b..26261ef 100644
--- a/libs/incident/src/IncidentReportArgs.cpp
+++ b/libs/incident/src/IncidentReportArgs.cpp
@@ -161,9 +161,15 @@
}
void
-IncidentReportArgs::addHeader(const vector<uint8_t>& headerProto)
+IncidentReportArgs::addHeader(const IncidentHeaderProto& headerProto)
{
- mHeaders.push_back(headerProto);
+ vector<uint8_t> header;
+ auto serialized = headerProto.SerializeAsString();
+ if (serialized.empty()) return;
+ for (auto it = serialized.begin(); it != serialized.end(); it++) {
+ header.push_back((uint8_t)*it);
+ }
+ mHeaders.push_back(header);
}
bool
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java
index d06fc51..1b71904 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerSession.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -44,7 +44,6 @@
import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.apex.IApexService;
import android.app.admin.DevicePolicyManagerInternal;
import android.content.Context;
import android.content.IIntentReceiver;
@@ -80,7 +79,6 @@
import android.os.Process;
import android.os.RemoteException;
import android.os.RevocableFileDescriptor;
-import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.storage.StorageManager;
@@ -1084,6 +1082,11 @@
dispatchSessionFinished(PackageManager.INSTALL_SUCCEEDED, "Session staged", null);
return;
}
+ if ((params.installFlags & PackageManager.INSTALL_APEX) != 0) {
+ throw new PackageManagerException(
+ PackageManager.INSTALL_FAILED_INTERNAL_ERROR,
+ "APEX packages can only be installed using staged sessions.");
+ }
final PackageManagerService.ActiveInstallSession committingSession =
makeSessionActiveLocked();
if (committingSession == null) {
@@ -1101,12 +1104,6 @@
final PackageManagerService.ActiveInstallSession activeSession =
session.makeSessionActiveLocked();
if (activeSession != null) {
- if ((activeSession.getSessionParams().installFlags
- & PackageManager.INSTALL_APEX) != 0) {
- throw new PackageManagerException(
- PackageManager.INSTALL_FAILED_INTERNAL_ERROR,
- "Atomic install is not supported for APEX packages.");
- }
childSessions.add(activeSession);
}
} catch (PackageManagerException e) {
@@ -1124,27 +1121,7 @@
}
mPm.installStage(childSessions);
} else {
- if ((params.installFlags & PackageManager.INSTALL_APEX) != 0) {
- commitApexLocked();
- } else {
- mPm.installStage(committingSession);
- }
- }
- }
-
- @GuardedBy("mLock")
- private void commitApexLocked() throws PackageManagerException {
- try {
- IApexService apex = IApexService.Stub.asInterface(
- ServiceManager.getService("apexservice"));
- apex.stagePackage(mResolvedBaseFile.toString());
- } catch (Throwable e) {
- // Convert all exceptions into package manager exceptions as only those are handled
- // in the code above
- throw new PackageManagerException(e);
- } finally {
- destroyInternal();
- dispatchSessionFinished(PackageManager.INSTALL_SUCCEEDED, "APEX installed", null);
+ mPm.installStage(committingSession);
}
}