Skip to content

Commit 996c5b9

Browse files
author
Jessica Wagantall
committed
Merge tag 'android-6.0.1_r74' into HEAD
CYNGNOS-3303 Android 6.0.1 release 74
2 parents 8ec45de + ef525e8 commit 996c5b9

File tree

13 files changed

+662
-24
lines changed

13 files changed

+662
-24
lines changed

core/java/android/app/DownloadManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ public Uri getUriForDownloadedFile(long id) {
10381038
if (cursor.moveToFirst()) {
10391039
int status = cursor.getInt(cursor.getColumnIndexOrThrow(COLUMN_STATUS));
10401040
if (DownloadManager.STATUS_SUCCESSFUL == status) {
1041-
return ContentUris.withAppendedId(Downloads.Impl.CONTENT_URI, id);
1041+
return ContentUris.withAppendedId(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, id);
10421042
}
10431043
}
10441044
} finally {
@@ -1263,7 +1263,7 @@ private static void validateArgumentIsNonEmpty(String paramName, String val) {
12631263
* @hide
12641264
*/
12651265
public Uri getDownloadUri(long id) {
1266-
return ContentUris.withAppendedId(mBaseUri, id);
1266+
return ContentUris.withAppendedId(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, id);
12671267
}
12681268

12691269
/**
@@ -1344,7 +1344,7 @@ private String getLocalUri() {
13441344

13451345
// return content URI for cache download
13461346
long downloadId = getLong(getColumnIndex(Downloads.Impl._ID));
1347-
return ContentUris.withAppendedId(mBaseUri, downloadId).toString();
1347+
return ContentUris.withAppendedId(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, downloadId).toString();
13481348
}
13491349

13501350
private long getReason(int status) {

core/java/android/bluetooth/BluetoothDevice.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,12 +1166,12 @@ public boolean setPasskey(int passkey) {
11661166

11671167
/**
11681168
* Confirm passkey for {@link #PAIRING_VARIANT_PASSKEY_CONFIRMATION} pairing.
1169-
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}.
1169+
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
11701170
*
11711171
* @return true confirmation has been sent out
11721172
* false for error
11731173
*/
1174-
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
1174+
@RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
11751175
public boolean setPairingConfirmation(boolean confirm) {
11761176
if (sService == null) {
11771177
Log.e(TAG, "BT not enabled. Cannot set pairing confirmation");

core/jni/android/graphics/Bitmap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ Bitmap::Bitmap(void* address, void* context, FreeFunc freeFunc,
150150
mPixelRef->unref();
151151
}
152152

153-
Bitmap::Bitmap(void* address, int fd,
153+
Bitmap::Bitmap(void* address, int fd, size_t mappedSize,
154154
const SkImageInfo& info, size_t rowBytes, SkColorTable* ctable)
155155
: mPixelStorageType(PixelStorageType::Ashmem) {
156156
mPixelStorage.ashmem.address = address;
157157
mPixelStorage.ashmem.fd = fd;
158-
mPixelStorage.ashmem.size = ashmem_get_size_region(fd);
158+
mPixelStorage.ashmem.size = mappedSize;
159159
mPixelRef.reset(new WrappedPixelRef(this, address, info, rowBytes, ctable));
160160
// Note: this will trigger a call to onStrongRefDestroyed(), but
161161
// we want the pixel ref to have a ref count of 0 at this point
@@ -1015,7 +1015,7 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
10151015

10161016
// Map the pixels in place and take ownership of the ashmem region.
10171017
nativeBitmap = GraphicsJNI::mapAshmemPixelRef(env, bitmap.get(),
1018-
ctable, dupFd, const_cast<void*>(blob.data()), !isMutable);
1018+
ctable, dupFd, const_cast<void*>(blob.data()), size, !isMutable);
10191019
SkSafeUnref(ctable);
10201020
if (!nativeBitmap) {
10211021
close(dupFd);

core/jni/android/graphics/Bitmap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class Bitmap {
5151
const SkImageInfo& info, size_t rowBytes, SkColorTable* ctable);
5252
Bitmap(void* address, void* context, FreeFunc freeFunc,
5353
const SkImageInfo& info, size_t rowBytes, SkColorTable* ctable);
54-
Bitmap(void* address, int fd, const SkImageInfo& info, size_t rowBytes,
55-
SkColorTable* ctable);
54+
Bitmap(void* address, int fd, size_t mappedSize, const SkImageInfo& info,
55+
size_t rowBytes, SkColorTable* ctable);
5656

5757
const SkImageInfo& info() const;
5858

core/jni/android/graphics/Graphics.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ android::Bitmap* GraphicsJNI::allocateAshmemPixelRef(JNIEnv* env, SkBitmap* bitm
613613
return nullptr;
614614
}
615615

616-
android::Bitmap* wrapper = new android::Bitmap(addr, fd, info, rowBytes, ctable);
616+
android::Bitmap* wrapper = new android::Bitmap(addr, fd, size, info, rowBytes, ctable);
617617
wrapper->getSkBitmap(bitmap);
618618
// since we're already allocated, we lockPixels right away
619619
// HeapAllocator behaves this way too
@@ -623,7 +623,7 @@ android::Bitmap* GraphicsJNI::allocateAshmemPixelRef(JNIEnv* env, SkBitmap* bitm
623623
}
624624

625625
android::Bitmap* GraphicsJNI::mapAshmemPixelRef(JNIEnv* env, SkBitmap* bitmap,
626-
SkColorTable* ctable, int fd, void* addr, bool readOnly) {
626+
SkColorTable* ctable, int fd, void* addr, size_t size, bool readOnly) {
627627
const SkImageInfo& info = bitmap->info();
628628
if (info.fColorType == kUnknown_SkColorType) {
629629
doThrowIAE(env, "unknown bitmap configuration");
@@ -633,7 +633,8 @@ android::Bitmap* GraphicsJNI::mapAshmemPixelRef(JNIEnv* env, SkBitmap* bitmap,
633633
if (!addr) {
634634
// Map existing ashmem region if not already mapped.
635635
int flags = readOnly ? (PROT_READ) : (PROT_READ | PROT_WRITE);
636-
addr = mmap(NULL, ashmem_get_size_region(fd), flags, MAP_SHARED, fd, 0);
636+
size = ashmem_get_size_region(fd);
637+
addr = mmap(NULL, size, flags, MAP_SHARED, fd, 0);
637638
if (addr == MAP_FAILED) {
638639
return nullptr;
639640
}
@@ -643,7 +644,7 @@ android::Bitmap* GraphicsJNI::mapAshmemPixelRef(JNIEnv* env, SkBitmap* bitmap,
643644
// attempting to compute our own.
644645
const size_t rowBytes = bitmap->rowBytes();
645646

646-
android::Bitmap* wrapper = new android::Bitmap(addr, fd, info, rowBytes, ctable);
647+
android::Bitmap* wrapper = new android::Bitmap(addr, fd, size, info, rowBytes, ctable);
647648
wrapper->getSkBitmap(bitmap);
648649
if (readOnly) {
649650
bitmap->pixelRef()->setImmutable();

core/jni/android/graphics/GraphicsJNI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class GraphicsJNI {
9999
SkColorTable* ctable);
100100

101101
static android::Bitmap* mapAshmemPixelRef(JNIEnv* env, SkBitmap* bitmap,
102-
SkColorTable* ctable, int fd, void* addr, bool readOnly);
102+
SkColorTable* ctable, int fd, void* addr, size_t size, bool readOnly);
103103

104104
/**
105105
* Given a bitmap we natively allocate a memory block to store the contents

core/jni/com_android_internal_os_Zygote.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#define LOG_TAG "Zygote"
1818

19+
#include <sstream>
20+
1921
// sys/mount.h has to come before linux/fs.h due to redefinition of MS_RDONLY, MS_BIND, etc
2022
#include <sys/mount.h>
2123
#include <linux/fs.h>
@@ -53,6 +55,7 @@
5355
#include "ScopedLocalRef.h"
5456
#include "ScopedPrimitiveArray.h"
5557
#include "ScopedUtfChars.h"
58+
#include "fd_utils-inl.h"
5659

5760
#include "nativebridge/native_bridge.h"
5861

@@ -78,6 +81,12 @@ static void RuntimeAbort(JNIEnv* env) {
7881
env->FatalError("RuntimeAbort");
7982
}
8083

84+
static void RuntimeAbort(JNIEnv* env, int line, const char* msg) {
85+
std::ostringstream oss;
86+
oss << __FILE__ << ":" << line << ": " << msg;
87+
env->FatalError(oss.str().c_str());
88+
}
89+
8190
// This signal handler is for zygote mode, since the zygote must reap its children
8291
static void SigChldHandler(int /*signal_number*/) {
8392
pid_t pid;
@@ -439,6 +448,9 @@ static void SetForkLoad(bool boost) {
439448
}
440449
#endif
441450

451+
// The list of open zygote file descriptors.
452+
static FileDescriptorTable* gOpenFdTable = NULL;
453+
442454
// Utility routine to fork zygote and specialize the child process.
443455
static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray javaGids,
444456
jint debug_flags, jobjectArray javaRlimits,
@@ -453,6 +465,22 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra
453465
SetForkLoad(true);
454466
#endif
455467

468+
// Close any logging related FDs before we start evaluating the list of
469+
// file descriptors.
470+
__android_log_close();
471+
472+
// If this is the first fork for this zygote, create the open FD table.
473+
// If it isn't, we just need to check whether the list of open files has
474+
// changed (and it shouldn't in the normal case).
475+
if (gOpenFdTable == NULL) {
476+
gOpenFdTable = FileDescriptorTable::Create();
477+
if (gOpenFdTable == NULL) {
478+
RuntimeAbort(env, __LINE__, "Unable to construct file descriptor table.");
479+
}
480+
} else if (!gOpenFdTable->Restat()) {
481+
RuntimeAbort(env, __LINE__, "Unable to restat file descriptor table.");
482+
}
483+
456484
pid_t pid = fork();
457485

458486
if (pid == 0) {
@@ -462,6 +490,12 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra
462490
// Clean up any descriptors which must be closed immediately
463491
DetachDescriptors(env, fdsToClose);
464492

493+
// Re-open all remaining open file descriptors so that they aren't shared
494+
// with the zygote across a fork.
495+
if (!gOpenFdTable->ReopenOrDetach()) {
496+
RuntimeAbort(env, __LINE__, "Unable to reopen whitelisted descriptors.");
497+
}
498+
465499
// Keep capabilities across UID change, unless we're staying root.
466500
if (uid != 0) {
467501
EnableKeepCapabilities(env);

0 commit comments

Comments
 (0)