Merge "[Settings] Avoid from accessing createManageSubscriptionIntent(int)"
This commit is contained in:
@@ -19,8 +19,11 @@ package com.android.settings.datausage;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.net.INetworkPolicyManager;
|
||||||
import android.net.NetworkPolicyManager;
|
import android.net.NetworkPolicyManager;
|
||||||
import android.net.NetworkTemplate;
|
import android.net.NetworkTemplate;
|
||||||
|
import android.os.ServiceManager;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.SubscriptionPlan;
|
import android.telephony.SubscriptionPlan;
|
||||||
@@ -296,12 +299,51 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
|
|||||||
mSnapshotTime = primaryPlan.getDataUsageTime();
|
mSnapshotTime = primaryPlan.getDataUsageTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mManageSubscriptionIntent =
|
mManageSubscriptionIntent = createManageSubscriptionIntent(mSubscriptionId);
|
||||||
mSubscriptionManager.createManageSubscriptionIntent(mSubscriptionId);
|
|
||||||
Log.i(TAG, "Have " + mDataplanCount + " plans, dflt sub-id " + mSubscriptionId
|
Log.i(TAG, "Have " + mDataplanCount + " plans, dflt sub-id " + mSubscriptionId
|
||||||
+ ", intent " + mManageSubscriptionIntent);
|
+ ", intent " + mManageSubscriptionIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an {@link Intent} that can be launched towards the carrier app
|
||||||
|
* that is currently defining the billing relationship plan through
|
||||||
|
* {@link INetworkPolicyManager#setSubscriptionPlans(int, SubscriptionPlan [], String)}.
|
||||||
|
*
|
||||||
|
* @return ready to launch Intent targeted towards the carrier app, or
|
||||||
|
* {@code null} if no carrier app is defined, or if the defined
|
||||||
|
* carrier app provides no management activity.
|
||||||
|
*/
|
||||||
|
private Intent createManageSubscriptionIntent(int subId) {
|
||||||
|
final INetworkPolicyManager iNetPolicyManager = INetworkPolicyManager.Stub.asInterface(
|
||||||
|
ServiceManager.getService(Context.NETWORK_POLICY_SERVICE));
|
||||||
|
String owner = "";
|
||||||
|
try {
|
||||||
|
owner = iNetPolicyManager.getSubscriptionPlansOwner(subId);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Log.w(TAG, "Fail to get subscription plan owner for subId " + subId, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(owner)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<SubscriptionPlan> plans = mSubscriptionManager.getSubscriptionPlans(subId);
|
||||||
|
if (plans.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Intent intent = new Intent(SubscriptionManager.ACTION_MANAGE_SUBSCRIPTION_PLANS);
|
||||||
|
intent.setPackage(owner);
|
||||||
|
intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
|
||||||
|
|
||||||
|
if (mActivity.getPackageManager().queryIntentActivities(intent,
|
||||||
|
PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
|
|
||||||
public static SubscriptionPlan getPrimaryPlan(SubscriptionManager subManager, int primaryId) {
|
public static SubscriptionPlan getPrimaryPlan(SubscriptionManager subManager, int primaryId) {
|
||||||
List<SubscriptionPlan> plans = subManager.getSubscriptionPlans(primaryId);
|
List<SubscriptionPlan> plans = subManager.getSubscriptionPlans(primaryId);
|
||||||
if (CollectionUtils.isEmpty(plans)) {
|
if (CollectionUtils.isEmpty(plans)) {
|
||||||
|
Reference in New Issue
Block a user