1 package com.android.hotspot2; 2 3 import android.content.Context; 4 import android.content.Intent; 5 import android.os.UserHandle; 6 7 import com.android.hotspot2.osu.OSUInfo; 8 import com.android.hotspot2.osu.OSUOperationStatus; 9 10 import java.util.List; 11 12 public class AppBridge { 13 public static final String ACTION_OSU_NOTIFICATION = "com.android.hotspot2.OSU_NOTIFICATION"; 14 public static final String OSU_COUNT = "osu-count"; 15 public static final String SP_NAME = "sp-name"; 16 public static final String PROV_SUCCESS = "prov-success"; 17 public static final String DEAUTH = "deauth"; 18 public static final String DEAUTH_DELAY = "deauth-delay"; 19 public static final String DEAUTH_URL = "deauth-url"; 20 public static final String PROV_MESSAGE = "prov-message"; 21 public static final String OSU_INFO = "osu-info"; 22 23 public static final String GET_OSUS_ACTION = "com.android.hotspot2.GET_OSUS"; 24 25 private final Context mContext; 26 27 public AppBridge(Context context) { 28 mContext = context; 29 } 30 31 public void showOsuCount(int osuCount, List<OSUInfo> osus) { 32 Intent intent = new Intent(ACTION_OSU_NOTIFICATION); 33 intent.putExtra(OSU_COUNT, osuCount); 34 intent.setFlags( 35 Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); 36 37 mContext.startActivity(intent); 38 } 39 40 public void showStatus(OSUOperationStatus status, String spName, String message, 41 String remoteStatus) { 42 Intent intent = new Intent(ACTION_OSU_NOTIFICATION); 43 intent.putExtra(SP_NAME, spName); 44 intent.putExtra(PROV_SUCCESS, status == OSUOperationStatus.ProvisioningSuccess); 45 if (message != null) { 46 intent.putExtra(PROV_MESSAGE, message); 47 } 48 intent.setFlags( 49 Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); 50 mContext.startActivity(intent); 51 } 52 53 public void showDeauth(String spName, boolean ess, int delay, String url) { 54 Intent intent = new Intent(ACTION_OSU_NOTIFICATION); 55 intent.putExtra(SP_NAME, spName); 56 intent.putExtra(DEAUTH, ess); 57 intent.putExtra(DEAUTH_DELAY, delay); 58 intent.putExtra(DEAUTH_URL, url); 59 intent.setFlags( 60 Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); 61 mContext.startActivity(intent); 62 } 63 } 64