Merge sc-v2-dev-plus-aosp-without-vendor@8084891
Bug: 214455710 Merged-In: I962c318f41adcf180b885f2052ce0ec4952edfb6 Change-Id: I77764eaf895ac3c13c7440adb5b3f597a516d690
This commit is contained in:
@@ -26,6 +26,7 @@ import static com.android.settings.Utils.PROPERTY_APP_HIBERNATION_ENABLED;
|
||||
import static com.android.settings.Utils.PROPERTY_HIBERNATION_TARGETS_PRE_S_APPS;
|
||||
|
||||
import android.app.AppOpsManager;
|
||||
import android.apphibernation.AppHibernationManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.provider.DeviceConfig;
|
||||
@@ -134,8 +135,15 @@ public final class HibernationSwitchPreferenceController extends AppInfoPreferen
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object isChecked) {
|
||||
try {
|
||||
final boolean checked = (boolean) isChecked;
|
||||
mAppOpsManager.setUidMode(OPSTR_AUTO_REVOKE_PERMISSIONS_IF_UNUSED, mPackageUid,
|
||||
(boolean) isChecked ? MODE_ALLOWED : MODE_IGNORED);
|
||||
checked ? MODE_ALLOWED : MODE_IGNORED);
|
||||
if (!checked) {
|
||||
final AppHibernationManager ahm =
|
||||
mContext.getSystemService(AppHibernationManager.class);
|
||||
ahm.setHibernatingForUser(mPackageName, false);
|
||||
ahm.setHibernatingGlobally(mPackageName, false);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.applications.autofill;
|
||||
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
import static android.service.autofill.AutofillService.EXTRA_RESULT;
|
||||
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_CREATE;
|
||||
@@ -133,7 +134,8 @@ public class PasswordsPreferenceController extends BasePreferenceController
|
||||
new Intent(Intent.ACTION_MAIN)
|
||||
.setClassName(
|
||||
serviceInfo.packageName,
|
||||
service.getPasswordsActivity());
|
||||
service.getPasswordsActivity())
|
||||
.setFlags(FLAG_ACTIVITY_NEW_TASK);
|
||||
prefContext.startActivityAsUser(intent, UserHandle.of(user));
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -105,6 +105,11 @@ public class AppLaunchSettings extends AppInfoBase implements
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAppEntry == null) {
|
||||
Log.w(TAG, "onCreate: mAppEntry is null, please check the reason!!!");
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
addPreferencesFromResource(R.xml.installed_app_launch_settings);
|
||||
mDomainVerificationManager = mContext.getSystemService(DomainVerificationManager.class);
|
||||
initUIComponents();
|
||||
|
||||
@@ -272,8 +272,8 @@ public class ManageApplications extends InstrumentedFragment
|
||||
|
||||
Intent intent = activity.getIntent();
|
||||
Bundle args = getArguments();
|
||||
int screenTitle = intent.getIntExtra(
|
||||
SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.all_apps);
|
||||
final int screenTitle = getTitleResId(intent, args);
|
||||
|
||||
String className = args != null ? args.getString(EXTRA_CLASSNAME) : null;
|
||||
if (className == null) {
|
||||
className = intent.getComponent().getClassName();
|
||||
@@ -290,49 +290,36 @@ public class ManageApplications extends InstrumentedFragment
|
||||
mSortOrder = R.id.sort_order_size;
|
||||
} else if (className.equals(UsageAccessSettingsActivity.class.getName())) {
|
||||
mListType = LIST_TYPE_USAGE_ACCESS;
|
||||
screenTitle = R.string.usage_access;
|
||||
} else if (className.equals(HighPowerApplicationsActivity.class.getName())) {
|
||||
mListType = LIST_TYPE_HIGH_POWER;
|
||||
// Default to showing system.
|
||||
mShowSystem = true;
|
||||
screenTitle = R.string.high_power_apps;
|
||||
} else if (className.equals(OverlaySettingsActivity.class.getName())) {
|
||||
mListType = LIST_TYPE_OVERLAY;
|
||||
screenTitle = R.string.system_alert_window_settings;
|
||||
|
||||
reportIfRestrictedSawIntent(intent);
|
||||
} else if (className.equals(WriteSettingsActivity.class.getName())) {
|
||||
mListType = LIST_TYPE_WRITE_SETTINGS;
|
||||
screenTitle = R.string.write_settings;
|
||||
} else if (className.equals(ManageExternalSourcesActivity.class.getName())) {
|
||||
mListType = LIST_TYPE_MANAGE_SOURCES;
|
||||
screenTitle = R.string.install_other_apps;
|
||||
} else if (className.equals(GamesStorageActivity.class.getName())) {
|
||||
mListType = LIST_TYPE_GAMES;
|
||||
mSortOrder = R.id.sort_order_size;
|
||||
} else if (className.equals(Settings.ChangeWifiStateActivity.class.getName())) {
|
||||
mListType = LIST_TYPE_WIFI_ACCESS;
|
||||
screenTitle = R.string.change_wifi_state_title;
|
||||
} else if (className.equals(Settings.ManageExternalStorageActivity.class.getName())) {
|
||||
mListType = LIST_MANAGE_EXTERNAL_STORAGE;
|
||||
screenTitle = R.string.manage_external_storage_title;
|
||||
} else if (className.equals(Settings.MediaManagementAppsActivity.class.getName())) {
|
||||
mListType = LIST_TYPE_MEDIA_MANAGEMENT_APPS;
|
||||
screenTitle = R.string.media_management_apps_title;
|
||||
} else if (className.equals(Settings.AlarmsAndRemindersActivity.class.getName())) {
|
||||
mListType = LIST_TYPE_ALARMS_AND_REMINDERS;
|
||||
screenTitle = R.string.alarms_and_reminders_title;
|
||||
} else if (className.equals(Settings.NotificationAppListActivity.class.getName())) {
|
||||
mListType = LIST_TYPE_NOTIFICATION;
|
||||
mUsageStatsManager = IUsageStatsManager.Stub.asInterface(
|
||||
ServiceManager.getService(Context.USAGE_STATS_SERVICE));
|
||||
mNotificationBackend = new NotificationBackend();
|
||||
mSortOrder = R.id.sort_order_recent_notification;
|
||||
screenTitle = R.string.app_notifications_title;
|
||||
} else {
|
||||
if (screenTitle == -1) {
|
||||
screenTitle = R.string.all_apps;
|
||||
}
|
||||
mListType = LIST_TYPE_MAIN;
|
||||
}
|
||||
final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance();
|
||||
@@ -881,6 +868,46 @@ public class ManageApplications extends InstrumentedFragment
|
||||
params.setBehavior(behavior);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a resource ID of title based on what type of app list is
|
||||
* @param intent the intent of the activity that might include a specified title
|
||||
* @param args the args that includes a class name of app list
|
||||
*/
|
||||
public static int getTitleResId(@NonNull Intent intent, Bundle args) {
|
||||
int screenTitle = intent.getIntExtra(
|
||||
SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.all_apps);
|
||||
String className = args != null ? args.getString(EXTRA_CLASSNAME) : null;
|
||||
if (className == null) {
|
||||
className = intent.getComponent().getClassName();
|
||||
}
|
||||
if (className.equals(Settings.UsageAccessSettingsActivity.class.getName())) {
|
||||
screenTitle = R.string.usage_access;
|
||||
} else if (className.equals(Settings.HighPowerApplicationsActivity.class.getName())) {
|
||||
screenTitle = R.string.high_power_apps;
|
||||
} else if (className.equals(Settings.OverlaySettingsActivity.class.getName())) {
|
||||
screenTitle = R.string.system_alert_window_settings;
|
||||
} else if (className.equals(Settings.WriteSettingsActivity.class.getName())) {
|
||||
screenTitle = R.string.write_settings;
|
||||
} else if (className.equals(Settings.ManageExternalSourcesActivity.class.getName())) {
|
||||
screenTitle = R.string.install_other_apps;
|
||||
} else if (className.equals(Settings.ChangeWifiStateActivity.class.getName())) {
|
||||
screenTitle = R.string.change_wifi_state_title;
|
||||
} else if (className.equals(Settings.ManageExternalStorageActivity.class.getName())) {
|
||||
screenTitle = R.string.manage_external_storage_title;
|
||||
} else if (className.equals(Settings.MediaManagementAppsActivity.class.getName())) {
|
||||
screenTitle = R.string.media_management_apps_title;
|
||||
} else if (className.equals(Settings.AlarmsAndRemindersActivity.class.getName())) {
|
||||
screenTitle = R.string.alarms_and_reminders_title;
|
||||
} else if (className.equals(Settings.NotificationAppListActivity.class.getName())) {
|
||||
screenTitle = R.string.app_notifications_title;
|
||||
} else {
|
||||
if (screenTitle == -1) {
|
||||
screenTitle = R.string.all_apps;
|
||||
}
|
||||
}
|
||||
return screenTitle;
|
||||
}
|
||||
|
||||
static class FilterSpinnerAdapter extends SettingsSpinnerAdapter<CharSequence> {
|
||||
|
||||
private final ManageApplications mManageApplications;
|
||||
|
||||
@@ -17,27 +17,26 @@
|
||||
package com.android.settings.applications.managedomainurls;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.UserHandle;
|
||||
import android.util.ArraySet;
|
||||
import android.content.pm.verify.domain.DomainVerificationManager;
|
||||
import android.content.pm.verify.domain.DomainVerificationUserState;
|
||||
import android.util.IconDrawableFactory;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.applications.intentpicker.IntentPickerUtils;
|
||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
import com.android.settingslib.widget.AppPreference;
|
||||
|
||||
public class DomainAppPreference extends AppPreference {
|
||||
|
||||
private final AppEntry mEntry;
|
||||
private final PackageManager mPm;
|
||||
private final DomainVerificationManager mDomainVerificationManager;
|
||||
private final IconDrawableFactory mIconDrawableFactory;
|
||||
|
||||
public DomainAppPreference(final Context context, IconDrawableFactory iconFactory,
|
||||
AppEntry entry) {
|
||||
super(context);
|
||||
mIconDrawableFactory = iconFactory;
|
||||
mPm = context.getPackageManager();
|
||||
mDomainVerificationManager = context.getSystemService(DomainVerificationManager.class);
|
||||
mEntry = entry;
|
||||
mEntry.ensureLabel(getContext());
|
||||
|
||||
@@ -60,22 +59,14 @@ public class DomainAppPreference extends AppPreference {
|
||||
}
|
||||
|
||||
private CharSequence getDomainsSummary(String packageName) {
|
||||
// If the user has explicitly said "no" for this package, that's the
|
||||
// string we should show.
|
||||
int domainStatus =
|
||||
mPm.getIntentVerificationStatusAsUser(packageName, UserHandle.myUserId());
|
||||
if (domainStatus == PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER) {
|
||||
return getContext().getText(R.string.domain_urls_summary_none);
|
||||
}
|
||||
// Otherwise, ask package manager for the domains for this package,
|
||||
// and show the first one (or none if there aren't any).
|
||||
final ArraySet<String> result = Utils.getHandledDomains(mPm, packageName);
|
||||
if (result.isEmpty()) {
|
||||
return getContext().getText(R.string.domain_urls_summary_none);
|
||||
} else if (result.size() == 1) {
|
||||
return getContext().getString(R.string.domain_urls_summary_one, result.valueAt(0));
|
||||
} else {
|
||||
return getContext().getString(R.string.domain_urls_summary_some, result.valueAt(0));
|
||||
}
|
||||
return getContext().getText(isLinkHandlingAllowed(packageName)
|
||||
? R.string.app_link_open_always : R.string.app_link_open_never);
|
||||
}
|
||||
|
||||
private boolean isLinkHandlingAllowed(String packageName) {
|
||||
final DomainVerificationUserState userState =
|
||||
IntentPickerUtils.getDomainVerificationUserState(mDomainVerificationManager,
|
||||
packageName);
|
||||
return userState == null ? false : userState.isLinkHandlingAllowed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.settings.applications.managedomainurls;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
public class InstantAppWebActionPreferenceController extends TogglePreferenceController {
|
||||
@@ -43,4 +44,9 @@ public class InstantAppWebActionPreferenceController extends TogglePreferenceCon
|
||||
return Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.INSTANT_APPS_ENABLED, isChecked ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return R.string.menu_key_apps;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,9 @@ public class PictureInPictureDetailPreferenceController extends AppInfoPreferenc
|
||||
try {
|
||||
packageInfoWithActivities = mPackageManager.getPackageInfoAsUser(mPackageName,
|
||||
PackageManager.GET_ACTIVITIES, UserHandle.myUserId());
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
} catch (Exception e) {
|
||||
// Catch Exception to avoid DeadObjectException thrown with binder transaction
|
||||
// failures, since the explicit request of DeadObjectException has compiler errors.
|
||||
Log.e(TAG, "Exception while retrieving the package info of " + mPackageName, e);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user