Skip to content

Commit

Permalink
Settings: Add Security Hub from Pixel devices
Browse files Browse the repository at this point in the history
Obviously it needs the SecurityHubPrebuilt.apk installed
on your system for it to work correctly.

Change-Id: I3843f6134743db9802bc5c84bc4f609928549081
Signed-off-by: Jason Edson <[email protected]>
  • Loading branch information
mydongistiny authored and madmax7896 committed Sep 1, 2023
1 parent 92b5a4d commit a380e24
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 17 deletions.
13 changes: 13 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ android_library {
"Settings-change-ids",
"SystemUIUnfoldLib",
"co.aospa.framework",
"google-securityhub",
],

libs: [
Expand Down Expand Up @@ -150,6 +151,18 @@ android_app {
],
}

android_library_import {
name: "google-securityhub",
aars: ["libs/google-securityhub.aar"],
sdk_version: "33",
static_libs: [
"androidx.preference_preference",
"com.google.android.material_material",
"guava",
]
}


android_library_import {
name: "contextualcards",
aars: ["libs/contextualcards.aar"],
Expand Down
Binary file added libs/google-securityhub.aar
Binary file not shown.
5 changes: 4 additions & 1 deletion src/com/android/settings/core/gateway/SettingsGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@
import com.android.settings.wifi.tether.WifiTetherClientManager;
import com.android.settings.wifi.tether.WifiTetherSettings;

import com.google.android.settings.security.SecurityHubDashboard;

public class SettingsGateway {

/**
Expand Down Expand Up @@ -353,7 +355,8 @@ public class SettingsGateway {
AppLocaleDetails.class.getName(),
TurnScreenOnSettings.class.getName(),
TurnScreenOnDetails.class.getName(),
WifiTetherClientManager.class.getName()
WifiTetherClientManager.class.getName(),
SecurityHubDashboard.class.getName()
};

public static final String[] SETTINGS_FOR_RESTRICTED = {
Expand Down
4 changes: 3 additions & 1 deletion src/com/android/settings/overlay/FeatureFactoryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import com.android.settings.wifi.WifiTrackerLibProvider;
import com.android.settings.wifi.WifiTrackerLibProviderImpl;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.google.android.settings.security.SecuritySettingsFeatureProviderGoogleImpl;

/**
* {@link FeatureFactory} implementation for AOSP Settings.
Expand Down Expand Up @@ -314,7 +315,8 @@ public WifiTrackerLibProvider getWifiTrackerLibProvider() {
@Override
public SecuritySettingsFeatureProvider getSecuritySettingsFeatureProvider() {
if (mSecuritySettingsFeatureProvider == null) {
mSecuritySettingsFeatureProvider = new SecuritySettingsFeatureProviderImpl();
mSecuritySettingsFeatureProvider =
new SecuritySettingsFeatureProviderGoogleImpl(getAppContext());
}
return mSecuritySettingsFeatureProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,26 @@

package com.android.settings.security;

import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import com.google.android.settings.security.SecurityHubDashboard;

/** Implementation for {@code SecuritySettingsFeatureProvider}. */
public class SecuritySettingsFeatureProviderImpl implements SecuritySettingsFeatureProvider {

@Override
public boolean hasAlternativeSecuritySettingsFragment() {
return false;
return true;
}

@Override
public String getAlternativeSecuritySettingsFragmentClassname() {
return null;
return SecurityHubDashboard.class.getName();
}

@Override
public String getAlternativeAdvancedSettingsCategoryKey() {
return null;
return FeatureFactory.getAppContext().getString(
R.string.config_alternative_advanced_security_category_key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.safetycenter.SafetyCenterManagerWrapper;
import com.google.android.settings.security.SecurityHubDashboard;

public class TopLevelSecurityEntryPreferenceController extends BasePreferenceController {

Expand All @@ -50,18 +51,14 @@ public boolean handlePreferenceTreeClick(Preference preference) {
return super.handlePreferenceTreeClick(preference);
}

if (mSecuritySettingsFeatureProvider.hasAlternativeSecuritySettingsFragment()) {
String alternativeFragmentClassname =
mSecuritySettingsFeatureProvider
.getAlternativeSecuritySettingsFragmentClassname();
if (alternativeFragmentClassname != null) {
new SubSettingLauncher(mContext)
.setDestination(alternativeFragmentClassname)
.setSourceMetricsCategory(getMetricsCategory())
.setIsSecondLayerPage(true)
.launch();
return true;
}
String alternativeFragmentClassname = SecurityHubDashboard.class.getName();
if (alternativeFragmentClassname != null) {
new SubSettingLauncher(mContext)
.setDestination(alternativeFragmentClassname)
.setSourceMetricsCategory(getMetricsCategory())
.setIsSecondLayerPage(true)
.launch();
return true;
}

return super.handlePreferenceTreeClick(preference);
Expand Down

0 comments on commit a380e24

Please sign in to comment.