Merge "StatusBarWindowViewTest should run with a Looper"
diff --git a/Android.bp b/Android.bp
index e14281a..b4ce5de 100644
--- a/Android.bp
+++ b/Android.bp
@@ -226,6 +226,7 @@
"core/java/android/net/INetworkScoreService.aidl",
"core/java/android/net/INetworkStatsService.aidl",
"core/java/android/net/INetworkStatsSession.aidl",
+ "core/java/android/net/ITestNetworkManager.aidl",
"core/java/android/net/ITetheringEventCallback.aidl",
"core/java/android/net/ITetheringStatsProvider.aidl",
"core/java/android/net/nsd/INsdManager.aidl",
@@ -605,6 +606,7 @@
"telephony/java/com/android/internal/telephony/IOns.aidl",
"telephony/java/com/android/internal/telephony/ITelephony.aidl",
"telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl",
+ "telephony/java/com/android/internal/telephony/IUpdateAvailableNetworksCallback.aidl",
"telephony/java/com/android/internal/telephony/IWapPushManager.aidl",
"telephony/java/com/android/internal/telephony/euicc/IAuthenticateServerCallback.aidl",
"telephony/java/com/android/internal/telephony/euicc/ICancelSessionCallback.aidl",
diff --git a/api/current.txt b/api/current.txt
index e363f71..fe349e6 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -30187,7 +30187,7 @@
}
public final class ParcelablePeerHandle extends android.net.wifi.aware.PeerHandle implements android.os.Parcelable {
- ctor public ParcelablePeerHandle(android.net.wifi.aware.PeerHandle);
+ ctor public ParcelablePeerHandle(@NonNull android.net.wifi.aware.PeerHandle);
method public int describeContents();
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.aware.ParcelablePeerHandle> CREATOR;
@@ -30564,7 +30564,7 @@
}
public static interface WifiP2pManager.NetworkInfoListener {
- method public void onNetworkInfoAvailable(android.net.NetworkInfo);
+ method public void onNetworkInfoAvailable(@NonNull android.net.NetworkInfo);
}
public static interface WifiP2pManager.P2pStateListener {
@@ -34676,46 +34676,46 @@
public class Handler {
ctor public Handler();
- ctor public Handler(android.os.Handler.Callback);
- ctor public Handler(android.os.Looper);
- ctor public Handler(android.os.Looper, android.os.Handler.Callback);
+ ctor public Handler(@Nullable android.os.Handler.Callback);
+ ctor public Handler(@NonNull android.os.Looper);
+ ctor public Handler(@NonNull android.os.Looper, @Nullable android.os.Handler.Callback);
method @NonNull public static android.os.Handler createAsync(@NonNull android.os.Looper);
method @NonNull public static android.os.Handler createAsync(@NonNull android.os.Looper, @NonNull android.os.Handler.Callback);
- method public void dispatchMessage(android.os.Message);
- method public final void dump(android.util.Printer, String);
- method public final android.os.Looper getLooper();
- method public String getMessageName(android.os.Message);
- method public void handleMessage(android.os.Message);
- method public final boolean hasCallbacks(Runnable);
+ method public void dispatchMessage(@NonNull android.os.Message);
+ method public final void dump(@NonNull android.util.Printer, @NonNull String);
+ method @NonNull public final android.os.Looper getLooper();
+ method @NonNull public String getMessageName(@NonNull android.os.Message);
+ method public void handleMessage(@NonNull android.os.Message);
+ method public final boolean hasCallbacks(@NonNull Runnable);
method public final boolean hasMessages(int);
- method public final boolean hasMessages(int, Object);
- method public final android.os.Message obtainMessage();
- method public final android.os.Message obtainMessage(int);
- method public final android.os.Message obtainMessage(int, Object);
- method public final android.os.Message obtainMessage(int, int, int);
- method public final android.os.Message obtainMessage(int, int, int, Object);
- method public final boolean post(Runnable);
- method public final boolean postAtFrontOfQueue(Runnable);
- method public final boolean postAtTime(Runnable, long);
- method public final boolean postAtTime(Runnable, Object, long);
- method public final boolean postDelayed(Runnable, long);
- method public final boolean postDelayed(Runnable, Object, long);
- method public final void removeCallbacks(Runnable);
- method public final void removeCallbacks(Runnable, Object);
- method public final void removeCallbacksAndMessages(Object);
+ method public final boolean hasMessages(int, @Nullable Object);
+ method @NonNull public final android.os.Message obtainMessage();
+ method @NonNull public final android.os.Message obtainMessage(int);
+ method @NonNull public final android.os.Message obtainMessage(int, @Nullable Object);
+ method @NonNull public final android.os.Message obtainMessage(int, int, int);
+ method @NonNull public final android.os.Message obtainMessage(int, int, int, @Nullable Object);
+ method public final boolean post(@NonNull Runnable);
+ method public final boolean postAtFrontOfQueue(@NonNull Runnable);
+ method public final boolean postAtTime(@NonNull Runnable, long);
+ method public final boolean postAtTime(@NonNull Runnable, @Nullable Object, long);
+ method public final boolean postDelayed(@NonNull Runnable, long);
+ method public final boolean postDelayed(@NonNull Runnable, @Nullable Object, long);
+ method public final void removeCallbacks(@NonNull Runnable);
+ method public final void removeCallbacks(@NonNull Runnable, @Nullable Object);
+ method public final void removeCallbacksAndMessages(@Nullable Object);
method public final void removeMessages(int);
- method public final void removeMessages(int, Object);
+ method public final void removeMessages(int, @Nullable Object);
method public final boolean sendEmptyMessage(int);
method public final boolean sendEmptyMessageAtTime(int, long);
method public final boolean sendEmptyMessageDelayed(int, long);
- method public final boolean sendMessage(android.os.Message);
- method public final boolean sendMessageAtFrontOfQueue(android.os.Message);
- method public boolean sendMessageAtTime(android.os.Message, long);
- method public final boolean sendMessageDelayed(android.os.Message, long);
+ method public final boolean sendMessage(@NonNull android.os.Message);
+ method public final boolean sendMessageAtFrontOfQueue(@NonNull android.os.Message);
+ method public boolean sendMessageAtTime(@NonNull android.os.Message, long);
+ method public final boolean sendMessageDelayed(@NonNull android.os.Message, long);
}
public static interface Handler.Callback {
- method public boolean handleMessage(android.os.Message);
+ method public boolean handleMessage(@NonNull android.os.Message);
}
public class HandlerThread extends java.lang.Thread {
@@ -43968,7 +43968,6 @@
field public static final String EXTRA_INCOMING_CALL_EXTRAS = "android.telecom.extra.INCOMING_CALL_EXTRAS";
field public static final String EXTRA_INCOMING_VIDEO_STATE = "android.telecom.extra.INCOMING_VIDEO_STATE";
field public static final String EXTRA_IS_DEFAULT_CALL_SCREENING_APP = "android.telecom.extra.IS_DEFAULT_CALL_SCREENING_APP";
- field public static final String EXTRA_IS_ENABLED = "android.telecom.extra.IS_ENABLED";
field public static final String EXTRA_NOTIFICATION_COUNT = "android.telecom.extra.NOTIFICATION_COUNT";
field public static final String EXTRA_NOTIFICATION_PHONE_NUMBER = "android.telecom.extra.NOTIFICATION_PHONE_NUMBER";
field public static final String EXTRA_OUTGOING_CALL_EXTRAS = "android.telecom.extra.OUTGOING_CALL_EXTRAS";
@@ -44135,9 +44134,10 @@
}
public final class AvailableNetworkInfo implements android.os.Parcelable {
- ctor public AvailableNetworkInfo(int, int, java.util.List<java.lang.String>);
+ ctor public AvailableNetworkInfo(int, int, @NonNull java.util.List<java.lang.String>, @NonNull java.util.List<java.lang.Integer>);
method public int describeContents();
- method public java.util.List<java.lang.String> getMccMncs();
+ method @NonNull public java.util.List<java.lang.Integer> getBands();
+ method @NonNull public java.util.List<java.lang.String> getMccMncs();
method public int getPriority();
method public int getSubId();
method public void writeToParcel(android.os.Parcel, int);
@@ -44307,6 +44307,7 @@
field public static final String KEY_SUPPORT_PAUSE_IMS_VIDEO_CALLS_BOOL = "support_pause_ims_video_calls_bool";
field public static final String KEY_SUPPORT_SWAP_AFTER_MERGE_BOOL = "support_swap_after_merge_bool";
field public static final String KEY_TREAT_DOWNGRADED_VIDEO_CALLS_AS_VIDEO_CALLS_BOOL = "treat_downgraded_video_calls_as_video_calls_bool";
+ field public static final String KEY_TTY_SUPPORTED_BOOL = "tty_supported_bool";
field public static final String KEY_USE_HFA_FOR_PROVISIONING_BOOL = "use_hfa_for_provisioning_bool";
field public static final String KEY_USE_OTASP_FOR_PROVISIONING_BOOL = "use_otasp_for_provisioning_bool";
field public static final String KEY_USE_RCS_PRESENCE_BOOL = "use_rcs_presence_bool";
@@ -44597,7 +44598,7 @@
public class MbmsGroupCallSession implements java.lang.AutoCloseable {
method public void close();
method @Nullable public static android.telephony.MbmsGroupCallSession create(@NonNull android.content.Context, int, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.mbms.MbmsGroupCallSessionCallback);
- method public static android.telephony.MbmsGroupCallSession create(@NonNull android.content.Context, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.mbms.MbmsGroupCallSessionCallback);
+ method @Nullable public static android.telephony.MbmsGroupCallSession create(@NonNull android.content.Context, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.mbms.MbmsGroupCallSessionCallback);
method @Nullable public android.telephony.mbms.GroupCall startGroupCall(long, @NonNull java.util.List<java.lang.Integer>, @NonNull java.util.List<java.lang.Integer>, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.mbms.GroupCallCallback);
}
@@ -44965,9 +44966,9 @@
method public String getIccId();
method public int getIconTint();
method @Deprecated public int getMcc();
- method public String getMccString();
+ method @Nullable public String getMccString();
method @Deprecated public int getMnc();
- method public String getMncString();
+ method @Nullable public String getMncString();
method public String getNumber();
method public int getSimSlotIndex();
method public int getSubscriptionId();
@@ -45166,7 +45167,7 @@
method @Deprecated public void setVoicemailRingtoneUri(android.telecom.PhoneAccountHandle, android.net.Uri);
method @Deprecated public void setVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle, boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void switchMultiSimConfig(int);
- method public boolean updateAvailableNetworks(java.util.List<android.telephony.AvailableNetworkInfo>);
+ method public void updateAvailableNetworks(@NonNull java.util.List<android.telephony.AvailableNetworkInfo>, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
field public static final String ACTION_CARRIER_MESSAGING_CLIENT_SERVICE = "android.telephony.action.CARRIER_MESSAGING_CLIENT_SERVICE";
field public static final String ACTION_CONFIGURE_VOICEMAIL = "android.telephony.action.CONFIGURE_VOICEMAIL";
field public static final String ACTION_NETWORK_COUNTRY_CHANGED = "android.telephony.action.NETWORK_COUNTRY_CHANGED";
@@ -45259,6 +45260,11 @@
field public static final int UNINITIALIZED_CARD_ID = -2; // 0xfffffffe
field public static final int UNKNOWN_CARRIER_ID = -1; // 0xffffffff
field public static final int UNSUPPORTED_CARD_ID = -1; // 0xffffffff
+ field public static final int UPDATE_AVAILABLE_NETWORKS_ABORTED = 2; // 0x2
+ field public static final int UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS = 3; // 0x3
+ field public static final int UPDATE_AVAILABLE_NETWORKS_NO_CARRIER_PRIVILEGE = 4; // 0x4
+ field public static final int UPDATE_AVAILABLE_NETWORKS_SUCCESS = 0; // 0x0
+ field public static final int UPDATE_AVAILABLE_NETWORKS_UNKNOWN_FAILURE = 1; // 0x1
field public static final int USSD_ERROR_SERVICE_UNAVAIL = -2; // 0xfffffffe
field public static final int USSD_RETURN_FAILURE = -1; // 0xffffffff
field public static final String VVM_TYPE_CVVM = "vvm_type_cvvm";
@@ -53608,7 +53614,6 @@
method public int describeContents();
method @Nullable public String getCallingPackageName();
method @NonNull public java.util.List<android.view.textclassifier.ConversationActions.Message> getConversation();
- method @Nullable public String getConversationId();
method @Nullable public java.util.List<java.lang.String> getHints();
method @IntRange(from=0xffffffff) public int getMaxSuggestions();
method @NonNull public android.view.textclassifier.TextClassifier.EntityConfig getTypeConfig();
@@ -53621,7 +53626,6 @@
public static final class ConversationActions.Request.Builder {
ctor public ConversationActions.Request.Builder(@NonNull java.util.List<android.view.textclassifier.ConversationActions.Message>);
method @NonNull public android.view.textclassifier.ConversationActions.Request build();
- method @NonNull public android.view.textclassifier.ConversationActions.Request.Builder setConversationId(@Nullable String);
method @NonNull public android.view.textclassifier.ConversationActions.Request.Builder setHints(@Nullable java.util.List<java.lang.String>);
method @NonNull public android.view.textclassifier.ConversationActions.Request.Builder setMaxSuggestions(@IntRange(from=0xffffffff) int);
method @NonNull public android.view.textclassifier.ConversationActions.Request.Builder setTypeConfig(@Nullable android.view.textclassifier.TextClassifier.EntityConfig);
@@ -58057,7 +58061,7 @@
public final class DelegateLastClassLoader extends dalvik.system.PathClassLoader {
ctor public DelegateLastClassLoader(String, ClassLoader);
ctor public DelegateLastClassLoader(String, String, ClassLoader);
- ctor public DelegateLastClassLoader(String, String, ClassLoader, boolean);
+ ctor public DelegateLastClassLoader(@NonNull String, @Nullable String, @Nullable ClassLoader, boolean);
}
public class DexClassLoader extends dalvik.system.BaseDexClassLoader {
diff --git a/api/system-current.txt b/api/system-current.txt
index 0f1ab29..447f576 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -1576,6 +1576,7 @@
method public boolean getAllocateAggressive();
method @Deprecated public boolean getAllowDowngrade();
method public boolean getDontKillApp();
+ method public boolean getEnableRollback();
method @Nullable public String[] getGrantedRuntimePermissions();
method public boolean getInstallAsFullApp(boolean);
method public boolean getInstallAsInstantApp(boolean);
@@ -1587,7 +1588,7 @@
method @RequiresPermission(android.Manifest.permission.ALLOCATE_AGGRESSIVE) public void setAllocateAggressive(boolean);
method @Deprecated public void setAllowDowngrade(boolean);
method public void setDontKillApp(boolean);
- method public void setEnableRollback();
+ method public void setEnableRollback(boolean);
method @RequiresPermission(android.Manifest.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS) public void setGrantedRuntimePermissions(String[]);
method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void setInstallAsApex();
method public void setInstallAsInstantApp(boolean);
@@ -1822,18 +1823,18 @@
public final class PackageRollbackInfo implements android.os.Parcelable {
method public int describeContents();
- method public String getPackageName();
- method public android.content.pm.VersionedPackage getVersionRolledBackFrom();
- method public android.content.pm.VersionedPackage getVersionRolledBackTo();
+ method @NonNull public String getPackageName();
+ method @NonNull public android.content.pm.VersionedPackage getVersionRolledBackFrom();
+ method @NonNull public android.content.pm.VersionedPackage getVersionRolledBackTo();
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.content.rollback.PackageRollbackInfo> CREATOR;
}
public final class RollbackInfo implements android.os.Parcelable {
method public int describeContents();
- method public java.util.List<android.content.pm.VersionedPackage> getCausePackages();
+ method @NonNull public java.util.List<android.content.pm.VersionedPackage> getCausePackages();
method public int getCommittedSessionId();
- method public java.util.List<android.content.rollback.PackageRollbackInfo> getPackages();
+ method @NonNull public java.util.List<android.content.rollback.PackageRollbackInfo> getPackages();
method public int getRollbackId();
method public boolean isStaged();
method public void writeToParcel(android.os.Parcel, int);
@@ -1843,7 +1844,7 @@
public final class RollbackManager {
method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) public void commitRollback(int, @NonNull java.util.List<android.content.pm.VersionedPackage>, @NonNull android.content.IntentSender);
method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) public void expireRollbackForPackage(@NonNull String);
- method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) public java.util.List<android.content.rollback.RollbackInfo> getAvailableRollbacks();
+ method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) @NonNull public java.util.List<android.content.rollback.RollbackInfo> getAvailableRollbacks();
method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) @NonNull public java.util.List<android.content.rollback.RollbackInfo> getRecentlyCommittedRollbacks();
method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) public void reloadPersistedData();
field public static final String EXTRA_STATUS = "android.content.rollback.extra.STATUS";
@@ -5187,10 +5188,10 @@
public static interface Binder.ProxyTransactListener {
method public void onTransactEnded(@Nullable Object);
- method public Object onTransactStarted(android.os.IBinder, int);
+ method @Nullable public Object onTransactStarted(@NonNull android.os.IBinder, int);
}
- public class BugreportManager {
+ public final class BugreportManager {
method @RequiresPermission(android.Manifest.permission.DUMP) public void cancelBugreport();
method @RequiresPermission(android.Manifest.permission.DUMP) public void startBugreport(@NonNull android.os.ParcelFileDescriptor, @Nullable android.os.ParcelFileDescriptor, @NonNull android.os.BugreportParams, @NonNull java.util.concurrent.Executor, @NonNull android.os.BugreportManager.BugreportCallback);
}
@@ -5199,7 +5200,7 @@
ctor public BugreportManager.BugreportCallback();
method public void onError(int);
method public void onFinished();
- method public void onProgress(float);
+ method public void onProgress(@FloatRange(from=0.0f, to=100.0f) float);
field public static final int BUGREPORT_ERROR_ANOTHER_REPORT_IN_PROGRESS = 5; // 0x5
field public static final int BUGREPORT_ERROR_INVALID_INPUT = 1; // 0x1
field public static final int BUGREPORT_ERROR_RUNTIME = 2; // 0x2
@@ -5208,7 +5209,7 @@
}
public final class BugreportParams {
- ctor public BugreportParams(@android.os.BugreportParams.BugreportMode int);
+ ctor public BugreportParams(int);
method public int getMode();
field public static final int BUGREPORT_MODE_FULL = 0; // 0x0
field public static final int BUGREPORT_MODE_INTERACTIVE = 1; // 0x1
@@ -5218,9 +5219,6 @@
field public static final int BUGREPORT_MODE_WIFI = 5; // 0x5
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @IntDef(prefix={"BUGREPORT_MODE_"}, value={android.os.BugreportParams.BUGREPORT_MODE_FULL, android.os.BugreportParams.BUGREPORT_MODE_INTERACTIVE, android.os.BugreportParams.BUGREPORT_MODE_REMOTE, android.os.BugreportParams.BUGREPORT_MODE_WEAR, android.os.BugreportParams.BUGREPORT_MODE_TELEPHONY, android.os.BugreportParams.BUGREPORT_MODE_WIFI}) public static @interface BugreportParams.BugreportMode {
- }
-
public static class Build.VERSION {
field public static final String PREVIEW_SDK_FINGERPRINT;
}
diff --git a/api/system-removed.txt b/api/system-removed.txt
index 7e04469..18d0ec0 100644
--- a/api/system-removed.txt
+++ b/api/system-removed.txt
@@ -60,6 +60,14 @@
}
+package android.content.pm {
+
+ public static class PackageInstaller.SessionParams implements android.os.Parcelable {
+ method @Deprecated public void setEnableRollback();
+ }
+
+}
+
package android.location {
public class LocationManager {
diff --git a/api/test-current.txt b/api/test-current.txt
index 0bceddc..b0e8df8 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -1233,6 +1233,21 @@
field @NonNull public static final android.os.Parcelable.Creator<android.net.StaticIpConfiguration> CREATOR;
}
+ public final class TestNetworkInterface implements android.os.Parcelable {
+ ctor public TestNetworkInterface(android.os.ParcelFileDescriptor, String);
+ method public int describeContents();
+ method public android.os.ParcelFileDescriptor getFileDescriptor();
+ method public String getInterfaceName();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.net.TestNetworkInterface> CREATOR;
+ }
+
+ public class TestNetworkManager {
+ method public android.net.TestNetworkInterface createTunInterface(@NonNull android.net.LinkAddress[]);
+ method public void setupTestNetwork(@NonNull String, @NonNull android.os.IBinder);
+ method public void teardownTestNetwork(@NonNull android.net.Network);
+ }
+
public class TrafficStats {
method public static long getLoopbackRxBytes();
method public static long getLoopbackRxPackets();
diff --git a/cmds/idmap2/idmap2/Scan.cpp b/cmds/idmap2/idmap2/Scan.cpp
index e5f6223..e85f132 100644
--- a/cmds/idmap2/idmap2/Scan.cpp
+++ b/cmds/idmap2/idmap2/Scan.cpp
@@ -38,7 +38,10 @@
using android::idmap2::CommandLineOptions;
using android::idmap2::Idmap;
-using android::idmap2::PoliciesToBitmask;
+using android::idmap2::kPolicyProduct;
+using android::idmap2::kPolicyPublic;
+using android::idmap2::kPolicySystem;
+using android::idmap2::kPolicyVendor;
using android::idmap2::PolicyBitmask;
using android::idmap2::PolicyFlags;
using android::idmap2::Result;
@@ -87,20 +90,22 @@
return std::make_unique<std::vector<std::string>>(paths.cbegin(), paths.cend());
}
-PolicyBitmask PolicyForPath(const std::string& apk_path) {
- static const std::vector<std::pair<std::string, PolicyBitmask>> values = {
- {"/product/", PolicyFlags::POLICY_PRODUCT_PARTITION},
- {"/system/", PolicyFlags::POLICY_SYSTEM_PARTITION},
- {"/vendor/", PolicyFlags::POLICY_VENDOR_PARTITION},
+std::vector<std::string> PoliciesForPath(const std::string& apk_path) {
+ static const std::vector<std::pair<std::string, std::string>> values = {
+ {"/product/", kPolicyProduct},
+ {"/system/", kPolicySystem},
+ {"/vendor/", kPolicyVendor},
};
+ std::vector<std::string> fulfilled_policies = {kPolicyPublic};
for (auto const& pair : values) {
if (apk_path.compare(0, pair.first.size(), pair.first) == 0) {
- return pair.second | PolicyFlags::POLICY_PUBLIC;
+ fulfilled_policies.emplace_back(pair.second);
+ break;
}
}
- return PolicyFlags::POLICY_PUBLIC;
+ return fulfilled_policies;
}
} // namespace
@@ -161,21 +166,17 @@
continue;
}
- PolicyBitmask fulfilled_policies;
+ std::vector<std::string> fulfilled_policies;
if (!override_policies.empty()) {
- auto conv_result = PoliciesToBitmask(override_policies);
- if (conv_result) {
- fulfilled_policies = *conv_result;
- } else {
- out_error << "error: " << conv_result.GetErrorMessage() << std::endl;
- return false;
- }
+ fulfilled_policies = override_policies;
} else {
- fulfilled_policies = PolicyForPath(path);
+ fulfilled_policies = PoliciesForPath(path);
}
bool ignore_overlayable = false;
- if ((fulfilled_policies & PolicyFlags::POLICY_VENDOR_PARTITION) != 0 && !VendorIsQOrLater()) {
+ if (std::find(fulfilled_policies.begin(), fulfilled_policies.end(), kPolicyVendor) !=
+ fulfilled_policies.end() &&
+ !VendorIsQOrLater()) {
// If the overlay is on a pre-Q vendor partition, do not enforce overlayable
// restrictions on this overlay because the pre-Q platform has no understanding of
// overlayable.
@@ -185,7 +186,7 @@
std::string idmap_path = Idmap::CanonicalIdmapPathFor(output_directory, path);
// Sort the static overlays in ascending priority order
- InputOverlay input{path, idmap_path, overlay_info->priority, override_policies,
+ InputOverlay input{path, idmap_path, overlay_info->priority, fulfilled_policies,
ignore_overlayable};
interesting_apks.insert(
std::lower_bound(interesting_apks.begin(), interesting_apks.end(), input), input);
@@ -211,8 +212,8 @@
}
for (const std::string& policy : overlay.policies) {
- verify_args.emplace_back("--policy");
- verify_args.emplace_back(policy);
+ create_args.emplace_back("--policy");
+ create_args.emplace_back(policy);
}
if (!Create(create_args, out_error)) {
diff --git a/cmds/idmap2/include/idmap2/Policies.h b/cmds/idmap2/include/idmap2/Policies.h
index 911d3f2..cd76b84 100644
--- a/cmds/idmap2/include/idmap2/Policies.h
+++ b/cmds/idmap2/include/idmap2/Policies.h
@@ -27,13 +27,21 @@
namespace android::idmap2 {
+constexpr const char* kPolicyPublic = "public";
+constexpr const char* kPolicyProduct = "product";
+constexpr const char* kPolicySystem = "system";
+constexpr const char* kPolicyVendor = "vendor";
+constexpr const char* kPolicySignature = "signature";
+
using PolicyFlags = ResTable_overlayable_policy_header::PolicyFlags;
using PolicyBitmask = uint32_t;
-// Parses a the string representation of a set of policies into a bitmask. The format of the string
-// is the same as for the <policy> element.
+// Parses the string representations of policies into a bitmask.
Result<PolicyBitmask> PoliciesToBitmask(const std::vector<std::string>& policies);
+// Retrieves the string representations of policies in the bitmask.
+std::vector<std::string> BitmaskToPolicies(const PolicyBitmask& bitmask);
+
} // namespace android::idmap2
#endif // IDMAP2_INCLUDE_IDMAP2_POLICIES_H_
diff --git a/cmds/idmap2/libidmap2/Idmap.cpp b/cmds/idmap2/libidmap2/Idmap.cpp
index 889d731..a7d180c 100644
--- a/cmds/idmap2/libidmap2/Idmap.cpp
+++ b/cmds/idmap2/libidmap2/Idmap.cpp
@@ -285,24 +285,58 @@
return std::move(idmap);
}
-bool CheckOverlayable(const LoadedPackage& target_package,
- const utils::OverlayManifestInfo& overlay_info,
- const PolicyBitmask& fulfilled_policies, const ResourceId& resid) {
+std::string ConcatPolicies(const std::vector<std::string>& policies) {
+ std::string message;
+ for (const std::string& policy : policies) {
+ if (message.empty()) {
+ message.append(policy);
+ } else {
+ message.append(policy);
+ message.append("|");
+ }
+ }
+
+ return message;
+}
+
+Result<Unit> CheckOverlayable(const LoadedPackage& target_package,
+ const utils::OverlayManifestInfo& overlay_info,
+ const PolicyBitmask& fulfilled_policies, const ResourceId& resid) {
+ static constexpr const PolicyBitmask sDefaultPolicies =
+ PolicyFlags::POLICY_SYSTEM_PARTITION | PolicyFlags::POLICY_VENDOR_PARTITION |
+ PolicyFlags::POLICY_PRODUCT_PARTITION | PolicyFlags::POLICY_SIGNATURE;
+
+ // If the resource does not have an overlayable definition, allow the resource to be overlaid if
+ // the overlay is preinstalled or signed with the same signature as the target.
+ if (!target_package.DefinesOverlayable()) {
+ return (sDefaultPolicies & fulfilled_policies) != 0
+ ? Result<Unit>({})
+ : Error(
+ "overlay must be preinstalled or signed with the same signature as the "
+ "target");
+ }
+
const OverlayableInfo* overlayable_info = target_package.GetOverlayableInfo(resid);
if (overlayable_info == nullptr) {
- // If the resource does not have an overlayable definition, allow the resource to be overlaid.
- // Once overlayable enforcement is turned on, this check will return false.
- return !target_package.DefinesOverlayable();
+ // Do not allow non-overlayable resources to be overlaid.
+ return Error("resource has no overlayable declaration");
}
if (overlay_info.target_name != overlayable_info->name) {
// If the overlay supplies a target overlayable name, the resource must belong to the
// overlayable defined with the specified name to be overlaid.
- return false;
+ return Error("<overlay> android:targetName '%s' does not match overlayable name '%s'",
+ overlay_info.target_name.c_str(), overlayable_info->name.c_str());
}
// Enforce policy restrictions if the resource is declared as overlayable.
- return (overlayable_info->policy_flags & fulfilled_policies) != 0;
+ if ((overlayable_info->policy_flags & fulfilled_policies) == 0) {
+ return Error("overlay with policies '%s' does not fulfill any overlayable policies '%s'",
+ ConcatPolicies(BitmaskToPolicies(fulfilled_policies)).c_str(),
+ ConcatPolicies(BitmaskToPolicies(overlayable_info->policy_flags)).c_str());
+ }
+
+ return Result<Unit>({});
}
std::unique_ptr<const Idmap> Idmap::FromApkAssets(
@@ -418,16 +452,26 @@
continue;
}
- if (enforce_overlayable &&
- !CheckOverlayable(*target_pkg, *overlay_info, fulfilled_policies, target_resid)) {
- LOG(WARNING) << "overlay \"" << overlay_apk_path << "\" is not allowed to overlay resource \""
- << full_name << "\"" << std::endl;
- continue;
+ if (!enforce_overlayable) {
+ Result<Unit> success =
+ CheckOverlayable(*target_pkg, *overlay_info, fulfilled_policies, target_resid);
+ if (!success) {
+ LOG(WARNING) << "overlay \"" << overlay_apk_path
+ << "\" is not allowed to overlay resource \"" << full_name
+ << "\": " << success.GetErrorMessage();
+ continue;
+ }
}
matching_resources.Add(target_resid, overlay_resid);
}
+ if (matching_resources.Map().empty()) {
+ out_error << "overlay \"" << overlay_apk_path << "\" does not successfully overlay any resource"
+ << std::endl;
+ return nullptr;
+ }
+
// encode idmap data
std::unique_ptr<IdmapData> data(new IdmapData());
const auto types_end = matching_resources.Map().cend();
diff --git a/cmds/idmap2/libidmap2/Policies.cpp b/cmds/idmap2/libidmap2/Policies.cpp
index c6ba87d..7c45556 100644
--- a/cmds/idmap2/libidmap2/Policies.cpp
+++ b/cmds/idmap2/libidmap2/Policies.cpp
@@ -30,12 +30,13 @@
namespace {
const std::map<android::StringPiece, PolicyFlags> kStringToFlag = {
- {"public", PolicyFlags::POLICY_PUBLIC},
- {"product", PolicyFlags::POLICY_PRODUCT_PARTITION},
- {"system", PolicyFlags::POLICY_SYSTEM_PARTITION},
- {"vendor", PolicyFlags::POLICY_VENDOR_PARTITION},
- {"signature", PolicyFlags::POLICY_SIGNATURE},
+ {kPolicyPublic, PolicyFlags::POLICY_PUBLIC},
+ {kPolicyProduct, PolicyFlags::POLICY_PRODUCT_PARTITION},
+ {kPolicySystem, PolicyFlags::POLICY_SYSTEM_PARTITION},
+ {kPolicyVendor, PolicyFlags::POLICY_VENDOR_PARTITION},
+ {kPolicySignature, PolicyFlags::POLICY_SIGNATURE},
};
+
} // namespace
Result<PolicyBitmask> PoliciesToBitmask(const std::vector<std::string>& policies) {
@@ -52,4 +53,29 @@
return Result<PolicyBitmask>(bitmask);
}
+std::vector<std::string> BitmaskToPolicies(const PolicyBitmask& bitmask) {
+ std::vector<std::string> policies;
+ if ((bitmask & PolicyFlags::POLICY_PUBLIC) != 0) {
+ policies.emplace_back(kPolicyPublic);
+ }
+
+ if ((bitmask & PolicyFlags::POLICY_PRODUCT_PARTITION) != 0) {
+ policies.emplace_back(kPolicyProduct);
+ }
+
+ if ((bitmask & PolicyFlags::POLICY_SYSTEM_PARTITION) != 0) {
+ policies.emplace_back(kPolicySystem);
+ }
+
+ if ((bitmask & PolicyFlags::POLICY_VENDOR_PARTITION) != 0) {
+ policies.emplace_back(kPolicyVendor);
+ }
+
+ if ((bitmask & PolicyFlags::POLICY_SIGNATURE) != 0) {
+ policies.emplace_back(kPolicySignature);
+ }
+
+ return policies;
+}
+
} // namespace android::idmap2
diff --git a/cmds/idmap2/tests/IdmapTests.cpp b/cmds/idmap2/tests/IdmapTests.cpp
index bbfbad9..8d65428 100644
--- a/cmds/idmap2/tests/IdmapTests.cpp
+++ b/cmds/idmap2/tests/IdmapTests.cpp
@@ -173,20 +173,27 @@
ASSERT_THAT(idmap, IsNull());
}
-TEST(IdmapTests, CreateIdmapFromApkAssets) {
- const std::string target_apk_path(GetTestDataPath() + "/target/target.apk");
- std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
+void CreateIdmap(const StringPiece& target_apk_path, const StringPiece& overlay_apk_path,
+ const PolicyBitmask& fulfilled_policies, bool enforce_overlayable,
+ std::unique_ptr<const Idmap>* out_idmap) {
+ std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path.to_string());
ASSERT_THAT(target_apk, NotNull());
- const std::string overlay_apk_path(GetTestDataPath() + "/overlay/overlay.apk");
- std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
+ std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path.to_string());
ASSERT_THAT(overlay_apk, NotNull());
std::stringstream error;
- std::unique_ptr<const Idmap> idmap =
- Idmap::FromApkAssets(target_apk_path, *target_apk, overlay_apk_path, *overlay_apk,
- PolicyFlags::POLICY_PUBLIC, /* enforce_overlayable */ true, error);
- ASSERT_THAT(idmap, NotNull());
+ *out_idmap =
+ Idmap::FromApkAssets(target_apk_path.to_string(), *target_apk, overlay_apk_path.to_string(),
+ *overlay_apk, fulfilled_policies, enforce_overlayable, error);
+}
+
+TEST(IdmapTests, CreateIdmapFromApkAssets) {
+ std::unique_ptr<const Idmap> idmap;
+ std::string target_apk_path = GetTestDataPath() + "/target/target.apk";
+ std::string overlay_apk_path = GetTestDataPath() + "/overlay/overlay.apk";
+ CreateIdmap(target_apk_path, overlay_apk_path, PolicyFlags::POLICY_PUBLIC,
+ /* enforce_overlayable */ true, &idmap);
ASSERT_THAT(idmap->GetHeader(), NotNull());
ASSERT_EQ(idmap->GetHeader()->GetMagic(), 0x504d4449U);
@@ -226,19 +233,12 @@
// Overlays should abide by all overlayable restrictions if enforcement of overlayable is enabled.
TEST(IdmapOverlayableTests, CreateIdmapFromApkAssetsPolicySystemPublic) {
- const std::string target_apk_path(GetTestDataPath() + "/target/target.apk");
- std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
- ASSERT_THAT(target_apk, NotNull());
-
- const std::string overlay_apk_path(GetTestDataPath() + "/system-overlay/system-overlay.apk");
- std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
- ASSERT_THAT(overlay_apk, NotNull());
-
- std::stringstream error;
- std::unique_ptr<const Idmap> idmap =
- Idmap::FromApkAssets(target_apk_path, *target_apk, overlay_apk_path, *overlay_apk,
- PolicyFlags::POLICY_SYSTEM_PARTITION | PolicyFlags::POLICY_PUBLIC,
- /* enforce_overlayable */ true, error);
+ std::unique_ptr<const Idmap> idmap;
+ std::string target_apk_path = GetTestDataPath() + "/target/target.apk";
+ std::string overlay_apk_path = GetTestDataPath() + "/system-overlay/system-overlay.apk";
+ CreateIdmap(target_apk_path, overlay_apk_path,
+ PolicyFlags::POLICY_SYSTEM_PARTITION | PolicyFlags::POLICY_PUBLIC,
+ /* enforce_overlayable */ true, &idmap);
ASSERT_THAT(idmap, NotNull());
const std::vector<std::unique_ptr<const IdmapData>>& dataBlocks = idmap->GetData();
@@ -263,21 +263,12 @@
}
TEST(IdmapOverlayableTests, CreateIdmapFromApkAssetsPolicySignature) {
- const std::string target_apk_path(GetTestDataPath() + "/target/target.apk");
- std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
- ASSERT_THAT(target_apk, NotNull());
-
- const std::string overlay_apk_path(GetTestDataPath() +
- "/signature-overlay/signature-overlay.apk");
- std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
- ASSERT_THAT(overlay_apk, NotNull());
-
- uint32_t policy_flags = PolicyFlags::POLICY_PUBLIC | PolicyFlags::POLICY_SIGNATURE;
-
- std::stringstream error;
- std::unique_ptr<const Idmap> idmap =
- Idmap::FromApkAssets(target_apk_path, *target_apk, overlay_apk_path, *overlay_apk,
- policy_flags, /* enforce_overlayable */ true, error);
+ std::unique_ptr<const Idmap> idmap;
+ std::string target_apk_path = GetTestDataPath() + "/target/target.apk";
+ std::string overlay_apk_path = GetTestDataPath() + "/signature-overlay/signature-overlay.apk";
+ CreateIdmap(target_apk_path, overlay_apk_path,
+ PolicyFlags::POLICY_PUBLIC | PolicyFlags::POLICY_SIGNATURE,
+ /* enforce_overlayable */ true, &idmap);
ASSERT_THAT(idmap, NotNull());
const std::vector<std::unique_ptr<const IdmapData>>& dataBlocks = idmap->GetData();
@@ -298,52 +289,15 @@
ASSERT_EQ(types[0]->GetEntry(0), 0x0000U); // string/policy_signature
}
-TEST(IdmapOverlayableTests, CreateIdmapFromApkAssetsPolicySignatureNotFulfilled) {
- const std::string target_apk_path(GetTestDataPath() + "/target/target.apk");
- std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
- ASSERT_THAT(target_apk, NotNull());
-
- const std::string overlay_apk_path(GetTestDataPath() +
- "/signature-overlay/signature-overlay.apk");
- std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
- ASSERT_THAT(overlay_apk, NotNull());
-
- uint32_t policy_flags = PolicyFlags::POLICY_PUBLIC;
-
- std::stringstream error;
- std::unique_ptr<const Idmap> idmap =
- Idmap::FromApkAssets(target_apk_path, *target_apk, overlay_apk_path, *overlay_apk,
- policy_flags, /* enforce_overlayable */ true, error);
- ASSERT_THAT(idmap, NotNull());
-
- const std::vector<std::unique_ptr<const IdmapData>>& dataBlocks = idmap->GetData();
- ASSERT_EQ(dataBlocks.size(), 1U);
-
- const std::unique_ptr<const IdmapData>& data = dataBlocks[0];
-
- ASSERT_EQ(data->GetHeader()->GetTargetPackageId(), 0x7fU);
- ASSERT_EQ(data->GetHeader()->GetTypeCount(), 0U);
-
- const std::vector<std::unique_ptr<const IdmapData::TypeEntry>>& types = data->GetTypeEntries();
- ASSERT_EQ(types.size(), 0U); // can't overlay, so contains nothing
-}
-
// Overlays should abide by all overlayable restrictions if enforcement of overlayable is enabled.
TEST(IdmapOverlayableTests, CreateIdmapFromApkAssetsPolicySystemPublicInvalid) {
- const std::string target_apk_path(GetTestDataPath() + "/target/target.apk");
- std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
- ASSERT_THAT(target_apk, NotNull());
-
- const std::string overlay_apk_path(GetTestDataPath() +
- "/system-overlay-invalid/system-overlay-invalid.apk");
- std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
- ASSERT_THAT(overlay_apk, NotNull());
-
- std::stringstream error;
- std::unique_ptr<const Idmap> idmap =
- Idmap::FromApkAssets(target_apk_path, *target_apk, overlay_apk_path, *overlay_apk,
- PolicyFlags::POLICY_SYSTEM_PARTITION | PolicyFlags::POLICY_PUBLIC,
- /* enforce_overlayable */ true, error);
+ std::unique_ptr<const Idmap> idmap;
+ std::string target_apk_path = GetTestDataPath() + "/target/target.apk";
+ std::string overlay_apk_path =
+ GetTestDataPath() + "/system-overlay-invalid/system-overlay-invalid.apk";
+ CreateIdmap(target_apk_path, overlay_apk_path,
+ PolicyFlags::POLICY_SYSTEM_PARTITION | PolicyFlags::POLICY_PUBLIC,
+ /* enforce_overlayable */ true, &idmap);
ASSERT_THAT(idmap, NotNull());
const std::vector<std::unique_ptr<const IdmapData>>& dataBlocks = idmap->GetData();
@@ -369,20 +323,13 @@
// Overlays should ignore all overlayable restrictions if enforcement of overlayable is disabled.
TEST(IdmapOverlayableTests, CreateIdmapFromApkAssetsPolicySystemPublicInvalidIgnoreOverlayable) {
- const std::string target_apk_path(GetTestDataPath() + "/target/target.apk");
- std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
- ASSERT_THAT(target_apk, NotNull());
-
- const std::string overlay_apk_path(GetTestDataPath() +
- "/system-overlay-invalid/system-overlay-invalid.apk");
- std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
- ASSERT_THAT(overlay_apk, NotNull());
-
- std::stringstream error;
- std::unique_ptr<const Idmap> idmap =
- Idmap::FromApkAssets(target_apk_path, *target_apk, overlay_apk_path, *overlay_apk,
- PolicyFlags::POLICY_SYSTEM_PARTITION | PolicyFlags::POLICY_PUBLIC,
- /* enforce_overlayable */ false, error);
+ std::unique_ptr<const Idmap> idmap;
+ std::string target_apk_path = GetTestDataPath() + "/target/target.apk";
+ std::string overlay_apk_path =
+ GetTestDataPath() + "/system-overlay-invalid/system-overlay-invalid.apk";
+ CreateIdmap(target_apk_path, overlay_apk_path,
+ PolicyFlags::POLICY_SYSTEM_PARTITION | PolicyFlags::POLICY_PUBLIC,
+ /* enforce_overlayable */ false, &idmap);
ASSERT_THAT(idmap, NotNull());
const std::vector<std::unique_ptr<const IdmapData>>& dataBlocks = idmap->GetData();
@@ -409,63 +356,13 @@
ASSERT_EQ(types[0]->GetEntry(6), 0x0006U); // string/policy_system_vendor
}
-// The resources of APKs that do not include an overlayable declaration should not restrict what
-// resources can be overlaid.
-TEST(IdmapOverlayableTests, CreateIdmapFromApkAssetsNoDefinedOverlayable) {
- const std::string target_apk_path(GetTestDataPath() + "/target/target-no-overlayable.apk");
- std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
- ASSERT_THAT(target_apk, NotNull());
-
- const std::string overlay_apk_path(GetTestDataPath() +
- "/system-overlay-invalid/system-overlay-invalid.apk");
- std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
- ASSERT_THAT(overlay_apk, NotNull());
-
- std::stringstream error;
- std::unique_ptr<const Idmap> idmap =
- Idmap::FromApkAssets(target_apk_path, *target_apk, overlay_apk_path, *overlay_apk,
- PolicyFlags::POLICY_PUBLIC, /* enforce_overlayable */ true, error);
- ASSERT_THAT(idmap, NotNull());
-
- const std::vector<std::unique_ptr<const IdmapData>>& dataBlocks = idmap->GetData();
- ASSERT_EQ(dataBlocks.size(), 1U);
-
- const std::unique_ptr<const IdmapData>& data = dataBlocks[0];
-
- ASSERT_EQ(data->GetHeader()->GetTargetPackageId(), 0x7fU);
- ASSERT_EQ(data->GetHeader()->GetTypeCount(), 1U);
-
- const std::vector<std::unique_ptr<const IdmapData::TypeEntry>>& types = data->GetTypeEntries();
- ASSERT_EQ(types.size(), 1U);
-
- ASSERT_EQ(types[0]->GetTargetTypeId(), 0x02U);
- ASSERT_EQ(types[0]->GetOverlayTypeId(), 0x01U);
- ASSERT_EQ(types[0]->GetEntryCount(), 7U);
- ASSERT_EQ(types[0]->GetEntryOffset(), 3U);
- ASSERT_EQ(types[0]->GetEntry(0), 0x0000U); // string/not_overlayable
- ASSERT_EQ(types[0]->GetEntry(1), 0x0001U); // string/other
- ASSERT_EQ(types[0]->GetEntry(2), 0x0002U); // string/policy_product
- ASSERT_EQ(types[0]->GetEntry(3), 0x0003U); // string/policy_public
- ASSERT_EQ(types[0]->GetEntry(4), 0x0004U); // string/string/policy_signature
- ASSERT_EQ(types[0]->GetEntry(5), 0x0005U); // string/policy_system
- ASSERT_EQ(types[0]->GetEntry(6), 0x0006U); // string/policy_system_vendor
-}
-
-// The resources of APKs that do not include an overlayable declaration should not restrict what
-// resources can be overlaid.
+// Overlays that do not specify a target <overlayable> can overlay resources defined as overlayable.
TEST(IdmapOverlayableTests, CreateIdmapFromApkAssetsNoDefinedOverlayableAndNoTargetName) {
- const std::string target_apk_path(GetTestDataPath() + "/target/target-no-overlayable.apk");
- std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
- ASSERT_THAT(target_apk, NotNull());
-
- const std::string overlay_apk_path(GetTestDataPath() + "/overlay/overlay-no-name.apk");
- std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
- ASSERT_THAT(overlay_apk, NotNull());
-
- std::stringstream error;
- std::unique_ptr<const Idmap> idmap =
- Idmap::FromApkAssets(target_apk_path, *target_apk, overlay_apk_path, *overlay_apk,
- PolicyFlags::POLICY_PUBLIC, /* enforce_overlayable */ true, error);
+ std::unique_ptr<const Idmap> idmap;
+ std::string target_apk_path = GetTestDataPath() + "/target/target-no-overlayable.apk";
+ std::string overlay_apk_path = GetTestDataPath() + "/overlay/overlay-no-name.apk";
+ CreateIdmap(target_apk_path, overlay_apk_path, PolicyFlags::POLICY_PUBLIC,
+ /* enforce_overlayable */ false, &idmap);
ASSERT_THAT(idmap, NotNull());
const std::vector<std::unique_ptr<const IdmapData>>& dataBlocks = idmap->GetData();
@@ -483,16 +380,81 @@
ASSERT_EQ(types[0]->GetOverlayTypeId(), 0x01U);
ASSERT_EQ(types[0]->GetEntryCount(), 1U);
ASSERT_EQ(types[0]->GetEntryOffset(), 0U);
- ASSERT_EQ(types[0]->GetEntry(0), 0x0000U);
+ ASSERT_EQ(types[0]->GetEntry(0), 0x0000U); // string/int1
ASSERT_EQ(types[1]->GetTargetTypeId(), 0x02U);
ASSERT_EQ(types[1]->GetOverlayTypeId(), 0x02U);
ASSERT_EQ(types[1]->GetEntryCount(), 4U);
ASSERT_EQ(types[1]->GetEntryOffset(), 10U);
- ASSERT_EQ(types[1]->GetEntry(0), 0x0000U);
- ASSERT_EQ(types[1]->GetEntry(1), kNoEntry);
- ASSERT_EQ(types[1]->GetEntry(2), 0x0001U);
- ASSERT_EQ(types[1]->GetEntry(3), 0x0002U);
+ ASSERT_EQ(types[1]->GetEntry(0), 0x0000U); // string/str1
+ ASSERT_EQ(types[1]->GetEntry(1), kNoEntry); // string/str2
+ ASSERT_EQ(types[1]->GetEntry(2), 0x0001U); // string/str3
+ ASSERT_EQ(types[1]->GetEntry(3), 0x0002U); // string/str4
+}
+
+// Overlays that are not pre-installed and are not signed with the same signature as the target
+// cannot overlay packages that have not defined overlayable resources.
+TEST(IdmapOverlayableTests, CreateIdmapFromApkAssetsDefaultPoliciesPublicFail) {
+ std::unique_ptr<const Idmap> idmap;
+ std::string target_apk_path = GetTestDataPath() + "/target/target-no-overlayable.apk";
+ std::string overlay_apk_path = GetTestDataPath() + "/overlay/overlay-no-name.apk";
+ CreateIdmap(target_apk_path, overlay_apk_path, PolicyFlags::POLICY_PUBLIC,
+ /* enforce_overlayable */ true, &idmap);
+ ASSERT_THAT(idmap, IsNull());
+}
+
+// Overlays that are pre-installed or are signed with the same signature as the target can overlay
+// packages that have not defined overlayable resources.
+TEST(IdmapOverlayableTests, CreateIdmapFromApkAssetsDefaultPolicies) {
+ std::unique_ptr<const Idmap> idmap;
+ std::string target_apk_path = GetTestDataPath() + "/target/target-no-overlayable.apk";
+ std::string overlay_apk_path =
+ GetTestDataPath() + "/system-overlay-invalid/system-overlay-invalid.apk";
+
+ auto CheckEntries = [&]() -> void {
+ const std::vector<std::unique_ptr<const IdmapData>>& dataBlocks = idmap->GetData();
+ ASSERT_EQ(dataBlocks.size(), 1U);
+
+ const std::unique_ptr<const IdmapData>& data = dataBlocks[0];
+
+ ASSERT_EQ(data->GetHeader()->GetTargetPackageId(), 0x7fU);
+ ASSERT_EQ(data->GetHeader()->GetTypeCount(), 1U);
+
+ const std::vector<std::unique_ptr<const IdmapData::TypeEntry>>& types = data->GetTypeEntries();
+ ASSERT_EQ(types.size(), 1U);
+
+ ASSERT_EQ(types[0]->GetTargetTypeId(), 0x02U);
+ ASSERT_EQ(types[0]->GetOverlayTypeId(), 0x01U);
+ ASSERT_EQ(types[0]->GetEntryCount(), 7U);
+ ASSERT_EQ(types[0]->GetEntryOffset(), 3U);
+ ASSERT_EQ(types[0]->GetEntry(0), 0x0000U); // string/not_overlayable
+ ASSERT_EQ(types[0]->GetEntry(1), 0x0001U); // string/other
+ ASSERT_EQ(types[0]->GetEntry(2), 0x0002U); // string/policy_product
+ ASSERT_EQ(types[0]->GetEntry(3), 0x0003U); // string/policy_public
+ ASSERT_EQ(types[0]->GetEntry(4), 0x0004U); // string/string/policy_signature
+ ASSERT_EQ(types[0]->GetEntry(5), 0x0005U); // string/policy_system
+ ASSERT_EQ(types[0]->GetEntry(6), 0x0006U); // string/policy_system_vendor
+ };
+
+ CreateIdmap(target_apk_path, overlay_apk_path, PolicyFlags::POLICY_SIGNATURE,
+ /* enforce_overlayable */ true, &idmap);
+ ASSERT_THAT(idmap, NotNull());
+ CheckEntries();
+
+ CreateIdmap(target_apk_path, overlay_apk_path, PolicyFlags::POLICY_PRODUCT_PARTITION,
+ /* enforce_overlayable */ true, &idmap);
+ ASSERT_THAT(idmap, NotNull());
+ CheckEntries();
+
+ CreateIdmap(target_apk_path, overlay_apk_path, PolicyFlags::POLICY_SYSTEM_PARTITION,
+ /* enforce_overlayable */ true, &idmap);
+ ASSERT_THAT(idmap, NotNull());
+ CheckEntries();
+
+ CreateIdmap(target_apk_path, overlay_apk_path, PolicyFlags::POLICY_VENDOR_PARTITION,
+ /* enforce_overlayable */ true, &idmap);
+ ASSERT_THAT(idmap, NotNull());
+ CheckEntries();
}
TEST(IdmapTests, FailToCreateIdmapFromApkAssetsIfPathTooLong) {
diff --git a/cmds/idmap2/tests/data/overlay/build b/cmds/idmap2/tests/data/overlay/build
index e879f44..68b9f50 100755
--- a/cmds/idmap2/tests/data/overlay/build
+++ b/cmds/idmap2/tests/data/overlay/build
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-FRAMEWORK_RES_APK="${ANDROID_BUILD_TOP}/out/target/common/obj/APPS/framework-res_intermediates/package-export.apk"
+FRAMEWORK_RES_APK=${ANDROID_BUILD_TOP}/prebuilts/sdk/current/public/android.jar
aapt2 compile --dir res -o compiled.flata
diff --git a/cmds/idmap2/tests/data/overlay/overlay-no-name.apk b/cmds/idmap2/tests/data/overlay/overlay-no-name.apk
index 7d23c09..6425190 100644
--- a/cmds/idmap2/tests/data/overlay/overlay-no-name.apk
+++ b/cmds/idmap2/tests/data/overlay/overlay-no-name.apk
Binary files differ
diff --git a/core/java/android/bluetooth/BluetoothCodecStatus.java b/core/java/android/bluetooth/BluetoothCodecStatus.java
index 8eae2b4..58b6aea 100644
--- a/core/java/android/bluetooth/BluetoothCodecStatus.java
+++ b/core/java/android/bluetooth/BluetoothCodecStatus.java
@@ -75,8 +75,8 @@
* @param c2 the second array of capabilities to compare
* @return true if both arrays contain same capabilities
*/
- private static boolean sameCapabilities(BluetoothCodecConfig[] c1,
- BluetoothCodecConfig[] c2) {
+ public static boolean sameCapabilities(BluetoothCodecConfig[] c1,
+ BluetoothCodecConfig[] c2) {
if (c1 == null) {
return (c2 == null);
}
diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java
index d758c4d..7b4dd19 100644
--- a/core/java/android/content/pm/PackageInstaller.java
+++ b/core/java/android/content/pm/PackageInstaller.java
@@ -1448,14 +1448,33 @@
/**
* Request that rollbacks be enabled for the given upgrade.
+ *
+ * @removed
+ * @deprecated use {@link #setEnableRollback(boolean)} instead.
* @hide
*/
+ @Deprecated
@SystemApi
public void setEnableRollback() {
installFlags |= PackageManager.INSTALL_ENABLE_ROLLBACK;
}
/**
+ * Request that rollbacks be enabled or disabled for the given upgrade.
+ *
+ * @param enable set to {@code true} to enable, {@code false} to disable
+ * @hide
+ */
+ @SystemApi
+ public void setEnableRollback(boolean enable) {
+ if (enable) {
+ installFlags |= PackageManager.INSTALL_ENABLE_ROLLBACK;
+ } else {
+ installFlags &= ~PackageManager.INSTALL_ENABLE_ROLLBACK;
+ }
+ }
+
+ /**
* @deprecated use {@link #setRequestDowngrade(boolean)}.
* {@hide}
*/
@@ -2058,6 +2077,16 @@
}
/**
+ * Return whether rollback is enabled or disabled for the given upgrade.
+ *
+ * @hide
+ */
+ @SystemApi
+ public boolean getEnableRollback() {
+ return (installFlags & PackageManager.INSTALL_ENABLE_ROLLBACK) != 0;
+ }
+
+ /**
* Get the value set in {@link SessionParams#setAllocateAggressive(boolean)}.
*
* @hide
diff --git a/core/java/android/content/res/ResourcesImpl.java b/core/java/android/content/res/ResourcesImpl.java
index 565cd33..633966c 100644
--- a/core/java/android/content/res/ResourcesImpl.java
+++ b/core/java/android/content/res/ResourcesImpl.java
@@ -1303,7 +1303,7 @@
@AnyRes
static int getAttributeSetSourceResId(@Nullable AttributeSet set) {
- if (set == null) {
+ if (set == null || !(set instanceof XmlBlock.Parser)) {
return ID_NULL;
}
return ((XmlBlock.Parser) set).getSourceResId();
diff --git a/core/java/android/content/rollback/PackageRollbackInfo.java b/core/java/android/content/rollback/PackageRollbackInfo.java
index 03810f5..c0414fc 100644
--- a/core/java/android/content/rollback/PackageRollbackInfo.java
+++ b/core/java/android/content/rollback/PackageRollbackInfo.java
@@ -89,6 +89,7 @@
/**
* Returns the name of the package to roll back from.
*/
+ @NonNull
public String getPackageName() {
return mVersionRolledBackFrom.getPackageName();
}
@@ -96,6 +97,7 @@
/**
* Returns the version of the package rolled back from.
*/
+ @NonNull
public VersionedPackage getVersionRolledBackFrom() {
return mVersionRolledBackFrom;
}
@@ -103,6 +105,7 @@
/**
* Returns the version of the package rolled back to.
*/
+ @NonNull
public VersionedPackage getVersionRolledBackTo() {
return mVersionRolledBackTo;
}
diff --git a/core/java/android/content/rollback/RollbackInfo.java b/core/java/android/content/rollback/RollbackInfo.java
index 29b99e0..a363718 100644
--- a/core/java/android/content/rollback/RollbackInfo.java
+++ b/core/java/android/content/rollback/RollbackInfo.java
@@ -16,6 +16,7 @@
package android.content.rollback;
+import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.content.pm.VersionedPackage;
import android.os.Parcel;
@@ -72,6 +73,7 @@
/**
* Returns the list of package that are rolled back.
*/
+ @NonNull
public List<PackageRollbackInfo> getPackages() {
return mPackages;
}
@@ -105,6 +107,7 @@
* As provided to {@link #commitRollback} when the rollback was committed.
* This is only applicable for rollbacks that have been committed.
*/
+ @NonNull
public List<VersionedPackage> getCausePackages() {
return mCausePackages;
}
diff --git a/core/java/android/content/rollback/RollbackManager.java b/core/java/android/content/rollback/RollbackManager.java
index c043491..4e8c254 100644
--- a/core/java/android/content/rollback/RollbackManager.java
+++ b/core/java/android/content/rollback/RollbackManager.java
@@ -57,6 +57,7 @@
* MANAGE_ROLLBACKS permission.
*/
@RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS)
+ @NonNull
public List<RollbackInfo> getAvailableRollbacks() {
try {
return mBinder.getAvailableRollbacks().getList();
diff --git a/core/java/android/net/DnsPacket.java b/core/java/android/net/DnsPacket.java
index 458fb34..0ac02b1 100644
--- a/core/java/android/net/DnsPacket.java
+++ b/core/java/android/net/DnsPacket.java
@@ -28,7 +28,6 @@
import java.text.FieldPosition;
import java.util.ArrayList;
import java.util.List;
-import java.util.StringJoiner;
/**
* Defines basic data for DNS protocol based on RFC 1035.
@@ -42,7 +41,7 @@
public final int id;
public final int flags;
public final int rcode;
- private final int[] mSectionCount;
+ private final int[] mRecordCount;
/**
* Create a new DnsHeader from a positioned ByteBuffer.
@@ -52,27 +51,32 @@
* When this constructor returns, the reading position of the ByteBuffer has been
* advanced to the end of the DNS header record.
* This is meant to chain with other methods reading a DNS response in sequence.
- *
*/
DnsHeader(@NonNull ByteBuffer buf) throws BufferUnderflowException {
id = BitUtils.uint16(buf.getShort());
flags = BitUtils.uint16(buf.getShort());
rcode = flags & 0xF;
- mSectionCount = new int[NUM_SECTIONS];
+ mRecordCount = new int[NUM_SECTIONS];
for (int i = 0; i < NUM_SECTIONS; ++i) {
- mSectionCount[i] = BitUtils.uint16(buf.getShort());
+ mRecordCount[i] = BitUtils.uint16(buf.getShort());
}
}
/**
- * Get section count by section type.
+ * Get record count by type.
*/
- public int getSectionCount(int sectionType) {
- return mSectionCount[sectionType];
+ public int getRecordCount(int type) {
+ return mRecordCount[type];
}
}
- public class DnsSection {
+ /**
+ * It's used both for DNS questions and DNS resource records.
+ *
+ * DNS questions (No TTL/RDATA)
+ * DNS resource records (With TTL/RDATA)
+ */
+ public class DnsRecord {
private static final int MAXNAMESIZE = 255;
private static final int MAXLABELSIZE = 63;
private static final int MAXLABELCOUNT = 128;
@@ -81,57 +85,57 @@
private final DecimalFormat byteFormat = new DecimalFormat();
private final FieldPosition pos = new FieldPosition(0);
- private static final String TAG = "DnsSection";
+ private static final String TAG = "DnsRecord";
public final String dName;
public final int nsType;
public final int nsClass;
public final long ttl;
- private final byte[] mRR;
+ private final byte[] mRdata;
/**
- * Create a new DnsSection from a positioned ByteBuffer.
+ * Create a new DnsRecord from a positioned ByteBuffer.
*
- * The ByteBuffer must be in network byte order (which is the default).
- * Reads the passed ByteBuffer from its current position and decodes a DNS section.
+ * @param ByteBuffer input of record, must be in network byte order
+ * (which is the default).
+ * Reads the passed ByteBuffer from its current position and decodes a DNS record.
* When this constructor returns, the reading position of the ByteBuffer has been
* advanced to the end of the DNS header record.
* This is meant to chain with other methods reading a DNS response in sequence.
- *
*/
- DnsSection(int sectionType, @NonNull ByteBuffer buf)
+ DnsRecord(int recordType, @NonNull ByteBuffer buf)
throws BufferUnderflowException, ParseException {
dName = parseName(buf, 0 /* Parse depth */);
if (dName.length() > MAXNAMESIZE) {
- throw new ParseException("Parse name fail, name size is too long");
+ throw new ParseException(
+ "Parse name fail, name size is too long: " + dName.length());
}
nsType = BitUtils.uint16(buf.getShort());
nsClass = BitUtils.uint16(buf.getShort());
- if (sectionType != QDSECTION) {
+ if (recordType != QDSECTION) {
ttl = BitUtils.uint32(buf.getInt());
final int length = BitUtils.uint16(buf.getShort());
- mRR = new byte[length];
- buf.get(mRR);
+ mRdata = new byte[length];
+ buf.get(mRdata);
} else {
ttl = 0;
- mRR = null;
+ mRdata = null;
}
}
/**
- * Get a copy of rr.
+ * Get a copy of rdata.
*/
- @Nullable public byte[] getRR() {
- return (mRR == null) ? null : mRR.clone();
+ @Nullable
+ public byte[] getRR() {
+ return (mRdata == null) ? null : mRdata.clone();
}
/**
* Convert label from {@code byte[]} to {@code String}
*
- * It follows the same converting rule as native layer.
- * (See ns_name.c in libc)
- *
+ * Follows the same conversion rules of the native code (ns_name.c in libc)
*/
private String labelToString(@NonNull byte[] label) {
final StringBuffer sb = new StringBuffer();
@@ -139,13 +143,16 @@
int b = BitUtils.uint8(label[i]);
// Control characters and non-ASCII characters.
if (b <= 0x20 || b >= 0x7f) {
+ // Append the byte as an escaped decimal number, e.g., "\19" for 0x13.
sb.append('\\');
byteFormat.format(b, sb, pos);
} else if (b == '"' || b == '.' || b == ';' || b == '\\'
|| b == '(' || b == ')' || b == '@' || b == '$') {
+ // Append the byte as an escaped character, e.g., "\:" for 0x3a.
sb.append('\\');
sb.append((char) b);
} else {
+ // Append the byte as a character, e.g., "a" for 0x61.
sb.append((char) b);
}
}
@@ -154,7 +161,9 @@
private String parseName(@NonNull ByteBuffer buf, int depth) throws
BufferUnderflowException, ParseException {
- if (depth > MAXLABELCOUNT) throw new ParseException("Parse name fails, too many labels");
+ if (depth > MAXLABELCOUNT) {
+ throw new ParseException("Failed to parse name, too many labels");
+ }
final int len = BitUtils.uint8(buf.get());
final int mask = len & NAME_COMPRESSION;
if (0 == len) {
@@ -194,7 +203,7 @@
private static final String TAG = DnsPacket.class.getSimpleName();
protected final DnsHeader mHeader;
- protected final List<DnsSection>[] mSections;
+ protected final List<DnsRecord>[] mRecords;
public static class ParseException extends Exception {
public ParseException(String msg) {
@@ -216,18 +225,18 @@
throw new ParseException("Parse Header fail, bad input data", e);
}
- mSections = new ArrayList[NUM_SECTIONS];
+ mRecords = new ArrayList[NUM_SECTIONS];
for (int i = 0; i < NUM_SECTIONS; ++i) {
- final int count = mHeader.getSectionCount(i);
+ final int count = mHeader.getRecordCount(i);
if (count > 0) {
- mSections[i] = new ArrayList(count);
+ mRecords[i] = new ArrayList(count);
}
for (int j = 0; j < count; ++j) {
try {
- mSections[i].add(new DnsSection(i, buffer));
+ mRecords[i].add(new DnsRecord(i, buffer));
} catch (BufferUnderflowException e) {
- throw new ParseException("Parse section fail", e);
+ throw new ParseException("Parse record fail", e);
}
}
}
diff --git a/core/java/android/net/DnsResolver.java b/core/java/android/net/DnsResolver.java
index 6d54264..d3bc3e6 100644
--- a/core/java/android/net/DnsResolver.java
+++ b/core/java/android/net/DnsResolver.java
@@ -43,6 +43,9 @@
/**
* Dns resolver class for asynchronous dns querying
*
+ * Note that if a client sends a query with more than 1 record in the question section but
+ * the remote dns server does not support this, it may not respond at all, leading to a timeout.
+ *
*/
public final class DnsResolver {
private static final String TAG = "DnsResolver";
@@ -226,19 +229,19 @@
if (mHeader.rcode != 0) {
throw new ParseException("Response error, rcode:" + mHeader.rcode);
}
- if (mHeader.getSectionCount(ANSECTION) == 0) {
+ if (mHeader.getRecordCount(ANSECTION) == 0) {
throw new ParseException("No available answer");
}
- if (mHeader.getSectionCount(QDSECTION) == 0) {
+ if (mHeader.getRecordCount(QDSECTION) == 0) {
throw new ParseException("No question found");
}
- // Assume only one question per answer packet. (RFC1035)
- mQueryType = mSections[QDSECTION].get(0).nsType;
+ // Expect only one question in question section.
+ mQueryType = mRecords[QDSECTION].get(0).nsType;
}
public @NonNull List<InetAddress> getAddresses() {
final List<InetAddress> results = new ArrayList<InetAddress>();
- for (final DnsSection ansSec : mSections[ANSECTION]) {
+ for (final DnsRecord ansSec : mRecords[ANSECTION]) {
// Only support A and AAAA, also ignore answers if query type != answer type.
int nsType = ansSec.nsType;
if (nsType != mQueryType || (nsType != TYPE_A && nsType != TYPE_AAAA)) {
diff --git a/core/java/android/net/ITestNetworkManager.aidl b/core/java/android/net/ITestNetworkManager.aidl
new file mode 100644
index 0000000..119a30c
--- /dev/null
+++ b/core/java/android/net/ITestNetworkManager.aidl
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2018, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net;
+
+import android.net.LinkAddress;
+import android.net.TestNetworkInterface;
+import android.os.IBinder;
+import android.os.ParcelFileDescriptor;
+
+/**
+ * Interface that allows for creation and management of test-only networks.
+ *
+ * @hide
+ */
+interface ITestNetworkManager
+{
+ TestNetworkInterface createTunInterface(in LinkAddress[] linkAddrs);
+
+ void setupTestNetwork(in String iface, in IBinder binder);
+
+ void teardownTestNetwork(int netId);
+}
diff --git a/core/java/android/net/IpMemoryStore.java b/core/java/android/net/IpMemoryStore.java
index b35f097..2f4d9bc 100644
--- a/core/java/android/net/IpMemoryStore.java
+++ b/core/java/android/net/IpMemoryStore.java
@@ -171,4 +171,9 @@
throw e.rethrowFromSystemServer();
}
}
+
+ /** Gets an instance of the memory store */
+ public static IpMemoryStore getMemoryStore(final Context context) {
+ return (IpMemoryStore) context.getSystemService(Context.IP_MEMORY_STORE_SERVICE);
+ }
}
diff --git a/core/java/android/net/OWNERS b/core/java/android/net/OWNERS
index 15f4913..a1c7fce 100644
--- a/core/java/android/net/OWNERS
+++ b/core/java/android/net/OWNERS
@@ -1,12 +1,11 @@
set noparent
codewiz@google.com
-ek@google.com
-jsharkey@android.com
jchalard@google.com
+jsharkey@android.com
+junyulai@google.com
lorenzo@google.com
reminv@google.com
satk@google.com
-silberst@google.com
per-file SSL*, Uri*, Url* = flooey@google.com, narayan@google.com, tobiast@google.com
diff --git a/core/java/android/net/ParseException.java b/core/java/android/net/ParseException.java
index 68b209b..2380e86 100644
--- a/core/java/android/net/ParseException.java
+++ b/core/java/android/net/ParseException.java
@@ -24,6 +24,7 @@
public String response;
ParseException(String response) {
+ super(response);
this.response = response;
}
}
diff --git a/core/java/android/net/TestNetworkInterface.aidl b/core/java/android/net/TestNetworkInterface.aidl
new file mode 100644
index 0000000..e1f4f9f
--- /dev/null
+++ b/core/java/android/net/TestNetworkInterface.aidl
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+package android.net;
+
+/** @hide */
+parcelable TestNetworkInterface;
diff --git a/core/java/android/net/TestNetworkInterface.java b/core/java/android/net/TestNetworkInterface.java
new file mode 100644
index 0000000..30e68f5
--- /dev/null
+++ b/core/java/android/net/TestNetworkInterface.java
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+package android.net;
+
+import android.annotation.TestApi;
+import android.os.Parcel;
+import android.os.ParcelFileDescriptor;
+import android.os.Parcelable;
+
+/**
+ * This class is used to return the interface name and fd of the test interface
+ *
+ * @hide
+ */
+@TestApi
+public final class TestNetworkInterface implements Parcelable {
+ private static final String TAG = "TestNetworkInterface";
+
+ private final ParcelFileDescriptor mFileDescriptor;
+ private final String mInterfaceName;
+
+ @Override
+ public int describeContents() {
+ return (mFileDescriptor != null) ? Parcelable.CONTENTS_FILE_DESCRIPTOR : 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeParcelable(mFileDescriptor, PARCELABLE_WRITE_RETURN_VALUE);
+ out.writeString(mInterfaceName);
+ }
+
+ public TestNetworkInterface(ParcelFileDescriptor pfd, String intf) {
+ mFileDescriptor = pfd;
+ mInterfaceName = intf;
+ }
+
+ private TestNetworkInterface(Parcel in) {
+ mFileDescriptor = in.readParcelable(ParcelFileDescriptor.class.getClassLoader());
+ mInterfaceName = in.readString();
+ }
+
+ public ParcelFileDescriptor getFileDescriptor() {
+ return mFileDescriptor;
+ }
+
+ public String getInterfaceName() {
+ return mInterfaceName;
+ }
+
+ public static final Parcelable.Creator<TestNetworkInterface> CREATOR =
+ new Parcelable.Creator<TestNetworkInterface>() {
+ public TestNetworkInterface createFromParcel(Parcel in) {
+ return new TestNetworkInterface(in);
+ }
+
+ public TestNetworkInterface[] newArray(int size) {
+ return new TestNetworkInterface[size];
+ }
+ };
+}
diff --git a/core/java/android/net/TestNetworkManager.java b/core/java/android/net/TestNetworkManager.java
new file mode 100644
index 0000000..cd58e66
--- /dev/null
+++ b/core/java/android/net/TestNetworkManager.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.net;
+
+import android.annotation.NonNull;
+import android.annotation.TestApi;
+import android.content.Context;
+import android.os.IBinder;
+import android.os.RemoteException;
+
+import com.android.internal.util.Preconditions;
+
+/**
+ * Class that allows creation and management of per-app, test-only networks
+ *
+ * @hide
+ */
+@TestApi
+public class TestNetworkManager {
+ @NonNull private static final String TAG = TestNetworkManager.class.getSimpleName();
+
+ @NonNull private final ITestNetworkManager mService;
+ @NonNull private final Context mContext;
+
+ /** @hide */
+ public TestNetworkManager(@NonNull Context context, @NonNull ITestNetworkManager service) {
+ mContext = Preconditions.checkNotNull(context, "missing Context");
+ mService = Preconditions.checkNotNull(service, "missing ITestNetworkManager");
+ }
+
+ /**
+ * Teardown the capability-limited, testing-only network for a given interface
+ *
+ * @param network The test network that should be torn down
+ * @hide
+ */
+ @TestApi
+ public void teardownTestNetwork(@NonNull Network network) {
+ try {
+ mService.teardownTestNetwork(network.netId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Sets up a capability-limited, testing-only network for a given interface
+ *
+ * @param iface the name of the interface to be used for the Network LinkProperties.
+ * @param binder A binder object guarding the lifecycle of this test network.
+ * @hide
+ */
+ @TestApi
+ public void setupTestNetwork(@NonNull String iface, @NonNull IBinder binder) {
+ try {
+ mService.setupTestNetwork(iface, binder);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Create a tun interface for testing purposes
+ *
+ * @param linkAddrs an array of LinkAddresses to assign to the TUN interface
+ * @return A ParcelFileDescriptor of the underlying TUN interface. Close this to tear down the
+ * TUN interface.
+ * @hide
+ */
+ @TestApi
+ public TestNetworkInterface createTunInterface(@NonNull LinkAddress[] linkAddrs) {
+ try {
+ return mService.createTunInterface(linkAddrs);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+}
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index b28c2f4..d5ef249 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -653,7 +653,8 @@
*
* @return an object that will be passed back to #onTransactEnded (or null).
*/
- Object onTransactStarted(IBinder binder, int transactionCode);
+ @Nullable
+ Object onTransactStarted(@NonNull IBinder binder, int transactionCode);
/**
* Called after onTranact (even when an exception is thrown).
diff --git a/core/java/android/os/BugreportManager.java b/core/java/android/os/BugreportManager.java
index 684369a..672624c 100644
--- a/core/java/android/os/BugreportManager.java
+++ b/core/java/android/os/BugreportManager.java
@@ -17,6 +17,7 @@
package android.os;
import android.annotation.CallbackExecutor;
+import android.annotation.FloatRange;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -39,7 +40,7 @@
*/
@SystemApi
@SystemService(Context.BUGREPORT_SERVICE)
-public class BugreportManager {
+public final class BugreportManager {
private final Context mContext;
private final IDumpstate mBinder;
@@ -90,7 +91,7 @@
* Called when there is a progress update.
* @param progress the progress in [0.0, 100.0]
*/
- public void onProgress(float progress) {}
+ public void onProgress(@FloatRange(from = 0f, to = 100f) float progress) {}
/**
* Called when taking bugreport resulted in an error.
diff --git a/core/java/android/os/BugreportParams.java b/core/java/android/os/BugreportParams.java
index 3871375..279ccae 100644
--- a/core/java/android/os/BugreportParams.java
+++ b/core/java/android/os/BugreportParams.java
@@ -41,6 +41,7 @@
/**
* Defines acceptable types of bugreports.
+ * @hide
*/
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = { "BUGREPORT_MODE_" }, value = {
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java
index b3e35b6..fea69c0 100644
--- a/core/java/android/os/Environment.java
+++ b/core/java/android/os/Environment.java
@@ -389,7 +389,7 @@
/** {@hide} */
public static File getDataStagingDirectory(String volumeUuid) {
- return new File(getDataDirectory(volumeUuid), "pkg_staging");
+ return new File(getDataDirectory(volumeUuid), "app-staging");
}
/** {@hide} */
diff --git a/core/java/android/os/Handler.java b/core/java/android/os/Handler.java
index e6c12c7..a039742 100644
--- a/core/java/android/os/Handler.java
+++ b/core/java/android/os/Handler.java
@@ -82,19 +82,19 @@
* @param msg A {@link android.os.Message Message} object
* @return True if no further handling is desired
*/
- public boolean handleMessage(Message msg);
+ boolean handleMessage(@NonNull Message msg);
}
/**
* Subclasses must implement this to receive messages.
*/
- public void handleMessage(Message msg) {
+ public void handleMessage(@NonNull Message msg) {
}
/**
* Handle system messages here.
*/
- public void dispatchMessage(Message msg) {
+ public void dispatchMessage(@NonNull Message msg) {
if (msg.callback != null) {
handleCallback(msg);
} else {
@@ -128,7 +128,7 @@
*
* @param callback The callback interface in which to handle messages, or null.
*/
- public Handler(Callback callback) {
+ public Handler(@Nullable Callback callback) {
this(callback, false);
}
@@ -137,7 +137,7 @@
*
* @param looper The looper, must not be null.
*/
- public Handler(Looper looper) {
+ public Handler(@NonNull Looper looper) {
this(looper, null, false);
}
@@ -148,7 +148,7 @@
* @param looper The looper, must not be null.
* @param callback The callback interface in which to handle messages, or null.
*/
- public Handler(Looper looper, Callback callback) {
+ public Handler(@NonNull Looper looper, @Nullable Callback callback) {
this(looper, callback, false);
}
@@ -189,7 +189,7 @@
*
* @hide
*/
- public Handler(Callback callback, boolean async) {
+ public Handler(@Nullable Callback callback, boolean async) {
if (FIND_POTENTIAL_LEAKS) {
final Class<? extends Handler> klass = getClass();
if ((klass.isAnonymousClass() || klass.isMemberClass() || klass.isLocalClass()) &&
@@ -229,7 +229,7 @@
*
* @hide
*/
- public Handler(Looper looper, Callback callback, boolean async) {
+ public Handler(@NonNull Looper looper, @Nullable Callback callback, boolean async) {
mLooper = looper;
mQueue = looper.mQueue;
mCallback = callback;
@@ -289,7 +289,8 @@
}
/** {@hide} */
- public String getTraceName(Message message) {
+ @NonNull
+ public String getTraceName(@NonNull Message message) {
final StringBuilder sb = new StringBuilder();
sb.append(getClass().getName()).append(": ");
if (message.callback != null) {
@@ -308,7 +309,8 @@
*
* @param message The message whose name is being queried
*/
- public String getMessageName(Message message) {
+ @NonNull
+ public String getMessageName(@NonNull Message message) {
if (message.callback != null) {
return message.callback.getClass().getName();
}
@@ -320,6 +322,7 @@
* creating and allocating new instances. The retrieved message has its handler set to this instance (Message.target == this).
* If you don't want that facility, just call Message.obtain() instead.
*/
+ @NonNull
public final Message obtainMessage()
{
return Message.obtain(this);
@@ -331,6 +334,7 @@
* @param what Value to assign to the returned Message.what field.
* @return A Message from the global message pool.
*/
+ @NonNull
public final Message obtainMessage(int what)
{
return Message.obtain(this, what);
@@ -345,8 +349,8 @@
* @param obj Value to assign to the returned Message.obj field.
* @return A Message from the global message pool.
*/
- public final Message obtainMessage(int what, Object obj)
- {
+ @NonNull
+ public final Message obtainMessage(int what, @Nullable Object obj) {
return Message.obtain(this, what, obj);
}
@@ -359,6 +363,7 @@
* @param arg2 Value to assign to the returned Message.arg2 field.
* @return A Message from the global message pool.
*/
+ @NonNull
public final Message obtainMessage(int what, int arg1, int arg2)
{
return Message.obtain(this, what, arg1, arg2);
@@ -374,8 +379,8 @@
* @param obj Value to assign to the returned Message.obj field.
* @return A Message from the global message pool.
*/
- public final Message obtainMessage(int what, int arg1, int arg2, Object obj)
- {
+ @NonNull
+ public final Message obtainMessage(int what, int arg1, int arg2, @Nullable Object obj) {
return Message.obtain(this, what, arg1, arg2, obj);
}
@@ -390,8 +395,7 @@
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
- public final boolean post(Runnable r)
- {
+ public final boolean post(@NonNull Runnable r) {
return sendMessageDelayed(getPostMessage(r), 0);
}
@@ -413,8 +417,7 @@
* the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
- public final boolean postAtTime(Runnable r, long uptimeMillis)
- {
+ public final boolean postAtTime(@NonNull Runnable r, long uptimeMillis) {
return sendMessageAtTime(getPostMessage(r), uptimeMillis);
}
@@ -440,8 +443,8 @@
*
* @see android.os.SystemClock#uptimeMillis
*/
- public final boolean postAtTime(Runnable r, Object token, long uptimeMillis)
- {
+ public final boolean postAtTime(
+ @NonNull Runnable r, @Nullable Object token, long uptimeMillis) {
return sendMessageAtTime(getPostMessage(r, token), uptimeMillis);
}
@@ -464,8 +467,7 @@
* if the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
- public final boolean postDelayed(Runnable r, long delayMillis)
- {
+ public final boolean postDelayed(@NonNull Runnable r, long delayMillis) {
return sendMessageDelayed(getPostMessage(r), delayMillis);
}
@@ -495,8 +497,8 @@
* if the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
- public final boolean postDelayed(Runnable r, Object token, long delayMillis)
- {
+ public final boolean postDelayed(
+ @NonNull Runnable r, @Nullable Object token, long delayMillis) {
return sendMessageDelayed(getPostMessage(r, token), delayMillis);
}
@@ -515,8 +517,7 @@
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
- public final boolean postAtFrontOfQueue(Runnable r)
- {
+ public final boolean postAtFrontOfQueue(@NonNull Runnable r) {
return sendMessageAtFrontOfQueue(getPostMessage(r));
}
@@ -560,7 +561,7 @@
* If we ever do make it part of the API, we might want to rename it to something
* less funny like runUnsafe().
*/
- public final boolean runWithScissors(final Runnable r, long timeout) {
+ public final boolean runWithScissors(@NonNull Runnable r, long timeout) {
if (r == null) {
throw new IllegalArgumentException("runnable must not be null");
}
@@ -580,8 +581,7 @@
/**
* Remove any pending posts of Runnable r that are in the message queue.
*/
- public final void removeCallbacks(Runnable r)
- {
+ public final void removeCallbacks(@NonNull Runnable r) {
mQueue.removeMessages(this, r, null);
}
@@ -590,8 +590,7 @@
* <var>token</var> that are in the message queue. If <var>token</var> is null,
* all callbacks will be removed.
*/
- public final void removeCallbacks(Runnable r, Object token)
- {
+ public final void removeCallbacks(@NonNull Runnable r, @Nullable Object token) {
mQueue.removeMessages(this, r, token);
}
@@ -604,8 +603,7 @@
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
- public final boolean sendMessage(Message msg)
- {
+ public final boolean sendMessage(@NonNull Message msg) {
return sendMessageDelayed(msg, 0);
}
@@ -664,8 +662,7 @@
* the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
- public final boolean sendMessageDelayed(Message msg, long delayMillis)
- {
+ public final boolean sendMessageDelayed(@NonNull Message msg, long delayMillis) {
if (delayMillis < 0) {
delayMillis = 0;
}
@@ -691,7 +688,7 @@
* the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
- public boolean sendMessageAtTime(Message msg, long uptimeMillis) {
+ public boolean sendMessageAtTime(@NonNull Message msg, long uptimeMillis) {
MessageQueue queue = mQueue;
if (queue == null) {
RuntimeException e = new RuntimeException(
@@ -714,7 +711,7 @@
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
- public final boolean sendMessageAtFrontOfQueue(Message msg) {
+ public final boolean sendMessageAtFrontOfQueue(@NonNull Message msg) {
MessageQueue queue = mQueue;
if (queue == null) {
RuntimeException e = new RuntimeException(
@@ -734,7 +731,7 @@
* looper processing the message queue is exiting.
* @hide
*/
- public final boolean executeOrSendMessage(Message msg) {
+ public final boolean executeOrSendMessage(@NonNull Message msg) {
if (mLooper == Looper.myLooper()) {
dispatchMessage(msg);
return true;
@@ -742,7 +739,8 @@
return sendMessage(msg);
}
- private boolean enqueueMessage(MessageQueue queue, Message msg, long uptimeMillis) {
+ private boolean enqueueMessage(@NonNull MessageQueue queue, @NonNull Message msg,
+ long uptimeMillis) {
msg.target = this;
msg.workSourceUid = ThreadLocalWorkSource.getUid();
@@ -765,7 +763,7 @@
* 'object' that are in the message queue. If <var>object</var> is null,
* all messages will be removed.
*/
- public final void removeMessages(int what, Object object) {
+ public final void removeMessages(int what, @Nullable Object object) {
mQueue.removeMessages(this, what, object);
}
@@ -774,7 +772,7 @@
* <var>obj</var> is <var>token</var>. If <var>token</var> is null,
* all callbacks and messages will be removed.
*/
- public final void removeCallbacksAndMessages(Object token) {
+ public final void removeCallbacksAndMessages(@Nullable Object token) {
mQueue.removeCallbacksAndMessages(this, token);
}
@@ -798,7 +796,7 @@
* Check if there are any pending posts of messages with code 'what' and
* whose obj is 'object' in the message queue.
*/
- public final boolean hasMessages(int what, Object object) {
+ public final boolean hasMessages(int what, @Nullable Object object) {
return mQueue.hasMessages(this, what, object);
}
@@ -806,17 +804,18 @@
* Check if there are any pending posts of messages with callback r in
* the message queue.
*/
- public final boolean hasCallbacks(Runnable r) {
+ public final boolean hasCallbacks(@NonNull Runnable r) {
return mQueue.hasMessages(this, r, null);
}
// if we can get rid of this method, the handler need not remember its loop
// we could instead export a getMessageQueue() method...
+ @NonNull
public final Looper getLooper() {
return mLooper;
}
- public final void dump(Printer pw, String prefix) {
+ public final void dump(@NonNull Printer pw, @NonNull String prefix) {
pw.println(prefix + this + " @ " + SystemClock.uptimeMillis());
if (mLooper == null) {
pw.println(prefix + "looper uninitialized");
@@ -828,7 +827,7 @@
/**
* @hide
*/
- public final void dumpMine(Printer pw, String prefix) {
+ public final void dumpMine(@NonNull Printer pw, @NonNull String prefix) {
pw.println(prefix + this + " @ " + SystemClock.uptimeMillis());
if (mLooper == null) {
pw.println(prefix + "looper uninitialized");
diff --git a/core/java/android/os/UpdateEngine.java b/core/java/android/os/UpdateEngine.java
index 1df3dad..5cf3b97 100644
--- a/core/java/android/os/UpdateEngine.java
+++ b/core/java/android/os/UpdateEngine.java
@@ -39,8 +39,9 @@
*
* The APIs defined in this class and UpdateEngineCallback class must be in
* sync with the ones in
- * system/update_engine/binder_bindings/android/os/IUpdateEngine.aidl and
- * system/update_engine/binder_bindings/android/os/IUpdateEngineCallback.aidl.
+ * {@code system/update_engine/binder_bindings/android/os/IUpdateEngine.aidl}
+ * and
+ * {@code system/update_engine/binder_bindings/android/os/IUpdateEngineCallback.aidl}.
*
* {@hide}
*/
@@ -51,39 +52,150 @@
private static final String UPDATE_ENGINE_SERVICE = "android.os.UpdateEngineService";
/**
- * Error code from the update engine. Values must agree with the ones in
- * system/update_engine/common/error_code.h.
+ * Error codes from update engine upon finishing a call to
+ * {@link applyPayload}. Values will be passed via the callback function
+ * {@link UpdateEngineCallback#onPayloadApplicationComplete}. Values must
+ * agree with the ones in {@code system/update_engine/common/error_code.h}.
*/
public static final class ErrorCodeConstants {
+ /**
+ * Error code: a request finished successfully.
+ */
public static final int SUCCESS = 0;
+ /**
+ * Error code: a request failed due to a generic error.
+ */
public static final int ERROR = 1;
+ /**
+ * Error code: an update failed to apply due to filesystem copier
+ * error.
+ */
public static final int FILESYSTEM_COPIER_ERROR = 4;
+ /**
+ * Error code: an update failed to apply due to an error in running
+ * post-install hooks.
+ */
public static final int POST_INSTALL_RUNNER_ERROR = 5;
+ /**
+ * Error code: an update failed to apply due to a mismatching payload.
+ *
+ * <p>For example, the given payload uses a feature that's not
+ * supported by the current update engine.
+ */
public static final int PAYLOAD_MISMATCHED_TYPE_ERROR = 6;
+ /**
+ * Error code: an update failed to apply due to an error in opening
+ * devices.
+ */
public static final int INSTALL_DEVICE_OPEN_ERROR = 7;
+ /**
+ * Error code: an update failed to apply due to an error in opening
+ * kernel device.
+ */
public static final int KERNEL_DEVICE_OPEN_ERROR = 8;
+ /**
+ * Error code: an update failed to apply due to an error in fetching
+ * the payload.
+ *
+ * <p>For example, this could be a result of bad network connection
+ * when streaming an update.
+ */
public static final int DOWNLOAD_TRANSFER_ERROR = 9;
+ /**
+ * Error code: an update failed to apply due to a mismatch in payload
+ * hash.
+ *
+ * <p>Update engine does sanity checks for the given payload and its
+ * metadata.
+ */
public static final int PAYLOAD_HASH_MISMATCH_ERROR = 10;
+
+ /**
+ * Error code: an update failed to apply due to a mismatch in payload
+ * size.
+ */
public static final int PAYLOAD_SIZE_MISMATCH_ERROR = 11;
+
+ /**
+ * Error code: an update failed to apply due to failing to verify
+ * payload signatures.
+ */
public static final int DOWNLOAD_PAYLOAD_VERIFICATION_ERROR = 12;
+
+ /**
+ * Error code: an update failed to apply due to a downgrade in payload
+ * timestamp.
+ *
+ * <p>The timestamp of a build is encoded into the payload, which will
+ * be enforced during install to prevent downgrading a device.
+ */
public static final int PAYLOAD_TIMESTAMP_ERROR = 51;
+
+ /**
+ * Error code: an update has been applied successfully but the new slot
+ * hasn't been set to active.
+ *
+ * <p>It indicates a successful finish of calling {@link #applyPayload} with
+ * {@code SWITCH_SLOT_ON_REBOOT=0}. See {@link #applyPayload}.
+ */
public static final int UPDATED_BUT_NOT_ACTIVE = 52;
}
/**
- * Update status code from the update engine. Values must agree with the
- * ones in system/update_engine/client_library/include/update_engine/update_status.h.
+ * Status codes for update engine. Values must agree with the ones in
+ * {@code system/update_engine/client_library/include/update_engine/update_status.h}.
*/
public static final class UpdateStatusConstants {
+ /**
+ * Update status code: update engine is in idle state.
+ */
public static final int IDLE = 0;
+
+ /**
+ * Update status code: update engine is checking for update.
+ */
public static final int CHECKING_FOR_UPDATE = 1;
+
+ /**
+ * Update status code: an update is available.
+ */
public static final int UPDATE_AVAILABLE = 2;
+
+ /**
+ * Update status code: update engine is downloading an update.
+ */
public static final int DOWNLOADING = 3;
+
+ /**
+ * Update status code: update engine is verifying an update.
+ */
public static final int VERIFYING = 4;
+
+ /**
+ * Update status code: update engine is finalizing an update.
+ */
public static final int FINALIZING = 5;
+
+ /**
+ * Update status code: an update has been applied and is pending for
+ * reboot.
+ */
public static final int UPDATED_NEED_REBOOT = 6;
+
+ /**
+ * Update status code: update engine is reporting an error event.
+ */
public static final int REPORTING_ERROR_EVENT = 7;
+
+ /**
+ * Update status code: update engine is attempting to rollback an
+ * update.
+ */
public static final int ATTEMPTING_ROLLBACK = 8;
+
+ /**
+ * Update status code: update engine is in disabled state.
+ */
public static final int DISABLED = 9;
}
@@ -178,6 +290,18 @@
* "METADATA_SIZE=70604"
* };
* </pre>
+ *
+ * <p>The callback functions registered via {@code #bind} will be called
+ * during and at the end of the payload application.
+ *
+ * <p>By default the newly updated slot will be set active upon
+ * successfully finishing an update. Device will attempt to boot into the
+ * new slot on next reboot. This behavior can be customized by specifying
+ * {@code SWITCH_SLOT_ON_REBOOT=0} in {@code headerKeyValuePairs}, which
+ * allows the caller to later determine a good time to boot into the new
+ * slot. Calling {@code applyPayload} again with the same payload but with
+ * {@code SWITCH_SLOT_ON_REBOOT=1} will do the minimal work to set the new
+ * slot active, after verifying its integrity.
*/
public void applyPayload(String url, long offset, long size, String[] headerKeyValuePairs) {
try {
diff --git a/core/java/android/permission/PermissionControllerService.java b/core/java/android/permission/PermissionControllerService.java
index bd4a6ff..2313d59 100644
--- a/core/java/android/permission/PermissionControllerService.java
+++ b/core/java/android/permission/PermissionControllerService.java
@@ -112,6 +112,9 @@
/**
* Restore a backup of the runtime permissions.
*
+ * <p>If an app mentioned in the backup is not installed the state should be saved to later
+ * be restored via {@link #onRestoreDelayedRuntimePermissionsBackup}.
+ *
* @param user The user to restore
* @param backup The stream to read the backup from
*/
@@ -120,7 +123,8 @@
@NonNull InputStream backup);
/**
- * Restore a delayed backup of the runtime permissions.
+ * Restore the permission state of an app that was provided in
+ * {@link #onRestoreRuntimePermissionsBackup} but could not be restored back then.
*
* @param packageName The app to restore
* @param user The user to restore
diff --git a/core/java/android/provider/DocumentsProvider.java b/core/java/android/provider/DocumentsProvider.java
index cb794ad..2143a0d 100644
--- a/core/java/android/provider/DocumentsProvider.java
+++ b/core/java/android/provider/DocumentsProvider.java
@@ -471,10 +471,12 @@
* the most recently modified documents.
* <p>
* If this method is overriden by the concrete DocumentsProvider and
- * QUERY_ARGS_LIMIT is specified with a nonnegative int under queryArgs, the
- * result will be limited by that number and QUERY_ARG_LIMIT will be
- * specified under EXTRA_HONORED_ARGS. Otherwise, a default 64 limit will
- * be used and no QUERY_ARG* will be specified under EXTRA_HONORED_ARGS.
+ * {@link ContentResolver#QUERY_ARG_LIMIT} is specified with a nonnegative
+ * int under queryArgs, the result will be limited by that number and
+ * {@link ContentResolver#QUERY_ARG_LIMIT} will be specified under
+ * {@link ContentResolver#EXTRA_HONORED_ARGS}. Otherwise, a default 64 limit
+ * will be used and no QUERY_ARG* will be specified under
+ * {@link ContentResolver#EXTRA_HONORED_ARGS}.
* <p>
* Recent documents do not support change notifications.
*
diff --git a/core/java/android/service/contentsuggestions/ContentSuggestionsService.java b/core/java/android/service/contentsuggestions/ContentSuggestionsService.java
index 86f99bb..45a8466 100644
--- a/core/java/android/service/contentsuggestions/ContentSuggestionsService.java
+++ b/core/java/android/service/contentsuggestions/ContentSuggestionsService.java
@@ -185,7 +185,7 @@
/**
* For temporary compat reason, remove with b/127532182
- * @deprecated
+ * @deprecated use {@link #onProcessContextImage(int, Bitmap, Bundle)} instead.
*/
@Deprecated
public void processContextImage(
@@ -194,7 +194,8 @@
/**
* For temporary compat reason, remove with b/127532182
- * @deprecated
+ * @deprecated use {@link #onSuggestContentSelections(SelectionsRequest,
+ * ContentSuggestionsManager.SelectionsCallback)} instead.
*/
@Deprecated
public void suggestContentSelections(@NonNull SelectionsRequest request,
@@ -203,7 +204,8 @@
/**
* For temporary compat reason, remove with b/127532182
- * @deprecated
+ * @deprecated use {@link #onClassifyContentSelections(ClassificationsRequest,
+ * ContentSuggestionsManager.ClassificationsCallback)} instead.
*/
@Deprecated
public void classifyContentSelections(@NonNull ClassificationsRequest request,
@@ -212,7 +214,7 @@
/**
* For temporary compat reason, remove with b/127532182
- * @deprecated
+ * @deprecated use {@link #onNotifyInteraction(String, Bundle)} instead.
*/
@Deprecated
public void notifyInteraction(@NonNull String requestId, @NonNull Bundle interaction) {
diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java
index b99336b..7747a55 100644
--- a/core/java/android/util/FeatureFlagUtils.java
+++ b/core/java/android/util/FeatureFlagUtils.java
@@ -48,7 +48,7 @@
DEFAULT_FLAGS = new HashMap<>();
DEFAULT_FLAGS.put("settings_audio_switcher", "true");
DEFAULT_FLAGS.put("settings_mobile_network_v2", "true");
- DEFAULT_FLAGS.put("settings_network_and_internet_v2", "false");
+ DEFAULT_FLAGS.put("settings_network_and_internet_v2", "true");
DEFAULT_FLAGS.put("settings_slice_injection", "true");
DEFAULT_FLAGS.put("settings_systemui_theme", "true");
DEFAULT_FLAGS.put("settings_wifi_mac_randomization", "true");
diff --git a/core/java/android/view/textclassifier/ConversationActions.java b/core/java/android/view/textclassifier/ConversationActions.java
index 78ed9bf..dc75212 100644
--- a/core/java/android/view/textclassifier/ConversationActions.java
+++ b/core/java/android/view/textclassifier/ConversationActions.java
@@ -318,19 +318,15 @@
private final List<String> mHints;
@Nullable
private String mCallingPackageName;
- @Nullable
- private final String mConversationId;
private Request(
@NonNull List<Message> conversation,
@NonNull TextClassifier.EntityConfig typeConfig,
int maxSuggestions,
- String conversationId,
@Nullable @Hint List<String> hints) {
mConversation = Preconditions.checkNotNull(conversation);
mTypeConfig = Preconditions.checkNotNull(typeConfig);
mMaxSuggestions = maxSuggestions;
- mConversationId = conversationId;
mHints = hints;
}
@@ -339,7 +335,6 @@
in.readParcelableList(conversation, null);
TextClassifier.EntityConfig typeConfig = in.readParcelable(null);
int maxSuggestions = in.readInt();
- String conversationId = in.readString();
List<String> hints = new ArrayList<>();
in.readStringList(hints);
String callingPackageName = in.readString();
@@ -348,7 +343,6 @@
conversation,
typeConfig,
maxSuggestions,
- conversationId,
hints);
request.setCallingPackageName(callingPackageName);
return request;
@@ -359,7 +353,6 @@
parcel.writeParcelableList(mConversation, flags);
parcel.writeParcelable(mTypeConfig, flags);
parcel.writeInt(mMaxSuggestions);
- parcel.writeString(mConversationId);
parcel.writeStringList(mHints);
parcel.writeString(mCallingPackageName);
}
@@ -403,16 +396,6 @@
return mMaxSuggestions;
}
- /**
- * Return an unique identifier of the conversation that is generating actions for. This
- * identifier is unique within the calling package only, so use it with
- * {@link #getCallingPackageName()}.
- */
- @Nullable
- public String getConversationId() {
- return mConversationId;
- }
-
/** Returns an immutable list of hints */
@Nullable
@Hint
@@ -448,8 +431,6 @@
private TextClassifier.EntityConfig mTypeConfig;
private int mMaxSuggestions = -1;
@Nullable
- private String mConversationId;
- @Nullable
@Hint
private List<String> mHints;
@@ -490,15 +471,6 @@
return this;
}
- /**
- * Sets an unique identifier of the conversation that is generating actions for.
- */
- @NonNull
- public Builder setConversationId(@Nullable String conversationId) {
- mConversationId = conversationId;
- return this;
- }
-
/** Builds the {@link Request} object. */
@NonNull
public Request build() {
@@ -508,7 +480,6 @@
? new TextClassifier.EntityConfig.Builder().build()
: mTypeConfig,
mMaxSuggestions,
- mConversationId,
mHints == null
? Collections.emptyList()
: Collections.unmodifiableList(mHints));
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 6eceb003..24f1fb5 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -7794,6 +7794,11 @@
mLastSeenPos = firstPos;
final int childCount = getChildCount();
+
+ if (childCount <= 0) {
+ return;
+ }
+
final int position = mTargetPos;
final int lastPos = firstPos + childCount - 1;
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index fd978f5..91928b5 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -420,6 +420,10 @@
if (isFinishing() || isDestroyed()) {
return;
}
+ // May be null if there are no apps to perform share/open action.
+ if (mChooserListAdapter == null) {
+ return;
+ }
final List<DisplayResolveInfo> driList =
getDisplayResolveInfos(mChooserListAdapter);
final List<ShortcutManager.ShareShortcutInfo> shareShortcutInfos =
diff --git a/core/java/com/android/internal/colorextraction/types/Tonal.java b/core/java/com/android/internal/colorextraction/types/Tonal.java
index d6a8934..9d85a03 100644
--- a/core/java/com/android/internal/colorextraction/types/Tonal.java
+++ b/core/java/com/android/internal/colorextraction/types/Tonal.java
@@ -56,7 +56,6 @@
private final TonalPalette mGreyPalette;
private final ArrayList<TonalPalette> mTonalPalettes;
- private final ArrayList<ColorRange> mBlacklistedColors;
// Temporary variable to avoid allocations
private float[] mTmpHSL = new float[3];
@@ -65,7 +64,6 @@
ConfigParser parser = new ConfigParser(context);
mTonalPalettes = parser.getTonalPalettes();
- mBlacklistedColors = parser.getBlacklistedColors();
mGreyPalette = mTonalPalettes.get(0);
mTonalPalettes.remove(0);
@@ -131,7 +129,7 @@
Color.blue(colorValue), hsl);
// Stop when we find a color that meets our criteria
- if (!generatedFromBitmap || !isBlacklisted(hsl)) {
+ if (!generatedFromBitmap) {
bestColor = color;
break;
}
@@ -300,22 +298,6 @@
return getColorPalette(palette.h, palette.s, palette.l);
}
-
- /**
- * Checks if a given color exists in the blacklist
- * @param hsl float array with 3 components (H 0..360, S 0..1 and L 0..1)
- * @return true if color should be avoided
- */
- private boolean isBlacklisted(float[] hsl) {
- for (int i = mBlacklistedColors.size() - 1; i >= 0; i--) {
- ColorRange badRange = mBlacklistedColors.get(i);
- if (badRange.containsColor(hsl[0], hsl[1], hsl[2])) {
- return true;
- }
- }
- return false;
- }
-
/**
* Offsets all colors by a delta, clamping values that go beyond what's
* supported on the color space.
@@ -364,11 +346,6 @@
return minErrorIndex;
}
- @VisibleForTesting
- public List<ColorRange> getBlacklistedColors() {
- return mBlacklistedColors;
- }
-
@Nullable
private TonalPalette findTonalPalette(float h, float s) {
// Fallback to a grey palette if the color is too desaturated.
@@ -502,11 +479,9 @@
@VisibleForTesting
public static class ConfigParser {
private final ArrayList<TonalPalette> mTonalPalettes;
- private final ArrayList<ColorRange> mBlacklistedColors;
public ConfigParser(Context context) {
mTonalPalettes = new ArrayList<>();
- mBlacklistedColors = new ArrayList<>();
// Load all palettes and the blacklist from an XML.
try {
@@ -520,8 +495,6 @@
String tagName = parser.getName();
if (tagName.equals("palettes")) {
parsePalettes(parser);
- } else if (tagName.equals("blacklist")) {
- parseBlacklist(parser);
}
} else {
throw new XmlPullParserException("Invalid XML event " + eventType + " - "
@@ -538,28 +511,6 @@
return mTonalPalettes;
}
- public ArrayList<ColorRange> getBlacklistedColors() {
- return mBlacklistedColors;
- }
-
- private void parseBlacklist(XmlPullParser parser)
- throws XmlPullParserException, IOException {
- parser.require(XmlPullParser.START_TAG, null, "blacklist");
- while (parser.next() != XmlPullParser.END_TAG) {
- if (parser.getEventType() != XmlPullParser.START_TAG) {
- continue;
- }
- String name = parser.getName();
- // Starts by looking for the entry tag
- if (name.equals("range")) {
- mBlacklistedColors.add(readRange(parser));
- parser.next();
- } else {
- throw new XmlPullParserException("Invalid tag: " + name, parser, null);
- }
- }
- }
-
private ColorRange readRange(XmlPullParser parser)
throws XmlPullParserException, IOException {
parser.require(XmlPullParser.START_TAG, null, "range");
diff --git a/core/java/com/android/internal/net/VpnProfile.java b/core/java/com/android/internal/net/VpnProfile.java
index ec02432..940cc36 100644
--- a/core/java/com/android/internal/net/VpnProfile.java
+++ b/core/java/com/android/internal/net/VpnProfile.java
@@ -18,6 +18,8 @@
import android.annotation.UnsupportedAppUsage;
import android.os.Build;
+import android.net.ProxyInfo;
+import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
@@ -46,6 +48,10 @@
public static final int TYPE_IPSEC_HYBRID_RSA = 5;
public static final int TYPE_MAX = 5;
+ // Match these constants with R.array.vpn_proxy_settings.
+ public static final int PROXY_NONE = 0;
+ public static final int PROXY_MANUAL = 1;
+
// Entity fields.
@UnsupportedAppUsage
public final String key; // -1
@@ -68,6 +74,7 @@
public String ipsecUserCert = ""; // 12
public String ipsecCaCert = ""; // 13
public String ipsecServerCert = "";// 14
+ public ProxyInfo proxy = null; // 15~18
// Helper fields.
@UnsupportedAppUsage
@@ -96,6 +103,7 @@
ipsecCaCert = in.readString();
ipsecServerCert = in.readString();
saveLogin = in.readInt() != 0;
+ proxy = in.readParcelable(null);
}
@Override
@@ -117,6 +125,7 @@
out.writeString(ipsecCaCert);
out.writeString(ipsecServerCert);
out.writeInt(saveLogin ? 1 : 0);
+ out.writeParcelable(proxy, flags);
}
@UnsupportedAppUsage
@@ -127,8 +136,8 @@
}
String[] values = new String(value, StandardCharsets.UTF_8).split("\0", -1);
- // There can be 14 or 15 values in ICS MR1.
- if (values.length < 14 || values.length > 15) {
+ // There can be 14 - 19 Bytes in values.length.
+ if (values.length < 14 || values.length > 19) {
return null;
}
@@ -151,7 +160,18 @@
profile.ipsecUserCert = values[12];
profile.ipsecCaCert = values[13];
profile.ipsecServerCert = (values.length > 14) ? values[14] : "";
-
+ if (values.length > 15) {
+ String host = (values.length > 15) ? values[15] : "";
+ String port = (values.length > 16) ? values[16] : "";
+ String exclList = (values.length > 17) ? values[17] : "";
+ String pacFileUrl = (values.length > 18) ? values[18] : "";
+ if (pacFileUrl.isEmpty()) {
+ profile.proxy = new ProxyInfo(host, port.isEmpty() ?
+ 0 : Integer.parseInt(port), exclList);
+ } else {
+ profile.proxy = new ProxyInfo(pacFileUrl);
+ }
+ } // else profle.proxy = null
profile.saveLogin = !profile.username.isEmpty() || !profile.password.isEmpty();
return profile;
} catch (Exception e) {
@@ -176,6 +196,13 @@
builder.append('\0').append(ipsecUserCert);
builder.append('\0').append(ipsecCaCert);
builder.append('\0').append(ipsecServerCert);
+ if (proxy != null) {
+ builder.append('\0').append(proxy.getHost() != null ? proxy.getHost() : "");
+ builder.append('\0').append(proxy.getPort());
+ builder.append('\0').append(proxy.getExclusionListAsString() != null ?
+ proxy.getExclusionListAsString() : "");
+ builder.append('\0').append(proxy.getPacFileUrl().toString());
+ }
return builder.toString().getBytes(StandardCharsets.UTF_8);
}
diff --git a/core/java/com/android/internal/widget/MediaNotificationView.java b/core/java/com/android/internal/widget/MediaNotificationView.java
index de86d92..e7d240a 100644
--- a/core/java/com/android/internal/widget/MediaNotificationView.java
+++ b/core/java/com/android/internal/widget/MediaNotificationView.java
@@ -126,6 +126,9 @@
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (mImagePushIn > 0) {
+ if (this.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
+ mImagePushIn *= -1;
+ }
mRightIcon.layout(mRightIcon.getLeft() + mImagePushIn, mRightIcon.getTop(),
mRightIcon.getRight() + mImagePushIn, mRightIcon.getBottom());
}
diff --git a/core/java/com/android/server/net/OWNERS b/core/java/com/android/server/net/OWNERS
index 7311eee..d3836d4 100644
--- a/core/java/com/android/server/net/OWNERS
+++ b/core/java/com/android/server/net/OWNERS
@@ -1,8 +1,8 @@
set noparent
codewiz@google.com
-ek@google.com
jchalard@google.com
+junyulai@google.com
lorenzo@google.com
reminv@google.com
satk@google.com
diff --git a/core/res/res/layout/notification_material_media_seekbar.xml b/core/res/res/layout/notification_material_media_seekbar.xml
index c23ca83..4aa8acc 100644
--- a/core/res/res/layout/notification_material_media_seekbar.xml
+++ b/core/res/res/layout/notification_material_media_seekbar.xml
@@ -50,7 +50,7 @@
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginStart="@dimen/notification_content_margin_start"
- android:gravity="left"
+ android:gravity="start"
/>
<TextView android:id="@+id/notification_media_total_time"
@@ -59,7 +59,7 @@
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginEnd="@dimen/notification_content_margin_end"
- android:gravity="right"
+ android:gravity="end"
/>
</FrameLayout>
</LinearLayout>
\ No newline at end of file
diff --git a/core/res/res/values-night/values.xml b/core/res/res/values-night/values.xml
index a2ad3b9..4e6b712 100644
--- a/core/res/res/values-night/values.xml
+++ b/core/res/res/values-night/values.xml
@@ -24,6 +24,7 @@
<item name="colorError">@color/error_color_device_default_dark</item>
<item name="colorControlNormal">?attr/textColorPrimary</item>
<item name="alertDialogTheme">@style/Theme.DeviceDefault.Dialog.Alert</item>
+ <item name="forceDarkAllowed">false</item>
<!-- QS panel background -->
<item name="colorBackgroundFloating">@color/black</item>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index b7f594e..442ad7e 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -3943,4 +3943,8 @@
<!-- The default peak refresh rate for a given device. Change this value if you want to allow
for higher refresh rates to be automatically used out of the box -->
<integer name="config_defaultPeakRefreshRate">60</integer>
+
+ <!-- The type of the light sensor to be used by the display framework for things like
+ auto-brightness. If unset, then it just gets the default sensor of type TYPE_LIGHT. -->
+ <string name="config_displayLightSensorType" translatable="false" />
</resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 5b658b7..6671ff8 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -707,12 +707,12 @@
<string name="permgrouprequest_location">Allow
<b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g></b> to access this device\'s location?</string>
<!-- Subtitle of the message shown to the user when the apps requests permission to use the location only while app is in foreground [CHAR LIMIT=150]-->
- <string name="permgrouprequestdetail_location">The app will only have access to the location while you\u2019re using the app.</string>
+ <string name="permgrouprequestdetail_location">The app will only have access to the location while you\u2019re using the app</string>
<!-- Message shown to the user when the apps requests permission to use the location while app is in foreground and background. If ever possible this should stay below 80 characters (assuming the parameters takes 20 characters). Don't abbreviate until the message reaches 120 characters though. [CHAR LIMIT=120] -->
- <string name="permgroupbackgroundrequest_location">Always allow
- <b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g></b> to access this device\u2019s location?</string>
+ <string name="permgroupbackgroundrequest_location">Allow
+ <b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g></b> to access this device\u2019s location <b>all the time</b>?</string>
<!-- Subtitle of the message shown to the user when the apps requests permission to use the location while app is in foreground and background [CHAR LIMIT=150] -->
- <string name="permgroupbackgroundrequestdetail_location">The app will always have access to the location, even when you\u2019re not using the app.</string>
+ <string name="permgroupbackgroundrequestdetail_location">App currently can access location only while you\u2019re using the app</string>
<!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgrouplab_calendar">Calendar</string>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 96a3d96..c7e19c5 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -3693,5 +3693,9 @@
<java-symbol type="string" name="mime_type_presentation" />
<java-symbol type="string" name="mime_type_presentation_ext" />
+ <!-- For high refresh rate displays -->
<java-symbol type="integer" name="config_defaultPeakRefreshRate" />
+
+ <!-- For Auto-Brightness -->
+ <java-symbol type="string" name="config_displayLightSensorType" />
</resources>
diff --git a/core/res/res/xml/color_extraction.xml b/core/res/res/xml/color_extraction.xml
index 93ab0ff..c3ebe4e 100644
--- a/core/res/res/xml/color_extraction.xml
+++ b/core/res/res/xml/color_extraction.xml
@@ -246,109 +246,4 @@
0.6549019607843137,0.7549019607843137,0.8509803921568627,
0.9411764705882353"/>
</palettes>
- <blacklist>
- <!-- Red -->
- <range h="0, 20"
- s="0.7, 1"
- l="0.21, 0.79"/>
- <range h="0, 20"
- s="0.3, 0.7"
- l="0.355, 0.653"/>
- <!-- Red Orange -->
- <range h="20, 40"
- s="0.7, 1"
- l="0.2, 0.643"/>
- <range h="20, 40"
- s="0.3, 0.7"
- l="0.414, 0.561"/>
- <range h="20, 40"
- s="0, 0.3"
- l="0.343, 0.584"/>
- <!-- Orange -->
- <range h="40, 60"
- s="0.7, 1"
- l="0.173, 0.38"/>
- <range h="40, 60"
- s="0.3, 0.7"
- l="0.233, 0.427"/>
- <range h="40, 60"
- s="0, 0.3"
- l="0.231, 0.48"/>
- <!-- Yellow 60 -->
- <range h="60, 80"
- s="0.7, 1"
- l="0.15, 0.40"/>
- <range h="60, 80"
- s="0.3, 0.7"
- l="0.15, 0.42"/>
- <range h="60, 80"
- s="0, 0.3"
- l="0.35, 0.57"/>
- <!-- Yellow Green 80 -->
- <range h="80, 100"
- s="0.7, 1"
- l="0.36, 0.65"/>
- <range h="80, 100"
- s="0.3, 0.7"
- l="0.48, 0.57"/>
- <!-- Yellow green 100 -->
- <range h="100, 120"
- s="0.7, 1"
- l="0.388, 0.67"/>
- <range h="100, 120"
- s="0.3, 0.7"
- l="0.424, 0.58"/>
- <!-- Green -->
- <range h="120, 140"
- s="0.7, 1"
- l="0.37, 0.65"/>
- <range h="120, 140"
- s="0.3, 0.7"
- l="0.435, 0.58"/>
- <!-- Green Blue 140 -->
- <range h="140, 160"
- s="0.7, 1"
- l="0.43, 0.641"/>
- <!-- Seaoam -->
- <range h="160, 180"
- s="0.7, 1"
- l="0.496, 0.567"/>
- <!-- Cyan -->
- <range h="180, 200"
- s="0.7, 1"
- l="0.52, 0.729"/>
- <!-- Blue -->
- <range h="220, 240"
- s="0.7, 1"
- l="0.396, 0.571"/>
- <range h="220, 240"
- s="0.3, 0.7"
- l="0.425, 0.551"/>
- <!-- Blue Purple 240 -->
- <range h="240, 260"
- s="0.7, 1"
- l="0.418, 0.639"/>
- <range h="220, 240"
- s="0.3, 0.7"
- l="0.441, 0.576"/>
- <!-- Blue Purple 260 -->
- <range h="260, 280"
- s="0.3, 1"
- l="0.461, 0.553"/>
- <!-- Fuchsia -->
- <range h="300, 320"
- s="0.7, 1"
- l="0.484, 0.588"/>
- <range h="300, 320"
- s="0.3, 0.7"
- l="0.48, 0.592"/>
- <!-- Pink -->
- <range h="320, 340"
- s="0.7, 1"
- l="0.466, 0.629"/>
- <!-- Soft red -->
- <range h="340, 360"
- s="0.7, 1"
- l="0.437, 0.596"/>
- </blacklist>
-</colorextraction>
\ No newline at end of file
+</colorextraction>
diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp
index 793dd8d..4f1b2a4 100644
--- a/libs/hwui/Android.bp
+++ b/libs/hwui/Android.bp
@@ -69,6 +69,7 @@
"libminikin",
"libandroidfw",
"libcrypto",
+ "libsync",
],
static_libs: [
"libEGL_blobCache",
@@ -180,6 +181,7 @@
"renderthread/EglManager.cpp",
"renderthread/ReliableSurface.cpp",
"renderthread/VulkanManager.cpp",
+ "renderthread/VulkanSurface.cpp",
"renderthread/RenderProxy.cpp",
"renderthread/RenderTask.cpp",
"renderthread/RenderThread.cpp",
diff --git a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
index 87cffb5..edde6d3 100644
--- a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
@@ -55,20 +55,8 @@
}
Frame SkiaVulkanPipeline::getFrame() {
- LOG_ALWAYS_FATAL_IF(mVkSurface == nullptr,
- "drawRenderNode called on a context with no surface!");
-
- SkSurface* backBuffer = mVkManager.getBackbufferSurface(&mVkSurface);
- LOG_ALWAYS_FATAL_IF(mVkSurface == nullptr,
- "drawRenderNode called on a context with an invalid surface");
- if (backBuffer == nullptr) {
- SkDebugf("failed to get backbuffer");
- return Frame(-1, -1, 0);
- }
-
- Frame frame(mVkSurface->windowWidth(), mVkSurface->windowHeight(),
- mVkManager.getAge(mVkSurface));
- return frame;
+ LOG_ALWAYS_FATAL_IF(mVkSurface == nullptr, "getFrame() called on a context with no surface!");
+ return mVkManager.dequeueNextBuffer(mVkSurface);
}
bool SkiaVulkanPipeline::draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
@@ -77,13 +65,13 @@
bool opaque, const LightInfo& lightInfo,
const std::vector<sp<RenderNode>>& renderNodes,
FrameInfoVisualizer* profiler) {
- sk_sp<SkSurface> backBuffer = mVkSurface->getBackBufferSurface();
+ sk_sp<SkSurface> backBuffer = mVkSurface->getCurrentSkSurface();
if (backBuffer.get() == nullptr) {
return false;
}
SkiaPipeline::updateLighting(lightGeometry, lightInfo);
renderFrame(*layerUpdateQueue, dirty, renderNodes, opaque, contentDrawBounds,
- backBuffer, mVkSurface->preTransform());
+ backBuffer, mVkSurface->getCurrentPreTransform());
ShaderCache::get().onVkFrameFlushed(mRenderThread.getGrContext());
layerUpdateQueue->clear();
@@ -113,7 +101,7 @@
currentFrameInfo->markSwapBuffers();
if (*requireSwap) {
- mVkManager.swapBuffers(mVkSurface);
+ mVkManager.swapBuffers(mVkSurface, screenDirty);
}
return *requireSwap;
diff --git a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h
index 2c24edd..77a7ab1 100644
--- a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h
+++ b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h
@@ -18,6 +18,7 @@
#include "SkiaPipeline.h"
#include "renderthread/VulkanManager.h"
+#include "renderthread/VulkanSurface.h"
#include "renderstate/RenderState.h"
diff --git a/libs/hwui/renderthread/VulkanManager.cpp b/libs/hwui/renderthread/VulkanManager.cpp
index 5af660c..d4c6eae 100644
--- a/libs/hwui/renderthread/VulkanManager.cpp
+++ b/libs/hwui/renderthread/VulkanManager.cpp
@@ -16,6 +16,7 @@
#include "VulkanManager.h"
+#include <android/sync.h>
#include <gui/Surface.h>
#include "Properties.h"
@@ -23,6 +24,7 @@
#include "renderstate/RenderState.h"
#include "utils/FatVector.h"
+#include <GrBackendSemaphore.h>
#include <GrBackendSurface.h>
#include <GrContext.h>
#include <GrTypes.h>
@@ -142,6 +144,7 @@
GET_INST_PROC(GetPhysicalDeviceProperties);
GET_INST_PROC(GetPhysicalDeviceQueueFamilyProperties);
GET_INST_PROC(GetPhysicalDeviceFeatures2);
+ GET_INST_PROC(GetPhysicalDeviceImageFormatProperties2);
GET_INST_PROC(CreateDevice);
GET_INST_PROC(EnumerateDeviceExtensionProperties);
GET_INST_PROC(CreateAndroidSurfaceKHR);
@@ -318,11 +321,6 @@
GET_DEV_PROC(GetDeviceQueue);
GET_DEV_PROC(DeviceWaitIdle);
GET_DEV_PROC(DestroyDevice);
- GET_DEV_PROC(CreateSwapchainKHR);
- GET_DEV_PROC(DestroySwapchainKHR);
- GET_DEV_PROC(GetSwapchainImagesKHR);
- GET_DEV_PROC(AcquireNextImageKHR);
- GET_DEV_PROC(QueuePresentKHR);
GET_DEV_PROC(CreateCommandPool);
GET_DEV_PROC(DestroyCommandPool);
GET_DEV_PROC(AllocateCommandBuffers);
@@ -426,201 +424,102 @@
};
}
-// Returns the next BackbufferInfo to use for the next draw. The function will make sure all
-// previous uses have finished before returning.
-VulkanSurface::BackbufferInfo* VulkanManager::getAvailableBackbuffer(VulkanSurface* surface) {
- SkASSERT(surface->mBackbuffers);
+Frame VulkanManager::dequeueNextBuffer(VulkanSurface* surface) {
- ++surface->mCurrentBackbufferIndex;
- if (surface->mCurrentBackbufferIndex > surface->mImageCount) {
- surface->mCurrentBackbufferIndex = 0;
+ VulkanSurface::NativeBufferInfo* bufferInfo = surface->dequeueNativeBuffer();
+
+ if (bufferInfo == nullptr) {
+ ALOGE("VulkanSurface::dequeueNativeBuffer called with an invalid surface!");
+ return Frame(-1, -1, 0);
}
- VulkanSurface::BackbufferInfo* backbuffer =
- surface->mBackbuffers + surface->mCurrentBackbufferIndex;
+ LOG_ALWAYS_FATAL_IF(!bufferInfo->dequeued);
- // Before we reuse a backbuffer, make sure its fences have all signaled so that we can safely
- // reuse its commands buffers.
- VkResult res = mWaitForFences(mDevice, 2, backbuffer->mUsageFences, true, UINT64_MAX);
- if (res != VK_SUCCESS) {
- return nullptr;
+ if (bufferInfo->dequeue_fence != -1) {
+ int fence_clone = dup(bufferInfo->dequeue_fence);
+ if (fence_clone == -1) {
+ ALOGE("dup(fence) failed, stalling until signalled: %s (%d)", strerror(errno), errno);
+ sync_wait(bufferInfo->dequeue_fence, -1 /* forever */);
+ } else {
+ VkSemaphoreCreateInfo semaphoreInfo;
+ semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
+ semaphoreInfo.pNext = nullptr;
+ semaphoreInfo.flags = 0;
+ VkSemaphore semaphore;
+ VkResult err = mCreateSemaphore(mDevice, &semaphoreInfo, nullptr, &semaphore);
+ LOG_ALWAYS_FATAL_IF(VK_SUCCESS != err, "Failed to create import semaphore, err: %d",
+ err);
+
+ VkImportSemaphoreFdInfoKHR importInfo;
+ importInfo.sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR;
+ importInfo.pNext = nullptr;
+ importInfo.semaphore = semaphore;
+ importInfo.flags = VK_SEMAPHORE_IMPORT_TEMPORARY_BIT;
+ importInfo.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
+ importInfo.fd = fence_clone;
+
+ err = mImportSemaphoreFdKHR(mDevice, &importInfo);
+ LOG_ALWAYS_FATAL_IF(VK_SUCCESS != err, "Failed to import semaphore, err: %d", err);
+
+ GrBackendSemaphore backendSemaphore;
+ backendSemaphore.initVulkan(semaphore);
+ bufferInfo->skSurface->wait(1, &backendSemaphore);
+ }
}
- return backbuffer;
+ int bufferAge = (mSwapBehavior == SwapBehavior::Discard) ? 0 : surface->getCurrentBuffersAge();
+ return Frame(surface->logicalWidth(), surface->logicalHeight(), bufferAge);
}
-static SkMatrix getPreTransformMatrix(int width, int height,
- VkSurfaceTransformFlagBitsKHR transform) {
- switch (transform) {
- case VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR:
- return SkMatrix::I();
- case VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR:
- return SkMatrix::MakeAll(0, -1, height, 1, 0, 0, 0, 0, 1);
- case VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR:
- return SkMatrix::MakeAll(-1, 0, width, 0, -1, height, 0, 0, 1);
- case VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR:
- return SkMatrix::MakeAll(0, 1, 0, -1, 0, width, 0, 0, 1);
- case VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR:
- return SkMatrix::MakeAll(-1, 0, width, 0, 1, 0, 0, 0, 1);
- case VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR:
- return SkMatrix::MakeAll(0, -1, height, -1, 0, width, 0, 0, 1);
- case VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR:
- return SkMatrix::MakeAll(1, 0, 0, 0, -1, height, 0, 0, 1);
- case VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR:
- return SkMatrix::MakeAll(0, 1, 0, 1, 0, 0, 0, 0, 1);
- default:
- LOG_ALWAYS_FATAL("Unsupported pre transform of swapchain.");
- }
- return SkMatrix::I();
-}
-
-
-SkSurface* VulkanManager::getBackbufferSurface(VulkanSurface** surfaceOut) {
- // Recreate VulkanSurface, if ANativeWindow has been resized.
- VulkanSurface* surface = *surfaceOut;
- int windowWidth = 0, windowHeight = 0;
- ANativeWindow* window = surface->mNativeWindow;
- window->query(window, NATIVE_WINDOW_WIDTH, &windowWidth);
- window->query(window, NATIVE_WINDOW_HEIGHT, &windowHeight);
- if (windowWidth != surface->mWindowWidth || windowHeight != surface->mWindowHeight) {
- ColorMode colorMode = surface->mColorMode;
- sk_sp<SkColorSpace> colorSpace = surface->mColorSpace;
- SkColorType colorType = surface->mColorType;
- GrContext* grContext = surface->mGrContext;
- destroySurface(surface);
- *surfaceOut = createSurface(window, colorMode, colorSpace, colorType, grContext);
- surface = *surfaceOut;
- if (!surface) {
- return nullptr;
- }
+void VulkanManager::swapBuffers(VulkanSurface* surface, const SkRect& dirtyRect) {
+ if (CC_UNLIKELY(Properties::waitForGpuCompletion)) {
+ ATRACE_NAME("Finishing GPU work");
+ mDeviceWaitIdle(mDevice);
}
- VulkanSurface::BackbufferInfo* backbuffer = getAvailableBackbuffer(surface);
- SkASSERT(backbuffer);
+ VkExportSemaphoreCreateInfo exportInfo;
+ exportInfo.sType = VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO;
+ exportInfo.pNext = nullptr;
+ exportInfo.handleTypes = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
- VkResult res;
+ VkSemaphoreCreateInfo semaphoreInfo;
+ semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
+ semaphoreInfo.pNext = &exportInfo;
+ semaphoreInfo.flags = 0;
+ VkSemaphore semaphore;
+ VkResult err = mCreateSemaphore(mDevice, &semaphoreInfo, nullptr, &semaphore);
+ ALOGE_IF(VK_SUCCESS != err, "VulkanManager::swapBuffers(): Failed to create semaphore");
- res = mResetFences(mDevice, 2, backbuffer->mUsageFences);
- SkASSERT(VK_SUCCESS == res);
+ GrBackendSemaphore backendSemaphore;
+ backendSemaphore.initVulkan(semaphore);
- // The acquire will signal the attached mAcquireSemaphore. We use this to know the image has
- // finished presenting and that it is safe to begin sending new commands to the returned image.
- res = mAcquireNextImageKHR(mDevice, surface->mSwapchain, UINT64_MAX,
- backbuffer->mAcquireSemaphore, VK_NULL_HANDLE,
- &backbuffer->mImageIndex);
+ VulkanSurface::NativeBufferInfo* bufferInfo = surface->getCurrentBufferInfo();
- if (VK_ERROR_SURFACE_LOST_KHR == res) {
- // need to figure out how to create a new vkSurface without the platformData*
- // maybe use attach somehow? but need a Window
- return nullptr;
- }
- if (VK_ERROR_OUT_OF_DATE_KHR == res || VK_SUBOPTIMAL_KHR == res) {
- // tear swapchain down and try again
- if (!createSwapchain(surface)) {
- return nullptr;
- }
- backbuffer = getAvailableBackbuffer(surface);
- res = mResetFences(mDevice, 2, backbuffer->mUsageFences);
- SkASSERT(VK_SUCCESS == res);
+ int fenceFd = -1;
+ GrSemaphoresSubmitted submitted =
+ bufferInfo->skSurface->flush(SkSurface::BackendSurfaceAccess::kPresent,
+ SkSurface::kNone_FlushFlags, 1, &backendSemaphore);
+ if (submitted == GrSemaphoresSubmitted::kYes) {
+ VkSemaphoreGetFdInfoKHR getFdInfo;
+ getFdInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR;
+ getFdInfo.pNext = nullptr;
+ getFdInfo.semaphore = semaphore;
+ getFdInfo.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
- // acquire the image
- res = mAcquireNextImageKHR(mDevice, surface->mSwapchain, UINT64_MAX,
- backbuffer->mAcquireSemaphore, VK_NULL_HANDLE,
- &backbuffer->mImageIndex);
-
- if (VK_SUCCESS != res) {
- return nullptr;
- }
+ err = mGetSemaphoreFdKHR(mDevice, &getFdInfo, &fenceFd);
+ ALOGE_IF(VK_SUCCESS != err, "VulkanManager::swapBuffers(): Failed to get semaphore Fd");
+ } else {
+ ALOGE("VulkanManager::swapBuffers(): Semaphore submission failed");
+ mQueueWaitIdle(mGraphicsQueue);
}
- // set up layout transfer from initial to color attachment
- VkImageLayout layout = surface->mImageInfos[backbuffer->mImageIndex].mImageLayout;
- SkASSERT(VK_IMAGE_LAYOUT_UNDEFINED == layout || VK_IMAGE_LAYOUT_PRESENT_SRC_KHR == layout);
- VkPipelineStageFlags srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkAccessFlags srcAccessMask = 0;
- VkAccessFlags dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
- VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
+ surface->presentCurrentBuffer(dirtyRect, fenceFd);
- VkImageMemoryBarrier imageMemoryBarrier = {
- VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
- NULL, // pNext
- srcAccessMask, // outputMask
- dstAccessMask, // inputMask
- layout, // oldLayout
- VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // newLayout
- mPresentQueueIndex, // srcQueueFamilyIndex
- mGraphicsQueueIndex, // dstQueueFamilyIndex
- surface->mImages[backbuffer->mImageIndex], // image
- {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1} // subresourceRange
- };
- mResetCommandBuffer(backbuffer->mTransitionCmdBuffers[0], 0);
-
- VkCommandBufferBeginInfo info;
- memset(&info, 0, sizeof(VkCommandBufferBeginInfo));
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags = 0;
- mBeginCommandBuffer(backbuffer->mTransitionCmdBuffers[0], &info);
-
- mCmdPipelineBarrier(backbuffer->mTransitionCmdBuffers[0], srcStageMask, dstStageMask, 0, 0,
- nullptr, 0, nullptr, 1, &imageMemoryBarrier);
-
- mEndCommandBuffer(backbuffer->mTransitionCmdBuffers[0]);
-
- VkPipelineStageFlags waitDstStageFlags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- // insert the layout transfer into the queue and wait on the acquire
- VkSubmitInfo submitInfo;
- memset(&submitInfo, 0, sizeof(VkSubmitInfo));
- submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- submitInfo.waitSemaphoreCount = 1;
- // Wait to make sure aquire semaphore set above has signaled.
- submitInfo.pWaitSemaphores = &backbuffer->mAcquireSemaphore;
- submitInfo.pWaitDstStageMask = &waitDstStageFlags;
- submitInfo.commandBufferCount = 1;
- submitInfo.pCommandBuffers = &backbuffer->mTransitionCmdBuffers[0];
- submitInfo.signalSemaphoreCount = 0;
-
- // Attach first fence to submission here so we can track when the command buffer finishes.
- mQueueSubmit(mGraphicsQueue, 1, &submitInfo, backbuffer->mUsageFences[0]);
-
- // We need to notify Skia that we changed the layout of the wrapped VkImage
- sk_sp<SkSurface> skSurface = surface->mImageInfos[backbuffer->mImageIndex].mSurface;
- GrBackendRenderTarget backendRT = skSurface->getBackendRenderTarget(
- SkSurface::kFlushRead_BackendHandleAccess);
- if (!backendRT.isValid()) {
- SkASSERT(backendRT.isValid());
- return nullptr;
- }
- backendRT.setVkImageLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
-
- surface->mPreTransform = getPreTransformMatrix(surface->windowWidth(),
- surface->windowHeight(),
- surface->mTransform);
-
- surface->mBackbuffer = std::move(skSurface);
- return surface->mBackbuffer.get();
-}
-
-void VulkanManager::destroyBuffers(VulkanSurface* surface) {
- if (surface->mBackbuffers) {
- for (uint32_t i = 0; i < surface->mImageCount + 1; ++i) {
- mWaitForFences(mDevice, 2, surface->mBackbuffers[i].mUsageFences, true, UINT64_MAX);
- surface->mBackbuffers[i].mImageIndex = -1;
- mDestroySemaphore(mDevice, surface->mBackbuffers[i].mAcquireSemaphore, nullptr);
- mDestroySemaphore(mDevice, surface->mBackbuffers[i].mRenderSemaphore, nullptr);
- mFreeCommandBuffers(mDevice, mCommandPool, 2,
- surface->mBackbuffers[i].mTransitionCmdBuffers);
- mDestroyFence(mDevice, surface->mBackbuffers[i].mUsageFences[0], 0);
- mDestroyFence(mDevice, surface->mBackbuffers[i].mUsageFences[1], 0);
- }
- }
-
- delete[] surface->mBackbuffers;
- surface->mBackbuffers = nullptr;
- delete[] surface->mImageInfos;
- surface->mImageInfos = nullptr;
- delete[] surface->mImages;
- surface->mImages = nullptr;
+ // Exporting a semaphore with copy transference via vkGetSemaphoreFdKHR, has the same effect of
+ // destroying the semaphore and creating a new one with the same handle, and the payloads
+ // ownership is move to the Fd we created. Thus the semaphore is in a state that we can delete
+ // it and we don't need to wait on the command buffer we submitted to finish.
+ mDestroySemaphore(mDevice, semaphore, nullptr);
}
void VulkanManager::destroySurface(VulkanSurface* surface) {
@@ -630,271 +529,9 @@
}
mDeviceWaitIdle(mDevice);
- destroyBuffers(surface);
-
- if (VK_NULL_HANDLE != surface->mSwapchain) {
- mDestroySwapchainKHR(mDevice, surface->mSwapchain, nullptr);
- surface->mSwapchain = VK_NULL_HANDLE;
- }
-
- if (VK_NULL_HANDLE != surface->mVkSurface) {
- mDestroySurfaceKHR(mInstance, surface->mVkSurface, nullptr);
- surface->mVkSurface = VK_NULL_HANDLE;
- }
delete surface;
}
-void VulkanManager::createBuffers(VulkanSurface* surface, VkFormat format, VkExtent2D extent) {
- mGetSwapchainImagesKHR(mDevice, surface->mSwapchain, &surface->mImageCount, nullptr);
- SkASSERT(surface->mImageCount);
- surface->mImages = new VkImage[surface->mImageCount];
- mGetSwapchainImagesKHR(mDevice, surface->mSwapchain, &surface->mImageCount, surface->mImages);
-
- SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
-
- // set up initial image layouts and create surfaces
- surface->mImageInfos = new VulkanSurface::ImageInfo[surface->mImageCount];
- for (uint32_t i = 0; i < surface->mImageCount; ++i) {
- GrVkImageInfo info;
- info.fImage = surface->mImages[i];
- info.fAlloc = GrVkAlloc();
- info.fImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
- info.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
- info.fFormat = format;
- info.fLevelCount = 1;
-
- GrBackendRenderTarget backendRT(extent.width, extent.height, 0, 0, info);
-
- VulkanSurface::ImageInfo& imageInfo = surface->mImageInfos[i];
- imageInfo.mSurface = SkSurface::MakeFromBackendRenderTarget(
- surface->mGrContext, backendRT, kTopLeft_GrSurfaceOrigin,
- surface->mColorType, surface->mColorSpace, &props);
- }
-
- SkASSERT(mCommandPool != VK_NULL_HANDLE);
-
- // set up the backbuffers
- VkSemaphoreCreateInfo semaphoreInfo;
- memset(&semaphoreInfo, 0, sizeof(VkSemaphoreCreateInfo));
- semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
- semaphoreInfo.pNext = nullptr;
- semaphoreInfo.flags = 0;
- VkCommandBufferAllocateInfo commandBuffersInfo;
- memset(&commandBuffersInfo, 0, sizeof(VkCommandBufferAllocateInfo));
- commandBuffersInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
- commandBuffersInfo.pNext = nullptr;
- commandBuffersInfo.commandPool = mCommandPool;
- commandBuffersInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
- commandBuffersInfo.commandBufferCount = 2;
- VkFenceCreateInfo fenceInfo;
- memset(&fenceInfo, 0, sizeof(VkFenceCreateInfo));
- fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
- fenceInfo.pNext = nullptr;
- fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;
-
- // we create one additional backbuffer structure here, because we want to
- // give the command buffers they contain a chance to finish before we cycle back
- surface->mBackbuffers = new VulkanSurface::BackbufferInfo[surface->mImageCount + 1];
- for (uint32_t i = 0; i < surface->mImageCount + 1; ++i) {
- SkDEBUGCODE(VkResult res);
- surface->mBackbuffers[i].mImageIndex = -1;
- SkDEBUGCODE(res =) mCreateSemaphore(mDevice, &semaphoreInfo, nullptr,
- &surface->mBackbuffers[i].mAcquireSemaphore);
- SkDEBUGCODE(res =) mCreateSemaphore(mDevice, &semaphoreInfo, nullptr,
- &surface->mBackbuffers[i].mRenderSemaphore);
- SkDEBUGCODE(res =) mAllocateCommandBuffers(mDevice, &commandBuffersInfo,
- surface->mBackbuffers[i].mTransitionCmdBuffers);
- SkDEBUGCODE(res =) mCreateFence(mDevice, &fenceInfo, nullptr,
- &surface->mBackbuffers[i].mUsageFences[0]);
- SkDEBUGCODE(res =) mCreateFence(mDevice, &fenceInfo, nullptr,
- &surface->mBackbuffers[i].mUsageFences[1]);
- SkASSERT(VK_SUCCESS == res);
- }
- surface->mCurrentBackbufferIndex = surface->mImageCount;
-}
-
-bool VulkanManager::createSwapchain(VulkanSurface* surface) {
- // check for capabilities
- VkSurfaceCapabilitiesKHR caps;
- VkResult res = mGetPhysicalDeviceSurfaceCapabilitiesKHR(mPhysicalDevice,
- surface->mVkSurface, &caps);
- if (VK_SUCCESS != res) {
- return false;
- }
-
- uint32_t surfaceFormatCount;
- res = mGetPhysicalDeviceSurfaceFormatsKHR(mPhysicalDevice, surface->mVkSurface,
- &surfaceFormatCount, nullptr);
- if (VK_SUCCESS != res) {
- return false;
- }
-
- FatVector<VkSurfaceFormatKHR, 4> surfaceFormats(surfaceFormatCount);
- res = mGetPhysicalDeviceSurfaceFormatsKHR(mPhysicalDevice, surface->mVkSurface,
- &surfaceFormatCount, surfaceFormats.data());
- if (VK_SUCCESS != res) {
- return false;
- }
-
- uint32_t presentModeCount;
- res = mGetPhysicalDeviceSurfacePresentModesKHR(mPhysicalDevice,
- surface->mVkSurface, &presentModeCount, nullptr);
- if (VK_SUCCESS != res) {
- return false;
- }
-
- FatVector<VkPresentModeKHR, VK_PRESENT_MODE_RANGE_SIZE_KHR> presentModes(presentModeCount);
- res = mGetPhysicalDeviceSurfacePresentModesKHR(mPhysicalDevice,
- surface->mVkSurface, &presentModeCount,
- presentModes.data());
- if (VK_SUCCESS != res) {
- return false;
- }
-
- if (!SkToBool(caps.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR)) {
- return false;
- }
- VkSurfaceTransformFlagBitsKHR transform;
- if (SkToBool(caps.supportedTransforms & caps.currentTransform) &&
- !SkToBool(caps.currentTransform & VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR)) {
- transform = caps.currentTransform;
- } else {
- transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
- }
-
- VkExtent2D extent = caps.currentExtent;
- // clamp width; to handle currentExtent of -1 and protect us from broken hints
- if (extent.width < caps.minImageExtent.width) {
- extent.width = caps.minImageExtent.width;
- }
- SkASSERT(extent.width <= caps.maxImageExtent.width);
- // clamp height
- if (extent.height < caps.minImageExtent.height) {
- extent.height = caps.minImageExtent.height;
- }
- SkASSERT(extent.height <= caps.maxImageExtent.height);
-
- VkExtent2D swapExtent = extent;
- if (transform == VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR ||
- transform == VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR ||
- transform == VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR ||
- transform == VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR) {
- swapExtent.width = extent.height;
- swapExtent.height = extent.width;
- }
-
- surface->mWindowWidth = extent.width;
- surface->mWindowHeight = extent.height;
-
- uint32_t imageCount = std::max<uint32_t>(3, caps.minImageCount);
- if (caps.maxImageCount > 0 && imageCount > caps.maxImageCount) {
- // Application must settle for fewer images than desired:
- imageCount = caps.maxImageCount;
- }
-
- // Currently Skia requires the images to be color attchments and support all transfer
- // operations.
- VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
- VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
- VK_IMAGE_USAGE_TRANSFER_DST_BIT;
- SkASSERT((caps.supportedUsageFlags & usageFlags) == usageFlags);
-
- SkASSERT(caps.supportedCompositeAlpha &
- (VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR | VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR));
- VkCompositeAlphaFlagBitsKHR composite_alpha =
- (caps.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR)
- ? VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR
- : VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
-
- VkFormat surfaceFormat = VK_FORMAT_R8G8B8A8_UNORM;
- VkColorSpaceKHR colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
- if (surface->mColorType == SkColorType::kRGBA_F16_SkColorType) {
- surfaceFormat = VK_FORMAT_R16G16B16A16_SFLOAT;
- }
-
- if (surface->mColorMode == ColorMode::WideColorGamut) {
- skcms_Matrix3x3 surfaceGamut;
- LOG_ALWAYS_FATAL_IF(!surface->mColorSpace->toXYZD50(&surfaceGamut),
- "Could not get gamut matrix from color space");
- if (memcmp(&surfaceGamut, &SkNamedGamut::kSRGB, sizeof(surfaceGamut)) == 0) {
- colorSpace = VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT;
- } else if (memcmp(&surfaceGamut, &SkNamedGamut::kDCIP3, sizeof(surfaceGamut)) == 0) {
- colorSpace = VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT;
- } else {
- LOG_ALWAYS_FATAL("Unreachable: unsupported wide color space.");
- }
- }
-
- bool foundSurfaceFormat = false;
- for (uint32_t i = 0; i < surfaceFormatCount; ++i) {
- if (surfaceFormat == surfaceFormats[i].format
- && colorSpace == surfaceFormats[i].colorSpace) {
- foundSurfaceFormat = true;
- break;
- }
- }
-
- if (!foundSurfaceFormat) {
- return false;
- }
-
- // FIFO is always available and will match what we do on GL so just pick that here.
- VkPresentModeKHR mode = VK_PRESENT_MODE_FIFO_KHR;
-
- VkSwapchainCreateInfoKHR swapchainCreateInfo;
- memset(&swapchainCreateInfo, 0, sizeof(VkSwapchainCreateInfoKHR));
- swapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
- swapchainCreateInfo.surface = surface->mVkSurface;
- swapchainCreateInfo.minImageCount = imageCount;
- swapchainCreateInfo.imageFormat = surfaceFormat;
- swapchainCreateInfo.imageColorSpace = colorSpace;
- swapchainCreateInfo.imageExtent = swapExtent;
- swapchainCreateInfo.imageArrayLayers = 1;
- swapchainCreateInfo.imageUsage = usageFlags;
-
- uint32_t queueFamilies[] = {mGraphicsQueueIndex, mPresentQueueIndex};
- if (mGraphicsQueueIndex != mPresentQueueIndex) {
- swapchainCreateInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
- swapchainCreateInfo.queueFamilyIndexCount = 2;
- swapchainCreateInfo.pQueueFamilyIndices = queueFamilies;
- } else {
- swapchainCreateInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
- swapchainCreateInfo.queueFamilyIndexCount = 0;
- swapchainCreateInfo.pQueueFamilyIndices = nullptr;
- }
-
- swapchainCreateInfo.preTransform = transform;
- swapchainCreateInfo.compositeAlpha = composite_alpha;
- swapchainCreateInfo.presentMode = mode;
- swapchainCreateInfo.clipped = true;
- swapchainCreateInfo.oldSwapchain = surface->mSwapchain;
-
- res = mCreateSwapchainKHR(mDevice, &swapchainCreateInfo, nullptr, &surface->mSwapchain);
- if (VK_SUCCESS != res) {
- return false;
- }
-
- surface->mTransform = transform;
-
- // destroy the old swapchain
- if (swapchainCreateInfo.oldSwapchain != VK_NULL_HANDLE) {
- mDeviceWaitIdle(mDevice);
-
- destroyBuffers(surface);
-
- mDestroySwapchainKHR(mDevice, swapchainCreateInfo.oldSwapchain, nullptr);
- }
-
- createBuffers(surface, surfaceFormat, swapExtent);
-
- // The window content is not updated (frozen) until a buffer of the window size is received.
- // This prevents temporary stretching of the window after it is resized, but before the first
- // buffer with new size is enqueued.
- native_window_set_scaling_mode(surface->mNativeWindow, NATIVE_WINDOW_SCALING_MODE_FREEZE);
-
- return true;
-}
-
VulkanSurface* VulkanManager::createSurface(ANativeWindow* window, ColorMode colorMode,
sk_sp<SkColorSpace> surfaceColorSpace,
SkColorType surfaceColorType,
@@ -904,185 +541,8 @@
return nullptr;
}
- VulkanSurface* surface = new VulkanSurface(colorMode, window, surfaceColorSpace,
- surfaceColorType, grContext);
-
- VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo;
- memset(&surfaceCreateInfo, 0, sizeof(VkAndroidSurfaceCreateInfoKHR));
- surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
- surfaceCreateInfo.pNext = nullptr;
- surfaceCreateInfo.flags = 0;
- surfaceCreateInfo.window = window;
-
- VkResult res = mCreateAndroidSurfaceKHR(mInstance, &surfaceCreateInfo, nullptr,
- &surface->mVkSurface);
- if (VK_SUCCESS != res) {
- delete surface;
- return nullptr;
- }
-
- SkDEBUGCODE(VkBool32 supported; res = mGetPhysicalDeviceSurfaceSupportKHR(
- mPhysicalDevice, mPresentQueueIndex, surface->mVkSurface, &supported);
- // All physical devices and queue families on Android must be capable of
- // presentation with any native window.
- SkASSERT(VK_SUCCESS == res && supported););
-
- if (!createSwapchain(surface)) {
- destroySurface(surface);
- return nullptr;
- }
-
- return surface;
-}
-
-// Helper to know which src stage flags we need to set when transitioning to the present layout
-static VkPipelineStageFlags layoutToPipelineSrcStageFlags(const VkImageLayout layout) {
- if (VK_IMAGE_LAYOUT_GENERAL == layout) {
- return VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
- } else if (VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL == layout ||
- VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL == layout) {
- return VK_PIPELINE_STAGE_TRANSFER_BIT;
- } else if (VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL == layout) {
- return VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- } else if (VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL == layout ||
- VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL == layout) {
- return VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
- } else if (VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL == layout) {
- return VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
- } else if (VK_IMAGE_LAYOUT_PREINITIALIZED == layout) {
- return VK_PIPELINE_STAGE_HOST_BIT;
- }
-
- SkASSERT(VK_IMAGE_LAYOUT_UNDEFINED == layout);
- return VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
-}
-
-// Helper to know which src access mask we need to set when transitioning to the present layout
-static VkAccessFlags layoutToSrcAccessMask(const VkImageLayout layout) {
- VkAccessFlags flags = 0;
- if (VK_IMAGE_LAYOUT_GENERAL == layout) {
- flags = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT |
- VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_HOST_WRITE_BIT |
- VK_ACCESS_HOST_READ_BIT;
- } else if (VK_IMAGE_LAYOUT_PREINITIALIZED == layout) {
- flags = VK_ACCESS_HOST_WRITE_BIT;
- } else if (VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL == layout) {
- flags = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
- } else if (VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL == layout) {
- flags = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
- } else if (VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL == layout) {
- flags = VK_ACCESS_TRANSFER_WRITE_BIT;
- } else if (VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL == layout) {
- flags = VK_ACCESS_TRANSFER_READ_BIT;
- } else if (VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL == layout) {
- flags = VK_ACCESS_SHADER_READ_BIT;
- }
- return flags;
-}
-
-void VulkanManager::swapBuffers(VulkanSurface* surface) {
- if (CC_UNLIKELY(Properties::waitForGpuCompletion)) {
- ATRACE_NAME("Finishing GPU work");
- mDeviceWaitIdle(mDevice);
- }
-
- SkASSERT(surface->mBackbuffers);
- VulkanSurface::BackbufferInfo* backbuffer =
- surface->mBackbuffers + surface->mCurrentBackbufferIndex;
-
- SkSurface* skSurface = surface->mImageInfos[backbuffer->mImageIndex].mSurface.get();
- GrBackendRenderTarget backendRT = skSurface->getBackendRenderTarget(
- SkSurface::kFlushRead_BackendHandleAccess);
- SkASSERT(backendRT.isValid());
-
- GrVkImageInfo imageInfo;
- SkAssertResult(backendRT.getVkImageInfo(&imageInfo));
-
- // Check to make sure we never change the actually wrapped image
- SkASSERT(imageInfo.fImage == surface->mImages[backbuffer->mImageIndex]);
-
- // We need to transition the image to VK_IMAGE_LAYOUT_PRESENT_SRC_KHR and make sure that all
- // previous work is complete for before presenting. So we first add the necessary barrier here.
- VkImageLayout layout = imageInfo.fImageLayout;
- VkPipelineStageFlags srcStageMask = layoutToPipelineSrcStageFlags(layout);
- VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
- VkAccessFlags srcAccessMask = layoutToSrcAccessMask(layout);
- VkAccessFlags dstAccessMask = 0;
-
- VkImageMemoryBarrier imageMemoryBarrier = {
- VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
- NULL, // pNext
- srcAccessMask, // outputMask
- dstAccessMask, // inputMask
- layout, // oldLayout
- VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, // newLayout
- mGraphicsQueueIndex, // srcQueueFamilyIndex
- mPresentQueueIndex, // dstQueueFamilyIndex
- surface->mImages[backbuffer->mImageIndex], // image
- {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1} // subresourceRange
- };
-
- mResetCommandBuffer(backbuffer->mTransitionCmdBuffers[1], 0);
- VkCommandBufferBeginInfo info;
- memset(&info, 0, sizeof(VkCommandBufferBeginInfo));
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags = 0;
- mBeginCommandBuffer(backbuffer->mTransitionCmdBuffers[1], &info);
- mCmdPipelineBarrier(backbuffer->mTransitionCmdBuffers[1], srcStageMask, dstStageMask, 0, 0,
- nullptr, 0, nullptr, 1, &imageMemoryBarrier);
- mEndCommandBuffer(backbuffer->mTransitionCmdBuffers[1]);
-
- surface->mImageInfos[backbuffer->mImageIndex].mImageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
-
- // insert the layout transfer into the queue and wait on the acquire
- VkSubmitInfo submitInfo;
- memset(&submitInfo, 0, sizeof(VkSubmitInfo));
- submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- submitInfo.waitSemaphoreCount = 0;
- submitInfo.pWaitDstStageMask = 0;
- submitInfo.commandBufferCount = 1;
- submitInfo.pCommandBuffers = &backbuffer->mTransitionCmdBuffers[1];
- submitInfo.signalSemaphoreCount = 1;
- // When this command buffer finishes we will signal this semaphore so that we know it is now
- // safe to present the image to the screen.
- submitInfo.pSignalSemaphores = &backbuffer->mRenderSemaphore;
-
- // Attach second fence to submission here so we can track when the command buffer finishes.
- mQueueSubmit(mGraphicsQueue, 1, &submitInfo, backbuffer->mUsageFences[1]);
-
- // Submit present operation to present queue. We use a semaphore here to make sure all rendering
- // to the image is complete and that the layout has been change to present on the graphics
- // queue.
- const VkPresentInfoKHR presentInfo = {
- VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, // sType
- NULL, // pNext
- 1, // waitSemaphoreCount
- &backbuffer->mRenderSemaphore, // pWaitSemaphores
- 1, // swapchainCount
- &surface->mSwapchain, // pSwapchains
- &backbuffer->mImageIndex, // pImageIndices
- NULL // pResults
- };
-
- mQueuePresentKHR(mPresentQueue, &presentInfo);
-
- surface->mBackbuffer.reset();
- surface->mImageInfos[backbuffer->mImageIndex].mLastUsed = surface->mCurrentTime;
- surface->mImageInfos[backbuffer->mImageIndex].mInvalid = false;
- surface->mCurrentTime++;
-}
-
-int VulkanManager::getAge(VulkanSurface* surface) {
- SkASSERT(surface->mBackbuffers);
- VulkanSurface::BackbufferInfo* backbuffer =
- surface->mBackbuffers + surface->mCurrentBackbufferIndex;
- if (mSwapBehavior == SwapBehavior::Discard ||
- surface->mImageInfos[backbuffer->mImageIndex].mInvalid) {
- return 0;
- }
- uint16_t lastUsed = surface->mImageInfos[backbuffer->mImageIndex].mLastUsed;
- return surface->mCurrentTime - lastUsed;
+ return VulkanSurface::Create(window, colorMode, surfaceColorType, surfaceColorSpace, grContext,
+ *this);
}
bool VulkanManager::setupDummyCommandBuffer() {
diff --git a/libs/hwui/renderthread/VulkanManager.h b/libs/hwui/renderthread/VulkanManager.h
index 95c9630..c3d2891 100644
--- a/libs/hwui/renderthread/VulkanManager.h
+++ b/libs/hwui/renderthread/VulkanManager.h
@@ -28,7 +28,9 @@
#include <ui/Fence.h>
#include <utils/StrongPointer.h>
#include <vk/GrVkBackendContext.h>
+#include "Frame.h"
#include "IRenderPipeline.h"
+#include "VulkanSurface.h"
class GrVkExtensions;
@@ -38,66 +40,6 @@
class RenderThread;
-class VulkanSurface {
-public:
- VulkanSurface(ColorMode colorMode, ANativeWindow* window, sk_sp<SkColorSpace> colorSpace,
- SkColorType colorType, GrContext* grContext)
- : mColorMode(colorMode), mNativeWindow(window), mColorSpace(colorSpace),
- mColorType(colorType), mGrContext(grContext) {}
-
- sk_sp<SkSurface> getBackBufferSurface() { return mBackbuffer; }
-
- // The width and height are are the logical width and height for when submitting draws to the
- // surface. In reality if the window is rotated the underlying VkImage may have the width and
- // height swapped.
- int windowWidth() const { return mWindowWidth; }
- int windowHeight() const { return mWindowHeight; }
-
- SkMatrix& preTransform() { return mPreTransform; }
-
-private:
- friend class VulkanManager;
- struct BackbufferInfo {
- uint32_t mImageIndex; // image this is associated with
- VkSemaphore mAcquireSemaphore; // we signal on this for acquisition of image
- VkSemaphore mRenderSemaphore; // we wait on this for rendering to be done
- VkCommandBuffer
- mTransitionCmdBuffers[2]; // to transition layout between present and render
- // We use these fences to make sure the above Command buffers have finished their work
- // before attempting to reuse them or destroy them.
- VkFence mUsageFences[2];
- };
-
- struct ImageInfo {
- VkImageLayout mImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
- sk_sp<SkSurface> mSurface;
- uint16_t mLastUsed = 0;
- bool mInvalid = true;
- };
-
- sk_sp<SkSurface> mBackbuffer;
-
- VkSurfaceKHR mVkSurface = VK_NULL_HANDLE;
- VkSwapchainKHR mSwapchain = VK_NULL_HANDLE;
-
- BackbufferInfo* mBackbuffers = nullptr;
- uint32_t mCurrentBackbufferIndex;
-
- uint32_t mImageCount;
- VkImage* mImages = nullptr;
- ImageInfo* mImageInfos;
- uint16_t mCurrentTime = 0;
- ColorMode mColorMode;
- ANativeWindow* mNativeWindow;
- int mWindowWidth = 0;
- int mWindowHeight = 0;
- sk_sp<SkColorSpace> mColorSpace;
- SkColorType mColorType;
- VkSurfaceTransformFlagBitsKHR mTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
- SkMatrix mPreTransform;
- GrContext* mGrContext;
-};
-
// This class contains the shared global Vulkan objects, such as VkInstance, VkDevice and VkQueue,
// which are re-used by CanvasContext. This class is created once and should be used by all vulkan
// windowing contexts. The VulkanManager must be initialized before use.
@@ -114,33 +56,19 @@
// Quick check to see if the VulkanManager has been initialized.
bool hasVkContext() { return mDevice != VK_NULL_HANDLE; }
- // Given a window this creates a new VkSurfaceKHR and VkSwapchain and stores them inside a new
- // VulkanSurface object which is returned.
+ // Create and destroy functions for wrapping an ANativeWindow in a VulkanSurface
VulkanSurface* createSurface(ANativeWindow* window, ColorMode colorMode,
sk_sp<SkColorSpace> surfaceColorSpace,
SkColorType surfaceColorType,
GrContext* grContext);
-
- // Destroy the VulkanSurface and all associated vulkan objects.
void destroySurface(VulkanSurface* surface);
+ Frame dequeueNextBuffer(VulkanSurface* surface);
+ void swapBuffers(VulkanSurface* surface, const SkRect& dirtyRect);
+
// Cleans up all the global state in the VulkanManger.
void destroy();
- // No work is needed to make a VulkanSurface current, and all functions require that a
- // VulkanSurface is passed into them so we just return true here.
- bool isCurrent(VulkanSurface* surface) { return true; }
-
- int getAge(VulkanSurface* surface);
-
- // Returns an SkSurface which wraps the next image returned from vkAcquireNextImageKHR. It also
- // will transition the VkImage from a present layout to color attachment so that it can be used
- // by the client for drawing.
- SkSurface* getBackbufferSurface(VulkanSurface** surface);
-
- // Presents the current VkImage.
- void swapBuffers(VulkanSurface* surface);
-
// Inserts a wait on fence command into the Vulkan command buffer.
status_t fenceWait(sp<Fence>& fence);
@@ -153,17 +81,10 @@
sk_sp<GrContext> createContext(const GrContextOptions& options);
private:
+ friend class VulkanSurface;
// Sets up the VkInstance and VkDevice objects. Also fills out the passed in
// VkPhysicalDeviceFeatures struct.
void setupDevice(GrVkExtensions&, VkPhysicalDeviceFeatures2&);
-
- void destroyBuffers(VulkanSurface* surface);
-
- bool createSwapchain(VulkanSurface* surface);
- void createBuffers(VulkanSurface* surface, VkFormat format, VkExtent2D extent);
-
- VulkanSurface::BackbufferInfo* getAvailableBackbuffer(VulkanSurface* surface);
-
bool setupDummyCommandBuffer();
// simple wrapper class that exists only to initialize a pointer to NULL
@@ -190,13 +111,6 @@
VkPtr<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR> mGetPhysicalDeviceSurfaceFormatsKHR;
VkPtr<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR> mGetPhysicalDeviceSurfacePresentModesKHR;
- VkPtr<PFN_vkCreateSwapchainKHR> mCreateSwapchainKHR;
- VkPtr<PFN_vkDestroySwapchainKHR> mDestroySwapchainKHR;
- VkPtr<PFN_vkGetSwapchainImagesKHR> mGetSwapchainImagesKHR;
- VkPtr<PFN_vkAcquireNextImageKHR> mAcquireNextImageKHR;
- VkPtr<PFN_vkQueuePresentKHR> mQueuePresentKHR;
- VkPtr<PFN_vkCreateSharedSwapchainsKHR> mCreateSharedSwapchainsKHR;
-
// Instance Functions
VkPtr<PFN_vkEnumerateInstanceVersion> mEnumerateInstanceVersion;
VkPtr<PFN_vkEnumerateInstanceExtensionProperties> mEnumerateInstanceExtensionProperties;
@@ -207,6 +121,7 @@
VkPtr<PFN_vkGetPhysicalDeviceProperties> mGetPhysicalDeviceProperties;
VkPtr<PFN_vkGetPhysicalDeviceQueueFamilyProperties> mGetPhysicalDeviceQueueFamilyProperties;
VkPtr<PFN_vkGetPhysicalDeviceFeatures2> mGetPhysicalDeviceFeatures2;
+ VkPtr<PFN_vkGetPhysicalDeviceImageFormatProperties2> mGetPhysicalDeviceImageFormatProperties2;
VkPtr<PFN_vkCreateDevice> mCreateDevice;
VkPtr<PFN_vkEnumerateDeviceExtensionProperties> mEnumerateDeviceExtensionProperties;
diff --git a/libs/hwui/renderthread/VulkanSurface.cpp b/libs/hwui/renderthread/VulkanSurface.cpp
new file mode 100644
index 0000000..c03c3a8
--- /dev/null
+++ b/libs/hwui/renderthread/VulkanSurface.cpp
@@ -0,0 +1,536 @@
+/*
+ * 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.
+ */
+
+#include "VulkanSurface.h"
+
+#include <algorithm>
+#include <SkSurface.h>
+
+#include "VulkanManager.h"
+#include "utils/TraceUtils.h"
+#include "utils/Color.h"
+
+namespace android {
+namespace uirenderer {
+namespace renderthread {
+
+static bool IsTransformSupported(int transform) {
+ // For now, only support pure rotations, not flip or flip-and-rotate, until we have
+ // more time to test them and build sample code. As far as I know we never actually
+ // use anything besides pure rotations anyway.
+ return transform == 0
+ || transform == NATIVE_WINDOW_TRANSFORM_ROT_90
+ || transform == NATIVE_WINDOW_TRANSFORM_ROT_180
+ || transform == NATIVE_WINDOW_TRANSFORM_ROT_270;
+}
+
+static int InvertTransform(int transform) {
+ switch (transform) {
+ case NATIVE_WINDOW_TRANSFORM_ROT_90:
+ return NATIVE_WINDOW_TRANSFORM_ROT_270;
+ case NATIVE_WINDOW_TRANSFORM_ROT_180:
+ return NATIVE_WINDOW_TRANSFORM_ROT_180;
+ case NATIVE_WINDOW_TRANSFORM_ROT_270:
+ return NATIVE_WINDOW_TRANSFORM_ROT_90;
+ default:
+ return 0;
+ }
+}
+
+static int ConvertVkTransformToNative(VkSurfaceTransformFlagsKHR transform) {
+ switch (transform) {
+ case VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR:
+ return NATIVE_WINDOW_TRANSFORM_ROT_270;
+ case VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR:
+ return NATIVE_WINDOW_TRANSFORM_ROT_180;
+ case VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR:
+ return NATIVE_WINDOW_TRANSFORM_ROT_90;
+ case VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR:
+ case VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR:
+ default:
+ return 0;
+ }
+}
+
+static SkMatrix GetPreTransformMatrix(SkISize windowSize, int transform) {
+ const int width = windowSize.width();
+ const int height = windowSize.height();
+
+ switch (transform) {
+ case 0:
+ return SkMatrix::I();
+ case NATIVE_WINDOW_TRANSFORM_ROT_90:
+ return SkMatrix::MakeAll(0, -1, height, 1, 0, 0, 0, 0, 1);
+ case NATIVE_WINDOW_TRANSFORM_ROT_180:
+ return SkMatrix::MakeAll(-1, 0, width, 0, -1, height, 0, 0, 1);
+ case NATIVE_WINDOW_TRANSFORM_ROT_270:
+ return SkMatrix::MakeAll(0, 1, 0, -1, 0, width, 0, 0, 1);
+ default:
+ LOG_ALWAYS_FATAL("Unsupported Window Transform (%d)", transform);
+ }
+ return SkMatrix::I();
+}
+
+void VulkanSurface::ComputeWindowSizeAndTransform(WindowInfo* windowInfo, const SkISize& minSize,
+ const SkISize& maxSize) {
+ SkISize& windowSize = windowInfo->size;
+
+ // clamp width & height to handle currentExtent of -1 and protect us from broken hints
+ if (windowSize.width() < minSize.width() || windowSize.width() > maxSize.width()
+ || windowSize.height() < minSize.height() || windowSize.height() > maxSize.height()) {
+ int width = std::min(maxSize.width(), std::max(minSize.width(), windowSize.width()));
+ int height = std::min(maxSize.height(), std::max(minSize.height(), windowSize.height()));
+ ALOGE("Invalid Window Dimensions [%d, %d]; clamping to [%d, %d]",
+ windowSize.width(), windowSize.height(), width, height);
+ windowSize.set(width, height);
+ }
+
+ windowInfo->actualSize = windowSize;
+ if (windowInfo->transform & HAL_TRANSFORM_ROT_90) {
+ windowInfo->actualSize.set(windowSize.height(), windowSize.width());
+ }
+
+ windowInfo->preTransform = GetPreTransformMatrix(windowInfo->size, windowInfo->transform);
+}
+
+static bool ResetNativeWindow(ANativeWindow* window) {
+ // -- Reset the native window --
+ // The native window might have been used previously, and had its properties
+ // changed from defaults. That will affect the answer we get for queries
+ // like MIN_UNDEQUEUED_BUFFERS. Reset to a known/default state before we
+ // attempt such queries.
+
+ int err = native_window_api_connect(window, NATIVE_WINDOW_API_EGL);
+ if (err != 0) {
+ ALOGW("native_window_api_connect failed: %s (%d)", strerror(-err), err);
+ return false;
+ }
+
+ // this will match what we do on GL so pick that here.
+ err = window->setSwapInterval(window, 1);
+ if (err != 0) {
+ ALOGW("native_window->setSwapInterval(1) failed: %s (%d)", strerror(-err), err);
+ return false;
+ }
+
+ err = native_window_set_shared_buffer_mode(window, false);
+ if (err != 0) {
+ ALOGW("native_window_set_shared_buffer_mode(false) failed: %s (%d)", strerror(-err), err);
+ return false;
+ }
+
+ err = native_window_set_auto_refresh(window, false);
+ if (err != 0) {
+ ALOGW("native_window_set_auto_refresh(false) failed: %s (%d)", strerror(-err), err);
+ return false;
+ }
+
+ return true;
+}
+
+class VkSurfaceAutoDeleter {
+public:
+ VkSurfaceAutoDeleter(VkInstance instance, VkSurfaceKHR surface,
+ PFN_vkDestroySurfaceKHR destroySurfaceKHR)
+ : mInstance(instance)
+ , mSurface(surface)
+ , mDestroySurfaceKHR(destroySurfaceKHR) {}
+ ~VkSurfaceAutoDeleter() {
+ destroy();
+ }
+
+ void destroy() {
+ if (mSurface != VK_NULL_HANDLE) {
+ mDestroySurfaceKHR(mInstance, mSurface, nullptr);
+ mSurface = VK_NULL_HANDLE;
+ }
+ }
+
+private:
+ VkInstance mInstance;
+ VkSurfaceKHR mSurface;
+ PFN_vkDestroySurfaceKHR mDestroySurfaceKHR;
+};
+
+VulkanSurface* VulkanSurface::Create(ANativeWindow* window, ColorMode colorMode,
+ SkColorType colorType, sk_sp<SkColorSpace> colorSpace,
+ GrContext* grContext, const VulkanManager& vkManager) {
+
+ VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo;
+ memset(&surfaceCreateInfo, 0, sizeof(VkAndroidSurfaceCreateInfoKHR));
+ surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
+ surfaceCreateInfo.pNext = nullptr;
+ surfaceCreateInfo.flags = 0;
+ surfaceCreateInfo.window = window;
+
+ VkSurfaceKHR vkSurface = VK_NULL_HANDLE;
+ VkResult res = vkManager.mCreateAndroidSurfaceKHR(vkManager.mInstance, &surfaceCreateInfo,
+ nullptr, &vkSurface);
+ if (VK_SUCCESS != res) {
+ ALOGE("VulkanSurface::Create() vkCreateAndroidSurfaceKHR failed (%d)", res);
+ return nullptr;
+ }
+
+ VkSurfaceAutoDeleter vkSurfaceDeleter(vkManager.mInstance, vkSurface,
+ vkManager.mDestroySurfaceKHR);
+
+ SkDEBUGCODE(VkBool32 supported; res = vkManager.mGetPhysicalDeviceSurfaceSupportKHR(
+ vkManager.mPhysicalDevice, vkManager.mPresentQueueIndex, vkSurface, &supported);
+ // All physical devices and queue families on Android must be capable of
+ // presentation with any native window.
+ SkASSERT(VK_SUCCESS == res && supported););
+
+ // check for capabilities
+ VkSurfaceCapabilitiesKHR caps;
+ res = vkManager.mGetPhysicalDeviceSurfaceCapabilitiesKHR(vkManager.mPhysicalDevice, vkSurface,
+ &caps);
+ if (VK_SUCCESS != res) {
+ ALOGE("VulkanSurface::Create() vkGetPhysicalDeviceSurfaceCapabilitiesKHR failed (%d)", res);
+ return nullptr;
+ }
+
+ LOG_ALWAYS_FATAL_IF(0 == (caps.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR));
+
+ /*
+ * We must destroy the VK Surface before attempting to update the window as doing so after
+ * will cause the native window to be modified in unexpected ways.
+ */
+ vkSurfaceDeleter.destroy();
+
+ /*
+ * Populate Window Info struct
+ */
+ WindowInfo windowInfo;
+
+ windowInfo.transform = ConvertVkTransformToNative(caps.supportedTransforms);
+ windowInfo.size = SkISize::Make(caps.currentExtent.width, caps.currentExtent.height);
+
+ const SkISize minSize = SkISize::Make(caps.minImageExtent.width, caps.minImageExtent.height);
+ const SkISize maxSize = SkISize::Make(caps.maxImageExtent.width, caps.maxImageExtent.height);
+ ComputeWindowSizeAndTransform(&windowInfo, minSize, maxSize);
+
+ windowInfo.bufferCount = std::max<uint32_t>(VulkanSurface::sMaxBufferCount, caps.minImageCount);
+ if (caps.maxImageCount > 0 && windowInfo.bufferCount > caps.maxImageCount) {
+ // Application must settle for fewer images than desired:
+ windowInfo.bufferCount = caps.maxImageCount;
+ }
+
+ // Currently Skia requires the images to be color attachments and support all transfer
+ // operations.
+ VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
+ VK_IMAGE_USAGE_SAMPLED_BIT |
+ VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
+ VK_IMAGE_USAGE_TRANSFER_DST_BIT;
+ LOG_ALWAYS_FATAL_IF((caps.supportedUsageFlags & usageFlags) != usageFlags);
+
+ windowInfo.dataspace = HAL_DATASPACE_V0_SRGB;
+ if (colorMode == ColorMode::WideColorGamut) {
+ skcms_Matrix3x3 surfaceGamut;
+ LOG_ALWAYS_FATAL_IF(!colorSpace->toXYZD50(&surfaceGamut),
+ "Could not get gamut matrix from color space");
+ if (memcmp(&surfaceGamut, &SkNamedGamut::kSRGB, sizeof(surfaceGamut)) == 0) {
+ windowInfo.dataspace = HAL_DATASPACE_V0_SCRGB;
+ } else if (memcmp(&surfaceGamut, &SkNamedGamut::kDCIP3, sizeof(surfaceGamut)) == 0) {
+ windowInfo.dataspace = HAL_DATASPACE_DISPLAY_P3;
+ } else {
+ LOG_ALWAYS_FATAL("Unreachable: unsupported wide color space.");
+ }
+ }
+
+ windowInfo.pixelFormat = ColorTypeToPixelFormat(colorType);
+ VkFormat vkPixelFormat = VK_FORMAT_R8G8B8A8_UNORM;
+ if (windowInfo.pixelFormat == PIXEL_FORMAT_RGBA_FP16) {
+ vkPixelFormat = VK_FORMAT_R16G16B16A16_SFLOAT;
+ }
+
+ uint64_t producerUsage =
+ AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
+ uint64_t consumerUsage;
+ native_window_get_consumer_usage(window, &consumerUsage);
+ windowInfo.windowUsageFlags = consumerUsage | producerUsage;
+
+ /*
+ * Now we attempt to modify the window!
+ */
+ if (!UpdateWindow(window, windowInfo)) {
+ return nullptr;
+ }
+
+ return new VulkanSurface(window, windowInfo, minSize, maxSize, grContext);
+}
+
+bool VulkanSurface::UpdateWindow(ANativeWindow* window, const WindowInfo& windowInfo) {
+ ATRACE_CALL();
+
+ if (!ResetNativeWindow(window)) {
+ return false;
+ }
+
+ // -- Configure the native window --
+ int err = native_window_set_buffers_format(window, windowInfo.pixelFormat);
+ if (err != 0) {
+ ALOGE("VulkanSurface::UpdateWindow() native_window_set_buffers_format(%d) failed: %s (%d)",
+ windowInfo.pixelFormat, strerror(-err), err);
+ return false;
+ }
+
+ err = native_window_set_buffers_data_space(window, windowInfo.dataspace);
+ if (err != 0) {
+ ALOGE("VulkanSurface::UpdateWindow() native_window_set_buffers_data_space(%d) "
+ "failed: %s (%d)", windowInfo.dataspace, strerror(-err), err);
+ return false;
+ }
+
+ const SkISize& size = windowInfo.actualSize;
+ err = native_window_set_buffers_dimensions(window, size.width(), size.height());
+ if (err != 0) {
+ ALOGE("VulkanSurface::UpdateWindow() native_window_set_buffers_dimensions(%d,%d) "
+ "failed: %s (%d)", size.width(), size.height(), strerror(-err), err);
+ return false;
+ }
+
+ // native_window_set_buffers_transform() expects the transform the app is requesting that
+ // the compositor perform during composition. With native windows, pre-transform works by
+ // rendering with the same transform the compositor is applying (as in Vulkan), but
+ // then requesting the inverse transform, so that when the compositor does
+ // it's job the two transforms cancel each other out and the compositor ends
+ // up applying an identity transform to the app's buffer.
+ err = native_window_set_buffers_transform(window, InvertTransform(windowInfo.transform));
+ if (err != 0) {
+ ALOGE("VulkanSurface::UpdateWindow() native_window_set_buffers_transform(%d) "
+ "failed: %s (%d)", windowInfo.transform, strerror(-err), err);
+ return false;
+ }
+
+ // Vulkan defaults to NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW, but this is different than
+ // HWUI's expectation
+ err = native_window_set_scaling_mode(window, NATIVE_WINDOW_SCALING_MODE_FREEZE);
+ if (err != 0) {
+ ALOGE("VulkanSurface::UpdateWindow() native_window_set_scaling_mode(SCALE_TO_WINDOW) "
+ "failed: %s (%d)", strerror(-err), err);
+ return false;
+ }
+
+ // Lower layer insists that we have at least two buffers.
+ err = native_window_set_buffer_count(window, std::max(2, windowInfo.bufferCount));
+ if (err != 0) {
+ ALOGE("VulkanSurface::UpdateWindow() native_window_set_buffer_count(%d) failed: %s (%d)",
+ windowInfo.bufferCount, strerror(-err), err);
+ return false;
+ }
+
+ err = native_window_set_usage(window, windowInfo.windowUsageFlags);
+ if (err != 0) {
+ ALOGE("VulkanSurface::UpdateWindow() native_window_set_usage failed: %s (%d)",
+ strerror(-err), err);
+ return false;
+ }
+
+ return err == 0;
+}
+
+VulkanSurface::VulkanSurface(ANativeWindow* window, const WindowInfo& windowInfo,
+ SkISize minWindowSize, SkISize maxWindowSize, GrContext* grContext)
+ : mNativeWindow(window)
+ , mWindowInfo(windowInfo)
+ , mGrContext(grContext)
+ , mMinWindowSize(minWindowSize)
+ , mMaxWindowSize(maxWindowSize) { }
+
+VulkanSurface::~VulkanSurface() {
+ releaseBuffers();
+
+ // release the native window to be available for use by other clients
+ int err = native_window_api_disconnect(mNativeWindow.get(), NATIVE_WINDOW_API_EGL);
+ ALOGW_IF(err != 0, "native_window_api_disconnect failed: %s (%d)", strerror(-err), err);
+}
+
+void VulkanSurface::releaseBuffers() {
+ for (uint32_t i = 0; i < VulkanSurface::sMaxBufferCount; i++) {
+ VulkanSurface::NativeBufferInfo& bufferInfo = mNativeBuffers[i];
+
+ if (bufferInfo.buffer.get() != nullptr && bufferInfo.dequeued) {
+ int err = mNativeWindow->cancelBuffer(mNativeWindow.get(), bufferInfo.buffer.get(),
+ bufferInfo.dequeue_fence);
+ if (err != 0) {
+ ALOGE("cancelBuffer[%u] failed during destroy: %s (%d)", i, strerror(-err), err);
+ }
+ bufferInfo.dequeued = false;
+
+ if (bufferInfo.dequeue_fence >= 0) {
+ close(bufferInfo.dequeue_fence);
+ bufferInfo.dequeue_fence = -1;
+ }
+ }
+
+ LOG_ALWAYS_FATAL_IF(bufferInfo.dequeued);
+ LOG_ALWAYS_FATAL_IF(bufferInfo.dequeue_fence != -1);
+
+ bufferInfo.skSurface.reset();
+ bufferInfo.buffer.clear();
+ bufferInfo.hasValidContents = false;
+ bufferInfo.lastPresentedCount = 0;
+ }
+}
+
+VulkanSurface::NativeBufferInfo* VulkanSurface::dequeueNativeBuffer() {
+ // Set the dequeue index to invalid in case of error and only reset it to the correct
+ // value at the end of the function if everything dequeued correctly.
+ mDequeuedIndex = -1;
+
+ //check if the native window has been resized or rotated and update accordingly
+ SkISize newSize = SkISize::MakeEmpty();
+ int transformHint = 0;
+ mNativeWindow->query(mNativeWindow.get(), NATIVE_WINDOW_WIDTH, &newSize.fWidth);
+ mNativeWindow->query(mNativeWindow.get(), NATIVE_WINDOW_HEIGHT, &newSize.fHeight);
+ mNativeWindow->query(mNativeWindow.get(), NATIVE_WINDOW_TRANSFORM_HINT, &transformHint);
+ if (newSize != mWindowInfo.actualSize || transformHint != mWindowInfo.transform) {
+ WindowInfo newWindowInfo = mWindowInfo;
+ newWindowInfo.size = newSize;
+ newWindowInfo.transform = IsTransformSupported(transformHint) ? transformHint : 0;
+ ComputeWindowSizeAndTransform(&newWindowInfo, mMinWindowSize, mMaxWindowSize);
+
+ int err = 0;
+ if (newWindowInfo.actualSize != mWindowInfo.actualSize) {
+ // reset the native buffers and update the window
+ err = native_window_set_buffers_dimensions(mNativeWindow.get(),
+ newWindowInfo.actualSize.width(),
+ newWindowInfo.actualSize.height());
+ if (err != 0) {
+ ALOGE("native_window_set_buffers_dimensions(%d,%d) failed: %s (%d)",
+ newWindowInfo.actualSize.width(),
+ newWindowInfo.actualSize.height(), strerror(-err), err);
+ return nullptr;
+ }
+ // reset the NativeBufferInfo (including SkSurface) associated with the old buffers. The
+ // new NativeBufferInfo storage will be populated lazily as we dequeue each new buffer.
+ releaseBuffers();
+ // TODO should we ask the nativewindow to allocate buffers?
+ }
+
+ if (newWindowInfo.transform != mWindowInfo.transform) {
+ err = native_window_set_buffers_transform(mNativeWindow.get(),
+ InvertTransform(newWindowInfo.transform));
+ if (err != 0) {
+ ALOGE("native_window_set_buffers_transform(%d) failed: %s (%d)",
+ newWindowInfo.transform, strerror(-err), err);
+ newWindowInfo.transform = mWindowInfo.transform;
+ ComputeWindowSizeAndTransform(&newWindowInfo, mMinWindowSize, mMaxWindowSize);
+ }
+ }
+
+ mWindowInfo = newWindowInfo;
+ }
+
+ ANativeWindowBuffer* buffer;
+ int fence_fd;
+ int err = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buffer, &fence_fd);
+ if (err != 0) {
+ ALOGE("dequeueBuffer failed: %s (%d)", strerror(-err), err);
+ return nullptr;
+ }
+
+ uint32_t idx;
+ for (idx = 0; idx < mWindowInfo.bufferCount; idx++) {
+ if (mNativeBuffers[idx].buffer.get() == buffer) {
+ mNativeBuffers[idx].dequeued = true;
+ mNativeBuffers[idx].dequeue_fence = fence_fd;
+ break;
+ } else if (mNativeBuffers[idx].buffer.get() == nullptr) {
+ // increasing the number of buffers we have allocated
+ mNativeBuffers[idx].buffer = buffer;
+ mNativeBuffers[idx].dequeued = true;
+ mNativeBuffers[idx].dequeue_fence = fence_fd;
+ break;
+ }
+ }
+ if (idx == mWindowInfo.bufferCount) {
+ ALOGE("dequeueBuffer returned unrecognized buffer");
+ mNativeWindow->cancelBuffer(mNativeWindow.get(), buffer, fence_fd);
+ return nullptr;
+ }
+
+ VulkanSurface::NativeBufferInfo* bufferInfo = &mNativeBuffers[idx];
+
+ if (bufferInfo->skSurface.get() == nullptr) {
+ bufferInfo->skSurface =
+ SkSurface::MakeFromAHardwareBuffer(mGrContext,
+ ANativeWindowBuffer_getHardwareBuffer(bufferInfo->buffer.get()),
+ kTopLeft_GrSurfaceOrigin, DataSpaceToColorSpace(mWindowInfo.dataspace),
+ nullptr);
+ if (bufferInfo->skSurface.get() == nullptr) {
+ ALOGE("SkSurface::MakeFromAHardwareBuffer failed");
+ mNativeWindow->cancelBuffer(mNativeWindow.get(), buffer, fence_fd);
+ return nullptr;
+ }
+ }
+
+ mDequeuedIndex = idx;
+ return bufferInfo;
+}
+
+bool VulkanSurface::presentCurrentBuffer(const SkRect& dirtyRect, int semaphoreFd) {
+ if (!dirtyRect.isEmpty()) {
+ SkRect transformedRect;
+ mWindowInfo.preTransform.mapRect(&transformedRect, dirtyRect);
+
+ SkIRect transformedIRect;
+ transformedRect.roundOut(&transformedIRect);
+ transformedIRect.intersect(0, 0, mWindowInfo.size.fWidth, mWindowInfo.size.fHeight);
+
+ // map to bottom-left coordinate system
+ android_native_rect_t aRect;
+ aRect.left = transformedIRect.x();
+ aRect.top = mWindowInfo.size.fHeight - (transformedIRect.y() + transformedIRect.height());
+ aRect.right = aRect.left + transformedIRect.width();
+ aRect.bottom = aRect.top - transformedIRect.height();
+
+ int err = native_window_set_surface_damage(mNativeWindow.get(), &aRect, 1);
+ ALOGE_IF(err != 0, "native_window_set_surface_damage failed: %s (%d)", strerror(-err), err);
+ }
+
+ VulkanSurface::NativeBufferInfo& currentBuffer = mNativeBuffers[mDequeuedIndex];
+ int queuedFd = (semaphoreFd != -1) ? semaphoreFd : currentBuffer.dequeue_fence;
+ int err = mNativeWindow->queueBuffer(mNativeWindow.get(), currentBuffer.buffer.get(), queuedFd);
+
+ currentBuffer.dequeued = false;
+ // queueBuffer always closes fence, even on error
+ if (err != 0) {
+ ALOGE("queueBuffer failed: %s (%d)", strerror(-err), err);
+ mNativeWindow->cancelBuffer(mNativeWindow.get(), currentBuffer.buffer.get(),
+ currentBuffer.dequeue_fence);
+ } else {
+ currentBuffer.hasValidContents = true;
+ currentBuffer.lastPresentedCount = mPresentCount;
+ mPresentCount++;
+ }
+
+ if (currentBuffer.dequeue_fence >= 0) {
+ close(currentBuffer.dequeue_fence);
+ currentBuffer.dequeue_fence = -1;
+ }
+
+ return err == 0;
+}
+
+int VulkanSurface::getCurrentBuffersAge() {
+ VulkanSurface::NativeBufferInfo& currentBuffer = mNativeBuffers[mDequeuedIndex];
+ return currentBuffer.hasValidContents ? (mPresentCount - currentBuffer.lastPresentedCount) : 0;
+}
+
+} /* namespace renderthread */
+} /* namespace uirenderer */
+} /* namespace android */
diff --git a/libs/hwui/renderthread/VulkanSurface.h b/libs/hwui/renderthread/VulkanSurface.h
new file mode 100644
index 0000000..4fd9cd2
--- /dev/null
+++ b/libs/hwui/renderthread/VulkanSurface.h
@@ -0,0 +1,127 @@
+/*
+ * 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.
+ */
+#pragma once
+
+#include <system/graphics.h>
+#include <system/window.h>
+#include <vulkan/vulkan.h>
+
+#include <SkSize.h>
+#include <SkRefCnt.h>
+
+#include "IRenderPipeline.h"
+
+class SkSurface;
+
+namespace android {
+namespace uirenderer {
+namespace renderthread {
+
+class VulkanManager;
+
+class VulkanSurface {
+public:
+ static VulkanSurface* Create(ANativeWindow* window,
+ ColorMode colorMode,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ GrContext* grContext,
+ const VulkanManager& vkManager);
+ ~VulkanSurface();
+
+ sk_sp<SkSurface> getCurrentSkSurface() { return mNativeBuffers[mDequeuedIndex].skSurface; }
+ const SkMatrix& getCurrentPreTransform() { return mWindowInfo.preTransform; }
+
+private:
+ /*
+ * All structs/methods in this private section are specifically for use by the VulkanManager
+ *
+ */
+ friend VulkanManager;
+ struct NativeBufferInfo {
+ sk_sp<SkSurface> skSurface;
+ sp<ANativeWindowBuffer> buffer;
+ // The fence is only valid when the buffer is dequeued, and should be
+ // -1 any other time. When valid, we own the fd, and must ensure it is
+ // closed: either by closing it explicitly when queueing the buffer,
+ // or by passing ownership e.g. to ANativeWindow::cancelBuffer().
+ int dequeue_fence = -1;
+ bool dequeued = false;
+ uint32_t lastPresentedCount = 0;
+ bool hasValidContents = false;
+ };
+
+ NativeBufferInfo* dequeueNativeBuffer();
+ NativeBufferInfo* getCurrentBufferInfo() { return &mNativeBuffers[mDequeuedIndex]; }
+ bool presentCurrentBuffer(const SkRect& dirtyRect, int semaphoreFd);
+
+ // The width and height are are the logical width and height for when submitting draws to the
+ // surface. In reality if the window is rotated the underlying window may have the width and
+ // height swapped.
+ int logicalWidth() const { return mWindowInfo.size.width(); }
+ int logicalHeight() const { return mWindowInfo.size.height(); }
+ int getCurrentBuffersAge();
+
+private:
+ /*
+ * All code below this line while logically available to VulkanManager should not be treated
+ * as private to this class.
+ *
+ */
+ static constexpr int sMaxBufferCount = 3;
+
+ struct WindowInfo {
+ SkISize size;
+ PixelFormat pixelFormat;
+ android_dataspace dataspace;
+ int transform;
+ int bufferCount;
+ uint64_t windowUsageFlags;
+
+ // size of the ANativeWindow if the inverse of transform requires us to swap width/height
+ SkISize actualSize;
+ // transform to be applied to the SkSurface to map the coordinates to the provided transform
+ SkMatrix preTransform;
+ };
+
+ VulkanSurface(ANativeWindow* window,
+ const WindowInfo& windowInfo,
+ SkISize minWindowSize,
+ SkISize maxWindowSize,
+ GrContext* grContext);
+ static bool UpdateWindow(ANativeWindow* window,
+ const WindowInfo& windowInfo);
+ static void ComputeWindowSizeAndTransform(WindowInfo* windowInfo,
+ const SkISize& minSize,
+ const SkISize& maxSize);
+ void releaseBuffers();
+
+ NativeBufferInfo mNativeBuffers[VulkanSurface::sMaxBufferCount];
+
+ sp<ANativeWindow> mNativeWindow;
+ WindowInfo mWindowInfo;
+ GrContext* mGrContext;
+
+ int mDequeuedIndex = -1;
+ uint32_t mPresentCount = 0;
+
+ const SkISize mMinWindowSize;
+ const SkISize mMaxWindowSize;
+};
+
+} /* namespace renderthread */
+} /* namespace uirenderer */
+} /* namespace android */
\ No newline at end of file
diff --git a/media/java/android/media/ExifInterface.java b/media/java/android/media/ExifInterface.java
index bc91ca3..4cd8971 100644
--- a/media/java/android/media/ExifInterface.java
+++ b/media/java/android/media/ExifInterface.java
@@ -73,6 +73,12 @@
* Supported formats are: JPEG, DNG, CR2, NEF, NRW, ARW, RW2, ORF, PEF, SRW, RAF and HEIF.
* <p>
* Attribute mutation is supported for JPEG image files.
+ * <p>
+ * Note: It is recommended to use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a>
+ * <a href="{@docRoot}reference/androidx/exifinterface/media/ExifInterface.html">ExifInterface
+ * Library</a> since it is a superset of this class. In addition to the functionalities of this
+ * class, it supports parsing extra metadata such as exposure and data compression information
+ * as well as setting extra metadata such as GPS and datetime information.
*/
public class ExifInterface {
private static final String TAG = "ExifInterface";
@@ -1316,14 +1322,14 @@
}
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
- private final String mFilename;
- private final FileDescriptor mSeekableFileDescriptor;
- private final AssetManager.AssetInputStream mAssetInputStream;
- private final boolean mIsInputStream;
+ private String mFilename;
+ private FileDescriptor mSeekableFileDescriptor;
+ private AssetManager.AssetInputStream mAssetInputStream;
+ private boolean mIsInputStream;
private int mMimeType;
@UnsupportedAppUsage
private final HashMap[] mAttributes = new HashMap[EXIF_TAGS.length];
- private Set<Integer> mAttributesOffsets = new HashSet<>(EXIF_TAGS.length);
+ private Set<Integer> mHandledIfdOffsets = new HashSet<>(EXIF_TAGS.length);
private ByteOrder mExifByteOrder = ByteOrder.BIG_ENDIAN;
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
private boolean mHasThumbnail;
@@ -1350,7 +1356,10 @@
* Reads Exif tags from the specified image file.
*/
public ExifInterface(@NonNull File file) throws IOException {
- this(file.getAbsolutePath());
+ if (file == null) {
+ throw new NullPointerException("file cannot be null");
+ }
+ initForFilename(file.getName());
}
/**
@@ -1358,23 +1367,9 @@
*/
public ExifInterface(@NonNull String filename) throws IOException {
if (filename == null) {
- throw new IllegalArgumentException("filename cannot be null");
+ throw new NullPointerException("filename cannot be null");
}
- FileInputStream in = null;
- mAssetInputStream = null;
- mFilename = filename;
- mIsInputStream = false;
- try {
- in = new FileInputStream(filename);
- if (isSeekableFD(in.getFD())) {
- mSeekableFileDescriptor = in.getFD();
- } else {
- mSeekableFileDescriptor = null;
- }
- loadAttributes(in);
- } finally {
- IoUtils.closeQuietly(in);
- }
+ initForFilename(filename);
}
/**
@@ -1384,7 +1379,7 @@
*/
public ExifInterface(@NonNull FileDescriptor fileDescriptor) throws IOException {
if (fileDescriptor == null) {
- throw new IllegalArgumentException("fileDescriptor cannot be null");
+ throw new NullPointerException("fileDescriptor cannot be null");
}
mAssetInputStream = null;
mFilename = null;
@@ -1418,7 +1413,7 @@
*/
public ExifInterface(@NonNull InputStream inputStream) throws IOException {
if (inputStream == null) {
- throw new IllegalArgumentException("inputStream cannot be null");
+ throw new NullPointerException("inputStream cannot be null");
}
mFilename = null;
if (inputStream instanceof AssetManager.AssetInputStream) {
@@ -1443,6 +1438,9 @@
* @param tag the name of the tag.
*/
private @Nullable ExifAttribute getExifAttribute(@NonNull String tag) {
+ if (tag == null) {
+ throw new NullPointerException("tag shouldn't be null");
+ }
// Retrieves all tag groups. The value from primary image tag group has a higher priority
// than the value from the thumbnail tag group if there are more than one candidates.
for (int i = 0; i < EXIF_TAGS.length; ++i) {
@@ -1461,6 +1459,9 @@
* @param tag the name of the tag.
*/
public @Nullable String getAttribute(@NonNull String tag) {
+ if (tag == null) {
+ throw new NullPointerException("tag shouldn't be null");
+ }
ExifAttribute attribute = getExifAttribute(tag);
if (attribute != null) {
if (!sTagSetForCompatibility.contains(tag)) {
@@ -1499,6 +1500,9 @@
* @param defaultValue the value to return if the tag is not available.
*/
public int getAttributeInt(@NonNull String tag, int defaultValue) {
+ if (tag == null) {
+ throw new NullPointerException("tag shouldn't be null");
+ }
ExifAttribute exifAttribute = getExifAttribute(tag);
if (exifAttribute == null) {
return defaultValue;
@@ -1520,6 +1524,9 @@
* @param defaultValue the value to return if the tag is not available.
*/
public double getAttributeDouble(@NonNull String tag, double defaultValue) {
+ if (tag == null) {
+ throw new NullPointerException("tag shouldn't be null");
+ }
ExifAttribute exifAttribute = getExifAttribute(tag);
if (exifAttribute == null) {
return defaultValue;
@@ -1539,6 +1546,9 @@
* @param value the value of the tag.
*/
public void setAttribute(@NonNull String tag, @Nullable String value) {
+ if (tag == null) {
+ throw new NullPointerException("tag shouldn't be null");
+ }
// Convert the given value to rational values for backwards compatibility.
if (value != null && sTagSetForCompatibility.contains(tag)) {
if (tag.equals(TAG_GPS_TIMESTAMP)) {
@@ -1708,6 +1718,9 @@
* determine whether the image data format is JPEG or not.
*/
private void loadAttributes(@NonNull InputStream in) throws IOException {
+ if (in == null) {
+ throw new NullPointerException("inputstream shouldn't be null");
+ }
try {
// Initialize mAttributes.
for (int i = 0; i < EXIF_TAGS.length; ++i) {
@@ -2043,6 +2056,9 @@
* that means offsets may have changed.
*/
public @Nullable long[] getAttributeRange(@NonNull String tag) {
+ if (tag == null) {
+ throw new NullPointerException("tag shouldn't be null");
+ }
if (mModified) {
throw new IllegalStateException(
"The underlying file has been modified since being parsed");
@@ -2064,6 +2080,9 @@
* no tag was found.
*/
public @Nullable byte[] getAttributeBytes(@NonNull String tag) {
+ if (tag == null) {
+ throw new NullPointerException("tag shouldn't be null");
+ }
final ExifAttribute attribute = getExifAttribute(tag);
if (attribute != null) {
return attribute.bytes;
@@ -2234,6 +2253,24 @@
}
}
+ private void initForFilename(String filename) throws IOException {
+ FileInputStream in = null;
+ mAssetInputStream = null;
+ mFilename = filename;
+ mIsInputStream = false;
+ try {
+ in = new FileInputStream(filename);
+ if (isSeekableFD(in.getFD())) {
+ mSeekableFileDescriptor = in.getFD();
+ } else {
+ mSeekableFileDescriptor = null;
+ }
+ loadAttributes(in);
+ } finally {
+ IoUtils.closeQuietly(in);
+ }
+ }
+
// Checks the type of image file
private int getMimeType(BufferedInputStream in) throws IOException {
in.mark(SIGNATURE_CHECK_SIZE);
@@ -3085,6 +3122,9 @@
// Reads image file directory, which is a tag group in EXIF.
private void readImageFileDirectory(ByteOrderedDataInputStream dataInputStream,
@IfdType int ifdType) throws IOException {
+ // Save offset of current IFD to prevent reading an IFD that is already read.
+ mHandledIfdOffsets.add(dataInputStream.mPosition);
+
if (dataInputStream.mPosition + 2 > dataInputStream.mLength) {
// Return if there is no data from the offset.
return;
@@ -3223,9 +3263,7 @@
// 1. Exists within the boundaries of the input stream
// 2. Does not point to a previously read IFD.
if (offset > 0L && offset < dataInputStream.mLength) {
- if (!mAttributesOffsets.contains((int) offset)) {
- // Save offset of current IFD to prevent reading an IFD that is already read
- mAttributesOffsets.add(dataInputStream.mPosition);
+ if (!mHandledIfdOffsets.contains((int) offset)) {
dataInputStream.seek(offset);
readImageFileDirectory(dataInputStream, nextIfdType);
} else {
@@ -3279,9 +3317,7 @@
// 1. Exists within the boundaries of the input stream
// 2. Does not point to a previously read IFD.
if (nextIfdOffset > 0L && nextIfdOffset < dataInputStream.mLength) {
- if (!mAttributesOffsets.contains(nextIfdOffset)) {
- // Save offset of current IFD to prevent reading an IFD that is already read.
- mAttributesOffsets.add(dataInputStream.mPosition);
+ if (!mHandledIfdOffsets.contains(nextIfdOffset)) {
dataInputStream.seek(nextIfdOffset);
// Do not overwrite thumbnail IFD data if it alreay exists.
if (mAttributes[IFD_TYPE_THUMBNAIL].isEmpty()) {
diff --git a/native/android/OWNERS b/native/android/OWNERS
index b3f50aa..266764a 100644
--- a/native/android/OWNERS
+++ b/native/android/OWNERS
@@ -1,4 +1,4 @@
set noparent
-per-file libandroid_net.map.txt, net.c = codewiz@google.com, ek@google.com, jchalard@google.com
+per-file libandroid_net.map.txt, net.c = codewiz@google.com, jchalard@google.com, junyulai@google.com
per-file libandroid_net.map.txt, net.c = lorenzo@google.com, reminv@google.com, satk@google.com
diff --git a/packages/CaptivePortalLogin/OWNERS b/packages/CaptivePortalLogin/OWNERS
index 7311eee..d3836d4 100644
--- a/packages/CaptivePortalLogin/OWNERS
+++ b/packages/CaptivePortalLogin/OWNERS
@@ -1,8 +1,8 @@
set noparent
codewiz@google.com
-ek@google.com
jchalard@google.com
+junyulai@google.com
lorenzo@google.com
reminv@google.com
satk@google.com
diff --git a/packages/ExtServices/src/android/ext/services/notification/AssistantSettings.java b/packages/ExtServices/src/android/ext/services/notification/AssistantSettings.java
index ba361c4..46288bb 100644
--- a/packages/ExtServices/src/android/ext/services/notification/AssistantSettings.java
+++ b/packages/ExtServices/src/android/ext/services/notification/AssistantSettings.java
@@ -22,7 +22,6 @@
import android.os.Handler;
import android.provider.DeviceConfig;
import android.provider.Settings;
-import android.text.TextUtils;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
@@ -128,17 +127,17 @@
}
private void updateFromDeviceConfigFlags() {
- mGenerateReplies = DeviceConfigHelper.getBoolean(
+ mGenerateReplies = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES, DEFAULT_GENERATE_REPLIES);
- mGenerateActions = DeviceConfigHelper.getBoolean(
+ mGenerateActions = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS, DEFAULT_GENERATE_ACTIONS);
- mMaxMessagesToExtract = DeviceConfigHelper.getInteger(
+ mMaxMessagesToExtract = DeviceConfig.getInt(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_MAX_MESSAGES_TO_EXTRACT,
DEFAULT_MAX_MESSAGES_TO_EXTRACT);
- mMaxSuggestions = DeviceConfigHelper.getInteger(
+ mMaxSuggestions = DeviceConfig.getInt(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_MAX_SUGGESTIONS, DEFAULT_MAX_SUGGESTIONS);
mOnUpdateRunnable.run();
@@ -170,34 +169,6 @@
mOnUpdateRunnable.run();
}
- static class DeviceConfigHelper {
-
- static int getInteger(String key, int defaultValue) {
- String value = getValue(key);
- if (TextUtils.isEmpty(value)) {
- return defaultValue;
- }
- try {
- return Integer.parseInt(value);
- } catch (NumberFormatException ex) {
- return defaultValue;
- }
- }
-
- static boolean getBoolean(String key, boolean defaultValue) {
- String value = getValue(key);
- if (TextUtils.isEmpty(value)) {
- return defaultValue;
- }
- return Boolean.parseBoolean(value);
- }
-
- private static String getValue(String key) {
- return DeviceConfig.getProperty(
- DeviceConfig.NAMESPACE_SYSTEMUI, key);
- }
- }
-
public interface Factory {
AssistantSettings createAndRegister(Handler handler, ContentResolver resolver, int userId,
Runnable onUpdateRunnable);
diff --git a/packages/ExtServices/tests/src/android/ext/services/notification/AssistantSettingsTest.java b/packages/ExtServices/tests/src/android/ext/services/notification/AssistantSettingsTest.java
index 293b5b8..ad52e2b 100644
--- a/packages/ExtServices/tests/src/android/ext/services/notification/AssistantSettingsTest.java
+++ b/packages/ExtServices/tests/src/android/ext/services/notification/AssistantSettingsTest.java
@@ -120,7 +120,7 @@
}
@Test
- public void testGenerateRepliesEmptyFlag() {
+ public void testGenerateRepliesNullFlag() {
runWithShellPermissionIdentity(() -> setProperty(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES,
@@ -136,12 +136,12 @@
runWithShellPermissionIdentity(() -> setProperty(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES,
- "",
+ null,
false /* makeDefault */));
mAssistantSettings.onDeviceConfigPropertyChanged(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES,
- "");
+ null);
// Go back to the default value.
assertTrue(mAssistantSettings.mGenerateReplies);
@@ -178,7 +178,7 @@
}
@Test
- public void testGenerateActionsEmptyFlag() {
+ public void testGenerateActionsNullFlag() {
runWithShellPermissionIdentity(() -> setProperty(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS,
@@ -194,12 +194,12 @@
runWithShellPermissionIdentity(() -> setProperty(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS,
- "",
+ null,
false /* makeDefault */));
mAssistantSettings.onDeviceConfigPropertyChanged(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS,
- "");
+ null);
// Go back to the default value.
assertTrue(mAssistantSettings.mGenerateActions);
diff --git a/packages/NetworkStack/OWNERS b/packages/NetworkStack/OWNERS
index a395465..0e1e65d 100644
--- a/packages/NetworkStack/OWNERS
+++ b/packages/NetworkStack/OWNERS
@@ -1,5 +1,6 @@
codewiz@google.com
jchalard@google.com
+junyulai@google.com
lorenzo@google.com
reminv@google.com
satk@google.com
diff --git a/packages/NetworkStack/TEST_MAPPING b/packages/NetworkStack/TEST_MAPPING
index 55ba591..fe9731fe 100644
--- a/packages/NetworkStack/TEST_MAPPING
+++ b/packages/NetworkStack/TEST_MAPPING
@@ -1,5 +1,5 @@
{
- "postsubmit": [
+ "presubmit": [
{
"name": "NetworkStackTests"
}
diff --git a/packages/NetworkStack/src/android/net/metrics/DataStallStatsUtils.java b/packages/NetworkStack/src/android/net/metrics/DataStallStatsUtils.java
index 17a36ad..d1ca109 100644
--- a/packages/NetworkStack/src/android/net/metrics/DataStallStatsUtils.java
+++ b/packages/NetworkStack/src/android/net/metrics/DataStallStatsUtils.java
@@ -20,6 +20,7 @@
import android.annotation.Nullable;
import android.net.captiveportal.CaptivePortalProbeResult;
import android.util.Log;
+import android.util.StatsLog;
import com.android.internal.util.HexDump;
import com.android.server.connectivity.nano.DataStallEventProto;
@@ -36,6 +37,7 @@
*/
public class DataStallStatsUtils {
private static final String TAG = DataStallStatsUtils.class.getSimpleName();
+ private static final int DATA_STALL_EVENT_ID = 121;
private static final boolean DBG = false;
private static int probeResultToEnum(@Nullable final CaptivePortalProbeResult result) {
@@ -61,6 +63,13 @@
Log.d(TAG, "write: " + stats + " with result: " + validationResult
+ ", dns: " + HexDump.toHexString(stats.mDns));
}
- // TODO(b/124613085): Send to Statsd once the public StatsLog API is ready.
+ // TODO(b/124613085): Update API once the public StatsLog API is ready.
+ StatsLog.write(DATA_STALL_EVENT_ID,
+ stats.mEvaluationType,
+ validationResult,
+ stats.mNetworkType,
+ stats.mWifiInfo,
+ stats.mCellularInfo,
+ stats.mDns);
}
}
diff --git a/packages/NetworkStack/src/com/android/server/util/PermissionUtil.java b/packages/NetworkStack/src/com/android/server/util/PermissionUtil.java
index f6eb900..6fbeead 100644
--- a/packages/NetworkStack/src/com/android/server/util/PermissionUtil.java
+++ b/packages/NetworkStack/src/com/android/server/util/PermissionUtil.java
@@ -33,7 +33,9 @@
public static void checkNetworkStackCallingPermission() {
// TODO: check that the calling PID is the system server.
final int caller = getCallingUid();
- if (caller != Process.SYSTEM_UID && UserHandle.getAppId(caller) != Process.BLUETOOTH_UID) {
+ if (caller != Process.SYSTEM_UID
+ && UserHandle.getAppId(caller) != Process.BLUETOOTH_UID
+ && UserHandle.getAppId(caller) != Process.PHONE_UID) {
throw new SecurityException("Invalid caller: " + caller);
}
}
diff --git a/packages/NetworkStack/tests/Android.bp b/packages/NetworkStack/tests/Android.bp
index f22b647..e64f284 100644
--- a/packages/NetworkStack/tests/Android.bp
+++ b/packages/NetworkStack/tests/Android.bp
@@ -22,7 +22,6 @@
resource_dirs: ["res"],
static_libs: [
"androidx.test.rules",
- "frameworks-base-testutils",
"mockito-target-extended-minus-junit4",
"NetworkStackLib",
"testables",
diff --git a/packages/NetworkStack/tests/src/android/net/ip/IpClientTest.java b/packages/NetworkStack/tests/src/android/net/ip/IpClientTest.java
index 1990229..bd488ea 100644
--- a/packages/NetworkStack/tests/src/android/net/ip/IpClientTest.java
+++ b/packages/NetworkStack/tests/src/android/net/ip/IpClientTest.java
@@ -34,6 +34,7 @@
import static org.mockito.Mockito.when;
import android.app.AlarmManager;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.net.ConnectivityManager;
@@ -46,14 +47,11 @@
import android.net.shared.InitialConfiguration;
import android.net.shared.ProvisioningConfiguration;
import android.net.util.InterfaceParams;
-import android.provider.Settings;
-import android.test.mock.MockContentResolver;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.internal.R;
-import com.android.internal.util.test.FakeSettingsProvider;
import com.android.server.NetworkObserver;
import com.android.server.NetworkObserverRegistry;
@@ -94,7 +92,7 @@
@Mock private IIpClientCallbacks mCb;
@Mock private AlarmManager mAlarm;
@Mock private IpClient.Dependencies mDependencies;
- private MockContentResolver mContentResolver;
+ @Mock private ContentResolver mContentResolver;
private NetworkObserver mObserver;
private InterfaceParams mIfParams;
@@ -109,9 +107,6 @@
when(mDependencies.getNetd(any())).thenReturn(mNetd);
when(mResources.getInteger(R.integer.config_networkAvoidBadWifi))
.thenReturn(DEFAULT_AVOIDBADWIFI_CONFIG_VALUE);
-
- mContentResolver = new MockContentResolver();
- mContentResolver.addProvider(Settings.AUTHORITY, new FakeSettingsProvider());
when(mContext.getContentResolver()).thenReturn(mContentResolver);
mIfParams = null;
diff --git a/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java b/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java
index ee2baf2..34ca6ac 100644
--- a/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java
+++ b/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java
@@ -525,7 +525,7 @@
wrappedMonitor.setLastProbeTime(SystemClock.elapsedRealtime() - 1000);
makeDnsTimeoutEvent(wrappedMonitor, 5);
assertTrue(wrappedMonitor.isDataStall());
- verify(mDataStallStatsUtils, times(1)).write(any(), any());
+ verify(mDataStallStatsUtils, times(1)).write(makeEmptyDataStallDetectionStats(), any());
}
@Test
@@ -534,7 +534,7 @@
wrappedMonitor.setLastProbeTime(SystemClock.elapsedRealtime() - 1000);
makeDnsTimeoutEvent(wrappedMonitor, 3);
assertFalse(wrappedMonitor.isDataStall());
- verify(mDataStallStatsUtils, never()).write(any(), any());
+ verify(mDataStallStatsUtils, never()).write(makeEmptyDataStallDetectionStats(), any());
}
@Test
@@ -586,6 +586,10 @@
}
}
+ private DataStallDetectionStats makeEmptyDataStallDetectionStats() {
+ return new DataStallDetectionStats.Builder().build();
+ }
+
private void setDataStallEvaluationType(int type) {
when(mDependencies.getSetting(any(),
eq(Settings.Global.DATA_STALL_EVALUATION_TYPE), anyInt())).thenReturn(type);
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java
index bed3030..785dd56 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java
@@ -108,12 +108,43 @@
return true;
}
+ /**
+ * Get A2dp devices matching connection states{
+ * @code BluetoothProfile.STATE_CONNECTED,
+ * @code BluetoothProfile.STATE_CONNECTING,
+ * @code BluetoothProfile.STATE_DISCONNECTING}
+ *
+ * @return Matching device list
+ */
public List<BluetoothDevice> getConnectedDevices() {
- if (mService == null) return new ArrayList<BluetoothDevice>(0);
- return mService.getDevicesMatchingConnectionStates(
- new int[] {BluetoothProfile.STATE_CONNECTED,
- BluetoothProfile.STATE_CONNECTING,
- BluetoothProfile.STATE_DISCONNECTING});
+ return getDevicesByStates(new int[] {
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.STATE_CONNECTING,
+ BluetoothProfile.STATE_DISCONNECTING});
+ }
+
+ /**
+ * Get A2dp devices matching connection states{
+ * @code BluetoothProfile.STATE_DISCONNECTED,
+ * @code BluetoothProfile.STATE_CONNECTED,
+ * @code BluetoothProfile.STATE_CONNECTING,
+ * @code BluetoothProfile.STATE_DISCONNECTING}
+ *
+ * @return Matching device list
+ */
+ public List<BluetoothDevice> getConnectableDevices() {
+ return getDevicesByStates(new int[] {
+ BluetoothProfile.STATE_DISCONNECTED,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.STATE_CONNECTING,
+ BluetoothProfile.STATE_DISCONNECTING});
+ }
+
+ private List<BluetoothDevice> getDevicesByStates(int[] states) {
+ if (mService == null) {
+ return new ArrayList<BluetoothDevice>(0);
+ }
+ return mService.getDevicesMatchingConnectionStates(states);
}
public boolean connect(BluetoothDevice device) {
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java
index 41c1d60..ebaeb74 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java
@@ -106,12 +106,43 @@
return true;
}
+ /**
+ * Get Hearing Aid devices matching connection states{
+ * @code BluetoothProfile.STATE_CONNECTED,
+ * @code BluetoothProfile.STATE_CONNECTING,
+ * @code BluetoothProfile.STATE_DISCONNECTING}
+ *
+ * @return Matching device list
+ */
public List<BluetoothDevice> getConnectedDevices() {
- if (mService == null) return new ArrayList<BluetoothDevice>(0);
- return mService.getDevicesMatchingConnectionStates(
- new int[] {BluetoothProfile.STATE_CONNECTED,
- BluetoothProfile.STATE_CONNECTING,
- BluetoothProfile.STATE_DISCONNECTING});
+ return getDevicesByStates(new int[] {
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.STATE_CONNECTING,
+ BluetoothProfile.STATE_DISCONNECTING});
+ }
+
+ /**
+ * Get Hearing Aid devices matching connection states{
+ * @code BluetoothProfile.STATE_DISCONNECTED,
+ * @code BluetoothProfile.STATE_CONNECTED,
+ * @code BluetoothProfile.STATE_CONNECTING,
+ * @code BluetoothProfile.STATE_DISCONNECTING}
+ *
+ * @return Matching device list
+ */
+ public List<BluetoothDevice> getConnectableDevices() {
+ return getDevicesByStates(new int[] {
+ BluetoothProfile.STATE_DISCONNECTED,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.STATE_CONNECTING,
+ BluetoothProfile.STATE_DISCONNECTING});
+ }
+
+ private List<BluetoothDevice> getDevicesByStates(int[] states) {
+ if (mService == null) {
+ return new ArrayList<BluetoothDevice>(0);
+ }
+ return mService.getDevicesMatchingConnectionStates(states);
}
public boolean connect(BluetoothDevice device) {
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 9d6fc9ed..6df6c73 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -135,6 +135,7 @@
<uses-permission android:name="android.permission.MANAGE_BIOMETRIC" />
<uses-permission android:name="android.permission.MANAGE_SLICE_PERMISSIONS" />
<uses-permission android:name="android.permission.CONTROL_KEYGUARD_SECURE_NOTIFICATIONS" />
+ <uses-permission android:name="android.permission.GET_RUNTIME_PERMISSIONS" />
<!-- Needed for WallpaperManager.clear in ImageWallpaper.updateWallpaperLocked -->
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index b985b6b..4adece9 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -287,7 +287,6 @@
<item name="*android:lockPatternStyle">@style/LockPatternStyle</item>
<item name="passwordStyle">@style/PasswordTheme</item>
<item name="backgroundProtectedStyle">@style/BackgroundProtectedStyle</item>
- <item name="android:forceDarkAllowed">false</item>
<!-- Needed for MediaRoute chooser dialog -->
<item name="*android:isLightTheme">false</item>
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java
index 10996e88..794c30a 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java
@@ -217,4 +217,11 @@
WindowManagerGlobal.getWindowManagerService().registerPinnedStackListener(
DEFAULT_DISPLAY, mPinnedStackListenerForwarder);
}
+
+ /**
+ * Removes a pinned stack listener.
+ */
+ public void removePinnedStackListener(IPinnedStackListener listener) {
+ mPinnedStackListenerForwarder.removeListener(listener);
+ }
}
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/ClockLayout.java b/packages/SystemUI/src/com/android/keyguard/clock/ClockLayout.java
index 4d8cf96..59ee267 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/ClockLayout.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/ClockLayout.java
@@ -76,8 +76,10 @@
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
- final float offsetX = getBurnInOffset(mBurnInPreventionOffsetX, true);
- final float offsetY = getBurnInOffset(mBurnInPreventionOffsetY, false);
+ final float offsetX = getBurnInOffset(mBurnInPreventionOffsetX * 2, true)
+ - mBurnInPreventionOffsetX;
+ final float offsetY = getBurnInOffset(mBurnInPreventionOffsetY * 2, false)
+ - mBurnInPreventionOffsetY;
// Put digital clock in two left corner of the screen.
if (mDigitalClock != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/appops/AppOpsControllerImpl.java b/packages/SystemUI/src/com/android/systemui/appops/AppOpsControllerImpl.java
index c013df3..ace086f 100644
--- a/packages/SystemUI/src/com/android/systemui/appops/AppOpsControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/appops/AppOpsControllerImpl.java
@@ -20,6 +20,7 @@
import android.app.AppOpsManager;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
@@ -203,26 +204,37 @@
}
/**
+ * Does the app-op item refer to a user sensitive permission. Only user sensitive permission
+ * should be shown to the user by default.
+ *
+ * @param item The item
+ *
+ * @return {@code true} iff the app-op item is user sensitive
+ */
+ private boolean isUserSensitive(AppOpItem item) {
+ String permission = AppOpsManager.opToPermission(item.getCode());
+ if (permission == null) {
+ return false;
+ }
+ int permFlags = mContext.getPackageManager().getPermissionFlags(permission,
+ item.getPackageName(), UserHandle.getUserHandleForUid(item.getUid()));
+ return (permFlags & PackageManager.FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED) != 0;
+ }
+
+ /**
* Returns a copy of the list containing all the active AppOps that the controller tracks.
*
* @return List of active AppOps information
*/
public List<AppOpItem> getActiveAppOps() {
- ArrayList<AppOpItem> active;
- synchronized (mActiveItems) {
- active = new ArrayList<>(mActiveItems);
- }
- synchronized (mNotedItems) {
- active.addAll(mNotedItems);
- }
- return active;
+ return getActiveAppOpsForUser(UserHandle.USER_ALL);
}
/**
* Returns a copy of the list containing all the active AppOps that the controller tracks, for
* a given user id.
*
- * @param userId User id to track
+ * @param userId User id to track, can be {@link UserHandle#USER_ALL}
*
* @return List of active AppOps information for that user id
*/
@@ -232,7 +244,8 @@
final int numActiveItems = mActiveItems.size();
for (int i = 0; i < numActiveItems; i++) {
AppOpItem item = mActiveItems.get(i);
- if (UserHandle.getUserId(item.getUid()) == userId) {
+ if ((userId == UserHandle.USER_ALL || UserHandle.getUserId(item.getUid()) == userId)
+ && isUserSensitive(item)) {
list.add(item);
}
}
@@ -241,7 +254,8 @@
final int numNotedItems = mNotedItems.size();
for (int i = 0; i < numNotedItems; i++) {
AppOpItem item = mNotedItems.get(i);
- if (UserHandle.getUserId(item.getUid()) == userId) {
+ if ((userId == UserHandle.USER_ALL || UserHandle.getUserId(item.getUid()) == userId)
+ && isUserSensitive(item)) {
list.add(item);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index 51b2098..eb85589 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -23,6 +23,8 @@
import static com.android.systemui.statusbar.StatusBarState.SHADE;
import static com.android.systemui.statusbar.notification.NotificationAlertingManager.alertAgain;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
import android.annotation.Nullable;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityTaskManager;
@@ -42,6 +44,7 @@
import android.view.ViewGroup;
import android.widget.FrameLayout;
+import androidx.annotation.IntDef;
import androidx.annotation.MainThread;
import com.android.internal.annotations.VisibleForTesting;
@@ -59,6 +62,8 @@
import com.android.systemui.statusbar.notification.row.NotificationContentInflater.InflationFlag;
import com.android.systemui.statusbar.phone.StatusBarWindowController;
+import java.lang.annotation.Retention;
+
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -70,10 +75,22 @@
*/
@Singleton
public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListener {
- private static final int MAX_BUBBLES = 5; // TODO: actually enforce this
private static final String TAG = "BubbleController";
+ private static final int MAX_BUBBLES = 5; // TODO: actually enforce this
+
+ @Retention(SOURCE)
+ @IntDef({DISMISS_USER_GESTURE, DISMISS_AGED, DISMISS_TASK_FINISHED, DISMISS_BLOCKED,
+ DISMISS_NOTIF_CANCEL, DISMISS_ACCESSIBILITY_ACTION})
+ @interface DismissReason {}
+ static final int DISMISS_USER_GESTURE = 1;
+ static final int DISMISS_AGED = 2;
+ static final int DISMISS_TASK_FINISHED = 3;
+ static final int DISMISS_BLOCKED = 4;
+ static final int DISMISS_NOTIF_CANCEL = 5;
+ static final int DISMISS_ACCESSIBILITY_ACTION = 6;
+
// Enables some subset of notifs to automatically become bubbles
private static final boolean DEBUG_ENABLE_AUTO_BUBBLE = false;
@@ -248,11 +265,11 @@
/**
* Tell the stack of bubbles to be dismissed, this will remove all of the bubbles in the stack.
*/
- void dismissStack() {
+ void dismissStack(@DismissReason int reason) {
if (mStackView == null) {
return;
}
- mStackView.stackDismissed();
+ mStackView.stackDismissed(reason);
updateVisibility();
mNotificationEntryManager.updateNotifications();
@@ -304,9 +321,9 @@
* Must be called from the main thread.
*/
@MainThread
- void removeBubble(String key) {
+ void removeBubble(String key, int reason) {
if (mStackView != null) {
- mStackView.removeBubble(key);
+ mStackView.removeBubble(key, reason);
}
mNotificationEntryManager.updateNotifications();
updateVisibility();
@@ -320,7 +337,7 @@
boolean samePackage = entry.notification.getPackageName().equals(
e.notification.getPackageName());
if (samePackage) {
- removeBubble(entry.key);
+ removeBubble(entry.key, DISMISS_BLOCKED);
}
}
}
@@ -377,7 +394,7 @@
}
if (!removedByUser) {
// This was a cancel so we should remove the bubble
- removeBubble(entry.key);
+ removeBubble(entry.key, DISMISS_NOTIF_CANCEL);
}
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
index 25ee87a..856b9d6 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
@@ -135,7 +135,8 @@
public void onTaskRemovalStarted(int taskId) {
if (mEntry != null) {
// Must post because this is called from a binder thread.
- post(() -> mBubbleController.removeBubble(mEntry.key));
+ post(() -> mBubbleController.removeBubble(mEntry.key,
+ BubbleController.DISMISS_TASK_FINISHED));
}
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index 84efb9a..888e3fe 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -19,6 +19,8 @@
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
+import android.app.Notification;
+import android.app.PendingIntent;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Outline;
@@ -49,6 +51,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.ViewClippingUtil;
import com.android.systemui.R;
+import com.android.systemui.bubbles.BubbleController.DismissReason;
import com.android.systemui.bubbles.animation.ExpandedAnimationController;
import com.android.systemui.bubbles.animation.PhysicsAnimationLayout;
import com.android.systemui.bubbles.animation.StackAnimationController;
@@ -62,6 +65,7 @@
*/
public class BubbleStackView extends FrameLayout {
private static final String TAG = "BubbleStackView";
+ private static final boolean DEBUG = false;
private Point mDisplaySize;
@@ -232,7 +236,7 @@
}
switch (action) {
case AccessibilityNodeInfo.ACTION_DISMISS:
- stackDismissed();
+ stackDismissed(BubbleController.DISMISS_ACCESSIBILITY_ACTION);
return true;
case AccessibilityNodeInfo.ACTION_COLLAPSE:
collapseStack();
@@ -356,18 +360,12 @@
/**
* Remove a bubble from the stack.
*/
- public void removeBubble(String key) {
+ public void removeBubble(String key, int reason) {
Bubble b = mBubbleData.removeBubble(key);
if (b == null) {
return;
}
- b.entry.setBubbleDismissed(true);
-
- // Remove it from the views
- int removedIndex = mBubbleContainer.indexOfChild(b.iconView);
- b.expandedView.cleanUpExpandedState();
- mBubbleContainer.removeView(b.iconView);
-
+ int removedIndex = dismissBubble(b, reason);
int bubbleCount = mBubbleContainer.getChildCount();
if (bubbleCount == 0) {
// If no bubbles remain, collapse the entire stack.
@@ -385,26 +383,63 @@
mExpandedBubble = null;
}
}
+ // TODO: consider logging reason code
logBubbleEvent(b, StatsLog.BUBBLE_UICHANGED__ACTION__DISMISSED);
}
/**
* Dismiss the stack of bubbles.
*/
- public void stackDismissed() {
+ public void stackDismissed(int reason) {
for (Bubble bubble : mBubbleData.getBubbles()) {
- bubble.entry.setBubbleDismissed(true);
- bubble.expandedView.cleanUpExpandedState();
+ dismissBubble(bubble, reason);
}
mBubbleData.clear();
collapseStack();
mBubbleContainer.removeAllViews();
mExpandedViewContainer.removeAllViews();
+ // TODO: consider logging reason code
logBubbleEvent(null /* no bubble associated with bubble stack dismiss */,
StatsLog.BUBBLE_UICHANGED__ACTION__STACK_DISMISSED);
}
/**
+ * Marks the notification entry as dismissed, cleans up Bubble icon and expanded view UI
+ * elements and calls deleteIntent if necessary.
+ *
+ * <p>Note: This does not remove the Bubble from BubbleData.
+ *
+ * @param bubble the Bubble being dismissed
+ * @param reason code for the reason the dismiss was triggered
+ * @see BubbleController.DismissReason
+ */
+ private int dismissBubble(Bubble bubble, @DismissReason int reason) {
+ if (DEBUG) {
+ Log.d(TAG, "dismissBubble: " + bubble + " reason=" + reason);
+ }
+ bubble.entry.setBubbleDismissed(true);
+ bubble.expandedView.cleanUpExpandedState();
+
+ // Remove it from the views
+ int removedIndex = mBubbleContainer.indexOfChild(bubble.iconView);
+ mBubbleContainer.removeViewAt(removedIndex);
+
+ if (reason == BubbleController.DISMISS_USER_GESTURE) {
+ Notification.BubbleMetadata bubbleMetadata = bubble.entry.getBubbleMetadata();
+ PendingIntent deleteIntent = bubbleMetadata.getDeleteIntent();
+ if (deleteIntent != null) {
+ try {
+ deleteIntent.send();
+ } catch (PendingIntent.CanceledException e) {
+ Log.w(TAG, "Failed to send delete intent for bubble with key: "
+ + (bubble.entry != null ? bubble.entry.key : " null entry"));
+ }
+ }
+ }
+ return removedIndex;
+ }
+
+ /**
* Updates a bubble in the stack.
*
* @param entry the entry to update in the stack.
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
index c8eebac..a7170d0 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
@@ -140,7 +140,7 @@
case MotionEvent.ACTION_UP:
trackMovement(event);
if (mInDismissTarget && isStack) {
- mController.dismissStack();
+ mController.dismissStack(BubbleController.DISMISS_USER_GESTURE);
} else if (mMovedEnough) {
mVelocityTracker.computeCurrentVelocity(/* maxVelocity */ 1000);
final float velX = mVelocityTracker.getXVelocity();
@@ -152,7 +152,8 @@
mStack.onBubbleDragFinish(
mTouchedView, viewX, viewY, velX, velY, /* dismissed */ dismissed);
if (dismissed) {
- mController.removeBubble(((BubbleView) mTouchedView).getKey());
+ mController.removeBubble(((BubbleView) mTouchedView).getKey(),
+ BubbleController.DISMISS_USER_GESTURE);
}
}
} else if (mTouchedView == mStack.getExpandedBubbleView()) {
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeUi.java b/packages/SystemUI/src/com/android/systemui/doze/DozeUi.java
index 7656564..847182d 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeUi.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeUi.java
@@ -93,7 +93,13 @@
new DozeHost.PulseCallback() {
@Override
public void onPulseStarted() {
- mMachine.requestState(DozeMachine.State.DOZE_PULSING);
+ try {
+ mMachine.requestState(DozeMachine.State.DOZE_PULSING);
+ } catch (IllegalStateException e) {
+ // It's possible that the pulse was asynchronously cancelled while
+ // we were waiting for it to start (under stress conditions.)
+ // In those cases we should just ignore it. b/127657926
+ }
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
index 3273253..9b44066 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
@@ -89,6 +89,7 @@
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.plugins.GlobalActions.GlobalActionsManager;
import com.android.systemui.plugins.GlobalActionsPanelPlugin;
+import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ExtensionController;
import com.android.systemui.statusbar.policy.ExtensionController.Extension;
@@ -1533,7 +1534,7 @@
View panelView = initializePanel();
if (panelView == null) {
mBackgroundDrawable = new GradientDrawable(context);
- mScrimAlpha = 0.7f;
+ mScrimAlpha = ScrimController.GRADIENT_SCRIM_ALPHA;
} else {
mBackgroundDrawable = context.getDrawable(
com.android.systemui.R.drawable.global_action_panel_scrim);
diff --git a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java
index 7295008..9df6ba5 100644
--- a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java
+++ b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java
@@ -29,6 +29,7 @@
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.util.Log;
+import android.util.MathUtils;
import com.android.systemui.ImageWallpaper;
import com.android.systemui.ImageWallpaper.ImageGLView;
@@ -43,6 +44,8 @@
public class ImageWallpaperRenderer implements GLSurfaceView.Renderer,
ImageWallpaper.WallpaperStatusListener, ImageRevealHelper.RevealStateListener {
private static final String TAG = ImageWallpaperRenderer.class.getSimpleName();
+ private static final float SCALE_VIEWPORT_MIN = 0.98f;
+ private static final float SCALE_VIEWPORT_MAX = 1f;
private final WallpaperManager mWallpaperManager;
private final ImageGLProgram mProgram;
@@ -52,6 +55,8 @@
private final ImageGLView mGLView;
private float mXOffset = 0f;
private float mYOffset = 0f;
+ private int mWidth = 0;
+ private int mHeight = 0;
public ImageWallpaperRenderer(Context context, ImageGLView glView) {
mWallpaperManager = context.getSystemService(WallpaperManager.class);
@@ -87,6 +92,8 @@
Log.d(TAG, "onSurfaceChanged: width=" + width + ", height=" + height
+ ", xOffset=" + mXOffset + ", yOffset=" + mYOffset);
}
+ mWidth = width;
+ mHeight = height;
mWallpaper.adjustTextureCoordinates(mWallpaperManager.getBitmap(),
width, height, mXOffset, mYOffset);
}
@@ -102,10 +109,21 @@
glUniform1f(mWallpaper.getHandle(ImageGLWallpaper.U_PER85), per85);
glUniform1f(mWallpaper.getHandle(ImageGLWallpaper.U_REVEAL), reveal);
+ scaleViewport(reveal);
mWallpaper.useTexture();
mWallpaper.draw();
}
+ private void scaleViewport(float reveal) {
+ // Interpolation between SCALE_VIEWPORT_MAX and SCALE_VIEWPORT_MIN by reveal.
+ float vpScaled = MathUtils.lerp(SCALE_VIEWPORT_MAX, SCALE_VIEWPORT_MIN, reveal);
+ // Calculate the offset amount from the lower left corner.
+ float offset = (SCALE_VIEWPORT_MAX - vpScaled) / 2;
+ // Change the viewport.
+ glViewport((int) (mWidth * offset), (int) (mHeight * offset),
+ (int) (mWidth * vpScaled), (int) (mHeight * vpScaled));
+ }
+
@Override
public void onAmbientModeChanged(boolean inAmbientMode, long duration) {
mImageRevealHelper.updateAwake(!inAmbientMode, duration);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java
index b820dc0..a630e49 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java
@@ -461,9 +461,6 @@
}
public boolean shouldKeepForRemoteInputHistory(NotificationEntry entry) {
- if (entry.isDismissed()) {
- return false;
- }
if (!FORCE_REMOTE_INPUT_HISTORY) {
return false;
}
@@ -471,9 +468,6 @@
}
public boolean shouldKeepForSmartReplyHistory(NotificationEntry entry) {
- if (entry.isDismissed()) {
- return false;
- }
if (!FORCE_REMOTE_INPUT_HISTORY) {
return false;
}
@@ -661,9 +655,6 @@
protected class RemoteInputActiveExtender extends RemoteInputExtender {
@Override
public boolean shouldExtendLifetime(@NonNull NotificationEntry entry) {
- if (entry.isDismissed()) {
- return false;
- }
return mRemoteInputController.isRemoteInputActive(entry);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
index 4ed9ae4..7d224fb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
@@ -159,16 +159,19 @@
}
public void performRemoveNotification(StatusBarNotification n) {
- final int rank = mNotificationData.getRank(n.getKey());
- final int count = mNotificationData.getActiveNotifications().size();
- NotificationVisibility.NotificationLocation location =
- NotificationLogger.getNotificationLocation(getNotificationData().get(n.getKey()));
- final NotificationVisibility nv = NotificationVisibility.obtain(n.getKey(), rank, count,
- true, location);
+ final NotificationVisibility nv = obtainVisibility(n.getKey());
removeNotificationInternal(
n.getKey(), null, nv, false /* forceRemove */, true /* removedByUser */);
}
+ private NotificationVisibility obtainVisibility(String key) {
+ final int rank = mNotificationData.getRank(key);
+ final int count = mNotificationData.getActiveNotifications().size();
+ NotificationVisibility.NotificationLocation location =
+ NotificationLogger.getNotificationLocation(getNotificationData().get(key));
+ return NotificationVisibility.obtain(key, rank, count, true, location);
+ }
+
private void abortExistingInflation(String key) {
if (mPendingNotifications.containsKey(key)) {
NotificationEntry entry = mPendingNotifications.get(key);
@@ -226,8 +229,8 @@
@Override
public void removeNotification(String key, NotificationListenerService.RankingMap ranking) {
- removeNotificationInternal(
- key, ranking, null, false /* forceRemove */, false /* removedByUser */);
+ removeNotificationInternal(key, ranking, obtainVisibility(key), false /* forceRemove */,
+ false /* removedByUser */);
}
private void removeNotificationInternal(
@@ -245,7 +248,8 @@
if (entry != null) {
// If a manager needs to keep the notification around for whatever reason, we
// keep the notification
- if (!forceRemove) {
+ boolean entryDismissed = entry.isRowDismissed();
+ if (!forceRemove && !entryDismissed) {
for (NotificationLifetimeExtender extender : mNotificationLifetimeExtenders) {
if (extender.shouldExtendLifetime(entry)) {
mLatestRankingMap = ranking;
@@ -272,6 +276,7 @@
mNotificationData.remove(key, ranking);
updateNotifications();
Dependency.get(LeakDetector.class).trackGarbage(entry);
+ removedByUser |= entryDismissed;
for (NotificationEntryListener listener : mNotificationEntryListeners) {
listener.onEntryRemoved(entry, visibility, removedByUser);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
index 5cd1210..f1373d1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
@@ -543,14 +543,6 @@
return row == null || row.isRemoved();
}
- /**
- * @return {@code true} if the row is null or dismissed
- */
- public boolean isDismissed() {
- //TODO: recycling
- return row == null || row.isDismissed();
- }
-
public boolean isRowPinned() {
return row != null && row.isPinned();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index c389082..b540fb4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -42,6 +42,7 @@
import android.annotation.SuppressLint;
import android.app.StatusBarManager;
import android.content.Context;
+import android.content.pm.ParceledListSlice;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.Point;
@@ -59,6 +60,8 @@
import android.util.SparseArray;
import android.view.Display;
import android.view.Gravity;
+import android.view.IPinnedStackController;
+import android.view.IPinnedStackListener;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
@@ -355,6 +358,46 @@
}
};
+ private final IPinnedStackListener.Stub mImeChangedListener = new IPinnedStackListener.Stub() {
+ @Override
+ public void onListenerRegistered(IPinnedStackController controller) {
+ }
+
+ @Override
+ public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {
+ post(() -> {
+ // When the ime changes visibility, resize the edge panels to not cover the ime
+ final int width = mPrototypeController.getEdgeSensitivityWidth();
+ final int height = mContext.getDisplay().getHeight() - imeHeight
+ - getResources().getDimensionPixelOffset(R.dimen.status_bar_height);
+ if (mLeftEdgePanel != null) {
+ mLeftEdgePanel.setDimensions(width, height);
+ }
+ if (mRightEdgePanel != null) {
+ mRightEdgePanel.setDimensions(width, height);
+ }
+ });
+ }
+
+ @Override
+ public void onShelfVisibilityChanged(boolean shelfVisible, int shelfHeight) {
+ }
+
+ @Override
+ public void onMinimizedStateChanged(boolean isMinimized) {
+ }
+
+ @Override
+ public void onMovementBoundsChanged(Rect insetBounds, Rect normalBounds,
+ Rect animatingBounds, boolean fromImeAdjustment, boolean fromShelfAdjustment,
+ int displayRotation) {
+ }
+
+ @Override
+ public void onActionsChanged(ParceledListSlice actions) {
+ }
+ };
+
public NavigationBarView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -1296,13 +1339,19 @@
int height = mPrototypeController.getEdgeSensitivityHeight();
// Explicitly left and right, not start and end as this is device relative.
mLeftEdgePanel = NavigationBarEdgePanel.create(getContext(), width, height,
- Gravity.LEFT | Gravity.BOTTOM);
+ Gravity.LEFT | Gravity.TOP);
mRightEdgePanel = NavigationBarEdgePanel.create(getContext(), width, height,
- Gravity.RIGHT | Gravity.BOTTOM);
+ Gravity.RIGHT | Gravity.TOP);
mLeftEdgePanel.setOnTouchListener(mEdgePanelTouchListener);
mRightEdgePanel.setOnTouchListener(mEdgePanelTouchListener);
wm.addView(mLeftEdgePanel, mLeftEdgePanel.getLayoutParams());
wm.addView(mRightEdgePanel, mRightEdgePanel.getLayoutParams());
+
+ try {
+ WindowManagerWrapper.getInstance().addPinnedStackListener(mImeChangedListener);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to register pinned stack listener", e);
+ }
}
}
@@ -1327,6 +1376,7 @@
if (mRightEdgePanel != null) {
wm.removeView(mRightEdgePanel);
}
+ WindowManagerWrapper.getInstance().removePinnedStackListener(mImeChangedListener);
}
private void setUpSwipeUpOnboarding(boolean connectedToOverviewProxy) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index 8714a51..265fa2c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -421,6 +421,8 @@
interpolatedFract);
mCurrentInFrontAlpha = 0;
}
+ mCurrentBehindTint = ColorUtils.blendARGB(ScrimState.BOUNCER.getBehindTint(),
+ mState.getBehindTint(), interpolatedFract);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/appops/AppOpsControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/appops/AppOpsControllerTest.java
index 73ee0bd..b9afea1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/appops/AppOpsControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/appops/AppOpsControllerTest.java
@@ -22,11 +22,14 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.app.AppOpsManager;
+import android.content.pm.PackageManager;
import android.os.UserHandle;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
@@ -47,12 +50,15 @@
@TestableLooper.RunWithLooper
public class AppOpsControllerTest extends SysuiTestCase {
private static final String TEST_PACKAGE_NAME = "test";
- private static final int TEST_UID = 0;
- private static final int TEST_UID_OTHER = 500000;
+ private static final int TEST_UID = UserHandle.getUid(0, 0);
+ private static final int TEST_UID_OTHER = UserHandle.getUid(1, 0);
+ private static final int TEST_UID_NON_USER_SENSITIVE = UserHandle.getUid(2, 0);
@Mock
private AppOpsManager mAppOpsManager;
@Mock
+ private PackageManager mPackageManager;
+ @Mock
private AppOpsController.Callback mCallback;
@Mock
private AppOpsControllerImpl.H mMockHandler;
@@ -65,6 +71,18 @@
getContext().addMockSystemService(AppOpsManager.class, mAppOpsManager);
+ // All permissions of TEST_UID and TEST_UID_OTHER are user sensitive. None of
+ // TEST_UID_NON_USER_SENSITIVE are user sensitive.
+ getContext().setMockPackageManager(mPackageManager);
+ when(mPackageManager.getPermissionFlags(anyString(), anyString(),
+ eq(UserHandle.getUserHandleForUid(TEST_UID)))).thenReturn(
+ PackageManager.FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED);
+ when(mPackageManager.getPermissionFlags(anyString(), anyString(),
+ eq(UserHandle.getUserHandleForUid(TEST_UID_OTHER)))).thenReturn(
+ PackageManager.FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED);
+ when(mPackageManager.getPermissionFlags(anyString(), anyString(),
+ eq(UserHandle.getUserHandleForUid(TEST_UID_NON_USER_SENSITIVE)))).thenReturn(0);
+
mController = new AppOpsControllerImpl(mContext, Dependency.get(Dependency.BG_LOOPER));
}
@@ -157,6 +175,14 @@
}
@Test
+ public void nonUserSensitiveOpsAreIgnored() {
+ mController.onOpActiveChanged(AppOpsManager.OP_RECORD_AUDIO,
+ TEST_UID_NON_USER_SENSITIVE, TEST_PACKAGE_NAME, true);
+ assertEquals(0, mController.getActiveAppOpsForUser(
+ UserHandle.getUserId(TEST_UID_NON_USER_SENSITIVE)).size());
+ }
+
+ @Test
public void opNotedScheduledForRemoval() {
mController.setBGHandler(mMockHandler);
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
index 0fd7834..42c221a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
@@ -20,10 +20,13 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.IActivityManager;
+import android.app.PendingIntent;
import android.content.Context;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
@@ -83,6 +86,9 @@
@Mock
private BubbleController.BubbleExpandListener mBubbleExpandListener;
+ @Mock
+ private PendingIntent mDeleteIntent;
+
private BubbleData mBubbleData;
@Before
@@ -98,9 +104,9 @@
// Need notifications for bubbles
mNotificationTestHelper = new NotificationTestHelper(mContext);
- mRow = mNotificationTestHelper.createBubble();
- mRow2 = mNotificationTestHelper.createBubble();
- mNoChannelRow = mNotificationTestHelper.createBubble();
+ mRow = mNotificationTestHelper.createBubble(mDeleteIntent);
+ mRow2 = mNotificationTestHelper.createBubble(mDeleteIntent);
+ mNoChannelRow = mNotificationTestHelper.createBubble(mDeleteIntent);
// Return non-null notification data from the NEM
when(mNotificationEntryManager.getNotificationData()).thenReturn(mNotificationData);
@@ -141,11 +147,10 @@
verify(mBubbleStateChangeListener).onHasBubblesChanged(true);
- mBubbleController.removeBubble(mRow.getEntry().key);
+ mBubbleController.removeBubble(mRow.getEntry().key, BubbleController.DISMISS_USER_GESTURE);
assertFalse(mStatusBarWindowController.getBubblesShowing());
assertTrue(mRow.getEntry().isBubbleDismissed());
verify(mNotificationEntryManager).updateNotifications();
-
verify(mBubbleStateChangeListener).onHasBubblesChanged(false);
}
@@ -155,7 +160,7 @@
mBubbleController.updateBubble(mRow2.getEntry(), true /* updatePosition */);
assertTrue(mBubbleController.hasBubbles());
- mBubbleController.dismissStack();
+ mBubbleController.dismissStack(BubbleController.DISMISS_USER_GESTURE);
assertFalse(mStatusBarWindowController.getBubblesShowing());
verify(mNotificationEntryManager).updateNotifications();
assertTrue(mRow.getEntry().isBubbleDismissed());
@@ -271,7 +276,8 @@
assertFalse(mRow2.getEntry().showInShadeWhenBubble());
// Dismiss currently expanded
- mBubbleController.removeBubble(stackView.getExpandedBubbleView().getKey());
+ mBubbleController.removeBubble(stackView.getExpandedBubbleView().getKey(),
+ BubbleController.DISMISS_USER_GESTURE);
verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().key);
// Make sure next bubble is selected
@@ -279,7 +285,8 @@
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key);
// Dismiss that one
- mBubbleController.removeBubble(stackView.getExpandedBubbleView().getKey());
+ mBubbleController.removeBubble(stackView.getExpandedBubbleView().getKey(),
+ BubbleController.DISMISS_USER_GESTURE);
// Make sure state changes and collapse happens
verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getEntry().key);
@@ -299,6 +306,28 @@
assertTrue(mRow.getEntry().showInShadeWhenBubble());
}
+ @Test
+ public void testDeleteIntent_removeBubble_aged() throws PendingIntent.CanceledException {
+ mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */);
+ mBubbleController.removeBubble(mRow.getEntry().key, BubbleController.DISMISS_AGED);
+ verify(mDeleteIntent, never()).send();
+ }
+
+ @Test
+ public void testDeleteIntent_removeBubble_user() throws PendingIntent.CanceledException {
+ mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */);
+ mBubbleController.removeBubble(mRow.getEntry().key, BubbleController.DISMISS_USER_GESTURE);
+ verify(mDeleteIntent, times(1)).send();
+ }
+
+ @Test
+ public void testDeleteIntent_dismissStack() throws PendingIntent.CanceledException {
+ mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */);
+ mBubbleController.updateBubble(mRow2.getEntry(), true /* updatePosition */);
+ mBubbleController.dismissStack(BubbleController.DISMISS_USER_GESTURE);
+ verify(mDeleteIntent, times(2)).send();
+ }
+
static class TestableBubbleController extends BubbleController {
TestableBubbleController(Context context,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
index cef78db..de15505 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
@@ -23,6 +23,7 @@
import android.app.ActivityManager;
import android.app.Instrumentation;
import android.app.Notification;
+import android.app.Notification.BubbleMetadata;
import android.app.NotificationChannel;
import android.app.PendingIntent;
import android.content.Context;
@@ -152,8 +153,18 @@
* Returns an {@link ExpandableNotificationRow} that should be shown as a bubble.
*/
public ExpandableNotificationRow createBubble() throws Exception {
+ return createBubble(null);
+ }
+
+ /**
+ * Returns an {@link ExpandableNotificationRow} that should be shown as a bubble.
+ *
+ * @param deleteIntent the intent to assign to {@link BubbleMetadata#deleteIntent}
+ */
+ public ExpandableNotificationRow createBubble(@Nullable PendingIntent deleteIntent)
+ throws Exception {
Notification n = createNotification(false /* isGroupSummary */,
- null /* groupKey */, true /* isBubble */);
+ null /* groupKey */, true /* isBubble */, deleteIntent);
return generateRow(n, PKG, UID, USER_HANDLE, 0 /* extraInflationFlags */, IMPORTANCE_HIGH);
}
@@ -196,7 +207,8 @@
* @return a notification that is in the group specified or standalone if unspecified
*/
private Notification createNotification(boolean isGroupSummary, @Nullable String groupKey) {
- return createNotification(isGroupSummary, groupKey, false /* isBubble */);
+ return createNotification(isGroupSummary, groupKey, false /* isBubble */,
+ null /* bubbleDeleteIntent */);
}
/**
@@ -208,7 +220,8 @@
* @return a notification that is in the group specified or standalone if unspecified
*/
private Notification createNotification(boolean isGroupSummary,
- @Nullable String groupKey, boolean isBubble) {
+ @Nullable String groupKey, boolean isBubble,
+ @Nullable PendingIntent bubbleDeleteIntent) {
Notification publicVersion = new Notification.Builder(mContext).setSmallIcon(
R.drawable.ic_person)
.setCustomContentView(new RemoteViews(mContext.getPackageName(),
@@ -227,7 +240,8 @@
notificationBuilder.setGroup(groupKey);
}
if (isBubble) {
- notificationBuilder.setBubbleMetadata(makeBubbleMetadata());
+ BubbleMetadata metadata = makeBubbleMetadata(bubbleDeleteIntent);
+ notificationBuilder.setBubbleMetadata(metadata);
}
return notificationBuilder.build();
}
@@ -291,11 +305,13 @@
return row;
}
- private Notification.BubbleMetadata makeBubbleMetadata() {
+ private BubbleMetadata makeBubbleMetadata(PendingIntent deleteIntent) {
Intent target = new Intent(mContext, BubblesTestActivity.class);
PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0, target, 0);
- return new Notification.BubbleMetadata.Builder()
+
+ return new BubbleMetadata.Builder()
.setIntent(bubbleIntent)
+ .setDeleteIntent(deleteIntent)
.setTitle("bubble title")
.setIcon(Icon.createWithResource(mContext, 1))
.setDesiredHeight(314)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java
index 5543744..c8005dd 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java
@@ -347,7 +347,7 @@
verify(mPresenter).updateNotificationViews();
verify(mEntryListener).onEntryRemoved(
- mEntry, null, false /* removedByUser */);
+ eq(mEntry), any(), eq(false) /* removedByUser */);
verify(mRow).setRemoved();
assertNull(mEntryManager.getNotificationData().get(mSbn.getKey()));
@@ -360,7 +360,7 @@
mEntryManager.removeNotification("not_a_real_key", mRankingMap);
verify(mEntryListener, never()).onEntryRemoved(
- mEntry, null, false /* removedByUser */);
+ eq(mEntry), any(), eq(false) /* removedByUser */);
}
@Test
@@ -373,7 +373,7 @@
mEntryManager.removeNotification(mSbn.getKey(), mRankingMap);
verify(mEntryListener, never()).onEntryRemoved(
- mEntry, null, false /* removedByUser */);
+ eq(mEntry), any(), eq(false /* removedByUser */));
}
@Test
@@ -455,7 +455,7 @@
verify(extender).setShouldManageLifetime(mEntry, true);
// THEN the notification is retained
assertNotNull(mEntryManager.getNotificationData().get(mSbn.getKey()));
- verify(mEntryListener, never()).onEntryRemoved(mEntry, null, false);
+ verify(mEntryListener, never()).onEntryRemoved(eq(mEntry), any(), eq(false));
}
@Test
@@ -474,7 +474,7 @@
// THEN the notification is removed
assertNull(mEntryManager.getNotificationData().get(mSbn.getKey()));
- verify(mEntryListener).onEntryRemoved(mEntry, null, false);
+ verify(mEntryListener).onEntryRemoved(eq(mEntry), any(), eq(false));
}
@Test
diff --git a/services/core/java/com/android/server/DynamicAndroidService.java b/services/core/java/com/android/server/DynamicAndroidService.java
index 12a3f02..8488941 100644
--- a/services/core/java/com/android/server/DynamicAndroidService.java
+++ b/services/core/java/com/android/server/DynamicAndroidService.java
@@ -118,7 +118,9 @@
if (gsiService.isGsiRunning()) {
return gsiService.disableGsiInstall();
} else {
- return gsiService.setGsiBootable() == 0;
+ final int status = gsiService.getGsiBootStatus();
+ final boolean singleBoot = (status == IGsiService.BOOT_STATUS_SINGLE_BOOT);
+ return gsiService.setGsiBootable(singleBoot) == 0;
}
}
@@ -129,6 +131,6 @@
@Override
public boolean commit() throws RemoteException {
- return getGsiService().setGsiBootable() == 0;
+ return getGsiService().setGsiBootable(true) == 0;
}
}
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index bbd51ad..c2a0611 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -3210,18 +3210,6 @@
continue;
}
- if (!reportLocationAccessNoThrow(
- receiver.mCallerIdentity.mPid,
- receiver.mCallerIdentity.mUid,
- receiver.mCallerIdentity.mPackageName,
- receiver.mAllowedResolutionLevel)) {
- if (D) {
- Log.d(TAG, "skipping loc update for no op app: " +
- receiver.mCallerIdentity.mPackageName);
- }
- continue;
- }
-
Location notifyLocation;
if (receiver.mAllowedResolutionLevel < RESOLUTION_LEVEL_FINE) {
notifyLocation = coarseLocation; // use coarse location
@@ -3238,6 +3226,20 @@
} else {
lastLoc.set(notifyLocation);
}
+ // Report location access before delivering location to the client. This will
+ // note location delivery to appOps, so it should be called only when a
+ // location is really being delivered to the client.
+ if (!reportLocationAccessNoThrow(
+ receiver.mCallerIdentity.mPid,
+ receiver.mCallerIdentity.mUid,
+ receiver.mCallerIdentity.mPackageName,
+ receiver.mAllowedResolutionLevel)) {
+ if (D) {
+ Log.d(TAG, "skipping loc update for no op app: "
+ + receiver.mCallerIdentity.mPackageName);
+ }
+ continue;
+ }
if (!receiver.callLocationChangedLocked(notifyLocation)) {
Slog.w(TAG, "RemoteException calling onLocationChanged on "
+ receiver);
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java
index dc394d0..5582ad7 100644
--- a/services/core/java/com/android/server/NetworkManagementService.java
+++ b/services/core/java/com/android/server/NetworkManagementService.java
@@ -2512,6 +2512,10 @@
modifyRoute(MODIFY_OPERATION_ADD, INetd.LOCAL_NET_ID, route);
}
}
+
+ // IPv6 link local should be activated always.
+ modifyRoute(MODIFY_OPERATION_ADD, INetd.LOCAL_NET_ID,
+ new RouteInfo(new IpPrefix("fe80::/64"), null, iface));
}
@Override
diff --git a/services/core/java/com/android/server/TestNetworkService.java b/services/core/java/com/android/server/TestNetworkService.java
new file mode 100644
index 0000000..e64ab78
--- /dev/null
+++ b/services/core/java/com/android/server/TestNetworkService.java
@@ -0,0 +1,338 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server;
+
+import static com.android.internal.util.Preconditions.checkNotNull;
+
+import android.annotation.NonNull;
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.INetd;
+import android.net.ITestNetworkManager;
+import android.net.IpPrefix;
+import android.net.LinkAddress;
+import android.net.LinkProperties;
+import android.net.NetworkAgent;
+import android.net.NetworkCapabilities;
+import android.net.NetworkInfo;
+import android.net.NetworkInfo.DetailedState;
+import android.net.RouteInfo;
+import android.net.StringNetworkSpecifier;
+import android.net.TestNetworkInterface;
+import android.net.util.NetdService;
+import android.os.Binder;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.IBinder;
+import android.os.INetworkManagementService;
+import android.os.Looper;
+import android.os.ParcelFileDescriptor;
+import android.os.RemoteException;
+import android.util.SparseArray;
+
+import com.android.internal.annotations.GuardedBy;
+import com.android.internal.annotations.VisibleForTesting;
+
+import java.io.UncheckedIOException;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InterfaceAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/** @hide */
+class TestNetworkService extends ITestNetworkManager.Stub {
+ @NonNull private static final String TAG = TestNetworkService.class.getSimpleName();
+ @NonNull private static final String TEST_NETWORK_TYPE = "TEST_NETWORK";
+ @NonNull private static final String TEST_TUN_PREFIX = "testtun";
+ @NonNull private static final AtomicInteger sTestTunIndex = new AtomicInteger();
+
+ @NonNull private final Context mContext;
+ @NonNull private final INetworkManagementService mNMS;
+ @NonNull private final INetd mNetd;
+
+ @NonNull private final HandlerThread mHandlerThread;
+ @NonNull private final Handler mHandler;
+
+ // Native method stubs
+ private static native int jniCreateTun(@NonNull String iface);
+
+ @VisibleForTesting
+ protected TestNetworkService(
+ @NonNull Context context, @NonNull INetworkManagementService netManager) {
+ mHandlerThread = new HandlerThread("TestNetworkServiceThread");
+ mHandlerThread.start();
+ mHandler = new Handler(mHandlerThread.getLooper());
+
+ mContext = checkNotNull(context, "missing Context");
+ mNMS = checkNotNull(netManager, "missing INetworkManagementService");
+ mNetd = checkNotNull(NetdService.getInstance(), "could not get netd instance");
+ }
+
+ /**
+ * Create a TUN interface with the given interface name and link addresses
+ *
+ * <p>This method will return the FileDescriptor to the TUN interface. Close it to tear down the
+ * TUN interface.
+ */
+ @Override
+ public TestNetworkInterface createTunInterface(@NonNull LinkAddress[] linkAddrs) {
+ enforceTestNetworkPermissions(mContext);
+
+ checkNotNull(linkAddrs, "missing linkAddrs");
+
+ String iface = TEST_TUN_PREFIX + sTestTunIndex.getAndIncrement();
+ return Binder.withCleanCallingIdentity(
+ () -> {
+ try {
+ ParcelFileDescriptor tunIntf =
+ ParcelFileDescriptor.adoptFd(jniCreateTun(iface));
+ for (LinkAddress addr : linkAddrs) {
+ mNetd.interfaceAddAddress(
+ iface,
+ addr.getAddress().getHostAddress(),
+ addr.getPrefixLength());
+ }
+
+ return new TestNetworkInterface(tunIntf, iface);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ });
+ }
+
+ // Tracker for TestNetworkAgents
+ @GuardedBy("mTestNetworkTracker")
+ @NonNull
+ private final SparseArray<TestNetworkAgent> mTestNetworkTracker = new SparseArray<>();
+
+ public class TestNetworkAgent extends NetworkAgent implements IBinder.DeathRecipient {
+ private static final int NETWORK_SCORE = 1; // Use a low, non-zero score.
+
+ private final int mUid;
+ @NonNull private final NetworkInfo mNi;
+ @NonNull private final NetworkCapabilities mNc;
+ @NonNull private final LinkProperties mLp;
+
+ @GuardedBy("mBinderLock")
+ @NonNull
+ private IBinder mBinder;
+
+ @NonNull private final Object mBinderLock = new Object();
+
+ private TestNetworkAgent(
+ @NonNull Looper looper,
+ @NonNull Context context,
+ @NonNull NetworkInfo ni,
+ @NonNull NetworkCapabilities nc,
+ @NonNull LinkProperties lp,
+ int uid,
+ @NonNull IBinder binder)
+ throws RemoteException {
+ super(looper, context, TEST_NETWORK_TYPE, ni, nc, lp, NETWORK_SCORE);
+
+ mUid = uid;
+ mNi = ni;
+ mNc = nc;
+ mLp = lp;
+
+ synchronized (mBinderLock) {
+ mBinder = binder; // Binder null-checks in create()
+
+ try {
+ mBinder.linkToDeath(this, 0);
+ } catch (RemoteException e) {
+ binderDied();
+ throw e; // Abort, signal failure up the stack.
+ }
+ }
+ }
+
+ /**
+ * If the Binder object dies, this function is called to free the resources of this
+ * TestNetworkAgent
+ */
+ @Override
+ public void binderDied() {
+ teardown();
+ }
+
+ @Override
+ protected void unwanted() {
+ teardown();
+ }
+
+ private void teardown() {
+ mNi.setDetailedState(DetailedState.DISCONNECTED, null, null);
+ mNi.setIsAvailable(false);
+ sendNetworkInfo(mNi);
+
+ // Synchronize on mBinderLock to ensure that unlinkToDeath is never called more than
+ // once (otherwise it could throw an exception)
+ synchronized (mBinderLock) {
+ // If mBinder is null, this Test Network has already been cleaned up.
+ if (mBinder == null) return;
+ mBinder.unlinkToDeath(this, 0);
+ mBinder = null;
+ }
+
+ // Has to be in TestNetworkAgent to ensure all teardown codepaths properly clean up
+ // resources, even for binder death or unwanted calls.
+ synchronized (mTestNetworkTracker) {
+ mTestNetworkTracker.remove(netId);
+ }
+ }
+ }
+
+ private TestNetworkAgent registerTestNetworkAgent(
+ @NonNull Looper looper,
+ @NonNull Context context,
+ @NonNull String iface,
+ int callingUid,
+ @NonNull IBinder binder)
+ throws RemoteException, SocketException {
+ checkNotNull(looper, "missing Looper");
+ checkNotNull(context, "missing Context");
+ // iface and binder validity checked by caller
+
+ // Build network info with special testing type
+ NetworkInfo ni = new NetworkInfo(ConnectivityManager.TYPE_TEST, 0, TEST_NETWORK_TYPE, "");
+ ni.setDetailedState(DetailedState.CONNECTED, null, null);
+ ni.setIsAvailable(true);
+
+ // Build narrow set of NetworkCapabilities, useful only for testing
+ NetworkCapabilities nc = new NetworkCapabilities();
+ nc.clearAll(); // Remove default capabilities.
+ nc.addTransportType(NetworkCapabilities.TRANSPORT_TEST);
+ nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED);
+ nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
+ nc.setNetworkSpecifier(new StringNetworkSpecifier(iface));
+
+ // Build LinkProperties
+ LinkProperties lp = new LinkProperties();
+ lp.setInterfaceName(iface);
+
+ // Find the currently assigned addresses, and add them to LinkProperties
+ boolean allowIPv4 = false, allowIPv6 = false;
+ NetworkInterface netIntf = NetworkInterface.getByName(iface);
+ checkNotNull(netIntf, "No such network interface found: " + netIntf);
+
+ for (InterfaceAddress intfAddr : netIntf.getInterfaceAddresses()) {
+ lp.addLinkAddress(
+ new LinkAddress(intfAddr.getAddress(), intfAddr.getNetworkPrefixLength()));
+
+ if (intfAddr.getAddress() instanceof Inet6Address) {
+ allowIPv6 |= !intfAddr.getAddress().isLinkLocalAddress();
+ } else if (intfAddr.getAddress() instanceof Inet4Address) {
+ allowIPv4 = true;
+ }
+ }
+
+ // Add global routes (but as non-default, non-internet providing network)
+ if (allowIPv4) {
+ lp.addRoute(new RouteInfo(new IpPrefix(Inet4Address.ANY, 0), null, iface));
+ }
+ if (allowIPv6) {
+ lp.addRoute(new RouteInfo(new IpPrefix(Inet6Address.ANY, 0), null, iface));
+ }
+
+ return new TestNetworkAgent(looper, context, ni, nc, lp, callingUid, binder);
+ }
+
+ /**
+ * Sets up a Network with extremely limited privileges, guarded by the MANAGE_TEST_NETWORKS
+ * permission.
+ *
+ * <p>This method provides a Network that is useful only for testing.
+ */
+ @Override
+ public void setupTestNetwork(@NonNull String iface, @NonNull IBinder binder) {
+ enforceTestNetworkPermissions(mContext);
+
+ checkNotNull(iface, "missing Iface");
+ checkNotNull(binder, "missing IBinder");
+
+ if (!(iface.startsWith(INetd.IPSEC_INTERFACE_PREFIX)
+ || iface.startsWith(TEST_TUN_PREFIX))) {
+ throw new IllegalArgumentException(
+ "Cannot create network for non ipsec, non-testtun interface");
+ }
+
+ // Setup needs to be done with NETWORK_STACK privileges.
+ int callingUid = Binder.getCallingUid();
+ Binder.withCleanCallingIdentity(
+ () -> {
+ try {
+ mNMS.setInterfaceUp(iface);
+
+ // Synchronize all accesses to mTestNetworkTracker to prevent the case
+ // where:
+ // 1. TestNetworkAgent successfully binds to death of binder
+ // 2. Before it is added to the mTestNetworkTracker, binder dies,
+ // binderDied() is called (on a different thread)
+ // 3. This thread is pre-empted, put() is called after remove()
+ synchronized (mTestNetworkTracker) {
+ TestNetworkAgent agent =
+ registerTestNetworkAgent(
+ mHandler.getLooper(),
+ mContext,
+ iface,
+ callingUid,
+ binder);
+
+ mTestNetworkTracker.put(agent.netId, agent);
+ }
+ } catch (SocketException e) {
+ throw new UncheckedIOException(e);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ });
+ }
+
+ /** Teardown a test network */
+ @Override
+ public void teardownTestNetwork(int netId) {
+ enforceTestNetworkPermissions(mContext);
+
+ TestNetworkAgent agent;
+ synchronized (mTestNetworkTracker) {
+ agent = mTestNetworkTracker.get(netId);
+ }
+
+ if (agent == null) {
+ return; // Already torn down
+ } else if (agent.mUid != Binder.getCallingUid()) {
+ throw new SecurityException("Attempted to modify other user's test networks");
+ }
+
+ // Safe to be called multiple times.
+ agent.teardown();
+ }
+
+ // STOPSHIP: Change this back to android.Manifest.permission.MANAGE_TEST_NETWORKS
+ private static final String PERMISSION_NAME = "dummy";
+
+ public static void enforceTestNetworkPermissions(@NonNull Context context) {
+ // STOPSHIP: Re-enable these checks. Disabled until adoptShellPermissionIdentity() can be
+ // called from CTS test code.
+ if (false) {
+ context.enforceCallingOrSelfPermission(PERMISSION_NAME, "TestNetworkService");
+ }
+ }
+}
diff --git a/services/core/java/com/android/server/VibratorService.java b/services/core/java/com/android/server/VibratorService.java
index 5cca159..5d0fa26 100644
--- a/services/core/java/com/android/server/VibratorService.java
+++ b/services/core/java/com/android/server/VibratorService.java
@@ -111,6 +111,8 @@
// intensity level. It's important that we apply the scaling on the delta between the two so
// that the default intensity level applies no scaling to application provided effects.
private final SparseArray<ScaleLevel> mScaleLevels;
+ private final LinkedList<VibrationInfo> mPreviousRingVibrations;
+ private final LinkedList<VibrationInfo> mPreviousNotificationVibrations;
private final LinkedList<VibrationInfo> mPreviousVibrations;
private final int mPreviousVibrationsLimit;
private final boolean mAllowPriorityVibrationsInLowPowerMode;
@@ -354,6 +356,8 @@
mAllowPriorityVibrationsInLowPowerMode = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_allowPriorityVibrationsInLowPowerMode);
+ mPreviousRingVibrations = new LinkedList<>();
+ mPreviousNotificationVibrations = new LinkedList<>();
mPreviousVibrations = new LinkedList<>();
IntentFilter filter = new IntentFilter();
@@ -620,10 +624,19 @@
}
private void addToPreviousVibrationsLocked(Vibration vib) {
- if (mPreviousVibrations.size() > mPreviousVibrationsLimit) {
- mPreviousVibrations.removeFirst();
+ final LinkedList<VibrationInfo> previousVibrations;
+ if (vib.isRingtone()) {
+ previousVibrations = mPreviousRingVibrations;
+ } else if (vib.isNotification()) {
+ previousVibrations = mPreviousNotificationVibrations;
+ } else {
+ previousVibrations = mPreviousVibrations;
}
- mPreviousVibrations.addLast(vib.toInfo());
+
+ if (previousVibrations.size() > mPreviousVibrationsLimit) {
+ previousVibrations.removeFirst();
+ }
+ previousVibrations.addLast(vib.toInfo());
}
@Override // Binder call
@@ -1355,6 +1368,18 @@
pw.println(" mNotificationIntensity=" + mNotificationIntensity);
pw.println(" mRingIntensity=" + mRingIntensity);
pw.println("");
+ pw.println(" Previous ring vibrations:");
+ for (VibrationInfo info : mPreviousRingVibrations) {
+ pw.print(" ");
+ pw.println(info.toString());
+ }
+
+ pw.println(" Previous notification vibrations:");
+ for (VibrationInfo info : mPreviousNotificationVibrations) {
+ pw.print(" ");
+ pw.println(info.toString());
+ }
+
pw.println(" Previous vibrations:");
for (VibrationInfo info : mPreviousVibrations) {
pw.print(" ");
diff --git a/services/core/java/com/android/server/connectivity/PacManager.java b/services/core/java/com/android/server/connectivity/PacManager.java
index 9789688..1ac09ad 100644
--- a/services/core/java/com/android/server/connectivity/PacManager.java
+++ b/services/core/java/com/android/server/connectivity/PacManager.java
@@ -70,9 +70,8 @@
private static final long MAX_PAC_SIZE = 20 * 1000 * 1000;
// Return values for #setCurrentProxyScriptUrl
- enum ToSendOrNotToSendBroadcast {
- DONT_SEND_BROADCAST, DO_SEND_BROADCAST
- }
+ public static final boolean DONT_SEND_BROADCAST = false;
+ public static final boolean DO_SEND_BROADCAST = true;
private String mCurrentPac;
@GuardedBy("mProxyLock")
@@ -176,11 +175,11 @@
* @param proxy Proxy information that is about to be broadcast.
* @return Returns whether the broadcast should be sent : either DO_ or DONT_SEND_BROADCAST
*/
- synchronized ToSendOrNotToSendBroadcast setCurrentProxyScriptUrl(ProxyInfo proxy) {
+ synchronized boolean setCurrentProxyScriptUrl(ProxyInfo proxy) {
if (!Uri.EMPTY.equals(proxy.getPacFileUrl())) {
if (proxy.getPacFileUrl().equals(mPacUrl) && (proxy.getPort() > 0)) {
// Allow to send broadcast, nothing to do.
- return ToSendOrNotToSendBroadcast.DO_SEND_BROADCAST;
+ return DO_SEND_BROADCAST;
}
mPacUrl = proxy.getPacFileUrl();
mCurrentDelay = DELAY_1;
@@ -188,7 +187,7 @@
mHasDownloaded = false;
getAlarmManager().cancel(mPacRefreshIntent);
bind();
- return ToSendOrNotToSendBroadcast.DONT_SEND_BROADCAST;
+ return DONT_SEND_BROADCAST;
} else {
getAlarmManager().cancel(mPacRefreshIntent);
synchronized (mProxyLock) {
@@ -204,7 +203,7 @@
}
}
}
- return ToSendOrNotToSendBroadcast.DO_SEND_BROADCAST;
+ return DO_SEND_BROADCAST;
}
}
diff --git a/services/core/java/com/android/server/connectivity/ProxyTracker.java b/services/core/java/com/android/server/connectivity/ProxyTracker.java
index a671287..e715890 100644
--- a/services/core/java/com/android/server/connectivity/ProxyTracker.java
+++ b/services/core/java/com/android/server/connectivity/ProxyTracker.java
@@ -208,8 +208,7 @@
public void sendProxyBroadcast() {
final ProxyInfo defaultProxy = getDefaultProxy();
final ProxyInfo proxyInfo = null != defaultProxy ? defaultProxy : new ProxyInfo("", 0, "");
- if (mPacManager.setCurrentProxyScriptUrl(proxyInfo)
- == PacManager.ToSendOrNotToSendBroadcast.DONT_SEND_BROADCAST) {
+ if (mPacManager.setCurrentProxyScriptUrl(proxyInfo) == PacManager.DONT_SEND_BROADCAST) {
return;
}
if (DBG) Slog.d(TAG, "sending Proxy Broadcast for " + proxyInfo);
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index 59fffb4..8005dda 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -1842,6 +1842,7 @@
config.interfaze = iface;
config.session = profile.name;
config.isMetered = false;
+ config.proxyInfo = profile.proxy;
config.addLegacyRoutes(profile.routes);
if (!profile.dnsServers.isEmpty()) {
diff --git a/services/core/java/com/android/server/display/AutomaticBrightnessController.java b/services/core/java/com/android/server/display/AutomaticBrightnessController.java
index 1f28a6c..6d7dff5 100644
--- a/services/core/java/com/android/server/display/AutomaticBrightnessController.java
+++ b/services/core/java/com/android/server/display/AutomaticBrightnessController.java
@@ -216,7 +216,7 @@
private PackageManager mPackageManager;
public AutomaticBrightnessController(Callbacks callbacks, Looper looper,
- SensorManager sensorManager, BrightnessMappingStrategy mapper,
+ SensorManager sensorManager, Sensor lightSensor, BrightnessMappingStrategy mapper,
int lightSensorWarmUpTime, int brightnessMin, int brightnessMax, float dozeScaleFactor,
int lightSensorRate, int initialLightSensorRate, long brighteningLightDebounceConfig,
long darkeningLightDebounceConfig, boolean resetAmbientLuxAfterWarmUpConfig,
@@ -249,7 +249,7 @@
new AmbientLightRingBuffer(mNormalLightSensorRate, mAmbientLightHorizon);
if (!DEBUG_PRETEND_LIGHT_SENSOR_ABSENT) {
- mLightSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
+ mLightSensor = lightSensor;
}
mActivityTaskManager = ActivityTaskManager.getService();
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 74cda9d..b79ead0 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -44,6 +44,7 @@
import android.os.Trace;
import android.os.UserHandle;
import android.provider.Settings;
+import android.text.TextUtils;
import android.util.MathUtils;
import android.util.Slog;
import android.util.TimeUtils;
@@ -58,6 +59,7 @@
import com.android.server.policy.WindowManagerPolicy;
import java.io.PrintWriter;
+import java.util.List;
/**
* Controls the power state of the display.
@@ -474,10 +476,14 @@
int shortTermModelTimeout = resources.getInteger(
com.android.internal.R.integer.config_autoBrightnessShortTermModelTimeout);
+ String lightSensorType = resources.getString(
+ com.android.internal.R.string.config_displayLightSensorType);
+ Sensor lightSensor = findDisplayLightSensor(lightSensorType);
+
mBrightnessMapper = BrightnessMappingStrategy.create(resources);
if (mBrightnessMapper != null) {
mAutomaticBrightnessController = new AutomaticBrightnessController(this,
- handler.getLooper(), sensorManager, mBrightnessMapper,
+ handler.getLooper(), sensorManager, lightSensor, mBrightnessMapper,
lightSensorWarmUpTimeConfig, mScreenBrightnessRangeMinimum,
mScreenBrightnessRangeMaximum, dozeScaleFactor, lightSensorRate,
initialLightSensorRate, brighteningLightDebounce, darkeningLightDebounce,
@@ -530,6 +536,19 @@
mDisplayWhiteBalanceController = displayWhiteBalanceController;
}
+ private Sensor findDisplayLightSensor(String sensorType) {
+ if (!TextUtils.isEmpty(sensorType)) {
+ List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
+ for (int i = 0; i < sensors.size(); i++) {
+ Sensor sensor = sensors.get(i);
+ if (sensorType.equals(sensor.getStringType())) {
+ return sensor;
+ }
+ }
+ }
+ return mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
+ }
+
/**
* Returns true if the proximity sensor screen-off function is available.
*/
diff --git a/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java
index 500c388..a2515c8 100644
--- a/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java
@@ -29,6 +29,8 @@
import android.annotation.UserIdInt;
import android.annotation.WorkerThread;
import android.app.AppOpsManager;
+import android.app.Notification;
+import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -44,6 +46,7 @@
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
+import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
import android.os.HandlerThread;
@@ -66,6 +69,7 @@
import android.view.inputmethod.InputMethodSubtype;
import android.view.inputmethod.InputMethodSystemProperty;
+import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.inputmethod.IMultiClientInputMethod;
import com.android.internal.inputmethod.IMultiClientInputMethodPrivilegedOperations;
@@ -73,6 +77,8 @@
import com.android.internal.inputmethod.StartInputFlags;
import com.android.internal.inputmethod.StartInputReason;
import com.android.internal.inputmethod.UnbindReason;
+import com.android.internal.messages.nano.SystemMessageProto;
+import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.internal.view.IInputContext;
import com.android.internal.view.IInputMethodClient;
@@ -96,8 +102,15 @@
* we can switch the implementation at the boot time.</p>
*/
public final class MultiClientInputMethodManagerService {
- static final String TAG = "MultiClientInputMethodManagerService";
- static final boolean DEBUG = false;
+ private static final String TAG = "MultiClientInputMethodManagerService";
+ private static final boolean DEBUG = false;
+
+ private static final String PER_DISPLAY_FOCUS_DISABLED_WARNING_TITLE =
+ "config_perDisplayFocusEnabled is not true.";
+
+ private static final String PER_DISPLAY_FOCUS_DISABLED_WARNING_MSG =
+ "Consider rebuilding the system image after enabling config_perDisplayFocusEnabled to "
+ + "make IME focus compatible with multi-client IME mode.";
private static final long RECONNECT_DELAY_MSEC = 1000;
@@ -465,8 +478,33 @@
onPackageAdded(intent);
}
}, filter, null, mHandler);
+ break;
}
- break;
+ case SystemService.PHASE_BOOT_COMPLETED: {
+ final boolean perDisplayFocusEnabled = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_perDisplayFocusEnabled);
+ if (!perDisplayFocusEnabled) {
+ final Bundle extras = new Bundle();
+ extras.putBoolean(Notification.EXTRA_ALLOW_DURING_SETUP, true);
+ mContext.getSystemService(NotificationManager.class).notifyAsUser(TAG,
+ SystemMessageProto.SystemMessage.NOTE_SELECT_INPUT_METHOD,
+ new Notification.Builder(mContext,
+ SystemNotificationChannels.VIRTUAL_KEYBOARD)
+ .setContentTitle(PER_DISPLAY_FOCUS_DISABLED_WARNING_TITLE)
+ .setStyle(new Notification.BigTextStyle()
+ .bigText(PER_DISPLAY_FOCUS_DISABLED_WARNING_MSG))
+ .setSmallIcon(R.drawable.ic_notification_ime_default)
+ .setWhen(0)
+ .setOngoing(true)
+ .setLocalOnly(true)
+ .addExtras(extras)
+ .setCategory(Notification.CATEGORY_SYSTEM)
+ .setColor(mContext.getColor(
+ R.color.system_notification_accent_color))
+ .build(), UserHandle.ALL);
+ }
+ break;
+ }
}
}
diff --git a/services/core/java/com/android/server/inputmethod/multi-client-ime.md b/services/core/java/com/android/server/inputmethod/multi-client-ime.md
index 3021d2f..ba92cd2 100644
--- a/services/core/java/com/android/server/inputmethod/multi-client-ime.md
+++ b/services/core/java/com/android/server/inputmethod/multi-client-ime.md
@@ -39,7 +39,9 @@
## How to test
-On AOSP-based development devices (e.g. phones) where `android.os.Build.IS_DEBUGGABLE` returns `true` and you can have root access, you can enable multi-client IME feature by setting a valid component name that supports multi-client IME protocol to the system property `persist.debug.multi_client_ime`. Reboot is required for this to take effect.
+For multi-client IME to properly work, an internal boolean resource `com.android.internal.R.bool.config_perDisplayFocusEnabled` needs to be `true`. Since this value cannot be overridden at the run time, you may need to rebuild the system image to enable per-display focus mode.
+
+As for multi-client IME mode itself, you can enable multi-client IME mode just by setting a valid component name that supports multi-client IME protocol to the system property `persist.debug.multi_client_ime`, as long as `android.os.Build.IS_DEBUGGABLE` returns `true` and you can have root access. Reboot is required for this to take effect.
```shell
# Build and install a sample multi-client IME
diff --git a/services/core/java/com/android/server/net/OWNERS b/services/core/java/com/android/server/net/OWNERS
index 2e91f99..28ae6a4 100644
--- a/services/core/java/com/android/server/net/OWNERS
+++ b/services/core/java/com/android/server/net/OWNERS
@@ -1,12 +1,11 @@
set noparent
codewiz@google.com
-ek@google.com
jchalard@google.com
jsharkey@android.com
+junyulai@google.com
lorenzo@google.com
reminv@google.com
satk@google.com
-silberst@google.com
sudheersai@google.com
yamasani@google.com
diff --git a/services/core/java/com/android/server/rollback/TEST_MAPPING b/services/core/java/com/android/server/rollback/TEST_MAPPING
index 6be93a0..921b754 100644
--- a/services/core/java/com/android/server/rollback/TEST_MAPPING
+++ b/services/core/java/com/android/server/rollback/TEST_MAPPING
@@ -5,6 +5,14 @@
},
{
"name": "StagedRollbackTest"
+ },
+ {
+ "name": "FrameworksServicesTests",
+ "options": [
+ {
+ "include-filter": "com.android.server.rollback"
+ }
+ ]
}
]
}
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index 5a746eb..2b23ff0 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -1809,7 +1809,7 @@
}
}
- mNotTop = (mLaunchFlags & FLAG_ACTIVITY_PREVIOUS_IS_TOP) != 0 ? r : null;
+ mNotTop = (mLaunchFlags & FLAG_ACTIVITY_PREVIOUS_IS_TOP) != 0 ? sourceRecord : null;
mInTask = inTask;
// In some flows in to this function, we retrieve the task record and hold on to it
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 515ac52..db59030 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -392,7 +392,8 @@
final ArrayList<WindowToken> mExitingTokens = new ArrayList<>();
/** Detect user tapping outside of current focused task bounds .*/
- TaskTapPointerEventListener mTapDetector;
+ @VisibleForTesting
+ final TaskTapPointerEventListener mTapDetector;
/** Detect user tapping outside of current focused stack bounds .*/
private Region mTouchExcludeRegion = new Region();
@@ -876,14 +877,17 @@
mBoundsAnimationController = new BoundsAnimationController(service.mContext,
mAppTransition, AnimationThread.getHandler(), animationHandler);
- if (mWmService.mInputManager != null) {
- final InputChannel inputChannel = mWmService.mInputManager.monitorInput("Display "
- + mDisplayId, mDisplayId);
- mPointerEventDispatcher = inputChannel != null
- ? new PointerEventDispatcher(inputChannel) : null;
- } else {
- mPointerEventDispatcher = null;
- }
+ final InputChannel inputChannel = mWmService.mInputManager.monitorInput(
+ "PointerEventDispatcher" + mDisplayId, mDisplayId);
+ mPointerEventDispatcher = new PointerEventDispatcher(inputChannel);
+
+ // Tap Listeners are supported for:
+ // 1. All physical displays (multi-display).
+ // 2. VirtualDisplays on VR, AA (and everything else).
+ mTapDetector = new TaskTapPointerEventListener(mWmService, this);
+ registerPointerEventListener(mTapDetector);
+ registerPointerEventListener(mWmService.mMousePositionTracker);
+
mDisplayPolicy = new DisplayPolicy(service, this);
mDisplayRotation = new DisplayRotation(service, this);
if (isDefaultDisplay) {
@@ -1511,19 +1515,6 @@
mDisplayFrames.onDisplayInfoUpdated(mDisplayInfo,
calculateDisplayCutoutForRotation(mDisplayInfo.rotation));
-
- // Tap Listeners are supported for:
- // 1. All physical displays (multi-display).
- // 2. VirtualDisplays on VR, AA (and everything else).
- if (mPointerEventDispatcher != null && mTapDetector == null) {
- if (DEBUG_DISPLAY) {
- Slog.d(TAG,
- "Registering PointerEventListener for DisplayId: " + mDisplayId);
- }
- mTapDetector = new TaskTapPointerEventListener(mWmService, this);
- registerPointerEventListener(mTapDetector);
- registerPointerEventListener(mWmService.mMousePositionTracker);
- }
}
/**
@@ -2450,9 +2441,7 @@
mTmpRegion.set(mTmpRect);
mTouchExcludeRegion.op(mTmpRegion, Op.UNION);
}
- if (mTapDetector != null) {
- mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion);
- }
+ mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion);
}
/**
@@ -2502,11 +2491,7 @@
mWmService.stopFreezingDisplayLocked();
super.removeImmediately();
if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Removing display=" + this);
- if (mPointerEventDispatcher != null && mTapDetector != null) {
- unregisterPointerEventListener(mTapDetector);
- unregisterPointerEventListener(mWmService.mMousePositionTracker);
- mTapDetector = null;
- }
+ mPointerEventDispatcher.dispose();
mWmService.mAnimator.removeDisplayLocked(mDisplayId);
mWindowingLayer.release();
mOverlayLayer.release();
@@ -2516,7 +2501,6 @@
mRemovingDisplay = false;
}
- mDisplayPolicy.onDisplayRemoved();
mWmService.mWindowPlacerLocked.requestTraversal();
}
@@ -4825,15 +4809,11 @@
}
void registerPointerEventListener(@NonNull PointerEventListener listener) {
- if (mPointerEventDispatcher != null) {
- mPointerEventDispatcher.registerInputEventListener(listener);
- }
+ mPointerEventDispatcher.registerInputEventListener(listener);
}
void unregisterPointerEventListener(@NonNull PointerEventListener listener) {
- if (mPointerEventDispatcher != null) {
- mPointerEventDispatcher.unregisterInputEventListener(listener);
- }
+ mPointerEventDispatcher.unregisterInputEventListener(listener);
}
void prepareAppTransition(@WindowManager.TransitionType int transit,
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index 5862d43..e48361f 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -221,7 +221,6 @@
}
}
- @VisibleForTesting
private final SystemGesturesPointerEventListener mSystemGestures;
private volatile int mLidState = LID_ABSENT;
@@ -548,10 +547,6 @@
return mDisplayContent.getDisplayId();
}
- void onDisplayRemoved() {
- mDisplayContent.unregisterPointerEventListener(mSystemGestures);
- }
-
void configure(int width, int height, int shortSizeDp) {
// Allow the navigation bar to move on non-square small devices (phones).
mNavigationBarCanMove = width != height && shortSizeDp < 600;
diff --git a/services/core/java/com/android/server/wm/PointerEventDispatcher.java b/services/core/java/com/android/server/wm/PointerEventDispatcher.java
index f815fa0..8d08aa3 100644
--- a/services/core/java/com/android/server/wm/PointerEventDispatcher.java
+++ b/services/core/java/com/android/server/wm/PointerEventDispatcher.java
@@ -28,11 +28,13 @@
import java.util.ArrayList;
public class PointerEventDispatcher extends InputEventReceiver {
- ArrayList<PointerEventListener> mListeners = new ArrayList<PointerEventListener>();
- PointerEventListener[] mListenersArray = new PointerEventListener[0];
+ private final InputChannel mInputChannel;
+ private final ArrayList<PointerEventListener> mListeners = new ArrayList<>();
+ private PointerEventListener[] mListenersArray = new PointerEventListener[0];
public PointerEventDispatcher(InputChannel inputChannel) {
super(inputChannel, UiThread.getHandler().getLooper());
+ mInputChannel = inputChannel;
}
@Override
@@ -87,4 +89,15 @@
mListenersArray = null;
}
}
+
+ /** Dispose the associated input channel and clean up the listeners. */
+ @Override
+ public void dispose() {
+ super.dispose();
+ mInputChannel.dispose();
+ synchronized (mListeners) {
+ mListeners.clear();
+ mListenersArray = null;
+ }
+ }
}
diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp
index 5c7b287..050a079 100644
--- a/services/core/jni/Android.bp
+++ b/services/core/jni/Android.bp
@@ -38,6 +38,7 @@
"com_android_server_SerialService.cpp",
"com_android_server_storage_AppFuseBridge.cpp",
"com_android_server_SystemServer.cpp",
+ "com_android_server_TestNetworkService.cpp",
"com_android_server_tv_TvUinputBridge.cpp",
"com_android_server_tv_TvInputHal.cpp",
"com_android_server_vr_VrManagerService.cpp",
diff --git a/services/core/jni/com_android_server_TestNetworkService.cpp b/services/core/jni/com_android_server_TestNetworkService.cpp
new file mode 100644
index 0000000..b90ff23
--- /dev/null
+++ b/services/core/jni/com_android_server_TestNetworkService.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_NDEBUG 0
+
+#define LOG_TAG "TestNetworkServiceJni"
+
+#include <arpa/inet.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/if.h>
+#include <linux/if_tun.h>
+#include <linux/ipv6_route.h>
+#include <linux/route.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <log/log.h>
+
+#include "netutils/ifc.h"
+
+#include "jni.h"
+#include <android-base/stringprintf.h>
+#include <android-base/unique_fd.h>
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedUtfChars.h>
+
+namespace android {
+
+//------------------------------------------------------------------------------
+
+static void throwException(JNIEnv* env, int error, const char* action, const char* iface) {
+ const std::string& msg =
+ android::base::StringPrintf("Error %s %s: %s", action, iface, strerror(error));
+
+ jniThrowException(env, "java/lang/IllegalStateException", msg.c_str());
+}
+
+static int createTunInterface(JNIEnv* env, const char* iface) {
+ base::unique_fd tun(open("/dev/tun", O_RDWR | O_NONBLOCK));
+ ifreq ifr{};
+
+ // Allocate interface.
+ ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
+ strlcpy(ifr.ifr_name, iface, IFNAMSIZ);
+ if (ioctl(tun.get(), TUNSETIFF, &ifr)) {
+ throwException(env, errno, "allocating", ifr.ifr_name);
+ return -1;
+ }
+
+ // Activate interface using an unconnected datagram socket.
+ base::unique_fd inet6CtrlSock(socket(AF_INET6, SOCK_DGRAM, 0));
+ ifr.ifr_flags = IFF_UP;
+
+ if (ioctl(inet6CtrlSock.get(), SIOCSIFFLAGS, &ifr)) {
+ throwException(env, errno, "activating", ifr.ifr_name);
+ return -1;
+ }
+
+ return tun.release();
+}
+
+//------------------------------------------------------------------------------
+
+static jint create(JNIEnv* env, jobject /* thiz */, jstring jIface) {
+ ScopedUtfChars iface(env, jIface);
+ if (!iface.c_str()) {
+ jniThrowNullPointerException(env, "iface");
+ return -1;
+ }
+
+ int tun = createTunInterface(env, iface.c_str());
+
+ // Any exceptions will be thrown from the createTunInterface call
+ return tun;
+}
+
+//------------------------------------------------------------------------------
+
+static const JNINativeMethod gMethods[] = {
+ {"jniCreateTun", "(Ljava/lang/String;)I", (void*)create},
+};
+
+int register_android_server_TestNetworkService(JNIEnv* env) {
+ return jniRegisterNativeMethods(env, "com/android/server/TestNetworkService", gMethods,
+ NELEM(gMethods));
+}
+
+}; // namespace android
diff --git a/services/core/jni/onload.cpp b/services/core/jni/onload.cpp
index 6e31aed..5ffed03 100644
--- a/services/core/jni/onload.cpp
+++ b/services/core/jni/onload.cpp
@@ -41,6 +41,7 @@
int register_android_server_location_GnssLocationProvider(JNIEnv* env);
int register_android_server_connectivity_Vpn(JNIEnv* env);
int register_android_server_connectivity_tethering_OffloadHardwareInterface(JNIEnv*);
+int register_android_server_TestNetworkService(JNIEnv* env);
int register_android_server_devicepolicy_CryptoTestHelper(JNIEnv*);
int register_android_server_hdmi_HdmiCecController(JNIEnv* env);
int register_android_server_tv_TvUinputBridge(JNIEnv* env);
@@ -85,6 +86,7 @@
register_android_server_location_GnssLocationProvider(env);
register_android_server_connectivity_Vpn(env);
register_android_server_connectivity_tethering_OffloadHardwareInterface(env);
+ register_android_server_TestNetworkService(env);
register_android_server_devicepolicy_CryptoTestHelper(env);
register_android_server_ConsumerIrService(env);
register_android_server_BatteryStatsService(env);
diff --git a/services/net/OWNERS b/services/net/OWNERS
index 7311eee..d3836d4 100644
--- a/services/net/OWNERS
+++ b/services/net/OWNERS
@@ -1,8 +1,8 @@
set noparent
codewiz@google.com
-ek@google.com
jchalard@google.com
+junyulai@google.com
lorenzo@google.com
reminv@google.com
satk@google.com
diff --git a/services/net/java/android/net/NetworkStackClient.java b/services/net/java/android/net/NetworkStackClient.java
index 830dbbe..eed01ae 100644
--- a/services/net/java/android/net/NetworkStackClient.java
+++ b/services/net/java/android/net/NetworkStackClient.java
@@ -289,7 +289,8 @@
private void requestConnector(@NonNull NetworkStackCallback request) {
// TODO: PID check.
final int caller = Binder.getCallingUid();
- if (caller != Process.SYSTEM_UID && !UserHandle.isSameApp(caller, Process.BLUETOOTH_UID)) {
+ if (caller != Process.SYSTEM_UID && !UserHandle.isSameApp(caller, Process.BLUETOOTH_UID)
+ && !UserHandle.isSameApp(caller, Process.PHONE_UID)) {
// Don't even attempt to obtain the connector and give a nice error message
throw new SecurityException(
"Only the system server should try to bind to the network stack.");
diff --git a/services/net/java/android/net/ip/IpServer.java b/services/net/java/android/net/ip/IpServer.java
index 34fc735..0e44f88 100644
--- a/services/net/java/android/net/ip/IpServer.java
+++ b/services/net/java/android/net/ip/IpServer.java
@@ -87,7 +87,6 @@
return "UNKNOWN: " + state;
}
- private static final IpPrefix LINK_LOCAL_PREFIX = new IpPrefix("fe80::/64");
private static final byte DOUG_ADAMS = (byte) 42;
private static final String USB_NEAR_IFACE_ADDR = "192.168.42.129";
@@ -557,16 +556,6 @@
addedPrefixes.removeAll(mLastRaParams.prefixes);
}
- if (mLastRaParams == null || mLastRaParams.prefixes.isEmpty()) {
- // We need to be able to send unicast RAs, and clients might
- // like to ping the default router's link-local address. Note
- // that we never remove the link-local route from the network
- // until Tethering disables tethering on the interface. We
- // only need to add the link-local prefix once, but in the
- // event we add it more than once netd silently ignores EEXIST.
- addedPrefixes.add(LINK_LOCAL_PREFIX);
- }
-
if (!addedPrefixes.isEmpty()) {
final ArrayList<RouteInfo> toBeAdded =
getLocalRoutesFor(mIfaceName, addedPrefixes);
diff --git a/services/tests/uiservicestests/Android.bp b/services/tests/uiservicestests/Android.bp
index 92198fa..0ef2d15 100644
--- a/services/tests/uiservicestests/Android.bp
+++ b/services/tests/uiservicestests/Android.bp
@@ -18,6 +18,7 @@
"services.usage",
"guava",
"androidx.test.rules", "hamcrest-library",
+ "compatibility-device-util-axt",
"mockito-target-inline-minus-junit4",
"platform-test-annotations",
"hamcrest-library",
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index 7df52b2..49d8ad0 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -42,6 +42,8 @@
import static android.service.notification.NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE;
import static android.service.notification.NotificationListenerService.Ranking.USER_SENTIMENT_NEUTRAL;
+import static com.android.compatibility.common.util.SystemUtil.runWithShellPermissionIdentity;
+
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
@@ -4178,7 +4180,7 @@
mService.setNotificationAssistantAccessGrantedCallback(
mNotificationAssistantAccessGrantedCallback);
- mService.setDefaultAssistantForUser(0);
+ runWithShellPermissionIdentity(() -> mService.setDefaultAssistantForUser(0));
verify(mNotificationAssistantAccessGrantedCallback)
.onGranted(eq(xmlConfig), eq(0), eq(true));
@@ -4198,7 +4200,7 @@
mService.setNotificationAssistantAccessGrantedCallback(
mNotificationAssistantAccessGrantedCallback);
- mService.setDefaultAssistantForUser(0);
+ runWithShellPermissionIdentity(() -> mService.setDefaultAssistantForUser(0));
verify(mNotificationAssistantAccessGrantedCallback)
.onGranted(eq(deviceConfig), eq(0), eq(true));
@@ -4219,22 +4221,22 @@
mService.setNotificationAssistantAccessGrantedCallback(
mNotificationAssistantAccessGrantedCallback);
- mService.setDefaultAssistantForUser(0);
+ runWithShellPermissionIdentity(() -> mService.setDefaultAssistantForUser(0));
verify(mNotificationAssistantAccessGrantedCallback)
.onGranted(eq(xmlConfig), eq(0), eq(true));
}
private void clearDeviceConfig() {
- DeviceConfig.resetToDefaults(
- Settings.RESET_MODE_PACKAGE_DEFAULTS, DeviceConfig.NAMESPACE_SYSTEMUI);
+ runWithShellPermissionIdentity(() -> DeviceConfig.resetToDefaults(
+ Settings.RESET_MODE_PACKAGE_DEFAULTS, DeviceConfig.NAMESPACE_SYSTEMUI));
}
private void setDefaultAssistantInDeviceConfig(String componentName) {
- DeviceConfig.setProperty(
+ runWithShellPermissionIdentity(() -> DeviceConfig.setProperty(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE,
componentName,
- false);
+ false));
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
index d202e16..032eba1 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
@@ -270,7 +270,7 @@
WindowTestUtils.TestAppWindowToken createTestAppWindowToken(DisplayContent dc, int
windowingMode, int activityType) {
return createTestAppWindowToken(dc, windowingMode, activityType,
- true /*skipOnParentChanged */);
+ false /*skipOnParentChanged */);
}
WindowTestUtils.TestAppWindowToken createTestAppWindowToken(DisplayContent dc, int
diff --git a/services/tests/wmtests/src/com/android/server/wm/ZOrderingTests.java b/services/tests/wmtests/src/com/android/server/wm/ZOrderingTests.java
index 2907021..2fc6efa 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ZOrderingTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ZOrderingTests.java
@@ -74,7 +74,7 @@
public SurfaceControl.Transaction setLayer(SurfaceControl sc, int layer) {
mRelativeLayersForControl.remove(sc);
mLayersForControl.put(sc, layer);
- return super.setLayer(sc, layer);
+ return this;
}
@Override
@@ -83,7 +83,7 @@
int layer) {
mRelativeLayersForControl.put(sc, relativeTo);
mLayersForControl.put(sc, layer);
- return super.setRelativeLayer(sc, relativeTo, layer);
+ return this;
}
private int getLayer(SurfaceControl sc) {
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 7688ac6..6f9bc2c 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -478,12 +478,6 @@
"android.telecom.extra.START_CALL_WITH_RTT";
/**
- * A boolean extra set to indicate whether an app is eligible to be bound to when there are
- * ongoing calls on the device.
- */
- public static final String EXTRA_IS_ENABLED = "android.telecom.extra.IS_ENABLED";
-
- /**
* A boolean meta-data value indicating whether an {@link InCallService} implements an
* in-call user interface. Dialer implementations (see {@link #getDefaultDialerPackage()}) which
* would also like to replace the in-call interface should set this meta-data to {@code true} in
diff --git a/telephony/java/android/telephony/AvailableNetworkInfo.java b/telephony/java/android/telephony/AvailableNetworkInfo.java
index 8a7153e..a15f959 100644
--- a/telephony/java/android/telephony/AvailableNetworkInfo.java
+++ b/telephony/java/android/telephony/AvailableNetworkInfo.java
@@ -16,6 +16,7 @@
package android.telephony;
+import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
@@ -62,11 +63,22 @@
/**
* Describes the List of PLMN ids (MCC-MNC) associated with mSubId.
* If this entry is left empty, then the platform software will not scan the network
- * to revalidate the input.
+ * to revalidate the input else platform will scan and verify specified PLMNs are available.
*/
private ArrayList<String> mMccMncs;
/**
+ * Returns the frequency bands associated with the {@link #getMccMncs() MCC/MNCs}.
+ * Opportunistic network service will use these bands to scan.
+ *
+ * When no specific bands are specified (empty array or null) CBRS band (B48) will be
+ * used for network scan.
+ *
+ * See {@link AccessNetworkConstants} for details.
+ */
+ private ArrayList<Integer> mBands;
+
+ /**
* Return subscription Id of the available network.
* This value must be one of the entry retrieved from
* {@link SubscriptionManager#getOpportunisticSubscriptions}
@@ -91,10 +103,20 @@
* to revalidate the input.
* @return list of PLMN ids
*/
- public List<String> getMccMncs() {
+ public @NonNull List<String> getMccMncs() {
return (List<String>) mMccMncs.clone();
}
+ /**
+ * Returns the frequency bands that need to be scanned by opportunistic network service
+ *
+ * The returned value is defined in either of {@link AccessNetworkConstants.GeranBand},
+ * {@link AccessNetworkConstants.UtranBand} and {@link AccessNetworkConstants.EutranBand}
+ */
+ public @NonNull List<Integer> getBands() {
+ return (List<Integer>) mBands.clone();
+ }
+
@Override
public int describeContents() {
return 0;
@@ -105,6 +127,7 @@
dest.writeInt(mSubId);
dest.writeInt(mPriority);
dest.writeStringList(mMccMncs);
+ dest.writeList(mBands);
}
private AvailableNetworkInfo(Parcel in) {
@@ -112,12 +135,16 @@
mPriority = in.readInt();
mMccMncs = new ArrayList<>();
in.readStringList(mMccMncs);
+ mBands = new ArrayList<>();
+ in.readList(mBands, Integer.class.getClassLoader());
}
- public AvailableNetworkInfo(int subId, int priority, List<String> mccMncs) {
+ public AvailableNetworkInfo(int subId, int priority, @NonNull List<String> mccMncs,
+ @NonNull List<Integer> bands) {
mSubId = subId;
mPriority = priority;
mMccMncs = new ArrayList<String>(mccMncs);
+ mBands = new ArrayList<Integer>(bands);
}
@Override
@@ -135,14 +162,15 @@
}
return (mSubId == ani.mSubId
- && mPriority == ani.mPriority
- && (((mMccMncs != null)
- && mMccMncs.equals(ani.mMccMncs))));
+ && mPriority == ani.mPriority
+ && (((mMccMncs != null)
+ && mMccMncs.equals(ani.mMccMncs)))
+ && mBands.equals(ani.mBands));
}
@Override
public int hashCode() {
- return Objects.hash(mSubId, mPriority, mMccMncs);
+ return Objects.hash(mSubId, mPriority, mMccMncs, mBands);
}
public static final @android.annotation.NonNull Parcelable.Creator<AvailableNetworkInfo> CREATOR =
@@ -161,9 +189,9 @@
@Override
public String toString() {
return ("AvailableNetworkInfo:"
- + " mSubId: " + mSubId
- + " mPriority: " + mPriority
- + " mMccMncs: " + Arrays.toString(mMccMncs.toArray()));
+ + " mSubId: " + mSubId
+ + " mPriority: " + mPriority
+ + " mMccMncs: " + Arrays.toString(mMccMncs.toArray())
+ + " mBands: " + Arrays.toString(mBands.toArray()));
}
}
-
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 511b278..5262cf8 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -31,6 +31,7 @@
import android.os.RemoteException;
import android.os.ServiceManager;
import android.service.carrier.CarrierService;
+import android.telecom.TelecomManager;
import android.telephony.ims.ImsReasonInfo;
import com.android.internal.telephony.ICarrierConfigLoader;
@@ -2114,6 +2115,18 @@
public static final String KEY_RTT_SUPPORTED_BOOL = "rtt_supported_bool";
/**
+ * Boolean flag indicating whether the carrier supports TTY.
+ * <p>
+ * Note that {@link #KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL} controls availability of TTY over
+ * VoLTE; if {@link #KEY_TTY_SUPPORTED_BOOL} is disabled, then
+ * {@link #KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL} is also implicitly disabled.
+ * <p>
+ * {@link TelecomManager#isTtySupported()} should be used to determine if a device supports TTY,
+ * and this carrier config key should be used to see if the current carrier supports it.
+ */
+ public static final String KEY_TTY_SUPPORTED_BOOL = "tty_supported_bool";
+
+ /**
* Indicates if the carrier supports auto-upgrading a call to RTT when receiving a call from a
* RTT-supported device.
* @hide
@@ -2959,6 +2972,7 @@
sDefaults.putStringArray(KEY_ROAMING_OPERATOR_STRING_ARRAY, null);
sDefaults.putBoolean(KEY_SHOW_IMS_REGISTRATION_STATUS_BOOL, false);
sDefaults.putBoolean(KEY_RTT_SUPPORTED_BOOL, false);
+ sDefaults.putBoolean(KEY_TTY_SUPPORTED_BOOL, true);
sDefaults.putBoolean(KEY_DISABLE_CHARGE_INDICATION_BOOL, false);
sDefaults.putBoolean(KEY_SUPPORT_NO_REPLY_TIMER_FOR_CFNRY_BOOL, true);
sDefaults.putStringArray(KEY_FEATURE_ACCESS_CODES_STRING_ARRAY, null);
diff --git a/telephony/java/android/telephony/CellInfo.java b/telephony/java/android/telephony/CellInfo.java
index 223f3ef..1796034 100644
--- a/telephony/java/android/telephony/CellInfo.java
+++ b/telephony/java/android/telephony/CellInfo.java
@@ -22,7 +22,6 @@
import android.hardware.radio.V1_4.CellInfo.Info;
import android.os.Parcel;
import android.os.Parcelable;
-import android.os.SystemClock;
import com.android.internal.annotations.VisibleForTesting;
@@ -325,9 +324,9 @@
}
/** @hide */
- protected CellInfo(android.hardware.radio.V1_4.CellInfo ci) {
+ protected CellInfo(android.hardware.radio.V1_4.CellInfo ci, long timeStamp) {
this.mRegistered = ci.isRegistered;
- this.mTimeStamp = SystemClock.elapsedRealtimeNanos();
+ this.mTimeStamp = timeStamp;
this.mCellConnectionStatus = ci.connectionStatus;
}
@@ -358,14 +357,14 @@
}
/** @hide */
- public static CellInfo create(android.hardware.radio.V1_4.CellInfo ci) {
+ public static CellInfo create(android.hardware.radio.V1_4.CellInfo ci, long timeStamp) {
if (ci == null) return null;
switch (ci.info.getDiscriminator()) {
- case Info.hidl_discriminator.gsm: return new CellInfoGsm(ci);
- case Info.hidl_discriminator.cdma: return new CellInfoCdma(ci);
- case Info.hidl_discriminator.lte: return new CellInfoLte(ci);
- case Info.hidl_discriminator.wcdma: return new CellInfoWcdma(ci);
- case Info.hidl_discriminator.tdscdma: return new CellInfoTdscdma(ci);
+ case Info.hidl_discriminator.gsm: return new CellInfoGsm(ci, timeStamp);
+ case Info.hidl_discriminator.cdma: return new CellInfoCdma(ci, timeStamp);
+ case Info.hidl_discriminator.lte: return new CellInfoLte(ci, timeStamp);
+ case Info.hidl_discriminator.wcdma: return new CellInfoWcdma(ci, timeStamp);
+ case Info.hidl_discriminator.tdscdma: return new CellInfoTdscdma(ci, timeStamp);
default: return null;
}
}
diff --git a/telephony/java/android/telephony/CellInfoCdma.java b/telephony/java/android/telephony/CellInfoCdma.java
index 9c38506..82bb3961 100644
--- a/telephony/java/android/telephony/CellInfoCdma.java
+++ b/telephony/java/android/telephony/CellInfoCdma.java
@@ -68,8 +68,8 @@
}
/** @hide */
- public CellInfoCdma(android.hardware.radio.V1_4.CellInfo ci) {
- super(ci);
+ public CellInfoCdma(android.hardware.radio.V1_4.CellInfo ci, long timeStamp) {
+ super(ci, timeStamp);
final android.hardware.radio.V1_2.CellInfoCdma cic = ci.info.cdma();
mCellIdentityCdma = new CellIdentityCdma(cic.cellIdentityCdma);
mCellSignalStrengthCdma =
diff --git a/telephony/java/android/telephony/CellInfoGsm.java b/telephony/java/android/telephony/CellInfoGsm.java
index 0d91f80..59fcd1e 100644
--- a/telephony/java/android/telephony/CellInfoGsm.java
+++ b/telephony/java/android/telephony/CellInfoGsm.java
@@ -64,8 +64,8 @@
}
/** @hide */
- public CellInfoGsm(android.hardware.radio.V1_4.CellInfo ci) {
- super(ci);
+ public CellInfoGsm(android.hardware.radio.V1_4.CellInfo ci, long timeStamp) {
+ super(ci, timeStamp);
final android.hardware.radio.V1_2.CellInfoGsm cig = ci.info.gsm();
mCellIdentityGsm = new CellIdentityGsm(cig.cellIdentityGsm);
mCellSignalStrengthGsm = new CellSignalStrengthGsm(cig.signalStrengthGsm);
diff --git a/telephony/java/android/telephony/CellInfoLte.java b/telephony/java/android/telephony/CellInfoLte.java
index deae632..08dafe1 100644
--- a/telephony/java/android/telephony/CellInfoLte.java
+++ b/telephony/java/android/telephony/CellInfoLte.java
@@ -71,8 +71,8 @@
}
/** @hide */
- public CellInfoLte(android.hardware.radio.V1_4.CellInfo ci) {
- super(ci);
+ public CellInfoLte(android.hardware.radio.V1_4.CellInfo ci, long timeStamp) {
+ super(ci, timeStamp);
final android.hardware.radio.V1_4.CellInfoLte cil = ci.info.lte();
mCellIdentityLte = new CellIdentityLte(cil.base.cellIdentityLte);
mCellSignalStrengthLte = new CellSignalStrengthLte(cil.base.signalStrengthLte);
diff --git a/telephony/java/android/telephony/CellInfoTdscdma.java b/telephony/java/android/telephony/CellInfoTdscdma.java
index ae43bb2..93baabf 100644
--- a/telephony/java/android/telephony/CellInfoTdscdma.java
+++ b/telephony/java/android/telephony/CellInfoTdscdma.java
@@ -65,8 +65,8 @@
}
/** @hide */
- public CellInfoTdscdma(android.hardware.radio.V1_4.CellInfo ci) {
- super(ci);
+ public CellInfoTdscdma(android.hardware.radio.V1_4.CellInfo ci, long timeStamp) {
+ super(ci, timeStamp);
final android.hardware.radio.V1_2.CellInfoTdscdma cit = ci.info.tdscdma();
mCellIdentityTdscdma = new CellIdentityTdscdma(cit.cellIdentityTdscdma);
mCellSignalStrengthTdscdma = new CellSignalStrengthTdscdma(cit.signalStrengthTdscdma);
diff --git a/telephony/java/android/telephony/CellInfoWcdma.java b/telephony/java/android/telephony/CellInfoWcdma.java
index d2287ea..02dbb1a 100644
--- a/telephony/java/android/telephony/CellInfoWcdma.java
+++ b/telephony/java/android/telephony/CellInfoWcdma.java
@@ -64,8 +64,8 @@
}
/** @hide */
- public CellInfoWcdma(android.hardware.radio.V1_4.CellInfo ci) {
- super(ci);
+ public CellInfoWcdma(android.hardware.radio.V1_4.CellInfo ci, long timeStamp) {
+ super(ci, timeStamp);
final android.hardware.radio.V1_2.CellInfoWcdma ciw = ci.info.wcdma();
mCellIdentityWcdma = new CellIdentityWcdma(ciw.cellIdentityWcdma);
mCellSignalStrengthWcdma = new CellSignalStrengthWcdma(ciw.signalStrengthWcdma);
diff --git a/telephony/java/android/telephony/MbmsGroupCallSession.java b/telephony/java/android/telephony/MbmsGroupCallSession.java
index 269cda1..f1be31f 100644
--- a/telephony/java/android/telephony/MbmsGroupCallSession.java
+++ b/telephony/java/android/telephony/MbmsGroupCallSession.java
@@ -141,7 +141,7 @@
* Create a new {@link MbmsGroupCallSession} using the system default data subscription ID.
* See {@link #create(Context, int, Executor, MbmsGroupCallSessionCallback)}.
*/
- public static MbmsGroupCallSession create(@NonNull Context context,
+ public static @Nullable MbmsGroupCallSession create(@NonNull Context context,
@NonNull Executor executor, @NonNull MbmsGroupCallSessionCallback callback) {
return create(context, SubscriptionManager.getDefaultSubscriptionId(), executor, callback);
}
diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java
index fb6f39d..245f5b3 100644
--- a/telephony/java/android/telephony/SubscriptionInfo.java
+++ b/telephony/java/android/telephony/SubscriptionInfo.java
@@ -425,14 +425,14 @@
/**
* @return The MCC, as a string.
*/
- public String getMccString() {
+ public @Nullable String getMccString() {
return this.mMcc;
}
/**
* @return The MNC, as a string.
*/
- public String getMncString() {
+ public @Nullable String getMncString() {
return this.mMnc;
}
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 8edc5b4..d9a37c6 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -2706,7 +2706,8 @@
* 1) Even if it's active, it will be dormant most of the time. The modem will not try
* to scan or camp until it knows an available network is nearby to save power.
* 2) Telephony relies on system app or carrier input to notify nearby available networks.
- * See {@link TelephonyManager#updateAvailableNetworks(List)} for more information.
+ * See {@link TelephonyManager#updateAvailableNetworks(List, Executor, Consumer)}
+ * for more information.
* 3) In multi-SIM devices, when the network is nearby and camped, system may automatically
* switch internet data between it and default data subscription, based on carrier
* recommendation and its signal strength and metered-ness, etc.
@@ -2938,7 +2939,7 @@
}
/**
- * Enabled or disable a subscription. This is currently used in the settings page.
+ * Enables or disables a subscription. This is currently used in the settings page.
*
* <p>
* Permissions android.Manifest.permission.MODIFY_PHONE_STATE is required
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index dd58f31..9ca5717 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -84,6 +84,7 @@
import com.android.internal.telephony.ISetOpportunisticDataCallback;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.ITelephonyRegistry;
+import com.android.internal.telephony.IUpdateAvailableNetworksCallback;
import com.android.internal.telephony.OperatorInfo;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.RILConstants;
@@ -10190,6 +10191,41 @@
*/
public static final int SET_OPPORTUNISTIC_SUB_INVALID_PARAMETER = 2;
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"UPDATE_AVAILABLE_NETWORKS"}, value = {
+ UPDATE_AVAILABLE_NETWORKS_SUCCESS,
+ UPDATE_AVAILABLE_NETWORKS_UNKNOWN_FAILURE,
+ UPDATE_AVAILABLE_NETWORKS_ABORTED,
+ UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS,
+ UPDATE_AVAILABLE_NETWORKS_NO_CARRIER_PRIVILEGE})
+ public @interface UpdateAvailableNetworksResult {}
+
+ /**
+ * No error. Operation succeeded.
+ */
+ public static final int UPDATE_AVAILABLE_NETWORKS_SUCCESS = 0;
+
+ /**
+ * There is a unknown failure happened.
+ */
+ public static final int UPDATE_AVAILABLE_NETWORKS_UNKNOWN_FAILURE = 1;
+
+ /**
+ * The request is aborted.
+ */
+ public static final int UPDATE_AVAILABLE_NETWORKS_ABORTED = 2;
+
+ /**
+ * The parameter passed in is invalid.
+ */
+ public static final int UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS = 3;
+
+ /**
+ * No carrier privilege.
+ */
+ public static final int UPDATE_AVAILABLE_NETWORKS_NO_CARRIER_PRIVILEGE = 4;
+
/**
* Set preferred opportunistic data subscription id.
*
@@ -10272,28 +10308,46 @@
* This api should be called to inform OpportunisticNetwork Service about the availability
* of a network at the current location. This information will be used by OpportunisticNetwork
* service to decide to attach to the network opportunistically. If an empty list is passed,
- * it is assumed that no network is available.
+ * it is assumed that no network is available and will result in disabling the modem stack
+ * to save power.
* Requires that the calling app has carrier privileges on both primary and
* secondary subscriptions (see {@link #hasCarrierPrivileges}), or has permission
* {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}.
* @param availableNetworks is a list of available network information.
- * @return true if request is accepted
+ * @param executor The executor of where the callback will execute.
+ * @param callback Callback will be triggered once it succeeds or failed.
*
*/
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
- public boolean updateAvailableNetworks(List<AvailableNetworkInfo> availableNetworks) {
+ public void updateAvailableNetworks(@NonNull List<AvailableNetworkInfo> availableNetworks,
+ @Nullable @CallbackExecutor Executor executor,
+ @UpdateAvailableNetworksResult @Nullable Consumer<Integer> callback) {
String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>";
- boolean ret = false;
try {
IOns iOpportunisticNetworkService = getIOns();
- if (iOpportunisticNetworkService != null && availableNetworks != null) {
- ret = iOpportunisticNetworkService.updateAvailableNetworks(availableNetworks,
- pkgForDebug);
+ if (iOpportunisticNetworkService == null || availableNetworks == null) {
+ Binder.withCleanCallingIdentity(() -> executor.execute(() -> {
+ callback.accept(UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS);
+ }));
+ return;
}
+ IUpdateAvailableNetworksCallback callbackStub =
+ new IUpdateAvailableNetworksCallback.Stub() {
+ @Override
+ public void onComplete(int result) {
+ if (executor == null || callback == null) {
+ return;
+ }
+ Binder.withCleanCallingIdentity(() -> executor.execute(() -> {
+ callback.accept(result);
+ }));
+ }
+ };
+ iOpportunisticNetworkService.updateAvailableNetworks(availableNetworks, callbackStub,
+ pkgForDebug);
} catch (RemoteException ex) {
Rlog.e(TAG, "updateAvailableNetworks RemoteException", ex);
}
- return ret;
}
/**
diff --git a/telephony/java/com/android/internal/telephony/IOns.aidl b/telephony/java/com/android/internal/telephony/IOns.aidl
index 0364477..2c48b65 100755
--- a/telephony/java/com/android/internal/telephony/IOns.aidl
+++ b/telephony/java/com/android/internal/telephony/IOns.aidl
@@ -19,6 +19,7 @@
import android.telephony.AvailableNetworkInfo;
import com.android.internal.telephony.ISetOpportunisticDataCallback;
+import com.android.internal.telephony.IUpdateAvailableNetworksCallback;
interface IOns {
@@ -97,9 +98,9 @@
* {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}.
* @param availableNetworks is a list of available network information.
* @param callingPackage caller's package name
- * @return true if request is accepted
+ * @param callback callback upon request completion.
*
*/
- boolean updateAvailableNetworks(in List<AvailableNetworkInfo> availableNetworks,
- String callingPackage);
+ void updateAvailableNetworks(in List<AvailableNetworkInfo> availableNetworks,
+ IUpdateAvailableNetworksCallback callbackStub, String callingPackage);
}
diff --git a/telephony/java/com/android/internal/telephony/IUpdateAvailableNetworksCallback.aidl b/telephony/java/com/android/internal/telephony/IUpdateAvailableNetworksCallback.aidl
new file mode 100644
index 0000000..8fe086ce
--- /dev/null
+++ b/telephony/java/com/android/internal/telephony/IUpdateAvailableNetworksCallback.aidl
@@ -0,0 +1,25 @@
+/*
+ * 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 com.android.internal.telephony;
+
+/**
+ * Callback to provide asynchronous result of updateAvailableNetworks.
+ * @hide
+ */
+oneway interface IUpdateAvailableNetworksCallback {
+ void onComplete(int result);
+}
diff --git a/tests/AccessibilityEventsLogger/Android.bp b/tests/AccessibilityEventsLogger/Android.bp
new file mode 100644
index 0000000..ead1656
--- /dev/null
+++ b/tests/AccessibilityEventsLogger/Android.bp
@@ -0,0 +1,9 @@
+android_test {
+ name: "AccessibilityEventsLogger",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ certificate: "platform",
+ optimize: {
+ enabled: false,
+ },
+}
diff --git a/tests/AccessibilityEventsLogger/Android.mk b/tests/AccessibilityEventsLogger/Android.mk
deleted file mode 100644
index 4224017..0000000
--- a/tests/AccessibilityEventsLogger/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := AccessibilityEventsLogger
-LOCAL_SDK_VERSION := current
-LOCAL_CERTIFICATE := platform
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-include $(BUILD_PACKAGE)
diff --git a/tests/AccessoryDisplay/Android.mk b/tests/AccessoryDisplay/Android.mk
deleted file mode 100644
index 85cb309..0000000
--- a/tests/AccessoryDisplay/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (C) 2013 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/AccessoryDisplay/common/Android.bp b/tests/AccessoryDisplay/common/Android.bp
new file mode 100644
index 0000000..3ce4c57
--- /dev/null
+++ b/tests/AccessoryDisplay/common/Android.bp
@@ -0,0 +1,20 @@
+// Copyright (C) 2013 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.
+
+// Build the application.
+java_library_static {
+ name: "AccessoryDisplayCommon",
+ sdk_version: "current",
+ srcs: ["src/**/*.java"],
+}
diff --git a/tests/AccessoryDisplay/common/Android.mk b/tests/AccessoryDisplay/common/Android.mk
deleted file mode 100644
index 2d4de15..0000000
--- a/tests/AccessoryDisplay/common/Android.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (C) 2013 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.
-
-LOCAL_PATH := $(call my-dir)
-
-# Build the application.
-include $(CLEAR_VARS)
-LOCAL_MODULE := AccessoryDisplayCommon
-LOCAL_MODULE_TAGS := tests
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/tests/AccessoryDisplay/sink/Android.bp b/tests/AccessoryDisplay/sink/Android.bp
new file mode 100644
index 0000000..4e50a81
--- /dev/null
+++ b/tests/AccessoryDisplay/sink/Android.bp
@@ -0,0 +1,22 @@
+// Copyright (C) 2013 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.
+
+// Build the application.
+android_test {
+ name: "AccessoryDisplaySink",
+ sdk_version: "current",
+ srcs: ["src/**/*.java"],
+ resource_dirs: ["res"],
+ static_libs: ["AccessoryDisplayCommon"],
+}
diff --git a/tests/AccessoryDisplay/sink/Android.mk b/tests/AccessoryDisplay/sink/Android.mk
deleted file mode 100644
index 772ce0c..0000000
--- a/tests/AccessoryDisplay/sink/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2013 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.
-
-LOCAL_PATH := $(call my-dir)
-
-# Build the application.
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := AccessoryDisplaySink
-LOCAL_MODULE_TAGS := tests
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_RESOURCE_DIR = $(LOCAL_PATH)/res
-LOCAL_STATIC_JAVA_LIBRARIES := AccessoryDisplayCommon
-include $(BUILD_PACKAGE)
diff --git a/tests/AccessoryDisplay/source/Android.bp b/tests/AccessoryDisplay/source/Android.bp
new file mode 100644
index 0000000..6d8087f
--- /dev/null
+++ b/tests/AccessoryDisplay/source/Android.bp
@@ -0,0 +1,22 @@
+// Copyright (C) 2013 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.
+
+// Build the application.
+android_test {
+ name: "AccessoryDisplaySource",
+ sdk_version: "current",
+ srcs: ["src/**/*.java"],
+ resource_dirs: ["res"],
+ static_libs: ["AccessoryDisplayCommon"],
+}
diff --git a/tests/AccessoryDisplay/source/Android.mk b/tests/AccessoryDisplay/source/Android.mk
deleted file mode 100644
index 5d1085d..0000000
--- a/tests/AccessoryDisplay/source/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2013 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.
-
-LOCAL_PATH := $(call my-dir)
-
-# Build the application.
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := AccessoryDisplaySource
-LOCAL_MODULE_TAGS := tests
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_RESOURCE_DIR = $(LOCAL_PATH)/res
-LOCAL_STATIC_JAVA_LIBRARIES := AccessoryDisplayCommon
-include $(BUILD_PACKAGE)
diff --git a/tests/ActivityTests/Android.bp b/tests/ActivityTests/Android.bp
new file mode 100644
index 0000000..0182862
--- /dev/null
+++ b/tests/ActivityTests/Android.bp
@@ -0,0 +1,6 @@
+android_test {
+ name: "ActivityTest",
+ srcs: ["**/*.java"],
+ platform_apis: true,
+ certificate: "platform",
+}
diff --git a/tests/ActivityTests/Android.mk b/tests/ActivityTests/Android.mk
deleted file mode 100644
index 94294f6..0000000
--- a/tests/ActivityTests/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := ActivityTest
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_CERTIFICATE := platform
-
-LOCAL_USE_AAPT2 := true
-
-include $(BUILD_PACKAGE)
diff --git a/tests/AmSlam/Android.bp b/tests/AmSlam/Android.bp
new file mode 100644
index 0000000..a8e575a
--- /dev/null
+++ b/tests/AmSlam/Android.bp
@@ -0,0 +1,23 @@
+//
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "AmSlam",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ min_sdk_version: "21",
+ java_version: "1.8",
+}
diff --git a/tests/AmSlam/Android.mk b/tests/AmSlam/Android.mk
deleted file mode 100644
index 934bae0..0000000
--- a/tests/AmSlam/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright (C) 2016 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := AmSlam
-
-LOCAL_SDK_VERSION := current
-LOCAL_MIN_SDK_VERSION := 21
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/Assist/Android.bp b/tests/Assist/Android.bp
new file mode 100644
index 0000000..216e751
--- /dev/null
+++ b/tests/Assist/Android.bp
@@ -0,0 +1,5 @@
+android_test {
+ name: "Assist",
+ srcs: ["**/*.java"],
+ platform_apis: true,
+}
diff --git a/tests/Assist/Android.mk b/tests/Assist/Android.mk
deleted file mode 100644
index d0d3eca..0000000
--- a/tests/Assist/Android.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := Assist
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-include $(BUILD_PACKAGE)
diff --git a/tests/BandwidthTests/Android.bp b/tests/BandwidthTests/Android.bp
new file mode 100644
index 0000000..523f522
--- /dev/null
+++ b/tests/BandwidthTests/Android.bp
@@ -0,0 +1,21 @@
+//
+// Copyright (C) 2011 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "BandwidthEnforcementTest",
+ platform_apis: true,
+ srcs: ["src/**/*.java"],
+}
diff --git a/tests/BandwidthTests/Android.mk b/tests/BandwidthTests/Android.mk
deleted file mode 100644
index d00fdc6..0000000
--- a/tests/BandwidthTests/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_PACKAGE_NAME := BandwidthEnforcementTest
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_PACKAGE)
diff --git a/tests/BatteryWaster/Android.bp b/tests/BatteryWaster/Android.bp
new file mode 100644
index 0000000..4698910
--- /dev/null
+++ b/tests/BatteryWaster/Android.bp
@@ -0,0 +1,6 @@
+android_test {
+ name: "BatteryWaster",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ certificate: "platform",
+}
diff --git a/tests/BatteryWaster/Android.mk b/tests/BatteryWaster/Android.mk
deleted file mode 100644
index fb244a8..0000000
--- a/tests/BatteryWaster/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := BatteryWaster
-LOCAL_SDK_VERSION := current
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
diff --git a/tests/BiDiTests/Android.bp b/tests/BiDiTests/Android.bp
new file mode 100644
index 0000000..c659e8c
--- /dev/null
+++ b/tests/BiDiTests/Android.bp
@@ -0,0 +1,23 @@
+// Copyright (C) 2011 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_test {
+ name: "BiDiTests",
+ // Only compile source java files in this apk.
+ srcs: ["src/**/*.java"],
+ sdk_version: "current",
+ optimize: {
+ proguard_flags_files: ["proguard.flags"],
+ },
+}
diff --git a/tests/BiDiTests/Android.mk b/tests/BiDiTests/Android.mk
deleted file mode 100644
index 78cf4be..0000000
--- a/tests/BiDiTests/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright (C) 2011 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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := BiDiTests
-LOCAL_SDK_VERSION := current
-
-LOCAL_PROGUARD_FLAG_FILES := proguard.flags
-
-include $(BUILD_PACKAGE)
\ No newline at end of file
diff --git a/tests/BrowserPowerTest/Android.bp b/tests/BrowserPowerTest/Android.bp
new file mode 100644
index 0000000..1d358cb
--- /dev/null
+++ b/tests/BrowserPowerTest/Android.bp
@@ -0,0 +1,26 @@
+// Copyright 2008, The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_test {
+ name: "BrowserPowerTests",
+ libs: [
+ "android.test.runner",
+ "android.test.base",
+ ],
+ static_libs: ["junit"],
+ // Include all test java files.
+ srcs: ["src/**/*.java"],
+ platform_apis: true,
+ //LOCAL_INSTRUMENTATION_FOR := browserpowertest
+}
diff --git a/tests/BrowserPowerTest/Android.mk b/tests/BrowserPowerTest/Android.mk
deleted file mode 100644
index 0934889..0000000
--- a/tests/BrowserPowerTest/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2008, 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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base
-LOCAL_STATIC_JAVA_LIBRARIES := junit
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := BrowserPowerTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-#LOCAL_INSTRUMENTATION_FOR := browserpowertest
-
-include $(BUILD_PACKAGE)
diff --git a/tests/Camera2Tests/Android.mk b/tests/Camera2Tests/Android.mk
deleted file mode 100644
index 5053e7d..0000000
--- a/tests/Camera2Tests/Android.mk
+++ /dev/null
@@ -1 +0,0 @@
-include $(call all-subdir-makefiles)
diff --git a/tests/Camera2Tests/SmartCamera/Android.mk b/tests/Camera2Tests/SmartCamera/Android.mk
deleted file mode 100644
index 3fa8f54..0000000
--- a/tests/Camera2Tests/SmartCamera/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-include $(call all-subdir-makefiles)
diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/jni/Android.bp b/tests/Camera2Tests/SmartCamera/SimpleCamera/jni/Android.bp
index 0b16b0e..a23ac38 100644
--- a/tests/Camera2Tests/SmartCamera/SimpleCamera/jni/Android.bp
+++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/jni/Android.bp
@@ -15,9 +15,7 @@
cc_test_library {
name: "libsmartcamera_jni",
-
sdk_version: "14",
-
srcs: [
"contrast.cpp",
"brightness.cpp",
@@ -29,13 +27,11 @@
"sobeloperator.cpp",
"stats_scorer.cpp",
],
-
cflags: [
"-Wall",
"-Wextra",
"-Werror",
"-Wno-unused-parameter",
],
-
stl: "c++_static",
}
diff --git a/tests/CameraPrewarmTest/Android.bp b/tests/CameraPrewarmTest/Android.bp
new file mode 100644
index 0000000..eaf453b
--- /dev/null
+++ b/tests/CameraPrewarmTest/Android.bp
@@ -0,0 +1,6 @@
+android_test {
+ name: "CameraPrewarmTest",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ certificate: "platform",
+}
diff --git a/tests/CameraPrewarmTest/Android.mk b/tests/CameraPrewarmTest/Android.mk
deleted file mode 100644
index e128504..0000000
--- a/tests/CameraPrewarmTest/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := CameraPrewarmTest
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
diff --git a/tests/CoreTests/Android.mk b/tests/CoreTests/Android.mk
deleted file mode 100644
index 8338432..0000000
--- a/tests/CoreTests/Android.mk
+++ /dev/null
@@ -1,2 +0,0 @@
-include $(call all-subdir-makefiles)
-
diff --git a/tests/CoreTests/android/Android.bp b/tests/CoreTests/android/Android.bp
new file mode 100644
index 0000000..24134e8
--- /dev/null
+++ b/tests/CoreTests/android/Android.bp
@@ -0,0 +1,11 @@
+android_test {
+ name: "LegacyCoreTests",
+ srcs: ["**/*.java"],
+ libs: [
+ "android.test.runner.stubs",
+ "org.apache.http.legacy",
+ "android.test.base.stubs",
+ ],
+ sdk_version: "current",
+ static_libs: ["junit"],
+}
diff --git a/tests/CoreTests/android/Android.mk b/tests/CoreTests/android/Android.mk
deleted file mode 100644
index 04f6739..0000000
--- a/tests/CoreTests/android/Android.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := \
- $(call all-subdir-java-files)
-
-LOCAL_JAVA_LIBRARIES := \
- android.test.runner.stubs \
- org.apache.http.legacy \
- android.test.base.stubs \
-
-LOCAL_SDK_VERSION := current
-
-LOCAL_STATIC_JAVA_LIBRARIES := junit
-
-LOCAL_PACKAGE_NAME := LegacyCoreTests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/DataIdleTest/Android.bp b/tests/DataIdleTest/Android.bp
new file mode 100644
index 0000000..19656ce
--- /dev/null
+++ b/tests/DataIdleTest/Android.bp
@@ -0,0 +1,28 @@
+//
+// Copyright (C) 2011 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "DataIdleTest",
+ platform_apis: true,
+ libs: [
+ "android.test.runner",
+ "android.test.base",
+ ],
+ static_libs: ["junit"],
+ srcs: ["src/**/*.java"],
+ // We need to sign it to get access to the network usage history.
+ certificate: "platform",
+}
diff --git a/tests/DataIdleTest/Android.mk b/tests/DataIdleTest/Android.mk
deleted file mode 100644
index bcf3599..0000000
--- a/tests/DataIdleTest/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_PACKAGE_NAME := DataIdleTest
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base
-LOCAL_STATIC_JAVA_LIBRARIES := junit
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-# We need to sign it to get access to the network usage history.
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
diff --git a/tests/DozeTest/Android.bp b/tests/DozeTest/Android.bp
new file mode 100644
index 0000000..f1be029
--- /dev/null
+++ b/tests/DozeTest/Android.bp
@@ -0,0 +1,6 @@
+android_app {
+ name: "DozeTest",
+ // Only compile source java files in this apk.
+ srcs: ["src/**/*.java"],
+ platform_apis: true,
+}
diff --git a/tests/DozeTest/Android.mk b/tests/DozeTest/Android.mk
deleted file mode 100644
index ec250ff..0000000
--- a/tests/DozeTest/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := DozeTest
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-include $(BUILD_PACKAGE)
-
-# Use the following include to make our test apk.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/DpiTest/Android.bp b/tests/DpiTest/Android.bp
new file mode 100644
index 0000000..7d6a78b
--- /dev/null
+++ b/tests/DpiTest/Android.bp
@@ -0,0 +1,9 @@
+android_test {
+ name: "DensityTest",
+ srcs: ["**/*.java"],
+ platform_apis: true,
+ aaptflags: [
+ "-c",
+ "120dpi,240dpi,160dpi,nodpi",
+ ],
+}
diff --git a/tests/DpiTest/Android.mk b/tests/DpiTest/Android.mk
deleted file mode 100644
index e69d082..0000000
--- a/tests/DpiTest/Android.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := DensityTest
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_AAPT_FLAGS = -c 120dpi,240dpi,160dpi,nodpi
-
-include $(BUILD_PACKAGE)
diff --git a/tests/FeatureSplit/base/Android.bp b/tests/FeatureSplit/base/Android.bp
new file mode 100644
index 0000000..ab25464
--- /dev/null
+++ b/tests/FeatureSplit/base/Android.bp
@@ -0,0 +1,22 @@
+//
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test_helper_app {
+ name: "FeatureSplitBase",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ export_package_resources: true,
+}
diff --git a/tests/FeatureSplit/base/Android.mk b/tests/FeatureSplit/base/Android.mk
deleted file mode 100644
index 8646460..0000000
--- a/tests/FeatureSplit/base/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_USE_AAPT2 := true
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_PACKAGE_NAME := FeatureSplitBase
-LOCAL_SDK_VERSION := current
-LOCAL_EXPORT_PACKAGE_RESOURCES := true
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/FeatureSplit/feature1/Android.bp b/tests/FeatureSplit/feature1/Android.bp
new file mode 100644
index 0000000..1a93e84
--- /dev/null
+++ b/tests/FeatureSplit/feature1/Android.bp
@@ -0,0 +1,29 @@
+//
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "FeatureSplit1",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ libs: ["FeatureSplitBase"],
+ aaptflags: [
+ "--package-id",
+ "0x80",
+ ] + [
+ "--custom-package",
+ "com.android.test.split.feature.one",
+ ],
+}
diff --git a/tests/FeatureSplit/feature1/Android.mk b/tests/FeatureSplit/feature1/Android.mk
deleted file mode 100644
index d4d2589..0000000
--- a/tests/FeatureSplit/feature1/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_USE_AAPT2 := true
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_PACKAGE_NAME := FeatureSplit1
-LOCAL_SDK_VERSION := current
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_APK_LIBRARIES := FeatureSplitBase
-LOCAL_RES_LIBRARIES := FeatureSplitBase
-
-LOCAL_AAPT_FLAGS += --package-id 0x80
-LOCAL_AAPT_FLAGS += --custom-package com.android.test.split.feature.one
-
-include $(BUILD_PACKAGE)
diff --git a/tests/FeatureSplit/feature2/Android.bp b/tests/FeatureSplit/feature2/Android.bp
new file mode 100644
index 0000000..a363482
--- /dev/null
+++ b/tests/FeatureSplit/feature2/Android.bp
@@ -0,0 +1,28 @@
+//
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "FeatureSplit2",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ libs: ["FeatureSplitBase"],
+ aaptflags: [
+ "--package-id",
+ "0x81",
+ "--custom-package",
+ "com.android.test.split.feature.two",
+ ],
+}
diff --git a/tests/FeatureSplit/feature2/Android.mk b/tests/FeatureSplit/feature2/Android.mk
deleted file mode 100644
index 5e5e78b..0000000
--- a/tests/FeatureSplit/feature2/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_USE_AAPT2 := true
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_PACKAGE_NAME := FeatureSplit2
-LOCAL_SDK_VERSION := current
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_APK_LIBRARIES := FeatureSplitBase
-LOCAL_RES_LIBRARIES := FeatureSplitBase
-
-LOCAL_AAPT_FLAGS += --package-id 0x81
-LOCAL_AAPT_FLAGS += --custom-package com.android.test.split.feature.two
-
-include $(BUILD_PACKAGE)
diff --git a/tests/FixVibrateSetting/Android.bp b/tests/FixVibrateSetting/Android.bp
new file mode 100644
index 0000000..5608a2b
--- /dev/null
+++ b/tests/FixVibrateSetting/Android.bp
@@ -0,0 +1,6 @@
+android_app {
+ name: "FixVibrateSetting",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ certificate: "platform",
+}
diff --git a/tests/FixVibrateSetting/Android.mk b/tests/FixVibrateSetting/Android.mk
deleted file mode 100644
index 86db09e..0000000
--- a/tests/FixVibrateSetting/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := FixVibrateSetting
-LOCAL_SDK_VERSION := current
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
diff --git a/tests/FrameworkPerf/Android.bp b/tests/FrameworkPerf/Android.bp
new file mode 100644
index 0000000..a259ebd
--- /dev/null
+++ b/tests/FrameworkPerf/Android.bp
@@ -0,0 +1,14 @@
+android_test {
+ name: "FrameworkPerf",
+ srcs: ["**/*.java"],
+ platform_apis: true,
+ libs: [
+ "android.test.runner",
+ "android.test.base",
+ ],
+ static_libs: ["junit"],
+ aaptflags: [
+ "-c",
+ "120dpi,240dpi,160dpi,161dpi,320dpi,nodpi",
+ ],
+}
diff --git a/tests/FrameworkPerf/Android.mk b/tests/FrameworkPerf/Android.mk
deleted file mode 100644
index 0664d4d..0000000
--- a/tests/FrameworkPerf/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := FrameworkPerf
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base
-LOCAL_STATIC_JAVA_LIBRARIES := junit
-
-LOCAL_AAPT_FLAGS = -c 120dpi,240dpi,160dpi,161dpi,320dpi,nodpi
-
-include $(BUILD_PACKAGE)
diff --git a/tests/GridLayoutTest/Android.bp b/tests/GridLayoutTest/Android.bp
new file mode 100644
index 0000000..b4b5ba5
--- /dev/null
+++ b/tests/GridLayoutTest/Android.bp
@@ -0,0 +1,21 @@
+//
+// Copyright (C) 2010 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "GridLayoutTest",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+}
diff --git a/tests/GridLayoutTest/Android.mk b/tests/GridLayoutTest/Android.mk
deleted file mode 100644
index e7e3ccd..0000000
--- a/tests/GridLayoutTest/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := GridLayoutTest
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/HierarchyViewerTest/Android.bp b/tests/HierarchyViewerTest/Android.bp
new file mode 100644
index 0000000..814c883
--- /dev/null
+++ b/tests/HierarchyViewerTest/Android.bp
@@ -0,0 +1,10 @@
+android_test {
+ name: "HierarchyViewerTest",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ libs: [
+ "android.test.runner.stubs",
+ "android.test.base.stubs",
+ ],
+ static_libs: ["junit"],
+}
diff --git a/tests/HierarchyViewerTest/Android.mk b/tests/HierarchyViewerTest/Android.mk
deleted file mode 100644
index cf1a512..0000000
--- a/tests/HierarchyViewerTest/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := HierarchyViewerTest
-LOCAL_SDK_VERSION := current
-
-LOCAL_JAVA_LIBRARIES := android.test.runner.stubs android.test.base.stubs
-LOCAL_STATIC_JAVA_LIBRARIES := junit
-
-include $(BUILD_PACKAGE)
diff --git a/tests/HugeBackup/Android.bp b/tests/HugeBackup/Android.bp
new file mode 100644
index 0000000..b44c457
--- /dev/null
+++ b/tests/HugeBackup/Android.bp
@@ -0,0 +1,9 @@
+android_test {
+ name: "HugeBackup",
+ // Only compile source java files in this apk.
+ srcs: ["src/**/*.java"],
+ sdk_version: "current",
+ optimize: {
+ proguard_flags_files: ["proguard.flags"],
+ },
+}
diff --git a/tests/HugeBackup/Android.mk b/tests/HugeBackup/Android.mk
deleted file mode 100644
index 4789bc8..0000000
--- a/tests/HugeBackup/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := HugeBackup
-
-LOCAL_SDK_VERSION := current
-
-LOCAL_PROGUARD_FLAG_FILES := proguard.flags
-
-include $(BUILD_PACKAGE)
diff --git a/tests/Internal/src/com/android/internal/colorextraction/types/TonalTest.java b/tests/Internal/src/com/android/internal/colorextraction/types/TonalTest.java
index d92cfce0..300182d 100644
--- a/tests/Internal/src/com/android/internal/colorextraction/types/TonalTest.java
+++ b/tests/Internal/src/com/android/internal/colorextraction/types/TonalTest.java
@@ -27,7 +27,6 @@
import androidx.test.runner.AndroidJUnit4;
import com.android.internal.colorextraction.ColorExtractor.GradientColors;
-import com.android.internal.graphics.ColorUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -96,7 +95,6 @@
Tonal.ConfigParser config = new Tonal.ConfigParser(InstrumentationRegistry.getContext());
// 1 to avoid regression where only first item would be parsed.
assertTrue("Tonal palettes are empty", config.getTonalPalettes().size() > 1);
- assertTrue("Blacklisted colors are empty", config.getBlacklistedColors().size() > 1);
}
@Test
@@ -113,41 +111,4 @@
assertTrue("L should be <= to 1.", palette.l[1] <= 1);
}
}
-
- @Test
- public void tonal_blacklistTest() {
- // Make sure that palette generation will fail.
- final Tonal tonal = new Tonal(InstrumentationRegistry.getContext());
-
- // Creating a WallpaperColors object that contains *only* blacklisted colors.
- final float[] hsl = tonal.getBlacklistedColors().get(0).getCenter();
- final int blacklistedColor = ColorUtils.HSLToColor(hsl);
- WallpaperColors colorsFromBitmap = new WallpaperColors(Color.valueOf(blacklistedColor),
- null, null, WallpaperColors.HINT_FROM_BITMAP);
-
- // Make sure that palette generation will fail
- final GradientColors normal = new GradientColors();
- tonal.extractInto(colorsFromBitmap, normal, new GradientColors(),
- new GradientColors());
- assertTrue("Cannot generate a tonal palette from blacklisted colors.",
- normal.getMainColor() == Tonal.MAIN_COLOR_DARK);
- }
-
- @Test
- public void tonal_ignoreBlacklistTest() {
- final Tonal tonal = new Tonal(InstrumentationRegistry.getContext());
-
- // Creating a WallpaperColors object that contains *only* blacklisted colors.
- final float[] hsl = tonal.getBlacklistedColors().get(0).getCenter();
- final int blacklistedColor = ColorUtils.HSLToColor(hsl);
- WallpaperColors colors = new WallpaperColors(Color.valueOf(blacklistedColor),
- null, null);
-
- // Blacklist should be ignored when HINT_FROM_BITMAP isn't present.
- final GradientColors normal = new GradientColors();
- tonal.extractInto(colors, normal, new GradientColors(),
- new GradientColors());
- assertTrue("Blacklist should never be used on WallpaperColors generated using "
- + "default constructor.", normal.getMainColor() == blacklistedColor);
- }
}
diff --git a/tests/JobSchedulerTestApp/Android.bp b/tests/JobSchedulerTestApp/Android.bp
new file mode 100644
index 0000000..bac0220
--- /dev/null
+++ b/tests/JobSchedulerTestApp/Android.bp
@@ -0,0 +1,9 @@
+android_app {
+ name: "JobSchedulerTestApp",
+ srcs: ["src/**/*.java"],
+ resource_dirs: ["res"],
+ sdk_version: "current",
+ optimize: {
+ enabled: false,
+ },
+}
diff --git a/tests/JobSchedulerTestApp/Android.mk b/tests/JobSchedulerTestApp/Android.mk
deleted file mode 100644
index 48ee1f6..0000000
--- a/tests/JobSchedulerTestApp/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
-LOCAL_PACKAGE_NAME := JobSchedulerTestApp
-LOCAL_SDK_VERSION := current
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-include $(BUILD_PACKAGE)
-
diff --git a/tests/LargeAssetTest/Android.bp b/tests/LargeAssetTest/Android.bp
new file mode 100644
index 0000000..499e6a0
--- /dev/null
+++ b/tests/LargeAssetTest/Android.bp
@@ -0,0 +1,6 @@
+android_app {
+ name: "LargeAssetTest",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ certificate: "platform",
+}
diff --git a/tests/LargeAssetTest/Android.mk b/tests/LargeAssetTest/Android.mk
deleted file mode 100644
index f6d98bf..0000000
--- a/tests/LargeAssetTest/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := LargeAssetTest
-LOCAL_SDK_VERSION := current
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
diff --git a/tests/LegacyAssistant/Android.bp b/tests/LegacyAssistant/Android.bp
new file mode 100644
index 0000000..fef924d
--- /dev/null
+++ b/tests/LegacyAssistant/Android.bp
@@ -0,0 +1,6 @@
+android_test {
+ name: "LegacyAssistant",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ certificate: "platform",
+}
diff --git a/tests/LegacyAssistant/Android.mk b/tests/LegacyAssistant/Android.mk
deleted file mode 100644
index a583369..0000000
--- a/tests/LegacyAssistant/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := LegacyAssistant
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
diff --git a/tests/LocationTracker/Android.bp b/tests/LocationTracker/Android.bp
new file mode 100644
index 0000000..f0075a9
--- /dev/null
+++ b/tests/LocationTracker/Android.bp
@@ -0,0 +1,5 @@
+android_test {
+ name: "LocationTracker",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+}
diff --git a/tests/LocationTracker/Android.mk b/tests/LocationTracker/Android.mk
deleted file mode 100644
index 0d51b3b..0000000
--- a/tests/LocationTracker/Android.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := LocationTracker
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/LotsOfApps/Android.bp b/tests/LotsOfApps/Android.bp
new file mode 100644
index 0000000..68b9f88
--- /dev/null
+++ b/tests/LotsOfApps/Android.bp
@@ -0,0 +1,9 @@
+android_app {
+ name: "LotsOfApps",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ certificate: "platform",
+ optimize: {
+ enabled: false,
+ },
+}
diff --git a/tests/LotsOfApps/Android.mk b/tests/LotsOfApps/Android.mk
deleted file mode 100644
index bee3bcc..0000000
--- a/tests/LotsOfApps/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := LotsOfApps
-LOCAL_SDK_VERSION := current
-LOCAL_CERTIFICATE := platform
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-include $(BUILD_PACKAGE)
diff --git a/tests/LowStorageTest/Android.bp b/tests/LowStorageTest/Android.bp
new file mode 100644
index 0000000..e72e4a5
--- /dev/null
+++ b/tests/LowStorageTest/Android.bp
@@ -0,0 +1,20 @@
+// Copyright (C) 2009 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_test {
+ name: "lowstoragetest",
+ certificate: "platform",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+}
diff --git a/tests/LowStorageTest/Android.mk b/tests/LowStorageTest/Android.mk
deleted file mode 100644
index bdde6bd..0000000
--- a/tests/LowStorageTest/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2009 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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_CERTIFICATE := platform
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := lowstoragetest
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
diff --git a/tests/MemoryUsage/Android.bp b/tests/MemoryUsage/Android.bp
new file mode 100644
index 0000000..aeb5338
--- /dev/null
+++ b/tests/MemoryUsage/Android.bp
@@ -0,0 +1,12 @@
+android_test {
+ name: "MemoryUsage",
+ // Only compile source java files in this apk.
+ srcs: ["src/**/*.java"],
+ platform_apis: true,
+ certificate: "platform",
+ libs: [
+ "android.test.runner",
+ "android.test.base",
+ ],
+ static_libs: ["junit"],
+}
diff --git a/tests/MemoryUsage/Android.mk b/tests/MemoryUsage/Android.mk
deleted file mode 100644
index 5040d5a..0000000
--- a/tests/MemoryUsage/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := MemoryUsage
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_CERTIFICATE := platform
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base
-LOCAL_STATIC_JAVA_LIBRARIES := junit
-
-include $(BUILD_PACKAGE)
-
-# Use the following include to make our test apk.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/NetworkSecurityConfigTest/Android.bp b/tests/NetworkSecurityConfigTest/Android.bp
new file mode 100644
index 0000000..cf8ca57
--- /dev/null
+++ b/tests/NetworkSecurityConfigTest/Android.bp
@@ -0,0 +1,12 @@
+android_test {
+ name: "NetworkSecurityConfigTests",
+ certificate: "platform",
+ libs: [
+ "android.test.runner",
+ "android.test.base",
+ ],
+ static_libs: ["junit"],
+ // Include all test java files.
+ srcs: ["src/**/*.java"],
+ platform_apis: true,
+}
diff --git a/tests/NetworkSecurityConfigTest/Android.mk b/tests/NetworkSecurityConfigTest/Android.mk
deleted file mode 100644
index a6c21db..0000000
--- a/tests/NetworkSecurityConfigTest/Android.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-LOCAL_CERTIFICATE := platform
-
-LOCAL_JAVA_LIBRARIES := \
- android.test.runner \
- android.test.base \
-
-LOCAL_STATIC_JAVA_LIBRARIES := junit
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := NetworkSecurityConfigTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-include $(BUILD_PACKAGE)
diff --git a/tests/OdmApps/Android.bp b/tests/OdmApps/Android.bp
new file mode 100644
index 0000000..d86f9cc
--- /dev/null
+++ b/tests/OdmApps/Android.bp
@@ -0,0 +1,20 @@
+// Copyright (C) 2018 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+java_test_host {
+ name: "OdmAppsTest",
+ srcs: ["src/**/*.java"],
+ libs: ["tradefed"],
+ test_suites: ["device-tests"],
+}
diff --git a/tests/OdmApps/Android.mk b/tests/OdmApps/Android.mk
deleted file mode 100644
index 64fa653..0000000
--- a/tests/OdmApps/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := OdmAppsTest
-LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_LIBRARIES := tradefed
-LOCAL_COMPATIBILITY_SUITE := device-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/OdmApps/app/Android.bp b/tests/OdmApps/app/Android.bp
new file mode 100644
index 0000000..5eb8590
--- /dev/null
+++ b/tests/OdmApps/app/Android.bp
@@ -0,0 +1,19 @@
+// Copyright (C) 2018 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_test {
+ name: "TestOdmApp",
+ test_suites: ["device-tests"],
+ sdk_version: "current",
+}
diff --git a/tests/OdmApps/app/Android.mk b/tests/OdmApps/app/Android.mk
deleted file mode 100644
index 9eec0cc..0000000
--- a/tests/OdmApps/app/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (C) 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := TestOdmApp
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := device-tests
-LOCAL_SDK_VERSION := current
-include $(BUILD_PACKAGE)
diff --git a/tests/OdmApps/priv-app/Android.bp b/tests/OdmApps/priv-app/Android.bp
new file mode 100644
index 0000000..9dd477cf
--- /dev/null
+++ b/tests/OdmApps/priv-app/Android.bp
@@ -0,0 +1,19 @@
+// Copyright (C) 2018 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_test {
+ name: "TestOdmPrivApp",
+ test_suites: ["device-tests"],
+ sdk_version: "current",
+}
diff --git a/tests/OdmApps/priv-app/Android.mk b/tests/OdmApps/priv-app/Android.mk
deleted file mode 100644
index d423133..0000000
--- a/tests/OdmApps/priv-app/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (C) 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := TestOdmPrivApp
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := device-tests
-LOCAL_SDK_VERSION := current
-include $(BUILD_PACKAGE)
diff --git a/tests/OneMedia/Android.bp b/tests/OneMedia/Android.bp
new file mode 100644
index 0000000..11e12f35
--- /dev/null
+++ b/tests/OneMedia/Android.bp
@@ -0,0 +1,13 @@
+android_app {
+ name: "OneMedia",
+ srcs: [
+ "**/*.java",
+ "src/**/I*.aidl",
+ ],
+ platform_apis: true,
+ certificate: "platform",
+ libs: ["org.apache.http.legacy"],
+ optimize: {
+ enabled: false,
+ },
+}
diff --git a/tests/OneMedia/Android.mk b/tests/OneMedia/Android.mk
deleted file mode 100644
index 41f3f64..0000000
--- a/tests/OneMedia/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files) \
- $(call all-Iaidl-files-under, src)
-
-LOCAL_PACKAGE_NAME := OneMedia
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_CERTIFICATE := platform
-
-LOCAL_JAVA_LIBRARIES += org.apache.http.legacy
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RemoteDisplayProvider/Android.bp b/tests/RemoteDisplayProvider/Android.bp
new file mode 100644
index 0000000..6c7798f
--- /dev/null
+++ b/tests/RemoteDisplayProvider/Android.bp
@@ -0,0 +1,23 @@
+// Copyright (C) 2013 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.
+
+// Build the application.
+android_test {
+ name: "RemoteDisplayProviderTest",
+ sdk_version: "system_current",
+ srcs: ["src/**/*.java"],
+ resource_dirs: ["res"],
+ libs: ["com.android.media.remotedisplay"],
+ certificate: "platform",
+}
diff --git a/tests/RemoteDisplayProvider/Android.mk b/tests/RemoteDisplayProvider/Android.mk
deleted file mode 100644
index 43bf024..0000000
--- a/tests/RemoteDisplayProvider/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2013 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.
-
-LOCAL_PATH := $(call my-dir)
-
-# Build the application.
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := RemoteDisplayProviderTest
-LOCAL_MODULE_TAGS := tests
-LOCAL_SDK_VERSION := system_current
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_RESOURCE_DIR = $(LOCAL_PATH)/res
-LOCAL_JAVA_LIBRARIES := com.android.media.remotedisplay
-LOCAL_CERTIFICATE := platform
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderThreadTest/Android.bp b/tests/RenderThreadTest/Android.bp
new file mode 100644
index 0000000..1659776
--- /dev/null
+++ b/tests/RenderThreadTest/Android.bp
@@ -0,0 +1,10 @@
+android_test {
+ name: "RenderThreadTest",
+ // Only compile source java files in this apk.
+ srcs: ["src/**/*.java"],
+ platform_apis: true,
+ static_libs: ["android-common"],
+ optimize: {
+ enabled: false,
+ },
+}
diff --git a/tests/RenderThreadTest/Android.mk b/tests/RenderThreadTest/Android.mk
deleted file mode 100644
index 4e5f35b..0000000
--- a/tests/RenderThreadTest/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := RenderThreadTest
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_STATIC_JAVA_LIBRARIES += android-common
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-include $(BUILD_PACKAGE)
-
-# Use the following include to make our test apk.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTestUtils.java b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTestUtils.java
index ed8a533..a03fae0 100644
--- a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTestUtils.java
+++ b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTestUtils.java
@@ -165,9 +165,7 @@
PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller();
PackageInstaller.SessionParams params = new PackageInstaller.SessionParams(
PackageInstaller.SessionParams.MODE_FULL_INSTALL);
- if (enableRollback) {
- params.setEnableRollback();
- }
+ params.setEnableRollback(enableRollback);
int sessionId = packageInstaller.createSession(params);
session = packageInstaller.openSession(sessionId);
@@ -224,11 +222,9 @@
if (staged) {
multiPackageParams.setStaged();
}
- if (enableRollback) {
- // TODO: Do we set this on the parent params, the child params, or
- // both?
- multiPackageParams.setEnableRollback();
- }
+ // TODO: Do we set this on the parent params, the child params, or
+ // both?
+ multiPackageParams.setEnableRollback(enableRollback);
int multiPackageId = packageInstaller.createSession(multiPackageParams);
PackageInstaller.Session multiPackage = packageInstaller.openSession(multiPackageId);
@@ -242,9 +238,7 @@
if (resourceName.endsWith(".apex")) {
params.setInstallAsApex();
}
- if (enableRollback) {
- params.setEnableRollback();
- }
+ params.setEnableRollback(enableRollback);
int sessionId = packageInstaller.createSession(params);
session = packageInstaller.openSession(sessionId);
diff --git a/tests/SerialChat/Android.bp b/tests/SerialChat/Android.bp
new file mode 100644
index 0000000..3c18035
--- /dev/null
+++ b/tests/SerialChat/Android.bp
@@ -0,0 +1,21 @@
+//
+// Copyright (C) 2011 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "SerialChat",
+ srcs: ["**/*.java"],
+ platform_apis: true,
+}
diff --git a/tests/SerialChat/Android.mk b/tests/SerialChat/Android.mk
deleted file mode 100644
index ed6ca999..0000000
--- a/tests/SerialChat/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := SerialChat
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-include $(BUILD_PACKAGE)
diff --git a/tests/SharedLibrary/client/Android.bp b/tests/SharedLibrary/client/Android.bp
new file mode 100644
index 0000000..dbf6dc9
--- /dev/null
+++ b/tests/SharedLibrary/client/Android.bp
@@ -0,0 +1,6 @@
+android_test {
+ name: "SharedLibraryClient",
+ srcs: ["**/*.java"],
+ libs: ["SharedLibrary"],
+ sdk_version: "current",
+}
diff --git a/tests/SharedLibrary/client/Android.mk b/tests/SharedLibrary/client/Android.mk
deleted file mode 100644
index 9e76c40..0000000
--- a/tests/SharedLibrary/client/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_USE_AAPT2 := true
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_RES_LIBRARIES := SharedLibrary
-
-LOCAL_PACKAGE_NAME := SharedLibraryClient
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/SharedLibrary/lib/Android.bp b/tests/SharedLibrary/lib/Android.bp
new file mode 100644
index 0000000..f69d388
--- /dev/null
+++ b/tests/SharedLibrary/lib/Android.bp
@@ -0,0 +1,11 @@
+android_app {
+ name: "SharedLibrary",
+ srcs: ["**/*.java"],
+ aaptflags: ["--shared-lib"],
+ sdk_version: "current",
+ export_package_resources: true,
+ privileged: true,
+ optimize: {
+ proguard_flags_files: ["proguard.proguard"],
+ },
+}
diff --git a/tests/SharedLibrary/lib/Android.mk b/tests/SharedLibrary/lib/Android.mk
deleted file mode 100644
index 3c1ca87..0000000
--- a/tests/SharedLibrary/lib/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_AAPT_FLAGS := --shared-lib
-LOCAL_PACKAGE_NAME := SharedLibrary
-LOCAL_SDK_VERSION := current
-
-LOCAL_EXPORT_PACKAGE_RESOURCES := true
-LOCAL_PRIVILEGED_MODULE := true
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PROGUARD_FLAG_FILES := proguard.proguard
-
-include $(BUILD_PACKAGE)
diff --git a/tests/ShowWhenLockedApp/Android.bp b/tests/ShowWhenLockedApp/Android.bp
new file mode 100644
index 0000000..dba564c
--- /dev/null
+++ b/tests/ShowWhenLockedApp/Android.bp
@@ -0,0 +1,5 @@
+android_test {
+ name: "ShowWhenLocked",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+}
diff --git a/tests/ShowWhenLockedApp/Android.mk b/tests/ShowWhenLockedApp/Android.mk
deleted file mode 100644
index 41e0ac4..0000000
--- a/tests/ShowWhenLockedApp/Android.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := ShowWhenLocked
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_PACKAGE)
\ No newline at end of file
diff --git a/tests/SmokeTest/Android.bp b/tests/SmokeTest/Android.bp
new file mode 100644
index 0000000..bc45ee6
--- /dev/null
+++ b/tests/SmokeTest/Android.bp
@@ -0,0 +1,6 @@
+android_test {
+ name: "SmokeTestApp",
+ // This builds "SmokeTestApp"
+ srcs: ["src/**/*.java"],
+ sdk_version: "8",
+}
diff --git a/tests/SmokeTest/Android.mk b/tests/SmokeTest/Android.mk
deleted file mode 100644
index 591a84e..0000000
--- a/tests/SmokeTest/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-# This builds "SmokeTestApp"
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := SmokeTestApp
-
-LOCAL_SDK_VERSION := 8
-
-include $(BUILD_PACKAGE)
-
-# This builds "SmokeTest"
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/SmokeTest/tests/Android.bp b/tests/SmokeTest/tests/Android.bp
new file mode 100644
index 0000000..ceb2d19
--- /dev/null
+++ b/tests/SmokeTest/tests/Android.bp
@@ -0,0 +1,10 @@
+android_test {
+ name: "SmokeTest",
+ // Include all test java files.
+ srcs: ["src/**/*.java"],
+ // Notice that we don't have to include the src files of SmokeTestApp because, by
+ // running the tests using an instrumentation targeting SmokeTestApp, we
+ // automatically get all of its classes loaded into our environment.
+ instrumentation_for: "SmokeTestApp",
+ sdk_version: "8",
+}
diff --git a/tests/SmokeTest/tests/Android.mk b/tests/SmokeTest/tests/Android.mk
deleted file mode 100644
index 18e682e..0000000
--- a/tests/SmokeTest/tests/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-# Notice that we don't have to include the src files of SmokeTestApp because, by
-# running the tests using an instrumentation targeting SmokeTestApp, we
-# automatically get all of its classes loaded into our environment.
-
-LOCAL_PACKAGE_NAME := SmokeTest
-
-LOCAL_INSTRUMENTATION_FOR := SmokeTestApp
-
-LOCAL_SDK_VERSION := 8
-
-include $(BUILD_PACKAGE)
-
diff --git a/tests/SmokeTestApps/Android.bp b/tests/SmokeTestApps/Android.bp
new file mode 100644
index 0000000..0feb0004
--- /dev/null
+++ b/tests/SmokeTestApps/Android.bp
@@ -0,0 +1,5 @@
+android_test {
+ name: "SmokeTestTriggerApps",
+ srcs: ["src/**/*.java"],
+ sdk_version: "current",
+}
diff --git a/tests/SmokeTestApps/Android.mk b/tests/SmokeTestApps/Android.mk
deleted file mode 100644
index 1f564e0..0000000
--- a/tests/SmokeTestApps/Android.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := SmokeTestTriggerApps
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/SoundTriggerTestApp/Android.bp b/tests/SoundTriggerTestApp/Android.bp
new file mode 100644
index 0000000..d3a1300
--- /dev/null
+++ b/tests/SoundTriggerTestApp/Android.bp
@@ -0,0 +1,7 @@
+android_app {
+ name: "SoundTriggerTestApp",
+ srcs: ["**/*.java"],
+ platform_apis: true,
+ privileged: true,
+ certificate: "platform",
+}
diff --git a/tests/SoundTriggerTestApp/Android.mk b/tests/SoundTriggerTestApp/Android.mk
deleted file mode 100644
index 73fb5e8..0000000
--- a/tests/SoundTriggerTestApp/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := SoundTriggerTestApp
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PRIVILEGED_MODULE := true
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
diff --git a/tests/Split/Android.bp b/tests/Split/Android.bp
new file mode 100644
index 0000000..d8c89ba
--- /dev/null
+++ b/tests/Split/Android.bp
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "Split",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ package_splits: [
+ "mdpi-v4",
+ "hdpi-v4",
+ "xhdpi-v4",
+ "xxhdpi-v4",
+ ],
+}
diff --git a/tests/Split/Android.mk b/tests/Split/Android.mk
deleted file mode 100644
index 4d15b2d..0000000
--- a/tests/Split/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_PACKAGE_NAME := Split
-LOCAL_SDK_VERSION := current
-
-LOCAL_PACKAGE_SPLITS := mdpi-v4 hdpi-v4 xhdpi-v4 xxhdpi-v4
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/StatusBar/Android.bp b/tests/StatusBar/Android.bp
new file mode 100644
index 0000000..0b650ed
--- /dev/null
+++ b/tests/StatusBar/Android.bp
@@ -0,0 +1,9 @@
+android_test {
+ name: "StatusBarTest",
+ srcs: ["**/*.java"],
+ platform_apis: true,
+ certificate: "platform",
+ optimize: {
+ enabled: false,
+ },
+}
diff --git a/tests/StatusBar/Android.mk b/tests/StatusBar/Android.mk
deleted file mode 100644
index e845335..0000000
--- a/tests/StatusBar/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := StatusBarTest
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_CERTIFICATE := platform
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-include $(BUILD_PACKAGE)
diff --git a/tests/SystemUIDemoModeController/Android.bp b/tests/SystemUIDemoModeController/Android.bp
new file mode 100644
index 0000000..1e4c437
--- /dev/null
+++ b/tests/SystemUIDemoModeController/Android.bp
@@ -0,0 +1,5 @@
+android_test {
+ name: "DemoModeController",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+}
diff --git a/tests/SystemUIDemoModeController/Android.mk b/tests/SystemUIDemoModeController/Android.mk
deleted file mode 100644
index cc6fa8d..0000000
--- a/tests/SystemUIDemoModeController/Android.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := DemoModeController
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
diff --git a/tests/TouchLatency/Android.bp b/tests/TouchLatency/Android.bp
new file mode 100644
index 0000000..1174bcb0
--- /dev/null
+++ b/tests/TouchLatency/Android.bp
@@ -0,0 +1,10 @@
+android_test {
+ name: "TouchLatency",
+ manifest: "app/src/main/AndroidManifest.xml",
+ // omit gradle 'build' dir
+ srcs: ["app/src/main/java/**/*.java"],
+ resource_dirs: ["app/src/main/res"],
+ aaptflags: ["--auto-add-overlay"],
+ sdk_version: "current",
+ test_suites: ["device-tests"],
+}
diff --git a/tests/TouchLatency/Android.mk b/tests/TouchLatency/Android.mk
deleted file mode 100644
index 2334bd8..0000000
--- a/tests/TouchLatency/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_MANIFEST_FILE := app/src/main/AndroidManifest.xml
-
-# omit gradle 'build' dir
-LOCAL_SRC_FILES := $(call all-java-files-under,app/src/main/java)
-
-LOCAL_RESOURCE_DIR := \
- $(LOCAL_PATH)/app/src/main/res
-
-LOCAL_AAPT_FLAGS := \
- --auto-add-overlay
-
-LOCAL_PACKAGE_NAME := TouchLatency
-LOCAL_SDK_VERSION := current
-
-LOCAL_COMPATIBILITY_SUITE := device-tests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/TransformTest/Android.bp b/tests/TransformTest/Android.bp
new file mode 100644
index 0000000..fd7aaeb
--- /dev/null
+++ b/tests/TransformTest/Android.bp
@@ -0,0 +1,5 @@
+android_test {
+ name: "TransformTest",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+}
diff --git a/tests/TransformTest/Android.mk b/tests/TransformTest/Android.mk
deleted file mode 100644
index 5340cdd..0000000
--- a/tests/TransformTest/Android.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := TransformTest
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/TransitionTests/Android.bp b/tests/TransitionTests/Android.bp
new file mode 100644
index 0000000..57f19e3
--- /dev/null
+++ b/tests/TransitionTests/Android.bp
@@ -0,0 +1,10 @@
+android_app {
+ name: "TransitionTests",
+ // Only compile source java files in this apk.
+ srcs: ["src/**/*.java"],
+ platform_apis: true,
+ static_libs: ["android-common"],
+ optimize: {
+ enabled: false,
+ },
+}
diff --git a/tests/TransitionTests/Android.mk b/tests/TransitionTests/Android.mk
deleted file mode 100644
index a696156..0000000
--- a/tests/TransitionTests/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := TransitionTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_STATIC_JAVA_LIBRARIES += android-common
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-include $(BUILD_PACKAGE)
-
-# Use the following include to make our test apk.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/TtsTests/Android.bp b/tests/TtsTests/Android.bp
new file mode 100644
index 0000000..b137523
--- /dev/null
+++ b/tests/TtsTests/Android.bp
@@ -0,0 +1,26 @@
+//
+// Copyright (C) 2011 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "TtsTests",
+ srcs: ["**/*.java"],
+ static_libs: ["mockito-target"],
+ libs: [
+ "android.test.runner",
+ "android.test.base",
+ ],
+ platform_apis: true,
+}
diff --git a/tests/TtsTests/Android.mk b/tests/TtsTests/Android.mk
deleted file mode 100644
index 116cc0a..0000000
--- a/tests/TtsTests/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_STATIC_JAVA_LIBRARIES := mockito-target
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base
-
-LOCAL_PACKAGE_NAME := TtsTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-include $(BUILD_PACKAGE)
diff --git a/tests/UsesFeature2Test/Android.bp b/tests/UsesFeature2Test/Android.bp
new file mode 100644
index 0000000..a1b77d0
--- /dev/null
+++ b/tests/UsesFeature2Test/Android.bp
@@ -0,0 +1,21 @@
+//
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "UsesFeature2Test",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+}
diff --git a/tests/UsesFeature2Test/Android.mk b/tests/UsesFeature2Test/Android.mk
deleted file mode 100644
index 4cba4ff..0000000
--- a/tests/UsesFeature2Test/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_PACKAGE_NAME := UsesFeature2Test
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/VectorDrawableTest/Android.bp b/tests/VectorDrawableTest/Android.bp
new file mode 100644
index 0000000..13f318e
--- /dev/null
+++ b/tests/VectorDrawableTest/Android.bp
@@ -0,0 +1,21 @@
+//
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "VectorDrawableTest",
+ srcs: ["**/*.java"],
+ platform_apis: true,
+}
diff --git a/tests/VectorDrawableTest/Android.mk b/tests/VectorDrawableTest/Android.mk
deleted file mode 100644
index 155b2bc..0000000
--- a/tests/VectorDrawableTest/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := VectorDrawableTest
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/VoiceEnrollment/Android.bp b/tests/VoiceEnrollment/Android.bp
new file mode 100644
index 0000000..e43b38c
--- /dev/null
+++ b/tests/VoiceEnrollment/Android.bp
@@ -0,0 +1,6 @@
+android_app {
+ name: "VoiceEnrollment",
+ srcs: ["**/*.java"],
+ platform_apis: true,
+ privileged: true,
+}
diff --git a/tests/VoiceEnrollment/Android.mk b/tests/VoiceEnrollment/Android.mk
deleted file mode 100644
index 725e2bd..0000000
--- a/tests/VoiceEnrollment/Android.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := VoiceEnrollment
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PRIVILEGED_MODULE := true
-
-include $(BUILD_PACKAGE)
diff --git a/tests/VoiceInteraction/Android.bp b/tests/VoiceInteraction/Android.bp
new file mode 100644
index 0000000..7059473
--- /dev/null
+++ b/tests/VoiceInteraction/Android.bp
@@ -0,0 +1,5 @@
+android_test {
+ name: "VoiceInteraction",
+ srcs: ["**/*.java"],
+ platform_apis: true,
+}
diff --git a/tests/VoiceInteraction/Android.mk b/tests/VoiceInteraction/Android.mk
deleted file mode 100644
index aa48b42..0000000
--- a/tests/VoiceInteraction/Android.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := VoiceInteraction
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-include $(BUILD_PACKAGE)
diff --git a/tests/WallpaperTest/Android.bp b/tests/WallpaperTest/Android.bp
new file mode 100644
index 0000000..f68b6ec
--- /dev/null
+++ b/tests/WallpaperTest/Android.bp
@@ -0,0 +1,9 @@
+android_app {
+ name: "WallpaperTest",
+ srcs: ["src/**/*.java"],
+ resource_dirs: ["res"],
+ platform_apis: true,
+ optimize: {
+ enabled: false,
+ },
+}
diff --git a/tests/WallpaperTest/Android.mk b/tests/WallpaperTest/Android.mk
deleted file mode 100644
index 4815500..0000000
--- a/tests/WallpaperTest/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
-LOCAL_PACKAGE_NAME := WallpaperTest
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-include $(BUILD_PACKAGE)
-
diff --git a/tests/WindowManagerStressTest/Android.bp b/tests/WindowManagerStressTest/Android.bp
new file mode 100644
index 0000000..98749a7
--- /dev/null
+++ b/tests/WindowManagerStressTest/Android.bp
@@ -0,0 +1,21 @@
+//
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "WindowManagerStressTest",
+ srcs: ["**/*.java"],
+ platform_apis: true,
+}
diff --git a/tests/WindowManagerStressTest/Android.mk b/tests/WindowManagerStressTest/Android.mk
deleted file mode 100644
index 6f4403f..0000000
--- a/tests/WindowManagerStressTest/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2016 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := WindowManagerStressTest
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/appwidgets/AppWidgetHostTest/Android.bp b/tests/appwidgets/AppWidgetHostTest/Android.bp
new file mode 100644
index 0000000..24b7613
--- /dev/null
+++ b/tests/appwidgets/AppWidgetHostTest/Android.bp
@@ -0,0 +1,6 @@
+android_app {
+ name: "AppWidgetHostTest",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ certificate: "platform",
+}
diff --git a/tests/appwidgets/AppWidgetHostTest/Android.mk b/tests/appwidgets/AppWidgetHostTest/Android.mk
deleted file mode 100644
index c9e6c6b..0000000
--- a/tests/appwidgets/AppWidgetHostTest/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := AppWidgetHostTest
-LOCAL_SDK_VERSION := current
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
diff --git a/tests/appwidgets/AppWidgetProviderTest/Android.bp b/tests/appwidgets/AppWidgetProviderTest/Android.bp
new file mode 100644
index 0000000..a1a5991
--- /dev/null
+++ b/tests/appwidgets/AppWidgetProviderTest/Android.bp
@@ -0,0 +1,6 @@
+android_app {
+ name: "AppWidgetProvider",
+ srcs: ["**/*.java"],
+ sdk_version: "current",
+ certificate: "platform",
+}
diff --git a/tests/appwidgets/AppWidgetProviderTest/Android.mk b/tests/appwidgets/AppWidgetProviderTest/Android.mk
deleted file mode 100644
index b26c60b..0000000
--- a/tests/appwidgets/AppWidgetProviderTest/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := AppWidgetProvider
-LOCAL_SDK_VERSION := current
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
diff --git a/tests/net/Android.bp b/tests/net/Android.bp
new file mode 100644
index 0000000..2539c0f
--- /dev/null
+++ b/tests/net/Android.bp
@@ -0,0 +1,27 @@
+//########################################################################
+// Build FrameworksNetTests package
+//########################################################################
+
+android_test {
+ name: "FrameworksNetTests",
+ // Include all test java files.
+ srcs: ["java/**/*.java"],
+ static_libs: [
+ "frameworks-base-testutils",
+ "framework-protos",
+ "androidx.test.rules",
+ "mockito-target-minus-junit4",
+ "platform-test-annotations",
+ "services.core",
+ "services.ipmemorystore",
+ "services.net",
+ ],
+ libs: [
+ "android.test.runner",
+ "android.test.base",
+ "android.test.mock",
+ ],
+ platform_apis: true,
+ test_suites: ["device-tests"],
+ certificate: "platform",
+}
diff --git a/tests/net/Android.mk b/tests/net/Android.mk
deleted file mode 100644
index 2ef141f..0000000
--- a/tests/net/Android.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-#########################################################################
-# Build FrameworksNetTests package
-#########################################################################
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, java)
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- frameworks-base-testutils \
- framework-protos \
- androidx.test.rules \
- mockito-target-minus-junit4 \
- platform-test-annotations \
- services.core \
- services.ipmemorystore \
- services.net
-
-LOCAL_JAVA_LIBRARIES := \
- android.test.runner \
- android.test.base \
- android.test.mock
-
-LOCAL_PACKAGE_NAME := FrameworksNetTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_COMPATIBILITY_SUITE := device-tests
-
-LOCAL_CERTIFICATE := platform
-
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-include $(BUILD_PACKAGE)
diff --git a/tests/net/OWNERS b/tests/net/OWNERS
index 7311eee..d3836d4 100644
--- a/tests/net/OWNERS
+++ b/tests/net/OWNERS
@@ -1,8 +1,8 @@
set noparent
codewiz@google.com
-ek@google.com
jchalard@google.com
+junyulai@google.com
lorenzo@google.com
reminv@google.com
satk@google.com
diff --git a/tests/net/java/android/net/DnsPacketTest.java b/tests/net/java/android/net/DnsPacketTest.java
index 91ff6b3..9ede2b8 100644
--- a/tests/net/java/android/net/DnsPacketTest.java
+++ b/tests/net/java/android/net/DnsPacketTest.java
@@ -36,19 +36,19 @@
int qCount, int aCount, int nsCount, int arCount) {
assertEquals(header.id, id);
assertEquals(header.flags, flag);
- assertEquals(header.getSectionCount(DnsPacket.QDSECTION), qCount);
- assertEquals(header.getSectionCount(DnsPacket.ANSECTION), aCount);
- assertEquals(header.getSectionCount(DnsPacket.NSSECTION), nsCount);
- assertEquals(header.getSectionCount(DnsPacket.ARSECTION), arCount);
+ assertEquals(header.getRecordCount(DnsPacket.QDSECTION), qCount);
+ assertEquals(header.getRecordCount(DnsPacket.ANSECTION), aCount);
+ assertEquals(header.getRecordCount(DnsPacket.NSSECTION), nsCount);
+ assertEquals(header.getRecordCount(DnsPacket.ARSECTION), arCount);
}
- private void assertSectionParses(DnsPacket.DnsSection section, String dname,
+ private void assertRecordParses(DnsPacket.DnsRecord record, String dname,
int dtype, int dclass, int ttl, byte[] rr) {
- assertEquals(section.dName, dname);
- assertEquals(section.nsType, dtype);
- assertEquals(section.nsClass, dclass);
- assertEquals(section.ttl, ttl);
- assertTrue(Arrays.equals(section.getRR(), rr));
+ assertEquals(record.dName, dname);
+ assertEquals(record.nsType, dtype);
+ assertEquals(record.nsClass, dclass);
+ assertEquals(record.ttl, ttl);
+ assertTrue(Arrays.equals(record.getRR(), rr));
}
class TestDnsPacket extends DnsPacket {
@@ -59,8 +59,8 @@
public DnsHeader getHeader() {
return mHeader;
}
- public List<DnsSection> getSectionList(int secType) {
- return mSections[secType];
+ public List<DnsRecord> getRecordList(int secType) {
+ return mRecords[secType];
}
}
@@ -101,16 +101,16 @@
// Header part
assertHeaderParses(packet.getHeader(), 0x5566, 0x8180, 1, 1, 0, 0);
- // Section part
- List<DnsPacket.DnsSection> qdSectionList =
- packet.getSectionList(DnsPacket.QDSECTION);
- assertEquals(qdSectionList.size(), 1);
- assertSectionParses(qdSectionList.get(0), "www.google.com", 1, 1, 0, null);
+ // Record part
+ List<DnsPacket.DnsRecord> qdRecordList =
+ packet.getRecordList(DnsPacket.QDSECTION);
+ assertEquals(qdRecordList.size(), 1);
+ assertRecordParses(qdRecordList.get(0), "www.google.com", 1, 1, 0, null);
- List<DnsPacket.DnsSection> anSectionList =
- packet.getSectionList(DnsPacket.ANSECTION);
- assertEquals(anSectionList.size(), 1);
- assertSectionParses(anSectionList.get(0), "www.google.com", 1, 1, 0x12b,
+ List<DnsPacket.DnsRecord> anRecordList =
+ packet.getRecordList(DnsPacket.ANSECTION);
+ assertEquals(anRecordList.size(), 1);
+ assertRecordParses(anRecordList.get(0), "www.google.com", 1, 1, 0x12b,
new byte[]{ (byte) 0xac, (byte) 0xd9, (byte) 0xa1, (byte) 0x84 });
}
@@ -143,16 +143,16 @@
// Header part
assertHeaderParses(packet.getHeader(), 0x7722, 0x8180, 1, 1, 0, 0);
- // Section part
- List<DnsPacket.DnsSection> qdSectionList =
- packet.getSectionList(DnsPacket.QDSECTION);
- assertEquals(qdSectionList.size(), 1);
- assertSectionParses(qdSectionList.get(0), "www.google.com", 28, 1, 0, null);
+ // Record part
+ List<DnsPacket.DnsRecord> qdRecordList =
+ packet.getRecordList(DnsPacket.QDSECTION);
+ assertEquals(qdRecordList.size(), 1);
+ assertRecordParses(qdRecordList.get(0), "www.google.com", 28, 1, 0, null);
- List<DnsPacket.DnsSection> anSectionList =
- packet.getSectionList(DnsPacket.ANSECTION);
- assertEquals(anSectionList.size(), 1);
- assertSectionParses(anSectionList.get(0), "www.google.com", 28, 1, 0x37,
+ List<DnsPacket.DnsRecord> anRecordList =
+ packet.getRecordList(DnsPacket.ANSECTION);
+ assertEquals(anRecordList.size(), 1);
+ assertRecordParses(anRecordList.get(0), "www.google.com", 28, 1, 0x37,
new byte[]{ 0x24, 0x04, 0x68, 0x00, 0x40, 0x05, 0x08, 0x0d,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x04 });
}
diff --git a/tests/notification/Android.bp b/tests/notification/Android.bp
new file mode 100644
index 0000000..f05edaf
--- /dev/null
+++ b/tests/notification/Android.bp
@@ -0,0 +1,7 @@
+android_test {
+ name: "NotificationTests",
+ // Include all test java files.
+ srcs: ["src/**/*.java"],
+ libs: ["android.test.runner.stubs"],
+ sdk_version: "21",
+}
diff --git a/tests/notification/Android.mk b/tests/notification/Android.mk
deleted file mode 100644
index 255e6e7..0000000
--- a/tests/notification/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
-LOCAL_PACKAGE_NAME := NotificationTests
-
-LOCAL_SDK_VERSION := 21
-
-include $(BUILD_PACKAGE)
-
diff --git a/tests/permission/Android.bp b/tests/permission/Android.bp
new file mode 100644
index 0000000..bd07009
--- /dev/null
+++ b/tests/permission/Android.bp
@@ -0,0 +1,12 @@
+android_test {
+ name: "FrameworkPermissionTests",
+ // Include all test java files.
+ srcs: ["src/**/*.java"],
+ libs: [
+ "android.test.runner",
+ "telephony-common",
+ "android.test.base",
+ ],
+ static_libs: ["junit"],
+ platform_apis: true,
+}
diff --git a/tests/permission/Android.mk b/tests/permission/Android.mk
deleted file mode 100644
index dd2f3ec..0000000
--- a/tests/permission/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common android.test.base
-LOCAL_STATIC_JAVA_LIBRARIES := junit
-LOCAL_PACKAGE_NAME := FrameworkPermissionTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-include $(BUILD_PACKAGE)
-
diff --git a/tests/testables/Android.bp b/tests/testables/Android.bp
index 0bad7a4..eb6811c 100644
--- a/tests/testables/Android.bp
+++ b/tests/testables/Android.bp
@@ -15,18 +15,12 @@
//
java_library {
-
name: "testables",
- // ANDROIDMK TRANSLATION ERROR: unsupported assignment to LOCAL_MODULE_TAG
- // LOCAL_MODULE_TAG := tests
-
srcs: ["src/**/*.java"],
-
libs: [
"android.test.runner",
"android.test.mock",
"androidx.test.rules",
"mockito-target-inline-minus-junit4",
],
-
}
diff --git a/tests/testables/tests/Android.bp b/tests/testables/tests/Android.bp
new file mode 100644
index 0000000..e1a58be
--- /dev/null
+++ b/tests/testables/tests/Android.bp
@@ -0,0 +1,41 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_test {
+ name: "TestablesTests",
+ platform_apis: true,
+ srcs: [
+ "src/**/*.java",
+ "src/**/I*.aidl",
+ ],
+ resource_dirs: ["res"],
+ static_libs: [
+ "androidx.test.rules",
+ "hamcrest-library",
+ "mockito-target-inline-minus-junit4",
+ "testables",
+ ],
+ compile_multilib: "both",
+ jni_libs: [
+ "libdexmakerjvmtiagent",
+ "libmultiplejvmtiagentsinterferenceagent",
+ ],
+ libs: [
+ "android.test.runner",
+ "android.test.base",
+ "android.test.mock",
+ ],
+ certificate: "platform",
+ test_suites: ["device-tests"],
+}
diff --git a/tests/testables/tests/Android.mk b/tests/testables/tests/Android.mk
deleted file mode 100644
index 16fbb18..0000000
--- a/tests/testables/tests/Android.mk
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_USE_AAPT2 := true
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_PACKAGE_NAME := TestablesTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
- $(call all-Iaidl-files-under, src)
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- androidx.test.rules hamcrest-library \
- mockito-target-inline-minus-junit4 \
- testables
-
-LOCAL_MULTILIB := both
-
-LOCAL_JNI_SHARED_LIBRARIES := \
- libdexmakerjvmtiagent \
- libmultiplejvmtiagentsinterferenceagent
-
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base android.test.mock
-
-LOCAL_CERTIFICATE := platform
-
-LOCAL_COMPATIBILITY_SUITE := device-tests
-
-include $(BUILD_PACKAGE)
-
diff --git a/tests/touchlag/Android.bp b/tests/touchlag/Android.bp
index 2610cb3..092eea9 100644
--- a/tests/touchlag/Android.bp
+++ b/tests/touchlag/Android.bp
@@ -1,14 +1,11 @@
cc_test {
name: "test-touchlag",
gtest: false,
-
srcs: ["touchlag.cpp"],
-
shared_libs: [
"libcutils",
"libutils",
],
-
cflags: [
"-Wall",
"-Wextra",
diff --git a/tests/utils/Android.mk b/tests/utils/Android.mk
deleted file mode 100644
index c141484..0000000
--- a/tests/utils/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-include $(call all-subdir-makefiles)
diff --git a/tests/utils/DummyIME/Android.bp b/tests/utils/DummyIME/Android.bp
new file mode 100644
index 0000000..4a44b3b
--- /dev/null
+++ b/tests/utils/DummyIME/Android.bp
@@ -0,0 +1,21 @@
+//
+// Copyright (C) 2012 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "DummyIME",
+ srcs: ["src/**/*.java"],
+ sdk_version: "current",
+}
diff --git a/tests/utils/DummyIME/Android.mk b/tests/utils/DummyIME/Android.mk
deleted file mode 100644
index 0f6c988..0000000
--- a/tests/utils/DummyIME/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2012 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := DummyIME
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
diff --git a/tools/hiddenapi/generate_hiddenapi_lists.py b/tools/hiddenapi/generate_hiddenapi_lists.py
index 2a8f695..6781eba 100755
--- a/tools/hiddenapi/generate_hiddenapi_lists.py
+++ b/tools/hiddenapi/generate_hiddenapi_lists.py
@@ -29,6 +29,9 @@
FLAG_GREYLIST_MAX_O = "greylist-max-o"
FLAG_GREYLIST_MAX_P = "greylist-max-p"
FLAG_CORE_PLATFORM_API = "core-platform-api"
+FLAG_PUBLIC_API = "public-api"
+FLAG_SYSTEM_API = "system-api"
+FLAG_TEST_API = "test-api"
# List of all known flags.
FLAGS_API_LIST = [
@@ -38,7 +41,12 @@
FLAG_GREYLIST_MAX_O,
FLAG_GREYLIST_MAX_P,
]
-ALL_FLAGS = FLAGS_API_LIST + [ FLAG_CORE_PLATFORM_API ]
+ALL_FLAGS = FLAGS_API_LIST + [
+ FLAG_CORE_PLATFORM_API,
+ FLAG_PUBLIC_API,
+ FLAG_SYSTEM_API,
+ FLAG_TEST_API,
+ ]
FLAGS_API_LIST_SET = set(FLAGS_API_LIST)
ALL_FLAGS_SET = set(ALL_FLAGS)
@@ -203,14 +211,19 @@
# Iterate over all CSV lines, find entry in dict and append flags to it.
for csv in csv_values:
- self._dict[csv[0]].update(csv[1:])
+ flags = csv[1:]
+ if (FLAG_PUBLIC_API in flags) or (FLAG_SYSTEM_API in flags):
+ flags.append(FLAG_WHITELIST)
+ elif FLAG_TEST_API in flags:
+ flags.append(FLAG_GREYLIST)
+ self._dict[csv[0]].update(flags)
def assign_flag(self, flag, apis, source="<unknown>"):
"""Assigns a flag to given subset of entries.
Args:
flag (string): One of ALL_FLAGS.
- apis (set): Subset of APIs to recieve the flag.
+ apis (set): Subset of APIs to receive the flag.
source (string): Origin of `entries_subset`. Will be printed in error messages.
Throws:
diff --git a/wifi/java/android/net/wifi/aware/ParcelablePeerHandle.java b/wifi/java/android/net/wifi/aware/ParcelablePeerHandle.java
index ce67abf..ca473db 100644
--- a/wifi/java/android/net/wifi/aware/ParcelablePeerHandle.java
+++ b/wifi/java/android/net/wifi/aware/ParcelablePeerHandle.java
@@ -16,6 +16,7 @@
package android.net.wifi.aware;
+import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
@@ -29,7 +30,7 @@
*
* @param peerHandle The {@link PeerHandle} to be made parcelable.
*/
- public ParcelablePeerHandle(PeerHandle peerHandle) {
+ public ParcelablePeerHandle(@NonNull PeerHandle peerHandle) {
super(peerHandle.peerId);
}
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java b/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java
index 6c1b073..c3cfb02 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java
@@ -227,7 +227,7 @@
public static final class Builder {
private static final MacAddress MAC_ANY_ADDRESS =
- MacAddress.fromString("00:00:00:00:00:00");
+ MacAddress.fromString("02:00:00:00:00:00");
private MacAddress mDeviceAddress = MAC_ANY_ADDRESS;
private String mNetworkName = "";
@@ -240,9 +240,9 @@
* Specify the peer's MAC address. If not set, the device will
* try to find a peer whose SSID matches the network name as
* specified by {@link #setNetworkName(String)}. Specifying null will
- * reset the peer's MAC address to "00:00:00:00:00:00".
+ * reset the peer's MAC address to "02:00:00:00:00:00".
* <p>
- * Optional. "00:00:00:00:00:00" by default.
+ * Optional. "02:00:00:00:00:00" by default.
*
* @param deviceAddress the peer's MAC address.
* @return The builder to facilitate chaining
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
index 29a18d2..a779378 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
@@ -793,7 +793,7 @@
* The requested {@link android.net.NetworkInfo} is available
* @param networkInfo Wi-Fi p2p {@link android.net.NetworkInfo}
*/
- void onNetworkInfoAvailable(NetworkInfo networkInfo);
+ void onNetworkInfoAvailable(@NonNull NetworkInfo networkInfo);
}
/**