Snap for 11784291 from 9b102c8921 to 24Q3-release

Change-Id: I5aaae35dec8c836a38a5c87217ac6191cc4aa483
This commit is contained in:
Android Build Coastguard Worker
2024-04-30 23:24:01 +00:00
8 changed files with 258 additions and 7 deletions

View File

@@ -5164,6 +5164,14 @@
android:theme="@style/Theme.SpaLib.Dialog">
</activity>
<activity
android:name="com.android.settings.network.SatelliteWarningDialogActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout|smallestScreenSize"
android:excludeFromRecents="true"
android:exported="false"
android:theme="@style/Theme.SpaLib.Dialog">
</activity>
<!-- This is the longest AndroidManifest.xml ever. -->
</application>
</manifest>

View File

@@ -11707,6 +11707,11 @@
<string name="satellite_setting_summary_more_information">Satellite messaging may take longer and is available only in some areas. Weather and certain structures may affect your satellite connection. Calling by satellite isn\u2019t available. Emergency calls may still connect.\n\nIt may take some time for account changes to show in Settings. Contact your carrier for details.</string>
<!-- more about satellite messaging [CHAR_LIMIT=NONE] -->
<string name="more_about_satellite_messaging">More about satellite messaging</string>
<!-- Title for satellite warning dialog to avoid user using wifi/bluetooth/airplane mode [CHAR_LIMIT=NONE] -->
<string name="satellite_warning_dialog_title">Cant turn on <xliff:g id="function" example="bluetooth">%1$s</xliff:g></string>
<!-- Content for satellite warning dialog to avoid user using wifi/bluetooth/airplane mode [CHAR_LIMIT=NONE] -->
<string name="satellite_warning_dialog_content">To turn on <xliff:g id="function" example="bluetooth">%1$s</xliff:g>, first end the satellite connection</string>
<!-- Title for Apn settings in mobile network settings [CHAR LIMIT=60] -->
<string name="mobile_network_apn_title">Access Point Names</string>

View File

