Block the user from enabling or disabling webview fallback packages.

Now that we support webview fallback packages - packages that should be
enabled if and only if no other webview packages are available - we need
to ensure that the Settings UI consistently shows that these packages
cannot be enabled or disabled (e.g. the 'Enable' and 'Disable' buttons
for enabling/disabling them are greyed out).

Also, remove the Dialog that lets a user enable a disabled webview
package from the webview implementation Dev Setting. Instead show a
Toast if the user has chosen an invalid package.

Bug: 26375524, 26375860

Change-Id: I949083d3f7c83cd2e049dd2c5c15ec5ab880fe07
This commit is contained in:
Gustav Sennton
2016-02-18 12:28:36 +00:00
parent 0b485bb523
commit a4e32a24c4
3 changed files with 35 additions and 56 deletions

View File

@@ -30,6 +30,7 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.webkit.IWebViewUpdateService;
import com.android.settings.R;
@@ -46,6 +47,7 @@ public class ResetAppsHelper implements DialogInterface.OnClickListener,
private final PackageManager mPm;
private final IPackageManager mIPm;
private final INotificationManager mNm;
private final IWebViewUpdateService mWvus;
private final NetworkPolicyManager mNpm;
private final AppOpsManager mAom;
private final Context mContext;
@@ -58,6 +60,7 @@ public class ResetAppsHelper implements DialogInterface.OnClickListener,
mIPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
mNm = INotificationManager.Stub.asInterface(
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
mWvus = IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate"));
mNpm = NetworkPolicyManager.from(context);
mAom = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
}
@@ -118,7 +121,8 @@ public class ResetAppsHelper implements DialogInterface.OnClickListener,
}
if (!app.enabled) {
if (mPm.getApplicationEnabledSetting(app.packageName)
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) {
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER
&& !isNonEnableableFallback(app.packageName)) {
mPm.setApplicationEnabledSetting(app.packageName,
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
PackageManager.DONT_KILL_APP);
@@ -142,4 +146,12 @@ public class ResetAppsHelper implements DialogInterface.OnClickListener,
}
});
}
private boolean isNonEnableableFallback(String packageName) {
try {
return mWvus.isFallbackPackage(packageName);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
}
}