Snap for 10306978 from decc428857 to udc-release

Change-Id: I48bcab4f28d9750df250f50c6a9b10c75b8a40a7
This commit is contained in:
Android Build Coastguard Worker
2023-06-12 23:22:28 +00:00
11 changed files with 195 additions and 63 deletions

View File

@@ -131,7 +131,7 @@
<!-- Connected devices settings. Title of the preference to show the entrance of the hearing device controls related page. [CHAR LIMIT=65] -->
<string name="bluetooth_device_controls_title">Hearing device settings</string>
<!-- Connected devices settings. Title of the preference to show the entrance of the hearing device controls related page. [CHAR LIMIT=65] -->
<string name="bluetooth_device_controls_summary">Audio output, shortcut, hearing aid compatibility</string>
<string name="bluetooth_device_controls_summary">Shortcut, hearing aid compatibility</string>
<!-- Title for this device specific controls section. [CHAR LIMIT=30] -->
<string name="bluetooth_device_controls_specific">For this device</string>
<!-- Connected devices settings. Title of the preference to show the entrance of the audio output page. It can change different types of audio are played on phone or other bluetooth devices. [CHAR LIMIT=35] -->
@@ -2642,6 +2642,8 @@
<string name="model_info">Model</string>
<!-- Label for device's hardware revision value [CHAR LIMIT=40] -->
<string name="hardware_revision">Hardware version</string>
<!-- Label for device's manufactured year value [CHAR LIMIT=40] -->
<string name="manufactured_year">Manufactured year</string>
<!-- About phone screen, fcc equipment id label [CHAR LIMIT=40] -->
<string name="fcc_equipment_id">Equipment ID</string>
<!-- About phone screen, setting option name [CHAR LIMIT=40] -->

View File

@@ -48,4 +48,13 @@
settings:controller="com.android.settings.deviceinfo.hardwareinfo.HardwareRevisionPreferenceController"
settings:enableCopying="true"/>
<!-- Manufactured year -->
<Preference
android:key="hardware_info_manufactured_year"
android:title="@string/manufactured_year"
android:summary="@string/summary_placeholder"
android:selectable="false"
settings:controller="com.android.settings.deviceinfo.hardwareinfo.ManufacturedYearPreferenceController"
settings:enableCopying="true"/>
</PreferenceScreen>

View File

@@ -66,6 +66,7 @@ import android.text.TextUtils.TruncateAt;
import android.util.EventLog;
import android.util.Log;
import android.view.Display;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -155,12 +156,12 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
mHandler = new Handler(getMainLooper());
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
mAppOps = (AppOpsManager)getSystemService(Context.APP_OPS_SERVICE);
mDPM = getSystemService(DevicePolicyManager.class);
mAppOps = getSystemService(AppOpsManager.class);
mLayoutInflaternflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
PackageManager packageManager = getPackageManager();
if ((getIntent().getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
Log.w(TAG, "Cannot start ADD_DEVICE_ADMIN as a new task");
finish();
return;
@@ -170,7 +171,7 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
EXTRA_CALLED_FROM_SUPPORT_DIALOG, false);
String action = getIntent().getAction();
ComponentName who = (ComponentName)getIntent().getParcelableExtra(
ComponentName who = (ComponentName) getIntent().getParcelableExtra(
DevicePolicyManager.EXTRA_DEVICE_ADMIN);
if (who == null) {
String packageName = getIntent().getStringExtra(EXTRA_DEVICE_ADMIN_PACKAGE_NAME);
@@ -226,7 +227,7 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS);
int count = avail == null ? 0 : avail.size();
boolean found = false;
for (int i=0; i<count; i++) {
for (int i = 0; i < count; i++) {
ResolveInfo ri = avail.get(i);
if (ai.packageName.equals(ri.activityInfo.packageName)
&& ai.name.equals(ri.activityInfo.name)) {
@@ -350,16 +351,16 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
}
setContentView(R.layout.device_admin_add);
mAdminIcon = (ImageView)findViewById(R.id.admin_icon);
mAdminName = (TextView)findViewById(R.id.admin_name);
mAdminDescription = (TextView)findViewById(R.id.admin_description);
mAdminIcon = (ImageView) findViewById(R.id.admin_icon);
mAdminName = (TextView) findViewById(R.id.admin_name);
mAdminDescription = (TextView) findViewById(R.id.admin_description);
mProfileOwnerWarning = (TextView) findViewById(R.id.profile_owner_warning);
mProfileOwnerWarning.setText(
mDPM.getResources().getString(SET_PROFILE_OWNER_POSTSETUP_WARNING,
() -> getString(R.string.adding_profile_owner_warning)));
mAddMsg = (TextView)findViewById(R.id.add_msg);
mAddMsg = (TextView) findViewById(R.id.add_msg);
mAddMsgExpander = (ImageView) findViewById(R.id.add_msg_expander);
final View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
@@ -380,7 +381,7 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
boolean hideMsgExpander = mAddMsg.getLineCount() <= maxLines;
mAddMsgExpander.setVisibility(hideMsgExpander ? View.GONE : View.VISIBLE);
if (hideMsgExpander) {
((View)mAddMsgExpander.getParent()).invalidate();
((View) mAddMsgExpander.getParent()).invalidate();
}
mAddMsg.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
@@ -420,8 +421,8 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
final View restrictedAction = findViewById(R.id.restricted_action);
restrictedAction.setFilterTouchesWhenObscured(true);
restrictedAction.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final View.OnClickListener restrictedActionClickListener = v -> {
if (!mActionButton.isEnabled()) {
showPolicyTransparencyDialogIfRequired();
return;
@@ -464,14 +465,20 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
}
}, mHandler));
// Don't want to wait too long.
getWindow().getDecorView().getHandler().postDelayed(new Runnable() {
@Override public void run() {
continueRemoveAction(null);
}
}, 2*1000);
getWindow().getDecorView().getHandler().postDelayed(
() -> continueRemoveAction(null), 2 * 1000);
}
};
restrictedAction.setOnKeyListener((view, keyCode, keyEvent) -> {
if ((keyEvent.getFlags() & KeyEvent.FLAG_FROM_SYSTEM) == 0) {
Log.e(TAG, "Can not activate device-admin with KeyEvent from non-system app.");
// Consume event to suppress click.
return true;
}
// Fallback to view click handler.
return false;
});
restrictedAction.setOnClickListener(restrictedActionClickListener);
}
/**

View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) 2023 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.deviceinfo.hardwareinfo
/**
* Feature provider for hardware info
*/
interface HardwareInfoFeatureProvider {
/**
* Returns the manufactured year
*/
val manufacturedYear: String?
}

