Loading AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -183,6 +183,10 @@ <action android:name="android.provider.Telephony.ACTION_CHANGE_DEFAULT" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter android:priority="1001"> <action android:name="android.telecom.action.CHANGE_DEFAULT_DIALER" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name="com.android.packageinstaller.role.ui.DefaultAppListActivity" Loading src/com/android/packageinstaller/role/ui/RequestRoleActivity.java +50 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.content.pm.ApplicationInfo; import android.os.Bundle; import android.os.Process; import android.provider.Telephony; import android.telecom.TelecomManager; import android.text.TextUtils; import android.util.Log; import android.view.WindowManager; Loading Loading @@ -61,6 +62,13 @@ public class RequestRoleActivity extends FragmentActivity { mRoleName = getIntent().getStringExtra(Intent.EXTRA_ROLE_NAME); mPackageName = getCallingPackage(); if (!handleChangeDefaultDialerDialogCompatibility()) { reportRequestResult( PermissionControllerStatsLog.ROLE_REQUEST_RESULT_REPORTED__RESULT__IGNORED); finish(); return; } if (!handleSmsDefaultDialogCompatibility()) { reportRequestResult( PermissionControllerStatsLog.ROLE_REQUEST_RESULT_REPORTED__RESULT__IGNORED); Loading Loading @@ -172,6 +180,48 @@ public class RequestRoleActivity extends FragmentActivity { } } /** * Handle compatibility with the old * {@link com.android.server.telecom.components.ChangeDefaultDialerDialog}. * * @return whether we should continue requesting the role. The activity should be finished if * {@code false} is returned. */ private boolean handleChangeDefaultDialerDialogCompatibility() { Intent intent = getIntent(); if (!Objects.equals(intent.getAction(), TelecomManager.ACTION_CHANGE_DEFAULT_DIALER)) { return true; } Log.w(LOG_TAG, "TelecomManager.ACTION_CHANGE_DEFAULT_DIALER is deprecated; please use" + " RoleManager.createRequestRoleIntent() and Activity.startActivityForResult()" + " instead"); mRoleName = RoleManager.ROLE_DIALER; mPackageName = null; String callingPackageName = getCallingPackage(); String extraPackageName = intent.getStringExtra( TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME); if (Objects.equals(extraPackageName, callingPackageName)) { // Requesting for itself is okay. mPackageName = extraPackageName; return true; } RoleManager roleManager = getSystemService(RoleManager.class); String holderPackageName = CollectionUtils.firstOrNull(roleManager.getRoleHolders( RoleManager.ROLE_DIALER)); if (Objects.equals(callingPackageName, holderPackageName)) { // Giving away its own role is okay. mPackageName = extraPackageName; return true; } // If we reach here it's not okay. return false; } /** * Handle compatibility with the old {@link com.android.settings.SmsDefaultDialog}. * Loading Loading
AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -183,6 +183,10 @@ <action android:name="android.provider.Telephony.ACTION_CHANGE_DEFAULT" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter android:priority="1001"> <action android:name="android.telecom.action.CHANGE_DEFAULT_DIALER" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name="com.android.packageinstaller.role.ui.DefaultAppListActivity" Loading
src/com/android/packageinstaller/role/ui/RequestRoleActivity.java +50 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.content.pm.ApplicationInfo; import android.os.Bundle; import android.os.Process; import android.provider.Telephony; import android.telecom.TelecomManager; import android.text.TextUtils; import android.util.Log; import android.view.WindowManager; Loading Loading @@ -61,6 +62,13 @@ public class RequestRoleActivity extends FragmentActivity { mRoleName = getIntent().getStringExtra(Intent.EXTRA_ROLE_NAME); mPackageName = getCallingPackage(); if (!handleChangeDefaultDialerDialogCompatibility()) { reportRequestResult( PermissionControllerStatsLog.ROLE_REQUEST_RESULT_REPORTED__RESULT__IGNORED); finish(); return; } if (!handleSmsDefaultDialogCompatibility()) { reportRequestResult( PermissionControllerStatsLog.ROLE_REQUEST_RESULT_REPORTED__RESULT__IGNORED); Loading Loading @@ -172,6 +180,48 @@ public class RequestRoleActivity extends FragmentActivity { } } /** * Handle compatibility with the old * {@link com.android.server.telecom.components.ChangeDefaultDialerDialog}. * * @return whether we should continue requesting the role. The activity should be finished if * {@code false} is returned. */ private boolean handleChangeDefaultDialerDialogCompatibility() { Intent intent = getIntent(); if (!Objects.equals(intent.getAction(), TelecomManager.ACTION_CHANGE_DEFAULT_DIALER)) { return true; } Log.w(LOG_TAG, "TelecomManager.ACTION_CHANGE_DEFAULT_DIALER is deprecated; please use" + " RoleManager.createRequestRoleIntent() and Activity.startActivityForResult()" + " instead"); mRoleName = RoleManager.ROLE_DIALER; mPackageName = null; String callingPackageName = getCallingPackage(); String extraPackageName = intent.getStringExtra( TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME); if (Objects.equals(extraPackageName, callingPackageName)) { // Requesting for itself is okay. mPackageName = extraPackageName; return true; } RoleManager roleManager = getSystemService(RoleManager.class); String holderPackageName = CollectionUtils.firstOrNull(roleManager.getRoleHolders( RoleManager.ROLE_DIALER)); if (Objects.equals(callingPackageName, holderPackageName)) { // Giving away its own role is okay. mPackageName = extraPackageName; return true; } // If we reach here it's not okay. return false; } /** * Handle compatibility with the old {@link com.android.settings.SmsDefaultDialog}. * Loading