Merge "Remove credential management app Settings" into sc-dev am: 713d325310
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15046667 Change-Id: I7af2c7ad672a682c6974332a02cc98e3e3d6e2f2
This commit is contained in:
@@ -1486,6 +1486,7 @@
|
||||
</activity>
|
||||
|
||||
<activity android:name=".security.RequestManageCredentials"
|
||||
android:theme="@style/Theme.SubSettings"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.security.MANAGE_CREDENTIALS"/>
|
||||
|
25
res/drawable/ic_redo_24.xml
Normal file
25
res/drawable/ic_redo_24.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
~ Copyright (C) 2021 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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M6,13.5C6,11.57 7.75,10 9.9,10h6.27l-2.59,2.59L15,14l5,-5 -5,-5 -1.41,1.41L16.17,8H9.9C6.65,8 4,10.47 4,13.5S6.65,19 9.9,19H17v-2H9.9C7.75,17 6,15.43 6,13.5z"/>
|
||||
</vector>
|
@@ -123,11 +123,12 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/request_manage_credentials_more"
|
||||
android:textColor="?android:attr/colorBackground"
|
||||
android:theme="@style/Theme.CollapsingToolbar.Settings"
|
||||
app:backgroundTint="?android:attr/colorAccent"
|
||||
app:elevation="3dp"
|
||||
app:icon="@drawable/ic_arrow_downward"
|
||||
app:iconTint="?android:attr/textColorPrimary"
|
||||
app:iconTint="?android:attr/colorBackground"
|
||||
app:layout_anchor="@id/apps_list"
|
||||
app:layout_anchorGravity="bottom|center" />
|
||||
|
||||
|
@@ -97,11 +97,12 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/request_manage_credentials_more"
|
||||
android:textColor="?android:attr/colorBackground"
|
||||
android:theme="@style/Theme.CollapsingToolbar.Settings"
|
||||
app:backgroundTint="?android:attr/colorAccent"
|
||||
app:elevation="3dp"
|
||||
app:icon="@drawable/ic_arrow_downward"
|
||||
app:iconTint="?android:attr/textColorPrimary"
|
||||
app:iconTint="?android:attr/colorBackground"
|
||||
app:layout_anchor="@id/apps_list"
|
||||
app:layout_anchorGravity="bottom|center" />
|
||||
|
||||
|
@@ -67,11 +67,12 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/request_manage_credentials_more"
|
||||
android:textColor="?android:attr/colorBackground"
|
||||
app:layout_anchor="@id/apps_list"
|
||||
app:layout_anchorGravity="bottom|center"
|
||||
app:elevation="3dp"
|
||||
app:icon="@drawable/ic_arrow_downward"
|
||||
app:iconTint="?android:attr/textColorPrimary"
|
||||
app:iconTint="?android:attr/colorBackground"
|
||||
app:backgroundTint="?android:attr/colorAccent"
|
||||
android:theme="@style/Theme.CollapsingToolbar.Settings"/>
|
||||
|
||||
|
@@ -6865,7 +6865,11 @@
|
||||
<!-- Label for button to uninstall all certificates installed by the credential management app [CHAR LIMIT=30] -->
|
||||
<string name="uninstall_certs_credential_management_app">Uninstall certificates</string>
|
||||
<!-- Label for button to remove the credential management app [CHAR LIMIT=30] -->
|
||||
<string name="remove_credential_management_app">Remove</string>
|
||||
<string name="remove_credential_management_app">Remove app</string>
|
||||
<!-- Dialog title for button to remove the credential management app [CHAR LIMIT=30] -->
|
||||
<string name="remove_credential_management_app_dialog_title">Remove this app?</string>
|
||||
<!-- Dialog message for button to remove the credential management app [CHAR LIMIT=NONE] -->
|
||||
<string name="remove_credential_management_app_dialog_message">This app won\u2019t manage certificates, but it will stay on your device. Any certificates installed by the app will be uninstalled.</string>
|
||||
<!-- List item found in the credential management app's authentication policy [CHAR LIMIT=NONE] -->
|
||||
<plurals name="number_of_urls">
|
||||
<item quantity="one"><xliff:g id="number">%d</xliff:g> URL</item>
|
||||
@@ -7487,7 +7491,7 @@
|
||||
<!-- Button label for enabling a system CA certificate. -->
|
||||
<string name="trusted_credentials_enable_label">Enable</string>
|
||||
<!-- Button label for removing a user CA certificate. -->
|
||||
<string name="trusted_credentials_remove_label">Remove</string>
|
||||
<string name="trusted_credentials_remove_label">Uninstall</string>
|
||||
<!-- Button label for trusting a user CA certificate. -->
|
||||
<string name="trusted_credentials_trust_label">Trust</string>
|
||||
<!-- Alert dialog confirmation when enabling a system CA certificate. -->
|
||||
|
@@ -823,21 +823,18 @@
|
||||
<item name="android:fontFamily">google-sans-medium</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:textAllCaps">false</item>
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="RequestManageCredentialsDontAllowButton"
|
||||
parent="@style/Widget.AppCompat.Button.Borderless">
|
||||
parent="@style/Widget.AppCompat.Button.Borderless.Colored">
|
||||
<item name="android:fontFamily">google-sans-medium</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:textAllCaps">false</item>
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="RequestManageCredentialsFab">
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:textAllCaps">false</item>
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
<item name="android:layout_marginBottom">12dp</item>
|
||||
</style>
|
||||
|
||||
|
@@ -16,8 +16,11 @@
|
||||
|
||||
package com.android.settings.security;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.admin.DevicePolicyEventLogger;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
@@ -25,12 +28,15 @@ import android.security.IKeyChainService;
|
||||
import android.security.KeyChain;
|
||||
import android.stats.devicepolicy.DevicePolicyEnums;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settingslib.widget.ActionButtonsPreference;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@@ -48,9 +54,16 @@ public class CredentialManagementAppButtonsController extends BasePreferenceCont
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
private boolean mHasCredentialManagerPackage;
|
||||
private Fragment mFragment;
|
||||
private final int mRemoveIcon;
|
||||
|
||||
public CredentialManagementAppButtonsController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
if (context.getResources().getConfiguration().getLayoutDirection()
|
||||
== View.LAYOUT_DIRECTION_RTL) {
|
||||
mRemoveIcon = R.drawable.ic_redo_24;
|
||||
} else {
|
||||
mRemoveIcon = R.drawable.ic_undo_24;
|
||||
}
|
||||
}
|
||||
|
||||
public void setParentFragment(Fragment fragment) {
|
||||
@@ -84,8 +97,8 @@ public class CredentialManagementAppButtonsController extends BasePreferenceCont
|
||||
.setButton1Icon(R.drawable.ic_upload)
|
||||
.setButton1OnClickListener(view -> uninstallCertificates())
|
||||
.setButton2Text(R.string.remove_credential_management_app)
|
||||
.setButton2Icon(R.drawable.ic_delete)
|
||||
.setButton2OnClickListener(view -> removeCredentialManagementApp());
|
||||
.setButton2Icon(mRemoveIcon)
|
||||
.setButton2OnClickListener(view -> showRemoveCredentialManagementAppDialog());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,18 +116,54 @@ public class CredentialManagementAppButtonsController extends BasePreferenceCont
|
||||
});
|
||||
}
|
||||
|
||||
private void removeCredentialManagementApp() {
|
||||
mExecutor.execute(() -> {
|
||||
try {
|
||||
IKeyChainService service = KeyChain.bind(mContext).getService();
|
||||
service.removeCredentialManagementApp();
|
||||
DevicePolicyEventLogger
|
||||
.createEvent(DevicePolicyEnums.CREDENTIAL_MANAGEMENT_APP_REMOVED)
|
||||
.write();
|
||||
mFragment.getActivity().finish();
|
||||
} catch (InterruptedException | RemoteException e) {
|
||||
Log.e(TAG, "Unable to remove the credential management app");
|
||||
}
|
||||
});
|
||||
private void showRemoveCredentialManagementAppDialog() {
|
||||
final RemoveCredentialManagementAppDialog dialog =
|
||||
RemoveCredentialManagementAppDialog.newInstance();
|
||||
dialog.show(mFragment.getParentFragmentManager(),
|
||||
RemoveCredentialManagementAppDialog.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements an AlertDialog for confirming that a user wants to remove the credential
|
||||
* management app. The app will no longer be able to manage certificates, but it will stay on
|
||||
* the device. All certificates installed by the credential management app will be uninstalled.
|
||||
*/
|
||||
public static class RemoveCredentialManagementAppDialog extends InstrumentedDialogFragment {
|
||||
|
||||
public static RemoveCredentialManagementAppDialog newInstance() {
|
||||
return new RemoveCredentialManagementAppDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getContext(), R.style.Theme_AlertDialog)
|
||||
.setTitle(R.string.remove_credential_management_app_dialog_title)
|
||||
.setMessage(R.string.remove_credential_management_app_dialog_message)
|
||||
.setPositiveButton(R.string.remove_credential_management_app,
|
||||
(dialog, which) -> removeCredentialManagementApp())
|
||||
.setNegativeButton(R.string.cancel, (dialog, which) -> dismiss())
|
||||
.create();
|
||||
}
|
||||
|
||||
private void removeCredentialManagementApp() {
|
||||
final ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
executor.execute(() -> {
|
||||
try {
|
||||
IKeyChainService service = KeyChain.bind(getContext()).getService();
|
||||
service.removeCredentialManagementApp();
|
||||
DevicePolicyEventLogger
|
||||
.createEvent(DevicePolicyEnums.CREDENTIAL_MANAGEMENT_APP_REMOVED)
|
||||
.write();
|
||||
getParentFragment().getActivity().finish();
|
||||
} catch (InterruptedException | RemoteException e) {
|
||||
Log.e(TAG, "Unable to remove the credential management app");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.CREDENTIAL_MANAGEMENT_APP_REMOVE_APP;
|
||||
}
|
||||
}
|
||||
}
|
@@ -288,7 +288,7 @@ public class RequestManageCredentials extends Activity {
|
||||
// On down scroll, hide text in floating action button by setting
|
||||
// extended to false.
|
||||
if (dy > 0 && mExtendedFab.getVisibility() == View.VISIBLE) {
|
||||
mExtendedFab.setExtended(false);
|
||||
mExtendedFab.shrink();
|
||||
}
|
||||
if (isRecyclerScrollable()) {
|
||||
mExtendedFab.show();
|
||||
|
Reference in New Issue
Block a user