View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2023 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.deviceinfo.hardwareinfo
/**
* Feature provider for hardware info
*/
object HardwareInfoFeatureProviderImpl : HardwareInfoFeatureProvider {
override val manufacturedYear: String?
get() = null
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2023 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.deviceinfo.hardwareinfo
import android.content.Context
import com.android.settings.core.BasePreferenceController
import com.android.settings.overlay.FeatureFactory
/** Preference controller for Manufactured Year. */
class ManufacturedYearPreferenceController(context: Context, preferenceKey: String) :
BasePreferenceController(context, preferenceKey) {
private val year: String? =
FeatureFactory.getFactory(context).hardwareInfoFeatureProvider.manufacturedYear
override fun getAvailabilityStatus(): Int =
if (!year.isNullOrEmpty()) AVAILABLE else UNSUPPORTED_ON_DEVICE
override fun getSummary(): CharSequence = year ?: ""
}

View File

@@ -33,6 +33,7 @@ import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
import com.android.settings.bluetooth.BluetoothFeatureProvider;
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.fuelgauge.BatterySettingsFeatureProvider;
import com.android.settings.fuelgauge.BatteryStatusFeatureProvider;
@@ -109,6 +110,11 @@ public abstract class FeatureFactory {
*/
public abstract SuggestionFeatureProvider getSuggestionFeatureProvider();
/**
* Retrieves implementation for Hardware Info feature.
*/
public abstract HardwareInfoFeatureProvider getHardwareInfoFeatureProvider();
public abstract SupportFeatureProvider getSupportFeatureProvider(Context context);
public abstract MetricsFeatureProvider getMetricsFeatureProvider();

View File

@@ -47,6 +47,8 @@ import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.DashboardFeatureProviderImpl;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl;
import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProvider;
import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProviderImpl;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProviderImpl;
import com.android.settings.fuelgauge.BatterySettingsFeatureProvider;
@@ -115,6 +117,11 @@ public class FeatureFactoryImpl extends FeatureFactory {
private AdvancedVpnFeatureProvider mAdvancedVpnFeatureProvider;
private WifiFeatureProvider mWifiFeatureProvider;
@Override
public HardwareInfoFeatureProvider getHardwareInfoFeatureProvider() {
return HardwareInfoFeatureProviderImpl.INSTANCE;
}
@Override
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
return null;

View File

@@ -31,6 +31,8 @@ import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
import com.android.settings.bluetooth.BluetoothFeatureProvider;
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProvider;
import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProviderImpl;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.fuelgauge.BatterySettingsFeatureProvider;
import com.android.settings.fuelgauge.BatteryStatusFeatureProvider;
@@ -287,6 +289,11 @@ public class FakeFeatureFactory extends FeatureFactory {
return mAccessibilityMetricsFeatureProvider;
}
@Override
public HardwareInfoFeatureProvider getHardwareInfoFeatureProvider() {
return HardwareInfoFeatureProviderImpl.INSTANCE;
}
@Override
public AdvancedVpnFeatureProvider getAdvancedVpnFeatureProvider() {
return mAdvancedVpnFeatureProvider;

View File

@@ -27,6 +27,7 @@ import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider
import com.android.settings.bluetooth.BluetoothFeatureProvider
import com.android.settings.dashboard.DashboardFeatureProvider
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider
import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProvider
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider
import com.android.settings.fuelgauge.BatterySettingsFeatureProvider
import com.android.settings.fuelgauge.BatteryStatusFeatureProvider
@@ -175,6 +176,10 @@ class FakeFeatureFactory : FeatureFactory() {
TODO("Not yet implemented")
}
override fun getHardwareInfoFeatureProvider(): HardwareInfoFeatureProvider {
TODO("Not yet implemented")
}
override fun getAdvancedVpnFeatureProvider(): AdvancedVpnFeatureProvider {
TODO("Not yet implemented")
}

View File

@@ -29,6 +29,8 @@ import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
import com.android.settings.bluetooth.BluetoothFeatureProvider;
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProvider;
import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProviderImpl;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.fuelgauge.BatterySettingsFeatureProvider;
import com.android.settings.fuelgauge.BatteryStatusFeatureProvider;
@@ -273,6 +275,11 @@ public class FakeFeatureFactory extends FeatureFactory {
return mAccessibilityMetricsFeatureProvider;
}
@Override
public HardwareInfoFeatureProvider getHardwareInfoFeatureProvider() {
return HardwareInfoFeatureProviderImpl.INSTANCE;
}
@Override
public AdvancedVpnFeatureProvider getAdvancedVpnFeatureProvider() {
return mAdvancedVpnFeatureProvider;