正在查看: Loan Locker v1.5 应用的 SetupManagementFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Loan Locker v1.5 应用的 SetupManagementFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.user.a4keygen;
import android.accounts.Account;
import android.app.Activity;
import android.app.Fragment;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.net.Uri;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.android.setupwizardlib.GlifLayout;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.user.a4keygen.common.ColorPicker;
import com.user.a4keygen.common.LaunchIntentUtil;
import com.user.a4keygen.common.ProvisioningStateUtil;
import com.user.a4keygen.common.Util;
import java.security.SecureRandom;
import java.util.Collections;
import java.util.Set;
import kotlin.time.DurationKt;
public class SetupManagementFragment extends Fragment implements View.OnClickListener, ColorPicker.OnColorSelectListener, RadioGroup.OnCheckedChangeListener {
public static final String FRAGMENT_TAG = "SetupManagementFragment";
private static final int NO_COLOR_SPECIFIED = -1;
private static final int REQUEST_GET_LOGO = 3;
private static final int REQUEST_PROVISION_DEVICE_OWNER = 2;
private static final int REQUEST_PROVISION_MANAGED_PROFILE = 1;
private ImageView mColorPreviewView;
private TextView mColorValue;
private CheckBox mKeepAccountMigrated;
private ImageView mLogoPreviewView;
private TextView mLogoValue;
private Button mNavigationNextButton;
private ImageButton mParamsIndicator;
private View mParamsView;
private TextView mSetupManagementMessage;
private RadioGroup mSetupOptions;
private CheckBox mSkipEncryption;
private CheckBox mSkipUserConsent;
private static final int[] STATE_EXPANDED = {R.attr.state_expanded};
private static final int[] STATE_COLLAPSED = {-2130969608};
private int mCurrentColor = -1;
private Uri mLogoUri = null;
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
if (bundle != null) {
this.mLogoUri = (Uri) bundle.getParcelable("android.app.extra.PROVISIONING_LOGO_URI");
this.mCurrentColor = bundle.getInt("android.app.extra.PROVISIONING_MAIN_COLOR");
}
View inflate = layoutInflater.inflate(R.layout.setup_management_fragment, viewGroup, false);
GlifLayout findViewById = inflate.findViewById(R.id.setup_wizard_layout);
Button button = (Button) findViewById.findViewById(R.id.suw_navbar_next);
this.mNavigationNextButton = button;
button.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SetupManagementFragment.this.onNavigateNext(view);
}
});
findViewById.findViewById(R.id.exit_button).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SetupManagementFragment.this.onNavigateBack(view);
}
});
this.mSetupManagementMessage = (TextView) inflate.findViewById(R.id.setup_management_message_id);
RadioGroup radioGroup = (RadioGroup) inflate.findViewById(R.id.setup_options);
this.mSetupOptions = radioGroup;
radioGroup.setOnCheckedChangeListener(this);
this.mSkipUserConsent = (CheckBox) inflate.findViewById(R.id.skip_user_consent);
this.mKeepAccountMigrated = (CheckBox) inflate.findViewById(R.id.keep_account_migrated);
this.mSkipEncryption = (CheckBox) inflate.findViewById(R.id.skip_encryption);
this.mParamsView = inflate.findViewById(R.id.params);
ImageButton imageButton = (ImageButton) inflate.findViewById(R.id.params_indicator);
this.mParamsIndicator = imageButton;
imageButton.setOnClickListener(this);
inflate.findViewById(R.id.color_select_button).setOnClickListener(this);
this.mColorValue = (TextView) inflate.findViewById(R.id.selected_color_value);
this.mColorPreviewView = (ImageView) inflate.findViewById(R.id.preview_color);
updateColorUi();
Intent intent = getActivity().getIntent();
if (LaunchIntentUtil.isSynchronousAuthLaunch(intent)) {
Account addedAccount = LaunchIntentUtil.getAddedAccount(intent);
if (addedAccount != null) {
inflate.findViewById(R.id.managed_account_desc).setVisibility(0);
TextView textView = (TextView) inflate.findViewById(R.id.managed_account_name);
textView.setVisibility(0);
textView.setText(addedAccount.name);
} else {
Toast.makeText(getActivity(), R.string.invalid_launch_intent_no_account, 1).show();
}
}
return inflate;
}
@Override
public void onSaveInstanceState(Bundle bundle) {
bundle.putParcelable("android.app.extra.PROVISIONING_LOGO_URI", this.mLogoUri);
bundle.putInt("android.app.extra.PROVISIONING_MAIN_COLOR", this.mCurrentColor);
super.onSaveInstanceState(bundle);
}
@Override
public void onResume() {
super.onResume();
if (setProvisioningMethodsVisibility()) {
if (Util.SDK_INT >= 24) {
getView().findViewById(R.id.params_title).setVisibility(0);
if (canAnAppHandleGetContent()) {
getView().findViewById(R.id.choose_logo_item_layout).setVisibility(0);
getView().findViewById(R.id.logo_select_button).setOnClickListener(this);
this.mLogoValue = (TextView) getView().findViewById(R.id.selected_logo_value);
this.mLogoPreviewView = (ImageView) getView().findViewById(R.id.preview_logo);
}
setProvisioningModeSpecificUI();
return;
}
return;
}
showNoProvisioningPossibleUI();
}
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
setProvisioningModeSpecificUI();
}
private void setProvisioningModeSpecificUI() {
int checkedRadioButtonId = this.mSetupOptions.getCheckedRadioButtonId();
int i = 0;
boolean z = checkedRadioButtonId == 2131362580;
boolean z2 = checkedRadioButtonId == 2131362579;
this.mSkipUserConsent.setVisibility((Util.SDK_INT >= 26 && z && Util.isDeviceOwner(getActivity())) ? 0 : 8);
this.mKeepAccountMigrated.setVisibility((Util.SDK_INT < 26 || !z) ? 8 : 0);
CheckBox checkBox = this.mSkipEncryption;
if ((!z || Util.SDK_INT < 24) && (!z2 || Util.SDK_INT < 23)) {
i = 8;
}
checkBox.setVisibility(i);
if (Util.isDeviceOwner(getActivity())) {
this.mSetupManagementMessage.setText(R.string.setup_management_message_for_do);
}
}
private void maybeLaunchProvisioning(String str, int i) {
Activity activity = getActivity();
Intent intent = new Intent(str);
if (Util.SDK_INT >= 23) {
intent.putExtra("android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME", DeviceAdminReceiver.getComponentName(getActivity()));
} else {
intent.putExtra("android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME", getActivity().getPackageName());
}
if (maybeSpecifyNExtras(intent)) {
PersistableBundle persistableBundle = new PersistableBundle();
maybeSpecifySyncAuthExtras(intent, persistableBundle);
maybePassAffiliationIds(intent, persistableBundle);
specifySkipUserConsent(intent);
specifyKeepAccountMigrated(intent);
specifySkipEncryption(intent);
specifyDefaultDisclaimers(intent);
if (persistableBundle.size() > 0) {
intent.putExtra("android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE", persistableBundle);
}
if (intent.resolveActivity(activity.getPackageManager()) != null) {
startActivityForResult(intent, i);
} else {
Toast.makeText(activity, R.string.provisioning_not_supported, 0).show();
}
}
}
private void maybeSpecifySyncAuthExtras(Intent intent, PersistableBundle persistableBundle) {
Activity activity = getActivity();
Intent intent2 = activity.getIntent();
if (LaunchIntentUtil.isSynchronousAuthLaunch(intent2)) {
Account addedAccount = LaunchIntentUtil.getAddedAccount(intent2);
if (addedAccount != null) {
if (Util.SDK_INT >= 22) {
intent.putExtra("android.app.extra.PROVISIONING_ACCOUNT_TO_MIGRATE", addedAccount);
} else {
Toast.makeText(activity, R.string.migration_not_supported, 0).show();
}
}
LaunchIntentUtil.prepareDeviceAdminExtras(intent2, persistableBundle);
}
}
private void maybePassAffiliationIds(Intent intent, PersistableBundle persistableBundle) {
if (Util.isDeviceOwner(getActivity()) && "android.app.action.PROVISION_MANAGED_PROFILE".equals(intent.getAction()) && Util.SDK_INT >= 26) {
passAffiliationIds(intent, persistableBundle);
}
}
private void passAffiliationIds(Intent intent, PersistableBundle persistableBundle) {
String next;
DevicePolicyManagerGatewayImpl devicePolicyManagerGatewayImpl = new DevicePolicyManagerGatewayImpl(getActivity());
Set<String> affiliationIds = devicePolicyManagerGatewayImpl.getAffiliationIds();
if (affiliationIds.size() == 0) {
next = Integer.toString(new SecureRandom().nextInt(DurationKt.NANOS_IN_MILLIS));
devicePolicyManagerGatewayImpl.setAffiliationIds(Collections.singleton(next));
} else {
next = affiliationIds.iterator().next();
}
persistableBundle.putString(LaunchIntentUtil.EXTRA_AFFILIATION_ID, next);
}
private boolean maybeSpecifyNExtras(Intent intent) {
if (Util.SDK_INT < 24) {
return true;
}
specifyLogoUri(intent);
specifyColor(intent);
return true;
}
private void specifyDefaultDisclaimers(Intent intent) {
if (Util.SDK_INT >= 26) {
Bundle bundle = new Bundle();
bundle.putString("android.app.extra.PROVISIONING_DISCLAIMER_HEADER", getString(R.string.default_disclaimer_emm_name));
bundle.putParcelable("android.app.extra.PROVISIONING_DISCLAIMER_CONTENT", resourceToUri(getActivity(), R.raw.emm_disclaimer));
Bundle bundle2 = new Bundle();
bundle2.putString("android.app.extra.PROVISIONING_DISCLAIMER_HEADER", getString(R.string.default_disclaimer_company_name));
bundle2.putParcelable("android.app.extra.PROVISIONING_DISCLAIMER_CONTENT", resourceToUri(getActivity(), R.raw.company_disclaimer));
intent.putExtra("android.app.extra.PROVISIONING_DISCLAIMERS", new Bundle[]{bundle, bundle2});
}
}
private static Uri resourceToUri(Context context, int i) {
return Uri.parse("android.resource://" + context.getResources().getResourcePackageName(i) + '/' + context.getResources().getResourceTypeName(i) + '/' + context.getResources().getResourceEntryName(i));
}
private void specifySkipUserConsent(Intent intent) {
if (Util.SDK_INT >= 26 && "android.app.action.PROVISION_MANAGED_PROFILE".equals(intent.getAction()) && this.mSkipUserConsent.getVisibility() == 0) {
intent.putExtra("android.app.extra.PROVISIONING_SKIP_USER_CONSENT", this.mSkipUserConsent.isChecked());
}
}
private void specifyKeepAccountMigrated(Intent intent) {
if (Util.SDK_INT >= 26 && "android.app.action.PROVISION_MANAGED_PROFILE".equals(intent.getAction()) && this.mKeepAccountMigrated.getVisibility() == 0) {
intent.putExtra("android.app.extra.PROVISIONING_KEEP_ACCOUNT_ON_MIGRATION", this.mKeepAccountMigrated.isChecked());
}
}
private void specifySkipEncryption(Intent intent) {
if (this.mSkipEncryption.getVisibility() == 0) {
intent.putExtra("android.app.extra.PROVISIONING_SKIP_ENCRYPTION", this.mSkipEncryption.isChecked());
}
}
private void specifyLogoUri(Intent intent) {
Uri uri = this.mLogoUri;
if (uri == null) {
return;
}
intent.putExtra("android.app.extra.PROVISIONING_LOGO_URI", uri);
if (this.mLogoUri.getScheme().equals(FirebaseAnalytics.Param.CONTENT)) {
intent.setFlags(1);
intent.setClipData(ClipData.newUri(getActivity().getContentResolver(), "", this.mLogoUri));
}
}
private void specifyColor(Intent intent) {
int i = this.mCurrentColor;
if (i == -1) {
return;
}
intent.putExtra("android.app.extra.PROVISIONING_MAIN_COLOR", i);
}
private void showNoProvisioningPossibleUI() {
this.mNavigationNextButton.setVisibility(8);
((TextView) getView().findViewById(R.id.setup_management_message_id)).setText(Util.isDeviceOwner(getActivity()) ? R.string.provisioning_not_possible_for_do : R.string.provisioning_not_possible);
}
private boolean setProvisioningMethodsVisibility() {
return setVisibility("android.app.action.PROVISION_MANAGED_PROFILE", R.id.setup_managed_profile) | false | setVisibility("android.app.action.PROVISION_MANAGED_DEVICE", R.id.setup_device_owner);
}
private boolean setVisibility(String str, int i) {
int i2 = ProvisioningStateUtil.isProvisioningAllowed(getActivity(), str) ? 0 : 8;
getView().findViewById(i).setVisibility(i2);
return i2 == 0;
}
@Override
public void onActivityResult(int i, int i2, Intent intent) {
Activity activity = getActivity();
if (i == 1 || i == 2) {
if (i2 == -1) {
activity.setResult(-1);
activity.finish();
return;
} else {
Toast.makeText(activity, R.string.provisioning_failed_or_cancelled, 0).show();
return;
}
}
if (i != 3 || intent == null || intent.getData() == null) {
return;
}
Uri data = intent.getData();
this.mLogoUri = data;
this.mLogoValue.setText(data.getLastPathSegment());
Util.updateImageView(getActivity(), this.mLogoPreviewView, this.mLogoUri);
}
@Override
public void onClick(View view) {
int id = view.getId();
if (id == 2131362040) {
ColorPicker.newInstance(this.mCurrentColor, FRAGMENT_TAG, "provisioningColor").show(getFragmentManager(), "colorPicker");
return;
}
if (id == 2131362351) {
startActivityForResult(getGetContentIntent(), 3);
return;
}
if (id != 2131362453) {
return;
}
if (this.mParamsView.getVisibility() == 0) {
this.mParamsView.setVisibility(8);
this.mParamsIndicator.setImageState(STATE_COLLAPSED, false);
} else {
this.mParamsIndicator.setImageState(STATE_EXPANDED, false);
this.mParamsView.setVisibility(0);
}
}
@Override
public void onColorSelected(int i, String str) {
this.mCurrentColor = i;
updateColorUi();
}
public void onNavigateBack(View view) {
getActivity().onBackPressed();
}
public void onNavigateNext(View view) {
if (this.mSetupOptions.getCheckedRadioButtonId() == 2131362580) {
maybeLaunchProvisioning("android.app.action.PROVISION_MANAGED_PROFILE", 1);
} else {
maybeLaunchProvisioning("android.app.action.PROVISION_MANAGED_DEVICE", 2);
}
}
private Intent getGetContentIntent() {
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.setType("image/*");
return intent;
}
private boolean canAnAppHandleGetContent() {
return getGetContentIntent().resolveActivity(getActivity().getPackageManager()) != null;
}
private void updateColorUi() {
int i = this.mCurrentColor;
if (i != -1) {
this.mColorValue.setText(String.format(ColorPicker.COLOR_STRING_FORMATTER, Integer.valueOf(i)));
this.mColorPreviewView.setImageTintList(ColorStateList.valueOf(this.mCurrentColor));
this.mColorPreviewView.setVisibility(0);
} else {
this.mColorValue.setText("");
this.mColorPreviewView.setVisibility(8);
}
}
}