Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
AOSP security dialog
As pointed out by CopperheadOS on Twiiter[1], Android security updates
include the Android operating system updates in addition to closed
source binaries[2]. Since we cannot control whether or not these
binaries get updated (since it relies on both the vendors to provide
the patches and the OEM to distribute them), we should make it clear
that we are only merging what comes from Google through the Android
Open Source Project repositories. While some may consider this change
pedantic, it does not make it untrue or unreasonable to do.

This changes the look and feel of the 'Security level' preference to
only show it as "AOSP security patch level" but also launch a dialog
explaining the difference between AOSP security updates and actual
security updates. Furthermore, explain to the user that we merge in
functional updates along with the security updates.

[1]: https://twitter.com/CopperheadOS/status/984509294941892608
[2]: https://source.android.com/security/bulletin/2018-04-01#qualcomm-closed-source-components

Change-Id: Ia78de284277b39a176cb2c2d4146cf0f32f39644
Signed-off-by: Nathan Chancellor <nathan@dirtyunicorns.com>
  • Loading branch information
Alex Cruz committed Apr 21, 2018
1 parent 835be35 commit 7dd1767
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 2 deletions.
10 changes: 10 additions & 0 deletions res/drawable/security_dialog_corners.xml
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="1dp" android:color="@android:color/transparent" />
<solid android:color="@color/BottomBarBackgroundColor" />
<corners
android:bottomRightRadius="8dp"
android:bottomLeftRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp"/>
</shape>
68 changes: 68 additions & 0 deletions res/layout/security_dialog_layout.xml
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="@string/security_dialog_title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="22sp"
android:textStyle="bold" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="12dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:clickable="true"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/android_security_title"
android:textColor="?android:attr/textColorSecondary"
android:textSize="16sp" />

<TextView
android:id="@+id/security_patch_level_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:attr/colorAccent"
android:textSize="14sp" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/android_security_summary"
android:textColor="?android:attr/textColorSecondary"
android:textSize="16sp" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/android_functional_updates_title"
android:textColor="?android:attr/textColorSecondary"
android:textSize="16sp" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/android_functional_updates_summary"
android:textColor="?android:attr/textColorSecondary"
android:textSize="16sp" />
</LinearLayout>

</LinearLayout>
</ScrollView>
9 changes: 9 additions & 0 deletions res/values/du_strings.xml
Expand Up @@ -15,6 +15,15 @@
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

<!-- Security dialog -->
<string name="aosp_security_bulletin_url">https://source.android.com/security/bulletin/2018-04-01</string>
<string name="security_dialog_title">Security updates</string>
<string name="security_dialog_neutral_button">AOSP Security Bulletins</string>
<string name="android_security_title">AOSP security patch level</string>
<string name="android_security_summary">Android security updates are a collection of patches to the Android platform and the vendor binaries that help it run. Since these binaries are closed source, we have to rely on the vendors to supply them to the OEMs and the OEMs to ship them to users so we can add them to our builds. As we cannot control this process at all, we want to make it clear that we only update the security patch level in the repos that come from the Android Open Source Project. Generally, the vendor security patch level will be whatever patch level the latest stock ROM is on.</string>
<string name="android_functional_updates_title">Functional updates</string>
<string name="android_functional_updates_summary">In addition to AOSP security updates, we include Google\'s functional updates. These are patches that Google push in addition to security updates for Pixel devices to address functionality issues such as connectivity, stability, and performance. Since we support more than just Pixel devices, they are included for all our devices.</string>

<!-- Message shown in fingerprint enrollment dialog to locate the sensor -->
<string name="security_settings_fingerprint_enroll_find_sensor_message_custom">It\u2019s on the back of your phone. Use any finger.</string>

Expand Down
5 changes: 5 additions & 0 deletions res/values/du_styles.xml
Expand Up @@ -17,4 +17,9 @@

<resources>
<style name="Theme.SmartBar.Dialog" parent="@*android:style/Theme.DeviceDefault.Light.Dialog.Alert" />

<style name="SecurityDialog" parent="@*android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar.MinWidth">
<item name="android:windowBackground">@drawable/security_dialog_corners</item>
</style>

</resources>
10 changes: 8 additions & 2 deletions res/xml/device_info_settings.xml
Expand Up @@ -82,13 +82,19 @@
android:title="@string/firmware_version"
android:summary="@string/summary_placeholder"/>

