Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
integrate Google's eUICC LPA app
Browse files Browse the repository at this point in the history
Depends on GmsCompat.
  • Loading branch information
muhomorr authored and thestinger committed Mar 28, 2023
1 parent d53b301 commit 8cb96de
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 126 deletions.
8 changes: 0 additions & 8 deletions core/java/com/android/internal/gmscompat/GmsInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,5 @@ public final class GmsInfo {
"308204433082032ba003020102020900c2e08746644a308d300d06092a864886f70d01010405003074310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f69643110300e06035504031307416e64726f6964301e170d3038303832313233313333345a170d3336303130373233313333345a3074310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f69643110300e06035504031307416e64726f696430820120300d06092a864886f70d01010105000382010d00308201080282010100ab562e00d83ba208ae0a966f124e29da11f2ab56d08f58e2cca91303e9b754d372f640a71b1dcb130967624e4656a7776a92193db2e5bfb724a91e77188b0e6a47a43b33d9609b77183145ccdf7b2e586674c9e1565b1f4c6a5955bff251a63dabf9c55c27222252e875e4f8154a645f897168c0b1bfc612eabf785769bb34aa7984dc7e2ea2764cae8307d8c17154d7ee5f64a51a44a602c249054157dc02cd5f5c0e55fbef8519fbe327f0b1511692c5a06f19d18385f5c4dbc2d6b93f68cc2979c70e18ab93866b3bd5db8999552a0e3b4c99df58fb918bedc182ba35e003c1b4b10dd244a8ee24fffd333872ab5221985edab0fc0d0b145b6aa192858e79020103a381d93081d6301d0603551d0e04160414c77d8cc2211756259a7fd382df6be398e4d786a53081a60603551d2304819e30819b8014c77d8cc2211756259a7fd382df6be398e4d786a5a178a4763074310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f69643110300e06035504031307416e64726f6964820900c2e08746644a308d300c0603551d13040530030101ff300d06092a864886f70d010104050003820101006dd252ceef85302c360aaace939bcff2cca904bb5d7a1661f8ae46b2994204d0ff4a68c7ed1a531ec4595a623ce60763b167297a7ae35712c407f208f0cb109429124d7b106219c084ca3eb3f9ad5fb871ef92269a8be28bf16d44c8d9a08e6cb2f005bb3fe2cb96447e868e731076ad45b33f6009ea19c161e62641aa99271dfd5228c5c587875ddb7f452758d661f6cc0cccb7352e424cc4365c523532f7325137593c4ae341f4db41edda0d0b1071a7c440f0fe9ea01cb627ca674369d084bd2fd911ff06cdbf2cfa10dc0f893ae35762919048c7efc64c7144178342f70581c9de573af55b390dd7fdb9418631895d5f759f30112687ff621410c069308a"
};

// these packages are included in the system image, certificate checks aren't needed
public static final String[] EUICC_PACKAGES = {
"com.google.euiccpixel",
"com.google.android.euicc",
};

public static final String[] DEPENDENCIES_OF_EUICC_PACKAGES = { PACKAGE_GSF, PACKAGE_GMS_CORE, PACKAGE_PLAY_STORE };

private GmsInfo() { }
}
26 changes: 26 additions & 0 deletions core/java/com/android/internal/util/GoogleEuicc.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
package com.android.internal.util;

import android.app.compat.gms.GmsCompat;
import android.os.UserHandle;

import com.android.internal.gmscompat.GmsInfo;

public class GoogleEuicc {
// handles firmware updates of embedded secure element that is used for eSIM, NFC, Felica etc
public static final String EUICC_SUPPORT_PIXEL_PKG_NAME = "com.google.euiccpixel";
public static final String LPA_PKG_NAME = "com.google.android.euicc";

public static String[] getLpaDependencies() {
return new String[] {
GmsInfo.PACKAGE_GSF, GmsInfo.PACKAGE_GMS_CORE, GmsInfo.PACKAGE_PLAY_STORE,
};
}

public static boolean checkLpaDependencies() {
for (String pkg : getLpaDependencies()) {
try {
if (!GmsCompat.isGmsApp(pkg, UserHandle.USER_SYSTEM)) {
return false;
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.android.server.ext;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.PatternMatcher;
import android.util.Slog;

import com.android.internal.util.GoogleEuicc;

/**
* Automatically disables Google's eUICC (eSIM) LPA package when its dependencies get uninstalled or
* disabled.
*/
public class GoogleEuiccLpaDisabler extends BroadcastReceiver {
private static final String TAG = GoogleEuiccLpaDisabler.class.getSimpleName();

GoogleEuiccLpaDisabler(SystemServerExt sse) {
var f = new IntentFilter();
f.addAction(Intent.ACTION_PACKAGE_CHANGED);
f.addAction(Intent.ACTION_PACKAGE_REMOVED);
f.addAction(Intent.ACTION_PACKAGE_FULLY_REMOVED);

f.addDataScheme("package");
for (String pkg : GoogleEuicc.getLpaDependencies()) {
f.addDataSchemeSpecificPart(pkg, PatternMatcher.PATTERN_LITERAL);
}

sse.registerReceiver(this, f, sse.bgHandler);
}

@Override
public void onReceive(Context context, Intent intent) {
// LPA is only enabled in the Owner user, which matches the userId of this Context
PackageManager pm = context.getPackageManager();
try {
if (!GoogleEuicc.checkLpaDependencies()) {
pm.setApplicationEnabledSetting(GoogleEuicc.LPA_PKG_NAME,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
}
} catch (Exception e) {
// don't crash the system_server
Slog.e(TAG, "", e);
}
}
}
116 changes: 0 additions & 116 deletions services/core/java/com/android/server/ext/GoogleEuiccPkgsDisabler.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public static Integer maybeOverridePackageEnabledSetting(String pkgName, @UserId
// one of the previous OS versions enabled EuiccSupportPixel in all users
return PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
}
case GoogleEuicc.LPA_PKG_NAME:
// Google's LPA should be always disabled after reboot
return PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
default:
return null;
}
Expand All @@ -40,6 +43,12 @@ public static void amendParsedPackage(ParsingPackage pkg) {
// EuiccSupportPixel uses INTERNET perm only as part of its dev mode
removeUsesPermissions(pkg, Manifest.permission.INTERNET);
return;
case GoogleEuicc.LPA_PKG_NAME:
// this is the same as android:enabled="false" in <application> AndroidManifest tag,
// it makes the package disabled by default on first boot, when there's no
// serialized package state
pkg.setEnabled(false);
return;
default:
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public static void init(Context systemContext, PackageManagerService pm) {
sse.bgHandler.post(sse::initBgThread);
instance = sse;

// init synchronously to make sure they are disabled before any of the apps are started
new GoogleEuiccPkgsDisabler(sse);
new GoogleEuiccLpaDisabler(sse);
}

void initBgThread() {
Expand Down

0 comments on commit 8cb96de

Please sign in to comment.