zuma: Disable Euicc when GMS and GSF are not installed
* This avoids EuiccGoogle / GoogleCarrierServices crashing, taking the whole telephony stack with them when no GMS or GSF is installed. * Compared to change 274251, this approach is no-op when GAPPS add-on is flashed before the first boot, and thus should not cause issues with eSIM when GAPPS is flashed. * With microG, this also works after installing the microG GMS & GSF packages and rebooting, although manual activation of the eSIM is needed via Settings - Network. * The only downside is that users will still see one or two crashes during the first boot because our application only starts after the device is booted. Change-Id: I4a11c93e855978abbf8d84fdbe4ffc8b2aedc27c
This commit is contained in:
parent
fbc4a55c4e
commit
ff57b774d2
6 changed files with 181 additions and 0 deletions
|
@ -22,5 +22,9 @@ include hardware/google/pixel/lineage_health/device.mk
|
|||
PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS += \
|
||||
device/google/zumapro/linker.config.json
|
||||
|
||||
# Parts
|
||||
PRODUCT_PACKAGES += \
|
||||
GoogleParts
|
||||
|
||||
# Touch
|
||||
include hardware/google/pixel/touch/device.mk
|
||||
|
|
23
parts/Android.bp
Normal file
23
parts/Android.bp
Normal file
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// Copyright (C) 2021 The LineageOS Project
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
android_app {
|
||||
name: "GoogleParts",
|
||||
|
||||
srcs: ["src/**/*.java"],
|
||||
certificate: "platform",
|
||||
platform_apis: true,
|
||||
privileged: true,
|
||||
system_ext_specific: true,
|
||||
|
||||
static_libs: [
|
||||
"org.lineageos.settings.resources",
|
||||
],
|
||||
|
||||
optimize: {
|
||||
proguard_flags_files: ["proguard.flags"],
|
||||
},
|
||||
}
|
48
parts/AndroidManifest.xml
Normal file
48
parts/AndroidManifest.xml
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 The LineageOS 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.
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.lineageos.settings"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0"
|
||||
android:sharedUserId="android.uid.system">
|
||||
|
||||
<queries>
|
||||
<package android:name="com.google.android.gms" />
|
||||
<package android:name="com.google.android.gsf" />
|
||||
<package android:name="com.google.android.euicc" />
|
||||
<package android:name="com.google.euiccpixel" />
|
||||
</queries>
|
||||
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="30"
|
||||
android:targetSdkVersion="30"/>
|
||||
|
||||
<application
|
||||
android:label="@string/device_settings_app_name"
|
||||
android:persistent="true">
|
||||
|
||||
<receiver android:name=".BootCompletedReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
</manifest>
|
3
parts/proguard.flags
Normal file
3
parts/proguard.flags
Normal file
|
@ -0,0 +1,3 @@
|
|||
-keep class org.lineageos.settings.* {
|
||||
*;
|
||||
}
|
32
parts/src/org/lineageos/settings/BootCompletedReceiver.java
Normal file
32
parts/src/org/lineageos/settings/BootCompletedReceiver.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (C) 2021 The LineageOS 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 org.lineageos.settings;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
public class BootCompletedReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "GoogleParts";
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, Intent intent) {
|
||||
Log.d(TAG, "Received boot completed intent");
|
||||
EuiccDisabler.enableOrDisableEuicc(context);
|
||||
}
|
||||
}
|
71
parts/src/org/lineageos/settings/EuiccDisabler.java
Normal file
71
parts/src/org/lineageos/settings/EuiccDisabler.java
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (C) 2021 The LineageOS 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 org.lineageos.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.util.Log;
|
||||
|
||||
class EuiccDisabler {
|
||||
private static final String TAG = "GoogleParts";
|
||||
private static final String[] EUICC_DEPENDENCIES = new String[]{
|
||||
"com.google.android.gms",
|
||||
"com.google.android.gsf"
|
||||
};
|
||||
private static final String[] EUICC_PACKAGES = new String[]{
|
||||
"com.google.android.euicc",
|
||||
"com.google.euiccpixel"
|
||||
};
|
||||
|
||||
private static boolean isInstalledAndEnabled(PackageManager pm, String pkgName) {
|
||||
try {
|
||||
PackageInfo info = pm.getPackageInfo(pkgName, 0);
|
||||
Log.d(TAG, "package " + pkgName + " installed, " +
|
||||
"enabled = " + info.applicationInfo.enabled);
|
||||
return info.applicationInfo.enabled;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.d(TAG, "package " + pkgName + " is not installed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean shouldDisable(PackageManager pm) {
|
||||
for (String dep : EUICC_DEPENDENCIES) {
|
||||
if (!isInstalledAndEnabled(pm, dep)) {
|
||||
// Disable if any of the dependencies are disabled
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void enableOrDisableEuicc(Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
boolean disable = shouldDisable(pm);
|
||||
int flag = disable
|
||||
? PackageManager.COMPONENT_ENABLED_STATE_DISABLED
|
||||
: PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
|
||||
for (String pkg : EUICC_PACKAGES) {
|
||||
try {
|
||||
pm.setApplicationEnabledSetting(pkg, flag, 0);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.d(TAG, "package " + pkg + " is not present");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue