diff options
123 files changed, 1402 insertions, 497 deletions
diff --git a/Android.bp b/Android.bp index 13c6e858c377..7e71bdfe35c7 100644 --- a/Android.bp +++ b/Android.bp @@ -196,6 +196,7 @@ java_defaults { "core/java/android/hardware/radio/ITunerCallback.aidl", "core/java/android/hardware/soundtrigger/IRecognitionStatusCallback.aidl", "core/java/android/hardware/usb/IUsbManager.aidl", + "core/java/android/hardware/usb/IUsbSerialReader.aidl", "core/java/android/net/ICaptivePortal.aidl", "core/java/android/net/IConnectivityManager.aidl", "core/java/android/net/IIpConnectivityMetrics.aidl", diff --git a/apct-tests/perftests/core/src/android/os/CpuUsageTrackingPerfTest.java b/apct-tests/perftests/core/src/android/os/CpuUsageTrackingPerfTest.java new file mode 100644 index 000000000000..4961b4f94057 --- /dev/null +++ b/apct-tests/perftests/core/src/android/os/CpuUsageTrackingPerfTest.java @@ -0,0 +1,80 @@ +/* + * 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.os; + +import android.perftests.utils.BenchmarkState; +import android.perftests.utils.PerfStatusReporter; +import android.support.test.filters.LargeTest; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.nio.file.Files; +import java.nio.file.Paths; + + +/** + * Performance tests collecting CPU data different mechanisms. + */ +@RunWith(AndroidJUnit4.class) +@LargeTest +public class CpuUsageTrackingPerfTest { + @Rule + public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + + @Test + public void timeSystemThread() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + Binder b = new Binder(); + while (state.keepRunning()) { + SystemClock.currentThreadTimeMicro(); + } + } + + @Test + public void timeReadStatFileDirectly() throws Exception { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + // CPU usage by frequency for this pid. Data is in text format. + final String procFile = "/proc/self/stat"; + while (state.keepRunning()) { + byte[] data = Files.readAllBytes(Paths.get(procFile)); + } + } + + @Test + public void timeReadPidProcDirectly() throws Exception { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + // CPU usage by frequency for this pid. Data is in text format. + final String procFile = "/proc/self/time_in_state"; + while (state.keepRunning()) { + byte[] data = Files.readAllBytes(Paths.get(procFile)); + } + } + + @Test + public void timeReadThreadProcDirectly() throws Exception { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + // CPU usage by frequency for this UID. Data is in text format. + final String procFile = "/proc/self/task/" + android.os.Process.myTid() + + "/time_in_state"; + while (state.keepRunning()) { + byte[] data = Files.readAllBytes(Paths.get(procFile)); + } + } +} diff --git a/api/current.txt b/api/current.txt index 373bc18f3cf5..702e34d1c828 100755 --- a/api/current.txt +++ b/api/current.txt @@ -42972,6 +42972,7 @@ package android.telephony { method public java.util.List<android.telephony.SubscriptionPlan> getSubscriptionPlans(int); method public boolean isActiveSubscriptionId(int); method public boolean isNetworkRoaming(int); + method public static boolean isUsableSubscriptionId(int); method public static boolean isValidSubscriptionId(int); method public void removeOnOpportunisticSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnOpportunisticSubscriptionsChangedListener); method public void removeOnSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnSubscriptionsChangedListener); @@ -42985,6 +42986,7 @@ package android.telephony { field public static final java.lang.String ACTION_REFRESH_SUBSCRIPTION_PLANS = "android.telephony.action.REFRESH_SUBSCRIPTION_PLANS"; field public static final int DATA_ROAMING_DISABLE = 0; // 0x0 field public static final int DATA_ROAMING_ENABLE = 1; // 0x1 + field public static final int DEFAULT_SUBSCRIPTION_ID = 2147483647; // 0x7fffffff field public static final java.lang.String EXTRA_SUBSCRIPTION_INDEX = "android.telephony.extra.SUBSCRIPTION_INDEX"; field public static final int INVALID_SIM_SLOT_INDEX = -2; // 0xfffffffe field public static final int INVALID_SUBSCRIPTION_ID = -1; // 0xffffffff diff --git a/cmds/statsd/src/packages/UidMap.cpp b/cmds/statsd/src/packages/UidMap.cpp index 8b1f5cbba3cb..37a00673959c 100644 --- a/cmds/statsd/src/packages/UidMap.cpp +++ b/cmds/statsd/src/packages/UidMap.cpp @@ -492,6 +492,7 @@ const std::map<string, uint32_t> UidMap::sAidToUidMapping = {{"AID_ROOT", 0}, {"AID_SECURE_ELEMENT", 1068}, {"AID_LMKD", 1069}, {"AID_LLKD", 1070}, + {"AID_IORAPD", 1071}, {"AID_SHELL", 2000}, {"AID_CACHE", 2001}, {"AID_DIAG", 2002}}; diff --git a/core/java/android/hardware/usb/IUsbSerialReader.aidl b/core/java/android/hardware/usb/IUsbSerialReader.aidl new file mode 100644 index 000000000000..787d5cdf8281 --- /dev/null +++ b/core/java/android/hardware/usb/IUsbSerialReader.aidl @@ -0,0 +1,24 @@ +/* + * 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.hardware.usb; + +/** @hide */ +interface IUsbSerialReader +{ + /* Returns a serial for the accessory/device */ + String getSerial(String packageName); +} diff --git a/core/java/android/hardware/usb/UsbAccessory.java b/core/java/android/hardware/usb/UsbAccessory.java index 4aeb40c167a0..b418d43d1990 100644 --- a/core/java/android/hardware/usb/UsbAccessory.java +++ b/core/java/android/hardware/usb/UsbAccessory.java @@ -18,8 +18,11 @@ package android.hardware.usb; import android.annotation.NonNull; import android.annotation.Nullable; +import android.app.ActivityThread; import android.os.Parcel; import android.os.Parcelable; +import android.os.RemoteException; + import com.android.internal.util.Preconditions; /** @@ -54,7 +57,7 @@ public class UsbAccessory implements Parcelable { private final @Nullable String mDescription; private final @Nullable String mVersion; private final @Nullable String mUri; - private final @Nullable String mSerial; + private final @NonNull IUsbSerialReader mSerialNumberReader; /** @hide */ public static final int MANUFACTURER_STRING = 0; @@ -75,22 +78,38 @@ public class UsbAccessory implements Parcelable { */ public UsbAccessory(@NonNull String manufacturer, @NonNull String model, @Nullable String description, @Nullable String version, @Nullable String uri, - @Nullable String serial) { + @NonNull IUsbSerialReader serialNumberReader) { mManufacturer = Preconditions.checkNotNull(manufacturer); mModel = Preconditions.checkNotNull(model); mDescription = description; mVersion = version; mUri = uri; - mSerial = serial; + mSerialNumberReader = serialNumberReader; + + // Make sure the binder belongs to the system + if (ActivityThread.isSystem()) { + Preconditions.checkArgument(mSerialNumberReader instanceof IUsbSerialReader.Stub); + } } /** - * UsbAccessory should only be instantiated by UsbService implementation + * DO NOT USE. Only for backwards compatibility with + * {@link com.android.future.usb.UsbAccessory}. + * * @hide + * @deprecated use {@link UsbAccessory#UsbAccessory(String, String, String, String, String, + * IUsbSerialReader) instead} */ - public UsbAccessory(String[] strings) { - this(strings[MANUFACTURER_STRING], strings[MODEL_STRING], strings[DESCRIPTION_STRING], - strings[VERSION_STRING], strings[URI_STRING], strings[SERIAL_STRING]); + @Deprecated + public UsbAccessory(@NonNull String manufacturer, @NonNull String model, + @Nullable String description, @Nullable String version, @Nullable String uri, + @Nullable String serialNumber) { + this(manufacturer, model, description, version, uri, new IUsbSerialReader.Stub() { + @Override + public String getSerial(String packageName) { + return serialNumber; + } + }); } /** @@ -146,9 +165,17 @@ public class UsbAccessory implements Parcelable { * between individual accessories of the same model and manufacturer * * @return the unique serial number, or {@code null} if not set + * + * @throws SecurityException if the app targets SDK >= {@value android.os.Build.VERSION_CODES#Q} + * and the app does not have permission to read from the accessory. */ public @Nullable String getSerial() { - return mSerial; + try { + return mSerialNumberReader.getSerial(ActivityThread.currentPackageName()); + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + return null; + } } private static boolean compare(String s1, String s2) { @@ -165,7 +192,7 @@ public class UsbAccessory implements Parcelable { compare(mDescription, accessory.getDescription()) && compare(mVersion, accessory.getVersion()) && compare(mUri, accessory.getUri()) && - compare(mSerial, accessory.getSerial())); + compare(getSerial(), accessory.getSerial())); } return false; } @@ -175,7 +202,7 @@ public class UsbAccessory implements Parcelable { return mManufacturer.hashCode() ^ mModel.hashCode() ^ (mDescription == null ? 0 : mDescription.hashCode()) ^ (mVersion == null ? 0 : mVersion.hashCode()) ^ - (mUri == null ? 0 : mUri.hashCode()) ^ (mSerial == null ? 0 : mSerial.hashCode()); + (mUri == null ? 0 : mUri.hashCode()); } @Override @@ -185,7 +212,7 @@ public class UsbAccessory implements Parcelable { ", mDescription=" + mDescription + ", mVersion=" + mVersion + ", mUri=" + mUri + - ", mSerial=" + mSerial + "]"; + ", mSerialNumberReader=" + mSerialNumberReader + "]"; } public static final Parcelable.Creator<UsbAccessory> CREATOR = @@ -196,8 +223,11 @@ public class UsbAccessory implements Parcelable { String description = in.readString(); String version = in.readString(); String uri = in.readString(); - String serial = in.readString(); - return new UsbAccessory(manufacturer, model, description, version, uri, serial); + IUsbSerialReader serialNumberReader = IUsbSerialReader.Stub.asInterface( + in.readStrongBinder()); + + return new UsbAccessory(manufacturer, model, description, version, uri, + serialNumberReader); } public UsbAccessory[] newArray(int size) { @@ -215,6 +245,6 @@ public class UsbAccessory implements Parcelable { parcel.writeString(mDescription); parcel.writeString(mVersion); parcel.writeString(mUri); - parcel.writeString(mSerial); + parcel.writeStrongBinder(mSerialNumberReader.asBinder()); } } diff --git a/core/java/android/hardware/usb/UsbDevice.java b/core/java/android/hardware/usb/UsbDevice.java index 26c5a9597571..b08212c2d37a 100644 --- a/core/java/android/hardware/usb/UsbDevice.java +++ b/core/java/android/hardware/usb/UsbDevice.java @@ -19,8 +19,11 @@ package android.hardware.usb; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UnsupportedAppUsage; +import android.app.ActivityThread; import android.os.Parcel; import android.os.Parcelable; +import android.os.RemoteException; + import com.android.internal.util.Preconditions; /** @@ -50,27 +53,27 @@ public class UsbDevice implements Parcelable { private final @Nullable String mManufacturerName; private final @Nullable String mProductName; private final @NonNull String mVersion; - private final @Nullable String mSerialNumber; + private final @NonNull UsbConfiguration[] mConfigurations; + private final @NonNull IUsbSerialReader mSerialNumberReader; private final int mVendorId; private final int mProductId; private final int mClass; private final int mSubclass; private final int mProtocol; - /** All configurations for this device, only null during creation */ - private @Nullable Parcelable[] mConfigurations; - /** All interfaces on the device. Initialized on first call to getInterfaceList */ @UnsupportedAppUsage private @Nullable UsbInterface[] mInterfaces; /** - * UsbDevice should only be instantiated by UsbService implementation + * Create a new UsbDevice object. Only called by {@link Builder#build(IUsbSerialReader)} + * * @hide */ - public UsbDevice(@NonNull String name, int vendorId, int productId, int Class, int subClass, + private UsbDevice(@NonNull String name, int vendorId, int productId, int Class, int subClass, int protocol, @Nullable String manufacturerName, @Nullable String productName, - @NonNull String version, @Nullable String serialNumber) { + @NonNull String version, @NonNull UsbConfiguration[] configurations, + @NonNull IUsbSerialReader serialNumberReader) { mName = Preconditions.checkNotNull(name); mVendorId = vendorId; mProductId = productId; @@ -80,7 +83,13 @@ public class UsbDevice implements Parcelable { mManufacturerName = manufacturerName; mProductName = productName; mVersion = Preconditions.checkStringNotEmpty(version); - mSerialNumber = serialNumber; + mConfigurations = Preconditions.checkArrayElementsNotNull(configurations, "configurations"); + mSerialNumberReader = Preconditions.checkNotNull(serialNumberReader); + + // Make sure the binder belongs to the system + if (ActivityThread.isSystem()) { + Preconditions.checkArgument(mSerialNumberReader instanceof IUsbSerialReader.Stub); + } } /** @@ -125,9 +134,17 @@ public class UsbDevice implements Parcelable { * Returns the serial number of the device. * * @return the serial number name, or {@code null} if the property could not be read + * + * @throws SecurityException if the app targets SDK >= {@value android.os.Build.VERSION_CODES#Q} + * and the app does not have permission to read from the device. */ public @Nullable String getSerialNumber() { - return mSerialNumber; + try { + return mSerialNumberReader.getSerial(ActivityThread.currentPackageName()); + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + return null; + } } /** @@ -203,7 +220,7 @@ public class UsbDevice implements Parcelable { * @return the configuration */ public @NonNull UsbConfiguration getConfiguration(int index) { - return (UsbConfiguration)mConfigurations[index]; + return mConfigurations[index]; } private @Nullable UsbInterface[] getInterfaceList() { @@ -211,14 +228,14 @@ public class UsbDevice implements Parcelable { int configurationCount = mConfigurations.length; int interfaceCount = 0; for (int i = 0; i < configurationCount; i++) { - UsbConfiguration configuration = (UsbConfiguration)mConfigurations[i]; + UsbConfiguration configuration = mConfigurations[i]; interfaceCount += configuration.getInterfaceCount(); } mInterfaces = new UsbInterface[interfaceCount]; int offset = 0; for (int i = 0; i < configurationCount; i++) { - UsbConfiguration configuration = (UsbConfiguration)mConfigurations[i]; + UsbConfiguration configuration = mConfigurations[i]; interfaceCount = configuration.getInterfaceCount(); for (int j = 0; j < interfaceCount; j++) { mInterfaces[offset++] = configuration.getInterface(j); @@ -251,14 +268,6 @@ public class UsbDevice implements Parcelable { return getInterfaceList()[index]; } - /** - * Only used by UsbService implementation - * @hide - */ - public void setConfigurations(@NonNull Parcelable[] configuration) { - mConfigurations = Preconditions.checkArrayElementsNotNull(configuration, "configuration"); - } - @Override public boolean equals(Object o) { if (o instanceof UsbDevice) { @@ -281,7 +290,8 @@ public class UsbDevice implements Parcelable { ",mVendorId=" + mVendorId + ",mProductId=" + mProductId + ",mClass=" + mClass + ",mSubclass=" + mSubclass + ",mProtocol=" + mProtocol + ",mManufacturerName=" + mManufacturerName + ",mProductName=" + mProductName + - ",mVersion=" + mVersion + ",mSerialNumber=" + mSerialNumber + ",mConfigurations=["); + ",mVersion=" + mVersion + ",mSerialNumberReader=" + mSerialNumberReader + + ",mConfigurations=["); for (int i = 0; i < mConfigurations.length; i++) { builder.append("\n"); builder.append(mConfigurations[i].toString()); @@ -302,11 +312,13 @@ public class UsbDevice implements Parcelable { String manufacturerName = in.readString(); String productName = in.readString(); String version = in.readString(); - String serialNumber = in.readString(); - Parcelable[] configurations = in.readParcelableArray(UsbInterface.class.getClassLoader()); + IUsbSerialReader serialNumberReader = + IUsbSerialReader.Stub.asInterface(in.readStrongBinder()); + UsbConfiguration[] configurations = in.readParcelableArray( + UsbConfiguration.class.getClassLoader(), UsbConfiguration.class); UsbDevice device = new UsbDevice(name, vendorId, productId, clasz, subClass, protocol, - manufacturerName, productName, version, serialNumber); - device.setConfigurations(configurations); + manufacturerName, productName, version, configurations, + serialNumberReader); return device; } @@ -329,7 +341,7 @@ public class UsbDevice implements Parcelable { parcel.writeString(mManufacturerName); parcel.writeString(mProductName); parcel.writeString(mVersion); - parcel.writeString(mSerialNumber); + parcel.writeStrongBinder(mSerialNumberReader.asBinder()); parcel.writeParcelableArray(mConfigurations, 0); } @@ -343,4 +355,53 @@ public class UsbDevice implements Parcelable { private static native int native_get_device_id(String name); private static native String native_get_device_name(int id); + + /** + * @hide + */ + public static class Builder { + private final @NonNull String mName; + private final int mVendorId; + private final int mProductId; + private final int mClass; + private final int mSubclass; + private final int mProtocol; + private final @Nullable String mManufacturerName; + private final @Nullable String mProductName; + private final @NonNull String mVersion; + private final @NonNull UsbConfiguration[] mConfigurations; + + // Temporary storage for serial number. Serial number reader need to be wrapped in a + // IUsbSerialReader as they might be used as PII. + public final @Nullable String serialNumber; + + public Builder(@NonNull String name, int vendorId, int productId, int Class, int subClass, + int protocol, @Nullable String manufacturerName, @Nullable String productName, + @NonNull String version, @NonNull UsbConfiguration[] configurations, + @Nullable String serialNumber) { + mName = Preconditions.checkNotNull(name); + mVendorId = vendorId; + mProductId = productId; + mClass = Class; + mSubclass = subClass; + mProtocol = protocol; + mManufacturerName = manufacturerName; + mProductName = productName; + mVersion = Preconditions.checkStringNotEmpty(version); + mConfigurations = configurations; + this.serialNumber = serialNumber; + } + + /** + * Create a new {@link UsbDevice} + * + * @param serialReader The method to read the serial number. + * + * @return The usb device + */ + public UsbDevice build(@NonNull IUsbSerialReader serialReader) { + return new UsbDevice(mName, mVendorId, mProductId, mClass, mSubclass, mProtocol, + mManufacturerName, mProductName, mVersion, mConfigurations, serialReader); + } + } } diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java index 112329e48703..25554b937065 100644 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -868,7 +868,11 @@ public final class ContactsContract { */ protected interface ContactOptionsColumns { /** - * The number of times a contact has been contacted + * The number of times a contact has been contacted. + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. For + * more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page.</p> * <P>Type: INTEGER</P> * * @deprecated Contacts affinity information is no longer supported as of @@ -880,6 +884,10 @@ public final class ContactsContract { /** * The last time a contact was contacted. + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. For + * more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page.</p> * <P>Type: INTEGER</P> * * @deprecated Contacts affinity information is no longer supported as of @@ -1682,6 +1690,11 @@ public final class ContactsContract { * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED * field is populated with the current system time. * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this method is obsolete. For + * more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. + * * @param resolver the ContentResolver to use * @param contactId the person who was contacted * @@ -1715,6 +1728,11 @@ public final class ContactsContract { * {@link ContactsContract.Data}, filtered to include only starred contacts. * Frequent contacts are no longer included in the result as of * Android version {@link android.os.Build.VERSION_CODES#Q}. + * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts + * results based on contacts frequency. For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. */ public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath( CONTENT_URI, "strequent"); @@ -1725,16 +1743,26 @@ public final class ContactsContract { * @deprecated Frequent contacts are no longer supported as of * Android version {@link android.os.Build.VERSION_CODES#Q}. * This URI always returns an empty cursor. + * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts + * results based on contacts frequency. For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. */ @Deprecated public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath( CONTENT_URI, "frequent"); /** - * The content:// style URI used for "type-to-filter" functionality on the + * <p>The content:// style URI used for "type-to-filter" functionality on the * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match * various parts of the contact name. The filter argument should be passed * as an additional path segment after this URI. + * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts + * results based on contacts frequency. For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. */ public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath( CONTENT_STREQUENT_URI, "filter"); @@ -4262,6 +4290,11 @@ public final class ContactsContract { * @deprecated Contacts affinity information is no longer supported as of * Android version {@link android.os.Build.VERSION_CODES#Q}. * This column always contains 0. + * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. + * For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. */ @Deprecated public static final String LAST_TIME_USED = "last_time_used"; @@ -4271,6 +4304,11 @@ public final class ContactsContract { * @deprecated Contacts affinity information is no longer supported as of * Android version {@link android.os.Build.VERSION_CODES#Q}. * This column always contains 0. + * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. + * For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. */ @Deprecated public static final String TIMES_USED = "times_used"; @@ -5218,7 +5256,14 @@ public final class ContactsContract { private PhoneLookup() {} /** - * The content:// style URI for this table. Append the phone number you want to lookup + * The content:// style URI for this table. + * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer + * sorts results based on contacts frequency. For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. + * + * Append the phone number you want to lookup * to this URI and query it to perform a lookup. For example: * <pre> * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, @@ -5231,6 +5276,11 @@ public final class ContactsContract { /** * <p>URI used for the "enterprise caller-id".</p> * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer + * sorts results based on contacts frequency. For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. + * * <p> * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same * columns. If the device has no corp profile that is linked to the current profile, it @@ -6023,18 +6073,28 @@ public final class ContactsContract { Uri.withAppendedPath(Data.ENTERPRISE_CONTENT_URI, "phones"); /** - * The content:// style URL for phone lookup using a filter. The filter returns + * <p>The content:// style URL for phone lookup using a filter. The filter returns * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied * to display names as well as phone numbers. The filter argument should be passed * as an additional path segment after this URI. + * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer + * sorts results based on contacts frequency. For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. */ public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, "filter"); /** - * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same - * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in + * <p>It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the + * same columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in * parameters, otherwise it will throw IllegalArgumentException. + * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts + * results based on contacts frequency. For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. */ public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( CONTENT_URI, "filter_enterprise"); @@ -6202,7 +6262,7 @@ public final class ContactsContract { */ public static final class Email implements DataColumnsWithJoins, CommonColumns, ContactCounts { - /** + /* * This utility class cannot be instantiated */ private Email() {} @@ -6293,12 +6353,17 @@ public final class ContactsContract { Uri.withAppendedPath(CONTENT_URI, "lookup_enterprise"); /** - * <p> - * The content:// style URL for email lookup using a filter. The filter returns + * <p>The content:// style URL for email lookup using a filter. The filter returns * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied * to display names as well as email addresses. The filter argument should be passed * as an additional path segment after this URI. * </p> + * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts + * results based on contacts frequency. For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page.</p> + * * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" * as well as "Bob Parr (incredible@android.com)". * <pre> @@ -6313,9 +6378,14 @@ public final class ContactsContract { "filter"); /** - * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same - * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in + * <p>It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the + * same columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in * parameters, otherwise it will throw IllegalArgumentException. + * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer + * sorts results based on contacts frequency. For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. */ public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( CONTENT_URI, "filter_enterprise"); @@ -7528,16 +7598,26 @@ public final class ContactsContract { public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, "callables"); /** - * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable + * <p>Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable * data. + * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer + * sorts results based on contacts frequency. For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. */ public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, "filter"); /** - * Similar to {@link Phone#ENTERPRISE_CONTENT_FILTER_URI}, but allows users to filter + * <p>Similar to {@link Phone#ENTERPRISE_CONTENT_FILTER_URI}, but allows users to filter * callable data. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in * parameters, otherwise it will throw IllegalArgumentException. + * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer + * sorts results based on contacts frequency. For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page.</p> */ public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( CONTENT_URI, "filter_enterprise"); @@ -7562,8 +7642,13 @@ public final class ContactsContract { "contactables"); /** - * The content:// style URI for these data items, which allows for a query parameter to - * be appended onto the end to filter for data items matching the query. + * <p>The content:// style URI for these data items, which allows for a query parameter + * to be appended onto the end to filter for data items matching the query. + * + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer + * sorts results based on contacts frequency. For more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. */ public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( Contactables.CONTENT_URI, "filter"); @@ -8212,6 +8297,11 @@ public final class ContactsContract { } /** + * <p class="caution"><b>Caution: </b>As of January 7, 2019, this class is obsolete. For + * more information, see the + * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> + * page. + * </p> * <p> * API allowing applications to send usage information for each {@link Data} row to the * Contacts Provider. Applications can also clear all usage information. diff --git a/core/java/com/android/internal/content/NativeLibraryHelper.java b/core/java/com/android/internal/content/NativeLibraryHelper.java index c3881485d4f9..fee8345d1660 100644 --- a/core/java/com/android/internal/content/NativeLibraryHelper.java +++ b/core/java/com/android/internal/content/NativeLibraryHelper.java @@ -171,8 +171,7 @@ public class NativeLibraryHelper { boolean debuggable); private native static int nativeCopyNativeBinaries(long handle, String sharedLibraryPath, - String abiToCopy, boolean extractNativeLibs, boolean hasNativeBridge, - boolean debuggable); + String abiToCopy, boolean extractNativeLibs, boolean debuggable); private static long sumNativeBinaries(Handle handle, String abi) { long sum = 0; @@ -193,7 +192,7 @@ public class NativeLibraryHelper { public static int copyNativeBinaries(Handle handle, File sharedLibraryDir, String abi) { for (long apkHandle : handle.apkHandles) { int res = nativeCopyNativeBinaries(apkHandle, sharedLibraryDir.getPath(), abi, - handle.extractNativeLibs, HAS_NATIVE_BRIDGE, handle.debuggable); + handle.extractNativeLibs, handle.debuggable); if (res != INSTALL_SUCCEEDED) { return res; } @@ -448,9 +447,6 @@ public class NativeLibraryHelper { // We don't care about the other return values for now. private static final int BITCODE_PRESENT = 1; - private static final boolean HAS_NATIVE_BRIDGE = - !"0".equals(SystemProperties.get("ro.dalvik.vm.native.bridge", "0")); - private static native int hasRenderscriptBitcode(long apkHandle); public static boolean hasRenderscriptBitcode(Handle handle) throws IOException { diff --git a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp index dc0426987b1e..5eefc8196d30 100644 --- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp +++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp @@ -176,7 +176,6 @@ copyFileIfChanged(JNIEnv *env, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntr void** args = reinterpret_cast<void**>(arg); jstring* javaNativeLibPath = (jstring*) args[0]; jboolean extractNativeLibs = *(jboolean*) args[1]; - jboolean hasNativeBridge = *(jboolean*) args[2]; ScopedUtfChars nativeLibPath(env, *javaNativeLibPath); @@ -206,9 +205,7 @@ copyFileIfChanged(JNIEnv *env, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntr return INSTALL_FAILED_INVALID_APK; } - if (!hasNativeBridge) { - return INSTALL_SUCCEEDED; - } + return INSTALL_SUCCEEDED; } // Build local file path @@ -489,9 +486,9 @@ static int findSupportedAbi(JNIEnv *env, jlong apkHandle, jobjectArray supported static jint com_android_internal_content_NativeLibraryHelper_copyNativeBinaries(JNIEnv *env, jclass clazz, jlong apkHandle, jstring javaNativeLibPath, jstring javaCpuAbi, - jboolean extractNativeLibs, jboolean hasNativeBridge, jboolean debuggable) + jboolean extractNativeLibs, jboolean debuggable) { - void* args[] = { &javaNativeLibPath, &extractNativeLibs, &hasNativeBridge }; + void* args[] = { &javaNativeLibPath, &extractNativeLibs }; return (jint) iterateOverNativeFiles(env, apkHandle, javaCpuAbi, debuggable, copyFileIfChanged, reinterpret_cast<void*>(args)); } @@ -597,7 +594,7 @@ static const JNINativeMethod gMethods[] = { "(J)V", (void *)com_android_internal_content_NativeLibraryHelper_close}, {"nativeCopyNativeBinaries", - "(JLjava/lang/String;Ljava/lang/String;ZZZ)I", + "(JLjava/lang/String;Ljava/lang/String;ZZ)I", (void *)com_android_internal_content_NativeLibraryHelper_copyNativeBinaries}, {"nativeSumNativeBinaries", "(JLjava/lang/String;Z)J", diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 6d0127a4bba1..1e3aeae8e3c4 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1132,9 +1132,9 @@ <string name="permdesc_accessCoarseLocation" product="default">This app can get your location based on network sources such as cell towers and Wi-Fi networks. These location services must be turned on and available on your phone for the app to be able to use them.</string> <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> - <string name="permlab_accessBackgroundLocation">access precise location in the background</string> + <string name="permlab_accessBackgroundLocation">access location in the background</string> <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> - <string name="permdesc_accessBackgroundLocation">This app can get your exact location any time it is in the background. These location services must be turned on and available on your phone for the app to be able to use them. This may increase battery consumption.</string> + <string name="permdesc_accessBackgroundLocation">If this is granted additionally to the approximate or precise location access the app can access the location while running in the background.</string> <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> <string name="permlab_modifyAudioSettings">change your audio settings</string> diff --git a/libs/androidfw/Android.bp b/libs/androidfw/Android.bp index bba36bcba804..74cab920cf2d 100644 --- a/libs/androidfw/Android.bp +++ b/libs/androidfw/Android.bp @@ -43,8 +43,10 @@ cc_library { "AssetManager2.cpp", "AttributeResolution.cpp", "ChunkIterator.cpp", + "ConfigDescription.cpp", "Idmap.cpp", "LoadedArsc.cpp", + "Locale.cpp", "LocaleData.cpp", "misc.cpp", "ObbFile.cpp", @@ -135,10 +137,12 @@ cc_test { "tests/AttributeResolution_test.cpp", "tests/ByteBucketArray_test.cpp", "tests/Config_test.cpp", + "tests/ConfigDescription_test.cpp", "tests/ConfigLocale_test.cpp", "tests/DynamicRefTable_test.cpp", "tests/Idmap_test.cpp", "tests/LoadedArsc_test.cpp", + "tests/Locale_test.cpp", "tests/ResourceUtils_test.cpp", "tests/ResTable_test.cpp", "tests/Split_test.cpp", diff --git a/tools/aapt2/ConfigDescription.cpp b/libs/androidfw/ConfigDescription.cpp index f621660cb8ad..1f3a89edb8af 100644 --- a/tools/aapt2/ConfigDescription.cpp +++ b/libs/androidfw/ConfigDescription.cpp @@ -14,22 +14,16 @@ * limitations under the License. */ -#include "ConfigDescription.h" - -#include <string> -#include <vector> - +#include "androidfw/ConfigDescription.h" +#include "androidfw/Locale.h" #include "androidfw/ResourceTypes.h" #include "androidfw/StringPiece.h" +#include "androidfw/Util.h" -#include "Locale.h" -#include "SdkConstants.h" -#include "util/Util.h" - -using android::ResTable_config; -using android::StringPiece; +#include <string> +#include <vector> -namespace aapt { +namespace android { static const char* kWildcardName = "any"; @@ -883,7 +877,7 @@ std::string ConfigDescription::GetBcp47LanguageTag(bool canonicalize) const { } std::string ConfigDescription::to_string() const { - const android::String8 str = toString(); + const String8 str = toString(); return std::string(str.string(), str.size()); } @@ -996,4 +990,4 @@ bool ConfigDescription::IsCompatibleWith(const ConfigDescription& o) const { return !ConflictsWith(o) && !Dominates(o) && !o.Dominates(*this); } -} // namespace aapt +} // namespace android diff --git a/tools/aapt2/Locale.cpp b/libs/androidfw/Locale.cpp index d81921f23904..2870066ccbba 100644 --- a/tools/aapt2/Locale.cpp +++ b/libs/androidfw/Locale.cpp @@ -14,7 +14,8 @@ * limitations under the License. */ -#include "Locale.h" +#include "androidfw/Locale.h" +#include "androidfw/Util.h" #include <ctype.h> @@ -22,12 +23,10 @@ #include <string> #include <vector> -#include "util/Util.h" - using ::android::ResTable_config; using ::android::StringPiece; -namespace aapt { +namespace android { void LocaleValue::set_language(const char* language_chars) { size_t i = 0; @@ -258,4 +257,4 @@ void LocaleValue::WriteTo(ResTable_config* out) const { } } -} // namespace aapt +} // namespace android diff --git a/libs/androidfw/Util.cpp b/libs/androidfw/Util.cpp index 575cd18a36dd..59c9d640bb91 100644 --- a/libs/androidfw/Util.cpp +++ b/libs/androidfw/Util.cpp @@ -16,6 +16,7 @@ #include "androidfw/Util.h" +#include <algorithm> #include <string> #include "utils/ByteOrder.h" @@ -67,5 +68,28 @@ std::string Utf16ToUtf8(const StringPiece16& utf16) { return utf8; } +static std::vector<std::string> SplitAndTransform( + const StringPiece& str, char sep, const std::function<char(char)>& f) { + std::vector<std::string> parts; + const StringPiece::const_iterator end = std::end(str); + StringPiece::const_iterator start = std::begin(str); + StringPiece::const_iterator current; + do { + current = std::find(start, end, sep); + parts.emplace_back(str.substr(start, current).to_string()); + if (f) { + std::string& part = parts.back(); + std::transform(part.begin(), part.end(), part.begin(), f); + } + start = current + 1; + } while (current != end); + return parts; +} + +std::vector<std::string> SplitAndLowercase(const StringPiece& str, char sep) { + return SplitAndTransform(str, sep, ::tolower); +} + + } // namespace util } // namespace android diff --git a/tools/aapt2/ConfigDescription.h b/libs/androidfw/include/androidfw/ConfigDescription.h index b46a50398217..29424c4462aa 100644 --- a/tools/aapt2/ConfigDescription.h +++ b/libs/androidfw/include/androidfw/ConfigDescription.h @@ -14,21 +14,52 @@ * limitations under the License. */ -#ifndef AAPT_CONFIG_DESCRIPTION_H -#define AAPT_CONFIG_DESCRIPTION_H +#ifndef ANDROIDFW_CONFIG_DESCRIPTION_H +#define ANDROIDFW_CONFIG_DESCRIPTION_H #include <ostream> #include "androidfw/ResourceTypes.h" #include "androidfw/StringPiece.h" -namespace aapt { +namespace android { + +using ApiVersion = int; + +enum : ApiVersion { + SDK_CUPCAKE = 3, + SDK_DONUT = 4, + SDK_ECLAIR = 5, + SDK_ECLAIR_0_1 = 6, + SDK_ECLAIR_MR1 = 7, + SDK_FROYO = 8, + SDK_GINGERBREAD = 9, + SDK_GINGERBREAD_MR1 = 10, + SDK_HONEYCOMB = 11, + SDK_HONEYCOMB_MR1 = 12, + SDK_HONEYCOMB_MR2 = 13, + SDK_ICE_CREAM_SANDWICH = 14, + SDK_ICE_CREAM_SANDWICH_MR1 = 15, + SDK_JELLY_BEAN = 16, + SDK_JELLY_BEAN_MR1 = 17, + SDK_JELLY_BEAN_MR2 = 18, + SDK_KITKAT = 19, + SDK_KITKAT_WATCH = 20, + SDK_LOLLIPOP = 21, + SDK_LOLLIPOP_MR1 = 22, + SDK_MARSHMALLOW = 23, + SDK_NOUGAT = 24, + SDK_NOUGAT_MR1 = 25, + SDK_O = 26, + SDK_O_MR1 = 27, + SDK_P = 28, +}; /* * Subclass of ResTable_config that adds convenient * initialization and comparison methods. */ -struct ConfigDescription : public android::ResTable_config { +struct ConfigDescription : public ResTable_config { /** * Returns an immutable default config. */ @@ -180,6 +211,6 @@ inline ::std::ostream& operator<<(::std::ostream& out, return out << o.toString().string(); } -} // namespace aapt +} // namespace android -#endif // AAPT_CONFIG_DESCRIPTION_H +#endif // ANDROIDFW_CONFIG_DESCRIPTION_H diff --git a/tools/aapt2/Locale.h b/libs/androidfw/include/androidfw/Locale.h index 6d8b598415cc..484ed79a8efd 100644 --- a/tools/aapt2/Locale.h +++ b/libs/androidfw/include/androidfw/Locale.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef AAPT_LOCALE_VALUE_H -#define AAPT_LOCALE_VALUE_H +#ifndef ANDROIDFW_LOCALE_VALUE_H +#define ANDROIDFW_LOCALE_VALUE_H #include <string> #include <vector> @@ -23,7 +23,7 @@ #include "androidfw/ResourceTypes.h" #include "androidfw/StringPiece.h" -namespace aapt { +namespace android { /** * A convenience class to build and parse locales. @@ -112,6 +112,6 @@ bool LocaleValue::operator>(const LocaleValue& o) const { return compare(o) > 0; } -} // namespace aapt +} // namespace android -#endif // AAPT_LOCALE_VALUE_H +#endif // ANDROIDFW_LOCALE_VALUE_H diff --git a/libs/androidfw/include/androidfw/Util.h b/libs/androidfw/include/androidfw/Util.h index 6c9eee0b8835..10d088e02829 100644 --- a/libs/androidfw/include/androidfw/Util.h +++ b/libs/androidfw/include/androidfw/Util.h @@ -19,6 +19,7 @@ #include <cstdlib> #include <memory> +#include <vector> #include "android-base/macros.h" @@ -116,6 +117,8 @@ std::u16string Utf8ToUtf16(const StringPiece& utf8); // Converts a UTF-16 string to a UTF-8 string. std::string Utf16ToUtf8(const StringPiece16& utf16); +std::vector<std::string> SplitAndLowercase(const android::StringPiece& str, char sep); + } // namespace util } // namespace android diff --git a/tools/aapt2/ConfigDescription_test.cpp b/libs/androidfw/tests/ConfigDescription_test.cpp index 1f351bf7481d..ce7f8054e2ca 100644 --- a/tools/aapt2/ConfigDescription_test.cpp +++ b/libs/androidfw/tests/ConfigDescription_test.cpp @@ -14,18 +14,16 @@ * limitations under the License. */ -#include "ConfigDescription.h" - -#include <string> - +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" -#include "SdkConstants.h" -#include "test/Test.h" +#include "android-base/logging.h" -using android::StringPiece; +#include "gtest/gtest.h" + +#include <string> -namespace aapt { +namespace android { static ::testing::AssertionResult TestParse( const StringPiece& input, ConfigDescription* config = nullptr) { @@ -140,9 +138,13 @@ TEST(ConfigDescriptionTest, ParseVrAttribute) { EXPECT_EQ(std::string("vrheadset-v26"), config.toString().string()); } -TEST(ConfigDescriptionTest, RangeQualifiersDoNotConflict) { - using test::ParseConfigOrDie; +static inline ConfigDescription ParseConfigOrDie(const android::StringPiece& str) { + ConfigDescription config; + CHECK(ConfigDescription::Parse(str, &config)) << "invalid configuration: " << str; + return config; +} +TEST(ConfigDescriptionTest, RangeQualifiersDoNotConflict) { EXPECT_FALSE(ParseConfigOrDie("large").ConflictsWith(ParseConfigOrDie("normal-land"))); EXPECT_FALSE(ParseConfigOrDie("long-hdpi").ConflictsWith(ParseConfigOrDie("xhdpi"))); EXPECT_FALSE(ParseConfigOrDie("sw600dp").ConflictsWith(ParseConfigOrDie("sw700dp"))); @@ -152,4 +154,4 @@ TEST(ConfigDescriptionTest, RangeQualifiersDoNotConflict) { EXPECT_FALSE(ParseConfigOrDie("600x400").ConflictsWith(ParseConfigOrDie("300x200"))); } -} // namespace aapt +} // namespace android diff --git a/tools/aapt2/Locale_test.cpp b/libs/androidfw/tests/Locale_test.cpp index 68b4cae44e15..6b2ef5f6a381 100644 --- a/tools/aapt2/Locale_test.cpp +++ b/libs/androidfw/tests/Locale_test.cpp @@ -14,15 +14,14 @@ * limitations under the License. */ -#include "Locale.h" +#include "androidfw/Locale.h" +#include "androidfw/Util.h" #include <string> #include "gtest/gtest.h" -#include "util/Util.h" - -namespace aapt { +namespace android { static ::testing::AssertionResult TestLanguage(const char* input, const char* lang) { @@ -93,4 +92,4 @@ TEST(ConfigDescriptionTest, ParseLanguage) { EXPECT_TRUE(TestLanguageRegion("fr-rCA", "fr", "CA")); } -} // namespace aapt +} // namespace android diff --git a/libs/hwui/renderthread/VulkanManager.cpp b/libs/hwui/renderthread/VulkanManager.cpp index b0d45052ca49..9e435a5dbf75 100644 --- a/libs/hwui/renderthread/VulkanManager.cpp +++ b/libs/hwui/renderthread/VulkanManager.cpp @@ -496,13 +496,11 @@ SkSurface* VulkanManager::getBackbufferSurface(VulkanSurface* surface) { // 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_IMAGE_LAYOUT_UNDEFINED == layout) - ? VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT - : VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + VkPipelineStageFlags srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - VkAccessFlags srcAccessMask = - (VK_IMAGE_LAYOUT_UNDEFINED == layout) ? 0 : VK_ACCESS_MEMORY_READ_BIT; - VkAccessFlags dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + VkAccessFlags srcAccessMask = 0; + VkAccessFlags dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | + VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; VkImageMemoryBarrier imageMemoryBarrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType @@ -761,16 +759,8 @@ bool VulkanManager::createSwapchain(VulkanSurface* surface) { return false; } - // If mailbox mode is available, use it, as it is the lowest-latency non- - // tearing mode. If not, fall back to FIFO which is always available. + // FIFO is always available and will match what we do on GL so just pick that here. VkPresentModeKHR mode = VK_PRESENT_MODE_FIFO_KHR; - for (uint32_t i = 0; i < presentModeCount; ++i) { - // use mailbox - if (VK_PRESENT_MODE_MAILBOX_KHR == presentModes[i]) { - mode = presentModes[i]; - break; - } - } VkSwapchainCreateInfoKHR swapchainCreateInfo; memset(&swapchainCreateInfo, 0, sizeof(VkSwapchainCreateInfoKHR)); @@ -857,17 +847,19 @@ VulkanSurface* VulkanManager::createSurface(ANativeWindow* window, ColorMode col } // Helper to know which src stage flags we need to set when transitioning to the present layout -static VkPipelineStageFlags layoutToPipelineStageFlags(const VkImageLayout 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 || - VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL == layout || - VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL == layout || - VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL == layout) { - return VK_PIPELINE_STAGE_ALL_GRAPHICS_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; } @@ -924,10 +916,10 @@ void VulkanManager::swapBuffers(VulkanSurface* surface) { // 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 = layoutToPipelineStageFlags(layout); + VkPipelineStageFlags srcStageMask = layoutToPipelineSrcStageFlags(layout); VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; VkAccessFlags srcAccessMask = layoutToSrcAccessMask(layout); - VkAccessFlags dstAccessMask = VK_ACCESS_MEMORY_READ_BIT; + VkAccessFlags dstAccessMask = 0; VkImageMemoryBarrier imageMemoryBarrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/RemotePrintDocument.java b/packages/PrintSpooler/src/com/android/printspooler/model/RemotePrintDocument.java index 164454690d46..42c1997b41a3 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/model/RemotePrintDocument.java +++ b/packages/PrintSpooler/src/com/android/printspooler/model/RemotePrintDocument.java @@ -218,8 +218,14 @@ public final class RemotePrintDocument { throw new IllegalStateException("Cannot update in state:" + stateToString(mState)); } - // We schedule a layout if the constraints changed. - if (!mUpdateSpec.hasSameConstraints(attributes, preview)) { + /* + * We schedule a layout in two cases: + * - if the current command is canceling. In this case the mUpdateSpec will be marked as + * stale once the command is done, hence we have to start from scratch + * - if the constraints changed we have a different document, hence start a new layout + */ + if (mCurrentCommand != null && mCurrentCommand.isCanceling() + || !mUpdateSpec.hasSameConstraints(attributes, preview)) { willUpdate = true; // If there is a current command that is running we ask for a diff --git a/packages/SettingsLib/src/com/android/settingslib/net/DataUsageController.java b/packages/SettingsLib/src/com/android/settingslib/net/DataUsageController.java index eeaa9872a452..183d4856ac6f 100644 --- a/packages/SettingsLib/src/com/android/settingslib/net/DataUsageController.java +++ b/packages/SettingsLib/src/com/android/settingslib/net/DataUsageController.java @@ -24,6 +24,8 @@ import static android.telephony.TelephonyManager.SIM_STATE_READY; import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH; import static android.text.format.DateUtils.FORMAT_SHOW_DATE; +import android.app.usage.NetworkStats.Bucket; +import android.app.usage.NetworkStatsManager; import android.content.Context; import android.net.ConnectivityManager; import android.net.INetworkStatsService; @@ -37,6 +39,7 @@ import android.os.ServiceManager; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.format.DateUtils; +import android.util.FeatureFlagUtils; import android.util.Log; import android.util.Range; @@ -51,6 +54,8 @@ import java.util.Locale; public class DataUsageController { private static final String TAG = "DataUsageController"; + @VisibleForTesting + static final String DATA_USAGE_V2 = "settings_data_usage_v2"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final int FIELDS = FIELD_RX_BYTES | FIELD_TX_BYTES; private static final StringBuilder PERIOD_BUILDER = new StringBuilder(50); @@ -62,6 +67,7 @@ public class DataUsageController { private final ConnectivityManager mConnectivityManager; private final INetworkStatsService mStatsService; private final NetworkPolicyManager mPolicyManager; + private final NetworkStatsManager mNetworkStatsManager; private INetworkStatsSession mSession; private Callback mCallback; @@ -74,6 +80,7 @@ public class DataUsageController { mStatsService = INetworkStatsService.Stub.asInterface( ServiceManager.getService(Context.NETWORK_STATS_SERVICE)); mPolicyManager = NetworkPolicyManager.from(mContext); + mNetworkStatsManager = context.getSystemService(NetworkStatsManager.class); } public void setNetworkController(NetworkNameProvider networkController) { @@ -89,6 +96,7 @@ public class DataUsageController { } @VisibleForTesting + @Deprecated INetworkStatsSession getSession() { if (mSession == null) { try { @@ -128,71 +136,72 @@ public class DataUsageController { } public DataUsageInfo getDataUsageInfo(NetworkTemplate template) { - final INetworkStatsSession session = getSession(); - if (session == null) { - return warn("no stats session"); - } final NetworkPolicy policy = findNetworkPolicy(template); - try { - final NetworkStatsHistory history = session.getHistoryForNetwork(template, FIELDS); - final long now = System.currentTimeMillis(); - final long start, end; - final Iterator<Range<ZonedDateTime>> it = - (policy != null) ? policy.cycleIterator() : null; - if (it != null && it.hasNext()) { - final Range<ZonedDateTime> cycle = it.next(); - start = cycle.getLower().toInstant().toEpochMilli(); - end = cycle.getUpper().toInstant().toEpochMilli(); - } else { - // period = last 4 wks - end = now; - start = now - DateUtils.WEEK_IN_MILLIS * 4; - } - final long callStart = System.currentTimeMillis(); - final NetworkStatsHistory.Entry entry = history.getValues(start, end, now, null); - final long callEnd = System.currentTimeMillis(); - if (DEBUG) Log.d(TAG, String.format("history call from %s to %s now=%s took %sms: %s", - new Date(start), new Date(end), new Date(now), callEnd - callStart, - historyEntryToString(entry))); - if (entry == null) { - return warn("no entry data"); - } - final long totalBytes = entry.rxBytes + entry.txBytes; - final DataUsageInfo usage = new DataUsageInfo(); - usage.startDate = start; - usage.usageLevel = totalBytes; - usage.period = formatDateRange(start, end); - usage.cycleStart = start; - usage.cycleEnd = end; - - if (policy != null) { - usage.limitLevel = policy.limitBytes > 0 ? policy.limitBytes : 0; - usage.warningLevel = policy.warningBytes > 0 ? policy.warningBytes : 0; - } else { - usage.warningLevel = getDefaultWarningLevel(); - } - if (usage != null && mNetworkController != null) { - usage.carrier = mNetworkController.getMobileDataNetworkName(); - } - return usage; - } catch (RemoteException e) { - return warn("remote call failed"); + final long now = System.currentTimeMillis(); + final long start, end; + final Iterator<Range<ZonedDateTime>> it = (policy != null) ? policy.cycleIterator() : null; + if (it != null && it.hasNext()) { + final Range<ZonedDateTime> cycle = it.next(); + start = cycle.getLower().toInstant().toEpochMilli(); + end = cycle.getUpper().toInstant().toEpochMilli(); + } else { + // period = last 4 wks + end = now; + start = now - DateUtils.WEEK_IN_MILLIS * 4; + } + final long totalBytes; + final long callStart = System.currentTimeMillis(); + if (FeatureFlagUtils.isEnabled(mContext, DATA_USAGE_V2)) { + totalBytes = getUsageLevel(template, start, end); + } else { + totalBytes = getUsageLevel(template, start, end, now); + } + if (totalBytes < 0L) { + return warn("no entry data"); } + final DataUsageInfo usage = new DataUsageInfo(); + usage.startDate = start; + usage.usageLevel = totalBytes; + usage.period = formatDateRange(start, end); + usage.cycleStart = start; + usage.cycleEnd = end; + + if (policy != null) { + usage.limitLevel = policy.limitBytes > 0 ? policy.limitBytes : 0; + usage.warningLevel = policy.warningBytes > 0 ? policy.warningBytes : 0; + } else { + usage.warningLevel = getDefaultWarningLevel(); + } + if (usage != null && mNetworkController != null) { + usage.carrier = mNetworkController.getMobileDataNetworkName(); + } + return usage; } /** * Get the total usage level recorded in the network history * @param template the network template to retrieve the network history - * @return the total usage level recorded in the network history + * @return the total usage level recorded in the network history or -1L if there is error + * retrieving the data. */ - public long getHistoriclUsageLevel(NetworkTemplate template) { + public long getHistoricalUsageLevel(NetworkTemplate template) { + if (FeatureFlagUtils.isEnabled(mContext, DATA_USAGE_V2)) { + return getUsageLevel(template, 0L /* start */, System.currentTimeMillis() /* end */); + } else { + final long now = System.currentTimeMillis(); + return getUsageLevel(template, 0L /* start */, now /* end */, now); + } + } + + @Deprecated + private long getUsageLevel(NetworkTemplate template, long start, long end, long now) { final INetworkStatsSession session = getSession(); if (session != null) { try { - final NetworkStatsHistory history = session.getHistoryForNetwork(template, FIELDS); - final long now = System.currentTimeMillis(); - final NetworkStatsHistory.Entry entry = - history.getValues(0L /* start */, now /* end */, now, null /* recycle */); + final NetworkStatsHistory history = + session.getHistoryForNetwork(template, FIELDS); + final NetworkStatsHistory.Entry entry = history.getValues( + start, end, System.currentTimeMillis() /* now */, null /* recycle */); if (entry != null) { return entry.rxBytes + entry.txBytes; } @@ -201,7 +210,21 @@ public class DataUsageController { Log.w(TAG, "Failed to get data usage, remote call failed"); } } - return 0L; + return -1L; + } + + private long getUsageLevel(NetworkTemplate template, long start, long end) { + try { + final Bucket bucket = mNetworkStatsManager.querySummaryForDevice( + getNetworkType(template), getActiveSubscriberId(mContext), start, end); + if (bucket != null) { + return bucket.getRxBytes() + bucket.getTxBytes(); + } + Log.w(TAG, "Failed to get data usage, no entry data"); + } catch (RemoteException e) { + Log.w(TAG, "Failed to get data usage, remote call failed"); + } + return -1L; } private NetworkPolicy findNetworkPolicy(NetworkTemplate template) { @@ -218,6 +241,7 @@ public class DataUsageController { return null; } + @Deprecated private static String historyEntryToString(NetworkStatsHistory.Entry entry) { return entry == null ? null : new StringBuilder("Entry[") .append("bucketDuration=").append(entry.bucketDuration) @@ -231,6 +255,17 @@ public class DataUsageController { .append(']').toString(); } + private static String statsBucketToString(Bucket bucket) { + return bucket == null ? null : new StringBuilder("Entry[") + .append("bucketDuration=").append(bucket.getEndTimeStamp() - bucket.getStartTimeStamp()) + .append(",bucketStart=").append(bucket.getStartTimeStamp()) + .append(",rxBytes=").append(bucket.getRxBytes()) + .append(",rxPackets=").append(bucket.getRxPackets()) + .append(",txBytes=").append(bucket.getTxBytes()) + .append(",txPackets=").append(bucket.getTxPackets()) + .append(']').toString(); + } + public void setMobileDataEnabled(boolean enabled) { Log.d(TAG, "setMobileDataEnabled: enabled=" + enabled); mTelephonyManager.setDataEnabled(enabled); @@ -249,6 +284,25 @@ public class DataUsageController { return mTelephonyManager.getDataEnabled(); } + static int getNetworkType(NetworkTemplate networkTemplate) { + if (networkTemplate == null) { + return ConnectivityManager.TYPE_NONE; + } + final int matchRule = networkTemplate.getMatchRule(); + switch (matchRule) { + case NetworkTemplate.MATCH_MOBILE: + case NetworkTemplate.MATCH_MOBILE_WILDCARD: + return ConnectivityManager.TYPE_MOBILE; + case NetworkTemplate.MATCH_WIFI: + case NetworkTemplate.MATCH_WIFI_WILDCARD: + return ConnectivityManager.TYPE_WIFI; + case NetworkTemplate.MATCH_ETHERNET: + return ConnectivityManager.TYPE_ETHERNET; + default: + return ConnectivityManager.TYPE_MOBILE; + } + } + private static String getActiveSubscriberId(Context context) { final TelephonyManager tele = TelephonyManager.from(context); final String actualSubscriberId = tele.getSubscriberId( diff --git a/packages/SettingsLib/src/com/android/settingslib/net/NetworkCycleChartDataLoader.java b/packages/SettingsLib/src/com/android/settingslib/net/NetworkCycleChartDataLoader.java index 7ae3398d42ea..ec5a0b5cc4cd 100644 --- a/packages/SettingsLib/src/com/android/settingslib/net/NetworkCycleChartDataLoader.java +++ b/packages/SettingsLib/src/com/android/settingslib/net/NetworkCycleChartDataLoader.java @@ -43,9 +43,9 @@ public class NetworkCycleChartDataLoader @Override void recordUsage(long start, long end) { try { - final NetworkStats stats = mNetworkStatsManager.querySummary( + final NetworkStats.Bucket bucket = mNetworkStatsManager.querySummaryForDevice( mNetworkType, mSubId, start, end); - final long total = getTotalUsage(stats); + final long total = bucket == null ? 0L : bucket.getRxBytes() + bucket.getTxBytes(); if (total > 0L) { final NetworkCycleChartData.Builder builder = new NetworkCycleChartData.Builder(); builder.setUsageBuckets(getUsageBuckets(start, end)) @@ -80,9 +80,11 @@ public class NetworkCycleChartDataLoader while (bucketEnd <= end) { long usage = 0L; try { - final NetworkStats stats = mNetworkStatsManager.querySummary( + final NetworkStats.Bucket bucket = mNetworkStatsManager.querySummaryForDevice( mNetworkType, mSubId, bucketStart, bucketEnd); - usage = getTotalUsage(stats); + if (bucket != null) { + usage = bucket.getRxBytes() + bucket.getTxBytes(); + } } catch (RemoteException e) { Log.e(TAG, "Exception querying network detail.", e); } diff --git a/packages/SettingsLib/src/com/android/settingslib/net/NetworkCycleDataLoader.java b/packages/SettingsLib/src/com/android/settingslib/net/NetworkCycleDataLoader.java index b1c2c3a2d2e5..d9578014e846 100644 --- a/packages/SettingsLib/src/com/android/settingslib/net/NetworkCycleDataLoader.java +++ b/packages/SettingsLib/src/com/android/settingslib/net/NetworkCycleDataLoader.java @@ -176,31 +176,11 @@ public abstract class NetworkCycleDataLoader<D> extends AsyncTaskLoader<D> { public Builder<T> setNetworkTemplate(NetworkTemplate template) { mNetworkTemplate = template; - setNetworkType(); + mNetworkType = DataUsageController.getNetworkType(template); return this; } public abstract T build(); - - private void setNetworkType() { - if (mNetworkTemplate != null) { - final int matchRule = mNetworkTemplate.getMatchRule(); - switch (matchRule) { - case NetworkTemplate.MATCH_MOBILE: - case NetworkTemplate.MATCH_MOBILE_WILDCARD: - mNetworkType = ConnectivityManager.TYPE_MOBILE; - break; - case NetworkTemplate.MATCH_WIFI: - mNetworkType = ConnectivityManager.TYPE_WIFI; - break; - case NetworkTemplate.MATCH_ETHERNET: - mNetworkType = ConnectivityManager.TYPE_ETHERNET; - break; - default: - mNetworkType = ConnectivityManager.TYPE_MOBILE; - } - } - } } } diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/DataUsageControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/DataUsageControllerTest.java index 1be856a59fb5..b6ac467c729f 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/DataUsageControllerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/DataUsageControllerTest.java @@ -24,16 +24,23 @@ import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.anyLong; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import android.app.usage.NetworkStats; +import android.app.usage.NetworkStatsManager; import android.content.Context; +import android.net.ConnectivityManager; import android.net.INetworkStatsSession; import android.net.NetworkStatsHistory; import android.net.NetworkStatsHistory.Entry; import android.net.NetworkTemplate; import android.os.RemoteException; +import android.telephony.TelephonyManager; import android.text.format.DateUtils; +import android.util.FeatureFlagUtils; import com.android.settingslib.SettingsLibRobolectricTestRunner; @@ -47,8 +54,14 @@ import org.robolectric.RuntimeEnvironment; @RunWith(SettingsLibRobolectricTestRunner.class) public class DataUsageControllerTest { + private static final String SUB_ID = "Test Subscriber"; + @Mock private INetworkStatsSession mSession; + @Mock + private TelephonyManager mTelephonyManager; + @Mock + private NetworkStatsManager mNetworkStatsManager; private Context mContext; private DataUsageController mController; @@ -63,13 +76,14 @@ public class DataUsageControllerTest { new NetworkStatsHistory(DateUtils.DAY_IN_MILLIS /* bucketDuration */)); doReturn(mNetworkStatsHistory) .when(mSession).getHistoryForNetwork(any(NetworkTemplate.class), anyInt()); + doReturn(SUB_ID).when(mTelephonyManager).getSubscriberId(anyInt()); } @Test - public void getHistoriclUsageLevel_noNetworkSession_shouldReturn0() { + public void getHistoricalUsageLevel_noNetworkSession_shouldReturnNegative1() { doReturn(null).when(mController).getSession(); - assertThat(mController.getHistoriclUsageLevel(null /* template */)).isEqualTo(0L); + assertThat(mController.getHistoricalUsageLevel(null /* template */)).isEqualTo(-1L); } @@ -77,13 +91,13 @@ public class DataUsageControllerTest { public void getHistoriclUsageLevel_noUsageData_shouldReturn0() { doReturn(mSession).when(mController).getSession(); - assertThat(mController.getHistoriclUsageLevel(NetworkTemplate.buildTemplateWifiWildcard())) + assertThat(mController.getHistoricalUsageLevel(NetworkTemplate.buildTemplateWifiWildcard())) .isEqualTo(0L); } @Test - public void getHistoriclUsageLevel_hasUsageData_shouldReturnTotalUsage() { + public void getHistoricalUsageLevel_hasUsageData_shouldReturnTotalUsage() { doReturn(mSession).when(mController).getSession(); final long receivedBytes = 743823454L; final long transmittedBytes = 16574289L; @@ -94,8 +108,57 @@ public class DataUsageControllerTest { when(mNetworkStatsHistory.getValues(eq(0L), anyLong(), anyLong(), nullable(Entry.class))) .thenReturn(entry); - assertThat(mController.getHistoriclUsageLevel(NetworkTemplate.buildTemplateWifiWildcard())) + assertThat(mController.getHistoricalUsageLevel(NetworkTemplate.buildTemplateWifiWildcard())) .isEqualTo(receivedBytes + transmittedBytes); } + + @Test + public void getHistoricalUsageLevel_v2_shouldQuerySummaryForDevice() throws Exception { + final Context context = mock(Context.class); + FeatureFlagUtils.setEnabled(context, DataUsageController.DATA_USAGE_V2, true); + when(context.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager); + when(context.getSystemService(NetworkStatsManager.class)).thenReturn(mNetworkStatsManager); + final DataUsageController controller = new DataUsageController(context); + + controller.getHistoricalUsageLevel(NetworkTemplate.buildTemplateWifiWildcard()); + + verify(mNetworkStatsManager).querySummaryForDevice(eq(ConnectivityManager.TYPE_WIFI), + eq(SUB_ID), eq(0L) /* startTime */, anyLong() /* endTime */); + } + + @Test + public void getHistoricalUsageLevel_v2NoUsageData_shouldReturn0() throws Exception { + final Context context = mock(Context.class); + FeatureFlagUtils.setEnabled(context, DataUsageController.DATA_USAGE_V2, true); + when(context.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager); + when(context.getSystemService(NetworkStatsManager.class)).thenReturn(mNetworkStatsManager); + when(mNetworkStatsManager.querySummaryForDevice(eq(ConnectivityManager.TYPE_WIFI), + eq(SUB_ID), eq(0L) /* startTime */, anyLong() /* endTime */)) + .thenReturn(mock(NetworkStats.Bucket.class)); + final DataUsageController controller = new DataUsageController(context); + + assertThat(controller.getHistoricalUsageLevel(NetworkTemplate.buildTemplateWifiWildcard())) + .isEqualTo(0L); + } + + @Test + public void getHistoricalUsageLevel_v2HasUsageData_shouldReturnTotalUsage() + throws Exception { + final Context context = mock(Context.class); + FeatureFlagUtils.setEnabled(context, DataUsageController.DATA_USAGE_V2, true); + when(context.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager); + when(context.getSystemService(NetworkStatsManager.class)).thenReturn(mNetworkStatsManager); + final long receivedBytes = 743823454L; + final long transmittedBytes = 16574289L; + final NetworkStats.Bucket bucket = mock(NetworkStats.Bucket.class); + when(bucket.getRxBytes()).thenReturn(receivedBytes); + when(bucket.getTxBytes()).thenReturn(transmittedBytes); + when(mNetworkStatsManager.querySummaryForDevice(eq(ConnectivityManager.TYPE_WIFI), + eq(SUB_ID), eq(0L) /* startTime */, anyLong() /* endTime */)).thenReturn(bucket); + final DataUsageController controller = new DataUsageController(context); + + assertThat(controller.getHistoricalUsageLevel(NetworkTemplate.buildTemplateWifiWildcard())) + .isEqualTo(receivedBytes + transmittedBytes); + } } diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/NetworkCycleChartDataLoaderTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/NetworkCycleChartDataLoaderTest.java index cad88b1f97a4..0a036317910e 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/NetworkCycleChartDataLoaderTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/NetworkCycleChartDataLoaderTest.java @@ -58,7 +58,7 @@ public class NetworkCycleChartDataLoaderTest { } @Test - public void recordUsage_shouldQueryNetworkSummary() throws RemoteException { + public void recordUsage_shouldQueryNetworkSummaryForDevice() throws RemoteException { final long end = System.currentTimeMillis(); final long start = end - (DateUtils.WEEK_IN_MILLIS * 4); final int networkType = ConnectivityManager.TYPE_MOBILE; @@ -68,6 +68,6 @@ public class NetworkCycleChartDataLoaderTest { mLoader.recordUsage(start, end); - verify(mNetworkStatsManager).querySummary(networkType, subId, start, end); + verify(mNetworkStatsManager).querySummaryForDevice(networkType, subId, start, end); } } diff --git a/packages/SystemUI/plugin/Android.bp b/packages/SystemUI/plugin/Android.bp index b38059de0f8d..df5561acbbc4 100644 --- a/packages/SystemUI/plugin/Android.bp +++ b/packages/SystemUI/plugin/Android.bp @@ -18,6 +18,9 @@ java_library { srcs: ["src/**/*.java"], + static_libs: [ + "PluginCoreLib" + ], } diff --git a/packages/SystemUI/plugin_core/Android.bp b/packages/SystemUI/plugin_core/Android.bp new file mode 100644 index 000000000000..58a8e494856e --- /dev/null +++ b/packages/SystemUI/plugin_core/Android.bp @@ -0,0 +1,21 @@ +// 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_library { + + name: "PluginCoreLib", + + srcs: ["src/**/*.java"], + +} diff --git a/packages/SystemUI/plugin_core/AndroidManifest.xml b/packages/SystemUI/plugin_core/AndroidManifest.xml new file mode 100644 index 000000000000..df835fd8e32d --- /dev/null +++ b/packages/SystemUI/plugin_core/AndroidManifest.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2018 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.systemui.plugin_core"> + + <uses-sdk + android:minSdkVersion="28" /> + +</manifest> diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/Plugin.java b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/Plugin.java index bb93367c3791..bb93367c3791 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/Plugin.java +++ b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/Plugin.java diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginFragment.java b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/PluginFragment.java index 1bfa567b6630..1bfa567b6630 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginFragment.java +++ b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/PluginFragment.java diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginListener.java b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/PluginListener.java index b488d2a84baa..b488d2a84baa 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginListener.java +++ b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/PluginListener.java diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Dependencies.java b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/annotations/Dependencies.java index dbbf047519bb..dbbf047519bb 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Dependencies.java +++ b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/annotations/Dependencies.java diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/DependsOn.java b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/annotations/DependsOn.java index b81d67306307..b81d67306307 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/DependsOn.java +++ b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/annotations/DependsOn.java diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/ProvidesInterface.java b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/annotations/ProvidesInterface.java index d0e14b8657ff..d0e14b8657ff 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/ProvidesInterface.java +++ b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/annotations/ProvidesInterface.java diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Requirements.java b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/annotations/Requirements.java index 9cfa279b9c19..9cfa279b9c19 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Requirements.java +++ b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/annotations/Requirements.java diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Requires.java b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/annotations/Requires.java index e1b1303b8cb5..e1b1303b8cb5 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Requires.java +++ b/packages/SystemUI/plugin_core/src/com/android/systemui/plugins/annotations/Requires.java diff --git a/packages/SystemUI/res/drawable/ic_face_unlock.xml b/packages/SystemUI/res/drawable/ic_face_unlock.xml index 29c22759be70..b302ed4a762c 100644 --- a/packages/SystemUI/res/drawable/ic_face_unlock.xml +++ b/packages/SystemUI/res/drawable/ic_face_unlock.xml @@ -15,8 +15,8 @@ --> <vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="48dp" - android:height="48dp" + android:width="24dp" + android:height="24dp" android:viewportHeight="24.0" android:viewportWidth="24.0"> <path android:fillColor="?attr/wallpaperTextColor" diff --git a/packages/SystemUI/shared/Android.bp b/packages/SystemUI/shared/Android.bp index defc49b5fac1..31a538c65dea 100644 --- a/packages/SystemUI/shared/Android.bp +++ b/packages/SystemUI/shared/Android.bp @@ -21,10 +21,10 @@ android_library { ], static_libs: [ - "SystemUIPluginLib" + "PluginCoreLib" ], - // Enforce that the library is build agains java 7 so that there are + // Enforce that the library is built against java 7 so that there are // no compatibility issues with launcher java_version: "1.7", } diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginEnabler.java b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginEnabler.java new file mode 100644 index 000000000000..74fd13f9564e --- /dev/null +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginEnabler.java @@ -0,0 +1,25 @@ +/* + * 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.systemui.shared.plugins; + +import android.content.ComponentName; + +/** + * Enables and disables plugins. + */ +public interface PluginEnabler { + void setEnabled(ComponentName component, boolean enabled); + boolean isEnabled(ComponentName component); +} diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInitializer.java b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInitializer.java index 985789415363..c6a086dcfbdc 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInitializer.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInitializer.java @@ -14,6 +14,7 @@ package com.android.systemui.shared.plugins; +import android.annotation.Nullable; import android.content.Context; import android.os.Looper; @@ -26,9 +27,10 @@ public interface PluginInitializer { /** * This Runnable is run on the bg looper during initialization of {@link PluginManagerImpl}. - * It can be null. */ - Runnable getBgInitCallback(); + @Nullable Runnable getBgInitCallback(); String[] getWhitelistedPlugins(Context context); + + PluginEnabler getPluginEnabler(Context context); } diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInstanceManager.java b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInstanceManager.java index e80c079f60de..8cc6091f52f5 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInstanceManager.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInstanceManager.java @@ -159,10 +159,8 @@ public class PluginInstanceManager<T extends Plugin> { // plugin, if the plugin causing a crash cannot be identified, they are all disabled // assuming one of them must be bad. Log.w(TAG, "Disabling plugin " + info.mPackage + "/" + info.mClass); - mPm.setComponentEnabledSetting( - new ComponentName(info.mPackage, info.mClass), - PackageManager.COMPONENT_ENABLED_STATE_DISABLED, - PackageManager.DONT_KILL_APP); + mManager.getPluginEnabler().setEnabled(new ComponentName(info.mPackage, info.mClass), + false); } public <T> boolean dependsOn(Plugin p, Class<T> cls) { @@ -280,8 +278,7 @@ public class PluginInstanceManager<T extends Plugin> { if (pkgName != null) { intent.setPackage(pkgName); } - List<ResolveInfo> result = - mPm.queryIntentServices(intent, 0); + List<ResolveInfo> result = mPm.queryIntentServices(intent, 0); if (DEBUG) Log.d(TAG, "Found " + result.size() + " plugins"); if (result.size() > 1 && !mAllowMultiple) { // TODO: Show warning. @@ -306,6 +303,10 @@ public class PluginInstanceManager<T extends Plugin> { Log.w(TAG, "Plugin cannot be loaded on production build: " + component); return null; } + if (!mManager.getPluginEnabler().isEnabled(component)) { + if (DEBUG) Log.d(TAG, "Plugin is not enabled, aborting load: " + component); + return null; + } String pkg = component.getPackageName(); String cls = component.getClassName(); try { diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginManagerImpl.java b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginManagerImpl.java index 7f1d161123f2..a54e08eba23d 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginManagerImpl.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginManagerImpl.java @@ -41,12 +41,11 @@ import android.widget.Toast; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; - import com.android.systemui.plugins.Plugin; import com.android.systemui.plugins.PluginListener; +import com.android.systemui.plugins.annotations.ProvidesInterface; import com.android.systemui.shared.plugins.PluginInstanceManager.PluginContextWrapper; import com.android.systemui.shared.plugins.PluginInstanceManager.PluginInfo; -import com.android.systemui.plugins.annotations.ProvidesInterface; import dalvik.system.PathClassLoader; @@ -74,6 +73,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage private final PluginInstanceManagerFactory mFactory; private final boolean isDebuggable; private final PluginPrefs mPluginPrefs; + private final PluginEnabler mPluginEnabler; private ClassLoaderFilter mParentClassLoader; private boolean mListening; private boolean mHasOneShot; @@ -94,6 +94,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage isDebuggable = debuggable; mWhitelistedPlugins.addAll(Arrays.asList(initializer.getWhitelistedPlugins(mContext))); mPluginPrefs = new PluginPrefs(mContext); + mPluginEnabler = initializer.getPluginEnabler(mContext); PluginExceptionHandler uncaughtExceptionHandler = new PluginExceptionHandler( defaultHandler); @@ -109,6 +110,10 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage return mWhitelistedPlugins.toArray(new String[0]); } + public PluginEnabler getPluginEnabler() { + return mPluginEnabler; + } + public <T extends Plugin> T getOneShotPlugin(Class<T> cls) { ProvidesInterface info = cls.getDeclaredAnnotation(ProvidesInterface.class); if (info == null) { @@ -202,9 +207,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage Uri uri = intent.getData(); ComponentName component = ComponentName.unflattenFromString( uri.toString().substring(10)); - mContext.getPackageManager().setComponentEnabledSetting(component, - PackageManager.COMPONENT_ENABLED_STATE_DISABLED, - PackageManager.DONT_KILL_APP); + getPluginEnabler().setEnabled(component, false); mContext.getSystemService(NotificationManager.class).cancel(component.getClassName(), SystemMessage.NOTE_PLUGIN); } else { diff --git a/packages/SystemUI/src/com/android/systemui/plugins/PluginEnablerImpl.java b/packages/SystemUI/src/com/android/systemui/plugins/PluginEnablerImpl.java new file mode 100644 index 000000000000..e2417f7b6397 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/plugins/PluginEnablerImpl.java @@ -0,0 +1,48 @@ +/* + * 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.systemui.plugins; + +import android.content.ComponentName; +import android.content.Context; +import android.content.pm.PackageManager; + +import com.android.internal.annotations.VisibleForTesting; +import com.android.systemui.shared.plugins.PluginEnabler; + +public class PluginEnablerImpl implements PluginEnabler { + + final private PackageManager mPm; + + public PluginEnablerImpl(Context context) { + this(context.getPackageManager()); + } + + @VisibleForTesting public PluginEnablerImpl(PackageManager pm) { + mPm = pm; + } + + @Override + public void setEnabled(ComponentName component, boolean enabled) { + final int desiredState = enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED + : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; + mPm.setComponentEnabledSetting(component, desiredState, PackageManager.DONT_KILL_APP); + } + + @Override + public boolean isEnabled(ComponentName component) { + return mPm.getComponentEnabledSetting(component) + != PackageManager.COMPONENT_ENABLED_STATE_DISABLED; + } +} diff --git a/packages/SystemUI/src/com/android/systemui/plugins/PluginInitializerImpl.java b/packages/SystemUI/src/com/android/systemui/plugins/PluginInitializerImpl.java index 108c2d05d76c..ac0a226080bf 100644 --- a/packages/SystemUI/src/com/android/systemui/plugins/PluginInitializerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/plugins/PluginInitializerImpl.java @@ -18,6 +18,7 @@ import android.content.Context; import android.os.Looper; import com.android.systemui.Dependency; +import com.android.systemui.shared.plugins.PluginEnabler; import com.android.systemui.shared.plugins.PluginInitializer; import com.android.systemui.R; @@ -44,4 +45,8 @@ public class PluginInitializerImpl implements PluginInitializer { public String[] getWhitelistedPlugins(Context context) { return context.getResources().getStringArray(R.array.config_pluginWhitelist); } + + public PluginEnabler getPluginEnabler(Context context) { + return new PluginEnablerImpl(context); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java index 9c579daa38c6..0b5871ed5e3f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java @@ -195,7 +195,7 @@ public class NavigationBarFragment extends Fragment implements Callbacks { @Override public void onBackButtonAlphaChanged(float alpha, boolean animate) { final ButtonDispatcher backButton = mNavigationBarView.getBackButton(); - if (QuickStepController.shouldhideBackButton()) { + if (QuickStepController.shouldhideBackButton(getContext())) { // If property was changed to hide/show back button, going home will trigger // launcher to to change the back button alpha to reflect property change backButton.setVisibility(View.GONE); 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 16b2987558d3..c4efa9431317 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -594,7 +594,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav // Always disable recents when alternate car mode UI is active. boolean disableRecent = mUseCarModeUi || !isOverviewEnabled(); - boolean disableBack = QuickStepController.shouldhideBackButton() + boolean disableBack = QuickStepController.shouldhideBackButton(getContext()) || (((mDisabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0) && !useAltBack); // When screen pinning, don't hide back and home when connected service or back and diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java index bce52a294e85..fd5403fd8301 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java @@ -42,7 +42,7 @@ import android.hardware.input.InputManager; import android.os.Handler; import android.os.RemoteException; import android.os.SystemClock; -import android.os.SystemProperties; +import android.provider.Settings; import android.util.FloatProperty; import android.util.Log; import android.util.Slog; @@ -77,10 +77,11 @@ public class QuickStepController implements GestureHelper { private static final float GRADIENT_WIDTH = .75f; /** Experiment to swipe home button left to execute a back key press */ - private static final String PULL_HOME_GO_BACK_PROP = "persist.quickstepcontroller.homegoesback"; - private static final String HIDE_BACK_BUTTON_PROP = "persist.quickstepcontroller.hideback"; + private static final String PULL_HOME_GO_BACK_PROP = "quickstepcontroller_homegoesback"; + private static final String HIDE_BACK_BUTTON_PROP = "quickstepcontroller_hideback"; private static final String BACK_AFTER_END_PROP - = "persist.quickstepcontroller.homegoesbackwhenend"; + = "quickstepcontroller_homegoesbackwhenend"; + private static final String NAVBAR_EXPERIMENTS_DISABLED = "navbarexperiments_disabled"; private static final long BACK_BUTTON_FADE_OUT_ALPHA = 60; private static final long BACK_BUTTON_FADE_IN_ALPHA = 150; private static final long BACK_GESTURE_POLL_TIMEOUT = 1000; @@ -124,14 +125,6 @@ public class QuickStepController implements GestureHelper { private final Matrix mTransformLocalMatrix = new Matrix(); private final Paint mTrackPaint = new Paint(); - public static boolean swipeHomeGoBackGestureEnabled() { - return SystemProperties.getBoolean(PULL_HOME_GO_BACK_PROP, false); - } - public static boolean shouldhideBackButton() { - return swipeHomeGoBackGestureEnabled() - && SystemProperties.getBoolean(HIDE_BACK_BUTTON_PROP, false); - } - private final FloatProperty<QuickStepController> mTrackAlphaProperty = new FloatProperty<QuickStepController>("TrackAlpha") { @Override @@ -211,7 +204,7 @@ public class QuickStepController implements GestureHelper { public void setComponents(NavigationBarView navigationBarView) { mNavigationBarView = navigationBarView; - mNavigationBarView.getBackButton().setVisibility(shouldhideBackButton() + mNavigationBarView.getBackButton().setVisibility(shouldhideBackButton(mContext) ? View.GONE : View.VISIBLE); } @@ -344,7 +337,7 @@ public class QuickStepController implements GestureHelper { // Passing the drag slop then touch slop will start quick step if (allowDrag) { startQuickScrub(); - } else if (swipeHomeGoBackGestureEnabled() + } else if (swipeHomeGoBackGestureEnabled(mContext) && mNavigationBarView.getDownHitTarget() == HIT_TARGET_HOME && mDragPositive ? pos < touchDown : pos > touchDown) { startBackGesture(); @@ -607,10 +600,9 @@ public class QuickStepController implements GestureHelper { if (!mBackGestureActive) { mBackGestureActive = true; mNavigationBarView.getHomeButton().abortCurrentGesture(); - final boolean runBackMidGesture - = !SystemProperties.getBoolean(BACK_AFTER_END_PROP, false); + final boolean runBackMidGesture = !shouldExecuteBackOnUp(mContext); if (mCanPerformBack) { - if (!shouldhideBackButton()) { + if (!shouldhideBackButton(mContext)) { mNavigationBarView.getBackButton().setAlpha(0 /* alpha */, true /* animate */, BACK_BUTTON_FADE_OUT_ALPHA); } @@ -638,11 +630,11 @@ public class QuickStepController implements GestureHelper { mHomeAnimator.translationX(0); } mHomeAnimator.start(); - if (!shouldhideBackButton()) { + if (!shouldhideBackButton(mContext)) { mNavigationBarView.getBackButton().setAlpha( mOverviewEventSender.getBackButtonAlpha(), true /* animate */); } - if (SystemProperties.getBoolean(BACK_AFTER_END_PROP, false)) { + if (shouldExecuteBackOnUp(mContext)) { performBack(); } } @@ -709,7 +701,8 @@ public class QuickStepController implements GestureHelper { } private boolean canPerformHomeBackGesture() { - return swipeHomeGoBackGestureEnabled() && mOverviewEventSender.getBackButtonAlpha() > 0; + return swipeHomeGoBackGestureEnabled(mContext) + && mOverviewEventSender.getBackButtonAlpha() > 0; } private void performBack() { @@ -746,4 +739,23 @@ public class QuickStepController implements GestureHelper { } return false; } + + private static boolean getBoolGlobalSetting(Context context, String key) { + return Settings.Global.getInt(context.getContentResolver(), key, 0) != 0; + } + + public static boolean swipeHomeGoBackGestureEnabled(Context context) { + return !getBoolGlobalSetting(context, NAVBAR_EXPERIMENTS_DISABLED) + && getBoolGlobalSetting(context, PULL_HOME_GO_BACK_PROP); + } + + public static boolean shouldhideBackButton(Context context) { + return swipeHomeGoBackGestureEnabled(context) + && getBoolGlobalSetting(context, HIDE_BACK_BUTTON_PROP); + } + + public static boolean shouldExecuteBackOnUp(Context context) { + return !getBoolGlobalSetting(context, NAVBAR_EXPERIMENTS_DISABLED) + && getBoolGlobalSetting(context, BACK_AFTER_END_PROP); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 90ed97f665d5..a7c43cdbf9c5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -2852,7 +2852,9 @@ public class StatusBar extends SystemUI implements DemoMode, } } else if (Intent.ACTION_SCREEN_OFF.equals(action)) { - mStatusBarWindowController.setNotTouchable(false); + if (mStatusBarWindowController != null) { + mStatusBarWindowController.setNotTouchable(false); + } finishBarAnimations(); resetUserExpandedStates(); } diff --git a/packages/SystemUI/src/com/android/systemui/tuner/PluginFragment.java b/packages/SystemUI/src/com/android/systemui/tuner/PluginFragment.java index 71414a266724..0826054f3740 100644 --- a/packages/SystemUI/src/com/android/systemui/tuner/PluginFragment.java +++ b/packages/SystemUI/src/com/android/systemui/tuner/PluginFragment.java @@ -25,15 +25,13 @@ import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Bundle; import android.provider.Settings; -import androidx.preference.PreferenceFragment; -import androidx.preference.SwitchPreference; -import androidx.preference.PreferenceScreen; -import androidx.preference.PreferenceViewHolder; import android.util.ArrayMap; import android.util.ArraySet; import android.view.View; import com.android.systemui.R; +import com.android.systemui.plugins.PluginEnablerImpl; +import com.android.systemui.shared.plugins.PluginEnabler; import com.android.systemui.shared.plugins.PluginInstanceManager; import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.shared.plugins.PluginPrefs; @@ -41,12 +39,18 @@ import com.android.systemui.shared.plugins.PluginPrefs; import java.util.List; import java.util.Set; +import androidx.preference.PreferenceFragment; +import androidx.preference.PreferenceScreen; +import androidx.preference.PreferenceViewHolder; +import androidx.preference.SwitchPreference; + public class PluginFragment extends PreferenceFragment { public static final String ACTION_PLUGIN_SETTINGS = "com.android.systemui.action.PLUGIN_SETTINGS"; private PluginPrefs mPluginPrefs; + private PluginEnabler mPluginEnabler; @Override public void onCreate(Bundle savedInstanceState) { @@ -68,6 +72,7 @@ public class PluginFragment extends PreferenceFragment { @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { + mPluginEnabler = new PluginEnablerImpl(getContext()); loadPrefs(); } @@ -98,7 +103,7 @@ public class PluginFragment extends PreferenceFragment { PackageManager.MATCH_DISABLED_COMPONENTS | PackageManager.GET_SERVICES); apps.forEach(app -> { if (!plugins.containsKey(app.packageName)) return; - SwitchPreference pref = new PluginPreference(prefContext, app); + SwitchPreference pref = new PluginPreference(prefContext, app, mPluginEnabler); pref.setSummary("Plugins: " + toString(plugins.get(app.packageName))); screen.addPreference(pref); }); @@ -139,15 +144,16 @@ public class PluginFragment extends PreferenceFragment { private static class PluginPreference extends SwitchPreference { private final boolean mHasSettings; private final PackageInfo mInfo; - private final PackageManager mPm; + private final PluginEnabler mPluginEnabler; - public PluginPreference(Context prefContext, PackageInfo info) { + public PluginPreference(Context prefContext, PackageInfo info, PluginEnabler pluginEnabler) { super(prefContext); - mPm = prefContext.getPackageManager(); - mHasSettings = mPm.resolveActivity(new Intent(ACTION_PLUGIN_SETTINGS) + PackageManager pm = prefContext.getPackageManager(); + mHasSettings = pm.resolveActivity(new Intent(ACTION_PLUGIN_SETTINGS) .setPackage(info.packageName), 0) != null; mInfo = info; - setTitle(info.applicationInfo.loadLabel(mPm)); + mPluginEnabler = pluginEnabler; + setTitle(info.applicationInfo.loadLabel(pm)); setChecked(isPluginEnabled()); setWidgetLayoutResource(R.layout.tuner_widget_settings_switch); } @@ -156,8 +162,7 @@ public class PluginFragment extends PreferenceFragment { for (int i = 0; i < mInfo.services.length; i++) { ComponentName componentName = new ComponentName(mInfo.packageName, mInfo.services[i].name); - if (mPm.getComponentEnabledSetting(componentName) - == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) { + if (!mPluginEnabler.isEnabled(componentName)) { return false; } } @@ -165,17 +170,14 @@ public class PluginFragment extends PreferenceFragment { } @Override - protected boolean persistBoolean(boolean value) { - final int desiredState = value ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED - : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; + protected boolean persistBoolean(boolean isEnabled) { boolean shouldSendBroadcast = false; for (int i = 0; i < mInfo.services.length; i++) { ComponentName componentName = new ComponentName(mInfo.packageName, mInfo.services[i].name); - if (mPm.getComponentEnabledSetting(componentName) != desiredState) { - mPm.setComponentEnabledSetting(componentName, desiredState, - PackageManager.DONT_KILL_APP); + if (mPluginEnabler.isEnabled(componentName) != isEnabled) { + mPluginEnabler.setEnabled(componentName, isEnabled); shouldSendBroadcast = true; } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/shared/plugins/PluginInstanceManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shared/plugins/PluginInstanceManagerTest.java index 6d1ff8c06acf..5bf60400089b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shared/plugins/PluginInstanceManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shared/plugins/PluginInstanceManagerTest.java @@ -28,6 +28,7 @@ import static org.mockito.Mockito.when; import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; import com.android.systemui.SysuiTestCase; import com.android.systemui.plugins.Plugin; +import com.android.systemui.plugins.PluginEnablerImpl; import com.android.systemui.plugins.PluginListener; import com.android.systemui.shared.plugins.PluginInstanceManager.PluginInfo; import com.android.systemui.shared.plugins.VersionInfo.InvalidVersionException; @@ -88,6 +89,7 @@ public class PluginInstanceManagerTest extends SysuiTestCase { mMockManager = mock(PluginManagerImpl.class); when(mMockManager.getClassLoader(any(), any())) .thenReturn(getClass().getClassLoader()); + when(mMockManager.getPluginEnabler()).thenReturn(new PluginEnablerImpl(mMockPm)); mMockVersionInfo = mock(VersionInfo.class); mPluginInstanceManager = new PluginInstanceManager(mContextWrapper, mMockPm, "myAction", mMockListener, true, mHandlerThread.getLooper(), mMockVersionInfo, diff --git a/packages/SystemUI/tests/src/com/android/systemui/shared/plugins/PluginManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shared/plugins/PluginManagerTest.java index 3c7020569db4..ff1bc8abf5d1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shared/plugins/PluginManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shared/plugins/PluginManagerTest.java @@ -37,6 +37,7 @@ import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; import com.android.systemui.Dependency; import com.android.systemui.SysuiTestCase; import com.android.systemui.plugins.Plugin; +import com.android.systemui.plugins.PluginEnablerImpl; import com.android.systemui.plugins.PluginInitializerImpl; import com.android.systemui.plugins.PluginListener; import com.android.systemui.plugins.annotations.ProvidesInterface; @@ -62,6 +63,7 @@ public class PluginManagerTest extends SysuiTestCase { private PluginInstanceManager mMockPluginInstance; private PluginManagerImpl mPluginManager; private PluginListener mMockListener; + private PackageManager mMockPackageManager; private UncaughtExceptionHandler mRealExceptionHandler; private UncaughtExceptionHandler mMockExceptionHandler; @@ -79,12 +81,18 @@ public class PluginManagerTest extends SysuiTestCase { Mockito.anyBoolean(), Mockito.any(), Mockito.any(), Mockito.any())) .thenReturn(mMockPluginInstance); + mMockPackageManager = mock(PackageManager.class); mPluginManager = new PluginManagerImpl(getContext(), mMockFactory, true, mMockExceptionHandler, new PluginInitializerImpl() { @Override public String[] getWhitelistedPlugins(Context context) { return new String[0]; } + + @Override + public PluginEnabler getPluginEnabler(Context context) { + return new PluginEnablerImpl(mMockPackageManager); + } }); resetExceptionHandler(); mMockListener = mock(PluginListener.class); @@ -182,9 +190,8 @@ public class PluginManagerTest extends SysuiTestCase { @Test public void testDisableIntent() { NotificationManager nm = mock(NotificationManager.class); - PackageManager pm = mock(PackageManager.class); mContext.addMockSystemService(Context.NOTIFICATION_SERVICE, nm); - mContext.setMockPackageManager(pm); + mContext.setMockPackageManager(mMockPackageManager); ComponentName testComponent = new ComponentName(getContext().getPackageName(), PluginManagerTest.class.getName()); @@ -192,7 +199,7 @@ public class PluginManagerTest extends SysuiTestCase { intent.setData(Uri.parse("package://" + testComponent.flattenToString())); mPluginManager.onReceive(mContext, intent); verify(nm).cancel(eq(testComponent.getClassName()), eq(SystemMessage.NOTE_PLUGIN)); - verify(pm).setComponentEnabledSetting(eq(testComponent), + verify(mMockPackageManager).setComponentEnabledSetting(eq(testComponent), eq(PackageManager.COMPONENT_ENABLED_STATE_DISABLED), eq(PackageManager.DONT_KILL_APP)); } diff --git a/services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java b/services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java index 46c515f20a13..ebd9e77a6a98 100644 --- a/services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java +++ b/services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java @@ -216,7 +216,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ * Called back to notify system that the client has changed * @param serviceInfoChanged True if the service's AccessibilityServiceInfo changed. */ - void onClientChange(boolean serviceInfoChanged); + void onClientChangeLocked(boolean serviceInfoChanged); int getCurrentUserIdLocked(); @@ -363,7 +363,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ } else { setDynamicallyConfigurableProperties(info); } - mSystemSupport.onClientChange(true); + mSystemSupport.onClientChangeLocked(true); } } finally { Binder.restoreCallingIdentity(identity); diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java index 44ef8b6d6c3d..6918275dd8c0 100644 --- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -254,7 +254,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub private final UserManager mUserManager; - private final UiAutomationManager mUiAutomationManager = new UiAutomationManager(); + private final UiAutomationManager mUiAutomationManager = new UiAutomationManager(mLock); private int mCurrentUserId = UserHandle.USER_SYSTEM; @@ -830,7 +830,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub synchronized (mLock) { mUiAutomationManager.registerUiTestAutomationServiceLocked(owner, serviceClient, - mContext, accessibilityServiceInfo, sIdCounter++, mMainHandler, mLock, + mContext, accessibilityServiceInfo, sIdCounter++, mMainHandler, mSecurityPolicy, this, mWindowManagerService, mGlobalActionPerformer, flags); onUserStateChangedLocked(getCurrentUserStateLocked()); } @@ -2787,7 +2787,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub } @Override - public void onClientChange(boolean serviceInfoChanged) { + public void onClientChangeLocked(boolean serviceInfoChanged) { AccessibilityManagerService.UserState userState = getUserStateLocked(mCurrentUserId); onUserStateChangedLocked(userState); if (serviceInfoChanged) { diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityServiceConnection.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityServiceConnection.java index 9d84f5719dfc..2396ded6dba5 100644 --- a/services/accessibility/java/com/android/server/accessibility/AccessibilityServiceConnection.java +++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityServiceConnection.java @@ -16,8 +16,6 @@ package com.android.server.accessibility; -import static android.provider.Settings.Secure.SHOW_MODE_AUTO; - import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage; import android.accessibilityservice.AccessibilityServiceInfo; @@ -133,7 +131,7 @@ class AccessibilityServiceConnection extends AbstractAccessibilityServiceConnect } finally { Binder.restoreCallingIdentity(identity); } - mSystemSupport.onClientChange(false); + mSystemSupport.onClientChangeLocked(false); } } } @@ -158,7 +156,7 @@ class AccessibilityServiceConnection extends AbstractAccessibilityServiceConnect UserState userState = mUserStateWeakReference.get(); if (userState == null) return; userState.addServiceLocked(this); - mSystemSupport.onClientChange(false); + mSystemSupport.onClientChangeLocked(false); // Initialize the service on the main handler after we're done setting up for // the new configuration (for example, initializing the input filter). mMainHandler.sendMessage(obtainMessage( @@ -259,7 +257,7 @@ class AccessibilityServiceConnection extends AbstractAccessibilityServiceConnect } resetLocked(); mSystemSupport.getMagnificationController().resetIfNeeded(mId); - mSystemSupport.onClientChange(false); + mSystemSupport.onClientChangeLocked(false); } } diff --git a/services/accessibility/java/com/android/server/accessibility/UiAutomationManager.java b/services/accessibility/java/com/android/server/accessibility/UiAutomationManager.java index ff2931160f09..4bbf68271eb9 100644 --- a/services/accessibility/java/com/android/server/accessibility/UiAutomationManager.java +++ b/services/accessibility/java/com/android/server/accessibility/UiAutomationManager.java @@ -43,6 +43,8 @@ class UiAutomationManager { new ComponentName("com.android.server.accessibility", "UiAutomation"); private static final String LOG_TAG = "UiAutomationManager"; + private final Object mLock; + private UiAutomationService mUiAutomationService; private AccessibilityServiceInfo mUiAutomationServiceInfo; @@ -51,6 +53,10 @@ class UiAutomationManager { private int mUiAutomationFlags; + UiAutomationManager(Object lock) { + mLock = lock; + } + private IBinder mUiAutomationServiceOwner; private final DeathRecipient mUiAutomationServiceOwnerDeathRecipient = new DeathRecipient() { @@ -77,56 +83,62 @@ class UiAutomationManager { void registerUiTestAutomationServiceLocked(IBinder owner, IAccessibilityServiceClient serviceClient, Context context, AccessibilityServiceInfo accessibilityServiceInfo, - int id, Handler mainHandler, Object lock, + int id, Handler mainHandler, AccessibilityManagerService.SecurityPolicy securityPolicy, AbstractAccessibilityServiceConnection.SystemSupport systemSupport, WindowManagerInternal windowManagerInternal, GlobalActionPerformer globalActionPerfomer, int flags) { - accessibilityServiceInfo.setComponentName(COMPONENT_NAME); + synchronized (mLock) { + accessibilityServiceInfo.setComponentName(COMPONENT_NAME); - if (mUiAutomationService != null) { - throw new IllegalStateException("UiAutomationService " + serviceClient - + "already registered!"); - } + if (mUiAutomationService != null) { + throw new IllegalStateException("UiAutomationService " + serviceClient + + "already registered!"); + } - try { - owner.linkToDeath(mUiAutomationServiceOwnerDeathRecipient, 0); - } catch (RemoteException re) { - Slog.e(LOG_TAG, "Couldn't register for the death of a UiTestAutomationService!", re); - return; - } + try { + owner.linkToDeath(mUiAutomationServiceOwnerDeathRecipient, 0); + } catch (RemoteException re) { + Slog.e(LOG_TAG, "Couldn't register for the death of a UiTestAutomationService!", + re); + return; + } - mSystemSupport = systemSupport; - mUiAutomationService = new UiAutomationService(context, accessibilityServiceInfo, id, - mainHandler, lock, securityPolicy, systemSupport, windowManagerInternal, - globalActionPerfomer); - mUiAutomationServiceOwner = owner; - mUiAutomationFlags = flags; - mUiAutomationServiceInfo = accessibilityServiceInfo; - mUiAutomationService.mServiceInterface = serviceClient; - mUiAutomationService.onAdded(); - try { - mUiAutomationService.mServiceInterface.asBinder().linkToDeath(mUiAutomationService, 0); - } catch (RemoteException re) { - Slog.e(LOG_TAG, "Failed registering death link: " + re); - destroyUiAutomationService(); - return; - } + mSystemSupport = systemSupport; + mUiAutomationService = new UiAutomationService(context, accessibilityServiceInfo, id, + mainHandler, mLock, securityPolicy, systemSupport, windowManagerInternal, + globalActionPerfomer); + mUiAutomationServiceOwner = owner; + mUiAutomationFlags = flags; + mUiAutomationServiceInfo = accessibilityServiceInfo; + mUiAutomationService.mServiceInterface = serviceClient; + mUiAutomationService.onAdded(); + try { + mUiAutomationService.mServiceInterface.asBinder().linkToDeath(mUiAutomationService, + 0); + } catch (RemoteException re) { + Slog.e(LOG_TAG, "Failed registering death link: " + re); + destroyUiAutomationService(); + return; + } - mUiAutomationService.connectServiceUnknownThread(); + mUiAutomationService.connectServiceUnknownThread(); + } } void unregisterUiTestAutomationServiceLocked(IAccessibilityServiceClient serviceClient) { - if ((mUiAutomationService == null) - || (serviceClient == null) - || (mUiAutomationService.mServiceInterface == null) - || (serviceClient.asBinder() - != mUiAutomationService.mServiceInterface.asBinder())) { - throw new IllegalStateException("UiAutomationService " + serviceClient - + " not registered!"); - } + synchronized (mLock) { + if ((mUiAutomationService == null) + || (serviceClient == null) + || (mUiAutomationService.mServiceInterface == null) + || (serviceClient.asBinder() + != mUiAutomationService.mServiceInterface.asBinder())) { + throw new IllegalStateException("UiAutomationService " + serviceClient + + " not registered!"); + } - destroyUiAutomationService(); + destroyUiAutomationService(); + } } void sendAccessibilityEventLocked(AccessibilityEvent event) { @@ -159,33 +171,48 @@ class UiAutomationManager { } int getRelevantEventTypes() { - if (mUiAutomationService == null) return 0; - return mUiAutomationService.getRelevantEventTypes(); + UiAutomationService uiAutomationService; + synchronized (mLock) { + uiAutomationService = mUiAutomationService; + } + if (uiAutomationService == null) return 0; + return uiAutomationService.getRelevantEventTypes(); } @Nullable AccessibilityServiceInfo getServiceInfo() { - if (mUiAutomationService == null) return null; - return mUiAutomationService.getServiceInfo(); + UiAutomationService uiAutomationService; + synchronized (mLock) { + uiAutomationService = mUiAutomationService; + } + if (uiAutomationService == null) return null; + return uiAutomationService.getServiceInfo(); } void dumpUiAutomationService(FileDescriptor fd, final PrintWriter pw, String[] args) { - if (mUiAutomationService != null) { - mUiAutomationService.dump(fd, pw, args); + UiAutomationService uiAutomationService; + synchronized (mLock) { + uiAutomationService = mUiAutomationService; + } + if (uiAutomationService != null) { + uiAutomationService.dump(fd, pw, args); } } private void destroyUiAutomationService() { - mUiAutomationService.mServiceInterface.asBinder().unlinkToDeath(mUiAutomationService, 0); - mUiAutomationService.onRemoved(); - mUiAutomationService.resetLocked(); - mUiAutomationService = null; - mUiAutomationFlags = 0; - if (mUiAutomationServiceOwner != null) { - mUiAutomationServiceOwner.unlinkToDeath(mUiAutomationServiceOwnerDeathRecipient, 0); - mUiAutomationServiceOwner = null; + synchronized (mLock) { + mUiAutomationService.mServiceInterface.asBinder().unlinkToDeath(mUiAutomationService, + 0); + mUiAutomationService.onRemoved(); + mUiAutomationService.resetLocked(); + mUiAutomationService = null; + mUiAutomationFlags = 0; + if (mUiAutomationServiceOwner != null) { + mUiAutomationServiceOwner.unlinkToDeath(mUiAutomationServiceOwnerDeathRecipient, 0); + mUiAutomationServiceOwner = null; + } + mSystemSupport.onClientChangeLocked(false); } - mSystemSupport.onClientChange(false); } private class UiAutomationService extends AbstractAccessibilityServiceConnection { diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 14b5e42366fd..37167c688d87 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -7552,7 +7552,12 @@ public class ActivityManagerService extends IActivityManager.Stub // how to test this case.) if (cpr.proc.killed && cpr.proc.killedByAm) { checkTime(startTime, "getContentProviderImpl: before appDied (killedByAm)"); - appDiedLocked(cpr.proc); + final long iden = Binder.clearCallingIdentity(); + try { + appDiedLocked(cpr.proc); + } finally { + Binder.restoreCallingIdentity(iden); + } checkTime(startTime, "getContentProviderImpl: after appDied (killedByAm)"); } } diff --git a/services/tests/servicestests/src/com/android/server/accessibility/UiAutomationManagerTest.java b/services/tests/servicestests/src/com/android/server/accessibility/UiAutomationManagerTest.java index 8e09d6001310..9ac398770f8a 100644 --- a/services/tests/servicestests/src/com/android/server/accessibility/UiAutomationManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/accessibility/UiAutomationManagerTest.java @@ -49,7 +49,7 @@ import org.mockito.MockitoAnnotations; public class UiAutomationManagerTest { static final int SERVICE_ID = 42; - final UiAutomationManager mUiAutomationManager = new UiAutomationManager(); + final UiAutomationManager mUiAutomationManager = new UiAutomationManager(new Object()); MessageCapturingHandler mMessageCapturingHandler; @@ -158,13 +158,13 @@ public class UiAutomationManagerTest { verify(mMockOwner).linkToDeath(captor.capture(), anyInt()); captor.getValue().binderDied(); mMessageCapturingHandler.sendAllMessages(); - verify(mMockSystemSupport).onClientChange(false); + verify(mMockSystemSupport).onClientChangeLocked(false); } private void register(int flags) { mUiAutomationManager.registerUiTestAutomationServiceLocked(mMockOwner, mMockAccessibilityServiceClient, mMockContext, mMockServiceInfo, SERVICE_ID, - mMessageCapturingHandler, new Object(), mMockSecurityPolicy, mMockSystemSupport, + mMessageCapturingHandler, mMockSecurityPolicy, mMockSystemSupport, mMockWindowManagerInternal, mMockGlobalActionPerformer, flags); } diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java index 7e184eb90a3c..8d6dccc627cb 100644 --- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java +++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java @@ -20,8 +20,6 @@ import static com.android.internal.usb.DumpUtils.writeAccessory; import static com.android.internal.util.dump.DumpUtils.writeStringIfNotNull; import android.app.ActivityManager; - -import com.android.server.wm.ActivityTaskManagerInternal; import android.app.KeyguardManager; import android.app.Notification; import android.app.NotificationChannel; @@ -52,6 +50,7 @@ import android.hardware.usb.gadget.V1_0.Status; import android.hidl.manager.V1_0.IServiceManager; import android.hidl.manager.V1_0.IServiceNotification; import android.os.BatteryManager; +import android.os.Binder; import android.os.Environment; import android.os.FileUtils; import android.os.Handler; @@ -82,6 +81,7 @@ import com.android.internal.os.SomeArgs; import com.android.internal.util.dump.DualDumpOutputStream; import com.android.server.FgThread; import com.android.server.LocalServices; +import com.android.server.wm.ActivityTaskManagerInternal; import java.io.File; import java.io.FileDescriptor; @@ -659,7 +659,19 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser // successfully entered accessory mode String[] accessoryStrings = mUsbDeviceManager.getAccessoryStrings(); if (accessoryStrings != null) { - mCurrentAccessory = new UsbAccessory(accessoryStrings); + UsbSerialReader serialReader = new UsbSerialReader(mContext, mSettingsManager, + accessoryStrings[UsbAccessory.SERIAL_STRING]); + + mCurrentAccessory = new UsbAccessory( + accessoryStrings[UsbAccessory.MANUFACTURER_STRING], + accessoryStrings[UsbAccessory.MODEL_STRING], + accessoryStrings[UsbAccessory.DESCRIPTION_STRING], + accessoryStrings[UsbAccessory.VERSION_STRING], + accessoryStrings[UsbAccessory.URI_STRING], + serialReader); + + serialReader.setDevice(mCurrentAccessory); + Slog.d(TAG, "entering USB accessory mode: " + mCurrentAccessory); // defer accessoryAttached if system is not ready if (mBootCompleted) { @@ -1983,7 +1995,7 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser + currentAccessory; throw new IllegalArgumentException(error); } - settings.checkPermission(accessory); + settings.checkPermission(accessory, Binder.getCallingUid()); return nativeOpenAccessory(); } diff --git a/services/usb/java/com/android/server/usb/UsbHostManager.java b/services/usb/java/com/android/server/usb/UsbHostManager.java index cf47ad3520ec..613ba0044f6a 100644 --- a/services/usb/java/com/android/server/usb/UsbHostManager.java +++ b/services/usb/java/com/android/server/usb/UsbHostManager.java @@ -378,13 +378,18 @@ public class UsbHostManager { return false; } - UsbDevice newDevice = parser.toAndroidUsbDevice(); - if (newDevice == null) { + UsbDevice.Builder newDeviceBuilder = parser.toAndroidUsbDevice(); + if (newDeviceBuilder == null) { Slog.e(TAG, "Couldn't create UsbDevice object."); // Tracking addConnectionRecord(deviceAddress, ConnectionRecord.CONNECT_BADDEVICE, parser.getRawDescriptors()); } else { + UsbSerialReader serialNumberReader = new UsbSerialReader(mContext, mSettingsManager, + newDeviceBuilder.serialNumber); + UsbDevice newDevice = newDeviceBuilder.build(serialNumberReader); + serialNumberReader.setDevice(newDevice); + mDevices.put(deviceAddress, newDevice); Slog.d(TAG, "Added device " + newDevice); diff --git a/services/usb/java/com/android/server/usb/UsbPermissionManager.java b/services/usb/java/com/android/server/usb/UsbPermissionManager.java index 2c9ee36107e8..dd2f29ba74ae 100644 --- a/services/usb/java/com/android/server/usb/UsbPermissionManager.java +++ b/services/usb/java/com/android/server/usb/UsbPermissionManager.java @@ -148,11 +148,11 @@ class UsbPermissionManager { * Returns true if caller has permission to access the accessory. * * @param accessory to check permission for + * @param uid to check permission for * @return {@code true} if caller has permssion */ - boolean hasPermission(@NonNull UsbAccessory accessory) { + boolean hasPermission(@NonNull UsbAccessory accessory, int uid) { synchronized (mLock) { - int uid = Binder.getCallingUid(); if (uid == Process.SYSTEM_UID || mDisablePermissionDialogs) { return true; } diff --git a/services/usb/java/com/android/server/usb/UsbSerialReader.java b/services/usb/java/com/android/server/usb/UsbSerialReader.java new file mode 100644 index 000000000000..5bf94afd7683 --- /dev/null +++ b/services/usb/java/com/android/server/usb/UsbSerialReader.java @@ -0,0 +1,110 @@ +/* + * 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.usb; + +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.content.Context; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.hardware.usb.IUsbSerialReader; +import android.hardware.usb.UsbAccessory; +import android.hardware.usb.UsbDevice; +import android.os.Binder; +import android.os.Build; +import android.os.Process; +import android.os.RemoteException; +import android.os.UserHandle; + +import com.android.internal.util.ArrayUtils; + +/** + * Allows an app to read the serial number of the {@link UsbDevice}/{@link UsbAccessory} only if + * the app has got the permission to do so. + */ +class UsbSerialReader extends IUsbSerialReader.Stub { + private final @Nullable String mSerialNumber; + private final @NonNull Context mContext; + private final @NonNull UsbSettingsManager mSettingsManager; + + private Object mDevice; + + /** + * Create an new {@link UsbSerialReader}. It is mandatory to call {@link #setDevice(Object)} + * immediately after this. + * + * @param context A context to be used by the reader + * @param settingsManager The USB settings manager + * @param serialNumber The serial number that might be read + */ + UsbSerialReader(@NonNull Context context, @NonNull UsbSettingsManager settingsManager, + @Nullable String serialNumber) { + mContext = context; + mSettingsManager = settingsManager; + mSerialNumber = serialNumber; + } + + /** + * Set the {@link UsbDevice}/{@link UsbAccessory} the serial number belongs to + * + * @param device The device/accessory + */ + public void setDevice(@NonNull Object device) { + mDevice = device; + } + + @Override + public String getSerial(String packageName) throws RemoteException { + int pid = Binder.getCallingPid(); + int uid = Binder.getCallingUid(); + + if (uid != Process.SYSTEM_UID) { + enforcePackageBelongsToUid(uid, packageName); + + PackageInfo pkg; + try { + pkg = mContext.getPackageManager().getPackageInfo(packageName, 0); + } catch (PackageManager.NameNotFoundException e) { + throw new RemoteException("package " + packageName + " cannot be found"); + } + + if (pkg.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.Q) { + if (mContext.checkPermission(android.Manifest.permission.MANAGE_USB, pid, uid) + == PackageManager.PERMISSION_DENIED) { + UsbUserSettingsManager settings = mSettingsManager.getSettingsForUser( + UserHandle.getUserId(uid)); + + if (mDevice instanceof UsbDevice) { + settings.checkPermission((UsbDevice) mDevice, packageName, uid); + } else { + settings.checkPermission((UsbAccessory) mDevice, uid); + } + } + } + } + + return mSerialNumber; + } + + private void enforcePackageBelongsToUid(int uid, @NonNull String packageName) { + String[] packages = mContext.getPackageManager().getPackagesForUid(uid); + + if (!ArrayUtils.contains(packages, packageName)) { + throw new IllegalArgumentException(packageName + " does to belong to the " + uid); + } + } +} diff --git a/services/usb/java/com/android/server/usb/UsbService.java b/services/usb/java/com/android/server/usb/UsbService.java index e92bd74fadf2..4be70af05a3f 100644 --- a/services/usb/java/com/android/server/usb/UsbService.java +++ b/services/usb/java/com/android/server/usb/UsbService.java @@ -318,8 +318,13 @@ public class UsbService extends IUsbManager.Stub { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null); UserHandle user = UserHandle.of(userId); - mSettingsManager.getSettingsForProfileGroup(user).setDevicePackage(device, packageName, - user); + final long token = Binder.clearCallingIdentity(); + try { + mSettingsManager.getSettingsForProfileGroup(user).setDevicePackage(device, packageName, + user); + } finally { + Binder.restoreCallingIdentity(token); + } } @Override @@ -329,49 +334,93 @@ public class UsbService extends IUsbManager.Stub { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null); UserHandle user = UserHandle.of(userId); - mSettingsManager.getSettingsForProfileGroup(user).setAccessoryPackage(accessory, - packageName, user); + + final long token = Binder.clearCallingIdentity(); + try { + mSettingsManager.getSettingsForProfileGroup(user).setAccessoryPackage(accessory, + packageName, user); + } finally { + Binder.restoreCallingIdentity(token); + } } @Override public boolean hasDevicePermission(UsbDevice device, String packageName) { - final int userId = UserHandle.getCallingUserId(); - return getSettingsForUser(userId).hasPermission(device, packageName, - Binder.getCallingUid()); + final int uid = Binder.getCallingUid(); + final int userId = UserHandle.getUserId(uid); + + final long token = Binder.clearCallingIdentity(); + try { + return getSettingsForUser(userId).hasPermission(device, packageName, uid); + } finally { + Binder.restoreCallingIdentity(token); + } } @Override public boolean hasAccessoryPermission(UsbAccessory accessory) { - final int userId = UserHandle.getCallingUserId(); - return getSettingsForUser(userId).hasPermission(accessory); + final int uid = Binder.getCallingUid(); + final int userId = UserHandle.getUserId(uid); + + final long token = Binder.clearCallingIdentity(); + try { + return getSettingsForUser(userId).hasPermission(accessory, uid); + } finally { + Binder.restoreCallingIdentity(token); + } } @Override public void requestDevicePermission(UsbDevice device, String packageName, PendingIntent pi) { - final int userId = UserHandle.getCallingUserId(); - getSettingsForUser(userId).requestPermission(device, packageName, pi, - Binder.getCallingUid()); + final int uid = Binder.getCallingUid(); + final int userId = UserHandle.getUserId(uid); + + final long token = Binder.clearCallingIdentity(); + try { + getSettingsForUser(userId).requestPermission(device, packageName, pi, uid); + } finally { + Binder.restoreCallingIdentity(token); + } } @Override public void requestAccessoryPermission( UsbAccessory accessory, String packageName, PendingIntent pi) { - final int userId = UserHandle.getCallingUserId(); - getSettingsForUser(userId).requestPermission(accessory, packageName, pi); + final int uid = Binder.getCallingUid(); + final int userId = UserHandle.getUserId(uid); + + final long token = Binder.clearCallingIdentity(); + try { + getSettingsForUser(userId).requestPermission(accessory, packageName, pi, uid); + } finally { + Binder.restoreCallingIdentity(token); + } } @Override public void grantDevicePermission(UsbDevice device, int uid) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null); final int userId = UserHandle.getUserId(uid); - getSettingsForUser(userId).grantDevicePermission(device, uid); + + final long token = Binder.clearCallingIdentity(); + try { + getSettingsForUser(userId).grantDevicePermission(device, uid); + } finally { + Binder.restoreCallingIdentity(token); + } } @Override public void grantAccessoryPermission(UsbAccessory accessory, int uid) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null); final int userId = UserHandle.getUserId(uid); - getSettingsForUser(userId).grantAccessoryPermission(accessory, uid); + + final long token = Binder.clearCallingIdentity(); + try { + getSettingsForUser(userId).grantAccessoryPermission(accessory, uid); + } finally { + Binder.restoreCallingIdentity(token); + } } @Override @@ -381,7 +430,13 @@ public class UsbService extends IUsbManager.Stub { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null); UserHandle user = UserHandle.of(userId); - return mSettingsManager.getSettingsForProfileGroup(user).hasDefaults(packageName, user); + + final long token = Binder.clearCallingIdentity(); + try { + return mSettingsManager.getSettingsForProfileGroup(user).hasDefaults(packageName, user); + } finally { + Binder.restoreCallingIdentity(token); + } } @Override @@ -391,7 +446,13 @@ public class UsbService extends IUsbManager.Stub { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null); UserHandle user = UserHandle.of(userId); - mSettingsManager.getSettingsForProfileGroup(user).clearDefaults(packageName, user); + + final long token = Binder.clearCallingIdentity(); + try { + mSettingsManager.getSettingsForProfileGroup(user).clearDefaults(packageName, user); + } finally { + Binder.restoreCallingIdentity(token); + } } @Override diff --git a/services/usb/java/com/android/server/usb/UsbUserSettingsManager.java b/services/usb/java/com/android/server/usb/UsbUserSettingsManager.java index fe93399c2d60..0121d30736c2 100644 --- a/services/usb/java/com/android/server/usb/UsbUserSettingsManager.java +++ b/services/usb/java/com/android/server/usb/UsbUserSettingsManager.java @@ -168,19 +168,21 @@ class UsbUserSettingsManager { return mUsbPermissionManager.hasPermission(device, uid); } - public boolean hasPermission(UsbAccessory accessory) { - return mUsbPermissionManager.hasPermission(accessory); + public boolean hasPermission(UsbAccessory accessory, int uid) { + return mUsbPermissionManager.hasPermission(accessory, uid); } public void checkPermission(UsbDevice device, String packageName, int uid) { if (!hasPermission(device, packageName, uid)) { - throw new SecurityException("User has not given permission to device " + device); + throw new SecurityException("User has not given " + uid + "/" + packageName + + " permission to access device " + device.getDeviceName()); } } - public void checkPermission(UsbAccessory accessory) { - if (!hasPermission(accessory)) { - throw new SecurityException("User has not given permission to accessory " + accessory); + public void checkPermission(UsbAccessory accessory, int uid) { + if (!hasPermission(accessory, uid)) { + throw new SecurityException("User has not given " + uid + " permission to accessory " + + accessory); } } @@ -236,9 +238,10 @@ class UsbUserSettingsManager { requestPermissionDialog(device, null, canBeDefault(device, packageName), packageName, pi); } - public void requestPermission(UsbAccessory accessory, String packageName, PendingIntent pi) { + public void requestPermission(UsbAccessory accessory, String packageName, PendingIntent pi, + int uid) { // respond immediately if permission has already been granted - if (hasPermission(accessory)) { + if (hasPermission(accessory, uid)) { Intent intent = new Intent(); intent.putExtra(UsbManager.EXTRA_ACCESSORY, accessory); intent.putExtra(UsbManager.EXTRA_PERMISSION_GRANTED, true); diff --git a/services/usb/java/com/android/server/usb/descriptors/UsbDescriptorParser.java b/services/usb/java/com/android/server/usb/descriptors/UsbDescriptorParser.java index e61542824083..c02110186d8d 100644 --- a/services/usb/java/com/android/server/usb/descriptors/UsbDescriptorParser.java +++ b/services/usb/java/com/android/server/usb/descriptors/UsbDescriptorParser.java @@ -271,13 +271,13 @@ public final class UsbDescriptorParser { /** * @hide */ - public UsbDevice toAndroidUsbDevice() { + public UsbDevice.Builder toAndroidUsbDevice() { if (mDeviceDescriptor == null) { Log.e(TAG, "toAndroidUsbDevice() ERROR - No Device Descriptor"); return null; } - UsbDevice device = mDeviceDescriptor.toAndroid(this); + UsbDevice.Builder device = mDeviceDescriptor.toAndroid(this); if (device == null) { Log.e(TAG, "toAndroidUsbDevice() ERROR Creating Device"); } diff --git a/services/usb/java/com/android/server/usb/descriptors/UsbDeviceDescriptor.java b/services/usb/java/com/android/server/usb/descriptors/UsbDeviceDescriptor.java index fae594ac4986..f50b9cbc5e3d 100644 --- a/services/usb/java/com/android/server/usb/descriptors/UsbDeviceDescriptor.java +++ b/services/usb/java/com/android/server/usb/descriptors/UsbDeviceDescriptor.java @@ -135,7 +135,7 @@ public final class UsbDeviceDescriptor extends UsbDescriptor { /** * @hide */ - public UsbDevice toAndroid(UsbDescriptorParser parser) { + public UsbDevice.Builder toAndroid(UsbDescriptorParser parser) { if (DEBUG) { Log.d(TAG, "toAndroid()"); } @@ -152,16 +152,14 @@ public final class UsbDeviceDescriptor extends UsbDescriptor { Log.d(TAG, " versionString:" + versionString + " serialStr:" + serialStr); } - UsbDevice device = new UsbDevice(parser.getDeviceAddr(), mVendorID, mProductID, - mDevClass, mDevSubClass, - mProtocol, mfgName, prodName, - versionString, serialStr); UsbConfiguration[] configs = new UsbConfiguration[mConfigDescriptors.size()]; Log.d(TAG, " " + configs.length + " configs"); for (int index = 0; index < mConfigDescriptors.size(); index++) { configs[index] = mConfigDescriptors.get(index).toAndroid(parser); } - device.setConfigurations(configs); + UsbDevice.Builder device = new UsbDevice.Builder(parser.getDeviceAddr(), mVendorID, + mProductID, mDevClass, mDevSubClass, mProtocol, mfgName, prodName, versionString, + configs, serialStr); return device; } diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index cc143d63d624..96069ac98a22 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -89,9 +89,7 @@ public class SubscriptionManager { /** Indicates invalid sim slot. This can be returned by {@link #getSlotIndex(int)}. */ public static final int INVALID_SIM_SLOT_INDEX = -2; - /** Indicates the caller wants the default sub id. */ - /** @hide */ - @UnsupportedAppUsage + /** Indicates the default subscription ID in Telephony. */ public static final int DEFAULT_SUBSCRIPTION_ID = Integer.MAX_VALUE; /** @@ -1606,6 +1604,19 @@ public class SubscriptionManager { } /** + * Check if the subscription ID is usable. + * + * A usable subscription ID has a valid value except some special values such as + * {@link DEFAULT_SUBSCRIPTION_ID}. It can be used for subscription functions. + * + * @param subscriptionId the subscription ID + * @return {@code true} if the subscription ID is usable; {@code false} otherwise. + */ + public static boolean isUsableSubscriptionId(int subscriptionId) { + return isUsableSubIdValue(subscriptionId); + } + + /** * @return true if subId is an usable subId value else false. A * usable subId means its neither a INVALID_SUBSCRIPTION_ID nor a DEFAULT_SUB_ID. * @hide diff --git a/tools/aapt2/Android.bp b/tools/aapt2/Android.bp index c02ca211a194..ba498e19f837 100644 --- a/tools/aapt2/Android.bp +++ b/tools/aapt2/Android.bp @@ -123,7 +123,6 @@ cc_library_host_static { "util/BigBuffer.cpp", "util/Files.cpp", "util/Util.cpp", - "ConfigDescription.cpp", "Debug.cpp", "DominatorTree.cpp", "java/AnnotationProcessor.cpp", @@ -132,7 +131,6 @@ cc_library_host_static { "java/ManifestClassGenerator.cpp", "java/ProguardRules.cpp", "LoadedApk.cpp", - "Locale.cpp", "Resource.cpp", "ResourceParser.cpp", "ResourceTable.cpp", diff --git a/tools/aapt2/DominatorTree.cpp b/tools/aapt2/DominatorTree.cpp index 118a385e2253..ff18033c641a 100644 --- a/tools/aapt2/DominatorTree.cpp +++ b/tools/aapt2/DominatorTree.cpp @@ -19,8 +19,9 @@ #include <algorithm> #include "android-base/logging.h" +#include "androidfw/ConfigDescription.h" -#include "ConfigDescription.h" +using ::android::ConfigDescription; namespace aapt { diff --git a/tools/aapt2/DominatorTree_test.cpp b/tools/aapt2/DominatorTree_test.cpp index efc523fcf59b..fe4f951a5cd0 100644 --- a/tools/aapt2/DominatorTree_test.cpp +++ b/tools/aapt2/DominatorTree_test.cpp @@ -23,6 +23,8 @@ #include "test/Test.h" #include "util/Util.h" +using ::android::ConfigDescription; + namespace aapt { namespace { diff --git a/tools/aapt2/Resource.h b/tools/aapt2/Resource.h index 879d0bd8d94e..dd5c751967b8 100644 --- a/tools/aapt2/Resource.h +++ b/tools/aapt2/Resource.h @@ -24,10 +24,10 @@ #include <tuple> #include <vector> +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" #include "utils/JenkinsHash.h" -#include "ConfigDescription.h" #include "Source.h" namespace aapt { @@ -176,7 +176,7 @@ struct ResourceFile { ResourceName name; // Configuration - ConfigDescription config; + android::ConfigDescription config; // Type Type type; @@ -194,7 +194,7 @@ struct ResourceFile { */ struct ResourceKey { ResourceName name; - ConfigDescription config; + android::ConfigDescription config; }; bool operator<(const ResourceKey& a, const ResourceKey& b); @@ -206,16 +206,16 @@ bool operator<(const ResourceKey& a, const ResourceKey& b); */ struct ResourceKeyRef { ResourceNameRef name; - ConfigDescription config; + android::ConfigDescription config; ResourceKeyRef() = default; - ResourceKeyRef(const ResourceNameRef& n, const ConfigDescription& c) + ResourceKeyRef(const ResourceNameRef& n, const android::ConfigDescription& c) : name(n), config(c) {} /** * Prevent taking a reference to a temporary. This is bad. */ - ResourceKeyRef(ResourceName&& n, const ConfigDescription& c) = delete; + ResourceKeyRef(ResourceName&& n, const android::ConfigDescription& c) = delete; }; bool operator<(const ResourceKeyRef& a, const ResourceKeyRef& b); diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp index 8719a233d774..9a3f14c8e08e 100644 --- a/tools/aapt2/ResourceParser.cpp +++ b/tools/aapt2/ResourceParser.cpp @@ -34,6 +34,7 @@ using ::aapt::ResourceUtils::StringBuilder; using ::aapt::text::Utf8Iterator; +using ::android::ConfigDescription; using ::android::StringPiece; namespace aapt { diff --git a/tools/aapt2/ResourceParser.h b/tools/aapt2/ResourceParser.h index 68130c2512d3..06bb0c9cf264 100644 --- a/tools/aapt2/ResourceParser.h +++ b/tools/aapt2/ResourceParser.h @@ -20,9 +20,9 @@ #include <memory> #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" -#include "ConfigDescription.h" #include "Diagnostics.h" #include "ResourceTable.h" #include "ResourceValues.h" @@ -57,7 +57,7 @@ struct ResourceParserOptions { class ResourceParser { public: ResourceParser(IDiagnostics* diag, ResourceTable* table, const Source& source, - const ConfigDescription& config, + const android::ConfigDescription& config, const ResourceParserOptions& options = {}); bool Parse(xml::XmlPullParser* parser); @@ -114,7 +114,7 @@ class ResourceParser { IDiagnostics* diag_; ResourceTable* table_; Source source_; - ConfigDescription config_; + android::ConfigDescription config_; ResourceParserOptions options_; }; diff --git a/tools/aapt2/ResourceParser_test.cpp b/tools/aapt2/ResourceParser_test.cpp index ee496d501113..0dff66430532 100644 --- a/tools/aapt2/ResourceParser_test.cpp +++ b/tools/aapt2/ResourceParser_test.cpp @@ -29,6 +29,7 @@ using ::aapt::io::StringInputStream; using ::aapt::test::StrValueEq; using ::aapt::test::ValueEq; +using ::android::ConfigDescription; using ::android::Res_value; using ::android::ResTable_map; using ::android::StringPiece; diff --git a/tools/aapt2/ResourceTable.cpp b/tools/aapt2/ResourceTable.cpp index 23322ab277bf..056a27bf011d 100644 --- a/tools/aapt2/ResourceTable.cpp +++ b/tools/aapt2/ResourceTable.cpp @@ -23,9 +23,9 @@ #include "android-base/logging.h" #include "android-base/stringprintf.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" -#include "ConfigDescription.h" #include "Debug.h" #include "NameMangler.h" #include "ResourceValues.h" @@ -34,6 +34,7 @@ #include "util/Util.h" using ::aapt::text::IsValidResourceEntryName; +using ::android::ConfigDescription; using ::android::StringPiece; using ::android::base::StringPrintf; diff --git a/tools/aapt2/ResourceTable.h b/tools/aapt2/ResourceTable.h index 5a43a2d86cfe..1917d7e78c4f 100644 --- a/tools/aapt2/ResourceTable.h +++ b/tools/aapt2/ResourceTable.h @@ -17,7 +17,6 @@ #ifndef AAPT_RESOURCE_TABLE_H #define AAPT_RESOURCE_TABLE_H -#include "ConfigDescription.h" #include "Diagnostics.h" #include "Resource.h" #include "ResourceValues.h" @@ -26,6 +25,7 @@ #include "io/File.h" #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" #include <functional> @@ -66,7 +66,7 @@ struct Overlayable { class ResourceConfigValue { public: // The configuration for which this value is defined. - const ConfigDescription config; + const android::ConfigDescription config; // The product for which this value is defined. const std::string product; @@ -74,7 +74,7 @@ class ResourceConfigValue { // The actual Value. std::unique_ptr<Value> value; - ResourceConfigValue(const ConfigDescription& config, const android::StringPiece& product) + ResourceConfigValue(const android::ConfigDescription& config, const android::StringPiece& product) : config(config), product(product.to_string()) {} private: @@ -103,14 +103,14 @@ class ResourceEntry { explicit ResourceEntry(const android::StringPiece& name) : name(name.to_string()) {} - ResourceConfigValue* FindValue(const ConfigDescription& config); + ResourceConfigValue* FindValue(const android::ConfigDescription& config); - ResourceConfigValue* FindValue(const ConfigDescription& config, + ResourceConfigValue* FindValue(const android::ConfigDescription& config, const android::StringPiece& product); - ResourceConfigValue* FindOrCreateValue(const ConfigDescription& config, + ResourceConfigValue* FindOrCreateValue(const android::ConfigDescription& config, const android::StringPiece& product); - std::vector<ResourceConfigValue*> FindAllValues(const ConfigDescription& config); + std::vector<ResourceConfigValue*> FindAllValues(const android::ConfigDescription& config); template <typename Func> std::vector<ResourceConfigValue*> FindValuesIf(Func f) { @@ -189,29 +189,30 @@ class ResourceTable { // When a collision of resources occurs, this method keeps both values static CollisionResult IgnoreCollision(Value* existing, Value* incoming); - bool AddResource(const ResourceNameRef& name, const ConfigDescription& config, + bool AddResource(const ResourceNameRef& name, const android::ConfigDescription& config, const android::StringPiece& product, std::unique_ptr<Value> value, IDiagnostics* diag); bool AddResourceWithId(const ResourceNameRef& name, const ResourceId& res_id, - const ConfigDescription& config, const android::StringPiece& product, - std::unique_ptr<Value> value, IDiagnostics* diag); + const android::ConfigDescription& config, + const android::StringPiece& product, std::unique_ptr<Value> value, + IDiagnostics* diag); - bool AddFileReference(const ResourceNameRef& name, const ConfigDescription& config, + bool AddFileReference(const ResourceNameRef& name, const android::ConfigDescription& config, const Source& source, const android::StringPiece& path, IDiagnostics* diag); - bool AddFileReferenceMangled(const ResourceNameRef& name, const ConfigDescription& config, + bool AddFileReferenceMangled(const ResourceNameRef& name, const android::ConfigDescription& config, const Source& source, const android::StringPiece& path, io::IFile* file, IDiagnostics* diag); // Same as AddResource, but doesn't verify the validity of the name. This is used // when loading resources from an existing binary resource table that may have mangled names. - bool AddResourceMangled(const ResourceNameRef& name, const ConfigDescription& config, + bool AddResourceMangled(const ResourceNameRef& name, const android::ConfigDescription& config, const android::StringPiece& product, std::unique_ptr<Value> value, IDiagnostics* diag); bool AddResourceWithIdMangled(const ResourceNameRef& name, const ResourceId& id, - const ConfigDescription& config, + const android::ConfigDescription& config, const android::StringPiece& product, std::unique_ptr<Value> value, IDiagnostics* diag); @@ -286,11 +287,12 @@ class ResourceTable { IDiagnostics* diag); bool AddResourceImpl(const ResourceNameRef& name, const ResourceId& res_id, - const ConfigDescription& config, const android::StringPiece& product, - std::unique_ptr<Value> value, NameValidator name_validator, - const CollisionResolverFunc& conflict_resolver, IDiagnostics* diag); + const android::ConfigDescription& config, + const android::StringPiece& product, std::unique_ptr<Value> value, + NameValidator name_validator, const CollisionResolverFunc& conflict_resolver, + IDiagnostics* diag); - bool AddFileReferenceImpl(const ResourceNameRef& name, const ConfigDescription& config, + bool AddFileReferenceImpl(const ResourceNameRef& name, const android::ConfigDescription& config, const Source& source, const android::StringPiece& path, io::IFile* file, NameValidator name_validator, IDiagnostics* diag); diff --git a/tools/aapt2/ResourceTable_test.cpp b/tools/aapt2/ResourceTable_test.cpp index 1aa97511dd37..05c6f1531d34 100644 --- a/tools/aapt2/ResourceTable_test.cpp +++ b/tools/aapt2/ResourceTable_test.cpp @@ -24,6 +24,7 @@ #include <ostream> #include <string> +using ::android::ConfigDescription; using ::android::StringPiece; using ::testing::Eq; using ::testing::NotNull; diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp index de00fcaea07b..dbe5ac5adb98 100644 --- a/tools/aapt2/ResourceUtils.cpp +++ b/tools/aapt2/ResourceUtils.cpp @@ -31,6 +31,7 @@ #include "util/Util.h" using ::aapt::text::Utf8Iterator; +using ::android::ConfigDescription; using ::android::StringPiece; using ::android::StringPiece16; using ::android::base::StringPrintf; diff --git a/tools/aapt2/ResourceUtils.h b/tools/aapt2/ResourceUtils.h index 410ef28ce78a..e282fd58d261 100644 --- a/tools/aapt2/ResourceUtils.h +++ b/tools/aapt2/ResourceUtils.h @@ -20,6 +20,7 @@ #include <functional> #include <memory> +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" #include "androidfw/StringPiece.h" @@ -219,7 +220,8 @@ std::string BuildResourceFileName(const ResourceFile& res_file, // Parses the binary form of a resource value. `type` is used as a hint to know when a value is // an ID versus a False boolean value, etc. `config` is for sorting strings in the string pool. -std::unique_ptr<Item> ParseBinaryResValue(const ResourceType& type, const ConfigDescription& config, +std::unique_ptr<Item> ParseBinaryResValue(const ResourceType& type, + const android::ConfigDescription& config, const android::ResStringPool& src_pool, const android::Res_value& res_value, StringPool* dst_pool); diff --git a/tools/aapt2/StringPool.h b/tools/aapt2/StringPool.h index f5b464de2ea5..1006ca970dc5 100644 --- a/tools/aapt2/StringPool.h +++ b/tools/aapt2/StringPool.h @@ -24,9 +24,9 @@ #include <vector> #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" -#include "ConfigDescription.h" #include "Diagnostics.h" #include "util/BigBuffer.h" @@ -60,12 +60,12 @@ class StringPool { kLowPriority = 0xffffffffu, }; uint32_t priority = kNormalPriority; - ConfigDescription config; + android::ConfigDescription config; Context() = default; - Context(uint32_t p, const ConfigDescription& c) : priority(p), config(c) {} + Context(uint32_t p, const android::ConfigDescription& c) : priority(p), config(c) {} explicit Context(uint32_t p) : priority(p) {} - explicit Context(const ConfigDescription& c) : priority(kNormalPriority), config(c) { + explicit Context(const android::ConfigDescription& c) : priority(kNormalPriority), config(c) { } }; diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp index 8060a8de4629..fc9514a691d2 100644 --- a/tools/aapt2/cmd/Compile.cpp +++ b/tools/aapt2/cmd/Compile.cpp @@ -22,11 +22,11 @@ #include "android-base/errors.h" #include "android-base/file.h" #include "android-base/utf8.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/zero_copy_stream_impl_lite.h" -#include "ConfigDescription.h" #include "Diagnostics.h" #include "ResourceParser.h" #include "ResourceTable.h" @@ -53,6 +53,7 @@ using ::aapt::io::FileInputStream; using ::aapt::text::Printer; +using ::android::ConfigDescription; using ::android::StringPiece; using ::android::base::SystemErrorCodeToString; using ::google::protobuf::io::CopyingOutputStreamAdaptor; diff --git a/tools/aapt2/cmd/Dump.cpp b/tools/aapt2/cmd/Dump.cpp index 91e39771e490..d80b5ea38bbd 100644 --- a/tools/aapt2/cmd/Dump.cpp +++ b/tools/aapt2/cmd/Dump.cpp @@ -20,6 +20,7 @@ #include <vector> #include "android-base/stringprintf.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" #include "Debug.h" @@ -233,12 +234,12 @@ int DumpConfigsCommand::Action(const std::vector<std::string>& args) { Printer printer(&fout); // Comparison function used to order configurations - auto compare = [](ConfigDescription c1, ConfigDescription c2) -> bool { + auto compare = [](android::ConfigDescription c1, android::ConfigDescription c2) -> bool { return c1.compare(c2) < 0; }; // Insert the configurations into a set in order to keep every configuarion seen - std::set<ConfigDescription, decltype(compare)> configs(compare); + std::set<android::ConfigDescription, decltype(compare)> configs(compare); for (auto& package : table->packages) { for (auto& type : package->types) { for (auto& entry : type->entries) { diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp index 20ea3cb6ffac..186f8a159fe7 100644 --- a/tools/aapt2/cmd/Link.cpp +++ b/tools/aapt2/cmd/Link.cpp @@ -27,12 +27,12 @@ #include "android-base/errors.h" #include "android-base/file.h" #include "android-base/stringprintf.h" +#include "androidfw/Locale.h" #include "androidfw/StringPiece.h" #include "AppInfo.h" #include "Debug.h" #include "LoadedApk.h" -#include "Locale.h" #include "NameMangler.h" #include "ResourceUtils.h" #include "ResourceValues.h" @@ -70,6 +70,7 @@ #include "xml/XmlDom.h" using ::aapt::io::FileInputStream; +using ::android::ConfigDescription; using ::android::StringPiece; using ::android::base::StringPrintf; diff --git a/tools/aapt2/cmd/Optimize.cpp b/tools/aapt2/cmd/Optimize.cpp index 47288ec092de..328b0beda372 100644 --- a/tools/aapt2/cmd/Optimize.cpp +++ b/tools/aapt2/cmd/Optimize.cpp @@ -22,6 +22,7 @@ #include "android-base/file.h" #include "android-base/stringprintf.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" #include "androidfw/StringPiece.h" @@ -47,6 +48,7 @@ using ::aapt::configuration::Abi; using ::aapt::configuration::OutputArtifact; +using ::android::ConfigDescription; using ::android::ResTable_config; using ::android::StringPiece; using ::android::base::ReadFileToString; diff --git a/tools/aapt2/cmd/Util.cpp b/tools/aapt2/cmd/Util.cpp index 5862d31e3f94..792120e449ae 100644 --- a/tools/aapt2/cmd/Util.cpp +++ b/tools/aapt2/cmd/Util.cpp @@ -19,15 +19,17 @@ #include <vector> #include "android-base/logging.h" +#include "androidfw/ConfigDescription.h" +#include "androidfw/Locale.h" -#include "ConfigDescription.h" -#include "Locale.h" #include "ResourceUtils.h" #include "ValueVisitor.h" #include "split/TableSplitter.h" #include "util/Maybe.h" #include "util/Util.h" +using ::android::ConfigDescription; +using ::android::LocaleValue; using ::android::StringPiece; using ::android::base::StringPrintf; diff --git a/tools/aapt2/cmd/Util_test.cpp b/tools/aapt2/cmd/Util_test.cpp index 6aeff08e618e..f92f1e3c4c7e 100644 --- a/tools/aapt2/cmd/Util_test.cpp +++ b/tools/aapt2/cmd/Util_test.cpp @@ -24,6 +24,8 @@ #include "test/Test.h" #include "util/Files.h" +using ::android::ConfigDescription; + namespace aapt { #ifdef _WIN32 diff --git a/tools/aapt2/compile/PseudolocaleGenerator.cpp b/tools/aapt2/compile/PseudolocaleGenerator.cpp index 36c24bc4a0fd..c5de9e058907 100644 --- a/tools/aapt2/compile/PseudolocaleGenerator.cpp +++ b/tools/aapt2/compile/PseudolocaleGenerator.cpp @@ -24,6 +24,7 @@ #include "compile/Pseudolocalizer.h" #include "util/Util.h" +using ::android::ConfigDescription; using ::android::StringPiece; using ::android::StringPiece16; diff --git a/tools/aapt2/compile/PseudolocaleGenerator_test.cpp b/tools/aapt2/compile/PseudolocaleGenerator_test.cpp index 711558aa51c1..31358020ab60 100644 --- a/tools/aapt2/compile/PseudolocaleGenerator_test.cpp +++ b/tools/aapt2/compile/PseudolocaleGenerator_test.cpp @@ -19,6 +19,8 @@ #include "test/Test.h" #include "util/Util.h" +using ::android::ConfigDescription; + namespace aapt { TEST(PseudolocaleGeneratorTest, PseudolocalizeStyledString) { diff --git a/tools/aapt2/configuration/ConfigurationParser.cpp b/tools/aapt2/configuration/ConfigurationParser.cpp index 902334b98d00..dd06b38f6c01 100644 --- a/tools/aapt2/configuration/ConfigurationParser.cpp +++ b/tools/aapt2/configuration/ConfigurationParser.cpp @@ -25,8 +25,8 @@ #include "android-base/file.h" #include "android-base/logging.h" +#include "androidfw/ConfigDescription.h" -#include "ConfigDescription.h" #include "Diagnostics.h" #include "ResourceUtils.h" #include "configuration/ConfigurationParser.internal.h" @@ -40,6 +40,8 @@ #include "xml/XmlDom.h" #include "xml/XmlUtil.h" +using ::android::ConfigDescription; + namespace aapt { namespace { diff --git a/tools/aapt2/configuration/ConfigurationParser.h b/tools/aapt2/configuration/ConfigurationParser.h index 7f1d4453f9b3..b9e3be9393c9 100644 --- a/tools/aapt2/configuration/ConfigurationParser.h +++ b/tools/aapt2/configuration/ConfigurationParser.h @@ -22,7 +22,8 @@ #include <unordered_map> #include <vector> -#include "ConfigDescription.h" +#include "androidfw/ConfigDescription.h" + #include "Diagnostics.h" #include "util/Maybe.h" @@ -109,8 +110,8 @@ struct OutputArtifact { std::string name; int version; std::vector<Abi> abis; - std::vector<ConfigDescription> screen_densities; - std::vector<ConfigDescription> locales; + std::vector<android::ConfigDescription> screen_densities; + std::vector<android::ConfigDescription> locales; Maybe<AndroidSdk> android_sdk; std::vector<DeviceFeature> features; std::vector<GlTexture> textures; diff --git a/tools/aapt2/configuration/ConfigurationParser.internal.h b/tools/aapt2/configuration/ConfigurationParser.internal.h index f071a69fc9e3..c541688bc018 100644 --- a/tools/aapt2/configuration/ConfigurationParser.internal.h +++ b/tools/aapt2/configuration/ConfigurationParser.internal.h @@ -17,6 +17,8 @@ #ifndef AAPT2_CONFIGURATIONPARSER_INTERNAL_H #define AAPT2_CONFIGURATIONPARSER_INTERNAL_H +#include "androidfw/ConfigDescription.h" + #include "configuration/ConfigurationParser.h" #include <algorithm> @@ -148,8 +150,8 @@ struct PostProcessingConfiguration { Maybe<std::string> artifact_format; Group<Abi> abi_groups; - Group<ConfigDescription> screen_density_groups; - Group<ConfigDescription> locale_groups; + Group<android::ConfigDescription> screen_density_groups; + Group<android::ConfigDescription> locale_groups; Group<DeviceFeature> device_feature_groups; Group<GlTexture> gl_texture_groups; Entry<AndroidSdk> android_sdks; diff --git a/tools/aapt2/configuration/ConfigurationParser_test.cpp b/tools/aapt2/configuration/ConfigurationParser_test.cpp index ccaea4e2a771..3a71e836aa38 100644 --- a/tools/aapt2/configuration/ConfigurationParser_test.cpp +++ b/tools/aapt2/configuration/ConfigurationParser_test.cpp @@ -26,6 +26,8 @@ #include "test/Test.h" #include "xml/XmlDom.h" +using ::android::ConfigDescription; + namespace aapt { namespace configuration { diff --git a/tools/aapt2/dump/DumpManifest.cpp b/tools/aapt2/dump/DumpManifest.cpp index b6a984f9b156..c0e1dc682845 100644 --- a/tools/aapt2/dump/DumpManifest.cpp +++ b/tools/aapt2/dump/DumpManifest.cpp @@ -26,7 +26,10 @@ #include "process/IResourceTableConsumer.h" #include "xml/XmlDom.h" +#include "androidfw/ConfigDescription.h" + using ::android::base::StringPrintf; +using ::android::ConfigDescription; namespace aapt { @@ -2320,4 +2323,4 @@ int DumpPermissionsCommand::Action(const std::vector<std::string>& args) { return 0; } -} // namespace aapt
\ No newline at end of file +} // namespace aapt diff --git a/tools/aapt2/filter/ConfigFilter.cpp b/tools/aapt2/filter/ConfigFilter.cpp index 5fbe77e98144..9d10d595882a 100644 --- a/tools/aapt2/filter/ConfigFilter.cpp +++ b/tools/aapt2/filter/ConfigFilter.cpp @@ -16,9 +16,10 @@ #include "filter/ConfigFilter.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" -#include "ConfigDescription.h" +using ::android::ConfigDescription; namespace aapt { diff --git a/tools/aapt2/filter/ConfigFilter.h b/tools/aapt2/filter/ConfigFilter.h index ebb81519dceb..c4b7e4356df9 100644 --- a/tools/aapt2/filter/ConfigFilter.h +++ b/tools/aapt2/filter/ConfigFilter.h @@ -20,7 +20,7 @@ #include <set> #include <utility> -#include "ConfigDescription.h" +#include "androidfw/ConfigDescription.h" namespace aapt { @@ -34,7 +34,7 @@ class IConfigFilter { /** * Returns true if the filter matches the configuration, false otherwise. */ - virtual bool Match(const ConfigDescription& config) const = 0; + virtual bool Match(const android::ConfigDescription& config) const = 0; }; /** @@ -46,12 +46,12 @@ class IConfigFilter { */ class AxisConfigFilter : public IConfigFilter { public: - void AddConfig(ConfigDescription config); + void AddConfig(android::ConfigDescription config); - bool Match(const ConfigDescription& config) const override; + bool Match(const android::ConfigDescription& config) const override; private: - std::set<std::pair<ConfigDescription, uint32_t>> configs_; + std::set<std::pair<android::ConfigDescription, uint32_t>> configs_; uint32_t config_mask_ = 0; }; diff --git a/tools/aapt2/format/binary/BinaryResourceParser.h b/tools/aapt2/format/binary/BinaryResourceParser.h index a1f9f83edfb6..2bdc051f4e29 100644 --- a/tools/aapt2/format/binary/BinaryResourceParser.h +++ b/tools/aapt2/format/binary/BinaryResourceParser.h @@ -20,6 +20,7 @@ #include <string> #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" #include "ResourceTable.h" @@ -54,22 +55,28 @@ class BinaryResourceParser { bool ParseType(const ResourceTablePackage* package, const android::ResChunk_header* chunk); bool ParseLibrary(const android::ResChunk_header* chunk); - std::unique_ptr<Item> ParseValue(const ResourceNameRef& name, const ConfigDescription& config, + std::unique_ptr<Item> ParseValue(const ResourceNameRef& name, + const android::ConfigDescription& config, const android::Res_value& value); - std::unique_ptr<Value> ParseMapEntry(const ResourceNameRef& name, const ConfigDescription& config, + std::unique_ptr<Value> ParseMapEntry(const ResourceNameRef& name, + const android::ConfigDescription& config, const android::ResTable_map_entry* map); - std::unique_ptr<Style> ParseStyle(const ResourceNameRef& name, const ConfigDescription& config, + std::unique_ptr<Style> ParseStyle(const ResourceNameRef& name, + const android::ConfigDescription& config, const android::ResTable_map_entry* map); - std::unique_ptr<Attribute> ParseAttr(const ResourceNameRef& name, const ConfigDescription& config, + std::unique_ptr<Attribute> ParseAttr(const ResourceNameRef& name, + const android::ConfigDescription& config, const android::ResTable_map_entry* map); - std::unique_ptr<Array> ParseArray(const ResourceNameRef& name, const ConfigDescription& config, + std::unique_ptr<Array> ParseArray(const ResourceNameRef& name, + const android::ConfigDescription& config, const android::ResTable_map_entry* map); - std::unique_ptr<Plural> ParsePlural(const ResourceNameRef& name, const ConfigDescription& config, + std::unique_ptr<Plural> ParsePlural(const ResourceNameRef& name, + const android::ConfigDescription& config, const android::ResTable_map_entry* map); /** diff --git a/tools/aapt2/format/proto/ProtoDeserialize.cpp b/tools/aapt2/format/proto/ProtoDeserialize.cpp index 3b101b7152be..d1b2fdb84afc 100644 --- a/tools/aapt2/format/proto/ProtoDeserialize.cpp +++ b/tools/aapt2/format/proto/ProtoDeserialize.cpp @@ -19,13 +19,15 @@ #include "android-base/logging.h" #include "android-base/macros.h" #include "androidfw/ResourceTypes.h" +#include "androidfw/Locale.h" -#include "Locale.h" #include "ResourceTable.h" #include "ResourceUtils.h" #include "ResourceValues.h" #include "ValueVisitor.h" +using ::android::ConfigDescription; +using ::android::LocaleValue; using ::android::ResStringPool; namespace aapt { diff --git a/tools/aapt2/format/proto/ProtoDeserialize.h b/tools/aapt2/format/proto/ProtoDeserialize.h index 0c581a17fa2e..723a1c095a50 100644 --- a/tools/aapt2/format/proto/ProtoDeserialize.h +++ b/tools/aapt2/format/proto/ProtoDeserialize.h @@ -18,9 +18,9 @@ #define AAPT_FORMAT_PROTO_PROTODESERIALIZE_H #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" -#include "ConfigDescription.h" #include "Configuration.pb.h" #include "ResourceTable.h" #include "ResourceValues.h" @@ -34,14 +34,15 @@ namespace aapt { std::unique_ptr<Value> DeserializeValueFromPb(const pb::Value& pb_value, const android::ResStringPool& src_pool, - const ConfigDescription& config, + const android::ConfigDescription& config, StringPool* value_pool, io::IFileCollection* files, std::string* out_error); std::unique_ptr<Item> DeserializeItemFromPb(const pb::Item& pb_item, const android::ResStringPool& src_pool, - const ConfigDescription& config, StringPool* value_pool, - io::IFileCollection* files, std::string* out_error); + const android::ConfigDescription& config, + StringPool* value_pool, io::IFileCollection* files, + std::string* out_error); std::unique_ptr<xml::XmlResource> DeserializeXmlResourceFromPb(const pb::XmlNode& pb_node, std::string* out_error); @@ -49,8 +50,8 @@ std::unique_ptr<xml::XmlResource> DeserializeXmlResourceFromPb(const pb::XmlNode bool DeserializeXmlFromPb(const pb::XmlNode& pb_node, xml::Element* out_el, StringPool* value_pool, std::string* out_error); -bool DeserializeConfigFromPb(const pb::Configuration& pb_config, ConfigDescription* out_config, - std::string* out_error); +bool DeserializeConfigFromPb(const pb::Configuration& pb_config, + android::ConfigDescription* out_config, std::string* out_error); // Optional io::IFileCollection used to lookup references to files in the ResourceTable. bool DeserializeTableFromPb(const pb::ResourceTable& pb_table, io::IFileCollection* files, diff --git a/tools/aapt2/format/proto/ProtoSerialize.cpp b/tools/aapt2/format/proto/ProtoSerialize.cpp index 411cc29630fe..7e35ea7bb7a3 100644 --- a/tools/aapt2/format/proto/ProtoSerialize.cpp +++ b/tools/aapt2/format/proto/ProtoSerialize.cpp @@ -19,6 +19,8 @@ #include "ValueVisitor.h" #include "util/BigBuffer.h" +using android::ConfigDescription; + namespace aapt { void SerializeStringPoolToPb(const StringPool& pool, pb::StringPool* out_pb_pool, IDiagnostics* diag) { diff --git a/tools/aapt2/format/proto/ProtoSerialize.h b/tools/aapt2/format/proto/ProtoSerialize.h index 951494ca8a0d..c40e5dd51da6 100644 --- a/tools/aapt2/format/proto/ProtoSerialize.h +++ b/tools/aapt2/format/proto/ProtoSerialize.h @@ -18,8 +18,8 @@ #define AAPT_FORMAT_PROTO_PROTOSERIALIZE_H #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" -#include "ConfigDescription.h" #include "Configuration.pb.h" #include "ResourceTable.h" #include "ResourceValues.h" @@ -49,7 +49,7 @@ void SerializeXmlResourceToPb(const xml::XmlResource& resource, pb::XmlNode* out void SerializeStringPoolToPb(const StringPool& pool, pb::StringPool* out_pb_pool, IDiagnostics* diag); // Serializes a ConfigDescription into its protobuf representation. -void SerializeConfig(const ConfigDescription& config, pb::Configuration* out_pb_config); +void SerializeConfig(const android::ConfigDescription& config, pb::Configuration* out_pb_config); // Serializes a ResourceTable into its protobuf representation. void SerializeTableToPb(const ResourceTable& table, pb::ResourceTable* out_table, IDiagnostics* diag); diff --git a/tools/aapt2/format/proto/ProtoSerialize_test.cpp b/tools/aapt2/format/proto/ProtoSerialize_test.cpp index 74295ab85846..3c4d41ae5d1a 100644 --- a/tools/aapt2/format/proto/ProtoSerialize_test.cpp +++ b/tools/aapt2/format/proto/ProtoSerialize_test.cpp @@ -20,6 +20,7 @@ #include "format/proto/ProtoDeserialize.h" #include "test/Test.h" +using ::android::ConfigDescription; using ::android::StringPiece; using ::testing::Eq; using ::testing::IsEmpty; diff --git a/tools/aapt2/java/ProguardRules_test.cpp b/tools/aapt2/java/ProguardRules_test.cpp index 3d93cb1dd43b..da24907417fa 100644 --- a/tools/aapt2/java/ProguardRules_test.cpp +++ b/tools/aapt2/java/ProguardRules_test.cpp @@ -21,6 +21,7 @@ #include "test/Test.h" using ::aapt::io::StringOutputStream; +using ::android::ConfigDescription; using ::testing::HasSubstr; using ::testing::Not; diff --git a/tools/aapt2/link/AutoVersioner.cpp b/tools/aapt2/link/AutoVersioner.cpp index f80c6e9b34d3..960c7d46cc98 100644 --- a/tools/aapt2/link/AutoVersioner.cpp +++ b/tools/aapt2/link/AutoVersioner.cpp @@ -20,14 +20,16 @@ #include "android-base/logging.h" -#include "ConfigDescription.h" #include "ResourceTable.h" #include "SdkConstants.h" #include "ValueVisitor.h" +using android::ConfigDescription; + namespace aapt { -bool ShouldGenerateVersionedResource(const ResourceEntry* entry, const ConfigDescription& config, +bool ShouldGenerateVersionedResource(const ResourceEntry* entry, + const ConfigDescription& config, const ApiVersion sdk_version_to_generate) { // We assume the caller is trying to generate a version greater than the current configuration. CHECK(sdk_version_to_generate > config.sdkVersion); diff --git a/tools/aapt2/link/AutoVersioner_test.cpp b/tools/aapt2/link/AutoVersioner_test.cpp index 49639f8ad549..1117472f104b 100644 --- a/tools/aapt2/link/AutoVersioner_test.cpp +++ b/tools/aapt2/link/AutoVersioner_test.cpp @@ -16,9 +16,11 @@ #include "link/Linkers.h" -#include "ConfigDescription.h" +#include "androidfw/ConfigDescription.h" + #include "test/Test.h" +using ::android::ConfigDescription; using ::testing::NotNull; namespace aapt { diff --git a/tools/aapt2/link/Linkers.h b/tools/aapt2/link/Linkers.h index 3c9c4767b3d1..c9b8d3993959 100644 --- a/tools/aapt2/link/Linkers.h +++ b/tools/aapt2/link/Linkers.h @@ -21,6 +21,7 @@ #include <unordered_set> #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" #include "Resource.h" @@ -32,7 +33,6 @@ namespace aapt { class ResourceTable; class ResourceEntry; -struct ConfigDescription; // Defines the context in which a resource value is defined. Most resources are defined with the // implicit package name of their compilation context. Understanding the package name of a resource @@ -43,12 +43,14 @@ struct CallSite { // Determines whether a versioned resource should be created. If a versioned resource already // exists, it takes precedence. -bool ShouldGenerateVersionedResource(const ResourceEntry* entry, const ConfigDescription& config, +bool ShouldGenerateVersionedResource(const ResourceEntry* entry, + const android::ConfigDescription& config, const ApiVersion sdk_version_to_generate); // Finds the next largest ApiVersion of the config which is identical to the given config except // for sdkVersion. -ApiVersion FindNextApiVersionForConfig(const ResourceEntry* entry, const ConfigDescription& config); +ApiVersion FindNextApiVersionForConfig(const ResourceEntry* entry, + const android::ConfigDescription& config); class AutoVersioner : public IResourceTableConsumer { public: diff --git a/tools/aapt2/link/NoDefaultResourceRemover.cpp b/tools/aapt2/link/NoDefaultResourceRemover.cpp index 5173b8541943..05990de6a9b3 100644 --- a/tools/aapt2/link/NoDefaultResourceRemover.cpp +++ b/tools/aapt2/link/NoDefaultResourceRemover.cpp @@ -14,12 +14,16 @@ * limitations under the License. */ +#include "androidfw/Locale.h" + #include "link/NoDefaultResourceRemover.h" #include <algorithm> #include "ResourceTable.h" +using android::ConfigDescription; + namespace aapt { static bool KeepResource(const std::unique_ptr<ResourceEntry>& entry, int minSdk) { diff --git a/tools/aapt2/link/ProductFilter_test.cpp b/tools/aapt2/link/ProductFilter_test.cpp index 86dd56ad8f5b..dd4767463711 100644 --- a/tools/aapt2/link/ProductFilter_test.cpp +++ b/tools/aapt2/link/ProductFilter_test.cpp @@ -18,6 +18,8 @@ #include "test/Test.h" +using ::android::ConfigDescription; + namespace aapt { TEST(ProductFilterTest, SelectTwoProducts) { diff --git a/tools/aapt2/optimize/MultiApkGenerator.cpp b/tools/aapt2/optimize/MultiApkGenerator.cpp index e92c121272eb..8c9c43409569 100644 --- a/tools/aapt2/optimize/MultiApkGenerator.cpp +++ b/tools/aapt2/optimize/MultiApkGenerator.cpp @@ -20,6 +20,7 @@ #include <regex> #include <string> +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" #include "LoadedApk.h" @@ -44,6 +45,7 @@ using ::aapt::configuration::AndroidSdk; using ::aapt::configuration::OutputArtifact; using ::aapt::xml::kSchemaAndroid; using ::aapt::xml::XmlResource; +using ::android::ConfigDescription; using ::android::StringPiece; /** diff --git a/tools/aapt2/optimize/MultiApkGenerator.h b/tools/aapt2/optimize/MultiApkGenerator.h index c8588791662a..4a5a6c3d5915 100644 --- a/tools/aapt2/optimize/MultiApkGenerator.h +++ b/tools/aapt2/optimize/MultiApkGenerator.h @@ -22,6 +22,8 @@ #include <unordered_set> #include <vector> +#include "androidfw/ConfigDescription.h" + #include "Diagnostics.h" #include "LoadedApk.h" #include "configuration/ConfigurationParser.h" @@ -66,7 +68,7 @@ class MultiApkGenerator { /** * Adds the <screen> elements to the parent node for the provided density configuration. */ - void AddScreens(const ConfigDescription& config, xml::Element* parent); + void AddScreens(const android::ConfigDescription& config, xml::Element* parent); LoadedApk* apk_; IAaptContext* context_; diff --git a/tools/aapt2/optimize/MultiApkGenerator_test.cpp b/tools/aapt2/optimize/MultiApkGenerator_test.cpp index 80eb737fa682..7d87eb8831e8 100644 --- a/tools/aapt2/optimize/MultiApkGenerator_test.cpp +++ b/tools/aapt2/optimize/MultiApkGenerator_test.cpp @@ -31,6 +31,8 @@ #include "test/Context.h" #include "test/Test.h" +using ::android::ConfigDescription; + namespace aapt { namespace { diff --git a/tools/aapt2/optimize/ResourceDeduper.cpp b/tools/aapt2/optimize/ResourceDeduper.cpp index 9d16268a276e..ee2dfbce7c06 100644 --- a/tools/aapt2/optimize/ResourceDeduper.cpp +++ b/tools/aapt2/optimize/ResourceDeduper.cpp @@ -21,6 +21,8 @@ #include "DominatorTree.h" #include "ResourceTable.h" +using android::ConfigDescription; + namespace aapt { namespace { diff --git a/tools/aapt2/optimize/ResourceDeduper_test.cpp b/tools/aapt2/optimize/ResourceDeduper_test.cpp index d9f384c095ca..2e098aec4f8d 100644 --- a/tools/aapt2/optimize/ResourceDeduper_test.cpp +++ b/tools/aapt2/optimize/ResourceDeduper_test.cpp @@ -20,6 +20,7 @@ #include "test/Test.h" using ::aapt::test::HasValue; +using ::android::ConfigDescription; using ::testing::Not; namespace aapt { diff --git a/tools/aapt2/optimize/ResourceFilter_test.cpp b/tools/aapt2/optimize/ResourceFilter_test.cpp index 800b2bfd0403..ef57f9c56dab 100644 --- a/tools/aapt2/optimize/ResourceFilter_test.cpp +++ b/tools/aapt2/optimize/ResourceFilter_test.cpp @@ -20,6 +20,7 @@ #include "test/Test.h" using ::aapt::test::HasValue; +using ::android::ConfigDescription; using ::testing::Not; namespace aapt { diff --git a/tools/aapt2/optimize/VersionCollapser.cpp b/tools/aapt2/optimize/VersionCollapser.cpp index cc1fc1e6910b..f9856047ac40 100644 --- a/tools/aapt2/optimize/VersionCollapser.cpp +++ b/tools/aapt2/optimize/VersionCollapser.cpp @@ -21,6 +21,8 @@ #include "ResourceTable.h" +using android::ConfigDescription; + namespace aapt { template <typename Iterator, typename Pred> diff --git a/tools/aapt2/process/SymbolTable.cpp b/tools/aapt2/process/SymbolTable.cpp index 70efbf5d17b2..a844a43698e5 100644 --- a/tools/aapt2/process/SymbolTable.cpp +++ b/tools/aapt2/process/SymbolTable.cpp @@ -21,15 +21,16 @@ #include "android-base/logging.h" #include "android-base/stringprintf.h" #include "androidfw/AssetManager.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" -#include "ConfigDescription.h" #include "NameMangler.h" #include "Resource.h" #include "ResourceUtils.h" #include "ValueVisitor.h" #include "util/Util.h" +using ::android::ConfigDescription; using ::android::StringPiece; using ::android::StringPiece16; diff --git a/tools/aapt2/split/TableSplitter.cpp b/tools/aapt2/split/TableSplitter.cpp index b5c330622c72..414758e14063 100644 --- a/tools/aapt2/split/TableSplitter.cpp +++ b/tools/aapt2/split/TableSplitter.cpp @@ -24,11 +24,13 @@ #include <vector> #include "android-base/logging.h" +#include "androidfw/ConfigDescription.h" -#include "ConfigDescription.h" #include "ResourceTable.h" #include "util/Util.h" +using ::android::ConfigDescription; + namespace aapt { using ConfigClaimedMap = std::unordered_map<ResourceConfigValue*, bool>; diff --git a/tools/aapt2/split/TableSplitter.h b/tools/aapt2/split/TableSplitter.h index ed24bc3991b4..cb1395f3132b 100644 --- a/tools/aapt2/split/TableSplitter.h +++ b/tools/aapt2/split/TableSplitter.h @@ -20,8 +20,8 @@ #include <set> #include <vector> #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" -#include "ConfigDescription.h" #include "ResourceTable.h" #include "filter/ConfigFilter.h" #include "process/IResourceTableConsumer.h" @@ -29,7 +29,7 @@ namespace aapt { struct SplitConstraints { - std::set<ConfigDescription> configs; + std::set<android::ConfigDescription> configs; std::string name; }; diff --git a/tools/aapt2/split/TableSplitter_test.cpp b/tools/aapt2/split/TableSplitter_test.cpp index d52f4b446b8f..cdf07386c70f 100644 --- a/tools/aapt2/split/TableSplitter_test.cpp +++ b/tools/aapt2/split/TableSplitter_test.cpp @@ -18,6 +18,8 @@ #include "test/Test.h" +using ::android::ConfigDescription; + namespace aapt { TEST(TableSplitterTest, NoSplitPreferredDensity) { diff --git a/tools/aapt2/test/Builders.cpp b/tools/aapt2/test/Builders.cpp index c4eab1269e4e..f33ae3155192 100644 --- a/tools/aapt2/test/Builders.cpp +++ b/tools/aapt2/test/Builders.cpp @@ -28,6 +28,7 @@ using ::aapt::configuration::AndroidSdk; using ::aapt::configuration::ConfiguredArtifact; using ::aapt::configuration::GetOrCreateGroup; using ::aapt::io::StringInputStream; +using ::android::ConfigDescription; using ::android::StringPiece; namespace aapt { diff --git a/tools/aapt2/test/Builders.h b/tools/aapt2/test/Builders.h index be6e51050c86..915959972bed 100644 --- a/tools/aapt2/test/Builders.h +++ b/tools/aapt2/test/Builders.h @@ -20,6 +20,7 @@ #include <memory> #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "Resource.h" #include "ResourceTable.h" @@ -40,7 +41,8 @@ class ResourceTableBuilder { ResourceTableBuilder& SetPackageId(const android::StringPiece& package_name, uint8_t id); ResourceTableBuilder& AddSimple(const android::StringPiece& name, const ResourceId& id = {}); - ResourceTableBuilder& AddSimple(const android::StringPiece& name, const ConfigDescription& config, + ResourceTableBuilder& AddSimple(const android::StringPiece& name, + const android::ConfigDescription& config, const ResourceId& id = {}); ResourceTableBuilder& AddReference(const android::StringPiece& name, const android::StringPiece& ref); @@ -51,7 +53,8 @@ class ResourceTableBuilder { ResourceTableBuilder& AddString(const android::StringPiece& name, const ResourceId& id, const android::StringPiece& str); ResourceTableBuilder& AddString(const android::StringPiece& name, const ResourceId& id, - const ConfigDescription& config, const android::StringPiece& str); + const android::ConfigDescription& config, + const android::StringPiece& str); ResourceTableBuilder& AddFileReference(const android::StringPiece& name, const android::StringPiece& path, io::IFile* file = nullptr); @@ -60,12 +63,13 @@ class ResourceTableBuilder { io::IFile* file = nullptr); ResourceTableBuilder& AddFileReference(const android::StringPiece& name, const android::StringPiece& path, - const ConfigDescription& config, + const android::ConfigDescription& config, io::IFile* file = nullptr); ResourceTableBuilder& AddValue(const android::StringPiece& name, std::unique_ptr<Value> value); ResourceTableBuilder& AddValue(const android::StringPiece& name, const ResourceId& id, std::unique_ptr<Value> value); - ResourceTableBuilder& AddValue(const android::StringPiece& name, const ConfigDescription& config, + ResourceTableBuilder& AddValue(const android::StringPiece& name, + const android::ConfigDescription& config, const ResourceId& id, std::unique_ptr<Value> value); ResourceTableBuilder& SetSymbolState(const android::StringPiece& name, const ResourceId& id, Visibility::Level level, bool allow_new = false); @@ -163,8 +167,8 @@ class ArtifactBuilder { ArtifactBuilder& SetName(const std::string& name); ArtifactBuilder& SetVersion(int version); ArtifactBuilder& AddAbi(configuration::Abi abi); - ArtifactBuilder& AddDensity(const ConfigDescription& density); - ArtifactBuilder& AddLocale(const ConfigDescription& locale); + ArtifactBuilder& AddDensity(const android::ConfigDescription& density); + ArtifactBuilder& AddLocale(const android::ConfigDescription& locale); ArtifactBuilder& SetAndroidSdk(int min_sdk); configuration::OutputArtifact Build(); @@ -302,12 +306,12 @@ class ConfigDescriptionBuilder { config_.screenConfigPad2 = screenConfigPad2; return *this; } - ConfigDescription Build() { + android::ConfigDescription Build() { return config_; } private: - ConfigDescription config_; + android::ConfigDescription config_; }; } // namespace test diff --git a/tools/aapt2/test/Common.cpp b/tools/aapt2/test/Common.cpp index 0fabbc4070e7..b54c155ddc2f 100644 --- a/tools/aapt2/test/Common.cpp +++ b/tools/aapt2/test/Common.cpp @@ -16,6 +16,8 @@ #include "test/Common.h" +using android::ConfigDescription; + namespace aapt { namespace test { diff --git a/tools/aapt2/test/Common.h b/tools/aapt2/test/Common.h index aca161a5189d..50b41f1cb1e8 100644 --- a/tools/aapt2/test/Common.h +++ b/tools/aapt2/test/Common.h @@ -21,11 +21,11 @@ #include "android-base/logging.h" #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "ConfigDescription.h" #include "Debug.h" #include "ResourceTable.h" #include "ResourceUtils.h" @@ -45,15 +45,15 @@ inline ResourceName ParseNameOrDie(const android::StringPiece& str) { return ref.ToResourceName(); } -inline ConfigDescription ParseConfigOrDie(const android::StringPiece& str) { - ConfigDescription config; - CHECK(ConfigDescription::Parse(str, &config)) << "invalid configuration: " << str; +inline android::ConfigDescription ParseConfigOrDie(const android::StringPiece& str) { + android::ConfigDescription config; + CHECK(android::ConfigDescription::Parse(str, &config)) << "invalid configuration: " << str; return config; } template <typename T = Value> T* GetValueForConfigAndProduct(ResourceTable* table, const android::StringPiece& res_name, - const ConfigDescription& config, + const android::ConfigDescription& config, const android::StringPiece& product) { Maybe<ResourceTable::SearchResult> result = table->FindResource(ParseNameOrDie(res_name)); if (result) { @@ -68,12 +68,12 @@ T* GetValueForConfigAndProduct(ResourceTable* table, const android::StringPiece& template <> Value* GetValueForConfigAndProduct<Value>(ResourceTable* table, const android::StringPiece& res_name, - const ConfigDescription& config, + const android::ConfigDescription& config, const android::StringPiece& product); template <typename T = Value> T* GetValueForConfig(ResourceTable* table, const android::StringPiece& res_name, - const ConfigDescription& config) { + const android::ConfigDescription& config) { return GetValueForConfigAndProduct<T>(table, res_name, config, {}); } |