Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 29664baf authored by William Xiao's avatar William Xiao Committed by Android (Google) Code Review
Browse files

Merge "Implement flag to not relaunch on dock config change for apps without...

Merge "Implement flag to not relaunch on dock config change for apps without -desk resources" into udc-dev
parents fbb43217 d631b010
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1452,6 +1452,16 @@ public final class AssetManager implements AutoCloseable {
        }
    }

    /**
     * @hide
     */
    Configuration[] getSizeAndUiModeConfigurations() {
        synchronized (this) {
            ensureValidLocked();
            return nativeGetSizeAndUiModeConfigurations(mObject);
        }
    }

    /**
     * Change the configuration used when retrieving resources.  Not for use by
     * applications.
@@ -1604,6 +1614,7 @@ public final class AssetManager implements AutoCloseable {
    private static native @Nullable String nativeGetResourceEntryName(long ptr, @AnyRes int resid);
    private static native @Nullable String[] nativeGetLocales(long ptr, boolean excludeSystem);
    private static native @Nullable Configuration[] nativeGetSizeConfigurations(long ptr);
    private static native @Nullable Configuration[] nativeGetSizeAndUiModeConfigurations(long ptr);
    private static native void nativeSetResourceResolutionLoggingEnabled(long ptr, boolean enabled);
    private static native @Nullable String nativeGetLastResourceResolution(long ptr);

+5 −0
Original line number Diff line number Diff line
@@ -2232,6 +2232,11 @@ public class Resources {
        return mResourcesImpl.getSizeConfigurations();
    }

    /** @hide */
    public Configuration[] getSizeAndUiModeConfigurations() {
        return mResourcesImpl.getSizeAndUiModeConfigurations();
    }

    /**
     * Return the compatibility mode information for the application.
     * The returned object should be treated as read-only.
+4 −0
Original line number Diff line number Diff line
@@ -207,6 +207,10 @@ public class ResourcesImpl {
        return mAssets.getSizeConfigurations();
    }

    Configuration[] getSizeAndUiModeConfigurations() {
        return mAssets.getSizeAndUiModeConfigurations();
    }

    CompatibilityInfo getCompatibilityInfo() {
        return mDisplayAdjustments.getCompatibilityInfo();
    }
+14 −1
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ static struct configuration_offsets_t {
  jfieldID mScreenWidthDpOffset;
  jfieldID mScreenHeightDpOffset;
  jfieldID mScreenLayoutOffset;
  jfieldID mUiMode;
} gConfigurationOffsets;

static struct arraymap_offsets_t {
@@ -1030,10 +1031,11 @@ static jobject ConstructConfigurationObject(JNIEnv* env, const ResTable_config&
  env->SetIntField(result, gConfigurationOffsets.mScreenWidthDpOffset, config.screenWidthDp);
  env->SetIntField(result, gConfigurationOffsets.mScreenHeightDpOffset, config.screenHeightDp);
  env->SetIntField(result, gConfigurationOffsets.mScreenLayoutOffset, config.screenLayout);
  env->SetIntField(result, gConfigurationOffsets.mUiMode, config.uiMode);
  return result;
}

static jobjectArray NativeGetSizeConfigurations(JNIEnv* env, jclass /*clazz*/, jlong ptr) {
static jobjectArray GetSizeAndUiModeConfigurations(JNIEnv* env, jlong ptr) {
  ScopedLock<AssetManager2> assetmanager(AssetManagerFromLong(ptr));
  auto configurations = assetmanager->GetResourceConfigurations(true /*exclude_system*/,
                                                                false /*exclude_mipmap*/);
@@ -1060,6 +1062,14 @@ static jobjectArray NativeGetSizeConfigurations(JNIEnv* env, jclass /*clazz*/, j
  return array;
}

static jobjectArray NativeGetSizeConfigurations(JNIEnv* env, jclass /*clazz*/, jlong ptr) {
  return GetSizeAndUiModeConfigurations(env, ptr);
}

static jobjectArray NativeGetSizeAndUiModeConfigurations(JNIEnv* env, jclass /*clazz*/, jlong ptr) {
  return GetSizeAndUiModeConfigurations(env, ptr);
}

static jintArray NativeAttributeResolutionStack(
    JNIEnv* env, jclass /*clazz*/, jlong ptr,
    jlong theme_ptr, jint xml_style_res,
@@ -1494,6 +1504,8 @@ static const JNINativeMethod gAssetManagerMethods[] = {
    {"nativeGetLocales", "(JZ)[Ljava/lang/String;", (void*)NativeGetLocales},
    {"nativeGetSizeConfigurations", "(J)[Landroid/content/res/Configuration;",
     (void*)NativeGetSizeConfigurations},
    {"nativeGetSizeAndUiModeConfigurations", "(J)[Landroid/content/res/Configuration;",
     (void*)NativeGetSizeAndUiModeConfigurations},

    // Style attribute related methods.
    {"nativeAttributeResolutionStack", "(JJIII)[I", (void*)NativeAttributeResolutionStack},
@@ -1572,6 +1584,7 @@ int register_android_content_AssetManager(JNIEnv* env) {
      GetFieldIDOrDie(env, configurationClass, "screenHeightDp", "I");
  gConfigurationOffsets.mScreenLayoutOffset =
          GetFieldIDOrDie(env, configurationClass, "screenLayout", "I");
  gConfigurationOffsets.mUiMode = GetFieldIDOrDie(env, configurationClass, "uiMode", "I");

  jclass arrayMapClass = FindClassOrDie(env, "android/util/ArrayMap");
  gArrayMapOffsets.classObject = MakeGlobalRefOrDie(env, arrayMapClass);
+6 −0
Original line number Diff line number Diff line
@@ -5593,6 +5593,12 @@
         treatment for stretched issues in camera viewfinder. -->
    <bool name="config_isCameraCompatControlForStretchedIssuesEnabled">false</bool>

    <!-- Docking is a uiMode configuration change and will cause activities to relaunch if it's not
         handled. If true, the configuration change will be sent but activities will not be
         relaunched upon docking. Apps with desk resources will behave like normal, since they may
         expect the relaunch upon the desk uiMode change. -->
    <bool name="config_skipActivityRelaunchWhenDocking">false</bool>

    <!-- If true, hide the display cutout with display area -->
    <bool name="config_hideDisplayCutoutWithDisplayArea">false</bool>

Loading