Merge "Remove "Allow persistent changes to the vendor overlay theme""
This commit is contained in:
committed by
Android (Google) Code Review
commit
bbf038bc5e
@@ -52,21 +52,6 @@ interface IUiModeManager {
|
||||
*/
|
||||
int getNightMode();
|
||||
|
||||
/**
|
||||
* Sets whith theme overlays to use within /vendor/overlay.
|
||||
*/
|
||||
void setTheme(String theme);
|
||||
|
||||
/**
|
||||
* Gets which theme overlays to use within /vendor/overlay.
|
||||
*/
|
||||
String getTheme();
|
||||
|
||||
/**
|
||||
* Gets the themes available in /vendor/overlay.
|
||||
*/
|
||||
String[] getAvailableThemes();
|
||||
|
||||
/**
|
||||
* Tells if UI mode is locked or not.
|
||||
*/
|
||||
|
||||
@@ -241,50 +241,6 @@ public class UiModeManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vendor theme overlay property, then triggers a reboot.
|
||||
* @hide
|
||||
*/
|
||||
public void setTheme(String theme) {
|
||||
if (mService != null) {
|
||||
try {
|
||||
mService.setTheme(theme);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vendor theme overlay property.
|
||||
* @hide
|
||||
*/
|
||||
public String getTheme() {
|
||||
if (mService != null) {
|
||||
try {
|
||||
return mService.getTheme();
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the valid inputs to {@link #setTheme(String)}.
|
||||
* @hide
|
||||
*/
|
||||
public String[] getAvailableThemes() {
|
||||
if (mService != null) {
|
||||
try {
|
||||
return mService.getAvailableThemes();
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently configured night mode.
|
||||
* <p>
|
||||
|
||||
@@ -178,11 +178,7 @@ static void verifySystemIdmaps()
|
||||
// Directories to scan for overlays: if OVERLAY_THEME_DIR_PROPERTY is defined,
|
||||
// use OVERLAY_DIR/<value of OVERLAY_THEME_DIR_PROPERTY> in addition to OVERLAY_DIR.
|
||||
char subdir[PROP_VALUE_MAX];
|
||||
int len = __system_property_get(AssetManager::OVERLAY_THEME_DIR_PERSIST_PROPERTY,
|
||||
subdir);
|
||||
if (len == 0) {
|
||||
len = __system_property_get(AssetManager::OVERLAY_THEME_DIR_PROPERTY, subdir);
|
||||
}
|
||||
int len = __system_property_get(AssetManager::OVERLAY_THEME_DIR_PROPERTY, subdir);
|
||||
if (len > 0) {
|
||||
String8 overlayPath = String8(AssetManager::OVERLAY_DIR) + "/" + subdir;
|
||||
if (stat(overlayPath.string(), &st) == 0) {
|
||||
|
||||
@@ -74,7 +74,6 @@ const char* AssetManager::RESOURCES_FILENAME = "resources.arsc";
|
||||
const char* AssetManager::IDMAP_BIN = "/system/bin/idmap";
|
||||
const char* AssetManager::OVERLAY_DIR = "/vendor/overlay";
|
||||
const char* AssetManager::OVERLAY_THEME_DIR_PROPERTY = "ro.boot.vendor.overlay.theme";
|
||||
const char* AssetManager::OVERLAY_THEME_DIR_PERSIST_PROPERTY = "persist.vendor.overlay.theme";
|
||||
const char* AssetManager::TARGET_PACKAGE_NAME = "android";
|
||||
const char* AssetManager::TARGET_APK_PATH = "/system/framework/framework-res.apk";
|
||||
const char* AssetManager::IDMAP_DIR = "/data/resource-cache";
|
||||
|
||||
@@ -66,11 +66,6 @@ public:
|
||||
* OVERLAY_DIR.
|
||||
*/
|
||||
static const char* OVERLAY_THEME_DIR_PROPERTY;
|
||||
/**
|
||||
* If OVERLAY_THEME_DIR_PERSIST_PROPERTY, use it to override
|
||||
* OVERLAY_THEME_DIR_PROPERTY.
|
||||
*/
|
||||
static const char* OVERLAY_THEME_DIR_PERSIST_PROPERTY;
|
||||
static const char* TARGET_PACKAGE_NAME;
|
||||
static const char* TARGET_APK_PATH;
|
||||
static const char* IDMAP_DIR;
|
||||
|
||||
@@ -322,52 +322,6 @@ final class UiModeManagerService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTheme(String theme) {
|
||||
if (getContext().checkCallingOrSelfPermission(
|
||||
android.Manifest.permission.MODIFY_THEME_OVERLAY)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
Slog.e(TAG, "setTheme requires MODIFY_THEME_OVERLAY permission");
|
||||
return;
|
||||
}
|
||||
SystemProperties.set("persist.vendor.overlay.theme", theme);
|
||||
mHandler.post(() -> ShutdownThread.reboot(getContext(),
|
||||
PowerManager.SHUTDOWN_USER_REQUESTED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTheme() {
|
||||
if (getContext().checkCallingOrSelfPermission(
|
||||
android.Manifest.permission.MODIFY_THEME_OVERLAY)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
Slog.e(TAG, "setTheme requires MODIFY_THEME_OVERLAY permission");
|
||||
return null;
|
||||
}
|
||||
return SystemProperties.get("persist.vendor.overlay.theme");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAvailableThemes() {
|
||||
if (getContext().checkCallingOrSelfPermission(
|
||||
android.Manifest.permission.MODIFY_THEME_OVERLAY)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
Slog.e(TAG, "getAvailableThemes requires MODIFY_THEME_OVERLAY permission");
|
||||
return null;
|
||||
}
|
||||
String def = SystemProperties.get("ro.boot.vendor.overlay.theme");
|
||||
if (TextUtils.isEmpty(def)) {
|
||||
def = null;
|
||||
}
|
||||
String[] fileList = new File("/vendor/overlay").list();
|
||||
if (fileList == null) return new String[0];
|
||||
ArrayList<String> options = new ArrayList(fileList.length + 1);
|
||||
Collections.addAll(options, fileList);
|
||||
if (!options.contains(def)) {
|
||||
options.add(0, def);
|
||||
}
|
||||
return options.toArray(new String[options.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNightMode() {
|
||||
synchronized (mLock) {
|
||||
|
||||
Reference in New Issue
Block a user