Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Merge "Only allow clearing of Euicc Data by owner or demo user" into …
Browse files Browse the repository at this point in the history
…main
  • Loading branch information
Treehugger Robot authored and Gerrit Code Review committed Oct 20, 2023
2 parents fcaf0ac + 922fc60 commit f1cbe74
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/com/android/settings/network/EraseEuiccDataController.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@

import android.content.Context;
import android.content.pm.PackageManager;
import android.os.UserManager;
import android.text.TextUtils;

import androidx.preference.Preference;

import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.network.telephony.MobileNetworkUtils;
Expand All @@ -33,8 +35,11 @@
public class EraseEuiccDataController extends BasePreferenceController {
private ResetDashboardFragment mHostFragment;

private final UserManager mUm;

public EraseEuiccDataController(Context context, String preferenceKey) {
super(context, preferenceKey);
mUm = context.getSystemService(UserManager.class);
}

public void setFragment(ResetDashboardFragment hostFragment) {
Expand All @@ -52,10 +57,12 @@ public boolean handlePreferenceTreeClick(Preference preference) {

@Override
public int getAvailabilityStatus() {
return SubscriptionUtil.isSimHardwareVisible(mContext) &&
(!MobileNetworkUtils.isMobileNetworkUserRestricted(mContext)) &&
mContext.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_TELEPHONY_EUICC) ? AVAILABLE_UNSEARCHABLE
: UNSUPPORTED_ON_DEVICE;
boolean isAllowedUser = (mUm.isAdminUser() || Utils.isDemoUser(mContext))
&& !MobileNetworkUtils.isMobileNetworkUserRestricted(mContext);
boolean hasEuiccFeature = mContext.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_TELEPHONY_EUICC);
return SubscriptionUtil.isSimHardwareVisible(mContext)
&& isAllowedUser
&& hasEuiccFeature ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
}
}

0 comments on commit f1cbe74

Please sign in to comment.