bangkk: Remove camera 5G disabler

Revert "dubai: camera: Ignore face unlock and ASI front camera usage"

This reverts commit 3e6bd8cf18.

Revert "dubai: camera: Disable N78 5G NSA band too"

This reverts commit 9b139ed94d.

Revert "dubai: Disable only N78 5G SA band for front camera"

This reverts commit b9046bddf1.

Revert "dubai: Disable 5G when front camera is in use"

This reverts commit 8808e9b818.

Change-Id: Ib786873d8d5707a6a1b6dbec5fbaf5d38be1ebac
This commit is contained in:
Michael Bestas 2024-06-28 16:24:33 +03:00
parent 5ee3b39628
commit 5a8bfe1975
No known key found for this signature in database
8 changed files with 0 additions and 443 deletions

View file

@ -1,24 +0,0 @@
//
// SPDX-FileCopyrightText: 2023 ArrowOS
// SPDX-License-Identifier: Apache-2.0
//
android_app {
name: "DubaiCameraService",
srcs: [
"src/**/*.java",
"src/**/*.aidl",
],
certificate: "platform",
platform_apis: true,
privileged: true,
system_ext_specific: true,
required: ["privapp-permissions-dubaicameraservice.xml"],
}
prebuilt_etc {
name: "privapp-permissions-dubaicameraservice.xml",
src: "privapp-permissions-dubaicameraservice.xml",
system_ext_specific: true,
sub_dir: "permissions",
}

View file

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2023 ArrowOS
SPDX-License-Identifier: Apache-2.0
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.arrow.dubaicameraservice"
android:sharedUserId="android.uid.system">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.CAMERA_OPEN_CLOSE_LISTENER" />
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="com.qualcomm.permission.USE_QCRIL_MSG_TUNNEL" />
<application
android:label="DubaiCameraService"
android:persistent="true">
<receiver
android:name=".BootReceiver"
android:exported="false">
<intent-filter android:priority="1000">
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<service android:name=".DubaiCameraService"
android:permission="DubaiCameraService"
android:exported="false">
</service>
</application>
</manifest>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2023 ArrowOS
SPDX-License-Identifier: Apache-2.0
-->
<permissions>
<privapp-permissions package="com.arrow.dubaicameraservice">
<permission name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
<permission name="android.permission.MODIFY_PHONE_STATE"/>
</privapp-permissions>
</permissions>

View file

@ -1,21 +0,0 @@
/*
* SPDX-FileCopyrightText: 2023 ArrowOS
* SPDX-License-Identifier: Apache-2.0
*/
package com.arrow.dubaicameraservice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
if (!intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED))
return;
DubaiCameraService.startService(context);
}
}

View file

