summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Zemiao Zhu <zemiao@google.com> 2021-05-10 10:59:38 -0700
committer Zemiao Zhu <zemiao@google.com> 2021-05-10 22:50:08 +0000
commit5a0b5e73ad176dbeec196bb718a43a165b4eb2b7 (patch)
treeca0bd3c1ec93051d831a0c641ec5cc9646eb0b6c
parentbf7e9c39ae9331c9bcc43626abb7fd13705c26f6 (diff)
Disable launcher icon for S.
Bug: 175598952 Test: Preload RRO with "is_launcher_enabled:true" on S, flash all device, boot to verify if DocumentsUI launcher icon hidden. Change-Id: I8562fd5eb0dec40e10a892c6320c88fb85bae9a2
-rw-r--r--res/values-v31/config.xml22
-rw-r--r--src/com/android/documentsui/PreBootReceiver.java11
2 files changed, 30 insertions, 3 deletions
diff --git a/res/values-v31/config.xml b/res/values-v31/config.xml
new file mode 100644
index 000000000..a96a3e999
--- /dev/null
+++ b/res/values-v31/config.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources>
+ <!-- Starting from Android S, using DocumentsUI as a file browser with launcher icon is no
+ longer supported. -->
+ <bool name="is_launcher_enabled">false</bool>
+</resources>
diff --git a/src/com/android/documentsui/PreBootReceiver.java b/src/com/android/documentsui/PreBootReceiver.java
index c47631654..f5ad9395a 100644
--- a/src/com/android/documentsui/PreBootReceiver.java
+++ b/src/com/android/documentsui/PreBootReceiver.java
@@ -30,6 +30,7 @@ import android.content.res.Resources;
import android.util.Log;
import com.android.documentsui.theme.ThemeOverlayManager;
+import com.android.documentsui.util.VersionUtils;
/**
* A receiver listening action.PRE_BOOT_COMPLETED event for setting component enable or disable.
@@ -91,11 +92,15 @@ public class PreBootReceiver extends BroadcastReceiver {
int resId = overlayRes.getIdentifier(config, "bool", overlayPkg);
if (resId != 0) {
final ComponentName component = new ComponentName(packageName, className);
- final boolean value = overlayRes.getBoolean(resId);
+ boolean enabled = overlayRes.getBoolean(resId);
+ if (VersionUtils.isAtLeastS() && CONFIG_IS_LAUNCHER_ENABLED.equals(config)) {
+ enabled = false; // Do not allow LauncherActivity to be enabled for S+.
+ }
if (DEBUG) {
- Log.i(TAG, "Overlay package:" + overlayPkg + ", customize " + config + ":" + value);
+ Log.i(TAG,
+ "Overlay package:" + overlayPkg + ", customize " + config + ":" + enabled);
}
- pm.setComponentEnabledSetting(component, value
+ pm.setComponentEnabledSetting(component, enabled
? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
: PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);