Merge "[pm] fix PackageManagerServiceTest"
diff --git a/api/StubLibraries.bp b/api/StubLibraries.bp
index 93d20dd..ed5a8f2 100644
--- a/api/StubLibraries.bp
+++ b/api/StubLibraries.bp
@@ -341,7 +341,7 @@
 }
 
 java_library {
-    name: "android_stubs_current",
+    name: "android_stubs_current.from-source",
     static_libs: [
         "all-modules-public-stubs",
         "android-non-updatable.stubs",
@@ -351,7 +351,7 @@
 }
 
 java_library {
-    name: "android_system_stubs_current",
+    name: "android_system_stubs_current.from-source",
     static_libs: [
         "all-modules-system-stubs",
         "android-non-updatable.stubs.system",
@@ -375,7 +375,7 @@
 }
 
 java_library {
-    name: "android_test_stubs_current",
+    name: "android_test_stubs_current.from-source",
     static_libs: [
         // Updatable modules do not have test APIs, but we want to include their SystemApis, like we
         // include the SystemApi of framework-non-updatable-sources.
@@ -395,7 +395,7 @@
 }
 
 java_library {
-    name: "android_module_lib_stubs_current",
+    name: "android_module_lib_stubs_current.from-source",
     defaults: [
         "android.jar_defaults",
         "android_stubs_dists_default",
@@ -411,7 +411,7 @@
 }
 
 java_library {
-    name: "android_system_server_stubs_current",
+    name: "android_system_server_stubs_current.from-source",
     defaults: [
         "android.jar_defaults",
         "android_stubs_dists_default",
@@ -419,7 +419,7 @@
     srcs: [":services-non-updatable-stubs"],
     installable: false,
     static_libs: [
-        "android_module_lib_stubs_current",
+        "android_module_lib_stubs_current.from-source",
     ],
     dist: {
         dir: "apistubs/android/system-server",
diff --git a/api/api.go b/api/api.go
index af817b5..c568a45 100644
--- a/api/api.go
+++ b/api/api.go
@@ -96,6 +96,7 @@
 	Sdk_version *string
 	Static_libs []string
 	Visibility  []string
+	Defaults    []string
 }
 
 type fgProps struct {
@@ -362,6 +363,30 @@
 	}
 }
 
+func createFullApiLibraries(ctx android.LoadHookContext) {
+	javaLibraryNames := []string{
+		"android_stubs_current",
+		"android_system_stubs_current",
+		"android_test_stubs_current",
+		"android_module_lib_stubs_current",
+		"android_system_server_stubs_current",
+	}
+
+	for _, libraryName := range javaLibraryNames {
+		props := libraryProps{}
+		props.Name = proptools.StringPtr(libraryName)
+		staticLib := libraryName + ".from-source"
+		if ctx.Config().BuildFromTextStub() {
+			staticLib = libraryName + ".from-text"
+		}
+		props.Static_libs = []string{staticLib}
+		props.Defaults = []string{"android.jar_defaults"}
+		props.Visibility = []string{"//visibility:public"}
+
+		ctx.CreateModule(java.LibraryFactory, &props)
+	}
+}
+
 func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) {
 	bootclasspath := a.properties.Bootclasspath
 	system_server_classpath := a.properties.System_server_classpath
@@ -382,6 +407,8 @@
 	createPublicStubsSourceFilegroup(ctx, bootclasspath)
 
 	createApiContributionDefaults(ctx, bootclasspath)
+
+	createFullApiLibraries(ctx)
 }
 
 func combinedApisModuleFactory() android.Module {
diff --git a/api/api_test.go b/api/api_test.go
index 15b695c..1f4c2af 100644
--- a/api/api_test.go
+++ b/api/api_test.go
@@ -19,6 +19,7 @@
 
 	"android/soong/android"
 	"android/soong/bp2build"
+	"android/soong/java"
 )
 
 func runCombinedApisTestCaseWithRegistrationCtxFunc(t *testing.T, tc bp2build.Bp2buildTestCase, registrationCtxFunc func(ctx android.RegistrationContext)) {
@@ -30,7 +31,9 @@
 
 func runCombinedApisTestCase(t *testing.T, tc bp2build.Bp2buildTestCase) {
 	t.Helper()
-	runCombinedApisTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) {})
+	runCombinedApisTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) {
+		ctx.RegisterModuleType("java_defaults", java.DefaultsFactory)
+	})
 }
 
 func TestCombinedApisGeneral(t *testing.T) {
@@ -42,6 +45,13 @@
     system_server_classpath: ["ssc"],
 }
 `,
+		Filesystem: map[string]string{
+			"a/Android.bp": `
+			java_defaults {
+				name: "android.jar_defaults",
+			}
+			`,
+		},
 		ExpectedBazelTargets: []string{
 			bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-current.txt", bp2build.AttrNameToString{
 				"scope": `"public"`,
diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java
index 20230e7..0427d10 100644
--- a/core/java/android/webkit/CookieManager.java
+++ b/core/java/android/webkit/CookieManager.java
@@ -103,15 +103,22 @@
      * will be ignored if it is expired. To set multiple cookies, your application should invoke
      * this method multiple times.
      *
-     * <p>The {@code value} parameter must follow the format of the {@code Set-Cookie} HTTP
-     * response header defined by
-     * <a href="https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03">RFC6265bis</a>.
-     * This is a key-value pair of the form {@code "key=value"}, optionally followed by a list of
-     * cookie attributes delimited with semicolons (ex. {@code "key=value; Max-Age=123"}). Please
-     * consult the RFC specification for a list of valid attributes.
+     * <p>The {@code value} parameter must follow the format of the {@code Set-Cookie} HTTP response
+     * header. This is a key-value pair of the form {@code "key=value"}, optionally followed by a
+     * list of cookie attributes delimited with semicolons (ex. {@code "key=value; Max-Age=123"}).
+     * For the header format and attributes supported by WebView, see the <a href=
+     * "https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie">{@code Set-Cookie}
+     * documentation on MDN</a>.
      *
-     * <p class="note"><b>Note:</b> if specifying a {@code value} containing the {@code "Secure"}
-     * attribute, {@code url} must use the {@code "https://"} scheme.
+     * <p class="note">
+     * <b>Notes:</b>
+     * <ul>
+     * <li>If specifying a {@code value} containing the {@code "Secure"} attribute,
+     * {@code url} must use the {@code "https://"} scheme.</li>
+     * <li>if specifying a {@code value} containing the {@code "Partitioned"}
+     * attribute, the cookie will be set for the top-level partition of the
+     * {@code url}.</li>
+     * </ul>
      *
      * @param url the URL for which the cookie is to be set
      * @param value the cookie as a string, using the format of the 'Set-Cookie'
@@ -125,12 +132,12 @@
      * will be ignored if it is expired. To set multiple cookies, your application should invoke
      * this method multiple times.
      *
-     * <p>The {@code value} parameter must follow the format of the {@code Set-Cookie} HTTP
-     * response header defined by
-     * <a href="https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03">RFC6265bis</a>.
-     * This is a key-value pair of the form {@code "key=value"}, optionally followed by a list of
-     * cookie attributes delimited with semicolons (ex. {@code "key=value; Max-Age=123"}). Please
-     * consult the RFC specification for a list of valid attributes.
+     * <p>The {@code value} parameter must follow the format of the {@code Set-Cookie} HTTP response
+     * header. This is a key-value pair of the form {@code "key=value"}, optionally followed by a
+     * list of cookie attributes delimited with semicolons (ex. {@code "key=value; Max-Age=123"}).
+     * For the header format and attributes supported by WebView, see the <a href=
+     * "https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie">{@code Set-Cookie}
+     * documentation on MDN</a>.
      *
      * <p>This method is asynchronous. If a {@link ValueCallback} is provided,
      * {@link ValueCallback#onReceiveValue} will be called on the current
@@ -140,8 +147,15 @@
      * completes or whether it succeeded, and in this case it is safe to call the method from a
      * thread without a Looper.
      *
-     * <p class="note"><b>Note:</b> if specifying a {@code value} containing the {@code "Secure"}
-     * attribute, {@code url} must use the {@code "https://"} scheme.
+     * <p class="note">
+     * <b>Notes:</b>
+     * <ul>
+     * <li>If specifying a {@code value} containing the {@code "Secure"} attribute,
+     * {@code url} must use the {@code "https://"} scheme.</li>
+     * <li>if specifying a {@code value} containing the {@code "Partitioned"}
+     * attribute, the cookie will be set for the top-level partition of the
+     * {@code url}.</li>
+     * </ul>
      *
      * @param url the URL for which the cookie is to be set
      * @param value the cookie as a string, using the format of the 'Set-Cookie'
@@ -157,6 +171,10 @@
      * "; "} characters (semicolon followed by a space). Each key-value pair will be of the form
      * {@code "key=value"}.
      *
+     * <p class="note">
+     * <b>Note:</b> Any cookies set with the {@code "Partitioned"} attribute will only be returned
+     * for the top-level partition of {@code url}.
+     *
      * @param url the URL for which the cookies are requested
      * @return value the cookies as a string, using the format of the 'Cookie'
      *               HTTP request header
diff --git a/data/fonts/fonts.xml b/data/fonts/fonts.xml
index c9c1af8..ab323ad 100644
--- a/data/fonts/fonts.xml
+++ b/data/fonts/fonts.xml
@@ -273,6 +273,99 @@
     </family>
     <alias name="source-sans-pro-semi-bold" to="source-sans-pro" weight="600"/>
 
+    <family name="roboto-flex">
+        <font weight="100" style="normal">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="0" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="100" />
+        </font>
+        <font weight="200" style="normal">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="0" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="200" />
+        </font>
+        <font weight="300" style="normal">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="0" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="300" />
+        </font>
+        <font weight="400" style="normal">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="0" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="400" />
+        </font>
+        <font weight="500" style="normal">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="0" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="500" />
+        </font>
+        <font weight="600" style="normal">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="0" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="600" />
+        </font>
+        <font weight="700" style="normal">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="0" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="700" />
+        </font>
+        <font weight="800" style="normal">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="0" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="800" />
+        </font>
+        <font weight="900" style="normal">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="0" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="900" />
+        </font>
+        <font weight="100" style="italic">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="-10" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="100" />
+        </font>
+        <font weight="200" style="italic">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="-10" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="200" />
+        </font>
+        <font weight="300" style="italic">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="-10" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="300" />
+        </font>
+        <font weight="400" style="italic">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="-10" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="400" />
+        </font>
+        <font weight="500" style="italic">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="-10" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="500" />
+        </font>
+        <font weight="600" style="italic">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="-10" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="600" />
+        </font>
+        <font weight="700" style="italic">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="-10" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="700" />
+        </font>
+        <font weight="800" style="italic">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="-10" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="800" />
+        </font>
+        <font weight="900" style="italic">RobotoFlex-Regular.ttf
+          <axis tag="slnt" stylevalue="-10" />
+          <axis tag="wdth" stylevalue="100" />
+          <axis tag="wght" stylevalue="900" />
+        </font>
+    </family>
+
     <!-- fallback fonts -->
     <family lang="und-Arab" variant="elegant">
         <font weight="400" style="normal" postScriptName="NotoNaskhArabic">
diff --git a/media/jni/android_media_tv_Tuner.cpp b/media/jni/android_media_tv_Tuner.cpp
index 397c704..6c79dcc 100644
--- a/media/jni/android_media_tv_Tuner.cpp
+++ b/media/jni/android_media_tv_Tuner.cpp
@@ -1342,6 +1342,10 @@
         return (int)Result::INVALID_STATE;
     }
 
+    if (mDemuxClient != NULL) {
+        mDemuxClient->setFrontendDataSourceById(feId);
+    }
+
     mSharedFeId = feId;
     return (int)Result::SUCCESS;
 }
diff --git a/services/core/java/com/android/server/tv/tunerresourcemanager/ClientProfile.java b/services/core/java/com/android/server/tv/tunerresourcemanager/ClientProfile.java
index fb9a4d4..8736c30 100644
--- a/services/core/java/com/android/server/tv/tunerresourcemanager/ClientProfile.java
+++ b/services/core/java/com/android/server/tv/tunerresourcemanager/ClientProfile.java
@@ -80,6 +80,11 @@
     private Set<Integer> mShareFeClientIds = new HashSet<>();
 
     /**
+     * Client id sharee that has shared frontend with the current client.
+     */
+    private Integer mShareeFeClientId = INVALID_RESOURCE_ID;
+
+    /**
      * List of the Lnb handles that are used by the current client.
      */
     private Set<Integer> mUsingLnbHandles = new HashSet<>();
@@ -223,12 +228,21 @@
         return mShareFeClientIds;
     }
 
+    public Integer getShareeFeClientId() {
+        return mShareeFeClientId;
+    }
+
+    public void setShareeFeClientId(Integer shareeFeClientId) {
+        mShareeFeClientId = shareeFeClientId;
+    }
+
     /**
      * Called when the client released a frontend.
      */
     public void releaseFrontend() {
         mUsingFrontendHandles.clear();
         mShareFeClientIds.clear();
+        mShareeFeClientId = INVALID_RESOURCE_ID;
         mPrimaryUsingFrontendHandle = TunerResourceManager.INVALID_RESOURCE_HANDLE;
     }
 
diff --git a/services/core/java/com/android/server/tv/tunerresourcemanager/TunerResourceManagerService.java b/services/core/java/com/android/server/tv/tunerresourcemanager/TunerResourceManagerService.java
index 6162d716..23d727e 100644
--- a/services/core/java/com/android/server/tv/tunerresourcemanager/TunerResourceManagerService.java
+++ b/services/core/java/com/android/server/tv/tunerresourcemanager/TunerResourceManagerService.java
@@ -996,9 +996,15 @@
         if (DEBUG) {
             Slog.d(TAG, "shareFrontend from " + selfClientId + " with " + targetClientId);
         }
+        Integer shareeFeClientId = getClientProfile(selfClientId).getShareeFeClientId();
+        if (shareeFeClientId != ClientProfile.INVALID_RESOURCE_ID) {
+            getClientProfile(shareeFeClientId).stopSharingFrontend(selfClientId);
+            getClientProfile(selfClientId).releaseFrontend();
+        }
         for (int feId : getClientProfile(targetClientId).getInUseFrontendHandles()) {
             getClientProfile(selfClientId).useFrontend(feId);
         }
+        getClientProfile(selfClientId).setShareeFeClientId(targetClientId);
         getClientProfile(targetClientId).shareFrontend(selfClientId);
     }
 
@@ -1008,6 +1014,8 @@
         // change the owner of all the inUse frontend
         newOwnerProfile.shareFrontend(currentOwnerId);
         currentOwnerProfile.stopSharingFrontend(newOwnerId);
+        newOwnerProfile.setShareeFeClientId(ClientProfile.INVALID_RESOURCE_ID);
+        currentOwnerProfile.setShareeFeClientId(newOwnerId);
         for (int inUseHandle : newOwnerProfile.getInUseFrontendHandles()) {
             getFrontendResource(inUseHandle).setOwner(newOwnerId);
         }
diff --git a/tests/DynamicCodeLoggerIntegrationTests/AndroidTest.xml b/tests/DynamicCodeLoggerIntegrationTests/AndroidTest.xml
index f8a1ec9..0ab3dfe 100644
--- a/tests/DynamicCodeLoggerIntegrationTests/AndroidTest.xml
+++ b/tests/DynamicCodeLoggerIntegrationTests/AndroidTest.xml
@@ -22,6 +22,9 @@
     <option name="test-suite-tag" value="apct"/>
     <option name="test-tag" value="DynamicCodeLoggerIntegrationTests"/>
 
+    <!-- This test make uses of the event log, make sure we capture it. -->
+    <option name="logcat-options" value="-b all" />
+
     <test class="com.android.tradefed.testtype.AndroidJUnitTest">
         <option name="package" value="com.android.frameworks.dynamiccodeloggertest"/>
         <option name="runner" value="androidx.test.runner.AndroidJUnitRunner"/>