<!-- Security dialog -->
<Preference
android:key="security_dialog"
android:title="@string/android_security_title"
android:summary=""/>

<!-- Security patch level -->
<Preference android:key="security_patch"
<!--Preference android:key="security_patch"
android:title="@string/security_patch"
android:summary="@string/summary_placeholder">
<intent android:action="android.intent.action.VIEW"
android:data="https://source.android.com/security/bulletin/" />
</Preference>
</Preference-->

<!-- ROM Version -->
<Preference
Expand Down
2 changes: 2 additions & 0 deletions src/com/android/settings/DeviceInfoSettings.java
Expand Up @@ -39,6 +39,7 @@
import com.android.settings.deviceinfo.ROMVersionPreferenceController;
import com.android.settings.deviceinfo.SELinuxStatusPreferenceController;
import com.android.settings.deviceinfo.SafetyInfoPreferenceController;
import com.android.settings.deviceinfo.SecurityDialogPreferenceController;
import com.android.settings.deviceinfo.SecurityPatchPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
Expand Down Expand Up @@ -130,6 +131,7 @@ private static List<AbstractPreferenceController> buildPreferenceControllers(Con
controllers.add(new FirmwareVersionPreferenceController(context, lifecycle));
//controllers.add(new RegulatoryInfoPreferenceController(context));
controllers.add(new DeviceModelPreferenceController(context, fragment));
controllers.add(new SecurityDialogPreferenceController(context, fragment));
controllers.add(new SecurityPatchPreferenceController(context));
controllers.add(new FccEquipmentIdPreferenceController(context));
controllers.add(new SELinuxStatusPreferenceController(context));
Expand Down
90 changes: 90 additions & 0 deletions src/com/android/settings/deviceinfo/SecurityDialogFragment.java
@@ -0,0 +1,90 @@
/*
* Copyright (C) 2017 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.deviceinfo;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settingslib.DeviceInfoUtils;

public class SecurityDialogFragment extends InstrumentedDialogFragment {

public static final String TAG = "SecurityDialogTag";

public static SecurityDialogFragment newInstance() {
return new SecurityDialogFragment();
}

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),
R.style.SecurityDialog);

@SuppressLint("InflateParams") final View content = LayoutInflater.from(builder.getContext())
.inflate(R.layout.security_dialog_layout, null /* parent */);

TextView mSecurityPatch = content.findViewById(R.id.security_patch_level_text);
mSecurityPatch.setText(DeviceInfoUtils.getSecurityPatch());

builder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.setNeutralButton(getString(R.string.security_dialog_neutral_button), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.aosp_security_bulletin_url)));
startActivity(intent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
});
if (getDialog() != null && getDialog().getWindow() != null) {
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
}
return builder.setView(content).create();
}

@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.DIRTYTWEAKS;
}
}
@@ -0,0 +1,71 @@
/*
* Copyright (C) 2017 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.deviceinfo;

import android.app.Fragment;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;

import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.deviceinfo.SecurityDialogFragment;
import com.android.settingslib.DeviceInfoUtils;
import com.android.settingslib.core.AbstractPreferenceController;

public class SecurityDialogPreferenceController extends AbstractPreferenceController implements
PreferenceControllerMixin {

private static final String TAG = "SecurityDialogTag";
private static final String KEY_SECURITY_DIALOG = "security_dialog";

private final Fragment mHost;

public SecurityDialogPreferenceController(Context context, Fragment host) {
super(context);
mHost = host;
}

@Override
public boolean isAvailable() {
return true;
}

@Override
public String getPreferenceKey() {
return KEY_SECURITY_DIALOG;
}

@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
final Preference pref = screen.findPreference(KEY_SECURITY_DIALOG);
if (pref == null) return;
pref.setSummary(DeviceInfoUtils.getSecurityPatch());
}

@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (TextUtils.equals(preference.getKey(), KEY_SECURITY_DIALOG)) {
SecurityDialogFragment fragment = SecurityDialogFragment.newInstance();
fragment.show(mHost.getFragmentManager(), SecurityDialogFragment.TAG);
return true;
}
return false;
}
}

0 comments on commit 7dd1767

Please sign in to comment.