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

Commit 83214ed5 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6560464 from 3314f72c to rvc-release

Change-Id: Ib5ad0b7da5b140104e8cbc8ee4e95d0ec217ba1d
parents 1573d649 3314f72c
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -61,8 +61,7 @@ Result<Unit> CheckOverlayable(const LoadedPackage& target_package,
                              const ResourceId& target_resource) {
  static constexpr const PolicyBitmask sDefaultPolicies =
      PolicyFlags::ODM_PARTITION | PolicyFlags::OEM_PARTITION | PolicyFlags::SYSTEM_PARTITION |
      PolicyFlags::VENDOR_PARTITION | PolicyFlags::PRODUCT_PARTITION | PolicyFlags::SIGNATURE |
      PolicyFlags::ACTOR_SIGNATURE;
      PolicyFlags::VENDOR_PARTITION | PolicyFlags::PRODUCT_PARTITION | PolicyFlags::SIGNATURE;

  // If the resource does not have an overlayable definition, allow the resource to be overlaid if
  // the overlay is preinstalled or signed with the same signature as the target.
+55 −15
Original line number Diff line number Diff line
@@ -287,26 +287,66 @@ TEST(ResourceMappingTests, ResourcesFromApkAssetsNoDefinedOverlayableAndNoTarget
                              R::overlay::string::str4, false /* rewrite */));
}


