Loading AndroidManifest.xml +0 −2 Original line number Diff line number Diff line Loading @@ -102,8 +102,6 @@ <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" /> <protected-broadcast android:name="com.android.settings.DELETE_SIM_PROFILE_RESULT"/> <application android:label="@string/settings_label" android:icon="@drawable/ic_launcher_settings" android:theme="@style/Theme.Settings" Loading src/com/android/settings/network/telephony/DeleteSimProfileConfirmationDialog.javadeleted 100644 → 0 +0 −83 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source 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.settings.network.telephony; import android.app.Dialog; import android.app.settings.SettingsEnums; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.telephony.SubscriptionInfo; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.appcompat.app.AlertDialog; import com.android.settings.R; import com.android.settings.core.instrumentation.InstrumentedDialogFragment; public class DeleteSimProfileConfirmationDialog extends InstrumentedDialogFragment implements DialogInterface.OnClickListener { public static final String TAG = "confirm_delete_sim"; public static final String KEY_SUBSCRIPTION_INFO = "subscription_info"; private SubscriptionInfo mInfo; public static DeleteSimProfileConfirmationDialog newInstance(SubscriptionInfo info) { final DeleteSimProfileConfirmationDialog dialog = new DeleteSimProfileConfirmationDialog(); final Bundle args = new Bundle(); args.putParcelable(KEY_SUBSCRIPTION_INFO, info); dialog.setArguments(args); return dialog; } @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { mInfo = getArguments().getParcelable(KEY_SUBSCRIPTION_INFO); Context context = getContext(); final String message = context.getString(R.string.mobile_network_erase_sim_dialog_body, mInfo.getCarrierName(), mInfo.getCarrierName()); return new AlertDialog.Builder(context) .setTitle(R.string.mobile_network_erase_sim_dialog_title) .setMessage(message) .setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.mobile_network_erase_sim_dialog_ok, this) .create(); } @Override public void onClick(DialogInterface dialog, int which) { if (which == DialogInterface.BUTTON_POSITIVE) { beginDeletionWithProgress(); } } @VisibleForTesting void beginDeletionWithProgress() { final DeleteSimProfileProgressDialog progress = DeleteSimProfileProgressDialog.newInstance(mInfo.getSubscriptionId()); progress.setTargetFragment(getTargetFragment(), 0); progress.show(getFragmentManager(), DeleteSimProfileProgressDialog.TAG); } @Override public int getMetricsCategory() { return SettingsEnums.DIALOG_DELETE_SIM_CONFIRMATION; } } src/com/android/settings/network/telephony/DeleteSimProfilePreferenceController.java +9 −6 Original line number Diff line number Diff line Loading @@ -17,7 +17,9 @@ package com.android.settings.network.telephony; import android.content.Context; import android.content.Intent; import android.telephony.SubscriptionInfo; import android.telephony.euicc.EuiccManager; import androidx.fragment.app.Fragment; import androidx.preference.Preference; Loading @@ -31,12 +33,13 @@ public class DeleteSimProfilePreferenceController extends BasePreferenceControll private SubscriptionInfo mSubscriptionInfo; private Fragment mParentFragment; private int mRequestCode; public DeleteSimProfilePreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); } public void init(int subscriptionId, Fragment parentFragment) { public void init(int subscriptionId, Fragment parentFragment, int requestCode) { mParentFragment = parentFragment; for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions( Loading @@ -46,6 +49,7 @@ public class DeleteSimProfilePreferenceController extends BasePreferenceControll break; } } mRequestCode = requestCode; } @Override Loading @@ -53,11 +57,10 @@ public class DeleteSimProfilePreferenceController extends BasePreferenceControll super.displayPreference(screen); final Preference pref = screen.findPreference(getPreferenceKey()); pref.setOnPreferenceClickListener(p -> { final DeleteSimProfileConfirmationDialog dialogFragment = DeleteSimProfileConfirmationDialog.newInstance(mSubscriptionInfo); dialogFragment.setTargetFragment(mParentFragment, 0); dialogFragment.show(mParentFragment.getFragmentManager(), DeleteSimProfileConfirmationDialog.TAG); final Intent intent = new Intent(EuiccManager.ACTION_DELETE_SUBSCRIPTION_PRIVILEGED); intent.putExtra(EuiccManager.EXTRA_SUBSCRIPTION_ID, mSubscriptionInfo.getSubscriptionId()); mParentFragment.startActivityForResult(intent, mRequestCode); return true; }); } Loading src/com/android/settings/network/telephony/DeleteSimProfileProgressDialog.javadeleted 100644 → 0 +0 −120 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source 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.settings.network.telephony; import android.app.Activity; import android.app.Dialog; import android.app.PendingIntent; import android.app.ProgressDialog; import android.app.settings.SettingsEnums; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.telephony.euicc.EuiccManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.android.settings.R; import com.android.settings.core.instrumentation.InstrumentedDialogFragment; public class DeleteSimProfileProgressDialog extends InstrumentedDialogFragment { public static final String TAG = "delete_sim_progress"; // Note that this must be listed in AndroidManfiest.xml in a <protected-broadcast> tag @VisibleForTesting static final String PENDING_INTENT = "com.android.settings.DELETE_SIM_PROFILE_RESULT"; private static final int PENDING_INTENT_REQUEST_CODE = 1; private static final String KEY_SUBSCRIPTION_ID = "subscription_id"; @VisibleForTesting static final String KEY_DELETE_STARTED = "delete_started"; private boolean mDeleteStarted; private BroadcastReceiver mReceiver; public static DeleteSimProfileProgressDialog newInstance(int subscriptionId) { final DeleteSimProfileProgressDialog dialog = new DeleteSimProfileProgressDialog(); final Bundle args = new Bundle(); args.putInt(KEY_SUBSCRIPTION_ID, subscriptionId); dialog.setArguments(args); return dialog; } @Override public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putBoolean(KEY_DELETE_STARTED, mDeleteStarted); } @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { if (savedInstanceState != null) { mDeleteStarted = savedInstanceState.getBoolean(KEY_DELETE_STARTED, false); } final Context context = getContext(); final ProgressDialog progressDialog = new ProgressDialog(context); progressDialog.setMessage( context.getString(R.string.mobile_network_erase_sim_dialog_progress)); mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { dismiss(); final Activity activity = getActivity(); if (activity != null && !activity.isFinishing()) { activity.finish(); } } }; context.registerReceiver(mReceiver, new IntentFilter(PENDING_INTENT)); if (!mDeleteStarted) { final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, PENDING_INTENT_REQUEST_CODE, new Intent(PENDING_INTENT), PendingIntent.FLAG_ONE_SHOT); final EuiccManager euiccManager = context.getSystemService(EuiccManager.class); final int subId = getArguments().getInt(KEY_SUBSCRIPTION_ID); euiccManager.deleteSubscription(subId, pendingIntent); mDeleteStarted = true; } return progressDialog; } @Override public void onDismiss(@NonNull DialogInterface dialog) { if (mReceiver != null) { final Context context = getContext(); if (context != null) { context.unregisterReceiver(mReceiver); } mReceiver = null; } } @Override public int getMetricsCategory() { return SettingsEnums.DIALOG_DELETE_SIM_PROGRESS; } } src/com/android/settings/network/telephony/MobileNetworkSettings.java +10 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment { private static final String LOG_TAG = "NetworkSettings"; public static final int REQUEST_CODE_EXIT_ECM = 17; public static final int REQUEST_CODE_DELETE_SUBSCRIPTION = 18; @VisibleForTesting static final String KEY_CLICKED_PREF = "key_clicked_pref"; Loading Loading @@ -138,7 +139,8 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment { use(BillingCyclePreferenceController.class).init(mSubId); use(MmsMessagePreferenceController.class).init(mSubId); use(DisabledSubscriptionController.class).init(getLifecycle(), mSubId); use(DeleteSimProfilePreferenceController.class).init(mSubId, this); use(DeleteSimProfilePreferenceController.class).init(mSubId, this, REQUEST_CODE_DELETE_SUBSCRIPTION); } use(MobileDataPreferenceController.class).init(getFragmentManager(), mSubId); use(RoamingPreferenceController.class).init(getFragmentManager(), mSubId); Loading Loading @@ -226,6 +228,13 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment { } break; case REQUEST_CODE_DELETE_SUBSCRIPTION: final Activity activity = getActivity(); if (activity != null && !activity.isFinishing()) { activity.finish(); } break; default: break; } Loading Loading
AndroidManifest.xml +0 −2 Original line number Diff line number Diff line Loading @@ -102,8 +102,6 @@ <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" /> <protected-broadcast android:name="com.android.settings.DELETE_SIM_PROFILE_RESULT"/> <application android:label="@string/settings_label" android:icon="@drawable/ic_launcher_settings" android:theme="@style/Theme.Settings" Loading
src/com/android/settings/network/telephony/DeleteSimProfileConfirmationDialog.javadeleted 100644 → 0 +0 −83 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source 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.settings.network.telephony; import android.app.Dialog; import android.app.settings.SettingsEnums; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.telephony.SubscriptionInfo; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.appcompat.app.AlertDialog; import com.android.settings.R; import com.android.settings.core.instrumentation.InstrumentedDialogFragment; public class DeleteSimProfileConfirmationDialog extends InstrumentedDialogFragment implements DialogInterface.OnClickListener { public static final String TAG = "confirm_delete_sim"; public static final String KEY_SUBSCRIPTION_INFO = "subscription_info"; private SubscriptionInfo mInfo; public static DeleteSimProfileConfirmationDialog newInstance(SubscriptionInfo info) { final DeleteSimProfileConfirmationDialog dialog = new DeleteSimProfileConfirmationDialog(); final Bundle args = new Bundle(); args.putParcelable(KEY_SUBSCRIPTION_INFO, info); dialog.setArguments(args); return dialog; } @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { mInfo = getArguments().getParcelable(KEY_SUBSCRIPTION_INFO); Context context = getContext(); final String message = context.getString(R.string.mobile_network_erase_sim_dialog_body, mInfo.getCarrierName(), mInfo.getCarrierName()); return new AlertDialog.Builder(context) .setTitle(R.string.mobile_network_erase_sim_dialog_title) .setMessage(message) .setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.mobile_network_erase_sim_dialog_ok, this) .create(); } @Override public void onClick(DialogInterface dialog, int which) { if (which == DialogInterface.BUTTON_POSITIVE) { beginDeletionWithProgress(); } } @VisibleForTesting void beginDeletionWithProgress() { final DeleteSimProfileProgressDialog progress = DeleteSimProfileProgressDialog.newInstance(mInfo.getSubscriptionId()); progress.setTargetFragment(getTargetFragment(), 0); progress.show(getFragmentManager(), DeleteSimProfileProgressDialog.TAG); } @Override public int getMetricsCategory() { return SettingsEnums.DIALOG_DELETE_SIM_CONFIRMATION; } }
src/com/android/settings/network/telephony/DeleteSimProfilePreferenceController.java +9 −6 Original line number Diff line number Diff line Loading @@ -17,7 +17,9 @@ package com.android.settings.network.telephony; import android.content.Context; import android.content.Intent; import android.telephony.SubscriptionInfo; import android.telephony.euicc.EuiccManager; import androidx.fragment.app.Fragment; import androidx.preference.Preference; Loading @@ -31,12 +33,13 @@ public class DeleteSimProfilePreferenceController extends BasePreferenceControll private SubscriptionInfo mSubscriptionInfo; private Fragment mParentFragment; private int mRequestCode; public DeleteSimProfilePreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); } public void init(int subscriptionId, Fragment parentFragment) { public void init(int subscriptionId, Fragment parentFragment, int requestCode) { mParentFragment = parentFragment; for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions( Loading @@ -46,6 +49,7 @@ public class DeleteSimProfilePreferenceController extends BasePreferenceControll break; } } mRequestCode = requestCode; } @Override Loading @@ -53,11 +57,10 @@ public class DeleteSimProfilePreferenceController extends BasePreferenceControll super.displayPreference(screen); final Preference pref = screen.findPreference(getPreferenceKey()); pref.setOnPreferenceClickListener(p -> { final DeleteSimProfileConfirmationDialog dialogFragment = DeleteSimProfileConfirmationDialog.newInstance(mSubscriptionInfo); dialogFragment.setTargetFragment(mParentFragment, 0); dialogFragment.show(mParentFragment.getFragmentManager(), DeleteSimProfileConfirmationDialog.TAG); final Intent intent = new Intent(EuiccManager.ACTION_DELETE_SUBSCRIPTION_PRIVILEGED); intent.putExtra(EuiccManager.EXTRA_SUBSCRIPTION_ID, mSubscriptionInfo.getSubscriptionId()); mParentFragment.startActivityForResult(intent, mRequestCode); return true; }); } Loading
src/com/android/settings/network/telephony/DeleteSimProfileProgressDialog.javadeleted 100644 → 0 +0 −120 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source 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.settings.network.telephony; import android.app.Activity; import android.app.Dialog; import android.app.PendingIntent; import android.app.ProgressDialog; import android.app.settings.SettingsEnums; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.telephony.euicc.EuiccManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.android.settings.R; import com.android.settings.core.instrumentation.InstrumentedDialogFragment; public class DeleteSimProfileProgressDialog extends InstrumentedDialogFragment { public static final String TAG = "delete_sim_progress"; // Note that this must be listed in AndroidManfiest.xml in a <protected-broadcast> tag @VisibleForTesting static final String PENDING_INTENT = "com.android.settings.DELETE_SIM_PROFILE_RESULT"; private static final int PENDING_INTENT_REQUEST_CODE = 1; private static final String KEY_SUBSCRIPTION_ID = "subscription_id"; @VisibleForTesting static final String KEY_DELETE_STARTED = "delete_started"; private boolean mDeleteStarted; private BroadcastReceiver mReceiver; public static DeleteSimProfileProgressDialog newInstance(int subscriptionId) { final DeleteSimProfileProgressDialog dialog = new DeleteSimProfileProgressDialog(); final Bundle args = new Bundle(); args.putInt(KEY_SUBSCRIPTION_ID, subscriptionId); dialog.setArguments(args); return dialog; } @Override public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putBoolean(KEY_DELETE_STARTED, mDeleteStarted); } @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { if (savedInstanceState != null) { mDeleteStarted = savedInstanceState.getBoolean(KEY_DELETE_STARTED, false); } final Context context = getContext(); final ProgressDialog progressDialog = new ProgressDialog(context); progressDialog.setMessage( context.getString(R.string.mobile_network_erase_sim_dialog_progress)); mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { dismiss(); final Activity activity = getActivity(); if (activity != null && !activity.isFinishing()) { activity.finish(); } } }; context.registerReceiver(mReceiver, new IntentFilter(PENDING_INTENT)); if (!mDeleteStarted) { final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, PENDING_INTENT_REQUEST_CODE, new Intent(PENDING_INTENT), PendingIntent.FLAG_ONE_SHOT); final EuiccManager euiccManager = context.getSystemService(EuiccManager.class); final int subId = getArguments().getInt(KEY_SUBSCRIPTION_ID); euiccManager.deleteSubscription(subId, pendingIntent); mDeleteStarted = true; } return progressDialog; } @Override public void onDismiss(@NonNull DialogInterface dialog) { if (mReceiver != null) { final Context context = getContext(); if (context != null) { context.unregisterReceiver(mReceiver); } mReceiver = null; } } @Override public int getMetricsCategory() { return SettingsEnums.DIALOG_DELETE_SIM_PROGRESS; } }
src/com/android/settings/network/telephony/MobileNetworkSettings.java +10 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment { private static final String LOG_TAG = "NetworkSettings"; public static final int REQUEST_CODE_EXIT_ECM = 17; public static final int REQUEST_CODE_DELETE_SUBSCRIPTION = 18; @VisibleForTesting static final String KEY_CLICKED_PREF = "key_clicked_pref"; Loading Loading @@ -138,7 +139,8 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment { use(BillingCyclePreferenceController.class).init(mSubId); use(MmsMessagePreferenceController.class).init(mSubId); use(DisabledSubscriptionController.class).init(getLifecycle(), mSubId); use(DeleteSimProfilePreferenceController.class).init(mSubId, this); use(DeleteSimProfilePreferenceController.class).init(mSubId, this, REQUEST_CODE_DELETE_SUBSCRIPTION); } use(MobileDataPreferenceController.class).init(getFragmentManager(), mSubId); use(RoamingPreferenceController.class).init(getFragmentManager(), mSubId); Loading Loading @@ -226,6 +228,13 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment { } break; case REQUEST_CODE_DELETE_SUBSCRIPTION: final Activity activity = getActivity(); if (activity != null && !activity.isFinishing()) { activity.finish(); } break; default: break; } Loading