From fa56915f167f1fe266ee2bf854043874613e1991 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Mon, 4 May 2015 12:29:50 -0700 Subject: Call Activity#onAttachFragment() This was accidentally removed during the changes to abstract a Fragment host. Also ensure Fragment#onInflate(Activity) gets invoked Bug: 20825263 Change-Id: I981266ae1e8817db5c82ec4609bbcf4a5e676fee --- api/current.txt | 1 + api/system-current.txt | 1 + core/java/android/app/Activity.java | 5 +++++ core/java/android/app/Fragment.java | 6 ++++++ core/java/android/app/FragmentHostCallback.java | 17 ++++++++--------- core/java/android/app/FragmentManager.java | 8 ++++---- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/api/current.txt b/api/current.txt index 07a4ff7da447..e3bb0b8dc4aa 100644 --- a/api/current.txt +++ b/api/current.txt @@ -4495,6 +4495,7 @@ package android.app { public abstract class FragmentHostCallback extends android.app.FragmentContainer { ctor public FragmentHostCallback(android.content.Context, android.os.Handler, int); + method public void onAttachFragment(android.app.Fragment); method public void onDump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]); method public android.view.View onFindViewById(int); method public abstract E onGetHost(); diff --git a/api/system-current.txt b/api/system-current.txt index 288044611013..6ccaa9d36c05 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4585,6 +4585,7 @@ package android.app { public abstract class FragmentHostCallback extends android.app.FragmentContainer { ctor public FragmentHostCallback(android.content.Context, android.os.Handler, int); + method public void onAttachFragment(android.app.Fragment); method public void onDump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]); method public android.view.View onFindViewById(int); method public abstract E onGetHost(); diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index afbddd94531c..7260d1027660 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -6498,6 +6498,11 @@ public class Activity extends ContextThemeWrapper return (w == null) ? 0 : w.getAttributes().windowAnimations; } + @Override + public void onAttachFragment(Fragment fragment) { + Activity.this.onAttachFragment(fragment); + } + @Nullable @Override public View onFindViewById(int id) { diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java index 91d810e7bae4..40c5c6442195 100644 --- a/core/java/android/app/Fragment.java +++ b/core/java/android/app/Fragment.java @@ -1314,6 +1314,12 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene com.android.internal.R.styleable.Fragment_fragmentAllowReturnTransitionOverlap, true); } a.recycle(); + + final Activity hostActivity = mHost == null ? null : mHost.getActivity(); + if (hostActivity != null) { + mCalled = false; + onInflate(hostActivity, attrs, savedInstanceState); + } } /** diff --git a/core/java/android/app/FragmentHostCallback.java b/core/java/android/app/FragmentHostCallback.java index dad2c79e52c2..3e753f09c15c 100644 --- a/core/java/android/app/FragmentHostCallback.java +++ b/core/java/android/app/FragmentHostCallback.java @@ -23,7 +23,6 @@ import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.util.ArrayMap; -import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; @@ -140,6 +139,14 @@ public abstract class FragmentHostCallback extends FragmentContainer { return mWindowAnimations; } + /** + * Called when a {@link Fragment} is being attached to this host, immediately + * after the call to its {@link Fragment#onAttach(Context)} method and before + * {@link Fragment#onCreate(Bundle)}. + */ + public void onAttachFragment(Fragment fragment) { + } + @Nullable @Override public View onFindViewById(int id) { @@ -187,14 +194,6 @@ public abstract class FragmentHostCallback extends FragmentContainer { } } - void onFragmentInflate(Fragment fragment, AttributeSet attrs, Bundle savedInstanceState) { - fragment.onInflate(mContext, attrs, savedInstanceState); - } - - void onFragmentAttach(Fragment fragment) { - fragment.onAttach(mContext); - } - void doLoaderStart() { if (mLoadersStarted) { return; diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java index 62436e985052..6b5239d26ee1 100644 --- a/core/java/android/app/FragmentManager.java +++ b/core/java/android/app/FragmentManager.java @@ -844,13 +844,13 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate f.mFragmentManager = mParent != null ? mParent.mChildFragmentManager : mHost.getFragmentManagerImpl(); f.mCalled = false; - mHost.onFragmentAttach(f); + f.onAttach(mHost.getContext()); if (!f.mCalled) { throw new SuperNotCalledException("Fragment " + f + " did not call through to super.onAttach()"); } if (f.mParentFragment == null) { - mHost.onFragmentAttach(f); + mHost.onAttachFragment(f); } if (!f.mRetaining) { @@ -2107,7 +2107,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate fragment.mTag = tag; fragment.mInLayout = true; fragment.mFragmentManager = this; - mHost.onFragmentInflate(fragment, attrs, fragment.mSavedFragmentState); + fragment.onInflate(mHost.getContext(), attrs, fragment.mSavedFragmentState); addFragment(fragment, true); } else if (fragment.mInLayout) { // A fragment already exists and it is not one we restored from @@ -2124,7 +2124,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate // from last saved state), then give it the attributes to // initialize itself. if (!fragment.mRetaining) { - mHost.onFragmentInflate(fragment, attrs, fragment.mSavedFragmentState); + fragment.onInflate(mHost.getContext(), attrs, fragment.mSavedFragmentState); } } -- cgit v1.2.3-59-g8ed1b From 6440b66ff33507b5175bf7a3fe264ea8ea046d20 Mon Sep 17 00:00:00 2001 From: Maxim Siniavine Date: Tue, 5 May 2015 12:00:24 -0700 Subject: Update permissions on memory usage instrumentation Change-Id: I0c2bbd893252eb1dc3cf8b93b787efd772317216 --- tests/MemoryUsage/AndroidManifest.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/MemoryUsage/AndroidManifest.xml b/tests/MemoryUsage/AndroidManifest.xml index 3932e5b9fb09..cd559c547dd0 100644 --- a/tests/MemoryUsage/AndroidManifest.xml +++ b/tests/MemoryUsage/AndroidManifest.xml @@ -6,7 +6,9 @@ android:name="com.android.tests.memoryusage.MemoryUsageInstrumentation" android:targetPackage="com.android.tests.memoryusage" /> + + - \ No newline at end of file + -- cgit v1.2.3-59-g8ed1b From f01684336c715cc542124232388d735ec7a08aad Mon Sep 17 00:00:00 2001 From: John Reck Date: Wed, 6 May 2015 14:55:05 -0700 Subject: Add warning if an in-use Bitmap is reconfigured Bug: 18928352 Also fix an issue around re-configure not properly handling mPinnedCount in android::Bitmap Change-Id: I1815b121f1474ad931060771bb1d52ef31d2aac7 --- core/jni/android/graphics/Bitmap.cpp | 53 +++++++++++++++++++---------- core/jni/android/graphics/Bitmap.h | 4 ++- core/jni/android/graphics/BitmapFactory.cpp | 4 +-- core/jni/android/graphics/Graphics.cpp | 4 +-- core/jni/android/graphics/GraphicsJNI.h | 2 +- core/jni/android_view_SurfaceControl.cpp | 2 +- native/graphics/jni/bitmap.cpp | 12 +++++-- 7 files changed, 53 insertions(+), 28 deletions(-) diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index 8ae2e3b51e96..9babe827ce97 100755 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -188,18 +188,43 @@ size_t Bitmap::rowBytes() const { return mPixelRef->rowBytes(); } -SkPixelRef* Bitmap::pixelRef() const { +SkPixelRef* Bitmap::peekAtPixelRef() const { assertValid(); return mPixelRef.get(); } +SkPixelRef* Bitmap::refPixelRef() { + assertValid(); + android::AutoMutex _lock(mLock); + return refPixelRefLocked(); +} + +SkPixelRef* Bitmap::refPixelRefLocked() { + mPixelRef->ref(); + if (mPixelRef->unique()) { + // We just restored this from 0, pin the pixels and inc the strong count + // Note that there *might be* an incoming onStrongRefDestroyed from whatever + // last unref'd + pinPixelsLocked(); + mPinnedRefCount++; + } + return mPixelRef.get(); +} + void Bitmap::reconfigure(const SkImageInfo& info, size_t rowBytes, SkColorTable* ctable) { + { + android::AutoMutex _lock(mLock); + if (mPinnedRefCount) { + ALOGW("Called reconfigure on a bitmap that is in use! This may" + " cause graphical corruption!"); + } + } mPixelRef->reconfigure(info, rowBytes, ctable); } void Bitmap::reconfigure(const SkImageInfo& info) { - mPixelRef->reconfigure(info, mPixelRef->rowBytes(), mPixelRef->colorTable()); + reconfigure(info, mPixelRef->rowBytes(), mPixelRef->colorTable()); } void Bitmap::detachFromJava() { @@ -287,18 +312,10 @@ void Bitmap::unpinPixelsLocked() { void Bitmap::getSkBitmap(SkBitmap* outBitmap) { assertValid(); android::AutoMutex _lock(mLock); - mPixelRef->ref(); - if (mPixelRef->unique()) { - // We just restored this from 0, pin the pixels and inc the strong count - // Note that there *might be* an incoming onStrongRefDestroyed from whatever - // last unref'd - pinPixelsLocked(); - mPinnedRefCount++; - } // Safe because mPixelRef is a WrappedPixelRef type, otherwise rowBytes() // would require locking the pixels first. outBitmap->setInfo(mPixelRef->info(), mPixelRef->rowBytes()); - outBitmap->setPixelRef(mPixelRef.get())->unref(); + outBitmap->setPixelRef(refPixelRefLocked())->unref(); outBitmap->setHasHardwareMipMap(hasHardwareMipMap()); } @@ -323,7 +340,7 @@ public: } void* pixels() { - return mBitmap->pixelRef()->pixels(); + return mBitmap->peekAtPixelRef()->pixels(); } bool valid() { @@ -780,7 +797,7 @@ static jint Bitmap_config(JNIEnv* env, jobject, jlong bitmapHandle) { static jint Bitmap_getGenerationId(JNIEnv* env, jobject, jlong bitmapHandle) { LocalScopedBitmap bitmap(bitmapHandle); - return static_cast(bitmap->pixelRef()->getGenerationID()); + return static_cast(bitmap->peekAtPixelRef()->getGenerationID()); } static jboolean Bitmap_isPremultiplied(JNIEnv* env, jobject, jlong bitmapHandle) { @@ -800,10 +817,10 @@ static void Bitmap_setHasAlpha(JNIEnv* env, jobject, jlong bitmapHandle, jboolean hasAlpha, jboolean requestPremul) { LocalScopedBitmap bitmap(bitmapHandle); if (hasAlpha) { - bitmap->pixelRef()->changeAlphaType( + bitmap->peekAtPixelRef()->changeAlphaType( requestPremul ? kPremul_SkAlphaType : kUnpremul_SkAlphaType); } else { - bitmap->pixelRef()->changeAlphaType(kOpaque_SkAlphaType); + bitmap->peekAtPixelRef()->changeAlphaType(kOpaque_SkAlphaType); } } @@ -812,9 +829,9 @@ static void Bitmap_setPremultiplied(JNIEnv* env, jobject, jlong bitmapHandle, LocalScopedBitmap bitmap(bitmapHandle); if (!bitmap->info().isOpaque()) { if (isPremul) { - bitmap->pixelRef()->changeAlphaType(kPremul_SkAlphaType); + bitmap->peekAtPixelRef()->changeAlphaType(kPremul_SkAlphaType); } else { - bitmap->pixelRef()->changeAlphaType(kUnpremul_SkAlphaType); + bitmap->peekAtPixelRef()->changeAlphaType(kUnpremul_SkAlphaType); } } } @@ -1164,7 +1181,7 @@ static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle, static jlong Bitmap_refPixelRef(JNIEnv* env, jobject, jlong bitmapHandle) { LocalScopedBitmap bitmap(bitmapHandle); - SkPixelRef* pixelRef = bitmap.valid() ? bitmap->pixelRef() : nullptr; + SkPixelRef* pixelRef = bitmap.valid() ? bitmap->peekAtPixelRef() : nullptr; SkSafeRef(pixelRef); return reinterpret_cast(pixelRef); } diff --git a/core/jni/android/graphics/Bitmap.h b/core/jni/android/graphics/Bitmap.h index d6e5c61f4039..efeb8981e0cc 100644 --- a/core/jni/android/graphics/Bitmap.h +++ b/core/jni/android/graphics/Bitmap.h @@ -62,7 +62,8 @@ public: int width() const { return info().width(); } int height() const { return info().height(); } size_t rowBytes() const; - SkPixelRef* pixelRef() const; + SkPixelRef* peekAtPixelRef() const; + SkPixelRef* refPixelRef(); bool valid() const { return mPixelStorageType != PixelStorageType::Invalid; } void reconfigure(const SkImageInfo& info, size_t rowBytes, SkColorTable* ctable); @@ -88,6 +89,7 @@ private: JNIEnv* jniEnv(); bool shouldDisposeSelfLocked(); void assertValid() const; + SkPixelRef* refPixelRefLocked(); android::Mutex mLock; int mPinnedRefCount = 0; diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp index cdd397d7fe61..3ca4e726c918 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -184,7 +184,7 @@ public: } mBitmap->reconfigure(info, bitmap->rowBytes(), ctable); - bitmap->setPixelRef(mBitmap->pixelRef()); + bitmap->setPixelRef(mBitmap->refPixelRef())->unref(); // since we're already allocated, we lockPixels right away // HeapAllocator/JavaPixelAllocator behaves this way too @@ -258,7 +258,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding unsigned int existingBufferSize = 0; if (javaBitmap != NULL) { reuseBitmap = GraphicsJNI::getBitmap(env, javaBitmap); - if (reuseBitmap->pixelRef()->isImmutable()) { + if (reuseBitmap->peekAtPixelRef()->isImmutable()) { ALOGW("Unable to reuse an immutable bitmap as an image decoder target."); javaBitmap = NULL; reuseBitmap = nullptr; diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp index 0deb8ccb6d95..1c6f7de0df38 100644 --- a/core/jni/android/graphics/Graphics.cpp +++ b/core/jni/android/graphics/Graphics.cpp @@ -352,8 +352,8 @@ void GraphicsJNI::getSkBitmap(JNIEnv* env, jobject bitmap, SkBitmap* outBitmap) getBitmap(env, bitmap)->getSkBitmap(outBitmap); } -SkPixelRef* GraphicsJNI::getSkPixelRef(JNIEnv* env, jobject bitmap) { - return getBitmap(env, bitmap)->pixelRef(); +SkPixelRef* GraphicsJNI::refSkPixelRef(JNIEnv* env, jobject bitmap) { + return getBitmap(env, bitmap)->refPixelRef(); } SkColorType GraphicsJNI::getNativeBitmapColorType(JNIEnv* env, jobject jconfig) { diff --git a/core/jni/android/graphics/GraphicsJNI.h b/core/jni/android/graphics/GraphicsJNI.h index e748bac63929..ef9c2a976dc5 100644 --- a/core/jni/android/graphics/GraphicsJNI.h +++ b/core/jni/android/graphics/GraphicsJNI.h @@ -52,7 +52,7 @@ public: static android::Canvas* getNativeCanvas(JNIEnv*, jobject canvas); static android::Bitmap* getBitmap(JNIEnv*, jobject bitmap); static void getSkBitmap(JNIEnv*, jobject bitmap, SkBitmap* outBitmap); - static SkPixelRef* getSkPixelRef(JNIEnv*, jobject bitmap); + static SkPixelRef* refSkPixelRef(JNIEnv*, jobject bitmap); static SkRegion* getNativeRegion(JNIEnv*, jobject region); // Given the 'native' long held by the Rasterizer.java object, return a diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index 1965cd399a04..77af341590f7 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -180,7 +180,7 @@ static jobject nativeScreenshotBitmap(JNIEnv* env, jclass clazz, (void*) screenshot->getPixels(), (void*) screenshot.get(), DeleteScreenshot, screenshotInfo, rowBytes, nullptr); screenshot.detach(); - bitmap->pixelRef()->setImmutable(); + bitmap->peekAtPixelRef()->setImmutable(); return GraphicsJNI::createBitmap(env, bitmap, GraphicsJNI::kBitmapCreateFlag_Premultiplied, NULL); diff --git a/native/graphics/jni/bitmap.cpp b/native/graphics/jni/bitmap.cpp index 05218336878c..6d2de98759c8 100644 --- a/native/graphics/jni/bitmap.cpp +++ b/native/graphics/jni/bitmap.cpp @@ -62,7 +62,7 @@ int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr) { return ANDROID_BITMAP_RESULT_BAD_PARAMETER; } - SkPixelRef* pixelRef = GraphicsJNI::getSkPixelRef(env, jbitmap); + SkPixelRef* pixelRef = GraphicsJNI::refSkPixelRef(env, jbitmap); if (!pixelRef) { return ANDROID_BITMAP_RESULT_JNI_EXCEPTION; } @@ -71,9 +71,9 @@ int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr) { void* addr = pixelRef->pixels(); if (NULL == addr) { pixelRef->unlockPixels(); + pixelRef->unref(); return ANDROID_BITMAP_RESULT_ALLOCATION_FAILED; } - pixelRef->ref(); if (addrPtr) { *addrPtr = addr; @@ -86,7 +86,7 @@ int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap) { return ANDROID_BITMAP_RESULT_BAD_PARAMETER; } - SkPixelRef* pixelRef = GraphicsJNI::getSkPixelRef(env, jbitmap); + SkPixelRef* pixelRef = GraphicsJNI::refSkPixelRef(env, jbitmap); if (!pixelRef) { return ANDROID_BITMAP_RESULT_JNI_EXCEPTION; } @@ -98,6 +98,12 @@ int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap) { pixelRef->notifyPixelsChanged(); pixelRef->unlockPixels(); + // Awkward in that we need to double-unref as the call to get the SkPixelRef + // did a ref(), so we need to unref() for the local ref and for the previous + // AndroidBitmap_lockPixels(). However this keeps GraphicsJNI a bit safer + // if others start using it without knowing about android::Bitmap's "fun" + // ref counting mechanism(s). + pixelRef->unref(); pixelRef->unref(); return ANDROID_BITMAP_RESULT_SUCCESS; -- cgit v1.2.3-59-g8ed1b From 9da9df9b90c00d6ac2bc953f40f621846138a1e7 Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Thu, 7 May 2015 13:56:14 -0400 Subject: Update the rowBytes when reconfiguring to match the new imageInfo. bug: 20872840 Change-Id: Ic98a9d16e095c27ddcc193a18641732c1ee4bad0 --- core/jni/android/graphics/Bitmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index 9babe827ce97..2785c4825dd2 100755 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -224,7 +224,7 @@ void Bitmap::reconfigure(const SkImageInfo& info, size_t rowBytes, } void Bitmap::reconfigure(const SkImageInfo& info) { - reconfigure(info, mPixelRef->rowBytes(), mPixelRef->colorTable()); + reconfigure(info, info.minRowBytes(), nullptr); } void Bitmap::detachFromJava() { -- cgit v1.2.3-59-g8ed1b From 4fb7ba03ac69b6573358f79119579c931231c1c0 Mon Sep 17 00:00:00 2001 From: Guang Zhu Date: Thu, 7 May 2015 10:51:29 -0700 Subject: improve app crash detection in compatibility test In addition to ensuring that process exists, we also need to check that it's the right state. Because crashed foreground activity can still get started as background service. Bug: 20899208 Change-Id: I101e556ce757af1afb66686827c5851dd6fda620 --- .../compatibilitytest/AppCompatibility.java | 58 ++++++++++++++++------ 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibility.java b/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibility.java index dd823aeaff00..b54f9be3461d 100644 --- a/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibility.java +++ b/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibility.java @@ -30,6 +30,7 @@ import android.util.Log; import junit.framework.Assert; +import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -102,7 +103,11 @@ public class AppCompatibility extends InstrumentationTestCase { // otherwise raise an // exception with the first error encountered. assertNull(getStackTrace(err), err); - assertTrue("App crashed after launch.", processStillUp(packageName)); + try { + assertTrue("App crashed after launch.", processStillUp(packageName)); + } finally { + returnHome(); + } } else { Log.d(TAG, "Missing argument, use " + PACKAGE_TO_LAUNCH + " to specify the package to launch"); @@ -138,6 +143,19 @@ public class AppCompatibility extends InstrumentationTestCase { } } + private void returnHome() { + Intent homeIntent = new Intent(Intent.ACTION_MAIN); + homeIntent.addCategory(Intent.CATEGORY_HOME); + homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + // Send the "home" intent and wait 2 seconds for us to get there + mContext.startActivity(homeIntent); + try { + Thread.sleep(mWorkspaceLaunchTimeout); + } catch (InterruptedException e) { + // ignore + } + } + /** * Launches and activity and queries for errors. * @@ -150,9 +168,6 @@ public class AppCompatibility extends InstrumentationTestCase { // the recommended way to see if this is a tv or not. boolean isleanback = !mPackageManager.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN) && !mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY); - Intent homeIntent = new Intent(Intent.ACTION_MAIN); - homeIntent.addCategory(Intent.CATEGORY_HOME); - homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Intent intent; if (isleanback) { Log.d(TAG, "Leanback and relax! " + packageName); @@ -173,14 +188,6 @@ public class AppCompatibility extends InstrumentationTestCase { // ignore } - // Send the "home" intent and wait 2 seconds for us to get there - mContext.startActivity(homeIntent); - try { - Thread.sleep(mWorkspaceLaunchTimeout); - } catch (InterruptedException e) { - // ignore - } - // See if there are any errors. We wait until down here to give ANRs as // much time as // possible to occur. @@ -198,6 +205,12 @@ public class AppCompatibility extends InstrumentationTestCase { return null; } + private boolean ensureForegroundActivity(RunningAppProcessInfo info) { + Log.d(TAG, String.format("ensureForegroundActivity: proc=%s, pid=%d, state=%d", + info.processName, info.pid, info.processState)); + return info.processState == ActivityManager.PROCESS_STATE_TOP; + } + /** * Determine if a given package is still running. * @@ -207,19 +220,32 @@ public class AppCompatibility extends InstrumentationTestCase { private boolean processStillUp(String packageName) { String processName = getProcessName(packageName); List runningApps = mActivityManager.getRunningAppProcesses(); + List relatedProcs = new ArrayList<>(); for (RunningAppProcessInfo app : runningApps) { if (app.processName.equalsIgnoreCase(processName)) { - Log.d(TAG, "Found process " + app.processName); + if (!ensureForegroundActivity(app)) { + Log.w(TAG, "Found process but it's not top activity."); + return false; + } return true; } for (String relatedPackage : app.pkgList) { - if (relatedPackage.equalsIgnoreCase(processName)) { - Log.d(TAG, "Found process " + app.processName); + if (relatedPackage.equalsIgnoreCase(packageName)) { + relatedProcs.add(app); + } + } + } + // now that we are here, we've found no RAPI's directly matching processName, but + // potentially a List of them with one of related packages being processName + if (!relatedProcs.isEmpty()) { + for (RunningAppProcessInfo app : relatedProcs) { + if (ensureForegroundActivity(app)) { return true; } } + Log.w(TAG, "Found related processes, but none has top activity."); } - Log.d(TAG, "Failed to find process " + processName + " with package name " + Log.w(TAG, "Failed to find process " + processName + " with package name " + packageName); return false; } -- cgit v1.2.3-59-g8ed1b From ca988ab75154eacf00e4852b0b6e83df1104758c Mon Sep 17 00:00:00 2001 From: Svet Ganov Date: Thu, 7 May 2015 10:49:07 -0700 Subject: Fix broke NDK sensor manager API Change-Id: I0f4e2a3ce20ce20e0aa5a7d38d1f988497c033c0 --- native/android/sensor.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/native/android/sensor.cpp b/native/android/sensor.cpp index 4e7c6bededba..26b41e85fddd 100644 --- a/native/android/sensor.cpp +++ b/native/android/sensor.cpp @@ -35,9 +35,27 @@ using android::Sensor; using android::SensorManager; using android::SensorEventQueue; using android::String8; +using android::String16; /*****************************************************************************/ +android::Mutex android::SensorManager::sLock; +std::map android::SensorManager::sPackageInstances; + +ASensorManager* ASensorManager_getInstance() +{ + return ASensorManager_getInstanceForPackage(NULL); +} + +ASensorManager* ASensorManager_getInstanceForPackage(const char* packageName) +{ + if (packageName) { + return &SensorManager::getInstanceForPackage(String16(packageName)); + } else { + return &SensorManager::getInstanceForPackage(String16()); + } +} + int ASensorManager_getSensorList(ASensorManager* manager, ASensorList* list) { -- cgit v1.2.3-59-g8ed1b From fea02e66c4e4f23a43191f7b93c0d7fe54230e94 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Thu, 7 May 2015 18:12:51 -0700 Subject: Fixed a bug with svelte and voice assist Handling the case that no info is around. Bug: 20925281 Change-Id: Id5a4c4373877909a898c8852891a854eacbc1f6c --- .../server/voiceinteraction/VoiceInteractionManagerService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java index 2897c616dee7..fcdb6d6cff60 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java @@ -754,7 +754,7 @@ public class VoiceInteractionManagerService extends SystemService { public boolean activeServiceSupportsAssist() { enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE); synchronized (this) { - return mImpl != null && mImpl.mInfo.getSupportsAssist(); + return mImpl != null && mImpl.mInfo != null && mImpl.mInfo.getSupportsAssist(); } } @@ -762,7 +762,8 @@ public class VoiceInteractionManagerService extends SystemService { public boolean activeServiceSupportsLaunchFromKeyguard() throws RemoteException { enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE); synchronized (this) { - return mImpl != null && mImpl.mInfo.getSupportsLaunchFromKeyguard(); + return mImpl != null && mImpl.mInfo != null + && mImpl.mInfo.getSupportsLaunchFromKeyguard(); } } -- cgit v1.2.3-59-g8ed1b From bb8251947d3a3bd52b32f65f982fcc692a12b2ff Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Thu, 7 May 2015 16:25:33 -0700 Subject: Allow obtaining BLE capabilities in BLE scan only mode. Bug:20923734 Change-Id: I7f3e5fd4410da39922be4512e4ba6ccdeb32887d --- core/java/android/bluetooth/BluetoothAdapter.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index 0a778681b57d..ec6f18d217ee 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -28,14 +28,11 @@ import android.bluetooth.le.ScanRecord; import android.bluetooth.le.ScanResult; import android.bluetooth.le.ScanSettings; import android.content.Context; +import android.os.Binder; import android.os.IBinder; import android.os.ParcelUuid; import android.os.RemoteException; import android.os.ServiceManager; -import android.app.ActivityThread; -import android.os.SystemProperties; -import android.provider.Settings; -import android.os.Binder; import android.util.Log; import android.util.Pair; @@ -1255,7 +1252,7 @@ public final class BluetoothAdapter { * @return true if chipset supports on-chip filtering */ public boolean isOffloadedFilteringSupported() { - if (getState() != STATE_ON) return false; + if (!getLeAccess()) return false; try { return mService.isOffloadedFilteringSupported(); } catch (RemoteException e) { @@ -1270,7 +1267,7 @@ public final class BluetoothAdapter { * @return true if chipset supports on-chip scan batching */ public boolean isOffloadedScanBatchingSupported() { - if (getState() != STATE_ON) return false; + if (!getLeAccess()) return false; try { return mService.isOffloadedScanBatchingSupported(); } catch (RemoteException e) { @@ -1286,7 +1283,7 @@ public final class BluetoothAdapter { * @hide */ public boolean isHardwareTrackingFiltersAvailable() { - if (getState() != STATE_ON) return false; + if (!getLeAccess()) return false; try { IBluetoothGatt iGatt = mManagerService.getBluetoothGatt(); if (iGatt == null) { -- cgit v1.2.3-59-g8ed1b From 7cb6822e4af3275305ff0de8893ca31a5a1758b3 Mon Sep 17 00:00:00 2001 From: Fyodor Kupolov Date: Mon, 11 May 2015 12:05:15 -0700 Subject: Fix errors during user switching Fix NPE in getHomeActivityForUser. Skip system processes in killBackgroundUserProcessesWithRecordAudioPermission. Bug: 21016983 Change-Id: I97f9ca362f4dbf0a659e3d5d7ae6cd8dbeb6404a --- services/core/java/com/android/server/am/ActivityManagerService.java | 2 +- services/core/java/com/android/server/audio/AudioService.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 10855e210e92..76ee3bcf55c7 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -19956,7 +19956,7 @@ public final class ActivityManagerService extends ActivityManagerNative public ComponentName getHomeActivityForUser(int userId) { synchronized (ActivityManagerService.this) { ActivityRecord homeActivity = mStackSupervisor.getHomeActivityForUser(userId); - return homeActivity.realActivity; + return homeActivity == null ? null : homeActivity.realActivity; } } } diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index aa365eae2afd..2149b7a6246f 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -20,6 +20,7 @@ import static android.Manifest.permission.REMOTE_AUDIO_PLAYBACK; import static android.media.AudioManager.RINGER_MODE_NORMAL; import static android.media.AudioManager.RINGER_MODE_SILENT; import static android.media.AudioManager.RINGER_MODE_VIBRATE; +import static android.os.Process.FIRST_APPLICATION_UID; import android.Manifest; import android.app.ActivityManager; @@ -5024,6 +5025,10 @@ public class AudioService extends IAudioService.Stub { } for (int j = packages.size() - 1; j >= 0; j--) { PackageInfo pkg = packages.get(j); + // Skip system processes + if (UserHandle.getAppId(pkg.applicationInfo.uid) < FIRST_APPLICATION_UID) { + continue; + } if (homeActivityName != null && pkg.packageName.equals(homeActivityName.getPackageName()) && pkg.applicationInfo.isSystemApp()) { -- cgit v1.2.3-59-g8ed1b From 8a9ce60e2bc928c94008171595250c9c4f386f38 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Tue, 12 May 2015 16:36:28 +0000 Subject: Revert "Use default constructor to get anti-aliasing" bug:20948129 This reverts commit 58fc522a69e8ddf9ac8530ce88e9c2c92da1dd14. Change-Id: Iddeccb4ad15b843bb3e610bd3673a0c7abc1bf46 --- core/java/android/widget/Editor.java | 2 +- core/java/android/widget/Switch.java | 2 +- core/java/android/widget/TextView.java | 4 ++-- core/java/com/android/internal/util/ImageUtils.java | 2 +- graphics/java/android/graphics/drawable/GradientDrawable.java | 6 +++--- graphics/java/android/graphics/drawable/ShapeDrawable.java | 4 ++-- .../SystemUI/src/com/android/systemui/BatteryMeterView.java | 10 +++++----- services/core/java/com/android/server/wm/Watermark.java | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 4fd85b6ea953..5fc9e35dd657 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -4472,7 +4472,7 @@ public class Editor { private class CorrectionHighlighter { private final Path mPath = new Path(); - private final Paint mPaint = new Paint(); + private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private int mStart, mEnd; private long mFadingStartTime; private RectF mTempRectF; diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java index ff587c2c4c2e..356df31d15ba 100644 --- a/core/java/android/widget/Switch.java +++ b/core/java/android/widget/Switch.java @@ -214,7 +214,7 @@ public class Switch extends CompoundButton { public Switch(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); - mTextPaint = new TextPaint(); + mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); final Resources res = getResources(); mTextPaint.density = res.getDisplayMetrics().density; diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 68c49cd06302..574f24b7768e 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -669,11 +669,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener final Resources res = getResources(); final CompatibilityInfo compat = res.getCompatibilityInfo(); - mTextPaint = new TextPaint(); + mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); mTextPaint.density = res.getDisplayMetrics().density; mTextPaint.setCompatibilityScaling(compat.applicationScale); - mHighlightPaint = new Paint(); + mHighlightPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mHighlightPaint.setCompatibilityScaling(compat.applicationScale); mMovement = getDefaultMovementMethod(); diff --git a/core/java/com/android/internal/util/ImageUtils.java b/core/java/com/android/internal/util/ImageUtils.java index a0d0b202774a..7d56e9e53b1c 100644 --- a/core/java/com/android/internal/util/ImageUtils.java +++ b/core/java/com/android/internal/util/ImageUtils.java @@ -66,7 +66,7 @@ public class ImageUtils { COMPACT_BITMAP_SIZE, COMPACT_BITMAP_SIZE, Bitmap.Config.ARGB_8888 ); mTempCompactBitmapCanvas = new Canvas(mTempCompactBitmap); - mTempCompactBitmapPaint = new Paint(); + mTempCompactBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTempCompactBitmapPaint.setFilterBitmap(true); } mTempMatrix.reset(); diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index dc9aa67a5891..4c2817c4459e 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -133,7 +133,7 @@ public class GradientDrawable extends Drawable { private GradientState mGradientState; - private final Paint mFillPaint = new Paint(); + private final Paint mFillPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private Rect mPadding; private Paint mStrokePaint; // optional, set by the caller private ColorFilter mColorFilter; // optional, set by the caller @@ -323,7 +323,7 @@ public class GradientDrawable extends Drawable { private void setStrokeInternal(int width, int color, float dashWidth, float dashGap) { if (mStrokePaint == null) { - mStrokePaint = new Paint(); + mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mStrokePaint.setStyle(Paint.Style.STROKE); } mStrokePaint.setStrokeWidth(width); @@ -1802,7 +1802,7 @@ public class GradientDrawable extends Drawable { mPadding = state.mPadding; if (state.mStrokeWidth >= 0) { - mStrokePaint = new Paint(); + mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mStrokePaint.setStyle(Paint.Style.STROKE); mStrokePaint.setStrokeWidth(state.mStrokeWidth); diff --git a/graphics/java/android/graphics/drawable/ShapeDrawable.java b/graphics/java/android/graphics/drawable/ShapeDrawable.java index caa0787cecb6..334b3bd366db 100644 --- a/graphics/java/android/graphics/drawable/ShapeDrawable.java +++ b/graphics/java/android/graphics/drawable/ShapeDrawable.java @@ -501,7 +501,7 @@ public class ShapeDrawable extends Drawable { if (mShapeState.mPaint != null) { mShapeState.mPaint = new Paint(mShapeState.mPaint); } else { - mShapeState.mPaint = new Paint(); + mShapeState.mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); } if (mShapeState.mPadding != null) { mShapeState.mPadding = new Rect(mShapeState.mPadding); @@ -555,7 +555,7 @@ public class ShapeDrawable extends Drawable { mAlpha = orig.mAlpha; mShaderFactory = orig.mShaderFactory; } else { - mPaint = new Paint(); + mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); } } diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java index 3fbc76b9efef..0d331d1a93cf 100755 --- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java +++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java @@ -225,23 +225,23 @@ public class BatteryMeterView extends View implements DemoMode, mSubpixelSmoothingRight = context.getResources().getFraction( R.fraction.battery_subpixel_smoothing_right, 1, 1); - mFramePaint = new Paint(); + mFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mFramePaint.setColor(frameColor); mFramePaint.setDither(true); mFramePaint.setStrokeWidth(0); mFramePaint.setStyle(Paint.Style.FILL_AND_STROKE); - mBatteryPaint = new Paint(); + mBatteryPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mBatteryPaint.setDither(true); mBatteryPaint.setStrokeWidth(0); mBatteryPaint.setStyle(Paint.Style.FILL_AND_STROKE); - mTextPaint = new Paint(); + mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); Typeface font = Typeface.create("sans-serif-condensed", Typeface.BOLD); mTextPaint.setTypeface(font); mTextPaint.setTextAlign(Paint.Align.CENTER); - mWarningTextPaint = new Paint(); + mWarningTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mWarningTextPaint.setColor(mColors[1]); font = Typeface.create("sans-serif", Typeface.BOLD); mWarningTextPaint.setTypeface(font); @@ -249,7 +249,7 @@ public class BatteryMeterView extends View implements DemoMode, mChargeColor = context.getColor(R.color.batterymeter_charge_color); - mBoltPaint = new Paint(); + mBoltPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mBoltPaint.setColor(context.getColor(R.color.batterymeter_bolt_color)); mBoltPoints = loadBoltPoints(res); diff --git a/services/core/java/com/android/server/wm/Watermark.java b/services/core/java/com/android/server/wm/Watermark.java index ba3ce36c6649..e226e3d73e47 100644 --- a/services/core/java/com/android/server/wm/Watermark.java +++ b/services/core/java/com/android/server/wm/Watermark.java @@ -84,7 +84,7 @@ class Watermark { int fontSize = WindowManagerService.getPropertyInt(tokens, 1, TypedValue.COMPLEX_UNIT_DIP, 20, dm); - mTextPaint = new Paint(); + mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTextPaint.setTextSize(fontSize); mTextPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD)); -- cgit v1.2.3-59-g8ed1b From c5058a502d2291d113fce033400cadf473ef50ec Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Tue, 12 May 2015 14:20:25 -0400 Subject: Fix crash in setup wizard Clear out any unhandled worker messages before stopping tracking. Bug: 21048197 Change-Id: I3792215a1e7799bdb93587cd7158c4d5d86de348 --- packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java index 28fa8fba5b36..c4e3bd6129e9 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java @@ -189,6 +189,8 @@ public class WifiTracker { */ public void stopTracking() { if (mRegistered) { + mWorkHandler.removeMessages(WorkHandler.MSG_UPDATE_ACCESS_POINTS); + mWorkHandler.removeMessages(WorkHandler.MSG_UPDATE_NETWORK_INFO); mContext.unregisterReceiver(mReceiver); mRegistered = false; } -- cgit v1.2.3-59-g8ed1b From e7ab89abf2ba29cabf8c2bcdac9430a2cdbf5691 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Tue, 12 May 2015 17:22:22 +0000 Subject: Fix build - Revert "Revert "Use default constructor to get anti-aliasing"" This reverts commit dfe0a66ceca530e0777ebfab20f81103baa18f14. Change-Id: I58a1bae649a284f3d3b6213064d903ea7fcf185a --- core/java/android/widget/Editor.java | 2 +- core/java/android/widget/Switch.java | 2 +- core/java/android/widget/TextView.java | 4 ++-- core/java/com/android/internal/util/ImageUtils.java | 2 +- graphics/java/android/graphics/drawable/GradientDrawable.java | 6 +++--- graphics/java/android/graphics/drawable/ShapeDrawable.java | 4 ++-- .../SystemUI/src/com/android/systemui/BatteryMeterView.java | 10 +++++----- services/core/java/com/android/server/wm/Watermark.java | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 5fc9e35dd657..4fd85b6ea953 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -4472,7 +4472,7 @@ public class Editor { private class CorrectionHighlighter { private final Path mPath = new Path(); - private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + private final Paint mPaint = new Paint(); private int mStart, mEnd; private long mFadingStartTime; private RectF mTempRectF; diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java index 356df31d15ba..ff587c2c4c2e 100644 --- a/core/java/android/widget/Switch.java +++ b/core/java/android/widget/Switch.java @@ -214,7 +214,7 @@ public class Switch extends CompoundButton { public Switch(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); - mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + mTextPaint = new TextPaint(); final Resources res = getResources(); mTextPaint.density = res.getDisplayMetrics().density; diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 574f24b7768e..68c49cd06302 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -669,11 +669,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener final Resources res = getResources(); final CompatibilityInfo compat = res.getCompatibilityInfo(); - mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + mTextPaint = new TextPaint(); mTextPaint.density = res.getDisplayMetrics().density; mTextPaint.setCompatibilityScaling(compat.applicationScale); - mHighlightPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mHighlightPaint = new Paint(); mHighlightPaint.setCompatibilityScaling(compat.applicationScale); mMovement = getDefaultMovementMethod(); diff --git a/core/java/com/android/internal/util/ImageUtils.java b/core/java/com/android/internal/util/ImageUtils.java index 7d56e9e53b1c..a0d0b202774a 100644 --- a/core/java/com/android/internal/util/ImageUtils.java +++ b/core/java/com/android/internal/util/ImageUtils.java @@ -66,7 +66,7 @@ public class ImageUtils { COMPACT_BITMAP_SIZE, COMPACT_BITMAP_SIZE, Bitmap.Config.ARGB_8888 ); mTempCompactBitmapCanvas = new Canvas(mTempCompactBitmap); - mTempCompactBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mTempCompactBitmapPaint = new Paint(); mTempCompactBitmapPaint.setFilterBitmap(true); } mTempMatrix.reset(); diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index 4c2817c4459e..dc9aa67a5891 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -133,7 +133,7 @@ public class GradientDrawable extends Drawable { private GradientState mGradientState; - private final Paint mFillPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + private final Paint mFillPaint = new Paint(); private Rect mPadding; private Paint mStrokePaint; // optional, set by the caller private ColorFilter mColorFilter; // optional, set by the caller @@ -323,7 +323,7 @@ public class GradientDrawable extends Drawable { private void setStrokeInternal(int width, int color, float dashWidth, float dashGap) { if (mStrokePaint == null) { - mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mStrokePaint = new Paint(); mStrokePaint.setStyle(Paint.Style.STROKE); } mStrokePaint.setStrokeWidth(width); @@ -1802,7 +1802,7 @@ public class GradientDrawable extends Drawable { mPadding = state.mPadding; if (state.mStrokeWidth >= 0) { - mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mStrokePaint = new Paint(); mStrokePaint.setStyle(Paint.Style.STROKE); mStrokePaint.setStrokeWidth(state.mStrokeWidth); diff --git a/graphics/java/android/graphics/drawable/ShapeDrawable.java b/graphics/java/android/graphics/drawable/ShapeDrawable.java index 334b3bd366db..caa0787cecb6 100644 --- a/graphics/java/android/graphics/drawable/ShapeDrawable.java +++ b/graphics/java/android/graphics/drawable/ShapeDrawable.java @@ -501,7 +501,7 @@ public class ShapeDrawable extends Drawable { if (mShapeState.mPaint != null) { mShapeState.mPaint = new Paint(mShapeState.mPaint); } else { - mShapeState.mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mShapeState.mPaint = new Paint(); } if (mShapeState.mPadding != null) { mShapeState.mPadding = new Rect(mShapeState.mPadding); @@ -555,7 +555,7 @@ public class ShapeDrawable extends Drawable { mAlpha = orig.mAlpha; mShaderFactory = orig.mShaderFactory; } else { - mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mPaint = new Paint(); } } diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java index 0d331d1a93cf..3fbc76b9efef 100755 --- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java +++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java @@ -225,23 +225,23 @@ public class BatteryMeterView extends View implements DemoMode, mSubpixelSmoothingRight = context.getResources().getFraction( R.fraction.battery_subpixel_smoothing_right, 1, 1); - mFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mFramePaint = new Paint(); mFramePaint.setColor(frameColor); mFramePaint.setDither(true); mFramePaint.setStrokeWidth(0); mFramePaint.setStyle(Paint.Style.FILL_AND_STROKE); - mBatteryPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mBatteryPaint = new Paint(); mBatteryPaint.setDither(true); mBatteryPaint.setStrokeWidth(0); mBatteryPaint.setStyle(Paint.Style.FILL_AND_STROKE); - mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mTextPaint = new Paint(); Typeface font = Typeface.create("sans-serif-condensed", Typeface.BOLD); mTextPaint.setTypeface(font); mTextPaint.setTextAlign(Paint.Align.CENTER); - mWarningTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mWarningTextPaint = new Paint(); mWarningTextPaint.setColor(mColors[1]); font = Typeface.create("sans-serif", Typeface.BOLD); mWarningTextPaint.setTypeface(font); @@ -249,7 +249,7 @@ public class BatteryMeterView extends View implements DemoMode, mChargeColor = context.getColor(R.color.batterymeter_charge_color); - mBoltPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mBoltPaint = new Paint(); mBoltPaint.setColor(context.getColor(R.color.batterymeter_bolt_color)); mBoltPoints = loadBoltPoints(res); diff --git a/services/core/java/com/android/server/wm/Watermark.java b/services/core/java/com/android/server/wm/Watermark.java index e226e3d73e47..ba3ce36c6649 100644 --- a/services/core/java/com/android/server/wm/Watermark.java +++ b/services/core/java/com/android/server/wm/Watermark.java @@ -84,7 +84,7 @@ class Watermark { int fontSize = WindowManagerService.getPropertyInt(tokens, 1, TypedValue.COMPLEX_UNIT_DIP, 20, dm); - mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mTextPaint = new Paint(); mTextPaint.setTextSize(fontSize); mTextPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD)); -- cgit v1.2.3-59-g8ed1b From 200166776f050927e25d9f2a8ca43276394b234e Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 12 May 2015 13:07:14 -0700 Subject: Ignore abandon after install relinquished. We recently changed the install flow to fully dexopt before renaming the staging directory. This exposed the ability for the session owner to abandon and destroy the stage contents while dexopt was still happening. Due to SELinux rules, the abandon would fail to clean up the stage directory, and PackageManager would "successfully" rename and install that stage, which now only contained the oat/ directory. To avoid this case, we now ignore abandon requests once we've passed the "point of no return" and relinquished our stage over to PackageManagerService. Bug: 20175072 Change-Id: I4ad5b1eba0e38f1315b8330bd95be6e3bc6c635a --- .../java/com/android/server/pm/PackageInstallerSession.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java index 89ca00e2f229..dcf668d665dd 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerSession.java +++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java @@ -127,6 +127,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { @GuardedBy("mLock") private boolean mPermissionsAccepted = false; @GuardedBy("mLock") + private boolean mRelinquished = false; + @GuardedBy("mLock") private boolean mDestroyed = false; private int mFinalStatus; @@ -557,6 +559,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { user = new UserHandle(userId); } + mRelinquished = true; mPm.installStage(mPackageName, stageDir, stageCid, localObserver, params, installerPackageName, installerUid, user); } @@ -928,6 +931,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { @Override public void abandon() { + if (mRelinquished) { + Slog.d(TAG, "Ignoring abandon after commit relinquished control"); + return; + } destroyInternal(); dispatchSessionFinished(INSTALL_FAILED_ABORTED, "Session was abandoned", null); } @@ -958,8 +965,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { } } if (stageDir != null) { - FileUtils.deleteContents(stageDir); - stageDir.delete(); + mPm.mInstaller.rmPackageDir(stageDir.getAbsolutePath()); } if (stageCid != null) { PackageHelper.destroySdDir(stageCid); @@ -990,6 +996,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { pw.printPair("mProgress", mProgress); pw.printPair("mSealed", mSealed); pw.printPair("mPermissionsAccepted", mPermissionsAccepted); + pw.printPair("mRelinquished", mRelinquished); pw.printPair("mDestroyed", mDestroyed); pw.printPair("mBridges", mBridges.size()); pw.printPair("mFinalStatus", mFinalStatus); -- cgit v1.2.3-59-g8ed1b From c5632e8f77607e2c87006f0e780b2c99c152fa93 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Wed, 13 May 2015 12:38:16 -0700 Subject: Rewriting should fail when any paths are null. Bug: 21017105 Change-Id: I0c5e9c5bdf397d51e2799b06a52bc5bd0bdd09b0 --- core/java/android/os/FileUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java index 021e5e4cdd6d..917271d6e670 100644 --- a/core/java/android/os/FileUtils.java +++ b/core/java/android/os/FileUtils.java @@ -528,7 +528,7 @@ public class FileUtils { * {@code /after/foo/bar.txt}. */ public static File rewriteAfterRename(File beforeDir, File afterDir, File file) { - if (file == null) return null; + if (file == null || beforeDir == null || afterDir == null) return null; if (contains(beforeDir, file)) { final String splice = file.getAbsolutePath().substring( beforeDir.getAbsolutePath().length()); -- cgit v1.2.3-59-g8ed1b From 976258b6322d4524bb28f160a9bea5a9346e33eb Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Thu, 14 May 2015 23:15:10 +0900 Subject: Don't display the "no Internet access" prompt on captive portals. Bug: 20081183 Bug: 21066461 Change-Id: Idc71844a604f9ca655411c6916de256780ea4586 --- .../core/java/com/android/server/ConnectivityService.java | 6 ++++-- .../com/android/server/connectivity/NetworkAgentInfo.java | 13 +++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 0961ffe1ffdc..16b3dcfa8b85 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -1982,7 +1982,7 @@ public class ConnectivityService extends IConnectivityManager.Stub if (msg.arg1 == 0) { setProvNotificationVisibleIntent(false, msg.arg2, 0, null, null); } else { - NetworkAgentInfo nai = null; + final NetworkAgentInfo nai; synchronized (mNetworkForNetId) { nai = mNetworkForNetId.get(msg.arg2); } @@ -1990,6 +1990,7 @@ public class ConnectivityService extends IConnectivityManager.Stub loge("EVENT_PROVISIONING_NOTIFICATION from unknown NetworkMonitor"); break; } + nai.captivePortalDetected = true; setProvNotificationVisibleIntent(true, msg.arg2, nai.networkInfo.getType(), nai.networkInfo.getExtraInfo(), (PendingIntent)msg.obj); } @@ -2384,7 +2385,8 @@ public class ConnectivityService extends IConnectivityManager.Stub // Only prompt if the network is unvalidated and was explicitly selected by the user, and if // we haven't already been told to switch to it regardless of whether it validated or not. - if (nai == null || nai.everValidated || + // Also don't prompt on captive portals because we're already prompting the user to sign in. + if (nai == null || nai.everValidated || nai.captivePortalDetected || !nai.networkMisc.explicitlySelected || nai.networkMisc.acceptUnvalidated) { return; } diff --git a/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java b/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java index 8a7c9020d952..eac748f4cff7 100644 --- a/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java +++ b/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java @@ -50,12 +50,11 @@ public class NetworkAgentInfo { public final NetworkMisc networkMisc; // Indicates if netd has been told to create this Network. Once created the appropriate routing // rules are setup and routes are added so packets can begin flowing over the Network. - // NOTE: This is a sticky bit; once set it is never cleared. + // This is a sticky bit; once set it is never cleared. public boolean created; // Set to true if this Network successfully passed validation or if it did not satisfy the // default NetworkRequest in which case validation will not be attempted. - // NOTE: This is a sticky bit; once set it is never cleared even if future validation attempts - // fail. + // This is a sticky bit; once set it is never cleared even if future validation attempts fail. public boolean everValidated; // The result of the last validation attempt on this network (true if validated, false if not). @@ -65,6 +64,10 @@ public class NetworkAgentInfo { // TODO: Fix the network scoring code, remove this, and rename everValidated to validated. public boolean lastValidated; + // Whether a captive portal was ever detected on this network. + // This is a sticky bit; once set it is never cleared. + public boolean captivePortalDetected; + // This represents the last score received from the NetworkAgent. private int currentScore; // Penalty applied to scores of Networks that have not been validated. @@ -101,9 +104,6 @@ public class NetworkAgentInfo { currentScore = score; networkMonitor = new NetworkMonitor(context, handler, this, defaultRequest); networkMisc = misc; - created = false; - everValidated = false; - lastValidated = false; } public void addRequest(NetworkRequest networkRequest) { @@ -166,6 +166,7 @@ public class NetworkAgentInfo { "created{" + created + "} " + "explicitlySelected{" + networkMisc.explicitlySelected + "} " + "acceptUnvalidated{" + networkMisc.acceptUnvalidated + "} " + + "captivePortalDetected{" + captivePortalDetected + "} " + "}"; } -- cgit v1.2.3-59-g8ed1b From 6aedb8ceb3656569bc01b7e1e29198424f51649b Mon Sep 17 00:00:00 2001 From: Dan Sandler Date: Thu, 14 May 2015 09:42:50 -0400 Subject: Fix icon-related crash. Bug: 21144636 Change-Id: Ib686e9a9a18ac6b9f1e249bcde74be9212e0f53b --- core/java/android/app/Notification.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 3ffeea7e3bd5..cb6f7d59f592 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -3191,8 +3191,9 @@ public class Notification implements Parcelable 0xFFFFFFFF, PorterDuff.Mode.SRC_ATOP, -1); } - final boolean gray = (smallIcon.getType() == Icon.TYPE_RESOURCE - && mColorUtil.isGrayscaleIcon(mContext, smallIcon.getResId())); + final boolean gray = isLegacy() + && smallIcon.getType() == Icon.TYPE_RESOURCE + && mColorUtil.isGrayscaleIcon(mContext, smallIcon.getResId()); if (!isLegacy() || gray) { contentView.setInt(R.id.right_icon, "setBackgroundResource", -- cgit v1.2.3-59-g8ed1b From 6c6f142548ae7a24103ebfc41b3bf515b9fbbbe6 Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Thu, 14 May 2015 15:32:28 +0000 Subject: Revert "Icon support comes to Notification." This reverts commit 08a04c15245c970856022d0779aa27d4d63cdee3. This also reverts commit 5bcbf857d129f4513e562801a4e88077b2655ade. Change-Id: Ia0b0a5339d523581c877822a3a1feec97ae4b73d --- api/current.txt | 5 - api/system-current.txt | 5 - core/java/android/app/Notification.java | 139 ++++++--------------- .../android/internal/statusbar/StatusBarIcon.java | 28 ++--- .../internal/util/NotificationColorUtil.java | 15 --- graphics/java/android/graphics/drawable/Icon.java | 82 +++--------- .../systemui/screenshot/GlobalScreenshot.java | 2 +- .../android/systemui/statusbar/BaseStatusBar.java | 16 +-- .../systemui/statusbar/StatusBarIconView.java | 56 ++++++--- .../systemui/statusbar/phone/DemoStatusIcons.java | 6 +- .../notification/NotificationManagerService.java | 8 +- 11 files changed, 117 insertions(+), 245 deletions(-) diff --git a/api/current.txt b/api/current.txt index 95d8f1ea8a1c..42a0b61fe2c4 100644 --- a/api/current.txt +++ b/api/current.txt @@ -4781,8 +4781,6 @@ package android.app { method public android.app.Notification clone(); method public int describeContents(); method public java.lang.String getGroup(); - method public android.graphics.drawable.Icon getLargeIcon(); - method public android.graphics.drawable.Icon getSmallIcon(); method public java.lang.String getSortKey(); method public deprecated void setLatestEventInfo(android.content.Context, java.lang.CharSequence, java.lang.CharSequence, android.app.PendingIntent); method public void writeToParcel(android.os.Parcel, int); @@ -4927,7 +4925,6 @@ package android.app { ctor public Notification.BigPictureStyle(); ctor public Notification.BigPictureStyle(android.app.Notification.Builder); method public android.app.Notification.BigPictureStyle bigLargeIcon(android.graphics.Bitmap); - method public android.app.Notification.BigPictureStyle bigLargeIcon(android.graphics.drawable.Icon); method public android.app.Notification.BigPictureStyle bigPicture(android.graphics.Bitmap); method public android.app.Notification.BigPictureStyle setBigContentTitle(java.lang.CharSequence); method public android.app.Notification.BigPictureStyle setSummaryText(java.lang.CharSequence); @@ -4966,7 +4963,6 @@ package android.app { method public android.app.Notification.Builder setGroup(java.lang.String); method public android.app.Notification.Builder setGroupSummary(boolean); method public android.app.Notification.Builder setLargeIcon(android.graphics.Bitmap); - method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon); method public android.app.Notification.Builder setLights(int, int, int); method public android.app.Notification.Builder setLocalOnly(boolean); method public android.app.Notification.Builder setNumber(int); @@ -4978,7 +4974,6 @@ package android.app { method public android.app.Notification.Builder setShowWhen(boolean); method public android.app.Notification.Builder setSmallIcon(int); method public android.app.Notification.Builder setSmallIcon(int, int); - method public android.app.Notification.Builder setSmallIcon(android.graphics.drawable.Icon); method public android.app.Notification.Builder setSortKey(java.lang.String); method public android.app.Notification.Builder setSound(android.net.Uri); method public deprecated android.app.Notification.Builder setSound(android.net.Uri, int); diff --git a/api/system-current.txt b/api/system-current.txt index 5d11b25842b9..7d5bdd4b7540 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4875,8 +4875,6 @@ package android.app { method public android.app.Notification clone(); method public int describeContents(); method public java.lang.String getGroup(); - method public android.graphics.drawable.Icon getLargeIcon(); - method public android.graphics.drawable.Icon getSmallIcon(); method public java.lang.String getSortKey(); method public deprecated void setLatestEventInfo(android.content.Context, java.lang.CharSequence, java.lang.CharSequence, android.app.PendingIntent); method public void writeToParcel(android.os.Parcel, int); @@ -5021,7 +5019,6 @@ package android.app { ctor public Notification.BigPictureStyle(); ctor public Notification.BigPictureStyle(android.app.Notification.Builder); method public android.app.Notification.BigPictureStyle bigLargeIcon(android.graphics.Bitmap); - method public android.app.Notification.BigPictureStyle bigLargeIcon(android.graphics.drawable.Icon); method public android.app.Notification.BigPictureStyle bigPicture(android.graphics.Bitmap); method public android.app.Notification.BigPictureStyle setBigContentTitle(java.lang.CharSequence); method public android.app.Notification.BigPictureStyle setSummaryText(java.lang.CharSequence); @@ -5060,7 +5057,6 @@ package android.app { method public android.app.Notification.Builder setGroup(java.lang.String); method public android.app.Notification.Builder setGroupSummary(boolean); method public android.app.Notification.Builder setLargeIcon(android.graphics.Bitmap); - method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon); method public android.app.Notification.Builder setLights(int, int, int); method public android.app.Notification.Builder setLocalOnly(boolean); method public android.app.Notification.Builder setNumber(int); @@ -5072,7 +5068,6 @@ package android.app { method public android.app.Notification.Builder setShowWhen(boolean); method public android.app.Notification.Builder setSmallIcon(int); method public android.app.Notification.Builder setSmallIcon(int, int); - method public android.app.Notification.Builder setSmallIcon(android.graphics.drawable.Icon); method public android.app.Notification.Builder setSortKey(java.lang.String); method public android.app.Notification.Builder setSound(android.net.Uri); method public deprecated android.app.Notification.Builder setSound(android.net.Uri, int); diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index cb6f7d59f592..49b254936295 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -30,7 +30,6 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; -import android.graphics.drawable.Icon; import android.media.AudioAttributes; import android.media.AudioManager; import android.media.session.MediaSession; @@ -886,9 +885,6 @@ public class Notification implements Parcelable */ public static final int HEADS_UP_REQUESTED = 2; - private Icon mSmallIcon; - private Icon mLargeIcon; - /** * Structure to encapsulate a named action that can be shown as part of this notification. * It must include an icon, a label, and a {@link PendingIntent} to be fired when the action is @@ -1366,7 +1362,7 @@ public class Notification implements Parcelable int version = parcel.readInt(); when = parcel.readLong(); - mSmallIcon = Icon.CREATOR.createFromParcel(parcel); + icon = parcel.readInt(); number = parcel.readInt(); if (parcel.readInt() != 0) { contentIntent = PendingIntent.CREATOR.createFromParcel(parcel); @@ -1384,7 +1380,7 @@ public class Notification implements Parcelable contentView = RemoteViews.CREATOR.createFromParcel(parcel); } if (parcel.readInt() != 0) { - mLargeIcon = Icon.CREATOR.createFromParcel(parcel); + largeIcon = Bitmap.CREATOR.createFromParcel(parcel); } defaults = parcel.readInt(); flags = parcel.readInt(); @@ -1449,7 +1445,7 @@ public class Notification implements Parcelable */ public void cloneInto(Notification that, boolean heavy) { that.when = this.when; - that.mSmallIcon = this.mSmallIcon; + that.icon = this.icon; that.number = this.number; // PendingIntents are global, so there's no reason (or way) to clone them. @@ -1466,8 +1462,8 @@ public class Notification implements Parcelable if (heavy && this.contentView != null) { that.contentView = this.contentView.clone(); } - if (heavy && this.mLargeIcon != null) { - that.mLargeIcon = this.mLargeIcon; + if (heavy && this.largeIcon != null) { + that.largeIcon = Bitmap.createBitmap(this.largeIcon); } that.iconLevel = this.iconLevel; that.sound = this.sound; // android.net.Uri is immutable @@ -1548,7 +1544,7 @@ public class Notification implements Parcelable contentView = null; bigContentView = null; headsUpContentView = null; - mLargeIcon = null; + largeIcon = null; if (extras != null) { extras.remove(Notification.EXTRA_LARGE_ICON); extras.remove(Notification.EXTRA_LARGE_ICON_BIG); @@ -1590,7 +1586,7 @@ public class Notification implements Parcelable parcel.writeInt(1); parcel.writeLong(when); - mSmallIcon.writeToParcel(parcel, 0); + parcel.writeInt(icon); parcel.writeInt(number); if (contentIntent != null) { parcel.writeInt(1); @@ -1622,9 +1618,9 @@ public class Notification implements Parcelable } else { parcel.writeInt(0); } - if (mLargeIcon != null) { + if (largeIcon != null) { parcel.writeInt(1); - mLargeIcon.writeToParcel(parcel, 0); + largeIcon.writeToParcel(parcel, 0); } else { parcel.writeInt(0); } @@ -1868,27 +1864,6 @@ public class Notification implements Parcelable } } - /** - * The small icon representing this notification in the status bar and content view. - * - * @return the small icon representing this notification. - * - * @see Builder#getSmallIcon() - * @see Builder#setSmallIcon(Icon) - */ - public Icon getSmallIcon() { - return mSmallIcon; - } - - /** - * The large icon shown in this notification's content view. - * @see Builder#getLargeIcon() - * @see Builder#setLargeIcon(Icon) - */ - public Icon getLargeIcon() { - return mLargeIcon; - } - /** * @hide */ @@ -1991,7 +1966,7 @@ public class Notification implements Parcelable private Context mContext; private long mWhen; - private Icon mSmallIcon, mLargeIcon; + private int mSmallIcon; private int mSmallIconLevel; private int mNumber; private CharSequence mContentTitle; @@ -2004,6 +1979,7 @@ public class Notification implements Parcelable private PendingIntent mFullScreenIntent; private CharSequence mTickerText; private RemoteViews mTickerView; + private Bitmap mLargeIcon; private Uri mSound; private int mAudioStreamType; private AudioAttributes mAudioAttributes; @@ -2184,7 +2160,8 @@ public class Notification implements Parcelable * @see Notification#icon */ public Builder setSmallIcon(@DrawableRes int icon) { - return setSmallIcon(Icon.createWithResource(mContext.getResources(), icon)); + mSmallIcon = icon; + return this; } /** @@ -2199,20 +2176,8 @@ public class Notification implements Parcelable * @see Notification#iconLevel */ public Builder setSmallIcon(@DrawableRes int icon, int level) { - mSmallIconLevel = level; - return setSmallIcon(icon); - } - - /** - * Set the small icon, which will be used to represent the notification in the - * status bar and content view (unless overriden there by a - * {@link #setLargeIcon(Bitmap) large icon}). - * - * @param icon An Icon object to use. - * @see Notification#icon - */ - public Builder setSmallIcon(Icon icon) { mSmallIcon = icon; + mSmallIconLevel = level; return this; } @@ -2359,24 +2324,14 @@ public class Notification implements Parcelable } /** - * Add a large icon to the notification content view. + * Add a large icon to the notification (and the ticker on some devices). * * In the platform template, this image will be shown on the left of the notification view - * in place of the {@link #setSmallIcon(Icon) small icon} (which will be placed in a small - * badge atop the large icon). - */ - public Builder setLargeIcon(Bitmap b) { - return setLargeIcon(b != null ? Icon.createWithBitmap(b) : null); - } - - /** - * Add a large icon to the notification content view. + * in place of the {@link #setSmallIcon(int) small icon} (which will move to the right side). * - * In the platform template, this image will be shown on the left of the notification view - * in place of the {@link #setSmallIcon(Icon) small icon} (which will be placed in a small - * badge atop the large icon). + * @see Notification#largeIcon */ - public Builder setLargeIcon(Icon icon) { + public Builder setLargeIcon(Bitmap icon) { mLargeIcon = icon; return this; } @@ -2885,13 +2840,13 @@ public class Notification implements Parcelable boolean contentTextInLine2 = false; if (mLargeIcon != null) { - contentView.setImageViewIcon(R.id.icon, mLargeIcon); + contentView.setImageViewBitmap(R.id.icon, mLargeIcon); processLargeLegacyIcon(mLargeIcon, contentView); - contentView.setImageViewIcon(R.id.right_icon, mSmallIcon); + contentView.setImageViewResource(R.id.right_icon, mSmallIcon); contentView.setViewVisibility(R.id.right_icon, View.VISIBLE); processSmallRightIcon(mSmallIcon, contentView); } else { // small icon at left - contentView.setImageViewIcon(R.id.icon, mSmallIcon); + contentView.setImageViewResource(R.id.icon, mSmallIcon); contentView.setViewVisibility(R.id.icon, View.VISIBLE); processSmallIconAsLarge(mSmallIcon, contentView); } @@ -3131,16 +3086,14 @@ public class Notification implements Parcelable /** * Apply any necessary background to smallIcons being used in the largeIcon spot. */ - private void processSmallIconAsLarge(Icon largeIcon, RemoteViews contentView) { + private void processSmallIconAsLarge(int largeIconId, RemoteViews contentView) { if (!isLegacy()) { contentView.setDrawableParameters(R.id.icon, false, -1, 0xFFFFFFFF, PorterDuff.Mode.SRC_ATOP, -1); + } + if (!isLegacy() || mColorUtil.isGrayscaleIcon(mContext, largeIconId)) { applyLargeIconBackground(contentView); - } else { - if (mColorUtil.isGrayscaleIcon(mContext, largeIcon)) { - applyLargeIconBackground(contentView); - } } } @@ -3149,9 +3102,8 @@ public class Notification implements Parcelable * if it's grayscale). */ // TODO: also check bounds, transparency, that sort of thing. - private void processLargeLegacyIcon(Icon largeIcon, RemoteViews contentView) { - if (largeIcon != null && isLegacy() - && mColorUtil.isGrayscaleIcon(mContext, largeIcon)) { + private void processLargeLegacyIcon(Bitmap largeIcon, RemoteViews contentView) { + if (isLegacy() && mColorUtil.isGrayscaleIcon(largeIcon)) { applyLargeIconBackground(contentView); } else { removeLargeIconBackground(contentView); @@ -3185,16 +3137,14 @@ public class Notification implements Parcelable /** * Recolor small icons when used in the R.id.right_icon slot. */ - private void processSmallRightIcon(Icon smallIcon, RemoteViews contentView) { + private void processSmallRightIcon(int smallIconDrawableId, + RemoteViews contentView) { if (!isLegacy()) { contentView.setDrawableParameters(R.id.right_icon, false, -1, 0xFFFFFFFF, PorterDuff.Mode.SRC_ATOP, -1); } - final boolean gray = isLegacy() - && smallIcon.getType() == Icon.TYPE_RESOURCE - && mColorUtil.isGrayscaleIcon(mContext, smallIcon.getResId()); - if (!isLegacy() || gray) { + if (!isLegacy() || mColorUtil.isGrayscaleIcon(mContext, smallIconDrawableId)) { contentView.setInt(R.id.right_icon, "setBackgroundResource", R.drawable.notification_icon_legacy_bg); @@ -3230,10 +3180,7 @@ public class Notification implements Parcelable public Notification buildUnstyled() { Notification n = new Notification(); n.when = mWhen; - n.mSmallIcon = mSmallIcon; - if (mSmallIcon.getType() == Icon.TYPE_RESOURCE) { - n.icon = mSmallIcon.getResId(); - } + n.icon = mSmallIcon; n.iconLevel = mSmallIconLevel; n.number = mNumber; @@ -3245,10 +3192,7 @@ public class Notification implements Parcelable n.fullScreenIntent = mFullScreenIntent; n.tickerText = mTickerText; n.tickerView = makeTickerView(); - n.mLargeIcon = mLargeIcon; - if (mLargeIcon != null && mLargeIcon.getType() == Icon.TYPE_BITMAP) { - n.largeIcon = mLargeIcon.getBitmap(); - } + n.largeIcon = mLargeIcon; n.sound = mSound; n.audioStreamType = mAudioStreamType; n.audioAttributes = mAudioAttributes; @@ -3298,7 +3242,7 @@ public class Notification implements Parcelable extras.putCharSequence(EXTRA_TEXT, mContentText); extras.putCharSequence(EXTRA_SUB_TEXT, mSubText); extras.putCharSequence(EXTRA_INFO_TEXT, mContentInfo); - extras.putParcelable(EXTRA_SMALL_ICON, mSmallIcon); + extras.putInt(EXTRA_SMALL_ICON, mSmallIcon); extras.putInt(EXTRA_PROGRESS, mProgress); extras.putInt(EXTRA_PROGRESS_MAX, mProgressMax); extras.putBoolean(EXTRA_PROGRESS_INDETERMINATE, mProgressIndeterminate); @@ -3486,7 +3430,7 @@ public class Notification implements Parcelable // Notification fields. mWhen = n.when; - mSmallIcon = n.mSmallIcon; + mSmallIcon = n.icon; mSmallIconLevel = n.iconLevel; mNumber = n.number; @@ -3497,7 +3441,7 @@ public class Notification implements Parcelable mFullScreenIntent = n.fullScreenIntent; mTickerText = n.tickerText; mTickerView = n.tickerView; - mLargeIcon = n.mLargeIcon; + mLargeIcon = n.largeIcon; mSound = n.sound; mAudioStreamType = n.audioStreamType; mAudioAttributes = n.audioAttributes; @@ -3528,7 +3472,7 @@ public class Notification implements Parcelable mContentText = extras.getCharSequence(EXTRA_TEXT); mSubText = extras.getCharSequence(EXTRA_SUB_TEXT); mContentInfo = extras.getCharSequence(EXTRA_INFO_TEXT); - mSmallIcon = extras.getParcelable(EXTRA_SMALL_ICON); + mSmallIcon = extras.getInt(EXTRA_SMALL_ICON); mProgress = extras.getInt(EXTRA_PROGRESS); mProgressMax = extras.getInt(EXTRA_PROGRESS_MAX); mProgressIndeterminate = extras.getBoolean(EXTRA_PROGRESS_INDETERMINATE); @@ -3820,7 +3764,7 @@ public class Notification implements Parcelable */ public static class BigPictureStyle extends Style { private Bitmap mPicture; - private Icon mBigLargeIcon; + private Bitmap mBigLargeIcon; private boolean mBigLargeIconSet = false; public BigPictureStyle() { @@ -3859,15 +3803,8 @@ public class Notification implements Parcelable * Override the large icon when the big notification is shown. */ public BigPictureStyle bigLargeIcon(Bitmap b) { - return bigLargeIcon(b != null ? Icon.createWithBitmap(b) : null); - } - - /** - * Override the large icon when the big notification is shown. - */ - public BigPictureStyle bigLargeIcon(Icon icon) { mBigLargeIconSet = true; - mBigLargeIcon = icon; + mBigLargeIcon = b; return this; } @@ -3878,7 +3815,7 @@ public class Notification implements Parcelable // 1. mBigLargeIconSet -> mBigLargeIcon (null or non-null) applies, overrides // mLargeIcon // 2. !mBigLargeIconSet -> mLargeIcon applies - Icon oldLargeIcon = null; + Bitmap oldLargeIcon = null; if (mBigLargeIconSet) { oldLargeIcon = mBuilder.mLargeIcon; mBuilder.mLargeIcon = mBigLargeIcon; diff --git a/core/java/com/android/internal/statusbar/StatusBarIcon.java b/core/java/com/android/internal/statusbar/StatusBarIcon.java index 4693d4b7c840..e0792cb37646 100644 --- a/core/java/com/android/internal/statusbar/StatusBarIcon.java +++ b/core/java/com/android/internal/statusbar/StatusBarIcon.java @@ -16,46 +16,40 @@ package com.android.internal.statusbar; -import android.graphics.drawable.Icon; import android.os.Parcel; import android.os.Parcelable; import android.os.UserHandle; public class StatusBarIcon implements Parcelable { + public String iconPackage; public UserHandle user; - public Icon icon; + public int iconId; 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(String iconPackage, UserHandle user, int iconId, int iconLevel, int number, CharSequence contentDescription) { + this.iconPackage = iconPackage; this.user = user; - this.icon = icon; + this.iconId = iconId; this.iconLevel = iconLevel; this.number = number; this.contentDescription = contentDescription; } - public StatusBarIcon(String iconPackage, UserHandle user, - int iconId, int iconLevel, int number, - CharSequence contentDescription) { - this(user, Icon.createWithResource(iconPackage, iconId), - iconLevel, number, contentDescription); - } - @Override public String toString() { - return "StatusBarIcon(icon=" + this.icon - + " user=" + user.getIdentifier() + return "StatusBarIcon(pkg=" + this.iconPackage + "user=" + user.getIdentifier() + + " id=0x" + Integer.toHexString(this.iconId) + " level=" + this.iconLevel + " visible=" + visible + " num=" + this.number + " )"; } @Override public StatusBarIcon clone() { - StatusBarIcon that = new StatusBarIcon(this.user, this.icon, + StatusBarIcon that = new StatusBarIcon(this.iconPackage, this.user, this.iconId, this.iconLevel, this.number, this.contentDescription); that.visible = this.visible; return that; @@ -69,8 +63,9 @@ public class StatusBarIcon implements Parcelable { } public void readFromParcel(Parcel in) { - this.icon = (Icon) in.readParcelable(null); + this.iconPackage = in.readString(); this.user = (UserHandle) in.readParcelable(null); + this.iconId = in.readInt(); this.iconLevel = in.readInt(); this.visible = in.readInt() != 0; this.number = in.readInt(); @@ -78,8 +73,9 @@ public class StatusBarIcon implements Parcelable { } public void writeToParcel(Parcel out, int flags) { - out.writeParcelable(this.icon, 0); + out.writeString(this.iconPackage); out.writeParcelable(this.user, 0); + out.writeInt(this.iconId); out.writeInt(this.iconLevel); out.writeInt(this.visible ? 1 : 0); out.writeInt(this.number); diff --git a/core/java/com/android/internal/util/NotificationColorUtil.java b/core/java/com/android/internal/util/NotificationColorUtil.java index 607697340ca0..3249ea3a5250 100644 --- a/core/java/com/android/internal/util/NotificationColorUtil.java +++ b/core/java/com/android/internal/util/NotificationColorUtil.java @@ -24,7 +24,6 @@ import android.graphics.Color; import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; -import android.graphics.drawable.Icon; import android.graphics.drawable.VectorDrawable; import android.text.SpannableStringBuilder; import android.text.Spanned; @@ -130,20 +129,6 @@ public class NotificationColorUtil { } } - public boolean isGrayscaleIcon(Context context, Icon icon) { - if (icon == null) { - return false; - } - switch (icon.getType()) { - case Icon.TYPE_BITMAP: - return isGrayscaleIcon(icon.getBitmap()); - case Icon.TYPE_RESOURCE: - return isGrayscaleIcon(context, icon.getResId()); - default: - return false; - } - } - /** * Checks whether a drawable with a resoure id is a small grayscale icon. * Grayscale here means "very close to a perfect gray"; icon means "no larger than 64dp". diff --git a/graphics/java/android/graphics/drawable/Icon.java b/graphics/java/android/graphics/drawable/Icon.java index 37fb703d77f7..668a14a41605 100644 --- a/graphics/java/android/graphics/drawable/Icon.java +++ b/graphics/java/android/graphics/drawable/Icon.java @@ -53,14 +53,10 @@ import java.io.OutputStream; public final class Icon implements Parcelable { private static final String TAG = "Icon"; - /** @hide */ - public static final int TYPE_BITMAP = 1; - /** @hide */ - public static final int TYPE_RESOURCE = 2; - /** @hide */ - public static final int TYPE_DATA = 3; - /** @hide */ - public static final int TYPE_URI = 4; + private static final int TYPE_BITMAP = 1; + private static final int TYPE_RESOURCE = 2; + private static final int TYPE_DATA = 3; + private static final int TYPE_URI = 4; private static final int VERSION_STREAM_SERIALIZER = 1; @@ -85,34 +81,15 @@ public final class Icon implements Parcelable { // TYPE_DATA: data offset private int mInt2; - /** - * @return The type of image data held in this Icon. One of - * {@link #TYPE_BITMAP}, - * {@link #TYPE_RESOURCE}, - * {@link #TYPE_DATA}, or - * {@link #TYPE_URI}. - * @hide - */ - public int getType() { - return mType; - } - - /** - * @return The {@link android.graphics.Bitmap} held by this {@link #TYPE_BITMAP} Icon. - * @hide - */ - public Bitmap getBitmap() { + // Internal accessors for different mType variants + private Bitmap getBitmap() { if (mType != TYPE_BITMAP) { throw new IllegalStateException("called getBitmap() on " + this); } return (Bitmap) mObj1; } - /** - * @return The length of the compressed bitmap byte array held by this {@link #TYPE_DATA} Icon. - * @hide - */ - public int getDataLength() { + private int getDataLength() { if (mType != TYPE_DATA) { throw new IllegalStateException("called getDataLength() on " + this); } @@ -121,12 +98,7 @@ public final class Icon implements Parcelable { } } - /** - * @return The offset into the byte array held by this {@link #TYPE_DATA} Icon at which - * valid compressed bitmap data is found. - * @hide - */ - public int getDataOffset() { + private int getDataOffset() { if (mType != TYPE_DATA) { throw new IllegalStateException("called getDataOffset() on " + this); } @@ -135,12 +107,7 @@ public final class Icon implements Parcelable { } } - /** - * @return The byte array held by this {@link #TYPE_DATA} Icon ctonaining compressed - * bitmap data. - * @hide - */ - public byte[] getDataBytes() { + private byte[] getDataBytes() { if (mType != TYPE_DATA) { throw new IllegalStateException("called getDataBytes() on " + this); } @@ -149,58 +116,39 @@ public final class Icon implements Parcelable { } } - /** - * @return The {@link android.content.res.Resources} for this {@link #TYPE_RESOURCE} Icon. - * @hide - */ - public Resources getResources() { + private Resources getResources() { if (mType != TYPE_RESOURCE) { throw new IllegalStateException("called getResources() on " + this); } return (Resources) mObj1; } - /** - * @return The package containing resources for this {@link #TYPE_RESOURCE} Icon. - * @hide - */ - public String getResPackage() { + private String getResPackage() { if (mType != TYPE_RESOURCE) { throw new IllegalStateException("called getResPackage() on " + this); } return mString1; } - /** - * @return The resource ID for this {@link #TYPE_RESOURCE} Icon. - * @hide - */ - public int getResId() { + private int getResId() { if (mType != TYPE_RESOURCE) { throw new IllegalStateException("called getResId() on " + this); } return mInt1; } - /** - * @return The URI (as a String) for this {@link #TYPE_URI} Icon. - * @hide - */ - public String getUriString() { + private String getUriString() { if (mType != TYPE_URI) { throw new IllegalStateException("called getUriString() on " + this); } return mString1; } - /** - * @return The {@link android.net.Uri} for this {@link #TYPE_URI} Icon. - * @hide - */ - public Uri getUri() { + private Uri getUri() { return Uri.parse(getUriString()); } + // Convert a int32 into a four-char string private static final String typeToString(int x) { switch (x) { case TYPE_BITMAP: return "BITMAP"; diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index be33085f68eb..715f4e443d21 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -194,7 +194,7 @@ class SaveImageInBackgroundTask extends AsyncTask") + + ": " + Integer.toHexString(icon.iconId)); + } + + return null; } public StatusBarIcon getStatusBarIcon() { 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 26d1c867ab08..44168bc71383 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java @@ -16,7 +16,6 @@ package com.android.systemui.statusbar.phone; -import android.graphics.drawable.Icon; import android.os.Bundle; import android.os.UserHandle; import android.view.Gravity; @@ -133,7 +132,8 @@ public class DemoStatusIcons extends LinearLayout implements DemoMode { break; } else { StatusBarIcon icon = v.getStatusBarIcon(); - icon.icon = Icon.createWithResource(icon.icon.getResPackage(), iconId); + icon.iconPackage = iconPkg; + icon.iconId = iconId; v.set(icon); v.updateDrawable(); return; @@ -152,4 +152,4 @@ public class DemoStatusIcons extends LinearLayout implements DemoMode { v.set(icon); addView(v, 0, new LinearLayout.LayoutParams(mIconSize, mIconSize)); } -} +} \ No newline at end of file diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index de74a044d3fd..290fb6579efd 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -2017,7 +2017,7 @@ public class NotificationManagerService extends SystemService { throw new IllegalArgumentException("null not allowed: pkg=" + pkg + " id=" + id + " notification=" + notification); } - if (notification.getSmallIcon() != null) { + if (notification.icon != 0) { if (!notification.isValid()) { throw new IllegalArgumentException("Invalid notification (): pkg=" + pkg + " id=" + id + " notification=" + notification); @@ -2138,11 +2138,11 @@ public class NotificationManagerService extends SystemService { applyZenModeLocked(r); mRankingHelper.sort(mNotificationList); - if (notification.getSmallIcon() != null) { + if (notification.icon != 0) { StatusBarNotification oldSbn = (old != null) ? old.sbn : null; mListeners.notifyPostedLocked(n, oldSbn); } else { - Slog.e(TAG, "Not posting notification without small icon: " + notification); + Slog.e(TAG, "Not posting notification with icon==0: " + notification); if (old != null && !old.isCanceled) { mListeners.notifyRemovedLocked(n); } @@ -2715,7 +2715,7 @@ public class NotificationManagerService extends SystemService { } // status bar - if (r.getNotification().getSmallIcon() != null) { + if (r.getNotification().icon != 0) { r.isCanceled = true; mListeners.notifyRemovedLocked(r.sbn); } -- cgit v1.2.3-59-g8ed1b From d2aac451ba562e066112c5b01e0ebcb6c46375c4 Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Thu, 14 May 2015 12:20:53 -0700 Subject: Revert "Update IME focus when the active view is losing the focus." This reverts commit 97c381304207013fd95c7806df4dcca0c69006c0. This causes issue with the right IME window getting focus. Bug: 21144633 Change-Id: I4c75b6e7dd87c10f008444d2059164b52a8f4335 --- core/java/android/view/ViewRootImpl.java | 5 +++ .../view/inputmethod/InputMethodManager.java | 36 +++++++++++++++++----- .../android/webkit/FindActionModeCallback.java | 1 + 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 7c635b95cddd..371d97b0ff3b 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -2014,6 +2014,7 @@ public final class ViewRootImpl implements ViewParent, mLastWasImTarget = imTarget; InputMethodManager imm = InputMethodManager.peekInstance(); if (imm != null && imTarget) { + imm.startGettingWindowFocus(mView); imm.onWindowFocus(mView, mView.findFocus(), mWindowAttributes.softInputMode, !mHasHadWindowFocus, mWindowAttributes.flags); @@ -3320,6 +3321,10 @@ public final class ViewRootImpl implements ViewParent, InputMethodManager imm = InputMethodManager.peekInstance(); if (mView != null) { + if (hasWindowFocus && imm != null && mLastWasImTarget && + !isInLocalFocusMode()) { + imm.startGettingWindowFocus(mView); + } mAttachInfo.mKeyDispatchState.reset(); mView.dispatchWindowFocusChanged(hasWindowFocus); mAttachInfo.mTreeObserver.dispatchOnWindowFocusChange(hasWindowFocus); diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 1fb791cf87ad..568e16074daa 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -281,7 +281,12 @@ public final class InputMethodManager { boolean mFullscreenMode; // ----------------------------------------------------------- - + + /** + * This is the root view of the overall window that currently has input + * method focus. + */ + View mCurRootView; /** * This is the view that should currently be served by an input method, * regardless of the state of setting that up. @@ -801,6 +806,7 @@ public final class InputMethodManager { * Disconnect any existing input connection, clearing the served view. */ void finishInputLocked() { + mCurRootView = null; mNextServedView = null; if (mServedView != null) { if (DEBUG) Log.v(TAG, "FINISH INPUT: " + mServedView); @@ -1284,9 +1290,10 @@ public final class InputMethodManager { void focusInLocked(View view) { if (DEBUG) Log.v(TAG, "focusIn: " + view); - if (!view.hasWindowFocus()) { - // This is a request from a window that doesn't have window focus, so ignore it. - if (DEBUG) Log.v(TAG, "Not focused window, ignoring"); + if (mCurRootView != view.getRootView()) { + // This is a request from a window that isn't in the window with + // IME focus, so ignore it. + if (DEBUG) Log.v(TAG, "Not IME target window, ignoring"); return; } @@ -1303,9 +1310,16 @@ public final class InputMethodManager { if (DEBUG) Log.v(TAG, "focusOut: " + view + " mServedView=" + mServedView + " winFocus=" + view.hasWindowFocus()); - if (mServedView == view && view.hasWindowFocus()) { - mNextServedView = null; - scheduleCheckFocusLocked(view); + if (mServedView != view) { + // The following code would auto-hide the IME if we end up + // with no more views with focus. This can happen, however, + // whenever we go into touch mode, so it ends up hiding + // at times when we don't really want it to. For now it + // seems better to just turn it all off. + if (false && view.hasWindowFocus()) { + mNextServedView = null; + scheduleCheckFocusLocked(view); + } } } } @@ -1428,6 +1442,13 @@ public final class InputMethodManager { } } + /** @hide */ + public void startGettingWindowFocus(View rootView) { + synchronized (mH) { + mCurRootView = rootView; + } + } + /** * Report the current selection range. * @@ -2135,6 +2156,7 @@ public final class InputMethodManager { + " mBindSequence=" + mBindSequence + " mCurId=" + mCurId); p.println(" mCurMethod=" + mCurMethod); + p.println(" mCurRootView=" + mCurRootView); p.println(" mServedView=" + mServedView); p.println(" mNextServedView=" + mNextServedView); p.println(" mServedConnecting=" + mServedConnecting); diff --git a/core/java/android/webkit/FindActionModeCallback.java b/core/java/android/webkit/FindActionModeCallback.java index 6fef2d6ce66f..ab6a2f91f95e 100644 --- a/core/java/android/webkit/FindActionModeCallback.java +++ b/core/java/android/webkit/FindActionModeCallback.java @@ -154,6 +154,7 @@ public class FindActionModeCallback implements ActionMode.Callback, TextWatcher, } public void showSoftInput() { + mInput.startGettingWindowFocus(mEditText.getRootView()); mInput.focusIn(mEditText); mInput.showSoftInput(mEditText, 0); } -- cgit v1.2.3-59-g8ed1b From 75d15097851b524a356a801313f1e9dc1fc0c78a Mon Sep 17 00:00:00 2001 From: Joseph Wen Date: Thu, 14 May 2015 14:13:11 -0400 Subject: Change the location of Brandmaster statement file. Change the location of statement file for web asset from /.well-known/associations.json to /.well-known/statements.json. BUG=21153250 Change-Id: Ie8538b852d62c54254c895e0abadc7f502ea2181 --- core/res/res/values/attrs_manifest.xml | 2 +- .../android/statementservice/retriever/AbstractStatementRetriever.java | 2 +- .../android/statementservice/retriever/DirectStatementRetriever.java | 2 +- .../src/com/android/statementservice/retriever/Statement.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index 38bbe660c419..470e3455cbbc 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -1105,7 +1105,7 @@ intern filter data scheme is set to "http" or "https". When set to true, the intent filter will need to use its data tag for getting the URIs to verify with. - For each URI, an HTTPS network request will be done to /.well-known/associations.json + For each URI, an HTTPS network request will be done to /.well-known/statements.json host to verify that the web site is okay with the app intercepting the URI. --> diff --git a/packages/StatementService/src/com/android/statementservice/retriever/AbstractStatementRetriever.java b/packages/StatementService/src/com/android/statementservice/retriever/AbstractStatementRetriever.java index fb30bc16ccbd..3b59fd6a5d83 100644 --- a/packages/StatementService/src/com/android/statementservice/retriever/AbstractStatementRetriever.java +++ b/packages/StatementService/src/com/android/statementservice/retriever/AbstractStatementRetriever.java @@ -90,7 +90,7 @@ public abstract class AbstractStatementRetriever { * Creates a new StatementRetriever that directly retrieves statements from the asset. * *