@ -1,162 +0,0 @@
/*
* SPDX-FileCopyrightText: 2023 ArrowOS
* SPDX-License-Identifier: Apache-2.0
*/
package com.arrow.dubaicameraservice;
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.hardware.camera2.CameraManager;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.IBinder;
import android.os.Looper;
import android.os.UserHandle;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.util.Log;
import java.util.Arrays;
import java.util.Set;
import java.util.concurrent.Executor;
public class DubaiCameraService extends Service {
private static final boolean DEBUG = false;
private static final String TAG = "DubaiCameraService";
private static final String FRONT_CAMERA_ID = "1";
private static final int OFFENDING_NR_BAND = 78;
private static final Set<String> IGNORED_PACKAGES = Set.of(
"co.aospa.sense", // face unlock
"com.google.android.as" // auto rotate, screen attention etc
);
private CameraManager mCameraManager;
private SubscriptionManager mSubManager;
private TelephonyManager mTelephonyManager;
private QcRilMsgUtils mQcRilMsgUtils;
private boolean mIsFrontCamInUse = false;
private int[] mActiveSubIds = new int[0];
private int mDefaultDataSubId = INVALID_SUBSCRIPTION_ID;
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final Executor mExecutor = new HandlerExecutor(mHandler);
private final CameraManager.AvailabilityCallback mCameraCallback =
new CameraManager.AvailabilityCallback() {
@Override
public void onCameraOpened(String cameraId, String packageId) {
dlog("onCameraOpened id=" + cameraId + " package=" + packageId);
if (cameraId.equals(FRONT_CAMERA_ID) && !IGNORED_PACKAGES.contains(packageId)) {
mIsFrontCamInUse = true;
update5gState();
}
}
@Override
public void onCameraClosed(String cameraId) {
dlog("onCameraClosed id=" + cameraId);
if (cameraId.equals(FRONT_CAMERA_ID) && mIsFrontCamInUse) {
mIsFrontCamInUse = false;
update5gState();
}
}
};
private final SubscriptionManager.OnSubscriptionsChangedListener mSubListener =
new SubscriptionManager.OnSubscriptionsChangedListener() {
@Override
public void onSubscriptionsChanged() {
dlog("onSubscriptionsChanged");
final int[] subs = mSubManager.getActiveSubscriptionIdList();
if (!Arrays.equals(subs, mActiveSubIds)) {
dlog("active subs changed, was: " + Arrays.toString(mActiveSubIds)
+ ", now: " + Arrays.toString(subs));
mActiveSubIds = subs;
update5gState();
}
}
};
private class ActiveDataSubIdCallback extends TelephonyCallback implements
TelephonyCallback.ActiveDataSubscriptionIdListener {
@Override
public void onActiveDataSubscriptionIdChanged(int subId) {
dlog("onActiveDataSubscriptionIdChanged subId:" + subId);
if (subId != mDefaultDataSubId) {
mDefaultDataSubId = subId;
update5gState();
}
}
};
private final TelephonyCallback mTelephonyCallback = new ActiveDataSubIdCallback();
@Override
public void onCreate() {
dlog("onCreate");
mQcRilMsgUtils = new QcRilMsgUtils(this);
mCameraManager = getSystemService(CameraManager.class);
mSubManager = getSystemService(SubscriptionManager.class);
mTelephonyManager = getSystemService(TelephonyManager.class);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
dlog("onStartCommand");
mQcRilMsgUtils.bindService();
mCameraManager.registerAvailabilityCallback(mCameraCallback, mHandler);
mTelephonyManager.registerTelephonyCallback(mExecutor, mTelephonyCallback);
mSubManager.addOnSubscriptionsChangedListener(mExecutor, mSubListener);
return START_STICKY;
}
@Override
public void onDestroy() {
dlog("onDestroy");
mQcRilMsgUtils.unbindService();
mCameraManager.unregisterAvailabilityCallback(mCameraCallback);
mTelephonyManager.unregisterTelephonyCallback(mTelephonyCallback);
mSubManager.removeOnSubscriptionsChangedListener(mSubListener);
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
public static void startService(Context context) {
Log.i(TAG, "Starting service");
context.startServiceAsUser(new Intent(context, DubaiCameraService.class),
UserHandle.CURRENT);
}
private void update5gState() {
if (mDefaultDataSubId == INVALID_SUBSCRIPTION_ID
|| mActiveSubIds.length == 0) {
dlog("update5gState: Invalid subid or no active subs!");
return;
}
if (mQcRilMsgUtils.setNrBandEnabled(mSubManager.getPhoneId(mDefaultDataSubId),
OFFENDING_NR_BAND, !mIsFrontCamInUse)) {
Log.i(TAG, (mIsFrontCamInUse ? "Disabled" : "Enabled") + " NR band "
+ OFFENDING_NR_BAND + " for subId " + mDefaultDataSubId);
} else {
Log.e(TAG, "Failed to " + (mIsFrontCamInUse ? "disable" : "enable") + " NR band "
+ OFFENDING_NR_BAND + " for subId " + mDefaultDataSubId);
}
}
protected static void dlog(String msg) {
if (DEBUG) Log.d(TAG, msg);
}
}

View file

@ -1,169 +0,0 @@
/*
* SPDX-FileCopyrightText: 2023 ArrowOS
* SPDX-License-Identifier: Apache-2.0
*/
package com.arrow.dubaicameraservice;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import com.qualcomm.qcrilmsgtunnel.IQcrilMsgTunnel;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class QcRilMsgUtils {
private static final String TAG = "DubaiCameraService-QcRil";
private static final String PACKAGE_NAME = "com.qualcomm.qcrilmsgtunnel";
private static final String SERVICE_NAME = "com.qualcomm.qcrilmsgtunnel.QcrilMsgTunnelService";
private static final int OEM_RIL_REQUEST_GET_BAND_PREF = 327723;
private static final int OEM_RIL_REQUEST_SET_BAND_PREF = 327724;
private static final int BAND_CONFIG_LENGTH = 168;
private static final int LTE_CONFIG_LENGTH = 4;
private static final int NR_CONFIG_LENGTH = 8;
private IQcrilMsgTunnel mService;
private QcrilMsgTunnelConnection mServiceConnection;
private Context mContext;
public QcRilMsgUtils(Context context) {
mContext = context;
mServiceConnection = new QcrilMsgTunnelConnection();
}
protected void bindService() {
dlog("bindService");
if (!mContext.bindService(new Intent().setClassName(PACKAGE_NAME, SERVICE_NAME),
mServiceConnection, Context.BIND_AUTO_CREATE)) {
Log.e(TAG, "Failed to bind to QcrilMsgTunnelService!");
}
}
protected void unbindService() {
dlog("unbindService");
mContext.unbindService(mServiceConnection);
mService = null;
}
/* TODO: split this function */
protected boolean setNrBandEnabled(int phoneId, int band, boolean enabled) {
if (mService == null) {
Log.e(TAG, "setNrSaBandEnabled: mService is null!");
return false;
}
dlog("setNrSaBandEnabled: phoneId=" + phoneId + " band=" + band + " enabled=" + enabled);
// get band config
byte[] reqData = new byte[8];
ByteBuffer reqBuf = ByteBuffer.wrap(reqData)
.order(ByteOrder.BIG_ENDIAN)
.putInt(OEM_RIL_REQUEST_GET_BAND_PREF)
.putInt(0);
byte[] resp = new byte[BAND_CONFIG_LENGTH];
try {
int ret = mService.sendOemRilRequestRaw(reqData, resp, phoneId);
if (ret < 0)
throw new Exception();
} catch (Exception e) {
Log.e(TAG, "sendOemRilRequestRaw failed to get band config!", e);
return false;
}
ByteBuffer buf = ByteBuffer.wrap(resp)
.order(ByteOrder.nativeOrder());
long nasConfig = buf.getLong();
long[] lteConfigs = new long[LTE_CONFIG_LENGTH];
for (int i = 0; i < LTE_CONFIG_LENGTH; i++) {
lteConfigs[i] = buf.getLong();
}
long[] nrSaConfigs = new long[NR_CONFIG_LENGTH];
for (int i = 0; i < NR_CONFIG_LENGTH; i++) {
nrSaConfigs[i] = buf.getLong();
}
long[] nrNsaConfigs = new long[NR_CONFIG_LENGTH];
for (int i = 0; i < NR_CONFIG_LENGTH; i++) {
nrNsaConfigs[i] = buf.getLong();
}
// modify band config
int row = (band - 1) / 64;
int col = (band - 1) % 64;
if (enabled) {
nrSaConfigs[row] |= (1 << col);
nrNsaConfigs[row] |= (1 << col);
} else {
nrSaConfigs[row] &= ~(1 << col);
nrNsaConfigs[row] &= ~(1 << col);
}
// set band config
byte[] newData = new byte[BAND_CONFIG_LENGTH + 8];
ByteBuffer newBuf = ByteBuffer.wrap(newData)
.order(ByteOrder.BIG_ENDIAN)
.putInt(OEM_RIL_REQUEST_SET_BAND_PREF)
.putInt(BAND_CONFIG_LENGTH)
.order(ByteOrder.nativeOrder())
.putLong(nasConfig);
for (int i = 0; i < LTE_CONFIG_LENGTH; i++) {
newBuf.putLong(lteConfigs[i]);
}
for (int i = 0; i < NR_CONFIG_LENGTH; i++) {
newBuf.putLong(nrSaConfigs[i]);
}
for (int i = 0; i < NR_CONFIG_LENGTH; i++) {
newBuf.putLong(nrNsaConfigs[i]);
}
try {
int ret = mService.sendOemRilRequestRaw(newData, new byte[1], phoneId);
if (ret < 0)
throw new Exception();
} catch (Exception e) {
Log.e(TAG, "sendOemRilRequestRaw failed to set band config!", e);
return false;
}
return true;
}
private class QcrilMsgTunnelConnection implements ServiceConnection {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IQcrilMsgTunnel.Stub.asInterface(service);
if (mService == null) {
Log.e(TAG, "Unable to get IQcrilMsgTunnel!");
return;
}
try {
service.linkToDeath(new IBinder.DeathRecipient() {
@Override
public void binderDied() {
Log.e(TAG, "QcrilMsgTunnel service died, trying to bind again");
mService = null;
QcRilMsgUtils.this.bindService();
}
}, 0);
} catch (RemoteException e) {
Log.e(TAG, "linkToDeath failed", e);
}
Log.i(TAG, "QcrilMsgTunnel service connected");
}
@Override
public void onServiceDisconnected(ComponentName name) {
Log.i(TAG, "QcrilMsgTunnel service disconnected");
mService = null;
}
}
private static void dlog(String msg) {
DubaiCameraService.dlog(msg);
}
}

View file

@ -1,16 +0,0 @@
/*
* SPDX-FileCopyrightText: 2023 ArrowOS
* SPDX-License-Identifier: Apache-2.0
*/
package com.qualcomm.qcrilmsgtunnel;
interface IQcrilMsgTunnel {
/**
* Sends a OEM request to the RIL and returns the response back to the
* Caller. The returnValue is negative on failure. 0 or length of response on SUCCESS
*/
int sendOemRilRequestRaw(in byte[] request, out byte[] response, in int sub);
}

View file

@ -41,10 +41,6 @@ PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \
$(LOCAL_PATH)/audio/default_volume_tables.xml:$(TARGET_COPY_OUT_VENDOR)/etc/default_volume_tables.xml
# Camera
PRODUCT_PACKAGES += \
DubaiCameraService
# Fingerprint
PRODUCT_PACKAGES += \
android.hardware.biometrics.fingerprint@2.3-service.bangkk