Port the setupwizard to Android 7
Initial changes required to get the FairphoneSetupWizard building in
the Android 7 tree.
* UserHandle.getCallingUserHandle() was removed in 7
* SubscriptionManager.getDefaultDataSubId() was renamed to
SubscriptionManager.getDefaultDataSubscriptionId()
Issue: FP2N-206
Change-Id: I767cde6f08d960bea3411f31f194907ec7b7fe8d
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0412771..ccaa995 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -19,6 +19,11 @@
package="com.fairphone.setupwizard"
android:sharedUserId="android.uid.system">
+ <uses-sdk
+ android:minSdkVersion="25"
+ android:targetSdkVersion="25"
+ android:maxSdkVersion="25" />
+
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
<uses-permission android:name="android.permission.STATUS_BAR" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
diff --git a/src/com/fairphone/setupwizard/ui/SetupWizardActivity.java b/src/com/fairphone/setupwizard/ui/SetupWizardActivity.java
index df17344..d124679 100644
--- a/src/com/fairphone/setupwizard/ui/SetupWizardActivity.java
+++ b/src/com/fairphone/setupwizard/ui/SetupWizardActivity.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
+ * Copyright (C) 2018 Fairphone B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +27,7 @@
import android.graphics.Bitmap;
import android.graphics.Point;
import android.os.AsyncTask;
+import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
@@ -349,7 +351,7 @@
final SetupWizardApp setupWizardApp = (SetupWizardApp)getApplication();
setupWizardApp.sendStickyBroadcastAsUser(
new Intent(SetupWizardApp.ACTION_FINISHED),
- UserHandle.getCallingUserHandle());
+ Binder.getCallingUserHandle());
mIsFinishing = true;
setupRevealImage();
}
diff --git a/src/com/fairphone/setupwizard/util/SetupWizardUtils.java b/src/com/fairphone/setupwizard/util/SetupWizardUtils.java
index 46519d9..cbd0ca0 100644
--- a/src/com/fairphone/setupwizard/util/SetupWizardUtils.java
+++ b/src/com/fairphone/setupwizard/util/SetupWizardUtils.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
+ * Copyright (C) 2018 Fairphone B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +28,7 @@
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;
-import android.os.UserHandle;
+import android.os.Binder;
import android.os.UserManager;
import android.service.persistentdata.PersistentDataBlockManager;
import android.telephony.ServiceState;
@@ -85,7 +86,7 @@
int phoneId = SubscriptionManager.from(context).getDefaultDataPhoneId();
android.provider.Settings.Global.putInt(context.getContentResolver(),
android.provider.Settings.Global.MOBILE_DATA + phoneId, enabled ? 1 : 0);
- int subId = SubscriptionManager.getDefaultDataSubId();
+ int subId = SubscriptionManager.getDefaultDataSubscriptionId();
tm.setDataEnabled(subId, enabled);
} else {
android.provider.Settings.Global.putInt(context.getContentResolver(),
@@ -188,7 +189,7 @@
}
public static boolean isOwner() {
- return UserHandle.getCallingUserHandle().isOwner();
+ return Binder.getCallingUserHandle().isSystem();
}
public static boolean accountExists(Context context, String accountType) {