Disable theme components for secondary users

This patch is to mitigate theming problems with multiple users.
Once themes properly support multiple users we can revert this.

Change-Id: Idc89a273bc1563fc668ca2a5a591cf133e8d5406
(cherry picked from commit 836f867086ce22c6c9c2c26bba4440177b1d9099)
This commit is contained in:
d34d 2015-03-13 18:35:34 -07:00 committed by Gerrit Code Review
parent 2104b3f5db
commit 88aba00aa3

View File

@ -20,6 +20,7 @@ package com.cyanogenmod.setupwizard;
import android.app.Application; import android.app.Application;
import android.app.StatusBarManager; import android.app.StatusBarManager;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager;
import android.provider.Settings; import android.provider.Settings;
import com.cyanogenmod.setupwizard.util.SetupWizardUtils; import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
@ -46,6 +47,12 @@ public class SetupWizardApp extends Application {
private static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled"; private static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled";
private static final String[] THEME_PACKAGES = {
"org.cyanogenmod.theme.chooser",
"com.cyngn.theme.chooser",
"com.cyngn.themestore"
};
public static final int REQUEST_CODE_SETUP_WIFI = 0; public static final int REQUEST_CODE_SETUP_WIFI = 0;
public static final int REQUEST_CODE_SETUP_GMS= 1; public static final int REQUEST_CODE_SETUP_GMS= 1;
public static final int REQUEST_CODE_RESTORE_GMS= 2; public static final int REQUEST_CODE_RESTORE_GMS= 2;
@ -61,11 +68,15 @@ public class SetupWizardApp extends Application {
try { try {
// Since this is a new component, we need to disable here if the user // Since this is a new component, we need to disable here if the user
// has already been through setup on a previous version. // has already been through setup on a previous version.
if (!SetupWizardUtils.isOwner() final boolean isOwner = SetupWizardUtils.isOwner();
if (!isOwner
|| Settings.Secure.getInt(getContentResolver(), || Settings.Secure.getInt(getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE) == 1) { Settings.Secure.USER_SETUP_COMPLETE) == 1) {
SetupWizardUtils.disableGMSSetupWizard(this); SetupWizardUtils.disableGMSSetupWizard(this);
SetupWizardUtils.disableSetupWizard(this); SetupWizardUtils.disableSetupWizard(this);
if (!isOwner) {
disableThemeComponentsForSecondaryUser();
}
} else { } else {
disableCaptivePortalDetection(); disableCaptivePortalDetection();
} }
@ -73,7 +84,6 @@ public class SetupWizardApp extends Application {
// Continue with setup // Continue with setup
disableCaptivePortalDetection(); disableCaptivePortalDetection();
} }
} }
public void disableStatusBar() { public void disableStatusBar() {
@ -93,4 +103,17 @@ public class SetupWizardApp extends Application {
public void enableCaptivePortalDetection() { public void enableCaptivePortalDetection() {
Settings.Global.putInt(getContentResolver(), KEY_DETECT_CAPTIVE_PORTAL, 1); Settings.Global.putInt(getContentResolver(), KEY_DETECT_CAPTIVE_PORTAL, 1);
} }
private void disableThemeComponentsForSecondaryUser() {
PackageManager pm = getPackageManager();
for(String pkgName : THEME_PACKAGES) {
try {
pm.getApplicationInfo(pkgName, 0);
pm.setApplicationEnabledSetting(pkgName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER, 0);
} catch (PackageManager.NameNotFoundException e) {
// don't care
}
}
}
} }