Revert "Support installation of the new app source certificate"

We decided to punt extra certificate to post-R.

This reverts commit c8a1960cf4.

Test: Treehugger
Bug: 112038744
Change-Id: Ic53e58944faebe7aa427975ebd77ce783bdddaf2
This commit is contained in:
Victor Hsieh
2020-02-14 10:23:57 -08:00
parent 22e86de207
commit cef970cda4
13 changed files with 10 additions and 371 deletions

View File

@@ -44,7 +44,6 @@ import androidx.fragment.app.FragmentActivity;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.RebootDialog;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.vpn2.VpnUtils;
@@ -131,10 +130,10 @@ public final class CredentialStorage extends FragmentActivity {
if (uid != KeyStore.UID_SELF && !UserHandle.isSameUser(uid, Process.myUid())) {
final int dstUserId = UserHandle.getUserId(uid);
// Restrict install target to the known uid.
if (uid != Process.WIFI_UID && uid != Process.FSVERITY_CERT_UID) {
// Restrict install target to the wifi uid.
if (uid != Process.WIFI_UID) {
Log.e(TAG, "Failed to install credentials as uid " + uid + ": cross-user installs"
+ " may only target known uids");
+ " may only target wifi uids");
return true;
}
@@ -310,16 +309,6 @@ public final class CredentialStorage extends FragmentActivity {
Log.i(TAG, String.format("Successfully installed alias %s to uid %d.",
alias, uid));
if (uid == Process.FSVERITY_CERT_UID) {
new RebootDialog(
this,
R.string.app_src_cert_reboot_dialog_install_title,
R.string.app_src_cert_reboot_dialog_install_message,
"Reboot to make new fsverity cert effective").show();
setResult(RESULT_OK);
return;
}
// Send the broadcast.
final Intent broadcast = new Intent(KeyChain.ACTION_KEYCHAIN_CHANGED);
sendBroadcast(broadcast);

View File

@@ -1,48 +0,0 @@
/*
* Copyright (C) 2019 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.security;
import android.content.Context;
import android.os.SystemProperties;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.core.BasePreferenceController;
/**
* This controller decides the verification result of the installed app.
*/
public class InstallAppSourceCertificatePreferenceController extends
BasePreferenceController {
private static final String APK_VERITY_PROPERTY = "ro.apk_verity.mode";
private static final int APK_VERITY_MODE_ENABLED = 2;
public InstallAppSourceCertificatePreferenceController(Context context, String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
return isApkVerityEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@VisibleForTesting
static boolean isApkVerityEnabled() {
// TODO(victorhsieh): replace this with a new API in PackageManager once it is landed.
return SystemProperties.getInt(APK_VERITY_PROPERTY, 0) == APK_VERITY_MODE_ENABLED;
}
}

View File

@@ -1,83 +0,0 @@
/*
* Copyright (C) 2019 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.security;
import android.annotation.Nullable;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.security.Credentials;
import android.view.View;
import android.widget.Toast;
import com.android.settings.R;
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupdesign.GlifLayout;
/**
* Creates a warning dialog explaining the consequences of installing a certificate
* This is displayed before an app source certificate can be installed from Settings.
*/
public class InstallAppSourceCertificateWarning extends Activity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.app_source_certificate_warning_dialog);
final GlifLayout layout = findViewById(R.id.setup_wizard_layout);
final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
mixin.setSecondaryButton(
new FooterButton.Builder(this)
.setText(R.string.certificate_warning_install_anyway)
.setListener(installCertificate())
.setButtonType(FooterButton.ButtonType.OTHER)
.setTheme(R.style.SudGlifButton_Secondary)
.build()
);
mixin.setPrimaryButton(
new FooterButton.Builder(this)
.setText(R.string.certificate_warning_dont_install)
.setListener(returnToInstallCertificateFromStorage())
.setButtonType(FooterButton.ButtonType.NEXT)
.setTheme(R.style.SudGlifButton_Primary)
.build()
);
}
private View.OnClickListener installCertificate() {
return v -> {
final Intent intent = new Intent();
intent.setAction(Credentials.INSTALL_ACTION);
intent.putExtra(Credentials.EXTRA_CERTIFICATE_USAGE,
Credentials.CERTIFICATE_USAGE_APP_SOURCE);
startActivity(intent);
finish();
};
}
private View.OnClickListener returnToInstallCertificateFromStorage() {
return v -> {
Toast.makeText(this, R.string.cert_not_installed, Toast.LENGTH_SHORT).show();
finish();
};
}
}

View File

@@ -60,7 +60,6 @@ public class InstallCertificateFromStorage extends DashboardFragment {
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
Lifecycle lifecycle) {
// TODO(eranm,victorhsieh): use "settings:controller" in xml and remove the following.
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new InstallCaCertificatePreferenceController(context));
controllers.add(new InstallUserCertificatePreferenceController(context));