Merge "DO NOT MERGE: Remove DayNight theme" into mnc-dev
diff --git a/api/current.txt b/api/current.txt
index 9b86fea..fc0ba7f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -36815,6 +36815,8 @@
method public boolean onRequestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent);
method public boolean onStartNestedScroll(android.view.View, android.view.View, int);
method public void onStopNestedScroll(android.view.View);
+ method public void onViewAdded(android.view.View);
+ method public void onViewRemoved(android.view.View);
method public void recomputeViewAttributes(android.view.View);
method public void removeAllViews();
method public void removeAllViewsInLayout();
diff --git a/api/system-current.txt b/api/system-current.txt
index fc0352d..b29fb4b 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -39095,6 +39095,8 @@
method public boolean onRequestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent);
method public boolean onStartNestedScroll(android.view.View, android.view.View, int);
method public void onStopNestedScroll(android.view.View);
+ method public void onViewAdded(android.view.View);
+ method public void onViewRemoved(android.view.View);
method public void recomputeViewAttributes(android.view.View);
method public void removeAllViews();
method public void removeAllViewsInLayout();
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 33a47b24..5a0d246 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1371,6 +1371,9 @@
when = parcel.readLong();
if (parcel.readInt() != 0) {
mSmallIcon = Icon.CREATOR.createFromParcel(parcel);
+ if (mSmallIcon.getType() == Icon.TYPE_RESOURCE) {
+ icon = mSmallIcon.getResId();
+ }
}
number = parcel.readInt();
if (parcel.readInt() != 0) {
@@ -1588,13 +1591,17 @@
}
/**
- * Flatten this notification from a parcel.
+ * Flatten this notification into a parcel.
*/
public void writeToParcel(Parcel parcel, int flags)
{
parcel.writeInt(1);
parcel.writeLong(when);
+ if (mSmallIcon == null && icon != 0) {
+ // you snuck an icon in here without using the builder; let's try to keep it
+ mSmallIcon = Icon.createWithResource("", icon);
+ }
if (mSmallIcon != null) {
parcel.writeInt(1);
mSmallIcon.writeToParcel(parcel, 0);
@@ -2791,7 +2798,10 @@
return this;
}
- private void setFlag(int mask, boolean value) {
+ /**
+ * @hide
+ */
+ public void setFlag(int mask, boolean value) {
if (value) {
mFlags |= mask;
} else {
diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java
index 0904e21..605c006 100644
--- a/core/java/android/app/NotificationManager.java
+++ b/core/java/android/app/NotificationManager.java
@@ -25,6 +25,7 @@
import android.content.pm.ParceledListSlice;
import android.graphics.drawable.Icon;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -216,6 +217,12 @@
}
}
fixLegacySmallIcon(notification, pkg);
+ if (mContext.getApplicationInfo().targetSdkVersion > Build.VERSION_CODES.LOLLIPOP_MR1) {
+ if (notification.getSmallIcon() == null) {
+ throw new IllegalArgumentException("Invalid notification (no valid small icon): "
+ + notification);
+ }
+ }
if (localLOGV) Log.v(TAG, pkg + ": notify(" + id + ", " + notification + ")");
Notification stripped = notification.clone();
Builder.stripForDelivery(stripped);
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index bd50ca0..dd1c5c2 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -2900,7 +2900,7 @@
*
* @return A List<ResolveInfo> containing one entry for each matching
* Receiver. These are ordered from first to last in priority. If
- * there are no matching receivers, an empty list is returned.
+ * there are no matching receivers, an empty list or {@code null} is returned.
*
* @see #MATCH_DEFAULT_ONLY
* @see #GET_INTENT_FILTERS
@@ -2936,7 +2936,7 @@
* ServiceInfo. These are ordered from best to worst match -- that
* is, the first item in the list is what is returned by
* resolveService(). If there are no matching services, an empty
- * list is returned.
+ * list or {@code null} is returned.
*
* @see #GET_INTENT_FILTERS
* @see #GET_RESOLVED_FILTER
@@ -2955,7 +2955,7 @@
* ServiceInfo. These are ordered from best to worst match -- that
* is, the first item in the list is what is returned by
* resolveService(). If there are no matching services, an empty
- * list is returned.
+ * list or {@code null} is returned.
*
* @see #GET_INTENT_FILTERS
* @see #GET_RESOLVED_FILTER
@@ -2977,7 +2977,7 @@
* @param flags Additional option flags.
* @return A List<ResolveInfo> containing one entry for each matching
* ProviderInfo. These are ordered from best to worst match. If
- * there are no matching providers, an empty list is returned.
+ * there are no matching providers, an empty list or {@code null} is returned.
* @see #GET_INTENT_FILTERS
* @see #GET_RESOLVED_FILTER
*/
diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java
index 98c684c..39dd29b 100644
--- a/core/java/android/service/voice/VoiceInteractionSession.java
+++ b/core/java/android/service/voice/VoiceInteractionSession.java
@@ -1097,7 +1097,8 @@
WindowManager.LayoutParams.TYPE_VOICE_INTERACTION, Gravity.BOTTOM, true);
mWindow.getWindow().addFlags(
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED |
- WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
+ WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
+ WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
initViews();
mWindow.getWindow().setLayout(MATCH_PARENT, MATCH_PARENT);
mWindow.setToken(mToken);
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 73cfd8c..2e2ba88 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -4148,24 +4148,38 @@
mOnHierarchyChangeListener = listener;
}
- /**
- * @hide
- */
- protected void onViewAdded(View child) {
+ void dispatchViewAdded(View child) {
+ onViewAdded(child);
if (mOnHierarchyChangeListener != null) {
mOnHierarchyChangeListener.onChildViewAdded(this, child);
}
}
/**
- * @hide
+ * Called when a new child is added to this ViewGroup. Overrides should always
+ * call super.onViewAdded.
+ *
+ * @param child the added child view
*/
- protected void onViewRemoved(View child) {
+ public void onViewAdded(View child) {
+ }
+
+ void dispatchViewRemoved(View child) {
+ onViewRemoved(child);
if (mOnHierarchyChangeListener != null) {
mOnHierarchyChangeListener.onChildViewRemoved(this, child);
}
}
+ /**
+ * Called when a child view is removed from this ViewGroup. Overrides should always
+ * call super.onViewRemoved.
+ *
+ * @param child the removed child view
+ */
+ public void onViewRemoved(View child) {
+ }
+
private void clearCachedLayoutMode() {
if (!hasBooleanFlag(FLAG_LAYOUT_MODE_WAS_EXPLICITLY_SET)) {
mLayoutMode = LAYOUT_MODE_UNDEFINED;
@@ -4292,7 +4306,7 @@
child.resetRtlProperties();
}
- onViewAdded(child);
+ dispatchViewAdded(child);
if ((child.mViewFlags & DUPLICATE_PARENT_STATE) == DUPLICATE_PARENT_STATE) {
mGroupFlags |= FLAG_NOTIFY_CHILDREN_ON_DRAWABLE_STATE_CHANGE;
@@ -4554,7 +4568,7 @@
}
}
- onViewRemoved(view);
+ dispatchViewRemoved(view);
if (view.getVisibility() != View.GONE) {
notifySubtreeAccessibilityStateChangedIfNeeded();
@@ -4646,7 +4660,7 @@
needGlobalAttributesUpdate(false);
- onViewRemoved(view);
+ dispatchViewRemoved(view);
}
removeFromArray(start, count);
@@ -4729,7 +4743,7 @@
childHasTransientStateChanged(view, false);
}
- onViewRemoved(view);
+ dispatchViewRemoved(view);
view.mParent = null;
children[i] = null;
@@ -4788,7 +4802,7 @@
childHasTransientStateChanged(child, false);
}
- onViewRemoved(child);
+ dispatchViewRemoved(child);
}
/**
diff --git a/core/java/android/view/accessibility/AccessibilityInteractionClient.java b/core/java/android/view/accessibility/AccessibilityInteractionClient.java
index db78ec5..b49cbc6 100644
--- a/core/java/android/view/accessibility/AccessibilityInteractionClient.java
+++ b/core/java/android/view/accessibility/AccessibilityInteractionClient.java
@@ -186,7 +186,9 @@
if (DEBUG) {
Log.i(LOG_TAG, "Window cache miss");
}
+ final long identityToken = Binder.clearCallingIdentity();
window = connection.getWindow(accessibilityWindowId);
+ Binder.restoreCallingIdentity(identityToken);
if (window != null) {
sAccessibilityCache.addWindow(window);
return window;
@@ -222,7 +224,9 @@
if (DEBUG) {
Log.i(LOG_TAG, "Windows cache miss");
}
+ final long identityToken = Binder.clearCallingIdentity();
windows = connection.getWindows();
+ Binder.restoreCallingIdentity(identityToken);
if (windows != null) {
final int windowCount = windows.size();
for (int i = 0; i < windowCount; i++) {
@@ -282,9 +286,11 @@
}
}
final int interactionId = mInteractionIdCounter.getAndIncrement();
+ final long identityToken = Binder.clearCallingIdentity();
final boolean success = connection.findAccessibilityNodeInfoByAccessibilityId(
accessibilityWindowId, accessibilityNodeId, interactionId, this,
prefetchFlags, Thread.currentThread().getId());
+ Binder.restoreCallingIdentity(identityToken);
// If the scale is zero the call has failed.
if (success) {
List<AccessibilityNodeInfo> infos = getFindAccessibilityNodeInfosResultAndClear(
@@ -328,9 +334,11 @@
IAccessibilityServiceConnection connection = getConnection(connectionId);
if (connection != null) {
final int interactionId = mInteractionIdCounter.getAndIncrement();
+ final long identityToken = Binder.clearCallingIdentity();
final boolean success = connection.findAccessibilityNodeInfosByViewId(
accessibilityWindowId, accessibilityNodeId, viewId, interactionId, this,
Thread.currentThread().getId());
+ Binder.restoreCallingIdentity(identityToken);
if (success) {
List<AccessibilityNodeInfo> infos = getFindAccessibilityNodeInfosResultAndClear(
interactionId);
@@ -374,9 +382,11 @@
IAccessibilityServiceConnection connection = getConnection(connectionId);
if (connection != null) {
final int interactionId = mInteractionIdCounter.getAndIncrement();
+ final long identityToken = Binder.clearCallingIdentity();
final boolean success = connection.findAccessibilityNodeInfosByText(
accessibilityWindowId, accessibilityNodeId, text, interactionId, this,
Thread.currentThread().getId());
+ Binder.restoreCallingIdentity(identityToken);
if (success) {
List<AccessibilityNodeInfo> infos = getFindAccessibilityNodeInfosResultAndClear(
interactionId);
@@ -419,9 +429,11 @@
IAccessibilityServiceConnection connection = getConnection(connectionId);
if (connection != null) {
final int interactionId = mInteractionIdCounter.getAndIncrement();
+ final long identityToken = Binder.clearCallingIdentity();
final boolean success = connection.findFocus(accessibilityWindowId,
accessibilityNodeId, focusType, interactionId, this,
Thread.currentThread().getId());
+ Binder.restoreCallingIdentity(identityToken);
if (success) {
AccessibilityNodeInfo info = getFindAccessibilityNodeInfoResultAndClear(
interactionId);
@@ -461,9 +473,11 @@
IAccessibilityServiceConnection connection = getConnection(connectionId);
if (connection != null) {
final int interactionId = mInteractionIdCounter.getAndIncrement();
+ final long identityToken = Binder.clearCallingIdentity();
final boolean success = connection.focusSearch(accessibilityWindowId,
accessibilityNodeId, direction, interactionId, this,
Thread.currentThread().getId());
+ Binder.restoreCallingIdentity(identityToken);
if (success) {
AccessibilityNodeInfo info = getFindAccessibilityNodeInfoResultAndClear(
interactionId);
@@ -502,9 +516,11 @@
IAccessibilityServiceConnection connection = getConnection(connectionId);
if (connection != null) {
final int interactionId = mInteractionIdCounter.getAndIncrement();
+ final long identityToken = Binder.clearCallingIdentity();
final boolean success = connection.performAccessibilityAction(
accessibilityWindowId, accessibilityNodeId, action, arguments,
interactionId, this, Thread.currentThread().getId());
+ Binder.restoreCallingIdentity(identityToken);
if (success) {
return getPerformAccessibilityActionResultAndClear(interactionId);
}
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 238d6c4..9ca59f1 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -4157,6 +4157,11 @@
offset = adjustedOffset;
}
positionCursor = true;
+ } else if (adjustedOffset < mPreviousOffset) {
+ // Handle has jumped to the start of the word, and the user is moving
+ // their finger towards the handle, the delta should be updated.
+ mTouchWordDelta = mTextView.convertToLocalHorizontalCoordinate(x)
+ - layout.getPrimaryHorizontal(mPreviousOffset);
}
}
@@ -4291,6 +4296,11 @@
offset = adjustedOffset;
}
positionCursor = true;
+ } else if (adjustedOffset > mPreviousOffset) {
+ // Handle has jumped to the end of the word, and the user is moving
+ // their finger towards the handle, the delta should be updated.
+ mTouchWordDelta = layout.getPrimaryHorizontal(mPreviousOffset)
+ - mTextView.convertToLocalHorizontalCoordinate(x);
}
}
diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java
index 6cc4bda..258424a 100644
--- a/core/java/android/widget/GridLayout.java
+++ b/core/java/android/widget/GridLayout.java
@@ -935,22 +935,14 @@
super.onDebugDraw(canvas);
}
- // Add/remove
-
- /**
- * @hide
- */
@Override
- protected void onViewAdded(View child) {
+ public void onViewAdded(View child) {
super.onViewAdded(child);
invalidateStructure();
}
- /**
- * @hide
- */
@Override
- protected void onViewRemoved(View child) {
+ public void onViewRemoved(View child) {
super.onViewRemoved(child);
invalidateStructure();
}
diff --git a/core/java/com/android/internal/logging/MetricsLogger.java b/core/java/com/android/internal/logging/MetricsLogger.java
index 230d96d..03f2e3a 100644
--- a/core/java/com/android/internal/logging/MetricsLogger.java
+++ b/core/java/com/android/internal/logging/MetricsLogger.java
@@ -26,6 +26,13 @@
* @hide
*/
public class MetricsLogger implements MetricsConstants {
+ public static final int VOLUME_DIALOG = 207;
+ public static final int VOLUME_DIALOG_DETAILS = 208;
+ public static final int ACTION_VOLUME_SLIDER = 209;
+ public static final int ACTION_VOLUME_STREAM = 210;
+ public static final int ACTION_VOLUME_KEY = 211;
+ public static final int ACTION_VOLUME_ICON = 212;
+ public static final int ACTION_RINGER_MODE = 213;
// Temporary constants go here, to await migration to MetricsConstants.
public static void visible(Context context, int category) throws IllegalArgumentException {
diff --git a/core/java/com/android/internal/statusbar/StatusBarIcon.java b/core/java/com/android/internal/statusbar/StatusBarIcon.java
index 4693d4b..1d62623 100644
--- a/core/java/com/android/internal/statusbar/StatusBarIcon.java
+++ b/core/java/com/android/internal/statusbar/StatusBarIcon.java
@@ -20,17 +20,27 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserHandle;
+import android.text.TextUtils;
public class StatusBarIcon implements Parcelable {
public UserHandle user;
+ public String pkg;
public Icon icon;
public int iconLevel;
public boolean visible = true;
public int number;
public CharSequence contentDescription;
- public StatusBarIcon(UserHandle user, Icon icon, int iconLevel, int number,
+ public StatusBarIcon(UserHandle user, String resPackage, Icon icon, int iconLevel, int number,
CharSequence contentDescription) {
+ if (icon.getType() == Icon.TYPE_RESOURCE
+ && TextUtils.isEmpty(icon.getResPackage())) {
+ // This is an odd situation where someone's managed to hand us an icon without a
+ // package inside, probably by mashing an int res into a Notification object.
+ // Now that we have the correct package name handy, let's fix it.
+ icon = Icon.createWithResource(resPackage, icon.getResId());
+ }
+ this.pkg = resPackage;
this.user = user;
this.icon = icon;
this.iconLevel = iconLevel;
@@ -41,21 +51,23 @@
public StatusBarIcon(String iconPackage, UserHandle user,
int iconId, int iconLevel, int number,
CharSequence contentDescription) {
- this(user, Icon.createWithResource(iconPackage, iconId),
+ this(user, iconPackage, Icon.createWithResource(iconPackage, iconId),
iconLevel, number, contentDescription);
}
@Override
public String toString() {
- return "StatusBarIcon(icon=" + this.icon
+ return "StatusBarIcon(icon=" + icon
+ + ((iconLevel != 0)?(" level=" + iconLevel):"")
+ + (visible?" visible":"")
+ " user=" + user.getIdentifier()
- + " level=" + this.iconLevel + " visible=" + visible
- + " num=" + this.number + " )";
+ + ((number != 0)?(" num=" + number):"")
+ + " )";
}
@Override
public StatusBarIcon clone() {
- StatusBarIcon that = new StatusBarIcon(this.user, this.icon,
+ StatusBarIcon that = new StatusBarIcon(this.user, this.pkg, this.icon,
this.iconLevel, this.number, this.contentDescription);
that.visible = this.visible;
return that;
@@ -70,6 +82,7 @@
public void readFromParcel(Parcel in) {
this.icon = (Icon) in.readParcelable(null);
+ this.pkg = in.readString();
this.user = (UserHandle) in.readParcelable(null);
this.iconLevel = in.readInt();
this.visible = in.readInt() != 0;
@@ -79,6 +92,7 @@
public void writeToParcel(Parcel out, int flags) {
out.writeParcelable(this.icon, 0);
+ out.writeString(this.pkg);
out.writeParcelable(this.user, 0);
out.writeInt(this.iconLevel);
out.writeInt(this.visible ? 1 : 0);
diff --git a/core/java/com/android/internal/widget/ResolverDrawerLayout.java b/core/java/com/android/internal/widget/ResolverDrawerLayout.java
index be727f1..585cbc9 100644
--- a/core/java/com/android/internal/widget/ResolverDrawerLayout.java
+++ b/core/java/com/android/internal/widget/ResolverDrawerLayout.java
@@ -127,6 +127,8 @@
final ViewConfiguration vc = ViewConfiguration.get(context);
mTouchSlop = vc.getScaledTouchSlop();
mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
+
+ setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
public void setSmallCollapsed(boolean smallCollapsed) {
@@ -593,11 +595,6 @@
}
@Override
- public CharSequence getAccessibilityClassName() {
- return ResolverDrawerLayout.class.getName();
- }
-
- @Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
if (isEnabled()) {
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 9f2181f..91b3278 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -856,7 +856,8 @@
bool useInMask;
size_t numPositionMasks = 0;
size_t numIndexMasks = 0;
- size_t numUniqueFormats;
+ size_t numUniqueFormats = 0;
+
ALOGV("convertAudioPortFromNative id %d role %d type %d name %s",
nAudioPort->id, nAudioPort->role, nAudioPort->type, nAudioPort->name);
@@ -907,12 +908,13 @@
}
// formats
- cFormats = new int[nAudioPort->num_formats];
- numUniqueFormats = 0;
- for (size_t index = 0; index < nAudioPort->num_formats; index++) {
- int format = audioFormatFromNative(nAudioPort->formats[index]);
- if (!hasFormat(cFormats, numUniqueFormats, format)) {
- cFormats[numUniqueFormats++] = format;
+ if (nAudioPort->num_formats != 0) {
+ cFormats = new int[nAudioPort->num_formats];
+ for (size_t index = 0; index < nAudioPort->num_formats; index++) {
+ int format = audioFormatFromNative(nAudioPort->formats[index]);
+ if (!hasFormat(cFormats, numUniqueFormats, format)) {
+ cFormats[numUniqueFormats++] = format;
+ }
}
}
jFormats = env->NewIntArray(numUniqueFormats);
@@ -920,7 +922,9 @@
jStatus = (jint)AUDIO_JAVA_ERROR;
goto exit;
}
- env->SetIntArrayRegion(jFormats, 0, numUniqueFormats, cFormats);
+ if (numUniqueFormats != 0) {
+ env->SetIntArrayRegion(jFormats, 0, numUniqueFormats, cFormats);
+ }
// gains
jGains = env->NewObjectArray(nAudioPort->num_gains,
diff --git a/core/res/res/values-mcc302-mnc220/config.xml b/core/res/res/values-mcc302-mnc220/config.xml
index 9147cbf..09a63aa 100644
--- a/core/res/res/values-mcc302-mnc220/config.xml
+++ b/core/res/res/values-mcc302-mnc220/config.xml
@@ -38,7 +38,8 @@
note that empty fields can be ommitted: "name,apn,,,,,,,,,310,260,,DUN" -->
<string-array translatable="false" name="config_tether_apndata">
<item>[ApnSettingV3]TELUS ISP,isp.telus.com,,,,,,,,,302,220,,DUN,,,true,0,,,,,,,gid,54</item>
- <item>[ApnSettingV3]Tethered PC Mobile,isp.mb.com,,,,,,,,,302,220,,DUN,,,true,0,,,,,,,gid,50</item>
+ <item>[ApnSettingV3]Tethered Mobile Internet,isp.mb.com,,,,,,,,,302,220,,DUN,,,true,0,,,,,,,gid,50</item>
+ <item>[ApnSettingV3]Tethered Public Mobile,isp.mb.com,,,,,,,,,302,220,,DUN,,,true,0,,,,,,,gid,4D4F</item>
</string-array>
</resources>
diff --git a/core/res/res/values-mcc302-mnc720/config.xml b/core/res/res/values-mcc302-mnc720/config.xml
index a83107a..dcfa5c5 100644
--- a/core/res/res/values-mcc302-mnc720/config.xml
+++ b/core/res/res/values-mcc302-mnc720/config.xml
@@ -29,6 +29,8 @@
<string-array translatable="false" name="config_tether_apndata">
<item>Rogers LTE Tethering,ltedata.apn,,,,,,,,,302,720,,DUN</item>
<item>[ApnSettingV3]chatr Tethering,chatrisp.apn,,,,,,,,,302,720,,DUN,,,true,0,,,,,,,imsi,302720x94</item>
+ <item>[ApnSettingV3]Tbaytel Tethering,ltedata.apn,,,,,,,,,302,720,,DUN,IPV4V6,IP,true,0,,,,,,,gid,BA</item>
+ <item>[ApnSettingV3]Cityfone Tethering,ltedata.apn,,,,,,,,,302,720,,DUN,IPV4V6,IP,true,0,,,,,,,spn,CITYFONE</item>
</string-array>
<!-- Configure mobile network MTU. Carrier specific value is set here.
diff --git a/graphics/java/android/graphics/drawable/Icon.java b/graphics/java/android/graphics/drawable/Icon.java
index 7b4329a..85db6a1 100644
--- a/graphics/java/android/graphics/drawable/Icon.java
+++ b/graphics/java/android/graphics/drawable/Icon.java
@@ -29,6 +29,7 @@
import android.os.Message;
import android.os.Parcel;
import android.os.Parcelable;
+import android.text.TextUtils;
import android.util.Log;
import java.io.DataInputStream;
@@ -258,16 +259,21 @@
return new BitmapDrawable(context.getResources(), getBitmap());
case TYPE_RESOURCE:
if (getResources() == null) {
- if (getResPackage() == null || "android".equals(getResPackage())) {
+ // figure out where to load resources from
+ String resPackage = getResPackage();
+ if (TextUtils.isEmpty(resPackage)) {
+ // if none is specified, try the given context
+ resPackage = context.getPackageName();
+ }
+ if ("android".equals(resPackage)) {
mObj1 = Resources.getSystem();
} else {
final PackageManager pm = context.getPackageManager();
try {
- mObj1 = pm.getResourcesForApplication(getResPackage());
+ mObj1 = pm.getResourcesForApplication(resPackage);
} catch (PackageManager.NameNotFoundException e) {
- Log.e(TAG, String.format("Unable to find pkg=%s",
- getResPackage()),
- e);
+ Log.e(TAG, String.format("Unable to find pkg=%s for icon %s",
+ resPackage, this), e);
break;
}
}
@@ -320,12 +326,15 @@
*/
public Drawable loadDrawableAsUser(Context context, int userId) {
if (mType == TYPE_RESOURCE) {
- if (getResources() == null
- && getResPackage() != null
- && !(getResPackage().equals("android"))) {
+ String resPackage = getResPackage();
+ if (TextUtils.isEmpty(resPackage)) {
+ resPackage = context.getPackageName();
+ }
+ if (getResources() == null && !(getResPackage().equals("android"))) {
final PackageManager pm = context.getPackageManager();
try {
- mObj1 = pm.getResourcesForApplicationAsUser(getResPackage(), userId);
+ // assign getResources() as the correct user
+ mObj1 = pm.getResourcesForApplicationAsUser(resPackage, userId);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, String.format("Unable to find pkg=%s user=%d",
getResPackage(),
@@ -410,6 +419,9 @@
* @param resId ID of the drawable resource
*/
public static Icon createWithResource(Context context, @DrawableRes int resId) {
+ if (context == null) {
+ throw new IllegalArgumentException("Context must not be null.");
+ }
final Icon rep = new Icon(TYPE_RESOURCE);
rep.mInt1 = resId;
rep.mString1 = context.getPackageName();
diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl
index a3ea896..f3d755c 100644
--- a/location/java/android/location/ILocationManager.aidl
+++ b/location/java/android/location/ILocationManager.aidl
@@ -75,6 +75,7 @@
String getBestProvider(in Criteria criteria, boolean enabledOnly);
boolean providerMeetsCriteria(String provider, in Criteria criteria);
ProviderProperties getProviderProperties(String provider);
+ String getNetworkProviderPackage();
boolean isProviderEnabled(String provider);
void addTestProvider(String name, in ProviderProperties properties, String opPackageName);
diff --git a/media/java/android/media/midi/MidiDevice.java b/media/java/android/media/midi/MidiDevice.java
index 7998a92..93fb6d2 100644
--- a/media/java/android/media/midi/MidiDevice.java
+++ b/media/java/android/media/midi/MidiDevice.java
@@ -50,21 +50,43 @@
* Close this object to terminate the connection.
*/
public class MidiConnection implements Closeable {
- private final IBinder mToken;
- private final MidiInputPort mInputPort;
+ private final IMidiDeviceServer mInputPortDeviceServer;
+ private final IBinder mInputPortToken;
+ private final IBinder mOutputPortToken;
+ private final CloseGuard mGuard = CloseGuard.get();
+ private boolean mIsClosed;
- MidiConnection(IBinder token, MidiInputPort inputPort) {
- mToken = token;
- mInputPort = inputPort;
+ MidiConnection(IBinder outputPortToken, MidiInputPort inputPort) {
+ mInputPortDeviceServer = inputPort.getDeviceServer();
+ mInputPortToken = inputPort.getToken();
+ mOutputPortToken = outputPortToken;
+ mGuard.open("close");
}
@Override
public void close() throws IOException {
+ synchronized (mGuard) {
+ if (mIsClosed) return;
+ mGuard.close();
+ try {
+ // close input port
+ mInputPortDeviceServer.closePort(mInputPortToken);
+ // close output port
+ mDeviceServer.closePort(mOutputPortToken);
+ } catch (RemoteException e) {
+ Log.e(TAG, "RemoteException in MidiConnection.close");
+ }
+ mIsClosed = true;
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
try {
- mDeviceServer.closePort(mToken);
- IoUtils.closeQuietly(mInputPort);
- } catch (RemoteException e) {
- Log.e(TAG, "RemoteException in MidiConnection.close");
+ mGuard.warnIfOpen();
+ close();
+ } finally {
+ super.finalize();
}
}
}
diff --git a/media/java/android/media/midi/MidiDeviceServer.java b/media/java/android/media/midi/MidiDeviceServer.java
index 1212b64..19ff624 100644
--- a/media/java/android/media/midi/MidiDeviceServer.java
+++ b/media/java/android/media/midi/MidiDeviceServer.java
@@ -257,7 +257,14 @@
public void connectPorts(IBinder token, ParcelFileDescriptor pfd,
int outputPortNumber) {
MidiInputPort inputPort = new MidiInputPort(pfd, outputPortNumber);
- mOutputPortDispatchers[outputPortNumber].getSender().connect(inputPort);
+ MidiDispatcher dispatcher = mOutputPortDispatchers[outputPortNumber];
+ synchronized (dispatcher) {
+ dispatcher.getSender().connect(inputPort);
+ int openCount = dispatcher.getReceiverCount();
+ mOutputPortOpenCount[outputPortNumber] = openCount;
+ updateDeviceStatus();
+ }
+
mInputPorts.add(inputPort);
OutputPortClient client = new OutputPortClient(token, inputPort);
synchronized (mPortClients) {
diff --git a/media/java/android/media/midi/MidiInputPort.java b/media/java/android/media/midi/MidiInputPort.java
index af5a86c..db41b10 100644
--- a/media/java/android/media/midi/MidiInputPort.java
+++ b/media/java/android/media/midi/MidiInputPort.java
@@ -103,17 +103,33 @@
// used by MidiDevice.connectInputPort() to connect our socket directly to another device
/* package */ ParcelFileDescriptor claimFileDescriptor() {
- synchronized (mBuffer) {
- ParcelFileDescriptor pfd = mParcelFileDescriptor;
- if (pfd != null) {
+ synchronized (mGuard) {
+ ParcelFileDescriptor pfd;
+ synchronized (mBuffer) {
+ pfd = mParcelFileDescriptor;
+ if (pfd == null) return null;
IoUtils.closeQuietly(mOutputStream);
mParcelFileDescriptor = null;
mOutputStream = null;
}
+
+ // Set mIsClosed = true so we will not call mDeviceServer.closePort() in close().
+ // MidiDevice.MidiConnection.close() will do the cleanup instead.
+ mIsClosed = true;
return pfd;
}
}
+ // used by MidiDevice.MidiConnection to close this port after the connection is closed
+ /* package */ IBinder getToken() {
+ return mToken;
+ }
+
+ // used by MidiDevice.MidiConnection to close this port after the connection is closed
+ /* package */ IMidiDeviceServer getDeviceServer() {
+ return mDeviceServer;
+ }
+
@Override
public void close() throws IOException {
synchronized (mGuard) {
diff --git a/media/jni/android_media_ImageWriter.cpp b/media/jni/android_media_ImageWriter.cpp
index 634ba64..ba7634c 100644
--- a/media/jni/android_media_ImageWriter.cpp
+++ b/media/jni/android_media_ImageWriter.cpp
@@ -361,8 +361,7 @@
ALOGV("%s:", __FUNCTION__);
JNIImageWriterContext* const ctx = reinterpret_cast<JNIImageWriterContext *>(nativeCtx);
if (ctx == NULL || thiz == NULL) {
- jniThrowException(env, "java/lang/IllegalStateException",
- "ImageWriterContext is not initialized");
+ // ImageWriter is already closed.
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 79761ec..a496548 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -41,6 +41,7 @@
import android.database.ContentObserver;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
@@ -1396,6 +1397,7 @@
final StatusBarIcon ic = new StatusBarIcon(
entry.notification.getUser(),
+ entry.notification.getPackageName(),
entry.notification.getNotification().getSmallIcon(),
entry.notification.getNotification().iconLevel,
entry.notification.getNotification().number,
@@ -1682,10 +1684,11 @@
final StatusBarIcon ic = new StatusBarIcon(
sbn.getUser(),
- n.getSmallIcon(),
- n.iconLevel,
- n.number,
- n.tickerText);
+ sbn.getPackageName(),
+ n.getSmallIcon(),
+ n.iconLevel,
+ n.number,
+ n.tickerText);
if (!iconView.set(ic)) {
handleNotificationError(sbn, "Couldn't create icon: " + ic);
return null;
@@ -1825,6 +1828,7 @@
// Update the icon
final StatusBarIcon ic = new StatusBarIcon(
notification.getUser(),
+ notification.getPackageName(),
n.getSmallIcon(),
n.iconLevel,
n.number,
@@ -1847,6 +1851,7 @@
if (DEBUG) Log.d(TAG, "not reusing notification for key: " + key);
final StatusBarIcon ic = new StatusBarIcon(
notification.getUser(),
+ notification.getPackageName(),
n.getSmallIcon(),
n.iconLevel,
n.number,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
index dbabe3f..aedae52 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
@@ -125,16 +125,22 @@
@Override
public int compare(Entry a, Entry b) {
- String mediaNotification = mEnvironment.getCurrentMediaNotificationKey();
- boolean aMedia = a.key.equals(mediaNotification);
- boolean bMedia = b.key.equals(mediaNotification);
-
final StatusBarNotification na = a.notification;
final StatusBarNotification nb = b.notification;
+ final int aPriority = na.getNotification().priority;
+ final int bPriority = nb.getNotification().priority;
- boolean aSystemMax = na.getNotification().priority >= Notification.PRIORITY_MAX &&
+ String mediaNotification = mEnvironment.getCurrentMediaNotificationKey();
+
+ // PRIORITY_MIN media streams are allowed to drift to the bottom
+ final boolean aMedia = a.key.equals(mediaNotification)
+ && aPriority > Notification.PRIORITY_MIN;
+ final boolean bMedia = b.key.equals(mediaNotification)
+ && bPriority > Notification.PRIORITY_MIN;
+
+ boolean aSystemMax = aPriority >= Notification.PRIORITY_MAX &&
isSystemNotification(na);
- boolean bSystemMax = nb.getNotification().priority >= Notification.PRIORITY_MAX &&
+ boolean bSystemMax = bPriority >= Notification.PRIORITY_MAX &&
isSystemNotification(nb);
int d = nb.getScore() - na.getScore();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java
index 26d1c86..fcdd4b7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java
@@ -124,6 +124,9 @@
private void updateSlot(String slot, String iconPkg, int iconId) {
if (!mDemoMode) return;
+ if (iconPkg == null) {
+ iconPkg = mContext.getPackageName();
+ }
int removeIndex = -1;
for (int i = 0; i < getChildCount(); i++) {
StatusBarIconView v = (StatusBarIconView) getChildAt(i);
@@ -143,10 +146,10 @@
if (iconId == 0) {
if (removeIndex != -1) {
removeViewAt(removeIndex);
- return;
}
+ return;
}
- StatusBarIcon icon = new StatusBarIcon(iconPkg, UserHandle.CURRENT, iconId, 0, 0, "Demo");
+ StatusBarIcon icon = new StatusBarIcon(iconPkg, UserHandle.OWNER, iconId, 0, 0, "Demo");
StatusBarIconView v = new StatusBarIconView(getContext(), null, null);
v.setTag(slot);
v.set(icon);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 495f0fd..c30cb34 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -491,7 +491,7 @@
}
public void closeQs() {
- cancelAnimation();
+ cancelQsAnimation();
setQsExpansion(mQsMinExpansionHeight);
}
@@ -508,7 +508,7 @@
}
public void openQs() {
- cancelAnimation();
+ cancelQsAnimation();
if (mQsExpansionEnabled) {
setQsExpansion(mQsMaxExpansionHeight);
}
@@ -921,7 +921,7 @@
@Override
public void onOverscrollTopChanged(float amount, boolean isRubberbanded) {
- cancelAnimation();
+ cancelQsAnimation();
if (!mQsExpansionEnabled) {
amount = 0f;
}
@@ -953,7 +953,8 @@
}
private void onQsExpansionStarted(int overscrollAmount) {
- cancelAnimation();
+ cancelQsAnimation();
+ cancelHeightAnimator();
// Reset scroll position and apply that position to the expanded height.
float height = mQsExpansionHeight - mScrollView.getScrollY() - overscrollAmount;
@@ -1391,7 +1392,7 @@
return mVelocityTracker.getYVelocity();
}
- private void cancelAnimation() {
+ private void cancelQsAnimation() {
if (mQsExpansionAnimator != null) {
mQsExpansionAnimator.cancel();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 9d4997c..094d5f0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -535,7 +535,7 @@
*/
protected abstract boolean isInContentBounds(float x, float y);
- private void cancelHeightAnimator() {
+ protected void cancelHeightAnimator() {
if (mHeightAnimator != null) {
mHeightAnimator.cancel();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 69198ed..cd90d27 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -3460,6 +3460,7 @@
mKeyguardIndicationController.setVisible(true);
mNotificationPanel.resetViews();
mKeyguardUserSwitcher.setKeyguard(true, fromShadeLocked);
+ mStatusBarView.removePendingHideExpandedRunnables();
} else {
mKeyguardIndicationController.setVisible(false);
mKeyguardUserSwitcher.setKeyguard(false,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index dfd280a..6a46924 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -42,6 +42,12 @@
private ScrimController mScrimController;
private float mMinFraction;
private float mPanelFraction;
+ private Runnable mHideExpandedRunnable = new Runnable() {
+ @Override
+ public void run() {
+ mBar.makeExpandedInvisible();
+ }
+ };
public PhoneStatusBarView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -118,15 +124,14 @@
+ Log.getStackTraceString(new Throwable()));
}
// Close the status bar in the next frame so we can show the end of the animation.
- postOnAnimation(new Runnable() {
- @Override
- public void run() {
- mBar.makeExpandedInvisible();
- }
- });
+ postOnAnimation(mHideExpandedRunnable);
mLastFullyOpenedPanel = null;
}
+ public void removePendingHideExpandedRunnables() {
+ removeCallbacks(mHideExpandedRunnable);
+ }
+
@Override
public void onPanelFullyOpened(PanelView openPanel) {
super.onPanelFullyOpened(openPanel);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/AccessPointControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AccessPointControllerImpl.java
index 0eb7197..d1e4963 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/AccessPointControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AccessPointControllerImpl.java
@@ -116,7 +116,7 @@
// Unknown network, need to add it.
if (ap.getSecurity() != AccessPoint.SECURITY_NONE) {
Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
- intent.putExtra(EXTRA_START_CONNECT_SSID, ap.getSsid());
+ intent.putExtra(EXTRA_START_CONNECT_SSID, ap.getSsidStr());
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
fireSettingsIntentCallback(intent);
return true;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index 18b5820..1ba87da 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -408,7 +408,7 @@
boolean hasNoSims = mHasMobileDataFeature && mMobileSignalControllers.size() == 0;
if (hasNoSims != mHasNoSims) {
mHasNoSims = hasNoSims;
- notifyListeners();
+ mCallbackHandler.setNoSims(mHasNoSims);
}
}
@@ -660,8 +660,8 @@
}
String nosim = args.getString("nosim");
if (nosim != null) {
- boolean show = nosim.equals("show");
- mCallbackHandler.setNoSims(show);
+ mHasNoSims = nosim.equals("show");
+ mCallbackHandler.setNoSims(mHasNoSims);
}
String mobile = args.getString("mobile");
if (mobile != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index 1bf4547..5700732 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -228,6 +228,7 @@
private ScrimController mScrimController;
private boolean mForceNoOverlappingRendering;
private NotificationOverflowContainer mOverflowContainer;
+ private final ArrayList<Pair<ExpandableNotificationRow, Boolean>> mTmpList = new ArrayList<>();
public NotificationStackScrollLayout(Context context) {
this(context, null);
@@ -1608,7 +1609,7 @@
}
@Override
- protected void onViewRemoved(View child) {
+ public void onViewRemoved(View child) {
super.onViewRemoved(child);
// we only call our internal methods if this is actually a removal and not just a
// notification which becomes a child notification
@@ -1651,8 +1652,7 @@
* @return Whether an animation was generated.
*/
private boolean generateRemoveAnimation(View child) {
- if (mAddedHeadsUpChildren.contains(child)) {
- removeChildFromHeadsUpChangeAnimations(child);
+ if (removeRemovedChildFromHeadsUpChangeAnimations(child)) {
mAddedHeadsUpChildren.remove(child);
return false;
}
@@ -1671,15 +1671,27 @@
return false;
}
- private void removeChildFromHeadsUpChangeAnimations(View child) {
- ArrayList<Pair<ExpandableNotificationRow, Boolean> > toRemove = new ArrayList<>();
+ /**
+ * Remove a removed child view from the heads up animations if it was just added there
+ *
+ * @return whether any child was removed from the list to animate
+ */
+ private boolean removeRemovedChildFromHeadsUpChangeAnimations(View child) {
+ boolean hasAddEvent = false;
for (Pair<ExpandableNotificationRow, Boolean> eventPair : mHeadsUpChangeAnimations) {
ExpandableNotificationRow row = eventPair.first;
+ boolean isHeadsUp = eventPair.second;
if (child == row) {
- toRemove.add(eventPair);
+ mTmpList.add(eventPair);
+ hasAddEvent |= isHeadsUp;
}
}
- mHeadsUpChangeAnimations.removeAll(toRemove);
+ if (hasAddEvent) {
+ // This child was just added lets remove all events.
+ mHeadsUpChangeAnimations.removeAll(mTmpList);
+ }
+ mTmpList.clear();
+ return hasAddEvent;
}
/**
@@ -1745,7 +1757,7 @@
}
@Override
- protected void onViewAdded(View child) {
+ public void onViewAdded(View child) {
super.onViewAdded(child);
onViewAddedInternal(child);
}
diff --git a/packages/SystemUI/src/com/android/systemui/tuner/DemoModeFragment.java b/packages/SystemUI/src/com/android/systemui/tuner/DemoModeFragment.java
index d9f0598..ca6aaeb 100644
--- a/packages/SystemUI/src/com/android/systemui/tuner/DemoModeFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/tuner/DemoModeFragment.java
@@ -131,11 +131,14 @@
intent.putExtra("mobile", "show");
intent.putExtra("sims", "1");
intent.putExtra("nosim", "false");
- intent.putExtra("fully", "true");
intent.putExtra("level", "4");
intent.putExtra("datatypel", "");
getContext().sendBroadcast(intent);
+ // Need to send this after so that the sim controller already exists.
+ intent.putExtra("fully", "true");
+ getContext().sendBroadcast(intent);
+
intent.putExtra(DemoMode.EXTRA_COMMAND, DemoMode.COMMAND_BATTERY);
intent.putExtra("level", "100");
intent.putExtra("plugged", "false");
diff --git a/packages/SystemUI/src/com/android/systemui/volume/Events.java b/packages/SystemUI/src/com/android/systemui/volume/Events.java
index 12dca94..893c939 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/Events.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/Events.java
@@ -16,11 +16,13 @@
package com.android.systemui.volume;
+import android.content.Context;
import android.media.AudioManager;
import android.media.AudioSystem;
import android.provider.Settings.Global;
import android.util.Log;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.volume.VolumeDialogController.State;
import java.util.Arrays;
@@ -47,6 +49,7 @@
public static final int EVENT_ZEN_MODE_CHANGED = 13; // (mode|int)
public static final int EVENT_SUPPRESSOR_CHANGED = 14; // (component|string) (name|string)
public static final int EVENT_MUTE_CHANGED = 15; // (stream|int) (muted|bool)
+ public static final int EVENT_TOUCH_LEVEL_DONE = 16; // (stream|int) (level|bool)
private static final String[] EVENT_TAGS = {
"show_dialog",
@@ -65,6 +68,7 @@
"zen_mode_changed",
"suppressor_changed",
"mute_changed",
+ "touch_level_done",
};
public static final int DISMISS_REASON_UNKNOWN = 0;
@@ -100,36 +104,59 @@
public static Callback sCallback;
- public static void writeEvent(int tag, Object... list) {
+ public static void writeEvent(Context context, int tag, Object... list) {
final long time = System.currentTimeMillis();
final StringBuilder sb = new StringBuilder("writeEvent ").append(EVENT_TAGS[tag]);
if (list != null && list.length > 0) {
sb.append(" ");
switch (tag) {
case EVENT_SHOW_DIALOG:
+ MetricsLogger.visible(context, MetricsLogger.VOLUME_DIALOG);
+ MetricsLogger.histogram(context, "volume_from_keyguard",
+ (Boolean) list[1] ? 1 : 0);
sb.append(SHOW_REASONS[(Integer) list[0]]).append(" keyguard=").append(list[1]);
break;
case EVENT_EXPAND:
+ MetricsLogger.visibility(context, MetricsLogger.VOLUME_DIALOG_DETAILS,
+ (Boolean) list[0]);
sb.append(list[0]);
break;
case EVENT_DISMISS_DIALOG:
+ MetricsLogger.hidden(context, MetricsLogger.VOLUME_DIALOG);
sb.append(DISMISS_REASONS[(Integer) list[0]]);
break;
case EVENT_ACTIVE_STREAM_CHANGED:
+ MetricsLogger.action(context, MetricsLogger.ACTION_VOLUME_STREAM,
+ (Integer) list[0]);
sb.append(AudioSystem.streamToString((Integer) list[0]));
break;
case EVENT_ICON_CLICK:
+ MetricsLogger.action(context, MetricsLogger.ACTION_VOLUME_ICON,
+ (Integer) list[1]);
sb.append(AudioSystem.streamToString((Integer) list[0])).append(' ')
.append(iconStateToString((Integer) list[1]));
break;
+ case EVENT_TOUCH_LEVEL_DONE:
+ MetricsLogger.action(context, MetricsLogger.ACTION_VOLUME_SLIDER,
+ (Integer) list[1]);
+ // fall through
case EVENT_TOUCH_LEVEL_CHANGED:
case EVENT_LEVEL_CHANGED:
case EVENT_MUTE_CHANGED:
sb.append(AudioSystem.streamToString((Integer) list[0])).append(' ')
.append(list[1]);
break;
- case EVENT_INTERNAL_RINGER_MODE_CHANGED:
+ case EVENT_KEY:
+ MetricsLogger.action(context, MetricsLogger.ACTION_VOLUME_KEY,
+ (Integer) list[1]);
+ sb.append(AudioSystem.streamToString((Integer) list[0])).append(' ')
+ .append(list[1]);
+ break;
case EVENT_EXTERNAL_RINGER_MODE_CHANGED:
+ MetricsLogger.action(context, MetricsLogger.ACTION_RINGER_MODE,
+ (Integer) list[0]);
+ // fall through
+ case EVENT_INTERNAL_RINGER_MODE_CHANGED:
sb.append(ringerModeToString((Integer) list[0]));
break;
case EVENT_ZEN_MODE_CHANGED:
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
index aa891b6..5b2eb84 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
@@ -369,7 +369,7 @@
row.icon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- Events.writeEvent(Events.EVENT_ICON_CLICK, row.stream, row.iconState);
+ Events.writeEvent(mContext, Events.EVENT_ICON_CLICK, row.stream, row.iconState);
mController.setActiveStream(row.stream);
if (row.stream == AudioManager.STREAM_RING) {
final boolean hasVibrator = mController.hasVibrator();
@@ -417,7 +417,7 @@
if (mShowing) return;
mShowing = true;
mDialog.show();
- Events.writeEvent(Events.EVENT_SHOW_DIALOG, reason, mKeyguard.isKeyguardLocked());
+ Events.writeEvent(mContext, Events.EVENT_SHOW_DIALOG, reason, mKeyguard.isKeyguardLocked());
mController.notifyVisible(true);
}
@@ -444,7 +444,7 @@
if (!mShowing) return;
mShowing = false;
mDialog.dismiss();
- Events.writeEvent(Events.EVENT_DISMISS_DIALOG, reason);
+ Events.writeEvent(mContext, Events.EVENT_DISMISS_DIALOG, reason);
setExpandedH(false);
mController.notifyVisible(false);
synchronized (mSafetyWarningLock) {
@@ -834,7 +834,7 @@
public void onClick(View v) {
if (mExpanding) return;
final boolean newExpand = !mExpanded;
- Events.writeEvent(Events.EVENT_EXPAND, v);
+ Events.writeEvent(mContext, Events.EVENT_EXPAND, newExpand);
setExpandedH(newExpand);
}
};
@@ -845,7 +845,7 @@
mSettingsButton.postDelayed(new Runnable() {
@Override
public void run() {
- Events.writeEvent(Events.EVENT_SETTINGS_CLICK);
+ Events.writeEvent(mContext, Events.EVENT_SETTINGS_CLICK);
if (mCallback != null) {
mCallback.onSettingsClicked();
}
@@ -933,7 +933,8 @@
if (mRow.requestedLevel != userLevel) {
mController.setStreamVolume(mRow.stream, userLevel);
mRow.requestedLevel = userLevel;
- Events.writeEvent(Events.EVENT_TOUCH_LEVEL_CHANGED, mRow.stream, userLevel);
+ Events.writeEvent(mContext, Events.EVENT_TOUCH_LEVEL_CHANGED, mRow.stream,
+ userLevel);
}
}
}
@@ -951,6 +952,7 @@
mRow.tracking = false;
mRow.userAttempt = SystemClock.uptimeMillis();
int userLevel = getImpliedLevel(seekBar, seekBar.getProgress());
+ Events.writeEvent(mContext, Events.EVENT_TOUCH_LEVEL_DONE, mRow.stream, userLevel);
if (mRow.ss.level != userLevel) {
mHandler.sendMessageDelayed(mHandler.obtainMessage(H.RECHECK, mRow),
USER_ATTEMPT_GRACE_PERIOD);
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java
index c6d9e46..9a59a2a 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java
@@ -104,7 +104,7 @@
public VolumeDialogController(Context context, ComponentName component) {
mContext = context.getApplicationContext();
- Events.writeEvent(Events.EVENT_COLLECTION_STARTED);
+ Events.writeEvent(mContext, Events.EVENT_COLLECTION_STARTED);
mComponent = component;
mWorkerThread = new HandlerThread(VolumeDialogController.class.getSimpleName());
mWorkerThread.start();
@@ -168,7 +168,7 @@
if (D.BUG) Log.d(TAG, "destroy");
if (mDestroyed) return;
mDestroyed = true;
- Events.writeEvent(Events.EVENT_COLLECTION_STOPPED);
+ Events.writeEvent(mContext, Events.EVENT_COLLECTION_STOPPED);
mMediaSessions.destroy();
mObserver.destroy();
mReceiver.destroy();
@@ -293,7 +293,8 @@
if (showUI) {
changed |= updateActiveStreamW(stream);
}
- changed |= updateStreamLevelW(stream, mAudio.getLastAudibleStreamVolume(stream));
+ int lastAudibleStreamVolume = mAudio.getLastAudibleStreamVolume(stream);
+ changed |= updateStreamLevelW(stream, lastAudibleStreamVolume);
changed |= checkRoutedToBluetoothW(showUI ? AudioManager.STREAM_MUSIC : stream);
if (changed) {
mCallbacks.onStateChanged(mState);
@@ -308,14 +309,14 @@
mCallbacks.onShowSilentHint();
}
if (changed && fromKey) {
- Events.writeEvent(Events.EVENT_KEY);
+ Events.writeEvent(mContext, Events.EVENT_KEY, stream, lastAudibleStreamVolume);
}
}
private boolean updateActiveStreamW(int activeStream) {
if (activeStream == mState.activeStream) return false;
mState.activeStream = activeStream;
- Events.writeEvent(Events.EVENT_ACTIVE_STREAM_CHANGED, activeStream);
+ Events.writeEvent(mContext, Events.EVENT_ACTIVE_STREAM_CHANGED, activeStream);
if (D.BUG) Log.d(TAG, "updateActiveStreamW " + activeStream);
final int s = activeStream < DYNAMIC_STREAM_START_INDEX ? activeStream : -1;
if (D.BUG) Log.d(TAG, "forceVolumeControlStream " + s);
@@ -364,7 +365,7 @@
if (ss.level == level) return false;
ss.level = level;
if (isLogWorthy(stream)) {
- Events.writeEvent(Events.EVENT_LEVEL_CHANGED, stream, level);
+ Events.writeEvent(mContext, Events.EVENT_LEVEL_CHANGED, stream, level);
}
return true;
}
@@ -387,7 +388,7 @@
if (ss.muted == muted) return false;
ss.muted = muted;
if (isLogWorthy(stream)) {
- Events.writeEvent(Events.EVENT_MUTE_CHANGED, stream, muted);
+ Events.writeEvent(mContext, Events.EVENT_MUTE_CHANGED, stream, muted);
}
if (muted && isRinger(stream)) {
updateRingerModeInternalW(mAudio.getRingerModeInternal());
@@ -410,7 +411,7 @@
if (Objects.equals(mState.effectsSuppressor, effectsSuppressor)) return false;
mState.effectsSuppressor = effectsSuppressor;
mState.effectsSuppressorName = getApplicationName(mContext, mState.effectsSuppressor);
- Events.writeEvent(Events.EVENT_SUPPRESSOR_CHANGED, mState.effectsSuppressor,
+ Events.writeEvent(mContext, Events.EVENT_SUPPRESSOR_CHANGED, mState.effectsSuppressor,
mState.effectsSuppressorName);
return true;
}
@@ -434,21 +435,21 @@
Settings.Global.ZEN_MODE, Settings.Global.ZEN_MODE_OFF);
if (mState.zenMode == zen) return false;
mState.zenMode = zen;
- Events.writeEvent(Events.EVENT_ZEN_MODE_CHANGED, zen);
+ Events.writeEvent(mContext, Events.EVENT_ZEN_MODE_CHANGED, zen);
return true;
}
private boolean updateRingerModeExternalW(int rm) {
if (rm == mState.ringerModeExternal) return false;
mState.ringerModeExternal = rm;
- Events.writeEvent(Events.EVENT_EXTERNAL_RINGER_MODE_CHANGED, rm);
+ Events.writeEvent(mContext, Events.EVENT_EXTERNAL_RINGER_MODE_CHANGED, rm);
return true;
}
private boolean updateRingerModeInternalW(int rm) {
if (rm == mState.ringerModeInternal) return false;
mState.ringerModeInternal = rm;
- Events.writeEvent(Events.EVENT_INTERNAL_RINGER_MODE_CHANGED, rm);
+ Events.writeEvent(mContext, Events.EVENT_INTERNAL_RINGER_MODE_CHANGED, rm);
return true;
}
diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
index b737de3..30680ed 100644
--- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
+++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
@@ -1298,7 +1298,7 @@
synchronized (mLock) {
ensureGroupStateLoadedLocked(userId);
- ArrayList<AppWidgetProviderInfo> result = null;
+ ArrayList<AppWidgetProviderInfo> result = new ArrayList<AppWidgetProviderInfo>();
final int providerCount = mProviders.size();
for (int i = 0; i < providerCount; i++) {
@@ -1315,9 +1315,6 @@
if (providerProfileId == profileId
&& mSecurityPolicy.isProviderInCallerOrInProfileAndWhitelListed(
provider.id.componentName.getPackageName(), providerProfileId)) {
- if (result == null) {
- result = new ArrayList<>();
- }
result.add(cloneIfLocalBinder(info));
}
}
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index c76fc1c..743aafb 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -1958,6 +1958,27 @@
return p.getProperties();
}
+ /**
+ * @return null if the provider does not exist
+ * @throws SecurityException if the provider is not allowed to be
+ * accessed by the caller
+ */
+ @Override
+ public String getNetworkProviderPackage() {
+ LocationProviderInterface p;
+ synchronized (mLock) {
+ if (mProvidersByName.get(LocationManager.NETWORK_PROVIDER) == null) {
+ return null;
+ }
+ p = mProvidersByName.get(LocationManager.NETWORK_PROVIDER);
+ }
+
+ if (p instanceof LocationProviderProxy) {
+ return ((LocationProviderProxy) p).getConnectedPackageName();
+ }
+ return null;
+ }
+
@Override
public boolean isProviderEnabled(String provider) {
// Fused provider is accessed indirectly via criteria rather than the provider-based APIs,
diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java
index 236af37..87cb40e 100644
--- a/services/core/java/com/android/server/am/ServiceRecord.java
+++ b/services/core/java/com/android/server/am/ServiceRecord.java
@@ -445,6 +445,11 @@
// icon, but this used to be able to slip through, so for
// those dirty apps we will create a notification clearly
// blaming the app.
+ Slog.v(TAG, "Attempted to start a foreground service ("
+ + name
+ + ") with a broken notification (no icon: "
+ + localForegroundNoti
+ + ")");
CharSequence appName = appInfo.loadLabel(
ams.mContext.getPackageManager());
@@ -461,6 +466,12 @@
// it's ugly, but it clearly identifies the app
notiBuilder.setSmallIcon(appInfo.icon);
+ // mark as foreground
+ notiBuilder.setFlag(Notification.FLAG_FOREGROUND_SERVICE, true);
+
+ // we are doing the app a kindness here
+ notiBuilder.setPriority(Notification.PRIORITY_MIN);
+
Intent runningIntent = new Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
runningIntent.setData(Uri.fromParts("package",
@@ -498,6 +509,8 @@
nm.enqueueNotification(localPackageName, localPackageName,
appUid, appPid, null, localForegroundId, localForegroundNoti,
outId, userId);
+
+ foregroundNoti = localForegroundNoti; // save it for amending next time
} catch (RuntimeException e) {
Slog.w(TAG, "Error showing notification for service", e);
// If it gave us a garbage notification, it doesn't
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index d39b25f..47d3bde 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -1542,11 +1542,7 @@
// UI update and Broadcast Intent
private void sendVolumeUpdate(int streamType, int oldIndex, int index, int flags) {
- if (!isPlatformVoice() && (streamType == AudioSystem.STREAM_RING)) {
- streamType = AudioSystem.STREAM_NOTIFICATION;
- } else {
- streamType = mStreamVolumeAlias[streamType];
- }
+ streamType = mStreamVolumeAlias[streamType];
if (streamType == AudioSystem.STREAM_MUSIC) {
flags = updateFlagsForSystemAudio(flags);
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index dbcfa19..6fb9a5c 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -3739,13 +3739,14 @@
attrs.gravity = Gravity.BOTTOM;
mDockLayer = win.getSurfaceLayer();
} else if (attrs.type == TYPE_VOICE_INTERACTION) {
- pf.left = df.left = of.left = cf.left = vf.left = mUnrestrictedScreenLeft;
+ pf.left = df.left = of.left = mUnrestrictedScreenLeft;
pf.top = df.top = of.top = mUnrestrictedScreenTop;
- pf.right = df.right = of.right = cf.right = vf.right = mUnrestrictedScreenLeft
- + mUnrestrictedScreenWidth;
- pf.bottom = df.bottom = of.bottom = cf.bottom = mUnrestrictedScreenTop
- + mUnrestrictedScreenHeight;
+ pf.right = df.right = of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth;
+ pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
cf.bottom = vf.bottom = mStableBottom;
+ // Note: In Phone landscape mode, the button bar should also be excluded.
+ cf.right = vf.right = mStableRight;
+ cf.left = vf.left = mStableLeft;
cf.top = vf.top = mStableTop;
} else if (win == mStatusBar) {
pf.left = df.left = of.left = mUnrestrictedScreenLeft;
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index e085d89..fa1ed54 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -1124,13 +1124,14 @@
* {@hide}
*/
public static int getSimStateForSlotIdx(int slotIdx) {
- int simState;
+ int simState = TelephonyManager.SIM_STATE_UNKNOWN;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
- simState = iSub.getSimStateForSlotIdx(slotIdx);
+ if (iSub != null) {
+ simState = iSub.getSimStateForSlotIdx(slotIdx);
+ }
} catch (RemoteException ex) {
- simState = TelephonyManager.SIM_STATE_UNKNOWN;
}
logd("getSimStateForSubscriber: simState=" + simState + " slotIdx=" + slotIdx);
return simState;
@@ -1144,7 +1145,9 @@
public boolean isActiveSubId(int subId) {
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
- return iSub.isActiveSubId(subId);
+ if (iSub != null) {
+ return iSub.isActiveSubId(subId);
+ }
} catch (RemoteException ex) {
}
return false;
diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable04.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable04.xml
index d282fc9..0f3fb95 100644
--- a/tests/VectorDrawableTest/res/drawable/vector_drawable04.xml
+++ b/tests/VectorDrawableTest/res/drawable/vector_drawable04.xml
@@ -13,37 +13,41 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="64dp"
- android:height="64dp"
- android:viewportWidth="7.30625"
- android:viewportHeight="12.25"
- android:autoMirrored="true">
+ android:autoMirrored="true"
+ android:height="64dp"
+ android:viewportHeight="12.25"
+ android:viewportWidth="7.30625"
+ android:width="64dp" >
<group>
<clip-path
- android:name="clip1"
- android:pathData="
+ android:name="clip1"
+ android:pathData="
M 3.65, 6.125
m-.001, 0
a .001,.001 0 1,0 .002,0
- a .001,.001 0 1,0-.002,0z"/>
- <path
- android:name="one"
- android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0-6.671875-2.109375,0.421875 0.0-1.078125
- l 2.09375-0.421875 1.1874998,0.0 0.0,7.75 1.9375,0.0 0.0,1.0
- l-5.046875,0.0 0.0-1.0Z"
- android:fillColor="#ff88ff"/>
+ a .001,.001 0 1,0-.002,0z" />
+ <path
+ android:name="one"
+ android:fillColor="#ff88ff"
+ android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0-6.671875-2.109375,0.421875 0.0-1.078125
+ l 2.09375-0.421875 1.1874998,0.0 0.0,7.75 1.9375,0.0 0.0,1.0
+ l-5.046875,0.0 0.0-1.0Z" />
+ </group>
+ <group>
<clip-path
- android:name="clip2"
- android:pathData="
+ android:name="clip2"
+ android:pathData="
M 3.65, 6.125
m-6, 0
a 6,6 0 1,0 12,0
- a 6,6 0 1,0-12,0z"/>
+ a 6,6 0 1,0-12,0z" />
+
<path
- android:name="two"
- android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0-5.5625,0.0 0.0-1.0q 0.671875-0.6875 1.828125-1.859375
+ android:name="two"
+ android:fillColor="#ff88ff"
+ android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0-5.5625,0.0 0.0-1.0q 0.671875-0.6875 1.828125-1.859375
q 1.1718752-1.1875 1.4687502-1.53125 0.578125-0.625 0.796875-1.0625
q 0.234375-0.453125 0.234375-0.875 0.0-0.703125-0.5-1.140625
q-0.484375-0.4375-1.2656252-0.4375-0.5625,0.0-1.1875,0.1875
@@ -51,7 +55,7 @@
q 0.625-0.15625 1.140625-0.15625 1.3593752,0.0 2.1718752,0.6875
q 0.8125,0.671875 0.8125,1.8125 0.0,0.53125-0.203125,1.015625
q-0.203125,0.484375-0.734375,1.140625-0.15625,0.171875-0.9375,0.984375
- q-0.78125024,0.8125-2.2187502,2.265625Z"
- android:fillColor="#ff88ff"/>
+ q-0.78125024,0.8125-2.2187502,2.265625Z" />
</group>
-</vector>
+
+</vector>
\ No newline at end of file
diff --git a/tools/aapt2/BinaryResourceParser.cpp b/tools/aapt2/BinaryResourceParser.cpp
index 3559f43..4f1947a 100644
--- a/tools/aapt2/BinaryResourceParser.cpp
+++ b/tools/aapt2/BinaryResourceParser.cpp
@@ -116,9 +116,11 @@
BinaryResourceParser::BinaryResourceParser(const std::shared_ptr<ResourceTable>& table,
const std::shared_ptr<IResolver>& resolver,
const Source& source,
+ const std::u16string& defaultPackage,
const void* data,
size_t len) :
- mTable(table), mResolver(resolver), mSource(source), mData(data), mDataLen(len) {
+ mTable(table), mResolver(resolver), mSource(source), mDefaultPackage(defaultPackage),
+ mData(data), mDataLen(len) {
}
bool BinaryResourceParser::parse() {
@@ -177,6 +179,9 @@
if (!type) {
return false;
}
+ if (outSymbol->package.empty()) {
+ outSymbol->package = mTable->getPackage();
+ }
outSymbol->type = *type;
// Since we scan the symbol table in order, we can start looking for the
@@ -350,7 +355,22 @@
size_t len = strnlen16(reinterpret_cast<const char16_t*>(packageHeader->name),
sizeof(packageHeader->name) / sizeof(packageHeader->name[0]));
- mTable->setPackage(StringPiece16(reinterpret_cast<const char16_t*>(packageHeader->name), len));
+ if (mTable->getPackage().empty() && len == 0) {
+ mTable->setPackage(mDefaultPackage);
+ } else if (len > 0) {
+ StringPiece16 thisPackage(reinterpret_cast<const char16_t*>(packageHeader->name), len);
+ if (mTable->getPackage().empty()) {
+ mTable->setPackage(thisPackage);
+ } else if (thisPackage != mTable->getPackage()) {
+ Logger::error(mSource)
+ << "incompatible packages: "
+ << mTable->getPackage()
+ << " vs. "
+ << thisPackage
+ << std::endl;
+ return false;
+ }
+ }
ResChunkPullParser parser(getChunkData(packageHeader->header),
getChunkDataLen(packageHeader->header));
diff --git a/tools/aapt2/BinaryResourceParser.h b/tools/aapt2/BinaryResourceParser.h
index 32876cd..3aab301 100644
--- a/tools/aapt2/BinaryResourceParser.h
+++ b/tools/aapt2/BinaryResourceParser.h
@@ -45,6 +45,7 @@
BinaryResourceParser(const std::shared_ptr<ResourceTable>& table,
const std::shared_ptr<IResolver>& resolver,
const Source& source,
+ const std::u16string& defaultPackage,
const void* data, size_t len);
BinaryResourceParser(const BinaryResourceParser&) = delete; // No copy.
@@ -97,12 +98,12 @@
const Source mSource;
+ // The package name of the resource table.
+ std::u16string mDefaultPackage;
+
const void* mData;
const size_t mDataLen;
- // The package name of the resource table.
- std::u16string mPackage;
-
// The array of symbol entries. Each element points to an offset
// in the table and an index into the symbol table string pool.
const SymbolTable_entry* mSymbolEntries = nullptr;
diff --git a/tools/aapt2/Linker.cpp b/tools/aapt2/Linker.cpp
index f3f04a5..c37cc93 100644
--- a/tools/aapt2/Linker.cpp
+++ b/tools/aapt2/Linker.cpp
@@ -160,7 +160,7 @@
void Linker::visit(Reference& reference, ValueVisitorArgs& a) {
Args& args = static_cast<Args&>(a);
- if (!reference.name.isValid()) {
+ if (reference.name.entry.empty()) {
// We can't have a completely bad reference.
if (!reference.id.isValid()) {
Logger::error() << "srsly? " << args.referrer << std::endl;
diff --git a/tools/aapt2/Main.cpp b/tools/aapt2/Main.cpp
index 41c229d..54a7329 100644
--- a/tools/aapt2/Main.cpp
+++ b/tools/aapt2/Main.cpp
@@ -756,8 +756,8 @@
zipFile->uncompress(entry));
assert(uncompressedData);
- BinaryResourceParser parser(table, resolver, source, uncompressedData.get(),
- entry->getUncompressedLen());
+ BinaryResourceParser parser(table, resolver, source, options.appInfo.package,
+ uncompressedData.get(), entry->getUncompressedLen());
if (!parser.parse()) {
return false;
}
@@ -1085,50 +1085,47 @@
}
bool isStaticLib = false;
+ if (options.phase == AaptOptions::Phase::Link) {
+ flag::requiredFlag("--manifest", "AndroidManifest.xml of your app",
+ [&options](const StringPiece& arg) {
+ options.manifest = Source{ arg.toString() };
+ });
+
+ flag::optionalFlag("-I", "add an Android APK to link against",
+ [&options](const StringPiece& arg) {
+ options.libraries.push_back(Source{ arg.toString() });
+ });
+
+ flag::optionalFlag("--java", "directory in which to generate R.java",
+ [&options](const StringPiece& arg) {
+ options.generateJavaClass = Source{ arg.toString() };
+ });
+
+ flag::optionalFlag("--proguard", "file in which to output proguard rules",
+ [&options](const StringPiece& arg) {
+ options.generateProguardRules = Source{ arg.toString() };
+ });
+
+ flag::optionalSwitch("--static-lib", "generate a static Android library", true,
+ &isStaticLib);
+
+ flag::optionalFlag("--binding", "Output directory for binding XML files",
+ [&options](const StringPiece& arg) {
+ options.bindingOutput = Source{ arg.toString() };
+ });
+ flag::optionalSwitch("--no-version", "Disables automatic style and layout versioning",
+ false, &options.versionStylesAndLayouts);
+ }
+
if (options.phase == AaptOptions::Phase::Compile ||
options.phase == AaptOptions::Phase::Link) {
- if (options.phase == AaptOptions::Phase::Compile) {
- flag::requiredFlag("--package", "Android package name",
- [&options](const StringPiece& arg) {
- options.appInfo.package = util::utf8ToUtf16(arg);
- });
- } else if (options.phase == AaptOptions::Phase::Link) {
- flag::requiredFlag("--manifest", "AndroidManifest.xml of your app",
- [&options](const StringPiece& arg) {
- options.manifest = Source{ arg.toString() };
- });
-
- flag::optionalFlag("-I", "add an Android APK to link against",
- [&options](const StringPiece& arg) {
- options.libraries.push_back(Source{ arg.toString() });
- });
-
- flag::optionalFlag("--java", "directory in which to generate R.java",
- [&options](const StringPiece& arg) {
- options.generateJavaClass = Source{ arg.toString() };
- });
-
- flag::optionalFlag("--proguard", "file in which to output proguard rules",
- [&options](const StringPiece& arg) {
- options.generateProguardRules = Source{ arg.toString() };
- });
-
- flag::optionalSwitch("--static-lib", "generate a static Android library", true,
- &isStaticLib);
-
- flag::optionalFlag("--binding", "Output directory for binding XML files",
- [&options](const StringPiece& arg) {
- options.bindingOutput = Source{ arg.toString() };
- });
- flag::optionalSwitch("--no-version", "Disables automatic style and layout versioning",
- false, &options.versionStylesAndLayouts);
- }
-
// Common flags for all steps.
flag::requiredFlag("-o", "Output path", [&options](const StringPiece& arg) {
options.output = Source{ arg.toString() };
});
- } else if (options.phase == AaptOptions::Phase::DumpStyleGraph) {
+ }
+
+ if (options.phase == AaptOptions::Phase::DumpStyleGraph) {
flag::requiredFlag("--style", "Name of the style to dump",
[&options](const StringPiece& arg, std::string* outError) -> bool {
Reference styleReference;
@@ -1191,7 +1188,7 @@
zipFile->uncompress(entry));
assert(uncompressedData);
- BinaryResourceParser parser(table, resolver, source, uncompressedData.get(),
+ BinaryResourceParser parser(table, resolver, source, {}, uncompressedData.get(),
entry->getUncompressedLen());
if (!parser.parse()) {
return false;
@@ -1223,16 +1220,17 @@
if (!loadAppInfo(options.manifest, &options.appInfo)) {
return false;
}
- }
- // Verify we have some common options set.
- if (options.appInfo.package.empty()) {
- Logger::error() << "no package name specified." << std::endl;
- return false;
+ if (options.appInfo.package.empty()) {
+ Logger::error() << "no package name specified." << std::endl;
+ return false;
+ }
}
// Every phase needs a resource table.
std::shared_ptr<ResourceTable> table = std::make_shared<ResourceTable>();
+
+ // The package name is empty when in the compile phase.
table->setPackage(options.appInfo.package);
if (options.appInfo.package == u"android") {
table->setPackageId(0x01);
diff --git a/tools/aapt2/TableFlattener.cpp b/tools/aapt2/TableFlattener.cpp
index 539c48f..b7c04f0 100644
--- a/tools/aapt2/TableFlattener.cpp
+++ b/tools/aapt2/TableFlattener.cpp
@@ -79,7 +79,7 @@
// Write the key.
if (!Res_INTERNALID(key.id.id) && !key.id.isValid()) {
- assert(key.name.isValid());
+ assert(!key.name.entry.empty());
mSymbols->push_back(std::make_pair(ResourceNameRef(key.name),
mOut->size() - sizeof(*outMapEntry)));
}
@@ -284,13 +284,6 @@
bool TableFlattener::flatten(BigBuffer* out, const ResourceTable& table) {
const size_t beginning = out->size();
- if (table.getPackage().size() == 0) {
- Logger::error()
- << "ResourceTable has no package name."
- << std::endl;
- return false;
- }
-
if (table.getPackageId() == ResourceTable::kUnsetPackageId) {
Logger::error()
<< "ResourceTable has no package ID set."
diff --git a/tools/aapt2/data/Makefile b/tools/aapt2/data/Makefile
index 3387135..91ff5fe 100644
--- a/tools/aapt2/data/Makefile
+++ b/tools/aapt2/data/Makefile
@@ -50,7 +50,7 @@
# returns: out/values-v4.apk: res/values-v4/styles.xml res/values-v4/colors.xml
define make-collect-rule
$(LOCAL_OUT)/$1.apk: $(filter $(LOCAL_RESOURCE_DIR)/$1/%,$(PRIVATE_RESOURCES))
- $(AAPT) compile --package $(LOCAL_PACKAGE) -o $$@ $$^
+ $(AAPT) compile -o $$@ $$^
endef
# Collect: out/values-v4.apk <- res/values-v4/styles.xml res/values-v4/colors.xml
diff --git a/tools/aapt2/data/lib/Makefile b/tools/aapt2/data/lib/Makefile
index 372c225..741be9a 100644
--- a/tools/aapt2/data/lib/Makefile
+++ b/tools/aapt2/data/lib/Makefile
@@ -48,7 +48,7 @@
# returns: out/values-v4.apk: res/values-v4/styles.xml res/values-v4/colors.xml
define make-collect-rule
$(LOCAL_OUT)/$1.apk: $(filter $(LOCAL_RESOURCE_DIR)/$1/%,$(PRIVATE_RESOURCES))
- $(AAPT) compile --package $(LOCAL_PACKAGE) -o $$@ $$^
+ $(AAPT) compile -o $$@ $$^
endef
# Collect: out/values-v4.apk <- res/values-v4/styles.xml res/values-v4/colors.xml