Merge "Add method to disable "disable" button in installed app UI" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e12790e34f
@@ -42,6 +42,7 @@ import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
@@ -62,6 +63,7 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
|
||||
protected EnforcedAdmin mAppsControlDisallowedAdmin;
|
||||
protected boolean mAppsControlDisallowedBySystem;
|
||||
|
||||
protected ApplicationFeatureProvider mApplicationFeatureProvider;
|
||||
protected ApplicationsState mState;
|
||||
protected ApplicationsState.Session mSession;
|
||||
protected ApplicationsState.AppEntry mAppEntry;
|
||||
@@ -84,13 +86,14 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mFinishing = false;
|
||||
|
||||
mState = ApplicationsState.getInstance(getActivity().getApplication());
|
||||
final Activity activity = getActivity();
|
||||
mApplicationFeatureProvider = FeatureFactory.getFactory(activity)
|
||||
.getApplicationFeatureProvider(activity);
|
||||
mState = ApplicationsState.getInstance(activity.getApplication());
|
||||
mSession = mState.newSession(this);
|
||||
Context context = getActivity();
|
||||
mDpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
mPm = context.getPackageManager();
|
||||
mDpm = (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
mUserManager = (UserManager) activity.getSystemService(Context.USER_SERVICE);
|
||||
mPm = activity.getPackageManager();
|
||||
IBinder b = ServiceManager.getService(Context.USB_SERVICE);
|
||||
mUsbManager = IUsbManager.Stub.asInterface(b);
|
||||
|
||||
|
@@ -24,6 +24,7 @@ import android.view.View;
|
||||
import com.android.settings.applications.instantapps.InstantAppButtonsController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ApplicationFeatureProvider {
|
||||
|
||||
@@ -93,6 +94,11 @@ public interface ApplicationFeatureProvider {
|
||||
*/
|
||||
List<UserAppInfo> findPersistentPreferredActivities(@UserIdInt int userId, Intent[] intents);
|
||||
|
||||
/**
|
||||
* Returns a list of package names that should be kept enabled.
|
||||
*/
|
||||
Set<String> getKeepEnabledPackages();
|
||||
|
||||
/**
|
||||
* Callback that receives the number of packages installed on the device.
|
||||
*/
|
||||
|
@@ -135,6 +135,11 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide
|
||||
return preferredActivities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getKeepEnabledPackages() {
|
||||
return new ArraySet<>();
|
||||
}
|
||||
|
||||
private static class CurrentUserAndManagedProfilePolicyInstalledAppCounter
|
||||
extends InstalledAppCounter {
|
||||
private NumberOfAppsCallback mCallback;
|
||||
|
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.settings.applications;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import android.Manifest.permission;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
@@ -117,6 +115,8 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
/**
|
||||
* Activity to display application information from Settings. This activity presents
|
||||
* extended information associated with a package like code, data, total size, permissions
|
||||
@@ -232,7 +232,8 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
}
|
||||
};
|
||||
|
||||
private boolean handleDisableable(Button button) {
|
||||
@VisibleForTesting
|
||||
boolean handleDisableable(Button button) {
|
||||
boolean disableable = false;
|
||||
// Try to prevent the user from bricking their phone
|
||||
// by not allowing disabling of apps signed with the
|
||||
@@ -243,7 +244,8 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
button.setText(R.string.disable_text);
|
||||
} else if (mAppEntry.info.enabled && !isDisabledUntilUsed()) {
|
||||
button.setText(R.string.disable_text);
|
||||
disableable = true;
|
||||
disableable = !mApplicationFeatureProvider.getKeepEnabledPackages()
|
||||
.contains(mAppEntry.info.packageName);
|
||||
} else {
|
||||
button.setText(R.string.enable_text);
|
||||
disableable = true;
|
||||
@@ -1221,9 +1223,7 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
void maybeAddInstantAppButtons() {
|
||||
if (AppUtils.isInstant(mPackageInfo.applicationInfo)) {
|
||||
LayoutPreference buttons = (LayoutPreference) findPreference(KEY_INSTANT_APP_BUTTONS);
|
||||
final Activity activity = getActivity();
|
||||
mInstantAppButtonsController = FeatureFactory.getFactory(activity)
|
||||
.getApplicationFeatureProvider(activity)
|
||||
mInstantAppButtonsController = mApplicationFeatureProvider
|
||||
.newInstantAppButtonsController(this,
|
||||
buttons.findViewById(R.id.instant_app_button_container),
|
||||
id -> showDialogInner(id, 0))
|
||||
|
Reference in New Issue
Block a user