Fix CarrierSettings preference
This used the CarrierConfigManager to get the CarrierSettings activity component and open that activity when the preference is clicked. Bug: 117651939 Test: make -j40 ROBOTEST_FILTER=telephony RunSettingsRoboTests Change-Id: Ic5267bba18ab32fbcc2e04aa61e7361151130275
This commit is contained in:
@@ -17,6 +17,10 @@
|
||||
package com.android.settings.network.telephony;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.PersistableBundle;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.SubscriptionManager;
|
||||
@@ -62,10 +66,31 @@ public class CarrierPreferenceController extends BasePreferenceController {
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (getPreferenceKey().equals(preference.getKey())) {
|
||||
//TODO(b/117651939): start carrier settings activity
|
||||
final Intent carrierSettingsIntent = getCarrierSettingsActivityIntent(mSubId);
|
||||
if (carrierSettingsIntent != null) {
|
||||
mContext.startActivity(carrierSettingsIntent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Intent getCarrierSettingsActivityIntent(int subId) {
|
||||
final PersistableBundle config = mCarrierConfigManager.getConfigForSubId(subId);
|
||||
final ComponentName cn = ComponentName.unflattenFromString(
|
||||
config == null ? "" : config.getString(
|
||||
CarrierConfigManager.KEY_CARRIER_SETTINGS_ACTIVITY_COMPONENT_NAME_STRING,
|
||||
"" /* default value */));
|
||||
|
||||
if (cn == null) return null;
|
||||
|
||||
final Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.setComponent(cn);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
final PackageManager pm = mContext.getPackageManager();
|
||||
final ResolveInfo resolveInfo = pm.resolveActivity(intent, 0 /* flags */);
|
||||
return resolveInfo != null ? intent : null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user