For web assets, {@link AbstractStatementRetriever} will try to retrieve the statement - * file from URL: {@code [webAsset.site]/.well-known/associations.json"} where {@code + * file from URL: {@code [webAsset.site]/.well-known/statements.json"} where {@code * [webAsset.site]} is in the form {@code http{s}://[hostname]:[optional_port]}. The file * should contain one JSON array of statements. * diff --git a/packages/StatementService/src/com/android/statementservice/retriever/DirectStatementRetriever.java b/packages/StatementService/src/com/android/statementservice/retriever/DirectStatementRetriever.java index 3ad71c44b528..6516516f0847 100644 --- a/packages/StatementService/src/com/android/statementservice/retriever/DirectStatementRetriever.java +++ b/packages/StatementService/src/com/android/statementservice/retriever/DirectStatementRetriever.java @@ -38,7 +38,7 @@ import java.util.List; private static final int HTTP_CONNECTION_TIMEOUT_MILLIS = 5000; private static final long HTTP_CONTENT_SIZE_LIMIT_IN_BYTES = 1024 * 1024; private static final int MAX_INCLUDE_LEVEL = 1; - private static final String WELL_KNOWN_STATEMENT_PATH = "/.well-known/associations.json"; + private static final String WELL_KNOWN_STATEMENT_PATH = "/.well-known/statements.json"; private final URLFetcher mUrlFetcher; private final AndroidPackageInfoFetcher mAndroidFetcher; diff --git a/packages/StatementService/src/com/android/statementservice/retriever/Statement.java b/packages/StatementService/src/com/android/statementservice/retriever/Statement.java index f83edafe0eae..da3c3553d731 100644 --- a/packages/StatementService/src/com/android/statementservice/retriever/Statement.java +++ b/packages/StatementService/src/com/android/statementservice/retriever/Statement.java @@ -21,7 +21,7 @@ import android.annotation.NonNull; /** * An immutable value type representing a statement, consisting of a source, target, and relation. * This reflects an assertion that the relation holds for the source, target pair. For example, if a - * web site has the following in its associations.json file: + * web site has the following in its statements.json file: * *

  * {
-- 
cgit v1.2.3-59-g8ed1b


From 6de344e2a3b1906a16773c0fd4207b2dadfb128a Mon Sep 17 00:00:00 2001
From: Miao Wang 
Date: Thu, 14 May 2015 14:53:30 -0700
Subject: [RenderScript] Add dummy getMinorID to maintain compatible with old
 RS compat lib.

bug: 21132592
Change-Id: I375f188dfbd33367a9589533aa51b182fda8bc21
---
 rs/java/android/renderscript/RenderScript.java | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
index 27f2cc8aa9e8..8b1a0324956a 100644
--- a/rs/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -133,6 +133,20 @@ public class RenderScript {
     // used in conjunction with the API version of a device
     static final long sMinorVersion = 1;
 
+    /**
+     * @hide
+     *
+     * Only exist to be compatible with old version RenderScript Support lib.
+     * Will eventually be removed.
+     *
+     * @return Always return 1
+     *
+     */
+    public static long getMinorID() {
+        return 1;
+    }
+
+
     /**
      * Returns an identifier that can be used to identify a particular
      * minor version of RS.
-- 
cgit v1.2.3-59-g8ed1b


From 700132dd0af76228d3fccca8ee3993c254a638e7 Mon Sep 17 00:00:00 2001
From: Jorim Jaggi 
Date: Thu, 14 May 2015 14:13:20 -0700
Subject: Adjust lockscreen style to spec

Bug: 21111048
Change-Id: Ibdecaf01224ef45a53b4981d8b79d27034a3df45
---
 packages/Keyguard/res/layout/keyguard_status_area.xml                 | 4 ++++
 packages/Keyguard/res/layout/keyguard_status_view.xml                 | 1 +
 packages/Keyguard/res/values-h650dp/dimens.xml                        | 2 +-
 packages/Keyguard/res/values-sw600dp/dimens.xml                       | 2 +-
 packages/Keyguard/res/values-sw720dp/dimens.xml                       | 2 +-
 packages/Keyguard/res/values/colors.xml                               | 2 +-
 packages/Keyguard/res/values/dimens.xml                               | 2 +-
 packages/Keyguard/res/values/styles.xml                               | 2 +-
 .../src/com/android/systemui/statusbar/phone/ScrimController.java     | 2 +-
 9 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/packages/Keyguard/res/layout/keyguard_status_area.xml b/packages/Keyguard/res/layout/keyguard_status_area.xml
index 7d8977c8a17d..8fe283519861 100644
--- a/packages/Keyguard/res/layout/keyguard_status_area.xml
+++ b/packages/Keyguard/res/layout/keyguard_status_area.xml
@@ -30,6 +30,8 @@
         android:layout_height="wrap_content"
         android:textColor="@color/clock_white"
         style="@style/widget_label"
+        android:textAllCaps="true"
+        android:letterSpacing="0.15"
         android:gravity="center"
         />
     
 
diff --git a/packages/Keyguard/res/values-h650dp/dimens.xml b/packages/Keyguard/res/values-h650dp/dimens.xml
index 48643268a9bd..92035bbc0977 100644
--- a/packages/Keyguard/res/values-h650dp/dimens.xml
+++ b/packages/Keyguard/res/values-h650dp/dimens.xml
@@ -16,5 +16,5 @@
   -->
 
 
-    112dp
+    104dp
 
\ No newline at end of file
diff --git a/packages/Keyguard/res/values-sw600dp/dimens.xml b/packages/Keyguard/res/values-sw600dp/dimens.xml
index 5de1d110e0e2..b181682f90ba 100644
--- a/packages/Keyguard/res/values-sw600dp/dimens.xml
+++ b/packages/Keyguard/res/values-sw600dp/dimens.xml
@@ -26,7 +26,7 @@
     12dp
 
     
-    140dp
+    125dp
     16sp
     -16dp
 
diff --git a/packages/Keyguard/res/values-sw720dp/dimens.xml b/packages/Keyguard/res/values-sw720dp/dimens.xml
index 428c18e795d0..08ab791f856e 100644
--- a/packages/Keyguard/res/values-sw720dp/dimens.xml
+++ b/packages/Keyguard/res/values-sw720dp/dimens.xml
@@ -24,5 +24,5 @@
     
     420dp
 
-    150dp
+    138dp
 
diff --git a/packages/Keyguard/res/values/colors.xml b/packages/Keyguard/res/values/colors.xml
index 3b741eaff8a4..3998c5b8ad57 100644
--- a/packages/Keyguard/res/values/colors.xml
+++ b/packages/Keyguard/res/values/colors.xml
@@ -17,5 +17,5 @@
 
     
     #ffffffff
-    #99ffffff
+    @*android:color/secondary_text_default_material_dark
 
diff --git a/packages/Keyguard/res/values/dimens.xml b/packages/Keyguard/res/values/dimens.xml
index 92902361e71d..18d893a7b3f1 100644
--- a/packages/Keyguard/res/values/dimens.xml
+++ b/packages/Keyguard/res/values/dimens.xml
@@ -40,7 +40,7 @@
 
     
     -10dp
-    16sp
+    14sp
     88dp
 
     
diff --git a/packages/Keyguard/res/values/styles.xml b/packages/Keyguard/res/values/styles.xml
index 404a17eabd91..943c3eabb69c 100644
--- a/packages/Keyguard/res/values/styles.xml
+++ b/packages/Keyguard/res/values/styles.xml
@@ -41,7 +41,7 @@