lineage_patches_unified/patches_device/frameworks_base/0001-fwb-Start-device-specific-popup-camera-service-condi.patch
2021-08-08 09:32:01 +00:00

134 lines
5.7 KiB
Diff

From f63609cfc0fcc6a488ba7d024a1b1e3853637b09 Mon Sep 17 00:00:00 2001
From: jhenrique09 <jhenrique09.mcz@hotmail.com>
Date: Sun, 29 Mar 2020 17:38:39 -0300
Subject: [PATCH] fwb: Start device specific popup camera service conditionally
Change-Id: I07f97fe58495ef666fa317d14fa1334389015e11
---
.../custom/popupcamera/PopUpCameraUtils.java | 20 +++++++++++++++++++
core/res/res/values/lineage_config.xml | 3 +++
core/res/res/values/lineage_symbols.xml | 3 +++
.../server/camera/CameraServiceProxy.java | 20 +++++++++++++++++++
4 files changed, 46 insertions(+)
create mode 100644 core/java/com/android/internal/util/custom/popupcamera/PopUpCameraUtils.java
diff --git a/core/java/com/android/internal/util/custom/popupcamera/PopUpCameraUtils.java b/core/java/com/android/internal/util/custom/popupcamera/PopUpCameraUtils.java
new file mode 100644
index 00000000000..f7988608141
--- /dev/null
+++ b/core/java/com/android/internal/util/custom/popupcamera/PopUpCameraUtils.java
@@ -0,0 +1,20 @@
+/*
+* Copyright (C) 2019 The Pixel Experience 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.internal.util.custom.popupcamera;
+
+public class PopUpCameraUtils {
+ public static String MANAGE_POPUP_CAMERA_SERVICE_PERMISSION = "org.pixelexperience.device.MANAGE_POPUP_CAMERA_SERVICE";
+}
diff --git a/core/res/res/values/lineage_config.xml b/core/res/res/values/lineage_config.xml
index 4b090379f5a..3315de74147 100644
--- a/core/res/res/values/lineage_config.xml
+++ b/core/res/res/values/lineage_config.xml
@@ -34,4 +34,7 @@
<!-- The list of components which should be forced to be enabled. -->
<string-array name="config_forceEnabledComponents" translatable="false">
</string-array>
+
+ <!-- Component name of popup camera service -->
+ <string name="config_popUpCameraServiceComponentName" translatable="false"></string>
</resources>
diff --git a/core/res/res/values/lineage_symbols.xml b/core/res/res/values/lineage_symbols.xml
index 155da4479fb..c7e58b3943f 100644
--- a/core/res/res/values/lineage_symbols.xml
+++ b/core/res/res/values/lineage_symbols.xml
@@ -25,4 +25,7 @@
<java-symbol type="array" name="config_deviceDisabledComponents" />
<java-symbol type="array" name="config_globallyDisabledComponents" />
<java-symbol type="array" name="config_forceEnabledComponents" />
+
+ <!-- Component name of popup camera service -->
+ <java-symbol type="string" name="config_popUpCameraServiceComponentName" />
</resources>
diff --git a/services/core/java/com/android/server/camera/CameraServiceProxy.java b/services/core/java/com/android/server/camera/CameraServiceProxy.java
index 5f7a72c8512..9e72fa09993 100644
--- a/services/core/java/com/android/server/camera/CameraServiceProxy.java
+++ b/services/core/java/com/android/server/camera/CameraServiceProxy.java
@@ -16,6 +16,7 @@
package com.android.server.camera;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -32,6 +33,7 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
+import android.os.UserHandle;
import android.os.UserManager;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -53,6 +55,8 @@ import java.util.Set;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import com.android.internal.util.custom.popupcamera.PopUpCameraUtils;
+
/**
* CameraServiceProxy is the system_server analog to the camera service running in cameraserver.
*
@@ -106,6 +110,8 @@ public class CameraServiceProxy extends SystemService
private final boolean mNotifyNfc;
private final boolean mAllowMediaUid;
+ private final String mPopUpCameraServiceComponentName;
+
private ScheduledThreadPoolExecutor mLogWriterService = new ScheduledThreadPoolExecutor(
/*corePoolSize*/ 1);
@@ -218,6 +224,8 @@ public class CameraServiceProxy extends SystemService
// Don't keep any extra logging threads if not needed
mLogWriterService.setKeepAliveTime(1, TimeUnit.SECONDS);
mLogWriterService.allowCoreThreadTimeOut(true);
+ mPopUpCameraServiceComponentName = mContext.getResources().getString(
+ com.android.internal.R.string.config_popUpCameraServiceComponentName);
}
@Override
@@ -338,6 +346,18 @@ public class CameraServiceProxy extends SystemService
}
}
+ @Override
+ public void onBootPhase(int phase) {
+ if (phase == PHASE_BOOT_COMPLETED &&
+ !mPopUpCameraServiceComponentName.equals("")) {
+ String perm = PopUpCameraUtils.MANAGE_POPUP_CAMERA_SERVICE_PERMISSION;
+ mContext.enforceCallingOrSelfPermission(perm, "Missing or invalid popup camera service permission: " + perm);
+ Intent i = new Intent();
+ i.setComponent(ComponentName.unflattenFromString(mPopUpCameraServiceComponentName));
+ mContext.startServiceAsUser(i, UserHandle.SYSTEM);
+ }
+ }
+
/**
* Dump camera usage events to log.
* Package-private
--
2.25.1