Merge "Merge QQ3A.200805.001" am: 4b3c00e75f

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1387434

Change-Id: I12420dd6aa080e632f4e3b2748b4970450a4ee72
This commit is contained in:
Xin Li
2020-08-05 21:19:12 +00:00
committed by Automerger Merge Worker
9 changed files with 70 additions and 32 deletions

View File

@@ -19,6 +19,7 @@ package android.app;
import static android.content.Context.DISPLAY_SERVICE; import static android.content.Context.DISPLAY_SERVICE;
import static android.content.Context.WINDOW_SERVICE; import static android.content.Context.WINDOW_SERVICE;
import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION; import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION;
import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context; import android.content.Context;
@@ -26,18 +27,18 @@ import android.content.res.Resources;
import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener; import android.hardware.display.DisplayManager.DisplayListener;
import android.os.Binder; import android.os.Binder;
import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.os.Message;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import android.view.Display; import android.view.Display;
import android.view.Gravity; import android.view.Gravity;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.WindowManagerImpl; import android.view.WindowManagerImpl;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
/** /**
* Base class for presentations. * Base class for presentations.
@@ -116,7 +117,9 @@ import android.util.TypedValue;
* The display manager keeps track of all displays in the system. However, not all * The display manager keeps track of all displays in the system. However, not all
* displays are appropriate for showing presentations. For example, if an activity * displays are appropriate for showing presentations. For example, if an activity
* attempted to show a presentation on the main display it might obscure its own content * attempted to show a presentation on the main display it might obscure its own content
* (it's like opening a dialog on top of your activity). * (it's like opening a dialog on top of your activity). Creating a presentation on the main
* display will result in {@link android.view.WindowManager.InvalidDisplayException} being thrown
* when invoking {@link #show()}.
* </p><p> * </p><p>
* Here's how to identify suitable displays for showing presentations using * Here's how to identify suitable displays for showing presentations using
* {@link DisplayManager#getDisplays(String)} and the * {@link DisplayManager#getDisplays(String)} and the
@@ -189,12 +192,16 @@ public class Presentation extends Dialog {
mDisplay = display; mDisplay = display;
mDisplayManager = (DisplayManager)getContext().getSystemService(DISPLAY_SERVICE); mDisplayManager = (DisplayManager)getContext().getSystemService(DISPLAY_SERVICE);
final int windowType =
(display.getFlags() & Display.FLAG_PRIVATE) != 0 ? TYPE_PRIVATE_PRESENTATION
: TYPE_PRESENTATION;
final Window w = getWindow(); final Window w = getWindow();
final WindowManager.LayoutParams attr = w.getAttributes(); final WindowManager.LayoutParams attr = w.getAttributes();
attr.token = mToken; attr.token = mToken;
w.setAttributes(attr); w.setAttributes(attr);
w.setGravity(Gravity.FILL); w.setGravity(Gravity.FILL);
w.setType(TYPE_PRESENTATION); w.setType(windowType);
setCanceledOnTouchOutside(false); setCanceledOnTouchOutside(false);
} }
@@ -243,7 +250,7 @@ public class Presentation extends Dialog {
/** /**
* Inherited from {@link Dialog#show}. Will throw * Inherited from {@link Dialog#show}. Will throw
* {@link android.view.WindowManager.InvalidDisplayException} if the specified secondary * {@link android.view.WindowManager.InvalidDisplayException} if the specified secondary
* {@link Display} can't be found. * {@link Display} can't be found or if it does not have {@link Display#FLAG_PRESENTATION} set.
*/ */
@Override @Override
public void show() { public void show() {

View File

@@ -92,10 +92,9 @@ public class AppZygote {
@GuardedBy("mLock") @GuardedBy("mLock")
private void stopZygoteLocked() { private void stopZygoteLocked() {
if (mZygote != null) { if (mZygote != null) {
// Close the connection and kill the zygote process. This will not cause
// child processes to be killed by itself.
mZygote.close(); mZygote.close();
Process.killProcess(mZygote.getPid()); // use killProcessGroup() here, so we kill all untracked children as well.
Process.killProcessGroup(mZygoteUid, mZygote.getPid());
mZygote = null; mZygote = null;
} }
} }

View File

@@ -1260,6 +1260,7 @@ public abstract class DocumentsProvider extends ContentProvider {
out.putParcelable(DocumentsContract.EXTRA_RESULT, path); out.putParcelable(DocumentsContract.EXTRA_RESULT, path);
} else if (METHOD_GET_DOCUMENT_METADATA.equals(method)) { } else if (METHOD_GET_DOCUMENT_METADATA.equals(method)) {
enforceReadPermissionInner(documentUri, getCallingPackage(), null);
return getDocumentMetadata(documentId); return getDocumentMetadata(documentId);
} else { } else {
throw new UnsupportedOperationException("Method not supported " + method); throw new UnsupportedOperationException("Method not supported " + method);

View File

@@ -507,8 +507,16 @@ static void UnsetChldSignalHandler() {
// Calls POSIX setgroups() using the int[] object as an argument. // Calls POSIX setgroups() using the int[] object as an argument.
// A nullptr argument is tolerated. // A nullptr argument is tolerated.
static void SetGids(JNIEnv* env, jintArray managed_gids, fail_fn_t fail_fn) { static void SetGids(JNIEnv* env, jintArray managed_gids, jboolean is_child_zygote,
fail_fn_t fail_fn) {
if (managed_gids == nullptr) { if (managed_gids == nullptr) {
if (is_child_zygote) {
// For child zygotes like webview and app zygote, we want to clear out
// any supplemental groups the parent zygote had.
if (setgroups(0, NULL) == -1) {
fail_fn(CREATE_ERROR("Failed to remove supplementary groups for child zygote"));
}
}
return; return;
} }
@@ -1163,7 +1171,7 @@ static void SpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray gids,
} }
} }
SetGids(env, gids, fail_fn); SetGids(env, gids, is_child_zygote, fail_fn);
SetRLimits(env, rlimits, fail_fn); SetRLimits(env, rlimits, fail_fn);
if (need_pre_initialize_native_bridge) { if (need_pre_initialize_native_bridge) {

View File

@@ -167,7 +167,7 @@ class ImageGLWallpaper {
private void setupTexture(Bitmap bitmap) { private void setupTexture(Bitmap bitmap) {
final int[] tids = new int[1]; final int[] tids = new int[1];
if (bitmap == null) { if (bitmap == null || bitmap.isRecycled()) {
Log.w(TAG, "setupTexture: invalid bitmap"); Log.w(TAG, "setupTexture: invalid bitmap");
return; return;
} }
@@ -179,16 +179,20 @@ class ImageGLWallpaper {
return; return;
} }
// Bind a named texture to a target. try {
glBindTexture(GL_TEXTURE_2D, tids[0]); // Bind a named texture to a target.
// Load the bitmap data and copy it over into the texture object that is currently bound. glBindTexture(GL_TEXTURE_2D, tids[0]);
GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0); // Load the bitmap data and copy it over into the texture object
// Use bilinear texture filtering when minification. // that is currently bound.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);
// Use bilinear texture filtering when magnification. // Use bilinear texture filtering when minification.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// Use bilinear texture filtering when magnification.
mTextureId = tids[0]; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
mTextureId = tids[0];
} catch (IllegalArgumentException e) {
Log.w(TAG, "Failed uploading texture: " + e.getLocalizedMessage());
}
} }
void useTexture() { void useTexture() {

View File

@@ -86,7 +86,13 @@ class ImageProcessHelper {
protected Float doInBackground(Bitmap... bitmaps) { protected Float doInBackground(Bitmap... bitmaps) {
Bitmap bitmap = bitmaps[0]; Bitmap bitmap = bitmaps[0];
if (bitmap != null) { if (bitmap != null) {
return new Threshold().compute(bitmap); try {
return new Threshold().compute(bitmap);
} catch (RuntimeException e) {
Log.e(TAG, "Failed at computing threshold, color space="
+ bitmap.getColorSpace(), e);
return DEFAULT_THRESHOLD;
}
} }
Log.e(TAG, "ThresholdComputeTask: Can't get bitmap"); Log.e(TAG, "ThresholdComputeTask: Can't get bitmap");
return DEFAULT_THRESHOLD; return DEFAULT_THRESHOLD;
@@ -116,7 +122,8 @@ class ImageProcessHelper {
int width = bitmap.getWidth(); int width = bitmap.getWidth();
int height = bitmap.getHeight(); int height = bitmap.getHeight();
Bitmap grayscale = Bitmap.createBitmap(width, height, bitmap.getConfig()); Bitmap grayscale = Bitmap.createBitmap(width, height,
bitmap.getConfig(), false, bitmap.getColorSpace());
Canvas canvas = new Canvas(grayscale); Canvas canvas = new Canvas(grayscale);
ColorMatrix cm = new ColorMatrix(LUMINOSITY_MATRIX); ColorMatrix cm = new ColorMatrix(LUMINOSITY_MATRIX);
Paint paint = new Paint(); Paint paint = new Paint();

View File

@@ -269,7 +269,7 @@ public class InstantAppNotifier extends SystemUI
0, 0,
new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
.setData(Uri.fromParts("package", pkg, null)), .setData(Uri.fromParts("package", pkg, null)),
0, PendingIntent.FLAG_IMMUTABLE,
null, null,
user); user);
Notification.Action action = Notification.Action action =
@@ -282,7 +282,7 @@ public class InstantAppNotifier extends SystemUI
mContext, mContext,
0, 0,
new Intent(Intent.ACTION_VIEW).setData(Uri.parse(helpUrl)), new Intent(Intent.ACTION_VIEW).setData(Uri.parse(helpUrl)),
0, PendingIntent.FLAG_IMMUTABLE,
null, null,
user) user)
: null; : null;
@@ -303,7 +303,7 @@ public class InstantAppNotifier extends SystemUI
mContext, mContext,
0 /* requestCode */, 0 /* requestCode */,
browserIntent, browserIntent,
0 /* flags */, PendingIntent.FLAG_IMMUTABLE /* flags */,
null, null,
user); user);
ComponentName aiaComponent = null; ComponentName aiaComponent = null;
@@ -325,8 +325,8 @@ public class InstantAppNotifier extends SystemUI
.putExtra(Intent.EXTRA_LONG_VERSION_CODE, appInfo.longVersionCode) .putExtra(Intent.EXTRA_LONG_VERSION_CODE, appInfo.longVersionCode)
.putExtra(Intent.EXTRA_INSTANT_APP_FAILURE, pendingIntent); .putExtra(Intent.EXTRA_INSTANT_APP_FAILURE, pendingIntent);
PendingIntent webPendingIntent = PendingIntent webPendingIntent = PendingIntent.getActivityAsUser(mContext, 0,
PendingIntent.getActivityAsUser(mContext, 0, goToWebIntent, 0, null, user); goToWebIntent, PendingIntent.FLAG_IMMUTABLE, null, user);
Notification.Action webAction = Notification.Action webAction =
new Notification.Action.Builder( new Notification.Action.Builder(
null, mContext.getString(R.string.go_to_web), webPendingIntent) null, mContext.getString(R.string.go_to_web), webPendingIntent)

View File

@@ -383,7 +383,11 @@ class AppErrors {
// and then the delayed summary kill will be a no-op. // and then the delayed summary kill will be a no-op.
final ProcessRecord p = proc; final ProcessRecord p = proc;
mService.mHandler.postDelayed( mService.mHandler.postDelayed(
() -> killAppImmediateLocked(p, "forced", "killed for invalid state"), () -> {
synchronized (mService) {
killAppImmediateLocked(p, "forced", "killed for invalid state");
}
},
5000L); 5000L);
} }
} }

View File

@@ -61,6 +61,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_DREAM;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION;
import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION; import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION;
import static android.view.WindowManager.LayoutParams.TYPE_QS_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_QS_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
@@ -1297,6 +1298,13 @@ public class WindowManagerService extends IWindowManager.Stub
return WindowManagerGlobal.ADD_PERMISSION_DENIED; return WindowManagerGlobal.ADD_PERMISSION_DENIED;
} }
if (type == TYPE_PRESENTATION && !displayContent.getDisplay().isPublicPresentation()) {
Slog.w(TAG_WM,
"Attempted to add presentation window to a non-suitable display. "
+ "Aborting.");
return WindowManagerGlobal.ADD_INVALID_DISPLAY;
}
AppWindowToken atoken = null; AppWindowToken atoken = null;
final boolean hasParent = parentWindow != null; final boolean hasParent = parentWindow != null;
// Use existing parent window token for child windows since they go in the same token // Use existing parent window token for child windows since they go in the same token