@@ -667,7 +667,11 @@ public class ManageApplications extends InstrumentedFragment
compositeFilter =
new CompoundFilter(compositeFilter, ApplicationsState.FILTER_PRIVATE_PROFILE);
}
if (mIsPersonalOnly) {
// We might not be showing the private tab even when there's a private profile present and
// there's only personal profile info to show, in which case we should still apply the
// personal filter.
if (mIsPersonalOnly || !(mIsWorkOnly || mIsPrivateProfileOnly)) {
compositeFilter = new CompoundFilter(compositeFilter,
ApplicationsState.FILTER_PERSONAL);
}

View File

@@ -32,6 +32,8 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.service.oemlock.OemLockManager;
import android.system.Os;
import android.system.OsConstants;
import android.util.Log;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
@@ -92,6 +94,9 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen
private static final int OFFSET_TO_FILE_NAME = 30;
public static final String EXPERIMENTAL_UPDATE_TITLE = "Android 16K Kernel Experimental Update";
private static final long PAGE_SIZE = Os.sysconf(OsConstants._SC_PAGESIZE);
private static final int PAGE_SIZE_16KB = 16 * 1024;
private @NonNull DevelopmentSettingsDashboardFragment mFragment;
private boolean mEnable16k;
@@ -104,6 +109,7 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen
@NonNull Context context, @NonNull DevelopmentSettingsDashboardFragment fragment) {
super(context);
this.mFragment = fragment;
mEnable16k = (PAGE_SIZE == PAGE_SIZE_16KB);
}
@Override
@@ -135,11 +141,13 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen
@Override
public void updateState(Preference preference) {
int defaultOptionValue =
PAGE_SIZE == PAGE_SIZE_16KB ? ENABLE_16K_PAGE_SIZE : ENABLE_4K_PAGE_SIZE;
final int optionValue =
Settings.Global.getInt(
mContext.getContentResolver(),
Settings.Global.ENABLE_16K_PAGES,
ENABLE_4K_PAGE_SIZE /* default */);
defaultOptionValue /* default */);
((SwitchPreference) mPreference).setChecked(optionValue == ENABLE_16K_PAGE_SIZE);
}
@@ -155,6 +163,14 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen
((SwitchPreference) mPreference).setChecked(false);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
int currentStatus =
PAGE_SIZE == PAGE_SIZE_16KB ? ENABLE_16K_PAGE_SIZE : ENABLE_4K_PAGE_SIZE;
Settings.Global.putInt(
mContext.getContentResolver(), Settings.Global.ENABLE_16K_PAGES, currentStatus);
}
/** Called when user confirms reboot dialog */
@Override
public void on16kPagesDialogConfirmed() {
@@ -179,7 +195,7 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen
@Override
public void onFailure(@NonNull Throwable t) {
hideProgressDialog();
Log.e(TAG, "Failed to call applyPayload of UpdateEngineStable!");
Log.e(TAG, "Failed to call applyPayload of UpdateEngineStable!", t);
displayToast(mContext.getString(R.string.toast_16k_update_failed_text));
}
},
@@ -188,7 +204,12 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen
/** Called when user dismisses to reboot dialog */
@Override
public void on16kPagesDialogDismissed() {}
public void on16kPagesDialogDismissed() {
if (mPreference == null) {
return;
}
updateState(mPreference);
}
private void installUpdate() {
// Check if there is any pending system update
@@ -412,7 +433,6 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen
try (BufferedReader br = new BufferedReader(new FileReader("/proc/mounts"))) {
String line;
while ((line = br.readLine()) != null) {
Log.i(TAG, line);
final String[] fields = line.split(" ");
final String partition = fields[1];
final String fsType = fields[2];

View File

@@ -0,0 +1,87 @@
/*
* Copyright (C) 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.network
import android.os.Bundle
import android.view.WindowManager
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import com.android.settings.R
import com.android.settingslib.spa.SpaDialogWindowTypeActivity
import com.android.settingslib.spa.widget.dialog.AlertDialogButton
import com.android.settingslib.spa.widget.dialog.SettingsAlertDialogContent
/** A dialog to show the warning message when device is under satellite mode. */
class SatelliteWarningDialogActivity : SpaDialogWindowTypeActivity() {
private var warningType = TYPE_IS_UNKNOWN
override fun onCreate(savedInstanceState: Bundle?) {
warningType = intent.getIntExtra(EXTRA_TYPE_OF_SATELLITE_WARNING_DIALOG, TYPE_IS_UNKNOWN)
if (warningType == TYPE_IS_UNKNOWN) {
finish()
}
super.onCreate(savedInstanceState)
}
override fun getDialogWindowType(): Int {
return WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
}
@Composable
override fun Content() {
SettingsAlertDialogContent(
dismissButton = null,
confirmButton = AlertDialogButton(
getString(com.android.settingslib.R.string.okay)
) { finish() },
title = String.format(
getString(R.string.satellite_warning_dialog_title),
getTypeString(warningType)
),
text = {
Text(
String.format(
getString(R.string.satellite_warning_dialog_content),
getTypeString(warningType)
),
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.Center
)
})
}
private fun getTypeString(num: Int): String {
return when (num) {
TYPE_IS_WIFI -> getString(R.string.wifi)
TYPE_IS_BLUETOOTH -> getString(R.string.bluetooth)
TYPE_IS_AIRPLANE_MODE -> getString(R.string.airplane_mode)
else -> ""
}
}
companion object {
const val EXTRA_TYPE_OF_SATELLITE_WARNING_DIALOG: String =
"extra_type_of_satellite_warning_dialog"
const val TYPE_IS_UNKNOWN = -1
const val TYPE_IS_WIFI = 0
const val TYPE_IS_BLUETOOTH = 1
const val TYPE_IS_AIRPLANE_MODE = 2
}
}

View File

@@ -278,7 +278,8 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
.setRequestWriteRepairModePassword(true)
.setForceVerifyPath(true)
.show();
} else if (isEffectiveUserManagedProfile && isInternalActivity()) {
} else if (mLockPatternUtils.isManagedProfileWithUnifiedChallenge(mUserId)
&& isInternalActivity()) {
// When the mForceVerifyPath is set to true, we launch the real confirm credential
// activity with an explicit but fake challenge value (0L). This will result in
// ConfirmLockPassword calling verifyTiedProfileChallenge() (if it's a profile with

View File

@@ -32,7 +32,7 @@ fun MobileDataSwitchingPreference(
isMobileDataEnabled: () -> Boolean?,
setMobileDataEnabled: (newEnabled: Boolean) -> Unit,
) {
val mobileDataSummary = stringResource(id = R.string.primary_sim_automatic_data_msg)
val mobileDataSummary = stringResource(id = R.string.mobile_data_settings_summary)
val coroutineScope = rememberCoroutineScope()
SwitchPreference(
object : SwitchPreferenceModel {

View File

@@ -0,0 +1,126 @@
/*
* Copyright (C) 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.spa.network
import android.content.Context
import android.content.Intent
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.lifecycle.Lifecycle
import androidx.test.core.app.ActivityScenario
import androidx.test.core.app.ActivityScenario.launch
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settings.R
import com.android.settings.network.SatelliteWarningDialogActivity
import com.android.settings.network.SatelliteWarningDialogActivity.Companion.EXTRA_TYPE_OF_SATELLITE_WARNING_DIALOG
import com.android.settings.network.SatelliteWarningDialogActivity.Companion.TYPE_IS_AIRPLANE_MODE
import com.android.settings.network.SatelliteWarningDialogActivity.Companion.TYPE_IS_BLUETOOTH
import com.android.settings.network.SatelliteWarningDialogActivity.Companion.TYPE_IS_UNKNOWN
import com.android.settings.network.SatelliteWarningDialogActivity.Companion.TYPE_IS_WIFI
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class SatelliteWarningDialogActivityTest {
@get:Rule
val composeTestRule = createAndroidComposeRule<SatelliteWarningDialogActivity>()
val context: Context = ApplicationProvider.getApplicationContext()
@Test
fun launchActivity_checkExtraValue_typeIsWifi() {
val scenario = launchDialogActivity(TYPE_IS_WIFI)
scenario.onActivity { activity ->
assert(
activity.intent.getIntExtra(
EXTRA_TYPE_OF_SATELLITE_WARNING_DIALOG,
TYPE_IS_UNKNOWN
) == TYPE_IS_WIFI
)
}
scenario.close()
}
@Test
fun launchActivity_checkExtraValue_typeIsBluetooth() {
val scenario = launchDialogActivity(TYPE_IS_BLUETOOTH)
scenario.onActivity { activity ->
assert(
activity.intent.getIntExtra(
EXTRA_TYPE_OF_SATELLITE_WARNING_DIALOG,
TYPE_IS_UNKNOWN
) == TYPE_IS_BLUETOOTH
)
}
scenario.close()
}
@Test
fun launchActivity_unknownType_destroyActivity() {
val scenario = launchDialogActivity(TYPE_IS_UNKNOWN)
assertTrue(scenario.state.isAtLeast(Lifecycle.State.DESTROYED))
scenario.close()
}
@Test
fun testDialogIsExisted() {
val scenario = launchDialogActivity(TYPE_IS_WIFI)
composeTestRule.onNodeWithText(context.getString(com.android.settingslib.R.string.okay))
.assertIsDisplayed()
scenario.close()
}
@Test
fun testDialogTitle_titleIsIncludeWifi() {
val scenario = launchDialogActivity(TYPE_IS_WIFI)
composeTestRule.onNodeWithText(
String.format(
context.getString(R.string.satellite_warning_dialog_title),
context.getString(R.string.wifi),
)
).assertIsDisplayed()
scenario.close()
}
@Test
fun testDialogTitle_titleIsIncludeAirplaneMode() {
val scenario = launchDialogActivity(TYPE_IS_AIRPLANE_MODE)
composeTestRule.onNodeWithText(
String.format(
context.getString(R.string.satellite_warning_dialog_title),
context.getString(R.string.airplane_mode),
)
).assertIsDisplayed()
scenario.close()
}
private fun launchDialogActivity(type: Int): ActivityScenario<SatelliteWarningDialogActivity> = launch(
Intent(
context,
SatelliteWarningDialogActivity::class.java
).putExtra(EXTRA_TYPE_OF_SATELLITE_WARNING_DIALOG, type)
)
}