// Overlays that are pre-installed or are signed with the same signature as the target/actor can
// Overlays that are neither pre-installed nor signed with the same signature as the target cannot
// overlay packages that have not defined overlayable resources.
TEST(ResourceMappingTests, ResourcesFromApkAssetsDefaultPolicies) {
  constexpr PolicyBitmask kDefaultPolicies =
      PolicyFlags::SIGNATURE | PolicyFlags::ACTOR_SIGNATURE | PolicyFlags::PRODUCT_PARTITION |
      PolicyFlags::SYSTEM_PARTITION | PolicyFlags::VENDOR_PARTITION | PolicyFlags::ODM_PARTITION |
      PolicyFlags::OEM_PARTITION;
TEST(ResourceMappingTests, ResourcesFromApkAssetsDefaultPoliciesPublicFail) {
  auto resources = TestGetResourceMapping("/target/target-no-overlayable.apk",
                                          "/overlay/overlay-no-name.apk", PolicyFlags::PUBLIC,
                                          /* enforce_overlayable */ true);

  ASSERT_TRUE(resources) << resources.GetErrorMessage();
  ASSERT_EQ(resources->GetTargetToOverlayMap().size(), 0U);
}

  for (PolicyBitmask policy = 1U << (sizeof(PolicyBitmask) * 8 - 1); policy > 0;
       policy = policy >> 1U) {
// Overlays that are pre-installed or are signed with the same signature as the target can overlay
// packages that have not defined overlayable resources.
TEST(ResourceMappingTests, ResourcesFromApkAssetsDefaultPolicies) {
  auto CheckEntries = [&](const PolicyBitmask& fulfilled_policies) -> void {
    auto resources = TestGetResourceMapping("/target/target-no-overlayable.apk",
                                            "/system-overlay-invalid/system-overlay-invalid.apk",
                                            policy, /* enforce_overlayable */ true);
    ASSERT_TRUE(resources) << resources.GetErrorMessage();
                                            fulfilled_policies,
                                            /* enforce_overlayable */ true);

    const size_t expected_overlaid = (policy & kDefaultPolicies) != 0 ? 10U : 0U;
    ASSERT_EQ(expected_overlaid, resources->GetTargetToOverlayMap().size())
        << "Incorrect number of resources overlaid through policy " << policy;
  }
    ASSERT_TRUE(resources) << resources.GetErrorMessage();
    auto& res = *resources;
    ASSERT_EQ(resources->GetTargetToOverlayMap().size(), 10U);
    ASSERT_RESULT(MappingExists(res, R::target::string::not_overlayable, Res_value::TYPE_REFERENCE,
                                R::system_overlay_invalid::string::not_overlayable,
                                false /* rewrite */));
    ASSERT_RESULT(MappingExists(res, R::target::string::other, Res_value::TYPE_REFERENCE,
                                R::system_overlay_invalid::string::other, false /* rewrite */));
    ASSERT_RESULT(MappingExists(res, R::target::string::policy_actor, Res_value::TYPE_REFERENCE,
                                R::system_overlay_invalid::string::policy_actor,
                                false /* rewrite */));
    ASSERT_RESULT(MappingExists(res, R::target::string::policy_odm, Res_value::TYPE_REFERENCE,
                                R::system_overlay_invalid::string::policy_odm,
                                false /* rewrite */));
    ASSERT_RESULT(MappingExists(res, R::target::string::policy_oem, Res_value::TYPE_REFERENCE,
                                R::system_overlay_invalid::string::policy_oem,
                                false /* rewrite */));
    ASSERT_RESULT(MappingExists(res, R::target::string::policy_product, Res_value::TYPE_REFERENCE,
                                R::system_overlay_invalid::string::policy_product,
                                false /* rewrite */));
    ASSERT_RESULT(MappingExists(res, R::target::string::policy_public, Res_value::TYPE_REFERENCE,
                                R::system_overlay_invalid::string::policy_public,
                                false /* rewrite */));
    ASSERT_RESULT(MappingExists(res, R::target::string::policy_signature, Res_value::TYPE_REFERENCE,
                                R::system_overlay_invalid::string::policy_signature,
                                false /* rewrite */));
    ASSERT_RESULT(MappingExists(res, R::target::string::policy_system, Res_value::TYPE_REFERENCE,
                                R::system_overlay_invalid::string::policy_system,
                                false /* rewrite */));
    ASSERT_RESULT(MappingExists(
        res, R::target::string::policy_system_vendor, Res_value::TYPE_REFERENCE,
        R::system_overlay_invalid::string::policy_system_vendor, false /* rewrite */));
  };

  CheckEntries(PolicyFlags::SIGNATURE);
  CheckEntries(PolicyFlags::PRODUCT_PARTITION);
  CheckEntries(PolicyFlags::SYSTEM_PARTITION);
  CheckEntries(PolicyFlags::VENDOR_PARTITION);
  CheckEntries(PolicyFlags::ODM_PARTITION);
  CheckEntries(PolicyFlags::OEM_PARTITION);
}

}  // namespace android::idmap2
+55 −0
Original line number Diff line number Diff line
@@ -446,6 +446,9 @@ message Atom {
            277 [(module) = "settings"];
        CellBroadcastMessageFiltered cb_message_filtered =
            278 [(module) = "cellbroadcast"];
        TvTunerDvrStatus tv_tuner_dvr_status = 279 [(module) = "framework"];
        TvCasSessionOpenStatus tv_cas_session_open_status =
            280 [(module) = "framework"];

        // StatsdStats tracks platform atoms with ids upto 500.
        // Update StatsdStats::kMaxPushedAtomId when atom ids here approach that value.
@@ -9242,6 +9245,58 @@ message TvTunerStateChanged {
    //  new state
    optional State state = 2;
}

/**
 * Logs the status of a dvr playback or record.
 * This is atom ID 279.
 *
 * Logged from:
 *   frameworks/base/media/java/android/media/tv/tuner/dvr
 */
message TvTunerDvrStatus {
    enum Type {
        UNKNOWN_TYPE = 0;
        PLAYBACK = 1; // is a playback
        RECORD = 2; // is a record
    }
    enum State {
        UNKNOWN_STATE = 0;
        STARTED = 1; // DVR is started
        STOPPED = 2; // DVR is stopped
    }
    // The uid of the application that sent this custom atom.
    optional int32 uid = 1 [(is_uid) = true];
    // DVR type
    optional Type type = 2;
    //  DVR state
    optional State state = 3;
    //  Identify the segment of a record or playback
    optional int32 segment_id = 4;
    // indicate how many overflow or underflow happened between started to stopped
    optional int32 overflow_underflow_count = 5;
}

/**
 * Logs when a cas session opened through MediaCas.
 * This is atom ID 280.
 *
 * Logged from:
 *   frameworks/base/media/java/android/media/MediaCas.java
 */
message TvCasSessionOpenStatus {
    enum State {
        UNKNOWN = 0;
        SUCCEEDED = 1; // indicate that the session is opened successfully.
        FAILED = 2; // indicate that the session isn’t opened successfully.
    }
    // The uid of the application that sent this custom atom.
    optional int32 uid = 1 [(is_uid) = true];
    //  Cas system Id
    optional int32 cas_system_id = 2;
    // State of the session
    optional State state = 3;
}

/**
 * Logs when an app is frozen or unfrozen.
 *
+64 −9
Original line number Diff line number Diff line
@@ -3252,19 +3252,57 @@ public final class ActivityThread extends ClientTransactionHandler {
    @Override
    public void handleFixedRotationAdjustments(@NonNull IBinder token,
            @Nullable FixedRotationAdjustments fixedRotationAdjustments) {
        final Consumer<DisplayAdjustments> override = fixedRotationAdjustments != null
                ? displayAdjustments -> displayAdjustments.setFixedRotationAdjustments(
                        fixedRotationAdjustments)
                : null;
        handleFixedRotationAdjustments(token, fixedRotationAdjustments, null /* overrideConfig */);
    }

    /**
     * Applies the rotation adjustments to override display information in resources belong to the
     * provided token. If the token is activity token, the adjustments also apply to application
     * because the appearance of activity is usually more sensitive to the application resources.
     *
     * @param token The token to apply the adjustments.
     * @param fixedRotationAdjustments The information to override the display adjustments of
     *                                 corresponding resources. If it is null, the exiting override
     *                                 will be cleared.
     * @param overrideConfig The override configuration of activity. It is used to override
     *                       application configuration. If it is non-null, it means the token is
     *                       confirmed as activity token. Especially when launching new activity,
     *                       {@link #mActivities} hasn't put the new token.
     */
    private void handleFixedRotationAdjustments(@NonNull IBinder token,
            @Nullable FixedRotationAdjustments fixedRotationAdjustments,
            @Nullable Configuration overrideConfig) {
        // The element of application configuration override is set only if the application
        // adjustments are needed, because activity already has its own override configuration.
        final Configuration[] appConfigOverride;
        final Consumer<DisplayAdjustments> override;
        if (fixedRotationAdjustments != null) {
            appConfigOverride = new Configuration[1];
            override = displayAdjustments -> {
                displayAdjustments.setFixedRotationAdjustments(fixedRotationAdjustments);
                if (appConfigOverride[0] != null) {
                    displayAdjustments.getConfiguration().updateFrom(appConfigOverride[0]);
                }
            };
        } else {
            appConfigOverride = null;
            override = null;
        }
        if (!mResourcesManager.overrideTokenDisplayAdjustments(token, override)) {
            // No resources are associated with the token.
            return;
        }
        if (mActivities.get(token) == null) {
            // Only apply the override to application for activity token because the appearance of
            // activity is usually more sensitive to the application resources.
        if (overrideConfig == null) {
            final ActivityClientRecord r = mActivities.get(token);
            if (r == null) {
                // It is not an activity token. Nothing to do for application.
                return;
            }
            overrideConfig = r.overrideConfig;
        }
        if (appConfigOverride != null) {
            appConfigOverride[0] = overrideConfig;
        }

        // Apply the last override to application resources for compatibility. Because the Resources
        // of Display can be from application, e.g.
@@ -3503,7 +3541,8 @@ public final class ActivityThread extends ClientTransactionHandler {
        // The rotation adjustments must be applied before creating the activity, so the activity
        // can get the adjusted display info during creation.
        if (r.mPendingFixedRotationAdjustments != null) {
            handleFixedRotationAdjustments(r.token, r.mPendingFixedRotationAdjustments);
            handleFixedRotationAdjustments(r.token, r.mPendingFixedRotationAdjustments,
                    r.overrideConfig);
            r.mPendingFixedRotationAdjustments = null;
        }

@@ -7388,6 +7427,10 @@ public final class ActivityThread extends ClientTransactionHandler {
        }
    }

    public Bundle getCoreSettings() {
        return mCoreSettings;
    }

    public int getIntCoreSetting(String key, int defaultValue) {
        synchronized (mResourcesManager) {
            if (mCoreSettings != null) {
@@ -7397,6 +7440,18 @@ public final class ActivityThread extends ClientTransactionHandler {
        }
    }

    /**
     * Get the string value of the given key from core settings.
     */
    public String getStringCoreSetting(String key, String defaultValue) {
        synchronized (mResourcesManager) {
            if (mCoreSettings != null) {
                return mCoreSettings.getString(key, defaultValue);
            }
            return defaultValue;
        }
    }

    float getFloatCoreSetting(String key, float defaultValue) {
        synchronized (mResourcesManager) {
            if (mCoreSettings != null) {
+10 −0
Original line number Diff line number Diff line
@@ -216,4 +216,14 @@ oneway interface ITaskStackListener {
     *                             in {@link android.content.pm.ActivityInfo}.
     */
     void onTaskRequestedOrientationChanged(int taskId, int requestedOrientation);

    /**
     * Called when a rotation is about to start on the foreground activity.
     * This applies for:
     *   * free sensor rotation
     *   * forced rotation
     *   * rotation settings set through adb command line
     *   * rotation that occurs when rotation tile is toggled in quick settings
     */
     void onActivityRotation();
}
Loading